From c31310be74325653093d7d422ee6a6cbc65ecefe Mon Sep 17 00:00:00 2001 From: hurui <177768073@qq.com> Date: Wed, 1 Jun 2022 16:20:25 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cweb/controller/pay/OrderController.java | 24 ++++ .../java/com/hai/dao/HighOrderMapper.java | 19 ++- .../com/hai/dao/HighOrderSqlProvider.java | 28 ++++ .../main/java/com/hai/entity/HighOrder.java | 52 +++++-- .../java/com/hai/entity/HighOrderExample.java | 130 ++++++++++++++++++ .../pay/impl/GoodsOrderServiceImpl.java | 64 +++++---- 6 files changed, 273 insertions(+), 44 deletions(-) diff --git a/hai-cweb/src/main/java/com/cweb/controller/pay/OrderController.java b/hai-cweb/src/main/java/com/cweb/controller/pay/OrderController.java index ff42bcfc..095428ac 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/pay/OrderController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/pay/OrderController.java @@ -87,6 +87,9 @@ public class OrderController { @Resource private HighMerchantStoreService merchantStoreService; + @Resource + private HighMerchantTripartitePlatformService tripartitePlatformService; + @Resource private HighQzOrderService highQzOrderService; @@ -211,6 +214,25 @@ public class OrderController { } else if (order.getHighChildOrderList().get(0).getGoodsType() == 3) { weChatPayReqInfo.setSub_mch_id("1624126902"); // 浩联商户号 profitSharing = "Y"; + + // 查询油站 + HighMerchantStoreModel store = merchantStoreService.getMerchantStoreById(order.getHighChildOrderList().get(0).getGoodsId()); + if (store != null && store.getSourceType().equals(1)) { + // 预存类型 0:非预存 1:预存门店 + if (store.getPrestoreType().equals(0)) { + profitSharing = "N"; + + // 第三方平台 + HighMerchantTripartitePlatform merTripartitePlatform = tripartitePlatformService.getDetail(store.getId(), 1); + if (merTripartitePlatform != null) { + weChatPayReqInfo.setSub_mch_id(merTripartitePlatform.getPlatformMerNumber()); + profitSharing = merTripartitePlatform.getProfitSharingStatus().equals(true)?"Y":"N"; + } + } + if (store.getPrestoreType().equals(1)) { + profitSharing = "N"; + } + } } else { //子商户号 weChatPayReqInfo.setSub_mch_id(SysConst.getSysConfig().getWxSubMchId()); @@ -236,6 +258,8 @@ public class OrderController { payMap.put("unified_order_url",SysConst.getSysConfig().getWxUnifiedOrderUrl()); SortedMap sortedMap = wechatPayUtil.goWechatPay(weChatPayReqInfo,payMap); + order.setProfitSharingStatus(profitSharing.equals("y")?true:false); + order.setAccountMerchantNum(weChatPayReqInfo.getSub_mch_id()); order.setExt1(weChatPayReqInfo.getSub_appid()); highOrderService.updateOrderDetail(order); return ResponseMsgUtil.success(sortedMap); diff --git a/hai-service/src/main/java/com/hai/dao/HighOrderMapper.java b/hai-service/src/main/java/com/hai/dao/HighOrderMapper.java index 99cefb59..8c8a611c 100644 --- a/hai-service/src/main/java/com/hai/dao/HighOrderMapper.java +++ b/hai-service/src/main/java/com/hai/dao/HighOrderMapper.java @@ -53,7 +53,8 @@ public interface HighOrderMapper extends HighOrderMapperExt { "finish_time, remarks, ", "refund_time, refund_price, ", "refund_content, refusal_refund_content, ", - "Identification_code, ext_1, ", + "Identification_code, profit_sharing_status, ", + "account_merchant_num, ext_1, ", "ext_2, ext_3)", "values (#{orderNo,jdbcType=VARCHAR}, #{memDiscountId,jdbcType=BIGINT}, ", "#{memDiscountName,jdbcType=VARCHAR}, #{memId,jdbcType=BIGINT}, ", @@ -69,7 +70,8 @@ public interface HighOrderMapper extends HighOrderMapperExt { "#{finishTime,jdbcType=TIMESTAMP}, #{remarks,jdbcType=VARCHAR}, ", "#{refundTime,jdbcType=TIMESTAMP}, #{refundPrice,jdbcType=DECIMAL}, ", "#{refundContent,jdbcType=VARCHAR}, #{refusalRefundContent,jdbcType=VARCHAR}, ", - "#{identificationCode,jdbcType=BIGINT}, #{ext1,jdbcType=VARCHAR}, ", + "#{identificationCode,jdbcType=BIGINT}, #{profitSharingStatus,jdbcType=BIT}, ", + "#{accountMerchantNum,jdbcType=VARCHAR}, #{ext1,jdbcType=VARCHAR}, ", "#{ext2,jdbcType=VARCHAR}, #{ext3,jdbcType=VARCHAR})" }) @Options(useGeneratedKeys=true,keyProperty="id") @@ -111,6 +113,8 @@ public interface HighOrderMapper extends HighOrderMapperExt { @Result(column="refund_content", property="refundContent", jdbcType=JdbcType.VARCHAR), @Result(column="refusal_refund_content", property="refusalRefundContent", jdbcType=JdbcType.VARCHAR), @Result(column="Identification_code", property="identificationCode", jdbcType=JdbcType.BIGINT), + @Result(column="profit_sharing_status", property="profitSharingStatus", jdbcType=JdbcType.BIT), + @Result(column="account_merchant_num", property="accountMerchantNum", jdbcType=JdbcType.VARCHAR), @Result(column="ext_1", property="ext1", jdbcType=JdbcType.VARCHAR), @Result(column="ext_2", property="ext2", jdbcType=JdbcType.VARCHAR), @Result(column="ext_3", property="ext3", jdbcType=JdbcType.VARCHAR) @@ -123,7 +127,8 @@ public interface HighOrderMapper extends HighOrderMapperExt { "mem_card_id, mem_card_type, mem_card_no, pay_model, pay_type, pay_gold, pay_price, ", "pay_real_price, pay_serial_no, deduction_price, order_status, total_price, create_time, ", "pay_time, cancel_time, cancel_remarks, finish_time, remarks, refund_time, refund_price, ", - "refund_content, refusal_refund_content, Identification_code, ext_1, ext_2, ext_3", + "refund_content, refusal_refund_content, Identification_code, profit_sharing_status, ", + "account_merchant_num, ext_1, ext_2, ext_3", "from high_order", "where id = #{id,jdbcType=BIGINT}" }) @@ -158,6 +163,8 @@ public interface HighOrderMapper extends HighOrderMapperExt { @Result(column="refund_content", property="refundContent", jdbcType=JdbcType.VARCHAR), @Result(column="refusal_refund_content", property="refusalRefundContent", jdbcType=JdbcType.VARCHAR), @Result(column="Identification_code", property="identificationCode", jdbcType=JdbcType.BIGINT), + @Result(column="profit_sharing_status", property="profitSharingStatus", jdbcType=JdbcType.BIT), + @Result(column="account_merchant_num", property="accountMerchantNum", jdbcType=JdbcType.VARCHAR), @Result(column="ext_1", property="ext1", jdbcType=JdbcType.VARCHAR), @Result(column="ext_2", property="ext2", jdbcType=JdbcType.VARCHAR), @Result(column="ext_3", property="ext3", jdbcType=JdbcType.VARCHAR) @@ -204,12 +211,12 @@ public interface HighOrderMapper extends HighOrderMapperExt { "refund_content = #{refundContent,jdbcType=VARCHAR},", "refusal_refund_content = #{refusalRefundContent,jdbcType=VARCHAR},", "Identification_code = #{identificationCode,jdbcType=BIGINT},", + "profit_sharing_status = #{profitSharingStatus,jdbcType=BIT},", + "account_merchant_num = #{accountMerchantNum,jdbcType=VARCHAR},", "ext_1 = #{ext1,jdbcType=VARCHAR},", "ext_2 = #{ext2,jdbcType=VARCHAR},", "ext_3 = #{ext3,jdbcType=VARCHAR}", "where id = #{id,jdbcType=BIGINT}" }) int updateByPrimaryKey(HighOrder record); - - -} +} \ No newline at end of file diff --git a/hai-service/src/main/java/com/hai/dao/HighOrderSqlProvider.java b/hai-service/src/main/java/com/hai/dao/HighOrderSqlProvider.java index 10dd906d..c3aba52d 100644 --- a/hai-service/src/main/java/com/hai/dao/HighOrderSqlProvider.java +++ b/hai-service/src/main/java/com/hai/dao/HighOrderSqlProvider.java @@ -144,6 +144,14 @@ public class HighOrderSqlProvider { sql.VALUES("Identification_code", "#{identificationCode,jdbcType=BIGINT}"); } + if (record.getProfitSharingStatus() != null) { + sql.VALUES("profit_sharing_status", "#{profitSharingStatus,jdbcType=BIT}"); + } + + if (record.getAccountMerchantNum() != null) { + sql.VALUES("account_merchant_num", "#{accountMerchantNum,jdbcType=VARCHAR}"); + } + if (record.getExt1() != null) { sql.VALUES("ext_1", "#{ext1,jdbcType=VARCHAR}"); } @@ -195,6 +203,8 @@ public class HighOrderSqlProvider { sql.SELECT("refund_content"); sql.SELECT("refusal_refund_content"); sql.SELECT("Identification_code"); + sql.SELECT("profit_sharing_status"); + sql.SELECT("account_merchant_num"); sql.SELECT("ext_1"); sql.SELECT("ext_2"); sql.SELECT("ext_3"); @@ -335,6 +345,14 @@ public class HighOrderSqlProvider { sql.SET("Identification_code = #{record.identificationCode,jdbcType=BIGINT}"); } + if (record.getProfitSharingStatus() != null) { + sql.SET("profit_sharing_status = #{record.profitSharingStatus,jdbcType=BIT}"); + } + + if (record.getAccountMerchantNum() != null) { + sql.SET("account_merchant_num = #{record.accountMerchantNum,jdbcType=VARCHAR}"); + } + if (record.getExt1() != null) { sql.SET("ext_1 = #{record.ext1,jdbcType=VARCHAR}"); } @@ -385,6 +403,8 @@ public class HighOrderSqlProvider { sql.SET("refund_content = #{record.refundContent,jdbcType=VARCHAR}"); sql.SET("refusal_refund_content = #{record.refusalRefundContent,jdbcType=VARCHAR}"); sql.SET("Identification_code = #{record.identificationCode,jdbcType=BIGINT}"); + sql.SET("profit_sharing_status = #{record.profitSharingStatus,jdbcType=BIT}"); + sql.SET("account_merchant_num = #{record.accountMerchantNum,jdbcType=VARCHAR}"); sql.SET("ext_1 = #{record.ext1,jdbcType=VARCHAR}"); sql.SET("ext_2 = #{record.ext2,jdbcType=VARCHAR}"); sql.SET("ext_3 = #{record.ext3,jdbcType=VARCHAR}"); @@ -514,6 +534,14 @@ public class HighOrderSqlProvider { sql.SET("Identification_code = #{identificationCode,jdbcType=BIGINT}"); } + if (record.getProfitSharingStatus() != null) { + sql.SET("profit_sharing_status = #{profitSharingStatus,jdbcType=BIT}"); + } + + if (record.getAccountMerchantNum() != null) { + sql.SET("account_merchant_num = #{accountMerchantNum,jdbcType=VARCHAR}"); + } + if (record.getExt1() != null) { sql.SET("ext_1 = #{ext1,jdbcType=VARCHAR}"); } diff --git a/hai-service/src/main/java/com/hai/entity/HighOrder.java b/hai-service/src/main/java/com/hai/entity/HighOrder.java index cf0c1f52..f26e5068 100644 --- a/hai-service/src/main/java/com/hai/entity/HighOrder.java +++ b/hai-service/src/main/java/com/hai/entity/HighOrder.java @@ -71,7 +71,7 @@ public class HighOrder implements Serializable { private Integer payModel; /** - * 支付方式: 1:支付宝 2:微信 3:金币 4:汇联通工会卡 + * 支付方式: 1:支付宝 2:微信 3:金币 4:汇联通工会卡 5:银联 6:银联分期 */ private Integer payType; @@ -101,7 +101,7 @@ public class HighOrder implements Serializable { private BigDecimal deductionPrice; /** - * 订单状态:1 待支付 2 已支付 3.已完成 4. 已退款 5.已取消 6.退款中 7.拒绝退款 + * 订单状态:1 待支付 2 已支付 3.已完成 4. 已退款 5.已取消 6.退款中 7.拒绝退款 */ private Integer orderStatus; @@ -165,6 +165,16 @@ public class HighOrder implements Serializable { */ private Long identificationCode; + /** + * 是否分账 + */ + private Boolean profitSharingStatus; + + /** + * 进账商户号 + */ + private String accountMerchantNum; + private String ext1; private String ext2; @@ -177,14 +187,6 @@ public class HighOrder implements Serializable { private Boolean isTyAgent; - public Boolean getIsTyAgent() { - return isTyAgent; - } - - public void setIsTyAgent(Boolean tyAgent) { - isTyAgent = tyAgent; - } - public List getHighChildOrderList() { return highChildOrderList; } @@ -201,6 +203,14 @@ public class HighOrder implements Serializable { this.highDiscount = highDiscount; } + public Boolean getTyAgent() { + return isTyAgent; + } + + public void setTyAgent(Boolean tyAgent) { + isTyAgent = tyAgent; + } + private static final long serialVersionUID = 1L; public Long getId() { @@ -443,6 +453,22 @@ public class HighOrder implements Serializable { this.identificationCode = identificationCode; } + public Boolean getProfitSharingStatus() { + return profitSharingStatus; + } + + public void setProfitSharingStatus(Boolean profitSharingStatus) { + this.profitSharingStatus = profitSharingStatus; + } + + public String getAccountMerchantNum() { + return accountMerchantNum; + } + + public void setAccountMerchantNum(String accountMerchantNum) { + this.accountMerchantNum = accountMerchantNum; + } + public String getExt1() { return ext1; } @@ -509,6 +535,8 @@ public class HighOrder implements Serializable { && (this.getRefundContent() == null ? other.getRefundContent() == null : this.getRefundContent().equals(other.getRefundContent())) && (this.getRefusalRefundContent() == null ? other.getRefusalRefundContent() == null : this.getRefusalRefundContent().equals(other.getRefusalRefundContent())) && (this.getIdentificationCode() == null ? other.getIdentificationCode() == null : this.getIdentificationCode().equals(other.getIdentificationCode())) + && (this.getProfitSharingStatus() == null ? other.getProfitSharingStatus() == null : this.getProfitSharingStatus().equals(other.getProfitSharingStatus())) + && (this.getAccountMerchantNum() == null ? other.getAccountMerchantNum() == null : this.getAccountMerchantNum().equals(other.getAccountMerchantNum())) && (this.getExt1() == null ? other.getExt1() == null : this.getExt1().equals(other.getExt1())) && (this.getExt2() == null ? other.getExt2() == null : this.getExt2().equals(other.getExt2())) && (this.getExt3() == null ? other.getExt3() == null : this.getExt3().equals(other.getExt3())); @@ -548,6 +576,8 @@ public class HighOrder implements Serializable { result = prime * result + ((getRefundContent() == null) ? 0 : getRefundContent().hashCode()); result = prime * result + ((getRefusalRefundContent() == null) ? 0 : getRefusalRefundContent().hashCode()); result = prime * result + ((getIdentificationCode() == null) ? 0 : getIdentificationCode().hashCode()); + result = prime * result + ((getProfitSharingStatus() == null) ? 0 : getProfitSharingStatus().hashCode()); + result = prime * result + ((getAccountMerchantNum() == null) ? 0 : getAccountMerchantNum().hashCode()); result = prime * result + ((getExt1() == null) ? 0 : getExt1().hashCode()); result = prime * result + ((getExt2() == null) ? 0 : getExt2().hashCode()); result = prime * result + ((getExt3() == null) ? 0 : getExt3().hashCode()); @@ -590,6 +620,8 @@ public class HighOrder implements Serializable { sb.append(", refundContent=").append(refundContent); sb.append(", refusalRefundContent=").append(refusalRefundContent); sb.append(", identificationCode=").append(identificationCode); + sb.append(", profitSharingStatus=").append(profitSharingStatus); + sb.append(", accountMerchantNum=").append(accountMerchantNum); sb.append(", ext1=").append(ext1); sb.append(", ext2=").append(ext2); sb.append(", ext3=").append(ext3); diff --git a/hai-service/src/main/java/com/hai/entity/HighOrderExample.java b/hai-service/src/main/java/com/hai/entity/HighOrderExample.java index ffb207fb..1d21409a 100644 --- a/hai-service/src/main/java/com/hai/entity/HighOrderExample.java +++ b/hai-service/src/main/java/com/hai/entity/HighOrderExample.java @@ -2026,6 +2026,136 @@ public class HighOrderExample { return (Criteria) this; } + public Criteria andProfitSharingStatusIsNull() { + addCriterion("profit_sharing_status is null"); + return (Criteria) this; + } + + public Criteria andProfitSharingStatusIsNotNull() { + addCriterion("profit_sharing_status is not null"); + return (Criteria) this; + } + + public Criteria andProfitSharingStatusEqualTo(Boolean value) { + addCriterion("profit_sharing_status =", value, "profitSharingStatus"); + return (Criteria) this; + } + + public Criteria andProfitSharingStatusNotEqualTo(Boolean value) { + addCriterion("profit_sharing_status <>", value, "profitSharingStatus"); + return (Criteria) this; + } + + public Criteria andProfitSharingStatusGreaterThan(Boolean value) { + addCriterion("profit_sharing_status >", value, "profitSharingStatus"); + return (Criteria) this; + } + + public Criteria andProfitSharingStatusGreaterThanOrEqualTo(Boolean value) { + addCriterion("profit_sharing_status >=", value, "profitSharingStatus"); + return (Criteria) this; + } + + public Criteria andProfitSharingStatusLessThan(Boolean value) { + addCriterion("profit_sharing_status <", value, "profitSharingStatus"); + return (Criteria) this; + } + + public Criteria andProfitSharingStatusLessThanOrEqualTo(Boolean value) { + addCriterion("profit_sharing_status <=", value, "profitSharingStatus"); + return (Criteria) this; + } + + public Criteria andProfitSharingStatusIn(List values) { + addCriterion("profit_sharing_status in", values, "profitSharingStatus"); + return (Criteria) this; + } + + public Criteria andProfitSharingStatusNotIn(List values) { + addCriterion("profit_sharing_status not in", values, "profitSharingStatus"); + return (Criteria) this; + } + + public Criteria andProfitSharingStatusBetween(Boolean value1, Boolean value2) { + addCriterion("profit_sharing_status between", value1, value2, "profitSharingStatus"); + return (Criteria) this; + } + + public Criteria andProfitSharingStatusNotBetween(Boolean value1, Boolean value2) { + addCriterion("profit_sharing_status not between", value1, value2, "profitSharingStatus"); + return (Criteria) this; + } + + public Criteria andAccountMerchantNumIsNull() { + addCriterion("account_merchant_num is null"); + return (Criteria) this; + } + + public Criteria andAccountMerchantNumIsNotNull() { + addCriterion("account_merchant_num is not null"); + return (Criteria) this; + } + + public Criteria andAccountMerchantNumEqualTo(String value) { + addCriterion("account_merchant_num =", value, "accountMerchantNum"); + return (Criteria) this; + } + + public Criteria andAccountMerchantNumNotEqualTo(String value) { + addCriterion("account_merchant_num <>", value, "accountMerchantNum"); + return (Criteria) this; + } + + public Criteria andAccountMerchantNumGreaterThan(String value) { + addCriterion("account_merchant_num >", value, "accountMerchantNum"); + return (Criteria) this; + } + + public Criteria andAccountMerchantNumGreaterThanOrEqualTo(String value) { + addCriterion("account_merchant_num >=", value, "accountMerchantNum"); + return (Criteria) this; + } + + public Criteria andAccountMerchantNumLessThan(String value) { + addCriterion("account_merchant_num <", value, "accountMerchantNum"); + return (Criteria) this; + } + + public Criteria andAccountMerchantNumLessThanOrEqualTo(String value) { + addCriterion("account_merchant_num <=", value, "accountMerchantNum"); + return (Criteria) this; + } + + public Criteria andAccountMerchantNumLike(String value) { + addCriterion("account_merchant_num like", value, "accountMerchantNum"); + return (Criteria) this; + } + + public Criteria andAccountMerchantNumNotLike(String value) { + addCriterion("account_merchant_num not like", value, "accountMerchantNum"); + return (Criteria) this; + } + + public Criteria andAccountMerchantNumIn(List values) { + addCriterion("account_merchant_num in", values, "accountMerchantNum"); + return (Criteria) this; + } + + public Criteria andAccountMerchantNumNotIn(List values) { + addCriterion("account_merchant_num not in", values, "accountMerchantNum"); + return (Criteria) this; + } + + public Criteria andAccountMerchantNumBetween(String value1, String value2) { + addCriterion("account_merchant_num between", value1, value2, "accountMerchantNum"); + return (Criteria) this; + } + + public Criteria andAccountMerchantNumNotBetween(String value1, String value2) { + addCriterion("account_merchant_num not between", value1, value2, "accountMerchantNum"); + return (Criteria) this; + } + public Criteria andExt1IsNull() { addCriterion("ext_1 is null"); return (Criteria) this; diff --git a/hai-service/src/main/java/com/hai/service/pay/impl/GoodsOrderServiceImpl.java b/hai-service/src/main/java/com/hai/service/pay/impl/GoodsOrderServiceImpl.java index ffc16c68..7c167757 100644 --- a/hai-service/src/main/java/com/hai/service/pay/impl/GoodsOrderServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/pay/impl/GoodsOrderServiceImpl.java @@ -442,33 +442,41 @@ public class GoodsOrderServiceImpl implements PayService { if (order.getHighChildOrderList().get(0).getGoodsType().equals(3)) { - new Thread(() -> { - Map pushMsg = new HashMap<>(); - pushMsg.put("userId", order.getHighChildOrderList().get(0).getGoodsId()); - - Map msgContent = new HashMap<>(); - msgContent.put("order", highOrderService.getGasOrderDetail(order.getOrderNo())); - msgContent.put("voice", baiduVoiceService.text2audio(order.getHighChildOrderList().get(0).getGoodsName() + ",收款:" + order.getTotalPrice() + "元")); - pushMsg.put("message", JSONObject.toJSONString(msgContent)); - HttpsUtils.doPost("http://127.0.0.1:9901/msg/websocket/websocket", pushMsg, new HashMap<>()); - }).start(); - - 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.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(); + // 加油站 + HighMerchantStoreModel store = highMerchantStoreService.getMerchantStoreById(order.getHighChildOrderList().get(0).getGoodsId()); + if (store != null) { + if (store.getSourceType() != null && store.getSourceType().equals(1)) { + new Thread(() -> { + Map pushMsg = new HashMap<>(); + pushMsg.put("userId", order.getHighChildOrderList().get(0).getGoodsId()); + + Map msgContent = new HashMap<>(); + msgContent.put("order", highOrderService.getGasOrderDetail(order.getOrderNo())); + msgContent.put("voice", baiduVoiceService.text2audio(order.getHighChildOrderList().get(0).getGoodsName() + ",收款:" + order.getTotalPrice() + "元")); + pushMsg.put("message", JSONObject.toJSONString(msgContent)); + HttpsUtils.doPost("http://127.0.0.1:9901/msg/websocket/websocket", pushMsg, new HashMap<>()); + }).start(); } - }).start(); + } + + if (order.getProfitSharingStatus() == true) { + 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.05 注:如果与两个相邻数字的距离相等,则为上舍入的舍入模式。 + BigDecimal profitSharingAmount = price.multiply(rake).setScale(2,BigDecimal.ROUND_DOWN); + this.wxGasProfitsharing(order.getExt1(), order.getAccountMerchantNum(), order.getPaySerialNo(),order.getOrderNo(),profitSharingAmount); + } catch (InterruptedException e) { + e.printStackTrace(); + } + }).start(); + } } else { new Thread(() -> { try { @@ -504,12 +512,12 @@ public class GoodsOrderServiceImpl implements PayService { System.out.println("实际分账价格:" + profitSharingAmount); } - public void wxGasProfitsharing(String appid, String transaction_id,String out_order_no, BigDecimal amount) { + public void wxGasProfitsharing(String appid, String subMchId, String transaction_id,String out_order_no, BigDecimal amount) { try { Map param = new LinkedHashMap<>(); param.put("appid", appid); param.put("mch_id", "1289663601"); - param.put("sub_mch_id" , "1624126902"); // 渝北区浩联物资经营部 + param.put("sub_mch_id" , subMchId); // 渝北区浩联物资经营部 param.put("transaction_id" , transaction_id); param.put("out_order_no" , out_order_no); param.put("nonce_str" , WxUtils.makeNonStr());