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

Merge branch 'release_toaliyun_real_202211' of https://git.malls.iformall.com/server/formallProject into release_toaliyun_real_202211

release_toaliyun_real
zhengfangyuan 3 лет назад
Родитель
Сommit
66e327400b
6 измененных файлов: 193 добавлений и 116 удалений
  1. +8
    -0
      mallinkAdmin/src/main/resources/db/migration/V2022121200001__addmenu.sql
  2. +1
    -1
      mallinkService/src/main/java/com/iformall/enums/EnumMerchantSubsidySource.java
  3. +1
    -1
      mallinkService/src/main/java/com/iformall/enums/EnumMerchantSubsidyType.java
  4. +2
    -0
      mallinkService/src/main/java/com/iformall/service/WxCouponOrderService.java
  5. +49
    -38
      mallinkService/src/main/java/com/iformall/service/impl/WxCouponOrderServiceImpl.java
  6. +132
    -76
      mallinkService/src/main/java/com/iformall/service/impl/WxProfitSharingOrderServiceImpl.java

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

@@ -0,0 +1,8 @@
INSERT INTO `mallink`.`mall_permission`(`id`, `name`, `parent_id`, `available`, `permission`, `resource_type`, `module_color`, `module_color_num`, `url`, `icon`, `version_type`, `sort`) VALUES (71101, '集团券订单', 610, 'Y', NULL, 1, NULL, NULL, 'groupOrderList', NULL, 0, 711);

INSERT INTO `mallink`.`mall_permission`(`id`, `name`, `parent_id`, `available`, `permission`, `resource_type`, `module_color`, `module_color_num`, `url`, `icon`, `version_type`, `sort`) VALUES (41001, '集团自动分账', 416, 'Y', NULL, 1, NULL, NULL, 'groupSharingOrderList', NULL, 0, 412);

INSERT INTO `mallink`.`mall_permission`(`id`, `name`, `parent_id`, `available`, `permission`, `resource_type`, `module_color`, `module_color_num`, `url`, `icon`, `version_type`, `sort`) VALUES (41101, '集团营销结算', 416, 'Y', NULL, 1, NULL, NULL, 'groupMarketingList', NULL, 0, 413);

UPDATE `mallink`.`mall_sale_type` SET `menus` = '[1, 2, 4, 5, 6, 50, 105, 110, 201, 205, 202, 211, 212, 221, 222, 223, 224, 251, 409, 410, 411, 416, 500, 502, 504, 505, 506, 507, 508, 511, 512, 521, 522, 523, 591, 592, 595, 601, 602, 605, 606, 610, 615, 622, 647, 650, 676, 680, 711, 901, 902, 904, 907, 41001, 41101, 5310, 5320, 61501, 61502, 71101]' WHERE `id` = 102;


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

@@ -12,7 +12,7 @@ public enum EnumMerchantSubsidySource {
GROUP(4, "拼团核销"),
CASHIER(5, "收银台"),
DISTRIBUTION_GOODS(6, "可配送商品"),
GIFT_BAG(7, "券订单"),;
GIFT_BAG(7, "券礼包"),;

public static EnumMerchantSubsidySource getEnum(Integer code) {
for (EnumMerchantSubsidySource value : values()) {


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

@@ -5,7 +5,7 @@ package com.iformall.enums;
*/
public enum EnumMerchantSubsidyType {

MANUAL(1, "自主结算"),
MANUAL(1, "自主结算"),//补贴
WECHAT(2, "微信结算"),
DOUYIN(3, "抖音结算"),;



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

@@ -96,6 +96,8 @@ public interface WxCouponOrderService {
*/
void shareAfterVerify(WxCouponOrder couponOrder, WxMerchant wxMerchant,boolean mulityShare);

WxMerchantSubsidy recordAfterVerified(WxOrder order, WxMerchant wxMerchant);

/**
* 核销后补贴
* @param couponOrder


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

@@ -43,6 +43,7 @@ import com.iformall.utils.RedisLock;

import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.lang3.StringUtils;
import org.flowable.engine.runtime.Execution;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -1765,34 +1766,45 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService {
}
}

@Override
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class})
public WxMerchantSubsidy recordAfterVerified(WxCouponOrder couponOrder, WxMerchant wxMerchant) {
WxCoupon wxCoupon = wxCouponMapper.selectById(couponOrder.getCouponId(),couponOrder.getTenantId());
public WxMerchantSubsidy recordAfterVerified(WxOrder order, WxMerchant wxMerchant) {
WxMerchantSubsidy merchantSubsidy = new WxMerchantSubsidy();
merchantSubsidy.updateTenantInfo(wxMerchant);
if (couponOrder.getCouponType().equals(EnumCouponType.COUPON_PRESS.getCode())
&& couponOrder.getCouponPrice().equals(wxCoupon.getSalePrice())) {
//砍价
merchantSubsidy.setSource(EnumMerchantSubsidySource.PRESS.getCode());
} else if (couponOrder.getCouponType().equals(EnumCouponType.COUPON_GROUP.getCode())
&& couponOrder.getCouponPrice().equals(wxCoupon.getSalePrice())) {
//拼团
merchantSubsidy.setSource(EnumMerchantSubsidySource.GROUP.getCode());
} else if(couponOrder.getCouponType().equals(EnumCouponType.COUPON_DISTRIBUTION.getCode())){
//可配送商品
merchantSubsidy.setSource(EnumMerchantSubsidySource.DISTRIBUTION_GOODS.getCode());
} else if(couponOrder.getCouponType().equals(EnumCouponType.COUPON_GIFT.getCode())){
//券礼包
merchantSubsidy.setSource(EnumMerchantSubsidySource.GIFT_BAG.getCode());
} else {
//券
merchantSubsidy.setSource(EnumMerchantSubsidySource.COUPON.getCode());
merchantSubsidy.updateTenantInfo(order);
merchantSubsidy.setOrderId(order.getId());
if(EnumOrderType.COUPON.getCode().equals(order.getType())){
merchantSubsidy.setOrderType(EnumOrderType.COUPON.getCode());

WxCouponOrder couponOrderQ = new WxCouponOrder();
couponOrderQ.setOrderId(order.getId());
couponOrderQ.updateTenantInfo(order);
WxCouponOrder couponOrder = wxCouponOrderMapper.selectOne(new QueryWrapper<>(couponOrderQ));
// WxCoupon wxCoupon = wxCouponMapper.selectById(couponOrder.getCouponId(),order.getTenantId());
merchantSubsidy.setCouponOrderId(couponOrder.getId());
merchantSubsidy.setCouponType(couponOrder.getCouponType());

if(EnumCouponType.COUPON_PRESS.getCode().equals(couponOrder.getCouponType())){
merchantSubsidy.setSource(EnumMerchantSubsidySource.PRESS.getCode());
}else if(EnumCouponType.COUPON_GROUP.getCode().equals(couponOrder.getCouponType())){
merchantSubsidy.setSource(EnumMerchantSubsidySource.GROUP.getCode());
}else if(EnumCouponType.COUPON_DISTRIBUTION.getCode().equals(couponOrder.getCouponType())){
merchantSubsidy.setSource(EnumMerchantSubsidySource.DISTRIBUTION_GOODS.getCode());
}else if(EnumCouponType.COUPON_GIFT.getCode().equals(couponOrder.getCouponType())){
merchantSubsidy.setSource(EnumMerchantSubsidySource.GIFT_BAG.getCode());
}else{
merchantSubsidy.setSource(EnumMerchantSubsidySource.COUPON.getCode());
}
}else if(EnumOrderType.MICROPAY.getCode().equals(order.getType())){
merchantSubsidy.setOrderType(EnumOrderType.MICROPAY.getCode());
merchantSubsidy.setSource(EnumMerchantSubsidySource.CASHIER.getCode());
merchantSubsidy.setCouponOrderId(0l);
merchantSubsidy.setCouponType(0);
}else {
//todo 只有券和收银台的记账
// throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"记账数据异常");
return null;
}
merchantSubsidy.setOrderId(couponOrder.getOrderId());
merchantSubsidy.setOrderType(EnumOrderType.COUPON.getCode());
merchantSubsidy.setCouponOrderId(couponOrder.getId());
merchantSubsidy.setCouponType(couponOrder.getCouponType());
merchantSubsidy.setType(payServiceFactory.getPayShareAdapterService(couponOrder.getPayVendor(),couponOrder.getPayVersion()).getSubsidyType());
merchantSubsidy.setType(payServiceFactory.getPayShareAdapterService(order.getPayVendor(),order.getPayVersion()).getSubsidyType());

List<WxMerchantSubsidy> msList = wxMerchantSubsidyMapper.selectList(new QueryWrapper<WxMerchantSubsidy>(merchantSubsidy));
if (msList.size() > 0) {
@@ -1804,12 +1816,11 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService {
merchantSubsidy.setId(idWorker.nextId());
merchantSubsidy.setMerchantId(wxMerchant.getId());
merchantSubsidy.setBTenantId(wxMerchant.getTenantId());
merchantSubsidy.setOrderPayment(couponOrder.getCouponPrice());
merchantSubsidy.setReceiverPayment(couponOrder.getCouponPrice());
merchantSubsidy.setRealPayment(couponOrder.getCouponPrice());
merchantSubsidy.setSubsidy(couponOrder.getCouponPrice());
merchantSubsidy.setRealSubsidy(couponOrder.getCouponPrice());
merchantSubsidy.setType(payServiceFactory.getPayShareAdapterService(couponOrder.getPayVendor(),couponOrder.getPayVersion()).getSubsidyType());
merchantSubsidy.setOrderPayment(order.getPayment());
merchantSubsidy.setReceiverPayment(order.getPayment());
merchantSubsidy.setRealPayment(order.getPayment());
merchantSubsidy.setSubsidy(order.getPayment());
merchantSubsidy.setRealSubsidy(order.getPayment());
merchantSubsidy.setCreateDate(curDate);
merchantSubsidy.setUpdateDate(curDate);
merchantSubsidy.setStatus(EnumMerchantSubsidyStatus.NOT_SUBSIDY.getCode());
@@ -1817,7 +1828,7 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService {
//是否开通了商户提现,开通了商户提现往商户账户里面加金额
cashOutService.addCashOut(wxMerchant, couponOrder.getCouponPrice());
cashOutService.addCashOut(wxMerchant, order.getPayment());
return merchantSubsidy;
}
@@ -1838,24 +1849,24 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService {
logger.error("券订单"+couponOrder.getId()+"未查询到支付订单.");
throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"券订单"+couponOrder.getId()+"未查询到支付订单.");
}
WxOrder order = wxOrderService.getById(couponOrder.getOrderId(), wxPayOrder.getTenantId());
if (null == order) {
logger.error("租户"+wxPayOrder.getTenantId()+"券订单"+couponOrder.getId()+"未查询到订单.");
throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"租户"+wxPayOrder.getTenantId()+"券订单"+couponOrder.getId()+"未查询到订单.");
}
if(EnumPayMchType.TOTAL.getCode().equals(wxPayOrder.getMchType())
&& EnumPayShare.NO.getCode().equals(wxPayOrder.getShare())){
//总分并且不分账 记账
try {
// 订单购买时未分账 核销记账,并且往账户里面记帐
if (couponOrder.getCouponPrice() > 0) {
recordAfterVerified(couponOrder, wxMerchant);
recordAfterVerified(order, wxMerchant);
}
} catch (Exception e) {
logger.error("核销记账失败"+e.getMessage(),e);
}
}

WxOrder order = wxOrderService.getById(couponOrder.getOrderId(), wxPayOrder.getTenantId());
if (null == order) {
logger.error("租户"+wxPayOrder.getTenantId()+"券订单"+couponOrder.getId()+"未查询到订单.");
throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"租户"+wxPayOrder.getTenantId()+"券订单"+couponOrder.getId()+"未查询到订单.");
}
WxSharingOrderDto wxSharingOrderDto = new WxSharingOrderDto();
wxSharingOrderDto.setCUserId(wxPayOrder.getCUserId());
wxSharingOrderDto.setMerchantId(wxMerchant.getId());


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

@@ -21,13 +21,11 @@ import com.iformall.enums.*;
import com.iformall.exception.MallinkException;
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.*;
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.pay.douyin.v1.miniApp.EnumTtPayChannel;
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.PayShareQueryResult;
@@ -45,6 +43,7 @@ import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
@@ -106,6 +105,10 @@ public class WxProfitSharingOrderServiceImpl implements WxProfitSharingOrderServ
@Autowired
ExcelService excelService;

@Lazy
@Autowired
WxCouponOrderService wxCouponOrderService;

final JSONObject errorMap = JSON.parseObject("{" +
"\"SYSTEMERROR\":{\"detail\":\"接口返回错误\",\"reason\":\"系统超时\",\"resolution\":\"系统异常,请用相同参数重新调用\"}," +
"\"AMOUNT_OVERDUE\":{\"detail\":\"分账金额超限\",\"reason\":\"分账金额大于可分金额 或大于分账最大比例 \",\"resolution\":\"请调整分账金额\"}," +
@@ -185,21 +188,10 @@ public class WxProfitSharingOrderServiceImpl implements WxProfitSharingOrderServ
return new ResultData(ErrorCode.PROFIT_SHARING_REQUEST_FAILED.getCode(),"分账状态不允许");
}


WxMerchant merchant = wxMerchantService.getById(sharingOrder.getMerchantId());

Date currentDate = new Date();
if(EnumPayWay.PAY_WAY_WECHAT.getCode().equals(payOrder.getPayVendor())
&& DateUtils.daysBetween(payOrder.getCreateTime(),currentDate) > 30){
WxProfitSharingOrder updSharingOrder = new WxProfitSharingOrder();
updSharingOrder.updateTenantInfo(sharingOrder);
updSharingOrder.setId(sharingOrder.getId());
updSharingOrder.setSharingStatus(EnumProfitSharingOrderStatus.PROFIT_SHARING_FAILED.getCode());
updSharingOrder.setErrorMsg("微信支付超30天无法分账");
updSharingOrder.setUpdateTime(currentDate);
wxProfitSharingOrderMapper.updateById(updSharingOrder);

return new ResultData(ErrorCode.PROFIT_SHARING_REQUEST_FAILED.getCode(),"微信支付超30天无法分账");
}

PayShareAdapterService payShareAdapterService = payServiceFactory.getPayShareAdapterService(payOrder.getPayVendor(),payOrder.getPayVersion());

@@ -207,7 +199,6 @@ public class WxProfitSharingOrderServiceImpl implements WxProfitSharingOrderServ

//获取达人佣金
int cpsCommission = payShareAdapterService.getCPSCommission(sharingOrder,sharingOrder.getSingleOrderId());

if(cpsCommission < 0){
WxProfitSharingOrder updSharingOrder = new WxProfitSharingOrder();
updSharingOrder.updateTenantInfo(sharingOrder);
@@ -216,8 +207,9 @@ public class WxProfitSharingOrderServiceImpl implements WxProfitSharingOrderServ
updSharingOrder.setErrorMsg("未获取到达人佣金");
updSharingOrder.setUpdateTime(currentDate);
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();
@@ -232,15 +224,21 @@ public class WxProfitSharingOrderServiceImpl implements WxProfitSharingOrderServ
wxComposeChildOrderShare = payOrder.getSingleChildOrderShare();
}
wxComposeChildOrderShare.setCpsCommission(cpsCommission);

//官方手续费千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()) && EnumYesOrNo.YES.getCode().equals(payAccount.getIsCommission())){
//只有抖音直连才有分账
if(EnumPayWay.PAY_WAY_TT.getCode().equals(payOrder.getPayVendor())
&& EnumPayMchType.DIRECT.getCode().equals(payOrder.getMchType())
&& EnumYesOrNo.YES.getCode().equals(payAccount.getIsCommission())){
//销售抽点+系统抽点
int selSysAmount = PayUtils.getPayRate(wxComposeChildOrderShare.getRealPayMent(), payAccount.getSellRate()+payAccount.getSystemRate(), false);
//销售抽点
@@ -322,68 +320,126 @@ public class WxProfitSharingOrderServiceImpl implements WxProfitSharingOrderServ
//商户所得
int shareAmount = wxComposeChildOrderShare.getShareAmount() + surplus;

WxProfitSharingReceiver receiver = payShareAdapterService.getReceiver(merchant,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());
jo.put("account",receiver.getReceiverAccount());
jo.put("amount", shareAmount);
jo.put("merchantId",receiver.getMerchantId());
jo.put("bTenantId",receiver.getTenantId());
jo.put("description",receiver.getId());
receivers.add(jo);
boolean isCallSharing = false;//是否调用分账
boolean isCreateSubsidy = false;//是否需要记账
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())){
isCreateSubsidy = true;
}
isSharingResult = true;
}else{
isCallSharing = true;
WxProfitSharingReceiver receiver = payShareAdapterService.getReceiver(merchant,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());
jo.put("account",receiver.getReceiverAccount());
jo.put("amount", shareAmount);
jo.put("merchantId",receiver.getMerchantId());
jo.put("bTenantId",receiver.getTenantId());
jo.put("description",receiver.getId());
receivers.add(jo);
}else if(EnumPayWay.PAY_WAY_TT.getCode().equals(payOrder.getPayVendor())
&& EnumPayMchType.DIRECT.getCode().equals(payOrder.getMchType())
&& !sharingOrder.getMerchantId().equals(wxComposeChildOrderShare.getMerchantId())
&& EnumTtPayChannel.ALI_PAY.getCode().equals(payOrder.getTtPayWay())){
//抖音 直连 多商户 支付宝支付 进件支付宝 分账 否则记账
JSONObject jo = new JSONObject();
jo.put("type",payShareAdapterService.getShareAccount(receiver.getReceiverType()).getMessage());
jo.put("account",receiver.getReceiverAccount());
jo.put("amount", shareAmount);
jo.put("merchantId",receiver.getMerchantId());
jo.put("bTenantId",receiver.getTenantId());
jo.put("description",receiver.getId());
receivers.add(jo);
}else if(EnumPayMchType.DIRECT.getCode().equals(payOrder.getMchType())
&& !sharingOrder.getMerchantId().equals(wxComposeChildOrderShare.getMerchantId())){
isCreateSubsidy = true;
isSharingResult = true;
}else{
isSharingResult = true;
}
}

if(receivers.isEmpty()){
shareResult = payShareAdapterService.noReciverShare(cAppInfo, payAccount, sharingOrder);
if(isCallSharing){
if(receivers.isEmpty()){
shareResult = payShareAdapterService.noReciverShare(cAppInfo, payAccount, sharingOrder);
}else{
shareResult = payShareAdapterService.haveReciversShare(cAppInfo, payAccount, sharingOrder, receivers);
}

if (null == shareResult) {
return new ResultData(ErrorCode.PROFIT_SHARING_REQUEST_FAILED.getCode(),"当前支付模式调用分账未返回结果");
}

WxProfitSharingOrder updSharingOrder = new WxProfitSharingOrder();
updSharingOrder.updateTenantInfo(sharingOrder);
updSharingOrder.setId(sharingOrder.getId());
updSharingOrder.setOutSettleNo(sharingOrder.getOutSettleNo());

updSharingOrder.setUpdateTime(currentDate);

if(shareResult.isSuccess()){
updSharingOrder.setPayTimeEnd(currentDate);
updSharingOrder.setSharingOrderNo(shareResult.getShareOrderNo());
updSharingOrder.setSharingStatus(EnumProfitSharingOrderStatus.PROFIT_SHARING_ACCEPTED.getCode());
updSharingOrder.setErrorMsg(shareResult.getMsg());
}else{
updSharingOrder.setSharingStatus(shareResult.getCode());
updSharingOrder.setErrorMsg(shareResult.getMsg());
}
updSharingOrder.setPointDeduction(JSON.toJSONString(wxComposeChildOrderShare));
updSharingOrder.setReceivers(JSON.toJSONString(receivers));
wxProfitSharingOrderMapper.updateById(updSharingOrder);
}else{
shareResult = payShareAdapterService.haveReciversShare(cAppInfo, payAccount, sharingOrder, receivers);
}
if (null == shareResult) {
return new ResultData(ErrorCode.PROFIT_SHARING_REQUEST_FAILED.getCode(),"当前支付模式调用分账未返回结果");
WxProfitSharingOrder updSharingOrder = new WxProfitSharingOrder();
updSharingOrder.updateTenantInfo(sharingOrder);
updSharingOrder.setId(sharingOrder.getId());
updSharingOrder.setSharingStatus(EnumProfitSharingOrderStatus.PROFIT_SHARING_DONE.getCode());
updSharingOrder.setErrorMsg("微信支付超30天已自动解冻");
updSharingOrder.setPointDeduction(JSON.toJSONString(wxComposeChildOrderShare));
updSharingOrder.setReceivers(JSON.toJSONString(receivers));
updSharingOrder.setUpdateTime(currentDate);
wxProfitSharingOrderMapper.updateById(updSharingOrder);
}
WxProfitSharingOrder updSharingOrder = new WxProfitSharingOrder();
updSharingOrder.updateTenantInfo(sharingOrder);
updSharingOrder.setId(sharingOrder.getId());
updSharingOrder.setOutSettleNo(sharingOrder.getOutSettleNo());

updSharingOrder.setUpdateTime(currentDate);

if(shareResult.isSuccess()){
updSharingOrder.setPayTimeEnd(currentDate);
updSharingOrder.setSharingOrderNo(shareResult.getShareOrderNo());
updSharingOrder.setSharingStatus(EnumProfitSharingOrderStatus.PROFIT_SHARING_ACCEPTED.getCode());
updSharingOrder.setErrorMsg(shareResult.getMsg());
}else{
updSharingOrder.setSharingStatus(shareResult.getCode());
updSharingOrder.setErrorMsg(shareResult.getMsg());

if(isCreateSubsidy){
try {
// 微信超过30天无法分账的,
WxOrder order = wxOrderMapper.selectById(sharingOrder.getSingleOrderId(), sharingOrder.getTenantId());
wxCouponOrderService.recordAfterVerified(order, merchant);
} catch (Exception e) {
logger.error("核销记账失败"+e.getMessage(),e);
}
}
updSharingOrder.setPointDeduction(JSON.toJSONString(wxComposeChildOrderShare));
updSharingOrder.setReceivers(JSON.toJSONString(receivers));
wxProfitSharingOrderMapper.updateById(updSharingOrder);

if(EnumPayMchType.TOTAL.getCode().equals(payOrder.getMchType()) && EnumPayShare.NO.getCode().equals(payOrder.getShare())){
//解冻给收款方(广场)
JSONObject jo = new JSONObject();
jo.put("type",EnumProfitSharingReceiverType.PROFIT_SHARING_RECEIVER_MERCHANT_ID.getMessage());
jo.put("account",payAccount.getSubMchId());
jo.put("amount", shareAmount);
jo.put("merchantId",0);
jo.put("bTenantId",payOrder.getTenantId());
jo.put("description",0);
receivers.add(jo);
}else if(EnumPayMchType.DIRECT.getCode().equals(payOrder.getMchType())){
//解冻给收款方(门店)
JSONObject jo = new JSONObject();
jo.put("type",payShareAdapterService.getShareAccount(receiver.getReceiverType()).getMessage());
jo.put("account",receiver.getReceiverAccount());
jo.put("amount", shareAmount);
jo.put("merchantId",receiver.getMerchantId());
jo.put("bTenantId",receiver.getTenantId());
jo.put("description",receiver.getId());
receivers.add(jo);

if(isSharingResult){
if(EnumPayMchType.TOTAL.getCode().equals(payOrder.getMchType()) && EnumPayShare.NO.getCode().equals(payOrder.getShare())){
//解冻给收款方(广场)
JSONObject jo = new JSONObject();
jo.put("type",EnumProfitSharingReceiverType.PROFIT_SHARING_RECEIVER_MERCHANT_ID.getMessage());
jo.put("account",payAccount.getSubMchId());
jo.put("amount", shareAmount);
jo.put("merchantId",0);
jo.put("bTenantId",payOrder.getTenantId());
jo.put("description",0);
receivers.add(jo);
}else if(EnumPayMchType.DIRECT.getCode().equals(payOrder.getMchType())){
WxProfitSharingReceiver receiver = payShareAdapterService.getReceiver(sharingOrder,wxComposeChildOrderShare.getMerchantId(),payOrder.getTtPayWay(),payOrder.getMchType());
//解冻给收款方(门店)
JSONObject jo = new JSONObject();
jo.put("type",payShareAdapterService.getShareAccount(receiver.getReceiverType()).getMessage());
jo.put("account",receiver.getReceiverAccount());
jo.put("amount", shareAmount);
jo.put("merchantId",receiver.getMerchantId());
jo.put("bTenantId",receiver.getTenantId());
jo.put("description",receiver.getId());
receivers.add(jo);
}
}

try{


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