| @@ -8,6 +8,7 @@ import com.iformall.common.ResultData; | |||||
| import com.iformall.controller.base.BaseController; | import com.iformall.controller.base.BaseController; | ||||
| import com.iformall.domain.po.TtPoiTakeRate; | import com.iformall.domain.po.TtPoiTakeRate; | ||||
| import com.iformall.domain.po.base.BaseEntity; | import com.iformall.domain.po.base.BaseEntity; | ||||
| import com.iformall.enums.EnumCpsPlanType; | |||||
| import com.iformall.service.TtCouponGoodsService; | import com.iformall.service.TtCouponGoodsService; | ||||
| import io.swagger.annotations.ApiImplicitParam; | import io.swagger.annotations.ApiImplicitParam; | ||||
| import io.swagger.annotations.ApiImplicitParams; | import io.swagger.annotations.ApiImplicitParams; | ||||
| @@ -18,6 +19,7 @@ import org.slf4j.LoggerFactory; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.web.bind.annotation.*; | import org.springframework.web.bind.annotation.*; | ||||
| import java.util.HashMap; | |||||
| import java.util.Map; | import java.util.Map; | ||||
| @@ -155,4 +157,52 @@ public class TtPoiPlanController extends BaseController { | |||||
| return ttCouponGoodsService.poiTakeRate(getTenantInfo(),couponId,douyinId,takeRate,status); | return ttCouponGoodsService.poiTakeRate(getTenantInfo(),couponId,douyinId,takeRate,status); | ||||
| } | } | ||||
| @ApiOperation("获取佣金范围") | |||||
| @PostMapping("getRateScope") | |||||
| @SystemControllerLog(description = "获取") | |||||
| public ResultData getRateScope(@RequestBody Map<String, Object> param) { | |||||
| logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::getRateScope"); | |||||
| String couponIdStr = (String) param.get("couponId"); | |||||
| if(StringUtils.isBlank(couponIdStr)){ | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"商品Id为空"); | |||||
| } | |||||
| Long couponId = Long.parseLong(couponIdStr); | |||||
| return ttCouponGoodsService.getRateScope(getTenantInfo(),couponId); | |||||
| } | |||||
| @ApiOperation("设置总分佣率") | |||||
| @PostMapping("setUpRateAll") | |||||
| @SystemControllerLog(description = "更新") | |||||
| public ResultData setUpAll(@RequestBody Map<String, Object> param) { | |||||
| logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::setUpAll"); | |||||
| String couponIdStr = (String) param.get("couponId"); | |||||
| if(StringUtils.isBlank(couponIdStr)){ | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"商品Id为空"); | |||||
| } | |||||
| Long couponId = Long.parseLong(couponIdStr); | |||||
| Integer mallRate = (Integer) param.get("mallRate"); | |||||
| if(mallRate == null){ | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"总分佣率为空"); | |||||
| } | |||||
| return ttCouponGoodsService.setUpAll(getTenantInfo(),couponId,mallRate); | |||||
| } | |||||
| @ApiOperation("获取总分佣率及范围") | |||||
| @PostMapping("getRateAll") | |||||
| @SystemControllerLog(description = "获取") | |||||
| public ResultData getAll(@RequestBody Map<String, Object> param) { | |||||
| logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::getAll"); | |||||
| String couponIdStr = (String) param.get("couponId"); | |||||
| if(StringUtils.isBlank(couponIdStr)){ | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"商品Id为空"); | |||||
| } | |||||
| Long couponId = Long.parseLong(couponIdStr); | |||||
| return ttCouponGoodsService.getAll(getTenantInfo(),couponId); | |||||
| } | |||||
| } | } | ||||
| @@ -9,7 +9,7 @@ ADD COLUMN `point_deduction` json COMMENT '各种扣点费用' AFTER `type`; | |||||
| ALTER TABLE `mallink`.`wx_profit_sharing_order_2` | ALTER TABLE `mallink`.`wx_profit_sharing_order_2` | ||||
| ADD COLUMN `pay_version` smallint(3) AFTER `pay_vendor`, | ADD COLUMN `pay_version` smallint(3) AFTER `pay_vendor`, | ||||
| ADD COLUMN `mch_type` smallint(3) AFTER `pay_version`, | ADD COLUMN `mch_type` smallint(3) AFTER `pay_version`, | ||||
| ADD COLUMN `point_deduction` json COMMENT '各种扣点费用' AFTER `type`;p | |||||
| ADD COLUMN `point_deduction` json COMMENT '各种扣点费用' AFTER `type`; | |||||
| ALTER TABLE `mallink`.`wx_profit_sharing_order_3` | ALTER TABLE `mallink`.`wx_profit_sharing_order_3` | ||||
| ADD COLUMN `pay_version` smallint(3) AFTER `pay_vendor`, | ADD COLUMN `pay_version` smallint(3) AFTER `pay_vendor`, | ||||
| ADD COLUMN `mch_type` smallint(3) AFTER `pay_version`, | ADD COLUMN `mch_type` smallint(3) AFTER `pay_version`, | ||||
| @@ -0,0 +1,2 @@ | |||||
| ALTER TABLE `mallink`.`wx_pay_account` | |||||
| ADD COLUMN `sell_rate` int(6) NOT NULL DEFAULT 0 COMMENT '销售提点' AFTER `system_rate`; | |||||
| @@ -14,8 +14,6 @@ public class WxSharingOrderDto extends TenantEntity { | |||||
| private Long orderId; | private Long orderId; | ||||
| @io.swagger.annotations.ApiModelProperty(value="订单ID",name="singleOrderId") | @io.swagger.annotations.ApiModelProperty(value="订单ID",name="singleOrderId") | ||||
| private Long singleOrderId; | private Long singleOrderId; | ||||
| @io.swagger.annotations.ApiModelProperty(value="单个订单支付金额(分)",name="singleOrderAmount") | |||||
| private Integer singleOrderAmount; | |||||
| @io.swagger.annotations.ApiModelProperty(value="c用户ID",name="cUserId") | @io.swagger.annotations.ApiModelProperty(value="c用户ID",name="cUserId") | ||||
| private Long cUserId; | private Long cUserId; | ||||
| @io.swagger.annotations.ApiModelProperty(value="微信生成的订单号",name="transactionId") | @io.swagger.annotations.ApiModelProperty(value="微信生成的订单号",name="transactionId") | ||||
| @@ -24,19 +22,6 @@ public class WxSharingOrderDto extends TenantEntity { | |||||
| private Integer payAmount; | private Integer payAmount; | ||||
| @io.swagger.annotations.ApiModelProperty(value="商户ID",name="merchantId") | @io.swagger.annotations.ApiModelProperty(value="商户ID",name="merchantId") | ||||
| private Long merchantId; | private Long merchantId; | ||||
| @io.swagger.annotations.ApiModelProperty(value="支付时收款商户",name="payMerchantId") | |||||
| private Long payMerchantId; | |||||
| @io.swagger.annotations.ApiModelProperty(value="支付时收款商户号",name="payMerchantMchId") | |||||
| private String payMerchantMchId; | |||||
| @io.swagger.annotations.ApiModelProperty(value="商户分账金额",name="merchantShareAmount") | |||||
| private Integer merchantShareAmount; | |||||
| @io.swagger.annotations.ApiModelProperty(value="商场实际通道费",name="mallRealRateAmount") | |||||
| private Integer mallRealRateAmount; | |||||
| private Integer realRateAmount;//平台手续费(微信,抖音) | |||||
| private Integer commissionAmount;//平台佣金(微信,抖音) | |||||
| private Integer systemAmount;//系统扣点费 | |||||
| @io.swagger.annotations.ApiModelProperty(value="支付发起时间",name="payTimeStart") | @io.swagger.annotations.ApiModelProperty(value="支付发起时间",name="payTimeStart") | ||||
| private Date payTimeStart; | private Date payTimeStart; | ||||
| @@ -56,8 +56,10 @@ public class WxPayAccount extends TenantEntity { | |||||
| private Integer rate; | private Integer rate; | ||||
| @io.swagger.annotations.ApiModelProperty(value="实际手续费(万分之几,默认60)",name="realRate") | @io.swagger.annotations.ApiModelProperty(value="实际手续费(万分之几,默认60)",name="realRate") | ||||
| private Integer realRate; | private Integer realRate; | ||||
| @io.swagger.annotations.ApiModelProperty(value="系统提点,包含在rate之内",name="systemRate") | |||||
| @io.swagger.annotations.ApiModelProperty(value="系统提点",name="systemRate") | |||||
| private Integer systemRate; | private Integer systemRate; | ||||
| @io.swagger.annotations.ApiModelProperty(value="销售提点",name="sellRate") | |||||
| private Integer sellRate; | |||||
| public String getPayNotifyV3Url() { | public String getPayNotifyV3Url() { | ||||
| return notifyUrl + "/pay/v3/"+this.getTenantId(); | return notifyUrl + "/pay/v3/"+this.getTenantId(); | ||||
| @@ -104,31 +104,23 @@ public class WxPayOrder extends TenantEntity { | |||||
| private String posPayDes; | private String posPayDes; | ||||
| public WxComposeChildOrderShare getChildOrderShare(Long wxOrderId) { | public WxComposeChildOrderShare getChildOrderShare(Long wxOrderId) { | ||||
| if (StringUtils.isBlank(this.childOrderShare)) { | |||||
| return new WxComposeChildOrderShare(this.payAmount, this.shareAmount, this.rateAmount,0,this.commissionAmount,this.systemAmount,null,null,wxOrderId); | |||||
| } | |||||
| Map childs = JSON.parseObject(this.childOrderShare, Map.class); | Map childs = JSON.parseObject(this.childOrderShare, Map.class); | ||||
| JSONObject childOrderShare = (JSONObject) childs.get(String.valueOf(wxOrderId)); | JSONObject childOrderShare = (JSONObject) childs.get(String.valueOf(wxOrderId)); | ||||
| if (null != childOrderShare) { | if (null != childOrderShare) { | ||||
| return new WxComposeChildOrderShare(childOrderShare.getInteger("realPayMent"), childOrderShare.getInteger("shareAmount"), childOrderShare.getInteger("rateAmount"), | |||||
| childOrderShare.getInteger("realRateAmount"), childOrderShare.getInteger("commissionAmount"),childOrderShare.getInteger("systemAmount"), | |||||
| childOrderShare.getLong("merchantId"),childOrderShare.getString("merchantUid"),childOrderShare.getLong("orderId")); | |||||
| return new WxComposeChildOrderShare(childOrderShare.getLong("orderId"),childOrderShare.getInteger("realPayMent"), | |||||
| childOrderShare.getLong("merchantId"),childOrderShare.getString("merchantUid")); | |||||
| } | } | ||||
| return null; | return null; | ||||
| } | } | ||||
| private List<WxComposeChildOrderShare> getAllChilds(Integer index) { | private List<WxComposeChildOrderShare> getAllChilds(Integer index) { | ||||
| if (StringUtils.isBlank(this.childOrderShare)) { | |||||
| return null; | |||||
| } | |||||
| Map childs = JSON.parseObject(this.childOrderShare, Map.class); | Map childs = JSON.parseObject(this.childOrderShare, Map.class); | ||||
| List<WxComposeChildOrderShare> childList = new ArrayList<WxComposeChildOrderShare>(); | List<WxComposeChildOrderShare> childList = new ArrayList<WxComposeChildOrderShare>(); | ||||
| int _index = 0; | int _index = 0; | ||||
| for (Iterator<String> it = childs.keySet().iterator();it.hasNext();) { | for (Iterator<String> it = childs.keySet().iterator();it.hasNext();) { | ||||
| JSONObject childOrderShare = (JSONObject) childs.get(it.next()); | JSONObject childOrderShare = (JSONObject) childs.get(it.next()); | ||||
| WxComposeChildOrderShare child = new WxComposeChildOrderShare(childOrderShare.getInteger("realPayMent"), childOrderShare.getInteger("shareAmount"), childOrderShare.getInteger("rateAmount"), | |||||
| childOrderShare.getInteger("realRateAmount"), childOrderShare.getInteger("commissionAmount"),childOrderShare.getInteger("systemAmount"), | |||||
| childOrderShare.getLong("merchantId"),childOrderShare.getString("merchantUid"),childOrderShare.getLong("orderId")); | |||||
| WxComposeChildOrderShare child = new WxComposeChildOrderShare(childOrderShare.getLong("orderId"),childOrderShare.getInteger("realPayMent"), | |||||
| childOrderShare.getLong("merchantId"),childOrderShare.getString("merchantUid")); | |||||
| childList.add(child); | childList.add(child); | ||||
| if (null != index && index.intValue() == _index) { | if (null != index && index.intValue() == _index) { | ||||
| return childList; | return childList; | ||||
| @@ -6,7 +6,7 @@ package com.iformall.enums; | |||||
| public enum EnumCpsPlanContentType { | public enum EnumCpsPlanContentType { | ||||
| // | // | ||||
| ALL(0,"总和"), | |||||
| VIDEO(1, "仅短视频"), | VIDEO(1, "仅短视频"), | ||||
| LIVE(2, "仅直播间"), | LIVE(2, "仅直播间"), | ||||
| VIDEO_LIVE(3, "短视频和直播间"), | VIDEO_LIVE(3, "短视频和直播间"), | ||||
| @@ -6,7 +6,7 @@ package com.iformall.enums; | |||||
| public enum EnumCpsPlanType { | public enum EnumCpsPlanType { | ||||
| // | // | ||||
| ALL(0, "总和"), | |||||
| COMMON(1, "通用计划"), | COMMON(1, "通用计划"), | ||||
| DIRECTIONAL(2, "定向计划"), | DIRECTIONAL(2, "定向计划"), | ||||
| ; | ; | ||||
| @@ -9,11 +9,13 @@ import java.util.List; | |||||
| public interface TtPoiTakeRateMapper extends CommonMapper<TtPoiTakeRate, Long> { | public interface TtPoiTakeRateMapper extends CommonMapper<TtPoiTakeRate, Long> { | ||||
| TtPoiTakeRate selectByCouponAndDouyin(@Param("tenantId")String tenantId,@Param("couponId")Long couponId, | |||||
| TtPoiTakeRate selectByCoupon(@Param("tenantId")String tenantId,@Param("couponId")Long couponId, | |||||
| @Param("type") Integer type,@Param("douyinId")String douyinId); | @Param("type") Integer type,@Param("douyinId")String douyinId); | ||||
| List<TtPoiTakeRate> findList(TtPoiTakeRate takeRate); | List<TtPoiTakeRate> findList(TtPoiTakeRate takeRate); | ||||
| TtPoiTakeRate selectById(@Param("id")Long id,@Param("tenantId")String tenantId); | TtPoiTakeRate selectById(@Param("id")Long id,@Param("tenantId")String tenantId); | ||||
| Integer getMaxTakeRate(@Param("tenantId")String tenantId,@Param("couponId")Long couponId); | |||||
| } | } | ||||
| @@ -8,6 +8,7 @@ import com.iformall.domain.po.WxCoupon; | |||||
| import com.iformall.domain.po.base.TenantEntity; | import com.iformall.domain.po.base.TenantEntity; | ||||
| import com.iformall.domain.vo.TtCouponChannelVo; | import com.iformall.domain.vo.TtCouponChannelVo; | ||||
| import com.iformall.domain.vo.TtCouponVo; | import com.iformall.domain.vo.TtCouponVo; | ||||
| import com.iformall.enums.EnumCpsPlanType; | |||||
| public interface TtCouponGoodsService { | public interface TtCouponGoodsService { | ||||
| @@ -40,4 +41,12 @@ public interface TtCouponGoodsService { | |||||
| ResultData poiTakeRate(TenantEntity tenantInfo, Long couponId, String douyinId, Integer takeRate, Integer status); | ResultData poiTakeRate(TenantEntity tenantInfo, Long couponId, String douyinId, Integer takeRate, Integer status); | ||||
| PageInfo<TtPoiTakeRate> takeRateListAsPage(TtPoiTakeRate record, Integer pageNum, Integer pageSize); | PageInfo<TtPoiTakeRate> takeRateListAsPage(TtPoiTakeRate record, Integer pageNum, Integer pageSize); | ||||
| ResultData setUpAll(TenantEntity tenantInfo, Long couponId, Integer mallRate); | |||||
| TtPoiTakeRate selectByCoupon(TenantEntity tenantInfo, Long couponId, Integer planType, String douyinId); | |||||
| ResultData getAll(TenantEntity tenantInfo, Long couponId); | |||||
| ResultData getRateScope(TenantEntity tenantInfo, Long couponId); | |||||
| } | } | ||||
| @@ -17,6 +17,7 @@ import com.iformall.douyin.web.bean.PoiPlanPage; | |||||
| import com.iformall.douyin.web.bean.PoiTakeRate; | import com.iformall.douyin.web.bean.PoiTakeRate; | ||||
| import com.iformall.douyin.web.bean.Product; | import com.iformall.douyin.web.bean.Product; | ||||
| import com.iformall.enums.*; | import com.iformall.enums.*; | ||||
| import com.iformall.exception.MallinkException; | |||||
| import com.iformall.mapper.*; | import com.iformall.mapper.*; | ||||
| import com.iformall.service.*; | import com.iformall.service.*; | ||||
| import com.iformall.utils.Constant; | import com.iformall.utils.Constant; | ||||
| @@ -64,9 +65,15 @@ public class TtCouponGoodsServiceImpl implements TtCouponGoodsService { | |||||
| @Autowired | @Autowired | ||||
| WxAppinfoService wxAppinfoService; | WxAppinfoService wxAppinfoService; | ||||
| @Autowired | |||||
| WxPayAccountService wxPayAccountService; | |||||
| @Autowired | @Autowired | ||||
| TtPoiTakeRateMapper ttPoiTakeRateMapper; | TtPoiTakeRateMapper ttPoiTakeRateMapper; | ||||
| @Autowired | |||||
| TtGoodsCategoryMapper ttGoodsCategoryMapper; | |||||
| @Override | @Override | ||||
| public ResultData couponList(TtCouponVo ttCouponVo, Integer pageNum, Integer pageSize) { | public ResultData couponList(TtCouponVo ttCouponVo, Integer pageNum, Integer pageSize) { | ||||
| PageInfo<TtCouponVo> pageInfo = PageHelper.startPage(pageNum, pageSize).doSelectPageInfo(() -> wxCouponMapper.ttCouponList(ttCouponVo)); | PageInfo<TtCouponVo> pageInfo = PageHelper.startPage(pageNum, pageSize).doSelectPageInfo(() -> wxCouponMapper.ttCouponList(ttCouponVo)); | ||||
| @@ -496,11 +503,27 @@ public class TtCouponGoodsServiceImpl implements TtCouponGoodsService { | |||||
| @Override | @Override | ||||
| public ResultData poiPlanSave(TenantEntity tenantInfo, Long couponId, Long planId, Integer contentType, Integer commissionRate) { | public ResultData poiPlanSave(TenantEntity tenantInfo, Long couponId, Long planId, Integer contentType, Integer commissionRate) { | ||||
| WxCoupon wxCoupon = wxCouponMapper.selectById(couponId, tenantInfo.getTenantId()); | |||||
| if(wxCoupon == null){ | |||||
| return new ResultData(ErrorCode.COUPON_IS_EMPTY.getCode(),"未找到该券"); | |||||
| } | |||||
| if(wxCoupon.getSalePrice() == 0 || wxCoupon.checkIsCard()){ | |||||
| return new ResultData(ErrorCode.COUPON_ORDER_TYPE_NOT_SUPPORTED); | |||||
| } | |||||
| TtCouponChannelPoi ttCouponChannelPoi = ttCouponChannelPoiMapper.selectById(tenantInfo.getTenantId(),couponId); | TtCouponChannelPoi ttCouponChannelPoi = ttCouponChannelPoiMapper.selectById(tenantInfo.getTenantId(),couponId); | ||||
| if(ttCouponChannelPoi == null || !EnumSpuSyncStatus.sync_audit_pass.getCode().equals(ttCouponChannelPoi.getLastStatus())){ | if(ttCouponChannelPoi == null || !EnumSpuSyncStatus.sync_audit_pass.getCode().equals(ttCouponChannelPoi.getLastStatus())){ | ||||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"该券未提交审核或审核未通过"); | return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"该券未提交审核或审核未通过"); | ||||
| } | } | ||||
| try { | try { | ||||
| int rateMin = getRateMin(); | |||||
| if(commissionRate.intValue() < rateMin){ | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"分佣率低于最小值("+rateMin+")"); | |||||
| } | |||||
| int rateMax = getRateMax(wxCoupon); | |||||
| if(commissionRate.intValue() > rateMax){ | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"分佣率超过最大值("+rateMax+")"); | |||||
| } | |||||
| Long spu_id = Long.parseLong(ttCouponChannelPoi.getSpuId()); | Long spu_id = Long.parseLong(ttCouponChannelPoi.getSpuId()); | ||||
| PoiPlan poiPlan = new PoiPlan(); | PoiPlan poiPlan = new PoiPlan(); | ||||
| poiPlan.setPlanId(planId); | poiPlan.setPlanId(planId); | ||||
| @@ -525,6 +548,8 @@ public class TtCouponGoodsServiceImpl implements TtCouponGoodsService { | |||||
| } catch (WxErrorException e) { | } catch (WxErrorException e) { | ||||
| e.printStackTrace(); | e.printStackTrace(); | ||||
| return new ResultData(ErrorCode.SYS_SERVER_ERROR.getCode(),e.getMessage()); | return new ResultData(ErrorCode.SYS_SERVER_ERROR.getCode(),e.getMessage()); | ||||
| } catch (MallinkException e){ | |||||
| return new ResultData(e.getErrorCode(),e.getMessage()); | |||||
| } | } | ||||
| } | } | ||||
| @@ -551,11 +576,27 @@ public class TtCouponGoodsServiceImpl implements TtCouponGoodsService { | |||||
| @Override | @Override | ||||
| public ResultData poiTakeRate(TenantEntity tenantInfo, Long couponId, String douyinId, Integer takeRate, Integer status) { | public ResultData poiTakeRate(TenantEntity tenantInfo, Long couponId, String douyinId, Integer takeRate, Integer status) { | ||||
| WxCoupon wxCoupon = wxCouponMapper.selectById(couponId, tenantInfo.getTenantId()); | |||||
| if(wxCoupon == null){ | |||||
| return new ResultData(ErrorCode.COUPON_IS_EMPTY.getCode(),"未找到该券"); | |||||
| } | |||||
| if(wxCoupon.getSalePrice() == 0 || wxCoupon.checkIsCard()){ | |||||
| return new ResultData(ErrorCode.COUPON_ORDER_TYPE_NOT_SUPPORTED); | |||||
| } | |||||
| TtCouponChannelPoi ttCouponChannelPoi = ttCouponChannelPoiMapper.selectById(tenantInfo.getTenantId(),couponId); | TtCouponChannelPoi ttCouponChannelPoi = ttCouponChannelPoiMapper.selectById(tenantInfo.getTenantId(),couponId); | ||||
| if(ttCouponChannelPoi == null || !EnumSpuSyncStatus.sync_audit_pass.getCode().equals(ttCouponChannelPoi.getLastStatus())){ | if(ttCouponChannelPoi == null || !EnumSpuSyncStatus.sync_audit_pass.getCode().equals(ttCouponChannelPoi.getLastStatus())){ | ||||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"该券未提交审核或审核未通过"); | return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"该券未提交审核或审核未通过"); | ||||
| } | } | ||||
| try { | try { | ||||
| int rateMin = getRateMin(); | |||||
| if(takeRate.intValue() < rateMin){ | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"分佣率低于最小值("+rateMin+")"); | |||||
| } | |||||
| int rateMax = getRateMax(wxCoupon); | |||||
| if(takeRate.intValue() > rateMax){ | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"分佣率超过最大值("+rateMax+")"); | |||||
| } | |||||
| PoiTakeRate poiTakeRate = new PoiTakeRate(); | PoiTakeRate poiTakeRate = new PoiTakeRate(); | ||||
| poiTakeRate.setSpuExtId(couponId.toString()); | poiTakeRate.setSpuExtId(couponId.toString()); | ||||
| poiTakeRate.setDouyinId(douyinId); | poiTakeRate.setDouyinId(douyinId); | ||||
| @@ -587,17 +628,176 @@ public class TtCouponGoodsServiceImpl implements TtCouponGoodsService { | |||||
| return PageHelper.startPage(pageNum, pageSize).doSelectPageInfo(() -> ttPoiTakeRateMapper.findList(record)); | return PageHelper.startPage(pageNum, pageSize).doSelectPageInfo(() -> ttPoiTakeRateMapper.findList(record)); | ||||
| } | } | ||||
| @Override | |||||
| public ResultData setUpAll(TenantEntity tenantInfo, Long couponId, Integer mallRate) { | |||||
| WxCoupon wxCoupon = wxCouponMapper.selectById(couponId, tenantInfo.getTenantId()); | |||||
| if(wxCoupon == null){ | |||||
| return new ResultData(ErrorCode.COUPON_IS_EMPTY.getCode(),"未找到该券"); | |||||
| } | |||||
| if(wxCoupon.getSalePrice() == 0 || wxCoupon.checkIsCard()){ | |||||
| return new ResultData(ErrorCode.COUPON_ORDER_TYPE_NOT_SUPPORTED); | |||||
| } | |||||
| int allMax = getAllMax(); | |||||
| if(mallRate.intValue() > allMax){ | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"分佣率超过最大值("+allMax+")"); | |||||
| } | |||||
| int allMin = getAllMin(wxCoupon); | |||||
| if(mallRate.intValue() < allMin){ | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"分佣率低于最小值("+allMin+")"); | |||||
| } | |||||
| TtPoiTakeRate ttPoiTakeRate = new TtPoiTakeRate(); | |||||
| ttPoiTakeRate.updateTenantInfo(tenantInfo); | |||||
| ttPoiTakeRate.setCouponId(couponId); | |||||
| ttPoiTakeRate.setType(EnumCpsPlanType.ALL.getCode()); | |||||
| ttPoiTakeRate.setTakeRate(mallRate); | |||||
| this.saveorupdate(ttPoiTakeRate); | |||||
| return new ResultData(); | |||||
| } | |||||
| @Override | |||||
| public TtPoiTakeRate selectByCoupon(TenantEntity tenantInfo, Long couponId,Integer planType, String douyinId) { | |||||
| return ttPoiTakeRateMapper.selectByCoupon(tenantInfo.getTenantId(), couponId, | |||||
| planType,douyinId); | |||||
| } | |||||
| /** | |||||
| * 获取总分佣率极其范围 | |||||
| * @param tenantInfo | |||||
| * @param couponId | |||||
| * @return | |||||
| */ | |||||
| @Override | |||||
| public ResultData getAll(TenantEntity tenantInfo, Long couponId) { | |||||
| WxCoupon wxCoupon = wxCouponMapper.selectById(couponId, tenantInfo.getTenantId()); | |||||
| if(wxCoupon == null){ | |||||
| return new ResultData(ErrorCode.COUPON_IS_EMPTY.getCode(),"未找到该券"); | |||||
| } | |||||
| if(wxCoupon.getSalePrice() == 0 || wxCoupon.checkIsCard()){ | |||||
| return new ResultData(ErrorCode.COUPON_ORDER_TYPE_NOT_SUPPORTED); | |||||
| } | |||||
| TtPoiTakeRate ttPoiTakeRate = ttPoiTakeRateMapper.selectByCoupon(tenantInfo.getTenantId(), couponId,EnumCpsPlanType.ALL.getCode(),null); | |||||
| Map<String,Object> map = new HashMap<>(); | |||||
| if(ttPoiTakeRate != null){ | |||||
| map.put("mallReat",ttPoiTakeRate.getTakeRate()); | |||||
| } | |||||
| map.put("mallMax",getAllMax()); | |||||
| map.put("mallMin",getAllMin(wxCoupon)); | |||||
| return new ResultData(map); | |||||
| } | |||||
| /** | |||||
| * 获取计划佣金范围 | |||||
| * @param tenantInfo | |||||
| * @param couponId | |||||
| * @return | |||||
| */ | |||||
| @Override | |||||
| public ResultData getRateScope(TenantEntity tenantInfo, Long couponId) { | |||||
| WxCoupon wxCoupon = wxCouponMapper.selectById(couponId, tenantInfo.getTenantId()); | |||||
| if(wxCoupon == null){ | |||||
| return new ResultData(ErrorCode.COUPON_IS_EMPTY.getCode(),"未找到该券"); | |||||
| } | |||||
| if(wxCoupon.getSalePrice() == 0 || wxCoupon.checkIsCard()){ | |||||
| return new ResultData(ErrorCode.COUPON_ORDER_TYPE_NOT_SUPPORTED); | |||||
| } | |||||
| TtPoiTakeRate ttPoiTakeRate = ttPoiTakeRateMapper.selectByCoupon(tenantInfo.getTenantId(), couponId,EnumCpsPlanType.ALL.getCode(),null); | |||||
| if(ttPoiTakeRate == null){ | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"请先设置总分佣率"); | |||||
| } | |||||
| Map<String,Object> map = new HashMap<>(); | |||||
| map.put("rateMax",getRateMax(wxCoupon)); | |||||
| map.put("rateMin",getRateMin()); | |||||
| return new ResultData(map); | |||||
| } | |||||
| //达人分佣率最大值 | |||||
| private int getRateMax(WxCoupon wxCoupon){ | |||||
| if(wxCoupon.getSalePrice() == 0 || wxCoupon.checkIsCard()){ | |||||
| throw new MallinkException(ErrorCode.COUPON_ORDER_TYPE_NOT_SUPPORTED); | |||||
| } | |||||
| TtPoiTakeRate ttPoiTakeRate = ttPoiTakeRateMapper.selectByCoupon(wxCoupon.getTenantId(), wxCoupon.getId(),EnumCpsPlanType.ALL.getCode(),null); | |||||
| if(ttPoiTakeRate == null){ | |||||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"请先设置总分佣率"); | |||||
| } | |||||
| WxAppinfo couponAppInfo = wxAppinfoService.getCouponAppInfo(wxCoupon); | |||||
| if(couponAppInfo == null || couponAppInfo.getPayId() == null){ | |||||
| throw new MallinkException(ErrorCode.APP_ID_NOT_FOUND); | |||||
| } | |||||
| WxPayAccount payAccount = wxPayAccountService.getById(couponAppInfo.getPayId()); | |||||
| if(payAccount == null){ | |||||
| throw new MallinkException(ErrorCode.API_KEY_NOT_FOUND); | |||||
| } | |||||
| int rate = payAccount.getRealRate()+payAccount.getSystemRate()+payAccount.getSellRate(); | |||||
| if(EnumAppPlat.TOUTIAO.getCode().equals(couponAppInfo.getPlat())){ | |||||
| if(wxCoupon.getCategoryId() == null){ | |||||
| throw new MallinkException(ErrorCode.COUPON_ORDER_TYPE_NOT_SUPPORTED.getCode(),"卡券信息错误"); | |||||
| } | |||||
| TtGoodsCategory ttGoodsCategory = ttGoodsCategoryMapper.selectById(wxCoupon.getCategoryId()); | |||||
| rate = rate+payAccount.getRealRate()-ttGoodsCategory.getServiceFee(); | |||||
| } | |||||
| if(ttPoiTakeRate.getTakeRate().intValue() > rate){ | |||||
| rate = ttPoiTakeRate.getTakeRate().intValue() - rate; | |||||
| return rate; | |||||
| }else{ | |||||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"分佣率异常"); | |||||
| } | |||||
| } | |||||
| //达人分佣率最小值 | |||||
| private int getRateMin(){ | |||||
| return 100; | |||||
| } | |||||
| //总分佣率最大值 | |||||
| private int getAllMax(){ | |||||
| return 2900; | |||||
| } | |||||
| //总分佣率最小值 | |||||
| private int getAllMin(WxCoupon wxCoupon){ | |||||
| if(wxCoupon.getSalePrice() == 0 || wxCoupon.checkIsCard()){ | |||||
| throw new MallinkException(ErrorCode.COUPON_ORDER_TYPE_NOT_SUPPORTED); | |||||
| } | |||||
| WxAppinfo couponAppInfo = wxAppinfoService.getCouponAppInfo(wxCoupon); | |||||
| if(couponAppInfo == null || couponAppInfo.getPayId() == null){ | |||||
| throw new MallinkException(ErrorCode.APP_ID_NOT_FOUND); | |||||
| } | |||||
| WxPayAccount payAccount = wxPayAccountService.getById(couponAppInfo.getPayId()); | |||||
| if(payAccount == null){ | |||||
| throw new MallinkException(ErrorCode.API_KEY_NOT_FOUND); | |||||
| } | |||||
| int rate = payAccount.getRealRate()+payAccount.getSystemRate()+payAccount.getSellRate(); | |||||
| if(EnumAppPlat.TOUTIAO.getCode().equals(couponAppInfo.getPlat())){ | |||||
| if(wxCoupon.getCategoryId() == null){ | |||||
| throw new MallinkException(ErrorCode.COUPON_ORDER_TYPE_NOT_SUPPORTED.getCode(),"卡券信息错误"); | |||||
| } | |||||
| TtGoodsCategory ttGoodsCategory = ttGoodsCategoryMapper.selectById(wxCoupon.getCategoryId()); | |||||
| rate = rate+payAccount.getRealRate()-ttGoodsCategory.getServiceFee(); | |||||
| Integer maxTakeRate = ttPoiTakeRateMapper.getMaxTakeRate(wxCoupon.getTenantId(), wxCoupon.getId()); | |||||
| if(maxTakeRate != null){ | |||||
| rate += maxTakeRate; | |||||
| } | |||||
| rate += getRateMin(); | |||||
| } | |||||
| return rate; | |||||
| } | |||||
| private int saveorupdate(TtPoiTakeRate takeRate){ | private int saveorupdate(TtPoiTakeRate takeRate){ | ||||
| TtPoiTakeRate ttPoiTakeRate = null; | TtPoiTakeRate ttPoiTakeRate = null; | ||||
| if(EnumCpsPlanType.DIRECTIONAL.getCode().equals(takeRate.getType())){ | if(EnumCpsPlanType.DIRECTIONAL.getCode().equals(takeRate.getType())){ | ||||
| ttPoiTakeRate = ttPoiTakeRateMapper.selectByCouponAndDouyin(takeRate.getTenantId(), takeRate.getCouponId(), | |||||
| ttPoiTakeRate = ttPoiTakeRateMapper.selectByCoupon(takeRate.getTenantId(), takeRate.getCouponId(), | |||||
| takeRate.getType(),takeRate.getDouyinId()); | takeRate.getType(),takeRate.getDouyinId()); | ||||
| }else if(EnumCpsPlanType.COMMON.getCode().equals(takeRate.getType())){ | }else if(EnumCpsPlanType.COMMON.getCode().equals(takeRate.getType())){ | ||||
| ttPoiTakeRate = ttPoiTakeRateMapper.selectById(takeRate.getId(), takeRate.getTenantId()); | ttPoiTakeRate = ttPoiTakeRateMapper.selectById(takeRate.getId(), takeRate.getTenantId()); | ||||
| if(ttPoiTakeRate == null){ | if(ttPoiTakeRate == null){ | ||||
| takeRate.setStatus(EnumCpsPlanStatus.ING.getCode()); | takeRate.setStatus(EnumCpsPlanStatus.ING.getCode()); | ||||
| } | } | ||||
| }else if(EnumCpsPlanType.ALL.getCode().equals(takeRate.getType())){ | |||||
| ttPoiTakeRate = ttPoiTakeRateMapper.selectByCoupon(takeRate.getTenantId(), takeRate.getCouponId(), | |||||
| takeRate.getType(),null); | |||||
| if(ttPoiTakeRate == null){ | |||||
| takeRate.setStatus(EnumCpsPlanStatus.ING.getCode()); | |||||
| } | |||||
| } | } | ||||
| Date now = new Date(); | Date now = new Date(); | ||||
| @@ -614,7 +814,6 @@ public class TtCouponGoodsServiceImpl implements TtCouponGoodsService { | |||||
| takeRate.setUpdateDate(new Date()); | takeRate.setUpdateDate(new Date()); | ||||
| return ttPoiTakeRateMapper.updateById(takeRate); | return ttPoiTakeRateMapper.updateById(takeRate); | ||||
| } | } | ||||
| } | } | ||||
| @@ -1726,7 +1726,6 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { | |||||
| } | } | ||||
| } | } | ||||
| WxOrder order = wxOrderService.getById(couponOrder.getOrderId(), wxPayOrder.getTenantId()); | WxOrder order = wxOrderService.getById(couponOrder.getOrderId(), wxPayOrder.getTenantId()); | ||||
| if (null == order) { | if (null == order) { | ||||
| logger.error("租户"+wxPayOrder.getTenantId()+"券订单"+couponOrder.getId()+"未查询到订单."); | logger.error("租户"+wxPayOrder.getTenantId()+"券订单"+couponOrder.getId()+"未查询到订单."); | ||||
| @@ -1735,27 +1734,14 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { | |||||
| WxSharingOrderDto wxSharingOrderDto = new WxSharingOrderDto(); | WxSharingOrderDto wxSharingOrderDto = new WxSharingOrderDto(); | ||||
| wxSharingOrderDto.setCUserId(wxPayOrder.getCUserId()); | wxSharingOrderDto.setCUserId(wxPayOrder.getCUserId()); | ||||
| wxSharingOrderDto.setMerchantId(merchantId); | wxSharingOrderDto.setMerchantId(merchantId); | ||||
| WxComposeChildOrderShare childShare = wxPayOrder.getChildOrderShare(order.getId()); | |||||
| if (null == childShare) { | |||||
| logger.error("租户"+wxPayOrder.getTenantId()+"订单"+order.getId()+"在支付订单"+wxPayOrder.getId()+"未查询到."); | |||||
| throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"租户"+wxPayOrder.getTenantId()+"订单"+order.getId()+"在支付订单"+wxPayOrder.getId()+"未查询到."); | |||||
| } | |||||
| wxSharingOrderDto.setPayMerchantId(childShare.getMerchantId()); | |||||
| wxSharingOrderDto.setPayMerchantMchId(childShare.getMerchantUid()); | |||||
| if (mulityShare) { | if (mulityShare) { | ||||
| wxSharingOrderDto.setType(EnumProfitSharingOrderType.PROFIT_SHARING_MULTI.getCode()); | wxSharingOrderDto.setType(EnumProfitSharingOrderType.PROFIT_SHARING_MULTI.getCode()); | ||||
| }else { | }else { | ||||
| wxSharingOrderDto.setType(EnumProfitSharingOrderType.PROFIT_SHARING_SINGLE.getCode()); | wxSharingOrderDto.setType(EnumProfitSharingOrderType.PROFIT_SHARING_SINGLE.getCode()); | ||||
| } | } | ||||
| wxSharingOrderDto.setPayAmount(wxPayOrder.getPayAmount()); | wxSharingOrderDto.setPayAmount(wxPayOrder.getPayAmount()); | ||||
| wxSharingOrderDto.setMerchantShareAmount(childShare.getShareAmount()); | |||||
| wxSharingOrderDto.setMallRealRateAmount(childShare.getRateAmount()); | |||||
| wxSharingOrderDto.setRealRateAmount(childShare.getRealRateAmount()); | |||||
| wxSharingOrderDto.setCommissionAmount(childShare.getCommissionAmount()); | |||||
| wxSharingOrderDto.setSystemAmount(childShare.getSystemAmount()); | |||||
| wxSharingOrderDto.setOrderId(wxPayOrder.getId()); | wxSharingOrderDto.setOrderId(wxPayOrder.getId()); | ||||
| wxSharingOrderDto.setSingleOrderId(childShare.getOrderId()); | |||||
| wxSharingOrderDto.setSingleOrderAmount(childShare.getRealPayMent()); | |||||
| wxSharingOrderDto.setSingleOrderId(order.getId()); | |||||
| wxSharingOrderDto.setPayTimeStart(wxPayOrder.getPayTimeStart()); | wxSharingOrderDto.setPayTimeStart(wxPayOrder.getPayTimeStart()); | ||||
| wxSharingOrderDto.setPayTimeEnd(wxPayOrder.getPayTimeEnd()); | wxSharingOrderDto.setPayTimeEnd(wxPayOrder.getPayTimeEnd()); | ||||
| wxSharingOrderDto.updateTenantInfo(wxPayOrder); | wxSharingOrderDto.updateTenantInfo(wxPayOrder); | ||||
| @@ -2718,24 +2704,25 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { | |||||
| payOrder.setPayAmount(payAmount); | payOrder.setPayAmount(payAmount); | ||||
| payOrder.setPayVendor(payWay.getCode()); | payOrder.setPayVendor(payWay.getCode()); | ||||
| payOrder.setPayVersion(payVersion.getCode()); | payOrder.setPayVersion(payVersion.getCode()); | ||||
| payOrder.setMchType(payAccount.getMchType()); | |||||
| payOrder.setPayOrderStatus(EnumPayStatus.PAY_STATUS_WAIT.getCode()); | payOrder.setPayOrderStatus(EnumPayStatus.PAY_STATUS_WAIT.getCode()); | ||||
| payOrder.setShare(shareCode); | payOrder.setShare(shareCode); | ||||
| int systemAmount = OrderHelper.getAmount(payAmount, payAccount.getSystemRate()); | |||||
| PayShareAdapterService payShareServie = payServiceFactory.getPayShareAdapterService(payWay.getCode(),payAccount.getPayVersion()); | |||||
| int rate = payShareServie.getOfficialCommission(composeOrder.getSingleOrder(),payAccount);//抖音分佣率 | |||||
| PayShareCalculateAmount oShareAmount = payShareServie.calculateAmount(payAmount,rate,systemAmount, payAccount); | |||||
| if (shareCode.intValue() == EnumPayShare.YES.getCode().intValue()) { | |||||
| // 分账金额 | |||||
| payOrder.setShareAmount(oShareAmount.getMerchantShareAmount()); | |||||
| if(payAccount.getRealRate() != null) { | |||||
| payOrder.setRateAmount(oShareAmount.getMallRealRateAmount()); | |||||
| } | |||||
| if (oShareAmount.getMerchantShareAmount() <= 0) { | |||||
| payOrder.setShare(EnumPayShare.NO.getCode()); | |||||
| } | |||||
| } | |||||
| payOrder.setCommissionAmount(oShareAmount.getCommissionAmount()); | |||||
| payOrder.setSystemAmount(oShareAmount.getSystemAmount()); | |||||
| payOrder.setComposeOrder(EnumComposeOrder.SINGLE.getCode()); | |||||
| PayShareAdapterService payShareServie = payServiceFactory.getPayShareAdapterService(payWay.getCode(),payAccount.getPayVersion()); | |||||
| Map<String,WxComposeChildOrderShare> childShares = new HashMap<String,WxComposeChildOrderShare>(); | |||||
| Long merchant_id = null; | |||||
| String merchant_uid = ""; | |||||
| if(EnumPayMchType.DIRECT.getCode().equals(payOrder.getMchType())){//直连模式记录收款商户 | |||||
| merchant_id = bUser.getMerchantId(); | |||||
| WxProfitSharingReceiver receiver = payShareServie.getReceiver(payAccount, merchant_id, null, payOrder.getMchType()); | |||||
| if(receiver == null){ | |||||
| throw new MallinkException(ErrorCode.PAY_ORDER_MERCHANT_UID_ERROR); | |||||
| } | |||||
| merchant_uid = receiver.getReceiverAccount(); | |||||
| } | |||||
| childShares.put(String.valueOf(composeOrder.getSingleOrder().getId()), new WxComposeChildOrderShare(composeOrder.getSingleOrder().getId(),payAmount,merchant_id,merchant_uid)); | |||||
| payOrder.setPayFrom(EnumPayFrom.INSIDE_B.getCode()); | payOrder.setPayFrom(EnumPayFrom.INSIDE_B.getCode()); | ||||
| payOrder.setPosPayOrderId(couponOrder.getId()); | payOrder.setPosPayOrderId(couponOrder.getId()); | ||||
| @@ -1240,8 +1240,7 @@ public class WxOrderServiceImpl implements WxOrderService { | |||||
| order.setOrderType(EnumComposeOrder.SINGLE.getCode()); | order.setOrderType(EnumComposeOrder.SINGLE.getCode()); | ||||
| order.setCreateDate(new Date()); | order.setCreateDate(new Date()); | ||||
| wxBatchOrderMapper.insert(order); | wxBatchOrderMapper.insert(order); | ||||
| Long orderNumber = idWorker.nextId(); | Long orderNumber = idWorker.nextId(); | ||||
| @@ -2607,14 +2606,8 @@ public class WxOrderServiceImpl implements WxOrderService { | |||||
| sharingOrder.setMerchantId(wxMerchantBUser.getMerchantId()); | sharingOrder.setMerchantId(wxMerchantBUser.getMerchantId()); | ||||
| sharingOrder.setType(EnumProfitSharingOrderType.PROFIT_SHARING_SINGLE.getCode()); | sharingOrder.setType(EnumProfitSharingOrderType.PROFIT_SHARING_SINGLE.getCode()); | ||||
| sharingOrder.setPayAmount(wxPayOrder.getPayAmount()); | sharingOrder.setPayAmount(wxPayOrder.getPayAmount()); | ||||
| WxComposeChildOrderShare share = wxPayOrder.getChildOrderShare(wxOrder.getId()); | |||||
| sharingOrder.setMerchantShareAmount(share.getShareAmount()); | |||||
| sharingOrder.setMallRealRateAmount(share.getRateAmount()); | |||||
| sharingOrder.setRealRateAmount(share.getRealRateAmount()); | |||||
| sharingOrder.setCommissionAmount(share.getCommissionAmount()); | |||||
| sharingOrder.setOrderId(wxPayOrder.getId()); | sharingOrder.setOrderId(wxPayOrder.getId()); | ||||
| sharingOrder.setSingleOrderId(share.getOrderId()); | |||||
| sharingOrder.setSingleOrderAmount(share.getRealPayMent()); | |||||
| sharingOrder.setSingleOrderId(wxOrder.getId()); | |||||
| sharingOrder.setPayTimeStart(wxPayOrder.getPayTimeStart()); | sharingOrder.setPayTimeStart(wxPayOrder.getPayTimeStart()); | ||||
| sharingOrder.setPayTimeEnd(wxPayOrder.getPayTimeEnd()); | sharingOrder.setPayTimeEnd(wxPayOrder.getPayTimeEnd()); | ||||
| sharingOrder.updateTenantInfo(wxPayOrder); | sharingOrder.updateTenantInfo(wxPayOrder); | ||||
| @@ -434,16 +434,12 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { | |||||
| logger.error("getChildOrders null" + record.toString()); | logger.error("getChildOrders null" + record.toString()); | ||||
| throw new MallinkException(ErrorCode.PAY_ORDER_ERROR); | throw new MallinkException(ErrorCode.PAY_ORDER_ERROR); | ||||
| } | } | ||||
| int merchantShare_amount = 0; | |||||
| int mall_real_rate_amount = 0; | |||||
| int sys_share_amount = 0;//系统的提点 | |||||
| int commission_amount = 0;//平台(微信,抖音)扣点 | |||||
| //TODO 注意购物车模式(需测试)每笔子订单算法可能与总订单算法有差 | |||||
| for (WxOrder o : orderList) { | for (WxOrder o : orderList) { | ||||
| Long merchant_id = null; | Long merchant_id = null; | ||||
| String merchant_uid = ""; | String merchant_uid = ""; | ||||
| if(EnumPayMchType.DIRECT.equals(payMchType)){//直连模式记录收款商户 | if(EnumPayMchType.DIRECT.equals(payMchType)){//直连模式记录收款商户 | ||||
| //TODO 11111111111加缓存 | |||||
| //TODO 加缓存 | |||||
| merchant_id = wxCouponChannelService.getCouponOneMerchantId(o.getCouponChannelId(),o.getTenantId()); | merchant_id = wxCouponChannelService.getCouponOneMerchantId(o.getCouponChannelId(),o.getTenantId()); | ||||
| WxProfitSharingReceiver receiver = payShareServie.getReceiver(payAccount, merchant_id, null, payMchTypeEnum.getCode()); | WxProfitSharingReceiver receiver = payShareServie.getReceiver(payAccount, merchant_id, null, payMchTypeEnum.getCode()); | ||||
| if(receiver == null){ | if(receiver == null){ | ||||
| @@ -451,20 +447,9 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { | |||||
| } | } | ||||
| merchant_uid = receiver.getReceiverAccount(); | merchant_uid = receiver.getReceiverAccount(); | ||||
| } | } | ||||
| //TODO 1111111111111加缓存 | |||||
| int rate = payShareServie.getOfficialCommission(o,payAccount);//平台(微信,抖音)分佣率 | |||||
| int systemAmount = OrderHelper.getAmount(o.getPayment(), payAccount.getSystemRate());//系统扣点 | |||||
| PayShareCalculateAmount oShareAmount = payShareServie.calculateAmount(o.getPayment(),rate,systemAmount, payAccount); | |||||
| merchantShare_amount += oShareAmount.getMerchantShareAmount(); | |||||
| mall_real_rate_amount += oShareAmount.getMallRealRateAmount(); | |||||
| sys_share_amount += oShareAmount.getSystemAmount(); | |||||
| commission_amount += oShareAmount.getCommissionAmount(); | |||||
| childShares.put(String.valueOf(o.getId()), new WxComposeChildOrderShare(oShareAmount,merchant_id,merchant_uid,o.getId())); | |||||
| childShares.put(String.valueOf(o.getId()), new WxComposeChildOrderShare(o.getId(),o.getPayment(),merchant_id,merchant_uid)); | |||||
| } | } | ||||
| record.setShareAmount(merchantShare_amount); | |||||
| record.setRateAmount(mall_real_rate_amount); | |||||
| record.setSystemAmount(sys_share_amount); | |||||
| record.setCommissionAmount(commission_amount); | |||||
| record.setChildOrderShare(JSON.toJSONString(childShares)); | record.setChildOrderShare(JSON.toJSONString(childShares)); | ||||
| int sqlRow = wxPayOrderMapper.insert(record); | int sqlRow = wxPayOrderMapper.insert(record); | ||||
| @@ -576,6 +561,7 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { | |||||
| Long merchant_id = null; | Long merchant_id = null; | ||||
| String merchant_uid = ""; | String merchant_uid = ""; | ||||
| if(EnumPayMchType.DIRECT.getCode().equals(record.getMchType())){//直连模式记录收款商户 | if(EnumPayMchType.DIRECT.getCode().equals(record.getMchType())){//直连模式记录收款商户 | ||||
| //todo 缓存 | |||||
| merchant_id = user.getMerchantId(); | merchant_id = user.getMerchantId(); | ||||
| WxProfitSharingReceiver receiver = payShareServie.getReceiver(payAccount, merchant_id, null, record.getMchType()); | WxProfitSharingReceiver receiver = payShareServie.getReceiver(payAccount, merchant_id, null, record.getMchType()); | ||||
| if(receiver == null){ | if(receiver == null){ | ||||
| @@ -583,14 +569,7 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { | |||||
| } | } | ||||
| merchant_uid = receiver.getReceiverAccount(); | merchant_uid = receiver.getReceiverAccount(); | ||||
| } | } | ||||
| int systemAmount = OrderHelper.getAmount(order.getPayment(), payAccount.getSystemRate());//系统扣点 | |||||
| int rate = payShareServie.getOfficialCommission(order,payAccount);//抖音分佣率 | |||||
| PayShareCalculateAmount oShareAmount = payShareServie.calculateAmount(order.getPayment(),rate,systemAmount, payAccount); | |||||
| childShares.put(String.valueOf(order.getId()), new WxComposeChildOrderShare(oShareAmount,merchant_id,merchant_uid,order.getId())); | |||||
| record.setShareAmount(oShareAmount.getMerchantShareAmount()); | |||||
| record.setRateAmount(oShareAmount.getMallRealRateAmount()); | |||||
| record.setSystemAmount(oShareAmount.getSystemAmount()); | |||||
| record.setCommissionAmount(oShareAmount.getCommissionAmount()); | |||||
| childShares.put(String.valueOf(order.getId()), new WxComposeChildOrderShare(order.getId(),order.getPayment(),merchant_id,merchant_uid)); | |||||
| record.setChildOrderShare(JSON.toJSONString(childShares)); | record.setChildOrderShare(JSON.toJSONString(childShares)); | ||||
| int sqlRow = wxPayOrderMapper.insert(record); | int sqlRow = wxPayOrderMapper.insert(record); | ||||
| @@ -23,8 +23,10 @@ import com.iformall.mapper.*; | |||||
| import com.iformall.pay.*; | import com.iformall.pay.*; | ||||
| import com.iformall.service.ExcelService; | import com.iformall.service.ExcelService; | ||||
| import com.iformall.service.WxAppinfoService; | import com.iformall.service.WxAppinfoService; | ||||
| import com.iformall.service.WxMerchantService; | |||||
| import com.iformall.service.WxProfitSharingOrderService; | import com.iformall.service.WxProfitSharingOrderService; | ||||
| import com.iformall.service.order.entity.WxComposeChildOrderShare; | import com.iformall.service.order.entity.WxComposeChildOrderShare; | ||||
| import com.iformall.service.order.util.OrderHelper; | |||||
| import com.iformall.service.pay.PayServiceFactory; | import com.iformall.service.pay.PayServiceFactory; | ||||
| import com.iformall.service.pay.service.share.PayShareAdapterService; | import com.iformall.service.pay.service.share.PayShareAdapterService; | ||||
| import com.iformall.service.pay.service.share.entity.PayShareCalculateAmount; | import com.iformall.service.pay.service.share.entity.PayShareCalculateAmount; | ||||
| @@ -33,6 +35,7 @@ import com.iformall.service.pay.service.share.entity.PayShareQueryResultReceiver | |||||
| import com.iformall.service.pay.service.share.entity.PayShareResult; | import com.iformall.service.pay.service.share.entity.PayShareResult; | ||||
| import com.iformall.utils.BeanUtils; | import com.iformall.utils.BeanUtils; | ||||
| import com.iformall.utils.DateUtils; | import com.iformall.utils.DateUtils; | ||||
| import com.iformall.utils.PayUtils; | |||||
| import com.iformall.utils.Utility; | import com.iformall.utils.Utility; | ||||
| import cn.afterturn.easypoi.handler.inter.IExcelExportServer; | import cn.afterturn.easypoi.handler.inter.IExcelExportServer; | ||||
| @@ -61,6 +64,9 @@ public class WxProfitSharingOrderServiceImpl implements WxProfitSharingOrderServ | |||||
| @Autowired | @Autowired | ||||
| WxProfitSharingOrderMapper wxProfitSharingOrderMapper; | WxProfitSharingOrderMapper wxProfitSharingOrderMapper; | ||||
| @Autowired | |||||
| WxMerchantService wxMerchantService; | |||||
| @Autowired | @Autowired | ||||
| WxAppinfoMapper wxAppinfoMapper; | WxAppinfoMapper wxAppinfoMapper; | ||||
| @@ -87,6 +93,12 @@ public class WxProfitSharingOrderServiceImpl implements WxProfitSharingOrderServ | |||||
| @Autowired | @Autowired | ||||
| WxCardSpendMapper wxCardSpendMapper; | WxCardSpendMapper wxCardSpendMapper; | ||||
| @Autowired | |||||
| WxCouponChannelMapper wxCouponChannelMapper; | |||||
| @Autowired | |||||
| TtPoiTakeRateMapper ttPoiTakeRateMapper; | |||||
| @Autowired | @Autowired | ||||
| PayServiceFactory payServiceFactory; | PayServiceFactory payServiceFactory; | ||||
| @@ -138,6 +150,28 @@ public class WxProfitSharingOrderServiceImpl implements WxProfitSharingOrderServ | |||||
| return wxAppinfo; | return wxAppinfo; | ||||
| } | } | ||||
| private WxMerchant getByMerchantAdmin(TenantEntity tenantEntity,EnumMerchantAdmin merchantAdmin){ | |||||
| WxMerchant merchantQ = new WxMerchant(); | |||||
| merchantQ.updateTenantInfo(tenantEntity); | |||||
| merchantQ.setIsAdmin(merchantAdmin.getCode()); | |||||
| merchantQ.setStatus(EnumMerchantStatus.VALID.getCode()); | |||||
| return wxMerchantService.findListOne(merchantQ); | |||||
| } | |||||
| private int getMallSumRate(TenantEntity tenantEntity,Long orderId){ | |||||
| WxOrder o = wxOrderMapper.selectById(orderId, tenantEntity.getTenantId()); | |||||
| if(!EnumOrderType.COUPON.getCode().equals(o.getType())){ | |||||
| return 0; | |||||
| } | |||||
| Long couponId = wxCouponChannelMapper.findCouponIdById(o.getCouponChannelId(), o.getTenantId()); | |||||
| TtPoiTakeRate ttPoiTakeRate = ttPoiTakeRateMapper.selectByCoupon(tenantEntity.getTenantId(), couponId, EnumCpsPlanType.ALL.getCode(), null); | |||||
| if(ttPoiTakeRate != null){ | |||||
| return ttPoiTakeRate.getTakeRate(); | |||||
| }else{ | |||||
| return 0; | |||||
| } | |||||
| } | |||||
| @Override | @Override | ||||
| // @Transactional(isolation=Isolation.SERIALIZABLE, propagation = Propagation.REQUIRED, rollbackFor = {Exception.class}) | // @Transactional(isolation=Isolation.SERIALIZABLE, propagation = Propagation.REQUIRED, rollbackFor = {Exception.class}) | ||||
| public ResultData redoSharingOrder(WxProfitSharingOrder sharingOrder,WxPayOrder payOrder) { | public ResultData redoSharingOrder(WxProfitSharingOrder sharingOrder,WxPayOrder payOrder) { | ||||
| @@ -163,6 +197,12 @@ public class WxProfitSharingOrderServiceImpl implements WxProfitSharingOrderServ | |||||
| wxProfitSharingOrderMapper.updateById(updSharingOrder); | wxProfitSharingOrderMapper.updateById(updSharingOrder); | ||||
| return new ResultData(ErrorCode.PROFIT_SHARING_REQUEST_FAILED.getCode(),"未获取到达人佣金"); | return new ResultData(ErrorCode.PROFIT_SHARING_REQUEST_FAILED.getCode(),"未获取到达人佣金"); | ||||
| } | } | ||||
| JSONArray receivers = new JSONArray();//分账参数json | |||||
| EnumPayWay enumPayWay = EnumPayWay.getEnum(payOrder.getPayVendor()); | |||||
| EnumAppPlat enumPlat = enumPayWay.getPlat(); | |||||
| WxAppinfo cAppInfo = wxAppinfoService.getCAppInfo(sharingOrder, enumPlat); | |||||
| WxPayAccount payAccount = wxPayAccountMapper.selectById(cAppInfo.getPayId()); | |||||
| WxComposeChildOrderShare wxComposeChildOrderShare = null; | WxComposeChildOrderShare wxComposeChildOrderShare = null; | ||||
| if(sharingOrder.getSingleOrderId() != null){ | if(sharingOrder.getSingleOrderId() != null){ | ||||
| @@ -170,34 +210,89 @@ public class WxProfitSharingOrderServiceImpl implements WxProfitSharingOrderServ | |||||
| }else{ | }else{ | ||||
| wxComposeChildOrderShare = payOrder.getSingleChildOrderShare(); | wxComposeChildOrderShare = payOrder.getSingleChildOrderShare(); | ||||
| } | } | ||||
| wxComposeChildOrderShare.setCpsCommission(cpsCommission); | wxComposeChildOrderShare.setCpsCommission(cpsCommission); | ||||
| //添加分账账号: 系统抽点,销售提成,商场扣点,平台(微信,抖音)抽佣 | |||||
| int systemAmount = wxComposeChildOrderShare.getSystemAmount();//系统抽点 | |||||
| int sellerAmount = 0;//销售抽点 | |||||
| int mallAmount = wxComposeChildOrderShare.getRateAmount();//商场抽点 | |||||
| int commissionAmount = wxComposeChildOrderShare.getCommissionAmount();//平台(微信,抖音)抽佣 | |||||
| int realRateAmount = wxComposeChildOrderShare.getRealRateAmount();//支付通道费用 | |||||
| int shareAmount = wxComposeChildOrderShare.getShareAmount() - cpsCommission;//分给商户的钱 | |||||
| JSONArray receivers = new JSONArray();//分账参数json | |||||
| //todo | |||||
| // 1.总分模式下 不分账(只分给各个抽成方)如果各个抽成方为0 则直接解冻 | |||||
| // 2.总分模式下 分账 (分账给商家及各个抽成方) | |||||
| // 3.直连模式下 不分账和分账一样(只分账给各个抽成方)如果各种抽成金额为0 则直接解冻 | |||||
| if(systemAmount > 0){ | |||||
| //todo 查询系统抽点到账帐号 jsonArray.add() | |||||
| } | |||||
| if(sellerAmount > 0){ | |||||
| //todo 查询销售抽点到账帐号 jsonArray.add() | |||||
| } | |||||
| if(mallAmount > 0){ | |||||
| //todo 查询商场抽点到账帐号 jsonArray.add() | |||||
| //需要判断当前订单收款帐号非商场抽点到账帐号 | |||||
| //官方手续费千6 | |||||
| int realRateAmount = PayUtils.getPayRate(wxComposeChildOrderShare.getRealPayMent(), payAccount.getRealRate(), true); | |||||
| wxComposeChildOrderShare.setRealRateAmount(realRateAmount); | |||||
| //官方平台抽佣 | |||||
| int rate = payShareAdapterService.getOfficialCommission(wxComposeChildOrderShare.getOrderId(),payAccount); | |||||
| int commissionAmount = PayUtils.getPayRate(wxComposeChildOrderShare.getRealPayMent(), rate, true); | |||||
| wxComposeChildOrderShare.setCommissionAmount(commissionAmount); | |||||
| int surplus = 0;//当广场抽成帐号与收款帐号相等,无法添加分账方,计入商管商户中 | |||||
| if(EnumPayMchType.DIRECT.getCode().equals(payOrder.getMchType())){ | |||||
| //销售抽点 | |||||
| int sellerAmount = PayUtils.getPayRate(wxComposeChildOrderShare.getRealPayMent(), payAccount.getSellRate(), false); | |||||
| wxComposeChildOrderShare.setSellerAmount(sellerAmount); | |||||
| if(sellerAmount > 0){ | |||||
| WxMerchant sellMerchant = getByMerchantAdmin(payOrder,EnumMerchantAdmin.PRIVATE_SELL); | |||||
| if(sellMerchant != null){ | |||||
| WxProfitSharingReceiver receiver = payShareAdapterService.getReceiver(payOrder, sellMerchant.getId(), payOrder.getTtPayWay(), payOrder.getMchType()); | |||||
| if(receiver != null){ | |||||
| JSONObject jo = new JSONObject(); | |||||
| jo.put("type",payShareAdapterService.getShareAccount(receiver.getReceiverType()).getMessage()); | |||||
| jo.put("account",receiver.getReceiverAccount()); | |||||
| jo.put("amount", sellerAmount); | |||||
| jo.put("merchantId",receiver.getMerchantId()); | |||||
| jo.put("description",receiver.getId().toString()); //为重试做准备 | |||||
| receivers.add(jo); | |||||
| } | |||||
| } | |||||
| } | |||||
| //系统抽成 | |||||
| int systemAmount = PayUtils.getPayRate(wxComposeChildOrderShare.getRealPayMent(), payAccount.getSystemRate(), false); | |||||
| wxComposeChildOrderShare.setSystemAmount(systemAmount); | |||||
| if(sellerAmount > 0 && receivers.isEmpty()){ | |||||
| systemAmount += systemAmount; | |||||
| } | |||||
| if(systemAmount > 0){ | |||||
| WxMerchant sysMerchant = getByMerchantAdmin(payOrder,EnumMerchantAdmin.PRIVATE_SYSTEM); | |||||
| if(sysMerchant != null){ | |||||
| WxProfitSharingReceiver receiver = payShareAdapterService.getReceiver(payOrder, sysMerchant.getId(), payOrder.getTtPayWay(), payOrder.getMchType()); | |||||
| if(receiver != null){ | |||||
| JSONObject jo = new JSONObject(); | |||||
| jo.put("type",payShareAdapterService.getShareAccount(receiver.getReceiverType()).getMessage()); | |||||
| jo.put("account",receiver.getReceiverAccount()); | |||||
| jo.put("amount", sellerAmount); | |||||
| jo.put("merchantId",receiver.getMerchantId()); | |||||
| jo.put("description",receiver.getId().toString()); //为重试做准备 | |||||
| receivers.add(jo); | |||||
| } | |||||
| } | |||||
| } | |||||
| //总分佣 | |||||
| int mallRate = getMallSumRate(payOrder,wxComposeChildOrderShare.getOrderId()); | |||||
| int serviceAmount = PayUtils.getPayRate(wxComposeChildOrderShare.getRealPayMent(), mallRate, true); | |||||
| wxComposeChildOrderShare.setServiceAmount(serviceAmount); | |||||
| //商场分成 | |||||
| int mallAmount = wxComposeChildOrderShare.getRateAmount(); | |||||
| if(systemAmount > 0 && receivers.isEmpty()){ | |||||
| mallAmount += systemAmount; | |||||
| } | |||||
| if(mallAmount > 0){ | |||||
| WxMerchant adminMerchant = getByMerchantAdmin(payOrder,EnumMerchantAdmin.PUBLIC_ADMIN); | |||||
| if(adminMerchant != null && !wxComposeChildOrderShare.getMerchantId().equals(adminMerchant.getId())){ | |||||
| WxProfitSharingReceiver receiver = payShareAdapterService.getReceiver(payOrder, adminMerchant.getId(), payOrder.getTtPayWay(), payOrder.getMchType()); | |||||
| if(receiver != null){ | |||||
| JSONObject jo = new JSONObject(); | |||||
| jo.put("type",payShareAdapterService.getShareAccount(receiver.getReceiverType()).getMessage()); | |||||
| jo.put("account",receiver.getReceiverAccount()); | |||||
| jo.put("amount", sellerAmount); | |||||
| jo.put("merchantId",receiver.getMerchantId()); | |||||
| jo.put("description",receiver.getId().toString()); //为重试做准备 | |||||
| receivers.add(jo); | |||||
| } | |||||
| } | |||||
| } | |||||
| if(mallAmount > 0 && receivers.isEmpty()){ | |||||
| surplus += mallAmount; | |||||
| } | |||||
| }else{ | |||||
| wxComposeChildOrderShare.setServiceAmount(null); | |||||
| } | } | ||||
| //商户所得 | |||||
| int shareAmount = wxComposeChildOrderShare.getShareAmount() + surplus; | |||||
| WxProfitSharingReceiver receiver = payShareAdapterService.getReceiver(sharingOrder,sharingOrder.getMerchantId(),payOrder.getTtPayWay(),sharingOrder.getMchType()); | |||||
| WxProfitSharingReceiver receiver = payShareAdapterService.getReceiver(sharingOrder,sharingOrder.getMerchantId(),payOrder.getTtPayWay(),payOrder.getMchType()); | |||||
| if(EnumPayMchType.TOTAL.getCode().equals(payOrder.getMchType()) && EnumPayShare.YES.getCode().equals(payOrder.getShare())){ | if(EnumPayMchType.TOTAL.getCode().equals(payOrder.getMchType()) && EnumPayShare.YES.getCode().equals(payOrder.getShare())){ | ||||
| JSONObject jo = new JSONObject(); | JSONObject jo = new JSONObject(); | ||||
| jo.put("type",payShareAdapterService.getShareAccount(receiver.getReceiverType()).getMessage()); | jo.put("type",payShareAdapterService.getShareAccount(receiver.getReceiverType()).getMessage()); | ||||
| @@ -208,12 +303,6 @@ public class WxProfitSharingOrderServiceImpl implements WxProfitSharingOrderServ | |||||
| receivers.add(jo); | receivers.add(jo); | ||||
| } | } | ||||
| EnumPayWay enumPayWay = EnumPayWay.getEnum(payOrder.getPayVendor()); | |||||
| EnumAppPlat enumPlat = enumPayWay.getPlat(); | |||||
| WxAppinfo cAppInfo = wxAppinfoService.getCAppInfo(sharingOrder, enumPlat); | |||||
| WxPayAccount payAccount = wxPayAccountMapper.selectById(cAppInfo.getPayId()); | |||||
| if(receivers.isEmpty()){ | if(receivers.isEmpty()){ | ||||
| shareResult = payShareAdapterService.noReciverShare(cAppInfo, payAccount, sharingOrder); | shareResult = payShareAdapterService.noReciverShare(cAppInfo, payAccount, sharingOrder); | ||||
| }else{ | }else{ | ||||
| @@ -294,7 +383,7 @@ public class WxProfitSharingOrderServiceImpl implements WxProfitSharingOrderServ | |||||
| WxProfitSharingOrder record = new WxProfitSharingOrder(); | WxProfitSharingOrder record = new WxProfitSharingOrder(); | ||||
| record.updateTenantInfo(payOrder); | record.updateTenantInfo(payOrder); | ||||
| record.setOrderId(payOrder.getId()); | record.setOrderId(payOrder.getId()); | ||||
| record.setSingleOrderId(sharingOrderDto.getSingleOrderId()); | |||||
| record.setSingleOrderId(childOrderShare.getOrderId()); | |||||
| record = wxProfitSharingOrderMapper.selectOne(new QueryWrapper(record)); | record = wxProfitSharingOrderMapper.selectOne(new QueryWrapper(record)); | ||||
| if (record == null) { | if (record == null) { | ||||
| //创建分账订单 | //创建分账订单 | ||||
| @@ -326,7 +415,7 @@ public class WxProfitSharingOrderServiceImpl implements WxProfitSharingOrderServ | |||||
| record.setPayMerchantMchId(childOrderShare.getMerchantUid()); | record.setPayMerchantMchId(childOrderShare.getMerchantUid()); | ||||
| } | } | ||||
| record.setSharingStatus(EnumProfitSharingOrderStatus.PROFIT_SHARING_READY.getCode()); | record.setSharingStatus(EnumProfitSharingOrderStatus.PROFIT_SHARING_READY.getCode()); | ||||
| record.setPointDeduction(JSON.toJSONString(childOrderShare)); | |||||
| // record.setPointDeduction(JSON.toJSONString(childOrderShare)); | |||||
| record.setCreateTime(currentDate); | record.setCreateTime(currentDate); | ||||
| record.setUpdateTime(currentDate); | record.setUpdateTime(currentDate); | ||||
| record.setType(sharingOrderDto.getType()); | record.setType(sharingOrderDto.getType()); | ||||
| @@ -11,37 +11,44 @@ import lombok.Data; | |||||
| @Data | @Data | ||||
| public class WxComposeChildOrderShare { | public class WxComposeChildOrderShare { | ||||
| public WxComposeChildOrderShare(Integer realPayMent,Integer shareAmount,Integer rateAmount,Integer realRateAmount,Integer commissionAmount,Integer systemAmount, | |||||
| Long merchantId,String merchantUid,Long orderId) { | |||||
| this.realPayMent = realPayMent; | |||||
| this.shareAmount = shareAmount; | |||||
| this.rateAmount = rateAmount; | |||||
| this.realRateAmount = realRateAmount; | |||||
| if (null != commissionAmount) { | |||||
| this.commissionAmount = commissionAmount; | |||||
| } | |||||
| if (null != systemAmount) { | |||||
| this.systemAmount = systemAmount; | |||||
| } | |||||
| this.merchantId = merchantId; | |||||
| this.merchantUid = merchantUid; | |||||
| this.orderId = orderId; | |||||
| } | |||||
| // public WxComposeChildOrderShare(Integer realPayMent,Integer shareAmount,Integer rateAmount,Integer realRateAmount,Integer commissionAmount,Integer systemAmount, | |||||
| // Long merchantId,String merchantUid,Long orderId) { | |||||
| // this.realPayMent = realPayMent; | |||||
| // this.shareAmount = shareAmount; | |||||
| // this.rateAmount = rateAmount; | |||||
| // this.realRateAmount = realRateAmount; | |||||
| // if (null != commissionAmount) { | |||||
| // this.commissionAmount = commissionAmount; | |||||
| // } | |||||
| // if (null != systemAmount) { | |||||
| // this.systemAmount = systemAmount; | |||||
| // } | |||||
| // this.merchantId = merchantId; | |||||
| // this.merchantUid = merchantUid; | |||||
| // this.orderId = orderId; | |||||
| // } | |||||
| public WxComposeChildOrderShare(PayShareCalculateAmount shareCalculateAmount,Long merchantId,String merchantUid,Long orderId) { | |||||
| this.realPayMent = shareCalculateAmount.getPayAmount(); | |||||
| this.shareAmount = shareCalculateAmount.getMerchantShareAmount(); | |||||
| this.rateAmount = shareCalculateAmount.getMallRealRateAmount(); | |||||
| this.realRateAmount = shareCalculateAmount.getRealRateAmount(); | |||||
| if (null != shareCalculateAmount.getCommissionAmount()) { | |||||
| this.commissionAmount = shareCalculateAmount.getCommissionAmount(); | |||||
| } | |||||
| if (null != shareCalculateAmount.getSystemAmount()) { | |||||
| this.systemAmount = shareCalculateAmount.getSystemAmount(); | |||||
| } | |||||
| // public WxComposeChildOrderShare(PayShareCalculateAmount shareCalculateAmount,Long merchantId,String merchantUid,Long orderId) { | |||||
| // this.realPayMent = shareCalculateAmount.getPayAmount(); | |||||
| // this.shareAmount = shareCalculateAmount.getMerchantShareAmount(); | |||||
| // this.rateAmount = shareCalculateAmount.getMallRealRateAmount(); | |||||
| // this.realRateAmount = shareCalculateAmount.getRealRateAmount(); | |||||
| // if (null != shareCalculateAmount.getCommissionAmount()) { | |||||
| // this.commissionAmount = shareCalculateAmount.getCommissionAmount(); | |||||
| // } | |||||
| // if (null != shareCalculateAmount.getSystemAmount()) { | |||||
| // this.systemAmount = shareCalculateAmount.getSystemAmount(); | |||||
| // } | |||||
| // this.merchantId = merchantId; | |||||
| // this.merchantUid = merchantUid; | |||||
| // this.orderId = orderId; | |||||
| // } | |||||
| public WxComposeChildOrderShare(Long orderId,Integer realPayMent,Long merchantId,String merchantUid) { | |||||
| this.orderId = orderId; | |||||
| this.realPayMent = realPayMent; | |||||
| this.merchantId = merchantId; | this.merchantId = merchantId; | ||||
| this.merchantUid = merchantUid; | this.merchantUid = merchantUid; | ||||
| this.orderId = orderId; | |||||
| } | } | ||||
| private Long orderId;//订单编号,v3要用 | private Long orderId;//订单编号,v3要用 | ||||
| @@ -52,12 +59,43 @@ public class WxComposeChildOrderShare { | |||||
| private Integer rateAmount;//商场实际通道费(扣除了支付通道费的) | private Integer rateAmount;//商场实际通道费(扣除了支付通道费的) | ||||
| private Integer realRateAmount;//平台手续费(微信,抖音) | private Integer realRateAmount;//平台手续费(微信,抖音) | ||||
| private Integer commissionAmount = 0;//平台佣金(微信,抖音) | |||||
| private Integer commissionAmount;//平台佣金(微信,抖音) | |||||
| private Integer systemAmount = 0;//系统扣点费 | |||||
| private Integer systemAmount;//系统扣点费 | |||||
| private Integer sellerAmount;//销售扣点费 | |||||
| private Integer cpsCommission;//达人佣金 | private Integer cpsCommission;//达人佣金 | ||||
| private Integer serviceAmount;//所有扣款总合 | |||||
| private Long merchantId;//收款商户 | private Long merchantId;//收款商户 | ||||
| private String merchantUid;//收款商户 | private String merchantUid;//收款商户 | ||||
| public void setServiceAmount(Integer serviceAmount){ | |||||
| if(this.realRateAmount == null){ | |||||
| return; | |||||
| } | |||||
| int sumAmount = this.realRateAmount.intValue(); | |||||
| if(this.commissionAmount != null){ | |||||
| sumAmount += this.commissionAmount.intValue(); | |||||
| } | |||||
| if(this.cpsCommission != null){ | |||||
| sumAmount += this.cpsCommission.intValue(); | |||||
| } | |||||
| if(this.systemAmount != null){ | |||||
| sumAmount += this.systemAmount; | |||||
| } | |||||
| if(this.sellerAmount != null){ | |||||
| sumAmount += this.sellerAmount; | |||||
| } | |||||
| if(serviceAmount == null || serviceAmount.intValue() < sumAmount){ | |||||
| this.serviceAmount = sumAmount; | |||||
| }else{ | |||||
| this.serviceAmount = serviceAmount; | |||||
| } | |||||
| this.rateAmount = this.serviceAmount.intValue() - sumAmount; | |||||
| this.shareAmount = this.realPayMent.intValue() - this.serviceAmount.intValue(); | |||||
| } | |||||
| } | } | ||||
| @@ -8,11 +8,7 @@ import com.iformall.common.ResultData; | |||||
| import com.iformall.domain.dto.WxSharingOrderDto; | import com.iformall.domain.dto.WxSharingOrderDto; | ||||
| import com.iformall.domain.po.*; | import com.iformall.domain.po.*; | ||||
| import com.iformall.domain.po.base.TenantEntity; | import com.iformall.domain.po.base.TenantEntity; | ||||
| import com.iformall.enums.EnumPayMchType; | |||||
| import com.iformall.enums.EnumPayWay; | |||||
| import com.iformall.enums.EnumProfitSharingOrderType; | |||||
| import com.iformall.enums.EnumProfitSharingReceiverType; | |||||
| import com.iformall.enums.EnumProfitSharingType; | |||||
| import com.iformall.enums.*; | |||||
| import com.iformall.exception.MallinkException; | import com.iformall.exception.MallinkException; | ||||
| import com.iformall.service.pay.service.share.entity.ShareAccountResult; | import com.iformall.service.pay.service.share.entity.ShareAccountResult; | ||||
| import com.iformall.service.pay.service.share.entity.PayShareCalculateAmount; | import com.iformall.service.pay.service.share.entity.PayShareCalculateAmount; | ||||
| @@ -36,12 +32,12 @@ public interface PayShareAdapterService { | |||||
| * 获取分账订单初始状态 | * 获取分账订单初始状态 | ||||
| * @return | * @return | ||||
| */ | */ | ||||
| public Integer getSharingOrderInitialStatus(); | |||||
| // public Integer getSharingOrderInitialStatus(); | |||||
| /** | /** | ||||
| * 计算商场分账金额和实际费率金额 | * 计算商场分账金额和实际费率金额 | ||||
| */ | */ | ||||
| public PayShareCalculateAmount calculateAmount(Integer payAmount,Integer officialCommissionRate,Integer systemAmount,WxPayAccount payAccount); | |||||
| // public PayShareCalculateAmount calculateAmount(Integer payAmount,Integer officialCommissionRate,Integer systemAmount,WxPayAccount payAccount); | |||||
| /** | /** | ||||
| * 查询商户的收款账号信息 | * 查询商户的收款账号信息 | ||||
| @@ -130,6 +126,6 @@ public interface PayShareAdapterService { | |||||
| * @param payAccount | * @param payAccount | ||||
| * @return | * @return | ||||
| */ | */ | ||||
| int getOfficialCommission(WxOrder o, WxPayAccount payAccount); | |||||
| int getOfficialCommission(Long orderId, WxPayAccount payAccount); | |||||
| } | } | ||||
| @@ -43,96 +43,96 @@ public abstract class PayShareBaseAdapterService implements PayShareAdapterServi | |||||
| return JSONArray.parseArray(response,PayShareQueryResultReceivers.class); | return JSONArray.parseArray(response,PayShareQueryResultReceivers.class); | ||||
| } | } | ||||
| protected String calReceiversAmount(WxSharingOrderDto sharingOrderDto,List<WxProfitSharingReceiver> psReceiverList) { | |||||
| if (psReceiverList != null && psReceiverList.size() > 50) { | |||||
| throw new MallinkException(ErrorCode.PROFIT_SHARING_RECEIVER_INVALID); | |||||
| } | |||||
| if (psReceiverList == null || psReceiverList.size() == 0) { //没有分账账户, | |||||
| throw new MallinkException(ErrorCode.PROFIT_SHARING_RECEIVER_UNKNOWN); | |||||
| } | |||||
| if (psReceiverList.size() > 1 &&//计算分账账户合法性 | |||||
| psReceiverList.stream().filter(r->(r.getParameter() == null)).count() > 0) { | |||||
| throw new MallinkException(ErrorCode.PROFIT_SHARING_RECEIVER_INVALID); | |||||
| } | |||||
| //计算分账金额合法性 | |||||
| psReceiverList.stream().forEach(r-> | |||||
| { | |||||
| if (r.getParameter() == null){ | |||||
| r.setSharingAmount(sharingOrderDto.getMerchantShareAmount()); | |||||
| r.setRateAmount(sharingOrderDto.getMallRealRateAmount()); | |||||
| r.setRealRateAmount(sharingOrderDto.getRealRateAmount()); | |||||
| r.setCommissionAmount(sharingOrderDto.getCommissionAmount()); | |||||
| } else { | |||||
| r.setSharingAmount(sharingOrderDto.getMerchantShareAmount()*Integer.valueOf(r.getParameter())/10000); | |||||
| } | |||||
| }); | |||||
| if (psReceiverList.stream().mapToInt(r->r.getSharingAmount()).sum() > sharingOrderDto.getMerchantShareAmount()){ | |||||
| throw new MallinkException(ErrorCode.PROFIT_SHARING_RECEIVER_UNKNOWN); | |||||
| } | |||||
| // 添加分账接收方 | |||||
| JSONArray receivers = new JSONArray(); | |||||
| psReceiverList.stream().forEach(receiver->{ | |||||
| JSONObject jo = new JSONObject(); | |||||
| jo.put("type",this.getShareAccount(receiver.getReceiverType()).getMessage()); | |||||
| jo.put("account",receiver.getReceiverAccount()); | |||||
| jo.put("amount", receiver.getSharingAmount()); | |||||
| jo.put("rateAmount", receiver.getRateAmount()); | |||||
| jo.put("realRateAmount", receiver.getRateAmount()); | |||||
| jo.put("commissionAmount", receiver.getCommissionAmount()); | |||||
| //jo.put("description",receiver.getReceiverComments()); //改为存ID, | |||||
| jo.put("description",receiver.getId().toString()); //为重试做准备 | |||||
| receivers.add(jo); | |||||
| }); | |||||
| return receivers.toJSONString(); | |||||
| } | |||||
| // protected String calReceiversAmount(WxSharingOrderDto sharingOrderDto,List<WxProfitSharingReceiver> psReceiverList) { | |||||
| // if (psReceiverList != null && psReceiverList.size() > 50) { | |||||
| // throw new MallinkException(ErrorCode.PROFIT_SHARING_RECEIVER_INVALID); | |||||
| // } | |||||
| // | |||||
| // if (psReceiverList == null || psReceiverList.size() == 0) { //没有分账账户, | |||||
| // throw new MallinkException(ErrorCode.PROFIT_SHARING_RECEIVER_UNKNOWN); | |||||
| // } | |||||
| // | |||||
| // if (psReceiverList.size() > 1 &&//计算分账账户合法性 | |||||
| // psReceiverList.stream().filter(r->(r.getParameter() == null)).count() > 0) { | |||||
| // throw new MallinkException(ErrorCode.PROFIT_SHARING_RECEIVER_INVALID); | |||||
| // } | |||||
| // | |||||
| // //计算分账金额合法性 | |||||
| // psReceiverList.stream().forEach(r-> | |||||
| // { | |||||
| // if (r.getParameter() == null){ | |||||
| // r.setSharingAmount(sharingOrderDto.getMerchantShareAmount()); | |||||
| // r.setRateAmount(sharingOrderDto.getMallRealRateAmount()); | |||||
| // r.setRealRateAmount(sharingOrderDto.getRealRateAmount()); | |||||
| // r.setCommissionAmount(sharingOrderDto.getCommissionAmount()); | |||||
| // } else { | |||||
| // r.setSharingAmount(sharingOrderDto.getMerchantShareAmount()*Integer.valueOf(r.getParameter())/10000); | |||||
| // } | |||||
| // }); | |||||
| // if (psReceiverList.stream().mapToInt(r->r.getSharingAmount()).sum() > sharingOrderDto.getMerchantShareAmount()){ | |||||
| // throw new MallinkException(ErrorCode.PROFIT_SHARING_RECEIVER_UNKNOWN); | |||||
| // } | |||||
| // | |||||
| // // 添加分账接收方 | |||||
| // JSONArray receivers = new JSONArray(); | |||||
| // psReceiverList.stream().forEach(receiver->{ | |||||
| // JSONObject jo = new JSONObject(); | |||||
| // jo.put("type",this.getShareAccount(receiver.getReceiverType()).getMessage()); | |||||
| // jo.put("account",receiver.getReceiverAccount()); | |||||
| // jo.put("amount", receiver.getSharingAmount()); | |||||
| // jo.put("rateAmount", receiver.getRateAmount()); | |||||
| // jo.put("realRateAmount", receiver.getRateAmount()); | |||||
| // jo.put("commissionAmount", receiver.getCommissionAmount()); | |||||
| // //jo.put("description",receiver.getReceiverComments()); //改为存ID, | |||||
| // jo.put("description",receiver.getId().toString()); //为重试做准备 | |||||
| // receivers.add(jo); | |||||
| // }); | |||||
| // return receivers.toJSONString(); | |||||
| // } | |||||
| protected String calV3ReceiversAmount(WxSharingOrderDto sharingOrderDto,List<WxProfitSharingReceiver> psReceiverList) { | |||||
| if (psReceiverList != null && psReceiverList.size() > 50) { | |||||
| throw new MallinkException(ErrorCode.PROFIT_SHARING_RECEIVER_INVALID); | |||||
| } | |||||
| if (psReceiverList == null || psReceiverList.size() == 0) { //没有分账账户, | |||||
| throw new MallinkException(ErrorCode.PROFIT_SHARING_RECEIVER_UNKNOWN); | |||||
| } | |||||
| if (psReceiverList.size() > 1 &&//计算分账账户合法性 | |||||
| psReceiverList.stream().filter(r->(r.getParameter() == null)).count() > 0) { | |||||
| throw new MallinkException(ErrorCode.PROFIT_SHARING_RECEIVER_INVALID); | |||||
| } | |||||
| //计算分账金额合法性 | |||||
| psReceiverList.stream().forEach(r-> | |||||
| { | |||||
| if (r.getParameter() == null){ | |||||
| r.setSharingAmount(sharingOrderDto.getMerchantShareAmount()); | |||||
| r.setRateAmount(sharingOrderDto.getMallRealRateAmount()); | |||||
| r.setRealRateAmount(sharingOrderDto.getRealRateAmount()); | |||||
| r.setCommissionAmount(sharingOrderDto.getCommissionAmount()); | |||||
| } else { | |||||
| r.setSharingAmount(sharingOrderDto.getMerchantShareAmount()*Integer.valueOf(r.getParameter())/10000); | |||||
| } | |||||
| }); | |||||
| if (psReceiverList.stream().mapToInt(r->r.getSharingAmount()).sum() > sharingOrderDto.getMerchantShareAmount()){ | |||||
| throw new MallinkException(ErrorCode.PROFIT_SHARING_RECEIVER_UNKNOWN); | |||||
| } | |||||
| // 添加分账接收方 | |||||
| JSONArray receivers = new JSONArray(); | |||||
| psReceiverList.stream().forEach(receiver->{ | |||||
| JSONObject jo = new JSONObject(); | |||||
| jo.put("type",this.getShareAccount(receiver.getReceiverType()).getMessage()); | |||||
| jo.put("account",receiver.getReceiverAccount()); | |||||
| jo.put("amount", receiver.getSharingAmount()); | |||||
| //jo.put("description",receiver.getReceiverComments()); //改为存ID, | |||||
| jo.put("description",receiver.getId().toString()); //为重试做准备 | |||||
| receivers.add(jo); | |||||
| }); | |||||
| return receivers.toJSONString(); | |||||
| } | |||||
| // protected String calV3ReceiversAmount(WxSharingOrderDto sharingOrderDto,List<WxProfitSharingReceiver> psReceiverList) { | |||||
| // if (psReceiverList != null && psReceiverList.size() > 50) { | |||||
| // throw new MallinkException(ErrorCode.PROFIT_SHARING_RECEIVER_INVALID); | |||||
| // } | |||||
| // | |||||
| // if (psReceiverList == null || psReceiverList.size() == 0) { //没有分账账户, | |||||
| // throw new MallinkException(ErrorCode.PROFIT_SHARING_RECEIVER_UNKNOWN); | |||||
| // } | |||||
| // | |||||
| // if (psReceiverList.size() > 1 &&//计算分账账户合法性 | |||||
| // psReceiverList.stream().filter(r->(r.getParameter() == null)).count() > 0) { | |||||
| // throw new MallinkException(ErrorCode.PROFIT_SHARING_RECEIVER_INVALID); | |||||
| // } | |||||
| // | |||||
| // //计算分账金额合法性 | |||||
| // psReceiverList.stream().forEach(r-> | |||||
| // { | |||||
| // if (r.getParameter() == null){ | |||||
| // r.setSharingAmount(sharingOrderDto.getMerchantShareAmount()); | |||||
| // r.setRateAmount(sharingOrderDto.getMallRealRateAmount()); | |||||
| // r.setRealRateAmount(sharingOrderDto.getRealRateAmount()); | |||||
| // r.setCommissionAmount(sharingOrderDto.getCommissionAmount()); | |||||
| // } else { | |||||
| // r.setSharingAmount(sharingOrderDto.getMerchantShareAmount()*Integer.valueOf(r.getParameter())/10000); | |||||
| // } | |||||
| // }); | |||||
| // if (psReceiverList.stream().mapToInt(r->r.getSharingAmount()).sum() > sharingOrderDto.getMerchantShareAmount()){ | |||||
| // throw new MallinkException(ErrorCode.PROFIT_SHARING_RECEIVER_UNKNOWN); | |||||
| // } | |||||
| // | |||||
| // // 添加分账接收方 | |||||
| // JSONArray receivers = new JSONArray(); | |||||
| // psReceiverList.stream().forEach(receiver->{ | |||||
| // JSONObject jo = new JSONObject(); | |||||
| // jo.put("type",this.getShareAccount(receiver.getReceiverType()).getMessage()); | |||||
| // jo.put("account",receiver.getReceiverAccount()); | |||||
| // jo.put("amount", receiver.getSharingAmount()); | |||||
| // //jo.put("description",receiver.getReceiverComments()); //改为存ID, | |||||
| // jo.put("description",receiver.getId().toString()); //为重试做准备 | |||||
| // receivers.add(jo); | |||||
| // }); | |||||
| // return receivers.toJSONString(); | |||||
| // } | |||||
| protected ShareAccountResult _createShareAccount(WxAppinfo appInfo,WxPayAccount payAccount,WxProfitSharingReceiver receiver) { | protected ShareAccountResult _createShareAccount(WxAppinfo appInfo,WxPayAccount payAccount,WxProfitSharingReceiver receiver) { | ||||
| @@ -72,7 +72,7 @@ public class TtPayShareService extends PayShareBaseAdapterService{ | |||||
| WxProfitSharingReceiverMapper wxProfitSharingReceiverMapper; | WxProfitSharingReceiverMapper wxProfitSharingReceiverMapper; | ||||
| @Autowired | @Autowired | ||||
| TtGoodsCategoryMapper TtGoodsCategoryMapper; | |||||
| TtGoodsCategoryMapper ttGoodsCategoryMapper; | |||||
| @Autowired | @Autowired | ||||
| OrderCpsMapper orderCpsMapper; | OrderCpsMapper orderCpsMapper; | ||||
| @@ -87,18 +87,18 @@ public class TtPayShareService extends PayShareBaseAdapterService{ | |||||
| return EnumMerchantSubsidyType.DOUYIN.getCode(); | return EnumMerchantSubsidyType.DOUYIN.getCode(); | ||||
| } | } | ||||
| @Override | |||||
| public Integer getSharingOrderInitialStatus() { | |||||
| return EnumProfitSharingOrderStatus.PROFIT_SHARING_UNKNOWN.getCode(); | |||||
| } | |||||
| @Override | |||||
| public PayShareCalculateAmount calculateAmount(Integer payAmount,Integer officialCommissionRate,Integer systemAmount, WxPayAccount payAccount) { | |||||
| int mallCharge = OrderHelper.getMallCharge(payAmount, payAccount,true); | |||||
| Integer realRateAmount = OrderHelper.getRealRateAmount(payAmount, payAccount); | |||||
| int officialCommission = PayUtils.getPayRate(payAmount, officialCommissionRate, true);//抖音抽成 | |||||
| return new PayShareCalculateAmount(payAmount,mallCharge,realRateAmount,officialCommission,systemAmount); | |||||
| } | |||||
| // @Override | |||||
| // public Integer getSharingOrderInitialStatus() { | |||||
| // return EnumProfitSharingOrderStatus.PROFIT_SHARING_UNKNOWN.getCode(); | |||||
| // } | |||||
| // | |||||
| // @Override | |||||
| // public PayShareCalculateAmount calculateAmount(Integer payAmount,Integer officialCommissionRate,Integer systemAmount, WxPayAccount payAccount) { | |||||
| // int mallCharge = OrderHelper.getMallCharge(payAmount, payAccount,true); | |||||
| // Integer realRateAmount = OrderHelper.getRealRateAmount(payAmount, payAccount); | |||||
| // int officialCommission = PayUtils.getPayRate(payAmount, officialCommissionRate, true);//抖音抽成 | |||||
| // return new PayShareCalculateAmount(payAmount,mallCharge,realRateAmount,officialCommission,systemAmount); | |||||
| // } | |||||
| @Override | @Override | ||||
| public PayShareResult noReciverShare(WxAppinfo appInfo,WxPayAccount payAccount,WxProfitSharingOrder record) { | public PayShareResult noReciverShare(WxAppinfo appInfo,WxPayAccount payAccount,WxProfitSharingOrder record) { | ||||
| @@ -276,14 +276,15 @@ public class TtPayShareService extends PayShareBaseAdapterService{ | |||||
| } | } | ||||
| @Override | @Override | ||||
| public int getOfficialCommission(WxOrder o, WxPayAccount payAccount) { | |||||
| public int getOfficialCommission(Long orderId, WxPayAccount payAccount) { | |||||
| WxOrder o = wxOrderMapper.selectById(orderId, payAccount.getTenantId()); | |||||
| if(!EnumOrderType.COUPON.getCode().equals(o.getType())){ | if(!EnumOrderType.COUPON.getCode().equals(o.getType())){ | ||||
| return 0; | return 0; | ||||
| } | } | ||||
| Long couponId = wxCouponChannelMapper.findCouponIdById(o.getCouponChannelId(), o.getTenantId()); | Long couponId = wxCouponChannelMapper.findCouponIdById(o.getCouponChannelId(), o.getTenantId()); | ||||
| Integer categoryId = wxCouponMapper.findCategoryIdById(couponId,o.getTenantId()); | Integer categoryId = wxCouponMapper.findCategoryIdById(couponId,o.getTenantId()); | ||||
| if(categoryId != null){ | if(categoryId != null){ | ||||
| TtGoodsCategory ttGoodsCategory = TtGoodsCategoryMapper.selectById(categoryId); | |||||
| TtGoodsCategory ttGoodsCategory = ttGoodsCategoryMapper.selectById(categoryId); | |||||
| if(ttGoodsCategory != null && ttGoodsCategory.getServiceFee() != null){ | if(ttGoodsCategory != null && ttGoodsCategory.getServiceFee() != null){ | ||||
| Integer realRate = payAccount.getRealRate(); | Integer realRate = payAccount.getRealRate(); | ||||
| if(realRate==null){ | if(realRate==null){ | ||||
| @@ -71,17 +71,17 @@ public class WxPayShareSFTService extends PayShareBaseAdapterService{ | |||||
| return EnumMerchantSubsidyType.WECHAT.getCode(); | return EnumMerchantSubsidyType.WECHAT.getCode(); | ||||
| } | } | ||||
| @Override | |||||
| public Integer getSharingOrderInitialStatus() { | |||||
| return EnumProfitSharingOrderStatus.PROFIT_SHARING_READY.getCode(); | |||||
| } | |||||
| @Override | |||||
| public PayShareCalculateAmount calculateAmount(Integer payAmount,Integer officialCommissionRate,Integer systemAmount, WxPayAccount payAccount) { | |||||
| int mallCharge = OrderHelper.getMallCharge(payAmount, payAccount); | |||||
| Integer realRateAmount = OrderHelper.getRealRateAmount(payAmount, payAccount); | |||||
| return new PayShareCalculateAmount(payAmount,mallCharge,realRateAmount,0,systemAmount); | |||||
| } | |||||
| // @Override | |||||
| // public Integer getSharingOrderInitialStatus() { | |||||
| // return EnumProfitSharingOrderStatus.PROFIT_SHARING_READY.getCode(); | |||||
| // } | |||||
| // | |||||
| // @Override | |||||
| // public PayShareCalculateAmount calculateAmount(Integer payAmount,Integer officialCommissionRate,Integer systemAmount, WxPayAccount payAccount) { | |||||
| // int mallCharge = OrderHelper.getMallCharge(payAmount, payAccount); | |||||
| // Integer realRateAmount = OrderHelper.getRealRateAmount(payAmount, payAccount); | |||||
| // return new PayShareCalculateAmount(payAmount,mallCharge,realRateAmount,0,systemAmount); | |||||
| // } | |||||
| @Override | @Override | ||||
| public PayShareResult noReciverShare(WxAppinfo appInfo,WxPayAccount payAccount,WxProfitSharingOrder record) { | public PayShareResult noReciverShare(WxAppinfo appInfo,WxPayAccount payAccount,WxProfitSharingOrder record) { | ||||
| @@ -150,10 +150,10 @@ public class WxPayShareSFTService extends PayShareBaseAdapterService{ | |||||
| return 0; | return 0; | ||||
| } | } | ||||
| @Override | |||||
| public int getOfficialCommission(WxOrder o, WxPayAccount payAccount) { | |||||
| return 0; | |||||
| } | |||||
| @Override | |||||
| public int getOfficialCommission(Long orderId, WxPayAccount payAccount) { | |||||
| return 0; | |||||
| } | |||||
| @Override | @Override | ||||
| public WxProfitSharingReceiver getReceiver(TenantEntity tenantEntity, Long merchantId, Integer ttPayWay,Integer mchType) { | public WxProfitSharingReceiver getReceiver(TenantEntity tenantEntity, Long merchantId, Integer ttPayWay,Integer mchType) { | ||||
| @@ -64,17 +64,17 @@ public class WxPayShareService extends PayShareBaseAdapterService{ | |||||
| return EnumMerchantSubsidyType.WECHAT.getCode(); | return EnumMerchantSubsidyType.WECHAT.getCode(); | ||||
| } | } | ||||
| @Override | |||||
| public Integer getSharingOrderInitialStatus() { | |||||
| return EnumProfitSharingOrderStatus.PROFIT_SHARING_READY.getCode(); | |||||
| } | |||||
| @Override | |||||
| public PayShareCalculateAmount calculateAmount(Integer payAmount,Integer officialCommissionRate,Integer systemAmount, WxPayAccount payAccount) { | |||||
| int mallCharge = OrderHelper.getMallCharge(payAmount, payAccount); | |||||
| Integer realRateAmount = OrderHelper.getRealRateAmount(payAmount, payAccount); | |||||
| return new PayShareCalculateAmount(payAmount,mallCharge,realRateAmount,0,systemAmount); | |||||
| } | |||||
| // @Override | |||||
| // public Integer getSharingOrderInitialStatus() { | |||||
| // return EnumProfitSharingOrderStatus.PROFIT_SHARING_READY.getCode(); | |||||
| // } | |||||
| // | |||||
| // @Override | |||||
| // public PayShareCalculateAmount calculateAmount(Integer payAmount,Integer officialCommissionRate,Integer systemAmount, WxPayAccount payAccount) { | |||||
| // int mallCharge = OrderHelper.getMallCharge(payAmount, payAccount); | |||||
| // Integer realRateAmount = OrderHelper.getRealRateAmount(payAmount, payAccount); | |||||
| // return new PayShareCalculateAmount(payAmount,mallCharge,realRateAmount,0,systemAmount); | |||||
| // } | |||||
| @Override | @Override | ||||
| public PayShareResult noReciverShare(WxAppinfo appInfo,WxPayAccount payAccount,WxProfitSharingOrder record) { | public PayShareResult noReciverShare(WxAppinfo appInfo,WxPayAccount payAccount,WxProfitSharingOrder record) { | ||||
| @@ -340,7 +340,7 @@ public class WxPayShareService extends PayShareBaseAdapterService{ | |||||
| } | } | ||||
| @Override | @Override | ||||
| public int getOfficialCommission(WxOrder o, WxPayAccount payAccount) { | |||||
| public int getOfficialCommission(Long orderId, WxPayAccount payAccount) { | |||||
| return 0; | return 0; | ||||
| } | } | ||||
| @@ -64,17 +64,17 @@ public class WxPayShareV3Service extends PayShareBaseAdapterService{ | |||||
| return EnumMerchantSubsidyType.WECHAT.getCode(); | return EnumMerchantSubsidyType.WECHAT.getCode(); | ||||
| } | } | ||||
| @Override | |||||
| public Integer getSharingOrderInitialStatus() { | |||||
| return EnumProfitSharingOrderStatus.PROFIT_SHARING_READY.getCode(); | |||||
| } | |||||
| @Override | |||||
| public PayShareCalculateAmount calculateAmount(Integer payAmount,Integer officialCommissionRate,Integer systemAmount, WxPayAccount payAccount) { | |||||
| int mallCharge = OrderHelper.getMallCharge(payAmount, payAccount); | |||||
| Integer realRateAmount = OrderHelper.getRealRateAmount(payAmount, payAccount); | |||||
| return new PayShareCalculateAmount(payAmount,mallCharge,realRateAmount,0,systemAmount); | |||||
| } | |||||
| // @Override | |||||
| // public Integer getSharingOrderInitialStatus() { | |||||
| // return EnumProfitSharingOrderStatus.PROFIT_SHARING_READY.getCode(); | |||||
| // } | |||||
| // | |||||
| // @Override | |||||
| // public PayShareCalculateAmount calculateAmount(Integer payAmount,Integer officialCommissionRate,Integer systemAmount, WxPayAccount payAccount) { | |||||
| // int mallCharge = OrderHelper.getMallCharge(payAmount, payAccount); | |||||
| // Integer realRateAmount = OrderHelper.getRealRateAmount(payAmount, payAccount); | |||||
| // return new PayShareCalculateAmount(payAmount,mallCharge,realRateAmount,0,systemAmount); | |||||
| // } | |||||
| @Override | @Override | ||||
| @@ -282,7 +282,7 @@ public class WxPayShareV3Service extends PayShareBaseAdapterService{ | |||||
| if (payAccount.getMchType() == EnumPayMchType.DIRECT.getCode()) { | if (payAccount.getMchType() == EnumPayMchType.DIRECT.getCode()) { | ||||
| return new ShareAccountResult(false, ErrorCode.PROFIT_SHARING_RECEIVER_ADD_FAILED.getCode(), "微信支付3.0直连模式下不支持", null); | return new ShareAccountResult(false, ErrorCode.PROFIT_SHARING_RECEIVER_ADD_FAILED.getCode(), "微信支付3.0直连模式下不支持", null); | ||||
| //总分,跟2.0创建一样 | //总分,跟2.0创建一样 | ||||
| }else { | |||||
| } else { | |||||
| return super._createShareAccount(appInfo, payAccount, receiver); | return super._createShareAccount(appInfo, payAccount, receiver); | ||||
| } | } | ||||
| } | } | ||||
| @@ -308,7 +308,7 @@ public class WxPayShareV3Service extends PayShareBaseAdapterService{ | |||||
| } | } | ||||
| @Override | @Override | ||||
| public int getOfficialCommission(WxOrder o, WxPayAccount payAccount) { | |||||
| public int getOfficialCommission(Long orderId, WxPayAccount payAccount) { | |||||
| return 0; | return 0; | ||||
| } | } | ||||
| @@ -72,13 +72,15 @@ | |||||
| <if test=" null != sortColumns">order by ${sortColumns}</if> | <if test=" null != sortColumns">order by ${sortColumns}</if> | ||||
| </sql> | </sql> | ||||
| <select id="selectByCouponAndDouyin" parameterType="java.util.HashMap" resultMap="BaseResultMap"> | |||||
| <select id="selectByCoupon" parameterType="java.util.HashMap" resultMap="BaseResultMap"> | |||||
| select <include refid="allColumns"/> | select <include refid="allColumns"/> | ||||
| from tt_poi_take_rate | from tt_poi_take_rate | ||||
| where tenant_id = #{tenantId} | where tenant_id = #{tenantId} | ||||
| and `coupon_id` = #{couponId} | and `coupon_id` = #{couponId} | ||||
| and `type` = #{type} | and `type` = #{type} | ||||
| and `douyin_id` = #{douyinId} | |||||
| <if test=" null != douyinId "> | |||||
| and `douyin_id` = #{douyinId} | |||||
| </if> | |||||
| </select> | </select> | ||||
| <select id="findList" parameterType="com.iformall.domain.po.TtPoiTakeRate" resultMap="BaseResultMap"> | <select id="findList" parameterType="com.iformall.domain.po.TtPoiTakeRate" resultMap="BaseResultMap"> | ||||
| @@ -91,5 +93,14 @@ | |||||
| <select id="selectById" parameterType="java.util.HashMap" resultMap="BaseResultMap"> | <select id="selectById" parameterType="java.util.HashMap" resultMap="BaseResultMap"> | ||||
| select <include refid="allColumns" /> from tt_poi_take_rate where id = #{id} and tenant_id=#{tenantId} | select <include refid="allColumns" /> from tt_poi_take_rate where id = #{id} and tenant_id=#{tenantId} | ||||
| </select> | </select> | ||||
| <select id="getMaxTakeRate" parameterType="java.util.HashMap" resultType="Integer"> | |||||
| select max(take_rate) | |||||
| from tt_poi_take_rate | |||||
| where tenant_id = #{tenantId} | |||||
| and `coupon_id` = #{couponId} | |||||
| and `type` > 0 | |||||
| and `status` in (1,2) | |||||
| </select> | |||||
| </mapper> | </mapper> | ||||
| @@ -25,6 +25,7 @@ | |||||
| <result column="rate" jdbcType="INTEGER" property="rate"/> | <result column="rate" jdbcType="INTEGER" property="rate"/> | ||||
| <result column="real_rate" jdbcType="INTEGER" property="realRate"/> | <result column="real_rate" jdbcType="INTEGER" property="realRate"/> | ||||
| <result column="system_rate" jdbcType="INTEGER" property="systemRate"/> | <result column="system_rate" jdbcType="INTEGER" property="systemRate"/> | ||||
| <result column="sell_rate" jdbcType="INTEGER" property="sellRate"/> | |||||
| <result column="service_id" jdbcType="VARCHAR" property="serviceId"/> | <result column="service_id" jdbcType="VARCHAR" property="serviceId"/> | ||||
| <result column="pay_score_notify_url" jdbcType="VARCHAR" property="payScoreNotifyUrl"/> | <result column="pay_score_notify_url" jdbcType="VARCHAR" property="payScoreNotifyUrl"/> | ||||
| @@ -36,7 +37,7 @@ | |||||
| <sql id="allColumns"> | <sql id="allColumns"> | ||||
| `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`, | `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`, | |||||
| `merchant_cert_path`,`type`,`mch_type`,`open_pay`,`share`,`rate`,`real_rate`,`system_rate`,`sell_rate`, | |||||
| `service_id`,`pay_score_notify_url`,`api_v3_key`,`cert_serial_no`,`private_key_path`,`private_cert_pem_path`, | `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` | `merchant_key_path`,`merchant_apiv3_key`,`merchant_cert_pem_path` | ||||
| </sql> | </sql> | ||||
| @@ -116,7 +116,7 @@ | |||||
| </if> | </if> | ||||
| <if test=" null != sharingStatus "> | <if test=" null != sharingStatus "> | ||||
| and `sharing_status` like concat('%', #{sharingStatus},'%') | |||||
| and `sharing_status` = #{sharingStatus} | |||||
| </if> | </if> | ||||