Просмотр исходного кода

//rate share

release_toaliyun_real
xhxu 3 лет назад
Родитель
Сommit
1d72f87cd7
25 измененных файлов: 656 добавлений и 320 удалений
  1. +50
    -0
      mallinkAdmin/src/main/java/com/iformall/controller/basic/TtPoiPlanController.java
  2. +1
    -1
      mallinkAdmin/src/main/resources/db/migration/V2022090500002__addsharingorder.sql
  3. +2
    -0
      mallinkAdmin/src/main/resources/db/migration/V2022091400001__add_pay_account.sql
  4. +0
    -15
      mallinkService/src/main/java/com/iformall/domain/dto/WxSharingOrderDto.java
  5. +3
    -1
      mallinkService/src/main/java/com/iformall/domain/po/WxPayAccount.java
  6. +4
    -12
      mallinkService/src/main/java/com/iformall/domain/po/WxPayOrder.java
  7. +1
    -1
      mallinkService/src/main/java/com/iformall/enums/EnumCpsPlanContentType.java
  8. +1
    -1
      mallinkService/src/main/java/com/iformall/enums/EnumCpsPlanType.java
  9. +3
    -1
      mallinkService/src/main/java/com/iformall/mapper/TtPoiTakeRateMapper.java
  10. +9
    -0
      mallinkService/src/main/java/com/iformall/service/TtCouponGoodsService.java
  11. +201
    -2
      mallinkService/src/main/java/com/iformall/service/impl/TtCouponGoodsServiceImpl.java
  12. +18
    -31
      mallinkService/src/main/java/com/iformall/service/impl/WxCouponOrderServiceImpl.java
  13. +2
    -9
      mallinkService/src/main/java/com/iformall/service/impl/WxOrderServiceImpl.java
  14. +6
    -27
      mallinkService/src/main/java/com/iformall/service/impl/WxPayOrderServiceImpl.java
  15. +122
    -33
      mallinkService/src/main/java/com/iformall/service/impl/WxProfitSharingOrderServiceImpl.java
  16. +68
    -30
      mallinkService/src/main/java/com/iformall/service/order/entity/WxComposeChildOrderShare.java
  17. +4
    -8
      mallinkService/src/main/java/com/iformall/service/pay/service/share/PayShareAdapterService.java
  18. +89
    -89
      mallinkService/src/main/java/com/iformall/service/pay/service/share/PayShareBaseAdapterService.java
  19. +16
    -15
      mallinkService/src/main/java/com/iformall/service/pay/service/share/douyin/TtPayShareService.java
  20. +15
    -15
      mallinkService/src/main/java/com/iformall/service/pay/service/share/wx/sft/WxPayShareSFTService.java
  21. +12
    -12
      mallinkService/src/main/java/com/iformall/service/pay/service/share/wx/v2/WxPayShareService.java
  22. +13
    -13
      mallinkService/src/main/java/com/iformall/service/pay/service/share/wx/v3/WxPayShareV3Service.java
  23. +13
    -2
      mallinkService/src/main/resources/mapper/TtPoiTakeRateMapper.xml
  24. +2
    -1
      mallinkService/src/main/resources/mapper/WxPayAccountMapper.xml
  25. +1
    -1
      mallinkService/src/main/resources/mapper/WxProfitSharingOrderMapper.xml

+ 50
- 0
mallinkAdmin/src/main/java/com/iformall/controller/basic/TtPoiPlanController.java Просмотреть файл

@@ -8,6 +8,7 @@ import com.iformall.common.ResultData;
import com.iformall.controller.base.BaseController;
import com.iformall.domain.po.TtPoiTakeRate;
import com.iformall.domain.po.base.BaseEntity;
import com.iformall.enums.EnumCpsPlanType;
import com.iformall.service.TtCouponGoodsService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
@@ -18,6 +19,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;


@@ -155,4 +157,52 @@ public class TtPoiPlanController extends BaseController {
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);
}

}

+ 1
- 1
mallinkAdmin/src/main/resources/db/migration/V2022090500002__addsharingorder.sql Просмотреть файл

@@ -9,7 +9,7 @@ ADD COLUMN `point_deduction` json COMMENT '各种扣点费用' AFTER `type`;
ALTER TABLE `mallink`.`wx_profit_sharing_order_2`
ADD COLUMN `pay_version` smallint(3) AFTER `pay_vendor`,
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`
ADD COLUMN `pay_version` smallint(3) AFTER `pay_vendor`,
ADD COLUMN `mch_type` smallint(3) AFTER `pay_version`,


+ 2
- 0
mallinkAdmin/src/main/resources/db/migration/V2022091400001__add_pay_account.sql Просмотреть файл

@@ -0,0 +1,2 @@
ALTER TABLE `mallink`.`wx_pay_account`
ADD COLUMN `sell_rate` int(6) NOT NULL DEFAULT 0 COMMENT '销售提点' AFTER `system_rate`;

+ 0
- 15
mallinkService/src/main/java/com/iformall/domain/dto/WxSharingOrderDto.java Просмотреть файл

@@ -14,8 +14,6 @@ public class WxSharingOrderDto extends TenantEntity {
private Long orderId;
@io.swagger.annotations.ApiModelProperty(value="订单ID",name="singleOrderId")
private Long singleOrderId;
@io.swagger.annotations.ApiModelProperty(value="单个订单支付金额(分)",name="singleOrderAmount")
private Integer singleOrderAmount;
@io.swagger.annotations.ApiModelProperty(value="c用户ID",name="cUserId")
private Long cUserId;
@io.swagger.annotations.ApiModelProperty(value="微信生成的订单号",name="transactionId")
@@ -24,19 +22,6 @@ public class WxSharingOrderDto extends TenantEntity {
private Integer payAmount;
@io.swagger.annotations.ApiModelProperty(value="商户ID",name="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")
private Date payTimeStart;


+ 3
- 1
mallinkService/src/main/java/com/iformall/domain/po/WxPayAccount.java Просмотреть файл

@@ -56,8 +56,10 @@ public class WxPayAccount extends TenantEntity {
private Integer rate;
@io.swagger.annotations.ApiModelProperty(value="实际手续费(万分之几,默认60)",name="realRate")
private Integer realRate;
@io.swagger.annotations.ApiModelProperty(value="系统提点,包含在rate之内",name="systemRate")
@io.swagger.annotations.ApiModelProperty(value="系统提点",name="systemRate")
private Integer systemRate;
@io.swagger.annotations.ApiModelProperty(value="销售提点",name="sellRate")
private Integer sellRate;

public String getPayNotifyV3Url() {
return notifyUrl + "/pay/v3/"+this.getTenantId();


+ 4
- 12
mallinkService/src/main/java/com/iformall/domain/po/WxPayOrder.java Просмотреть файл

@@ -104,31 +104,23 @@ public class WxPayOrder extends TenantEntity {
private String posPayDes;
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);
JSONObject childOrderShare = (JSONObject) childs.get(String.valueOf(wxOrderId));
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;
}
private List<WxComposeChildOrderShare> getAllChilds(Integer index) {
if (StringUtils.isBlank(this.childOrderShare)) {
return null;
}
Map childs = JSON.parseObject(this.childOrderShare, Map.class);
List<WxComposeChildOrderShare> childList = new ArrayList<WxComposeChildOrderShare>();
int _index = 0;
for (Iterator<String> it = childs.keySet().iterator();it.hasNext();) {
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);
if (null != index && index.intValue() == _index) {
return childList;


+ 1
- 1
mallinkService/src/main/java/com/iformall/enums/EnumCpsPlanContentType.java Просмотреть файл

@@ -6,7 +6,7 @@ package com.iformall.enums;
public enum EnumCpsPlanContentType {

//
ALL(0,"总和"),
VIDEO(1, "仅短视频"),
LIVE(2, "仅直播间"),
VIDEO_LIVE(3, "短视频和直播间"),


+ 1
- 1
mallinkService/src/main/java/com/iformall/enums/EnumCpsPlanType.java Просмотреть файл

@@ -6,7 +6,7 @@ package com.iformall.enums;
public enum EnumCpsPlanType {

//
ALL(0, "总和"),
COMMON(1, "通用计划"),
DIRECTIONAL(2, "定向计划"),
;


+ 3
- 1
mallinkService/src/main/java/com/iformall/mapper/TtPoiTakeRateMapper.java Просмотреть файл

@@ -9,11 +9,13 @@ import java.util.List;

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);
List<TtPoiTakeRate> findList(TtPoiTakeRate takeRate);

TtPoiTakeRate selectById(@Param("id")Long id,@Param("tenantId")String tenantId);

Integer getMaxTakeRate(@Param("tenantId")String tenantId,@Param("couponId")Long couponId);

}

+ 9
- 0
mallinkService/src/main/java/com/iformall/service/TtCouponGoodsService.java Просмотреть файл

@@ -8,6 +8,7 @@ import com.iformall.domain.po.WxCoupon;
import com.iformall.domain.po.base.TenantEntity;
import com.iformall.domain.vo.TtCouponChannelVo;
import com.iformall.domain.vo.TtCouponVo;
import com.iformall.enums.EnumCpsPlanType;

public interface TtCouponGoodsService {

@@ -40,4 +41,12 @@ public interface TtCouponGoodsService {
ResultData poiTakeRate(TenantEntity tenantInfo, Long couponId, String douyinId, Integer takeRate, Integer status);

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

+ 201
- 2
mallinkService/src/main/java/com/iformall/service/impl/TtCouponGoodsServiceImpl.java Просмотреть файл

@@ -17,6 +17,7 @@ import com.iformall.douyin.web.bean.PoiPlanPage;
import com.iformall.douyin.web.bean.PoiTakeRate;
import com.iformall.douyin.web.bean.Product;
import com.iformall.enums.*;
import com.iformall.exception.MallinkException;
import com.iformall.mapper.*;
import com.iformall.service.*;
import com.iformall.utils.Constant;
@@ -64,9 +65,15 @@ public class TtCouponGoodsServiceImpl implements TtCouponGoodsService {
@Autowired
WxAppinfoService wxAppinfoService;

@Autowired
WxPayAccountService wxPayAccountService;

@Autowired
TtPoiTakeRateMapper ttPoiTakeRateMapper;

@Autowired
TtGoodsCategoryMapper ttGoodsCategoryMapper;

@Override
public ResultData couponList(TtCouponVo ttCouponVo, Integer pageNum, Integer pageSize) {
PageInfo<TtCouponVo> pageInfo = PageHelper.startPage(pageNum, pageSize).doSelectPageInfo(() -> wxCouponMapper.ttCouponList(ttCouponVo));
@@ -496,11 +503,27 @@ public class TtCouponGoodsServiceImpl implements TtCouponGoodsService {

@Override
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);
if(ttCouponChannelPoi == null || !EnumSpuSyncStatus.sync_audit_pass.getCode().equals(ttCouponChannelPoi.getLastStatus())){
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"该券未提交审核或审核未通过");
}
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());
PoiPlan poiPlan = new PoiPlan();
poiPlan.setPlanId(planId);
@@ -525,6 +548,8 @@ public class TtCouponGoodsServiceImpl implements TtCouponGoodsService {
} catch (WxErrorException e) {
e.printStackTrace();
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
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);
if(ttCouponChannelPoi == null || !EnumSpuSyncStatus.sync_audit_pass.getCode().equals(ttCouponChannelPoi.getLastStatus())){
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"该券未提交审核或审核未通过");
}
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.setSpuExtId(couponId.toString());
poiTakeRate.setDouyinId(douyinId);
@@ -587,17 +628,176 @@ public class TtCouponGoodsServiceImpl implements TtCouponGoodsService {
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){
TtPoiTakeRate ttPoiTakeRate = null;
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());
}else if(EnumCpsPlanType.COMMON.getCode().equals(takeRate.getType())){
ttPoiTakeRate = ttPoiTakeRateMapper.selectById(takeRate.getId(), takeRate.getTenantId());
if(ttPoiTakeRate == null){
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();
@@ -614,7 +814,6 @@ public class TtCouponGoodsServiceImpl implements TtCouponGoodsService {
takeRate.setUpdateDate(new Date());
return ttPoiTakeRateMapper.updateById(takeRate);
}

}




+ 18
- 31
mallinkService/src/main/java/com/iformall/service/impl/WxCouponOrderServiceImpl.java Просмотреть файл

@@ -1726,7 +1726,6 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService {
}
}


WxOrder order = wxOrderService.getById(couponOrder.getOrderId(), wxPayOrder.getTenantId());
if (null == order) {
logger.error("租户"+wxPayOrder.getTenantId()+"券订单"+couponOrder.getId()+"未查询到订单.");
@@ -1735,27 +1734,14 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService {
WxSharingOrderDto wxSharingOrderDto = new WxSharingOrderDto();
wxSharingOrderDto.setCUserId(wxPayOrder.getCUserId());
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) {
wxSharingOrderDto.setType(EnumProfitSharingOrderType.PROFIT_SHARING_MULTI.getCode());
}else {
wxSharingOrderDto.setType(EnumProfitSharingOrderType.PROFIT_SHARING_SINGLE.getCode());
}
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.setSingleOrderId(childShare.getOrderId());
wxSharingOrderDto.setSingleOrderAmount(childShare.getRealPayMent());
wxSharingOrderDto.setSingleOrderId(order.getId());
wxSharingOrderDto.setPayTimeStart(wxPayOrder.getPayTimeStart());
wxSharingOrderDto.setPayTimeEnd(wxPayOrder.getPayTimeEnd());
wxSharingOrderDto.updateTenantInfo(wxPayOrder);
@@ -2718,24 +2704,25 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService {
payOrder.setPayAmount(payAmount);
payOrder.setPayVendor(payWay.getCode());
payOrder.setPayVersion(payVersion.getCode());
payOrder.setMchType(payAccount.getMchType());
payOrder.setPayOrderStatus(EnumPayStatus.PAY_STATUS_WAIT.getCode());
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.setPosPayOrderId(couponOrder.getId());



+ 2
- 9
mallinkService/src/main/java/com/iformall/service/impl/WxOrderServiceImpl.java Просмотреть файл

@@ -1240,8 +1240,7 @@ public class WxOrderServiceImpl implements WxOrderService {
order.setOrderType(EnumComposeOrder.SINGLE.getCode());
order.setCreateDate(new Date());
wxBatchOrderMapper.insert(order);

Long orderNumber = idWorker.nextId();

@@ -2607,14 +2606,8 @@ public class WxOrderServiceImpl implements WxOrderService {
sharingOrder.setMerchantId(wxMerchantBUser.getMerchantId());
sharingOrder.setType(EnumProfitSharingOrderType.PROFIT_SHARING_SINGLE.getCode());
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.setSingleOrderId(share.getOrderId());
sharingOrder.setSingleOrderAmount(share.getRealPayMent());
sharingOrder.setSingleOrderId(wxOrder.getId());
sharingOrder.setPayTimeStart(wxPayOrder.getPayTimeStart());
sharingOrder.setPayTimeEnd(wxPayOrder.getPayTimeEnd());
sharingOrder.updateTenantInfo(wxPayOrder);


+ 6
- 27
mallinkService/src/main/java/com/iformall/service/impl/WxPayOrderServiceImpl.java Просмотреть файл

@@ -434,16 +434,12 @@ public class WxPayOrderServiceImpl implements WxPayOrderService {
logger.error("getChildOrders null" + record.toString());
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) {
Long merchant_id = null;
String merchant_uid = "";
if(EnumPayMchType.DIRECT.equals(payMchType)){//直连模式记录收款商户
//TODO 11111111111加缓存
//TODO 加缓存
merchant_id = wxCouponChannelService.getCouponOneMerchantId(o.getCouponChannelId(),o.getTenantId());
WxProfitSharingReceiver receiver = payShareServie.getReceiver(payAccount, merchant_id, null, payMchTypeEnum.getCode());
if(receiver == null){
@@ -451,20 +447,9 @@ public class WxPayOrderServiceImpl implements WxPayOrderService {
}
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));
int sqlRow = wxPayOrderMapper.insert(record);
@@ -576,6 +561,7 @@ public class WxPayOrderServiceImpl implements WxPayOrderService {
Long merchant_id = null;
String merchant_uid = "";
if(EnumPayMchType.DIRECT.getCode().equals(record.getMchType())){//直连模式记录收款商户
//todo 缓存
merchant_id = user.getMerchantId();
WxProfitSharingReceiver receiver = payShareServie.getReceiver(payAccount, merchant_id, null, record.getMchType());
if(receiver == null){
@@ -583,14 +569,7 @@ public class WxPayOrderServiceImpl implements WxPayOrderService {
}
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));

int sqlRow = wxPayOrderMapper.insert(record);


+ 122
- 33
mallinkService/src/main/java/com/iformall/service/impl/WxProfitSharingOrderServiceImpl.java Просмотреть файл

@@ -23,8 +23,10 @@ import com.iformall.mapper.*;
import com.iformall.pay.*;
import com.iformall.service.ExcelService;
import com.iformall.service.WxAppinfoService;
import com.iformall.service.WxMerchantService;
import com.iformall.service.WxProfitSharingOrderService;
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.service.share.PayShareAdapterService;
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.utils.BeanUtils;
import com.iformall.utils.DateUtils;
import com.iformall.utils.PayUtils;
import com.iformall.utils.Utility;

import cn.afterturn.easypoi.handler.inter.IExcelExportServer;
@@ -61,6 +64,9 @@ public class WxProfitSharingOrderServiceImpl implements WxProfitSharingOrderServ
@Autowired
WxProfitSharingOrderMapper wxProfitSharingOrderMapper;

@Autowired
WxMerchantService wxMerchantService;

@Autowired
WxAppinfoMapper wxAppinfoMapper;

@@ -87,6 +93,12 @@ public class WxProfitSharingOrderServiceImpl implements WxProfitSharingOrderServ

@Autowired
WxCardSpendMapper wxCardSpendMapper;

@Autowired
WxCouponChannelMapper wxCouponChannelMapper;

@Autowired
TtPoiTakeRateMapper ttPoiTakeRateMapper;
@Autowired
PayServiceFactory payServiceFactory;
@@ -138,6 +150,28 @@ public class WxProfitSharingOrderServiceImpl implements WxProfitSharingOrderServ
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
// @Transactional(isolation=Isolation.SERIALIZABLE, propagation = Propagation.REQUIRED, rollbackFor = {Exception.class})
public ResultData redoSharingOrder(WxProfitSharingOrder sharingOrder,WxPayOrder payOrder) {
@@ -163,6 +197,12 @@ public class WxProfitSharingOrderServiceImpl implements WxProfitSharingOrderServ
wxProfitSharingOrderMapper.updateById(updSharingOrder);
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;
if(sharingOrder.getSingleOrderId() != null){
@@ -170,34 +210,89 @@ public class WxProfitSharingOrderServiceImpl implements WxProfitSharingOrderServ
}else{
wxComposeChildOrderShare = payOrder.getSingleChildOrderShare();
}

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())){
JSONObject jo = new JSONObject();
jo.put("type",payShareAdapterService.getShareAccount(receiver.getReceiverType()).getMessage());
@@ -208,12 +303,6 @@ public class WxProfitSharingOrderServiceImpl implements WxProfitSharingOrderServ
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()){
shareResult = payShareAdapterService.noReciverShare(cAppInfo, payAccount, sharingOrder);
}else{
@@ -294,7 +383,7 @@ public class WxProfitSharingOrderServiceImpl implements WxProfitSharingOrderServ
WxProfitSharingOrder record = new WxProfitSharingOrder();
record.updateTenantInfo(payOrder);
record.setOrderId(payOrder.getId());
record.setSingleOrderId(sharingOrderDto.getSingleOrderId());
record.setSingleOrderId(childOrderShare.getOrderId());
record = wxProfitSharingOrderMapper.selectOne(new QueryWrapper(record));
if (record == null) {
//创建分账订单
@@ -326,7 +415,7 @@ public class WxProfitSharingOrderServiceImpl implements WxProfitSharingOrderServ
record.setPayMerchantMchId(childOrderShare.getMerchantUid());
}
record.setSharingStatus(EnumProfitSharingOrderStatus.PROFIT_SHARING_READY.getCode());
record.setPointDeduction(JSON.toJSONString(childOrderShare));
// record.setPointDeduction(JSON.toJSONString(childOrderShare));
record.setCreateTime(currentDate);
record.setUpdateTime(currentDate);
record.setType(sharingOrderDto.getType());


+ 68
- 30
mallinkService/src/main/java/com/iformall/service/order/entity/WxComposeChildOrderShare.java Просмотреть файл

@@ -11,37 +11,44 @@ import lombok.Data;
@Data
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.merchantUid = merchantUid;
this.orderId = orderId;
}
private Long orderId;//订单编号,v3要用
@@ -52,12 +59,43 @@ public class WxComposeChildOrderShare {
private Integer rateAmount;//商场实际通道费(扣除了支付通道费的)

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 serviceAmount;//所有扣款总合

private Long merchantId;//收款商户
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();
}

}

+ 4
- 8
mallinkService/src/main/java/com/iformall/service/pay/service/share/PayShareAdapterService.java Просмотреть файл

@@ -8,11 +8,7 @@ import com.iformall.common.ResultData;
import com.iformall.domain.dto.WxSharingOrderDto;
import com.iformall.domain.po.*;
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.service.pay.service.share.entity.ShareAccountResult;
import com.iformall.service.pay.service.share.entity.PayShareCalculateAmount;
@@ -36,12 +32,12 @@ public interface PayShareAdapterService {
* 获取分账订单初始状态
* @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
* @return
*/
int getOfficialCommission(WxOrder o, WxPayAccount payAccount);
int getOfficialCommission(Long orderId, WxPayAccount payAccount);

}

+ 89
- 89
mallinkService/src/main/java/com/iformall/service/pay/service/share/PayShareBaseAdapterService.java Просмотреть файл

@@ -43,96 +43,96 @@ public abstract class PayShareBaseAdapterService implements PayShareAdapterServi
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) {


+ 16
- 15
mallinkService/src/main/java/com/iformall/service/pay/service/share/douyin/TtPayShareService.java Просмотреть файл

@@ -72,7 +72,7 @@ public class TtPayShareService extends PayShareBaseAdapterService{
WxProfitSharingReceiverMapper wxProfitSharingReceiverMapper;

@Autowired
TtGoodsCategoryMapper TtGoodsCategoryMapper;
TtGoodsCategoryMapper ttGoodsCategoryMapper;

@Autowired
OrderCpsMapper orderCpsMapper;
@@ -87,18 +87,18 @@ public class TtPayShareService extends PayShareBaseAdapterService{
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
public PayShareResult noReciverShare(WxAppinfo appInfo,WxPayAccount payAccount,WxProfitSharingOrder record) {
@@ -276,14 +276,15 @@ public class TtPayShareService extends PayShareBaseAdapterService{
}

@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())){
return 0;
}
Long couponId = wxCouponChannelMapper.findCouponIdById(o.getCouponChannelId(), o.getTenantId());
Integer categoryId = wxCouponMapper.findCategoryIdById(couponId,o.getTenantId());
if(categoryId != null){
TtGoodsCategory ttGoodsCategory = TtGoodsCategoryMapper.selectById(categoryId);
TtGoodsCategory ttGoodsCategory = ttGoodsCategoryMapper.selectById(categoryId);
if(ttGoodsCategory != null && ttGoodsCategory.getServiceFee() != null){
Integer realRate = payAccount.getRealRate();
if(realRate==null){


+ 15
- 15
mallinkService/src/main/java/com/iformall/service/pay/service/share/wx/sft/WxPayShareSFTService.java Просмотреть файл

@@ -71,17 +71,17 @@ public class WxPayShareSFTService extends PayShareBaseAdapterService{
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
public PayShareResult noReciverShare(WxAppinfo appInfo,WxPayAccount payAccount,WxProfitSharingOrder record) {
@@ -150,10 +150,10 @@ public class WxPayShareSFTService extends PayShareBaseAdapterService{
return 0;
}

@Override
public int getOfficialCommission(WxOrder o, WxPayAccount payAccount) {
return 0;
}
@Override
public int getOfficialCommission(Long orderId, WxPayAccount payAccount) {
return 0;
}

@Override
public WxProfitSharingReceiver getReceiver(TenantEntity tenantEntity, Long merchantId, Integer ttPayWay,Integer mchType) {


+ 12
- 12
mallinkService/src/main/java/com/iformall/service/pay/service/share/wx/v2/WxPayShareService.java Просмотреть файл

@@ -64,17 +64,17 @@ public class WxPayShareService extends PayShareBaseAdapterService{
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
public PayShareResult noReciverShare(WxAppinfo appInfo,WxPayAccount payAccount,WxProfitSharingOrder record) {
@@ -340,7 +340,7 @@ public class WxPayShareService extends PayShareBaseAdapterService{
}

@Override
public int getOfficialCommission(WxOrder o, WxPayAccount payAccount) {
public int getOfficialCommission(Long orderId, WxPayAccount payAccount) {
return 0;
}



+ 13
- 13
mallinkService/src/main/java/com/iformall/service/pay/service/share/wx/v3/WxPayShareV3Service.java Просмотреть файл

@@ -64,17 +64,17 @@ public class WxPayShareV3Service extends PayShareBaseAdapterService{
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
@@ -282,7 +282,7 @@ public class WxPayShareV3Service extends PayShareBaseAdapterService{
if (payAccount.getMchType() == EnumPayMchType.DIRECT.getCode()) {
return new ShareAccountResult(false, ErrorCode.PROFIT_SHARING_RECEIVER_ADD_FAILED.getCode(), "微信支付3.0直连模式下不支持", null);
//总分,跟2.0创建一样
}else {
} else {
return super._createShareAccount(appInfo, payAccount, receiver);
}
}
@@ -308,7 +308,7 @@ public class WxPayShareV3Service extends PayShareBaseAdapterService{
}

@Override
public int getOfficialCommission(WxOrder o, WxPayAccount payAccount) {
public int getOfficialCommission(Long orderId, WxPayAccount payAccount) {
return 0;
}


+ 13
- 2
mallinkService/src/main/resources/mapper/TtPoiTakeRateMapper.xml Просмотреть файл

@@ -72,13 +72,15 @@
<if test=" null != sortColumns">order by ${sortColumns}</if>
</sql>

<select id="selectByCouponAndDouyin" parameterType="java.util.HashMap" resultMap="BaseResultMap">
<select id="selectByCoupon" parameterType="java.util.HashMap" resultMap="BaseResultMap">
select <include refid="allColumns"/>
from tt_poi_take_rate
where tenant_id = #{tenantId}
and `coupon_id` = #{couponId}
and `type` = #{type}
and `douyin_id` = #{douyinId}
<if test=" null != douyinId ">
and `douyin_id` = #{douyinId}
</if>
</select>

<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 <include refid="allColumns" /> from tt_poi_take_rate where id = #{id} and tenant_id=#{tenantId}
</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>

+ 2
- 1
mallinkService/src/main/resources/mapper/WxPayAccountMapper.xml Просмотреть файл

@@ -25,6 +25,7 @@
<result column="rate" jdbcType="INTEGER" property="rate"/>
<result column="real_rate" jdbcType="INTEGER" property="realRate"/>
<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="pay_score_notify_url" jdbcType="VARCHAR" property="payScoreNotifyUrl"/>
@@ -36,7 +37,7 @@

<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`,
`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`,
`merchant_key_path`,`merchant_apiv3_key`,`merchant_cert_pem_path`
</sql>


+ 1
- 1
mallinkService/src/main/resources/mapper/WxProfitSharingOrderMapper.xml Просмотреть файл

@@ -116,7 +116,7 @@
</if>
<if test=" null != sharingStatus ">
and `sharing_status` like concat('%', #{sharingStatus},'%')
and `sharing_status` = #{sharingStatus}
</if>


Загрузка…
Отмена
Сохранить