| @@ -14,6 +14,7 @@ public class WxProfitSharingP implements Serializable { | |||
| private String sub_appid; // 子公众账号ID | |||
| private String nonce_str; // 随机字符串 | |||
| private String sign; // 签名 | |||
| private String sign_type; // 签名方法 | |||
| private String transaction_id ; // 支付订单号 | |||
| private String out_trade_no; // 商户订单号 | |||
| private String receivers; // 分账接收方 | |||
| @@ -64,6 +65,13 @@ public class WxProfitSharingP implements Serializable { | |||
| this.sign = sign; | |||
| } | |||
| public String getSign_type() { | |||
| return sign_type; | |||
| } | |||
| public void setSign_type(String sign_type) { | |||
| this.sign_type = sign_type; | |||
| } | |||
| public String getTransaction_id() { | |||
| return transaction_id; | |||
| } | |||
| @@ -12,6 +12,7 @@ public class WxProfitSharingQueryP implements Serializable { | |||
| private String sub_mch_id; // 子商户号 | |||
| private String nonce_str; // 随机字符串 | |||
| private String sign; // 签名 | |||
| private String sign_type; // 签名方法 | |||
| private String transaction_id ; // 支付订单号 | |||
| private String out_trade_no; // 商户分账单号 | |||
| @@ -45,6 +46,13 @@ public class WxProfitSharingQueryP implements Serializable { | |||
| public void setSign(String sign) { | |||
| this.sign = sign; | |||
| } | |||
| public String getSign_type() { | |||
| return sign_type; | |||
| } | |||
| public void setSign_type(String sign_type) { | |||
| this.sign_type = sign_type; | |||
| } | |||
| public String getTransaction_id() { | |||
| return transaction_id; | |||
| @@ -14,6 +14,7 @@ public class WxProfitSharingReceiverP implements Serializable { | |||
| private String sub_appid; // 子公众账号ID | |||
| private String nonce_str; // 随机字符串 | |||
| private String sign; // 签名 | |||
| private String sign_type; // 签名方法 | |||
| private String receiver; // 分账接收方 | |||
| public String getMch_id() { | |||
| @@ -62,6 +63,14 @@ public class WxProfitSharingReceiverP implements Serializable { | |||
| this.sign = sign; | |||
| } | |||
| public String getSign_type() { | |||
| return sign_type; | |||
| } | |||
| public void setSign_type(String sign_type) { | |||
| this.sign_type = sign_type; | |||
| } | |||
| public String getReceiver() { | |||
| return receiver; | |||
| } | |||
| @@ -14,11 +14,11 @@ import com.simple.domain.vo.WxCouponOrderCVo; | |||
| import com.simple.domain.vo.WxCouponOrderCarCVo; | |||
| import com.simple.enums.EnumCouponOrderStatus; | |||
| import com.simple.enums.EnumCouponSendType; | |||
| import com.simple.enums.EnumPayShare; | |||
| import com.simple.enums.EnumPayStatus; | |||
| import com.simple.exception.MallinkException; | |||
| import com.simple.mapper.*; | |||
| import com.simple.service.WxCouponOrderService; | |||
| import com.simple.service.WxCouponSendService; | |||
| import com.simple.service.WxOrderService; | |||
| import com.simple.service.*; | |||
| import org.apache.log4j.Logger; | |||
| import org.apache.poi.ss.usermodel.Workbook; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| @@ -58,6 +58,13 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { | |||
| @Autowired | |||
| WxCouponSendService wxCouponSendService; | |||
| @Autowired | |||
| WxProfitSharingOrderService wxProfitSharingOrderService; | |||
| @Autowired | |||
| WxPayOrderMapper wxPayOrderMapper; | |||
| @Override | |||
| public PageInfo<WxCouponOrder> listAsPage(WxCouponOrder record, Integer pageIndex, Integer pageSize) { | |||
| return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCouponOrderMapper.findList(record)); | |||
| @@ -337,22 +344,27 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { | |||
| // 核销发券 | |||
| wxCouponSendService.sendCouponToUser(wxMerchantBUser.getTenantId(), wxOrder.getCUserId(), EnumCouponSendType.COUPON_VERIFY.getCode()); | |||
| // 微信分账 | |||
| WxPayOrder wxPayOrder = new WxPayOrder(); | |||
| wxPayOrder.setOrderId(wxCouponOrder.getOrderId()); | |||
| wxPayOrder.setPayOrderStatus(EnumPayStatus.PAY_WAY_SUCCESS.getCode()); | |||
| wxPayOrder = wxPayOrderMapper.selectOne(wxPayOrder); | |||
| if (wxPayOrder == null) | |||
| throw new MallinkException(ErrorCode.PAY_ORDER_NOT_FOUND); | |||
| if (wxPayOrder.getShare() == EnumPayShare.YES.getCode()) | |||
| wxProfitSharingOrderService.createSharingOrder(wxPayOrder); | |||
| return new ResultData(wxCouponOrder); | |||
| } | |||
| @Override | |||
| public List<CUserDateAmountVo> queryPriceTotalGroup(String tenantId, Date startTime, Date endTime) { | |||
| return wxCouponOrderMapper.queryPriceTotalGroup(tenantId, startTime, endTime); | |||
| } | |||
| @Override | |||
| public int queryPriceTotal(String tenantId, Date startTime, Date endTime) { | |||
| return wxCouponOrderMapper.queryPriceTotal(tenantId, startTime, endTime); | |||
| } | |||
| } | |||
| @@ -178,7 +178,7 @@ public class WxProfitSharingOrderServiceImpl implements WxProfitSharingOrderServ | |||
| wxProfitSharingP.setNonce_str(Utility.generate32UUID()); | |||
| wxProfitSharingP.setTransaction_id(wxPayOrder.getTransactionId()); | |||
| wxProfitSharingP.setOut_trade_no(record.getId().toString()); | |||
| wxProfitSharingP.setSign_type("HMAC-SHA256"); | |||
| //添加分账接受方 | |||
| WxProfitSharingReceiver wxProfitSharingReceiver = new WxProfitSharingReceiver(); | |||
| wxProfitSharingReceiver.setMerchantId(wxOrder.getMerchantId()); | |||
| @@ -211,7 +211,7 @@ public class WxProfitSharingOrderServiceImpl implements WxProfitSharingOrderServ | |||
| wxProfitSharingP.setReceivers(receivers.toJSONString()); | |||
| wxProfitSharingP.setSign(WxPayment.createSign(BeanUtils.toStringMap(wxProfitSharingP), payAccount.getApiKey())); | |||
| wxProfitSharingP.setSign(WxPayment.createSignHMAC(BeanUtils.toStringMap(wxProfitSharingP), payAccount.getApiKey())); | |||
| String response = WxProfitSharing.pushOrder(BeanUtils.toStringMap(wxProfitSharingP)); | |||
| Map<String, String> returnMap = WxPayment.xmlToMap(response); | |||
| @@ -220,11 +220,11 @@ public class WxProfitSharingOrderServiceImpl implements WxProfitSharingOrderServ | |||
| record.setSharingStatus(EnumProfitSharingStatus.PROFIT_SHARING_REQ_FAILED.getCode()); | |||
| record.setUpdateTime(new Date()); | |||
| wxProfitSharingOrderMapper.updateByPrimaryKey(record); | |||
| return new ResultData(ErrorCode.PROFIT_SHARING_REQUEST_FAILED.getCode(), returnMap.get("return_msg")); | |||
| throw new MallinkException(ErrorCode.PROFIT_SHARING_REQUEST_FAILED.getCode(), returnMap.get("return_msg")); | |||
| } | |||
| if (!WxPayment.verifyNotify(returnMap,payAccount.getApiKey())){ | |||
| return new ResultData(ErrorCode.PROFIT_SHARING_RETURN_INVALID.getCode(), ErrorCode.PROFIT_SHARING_RETURN_INVALID.getMessage()); | |||
| throw new MallinkException(ErrorCode.PROFIT_SHARING_RETURN_INVALID.getCode(), ErrorCode.PROFIT_SHARING_RETURN_INVALID.getMessage()); | |||
| } | |||
| String result_code = returnMap.get("result_code"); | |||
| @@ -232,7 +232,7 @@ public class WxProfitSharingOrderServiceImpl implements WxProfitSharingOrderServ | |||
| record.setSharingStatus(EnumProfitSharingStatus.PROFIT_SHARING_APPLY_FAILED.getCode()); | |||
| record.setUpdateTime(new Date()); | |||
| wxProfitSharingOrderMapper.updateByPrimaryKey(record); | |||
| return new ResultData(ErrorCode.PROFIT_SHARING_APPLY_FAILED.getCode(), returnMap.get("result_msg")); | |||
| throw new MallinkException(ErrorCode.PROFIT_SHARING_APPLY_FAILED.getCode(), returnMap.get("result_msg")); | |||
| } | |||
| record.setSharingOrderNo(returnMap.get("order_id")); | |||
| @@ -268,28 +268,29 @@ public class WxProfitSharingOrderServiceImpl implements WxProfitSharingOrderServ | |||
| wxProfitSharingQueryP.setNonce_str(Utility.generate32UUID()); | |||
| wxProfitSharingQueryP.setTransaction_id(wxPayOrder.getTransactionId()); | |||
| wxProfitSharingQueryP.setOut_trade_no(record.getId().toString()); | |||
| wxProfitSharingQueryP.setSign_type("HMAC-SHA256"); | |||
| wxProfitSharingQueryP.setSign(WxPayment.createSign(BeanUtils.toStringMap(wxProfitSharingQueryP), payAccount.getApiKey())); | |||
| wxProfitSharingQueryP.setSign(WxPayment.createSignHMAC(BeanUtils.toStringMap(wxProfitSharingQueryP), payAccount.getApiKey())); | |||
| String response = WxProfitSharing.pushOrder(BeanUtils.toStringMap(wxProfitSharingQueryP)); | |||
| Map<String, String> returnMap = WxPayment.xmlToMap(response); | |||
| String return_code = returnMap.get("return_code"); | |||
| if (!"SUCCESS".equals(return_code)) { | |||
| return new ResultData(ErrorCode.PROFIT_SHARING_QUERY_REQUEST_FAILED.getCode(), returnMap.get("return_msg")); | |||
| throw new MallinkException(ErrorCode.PROFIT_SHARING_QUERY_REQUEST_FAILED.getCode(), returnMap.get("return_msg")); | |||
| } | |||
| if (!WxPayment.verifyNotify(returnMap,payAccount.getApiKey())){ | |||
| return new ResultData(ErrorCode.PROFIT_SHARING_QUERY_RETURN_INVALID.getCode(), ErrorCode.PROFIT_SHARING_RETURN_INVALID.getMessage()); | |||
| throw new MallinkException(ErrorCode.PROFIT_SHARING_QUERY_RETURN_INVALID.getCode(), ErrorCode.PROFIT_SHARING_RETURN_INVALID.getMessage()); | |||
| } | |||
| String out_order_no = returnMap.get("out_order_no"); | |||
| if (!out_order_no.equals(record.getId().toString())){ | |||
| return new ResultData(ErrorCode.PROFIT_SHARING_QUERY_RETURN_INVALID.getCode(), ErrorCode.PROFIT_SHARING_RETURN_INVALID.getMessage()); | |||
| throw new MallinkException(ErrorCode.PROFIT_SHARING_QUERY_RETURN_INVALID.getCode(), ErrorCode.PROFIT_SHARING_RETURN_INVALID.getMessage()); | |||
| } | |||
| String result_code = returnMap.get("result_code"); | |||
| if (!"SUCCESS".equals(result_code)) { | |||
| return new ResultData(ErrorCode.PROFIT_SHARING_QUERY_APPLY_FAILED.getCode(), returnMap.get("result_msg")); | |||
| throw new MallinkException(ErrorCode.PROFIT_SHARING_QUERY_APPLY_FAILED.getCode(), returnMap.get("result_msg")); | |||
| } | |||
| record.setSharingStatus((Integer) statusMap.get(returnMap.get("status"))); | |||
| @@ -111,6 +111,7 @@ public class WxProfitSharingReceiverServiceImpl implements WxProfitSharingReceiv | |||
| wxProfitSharingReceiverP.setSub_appid(appInfo.getAppId()); | |||
| wxProfitSharingReceiverP.setSub_mch_id(payAccount.getSubMchId()); | |||
| wxProfitSharingReceiverP.setNonce_str(Utility.generate32UUID()); | |||
| wxProfitSharingReceiverP.setSign_type("HMAC-SHA256"); | |||
| JSONObject receiverJSON = new JSONObject(); | |||
| @@ -121,7 +122,7 @@ public class WxProfitSharingReceiverServiceImpl implements WxProfitSharingReceiv | |||
| wxProfitSharingReceiverP.setReceiver(receiverJSON.toJSONString()); | |||
| String response; | |||
| try { | |||
| wxProfitSharingReceiverP.setSign(WxPayment.createSign(BeanUtils.toStringMap(wxProfitSharingReceiverP), payAccount.getApiKey())); | |||
| wxProfitSharingReceiverP.setSign(WxPayment.createSignHMAC(BeanUtils.toStringMap(wxProfitSharingReceiverP), payAccount.getApiKey())); | |||
| response = WxProfitSharing.addReceiver(BeanUtils.toStringMap(wxProfitSharingReceiverP)); | |||
| }catch (Exception e) { | |||
| return new ResultData(ErrorCode.PROFIT_SHARING_RECEIVER_ADD_FAILED, e.getMessage()); | |||
| @@ -132,13 +133,13 @@ public class WxProfitSharingReceiverServiceImpl implements WxProfitSharingReceiv | |||
| return new ResultData(ErrorCode.PROFIT_SHARING_RECEIVER_ADD_FAILED.getCode(), returnMap.get("return_msg")); | |||
| } | |||
| if (!WxPayment.verifyNotify(returnMap,payAccount.getApiKey())){ | |||
| return new ResultData(ErrorCode.PROFIT_SHARING_RECEIVER_ADD_FAILED.getCode(), ErrorCode.PROFIT_SHARING_RECEIVER_ADD_FAILED.getMessage()); | |||
| } | |||
| String result_code = returnMap.get("result_code"); | |||
| if (!"SUCCESS".equals(result_code)) { | |||
| return new ResultData(ErrorCode.PROFIT_SHARING_RECEIVER_ADD_FAILED.getCode(), returnMap.get("result_msg")); | |||
| return new ResultData(ErrorCode.PROFIT_SHARING_RECEIVER_ADD_FAILED.getCode(), returnMap.get("err_code_des")); | |||
| } | |||
| if (!WxPayment.verifyNotify(returnMap,payAccount.getApiKey())){ | |||
| return new ResultData(ErrorCode.PROFIT_SHARING_RECEIVER_ADD_FAILED.getCode(), ErrorCode.PROFIT_SHARING_RECEIVER_ADD_FAILED.getMessage()); | |||
| } | |||
| wxProfitSharingReceiverMapper.insertSelective(receiver); | |||
| @@ -171,7 +172,7 @@ public class WxProfitSharingReceiverServiceImpl implements WxProfitSharingReceiv | |||
| wxProfitSharingReceiverP.setSub_appid(appInfo.getAppId()); | |||
| wxProfitSharingReceiverP.setSub_mch_id(payAccount.getSubMchId()); | |||
| wxProfitSharingReceiverP.setNonce_str(Utility.generate32UUID()); | |||
| wxProfitSharingReceiverP.setSign_type("HMAC-SHA256"); | |||
| JSONObject receiverJSON = new JSONObject(); | |||
| receiverJSON.put("type",EnumProfitSharingReceiverType.getEnum(receiver.getReceiverType()).getMessage()); | |||
| @@ -180,7 +181,7 @@ public class WxProfitSharingReceiverServiceImpl implements WxProfitSharingReceiv | |||
| wxProfitSharingReceiverP.setReceiver(receiverJSON.toJSONString()); | |||
| String response; | |||
| try { | |||
| wxProfitSharingReceiverP.setSign(WxPayment.createSign(BeanUtils.toStringMap(wxProfitSharingReceiverP), payAccount.getApiKey())); | |||
| wxProfitSharingReceiverP.setSign(WxPayment.createSignHMAC(BeanUtils.toStringMap(wxProfitSharingReceiverP), payAccount.getApiKey())); | |||
| response = WxProfitSharing.addReceiver(BeanUtils.toStringMap(wxProfitSharingReceiverP)); | |||
| }catch (Exception e) { | |||
| return new ResultData(ErrorCode.PROFIT_SHARING_RECEIVER_DEL_FAILED, e.getMessage()); | |||