Browse Source

no message

FengChaoYu 3 weeks ago
parent
commit
33f3cbd6da

+ 6 - 1
src/main/java/com/gree/mall/miniapp/controller/common/PayController.java

@@ -16,6 +16,7 @@ import com.gree.mall.miniapp.exception.RemoteServiceException;
 import com.gree.mall.miniapp.logic.user.PayLogic;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
 import org.jdom.JDOMException;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.integration.redis.util.RedisLockRegistry;
@@ -103,7 +104,11 @@ public class PayController {
     @ApiOperation(value = "云闪付回调", notes = "云闪付回调 ", httpMethod = "POST")
     public String umsPayCall(@ModelAttribute UmsPayCallBean bean) throws Exception  {
         log.info("云闪付支付回调 {}", JSONUtil.toJsonStr(bean));
-        String id = bean.getAttachedData();//订单号
+        String id = JSONUtil.parseObj(bean.getAttachedData()).get("d", String.class);//订单号
+        if (StringUtils.isBlank(id)) {
+            log.error("云闪付回调异常");
+            return "ERROR";
+        }
         String transactionId = bean.getTargetOrderId();// 渠道订单号
         BigDecimal totalFee = new BigDecimal(bean.getTotalAmount()).divide(BigDecimal.valueOf(100));//
         Lock obtain = redisLockRegistry.obtain(Constant.RedisPrefix.LOCK_ORDER + id);

+ 28 - 17
src/main/java/com/gree/mall/miniapp/enums/UMSDiscountCodeEnum.java

@@ -7,36 +7,47 @@ import java.util.Map;
 
 @Getter
 public enum UMSDiscountCodeEnum {
-    GDYJKT(1, "一级能效空调", "GDYJKT"),
-    GDEJKT(2, "二级能效空调", "GDEJKT"),
-    GDYJDS(3, "一级能效电视", "GDYJDS"),
-    GDEJDS(4, "二级能效电视", "GDEJDS"),
-    GDYJBX(5, "一级能效冰箱", "GDYJBX"),
-    GDEJBX(6, "二级能效冰箱", "GDEJBX"),
-    GDYJXYJ(7, "一级能效洗衣机", "GDYJXYJ"),
-    GDEJXYJ(8, "二级能效洗衣机", "GDEJXYJ"),
-    GDYJXYYJ(9, "一级能效吸油烟机", "GDYJXYYJ"),
-    GDEJXYYJ(10, "二级能效吸油烟机", "GDEJXYYJ"),
-    GDYJDZ(11, "一级能效家用灶具", "GDYJDZ"),
-    GDEJDZ(12, "二级能效家用灶具", "GDEJDZ"),
-    GDYJRSQ(13, "一级能效热水器", "GDYJRSQ"),
-    GDEJRSQ(14, "二级能效热水器", "GDEJRSQ"),
-    GDYJDN(15, "一级能效电脑", "GDYJDN"),
-    GDEJDN(16, "二级能效电脑", "GDEJDN"),
+    GDYJKT(1, "一级能效空调", "GDYJKT", "A04"),
+    GDEJKT(2, "二级能效空调", "GDEJKT", "A04"),
+    GDYJDS(3, "一级能效电视", "GDYJDS", "A01"),
+    GDEJDS(4, "二级能效电视", "GDEJDS", "A01"),
+    GDYJBX(5, "一级能效冰箱", "GDYJBX", "A02"),
+    GDEJBX(6, "二级能效冰箱", "GDEJBX", "A02"),
+    GDYJXYJ(7, "一级能效洗衣机", "GDYJXYJ", "A03"),
+    GDEJXYJ(8, "二级能效洗衣机", "GDEJXYJ", "A03"),
+    GDYJXYYJ(9, "一级能效吸油烟机", "GDYJXYYJ", "A07"),
+    GDEJXYYJ(10, "二级能效吸油烟机", "GDEJXYYJ", "A07"),
+    GDYJDZ(11, "一级能效家用灶具", "GDYJDZ", "A08"),
+    GDEJDZ(12, "二级能效家用灶具", "GDEJDZ", "A08"),
+    GDYJRSQ(13, "一级能效热水器", "GDYJRSQ", "A06"),
+    GDEJRSQ(14, "二级能效热水器", "GDEJRSQ", "A06"),
+    GDYJDN(15, "一级能效电脑", "GDYJDN", "A05"),
+    GDEJDN(16, "二级能效电脑", "GDEJDN", "A05"),
+    GDYJCSJ(17, "一级能效除湿机", "GDYJCSJ", "GDYJKT"),
+    GDEJCSJ(18, "二级能效除湿机", "GDEJCSJ", "GDYJKT"),
+    GDYJJSQ(19, "一级能效净水器", "GDYJJSQ", "A10"),
+    GDEJJSQ(20, "二级能效净水器", "GDEJJSQ", "A10"),
             ;
 
-    UMSDiscountCodeEnum(Integer index, String name, String code) {
+    UMSDiscountCodeEnum(Integer index, String name, String code, String category) {
         this.index = index;
         this.name = name;
         this.code = code;
+        this.category = category;
     }
 
     private Integer index;
     private String name;
     private String code;
+    private String category;
 
     public static String findNameByCode(String code) {
         final Map<String, Object> fieldMap = EnumUtil.getNameFieldMap(UMSDiscountCodeEnum.class, "name");
         return fieldMap.containsKey(code) ? fieldMap.get(code).toString() : "";
     }
+
+    public static String findShortNameByCode(String code) {
+        final Map<String, Object> fieldMap = EnumUtil.getNameFieldMap(UMSDiscountCodeEnum.class, "name");
+        return fieldMap.containsKey(code) ? fieldMap.get(code).toString().substring(4) : "";
+    }
 }

+ 50 - 0
src/main/java/com/gree/mall/miniapp/enums/UMSGZDiscountCodeEnum.java

@@ -0,0 +1,50 @@
+package com.gree.mall.miniapp.enums;
+
+import cn.hutool.core.util.EnumUtil;
+import lombok.Getter;
+
+import java.util.Map;
+
+@Getter
+public enum UMSGZDiscountCodeEnum {
+    GDYJKT("GZKTYJ", "一级能效空调", "GDYJKT"),
+    GDEJKT("GZKTEJ", "二级能效空调", "GDEJKT"),
+    GDYJDS("GZDSYJ", "一级能效电视", "GDYJDS"),
+    GDEJDS("GZDSEJ", "二级能效电视", "GDEJDS"),
+    GDYJBX("GZBXYJ", "一级能效冰箱", "GDYJBX"),
+    GDEJBX("GZBXEJ", "二级能效冰箱", "GDEJBX"),
+    GDYJXYJ("GZXYJYJ", "一级能效洗衣机", "GDYJXYJ"),
+    GDEJXYJ("GZXYJEJ", "二级能效洗衣机", "GDEJXYJ"),
+    GDYJXYYJ("GZYYJYJ", "一级能效吸油烟机", "GDYJXYYJ"),
+    GDEJXYYJ("GZYYJEJ", "二级能效吸油烟机", "GDEJXYYJ"),
+    GDYJDZ("GZRQZYJ", "一级能效家用灶具", "GDYJDZ"),
+    GDEJDZ("GZRQZEJ", "二级能效家用灶具", "GDEJDZ"),
+    GDYJRSQ("GZRSQYJ", "一级能效热水器", "GDYJRSQ"),
+    GDEJRSQ("GZRSQEJ", "二级能效热水器", "GDEJRSQ"),
+    GDYJCSJ("GZCSJYJ", "一级能效除湿机", "GDYJCSJ"),
+    GDEJCSJ("GZCSJEJ", "二级能效除湿机", "GDEJCSJ"),
+    GDYJJSQ("GZJSQYJ", "一级能效净水器", "GDYJJSQ"),
+    GDEJJSQ("GZJSQEJ", "二级能效净水器", "GDEJJSQ"),
+            ;
+
+    UMSGZDiscountCodeEnum(String cover, String name, String code) {
+        this.cover = cover;
+        this.name = name;
+        this.code = code;
+    }
+
+    private String cover;
+    private String name;
+    private String code;
+
+    public static String findNameByCode(String code) {
+        final Map<String, Object> fieldMap = EnumUtil.getNameFieldMap(UMSGZDiscountCodeEnum.class, "name");
+        return fieldMap.containsKey(code) ? fieldMap.get(code).toString() : "";
+    }
+
+
+    public static String findCoverByCode(String code) {
+        final Map<String, Object> fieldMap = EnumUtil.getNameFieldMap(UMSGZDiscountCodeEnum.class, "cover");
+        return fieldMap.containsKey(code) ? fieldMap.get(code).toString() : "";
+    }
+}

+ 46 - 16
src/main/java/com/gree/mall/miniapp/logic/common/UMSLogic.java

@@ -5,13 +5,16 @@ import com.alibaba.fastjson.JSONObject;
 import com.gree.mall.miniapp.bean.PayDetail;
 import com.gree.mall.miniapp.bean.UmsMiniRepBean;
 import com.gree.mall.miniapp.enums.UMSDiscountCodeEnum;
+import com.gree.mall.miniapp.enums.UMSGZDiscountCodeEnum;
 import com.gree.mall.miniapp.enums.UMSNotGZDiscountCodeEnum;
 import com.gree.mall.miniapp.exception.RemoteServiceException;
 import com.gree.mall.miniapp.logic.AppletOrders;
 import com.gree.mall.miniapp.plus.entity.AdminCompanyWechat;
+import com.gree.mall.miniapp.plus.entity.AdminWebsit;
 import com.gree.mall.miniapp.plus.entity.OrderDetail;
 import com.gree.mall.miniapp.plus.entity.OrderInfo;
 import com.gree.mall.miniapp.plus.service.AdminCompanyWechatService;
+import com.gree.mall.miniapp.plus.service.AdminWebsitService;
 import com.gree.mall.miniapp.utils.ArithUtils;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.codec.binary.Base64;
@@ -48,10 +51,14 @@ public class UMSLogic {
 
     @Resource
     AdminCompanyWechatService adminCompanyWechatService;
+    @Resource
+    AdminWebsitService adminWebsitService;
     @Value("${ums.url}")
     private String url;
     @Value("${ums.payment.notifyUrl}")
     private String notifyUrl;
+    @Value("${wechat.sub.appid}")
+    private String wechatSubAppid;
 
     /**
      * 云闪付 todo
@@ -59,10 +66,11 @@ public class UMSLogic {
      * @param payment
      * @param companyWechatId
      * @param orderDetail
+     * @param ip
      * @return
      * @throws Exception
      */
-/*    public PayDetail payment(OrderInfo orderInfo, BigDecimal payment, String openid, String companyWechatId, OrderDetail orderDetail) throws Exception {
+    public PayDetail payment(OrderInfo orderInfo, BigDecimal payment, String openid, String companyWechatId, OrderDetail orderDetail, String ip) throws Exception {
         if(payment.doubleValue() <= 0){
             PayDetail payDetail = new PayDetail();
             payDetail.setIsPay(false);
@@ -71,16 +79,28 @@ public class UMSLogic {
         }
 
         final AdminCompanyWechat company = adminCompanyWechatService.getById(companyWechatId);
+        final AdminWebsit websit = adminWebsitService.getById(orderInfo.getWebsitId());
         JSONObject json = new JSONObject();
 
+        StringBuilder allAddress = new StringBuilder();
+        if (!orderInfo.getReceAddress().contains(orderInfo.getProvince())) {
+            allAddress.append(orderInfo.getProvince());
+        }
+        if (!orderInfo.getReceAddress().contains(orderInfo.getCity())) {
+            allAddress.append(orderInfo.getCity());
+        }
+        if (!orderInfo.getReceAddress().contains(orderInfo.getArea())) {
+            allAddress.append(orderInfo.getArea());
+        }
+        allAddress.append(orderInfo.getReceAddress());
+
         json.put("requestTimestamp", DateFormatUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss"));    // 报文请求时间
-        json.put("merOrderId", company.getUmsSysCode() + orderInfo.getOrderId()); // 银商分配的4位来源编号 + 商户订单号
-        json.put("mid", company.getUmsMid()); // 商户号
-        json.put("tid", company.getUmsTid());    // 终端号
+        json.put("merOrderId", websit.getYunSystem() + orderInfo.getOrderId()); // 银商分配的4位来源编号 + 商户订单号
+        json.put("mid", websit.getYunCompany()); // 商户号
+        json.put("tid", websit.getYunNumber());    // 终端号
         json.put("instMid", "MINIDEFAULT");
         json.put("totalAmount", (int) ArithUtils.mul(payment.doubleValue(), 100));      // 支付总金额
-        json.put("attachedData", orderInfo.getOrderId());
-        json.put("subAppId", company.getSubAppId());    // 微信子商户appId
+        json.put("subAppId", wechatSubAppid);    // 微信子商户appId
         json.put("subOpenId", openid);    // 微信子商户openid
         json.put("tradeType", "UP_WX_MINI");    // 交易类型
         json.put("invokeScene", "03");    // 交易发起场景
@@ -90,28 +110,38 @@ public class UMSLogic {
         json.put("certNo", Base64.encodeBase64String(orderInfo.getBuyerIdCard().getBytes(StandardCharsets.UTF_8)));  // 实名认证证件号
         json.put("certType", "IDENTITY_CARD");  // 实名认证证件类型
         json.put("fixBuyer", "T");  // 是否需要实名认证 需要实名认证时置为T
-        if (StringUtils.isNotBlank(company.getTaxNo())) {
-            json.put("ylyxId", company.getTaxNo().substring(3));    // 二级商编
+        json.put("srcReserve", allAddress.toString());  // 请求系统预留字段
+        json.put("clientIp", ip);  // 客户端IP 用户客户端的ip地址
+        if (StringUtils.isNotBlank(websit.getYunTax())) {
+            json.put("ylyxId", websit.getYunTax().substring(3));    // 二级商编
         }
         if (StringUtils.isNotBlank(company.getCompanyName())) {
             json.put("ylyxName", company.getCompanyName());    // 二级商名称
         }
-        if (StringUtils.isNotBlank(company.getShortCompanyName())) {
-            json.put("ylyxMerAbbr", company.getShortCompanyName());    // 二级商简称
+        if (StringUtils.isNotBlank(websit.getYunName())) {
+            json.put("ylyxMerAbbr", websit.getYunName());    // 二级商简称
         }
-        json.put("srcReserve", company.getCompanyName());
+        JSONObject attachedDataJson = new JSONObject();
+        attachedDataJson.put("ISO2O", websit.getYunTwo().equals("YES") ? "Y" : "N");
+        attachedDataJson.put("SPcode", websit.getYunTwo().equals("YES") ? websit.getYunSpCode() : "");
+        attachedDataJson.put("d", orderInfo.getOrderId());
+        json.put("attachedData", attachedDataJson);
 
 
         if (Objects.nonNull(orderDetail) && StringUtils.isNotBlank(orderDetail.getUmsDiscountCode()) && StringUtils.isNotBlank(orderDetail.getBarCode())) {
             json.put("discountCode", orderDetail.getUmsDiscountCode());
-            if (!company.getIsGz()) {
+            if (!websit.getYunTwo().equals("YES")) {
                 final String coverByCode = UMSNotGZDiscountCodeEnum.findCoverByCode(orderDetail.getUmsDiscountCode());
                 if (StringUtils.isNotBlank(coverByCode)) {
                     json.put("discountCode", coverByCode);
                 }
+            } else if (websit.getYunTwo().equals("YES")) {
+                final String coverByCode = UMSGZDiscountCodeEnum.findCoverByCode(orderDetail.getUmsDiscountCode());
+                if (StringUtils.isNotBlank(coverByCode)) {
+                    json.put("discountCode", coverByCode);
+                }
             }
 
-
             JSONArray array = new JSONArray();
             JSONObject goods = new JSONObject();
             String goodsName = orderDetail.getGoodsName().replace("以旧换新", "")
@@ -122,7 +152,7 @@ public class UMSLogic {
                     .replace("【", "")
                     .replace("】", "")
                     .replaceAll(" ", "");
-            goods.put("goodsCategory", UMSDiscountCodeEnum.findNameByCode(orderDetail.getUmsDiscountCode()));
+            goods.put("goodsCategory", UMSDiscountCodeEnum.findShortNameByCode(orderDetail.getUmsDiscountCode()));
             goods.put("goodsId", orderDetail.getBarCode());
             goods.put("quantity", orderDetail.getNum());
             goods.put("goodsName", goodsName.length() > 120 ? goodsName.substring(0, 120) : goodsName);
@@ -133,7 +163,7 @@ public class UMSLogic {
         }
 
         //OPEN-BODY-SIG 方式
-        String authorization = getOpenBodySig(company.getUmsAppid(), company.getUmsAppKey(), json.toString());
+        String authorization = getOpenBodySig(websit.getYunAppid(), websit.getYunAppkey(), json.toString());
 //        String authorization = AppletOrders.getOpenBodySig(company.getUmsAppid(), company.getUmsAppKey(), json.toString());
         String send = send(url + "/v1/netpay/uac/mini-order", json.toString() , authorization);
         final UmsMiniRepBean resultObj = JSONObject.parseObject(send, UmsMiniRepBean.class);
@@ -147,7 +177,7 @@ public class UMSLogic {
         payDetail.setUmsMiniRep(resultObj);
         log.info("payDetail:{}",JSONObject.toJSONString(payDetail));
         return payDetail;
-    }*/
+    }
 
     /**
      * open-body-sig方式获取到Authorization 的值

File diff suppressed because it is too large
+ 191 - 186
src/main/java/com/gree/mall/miniapp/logic/order/OrderLogic.java


Some files were not shown because too many files changed in this diff