Parcourir la source

optimize code

java110 il y a 2 ans
Parent
commit
f703eba54a

+ 10 - 1
java110-interface/src/main/java/com/java110/intf/acct/INotifyPaymentV1InnerServiceSMO.java

@@ -44,5 +44,14 @@ public interface INotifyPaymentV1InnerServiceSMO {
      * @return 小区下的小区楼记录数
      */
     @RequestMapping(value = "/notifyPayment", method = RequestMethod.POST)
-    public ResponseEntity<String> notifyPayment(@RequestBody NotifyPaymentOrderDto notifyPaymentOrderDto);
+    ResponseEntity<String> notifyPayment(@RequestBody NotifyPaymentOrderDto notifyPaymentOrderDto);
+
+    /**
+     * native 支付回调
+     *
+     * @param notifyPaymentOrderDto 数据对象分享
+     * @return 小区下的小区楼记录数
+     */
+    @RequestMapping(value = "/nativeNotifyPayment", method = RequestMethod.POST)
+    ResponseEntity<String> nativeNotifyPayment(@RequestBody NotifyPaymentOrderDto notifyPaymentOrderDto);
 }

+ 5 - 0
java110-utils/src/main/java/com/java110/utils/constant/WechatConstant.java

@@ -61,6 +61,11 @@ public class WechatConstant {
     //支付适配器
     public static final String PAY_ADAPT = "PAY_ADAPT";
     public static final String PAYMENT_ADAPT = "PAYMENT_ADAPT";
+
+    // native 支付
+    public static final String NATIVE_QRCODE_PAYMENT_ADAPT = "NATIVE_QRCODE_PAYMENT_ADAPT";
+
+
     public static final String PAY_QR_ADAPT = "PAY_QR_ADAPT";
     //支付通知适配器
     public static final String PAY_NOTIFY_ADAPT = "PAY_NOTIFY_ADAPT";

+ 120 - 0
service-acct/src/main/java/com/java110/acct/cmd/payment/NativeQrcodePaymentCmd.java

@@ -0,0 +1,120 @@
+package com.java110.acct.cmd.payment;
+
+import com.alibaba.fastjson.JSONObject;
+import com.java110.acct.payment.IPaymentBusiness;
+import com.java110.acct.payment.IPaymentFactoryAdapt;
+import com.java110.acct.smo.IQrCodePaymentSMO;
+import com.java110.core.annotation.Java110Cmd;
+import com.java110.core.context.ICmdDataFlowContext;
+import com.java110.core.event.cmd.Cmd;
+import com.java110.core.event.cmd.CmdEvent;
+import com.java110.core.log.LoggerFactory;
+import com.java110.dto.payment.PaymentOrderDto;
+import com.java110.utils.cache.CommonCache;
+import com.java110.utils.cache.MappingCache;
+import com.java110.utils.constant.MappingConstant;
+import com.java110.utils.constant.WechatConstant;
+import com.java110.utils.exception.CmdException;
+import com.java110.utils.factory.ApplicationContextFactory;
+import com.java110.utils.util.Assert;
+import com.java110.utils.util.StringUtil;
+import org.slf4j.Logger;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+
+import java.text.ParseException;
+import java.util.Map;
+
+/**
+ * native qrcode 支付
+ * add by wuxw 2023-06-25
+ */
+@Java110Cmd(serviceCode = "payment.nativeQrcodePayment")
+public class NativeQrcodePaymentCmd extends Cmd {
+
+
+    private static final Logger logger = LoggerFactory.getLogger(NativeQrcodePaymentCmd.class);
+
+    protected static final String DEFAULT_PAYMENT_ADAPT = "wechatNativeQrcodePaymentFactory";// 默认微信通用支付
+
+
+    @Override
+    public void validate(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException, ParseException {
+        Assert.hasKeyAndValue(reqJson, "business", "未包含业务");
+
+    }
+
+    @Override
+    public void doCmd(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException, ParseException {
+
+        logger.debug(">>>>>>>>>>>>>>>>支付参数报文,{}", reqJson.toJSONString());
+        String appId = context.getReqHeaders().get("app-id");
+        String userId = context.getReqHeaders().get("user-id");
+
+
+        //1.0 查询当前支付的业务
+
+        IPaymentBusiness paymentBusiness = ApplicationContextFactory.getBean(reqJson.getString("business"), IPaymentBusiness.class);
+
+        if (paymentBusiness == null) {
+            throw new CmdException("当前支付业务不支持");
+        }
+
+        //2.0 相应业务 下单 返回 单号 ,金额,
+        PaymentOrderDto paymentOrderDto = paymentBusiness.unified(context, reqJson);
+        paymentOrderDto.setAppId(appId);
+        paymentOrderDto.setUserId(userId);
+
+
+        logger.debug(">>>>>>>>>>>>>>>>支付业务下单返回,{}", JSONObject.toJSONString(paymentOrderDto));
+
+        String env = MappingCache.getValue(MappingConstant.ENV_DOMAIN, "HC_ENV");
+
+        // 这里 演示环境不向微信下单
+//        if ("DEV".equals(env) || "TEST".equals(env)) {
+//            paymentBusiness.notifyPayment(paymentOrderDto, reqJson);
+//            JSONObject param = new JSONObject();
+//            param.put("code", "100");
+//            param.put("msg", "演示环境不触发支付");
+//            context.setResponseEntity(new ResponseEntity(JSONObject.toJSONString(param), HttpStatus.OK));
+//            return;
+//        }
+//
+//        // 3.0 如果支付金额为0 直接调用 支付完通知接口
+//        if (paymentOrderDto.getMoney() <= 0) {
+//            paymentBusiness.notifyPayment(paymentOrderDto, reqJson);
+//            JSONObject param = new JSONObject();
+//            param.put("code", "100");
+//            param.put("msg", "扣费为0回调成功");
+//            context.setResponseEntity(new ResponseEntity(JSONObject.toJSONString(param), HttpStatus.OK));
+//            return;
+//        }
+
+        // 3.0 寻找当前支付适配器
+        String payAdapt = MappingCache.getValue(WechatConstant.WECHAT_DOMAIN, WechatConstant.NATIVE_QRCODE_PAYMENT_ADAPT);
+        payAdapt = StringUtil.isEmpty(payAdapt) ? DEFAULT_PAYMENT_ADAPT : payAdapt;
+
+        if (reqJson.containsKey("payAdapt") && !StringUtil.isEmpty(reqJson.getString("payAdapt"))) {
+            payAdapt = reqJson.getString("payAdapt");
+        }
+
+        IPaymentFactoryAdapt tPayAdapt = ApplicationContextFactory.getBean(payAdapt, IPaymentFactoryAdapt.class);
+
+        // 4.0 相应支付厂家下单
+        Map result = null;
+        try {
+            result = tPayAdapt.java110Payment(paymentOrderDto, reqJson, context);
+        } catch (Exception e) {
+            logger.error("支付异常", e);
+            throw new CmdException(e.getLocalizedMessage());
+        }
+        ResponseEntity<String> responseEntity = new ResponseEntity(JSONObject.toJSONString(result), HttpStatus.OK);
+
+        logger.debug("调用支付厂家返回,{}", responseEntity);
+        context.setResponseEntity(responseEntity);
+
+
+        // redis 中 保存 请求参数
+        CommonCache.setValue("nativeQrcodePayment_" + paymentOrderDto.getOrderId(), reqJson.toJSONString(), CommonCache.PAY_DEFAULT_EXPIRE_TIME);
+    }
+}

+ 1 - 1
service-acct/src/main/java/com/java110/acct/payment/IPaymentFactoryAdapt.java

@@ -17,7 +17,7 @@ public interface IPaymentFactoryAdapt {
 
     /**
      * 支付完成通知
-     * @param param
+     * @param notifyPaymentOrderDto
      * @return
      */
     PaymentOrderDto java110NotifyPayment(NotifyPaymentOrderDto notifyPaymentOrderDto);

+ 284 - 0
service-acct/src/main/java/com/java110/acct/payment/adapt/wechat/WechatNativeQrcodePaymentFactoryAdapt.java

@@ -0,0 +1,284 @@
+package com.java110.acct.payment.adapt.wechat;
+
+import com.alibaba.fastjson.JSONObject;
+import com.java110.acct.payment.IPaymentFactoryAdapt;
+import com.java110.core.context.ICmdDataFlowContext;
+import com.java110.core.factory.GenerateCodeFactory;
+import com.java110.core.factory.WechatFactory;
+import com.java110.core.log.LoggerFactory;
+import com.java110.dto.payment.NotifyPaymentOrderDto;
+import com.java110.dto.payment.PaymentOrderDto;
+import com.java110.dto.wechat.OnlinePayDto;
+import com.java110.dto.wechat.SmallWeChatDto;
+import com.java110.intf.acct.IOnlinePayV1InnerServiceSMO;
+import com.java110.intf.store.ISmallWechatV1InnerServiceSMO;
+import com.java110.intf.user.IOwnerAppUserInnerServiceSMO;
+import com.java110.po.wechat.OnlinePayPo;
+import com.java110.utils.cache.MappingCache;
+import com.java110.utils.cache.UrlCache;
+import com.java110.utils.constant.MappingConstant;
+import com.java110.utils.constant.WechatConstant;
+import com.java110.utils.util.BeanConvertUtil;
+import com.java110.utils.util.PayUtil;
+import org.slf4j.Logger;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.stereotype.Service;
+import org.springframework.web.client.RestTemplate;
+
+import java.util.List;
+import java.util.Map;
+import java.util.SortedMap;
+import java.util.TreeMap;
+
+/**
+ * 微信native支付
+ */
+@Service("wechatNativeQrcodePaymentFactory")
+public class WechatNativeQrcodePaymentFactoryAdapt implements IPaymentFactoryAdapt {
+
+    private static final Logger logger = LoggerFactory.getLogger(WechatNativeQrcodePaymentFactoryAdapt.class);
+
+
+    public static final String wxPayUnifiedOrder = "https://api.mch.weixin.qq.com/pay/unifiedorder";
+
+    //微信支付
+    public static final String DOMAIN_WECHAT_PAY = "WECHAT_PAY";
+    // 微信服务商支付开关
+    public static final String WECHAT_SERVICE_PAY_SWITCH = "WECHAT_SERVICE_PAY_SWITCH";
+
+    //开关ON打开
+    public static final String WECHAT_SERVICE_PAY_SWITCH_ON = "ON";
+
+
+    private static final String WECHAT_SERVICE_APP_ID = "SERVICE_APP_ID";
+
+    private static final String WECHAT_SERVICE_MCH_ID = "SERVICE_MCH_ID";
+
+    public static final String TRADE_TYPE_NATIVE = "NATIVE";
+
+    @Autowired
+    private ISmallWechatV1InnerServiceSMO smallWechatV1InnerServiceSMOImpl;
+
+
+    @Autowired
+    private IOwnerAppUserInnerServiceSMO ownerAppUserInnerServiceSMOImpl;
+
+
+    @Autowired
+    private IOnlinePayV1InnerServiceSMO onlinePayV1InnerServiceSMOImpl;
+
+    @Autowired
+    private RestTemplate outRestTemplate;
+
+    @Override
+    public Map java110Payment(PaymentOrderDto paymentOrderDto, JSONObject reqJson, ICmdDataFlowContext context) throws Exception {
+        SmallWeChatDto smallWeChatDto = getSmallWechat(reqJson);
+
+
+        String appId = context.getReqHeaders().get("app-id");
+        String userId = context.getReqHeaders().get("user-id");
+
+        String notifyUrl = UrlCache.getOwnerUrl() + "/app/payment/notify/nativeWechat/992020011134400001/" + smallWeChatDto.getObjId();
+
+        logger.debug("【小程序支付】 统一下单开始, 订单编号=" + paymentOrderDto.getOrderId());
+        SortedMap<String, String> resultMap = new TreeMap<String, String>();
+        //生成支付金额,开发环境处理支付金额数到0.01、0.02、0.03元
+        double payAmount = PayUtil.getPayAmountByEnv(MappingCache.getValue(MappingConstant.ENV_DOMAIN, "HC_ENV"), paymentOrderDto.getMoney());
+        //添加或更新支付记录(参数跟进自己业务需求添加)
+
+        Map<String, String> resMap = null;
+        resMap = this.java110UnifieldOrder(paymentOrderDto.getName(),
+                paymentOrderDto.getOrderId(),
+                TRADE_TYPE_NATIVE,
+                payAmount,
+                smallWeChatDto,
+                notifyUrl
+        );
+
+        if ("SUCCESS".equals(resMap.get("return_code")) && "SUCCESS".equals(resMap.get("result_code"))) {
+            resultMap.put("prepayId", resMap.get("prepay_id"));
+            resultMap.put("codeUrl", resMap.get("code_url"));
+            resultMap.put("code", "0");
+            resultMap.put("msg", "下单成功");
+            logger.info("【小程序支付】统一下单成功,返回参数:" + resultMap + "===notifyUrl===" + notifyUrl);
+        } else {
+            resultMap.put("code", resMap.get("return_code"));
+            resultMap.put("msg", resMap.get("return_msg"));
+            logger.info("【小程序支付】统一下单失败,失败原因:" + resMap.get("return_msg") + "===code===" + resMap.get("return_code") + "===notifyUrl===" + notifyUrl);
+        }
+        return resultMap;
+    }
+
+    private Map<String, String> java110UnifieldOrder(String feeName, String orderNum,
+                                                     String tradeType, double payAmount,
+                                                     SmallWeChatDto smallWeChatDto, String notifyUrl) throws Exception {
+
+        //String systemName = MappingCache.getValue(WechatConstant.WECHAT_DOMAIN, WechatConstant.PAY_GOOD_NAME);
+
+        if (feeName.length() > 127) {
+            feeName = feeName.substring(0, 126);
+        }
+
+        SortedMap<String, String> paramMap = new TreeMap<String, String>();
+        paramMap.put("appid", smallWeChatDto.getAppId());
+        paramMap.put("mch_id", smallWeChatDto.getMchId());
+        paramMap.put("nonce_str", PayUtil.makeUUID(32));
+        paramMap.put("body", feeName);
+        paramMap.put("out_trade_no", orderNum);
+        paramMap.put("total_fee", PayUtil.moneyToIntegerStr(payAmount));
+        paramMap.put("spbill_create_ip", PayUtil.getLocalIp());
+        paramMap.put("notify_url", notifyUrl + "?wId=" + WechatFactory.getWId(smallWeChatDto.getAppId()));
+        paramMap.put("trade_type", tradeType);
+        String paySwitch = MappingCache.getValue(DOMAIN_WECHAT_PAY, WECHAT_SERVICE_PAY_SWITCH);
+        if (WECHAT_SERVICE_PAY_SWITCH_ON.equals(paySwitch)) {
+            paramMap.put("appid", MappingCache.getValue(DOMAIN_WECHAT_PAY, WECHAT_SERVICE_APP_ID));  //服务商appid,是服务商注册时公众号的id
+            paramMap.put("mch_id", MappingCache.getValue(DOMAIN_WECHAT_PAY, WECHAT_SERVICE_MCH_ID));  //服务商商户号
+            paramMap.put("sub_appid", smallWeChatDto.getAppId());//起调小程序appid
+            paramMap.put("sub_mch_id", smallWeChatDto.getMchId());//起调小程序的商户号
+        }
+        paramMap.put("sign", PayUtil.createSign(paramMap, smallWeChatDto.getPayPassword()));
+//转换为xml
+        String xmlData = PayUtil.mapToXml(paramMap);
+
+        logger.debug("调用支付统一下单接口" + xmlData);
+
+        ResponseEntity<String> responseEntity = outRestTemplate.postForEntity(
+                wxPayUnifiedOrder, xmlData, String.class);
+
+        logger.debug("统一下单返回" + responseEntity);
+//请求微信后台,获取预支付ID
+        if (responseEntity.getStatusCode() != HttpStatus.OK) {
+            throw new IllegalArgumentException("支付失败" + responseEntity.getBody());
+        }
+        doSaveOnlinePay(smallWeChatDto, "无", orderNum, feeName, payAmount, OnlinePayDto.STATE_WAIT, "待支付");
+        return PayUtil.xmlStrToMap(responseEntity.getBody());
+    }
+
+    @Override
+    public PaymentOrderDto java110NotifyPayment(NotifyPaymentOrderDto notifyPaymentOrderDto) {
+        String resXml = "";
+        String param = notifyPaymentOrderDto.getParam();
+        PaymentOrderDto paymentOrderDto = new PaymentOrderDto();
+        try {
+            Map<String, Object> map = PayUtil.getMapFromXML(param);
+            logger.info("【小程序支付回调】 回调数据: \n" + map);
+            String returnCode = (String) map.get("return_code");
+            if ("SUCCESS".equalsIgnoreCase(returnCode)) {
+                String returnmsg = (String) map.get("result_code");
+                if ("SUCCESS".equals(returnmsg)) {
+                    //更新数据
+                    int result = confirmPayFee(map, paymentOrderDto, notifyPaymentOrderDto);
+                    if (result > 0) {
+                        //支付成功
+                        resXml = "<xml>" + "<return_code><![CDATA[SUCCESS]]></return_code>"
+                                + "<return_msg><![CDATA[OK]]></return_msg>" + "</xml>";
+                    }
+                } else {
+                    resXml = "<xml>" + "<return_code><![CDATA[FAIL]]></return_code>"
+                            + "<return_msg><![CDATA[报文为空]></return_msg>" + "</xml>";
+                    logger.info("支付失败:" + resXml);
+                }
+            } else {
+                resXml = "<xml>" + "<return_code><![CDATA[FAIL]]></return_code>"
+                        + "<return_msg><![CDATA[报文为空]></return_msg>" + "</xml>";
+                logger.info("【订单支付失败】");
+            }
+        } catch (Exception e) {
+            logger.error("通知失败", e);
+            resXml = "<xml>" + "<return_code><![CDATA[FAIL]]></return_code>"
+                    + "<return_msg><![CDATA[鉴权失败]></return_msg>" + "</xml>";
+        }
+        paymentOrderDto.setResponseEntity(new ResponseEntity<String>(resXml, HttpStatus.OK));
+        return paymentOrderDto;
+    }
+
+    public int confirmPayFee(Map<String, Object> map, PaymentOrderDto paymentOrderDto, NotifyPaymentOrderDto notifyPaymentOrderDto) {
+        String appId = "";
+        //兼容 港币交易时 或者微信有时不会掉参数的问题
+        if (map.containsKey("wId")) {
+            String wId = map.get("wId").toString();
+            wId = wId.replace(" ", "+");
+            appId = WechatFactory.getAppId(wId);
+        } else {
+            appId = map.get("appid").toString();
+        }
+        SortedMap<String, String> paramMap = new TreeMap<String, String>();
+        ResponseEntity<String> responseEntity = null;
+        for (String key : map.keySet()) {
+            if ("wId".equals(key)) {
+                continue;
+            }
+            paramMap.put(key, map.get(key).toString());
+        }
+        //String appId = WechatFactory.getAppId(wId);
+        JSONObject paramIn = new JSONObject();
+        paramIn.put("appId", appId);
+        paramIn.put("communityId", notifyPaymentOrderDto.getCommunityId());
+        SmallWeChatDto smallWeChatDto = getSmallWechat(paramIn);
+
+        String sign = PayUtil.createSign(paramMap, smallWeChatDto.getPayPassword());
+
+        if (!sign.equals(map.get("sign"))) {
+            throw new IllegalArgumentException("鉴权失败");
+        }
+
+        String outTradeNo = map.get("out_trade_no").toString();
+        paymentOrderDto.setOrderId(outTradeNo);
+        paymentOrderDto.setTransactionId(map.get("transaction_id").toString());
+
+        doUpdateOnlinePay(outTradeNo, OnlinePayDto.STATE_COMPILE, "支付成功");
+        return 1;
+    }
+
+
+    private SmallWeChatDto getSmallWechat(JSONObject paramIn) {
+
+        SmallWeChatDto smallWeChatDto = new SmallWeChatDto();
+        smallWeChatDto.setObjId(paramIn.getString("communityId"));
+        smallWeChatDto.setAppId(paramIn.getString("appId"));
+        smallWeChatDto.setPage(1);
+        smallWeChatDto.setRow(1);
+        List<SmallWeChatDto> smallWeChatDtos = smallWechatV1InnerServiceSMOImpl.querySmallWechats(smallWeChatDto);
+
+        if (smallWeChatDtos == null || smallWeChatDtos.size() < 1) {
+            smallWeChatDto = new SmallWeChatDto();
+            smallWeChatDto.setAppId(MappingCache.getValue(WechatConstant.WECHAT_DOMAIN, "appId"));
+            smallWeChatDto.setAppSecret(MappingCache.getValue(WechatConstant.WECHAT_DOMAIN, "appSecret"));
+            smallWeChatDto.setMchId(MappingCache.getValue(MappingConstant.WECHAT_STORE_DOMAIN, "mchId"));
+            smallWeChatDto.setPayPassword(MappingCache.getValue(MappingConstant.WECHAT_STORE_DOMAIN, "key"));
+            smallWeChatDto.setObjId(paramIn.getString("communityId"));
+
+            return smallWeChatDto;
+        }
+
+        return BeanConvertUtil.covertBean(smallWeChatDtos.get(0), SmallWeChatDto.class);
+    }
+
+
+    private void doSaveOnlinePay(SmallWeChatDto smallWeChatDto, String openId, String orderId, String feeName, double money, String state, String message) {
+        OnlinePayPo onlinePayPo = new OnlinePayPo();
+        onlinePayPo.setAppId(smallWeChatDto.getAppId());
+        onlinePayPo.setMchId(smallWeChatDto.getMchId());
+        onlinePayPo.setMessage(message.length() > 1000 ? message.substring(0, 1000) : message);
+        onlinePayPo.setOpenId(openId);
+        onlinePayPo.setOrderId(orderId);
+        onlinePayPo.setPayId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_orderId));
+        onlinePayPo.setPayName(feeName);
+        onlinePayPo.setRefundFee("0");
+        onlinePayPo.setState(state);
+        onlinePayPo.setTotalFee(money + "");
+        onlinePayPo.setTransactionId(orderId);
+        onlinePayV1InnerServiceSMOImpl.saveOnlinePay(onlinePayPo);
+    }
+
+    private void doUpdateOnlinePay(String orderId, String state, String message) {
+        OnlinePayPo onlinePayPo = new OnlinePayPo();
+        onlinePayPo.setMessage(message.length() > 1000 ? message.substring(0, 1000) : message);
+        onlinePayPo.setOrderId(orderId);
+        onlinePayPo.setState(state);
+        onlinePayV1InnerServiceSMOImpl.updateOnlinePay(onlinePayPo);
+    }
+
+}

+ 43 - 2
service-acct/src/main/java/com/java110/acct/smo/impl/NotifyPaymentV1InnerServiceSMOImpl.java

@@ -50,6 +50,8 @@ public class NotifyPaymentV1InnerServiceSMOImpl extends BaseServiceSMO implement
 
     private static final String DEFAULT_PAYMENT_NOTIFY_ADAPT = "wechatPaymentFactory";// 默认微信通用支付
 
+    protected static final String DEFAULT_NATIVE_QRCODE_PAYMENT_ADAPT = "wechatNativeQrcodePaymentFactory";// 默认微信通用支付
+
     /**
      * 通知类
      *
@@ -89,8 +91,47 @@ public class NotifyPaymentV1InnerServiceSMOImpl extends BaseServiceSMO implement
 
 
             return paymentOrderDto.getResponseEntity();
-        }catch (Exception e){
-            logger.error("通知是配置异常",e);
+        } catch (Exception e) {
+            logger.error("通知是配置异常", e);
+            throw e;
+        }
+    }
+
+    @Override
+    public ResponseEntity<String> nativeNotifyPayment(@RequestBody NotifyPaymentOrderDto notifyPaymentOrderDto) {
+
+        try {
+            String payNotifyAdapt = MappingCache.getValue(WechatConstant.WECHAT_DOMAIN, WechatConstant.NATIVE_QRCODE_PAYMENT_ADAPT);
+            payNotifyAdapt = StringUtil.isEmpty(payNotifyAdapt) ? DEFAULT_NATIVE_QRCODE_PAYMENT_ADAPT : payNotifyAdapt;
+            //支付适配器IPayNotifyAdapt
+            logger.debug("适配器:" + payNotifyAdapt);
+            IPaymentFactoryAdapt tPayNotifyAdapt = ApplicationContextFactory.getBean(payNotifyAdapt, IPaymentFactoryAdapt.class);
+            PaymentOrderDto paymentOrderDto = tPayNotifyAdapt.java110NotifyPayment(notifyPaymentOrderDto);
+            logger.info("【支付回调响应】 响应内容:\n" + paymentOrderDto.getResponseEntity());
+
+            if (StringUtil.isEmpty(paymentOrderDto.getOrderId())) {
+                return paymentOrderDto.getResponseEntity();
+            }
+
+            String paramIn = CommonCache.getAndRemoveValue("nativeQrcodePayment_" + paymentOrderDto.getOrderId());
+
+            JSONObject reqJson = JSONObject.parseObject(paramIn);
+
+            IPaymentBusiness paymentBusiness = ApplicationContextFactory.getBean(reqJson.getString("business"), IPaymentBusiness.class);
+
+            if (paymentBusiness == null) {
+                throw new CmdException("当前支付业务不支持");
+            }
+
+            paymentOrderDto.setAppId(notifyPaymentOrderDto.getAppId());
+
+            //2.0 相应业务 下单 返回 单号 ,金额,
+            paymentBusiness.notifyPayment(paymentOrderDto, reqJson);
+
+
+            return paymentOrderDto.getResponseEntity();
+        } catch (Exception e) {
+            logger.error("通知是配置异常", e);
             throw e;
         }
     }

+ 15 - 0
service-api/src/main/java/com/java110/api/controller/app/payment/wechat/WechatNotifyPaymentController.java

@@ -34,4 +34,19 @@ public class WechatNotifyPaymentController {
         return notifyPaymentV1InnerServiceSMOImpl.notifyPayment(new NotifyPaymentOrderDto(appId,postInfo,communityId));
 
     }
+
+    /**
+     * <p>支付回调Api</p>
+     *
+     * @param request
+     * @throws Exception
+     */
+    @RequestMapping(path = "/nativeWechat/{appId}/{communityId}", method = RequestMethod.POST)
+    public ResponseEntity<String> nativeNotify(@RequestBody String postInfo, @PathVariable String appId,@PathVariable String communityId, HttpServletRequest request) {
+
+        logger.debug("微信支付回调报文" + postInfo);
+
+        return notifyPaymentV1InnerServiceSMOImpl.nativeNotifyPayment(new NotifyPaymentOrderDto(appId,postInfo,communityId));
+
+    }
 }