ソースを参照

修复生成跑腿订单时因用户可能删除原有下单地址导致的跑腿订单生成失败问题

codingliang 1 年間 前
コミット
4954326a0f

+ 10 - 1
src/main/java/com/sqx/modules/errand/service/impl/TbIndentServiceImpl.java

@@ -2,6 +2,7 @@ package com.sqx.modules.errand.service.impl;
 
 import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.core.util.StrUtil;
+import cn.hutool.json.JSONUtil;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@@ -246,7 +247,7 @@ public class TbIndentServiceImpl extends ServiceImpl<TbIndentDao, TbIndent> impl
             return Result.error("请勿重复生成订单!");
         }
         GoodsShop goodsShop = shopMessageService.getShopInfoById(order.getShopId());
-        Address address = addressDao.selectById(order.getAddressId());
+
         TbIndent tbIndent = new TbIndent();
         tbIndent.setItemCodeFlag(1);
         tbIndent.setCreateTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
@@ -268,6 +269,14 @@ public class TbIndentServiceImpl extends ServiceImpl<TbIndentDao, TbIndent> impl
 
         tbIndent.setShopAddressDetail(goodsShop.getDetailedAddress());
         if (order.getOrderType() == 2) {
+            Address address;
+            String addressStr = order.getAddress();
+            if (StrUtil.isNotBlank(addressStr)) {
+                address = JSONUtil.toBean(addressStr, Address.class);
+            } else {
+                address = addressDao.selectById(order.getAddressId());
+            }
+
             tbIndent.setUserName(address.getUserName());
             tbIndent.setUserPhone(address.getUserPhone());
             tbIndent.setUserProvince(address.getProvince());