From 3f30b2875ca1aead4346c31c98a1f0961958d950 Mon Sep 17 00:00:00 2001 From: xhxu Date: Fri, 16 Sep 2022 14:32:47 +0800 Subject: [PATCH] //rate share --- .../app/WxPayAccountController.java | 1 + .../V2022091400001__add_pay_account.sql | 5 ++- .../controller/WxPayAccountController.java | 1 + .../com/iformall/domain/po/WxPayAccount.java | 2 ++ .../impl/TtCouponGoodsServiceImpl.java | 32 +++++++++++++------ .../impl/WxProfitSharingOrderServiceImpl.java | 2 +- .../resources/mapper/WxPayAccountMapper.xml | 6 +++- 7 files changed, 37 insertions(+), 12 deletions(-) diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/app/WxPayAccountController.java b/mallinkAdmin/src/main/java/com/iformall/controller/app/WxPayAccountController.java index d875c3b61..ad0d2f280 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/app/WxPayAccountController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/app/WxPayAccountController.java @@ -56,6 +56,7 @@ public class WxPayAccountController extends BaseController { returnPayAccount.setOpenPay(payAccount.getOpenPay()); returnPayAccount.setPayVersion(payAccount.getPayVersion()); returnPayAccount.setShare(payAccount.getShare()); + returnPayAccount.setIsCommission(payAccount.getIsCommission()); return new ResultData(returnPayAccount); } diff --git a/mallinkAdmin/src/main/resources/db/migration/V2022091400001__add_pay_account.sql b/mallinkAdmin/src/main/resources/db/migration/V2022091400001__add_pay_account.sql index 1640cb093..13c094519 100644 --- a/mallinkAdmin/src/main/resources/db/migration/V2022091400001__add_pay_account.sql +++ b/mallinkAdmin/src/main/resources/db/migration/V2022091400001__add_pay_account.sql @@ -1,2 +1,5 @@ ALTER TABLE `mallink`.`wx_pay_account` -ADD COLUMN `sell_rate` int(6) NOT NULL DEFAULT 0 COMMENT '销售提点' AFTER `system_rate`; \ No newline at end of file +ADD COLUMN `sell_rate` int(6) NOT NULL DEFAULT 0 COMMENT '销售提点' AFTER `system_rate`; + +ALTER TABLE `mallink`.`wx_pay_account` +ADD COLUMN `is_commission` smallint(2) NOT NULL DEFAULT 0 COMMENT '是否抽佣' AFTER `real_rate`; \ No newline at end of file diff --git a/mallinkBApi/src/main/java/com/iformall/controller/WxPayAccountController.java b/mallinkBApi/src/main/java/com/iformall/controller/WxPayAccountController.java index 30ab1d6bf..00f545be3 100644 --- a/mallinkBApi/src/main/java/com/iformall/controller/WxPayAccountController.java +++ b/mallinkBApi/src/main/java/com/iformall/controller/WxPayAccountController.java @@ -66,6 +66,7 @@ public class WxPayAccountController extends BaseController { returnPayAccount.setOpenPay(payAccount.getOpenPay()); returnPayAccount.setPayVersion(payAccount.getPayVersion()); returnPayAccount.setShare(payAccount.getShare()); + returnPayAccount.setIsCommission(payAccount.getIsCommission()); return new ResultData(returnPayAccount); } diff --git a/mallinkService/src/main/java/com/iformall/domain/po/WxPayAccount.java b/mallinkService/src/main/java/com/iformall/domain/po/WxPayAccount.java index ede8c9c25..4a2e21415 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/WxPayAccount.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/WxPayAccount.java @@ -56,6 +56,8 @@ public class WxPayAccount extends TenantEntity { private Integer rate; @io.swagger.annotations.ApiModelProperty(value="实际手续费(万分之几,默认60)",name="realRate") private Integer realRate; + @io.swagger.annotations.ApiModelProperty(value="是否抽成",name="isCommission") + private Integer isCommission; @io.swagger.annotations.ApiModelProperty(value="系统提点",name="systemRate") private Integer systemRate; @io.swagger.annotations.ApiModelProperty(value="销售提点",name="sellRate") diff --git a/mallinkService/src/main/java/com/iformall/service/impl/TtCouponGoodsServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/TtCouponGoodsServiceImpl.java index b0f7d5d1d..380d464b6 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/TtCouponGoodsServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/TtCouponGoodsServiceImpl.java @@ -693,7 +693,13 @@ public class TtCouponGoodsServiceImpl implements TtCouponGoodsService { map.put("realRate",payAccount.getRealRate()); map.put("systemRate",payAccount.getSystemRate()+payAccount.getSellRate()); - int rate = payAccount.getRealRate()+payAccount.getSystemRate()+payAccount.getSellRate(); + int rate = 0; + if(EnumYesOrNo.YES.getCode().equals(payAccount.getIsCommission())){ + rate = payAccount.getRealRate()+payAccount.getSystemRate()+payAccount.getSellRate(); + }else{ + rate = payAccount.getRealRate(); + } + if(EnumAppPlat.TOUTIAO.getCode().equals(couponAppInfo.getPlat())){ if(wxCoupon.getCategoryId() == null){ return new ResultData(ErrorCode.COUPON_ORDER_TYPE_NOT_SUPPORTED.getCode(),"卡券信息错误"); @@ -705,7 +711,6 @@ public class TtCouponGoodsServiceImpl implements TtCouponGoodsService { if(maxTakeRate != null){ rate += maxTakeRate; } - rate += getRateMin(); } map.put("mallMax",getAllMax()); @@ -745,7 +750,7 @@ public class TtCouponGoodsServiceImpl implements TtCouponGoodsService { if(ttPoiTakeRate != null){ takeRate = ttPoiTakeRate.getTakeRate(); }else{ - takeRate = 2900; + takeRate = getAllMax(); } WxAppinfo couponAppInfo = wxAppinfoService.getCouponAppInfo(wxCoupon); @@ -756,7 +761,12 @@ public class TtCouponGoodsServiceImpl implements TtCouponGoodsService { if(payAccount == null){ throw new MallinkException(ErrorCode.API_KEY_NOT_FOUND); } - int rate = payAccount.getRealRate()+payAccount.getSystemRate()+payAccount.getSellRate(); + int rate = 0; + if(EnumYesOrNo.YES.getCode().equals(payAccount.getIsCommission())){ + rate = payAccount.getRealRate()+payAccount.getSystemRate()+payAccount.getSellRate(); + }else{ + return getAllMax(); + } if(EnumAppPlat.TOUTIAO.getCode().equals(couponAppInfo.getPlat())){ if(wxCoupon.getCategoryId() == null){ throw new MallinkException(ErrorCode.COUPON_ORDER_TYPE_NOT_SUPPORTED.getCode(),"卡券信息错误"); @@ -764,8 +774,8 @@ public class TtCouponGoodsServiceImpl implements TtCouponGoodsService { TtGoodsCategory ttGoodsCategory = ttGoodsCategoryMapper.selectById(wxCoupon.getCategoryId()); rate = rate+payAccount.getRealRate()-ttGoodsCategory.getServiceFee(); } - if(ttPoiTakeRate.getTakeRate().intValue() > rate){ - rate = ttPoiTakeRate.getTakeRate().intValue() - rate; + if(takeRate > rate){ + rate = takeRate - rate; return rate; }else{ throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"分佣率异常"); @@ -778,7 +788,7 @@ public class TtCouponGoodsServiceImpl implements TtCouponGoodsService { //总分佣率最大值 private int getAllMax(){ - return 3000; + return 2900; } //总分佣率最小值 private int getAllMin(WxCoupon wxCoupon){ @@ -793,7 +803,12 @@ public class TtCouponGoodsServiceImpl implements TtCouponGoodsService { if(payAccount == null){ throw new MallinkException(ErrorCode.API_KEY_NOT_FOUND); } - int rate = payAccount.getRealRate()+payAccount.getSystemRate()+payAccount.getSellRate(); + int rate = 0; + if(EnumYesOrNo.YES.getCode().equals(payAccount.getIsCommission())){ + rate = payAccount.getRealRate()+payAccount.getSystemRate()+payAccount.getSellRate(); + }else{ + rate = payAccount.getRealRate(); + } if(EnumAppPlat.TOUTIAO.getCode().equals(couponAppInfo.getPlat())){ if(wxCoupon.getCategoryId() == null){ throw new MallinkException(ErrorCode.COUPON_ORDER_TYPE_NOT_SUPPORTED.getCode(),"卡券信息错误"); @@ -804,7 +819,6 @@ public class TtCouponGoodsServiceImpl implements TtCouponGoodsService { if(maxTakeRate != null){ rate += maxTakeRate; } - rate += getRateMin(); } return rate; } diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxProfitSharingOrderServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxProfitSharingOrderServiceImpl.java index a252616e7..2ca81f9d6 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxProfitSharingOrderServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxProfitSharingOrderServiceImpl.java @@ -219,7 +219,7 @@ public class WxProfitSharingOrderServiceImpl implements WxProfitSharingOrderServ int commissionAmount = PayUtils.getPayRate(wxComposeChildOrderShare.getRealPayMent(), rate, true); wxComposeChildOrderShare.setCommissionAmount(commissionAmount); int surplus = 0;//当广场抽成帐号与收款帐号相等,无法添加分账方,计入商管商户中 - if(EnumPayMchType.DIRECT.getCode().equals(payOrder.getMchType())){ + if(EnumPayMchType.DIRECT.getCode().equals(payOrder.getMchType()) && EnumYesOrNo.YES.getCode().equals(payAccount.getIsCommission())){ //销售抽点+系统抽点 int selSysAmount = PayUtils.getPayRate(wxComposeChildOrderShare.getRealPayMent(), payAccount.getSellRate()+payAccount.getSystemRate(), false); //销售抽点 diff --git a/mallinkService/src/main/resources/mapper/WxPayAccountMapper.xml b/mallinkService/src/main/resources/mapper/WxPayAccountMapper.xml index 508908d0a..58565cc8d 100644 --- a/mallinkService/src/main/resources/mapper/WxPayAccountMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxPayAccountMapper.xml @@ -24,6 +24,7 @@ + @@ -37,7 +38,7 @@ `id`,`tenant_id`,`parent_tenant_id`,`mch_id`,`sub_mch_id`,`sub_app_id`,`api_key`,`merchant_api_key`,`notify_url`,`notify_token`,`cert_path`, - `merchant_cert_path`,`type`,`mch_type`,`open_pay`,`share`,`rate`,`real_rate`,`system_rate`,`sell_rate`, + `merchant_cert_path`,`type`,`mch_type`,`open_pay`,`share`,`rate`,`real_rate`,`is_commission`,`system_rate`,`sell_rate`, `service_id`,`pay_score_notify_url`,`api_v3_key`,`cert_serial_no`,`private_key_path`,`private_cert_pem_path`, `merchant_key_path`,`merchant_apiv3_key`,`merchant_cert_pem_path` @@ -83,6 +84,9 @@ and `real_rate` = #{realRate} + + and `is_commission` = #{isCommission} + and id in