Browse Source

代理商个人中心

wangtao-1 2 years ago
parent
commit
254d6f6a2b

+ 23 - 3
tour-api/src/main/java/com/tour/api/controller/AgentCenterApi.java

@@ -1,5 +1,7 @@
 package com.tour.api.controller;
 
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.tour.api.service.ApiAgentCenterService;
 import com.tour.api.vo.AgentVo;
@@ -39,12 +41,12 @@ public class AgentCenterApi extends BaseController {
 
     @ApiOperation("订单列表")
     @ApiImplicitParams({
-            @ApiImplicitParam(required = true, paramType = "query", name = "status", value = " 0 待出行 1出行中 2 已完成 -1取消"),
+            @ApiImplicitParam(required = true, paramType = "query", name = "status", value = " 0 待出行 1出行中 3 已完成 -1取消"),
             @ApiImplicitParam(required = true, paramType = "query", name = "id", value = " 代理id")
     })
-    @PostMapping(value = "/list")
+    @GetMapping(value = "/list")
 //    @AccessToken
-    public BaseResult<List<OmsOrderDto>> getList(Integer status, Long id) {
+    public BaseResult<List<OmsOrderDto>> getList(@RequestParam("status") Integer status, @RequestParam("id") Long id) {
         SystemOrderDto order = new SystemOrderDto();
         order.setStatus(status);
         List<Long> agentIds = agentService.getIds(id);
@@ -164,4 +166,22 @@ public class AgentCenterApi extends BaseController {
         return BaseResult.success(agent);
     }
 
+    @ApiOperation("修改密码")
+    @ApiImplicitParams({
+            @ApiImplicitParam(required = true, paramType = "query", name = "id", value = " 代理id"),
+            @ApiImplicitParam(required = true, paramType = "query", name = "oldPassword", value = "旧密码"),
+            @ApiImplicitParam(required = true, paramType = "query", name = "password", value = "新密码")
+    })
+    @PostMapping(value = "/updatePass")
+//    @AccessToken
+    public BaseResult updatePass(@RequestBody String body) {
+        JSONObject json = JSON.parseObject(body);
+        Long agentId = json.getLongValue("id");
+        String oldPassword = json.getString("oldPassword");
+        String password = json.getString("password");
+        int result = apiAgentCenterService.updateAgentPass(agentId, oldPassword, password);
+        return result > 0 ? BaseResult.success() : BaseResult.error("修改失败");
+    }
+
+
 }

+ 2 - 2
tour-api/src/main/java/com/tour/api/controller/HomeApi.java

@@ -28,8 +28,8 @@ public class HomeApi extends BaseController {
 
     @ApiOperation("线路列表")
     @ApiImplicitParams({
-            @ApiImplicitParam(required = true, paramType = "query", name = "code",value = " 1热门 2品质 3 经典"),
-            @ApiImplicitParam(required = true, paramType = "query", name = "city",value = " 热门地点")
+            @ApiImplicitParam(required = true, paramType = "query", name = "type",value = " 1热门 2品质 3 经典"),
+            @ApiImplicitParam(required = true, paramType = "query", name = "cityName",value = " 热门地点")
     })
     @PostMapping(value = "/list")
     public BaseResult getList(@RequestBody LineVo vo) {

+ 2 - 0
tour-api/src/main/java/com/tour/api/service/ApiAgentCenterService.java

@@ -39,4 +39,6 @@ public interface ApiAgentCenterService {
     List<OrderCommissonVo>  commissonList(Long agentId);
 
     List<AgentVo> getGroupUser(Long agentId);
+
+    int updateAgentPass(Long agentId,String oldPassword,String password);
 }

+ 15 - 0
tour-api/src/main/java/com/tour/api/service/impl/ApiAgentCenterServiceImpl.java

@@ -30,6 +30,7 @@ import org.springframework.security.core.userdetails.UsernameNotFoundException;
 import org.springframework.stereotype.Service;
 import org.springframework.util.CollectionUtils;
 
+import javax.annotation.Resource;
 import java.math.BigDecimal;
 import java.util.*;
 import java.util.stream.Collectors;
@@ -57,6 +58,7 @@ public class ApiAgentCenterServiceImpl implements ApiAgentCenterService {
     private final IAgentService agentService;
     private final IOrderCommissonService orderCommissonService;
 
+    private final  ISysUserService userService;
 
     @Override
     public Map getUseCard(Long agentId) {
@@ -194,4 +196,17 @@ public class ApiAgentCenterServiceImpl implements ApiAgentCenterService {
 
         return list;
     }
+
+    @Override
+    public int updateAgentPass(Long agentId, String oldPassword, String password) {
+       SysUser user =  userService.queryByAgentId(agentId);
+        if (user==null) {
+            throw new CustomException("用户不存在");
+        }
+        else if(!SecurityUtils.matchesPassword(oldPassword,user.getPassword())){
+            throw new CustomException("对不起,原密码错误");
+        }
+        user.setPassword(SecurityUtils.encryptPassword(password));
+        return userService.resetPwd(user);
+    }
 }

+ 2 - 0
tour-core/src/main/java/com/tour/system/mapper/SysUserMapper.java

@@ -111,4 +111,6 @@ public interface SysUserMapper
      * @return 结果
      */
     public SysUser checkEmailUnique(String email);
+
+    SysUser queryByAgentId(Long agentId);
 }

+ 2 - 0
tour-core/src/main/java/com/tour/system/service/ISysUserService.java

@@ -168,4 +168,6 @@ public interface ISysUserService
      * @return 结果
      */
     public String importUser(List<SysUser> userList, Boolean isUpdateSupport, String operName);
+
+    SysUser queryByAgentId(Long agentId);
 }

+ 5 - 0
tour-core/src/main/java/com/tour/system/service/impl/SysUserServiceImpl.java

@@ -469,4 +469,9 @@ public class SysUserServiceImpl implements ISysUserService
         }
         return successMsg.toString();
     }
+
+    @Override
+    public SysUser queryByAgentId(Long agentId) {
+        return userMapper.queryByAgentId(agentId);
+    }
 }

+ 4 - 0
tour-core/src/main/resources/mapper/system/SysUserMapper.xml

@@ -203,5 +203,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  			#{userId}
         </foreach>
  	</delete>
+	<select id="queryByAgentId" parameterType="String" resultMap="SysUserResult">
+		<include refid="selectUserVo"/>
+		where u.agent_id = #{agentId} and status=0 and del_flag=0
+	</select>
 
 </mapper>

+ 2 - 0
tour-module/src/main/java/com/tour/module/service/IAgentService.java

@@ -53,4 +53,6 @@ public interface IAgentService extends IService<Agent> {
 
 
     Agent getInfo(SysUser user);
+
+
 }