提交代码

dev-discount
胡锐 3 years ago
parent 9930e9d779
commit 43796a6072
  1. 14
      hai-cweb/src/main/java/com/cweb/controller/HighTestController.java
  2. 100
      hai-cweb/src/main/java/com/cweb/controller/OutRechargeOrderController.java
  3. 1
      hai-service/src/main/java/com/hai/dao/CmsContentMapperExt.java
  4. 4
      hai-service/src/main/java/com/hai/service/pay/impl/GoodsOrderServiceImpl.java

@ -268,6 +268,20 @@ public class HighTestController {
}
}
@RequestMapping(value = "/wxSplitAccount", method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "微信分账")
public ResponseData wxSplitAccount() {
try {
HighOrder orderNo = highOrderService.getOrderByOrderNo("HF2021101812025050304");
wxProfitsharing(orderNo.getOrderNo(),orderNo.getPaySerialNo(),orderNo.getPayRealPrice());
return ResponseMsgUtil.success("分账成功");
} catch (Exception e) {
log.error("HighOrderController --> getOrderById() error!", e);
return ResponseMsgUtil.exception(e);
}
}
public void wxProfitsharing(String transaction_id,String out_order_no, BigDecimal amount) {
try {

@ -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);

@ -60,6 +60,7 @@ public interface CmsContentMapperExt {
@Result(column="tag", property="tag", jdbcType= JdbcType.VARCHAR),
@Result(column="img_source", property="imgSource", jdbcType= JdbcType.TINYINT),
@Result(column="img_data", property="imgData", jdbcType= JdbcType.VARCHAR),
@Result(column="jump_type", property="jumpType", jdbcType= JdbcType.INTEGER),
@Result(column="jump_name", property="jumpName", jdbcType= JdbcType.VARCHAR),
@Result(column="jump_url", property="jumpUrl", jdbcType= JdbcType.VARCHAR),
@Result(column="sort_id", property="sortId", jdbcType= JdbcType.INTEGER),

@ -315,8 +315,8 @@ public class GoodsOrderServiceImpl implements PayService {
ResultProfitSharing resultProfitSharing = XmlUtil.getObjectFromXML(resultXmL, ResultProfitSharing.class);
HighProfitSharingRecord sharingRecord = new HighProfitSharingRecord();
sharingRecord.setOutOrderNo(resultProfitSharing.getOut_order_no());
sharingRecord.setTransactionId(resultProfitSharing.getTransaction_id());
sharingRecord.setOutOrderNo(out_order_no);
sharingRecord.setTransactionId(transaction_id);
sharingRecord.setOrderId(resultProfitSharing.getOrder_id());
sharingRecord.setStatus(resultProfitSharing.getResult_code());
sharingRecord.setPrice(amount);

Loading…
Cancel
Save