| @@ -266,7 +266,6 @@ public class WxRefundOrderServiceImpl implements WxRefundOrderService { | |||
| } | |||
| final IdWorker idWorker = IdWorker.get(); | |||
| Long refundOrderId = idWorker.nextId(); | |||
| String out_trade_no = String.valueOf(refundOrderId); | |||
| Date currentDate = new Date(); | |||
| @@ -317,10 +316,8 @@ public class WxRefundOrderServiceImpl implements WxRefundOrderService { | |||
| logger.error("db failed: couponOrder-" + couponOrderId + ", e:" + e.getMessage()); | |||
| throw new MallinkException(ErrorCode.DB_FAIL.getCode(), "DB FAILD " + e.getMessage()); | |||
| } | |||
| // 库存回复+1 | |||
| wxOrderService.stockBack(wxOrder); | |||
| // 创建 refundOrder | |||
| // 查找支付订单 | |||
| WxPayOrder payOrderQ = new WxPayOrder(); | |||
| payOrderQ.setTenantId(appInfo.getTenantId()); | |||
| payOrderQ.setCUserId(wxOrder.getCUserId()); | |||
| @@ -352,6 +349,7 @@ public class WxRefundOrderServiceImpl implements WxRefundOrderService { | |||
| record.setTenantId(appInfo.getTenantId()); | |||
| record.setCreateTime(currentDate); | |||
| record.setUpdateTime(currentDate); | |||
| // 微信内部订单号 | |||
| record.setTransactionId(payOrder.getTransactionId()); | |||
| record.setCUserId(payOrder.getCUserId()); | |||
| record.setTotalFee(payOrder.getPayAmount()); | |||
| @@ -392,9 +390,12 @@ public class WxRefundOrderServiceImpl implements WxRefundOrderService { | |||
| wxRefundOrderP.setAppid(appInfo.getAppId()); | |||
| wxRefundOrderP.setMch_id(payAccount.getMchId()); | |||
| wxRefundOrderP.setNonce_str(noncestr); | |||
| // 微信内部订单号 | |||
| if (record.getTransactionId() != null) | |||
| wxRefundOrderP.setTransaction_id(record.getTransactionId()); | |||
| wxRefundOrderP.setOut_trade_no(out_trade_no); | |||
| // 支付订单号 | |||
| wxRefundOrderP.setOut_trade_no(payOrder.getPayOrderNo()); | |||
| // 退款支付订单号 | |||
| wxRefundOrderP.setOut_refund_no(out_refund_id); | |||
| wxRefundOrderP.setTotal_fee(record.getTotalFee()); | |||
| wxRefundOrderP.setRefund_fee(record.getRefundFee()); | |||
| @@ -541,22 +542,22 @@ public class WxRefundOrderServiceImpl implements WxRefundOrderService { | |||
| return XmlUtil.getRequestXml(resultMap); | |||
| } | |||
| String rOrderNo = paramMap.get("out_trade_no"); | |||
| Long rOrderId = Long.valueOf(rOrderNo); | |||
| WxOrder rOrder = wxOrderMapper.selectByPrimaryKey(rOrderId); | |||
| if (rOrder == null) { | |||
| String payOrderNo = paramMap.get("out_trade_no"); | |||
| Long payOrderId = Long.valueOf(payOrderNo); | |||
| WxPayOrder payOrder = wxPayOrderMapper.selectByPrimaryKey(payOrderId); | |||
| if (payOrder == null) { | |||
| logger.warn("notify order, wxpay check pay order not exists, paramMap: "+paramMap.toString()+ ", payWay:" + payWay.toString()); | |||
| SortedMap resultMap = new TreeMap(); | |||
| resultMap.put("return_code", "FAIL"); | |||
| resultMap.put("return_msg", "订单不存在"); | |||
| resultMap.put("return_msg", "支付订单不存在"); | |||
| return XmlUtil.getRequestXml(resultMap); | |||
| } | |||
| // 验证支付金额 | |||
| if(!paramMap.get("total_fee").equals(rOrder.getPayment().toString())) { | |||
| if(!paramMap.get("total_fee").equals(payOrder.getPayAmount().toString())) { | |||
| logger.warn("notify order, wxpay check total_fee is invalid, paramMap: "+paramMap.toString()+ ", payWay:" + payWay.toString()); | |||
| SortedMap resultMap = new TreeMap(); | |||
| resultMap.put("return_code", "FAIL"); | |||
| resultMap.put("return_msg", "订单总金额不一致"); | |||
| resultMap.put("return_msg", "支付订单总金额不一致"); | |||
| return XmlUtil.getRequestXml(resultMap); | |||
| } | |||
| String refundIdStr = paramMap.get("out_refund_no"); | |||
| @@ -649,6 +650,8 @@ public class WxRefundOrderServiceImpl implements WxRefundOrderService { | |||
| logger.error(e.getMessage()); | |||
| throw new MallinkException(ErrorCode.DB_FAIL); | |||
| } | |||
| // 消息 | |||
| /* | |||
| Map<String, String> msgMap = new HashMap<>(); | |||
| try { | |||