Commit a9073a0d9f10533b300405dce1fa6c8950c1c4d0

Authored by guzijian
1 parent 9736095f

feat: 用户修改,设置用户类型

trash-garbage/src/main/java/com/trash/garbage/controller/GarbageUserController.java
... ... @@ -3,6 +3,7 @@ package com.trash.garbage.controller;
3 3  
4 4 import com.trash.garbage.global.Result;
5 5 import com.trash.garbage.pojo.domain.GarAddress;
  6 +import com.trash.garbage.pojo.domain.GarUser;
6 7 import com.trash.garbage.pojo.dto.AddressDto;
7 8 import com.trash.garbage.pojo.dto.LoginDto;
8 9 import com.trash.garbage.service.GarUserService;
... ... @@ -67,4 +68,11 @@ public class GarbageUserController {
67 68 }
68 69  
69 70  
  71 + @PutMapping("/update")
  72 + public Result<?> updateUser(@RequestBody GarUser user){
  73 + garUserService.updateUserInfo(user);
  74 + return Result.OK();
  75 + }
  76 +
  77 +
70 78 }
... ...
trash-garbage/src/main/java/com/trash/garbage/global/GlobalStatus.java
... ... @@ -36,8 +36,8 @@ public class GlobalStatus {
36 36 * 普通登录
37 37 */
38 38 NORMAL_LOGIN(0, "普通登录"),
39   - NORMAL_USER(0, "普通用户"),
40   - DRIVER_USER(1, "驾驶员用户");
  39 + NORMAL_USER(0, "居民用户"),
  40 + DRIVER_USER(1, "管理负责人");
41 41  
42 42 private Integer status;
43 43 private String description;
... ...
trash-garbage/src/main/java/com/trash/garbage/service/GarUserService.java
... ... @@ -27,4 +27,6 @@ public interface GarUserService extends IService&lt;GarUser&gt; {
27 27 String updateAddress(AddressDto dto);
28 28  
29 29 String deleteAddress(String addressId);
  30 +
  31 + void updateUserInfo(GarUser user);
30 32 }
... ...
trash-garbage/src/main/java/com/trash/garbage/service/impl/GarOrderServiceImpl.java
... ... @@ -90,7 +90,7 @@ public class GarOrderServiceImpl extends ServiceImpl&lt;GarOrderMapper, GarOrder&gt;
90 90 driverVo.setPhoneNo(tel);
91 91 driverVo.setCompanyId(Long.valueOf(order.getGarOrderCompanyId()));
92 92 List<DriverVo> driverVos = driverService.selectDriverList(driverVo);
93   - if (CollectionUtil.isNotEmpty(driverVos)){
  93 + if (CollectionUtil.isNotEmpty(driverVos)) {
94 94 vo.setHandleFlag(true);
95 95 }
96 96 List<GarOrderImage> imageList = garOrderImageService.list(qwi);
... ... @@ -112,13 +112,11 @@ public class GarOrderServiceImpl extends ServiceImpl&lt;GarOrderMapper, GarOrder&gt;
112 112 public PageInfo queryOrderList(Integer type, Integer pageNo, Integer pageSize) {
113 113 String userId = SecurityUtils.getLoginUser().getUser().getUserId();
114 114 GarUser user = garUserService.getById(userId);
115   - DriverVo driver = new DriverVo();
116   - driver.setPhoneNo(user.getGarUserTel());
117   - List<DriverVo> driverList = driverService.selectDriverList(driver);
118 115 LambdaQueryWrapper<GarOrder> qw = new LambdaQueryWrapper<>();
119 116 qw.orderByAsc(GarOrder::getGarEvaluateFlag, GarOrder::getGarOrderHandlerStatus);
120   - PageHelper.startPage(pageNo, pageSize);
121   - if (CollectionUtil.isEmpty(driverList)) {
  117 + // 居民用户
  118 + if (user.getGarUserType().equals(GlobalStatus.UserStatusEnum.DRIVER_USER.getDescription())) {
  119 + PageHelper.startPage(pageNo, pageSize);
122 120 // 待清运 || 清运中 || 已完成 || 待支付
123 121 if (GlobalStatus.GarOrderStatus.NEW_ORDER.getValue().equals(type)
124 122 || GlobalStatus.GarOrderStatus.ACTIVE_ORDER.getValue().equals(type)
... ... @@ -137,9 +135,12 @@ public class GarOrderServiceImpl extends ServiceImpl&lt;GarOrderMapper, GarOrder&gt;
137 135 return pageInfo;
138 136 }
139 137 } else {
140   -
  138 + DriverVo driver = new DriverVo();
  139 + driver.setPhoneNo(user.getGarUserTel());
  140 + List<DriverVo> driverList = driverService.selectDriverList(driver);
141 141 DriverVo driverVo = driverList.get(0);
142 142 String companyId = String.valueOf(driverVo.getCompanyId());
  143 + PageHelper.startPage(pageNo, pageSize);
143 144 if (GlobalStatus.GarOrderStatus.NEW_ORDER.getValue().equals(type)) {
144 145 qw.eq(GarOrder::getGarOrderCompanyId, companyId)
145 146 .eq(GarOrder::getGarOrderHandlerStatus, GlobalStatus.GarOrderStatus.NEW_ORDER.getValue());
... ... @@ -175,25 +176,28 @@ public class GarOrderServiceImpl extends ServiceImpl&lt;GarOrderMapper, GarOrder&gt;
175 176 String userId = SecurityUtils.getLoginUser().getUser().getUserId();
176 177 GarUser user = garUserService.getById(userId);
177 178 // 运输员操作 TODO 公司所属 待清运- 》 清运中
178   - if (order.getGarOrderHandlerStatus().equals(GlobalStatus.GarOrderStatus.NEW_ORDER.getValue())
179   - || GlobalStatus.GarOrderStatus.NEW_ORDER.getValue().equals(dto.getHandleType())) {
180   - LambdaUpdateWrapper<GarOrder> uw = new LambdaUpdateWrapper<>();
181   - uw.eq(GarOrder::getGarOrderId, dto.getGarOrderId())
182   - .set(GarOrder::getGarOrderHandlerStatus, GlobalStatus.GarOrderStatus.ACTIVE_ORDER.getValue())
183   - .set(GarOrder::getGarOrderHandlerId, userId);
184   - update(uw);
185   - return "准备清运";
186   - }
187   - // 运输员操作 清运中 ==》待支付 TODO
188   - if (GlobalStatus.GarOrderStatus.ACTIVE_ORDER.getValue().equals(order.getGarOrderHandlerStatus())
189   - && GlobalStatus.GarOrderStatus.SUCCESS_ORDER.getValue().equals(dto.getHandleType())) {
190   - LambdaUpdateWrapper<GarOrder> uw = new LambdaUpdateWrapper<>();
191   - uw.eq(GarOrder::getGarOrderId, dto.getGarOrderId())
192   - .set(GarOrder::getGarOrderHandlerStatus, GlobalStatus.GarOrderStatus.SUCCESS_ORDER.getValue())
193   - .set(GarOrder::getGarEvaluateFlag, GlobalStatus.GarOrderStatus.EVALUATE_ORDER_NO.getValue());
194   - update(uw);
  179 + if (GlobalStatus.UserStatusEnum.NORMAL_USER.getDescription().equals(user.getGarUserType())){
  180 + if (order.getGarOrderHandlerStatus().equals(GlobalStatus.GarOrderStatus.NEW_ORDER.getValue())
  181 + || GlobalStatus.GarOrderStatus.NEW_ORDER.getValue().equals(dto.getHandleType())) {
  182 + LambdaUpdateWrapper<GarOrder> uw = new LambdaUpdateWrapper<>();
  183 + uw.eq(GarOrder::getGarOrderId, dto.getGarOrderId())
  184 + .set(GarOrder::getGarOrderHandlerStatus, GlobalStatus.GarOrderStatus.ACTIVE_ORDER.getValue())
  185 + .set(GarOrder::getGarOrderHandlerId, userId);
  186 + update(uw);
  187 + return "准备清运";
  188 + }
  189 + // 运输员操作 清运中 ==》已完成
  190 + if (GlobalStatus.GarOrderStatus.ACTIVE_ORDER.getValue().equals(order.getGarOrderHandlerStatus())
  191 + && GlobalStatus.GarOrderStatus.SUCCESS_ORDER.getValue().equals(dto.getHandleType())) {
  192 + LambdaUpdateWrapper<GarOrder> uw = new LambdaUpdateWrapper<>();
  193 + uw.eq(GarOrder::getGarOrderId, dto.getGarOrderId())
  194 + .set(GarOrder::getGarOrderHandlerStatus, GlobalStatus.GarOrderStatus.SUCCESS_ORDER.getValue())
  195 + .set(GarOrder::getGarEvaluateFlag, GlobalStatus.GarOrderStatus.EVALUATE_ORDER_NO.getValue());
  196 + update(uw);
  197 + }
  198 + return "派单已完成";
195 199 }
196   - return "";
  200 + return "什么都没发生";
197 201 }
198 202  
199 203 @Override
... ...
trash-garbage/src/main/java/com/trash/garbage/service/impl/GarUserServiceImpl.java
... ... @@ -206,6 +206,17 @@ public class GarUserServiceImpl extends ServiceImpl&lt;GarUserMapper, GarUser&gt;
206 206 return "删除成功!";
207 207 }
208 208  
  209 + @Override
  210 + public void updateUserInfo(GarUser user) {
  211 + String userId = SecurityUtils.getLoginUser().getUser().getUserId();
  212 + LambdaUpdateWrapper<GarUser> uw = new LambdaUpdateWrapper<>();
  213 + uw.eq(GarUser::getGarUserId, userId)
  214 + .set(GarUser::getGarUserType, user.getGarUserType())
  215 + .set(GarUser::getGarUserName, user.getGarUserName())
  216 + .set(GarUser::getGarUserCarNum, user.getGarUserCarNum());
  217 + update(uw);
  218 + }
  219 +
209 220  
210 221 /**
211 222 * 微信小程序解密
... ...