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

//unsettle 分账 小改造

release_toaliyun_real
xhxu 2 лет назад
Родитель
Сommit
b61bc3c3fe
6 измененных файлов: 143 добавлений и 152 удалений
  1. +48
    -104
      mallinkService/src/main/java/com/iformall/service/impl/WxProfitSharingOrderServiceImpl.java
  2. +15
    -9
      mallinkService/src/main/java/com/iformall/service/order/entity/WxComposeChildOrderShare.java
  3. +6
    -1
      mallinkService/src/main/java/com/iformall/service/pay/service/fee/ServiceFeeAdapterService.java
  4. +42
    -12
      mallinkService/src/main/java/com/iformall/service/pay/service/fee/TtServiceFeeService.java
  5. +31
    -25
      mallinkService/src/main/java/com/iformall/service/pay/service/fee/WxServiceFeeService.java
  6. +1
    -1
      mallinkService/src/main/java/com/iformall/utils/PayUtils.java

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

@@ -157,20 +157,6 @@ public class WxProfitSharingOrderServiceImpl implements WxProfitSharingOrderServ
return null;
}

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());
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) {
@@ -178,8 +164,7 @@ public class WxProfitSharingOrderServiceImpl implements WxProfitSharingOrderServ
if(!EnumProfitSharingOrderStatus.shareStatus().contains(sharingOrder.getSharingStatus())){
return new ResultData(ErrorCode.PROFIT_SHARING_REQUEST_FAILED.getCode(),"分账状态不允许");
}


//核销商户
WxMerchant merchant = wxMerchantService.selectById(sharingOrder.getMerchantId());

Date currentDate = new Date();
@@ -188,19 +173,6 @@ public class WxProfitSharingOrderServiceImpl implements WxProfitSharingOrderServ

PayShareResult shareResult = null;

//获取达人佣金
int cpsCommission = payShareAdapterService.getCPSCommission(sharingOrder,sharingOrder.getSingleOrderId());
if(cpsCommission < 0){
WxProfitSharingOrder updSharingOrder = new WxProfitSharingOrder();
updSharingOrder.updateTenantInfo(sharingOrder);
updSharingOrder.setId(sharingOrder.getId());
updSharingOrder.setSharingStatus(EnumProfitSharingOrderStatus.PROFIT_SHARING_APPLY_FAILED.getCode());
updSharingOrder.setErrorMsg("未获取到达人佣金");
updSharingOrder.setUpdateTime(currentDate);
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();
@@ -216,113 +188,85 @@ public class WxProfitSharingOrderServiceImpl implements WxProfitSharingOrderServ
}else{
wxComposeChildOrderShare = payOrder.getSingleChildOrderShare();
}
wxComposeChildOrderShare.setCpsCommission(cpsCommission);

//官方手续费---千6
int realRate = serviceFeeService.getRealRate(payAccount);
int realRateAmount = PayUtils.getPayRate(wxComposeChildOrderShare.getRealPayMent(), realRate, true);
wxComposeChildOrderShare.setRealRateAmount(realRateAmount);

//官方平台抽佣
int rate = serviceFeeService.getOfficialCommissionByOrder(wxComposeChildOrderShare.getOrderId(),payAccount);
int commissionAmount = PayUtils.getPayRate(wxComposeChildOrderShare.getRealPayMent(), rate, true);
wxComposeChildOrderShare.setCommissionAmount(commissionAmount);

int surplus = 0;//无法获取到各分账帐号时,计入收款帐号
//只有抖音才有抽成
//微信缺少流程(分账帐号绑定) 无法抽成
if(EnumPayWay.PAY_WAY_TT.getCode().equals(payOrder.getPayVendor())
&& EnumYesOrNo.YES.getCode().equals(payAccount.getIsCommission())){
//销售抽点+系统抽点
int systemCommission = serviceFeeService.getSystemCommissionByOrder(wxComposeChildOrderShare.getOrderId(), payAccount);
int sellCommission = serviceFeeService.getSellCommission(payAccount);
int selSysAmount = PayUtils.getPayRate(wxComposeChildOrderShare.getRealPayMent(), systemCommission+sellCommission, false);
//销售抽点
int sellerAmount = PayUtils.getPayRate(wxComposeChildOrderShare.getRealPayMent(), sellCommission, false);
wxComposeChildOrderShare.setSellerAmount(sellerAmount);
boolean isSeller = false;
if(sellerAmount > 0){
WxProfitSharingReceiver receiver = getByMerchantAdmin(sharingOrder,payShareAdapterService,wxComposeChildOrderShare.getMerchantId(),EnumMerchantAdmin.PRIVATE_SELL,payOrder.getTtPayWay(), payOrder.getMchType());
if(receiver != null){
try{
//处理所有的佣金
boolean flag = serviceFeeService.handleShareServiceAmount(cAppInfo, payAccount, payOrder,wxComposeChildOrderShare);
if(!flag){
throw new MallinkException(ErrorCode.PROFIT_SHARING_REQUEST_FAILED.getCode(),"未获取到服务费");
}
//微信缺少流程(分账帐号绑定) 无法抽成
if(EnumYesOrNo.YES.getCode().equals(payAccount.getIsCommission())){
//系统
if(wxComposeChildOrderShare.getSystemAmount() > 0){
WxProfitSharingReceiver receiver = getByMerchantAdmin(sharingOrder,payShareAdapterService,wxComposeChildOrderShare.getMerchantId(),EnumMerchantAdmin.PRIVATE_SYSTEM,payOrder.getTtPayWay(), payOrder.getMchType());
if(receiver == null){
throw new MallinkException(ErrorCode.PROFIT_SHARING_REQUEST_FAILED.getCode(),"未获取到系统帐号2");
}
JSONObject jo = new JSONObject();
jo.put("type",EnumProfitPaymentReceiverType.getEnum(receiver.getReceiverType()).getMessage());
jo.put("account",receiver.getReceiverAccount());
jo.put("amount", sellerAmount);
jo.put("amount", wxComposeChildOrderShare.getSystemAmount());
jo.put("merchantId",receiver.getMerchantId());
jo.put("bTenantId",receiver.getTenantId());
jo.put("description",receiver.getId());
jo.put("isPrivate",EnumYesOrNo.YES.getCode());
receivers.add(jo);
}else{
isSeller = true;
}
}
//系统抽成
// int systemAmount = PayUtils.getPayRate(wxComposeChildOrderShare.getRealPayMent(), payAccount.getSystemRate(), false);
int systemAmount = selSysAmount - sellerAmount;
wxComposeChildOrderShare.setSystemAmount(systemAmount);
if(isSeller){//未找到销售帐号时转入到系统帐号中
systemAmount += sellerAmount;
}
boolean isSystem = false;
if(systemAmount > 0){
WxProfitSharingReceiver receiver = getByMerchantAdmin(sharingOrder,payShareAdapterService,wxComposeChildOrderShare.getMerchantId(),EnumMerchantAdmin.PRIVATE_SYSTEM,payOrder.getTtPayWay(), payOrder.getMchType());
if(receiver != null){
//销售
if(wxComposeChildOrderShare.getSellerAmount() > 0){
WxProfitSharingReceiver receiver = getByMerchantAdmin(sharingOrder,payShareAdapterService,wxComposeChildOrderShare.getMerchantId(),EnumMerchantAdmin.PRIVATE_SELL,payOrder.getTtPayWay(), payOrder.getMchType());
if(receiver == null){
throw new MallinkException(ErrorCode.PROFIT_SHARING_REQUEST_FAILED.getCode(),"未获取到系统帐号3");
}
JSONObject jo = new JSONObject();
jo.put("type",EnumProfitPaymentReceiverType.getEnum(receiver.getReceiverType()).getMessage());
jo.put("account",receiver.getReceiverAccount());
jo.put("amount", systemAmount);
jo.put("amount", wxComposeChildOrderShare.getSellerAmount());
jo.put("merchantId",receiver.getMerchantId());
jo.put("bTenantId",receiver.getTenantId());
jo.put("description",receiver.getId());
jo.put("isPrivate",EnumYesOrNo.YES.getCode());
receivers.add(jo);
}else{
isSystem = true;
}
}
//总分佣
int mallRate = getMallSumRate(payOrder,wxComposeChildOrderShare.getOrderId());
int serviceAmount = PayUtils.getPayRate(wxComposeChildOrderShare.getRealPayMent(), mallRate, true);
wxComposeChildOrderShare.setServiceAmount(serviceAmount);
//商场分成
int mallAmount = wxComposeChildOrderShare.getRateAmount();
if(isSystem){//未找到系统帐号时转入商管商户中
mallAmount += systemAmount;
}
boolean isMall = false;
if(mallAmount > 0){
WxProfitSharingReceiver receiver = getByMerchantAdmin(sharingOrder,payShareAdapterService,wxComposeChildOrderShare.getMerchantId(),EnumMerchantAdmin.PUBLIC_ADMIN,payOrder.getTtPayWay(), payOrder.getMchType());
if(receiver != null){
//商管
if(wxComposeChildOrderShare.getRateAmount() > 0){
WxProfitSharingReceiver receiver = getByMerchantAdmin(sharingOrder,payShareAdapterService,wxComposeChildOrderShare.getMerchantId(),EnumMerchantAdmin.PUBLIC_ADMIN,payOrder.getTtPayWay(), payOrder.getMchType());
if(receiver == null){
throw new MallinkException(ErrorCode.PROFIT_SHARING_REQUEST_FAILED.getCode(),"未获取到商管帐号");
}
JSONObject jo = new JSONObject();
jo.put("type",EnumProfitPaymentReceiverType.getEnum(receiver.getReceiverType()).getMessage());
jo.put("account",receiver.getReceiverAccount());
jo.put("amount", mallAmount);
jo.put("amount", wxComposeChildOrderShare.getRateAmount());
jo.put("merchantId",receiver.getMerchantId());
jo.put("bTenantId",receiver.getTenantId());
jo.put("description",receiver.getId());
jo.put("isPrivate",EnumYesOrNo.YES.getCode());
receivers.add(jo);
}else{
isMall = true;
}
}
if(isMall){
surplus += mallAmount;
}
}else{
wxComposeChildOrderShare.setServiceAmount(null);

}catch(Exception e){
WxProfitSharingOrder updSharingOrder = new WxProfitSharingOrder();
updSharingOrder.updateTenantInfo(sharingOrder);
updSharingOrder.setId(sharingOrder.getId());
updSharingOrder.setSharingStatus(EnumProfitSharingOrderStatus.PROFIT_SHARING_APPLY_FAILED.getCode());
updSharingOrder.setErrorMsg(e.getMessage());
updSharingOrder.setUpdateTime(currentDate);
wxProfitSharingOrderMapper.updateById(updSharingOrder);
return new ResultData(ErrorCode.PROFIT_SHARING_REQUEST_FAILED.getCode(),e.getMessage());
}

//商户所得
int shareAmount = wxComposeChildOrderShare.getShareAmount();

boolean isCallSharing = false;//是否调用分账
boolean isCreateSubsidy = false;//是否需要记账
boolean isSharingResult = false;//是否需要记录Result
boolean isSharingResult = false;//是否需要记录Result 解冻给收款方
if(EnumPayWay.PAY_WAY_WECHAT.getCode().equals(payOrder.getPayVendor())
&& DateUtils.daysBetween(payOrder.getCreateTime(),currentDate) > 30){
isCallSharing = false;
if(EnumPayShare.YES.getCode().equals(payOrder.getShare())){
if(!sharingOrder.getMerchantId().equals(wxComposeChildOrderShare.getMerchantId())){
isCreateSubsidy = true;
}
isSharingResult = true;
@@ -356,9 +300,11 @@ public class WxProfitSharingOrderServiceImpl implements WxProfitSharingOrderServ
receivers.add(jo);
}else if(EnumPayMchType.DIRECT.getCode().equals(payOrder.getMchType())
&& !sharingOrder.getMerchantId().equals(wxComposeChildOrderShare.getMerchantId())){
//微信 直连 多商户 分不了账 记账
isCreateSubsidy = true;
isSharingResult = true;
}else{
//总分不分账 已经记过账了
isSharingResult = true;
}
}
@@ -413,7 +359,6 @@ public class WxProfitSharingOrderServiceImpl implements WxProfitSharingOrderServ

if(isCreateSubsidy){
try {
// 微信超过30天无法分账的,
WxOrder order = wxOrderMapper.selectById(sharingOrder.getSingleOrderId(), sharingOrder.getTenantId());
wxCouponOrderService.recordAfterVerified(order, merchant);
} catch (Exception e) {
@@ -422,13 +367,12 @@ public class WxProfitSharingOrderServiceImpl implements WxProfitSharingOrderServ
}

if(isSharingResult){
int sharingSubsidyAmount = shareAmount+surplus;
if(EnumPayMchType.TOTAL.getCode().equals(payOrder.getMchType())){
//解冻给收款方(广场) +抽成没抽过去的。surplus
JSONObject jo = new JSONObject();
// jo.put("type",EnumProfitPaymentReceiverType.wx_special_merchant_number.getMessage());
jo.put("account",payAccount.getSubMchId());
jo.put("amount", sharingSubsidyAmount);
jo.put("amount", shareAmount);
jo.put("merchantId",0);
jo.put("bTenantId",payOrder.getTenantId());
jo.put("description",0);
@@ -440,13 +384,13 @@ public class WxProfitSharingOrderServiceImpl implements WxProfitSharingOrderServ
if(receiver != null && receiver.getReceiverAccount().equals(wxComposeChildOrderShare.getMerchantUid())){
jo.put("type",EnumProfitPaymentReceiverType.getEnum(receiver.getReceiverType()).getMessage());
jo.put("account",receiver.getReceiverAccount());
jo.put("amount", sharingSubsidyAmount);
jo.put("amount", shareAmount);
jo.put("merchantId",receiver.getMerchantId());
jo.put("bTenantId",receiver.getTenantId());
jo.put("description",receiver.getId());
}else{
jo.put("account",wxComposeChildOrderShare.getMerchantUid());
jo.put("amount", sharingSubsidyAmount);
jo.put("amount", shareAmount);
jo.put("merchantId",wxComposeChildOrderShare.getMerchantId());
jo.put("bTenantId",payOrder.getTenantId());
jo.put("description",0);


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

@@ -72,30 +72,36 @@ public class WxComposeChildOrderShare {
private String merchantUid;//收款商户

public void setServiceAmount(Integer serviceAmount){
if(this.realPayMent == null){
return;
}
if(this.realRateAmount == null){
return;
}
int sumAmount = this.realRateAmount.intValue();//支付通道费
int sumAmount = 0;
if(this.realRateAmount != null){
sumAmount += this.realRateAmount;//支付通道费
}
if(this.commissionAmount != null){
sumAmount += this.commissionAmount.intValue();//平台服务费
sumAmount += this.commissionAmount;//平台服务费
}
if(this.cpsCommission != null){
sumAmount += this.cpsCommission.intValue();//达人佣金
}
if(this.systemAmount != null){
sumAmount += this.systemAmount;//系统扣点
sumAmount += this.cpsCommission;//达人佣金
}
if(this.sellerAmount != null){
sumAmount += this.sellerAmount;//销售扣点
}
if(this.systemAmount != null){
sumAmount += this.systemAmount;//系统扣点
}

if(serviceAmount == null || serviceAmount.intValue() < sumAmount){
if(serviceAmount == null || serviceAmount < sumAmount){
this.serviceAmount = sumAmount;
}else{
this.serviceAmount = serviceAmount;//一笔订单总扣除手续费
}
this.rateAmount = this.serviceAmount.intValue() - sumAmount;//剩下的就是给商场的
this.shareAmount = this.realPayMent.intValue() - this.serviceAmount.intValue();//这就是给商户的
this.rateAmount = this.serviceAmount - sumAmount;//剩下的就是给商场的
this.shareAmount = this.realPayMent - this.serviceAmount;//这就是给商户的
}

}

+ 6
- 1
mallinkService/src/main/java/com/iformall/service/pay/service/fee/ServiceFeeAdapterService.java Просмотреть файл

@@ -3,7 +3,9 @@ package com.iformall.service.pay.service.fee;
import com.iformall.domain.po.WxAppinfo;
import com.iformall.domain.po.WxCashOut;
import com.iformall.domain.po.WxPayAccount;
import com.iformall.domain.po.WxPayOrder;
import com.iformall.domain.po.base.TenantEntity;
import com.iformall.service.order.entity.WxComposeChildOrderShare;
import com.iformall.service.pay.service.cashout.entity.CashOutAdapterResult;

/**
@@ -49,7 +51,10 @@ public interface ServiceFeeAdapterService {
* 获取所有的总抽佣费率
* 如过设置了就返回,没设置返回0
*/
public int getAllCommission(Long couponId, WxPayAccount payAccount);
public int getAllCommission(TenantEntity tenantEntity, Long orderId);


boolean handleShareServiceAmount(WxAppinfo cAppInfo, WxPayAccount payAccount, WxPayOrder payOrder, WxComposeChildOrderShare wxComposeChildOrderShare);

/**
* 获取商场抽佣费率


+ 42
- 12
mallinkService/src/main/java/com/iformall/service/pay/service/fee/TtServiceFeeService.java Просмотреть файл

@@ -1,11 +1,10 @@
package com.iformall.service.pay.service.fee;

import com.iformall.common.ErrorCode;
import com.iformall.domain.po.TtPoiTakeRate;
import com.iformall.domain.po.WxMallVersion;
import com.iformall.domain.po.WxOrder;
import com.iformall.domain.po.WxPayAccount;
import com.iformall.domain.po.*;
import com.iformall.domain.po.base.TenantEntity;
import com.iformall.douyin.pay.DouYinPayHelper;
import com.iformall.douyin.pay.orderQuery.QueryUnsettleAmount;
import com.iformall.enums.EnumCpsPlanType;
import com.iformall.enums.EnumDouyinApplicationVersion;
import com.iformall.enums.EnumOrderType;
@@ -19,6 +18,8 @@ import com.iformall.service.TtMallGoodsCategoryService;
import com.iformall.service.WxCouponService;
import com.iformall.service.WxMallService;

import com.iformall.service.order.entity.WxComposeChildOrderShare;
import com.iformall.utils.PayUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
@@ -104,16 +105,45 @@ public class TtServiceFeeService implements ServiceFeeAdapterService{
// }

@Override
public int getAllCommission(Long couponId, WxPayAccount payAccount) {
int allRate = 0;
if(EnumYesOrNo.YES.getCode().equals(payAccount.getIsCommission())){
TtPoiTakeRate ttPoiTakeRate = ttPoiTakeRateMapper.selectByCoupon(payAccount.getTenantId(), couponId, EnumCpsPlanType.ALL.getCode());
if(ttPoiTakeRate != null && ttPoiTakeRate.getTakeRate() != null){
allRate = ttPoiTakeRate.getTakeRate().intValue();
}
public int getAllCommission(TenantEntity tenantEntity, Long orderId) {
WxOrder o = wxOrderMapper.selectById(orderId, tenantEntity.getTenantId());
if(!EnumOrderType.COUPON.getCode().equals(o.getType())){
return 0;
}
TtPoiTakeRate ttPoiTakeRate = ttPoiTakeRateMapper.selectByCoupon(tenantEntity.getTenantId(), o.getProductId(), EnumCpsPlanType.ALL.getCode());
if(ttPoiTakeRate != null){
return ttPoiTakeRate.getTakeRate();
}else{
return 0;
}
}

return allRate;
@Override
public boolean handleShareServiceAmount(WxAppinfo cAppInfo, WxPayAccount payAccount,WxPayOrder payOrder, WxComposeChildOrderShare wxComposeChildOrderShare) {
QueryUnsettleAmount queryUnsettleAmount = DouYinPayHelper.unsettleAmount(cAppInfo.getAppId(), payAccount.getMerchantApiKey(), payOrder.getOrderId().toString(), null);
if(queryUnsettleAmount == null){
return false;
}
wxComposeChildOrderShare.setRealRateAmount(queryUnsettleAmount.getPaymentRake());

wxComposeChildOrderShare.setCommissionAmount(queryUnsettleAmount.getLifeRake());

wxComposeChildOrderShare.setCpsCommission(queryUnsettleAmount.getCommission());
//销售
int sellCommission = getSellCommission(payAccount);
int sellerAmount = PayUtils.getPayRate(wxComposeChildOrderShare.getRealPayMent(), sellCommission, false);
wxComposeChildOrderShare.setSellerAmount(sellerAmount);
//系统 先计算销售+系统 然后再减去销售
int systemCommission = getSystemCommission(null, payAccount);
int selSysAmount = PayUtils.getPayRate(wxComposeChildOrderShare.getRealPayMent(), systemCommission+sellCommission, false);
int systemAmount = selSysAmount - sellerAmount;
wxComposeChildOrderShare.setSystemAmount(systemAmount);

//商品设置的总分佣率
int allCommission = getAllCommission(payAccount,wxComposeChildOrderShare.getOrderId());
int serviceAmount = PayUtils.getPayRate(wxComposeChildOrderShare.getRealPayMent(), allCommission, true);
wxComposeChildOrderShare.setServiceAmount(serviceAmount);
return true;
}

// @Override


+ 31
- 25
mallinkService/src/main/java/com/iformall/service/pay/service/fee/WxServiceFeeService.java Просмотреть файл

@@ -1,35 +1,13 @@
package com.iformall.service.pay.service.fee;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.iformall.common.ErrorCode;
import com.iformall.domain.po.*;
import com.iformall.domain.po.base.TenantEntity;
import com.iformall.enums.*;
import com.iformall.exception.MallinkException;
import com.iformall.mapper.WxAppinfoMapper;
import com.iformall.mapper.WxPayAccountMapper;
import com.iformall.mapper.WxPayOrderMapper;
import com.iformall.pay.*;
import com.iformall.service.WxProfitPaymentReceiverService;
import com.iformall.service.WxProfitSharingReceiverService;
import com.iformall.service.pay.service.share.PayShareBaseAdapterService;
import com.iformall.service.pay.service.share.entity.PayShareQueryResult;
import com.iformall.service.pay.service.share.entity.PayShareResult;
import com.iformall.service.pay.service.share.entity.ShareAccountResult;
import com.iformall.service.pay.service.share.entity.ShareNotifyAdapterResult;
import com.iformall.utils.BeanUtils;
import com.iformall.utils.Utility;
import com.iformall.utils.XmlUtil;
import com.iformall.service.order.entity.WxComposeChildOrderShare;
import com.iformall.utils.PayUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.text.ParseException;
import java.util.*;

@Slf4j
@Service
public class WxServiceFeeService implements ServiceFeeAdapterService{
@@ -87,12 +65,40 @@ public class WxServiceFeeService implements ServiceFeeAdapterService{
// }

@Override
public int getAllCommission(Long couponId, WxPayAccount payAccount) {
public int getAllCommission(TenantEntity tenantEntity, Long orderId) {
return 0;
}

@Override
public boolean handleShareServiceAmount(WxAppinfo cAppInfo, WxPayAccount payAccount, WxPayOrder payOrder, WxComposeChildOrderShare wxComposeChildOrderShare) {
int realRate = getRealRate(payAccount);
int payRate = PayUtils.getPayRate(wxComposeChildOrderShare.getRealPayMent(), realRate, true);
wxComposeChildOrderShare.setRealRateAmount(payRate);

wxComposeChildOrderShare.setCommissionAmount(0);

wxComposeChildOrderShare.setCpsCommission(0);
//销售
int sellCommission = getSellCommission(payAccount);
int sellerAmount = PayUtils.getPayRate(wxComposeChildOrderShare.getRealPayMent(), sellCommission, false);
wxComposeChildOrderShare.setSellerAmount(sellerAmount);
//系统 先计算销售+系统 然后再减去销售
int systemCommission = getSystemCommission(null, payAccount);
int selSysAmount = PayUtils.getPayRate(wxComposeChildOrderShare.getRealPayMent(), systemCommission+sellCommission, false);
int systemAmount = selSysAmount - sellerAmount;
wxComposeChildOrderShare.setSystemAmount(systemAmount);

//商品设置的总分佣率
int allCommission = getAllCommission(payAccount,wxComposeChildOrderShare.getOrderId());
int serviceAmount = PayUtils.getPayRate(wxComposeChildOrderShare.getRealPayMent(), allCommission, true);
wxComposeChildOrderShare.setServiceAmount(serviceAmount);
return true;

}

// @Override
// public int getMallCommission(Long couponId, WxPayAccount payAccount) {
// return 0;
// }

}

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

@@ -22,7 +22,7 @@ public class PayUtils {
Double dBaseAmount = 5.0D * 1000 / rate;
// 基础分 千分之6 83分
if (isReal) {
// 小于基础分,四舍五入
//四舍五入
Double dPayRate = 1.0D * payAmount * rate / 10000;
long dChargeFee = Math.round(dPayRate);
return Long.valueOf(dChargeFee).intValue();


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