Browse Source

no message

FengChaoYu 10 months ago
parent
commit
82d4fa67bf

+ 27 - 21
mall-miniapp-service/src/main/java/com/gree/mall/miniapp/constant/Constant.java

@@ -28,28 +28,34 @@ public class Constant {
     }
 
     public class RedisPrefix{
-        public final static String WORK_MINI_ACCESS_TOKEN = "jsm:sxb::work:mini:access:token";
-        public final static String TOKEN_WX = "jsm:sxb::token:wx";
-        public final static String TOKEN_GREE = "jsm:sxb::token:gree";
-        public final static String LOCK_ORDER = "jsm:sxb::lock:order";
-        public final static String LOCK_ORDER_STOCK = "jsm:sxb::lock:stock";
-        public final static String SEC_IDENTIFIER = "jsm:sxb::sec:identifier";
-        public final static String LOCK_COUPON = "jsm:sxb::lock:coupon";
-        public final static String LOCK_GIFT = "jsm:sxb::lock:gift";
-        public final static String LOCK_COUPON_TRANSFER = "jsm:sxb::lock:coupon:transfer";
-        public final static String LOCK_COUPON_CHECK = "jsm:sxb::lock:coupon:check";
-        public final static String LOCK_AUTH = "jsm:sxb::lock:auth";
-        public final static String SMS = "jsm:sxb::sms";
-        public final static String VERIFICATION = "jsm:sxb::verification";
-        public final static String SMS_BIND_CODE= "jsm:sxb::sms:bind:";
-        public final static String TOKEN_TAX = "jsm:sxb::token:tax";
-        public final static String TOKEN_GONGDAN = "jsm:sxb::token:gongdan";
-        public final static String LOCK_EXCHANGE_CODE = "jsm:sxb::lock:exchangecode";
+        public final static String WORK_MINI_ACCESS_TOKEN = "jsm:sxb:work:mini:access:token";
+        public final static String TOKEN_WX = "jsm:sxb:token:wx";
+        public final static String TOKEN_GREE = "jsm:sxb:token:gree";
+        public final static String LOCK_ORDER = "jsm:sxb:lock:order";
+        public final static String LOCK_ORDER_STOCK = "jsm:sxb:lock:stock";
+        public final static String SEC_IDENTIFIER = "jsm:sxb:sec:identifier";
+        public final static String LOCK_COUPON = "jsm:sxb:lock:coupon";
+        public final static String LOCK_GIFT = "jsm:sxb:lock:gift";
+        public final static String LOCK_COUPON_TRANSFER = "jsm:sxb:lock:coupon:transfer";
+        public final static String LOCK_COUPON_CHECK = "jsm:sxb:lock:coupon:check";
+        public final static String LOCK_AUTH = "jsm:sxb:lock:auth";
+        public final static String SMS = "jsm:sxb:sms";
+        public final static String VERIFICATION = "jsm:sxb:verification";
+        public final static String SMS_BIND_CODE= "jsm:sxb:sms:bind:";
+        public final static String TOKEN_TAX = "jsm:sxb:token:tax";
+        public final static String TOKEN_GONGDAN = "jsm:sxb:token:gongdan";
+        public final static String LOCK_EXCHANGE_CODE = "jsm:sxb:lock:exchangecode";
         //订单号每日流水
-        public final static String ORDER_NUM = "jsm:sxb::orderNo:";
-        public final static String MATERIAL_STOCK_LOCK = "jsm:sxb::lock:material:stock:";
-        public final static String LEASE_ORDER_LOCK = "jsm:sxb::lock:lease:order:";
-        public final static String ES_GOODS_LOCK = "jsm:sxb::lock:es:goods:";
+        public final static String ORDER_NUM = "jsm:sxb:orderNo:";
+        public final static String MATERIAL_STOCK_LOCK = "jsm:sxb:lock:material:stock:";
+        public final static String LEASE_ORDER_LOCK = "jsm:sxb:lock:lease:order:";
+        public final static String ES_GOODS_LOCK = "jsm:sxb:lock:es:goods:";
+
+        // 接口令牌
+        public final static String INF_TOKEN = "jsm:sxb:token:inf";
+
+        // 查询通联支付订单信息
+        public final static String QUERY_ALLINPAY_ORDER = "jsm:sxb:lock:a:query:order:";
     }
 
     //礼品卡支持的市

+ 20 - 0
mall-miniapp-service/src/main/java/com/gree/mall/miniapp/constant/SybConstants.java

@@ -0,0 +1,20 @@
+package com.gree.mall.miniapp.constant;
+
+public class SybConstants {
+	//正式环境测试参数
+	public static final String SYB_ORGID = "";//集团/机构模式下该参数不为空,且appid与key是与次参数对应
+	public static final String SYB_CUSID = "990440148166000";
+	public static final String SYB_APPID = "00000003";
+	public static final String SYB_MD5_APPKEY = "a0ea3fa20dbd7bb4d5abf1d59d63bae8";
+	public static final String SYB_APIURL = "https://vsp.allinpay.com/apiweb/unitorder";//生产环境
+	public static final String SIGN_TYPE = "SM2";
+	public static final String SYB_RSACUSPRIKEY = "MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAO0HpPUP+eHk//Ba6ZOePvoZVDpOCRtt943oeVfCTllye43bqja1jVIaebX0MgX+yPYnWIQIOJ9ubSH0R4iyY9y1/HR00qkUpfW3/0usBPt9qn7r0xtFHerhVCd4dT2rKb2Oc5IhKOg05cw/BmMFohMkFsqt0jlrUXI8zJOlLIcxAgMBAAECgYA9lt/pAYa3iK5sQOMyhUrt54j4QXCiXPeXOxHUmNuM6G9sU+itoI0hCVoYymP5JNQJCf45CH3WB3Z5/SRdQ6Uoo1cjao6cCohPLxMSfJglsZCHckPH53o25RKEza4njIgKC+yN7HAhanKymhw/yYQ6i0aXq38zFIk8djMtE7R6xQJBAP6jvNy7UhPKO5rxGFKR+MvvbO3qnYH6x0jZCGY3FlxuGfbavueOiFtMeK67FuDv683dcUKi+M48yR4kH5CfIusCQQDuS9KF6mlm3kHAiZWgVhE8VVNYGpRLCRDgAKm4InGmvk5mUv+O1yAtAFVAEHWIgD4awC7Eqf1YFrSF/It9HV9TAkEAsXiU7JJxhfFw0XAvL30lFZ1tIfReinSp6A+7VuIV552k4vNaEjC4wEjv43fpXiRZCEXJ5lOHbNXYpfUvOrBuuQJAOpow8rf8Jc0g1G3Be0XPRUwii/c1YuKe4Meo9VybIIuKkkV1Dba/9fEwBepGTURkgYWjur+nSyOCT7UUxLcVewJAPLig8dVfKpsiNwYuveEYMcFaO5xoRuiB7v+CMmvxpuuK+rrFS+d7RdmwDbnBiDV4JkTgFObUiGvB7MtS+LGfhw==";
+	public static final String SYB_RSATLPUBKEY = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCm9OV6zH5DYH/ZnAVYHscEELdCNfNTHGuBv1nYYEY9FrOzE0/4kLl9f7Y9dkWHlc2ocDwbrFSm0Vqz0q2rJPxXUYBCQl5yW3jzuKSXif7q1yOwkFVtJXvuhf5WRy+1X5FOFoMvS7538No0RpnLzmNi3ktmiqmhpcY/1pmt20FHQQIDAQAB";
+//	/**商户sm2私钥,用于向通联发起请求前进行签名**/
+	public static final String SYB_SM2PPRIVATEKEY = "MIGTAgEAMBMGByqGSM49AgEGCCqBHM9VAYItBHkwdwIBAQQgjj4Rk+b0YjwO+UwXofnHf4bK+kaaY5Btkd8nMP2VimmgCgYIKoEcz1UBgi2hRANCAAQqlALW4qGC3bP1x3wo5QsKxaCMEZJ2ODTTwOQ+d8UGU7GoK/y/WMBQWf5upMnFU06p5FxGooXYYoBtldgm03hq";
+//	/**通联平台sm2公钥,用于请求返回或者通联通知的验签**/
+	public static final String SYB_SM2TLPUBKEY = "MFkwEwYHKoZIzj0CAQYIKoEcz1UBgi0DQgAEBQicgWm0KAMqhO3bdqMUEDrKQvYg8cCXHhdGwq7CGE6oJDzJ1P/94HpuVdBf1KidmPxr7HOH+0DAnpeCcx9TcQ==";
+
+	public static final String PAY_TYPE_W01 = "W01";
+	public static final String PAY_TYPE_W06 = "W06";
+}

+ 1 - 0
mall-miniapp-service/src/main/java/com/gree/mall/miniapp/enums/PayTypeEnum.java

@@ -7,6 +7,7 @@ import lombok.Getter;
 public enum PayTypeEnum implements BaseEnum {
     WECHAT("WECHAT","微信支付"),
     CASH("CASH","现金"),
+    ALLINPAY("ALLINPAY","通联支付"),
     TRANSFER("TRANSFER","转账支付"),
     STORE("STORE","到店支付"),
     LINE("LINE","线下支付");

+ 170 - 0
mall-miniapp-service/src/main/java/com/gree/mall/miniapp/logic/common/AllInPayLogic.java

@@ -0,0 +1,170 @@
+package com.gree.mall.miniapp.logic.common;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.TypeReference;
+import com.gree.mall.miniapp.constant.SybConstants;
+import com.gree.mall.miniapp.exception.RemoteServiceException;
+import com.gree.mall.miniapp.plus.entity.WebsitSalesPayOrder;
+import com.gree.mall.miniapp.utils.ArithUtils;
+import com.gree.mall.miniapp.utils.HttpUtils;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
+
+import javax.annotation.Resource;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Optional;
+
+@Component
+@Slf4j
+public class AllInPayLogic {
+
+    @Value("${allIn.payment.notifyUrl}")
+    private String notifyUrl;
+
+    @Resource
+    CommonLogic commonLogic;
+
+
+    /**
+     * 通联支付
+     */
+    public Map<String, String> serviceUnifiedOrder(WebsitSalesPayOrder order, String payType)
+            throws RemoteServiceException {
+        Map<String, String> reqMap = new HashMap<>();
+        reqMap.put("orgid", order.getOrgId());
+        reqMap.put("cusid", order.getMchNo());
+        reqMap.put("appid", order.getAppid());
+        if (SybConstants.PAY_TYPE_W06.equals(payType)) {
+            reqMap.put("acct", order.getOpenid());
+            reqMap.put("sub_appid", "wx21d155e8a449d9b1");
+        }
+        reqMap.put("notify_url", this.notifyUrl);
+        reqMap.put("trxamt", (int) ArithUtils.mul(order.getPayValue().doubleValue(), 100) + "");
+        reqMap.put("reqsn", order.getOrderNo());
+        reqMap.put("body", order.getWebsitName());
+        reqMap.put("paytype", payType);
+        reqMap.put("remark", order.getOrderId());
+
+        HashMap<String, String> heads = new HashMap();
+        String token = commonLogic.getInfToken();
+        if (StringUtils.isEmpty(token)) {
+            throw new RemoteServiceException("获取接口令牌失败");
+        }
+        heads.put("authorization_token", token);
+
+        String content = HttpUtils.requestPostBody(commonLogic.getInfUrl() + "/pay/csb/qrcode", JSON.toJSONString(reqMap), heads);
+
+        Map<String, Object> resMap = JSON.parseObject(content, new TypeReference<HashMap<String, Object>>() {});
+
+        if (!Optional.ofNullable(resMap.get("message")).orElse("error").toString().equals("success")) {
+            log.error("通联统一支付接口执行失败: {}>>>{}", order.getOrderId(), resMap);
+            throw new RemoteServiceException("通联统一支付接口执行失败:" + resMap.get("message"));
+        }
+
+        return (Map<String, String>) resMap.get("data");
+    }
+
+    /**
+     * 通联支付查询订单
+     */
+    public Map<String, String> serviceQueryOrder(WebsitSalesPayOrder order) throws RemoteServiceException {
+        Map<String, String> reqMap = new HashMap<>();
+        if (StringUtils.isNotBlank(order.getOrgId())) {
+            reqMap.put("orgid", order.getOrgId());
+        }
+        reqMap.put("cusid", order.getOrderNo());
+        reqMap.put("appid", order.getAppid());
+        reqMap.put("reqsn", order.getOutTradeNo());
+        reqMap.put("trxid", order.getOrderNo());
+
+        HashMap<String, String> heads = new HashMap();
+        String token = commonLogic.getInfToken();
+        if (StringUtils.isEmpty(token)) {
+            throw new RemoteServiceException("获取接口令牌失败");
+        }
+        heads.put("authorization_token", token);
+
+        String content = HttpUtils.requestPostBody(commonLogic.getInfUrl() + "/pay/csb/order/query", JSON.toJSONString(reqMap), heads);
+
+        Map<String, Object> resMap = JSON.parseObject(content, new TypeReference<HashMap<String, Object>>() {});
+
+        if (!Optional.ofNullable(resMap.get("message")).orElse("error").toString().equals("success")) {
+            log.error("通联交易查询接口执行失败: {}", resMap);
+            throw new RemoteServiceException("通联交易查询接口执行失败:" + resMap.get("message"));
+        }
+
+        return (Map<String, String>) resMap.get("data");
+    }
+
+    /**
+     * 通联支付退款
+     */
+//    public Map<String, String> serviceRefundOrder(SalesPayList paylist, BigDecimal refundValue) throws RemoteServiceException {
+//        Map<String, String> reqMap = new HashMap<>();
+//        if (StringUtils.isNotBlank(paylist.getMchNo())) {
+//            reqMap.put("orgid", paylist.getMchNo());
+//        }
+//        reqMap.put("appid", paylist.getAppid());
+//        reqMap.put("cusid", paylist.getSubMchNo());
+//        reqMap.put("trxamt", (int) ArithUtils.mul(refundValue.doubleValue(), 100) + ""); // 退款金额 单位:分
+//        reqMap.put("reqsn", LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmssSSS"))); // 商户的退款订单号
+//        reqMap.put("oldreqsn", paylist.getOutTradeNo()); // 原交易的商户订单号
+//        reqMap.put("oldtrxid", paylist.getOrderNo()); // 原交易的收银宝平台流水
+//        reqMap.put("trxid", paylist.getOrderNo());
+//
+//        HashMap<String, String> heads = new HashMap();
+//        String token = commonLogic.getInfToken();
+//        if (StringUtils.isEmpty(token)) {
+//            throw new RemoteServiceException("获取接口令牌失败");
+//        }
+//        heads.put("authorization_token", token);
+//
+//        String content = HttpUtils.requestPostBody(commonLogic.getInfUrl() + "/pay/csb/order/refund", JSON.toJSONString(reqMap), heads);
+//
+//        Map<String, Object> resMap = JSON.parseObject(content, new TypeReference<HashMap<String, Object>>() {});
+//
+//        if (!Optional.ofNullable(resMap.get("message")).orElse("error").toString().equals("success")) {
+//            log.error("通联交易退款接口执行失败: {}", resMap);
+//            throw new RemoteServiceException("通联交易退款接口执行失败:" + resMap.get("message"));
+//        }
+//
+//        return (Map<String, String>) resMap.get("data");
+//    }
+
+    /**
+     * 通联支付关闭
+     */
+//    public Map<String, String> serviceCloseOrder(SalesPayList payRecord) throws RemoteServiceException {
+//        Map<String, String> reqMap = new HashMap<>();
+//        if (StringUtils.isNotBlank(payRecord.getMchNo())) {
+//            reqMap.put("orgid", payRecord.getMchNo());
+//        }
+//        reqMap.put("appid", payRecord.getAppid());
+//        reqMap.put("cusid", payRecord.getSubMchNo());
+//        reqMap.put("reqsn", LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmssSSS"))); // 商户的退款订单号
+//        reqMap.put("oldreqsn", payRecord.getOutTradeNo()); // 原交易的商户订单号
+//        reqMap.put("oldtrxid", payRecord.getOrderNo()); // 原交易的收银宝平台流水
+//        reqMap.put("trxid", payRecord.getOrderNo());
+//
+//        HashMap<String, String> heads = new HashMap();
+//        String token = commonLogic.getInfToken();
+//        if (StringUtils.isEmpty(token)) {
+//            throw new RemoteServiceException("获取接口令牌失败");
+//        }
+//        heads.put("authorization_token", token);
+//
+//        String content = HttpUtils.requestPostBody(commonLogic.getInfUrl() + "/pay/csb/order/close", JSON.toJSONString(reqMap), heads);
+//
+//        Map<String, Object> resMap = JSON.parseObject(content, new TypeReference<HashMap<String, Object>>() {});
+//
+//        String message = Optional.ofNullable(resMap.get("message")).orElse("error").toString();
+//        if (message.equals("success") || message.equals("交易已关闭")) {
+//            return (Map<String, String>) resMap.get("data");
+//        }
+//        log.error("通联交易关闭接口执行失败: {}", resMap);
+//        throw new RemoteServiceException("通联交易关闭接口执行失败:" + resMap.get("message"));
+//    }
+}

+ 38 - 1
mall-miniapp-service/src/main/java/com/gree/mall/miniapp/logic/common/CommonLogic.java

@@ -2,8 +2,10 @@ package com.gree.mall.miniapp.logic.common;
 
 import cn.hutool.core.date.DateUtil;
 import cn.hutool.http.HttpUtil;
+import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
+import com.alibaba.fastjson.TypeReference;
 import com.gree.mall.miniapp.bean.user.CurrentCompanyWechat;
 import com.gree.mall.miniapp.constant.Constant;
 import com.gree.mall.miniapp.exception.RemoteServiceException;
@@ -11,6 +13,7 @@ import com.gree.mall.miniapp.plus.entity.*;
 import com.gree.mall.miniapp.plus.service.*;
 import com.gree.mall.miniapp.utils.ApplicationContextUtils;
 import com.gree.mall.miniapp.utils.CommonUtils;
+import com.gree.mall.miniapp.utils.HttpUtils;
 import com.gree.mall.miniapp.utils.RedisUtil;
 import com.gree.mall.miniapp.utils.oss.OSSUtil;
 import lombok.extern.slf4j.Slf4j;
@@ -52,7 +55,12 @@ public class CommonLogic {
     RedisUtil redisUtil;
     @Value("${spring.profiles.active}")
     private String profiles;
-
+    @Value("${inf.url}")
+    private String infUrl;
+    @Value("${inf.token.appid}")
+    private String clientId;
+    @Value("${inf.token.appSecret}")
+    private String clientSecret;
 
     //高德的webkey
     private final String mapWebKey = "69cebe7cded9307a588237b0618856c9";
@@ -308,5 +316,34 @@ public class CommonLogic {
         return list;
     }
 
+    public String getInfToken() throws RemoteServiceException {
+        Object token = redisUtil.get(Constant.RedisPrefix.INF_TOKEN);
+
+        if (token != null) {
+            return token.toString();
+        }
+        //过期就重新获取
+        return this.deleteAndAddInfToken();
+    }
+
+    public String deleteAndAddInfToken() throws RemoteServiceException {
+        HashMap<String, String> params = new HashMap();
+        params.put("clientId", this.clientId);
+        params.put("clientSecret", this.clientSecret);
+        String content = HttpUtils.requestGet(this.infUrl + "/com/token/get", params, null);
+        Map<String, Object> resMap = JSON.parseObject(content, new TypeReference<HashMap<String, Object>>() {
+        });
+
+        int code = (int) resMap.get("code");
+        if (code == 1) {
+            String token = (String) resMap.get("data");
+            redisUtil.set(Constant.RedisPrefix.INF_TOKEN, token, (2 * 60 * 60) - 30);//2小时过期
+            return token;
+        }
+        return null;
+    }
 
+    public String getInfUrl() {
+        return infUrl;
+    }
 }

+ 61 - 0
mall-miniapp-service/src/main/java/com/gree/mall/miniapp/logic/material/WebsitSalesLogic.java

@@ -7,13 +7,16 @@ import com.gree.mall.miniapp.bean.PayDetail;
 import com.gree.mall.miniapp.bean.material.*;
 import com.gree.mall.miniapp.bean.user.CurrentCompanyWechat;
 import com.gree.mall.miniapp.commonmapper.MaterialMapper;
+import com.gree.mall.miniapp.enums.IsYesNoEnum;
 import com.gree.mall.miniapp.enums.OrderInfoSourceEnum;
 import com.gree.mall.miniapp.enums.material.WebsitGoodsTypeEnum;
 import com.gree.mall.miniapp.exception.RemoteServiceException;
+import com.gree.mall.miniapp.logic.common.AllInPayLogic;
 import com.gree.mall.miniapp.logic.common.CommonLogic;
 import com.gree.mall.miniapp.logic.common.outside.WechatLogic;
 import com.gree.mall.miniapp.plus.entity.*;
 import com.gree.mall.miniapp.plus.service.*;
+import com.gree.mall.miniapp.utils.DateUtils;
 import com.gree.mall.miniapp.utils.IpUtil;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.BeanUtils;
@@ -23,6 +26,7 @@ import org.springframework.transaction.annotation.Transactional;
 import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
 import java.math.BigDecimal;
+import java.text.ParseException;
 import java.util.*;
 import java.util.function.Function;
 import java.util.stream.Collectors;
@@ -51,6 +55,10 @@ public class WebsitSalesLogic {
     WebsitGoodsCategoryService websitGoodsCategoryService;
     @Resource
     WechatLogic wechatLogic;
+    @Resource
+    AllInPayLogic allInPayLogic;
+    @Resource
+    AdminWebsitPayConfigService adminWebsitPayConfigService;
 
     public IPage<SalesOrderBean> buyList(String flag, Integer pageNum, Integer pageSize, HttpServletRequest request) {
         CurrentCompanyWechat wechat = commonLogic.getCurrentCompanyWechat(request);
@@ -302,6 +310,19 @@ public class WebsitSalesLogic {
 
         //订单
         WebsitSales sales = new WebsitSales();
+
+        // 检查是否有支付配置
+        final Integer payConfigCount = adminWebsitPayConfigService.lambdaQuery()
+                .eq(AdminWebsitPayConfig::getCompanyWechatId, wechat.getCompanyWechatId())
+                .eq(AdminWebsitPayConfig::getWebsitId, websitId)
+                .eq(AdminWebsitPayConfig::getType, sales.getGoodsType())
+                .eq(AdminWebsitPayConfig::getStatus, true)
+                .count();
+
+        if (payConfigCount == 0) {
+            throw new RemoteServiceException(sales.getWebsitName() + " 未配置线上收款");
+        }
+
         sales.setTotalAmount(BigDecimal.ZERO);
 
         //订单详情
@@ -374,4 +395,44 @@ public class WebsitSalesLogic {
 
         return salesId;
     }
+
+    @Transactional
+    public void queryAllinpayOrder(WebsitSalesPayOrder order) throws ParseException {
+        Map<String, String> resMap = allInPayLogic.serviceQueryOrder(order);
+        String fintime = resMap.get("fintime"); // 交易完成时间
+        String chnltrxid = resMap.get("chnltrxid"); // 渠道流水号
+        String acct = resMap.get("acct"); // 支付平台用户标识
+        String trxstatus = resMap.get("trxstatus"); // 交易状态
+        String errmsg = resMap.get("errmsg"); // 原因
+
+        switch(trxstatus.trim()) {
+            case "0000":
+                // 支付成功
+                websitSalesService.lambdaUpdate()
+                        .set(WebsitSales::getPayFlag, IsYesNoEnum.YES.getKey())
+                        .set(WebsitSales::getFlag, "PAY_NOT_TAKE")
+                        .set(WebsitSales::getPayTime, DateUtils.parseDate2(fintime))
+                        .set(WebsitSales::getPayNo, chnltrxid)
+                        .eq(WebsitSales::getSalesId, order.getOrderId())
+                        .update();
+                order.setPayTime(DateUtils.parseDate2(fintime))
+                        .setTransactionId(chnltrxid)
+                        .setOpenid(acct)
+                        .setLastStatus(trxstatus)
+                        .setLastMsg(errmsg)
+                        .updateById();
+                break;
+            case "2000":
+                // 交易处理中
+                int count = order.getRunCount() + 1;
+                order.setRunCount(count)
+                        .setRunTime(DateUtil.offsetSecond(DateUtil.date(), count * 5))
+                        .setLastStatus(trxstatus)
+                        .setLastMsg(errmsg)
+                        .updateById();
+                break;
+            default:
+                log.info("未定义交易状态:" + trxstatus);
+        }
+    }
 }

+ 67 - 0
mall-miniapp-service/src/main/java/com/gree/mall/miniapp/schedule/AllinpaySchedule.java

@@ -0,0 +1,67 @@
+package com.gree.mall.miniapp.schedule;
+
+import cn.hutool.core.collection.CollectionUtil;
+import cn.hutool.core.date.DateUtil;
+import com.gree.mall.miniapp.constant.Constant;
+import com.gree.mall.miniapp.enums.IsYesNoEnum;
+import com.gree.mall.miniapp.enums.PayTypeEnum;
+import com.gree.mall.miniapp.exception.RemoteServiceException;
+import com.gree.mall.miniapp.logic.material.WebsitSalesLogic;
+import com.gree.mall.miniapp.plus.entity.WebsitSalesPayOrder;
+import com.gree.mall.miniapp.plus.service.WebsitSalesPayOrderService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.integration.redis.util.RedisLockRegistry;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.stereotype.Component;
+
+import javax.annotation.Resource;
+import java.util.Date;
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.locks.Lock;
+
+@Component
+@Slf4j
+public class AllinpaySchedule {
+
+    @Resource
+    WebsitSalesPayOrderService websitSalesPayOrderService;
+    @Resource
+    WebsitSalesLogic websitSalesLogic;
+    @Resource
+    RedisLockRegistry redisLockRegistry;
+
+    //上一次执行完后5秒再扫支付记录表
+    @Scheduled(initialDelay = 5000, fixedDelay = 5000)
+    private void configureTasks() throws Exception {
+        List<WebsitSalesPayOrder> payList = websitSalesPayOrderService.lambdaQuery()
+                .eq(WebsitSalesPayOrder::getPayFlag, IsYesNoEnum.NO.getKey())
+                .eq(WebsitSalesPayOrder::getPayType, PayTypeEnum.ALLINPAY.getKey())
+                .le(WebsitSalesPayOrder::getRunCount, 50)
+                .le(WebsitSalesPayOrder::getRunTime, new Date())
+                .list();
+
+        if (CollectionUtil.isNotEmpty(payList)) {
+            for (WebsitSalesPayOrder order : payList) {
+                Lock obtain = redisLockRegistry.obtain(Constant.RedisPrefix.QUERY_ALLINPAY_ORDER + order.getOrderId());
+                try {
+                    if (obtain.tryLock(5, TimeUnit.SECONDS)) {
+                        websitSalesLogic.queryAllinpayOrder(order);
+                    }
+                } catch (RemoteServiceException e) {
+                    log.error("serviceQueryOrder() 查询通联订单出错:" + e.getMessage());
+                    int count = order.getRunCount() + 1;
+                    order.setRunCount(count)
+                            .setRunTime(DateUtil.offsetSecond(DateUtil.date(), count * 5))
+                            .setLastMsg("查询通联订单出错:" + e.getMessage())
+                            .updateById();
+                } catch(Exception e) {
+                    log.error("【查询通联订单处理】失败", e);
+                    throw e;
+                } finally {
+                    obtain.unlock();
+                }
+            }
+        }
+    }
+}

+ 10 - 1
mall-miniapp-service/src/main/resources/bootstrap-dev.properties

@@ -67,4 +67,13 @@ ali.sms.msg.code=SMS_284585310
 ali.cdn.url=
 
 
-gree.url.token=
+gree.url.token=
+
+#通联支付回调地址
+php.interface.url=https://admin.zfire.top
+allIn.payment.notifyUrl=${php.interface.url}/java_fucai/common/allInPayCall
+
+#内部接口
+inf.url=http://121.43.111.127:11111
+inf.token.appid=zfire-jsm-sxb
+inf.token.appSecret=3e7iee31ub94rvvesp7266kwske7fple

+ 26 - 17
mall-miniapp-service/src/main/resources/bootstrap-prd.propertiesb

@@ -1,21 +1,21 @@
 sys.url=https://sxb.zfire.top
-#pc服务url
+#pc锟斤拷锟斤拷url
 pc.server.url=${sys.url}/zfapi
-#物流回调
+#锟斤拷锟斤拷锟截碉拷
 express.callback=${pc.server.url}/common/express/callback
 
-#定时器
+#锟斤拷时锟斤拷
 schedule.enable=true
 
-##SQL执行分析,该插件有性能损耗,不建议生产环境使用
+##SQL执锟叫凤拷锟斤拷锟斤拷锟矫诧拷锟斤拷锟斤拷锟斤拷锟斤拷锟侥o拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷使锟斤拷
 spring.datasource.druid.db-type=mysql
 spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
 spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
 
-#内网
+#锟斤拷锟斤拷
 #spring.datasource.url=jdbc:mysql://rm-bp1gsex17k87vu0np.mysql.rds.aliyuncs.com:3306/sxb-mall?verifyServerCertificate=false&useSSL=false&requireSSL=false&useUnicode=true&characterEncoding=UTF-8&characterSetResults=utf8&serverTimezone=Asia/Shanghai
 
-#外网
+#锟斤拷锟斤拷
 spring.datasource.url=jdbc:mysql://rm-bp1gsex17k87vu0npmo.mysql.rds.aliyuncs.com:6033/sxb?verifyServerCertificate=false&useSSL=false&requireSSL=false&useUnicode=true&characterEncoding=UTF-8&characterSetResults=utf8&serverTimezone=Asia/Shanghai
 
 spring.datasource.username=sxb
@@ -24,32 +24,32 @@ spring.datasource.druid.connection-init-sqls=set names utf8mb4
 spring.datasource.druid.initial-size=5
 spring.datasource.druid.minIdle=5
 spring.datasource.druid.maxActive=20
-### 配置获取连接等待超时的时间,单位是毫秒
+### 锟斤拷锟矫伙拷取锟斤拷锟接等达拷锟斤拷时锟斤拷时锟戒,锟斤拷位锟角猴拷锟斤拷
 spring.datasource.druid.maxWait=60000
-### 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
+### 锟斤拷锟矫硷拷锟斤拷锟矫才斤拷锟斤拷一锟轿硷拷猓�拷锟斤拷锟斤拷要锟截闭的匡拷锟斤拷锟斤拷锟接o拷锟斤拷位锟角猴拷锟斤拷
 spring.datasource.druid.timeBetweenEvictionRunsMillis=60000
-### 配置一个连接在池中最小生存的时间,单位是毫秒
+### 锟斤拷锟斤拷一锟斤拷锟斤拷锟斤拷锟节筹拷锟斤拷锟斤拷小锟斤拷锟斤拷锟绞憋拷洌�拷锟轿伙拷呛锟斤拷锟�
 spring.datasource.druid.minEvictableIdleTimeMillis=300000
 spring.datasource.druid.validationQuery=SELECT 1 FROM DUAL
 spring.datasource.druid.testWhileIdle=true
 spring.datasource.druid.testOnBorrow=false
 spring.datasource.druid.testOnReturn=false
-### 打开PSCache,并且指定每个连接上PSCache的大
+### 锟斤拷PSCache锟斤拷锟斤拷锟斤拷指锟斤拷每锟斤拷锟斤拷锟斤拷锟斤拷PSCache锟侥达拷
 spring.datasource.druid.poolPreparedStatements=true
 spring.datasource.druid.maxPoolPreparedStatementPerConnectionSize=20
-### 配置监控统计拦截的filters,去掉后监控界面sql无法统计,'wall'用于防火
+### 锟斤拷锟矫硷拷锟酵筹拷锟斤拷锟斤拷氐锟絝ilters锟斤拷去锟斤拷锟斤拷锟截斤拷锟斤拷sql锟睫凤拷统锟狡o拷'wall'锟斤拷锟节凤拷锟斤拷
 spring.datasource.druid.filters=stat,wall
 
-### 通过connectProperties属性来打开mergeSql功能;慢SQL记
+### 通锟斤拷connectProperties锟斤拷锟斤拷锟斤拷锟斤拷mergeSql锟斤拷锟杰o拷锟斤拷SQL锟斤拷
 spring.datasource.druid.connectionProperties=druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000
-# 合并多个DruidDataSource的监控数据
+# 锟较诧拷锟斤拷锟紻ruidDataSource锟侥硷拷锟斤拷锟斤拷锟�
 #spring.datasource.useGlobalDataSourceStat=true
 
 
-#####################redis 单机版 start################
+#####################redis 锟斤拷锟斤拷锟斤拷 start################
 spring.redis.port=6379
 spring.redis.host=121.41.110.30
-#redis密码
+#redis锟斤拷锟斤拷
 spring.redis.password=
 spring.redis.lettuce.pool.max-active=300
 spring.redis.lettuce.pool.max-wait=1000ms
@@ -57,7 +57,7 @@ spring.redis.lettuce.pool.max-idle=100
 spring.redis.lettuce.pool.min-idle=0
 spring.redis.timeout=100000ms
 
-####################阿里云配置######################
+####################锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷######################
 ali.access.key.id=LTAI5tDHiEGKuwzNhW2gLPyc
 ali.access.key.secert=NVXSx3Gj7fHv6unGwWgalJh49uMZOI
 ali.oss.bucket.name=zf-mall
@@ -69,4 +69,13 @@ ali.cdn.url=
 
 
 
-gree.url.token=
+gree.url.token=
+
+#閫氳仈鏀�粯鍥炶皟鍦板潃
+php.interface.url=https://admin.zfire.top
+allIn.payment.notifyUrl=${php.interface.url}/java_fucai/common/allInPayCall
+
+#鍐呴儴鎺ュ彛
+inf.url=http://121.43.111.127:11111
+inf.token.appid=zfire-jsm-sxb
+inf.token.appSecret=3e7iee31ub94rvvesp7266kwske7fple

+ 10 - 1
mall-miniapp-service/src/main/resources/bootstrap-test.properties

@@ -65,4 +65,13 @@ ali.cdn.url=
 
 
 
-gree.url.token=
+gree.url.token=
+
+#通联支付回调地址
+php.interface.url=https://admin.zfire.top
+allIn.payment.notifyUrl=${php.interface.url}/java_fucai/common/allInPayCall
+
+#内部接口
+inf.url=http://121.43.111.127:11111
+inf.token.appid=zfire-jsm-sxb
+inf.token.appSecret=3e7iee31ub94rvvesp7266kwske7fple

+ 1 - 1
mall-server-api/src/main/java/com/gree/mall/manager/constant/Constant.java

@@ -60,7 +60,7 @@ public class Constant {
         public final static String ORDER_ENGIN_BASE =  "jsm:sxb:lock:order:engin:base:";
 
         // 接口令牌
-        public final static String INF_TOKEN = "material:token:inf";
+        public final static String INF_TOKEN = "jsm:sxb:token:inf";
     }
     public class ChatMessage {
         public final static String MSG_TYPE_DOC = "docmsg";

+ 1 - 0
mall-server-api/src/main/java/com/gree/mall/manager/enums/material/PayTypeEnum.java

@@ -12,6 +12,7 @@ import lombok.RequiredArgsConstructor;
 public enum PayTypeEnum implements BaseEnum {
     CASH("CASH","现金支付"),
     WECHAT("WECHAT","微信支付"),
+    ALLINPAY("ALLINPAY","通联支付"),
     ENGIN("ENGIN","工程支付"),
     TRANSFER("TRANSFER","转账支付"),
     LINE("LINE","线下支付")

+ 3 - 1
mall-server-api/src/main/java/com/gree/mall/manager/logic/material/manage/WebsitSalesLogic.java

@@ -557,13 +557,14 @@ public class WebsitSalesLogic {
                 .setWebsitName(sales.getWebsitName())
                 .setOrderId(sales.getSalesId())
                 .setOutTradeNo(payOrder.getId())
-                .setPayType(PayTypeEnum.WECHAT.getKey())
+                .setPayType(PayTypeEnum.ALLINPAY.getKey())
                 .setOrderCreateTime(sales.getCreateTime())
                 .setPayValue(sales.getTotalAmount())
                 .setOrgId(payConfig.getOrgId())
                 .setMchNo(payConfig.getMchNo())
                 .setAppid(payConfig.getAppid())
                 .setOrderType(PayOrderTypeEnum.S.getKey())
+                .setRunTime(DateUtil.offsetSecond(DateUtil.date(), 15))
                 .setOrderSource(sales.getGoodsType().equals(WebsitGoodsTypeEnum.M.getKey()) ? OrderSourceEnum.M_SALES.getKey() : OrderSourceEnum.P_SALES.getKey())
                 .setIsDeliver(false);
 
@@ -1245,4 +1246,5 @@ public class WebsitSalesLogic {
 
         return bean;
     }
+
 }