|
|
|
@ -354,58 +354,54 @@ public class OutRechargeOrderController { |
|
|
|
|
@ApiOperation(value = "分账") |
|
|
|
|
public ResponseData wxProfitsharing() { |
|
|
|
|
try { |
|
|
|
|
HighOrder order = highOrderService.getOrderByOrderNo("20211019173044475879505"); |
|
|
|
|
BigDecimal rake = new BigDecimal("0.01"); |
|
|
|
|
// 计算微信收取的手续费 支付金额 * 0.002 注:如果与两个相邻数字的距离相等,则为上舍入的舍入模式。
|
|
|
|
|
BigDecimal wxHandlingFee = order.getPayPrice().multiply(new BigDecimal("0.002")).setScale(2,BigDecimal.ROUND_HALF_DOWN); |
|
|
|
|
BigDecimal price = order.getPayPrice().subtract(wxHandlingFee); |
|
|
|
|
|
|
|
|
|
List<HighOrder> orderList = highOrderService.getTest(); |
|
|
|
|
for (HighOrder highOrder : orderList) { |
|
|
|
|
HighOrder order = highOrderService.getOrderById(highOrder.getId()); |
|
|
|
|
BigDecimal rake = new BigDecimal("0.01"); |
|
|
|
|
// 计算微信收取的手续费 支付金额 * 0.002 注:如果与两个相邻数字的距离相等,则为上舍入的舍入模式。
|
|
|
|
|
BigDecimal wxHandlingFee = order.getPayPrice().multiply(new BigDecimal("0.002")).setScale(2,BigDecimal.ROUND_HALF_DOWN); |
|
|
|
|
BigDecimal price = order.getPayPrice().subtract(wxHandlingFee); |
|
|
|
|
|
|
|
|
|
Map<String,String> param = new LinkedHashMap<>(); |
|
|
|
|
param.put("appid", "wx637bd6f7314daa46"); |
|
|
|
|
param.put("mch_id", "1289663601"); |
|
|
|
|
param.put("sub_mch_id" , "1609882817"); // 个体户黎杨珍
|
|
|
|
|
param.put("transaction_id" , highOrder.getPaySerialNo()); |
|
|
|
|
param.put("out_order_no" , order.getOrderNo()); |
|
|
|
|
param.put("nonce_str" , WxUtils.makeNonStr()); |
|
|
|
|
|
|
|
|
|
// 计算分账金额 手续费后的价格 * 0.01 注:如果与两个相邻数字的距离相等,则为上舍入的舍入模式。
|
|
|
|
|
BigDecimal porofitSharingAmount = price.multiply(rake).setScale(2,BigDecimal.ROUND_DOWN); |
|
|
|
|
|
|
|
|
|
List<Map<String,Object>> receiversList = new ArrayList<>(); |
|
|
|
|
Map<String,Object> receiversMap = new LinkedHashMap<>(); |
|
|
|
|
receiversMap.put("type", "MERCHANT_ID"); |
|
|
|
|
receiversMap.put("account", "1603942866"); |
|
|
|
|
receiversMap.put("amount", porofitSharingAmount.multiply(new BigDecimal("100")).intValue()); |
|
|
|
|
receiversMap.put("description", "分给商户【惠昕石化】"); |
|
|
|
|
receiversList.add(receiversMap); |
|
|
|
|
param.put("receivers" , JSONObject.toJSONString(receiversList)); |
|
|
|
|
String signStr = WxUtils.generateSignature(param, "Skufk5oi85wDFGl888i6wsRSTkdd5df5" , WXPayConstants.SignType.HMACSHA256); |
|
|
|
|
param.put("sign" , signStr); |
|
|
|
|
String resultXmL = this.doRefundRequest(param.get("mch_id"),null, WxUtils.mapToXml(param)); |
|
|
|
|
|
|
|
|
|
// 请求分账返回的结果
|
|
|
|
|
ResultProfitSharing resultProfitSharing = XmlUtil.getObjectFromXML(resultXmL, ResultProfitSharing.class); |
|
|
|
|
|
|
|
|
|
HighProfitSharingRecord sharingRecord = new HighProfitSharingRecord(); |
|
|
|
|
sharingRecord.setOutOrderNo(resultProfitSharing.getOut_order_no()); |
|
|
|
|
sharingRecord.setTransactionId(resultProfitSharing.getTransaction_id()); |
|
|
|
|
sharingRecord.setOrderId(resultProfitSharing.getOrder_id()); |
|
|
|
|
sharingRecord.setStatus(resultProfitSharing.getResult_code()); |
|
|
|
|
sharingRecord.setPrice(porofitSharingAmount); |
|
|
|
|
sharingRecord.setCreateTime(new Date()); |
|
|
|
|
sharingRecord.setContent(resultXmL); |
|
|
|
|
highProfitSharingRecordService.insert(sharingRecord); |
|
|
|
|
} |
|
|
|
|
Map<String,String> param = new LinkedHashMap<>(); |
|
|
|
|
param.put("appid", "wx637bd6f7314daa46"); |
|
|
|
|
param.put("mch_id", "1289663601"); |
|
|
|
|
param.put("sub_mch_id" , "1609882817"); // 个体户黎杨珍
|
|
|
|
|
param.put("transaction_id" , order.getPaySerialNo()); |
|
|
|
|
param.put("out_order_no" , order.getOrderNo()); |
|
|
|
|
param.put("nonce_str" , WxUtils.makeNonStr()); |
|
|
|
|
|
|
|
|
|
return ResponseMsgUtil.success("操作成功"); |
|
|
|
|
// 计算分账金额 手续费后的价格 * 0.01 注:如果与两个相邻数字的距离相等,则为上舍入的舍入模式。
|
|
|
|
|
BigDecimal porofitSharingAmount = price.multiply(rake).setScale(2,BigDecimal.ROUND_DOWN); |
|
|
|
|
|
|
|
|
|
List<Map<String,Object>> receiversList = new ArrayList<>(); |
|
|
|
|
Map<String,Object> receiversMap = new LinkedHashMap<>(); |
|
|
|
|
receiversMap.put("type", "MERCHANT_ID"); |
|
|
|
|
receiversMap.put("account", "1603942866"); |
|
|
|
|
receiversMap.put("amount", porofitSharingAmount.multiply(new BigDecimal("100")).intValue()); |
|
|
|
|
receiversMap.put("description", "分给商户【惠昕石化】"); |
|
|
|
|
receiversList.add(receiversMap); |
|
|
|
|
param.put("receivers" , JSONObject.toJSONString(receiversList)); |
|
|
|
|
String signStr = WxUtils.generateSignature(param, "Skufk5oi85wDFGl888i6wsRSTkdd5df5" , WXPayConstants.SignType.HMACSHA256); |
|
|
|
|
param.put("sign" , signStr); |
|
|
|
|
String resultXmL = this.doRefundRequest(param.get("mch_id"),null, WxUtils.mapToXml(param)); |
|
|
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
log.error("CmsContentController --> getCorporateAdvertising() error!", e); |
|
|
|
|
return ResponseMsgUtil.success(e); |
|
|
|
|
} |
|
|
|
|
// 请求分账返回的结果
|
|
|
|
|
ResultProfitSharing resultProfitSharing = XmlUtil.getObjectFromXML(resultXmL, ResultProfitSharing.class); |
|
|
|
|
|
|
|
|
|
HighProfitSharingRecord sharingRecord = new HighProfitSharingRecord(); |
|
|
|
|
sharingRecord.setOutOrderNo(resultProfitSharing.getOut_order_no()); |
|
|
|
|
sharingRecord.setTransactionId(resultProfitSharing.getTransaction_id()); |
|
|
|
|
sharingRecord.setOrderId(resultProfitSharing.getOrder_id()); |
|
|
|
|
sharingRecord.setStatus(resultProfitSharing.getResult_code()); |
|
|
|
|
sharingRecord.setPrice(porofitSharingAmount); |
|
|
|
|
sharingRecord.setCreateTime(new Date()); |
|
|
|
|
sharingRecord.setContent(resultXmL); |
|
|
|
|
highProfitSharingRecordService.insert(sharingRecord); |
|
|
|
|
|
|
|
|
|
return ResponseMsgUtil.success("操作成功"); |
|
|
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
log.error("CmsContentController --> getCorporateAdvertising() error!", e); |
|
|
|
|
return ResponseMsgUtil.success(e); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@RequestMapping(value = "/wxEndProfitsharing", method = RequestMethod.GET) |
|
|
|
@ -413,13 +409,15 @@ public class OutRechargeOrderController { |
|
|
|
|
@ApiOperation(value = "完结分账") |
|
|
|
|
public ResponseData wxEndProfitsharing(String transaction_id,String out_order_no, BigDecimal amount) { |
|
|
|
|
try { |
|
|
|
|
|
|
|
|
|
HighOrder orderNo = highOrderService.getOrderByOrderNo("HF2021101812025050304"); |
|
|
|
|
Map<String,String> param = new LinkedHashMap<>(); |
|
|
|
|
param.put("appid", "wx637bd6f7314daa46"); |
|
|
|
|
param.put("mch_id", "1289663601"); |
|
|
|
|
param.put("sub_mch_id" , "1609882817"); // 个体户黎杨珍
|
|
|
|
|
param.put("nonce_str" , WxUtils.makeNonStr()); |
|
|
|
|
param.put("transaction_id" , "4200001158202108094442626740"); |
|
|
|
|
param.put("out_order_no" , "30000408682021080916082519929"); |
|
|
|
|
param.put("transaction_id" , orderNo.getPaySerialNo()); |
|
|
|
|
param.put("out_order_no" , orderNo.getOrderNo()); |
|
|
|
|
param.put("description" , "系统自动完结分账"); |
|
|
|
|
String signStr = WxUtils.generateSignature(param, "Skufk5oi85wDFGl888i6wsRSTkdd5df5" , WXPayConstants.SignType.HMACSHA256); |
|
|
|
|
param.put("sign" , signStr); |
|
|
|
|