| @@ -260,7 +260,7 @@ public class WxBillController extends BaseController { | |||
| } | |||
| try { | |||
| Object result = payBillServiceFactory.getPayAdapterService(wxPayAccountBill.getPayChannel()) | |||
| .createPay(wxPayAccountBill,billdetail,Double.parseDouble(payMoney), paramMap); | |||
| .createPay(wxPayAccountBill,this.getLoginBUser(),billdetail,Double.parseDouble(payMoney), paramMap); | |||
| if (null == result) { | |||
| return new ResultData(Result.ERROR,"账单支付错误,请联系管理员"); | |||
| } | |||
| @@ -2,14 +2,24 @@ package com.iformall.controller.callback; | |||
| import com.alibaba.fastjson.JSON; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.domain.po.msg.FmInsideNotifyBillPaidSuccessMsg; | |||
| import com.iformall.domain.po.msg.FmInsideNotifyCarPaidSuccessMsg; | |||
| import com.iformall.enums.EnumBillPayChannel; | |||
| import com.iformall.enums.EnumBillPayWay; | |||
| import com.iformall.enums.EnumMsgMqKey; | |||
| import com.iformall.enums.EnumMsgMqTag; | |||
| import com.iformall.enums.EnumMsgMqTopic; | |||
| import com.iformall.enums.EnumMsgRecordType; | |||
| import com.iformall.enums.EnumPayVersion; | |||
| import com.iformall.enums.EnumPayWay; | |||
| import com.iformall.exception.BizException; | |||
| import com.iformall.exception.MallinkException; | |||
| import com.iformall.mq.MqBaseProducer; | |||
| import com.iformall.pay.WxPayment; | |||
| import com.iformall.service.MailService; | |||
| import com.iformall.service.WxPayBillService; | |||
| import com.iformall.service.WxRefundOrderService; | |||
| import com.iformall.service.msg.impl.FmInsideNotifyBillPaidSuccessMsgServiceImpl; | |||
| import com.iformall.utils.DateUtils; | |||
| import com.iformall.utils.XmlUtil; | |||
| import org.apache.commons.io.IOUtils; | |||
| @@ -18,6 +28,7 @@ import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.http.MediaType; | |||
| import org.springframework.web.bind.annotation.PathVariable; | |||
| import org.springframework.web.bind.annotation.RequestMapping; | |||
| import org.springframework.web.bind.annotation.ResponseBody; | |||
| import org.springframework.web.bind.annotation.RestController; | |||
| @@ -52,153 +63,54 @@ public class WxPayBillController extends BaseController { | |||
| @Autowired | |||
| private WxRefundOrderService wxRefundOrderService; | |||
| /** | |||
| * | |||
| * @return 接收微信异步通知 | |||
| * @throws Exception 可能产生的任何异常 | |||
| */ | |||
| @RequestMapping(value = "/pay", produces = MediaType.APPLICATION_JSON_UTF8_VALUE) | |||
| @ResponseBody | |||
| public String _payNotify(HttpServletRequest request) throws IOException, JDOMException { | |||
| logger.info("[" +getIpAddr() + "]微信支付回调Bill"); | |||
| InputStream inStream = request.getInputStream(); | |||
| ByteArrayOutputStream outSteam = new ByteArrayOutputStream(); | |||
| byte[] buffer = new byte[1024]; | |||
| int len = 0; | |||
| while ((len = inStream.read(buffer)) != -1) { | |||
| outSteam.write(buffer, 0, len); | |||
| } | |||
| String resultxml = new String(outSteam.toByteArray(), Charset.forName("UTF-8")); | |||
| logger.info(resultxml); | |||
| outSteam.close(); | |||
| inStream.close(); | |||
| Map<String, String> paramMap = null; | |||
| try { | |||
| paramMap = WxPayment.xmlToMap(resultxml); | |||
| logger.info("微信支付回调, notify, param: " + paramMap.toString() ); | |||
| String attach = paramMap.get("attach"); | |||
| String response = wxPayBillService.notify(getTenantId(attach),paramMap, EnumPayWay.PAY_WAY_WECHAT); | |||
| logger.info("微信支付回调, notify success, req : " + resultxml + ", resp: " + response.toString()); | |||
| return response; | |||
| } catch (BizException e) { | |||
| if (paramMap == null) { | |||
| logger.error("微信支付回调, order create error, e: " + e.getMessage()); | |||
| } else { | |||
| logger.error("微信支付回调, order create error, req: " + resultxml + ", e: " + e.getMessage()); | |||
| } | |||
| SortedMap resultMap = new TreeMap<>(); | |||
| resultMap.put("return_code", "FAIL"); | |||
| resultMap.put("return_msg", e.getMessage()); | |||
| return XmlUtil.getRequestXml(resultMap); | |||
| } catch (MallinkException e) { | |||
| if (paramMap == null) { | |||
| logger.error("微信支付回调, order create error, e: " + e.getMessage()); | |||
| } else { | |||
| logger.error("微信支付回调, order create error, req: " + resultxml + ", e: " + e.getMessage()); | |||
| } | |||
| SortedMap resultMap = new TreeMap<>(); | |||
| resultMap.put("return_code", "FAIL"); | |||
| resultMap.put("return_msg", e.getMessage()); | |||
| return XmlUtil.getRequestXml(resultMap); | |||
| } catch (Exception e) { | |||
| if (paramMap == null) { | |||
| logger.error("微信支付回调, order create error, e: " + e.getMessage()); | |||
| } else { | |||
| logger.error("微信支付回调, order create error, req: " + resultxml + ", e: " + e.getMessage()); | |||
| } | |||
| SortedMap resultMap = new TreeMap(); | |||
| resultMap.put("return_code", "FAIL"); | |||
| resultMap.put("return_msg", e.getMessage()); | |||
| return XmlUtil.getRequestXml(resultMap); | |||
| } | |||
| } | |||
| /** | |||
| * | |||
| * @return 接收微信退款异步通知 | |||
| * @throws Exception 可能产生的任何异常 | |||
| */ | |||
| @RequestMapping(value = "/refund") | |||
| public String __refundNotify(HttpServletRequest request) throws Exception { | |||
| logger.info("[" +getIpAddr() + "]微信退款回调Bill"); | |||
| @Autowired | |||
| private MqBaseProducer mqBaseProducer; | |||
| @Autowired | |||
| private FmInsideNotifyBillPaidSuccessMsgServiceImpl fmInsideNotifyBillPaidSuccessMsgServiceImpl; | |||
| @RequestMapping(value = "/wx/paid/{tenantId}") | |||
| public String parkInCallback(@PathVariable String tenantId,HttpServletRequest request) { | |||
| Map<String, String> paramMap = null; | |||
| String response = ""; | |||
| String xml = ""; | |||
| try { | |||
| xml = IOUtils.toString(request.getInputStream(), Charset.forName("UTF-8")); | |||
| logger.info(xml); | |||
| paramMap = WxPayment.xmlToMap(xml); | |||
| paramMap.put("tenantId", tenantId); | |||
| String jsonMsg = JSON.toJSONString(paramMap); | |||
| response = wxRefundOrderService.notify(paramMap, EnumPayWay.PAY_WAY_WECHAT,EnumPayVersion.WX_PAY_V2); | |||
| logger.info("refund wxpay, notify success, req : " + xml + ", resp: " + response.toString()); | |||
| return response; | |||
| } catch (BizException e) { | |||
| logger.error("refund wxpay, notify error, req: " + xml + ", e:" + e.getLocalizedMessage()); | |||
| SortedMap resultMap = new TreeMap(); | |||
| resultMap.put("return_code", "FAIL"); | |||
| resultMap.put("return_msg", e.getMessage()); | |||
| return XmlUtil.getRequestXml(resultMap); | |||
| } catch (MallinkException e) { | |||
| logger.error("refund wxpay, notify error, req: " + xml + ", e:" +e.getLocalizedMessage()); | |||
| SortedMap resultMap = new TreeMap(); | |||
| resultMap.put("return_code", "FAIL"); | |||
| resultMap.put("return_msg", e.getMessage()); | |||
| FmInsideNotifyBillPaidSuccessMsg refundSuccessMsg = new FmInsideNotifyBillPaidSuccessMsg(); | |||
| refundSuccessMsg.setTenantId(tenantId); | |||
| refundSuccessMsg.setMsgType(EnumMsgRecordType.BILL_PAID.getCode()); | |||
| refundSuccessMsg.setDelayTimeLevel(3); | |||
| refundSuccessMsg.setPayChannel(EnumBillPayChannel.WX_MINI_PROGRAM.getCode()); | |||
| refundSuccessMsg.setPayWay(EnumBillPayWay.WECHAT_PAY.getCode()); | |||
| refundSuccessMsg.setJsonMsg(jsonMsg); | |||
| //mqBaseProducer.sendMessage(refundSuccessMsg, EnumMsgMqTopic.DEFAULT.getCode(), EnumMsgMqTag.DEFAULT.getCode(), EnumMsgMqKey.DEFAULT.getCode()); | |||
| fmInsideNotifyBillPaidSuccessMsgServiceImpl.send(refundSuccessMsg); | |||
| logger.info("billPaid wxpay, notify success, req : " + xml + ", resp: " + response.toString()); | |||
| SortedMap resultMap = new TreeMap(); | |||
| resultMap.put("return_code", "SUCCESS"); | |||
| resultMap.put("return_msg", "OK"); | |||
| return XmlUtil.getRequestXml(resultMap); | |||
| } catch (Exception e) { | |||
| logger.error("refund wxpay, order create error, req: " + xml + ", e: " + e.getMessage()); | |||
| SortedMap resultMap = new TreeMap(); | |||
| resultMap.put("return_code", "FAIL"); | |||
| resultMap.put("return_msg", e.getMessage()); | |||
| return XmlUtil.getRequestXml(resultMap); | |||
| } | |||
| } | |||
| /** | |||
| * | |||
| * @return 接收微信分账异步通知 | |||
| * @throws Exception 可能产生的任何异常 | |||
| */ | |||
| @RequestMapping(value = "/sharing") | |||
| public String __shareNotify(HttpServletRequest request) throws Exception { | |||
| logger.info("[" +getIpAddr() + "]微信分账回调Bill"); | |||
| Map<String, String> paramMap = null; | |||
| String response = ""; | |||
| String xml = ""; | |||
| try { | |||
| xml = IOUtils.toString(request.getInputStream(), Charset.forName("UTF-8")); | |||
| paramMap = WxPayment.xmlToMap(xml); | |||
| logger.info("share wxpay, notify, param: " + xml ); | |||
| //发邮件 | |||
| String[] receivers = fmExceptionEmails.split(","); | |||
| StringBuilder sb = new StringBuilder(); | |||
| sb.append(DateUtils.date2String(new Date())); | |||
| sb.append("\n"); | |||
| sb.append("分账回调 :WxPayBillController"); | |||
| sb.append("\n"); | |||
| sb.append(JSON.toJSONString(paramMap)); | |||
| //发送邮件 | |||
| mailService.sendSimpleMail(receivers, "排查回调位置", sb.toString()); | |||
| // response = wxPayBillService.notify(paramMap, EnumPayWay.PAY_WAY_WECHAT); | |||
| logger.info("share wxpay, notify success, req : " + xml + ", resp: " + response.toString()); | |||
| return response; | |||
| } catch (BizException e) { | |||
| logger.error("share wxpay, notify error, req: " + xml + ", e:" + e.getLocalizedMessage()); | |||
| logger.error("billPaid wxpay, notify error, req: " + xml + ", e:" + e.getLocalizedMessage()); | |||
| SortedMap resultMap = new TreeMap(); | |||
| resultMap.put("return_code", "FAIL"); | |||
| resultMap.put("return_msg", e.getMessage()); | |||
| return XmlUtil.getRequestXml(resultMap); | |||
| } catch (MallinkException e) { | |||
| logger.error("refund wxpay, notify error, req: " + xml + ", e:" +e.getLocalizedMessage()); | |||
| logger.error("billPaid wxpay, notify error, req: " + xml + ", e:" +e.getLocalizedMessage()); | |||
| SortedMap resultMap = new TreeMap(); | |||
| resultMap.put("return_code", "FAIL"); | |||
| resultMap.put("return_msg", e.getMessage()); | |||
| return XmlUtil.getRequestXml(resultMap); | |||
| } catch (Exception e) { | |||
| logger.error("refund wxpay, order create error, req: " + xml + ", e: " + e.getMessage()); | |||
| logger.error("billPaid wxpay, notify error, req: " + xml + ", e: " + e.getMessage()); | |||
| SortedMap resultMap = new TreeMap(); | |||
| resultMap.put("return_code", "FAIL"); | |||
| resultMap.put("return_msg", e.getMessage()); | |||
| @@ -206,4 +118,160 @@ public class WxPayBillController extends BaseController { | |||
| } | |||
| } | |||
| // /** | |||
| // * | |||
| // * @return 接收微信异步通知 | |||
| // * @throws Exception 可能产生的任何异常 | |||
| // */ | |||
| // @RequestMapping(value = "/wxMiniProgram/pay/{tenantId}", produces = MediaType.APPLICATION_JSON_UTF8_VALUE) | |||
| // @ResponseBody | |||
| // public String wxPaidNotify(@PathVariable String tenantId,HttpServletRequest request) throws IOException, JDOMException { | |||
| // logger.info("[" +getIpAddr() + "]微信支付回调Bill"); | |||
| // InputStream inStream = request.getInputStream(); | |||
| // ByteArrayOutputStream outSteam = new ByteArrayOutputStream(); | |||
| // byte[] buffer = new byte[1024]; | |||
| // int len = 0; | |||
| // while ((len = inStream.read(buffer)) != -1) { | |||
| // outSteam.write(buffer, 0, len); | |||
| // } | |||
| // String resultxml = new String(outSteam.toByteArray(), Charset.forName("UTF-8")); | |||
| // logger.info(resultxml); | |||
| // | |||
| // outSteam.close(); | |||
| // inStream.close(); | |||
| // | |||
| // Map<String, String> paramMap = null; | |||
| // | |||
| // try { | |||
| // paramMap = WxPayment.xmlToMap(resultxml); | |||
| // logger.info("微信支付回调, notify, param: " + paramMap.toString() ); | |||
| // String attach = paramMap.get("attach"); | |||
| // String response = wxPayBillService.notify(getTenantId(attach),paramMap, EnumPayWay.PAY_WAY_WECHAT); | |||
| // logger.info("微信支付回调, notify success, req : " + resultxml + ", resp: " + response.toString()); | |||
| // return response; | |||
| // } catch (BizException e) { | |||
| // if (paramMap == null) { | |||
| // logger.error("微信支付回调, order create error, e: " + e.getMessage()); | |||
| // } else { | |||
| // logger.error("微信支付回调, order create error, req: " + resultxml + ", e: " + e.getMessage()); | |||
| // } | |||
| // SortedMap resultMap = new TreeMap<>(); | |||
| // resultMap.put("return_code", "FAIL"); | |||
| // resultMap.put("return_msg", e.getMessage()); | |||
| // return XmlUtil.getRequestXml(resultMap); | |||
| // } catch (MallinkException e) { | |||
| // if (paramMap == null) { | |||
| // logger.error("微信支付回调, order create error, e: " + e.getMessage()); | |||
| // } else { | |||
| // logger.error("微信支付回调, order create error, req: " + resultxml + ", e: " + e.getMessage()); | |||
| // } | |||
| // SortedMap resultMap = new TreeMap<>(); | |||
| // resultMap.put("return_code", "FAIL"); | |||
| // resultMap.put("return_msg", e.getMessage()); | |||
| // return XmlUtil.getRequestXml(resultMap); | |||
| // } catch (Exception e) { | |||
| // if (paramMap == null) { | |||
| // logger.error("微信支付回调, order create error, e: " + e.getMessage()); | |||
| // } else { | |||
| // logger.error("微信支付回调, order create error, req: " + resultxml + ", e: " + e.getMessage()); | |||
| // } | |||
| // SortedMap resultMap = new TreeMap(); | |||
| // resultMap.put("return_code", "FAIL"); | |||
| // resultMap.put("return_msg", e.getMessage()); | |||
| // return XmlUtil.getRequestXml(resultMap); | |||
| // } | |||
| // } | |||
| // /** | |||
| // * | |||
| // * @return 接收微信退款异步通知 | |||
| // * @throws Exception 可能产生的任何异常 | |||
| // */ | |||
| // @RequestMapping(value = "/refund") | |||
| // public String __refundNotify(HttpServletRequest request) throws Exception { | |||
| // logger.info("[" +getIpAddr() + "]微信退款回调Bill"); | |||
| // Map<String, String> paramMap = null; | |||
| // String response = ""; | |||
| // String xml = ""; | |||
| // try { | |||
| // xml = IOUtils.toString(request.getInputStream(), Charset.forName("UTF-8")); | |||
| // logger.info(xml); | |||
| // paramMap = WxPayment.xmlToMap(xml); | |||
| // | |||
| // response = wxRefundOrderService.notify(paramMap, EnumPayWay.PAY_WAY_WECHAT,EnumPayVersion.WX_PAY_V2); | |||
| // logger.info("refund wxpay, notify success, req : " + xml + ", resp: " + response.toString()); | |||
| // return response; | |||
| // } catch (BizException e) { | |||
| // logger.error("refund wxpay, notify error, req: " + xml + ", e:" + e.getLocalizedMessage()); | |||
| // SortedMap resultMap = new TreeMap(); | |||
| // resultMap.put("return_code", "FAIL"); | |||
| // resultMap.put("return_msg", e.getMessage()); | |||
| // return XmlUtil.getRequestXml(resultMap); | |||
| // } catch (MallinkException e) { | |||
| // logger.error("refund wxpay, notify error, req: " + xml + ", e:" +e.getLocalizedMessage()); | |||
| // SortedMap resultMap = new TreeMap(); | |||
| // resultMap.put("return_code", "FAIL"); | |||
| // resultMap.put("return_msg", e.getMessage()); | |||
| // return XmlUtil.getRequestXml(resultMap); | |||
| // } catch (Exception e) { | |||
| // logger.error("refund wxpay, order create error, req: " + xml + ", e: " + e.getMessage()); | |||
| // SortedMap resultMap = new TreeMap(); | |||
| // resultMap.put("return_code", "FAIL"); | |||
| // resultMap.put("return_msg", e.getMessage()); | |||
| // return XmlUtil.getRequestXml(resultMap); | |||
| // } | |||
| // } | |||
| // | |||
| // /** | |||
| // * | |||
| // * @return 接收微信分账异步通知 | |||
| // * @throws Exception 可能产生的任何异常 | |||
| // */ | |||
| // @RequestMapping(value = "/sharing") | |||
| // public String __shareNotify(HttpServletRequest request) throws Exception { | |||
| // logger.info("[" +getIpAddr() + "]微信分账回调Bill"); | |||
| // Map<String, String> paramMap = null; | |||
| // String response = ""; | |||
| // String xml = ""; | |||
| // try { | |||
| // xml = IOUtils.toString(request.getInputStream(), Charset.forName("UTF-8")); | |||
| // paramMap = WxPayment.xmlToMap(xml); | |||
| // logger.info("share wxpay, notify, param: " + xml ); | |||
| // //发邮件 | |||
| // String[] receivers = fmExceptionEmails.split(","); | |||
| // StringBuilder sb = new StringBuilder(); | |||
| // sb.append(DateUtils.date2String(new Date())); | |||
| // sb.append("\n"); | |||
| // sb.append("分账回调 :WxPayBillController"); | |||
| // sb.append("\n"); | |||
| // sb.append(JSON.toJSONString(paramMap)); | |||
| // //发送邮件 | |||
| // mailService.sendSimpleMail(receivers, "排查回调位置", sb.toString()); | |||
| //// response = wxPayBillService.notify(paramMap, EnumPayWay.PAY_WAY_WECHAT); | |||
| // logger.info("share wxpay, notify success, req : " + xml + ", resp: " + response.toString()); | |||
| // return response; | |||
| // } catch (BizException e) { | |||
| // logger.error("share wxpay, notify error, req: " + xml + ", e:" + e.getLocalizedMessage()); | |||
| // SortedMap resultMap = new TreeMap(); | |||
| // resultMap.put("return_code", "FAIL"); | |||
| // resultMap.put("return_msg", e.getMessage()); | |||
| // return XmlUtil.getRequestXml(resultMap); | |||
| // } catch (MallinkException e) { | |||
| // logger.error("refund wxpay, notify error, req: " + xml + ", e:" +e.getLocalizedMessage()); | |||
| // SortedMap resultMap = new TreeMap(); | |||
| // resultMap.put("return_code", "FAIL"); | |||
| // resultMap.put("return_msg", e.getMessage()); | |||
| // return XmlUtil.getRequestXml(resultMap); | |||
| // } catch (Exception e) { | |||
| // logger.error("refund wxpay, order create error, req: " + xml + ", e: " + e.getMessage()); | |||
| // SortedMap resultMap = new TreeMap(); | |||
| // resultMap.put("return_code", "FAIL"); | |||
| // resultMap.put("return_msg", e.getMessage()); | |||
| // return XmlUtil.getRequestXml(resultMap); | |||
| // } | |||
| // } | |||
| } | |||
| @@ -2,6 +2,7 @@ package com.iformall.controller.callback.car.pay; | |||
| import com.alibaba.fastjson.JSON; | |||
| import com.iformall.controller.callback.car.WxParkCallBackBaseController; | |||
| import com.iformall.domain.po.msg.FmInsideNotifyBillPaidSuccessMsg; | |||
| import com.iformall.domain.po.msg.FmInsideNotifyCarPaidSuccessMsg; | |||
| import com.iformall.enums.*; | |||
| import com.iformall.exception.BizException; | |||
| @@ -9,6 +10,7 @@ import com.iformall.exception.MallinkException; | |||
| import com.iformall.mq.MqBaseProducer; | |||
| import com.iformall.pay.WxPayment; | |||
| import com.iformall.service.*; | |||
| import com.iformall.service.msg.impl.FmInsideNotifyCarPaidSuccessMsgServiceImpl; | |||
| import com.iformall.service.park.pay.WxParkPayService; | |||
| import com.iformall.utils.XmlUtil; | |||
| import lombok.extern.slf4j.Slf4j; | |||
| @@ -65,6 +67,9 @@ public class WxCarPaidCallBackController extends WxParkCallBackBaseController { | |||
| @Autowired | |||
| private WxParkPayService wxParkPayService; | |||
| @Autowired | |||
| private FmInsideNotifyCarPaidSuccessMsgServiceImpl fmInsideNotifyCarPaidSuccessMsgServiceImpl; | |||
| /** | |||
| * @description 停车费支付成功通知 | |||
| @@ -97,10 +102,15 @@ public class WxCarPaidCallBackController extends WxParkCallBackBaseController { | |||
| refundSuccessMsg.setJsonMsg(jsonMsg); | |||
| // response = wxRefundOrderService.notify(paramMap, EnumPayWay.PAY_WAY_WEAPP); | |||
| mqBaseProducer.sendMessage(refundSuccessMsg, EnumMsgMqTopic.DEFAULT.getCode(), EnumMsgMqTag.DEFAULT.getCode(), EnumMsgMqKey.DEFAULT.getCode()); | |||
| //mqBaseProducer.sendMessage(refundSuccessMsg, EnumMsgMqTopic.DEFAULT.getCode(), EnumMsgMqTag.DEFAULT.getCode(), EnumMsgMqKey.DEFAULT.getCode()); | |||
| fmInsideNotifyCarPaidSuccessMsgServiceImpl.send(refundSuccessMsg); | |||
| logger.info("carPaid wxpay, notify success, req : " + xml + ", resp: " + response.toString()); | |||
| return response; | |||
| SortedMap resultMap = new TreeMap(); | |||
| resultMap.put("return_code", "SUCCESS"); | |||
| resultMap.put("return_msg", "OK"); | |||
| return XmlUtil.getRequestXml(resultMap); | |||
| } catch (BizException e) { | |||
| logger.error("carPaid wxpay, notify error, req: " + xml + ", e:" + e.getLocalizedMessage()); | |||
| SortedMap resultMap = new TreeMap(); | |||
| @@ -83,6 +83,9 @@ public class MqBaseConsumer { | |||
| @Autowired | |||
| private FmInsideNotifyCarPaidSuccessMsgServiceImpl fmInsideNotifyCarPaidSuccessMsgServiceImpl; | |||
| @Autowired | |||
| private FmInsideNotifyBillPaidSuccessMsgServiceImpl fmInsideNotifyBillPaidSuccessMsgServiceImpl; | |||
| public void doMessage(String message) { | |||
| @@ -237,6 +240,11 @@ public class MqBaseConsumer { | |||
| FmInsideNotifyCarPaidSuccessMsg msg = (FmInsideNotifyCarPaidSuccessMsg) JsonUtil.readValue(message,FmInsideNotifyCarPaidSuccessMsg.class); | |||
| fmInsideNotifyCarPaidSuccessMsgServiceImpl.send(msg); | |||
| } | |||
| else if (EnumMsgRecordType.BILL_PAID.getCode().equals(baseMsg.getMsgType())) { | |||
| FmInsideNotifyBillPaidSuccessMsg msg = (FmInsideNotifyBillPaidSuccessMsg) JsonUtil.readValue(message,FmInsideNotifyBillPaidSuccessMsg.class); | |||
| fmInsideNotifyBillPaidSuccessMsgServiceImpl.send(msg); | |||
| } | |||
| }catch (Throwable e){ | |||
| log.error("consum received error: ", e); | |||
| @@ -36,6 +36,9 @@ public class WxPayAccountBill extends TenantEntity { | |||
| @io.swagger.annotations.ApiModelProperty(value="支付配置",name="payConfig") | |||
| private String payConfig; | |||
| @io.swagger.annotations.ApiModelProperty(value="支付回调地址",name="paidCallBack") | |||
| private String paidCallBack; | |||
| public String getPayConfigString(String key) { | |||
| if (StringUtils.isNotBlank(payConfig)) { | |||
| JSONObject pc = JSON.parseObject(payConfig); | |||
| @@ -0,0 +1,20 @@ | |||
| package com.iformall.domain.po.msg; | |||
| import lombok.Data; | |||
| import lombok.EqualsAndHashCode; | |||
| import lombok.ToString; | |||
| @Data | |||
| @ToString(callSuper = true) | |||
| @EqualsAndHashCode(callSuper = true) | |||
| public class FmInsideNotifyBillPaidSuccessMsg extends BaseMsg { | |||
| @io.swagger.annotations.ApiModelProperty(value = "支付渠道 EnumBillPayChannel", name = "payWay") | |||
| private Integer payChannel; | |||
| @io.swagger.annotations.ApiModelProperty(value = "支付渠道 EnumBillPayWay", name = "payWay") | |||
| private Integer payWay; | |||
| @io.swagger.annotations.ApiModelProperty(value = "消息内容", name = "jsonMsg") | |||
| private String jsonMsg; | |||
| } | |||
| @@ -39,6 +39,8 @@ public enum EnumMsgRecordType { | |||
| INSIDE_C_PHONE_FIRST_LOGIN(113, "C端用户授权手机号"),//内部消息,加积分等 | |||
| INSIDE_C_COMPLETE_INFO(114, "C端会员完善个人信息"),//内部消息,加积分等 | |||
| BILL_PAID(115,"账单支付回调"), | |||
| INSIDE_ORDER_PUSH_DELIVERY(200, "2.0核销同步"), | |||
| ; | |||
| @@ -79,6 +79,6 @@ public interface WxBillDailyService { | |||
| public void notify(WxBillPayDTO dto, MallUserInfo user); | |||
| public void updatePay(WxBillPayDTO dto, MallUserInfo user); | |||
| public void updatePayByMerchant(WxBillPayDTO dto, WxMerchantBUser user); | |||
| public void updatePayByMerchant(WxBillPayDTO dto, WxMerchantBUser user,boolean isOnline); | |||
| } | |||
| @@ -81,6 +81,6 @@ public interface WxBillDepositService { | |||
| public void notify(WxBillPayDTO dto, MallUserInfo user); | |||
| public void updatePay(WxBillPayDTO dto, MallUserInfo user); | |||
| public void updatePayByMerchant(WxBillPayDTO dto, WxMerchantBUser user); | |||
| public void updatePayByMerchant(WxBillPayDTO dto, WxMerchantBUser user,boolean isOnline); | |||
| } | |||
| @@ -78,5 +78,5 @@ public interface WxBillOtherDepositService { | |||
| public void notify(WxBillPayDTO dto, MallUserInfo user); | |||
| public void updatePay(WxBillPayDTO dto, MallUserInfo user); | |||
| public void updatePayByMerchant(WxBillPayDTO dto, WxMerchantBUser user); | |||
| public void updatePayByMerchant(WxBillPayDTO dto, WxMerchantBUser user,boolean isOnline); | |||
| } | |||
| @@ -74,5 +74,5 @@ public interface WxBillOtherService { | |||
| public void notify(WxBillPayDTO dto, MallUserInfo user); | |||
| public void updatePay(WxBillPayDTO dto, MallUserInfo user); | |||
| public void updatePayByMerchant(WxBillPayDTO dto, WxMerchantBUser user); | |||
| public void updatePayByMerchant(WxBillPayDTO dto, WxMerchantBUser user ,boolean isOnline); | |||
| } | |||
| @@ -83,5 +83,5 @@ public interface WxBillPropertyDepositService { | |||
| public void notify(WxBillPayDTO dto, MallUserInfo user); | |||
| public void updatePay(WxBillPayDTO dto, MallUserInfo user); | |||
| public void updatePayByMerchant(WxBillPayDTO dto, WxMerchantBUser user); | |||
| public void updatePayByMerchant(WxBillPayDTO dto, WxMerchantBUser user,boolean isOnline); | |||
| } | |||
| @@ -89,5 +89,5 @@ public interface WxBillPropertyService { | |||
| public void notify(WxBillPayDTO dto, MallUserInfo user); | |||
| public void updatePay(WxBillPayDTO dto, MallUserInfo user); | |||
| public void updatePayByMerchant(WxBillPayDTO dto, WxMerchantBUser user); | |||
| public void updatePayByMerchant(WxBillPayDTO dto, WxMerchantBUser user,boolean isOnline); | |||
| } | |||
| @@ -89,5 +89,5 @@ public interface WxBillRentManageService { | |||
| public void notify(WxBillPayDTO dto, MallUserInfo user); | |||
| public void updatePay(WxBillPayDTO dto, MallUserInfo user); | |||
| public void updatePayByMerchant(WxBillPayDTO dto, WxMerchantBUser user); | |||
| public void updatePayByMerchant(WxBillPayDTO dto, WxMerchantBUser user,boolean isOnline); | |||
| } | |||
| @@ -90,7 +90,7 @@ public interface WxBillRentService { | |||
| void notify(WxBillPayDTO dto,MallUserInfo user); | |||
| void updatePay(WxBillPayDTO dto,MallUserInfo user); | |||
| void updatePayByMerchant(WxBillPayDTO dto,WxMerchantBUser user); | |||
| void updatePayByMerchant(WxBillPayDTO dto,WxMerchantBUser user,boolean isOnline); | |||
| } | |||
| @@ -873,25 +873,25 @@ public class WxBillAllHelper { | |||
| } | |||
| } | |||
| public void updatePayByMerchant(WxBillPayDTO dto,WxMerchantBUser user) { | |||
| public void updatePayByMerchant(WxBillPayDTO dto,WxMerchantBUser user,boolean isOnline) { | |||
| if (dto.getBillTypeValue().intValue() == EnumBillAllType.RENT.getCode().intValue()) { | |||
| wxBillRentService.updatePayByMerchant(dto, user); | |||
| wxBillRentService.updatePayByMerchant(dto, user,isOnline); | |||
| }else if (dto.getBillTypeValue().intValue() == EnumBillAllType.RENT_BUSSINESS_MANAGE.getCode().intValue()) { | |||
| wxBillRentManageService.updatePayByMerchant(dto, user); | |||
| wxBillRentManageService.updatePayByMerchant(dto, user,isOnline); | |||
| }else if (dto.getBillTypeValue().intValue() == EnumBillAllType.RENT_OPERATION_MANAGE.getCode().intValue()) { | |||
| wxBillRentManageService.updatePayByMerchant(dto, user); | |||
| wxBillRentManageService.updatePayByMerchant(dto, user,isOnline); | |||
| }else if (dto.getBillTypeValue().intValue() == EnumBillAllType.RENT_DEPOSIT.getCode().intValue()) { | |||
| wxBillRentDepositService.updatePayByMerchant(dto, user); | |||
| wxBillRentDepositService.updatePayByMerchant(dto, user,isOnline); | |||
| }else if (dto.getBillTypeValue().intValue() == EnumBillAllType.PROPERTY.getCode().intValue()) { | |||
| wxBillPropertyService.updatePayByMerchant(dto, user); | |||
| wxBillPropertyService.updatePayByMerchant(dto, user,isOnline); | |||
| }else if (dto.getBillTypeValue().intValue() == EnumBillAllType.PROPERTY_DEPOSIT.getCode().intValue()) { | |||
| wxBillPropertyDepositService.updatePayByMerchant(dto, user); | |||
| wxBillPropertyDepositService.updatePayByMerchant(dto, user,isOnline); | |||
| }else if (dto.getBillTypeValue().intValue() == EnumBillAllType.DAILY.getCode().intValue()) { | |||
| wxBillDailyService.updatePayByMerchant(dto, user); | |||
| wxBillDailyService.updatePayByMerchant(dto, user,isOnline); | |||
| }else if (dto.getBillTypeValue().intValue() == EnumBillAllType.OTHER.getCode().intValue()) { | |||
| wxBillOtherService.updatePayByMerchant(dto, user); | |||
| wxBillOtherService.updatePayByMerchant(dto, user,isOnline); | |||
| }else if (dto.getBillTypeValue().intValue() == EnumBillAllType.OTHER_DEPOSIT.getCode().intValue()) { | |||
| wxBillOtherDepositService.updatePayByMerchant(dto, user); | |||
| wxBillOtherDepositService.updatePayByMerchant(dto, user,isOnline); | |||
| } | |||
| } | |||
| @@ -542,9 +542,15 @@ public class WxBillDailyServiceImpl extends WxBillBaseService implements WxBillD | |||
| } | |||
| @Override | |||
| public void updatePayByMerchant(WxBillPayDTO dto, WxMerchantBUser user) { | |||
| public void updatePayByMerchant(WxBillPayDTO dto, WxMerchantBUser user,boolean isOnline) { | |||
| WxBillDaily wxBillRent = updateBillPay(dto); | |||
| this.addBillAction(EnumBillAction.OFFLINE_PAY, dto.getBillTypeValue(),dto.getId(), | |||
| EnumBillAction action = null; | |||
| if (isOnline) { | |||
| action = EnumBillAction.SELF_SERVICE_PAY; | |||
| }else { | |||
| action = EnumBillAction.OFFLINE_PAY; | |||
| } | |||
| this.addBillAction(action, dto.getBillTypeValue(),dto.getId(), | |||
| dto.getAddpay(), dto.getAddpay(),wxBillRent.getPayDate(),dto.getPayWay(),dto.getRemark(), user); | |||
| } | |||
| @@ -499,9 +499,15 @@ public class WxBillDepositServiceImpl extends WxBillBaseService implements WxBil | |||
| } | |||
| @Override | |||
| public void updatePayByMerchant(WxBillPayDTO dto, WxMerchantBUser user) { | |||
| public void updatePayByMerchant(WxBillPayDTO dto, WxMerchantBUser user,boolean isOnline) { | |||
| WxBillDeposit wxBillRent = updateBillPay(dto); | |||
| this.addBillAction(EnumBillAction.OFFLINE_PAY, dto.getBillTypeValue(),dto.getId(), | |||
| EnumBillAction action = null; | |||
| if (isOnline) { | |||
| action = EnumBillAction.SELF_SERVICE_PAY; | |||
| }else { | |||
| action = EnumBillAction.OFFLINE_PAY; | |||
| } | |||
| this.addBillAction(action, dto.getBillTypeValue(),dto.getId(), | |||
| dto.getAddpay(), dto.getAddpay(),wxBillRent.getPayDate(),dto.getPayWay(),dto.getRemark(), user); | |||
| } | |||
| @@ -501,9 +501,15 @@ public class WxBillOtherDepositServiceImpl extends WxBillBaseService implements | |||
| } | |||
| @Override | |||
| public void updatePayByMerchant(WxBillPayDTO dto, WxMerchantBUser user) { | |||
| public void updatePayByMerchant(WxBillPayDTO dto, WxMerchantBUser user,boolean isOnline) { | |||
| WxBillOtherDeposit wxBillRent = updateBillPay(dto); | |||
| this.addBillAction(EnumBillAction.OFFLINE_PAY, dto.getBillTypeValue(),dto.getId(), | |||
| EnumBillAction action = null; | |||
| if (isOnline) { | |||
| action = EnumBillAction.SELF_SERVICE_PAY; | |||
| }else { | |||
| action = EnumBillAction.OFFLINE_PAY; | |||
| } | |||
| this.addBillAction(action, dto.getBillTypeValue(),dto.getId(), | |||
| dto.getAddpay(), dto.getAddpay(),wxBillRent.getPayDate(),dto.getPayWay(),dto.getRemark(), user); | |||
| } | |||
| @@ -446,9 +446,15 @@ public class WxBillOtherServiceImpl extends WxBillBaseService implements WxBillO | |||
| } | |||
| @Override | |||
| public void updatePayByMerchant(WxBillPayDTO dto, WxMerchantBUser user) { | |||
| public void updatePayByMerchant(WxBillPayDTO dto, WxMerchantBUser user ,boolean isOnline) { | |||
| WxBillOther wxBillRent = updateBillPay(dto); | |||
| this.addBillAction(EnumBillAction.OFFLINE_PAY, dto.getBillTypeValue(),dto.getId(), | |||
| EnumBillAction action = null; | |||
| if (isOnline) { | |||
| action = EnumBillAction.SELF_SERVICE_PAY; | |||
| }else { | |||
| action = EnumBillAction.OFFLINE_PAY; | |||
| } | |||
| this.addBillAction(action, dto.getBillTypeValue(),dto.getId(), | |||
| dto.getAddpay(), dto.getAddpay(),wxBillRent.getPayDate(),dto.getPayWay(),dto.getRemark(), user); | |||
| } | |||
| } | |||
| @@ -479,9 +479,15 @@ public class WxBillPropertyDepositServiceImpl extends WxBillBaseService implemen | |||
| } | |||
| @Override | |||
| public void updatePayByMerchant(WxBillPayDTO dto, WxMerchantBUser user) { | |||
| public void updatePayByMerchant(WxBillPayDTO dto, WxMerchantBUser user,boolean isOnline) { | |||
| WxBillPropertyDeposit wxBillRent = updateBillPay(dto); | |||
| this.addBillAction(EnumBillAction.OFFLINE_PAY, dto.getBillTypeValue(),dto.getId(), | |||
| EnumBillAction action = null; | |||
| if (isOnline) { | |||
| action = EnumBillAction.SELF_SERVICE_PAY; | |||
| }else { | |||
| action = EnumBillAction.OFFLINE_PAY; | |||
| } | |||
| this.addBillAction(action, dto.getBillTypeValue(),dto.getId(), | |||
| dto.getAddpay(), dto.getAddpay(),wxBillRent.getPayDate(),dto.getPayWay(),dto.getRemark(), user); | |||
| } | |||
| @@ -568,9 +568,15 @@ public class WxBillPropertyServiceImpl extends WxBillBaseService implements WxBi | |||
| } | |||
| @Override | |||
| public void updatePayByMerchant(WxBillPayDTO dto, WxMerchantBUser user) { | |||
| public void updatePayByMerchant(WxBillPayDTO dto, WxMerchantBUser user,boolean isOnline) { | |||
| WxBillProperty wxBillRent = updateBillPay(dto); | |||
| this.addBillAction(EnumBillAction.OFFLINE_PAY, dto.getBillTypeValue(),dto.getId(), | |||
| EnumBillAction action = null; | |||
| if (isOnline) { | |||
| action = EnumBillAction.SELF_SERVICE_PAY; | |||
| }else { | |||
| action = EnumBillAction.OFFLINE_PAY; | |||
| } | |||
| this.addBillAction(action, dto.getBillTypeValue(),dto.getId(), | |||
| dto.getAddpay(), dto.getAddpay(),wxBillRent.getPayDate(),dto.getPayWay(),dto.getRemark(), user); | |||
| } | |||
| } | |||
| @@ -497,9 +497,15 @@ public class WxBillRentManageServiceImpl extends WxBillBaseService implements W | |||
| } | |||
| @Override | |||
| public void updatePayByMerchant(WxBillPayDTO dto, WxMerchantBUser user) { | |||
| public void updatePayByMerchant(WxBillPayDTO dto, WxMerchantBUser user,boolean isOnline) { | |||
| WxBillRentManage wxBillRent = updateBillPay(dto); | |||
| this.addBillAction(EnumBillAction.OFFLINE_PAY, dto.getBillTypeValue(),dto.getId(), | |||
| EnumBillAction action = null; | |||
| if (isOnline) { | |||
| action = EnumBillAction.SELF_SERVICE_PAY; | |||
| }else { | |||
| action = EnumBillAction.OFFLINE_PAY; | |||
| } | |||
| this.addBillAction(action, dto.getBillTypeValue(),dto.getId(), | |||
| dto.getAddpay(), dto.getAddpay(),wxBillRent.getPayDate(),dto.getPayWay(),dto.getRemark(), user); | |||
| } | |||
| @@ -662,9 +662,15 @@ public class WxBillRentServiceImpl extends WxBillBaseService implements WxBillRe | |||
| } | |||
| @Override | |||
| public void updatePayByMerchant(WxBillPayDTO dto, WxMerchantBUser user) { | |||
| public void updatePayByMerchant(WxBillPayDTO dto, WxMerchantBUser user,boolean isOnline) { | |||
| WxBillRent wxBillRent = updateBillPay(dto); | |||
| this.addBillAction(EnumBillAction.OFFLINE_PAY, dto.getBillTypeValue(),dto.getId(), | |||
| EnumBillAction action = null; | |||
| if (isOnline) { | |||
| action = EnumBillAction.SELF_SERVICE_PAY; | |||
| }else { | |||
| action = EnumBillAction.OFFLINE_PAY; | |||
| } | |||
| this.addBillAction(action, dto.getBillTypeValue(),dto.getId(), | |||
| dto.getAddpay(), dto.getAddpay(),wxBillRent.getPayDate(),dto.getPayWay(),dto.getRemark(), user); | |||
| } | |||
| } | |||
| @@ -0,0 +1,33 @@ | |||
| package com.iformall.service.msg.impl; | |||
| import com.alibaba.fastjson.JSON; | |||
| import com.iformall.domain.po.msg.BaseMsg; | |||
| import com.iformall.domain.po.msg.FmInsideNotifyBillPaidSuccessMsg; | |||
| import com.iformall.enums.EnumBillPayChannel; | |||
| import com.iformall.enums.EnumBillPayWay; | |||
| import com.iformall.service.msg.MsgSendService; | |||
| import com.iformall.service.payBill.PayBillServiceFactory; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.stereotype.Service; | |||
| import java.util.Map; | |||
| /** | |||
| */ | |||
| @Service | |||
| public class FmInsideNotifyBillPaidSuccessMsgServiceImpl implements MsgSendService { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| private PayBillServiceFactory payBillServiceFactory; | |||
| @Override | |||
| public void send(BaseMsg baseMsg) throws Exception { | |||
| FmInsideNotifyBillPaidSuccessMsg msg = (FmInsideNotifyBillPaidSuccessMsg)baseMsg; | |||
| Map<String, String> paramMap = JSON.parseObject(msg.getJsonMsg(), Map.class); | |||
| payBillServiceFactory.getPayAdapterService(msg.getPayChannel()) | |||
| .paidCallBack(msg.getTenantId(),EnumBillPayWay.getEnum(msg.getPayWay()),paramMap); | |||
| } | |||
| } | |||
| @@ -2,13 +2,16 @@ package com.iformall.service.payBill; | |||
| import java.util.Map; | |||
| import com.iformall.domain.po.WxMerchantBUser; | |||
| import com.iformall.domain.po.WxPayAccountBill; | |||
| import com.iformall.domain.po.base.WxBillBaseEntity; | |||
| import com.iformall.enums.EnumBillPayWay; | |||
| public interface PayBillAdapterService { | |||
| //发起支付,有可能是码,小程序支付,或者其他支付 | |||
| public Object createPay(WxPayAccountBill wxPayAccountBill,WxBillBaseEntity billdetail,Double money,Map<String,String> params); | |||
| public Object createPay(WxPayAccountBill wxPayAccountBill,WxMerchantBUser buser,WxBillBaseEntity billdetail,Double money,Map<String,String> params); | |||
| //支付通知处理 | |||
| public void paidCallBack(String tenantId,EnumBillPayWay payWay,Map<String, String> paramMap); | |||
| } | |||
| @@ -11,8 +11,11 @@ import org.springframework.stereotype.Service; | |||
| import com.alibaba.fastjson.JSON; | |||
| import com.alibaba.fastjson.JSONObject; | |||
| import com.aliyun.openservices.shade.org.apache.commons.lang3.StringUtils; | |||
| import com.iformall.common.IdWorker; | |||
| import com.iformall.domain.po.WxMerchantBUser; | |||
| import com.iformall.domain.po.WxPayAccountBill; | |||
| import com.iformall.domain.po.base.WxBillBaseEntity; | |||
| import com.iformall.enums.EnumBillPayWay; | |||
| import com.iformall.service.payBill.PayBillAdapterService; | |||
| import com.iformall.service.payBill.impl.entity.JianHangMaRequest; | |||
| import com.iformall.utils.DateUtils; | |||
| @@ -21,24 +24,23 @@ import lombok.extern.slf4j.Slf4j; | |||
| @Slf4j | |||
| @Service | |||
| public class JianHangMaServiceImpl implements PayBillAdapterService { | |||
| public class JianHangMaServiceImpl extends PayBillBaseService implements PayBillAdapterService { | |||
| private static final String url = "https://ibsbjstar.ccb.com.cn/CCBIS/ccbMain?CCB_IBSVersion=V6"; | |||
| //建行动态二维码接口 | |||
| @Override | |||
| public Object createPay(WxPayAccountBill wxPayAccountBill,WxBillBaseEntity billdetail,Double money,Map<String, String> params) { | |||
| public Object createPay(WxPayAccountBill wxPayAccountBill,WxMerchantBUser buser,WxBillBaseEntity billdetail,Double money,Map<String, String> params) { | |||
| JianHangMaRequest request = new JianHangMaRequest(); | |||
| request.setMERCHANTID(wxPayAccountBill.getPayConfigString("MERCHANTID")); | |||
| request.setPOSID(wxPayAccountBill.getPayConfigString("POSID")); | |||
| request.setBRANCHID(wxPayAccountBill.getPayConfigString("BRANCHID")); | |||
| request.setORDERID(billdetail.getBillType()+"_"+billdetail.getId()); | |||
| final IdWorker idWorker = IdWorker.get(); | |||
| request.setORDERID(billdetail.getBillType()+"_"+idWorker.nextId()); | |||
| request.setPAYMENT(money); | |||
| try { | |||
| request.setREMARK1(URLEncoder.encode(billdetail.getBillTypeName(),"utf-8")); | |||
| } catch (UnsupportedEncodingException e) { | |||
| log.error("JianHangMaServiceImpl createPay setREMARK1 error.",e); | |||
| } | |||
| //request.setREMARK1(URLEncoder.encode(billdetail.getBillTypeName(),"utf-8")); | |||
| request.setREMARK1(billdetail.getBillType()+"_"+billdetail.getId()); | |||
| request.setREMARK2(String.valueOf(buser.getId())); | |||
| request.setTIMEOUT(DateUtils.date2String(DateUtils.getSecondsTimeAfter(10*60, new Date()), DateUtils.DATE_PATTERN_ALL_NOSPACE)); | |||
| try { | |||
| request.setMAC(DigestUtils.md5Hex(request.toMacString().getBytes("UTF-8"))); | |||
| @@ -73,6 +75,10 @@ public class JianHangMaServiceImpl implements PayBillAdapterService { | |||
| } | |||
| return null; | |||
| } | |||
| @Override | |||
| public void paidCallBack(String tenantId,EnumBillPayWay payWay, Map<String, String> paramMap) { | |||
| } | |||
| @@ -0,0 +1,40 @@ | |||
| package com.iformall.service.payBill.impl; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.stereotype.Service; | |||
| import com.iformall.domain.dto.WxBillPayDTO; | |||
| import com.iformall.domain.po.WxMerchantBUser; | |||
| import com.iformall.enums.EnumBillAllType; | |||
| import com.iformall.enums.EnumBillPayWay; | |||
| import com.iformall.service.WxMerchantBUserService; | |||
| import com.iformall.service.helper.WxBillAllHelper; | |||
| @Service | |||
| public class PayBillBaseService { | |||
| @Autowired | |||
| WxBillAllHelper wxBillAllHelper; | |||
| @Autowired | |||
| WxMerchantBUserService wxMerchantBUserService; | |||
| public void updateBillPaid(String tenantId,Long merchantBUserId,EnumBillAllType billType,Long billId,String paid,EnumBillPayWay payWay,String remark) { | |||
| WxBillPayDTO dto = new WxBillPayDTO(); | |||
| dto.setTenantId(tenantId); | |||
| dto.setId(billId); | |||
| dto.setBillTypeValue(billType.getCode()); | |||
| dto.setAddpay(paid); | |||
| dto.setPayWay(payWay.getCode()); | |||
| dto.setRemark(remark); | |||
| WxMerchantBUser buser = wxMerchantBUserService.getById(merchantBUserId); | |||
| if (null == buser) { | |||
| buser = new WxMerchantBUser(); | |||
| buser.setId(merchantBUserId); | |||
| buser.setName("未知"); | |||
| buser.setPhone("111111111"); | |||
| } | |||
| wxBillAllHelper.updatePayByMerchant(dto, buser,true); | |||
| } | |||
| } | |||
| @@ -1,22 +1,132 @@ | |||
| package com.iformall.service.payBill.impl; | |||
| import java.math.BigDecimal; | |||
| import java.math.RoundingMode; | |||
| import java.util.Date; | |||
| import java.util.Map; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.stereotype.Service; | |||
| import com.alibaba.fastjson.JSON; | |||
| import com.aliyun.openservices.shade.org.apache.commons.lang3.StringUtils; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.IdWorker; | |||
| import com.iformall.domain.po.WxAppinfo; | |||
| import com.iformall.domain.po.WxMerchantBUser; | |||
| import com.iformall.domain.po.WxPark; | |||
| import com.iformall.domain.po.WxPayAccount; | |||
| import com.iformall.domain.po.WxPayAccountBill; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| import com.iformall.domain.po.base.WxBillBaseEntity; | |||
| import com.iformall.enums.EnumBillAllType; | |||
| import com.iformall.enums.EnumBillPayWay; | |||
| import com.iformall.enums.EnumPayWay; | |||
| import com.iformall.exception.MallinkException; | |||
| import com.iformall.service.WxAppinfoService; | |||
| import com.iformall.service.WxPayAccountService; | |||
| import com.iformall.service.pay.service.pay.entity.PayAdapterResult; | |||
| import com.iformall.service.pay.service.pay.wx.v2.miniApp.appPay.WxMiniAppPayAdapterService; | |||
| import com.iformall.service.payBill.PayBillAdapterService; | |||
| import com.iformall.utils.DateUtils; | |||
| import lombok.extern.slf4j.Slf4j; | |||
| @Slf4j | |||
| @Service | |||
| public class WxMiniProgramServiceImpl implements PayBillAdapterService { | |||
| public class WxMiniProgramServiceImpl extends PayBillBaseService implements PayBillAdapterService { | |||
| @Autowired | |||
| WxMiniAppPayAdapterService wxMiniAppPayAdapterService; | |||
| @Autowired | |||
| WxAppinfoService wxAppinfoService; | |||
| @Autowired | |||
| WxPayAccountService wxPayAccountService; | |||
| @Override | |||
| public Object createPay(WxPayAccountBill wxPayAccountBill,WxMerchantBUser buser,WxBillBaseEntity billdetail,Double money,Map<String, String> params) { | |||
| String openId = params.get("openId"); | |||
| if (StringUtils.isBlank(openId)) { | |||
| throw new MallinkException(ErrorCode.APP_ID_NOT_FOUND.getCode(),"参数openId为空"); | |||
| } | |||
| WxAppinfo cAppInfo = wxAppinfoService.getCAppInfoFromRedis(wxPayAccountBill.getTenantId(), EnumPayWay.PAY_WAY_WECHAT.getPlat()); | |||
| if(cAppInfo == null){ | |||
| throw new MallinkException(ErrorCode.APP_ID_NOT_FOUND.getCode(),"未查询到C端小程序"); | |||
| } | |||
| WxPayAccount payAccount = wxPayAccountService.getByIdFromRedis(cAppInfo.getPayId()); | |||
| if(payAccount == null){ | |||
| throw new MallinkException(ErrorCode.API_KEY_NOT_FOUND.getCode(),"未查询到payAccount."); | |||
| } | |||
| StringBuffer attachSb = new StringBuffer() | |||
| .append(billdetail.getBillType()).append(",") | |||
| .append(billdetail.getId()).append(",") | |||
| .append(buser.getId()).append(",") | |||
| ; | |||
| String attach = attachSb.toString(); | |||
| Integer fee = Integer.parseInt(String.valueOf(money*100)); | |||
| try { | |||
| final IdWorker idWorker = IdWorker.get(); | |||
| String uniquePayOrderNo = billdetail.getBillType()+"_"+idWorker.nextId(); | |||
| PayAdapterResult wxResult = wxMiniAppPayAdapterService.payIsv(payAccount, cAppInfo, payAccount.getSubMchId(), openId, billdetail.getBillTypeName(), attach, uniquePayOrderNo, | |||
| fee, "127.0.0.1", wxPayAccountBill.getPaidCallBack()+"/"+wxPayAccountBill.getTenantId(), new Date(), false); | |||
| if (wxResult.isSuccess()) { | |||
| return wxResult; | |||
| }else { | |||
| throw new MallinkException(ErrorCode.API_KEY_NOT_FOUND.getCode(),wxResult.getMsg()); | |||
| } | |||
| } catch (Exception e) { | |||
| log.error("WxMiniProgramServiceImpl createPay error.",e); | |||
| throw new MallinkException(ErrorCode.API_KEY_NOT_FOUND.getCode(),e.getMessage()); | |||
| } | |||
| } | |||
| @Override | |||
| public Object createPay(WxPayAccountBill wxPayAccountBill,WxBillBaseEntity billdetail,Double money,Map<String, String> params) { | |||
| return null; | |||
| public void paidCallBack(String tenantId,EnumBillPayWay payWay, Map<String, String> paramMap) { | |||
| log.debug("handleWxBillPaidCallBack."+JSON.toJSONString(paramMap)); | |||
| //支付返回消息 | |||
| String returnCode = paramMap.get("return_code"); | |||
| if ("SUCCESS".equals(returnCode)) { | |||
| String resultCode = paramMap.get("result_code"); | |||
| if ("SUCCESS".equals(resultCode)) { | |||
| //判断支付金额是否大于0 | |||
| String cashFeeStr = paramMap.get("cash_fee"); | |||
| Integer cashFee = Integer.parseInt(cashFeeStr); | |||
| if (cashFee > 0 ) { | |||
| try { | |||
| //String payOrderNo = paramMap.get("out_trade_no"); | |||
| String time_end = paramMap.get("time_end"); | |||
| String transcationId = paramMap.get("transaction_id"); | |||
| String attach = paramMap.get("attach"); | |||
| if (!StringUtils.isBlank(attach)) { | |||
| String[] attrs = attach.split(","); | |||
| if (attrs.length == 3) { | |||
| Integer billType = Integer.parseInt(attrs[0]); | |||
| Long billId = Long.parseLong(attrs[1]); | |||
| Long merchantBUserId = Long.parseLong(attrs[2]); | |||
| String paid = new BigDecimal(cashFee).divide(new BigDecimal(100)).setScale(2, RoundingMode.HALF_UP).toPlainString(); | |||
| this.updateBillPaid(tenantId, merchantBUserId, EnumBillAllType.getEnum(billType), billId, | |||
| paid, payWay, "微信支付单号"+transcationId); | |||
| }else { | |||
| throw new MallinkException(ErrorCode.API_KEY_NOT_FOUND.getCode(),"attach参数错误"); | |||
| } | |||
| }else { | |||
| throw new MallinkException(ErrorCode.API_KEY_NOT_FOUND.getCode(),"attach不能为空"); | |||
| } | |||
| } catch (Exception e) { | |||
| log.error("handleWxBillPaidCallBack.",e); | |||
| throw new MallinkException(ErrorCode.API_KEY_NOT_FOUND.getCode(),e.getMessage()); | |||
| } | |||
| } | |||
| }else { | |||
| String errorMsg = paramMap.get("err_code_des"); | |||
| throw new MallinkException(ErrorCode.API_KEY_NOT_FOUND.getCode(),errorMsg); | |||
| } | |||
| }else { | |||
| String errorMsg = paramMap.get("return_msg"); | |||
| throw new MallinkException(ErrorCode.API_KEY_NOT_FOUND.getCode(),errorMsg); | |||
| } | |||
| } | |||
| } | |||
| @@ -12,11 +12,12 @@ | |||
| <result column="service_charge_rate" property="serviceChargeRate"/> | |||
| <result column="pay_channel" property="payChannel"/> | |||
| <result column="pay_config" property="payConfig"/> | |||
| <result column="paid_callBack" property="paidCallBack"/> | |||
| </resultMap> | |||
| <sql id="allColumns"> | |||
| `id`,`tenant_id`,`parent_tenant_id`,`bank_account_name`,`bank_card_id`,`social_credit_code`,`bank_name`, | |||
| `service_charge_rate`,`pay_channel`,`pay_config` | |||
| `service_charge_rate`,`pay_channel`,`pay_config`,`paid_callBack` | |||
| </sql> | |||
| <sql id="dynamicWhereConditions"> | |||