Преглед на файлове

更新管理端展示店铺时同时展示所有的店铺类型

liu преди 9 месеца
родител
ревизия
1ecd6badc2

+ 12 - 0
src/main/java/com/sqx/modules/callBack/controller/CallBackController.java

@@ -28,6 +28,8 @@ import javax.servlet.http.HttpServletResponse;
 import java.io.BufferedReader;
 import java.io.IOException;
 import java.io.InputStreamReader;
+import java.text.SimpleDateFormat;
+import java.util.Date;
 
 @RestController
 @RequestMapping("/back")
@@ -82,6 +84,16 @@ public class CallBackController {
             tbIndentService.orderIndentReceiving(userEntity.getUserId(), tbOrder.getOrderId()+"");
         } else if ("5".equals(state)) {//取餐
             log.info("骑手取餐:" + order_no);
+            tbOrder.setStatus(3);
+            appOrderService.updateOrder(tbOrder);
+            if ("2".equals(tbIndent.getIndentState())) {
+                tbIndent.setIndentState("4"); // 4:骑手已取货/购买
+                String receiveTimeStr = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
+                tbIndent.setRiderUserId(userEntity.getUserId());
+                tbIndent.setReceivingTime(receiveTimeStr);
+                tbIndentService.updateById(tbIndent);
+            }
+
             tbIndentService.riderBuyGoods(tbIndent);
         } else if ("6".equals(state)) {//完成订单
             log.info("骑手完成订单:" + order_no);

+ 204 - 19
src/main/java/com/sqx/modules/errand/service/impl/TbIndentServiceImpl.java

@@ -90,7 +90,10 @@ import org.springframework.transaction.annotation.Transactional;
 import org.springframework.transaction.support.DefaultTransactionDefinition;
 
 import javax.annotation.Resource;
+import java.io.UnsupportedEncodingException;
 import java.math.BigDecimal;
+import java.net.URLDecoder;
+import java.net.URLEncoder;
 import java.nio.charset.StandardCharsets;
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
@@ -342,8 +345,8 @@ public class TbIndentServiceImpl extends ServiceImpl<TbIndentDao, TbIndent> impl
         tbIndent.setShopId(order.getShopId());
         baseMapper.insert(tbIndent);
 
-
-        if (!tbIndent.getIndentState().equals("11")) {
+        log.info("订单类型:"+order.getOrderType()+",跑腿订单状态:"+tbIndent.getIndentState());
+        if (order.getOrderType() == 2 && !"11".equals(tbIndent.getIndentState())) {
             //            创建快跑者订单
             log.info("第一次创建快跑者订单");
             String responseBody = creatSpeedRunnerOrder(order);
@@ -382,6 +385,14 @@ public class TbIndentServiceImpl extends ServiceImpl<TbIndentDao, TbIndent> impl
         return Result.success();
     }
 
+    public static void main(String[] args) {
+        try {
+          String  shopId = URLEncoder.encode("火腿炒鸡蛋: null,福袋 /&脆皮烤鸭\uD83E\uDD86(双拼):null,++++++", "GBK");
+            System.out.println("shopId = " + shopId);
+        } catch (UnsupportedEncodingException e) {
+            throw new RuntimeException(e);
+        }
+    }
     public String creatSpeedRunnerOrder(TbOrder tbOrder){
 //               获取店铺信息
         GoodsShop goodsShop = goodsShopService.getById(tbOrder.getShopId());
@@ -403,22 +414,175 @@ public class TbIndentServiceImpl extends ServiceImpl<TbIndentDao, TbIndent> impl
         Address address = addressService.getById(tbOrder.getAddressId());
 
         com.alibaba.fastjson.JSONObject body = new com.alibaba.fastjson.JSONObject();
-        body.put("shop_id", tbOrder.getShopId());
-        body.put("shop_name", goodsShop.getShopName());
-        body.put("shop_tel", goodsShop.getPhone());
-        body.put("shop_address", goodsShop.getDetailedAddress());
-        body.put("shop_tag", goodsShop.getShopLng() + "," + goodsShop.getShopLat());
-        body.put("order_content", stringBuilder.toString());
-        body.put("order_note", tbOrder.getRemark());
-        body.put("order_mark", tbOrder.getOrderSequence());
-        body.put("order_from", goodsShop.getShopName() + "#" + tbOrder.getOrderSequence());
-        body.put("order_time", tbOrder.getPayTime());
-        body.put("customer_name", address.getUserName());
-        body.put("customer_tel", address.getUserPhone());
-        body.put("customer_address", address.getAddressDetail());
-        body.put("customer_tag", address.getLng() + "," + address.getLat());
-        body.put("order_no", tbOrder.getOrderNumber());
-        body.put("order_price", tbOrder.getPayMoney());
+        String shopId = tbOrder.getShopId()+"";
+        if (ObjectUtils.isNotEmpty(shopId)) {
+            try {
+                shopId = URLDecoder.decode(shopId, "GBK");
+            } catch (UnsupportedEncodingException e) {
+                throw new RuntimeException(e);
+            }
+        }
+        body.put("shop_id", shopId);
+
+        String shopName = goodsShop.getShopName();
+        if (ObjectUtils.isNotEmpty(shopName)) {
+            try {
+                shopName = URLDecoder.decode(shopName, "GBK");
+            } catch (UnsupportedEncodingException e) {
+                throw new RuntimeException(e);
+            }
+//            shopName=shopName.replaceAll("\\+","-");
+        }
+        body.put("shop_name", shopName);
+
+        String phone = goodsShop.getPhone();
+        if (ObjectUtils.isNotEmpty(phone)) {
+            try {
+                phone = URLDecoder.decode(phone, "GBK");
+            } catch (UnsupportedEncodingException e) {
+                throw new RuntimeException(e);
+            }
+        }
+        body.put("shop_tel", phone);
+
+
+        String detailedAddress = goodsShop.getDetailedAddress();
+        if (ObjectUtils.isNotEmpty(detailedAddress)) {
+            try {
+                detailedAddress = URLDecoder.decode(detailedAddress, "GBK");
+            } catch (UnsupportedEncodingException e) {
+                throw new RuntimeException(e);
+            }
+//            detailedAddress=detailedAddress.replaceAll("\\+","-");
+        }
+        body.put("shop_address", detailedAddress);
+
+
+        String shopTag  =goodsShop.getShopLng() + "," + goodsShop.getShopLat();
+        if (ObjectUtils.isNotEmpty(detailedAddress)) {
+            try {
+                shopTag = URLDecoder.decode(shopTag, "GBK");
+            } catch (UnsupportedEncodingException e) {
+                throw new RuntimeException(e);
+            }
+        }
+        body.put("shop_tag", shopTag);
+
+
+//        将+变成-
+        String orderContent = stringBuilder.toString();
+        if (ObjectUtils.isNotEmpty(orderContent)) {
+            try {
+                orderContent = URLDecoder.decode(orderContent, "GBK");
+            } catch (UnsupportedEncodingException e) {
+                throw new RuntimeException(e);
+            }
+//            orderContent=orderContent.replaceAll("\\+","-");
+        }
+        body.put("order_content", orderContent);
+
+
+        String remark = tbOrder.getRemark();
+        if (ObjectUtils.isNotEmpty(remark)) {
+            try {
+                remark = URLDecoder.decode(remark, "GBK");
+            } catch (UnsupportedEncodingException e) {
+                throw new RuntimeException(e);
+            }
+//            remark=remark.replaceAll("\\+","-");
+        }
+        body.put("order_note", remark);
+
+        String orderSequence = tbOrder.getOrderSequence();
+        if (ObjectUtils.isNotEmpty(orderSequence)) {
+            try {
+                orderSequence =URLDecoder.decode(orderSequence, "GBK");
+            } catch (UnsupportedEncodingException e) {
+                throw new RuntimeException(e);
+            }
+        }
+        body.put("order_mark", orderSequence);
+
+
+        body.put("order_from", shopName+ "#" + orderSequence);
+
+
+        String payTime = tbOrder.getPayTime();
+        if (ObjectUtils.isNotEmpty(payTime)) {
+            try {
+                payTime = URLDecoder.decode(payTime, "GBK");
+            } catch (UnsupportedEncodingException e) {
+                throw new RuntimeException(e);
+            }
+        }
+        body.put("order_time", payTime);
+
+
+        String userName = address.getUserName();
+        if (ObjectUtils.isNotEmpty(userName)) {
+            try {
+                userName = URLDecoder.decode(userName, "GBK");
+            } catch (UnsupportedEncodingException e) {
+                throw new RuntimeException(e);
+            }
+//            userName=userName.replaceAll("\\+","-");
+        }
+        body.put("customer_name", userName);
+
+        String userPhone = address.getUserPhone();
+        if (ObjectUtils.isNotEmpty(userPhone)) {
+            try {
+                userPhone = URLDecoder.decode(userPhone, "GBK");
+            } catch (UnsupportedEncodingException e) {
+                throw new RuntimeException(e);
+            }
+        }
+        body.put("customer_tel", userPhone);
+
+
+        String addressDetail = address.getAddressDetail();
+        if (ObjectUtils.isNotEmpty(addressDetail)) {
+            try {
+                addressDetail = URLDecoder.decode(addressDetail, "GBK");
+            } catch (UnsupportedEncodingException e) {
+                throw new RuntimeException(e);
+            }
+
+//            addressDetail=addressDetail.replaceAll("\\+","-");
+        }
+        body.put("customer_address", addressDetail);
+
+
+        String customerTag=address.getLng() + "," + address.getLat();
+        if (ObjectUtils.isNotEmpty(customerTag)) {
+            try {
+                customerTag = URLDecoder.decode(customerTag, "GBK");
+            } catch (UnsupportedEncodingException e) {
+                throw new RuntimeException(e);
+            }
+        }
+        body.put("customer_tag", customerTag);
+
+
+        String orderNumber = tbOrder.getOrderNumber();
+        if (ObjectUtils.isNotEmpty(orderNumber)) {
+            try {
+                orderNumber = URLDecoder.decode(orderNumber, "GBK");
+            } catch (UnsupportedEncodingException e) {
+                throw new RuntimeException(e);
+            }
+        }
+        body.put("order_no", orderNumber);
+
+        String payMoney = tbOrder.getPayMoney().toPlainString();
+        if (ObjectUtils.isNotEmpty(payMoney)) {
+            try {
+                payMoney = URLDecoder.decode(payMoney, "GBK");
+            } catch (UnsupportedEncodingException e) {
+                throw new RuntimeException(e);
+            }
+        }
+        body.put("order_price",payMoney);
         body.put("pay_status", 0);
 
         log.info("body信息:" + body);
@@ -452,6 +616,7 @@ public class TbIndentServiceImpl extends ServiceImpl<TbIndentDao, TbIndent> impl
             log.info("创建结果:"+responseBody);
         }catch (Exception e){
             e.printStackTrace();
+//            throw new RuntimeException("responseBody");
         }
         return responseBody;
     }
@@ -1436,7 +1601,27 @@ public class TbIndentServiceImpl extends ServiceImpl<TbIndentDao, TbIndent> impl
 
         // 判断是否为当前骑手订单
         if (!Objects.equals(indentOrder.getRiderUserId(), userId)) {
-            throw new SqxException("不能完成非本人订单!");
+//            不为本人则需要调用转单接口
+            log.info("不为接单本人,需转单");
+            log.info("当前骑手id:"+indentOrder.getRiderUserId()+",需要更换的骑手id:"+userId);
+            UserEntity userEntity = userService.getById(userId);
+            indentOrder.setRiderUserId(userEntity.getUserId());
+            indentOrder.setIsRider(1);
+            updateById(indentOrder);
+            log.info("测试是否进入转单3");
+            String format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
+            TransferRecordEntity tr = new TransferRecordEntity();
+            tr.setUserId(userEntity.getUserId());
+            tr.setUserName(userEntity.getUserName());
+            tr.setUserPhone(userEntity.getPhone());
+            tr.setOrderId(indentOrder.getOrderId());
+            tr.setReceveTime(format);
+            tr.setStationName(userEntity.getStationName());
+            tr.setDeleteFlag(0);
+            log.info("测试是否进入转单4,tr:"+ new Gson().toJson(tr));
+            int insertCount = transferRecordDao.insert(tr);
+            log.info("测试是否进入转单5,insertCount:"+insertCount);
+//            throw new SqxException("不能完成非本人订单!");
         }
 
         RLock lock = redissonClient.getLock(String.format(RedisKey.UPDATE_INDENT_LOCK, indentOrder.getIndentNumber()));

+ 1 - 1
src/main/java/com/sqx/modules/goods/entity/GoodsShop.java

@@ -36,7 +36,7 @@ public class GoodsShop implements Serializable {
 
 
     @ApiModelProperty("商铺类型id")
-    private Long shopTypeId;
+    private String shopTypeId;
 
 
     @ApiModelProperty("商铺标签")

+ 2 - 1
src/main/java/com/sqx/modules/goods/service/impl/GoodsShopServiceImpl.java

@@ -272,7 +272,8 @@ public class GoodsShopServiceImpl extends ServiceImpl<GoodsShopDao, GoodsShop> i
                 .eq(GoodsShop::getShopId,goodsShop.getShopId())
                 .set(GoodsShop::getMchId , StringUtils.isEmpty(goodsShop.getMchId())?null:goodsShop.getMchId())
                 .set(GoodsShop::getSnCode , StringUtils.isEmpty(goodsShop.getSnCode())?null:goodsShop.getSnCode())
-                .set(GoodsShop::getValue , StringUtils.isEmpty(goodsShop.getValue())?null:goodsShop.getValue()));
+                .set(GoodsShop::getValue , StringUtils.isEmpty(goodsShop.getValue())?null:goodsShop.getValue())
+                .set(GoodsShop::getShopTypeId , StringUtils.isEmpty(goodsShop.getShopTypeId())?null:goodsShop.getShopTypeId()));
         //snCode value
 //        if(StringUtils.isEmpty(goodsShop.getSnCode())){
 //            baseMapper.update(null, Wrappers.<GoodsShop>lambdaUpdate()

+ 1 - 1
src/main/java/com/sqx/modules/utils/fieYun/FeiYunUtils.java

@@ -1520,7 +1520,7 @@ public class FeiYunUtils {
                 stringBuilder.append("<BR>");
                 //String returnNo = getDigitBarCode();
                 //sb.append("<BC128_C>"+returnNo+"</BC128_C>");
-                stringBuilder.append("<CB><QR>").append(tbOrder.getOrderId()).append("</QR></CB>");
+                stringBuilder.append("<CB><QR>").append(tbOrder.getOrderNumber()).append("</QR></CB>");
                 stringBuilder.append("<CB>收单码:").append(tbOrder.getOrderId()).append("</CB>");
                 stringBuilder.append("<BR>").append("<BR>").append("<BR>");
                 stringBuilder.append("<CUT>");

+ 2 - 1
src/main/resources/application.yml

@@ -79,7 +79,8 @@ mybatis-plus:
     cache-enabled: false
     call-setters-on-nulls: true
     jdbc-type-for-null: 'null'
-    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
+#    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
+    log-impl: org.apache.ibatis.logging.nologging.NoLoggingImpl
 
 sqx:
   redis:

+ 3 - 1
src/main/resources/mapper/goods/GoodsShopMapper.xml

@@ -3,7 +3,9 @@
 <mapper namespace="com.sqx.modules.goods.dao.GoodsShopDao">
 
     <select id="selectAllShop" resultType="com.sqx.modules.goods.entity.GoodsShop">
-        select gs.*, st.shop_type_name as shopTypeName,
+        select gs.*,
+        (SELECT GROUP_CONCAT(st1.shop_type_name SEPARATOR ',')
+        FROM shop_type st1 WHERE FIND_IN_SET(st1.id,gs.shop_type_id) ) as shopTypeName,
         (select user_id from sys_user where user_id in (select s.user_id from sys_user_shop s where
         s.shop_id=gs.shop_id) and user_type=2) as adminUserId
         from goods_shop gs