|
|
|
@ -380,33 +380,64 @@ public class GoodsOrderServiceImpl implements PayService { |
|
|
|
|
|
|
|
|
|
highOrderService.updateOrder(order); |
|
|
|
|
|
|
|
|
|
new Thread(() -> { |
|
|
|
|
try { |
|
|
|
|
Thread.sleep(120*1000); |
|
|
|
|
BigDecimal rake = new BigDecimal("0.01"); |
|
|
|
|
|
|
|
|
|
// 计算微信收取的手续费 支付金额 * 0.002 注:如果与两个相邻数字的距离相等,则为上舍入的舍入模式。
|
|
|
|
|
BigDecimal wxHandlingFee = order.getPayRealPrice().multiply(new BigDecimal("0.002")).setScale(2,BigDecimal.ROUND_HALF_DOWN); |
|
|
|
|
BigDecimal price = order.getPayRealPrice().subtract(wxHandlingFee); |
|
|
|
|
|
|
|
|
|
// 计算分账金额 手续费后的价格 * 0.01 注:如果与两个相邻数字的距离相等,则为上舍入的舍入模式。
|
|
|
|
|
BigDecimal profitSharingAmount = price.multiply(rake).setScale(2,BigDecimal.ROUND_DOWN); |
|
|
|
|
this.wxProfitsharing(order.getPaySerialNo(),order.getOrderNo(),profitSharingAmount); |
|
|
|
|
} catch (InterruptedException e) { |
|
|
|
|
e.printStackTrace(); |
|
|
|
|
} |
|
|
|
|
}).start(); |
|
|
|
|
if (order.getHighChildOrderList().get(0).getGoodsType().equals(3)) { |
|
|
|
|
new Thread(() -> { |
|
|
|
|
try { |
|
|
|
|
Thread.sleep(120*1000); |
|
|
|
|
BigDecimal rake = new BigDecimal("0.05"); |
|
|
|
|
|
|
|
|
|
// 计算微信收取的手续费 支付金额 * 0.002 注:如果与两个相邻数字的距离相等,则为上舍入的舍入模式。
|
|
|
|
|
BigDecimal wxHandlingFee = order.getPayRealPrice().multiply(new BigDecimal("0.002")).setScale(2,BigDecimal.ROUND_HALF_DOWN); |
|
|
|
|
BigDecimal price = order.getPayRealPrice().subtract(wxHandlingFee); |
|
|
|
|
|
|
|
|
|
// 计算分账金额 手续费后的价格 * 0.05 注:如果与两个相邻数字的距离相等,则为上舍入的舍入模式。
|
|
|
|
|
BigDecimal profitSharingAmount = price.multiply(rake).setScale(2,BigDecimal.ROUND_DOWN); |
|
|
|
|
this.wxGasProfitsharing(order.getExt1(), order.getPaySerialNo(),order.getOrderNo(),profitSharingAmount); |
|
|
|
|
} catch (InterruptedException e) { |
|
|
|
|
e.printStackTrace(); |
|
|
|
|
} |
|
|
|
|
}).start(); |
|
|
|
|
} else { |
|
|
|
|
new Thread(() -> { |
|
|
|
|
try { |
|
|
|
|
Thread.sleep(120*1000); |
|
|
|
|
BigDecimal rake = new BigDecimal("0.01"); |
|
|
|
|
|
|
|
|
|
// 计算微信收取的手续费 支付金额 * 0.002 注:如果与两个相邻数字的距离相等,则为上舍入的舍入模式。
|
|
|
|
|
BigDecimal wxHandlingFee = order.getPayRealPrice().multiply(new BigDecimal("0.002")).setScale(2,BigDecimal.ROUND_HALF_DOWN); |
|
|
|
|
BigDecimal price = order.getPayRealPrice().subtract(wxHandlingFee); |
|
|
|
|
|
|
|
|
|
// 计算分账金额 手续费后的价格 * 0.01 注:如果与两个相邻数字的距离相等,则为上舍入的舍入模式。
|
|
|
|
|
BigDecimal profitSharingAmount = price.multiply(rake).setScale(2,BigDecimal.ROUND_DOWN); |
|
|
|
|
this.wxProfitsharing(order.getExt1(), order.getPaySerialNo(),order.getOrderNo(),profitSharingAmount); |
|
|
|
|
} catch (InterruptedException e) { |
|
|
|
|
e.printStackTrace(); |
|
|
|
|
} |
|
|
|
|
}).start(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static void main(String[] args) { |
|
|
|
|
BigDecimal totalPrice = new BigDecimal("100"); |
|
|
|
|
|
|
|
|
|
public void wxProfitsharing(String transaction_id,String out_order_no, BigDecimal amount) { |
|
|
|
|
BigDecimal wxHandlingFee = totalPrice.multiply(new BigDecimal("0.002")).setScale(2,BigDecimal.ROUND_HALF_DOWN); |
|
|
|
|
System.out.println("手续费:" + wxHandlingFee); |
|
|
|
|
|
|
|
|
|
BigDecimal price = totalPrice.subtract(wxHandlingFee); |
|
|
|
|
System.out.println("扣除手机费后的价格:" + price); |
|
|
|
|
|
|
|
|
|
BigDecimal profitSharingAmount = price.multiply(new BigDecimal("0.05")).setScale(2,BigDecimal.ROUND_DOWN); |
|
|
|
|
System.out.println("实际分账价格:" + profitSharingAmount); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void wxGasProfitsharing(String appid, String transaction_id,String out_order_no, BigDecimal amount) { |
|
|
|
|
try { |
|
|
|
|
Map<String,String> param = new LinkedHashMap<>(); |
|
|
|
|
param.put("appid", "wx637bd6f7314daa46"); |
|
|
|
|
param.put("appid", appid); |
|
|
|
|
param.put("mch_id", "1289663601"); |
|
|
|
|
param.put("sub_mch_id" , "1609882817"); // 个体户黎杨珍
|
|
|
|
|
param.put("sub_mch_id" , "1624126902"); // 渝北区浩联物资经营部
|
|
|
|
|
param.put("transaction_id" , transaction_id); |
|
|
|
|
param.put("out_order_no" , out_order_no); |
|
|
|
|
param.put("nonce_str" , WxUtils.makeNonStr()); |
|
|
|
@ -444,6 +475,48 @@ public class GoodsOrderServiceImpl implements PayService { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void wxProfitsharing(String appid,String transaction_id,String out_order_no, BigDecimal amount) { |
|
|
|
|
try { |
|
|
|
|
Map<String,String> param = new LinkedHashMap<>(); |
|
|
|
|
param.put("appid", appid); |
|
|
|
|
param.put("mch_id", "1289663601"); |
|
|
|
|
param.put("sub_mch_id" , "1609882817"); // 个体户黎杨珍
|
|
|
|
|
param.put("transaction_id" , transaction_id); |
|
|
|
|
param.put("out_order_no" , out_order_no); |
|
|
|
|
param.put("nonce_str" , WxUtils.makeNonStr()); |
|
|
|
|
|
|
|
|
|
// 分账金额
|
|
|
|
|
BigDecimal porofitSharingAmount = amount; |
|
|
|
|
|
|
|
|
|
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(out_order_no); |
|
|
|
|
sharingRecord.setTransactionId(transaction_id); |
|
|
|
|
sharingRecord.setOrderId(resultProfitSharing.getOrder_id()); |
|
|
|
|
sharingRecord.setStatus(resultProfitSharing.getResult_code()); |
|
|
|
|
sharingRecord.setPrice(amount); |
|
|
|
|
sharingRecord.setCreateTime(new Date()); |
|
|
|
|
sharingRecord.setContent(resultXmL); |
|
|
|
|
highProfitSharingRecordService.insert(sharingRecord); |
|
|
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
log.error("CmsContentController --> getCorporateAdvertising() error!", e); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public CloseableHttpClient readCertificate(String mchId) throws Exception{ |
|
|
|
|
/** |
|
|
|
|