Pārlūkot izejas kodu

回写订单地址

yangyb 2 nedēļas atpakaļ
vecāks
revīzija
288506d24e

+ 0 - 1
mall-service/src/main/java/com/txz/mall/controller/CommonController.java

@@ -36,7 +36,6 @@ public class CommonController {
         List<EnumBo> list = new ArrayList<>();
         switch (id) {
             case 1:
-                // 把枚举转成list
                 list = Arrays.stream(OrderStatusEnum.values())
                         .map(temp -> EnumBo.builder().code(temp.getKey()).name(temp.getValue()).build()).collect(Collectors.toList());
                 break;

+ 16 - 2
mall-service/src/main/java/com/txz/mall/controller/UserAddressController.java

@@ -4,7 +4,9 @@ import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
 import com.txz.mall.core.Result;
 import com.txz.mall.core.ResultCode;
+import com.txz.mall.model.StoreOrder;
 import com.txz.mall.model.UserAddress;
+import com.txz.mall.service.StoreOrderService;
 import com.txz.mall.service.UserAddressService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
@@ -31,16 +33,28 @@ public class UserAddressController {
     @Resource
     private UserAddressService userAddressService;
 
+    @Resource
+    private StoreOrderService storeOrderService;
+
     @PostMapping("/add")
     @ApiOperation(value = "收获地址新增")
-    public Result add(@RequestBody UserAddress userAddress) {
+    public Result add(@RequestBody UserAddress userAddress, @RequestParam Long orderId) {
         if (userAddress == null) {
             return Result.fail(ResultCode.OBJECT_IS_NULL);
         }
         try {
             userAddress.setCreateTime(new Date());
-//    		userAddress.setCreateUserId(userId);
+            userAddress.setCreateUserId(userAddress.getUid());
             userAddressService.save(userAddress);
+            if (orderId != null) {
+                StoreOrder storeOrder = new StoreOrder();
+                storeOrder.setId(orderId);
+                storeOrder.setRealName(userAddress.getRealName());
+                storeOrder.setUserPhone(userAddress.getPhone());
+                String userAddressStr = userAddress.getProvince() + userAddress.getCity() + userAddress.getDistrict() + userAddress.getDetail();
+                storeOrder.setUserAddress(userAddressStr);
+                storeOrderService.update(storeOrder);
+            }
         } catch (Exception e) {
             log.error("新增对象操作异常e:{}", e);
             return Result.fail(ResultCode.INTERNAL_SERVER_ERROR);

+ 31 - 28
mall-service/src/main/java/com/txz/mall/service/impl/StoreOrderServiceImpl.java

@@ -914,7 +914,11 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
                 }
                 break;
             case 4:
-
+                pinkCriteria.andIn("status", Arrays.asList(0, 0));
+                pinkList = storePinkService.findByCondition(pinkCondition);
+                if (CollUtil.isNotEmpty(pinkList)) {
+                    criteria.andIn("id", pinkList.stream().map(StorePink::getOrderIdKey).collect(Collectors.toList()));
+                }
                 break;
             default:
                 break;
@@ -1074,19 +1078,13 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
         // 校验收货信息
         String verifyCode = "";
         String userAddressStr = "";
-//        if (request.getShippingType() == 1) {
-//            // 快递配送
-//            if (request.getAddressId() <= 0) {
-//                throw new ServiceException("请选择收货地址");
-//            }
-//            UserAddress userAddress = userAddressService.findById(request.getAddressId());
-//            if (ObjectUtil.isNull(userAddress) || userAddress.getIsDelete().equals(1)) {
-//                throw new ServiceException("收货地址有误");
-//            }
-//            request.setRealName(userAddress.getRealName());
-//            request.setPhone(userAddress.getPhone());
-//            userAddressStr = userAddress.getProvince() + userAddress.getCity() + userAddress.getDistrict() + userAddress.getDetail();
-//        }
+
+        UserAddress userAddress = userAddressService.getDefaultByUid(user.getId());
+        if (userAddress != null) {
+            request.setRealName(userAddress.getRealName());
+            request.setPhone(userAddress.getPhone());
+            userAddressStr = userAddress.getProvince() + userAddress.getCity() + userAddress.getDistrict() + userAddress.getDetail();
+        }
 
         // 计算订单各种价格
         OrderComputedPriceRequest orderComputedPriceRequest = new OrderComputedPriceRequest();
@@ -1234,26 +1232,31 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
     }
 
     @Override
+    @Transactional
     public Boolean goPay(GoPinkDTO dto) {
-//        StoreOrder storeOrder = findBy("orderId", dto.getOrderId());
-//        // 扣取余额
-//        Boolean b = accountDubboServiceClient.checkFee(dto.getUserId(), storeOrder.getPayPrice());
-//        if (!b){
-//            return Result.fail(ResultCode.INSUFFICIENT_BALANCE);
-//        }
-//        TransParam transParam = new TransParam();
-//        transParam.builder()
-//                .setBizId(dto.getOrderId())
-//                .setDebitAccount(user.getId())
-//                .setCreditAccount();
-//        accountDubboServiceClient.trans(transParam);
-//
-//        if (storeOrder.getPaid() == 1) {
+        StoreOrder storeOrder = findBy("orderId", dto.getOrderId());
 
+        // 检验余额够不够
+        storeOrder.setPaid(1);
+        update(storeOrder);
         if ("open".equals(dto.getType())) {
+//            OpenParam openParam = new OpenParam();
+//            openParam.setBizId(storeOrder.getId().toString());
+//            openParam.setBizNo(storeOrder.getOrderId());
+//            openParam.setUserId(storeOrder.getUid());
+//            openParam.setAmount(storeOrder.getPayPrice());
+//            openParam.setTransTime(new Date());
+//            accountDubboServiceClient.openGroup(openParam);
             goOpen(dto.getOrderId());
         }
         if ("join".equals(dto.getType())) {
+//            JoinParam joinParam = new JoinParam();
+//            joinParam.setBizId(storeOrder.getId().toString());
+//            joinParam.setBizNo(storeOrder.getOrderId());
+//            joinParam.setUserId(storeOrder.getUid());
+//            joinParam.setAmount(storeOrder.getPayPrice());
+//            joinParam.setTransTime(new Date());
+//            accountDubboServiceClient.joinGroup(joinParam);
             goPink(dto);
         }
         return true;