Browse Source

fix:新订单代受理通知

wrj 10 months ago
parent
commit
1121be8c29

+ 33 - 0
nightFragrance-massage/src/main/java/com/ylx/massage/service/impl/TOrderServiceImpl.java

@@ -1,6 +1,7 @@
 package com.ylx.massage.service.impl;
 
 import cn.hutool.core.collection.CollectionUtil;
+import cn.hutool.json.JSONUtil;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
@@ -23,6 +24,7 @@ import com.ylx.massage.service.*;
 import com.ylx.massage.utils.DateTimeUtils;
 import com.ylx.massage.utils.MassageUtil;
 import com.ylx.massage.utils.OrderNumberGenerator;
+import com.ylx.massage.utils.WeChatUtil;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.compress.utils.Lists;
 import org.springframework.stereotype.Service;
@@ -76,6 +78,10 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme
     @Resource
     private CouponService couponService;
 
+    @Resource
+    private WeChatUtil weChatUtil;
+
+
 
 
     public Boolean isFree(String jsId, BigDecimal distance) {
@@ -219,6 +225,7 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme
         if (order.getPayType().equals(MassageConstants.INTEGER_ONE)) {
             //微信支付
             R resp = rechargeService.getPay(orderNew.getOrderNo(), orderNew.getTotalPrice(), orderNew.getcOpenId(), BillTypeEnum.WX_PAY.getInfo(),BillTypeEnum.WX_PAY.getCode().toString());
+            this.newOrderNotification(orderNew);
             return resp;
         }
 
@@ -231,10 +238,36 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme
             throw new ServiceException("账户金额不够请充值");
         } else {
             orderPayManage(user, orderNew);
+            this.newOrderNotification(orderNew);
             return R.ok();
         }
     }
 
+
+    public void newOrderNotification(TOrder order) {
+
+        cn.hutool.json.JSONObject param = JSONUtil.createObj();
+        //订单号
+        param.set("character_string9", JSONUtil.createObj().set("value", order.getOrderNo()));
+        //点话
+        param.set("phone_number14",JSONUtil.createObj().set("value", order.getcPhone()));
+        param.set("thing18",JSONUtil.createObj().set("value", order.getcName()));
+        param.set("time6",JSONUtil.createObj().set("value", DateTimeUtils.formatDate(new Date(), DateTimeUtils.DATE_NUMBER_YEAR_MONTH_FORMAT)));
+        String caddress = order.getcAddress();
+        Object parse = JSONObject.parse(caddress);
+        String addres = " ";
+        if (parse instanceof JSONObject) {
+            JSONObject jsonObject = (JSONObject) parse;
+            String name = jsonObject.getString("name");
+            String address = jsonObject.getString("address");
+            addres = name + " " + address;
+        }
+        param.set("thing27",JSONUtil.createObj().set("value", addres));
+        TJs js = jsService.getById(order.getcJsId());
+        weChatUtil.notification(js.getcOpenId(), param);
+
+    }
+
     @Transactional(rollbackFor = Exception.class)
     public void orderPayManage(TWxUser user, TOrder orderNew) {
 

+ 2 - 1
nightFragrance-massage/src/main/java/com/ylx/massage/utils/DateTimeUtils.java

@@ -23,7 +23,8 @@ public final class DateTimeUtils {
     public static final String DATE_YEAR_MONT_DAY_FORMAT = "yyyy/MM/dd";
     public static final String DATE_NUMBER_FORMAT = "yyyyMMdd";
     public static final String DATE_NUMBER_YEARS_FORMAT = "yyyyMM";
-    public static final String DATE_NUMBER_YEAR_MONTH_FORMAT = "yyyy年MM月";
+    public static final String DATE_NUMBER_YEAR_MONTH_FORMAT = "yyyy年MM月dd日 HH:mm";
+
     public static final String DATE_NUMBER_YEAR_MONTH_FORMAT2 = "yyyy-MM";
     public static final String TIME_FORMAT = "yyyy-MM-dd 12:00:00";
     public static final long DAY_SECONDS = 24L * 60 * 60;

+ 0 - 1
nightFragrance-massage/src/main/java/com/ylx/massage/utils/WeChatUtil.java

@@ -254,7 +254,6 @@ public class WeChatUtil {
 
         String url = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=" + token;
 
-        //String param = "{\"touser\":\"o-HEJ6RAjBDjFvuZcAdHRX8mIZXw\",\"template_id\":\"HU2LfMIes91Au9kxR3VEoNYuMayxZoPNsFRfWNCmKrQ\",\"url\":\"https://test.baoxianzhanggui.com/fragrance/\",\"data\":{\"thing01\":{\"value\":\"23010000010101\"},\"thing02\":{\"value\":\"18360233903\"},\"thing03\":{\"value\":\"李四\"},\"thing04\":{\"value\":\"2022年11月11日22:22\"},\"thing05\":{\"value\":\"湖南长沙岳麓\"}}}";
         cn.hutool.json.JSONObject param1 = JSONUtil.createObj();
         param1.put("touser", openid);
         param1.put("template_id", wxPayProperties.getTemplateId1());