| @@ -461,7 +461,6 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { | |||
| String openId = returnMap.get("openid"); | |||
| String isSubscribe = returnMap.get("is_subscribe"); | |||
| String transactionId = returnMap.get("transaction_id"); | |||
| record.setPayOrderStatus(EnumPayStatus.PAY_STATUS_SUCCESS.getCode()); | |||
| record.setTransactionId(transactionId); | |||
| record.setUpdateTime(new Date()); | |||
| handleMicroOrderPaySuccess(record, transactionId, openId, isSubscribe); | |||
| @@ -533,7 +532,6 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { | |||
| String openId = returnMap.get("openid"); | |||
| String isSubscribe = returnMap.get("is_subscribe"); | |||
| String transactionId = returnMap.get("transaction_id"); | |||
| record.setPayOrderStatus(EnumPayStatus.PAY_STATUS_SUCCESS.getCode()); | |||
| record.setTransactionId(transactionId); | |||
| record.setUpdateTime(new Date()); | |||
| handleMicroOrderPaySuccess(record, transactionId, openId, isSubscribe); | |||
| @@ -669,9 +667,15 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { | |||
| //USERPAYING--用户支付中 | |||
| //PAYERROR--支付失败(其他原因,如银行返回失败) | |||
| if ("SUCCESS".equals(trade_state)) { | |||
| String openId = returnMap.get("sub_openid"); | |||
| String sub_is_subscribe = returnMap.get("sub_is_subscribe"); | |||
| String transactionId = returnMap.get("transaction_id"); | |||
| record.setPayOrderStatus(EnumPayStatus.PAY_STATUS_SUCCESS.getCode()); | |||
| handleOrderPaySuccess(record, transactionId); | |||
| String tradeType = returnMap.get("trade_type"); | |||
| if ("MICROPAY".equals(tradeType)) { | |||
| handleMicroOrderPaySuccess(record, transactionId, openId, sub_is_subscribe); | |||
| } else { | |||
| handleOrderPaySuccess(record, transactionId); | |||
| } | |||
| return new ResultData(Result.SUCCESS, "订单支付成功", returnMap); | |||
| } else if ("REFUND".equals(trade_state)) { | |||
| record.setPayOrderStatus(EnumPayStatus.PAY_STATUS_REFUND.getCode()); | |||
| @@ -1180,12 +1184,21 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { | |||
| return; | |||
| } | |||
| WxOrder order = wxOrderMapper.selectByPrimaryKey(record.getOrderId()); | |||
| if (order == null) { | |||
| logger.error("pay success handle, order " + record.getOrderId() + " not found , payOrderid : " + record.getPayOrderNo()); | |||
| throw new MallinkException(ErrorCode.ORDER_IS_NOT_FIND); | |||
| } | |||
| WxAppinfo appinfo = getWxAppinfo(order.getType(), order.getTenantId()); | |||
| // add c_user | |||
| Date curDate = new Date(); | |||
| WxCUser userQ = new WxCUser(); | |||
| userQ.setOpenId(openId); | |||
| userQ.setCreateDate(curDate); | |||
| userQ.setUpdateDate(curDate); | |||
| userQ.setAppId(appinfo.getAppId()); | |||
| WxCUser user1 = wxCUserMapper.findByOpenId(userQ); | |||
| if(user1 == null) { | |||
| final IdWorker idWorker = IdWorker.get(); | |||
| @@ -1195,12 +1208,6 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { | |||
| userQ.setId(user1.getId()); | |||
| } | |||
| WxOrder order = wxOrderMapper.selectByPrimaryKey(record.getOrderId()); | |||
| if (order == null) { | |||
| logger.error("pay success handle, order " + record.getOrderId() + " not found , payOrderid : " + record.getPayOrderNo()); | |||
| throw new MallinkException(ErrorCode.ORDER_IS_NOT_FIND); | |||
| } | |||
| // 修改支付订单状态 | |||
| WxPayOrder updateOrder = new WxPayOrder(); | |||
| updateOrder.setId(record.getId()); | |||
| @@ -1274,21 +1281,7 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { | |||
| Date currentDate = new Date(); | |||
| if (record.getId() > 0) { | |||
| // 1. get appinfo | |||
| WxAppinfo appInfo = null; | |||
| WxAppinfo appinfoQ = new WxAppinfo(); | |||
| appinfoQ.setTenantId(order.getTenantId()); | |||
| if(order.getType().equals(EnumOrderType.COUPON.getCode())) { | |||
| appinfoQ.setType(EnumAppType.C.getCode()); | |||
| } else if(order.getType().equals(EnumOrderType.MICROPAY.getCode())) { | |||
| appinfoQ.setType(EnumAppType.B.getCode()); | |||
| } else { | |||
| appinfoQ.setType(EnumAppType.C.getCode()); | |||
| } | |||
| List<WxAppinfo> appList = wxAppinfoMapper.select(appinfoQ); | |||
| if (appList.size() > 0) { | |||
| appInfo = appList.get(0); | |||
| } | |||
| WxAppinfo appInfo = getWxAppinfo(order.getType(), order.getTenantId()); | |||
| WxPayOrder updateOrder = null; | |||
| @@ -1402,6 +1395,25 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { | |||
| */ | |||
| } | |||
| private WxAppinfo getWxAppinfo(Integer orderType, String tenentId) { | |||
| WxAppinfo appInfo = null; | |||
| WxAppinfo appinfoQ = new WxAppinfo(); | |||
| appinfoQ.setTenantId(tenentId); | |||
| if(orderType.equals(EnumOrderType.COUPON.getCode())) { | |||
| appinfoQ.setType(EnumAppType.C.getCode()); | |||
| } else if(orderType.equals(EnumOrderType.MICROPAY.getCode())) { | |||
| appinfoQ.setType(EnumAppType.B.getCode()); | |||
| } else { | |||
| appinfoQ.setType(EnumAppType.C.getCode()); | |||
| } | |||
| List<WxAppinfo> appList = wxAppinfoMapper.select(appinfoQ); | |||
| if (appList.size() > 0) { | |||
| appInfo = appList.get(0); | |||
| } | |||
| return appInfo; | |||
| } | |||
| @Override | |||
| public PageInfo<WxPayOrder> listAsPage(WxPayOrder record, Integer pageIndex, Integer pageSize) { | |||