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

//sharing

release_toaliyun_real
xhxu 3 лет назад
Родитель
Сommit
99ad05030e
32 измененных файлов: 826 добавлений и 283 удалений
  1. +11
    -10
      mallinkAdmin/src/main/java/com/iformall/controller/basic/WxMerchantController.java
  2. +6
    -0
      mallinkAdmin/src/main/resources/db/migration/V2023021300001__add_分账类型.sql
  3. +12
    -16
      mallinkBApi/src/main/java/com/iformall/controller/WxMerchantController.java
  4. +4
    -2
      mallinkBApi/src/main/java/com/iformall/controller/WxProfitSharingReceiverApplyController.java
  5. +4
    -4
      mallinkCApi/src/main/java/com/iformall/controller/WxCarController.java
  6. +2
    -2
      mallinkSchedule/src/main/java/com/iformall/schedule/TtMerchantReciverSchedule.java
  7. +5
    -11
      mallinkService/src/main/java/com/iformall/domain/po/WxMerchant.java
  8. +94
    -0
      mallinkService/src/main/java/com/iformall/domain/po/WxProfitPaymentReceiver.java
  9. +1
    -1
      mallinkService/src/main/java/com/iformall/domain/po/WxProfitSharingReceiver.java
  10. +39
    -0
      mallinkService/src/main/java/com/iformall/enums/EnumProfitPaymentReceiverType.java
  11. +2
    -5
      mallinkService/src/main/java/com/iformall/enums/EnumProfitSharingType.java
  12. +15
    -0
      mallinkService/src/main/java/com/iformall/mapper/WxProfitPaymentReceiverMapper.java
  13. +0
    -1
      mallinkService/src/main/java/com/iformall/mapper/WxProfitSharingReceiverMapper.java
  14. +1
    -2
      mallinkService/src/main/java/com/iformall/service/WxMerchantService.java
  15. +70
    -0
      mallinkService/src/main/java/com/iformall/service/WxProfitPaymentReceiverService.java
  16. +4
    -12
      mallinkService/src/main/java/com/iformall/service/WxProfitSharingReceiverService.java
  17. +3
    -3
      mallinkService/src/main/java/com/iformall/service/impl/WxCouponOrderServiceImpl.java
  18. +4
    -4
      mallinkService/src/main/java/com/iformall/service/impl/WxCouponServiceImpl.java
  19. +2
    -2
      mallinkService/src/main/java/com/iformall/service/impl/WxMerchantServiceImpl.java
  20. +2
    -2
      mallinkService/src/main/java/com/iformall/service/impl/WxPayOrderServiceImpl.java
  21. +325
    -0
      mallinkService/src/main/java/com/iformall/service/impl/WxProfitPaymentReceiverServiceImpl.java
  22. +4
    -4
      mallinkService/src/main/java/com/iformall/service/impl/WxProfitSharingOrderServiceImpl.java
  23. +8
    -16
      mallinkService/src/main/java/com/iformall/service/impl/WxProfitSharingReceiverApplyServiceImpl.java
  24. +27
    -169
      mallinkService/src/main/java/com/iformall/service/impl/WxProfitSharingReceiverServiceImpl.java
  25. +9
    -1
      mallinkService/src/main/java/com/iformall/service/pay/service/share/PayShareAdapterService.java
  26. +24
    -2
      mallinkService/src/main/java/com/iformall/service/pay/service/share/douyin/TtPayShareService.java
  27. +6
    -1
      mallinkService/src/main/java/com/iformall/service/pay/service/share/wx/sft/WxPayShareSFTService.java
  28. +17
    -3
      mallinkService/src/main/java/com/iformall/service/pay/service/share/wx/v2/WxPayShareService.java
  29. +16
    -9
      mallinkService/src/main/java/com/iformall/service/pay/service/share/wx/v3/WxPayShareV3Service.java
  30. +1
    -0
      mallinkService/src/main/java/com/iformall/utils/Constant.java
  31. +102
    -0
      mallinkService/src/main/resources/mapper/WxProfitPaymentReceiverMapper.xml
  32. +6
    -1
      mallinkService/src/main/resources/mapper/WxProfitSharingReceiverMapper.xml

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

@@ -8,11 +8,8 @@ import com.iformall.common.ErrorCode;
import com.iformall.common.Result;
import com.iformall.common.ResultData;
import com.iformall.controller.base.BaseController;
import com.iformall.domain.po.WxAppinfo;
import com.iformall.domain.po.WxPayAccount;
import com.iformall.domain.po.*;
import com.iformall.domain.po.base.BaseEntity;
import com.iformall.domain.po.WxMerchant;
import com.iformall.domain.po.WxProfitSharingReceiver;
import com.iformall.domain.vo.WxMerchantTradeDetailVo;
import com.iformall.domain.vo.WxMerchantTradeVo;
import com.iformall.domain.vo.WxMerchantVo;
@@ -55,6 +52,10 @@ public class WxMerchantController extends BaseController {
@Autowired
private WxProfitSharingReceiverService wxProfitSharingReceiverService;

@Autowired
private WxProfitPaymentReceiverService wxProfitPaymentReceiverService;


@UserDataRuleAnnotation("merchant_list")
@ApiOperation("分页列表接口")
@GetMapping("listVo")
@@ -392,7 +393,7 @@ public class WxMerchantController extends BaseController {
if(merchant == null){
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"请检查传递参数");
}
return wxProfitSharingReceiverService.updateTtReceiver(merchant);
return wxProfitPaymentReceiverService.updateTtReceiver(merchant);
}


@@ -414,9 +415,9 @@ public class WxMerchantController extends BaseController {
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"请检查传递参数");
}
if(anEnum.equals(AppAddSubMerchantUrlType.improt_URL)){
return wxProfitSharingReceiverService.getTtReceiverImprotURL(merchant);
return wxProfitPaymentReceiverService.getTtReceiverImprotURL(merchant);
}else if(anEnum.equals(AppAddSubMerchantUrlType.Balance_URL)){
return wxProfitSharingReceiverService.getTtReceiverBalanceURL(merchant);
return wxProfitPaymentReceiverService.getTtReceiverBalanceURL(merchant);
}else{
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"请检查传递参数");
}
@@ -440,7 +441,7 @@ public class WxMerchantController extends BaseController {
if(payAcount == null){
return new ResultData(ErrorCode.APP_ID_NOT_FOUND);
}
return wxProfitSharingReceiverService.updateTtReceiverIsUse(merchant);
return wxProfitPaymentReceiverService.updateTtReceiverImportStatus(merchant);
}

@ApiOperation("更新收款账户信息:必填项 id(商户ID) name(商户名称) accountId(账号ID) accountTypeValue(账号类型) accountName(账号名称)")
@@ -466,7 +467,7 @@ public class WxMerchantController extends BaseController {
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "账号名称不能为空");
}
wxMerchant.updateTenantInfo(getTenantInfo());
return wxMerchantService.updateMerchantAccount(wxMerchant,false);
return wxMerchantService.updateMerchantAccount(wxMerchant);
}

@ApiOperation("删除分账账户")
@@ -479,7 +480,7 @@ public class WxMerchantController extends BaseController {
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "商户分账账户ID不能为空");
}
receiver.updateTenantInfo(getTenantInfo());
return wxProfitSharingReceiverService.delReceiver(receiver, EnumMsgSend.MSG_SEND_IMMEDIATELY.getCode(),false);
return wxProfitSharingReceiverService.delReceiver(receiver, EnumMsgSend.MSG_SEND_IMMEDIATELY.getCode());
}

}

+ 6
- 0
mallinkAdmin/src/main/resources/db/migration/V2023021300001__add_分账类型.sql Просмотреть файл

@@ -0,0 +1,6 @@
--创建收款帐号表

--备份分账帐号表
--将微信进件的数据转移到收款帐号表里--并将原数据删除

--将抖音进件的数据转移到收款帐号表里--原数据修改ReceiverType =10

+ 12
- 16
mallinkBApi/src/main/java/com/iformall/controller/WxMerchantController.java Просмотреть файл

@@ -27,6 +27,9 @@ public class WxMerchantController extends BaseController {
@Autowired
private WxMerchantService wxMerchantService;

@Autowired
private WxProfitPaymentReceiverService wxProfitPaymentReceiverService;

@Autowired
private WxProfitSharingReceiverService wxProfitSharingReceiverService;

@@ -45,7 +48,7 @@ public class WxMerchantController extends BaseController {
return new ResultData(wxMerchantService.findList(getTenantInfo()));
}

@ApiOperation("查询账信息")
@ApiOperation("微信查询账信息")
@GetMapping("/findAccountById")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
public ResultData findAccountById(@ModelAttribute WxMerchant wxMerchant) {
@@ -60,18 +63,11 @@ public class WxMerchantController extends BaseController {
if(payAccount == null){
return new ResultData(ErrorCode.API_KEY_NOT_FOUND);
}
EnumProfitSharingType enumSharingType = EnumProfitSharingType.PROFIT_SHARING_TYPE_WECHAT;
if(EnumPayMchType.TOTAL.getCode().equals(payAccount.getMchType())){
enumSharingType = EnumProfitSharingType.PROFIT_SHARING_TYPE_WECHAT;
}else if(EnumPayMchType.DIRECT.getCode().equals(payAccount.getMchType())){
enumSharingType = EnumProfitSharingType.PROFIT_SHARING_TYPE_WECHAT_v2;
}else{
return new ResultData(ErrorCode.APP_PLAT_ERROR);
}
return new ResultData(wxProfitSharingReceiverService.findReceiver(tenantInfo,wxMerchant.getId(), EnumAppPlat.WX,enumSharingType));

return new ResultData(wxProfitSharingReceiverService.findReceiver(tenantInfo,wxMerchant.getId(), EnumAppPlat.WX));
}

@ApiOperation("查询账户信息")
@ApiOperation("抖音查询收款账户信息")
@GetMapping("/findTtAccountById")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
public ResultData findTtAccountById(@ModelAttribute WxMerchant wxMerchant) {
@@ -80,7 +76,7 @@ public class WxMerchantController extends BaseController {
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "商户ID不能为空");
}
wxMerchant.updateTenantInfo(getTenantInfo());
return new ResultData(wxProfitSharingReceiverService.findReceiver(getTenantInfo(),wxMerchant.getId(), EnumAppPlat.TOUTIAO,EnumProfitSharingType.PROFIT_SHARING_TYPE_DOUYIN));
return new ResultData(wxProfitPaymentReceiverService.findReceiver(getTenantInfo(),wxMerchant.getId(), EnumAppPlat.TOUTIAO,EnumProfitPaymentReceiverType.tt_merchant_number));
}

@ApiOperation("更新收款账户信息:必填项 id(商户ID) name(商户名称) accountId(账号ID) accountTypeValue(账号类型) accountName(账号名称)")
@@ -106,7 +102,7 @@ public class WxMerchantController extends BaseController {
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "账号名称不能为空");
}
wxMerchant.updateTenantInfo(getTenantInfo());
return wxMerchantService.updateMerchantAccount(wxMerchant,true);
return wxMerchantService.updateMerchantAccount(wxMerchant);
}

@ApiOperation("删除分账账户")
@@ -121,7 +117,7 @@ public class WxMerchantController extends BaseController {
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "商户分账账户ID不能为空");
}
receiver.updateTenantInfo(getTenantInfo());
return wxProfitSharingReceiverService.delReceiver(receiver, EnumMsgSend.MSG_SEND_IMMEDIATELY.getCode(),true);
return wxProfitSharingReceiverService.delReceiver(receiver, EnumMsgSend.MSG_SEND_IMMEDIATELY.getCode());
}

@ApiOperation("查询是否有权限修改账户")
@@ -187,9 +183,9 @@ public class WxMerchantController extends BaseController {
}

if(anEnum.equals(AppAddSubMerchantUrlType.improt_URL)){
return wxProfitSharingReceiverService.getTtReceiverImprotURL(merchant);
return wxProfitPaymentReceiverService.getTtReceiverImprotURL(merchant);
}else if(anEnum.equals(AppAddSubMerchantUrlType.Balance_URL)){
return wxProfitSharingReceiverService.getTtReceiverBalanceURL(merchant);
return wxProfitPaymentReceiverService.getTtReceiverBalanceURL(merchant);
}else{
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"请检查传递参数");
}


+ 4
- 2
mallinkBApi/src/main/java/com/iformall/controller/WxProfitSharingReceiverApplyController.java Просмотреть файл

@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON;
import com.iformall.common.ErrorCode;
import com.iformall.common.ResultData;
import com.iformall.domain.po.WxMerchant;
import com.iformall.domain.po.WxProfitPaymentReceiver;
import com.iformall.domain.po.WxProfitSharingReceiver;
import com.iformall.domain.po.WxProfitSharingReceiverApply;
import com.iformall.domain.po.base.TenantEntity;
@@ -12,6 +13,7 @@ import com.iformall.enums.*;
import com.iformall.exception.MallinkException;
import com.iformall.file.aliyun.AliyunOSS;
import com.iformall.service.WxMerchantService;
import com.iformall.service.WxProfitPaymentReceiverService;
import com.iformall.service.WxProfitSharingReceiverApplyService;
import com.iformall.service.WxProfitSharingReceiverService;
import com.iformall.utils.ImgYwsqhUtil;
@@ -44,7 +46,7 @@ public class WxProfitSharingReceiverApplyController extends BaseController {
private WxProfitSharingReceiverApplyService wxProfitSharingReceiverApplyService;

@Autowired
private WxProfitSharingReceiverService wxProfitSharingReceiverService;
private WxProfitPaymentReceiverService wxProfitPaymentReceiverService;

@Autowired
private WxMerchantService wxMerchantService;
@@ -85,7 +87,7 @@ public class WxProfitSharingReceiverApplyController extends BaseController {
if(merchant == null || EnumMerchantStatus.NOT_VALID.getCode().equals(merchant.getStatus())){
return new ResultData(ErrorCode.MERCHANT_INFO_NOT_VALID.getCode(),"商户不存在或已停用");
}
WxProfitSharingReceiver receiver = wxProfitSharingReceiverService.findReceiver(merchant, merchant.getId(), EnumAppPlat.WX, EnumProfitSharingType.PROFIT_SHARING_TYPE_WECHAT_v2);
WxProfitPaymentReceiver receiver = wxProfitPaymentReceiverService.findReceiver(merchant, merchant.getId(), EnumAppPlat.WX, EnumProfitPaymentReceiverType.wx_special_merchant_number);
if(receiver != null && MerchantImportStatus.improt_success.getCode().equals(receiver.getWxImportStatus())){
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "该商户已进件成功");
}


+ 4
- 4
mallinkCApi/src/main/java/com/iformall/controller/WxCarController.java Просмотреть файл

@@ -90,9 +90,9 @@ public class WxCarController extends BaseController {
@Autowired
WxPayAccountService wxPayAccountService;
@Autowired
WxProfitSharingReceiverService wxProfitSharingReceiverService;
WxProfitPaymentReceiverService wxProfitPaymentReceiverService;
@Autowired
@Qualifier("objectCommonRedisTemplate")
@@ -470,14 +470,14 @@ public class WxCarController extends BaseController {
return new ResultData(Result.ERROR,"未设置停车商户.");
}
WxProfitSharingReceiver receiver = wxProfitSharingReceiverService.findReceiver(park, parkMerchant.getId(), EnumAppPlat.WX, EnumProfitSharingType.PROFIT_SHARING_TYPE_WECHAT_v2);
WxProfitPaymentReceiver receiver = wxProfitPaymentReceiverService.findReceiver(park, parkMerchant.getId(), EnumAppPlat.WX, EnumProfitPaymentReceiverType.wx_special_merchant_number);
if (null == receiver || StringUtils.isBlank(receiver.getReceiverAccount())) {
//查询商官商户
WxMerchant adminMerchant = wxMerchantService.findAdmin(park);
if (null == adminMerchant) {
return new ResultData(Result.ERROR,"未找到商管商户.");
}
receiver = wxProfitSharingReceiverService.findReceiver(park, adminMerchant.getId(), EnumAppPlat.WX, EnumProfitSharingType.PROFIT_SHARING_TYPE_WECHAT_v2);
receiver = wxProfitPaymentReceiverService.findReceiver(park, adminMerchant.getId(), EnumAppPlat.WX, EnumProfitPaymentReceiverType.wx_special_merchant_number);
if (null == receiver || StringUtils.isBlank(receiver.getReceiverAccount())) {
return new ResultData(Result.ERROR,"商管商户未设置收款账号.");
}


+ 2
- 2
mallinkSchedule/src/main/java/com/iformall/schedule/TtMerchantReciverSchedule.java Просмотреть файл

@@ -37,7 +37,7 @@ public class TtMerchantReciverSchedule {
private WxPayAccountService payAccountService;

@Autowired
private WxProfitSharingReceiverService wxProfitSharingReceiverService;
private WxProfitPaymentReceiverService wxProfitPaymentReceiverService;


/**
@@ -64,7 +64,7 @@ public class TtMerchantReciverSchedule {
// logger.error("TtMerchantReciverSchedule error.updateTtReceiver:"+m.getId(),e);
// }
try {
wxProfitSharingReceiverService.updateTtReceiverIsUse(m);
wxProfitPaymentReceiverService.updateTtReceiverImportStatus(m);
} catch (Exception e) {
e.printStackTrace();
logger.error("TtMerchantReciverSchedule error.updateTtReceiver:"+m.getId(),e);


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

@@ -196,20 +196,14 @@ public class WxMerchant extends TenantEntity {
return String.join("\n",
wxProfitSharingReceiver.stream().map(r->{
StringBuffer str = new StringBuffer();
if(EnumProfitSharingType.PROFIT_SHARING_TYPE_WECHAT_v2.getCode().equals(r.getSharingType())){
str.append("微信特约商户号:");
}else if(EnumProfitSharingType.PROFIT_SHARING_TYPE_DOUYIN.getCode().equals(r.getSharingType())){
str.append("抖音商户号:");
}else if(EnumProfitSharingType.PROFIT_SHARING_TYPE_BANK.getCode().equals(r.getSharingType())){
str.append("银行卡号:");
}else if(EnumProfitSharingType.PROFIT_SHARING_TYPE_WECHAT.getCode().equals(r.getSharingType())){
if(EnumProfitSharingReceiverType.PROFIT_SHARING_RECEIVER_MERCHANT_ID.getCode().equals(r.getReceiverType())){
if(EnumProfitSharingType.PROFIT_SHARING_TYPE_SYS.getCode().equals(r.getSharingType())){
if(EnumProfitPaymentReceiverType.wx_special_merchant_number.getCode().equals(r.getReceiverType())){
str.append("微信商户号:");
}else if(EnumProfitSharingReceiverType.PROFIT_SHARING_RECEIVER_PERSONAL_WECHATID.getCode().equals(r.getReceiverType())){
}else if(EnumProfitPaymentReceiverType.wx_personal_wechatid.getCode().equals(r.getReceiverType())){
str.append("个人微信号(微信已停用):");
}else if(EnumProfitSharingReceiverType.PROFIT_SHARING_RECEIVER_PERSONAL_OPENID.getCode().equals(r.getReceiverType())){
}else if(EnumProfitPaymentReceiverType.wx_personal_openid.getCode().equals(r.getReceiverType())){
str.append("OPENID:");
} else if(EnumProfitSharingReceiverType.PROFIT_SHARING_RECEIVER_PERSONAL_SUB_OPENID.getCode().equals(r.getReceiverType())){
} else if(EnumProfitPaymentReceiverType.wx_personal_sub_openid.getCode().equals(r.getReceiverType())){
str.append("OPENID:");
}
}


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

@@ -0,0 +1,94 @@
package com.iformall.domain.po;

import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.iformall.domain.po.base.TenantEntity;
import com.iformall.douyin.pay.orderQuery.QueryMerchantResult;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.apache.commons.lang3.StringUtils;

import java.util.Date;

@TableName(value = "wx_profit_payment_receiver")
@Data
@EqualsAndHashCode(callSuper = true)
public class WxProfitPaymentReceiver extends TenantEntity {

protected Long id;

@io.swagger.annotations.ApiModelProperty(value="商户ID",name="merchantId")
private Long merchantId;
@io.swagger.annotations.ApiModelProperty(value="收款帐号类型 EnumProfitPaymentReceiverType",name="receiverType")
private Integer receiverType;
@io.swagger.annotations.ApiModelProperty(value="收款商户号",name="receiverAccount")
private String receiverAccount;
@io.swagger.annotations.ApiModelProperty(value="说明",name="receiverComments")
private String receiverComments;
@io.swagger.annotations.ApiModelProperty(value="",name="createTime")
private Date createTime;
@io.swagger.annotations.ApiModelProperty(value="",name="updateTime")
private Date updateTime;

@io.swagger.annotations.ApiModelProperty(value="分账接收方状态 0,正常 1,停用",name="status")
private Integer status;
@io.swagger.annotations.ApiModelProperty(value="平台 EnumAppPlat",name="plat")
private Integer plat;

@io.swagger.annotations.ApiModelProperty(value = "进件状态", name = "ttImportStatus")
private String ttImportStatus;

@TableField(exist = false)
private Integer wxImportStatus;
@TableField(exist = false)
private Integer alipayImportStatus;
@TableField(exist = false)
private Integer hzImportStatus;

private QueryMerchantResult getMerchantResult(){
QueryMerchantResult queryMerchantResult = null;
try{
if(StringUtils.isNotBlank(this.ttImportStatus)) {
queryMerchantResult = JSON.parseObject(this.ttImportStatus, QueryMerchantResult.class);
}
}catch(Exception e){}
if(queryMerchantResult == null){
queryMerchantResult = new QueryMerchantResult();
}
return queryMerchantResult;
}

public Integer getWxImportStatus(){
return getMerchantResult().getWx();
}
public Integer getAlipayImportStatus(){
return getMerchantResult().getAlipay();
}
public Integer getHzImportStatus(){
return getMerchantResult().getHz();
}

@io.swagger.annotations.ApiModelProperty(value = "进件页面", name = "ttImportUrl")
private String ttImportUrl;

@io.swagger.annotations.ApiModelProperty(value = "余额页面", name = "ttBalanceUrl")
private String ttBalanceUrl;





@TableField(exist = false)
@io.swagger.annotations.ApiModelProperty(value="分账金额(分)",name="sharingAmount")
private Integer sharingAmount;
@TableField(exist = false)
@io.swagger.annotations.ApiModelProperty(value="真实费率",name="rateAmount")
private Integer rateAmount;
@TableField(exist = false)
private Integer realRateAmount;//平台手续费
@TableField(exist = false)
private Integer commissionAmount;//平台佣金


}

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

@@ -30,7 +30,7 @@ public class WxProfitSharingReceiver extends TenantEntity {
private Date createTime;
@io.swagger.annotations.ApiModelProperty(value="",name="updateTime")
private Date updateTime;
@io.swagger.annotations.ApiModelProperty(value="分账类型:1-服务商户分账,2-商户转入银行卡",name="sharingType")
@io.swagger.annotations.ApiModelProperty(value="EnumProfitSharingType 分账类型:1-服务商户分账,2-商户转入银行卡",name="sharingType")
private Integer sharingType;
@io.swagger.annotations.ApiModelProperty(value="",name="bankNo")
private String bankNo;


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

@@ -0,0 +1,39 @@
package com.iformall.enums;

/**
* Created by Stormeye on 2018/08/09.
*/
public enum EnumProfitPaymentReceiverType {
wx_special_merchant_number(0, "MERCHANT_ID"),//微信特约商户号
wx_personal_wechatid(1, "PERSONAL_WECHATID"),//微信号 已不支持
wx_personal_openid(2, "PERSONAL_OPENID"),//v2,v3
wx_personal_sub_openid(3, "PERSONAL_SUB_OPENID"),

tt_merchant_number(10,"")//抖音商户号
;

public static EnumProfitPaymentReceiverType getEnum(Integer code) {
for (EnumProfitPaymentReceiverType value : values()) {
if (value.getCode().equals(code)) {
return value;
}
}
return null;
}

private Integer code;
private String message;

EnumProfitPaymentReceiverType(Integer code, String message) {
this.code = code;
this.message = message;
}

public Integer getCode() {
return code;
}

public String getMessage() {
return message;
}
}

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

@@ -4,11 +4,8 @@ package com.iformall.enums;
* Created by Stormeye on 2018/08/09.
*/
public enum EnumProfitSharingType {
PROFIT_SHARING_TYPE_WECHAT(1, "微信分账"),
PROFIT_SHARING_TYPE_BANK(2, "银行卡分账"),

PROFIT_SHARING_TYPE_DOUYIN(3, "抖音进件"),
PROFIT_SHARING_TYPE_WECHAT_v2(4, "微信特约商户进件"),
PROFIT_SHARING_TYPE_SYS(1, "系统分账"),
PROFIT_SHARING_TYPE_BANK(2, "银行卡打款"),
;

public static EnumProfitSharingType getEnum(Integer code) {


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

@@ -0,0 +1,15 @@
package com.iformall.mapper;

import com.iformall.common.CommonMapper;
import com.iformall.domain.po.WxProfitPaymentReceiver;
import com.iformall.domain.po.WxProfitSharingReceiver;

import java.util.List;

public interface WxProfitPaymentReceiverMapper extends CommonMapper<WxProfitPaymentReceiver, Long> {

List<WxProfitPaymentReceiver> findList(WxProfitPaymentReceiver record);
WxProfitPaymentReceiver findOne(WxProfitPaymentReceiver record);

}

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

@@ -10,5 +10,4 @@ public interface WxProfitSharingReceiverMapper extends CommonMapper<WxProfitShar
WxProfitSharingReceiver findOne(WxProfitSharingReceiver wxProfitSharingReceiver);

List<Long> findMerchantIdList(WxProfitSharingReceiver wxProfitSharingReceiver);
}

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

@@ -142,10 +142,9 @@ public interface WxMerchantService {
/**
*
* @param wxMerchant
* @param isSync 是否需要同步第三方(微信总分模式需要)
* @return
*/
ResultData updateMerchantAccount(WxMerchant wxMerchant,boolean isSync);
ResultData updateMerchantAccount(WxMerchant wxMerchant);

ResultData updateMerchantAdmin(WxMerchant wxMerchant);



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

@@ -0,0 +1,70 @@
package com.iformall.service;

import com.github.pagehelper.PageInfo;
import com.iformall.common.ResultData;
import com.iformall.domain.po.WxMerchant;
import com.iformall.domain.po.WxProfitPaymentReceiver;
import com.iformall.domain.po.WxProfitSharingReceiver;
import com.iformall.domain.po.base.TenantEntity;
import com.iformall.enums.EnumAppPlat;
import com.iformall.enums.EnumProfitPaymentReceiverType;
import com.iformall.enums.EnumProfitSharingType;

import java.util.List;

public interface WxProfitPaymentReceiverService {

/**
* 根据实体查询分页列表
*
* @param record
* @return
*/
PageInfo<WxProfitPaymentReceiver> listAsPage(WxProfitPaymentReceiver record, Integer pageIndex, Integer pageSize);
/**
* 根据Id获得实体
*
* @param id
* @return
*/
WxProfitPaymentReceiver getById(Long id);
/**
* 保存或更新实体
*
* @param record
*/
void saveOrUpdate(WxProfitPaymentReceiver record);

// /**
// * 根据Id删除实体
// *
// * @param id
// */
// void deleteById(Long id);

/**
* 获取门店的收款帐号
* @param tenantEntity
* @param merchantId
* @param plat
* @param receiverType
* @return
*/
WxProfitPaymentReceiver findReceiver(TenantEntity tenantEntity, Long merchantId, EnumAppPlat plat, EnumProfitPaymentReceiverType receiverType);


ResultData updateReceiver(WxProfitPaymentReceiver receiver);



ResultData updateTtReceiver(WxMerchant merchant);

ResultData getTtReceiverImprotURL(WxMerchant merchant);

ResultData getTtReceiverBalanceURL(WxMerchant merchant);

ResultData updateTtReceiverImportStatus(WxMerchant merchant);

}

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

@@ -43,30 +43,22 @@ public interface WxProfitSharingReceiverService {
*/
void deleteById(Long id);

WxProfitSharingReceiver findReceiver(TenantEntity tenantEntity,Long merchantId, EnumAppPlat plat,EnumProfitSharingType sharingType);
WxProfitSharingReceiver findReceiver(TenantEntity tenantEntity,Long merchantId, EnumAppPlat plat);
List<WxProfitSharingReceiver> findReceivers(TenantEntity tenantEntity,Long merchantId);

ResultData addReceiver(WxMerchant merchant, WxProfitSharingReceiver receiver, List<WxProfitSharingReceiver> delList, boolean isSync);
ResultData addReceiver(WxMerchant merchant, WxProfitSharingReceiver receiver, List<WxProfitSharingReceiver> delList);

ResultData delReceiver(WxProfitSharingReceiver receiver, Integer send, boolean isSync);
ResultData delReceiver(WxProfitSharingReceiver receiver, Integer send);

/**
*
* @param merchant
* @param receiver
* @param isSync 是否需要同步第三方(微信总分模式需要)
* @return
*/
ResultData updateReceiver(WxMerchant merchant, WxProfitSharingReceiver receiver, boolean isSync);
ResultData updateReceiver(WxMerchant merchant, WxProfitSharingReceiver receiver);

void sendMsg(String phone, String account, String merchant, String time, Integer modelType, TenantEntity tenantEntity);

ResultData updateTtReceiver(WxMerchant merchant);

ResultData getTtReceiverImprotURL(WxMerchant merchant);

ResultData getTtReceiverBalanceURL(WxMerchant merchant);

ResultData updateTtReceiverIsUse(WxMerchant merchant);

}

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

@@ -1471,9 +1471,9 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService {
if(wxPayOrder != null && EnumPayMchType.TOTAL.getCode().equals(wxPayOrder.getMchType())
&& EnumPayShare.YES.getCode().equals(wxPayOrder.getShare())){
WxProfitSharingReceiver receiver = payServiceFactory.getPayShareAdapterService(wxPayOrder.getPayVendor(),couponOrder.getPayVersion())
.getReceiver(mallTenantEntity, merchantId, wxPayOrder.getTtPayWay(),wxPayOrder.getMchType());
.getSharingReceiver(mallTenantEntity, merchantId, wxPayOrder.getTtPayWay(),wxPayOrder.getMchType());
if (null == receiver) {
throw new MallinkException(ErrorCode.VERIFY_COUPON_ORDER_MERCHANT_IS_NULL.getCode(),"当前商户没有配置收款账号。");
throw new MallinkException(ErrorCode.VERIFY_COUPON_ORDER_MERCHANT_IS_NULL.getCode(),"当前商户没有配置分账账号。");
}
}
// else if(wxPayOrder != null && EnumPayMchType.DIRECT.getCode().equals(wxPayOrder.getMchType())){
@@ -2890,7 +2890,7 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService {
String merchant_uid = "";
if(EnumPayMchType.DIRECT.getCode().equals(payOrder.getMchType())){//直连模式记录收款商户
merchant_id = bUser.getMerchantId();
WxProfitSharingReceiver receiver = payShareServie.getReceiver(payAccount, merchant_id, null, payOrder.getMchType());
WxProfitPaymentReceiver receiver = payShareServie.getPaymantReceiver(payAccount, merchant_id);
if(receiver == null){
throw new MallinkException(ErrorCode.PAY_ORDER_MERCHANT_UID_ERROR);
}


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

@@ -890,7 +890,7 @@ public class WxCouponServiceImpl implements WxCouponService {
//多商户券,抖音 直连 门店只有进件支付宝才能参加活动 todo
if(EnumAppPlat.TOUTIAO.equals(plat) && EnumCouponMerchantType.MULTIPLE_MERCHANT.getCode().equals(record.getMerchantType())){
for (WxMerchant merchant:merchantList) {
WxProfitSharingReceiver receiver = payShareServie.getReceiver(mallTenantEntity, merchant.getId(), null, payMchType.getCode());
WxProfitPaymentReceiver receiver = payShareServie.getPaymantReceiver(mallTenantEntity, merchant.getId());
if (receiver == null) {
badNames.add(merchant.getName());
}
@@ -975,7 +975,7 @@ public class WxCouponServiceImpl implements WxCouponService {
//总分模式下不能分账的商户
private boolean toTalPayMchTypeMerchantIsBad(PayShareAdapterService payShareServie,WxPayAccount payAccount,
String merchantName,Long merchantId,EnumPayMchType payMchType,EnumAppPlat plat) throws Exception {
WxProfitSharingReceiver receiver = payShareServie.getReceiver(payAccount, merchantId, null, payMchType.getCode());
WxProfitSharingReceiver receiver = payShareServie.getSharingReceiver(payAccount, merchantId, null, payMchType.getCode());
if (receiver == null) {
return true;
}
@@ -1615,7 +1615,7 @@ public class WxCouponServiceImpl implements WxCouponService {

if(wxCoupon.getSalePrice() != null && wxCoupon.getSalePrice() > 0) {
PayShareAdapterService payShareServie = payServiceFactory.getPayShareAdapterService(payWay.getCode(),payAccount.getPayVersion());
WxProfitSharingReceiver receiver = payShareServie.getReceiver(makeMerchant, makeMerchant.getId(), null, payMchType.getCode());
WxProfitPaymentReceiver receiver = payShareServie.getPaymantReceiver(makeMerchant, makeMerchant.getId());
if (receiver == null) {
throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "所属商户[\""+makeMerchant.getName()+"\"]未配置收款账户");
}
@@ -1873,7 +1873,7 @@ public class WxCouponServiceImpl implements WxCouponService {
Map<Long,Boolean> merchantAutoShareMap = new HashMap<Long,Boolean>();
for (Long mid:wxCoupon.getMerchantIds()) {
//开通了支付宝就可以
WxProfitSharingReceiver receiver = payShareServie.getReceiver(payAccount, mid, null, payMchType.getCode());
WxProfitSharingReceiver receiver = payShareServie.getSharingReceiver(payAccount, mid, null, payMchType.getCode());
if (null == receiver) {
merchantAutoShareMap.put(mid, false);
}else {


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

@@ -744,7 +744,7 @@ public class WxMerchantServiceImpl implements WxMerchantService {

@Transactional(isolation=Isolation.SERIALIZABLE, propagation = Propagation.REQUIRED, rollbackFor = {Exception.class})
@Override
public ResultData updateMerchantAccount(WxMerchant wxMerchant,boolean isSync) {
public ResultData updateMerchantAccount(WxMerchant wxMerchant) {
try {
if (wxMerchant.getId() == null) {
return new ResultData(ErrorCode.MERCHANT_INFO_NOT_FOUND);
@@ -760,7 +760,7 @@ public class WxMerchantServiceImpl implements WxMerchantService {
receiver.setReceiverType(wxMerchant.getAccountTypeValue());
receiver.setTrueName(wxMerchant.getAccountName());
receiver.setParameter(wxMerchant.getAccountParameter());
return wxProfitSharingReceiverService.updateReceiver(wxMerchant, receiver, isSync);
return wxProfitSharingReceiverService.updateReceiver(wxMerchant, receiver);
}
} catch (Exception e) {
logger.error("db failed: 账户操作失败, e:" + e.getMessage(),e);


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

@@ -427,7 +427,7 @@ public class WxPayOrderServiceImpl implements WxPayOrderService {
throw new MallinkException(ErrorCode.PAY_ORDER_MERCHANT_UID_ERROR);
}
PayShareAdapterService payShareServie = payServiceFactory.getPayShareAdapterService(payWay.getCode(),payAccount.getPayVersion());
WxProfitSharingReceiver receiver = payShareServie.getReceiver(payAccount, merchant_id, null, payMchTypeEnum.getCode());
WxProfitPaymentReceiver receiver = payShareServie.getPaymantReceiver(payAccount, merchant_id);
if(receiver == null){
throw new MallinkException(ErrorCode.PAY_ORDER_MERCHANT_UID_ERROR);
}
@@ -558,7 +558,7 @@ public class WxPayOrderServiceImpl implements WxPayOrderService {
String merchant_uid = "";
if(EnumPayMchType.DIRECT.getCode().equals(record.getMchType())){//直连模式记录收款商户
merchant_id = user.getMerchantId();
WxProfitSharingReceiver receiver = payShareServie.getReceiver(payAccount, merchant_id, null, record.getMchType());
WxProfitPaymentReceiver receiver = payShareServie.getPaymantReceiver(payAccount, merchant_id);
if(receiver == null){
throw new MallinkException(ErrorCode.PAY_ORDER_MERCHANT_UID_ERROR);
}


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

@@ -0,0 +1,325 @@
package com.iformall.service.impl;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.iformall.common.ErrorCode;
import com.iformall.common.IdWorker;
import com.iformall.common.ResultData;
import com.iformall.domain.dto.WxMerchantDto;
import com.iformall.domain.po.*;
import com.iformall.domain.po.base.TenantEntity;
import com.iformall.domain.po.msg.WxMsgRecord;
import com.iformall.domain.vo.WxMerchantVo;
import com.iformall.douyin.pay.DouYinPayHelper;
import com.iformall.douyin.pay.enums.AppAddSubMerchantUrlType;
import com.iformall.douyin.pay.orderQuery.QueryMerchantResult;
import com.iformall.douyin.pay.preOrder.AppAddSubMerchant;
import com.iformall.douyin.pay.preOrder.AppAddSubMerchantResult;
import com.iformall.enums.*;
import com.iformall.exception.MallinkException;
import com.iformall.mapper.WxProfitPaymentReceiverMapper;
import com.iformall.mq.MqBaseProducer;
import com.iformall.service.*;
import com.iformall.service.pay.PayServiceFactory;
import com.iformall.service.pay.service.share.entity.ShareAccountResult;
import com.iformall.utils.Constant;
import com.iformall.utils.DateUtils;
import com.iformall.utils.RedisCacheUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Lazy;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


@Service
public class WxProfitPaymentReceiverServiceImpl implements WxProfitPaymentReceiverService {

private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
WxProfitPaymentReceiverMapper wxProfitPaymentReceiverMapper;
@Autowired
WxAppinfoService wxAppinfoService;
@Autowired
WxPayAccountService wxPayAccountService;
@Lazy
@Autowired
WxMerchantService wxMerchantService;
@Autowired
private MqBaseProducer mqBaseProducer;
@Autowired
PayServiceFactory payServiceFactory;

@Autowired
@Qualifier("objectCommonRedisTemplate")
RedisTemplate<String, Object> paymentReceicerRedisTemplate;

@Override
public PageInfo<WxProfitPaymentReceiver> listAsPage(WxProfitPaymentReceiver record, Integer pageIndex, Integer pageSize) {
return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxProfitPaymentReceiverMapper.findList(record));
}

@Override
public WxProfitPaymentReceiver getById(Long id) {
return wxProfitPaymentReceiverMapper.selectById(id);
}

@Override
public void saveOrUpdate(WxProfitPaymentReceiver record) {
Date date = new Date();
if (record.getId() == null) {
//record.setId(UUID.randomUUID().toString().replaceAll("-", ""));
final IdWorker idWorker = IdWorker.get();
record.setId(idWorker.nextId());
record.setCreateTime(date);
record.setUpdateTime(date);
wxProfitPaymentReceiverMapper.insert(record);
} else {
record.setUpdateTime(date);
wxProfitPaymentReceiverMapper.updateById(record);
this.deleteRedis(record.getId());
}
}

// @Override
// public void deleteById(Long id) {
// wxProfitPaymentReceiverMapper.deleteById(id);
// }


@Override
public WxProfitPaymentReceiver findReceiver(TenantEntity tenantEntity,Long merchantId, EnumAppPlat plat,EnumProfitPaymentReceiverType receiverType) {
WxProfitPaymentReceiver record = null;
String key = Constant.paymentReceicerPrev + tenantEntity.getTenantId()
+ ":" + plat.getCode()
+ ":" + merchantId
+ ":" + receiverType.getCode();
record = RedisCacheUtils.getCacheObject(paymentReceicerRedisTemplate, key, WxProfitPaymentReceiver.class);
if(record == null){
WxProfitPaymentReceiver receiver = new WxProfitPaymentReceiver();
receiver.updateTenantInfo(tenantEntity);
receiver.setMerchantId(merchantId);
receiver.setPlat(plat.getCode());
receiver.setReceiverType(receiverType.getCode());
receiver.setStatus(EnumProfitSharingReceiverStatus.PROFIT_SHARING_RECEIVER_STATUS_VALID.getCode());
record = wxProfitPaymentReceiverMapper.findOne(receiver);
if(record != null){
RedisCacheUtils.cache(paymentReceicerRedisTemplate, key, record, 3600*24*7);
}
}
return record;

}


@Override
public ResultData updateTtReceiver(WxMerchant merchant) {
if(merchant == null) {
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"请检查传递参数");
}
WxProfitPaymentReceiver wxProfitPaymentReceiver = getTtPaymentReceiver(merchant);

//进件页面
AppAddSubMerchantResult improt_URLResult = appAddSubMerchant(merchant,merchant.getId().toString(),AppAddSubMerchantUrlType.improt_URL);
if(improt_URLResult.isSuccess()){
wxProfitPaymentReceiver.setReceiverAccount(improt_URLResult.getMerchantId());
wxProfitPaymentReceiver.setTtImportUrl(improt_URLResult.getUrl());
}else{
logger.error("获取进件页面 error{}"+improt_URLResult.getMsg());
}
//余额页面
AppAddSubMerchantResult balance_URLResult = appAddSubMerchant(merchant,merchant.getId().toString(),AppAddSubMerchantUrlType.Balance_URL);
if(balance_URLResult.isSuccess()){
wxProfitPaymentReceiver.setReceiverAccount(balance_URLResult.getMerchantId());
wxProfitPaymentReceiver.setTtBalanceUrl(balance_URLResult.getUrl());
}else{
logger.error("获取余额页面 error{}"+balance_URLResult.getMsg());
}
this.saveOrUpdate(wxProfitPaymentReceiver);
return new ResultData();
}

@Override
public ResultData getTtReceiverImprotURL(WxMerchant merchant) {
if(merchant == null) {
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"请检查传递参数");
}
WxProfitPaymentReceiver wxProfitPaymentReceiver = getTtPaymentReceiver(merchant);
//进件页面
AppAddSubMerchantResult improt_URLResult = appAddSubMerchant(merchant,merchant.getId().toString(),AppAddSubMerchantUrlType.improt_URL);
if(improt_URLResult.isSuccess()){
wxProfitPaymentReceiver.setReceiverAccount(improt_URLResult.getMerchantId());
wxProfitPaymentReceiver.setTtImportUrl(improt_URLResult.getUrl());
this.saveOrUpdate(wxProfitPaymentReceiver);
return new ResultData(wxProfitPaymentReceiver.getTtImportUrl());
}else{
logger.error("获取进件页面 error{}"+improt_URLResult.getMsg());
return new ResultData(ErrorCode.SYS_SERVER_ERROR);
}
}

@Override
public ResultData getTtReceiverBalanceURL(WxMerchant merchant) {
if(merchant == null) {
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"请检查传递参数");
}
WxProfitPaymentReceiver wxProfitPaymentReceiver = getTtPaymentReceiver(merchant);
//余额页面
AppAddSubMerchantResult balance_URLResult = appAddSubMerchant(merchant,merchant.getId().toString(),AppAddSubMerchantUrlType.Balance_URL);
if(balance_URLResult.isSuccess()){
wxProfitPaymentReceiver.setReceiverAccount(balance_URLResult.getMerchantId());
wxProfitPaymentReceiver.setTtBalanceUrl(balance_URLResult.getUrl());
this.saveOrUpdate(wxProfitPaymentReceiver);
return new ResultData(wxProfitPaymentReceiver.getTtBalanceUrl());
}else{
logger.error("获取余额页面 error{}"+balance_URLResult.getMsg());
return new ResultData(ErrorCode.SYS_SERVER_ERROR);
}
}

private WxProfitPaymentReceiver getTtPaymentReceiver(WxMerchant merchant){
WxProfitPaymentReceiver receiver = new WxProfitPaymentReceiver();
receiver.updateTenantInfo(merchant);
receiver.setMerchantId(merchant.getId());
receiver.setReceiverType(EnumProfitPaymentReceiverType.tt_merchant_number.getCode());
receiver.setPlat(EnumAppPlat.TOUTIAO.getCode());
receiver.setStatus(EnumProfitSharingReceiverStatus.PROFIT_SHARING_RECEIVER_STATUS_VALID.getCode());
WxProfitPaymentReceiver wxProfitPaymentReceiver = wxProfitPaymentReceiverMapper.selectOne(new QueryWrapper(receiver));
if(wxProfitPaymentReceiver == null){
receiver.setReceiverAccount("0");
this.saveOrUpdate(receiver);
return receiver;
}
return wxProfitPaymentReceiver;
}

@Override
public ResultData updateTtReceiverImportStatus(WxMerchant merchant) {
if(merchant == null) {
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"请检查传递参数");
}
WxAppinfo appInfo = wxAppinfoService.getCAppInfoFromRedis(merchant.getTenantId(), EnumAppPlat.TOUTIAO);
if(appInfo == null){
throw new MallinkException(ErrorCode.APP_ID_NOT_FOUND);
}
WxPayAccount payAcount = wxPayAccountService.getByIdFromRedis(appInfo.getPayId());
if(payAcount == null){
throw new MallinkException(ErrorCode.API_KEY_NOT_FOUND);
}

WxProfitPaymentReceiver receiver = new WxProfitPaymentReceiver();
receiver.updateTenantInfo(merchant);
receiver.setMerchantId(merchant.getId());
receiver.setReceiverType(EnumProfitPaymentReceiverType.tt_merchant_number.getCode());
receiver.setPlat(EnumAppPlat.TOUTIAO.getCode());
receiver.setStatus(EnumProfitSharingReceiverStatus.PROFIT_SHARING_RECEIVER_STATUS_VALID.getCode());
WxProfitPaymentReceiver wxProfitPaymentReceiver = wxProfitPaymentReceiverMapper.selectOne(new QueryWrapper(receiver));
if(wxProfitPaymentReceiver == null){
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"未找到收款信息");
}

QueryMerchantResult queryMerchantResult = DouYinPayHelper.queryMerchantStatus(appInfo.getAppId(), payAcount.getMerchantApiKey(), wxProfitPaymentReceiver.getReceiverAccount(), wxProfitPaymentReceiver.getMerchantId().toString(), null);
if(queryMerchantResult != null){
wxProfitPaymentReceiver.setTtImportStatus(JSON.toJSONString(queryMerchantResult));
this.saveOrUpdate(wxProfitPaymentReceiver);
return new ResultData();
}else{
return new ResultData(ErrorCode.SYS_SERVER_ERROR.getCode(),"查询进件状态出错!");
}
}

private AppAddSubMerchantResult appAddSubMerchant(TenantEntity tenantEntity, String merchantId, AppAddSubMerchantUrlType appAddSubMerchantUrlType){
WxAppinfo appInfo = wxAppinfoService.getCAppInfoFromRedis(tenantEntity.getTenantId(), EnumAppPlat.TOUTIAO);
if(appInfo == null){
throw new MallinkException(ErrorCode.APP_ID_NOT_FOUND);
}
WxPayAccount payAcount = wxPayAccountService.getByIdFromRedis(appInfo.getPayId());
if(payAcount == null){
throw new MallinkException(ErrorCode.API_KEY_NOT_FOUND);
}
AppAddSubMerchant appAddSubMerchant = new AppAddSubMerchant();
appAddSubMerchant.setAppId(appInfo.getAppId());
appAddSubMerchant.setSalt(payAcount.getMerchantApiKey());
appAddSubMerchant.setSubMerchantId(merchantId);
appAddSubMerchant.setUrlType(appAddSubMerchantUrlType.getCode());
return DouYinPayHelper.appAddSubMerchant(appAddSubMerchant);
}

@Override
@Transactional(rollbackFor = {Exception.class})
public ResultData updateReceiver(WxProfitPaymentReceiver receiver) {

if(receiver.getMerchantId() == null){
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"缺少商户信息");
}
if(receiver.getPlat() == null){
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"缺少平台信息");
}
if(receiver.getReceiverType() == null){
receiver.setReceiverType(EnumProfitPaymentReceiverType.wx_special_merchant_number.getCode());
}

WxProfitPaymentReceiver receiverQ = new WxProfitPaymentReceiver();
receiverQ.updateTenantInfo(receiver);
receiverQ.setMerchantId(receiver.getMerchantId());
receiverQ.setReceiverAccount(receiver.getReceiverAccount());
//
WxProfitPaymentReceiver paymentReceiver = wxProfitPaymentReceiverMapper.selectOne(new QueryWrapper(receiverQ));
if(paymentReceiver != null){
receiver.setId(paymentReceiver.getId());
receiver.setStatus(EnumProfitSharingReceiverStatus.PROFIT_SHARING_RECEIVER_STATUS_VALID.getCode());
this.saveOrUpdate(receiver);
}else{
WxProfitPaymentReceiver oldReceiver = new WxProfitPaymentReceiver();
oldReceiver.updateTenantInfo(receiver);
oldReceiver.setMerchantId(receiver.getMerchantId());
oldReceiver.setReceiverType(receiver.getReceiverType());
oldReceiver.setPlat(receiver.getPlat());
oldReceiver.setStatus(EnumProfitSharingReceiverStatus.PROFIT_SHARING_RECEIVER_STATUS_VALID.getCode());
List<WxProfitPaymentReceiver> oldList = wxProfitPaymentReceiverMapper.selectList(new QueryWrapper(oldReceiver));

receiver.setId(null);
receiver.setStatus(EnumProfitSharingReceiverStatus.PROFIT_SHARING_RECEIVER_STATUS_VALID.getCode());
this.saveOrUpdate(receiver);

if(oldList != null && oldList.size() > 0){
for (WxProfitPaymentReceiver delReceiver:oldList) {
WxProfitPaymentReceiver del = new WxProfitPaymentReceiver();
del.setId(delReceiver.getId());
del.updateTenantInfo(delReceiver);
del.setStatus(EnumProfitSharingReceiverStatus.PROFIT_SHARING_RECEIVER_STATUS_INVALID.getCode());
this.saveOrUpdate(del);
}
}
}

return new ResultData();
}

private void deleteRedis(Long id){
WxProfitPaymentReceiver receiver = wxProfitPaymentReceiverMapper.selectById(id);
if(receiver != null){
String key = Constant.paymentReceicerPrev + receiver.getTenantId()
+ ":" + receiver.getPlat()
+ ":" + receiver.getMerchantId()
+ ":" + receiver.getReceiverType();
RedisCacheUtils.removeCache(paymentReceicerRedisTemplate, key);
}
}
}

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

@@ -161,7 +161,7 @@ public class WxProfitSharingOrderServiceImpl implements WxProfitSharingOrderServ
merchantQ.setStatus(EnumMerchantStatus.VALID.getCode());
WxMerchant merchant = wxMerchantService.findListOne(merchantQ);
if(merchant != null && !merchant.getId().equals(payMerchantId)){
return payShareAdapterService.getReceiver(tenantEntity, merchant.getId(), ttPayWay, mchType);
return payShareAdapterService.getSharingReceiver(tenantEntity, merchant.getId(), ttPayWay, mchType);
}
return null;
}
@@ -332,7 +332,7 @@ public class WxProfitSharingOrderServiceImpl implements WxProfitSharingOrderServ
isSharingResult = true;
}else{
isCallSharing = true;
WxProfitSharingReceiver receiver = payShareAdapterService.getReceiver(merchant,sharingOrder.getMerchantId(),payOrder.getTtPayWay(),payOrder.getMchType());
WxProfitSharingReceiver receiver = payShareAdapterService.getSharingReceiver(merchant,sharingOrder.getMerchantId(),payOrder.getTtPayWay(),payOrder.getMchType());
if(EnumPayMchType.TOTAL.getCode().equals(payOrder.getMchType()) && EnumPayShare.YES.getCode().equals(payOrder.getShare())){
//总分 分账 抖音不支持 不支持开通
JSONObject jo = new JSONObject();
@@ -427,7 +427,7 @@ public class WxProfitSharingOrderServiceImpl implements WxProfitSharingOrderServ
if(EnumPayMchType.TOTAL.getCode().equals(payOrder.getMchType())){
//解冻给收款方(广场)
JSONObject jo = new JSONObject();
jo.put("type",EnumProfitSharingReceiverType.PROFIT_SHARING_RECEIVER_MERCHANT_ID.getMessage());
jo.put("type",EnumProfitPaymentReceiverType.wx_special_merchant_number.getMessage());
jo.put("account",payAccount.getSubMchId());
jo.put("amount", shareAmount);
jo.put("merchantId",0);
@@ -435,7 +435,7 @@ public class WxProfitSharingOrderServiceImpl implements WxProfitSharingOrderServ
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());
WxProfitPaymentReceiver receiver = payShareAdapterService.getPaymantReceiver(sharingOrder,wxComposeChildOrderShare.getMerchantId());
//解冻给收款方(门店)
JSONObject jo = new JSONObject();
jo.put("type",payShareAdapterService.getShareAccount(receiver.getReceiverType()).getMessage());


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

@@ -39,7 +39,7 @@ public class WxProfitSharingReceiverApplyServiceImpl implements WxProfitSharingR
WxProfitSharingReceiverApplyMapper wxProfitSharingReceiverApplyMapper;

@Autowired
WxProfitSharingReceiverService wxProfitSharingReceiverService;
WxProfitPaymentReceiverService wxProfitPaymentReceiverService;

@Autowired
WxAppinfoService wxAppinfoService;
@@ -189,21 +189,13 @@ public class WxProfitSharingReceiverApplyServiceImpl implements WxProfitSharingR
receiverApplyUpd.setUpdateTime(new Date());
wxProfitSharingReceiverApplyMapper.updateById(receiverApplyUpd);
if(enumApplymentState.equals(EnumSharingReceiverApplymentState.APPLYMENT_STATE_FINISHED)){
WxProfitSharingReceiver receiver = wxProfitSharingReceiverService.findReceiver(receiverApply, receiverApply.getMerchantId(), EnumAppPlat.WX, EnumProfitSharingType.PROFIT_SHARING_TYPE_WECHAT_v2);
WxProfitSharingReceiver receiverUpd = new WxProfitSharingReceiver();
receiverUpd.updateTenantInfo(receiverApply);
if(receiver != null){
receiverUpd.setId(receiver.getId());
receiverUpd.setReceiverAccount(receiverApplyUpd.getSubMchid());
}else{
receiverUpd.setPlat(EnumAppPlat.WX.getCode());
receiverUpd.setMerchantId(receiverApply.getMerchantId());
receiverUpd.setReceiverType(EnumProfitSharingReceiverType.PROFIT_SHARING_RECEIVER_MERCHANT_ID.getCode());
receiverUpd.setReceiverAccount(receiverApplyUpd.getSubMchid());
receiverUpd.setSharingType(EnumProfitSharingType.PROFIT_SHARING_TYPE_WECHAT_v2.getCode());
receiverUpd.setStatus(EnumProfitSharingReceiverStatus.PROFIT_SHARING_RECEIVER_STATUS_VALID.getCode());
}
wxProfitSharingReceiverService.saveOrUpdate(receiverUpd);
WxProfitPaymentReceiver receiver = new WxProfitPaymentReceiver();
receiver.updateTenantInfo(receiverApply);
receiver.setMerchantId(receiverApply.getMerchantId());
receiver.setPlat(EnumAppPlat.WX.getCode());
receiver.setReceiverType(EnumProfitPaymentReceiverType.tt_merchant_number.getCode());
receiver.setReceiverAccount(receiverApplyUpd.getSubMchid());
wxProfitPaymentReceiverService.updateReceiver(receiver);
}

receiverApply.setSubMchid(receiverApplyUpd.getSubMchid());


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

@@ -124,20 +124,23 @@ public class WxProfitSharingReceiverServiceImpl implements WxProfitSharingReceiv


@Override
public WxProfitSharingReceiver findReceiver(TenantEntity tenantEntity,Long merchantId, EnumAppPlat plat,EnumProfitSharingType sharingType) {
public WxProfitSharingReceiver findReceiver(TenantEntity tenantEntity,Long merchantId, EnumAppPlat plat) {
WxProfitSharingReceiver record = null;
String key = Constant.sharingReceicerPrev + tenantEntity.getTenantId()
+ ":" + merchantId
+ ":" + plat.getCode() + "a" + sharingType.getCode();
+ ":" + plat.getCode()
+ ":" + merchantId;
record = RedisCacheUtils.getCacheObject(sharingReceicerRedisTemplate, key, WxProfitSharingReceiver.class);
if(record == null){
WxProfitSharingReceiver receiver = new WxProfitSharingReceiver();
receiver.updateTenantInfo(tenantEntity);
receiver.setMerchantId(merchantId);
receiver.setPlat(plat.getCode());
receiver.setSharingType(sharingType.getCode());
receiver.setSharingType(EnumProfitSharingType.PROFIT_SHARING_TYPE_SYS.getCode());
receiver.setStatus(EnumProfitSharingReceiverStatus.PROFIT_SHARING_RECEIVER_STATUS_VALID.getCode());
record = wxProfitSharingReceiverMapper.findOne(receiver);
List<WxProfitSharingReceiver> receivers = wxProfitSharingReceiverMapper.findList(receiver);
if(receivers != null && receivers.size() > 0){
record = receivers.get(0);
}
if(record != null){
RedisCacheUtils.cache(sharingReceicerRedisTemplate, key, record, 3600*24*7);
}
@@ -156,14 +159,14 @@ public class WxProfitSharingReceiverServiceImpl implements WxProfitSharingReceiv
}

@Override
public ResultData addReceiver(WxMerchant merchant, WxProfitSharingReceiver receiver, List<WxProfitSharingReceiver> delList, boolean isSync) {
public ResultData addReceiver(WxMerchant merchant, WxProfitSharingReceiver receiver, List<WxProfitSharingReceiver> delList) {

WxAppinfo appInfo = wxAppinfoService.getCAppInfo(merchant,EnumAppPlat.WX);
WxPayAccount payAccount = wxPayAccountService.getById(appInfo.getPayId());

receiver.updateTenantInfo(merchant);
receiver.setMerchantId(merchant.getId());
receiver.setSharingType(EnumProfitSharingType.PROFIT_SHARING_TYPE_WECHAT.getCode());
receiver.setSharingType(EnumProfitSharingType.PROFIT_SHARING_TYPE_SYS.getCode());
receiver.setId(IdWorker.get().nextId());
Date date = new Date();
receiver.setCreateTime(date);
@@ -177,20 +180,18 @@ public class WxProfitSharingReceiverServiceImpl implements WxProfitSharingReceiv
//receiver.setReceiverType(receiverParam.getReceiverType());
//receiver.setTrueName(receiverParam.getTrueName());

if(isSync){
//添加分账账户
ShareAccountResult createResult = payServiceFactory.getPayShareAdapterService(EnumPayWay.PAY_WAY_WECHAT.getCode(),payAccount.getPayVersion())
.createShareAccount(appInfo, payAccount, receiver);
if (!createResult.isSuccess()) {
return new ResultData(createResult.getCode(), createResult.getMsg());
}
//添加分账账户
ShareAccountResult createResult = payServiceFactory.getPayShareAdapterService(EnumPayWay.PAY_WAY_WECHAT.getCode(),payAccount.getPayVersion())
.createShareAccount(appInfo, payAccount, receiver);
if (!createResult.isSuccess()) {
return new ResultData(createResult.getCode(), createResult.getMsg());
}
wxProfitSharingReceiverMapper.insert(receiver);

//添加成功才删除账户
for (WxProfitSharingReceiver delReceiver : delList) {
delReceiver(delReceiver, EnumMsgSend.MSG_SEND_NOT_IMMEDIATELY.getCode(),isSync);
delReceiver(delReceiver, EnumMsgSend.MSG_SEND_NOT_IMMEDIATELY.getCode());
}

WxProfitSharingReceiver wxProfitSharingReceiver = new WxProfitSharingReceiver();
@@ -269,148 +270,7 @@ public class WxProfitSharingReceiverServiceImpl implements WxProfitSharingReceiv
}

@Override
public ResultData updateTtReceiver(WxMerchant merchant) {
if(merchant == null) {
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"请检查传递参数");
}
WxProfitSharingReceiver wxProfitSharingReceiver = getTtSharingReceiver(merchant);

//进件页面
AppAddSubMerchantResult improt_URLResult = appAddSubMerchant(merchant,merchant.getId().toString(),AppAddSubMerchantUrlType.improt_URL);
if(improt_URLResult.isSuccess()){
wxProfitSharingReceiver.setReceiverAccount(improt_URLResult.getMerchantId());
wxProfitSharingReceiver.setTtImportUrl(improt_URLResult.getUrl());
}else{
logger.error("获取进件页面 error{}"+improt_URLResult.getMsg());
}
//余额页面
AppAddSubMerchantResult balance_URLResult = appAddSubMerchant(merchant,merchant.getId().toString(),AppAddSubMerchantUrlType.Balance_URL);
if(balance_URLResult.isSuccess()){
wxProfitSharingReceiver.setReceiverAccount(balance_URLResult.getMerchantId());
wxProfitSharingReceiver.setTtBalanceUrl(balance_URLResult.getUrl());
}else{
logger.error("获取余额页面 error{}"+balance_URLResult.getMsg());
}
this.saveOrUpdate(wxProfitSharingReceiver);
return new ResultData();
}

@Override
public ResultData getTtReceiverImprotURL(WxMerchant merchant) {
if(merchant == null) {
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"请检查传递参数");
}
WxProfitSharingReceiver wxProfitSharingReceiver = getTtSharingReceiver(merchant);
//进件页面
AppAddSubMerchantResult improt_URLResult = appAddSubMerchant(merchant,merchant.getId().toString(),AppAddSubMerchantUrlType.improt_URL);
if(improt_URLResult.isSuccess()){
wxProfitSharingReceiver.setReceiverAccount(improt_URLResult.getMerchantId());
wxProfitSharingReceiver.setTtImportUrl(improt_URLResult.getUrl());
this.saveOrUpdate(wxProfitSharingReceiver);
return new ResultData(wxProfitSharingReceiver.getTtImportUrl());
}else{
logger.error("获取进件页面 error{}"+improt_URLResult.getMsg());
return new ResultData(ErrorCode.SYS_SERVER_ERROR);
}
}

@Override
public ResultData getTtReceiverBalanceURL(WxMerchant merchant) {
if(merchant == null) {
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"请检查传递参数");
}
WxProfitSharingReceiver wxProfitSharingReceiver = getTtSharingReceiver(merchant);
//余额页面
AppAddSubMerchantResult balance_URLResult = appAddSubMerchant(merchant,merchant.getId().toString(),AppAddSubMerchantUrlType.Balance_URL);
if(balance_URLResult.isSuccess()){
wxProfitSharingReceiver.setReceiverAccount(balance_URLResult.getMerchantId());
wxProfitSharingReceiver.setTtBalanceUrl(balance_URLResult.getUrl());
this.saveOrUpdate(wxProfitSharingReceiver);
return new ResultData(wxProfitSharingReceiver.getTtBalanceUrl());
}else{
logger.error("获取余额页面 error{}"+balance_URLResult.getMsg());
return new ResultData(ErrorCode.SYS_SERVER_ERROR);
}
}

private WxProfitSharingReceiver getTtSharingReceiver(WxMerchant merchant){
WxProfitSharingReceiver oldReceiver = new WxProfitSharingReceiver();
oldReceiver.updateTenantInfo(merchant);
oldReceiver.setMerchantId(merchant.getId());
oldReceiver.setSharingType(EnumProfitSharingType.PROFIT_SHARING_TYPE_DOUYIN.getCode());
oldReceiver.setPlat(EnumAppPlat.TOUTIAO.getCode());
WxProfitSharingReceiver wxProfitSharingReceiver = wxProfitSharingReceiverMapper.selectOne(new QueryWrapper(oldReceiver));
if(wxProfitSharingReceiver == null){
wxProfitSharingReceiver = oldReceiver;
wxProfitSharingReceiver.setReceiverType(EnumProfitSharingReceiverType.PROFIT_SHARING_RECEIVER_MERCHANT_ID.getCode());
wxProfitSharingReceiver.setReceiverAccount("0");
// wxProfitSharingReceiver.setIsUse(EnumProfitSharingUse.APPLY.getCode());
wxProfitSharingReceiver.setStatus(EnumProfitSharingReceiverStatus.PROFIT_SHARING_RECEIVER_STATUS_VALID.getCode());
this.saveOrUpdate(wxProfitSharingReceiver);
}
return wxProfitSharingReceiver;
}

@Override
public ResultData updateTtReceiverIsUse(WxMerchant merchant) {
if(merchant == null) {
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"请检查传递参数");
}
WxAppinfo appInfo = wxAppinfoService.getCAppInfoFromRedis(merchant.getTenantId(), EnumAppPlat.TOUTIAO);
if(appInfo == null){
throw new MallinkException(ErrorCode.APP_ID_NOT_FOUND);
}
WxPayAccount payAcount = wxPayAccountService.getByIdFromRedis(appInfo.getPayId());
if(payAcount == null){
throw new MallinkException(ErrorCode.API_KEY_NOT_FOUND);
}

WxProfitSharingReceiver oldReceiver = new WxProfitSharingReceiver();
oldReceiver.updateTenantInfo(merchant);
oldReceiver.setMerchantId(merchant.getId());
oldReceiver.setSharingType(EnumProfitSharingType.PROFIT_SHARING_TYPE_DOUYIN.getCode());
oldReceiver.setPlat(EnumAppPlat.TOUTIAO.getCode());
WxProfitSharingReceiver wxProfitSharingReceiver = wxProfitSharingReceiverMapper.selectOne(new QueryWrapper(oldReceiver));
if(wxProfitSharingReceiver == null){
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"未找到分账信息");
}

QueryMerchantResult queryMerchantResult = DouYinPayHelper.queryMerchantStatus(appInfo.getAppId(), payAcount.getMerchantApiKey(), wxProfitSharingReceiver.getReceiverAccount(), wxProfitSharingReceiver.getMerchantId().toString(), null);
if(queryMerchantResult != null){
// if(queryMerchantResult.getWx().intValue() != 1){
// return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"微信渠道未进件成功!");
// }
// if(queryMerchantResult.getAlipay().intValue() != 1){
// return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"支付宝渠道未进件成功!");
// }
// wxProfitSharingReceiver.setIsUse(EnumProfitSharingUse.YES.getCode());
wxProfitSharingReceiver.setTtImportStatus(JSON.toJSONString(queryMerchantResult));
this.saveOrUpdate(wxProfitSharingReceiver);
return new ResultData();
}else{
return new ResultData(ErrorCode.SYS_SERVER_ERROR.getCode(),"查询进件状态出错!");
}
}

private AppAddSubMerchantResult appAddSubMerchant(TenantEntity tenantEntity, String merchantId, AppAddSubMerchantUrlType appAddSubMerchantUrlType){
WxAppinfo appInfo = wxAppinfoService.getCAppInfoFromRedis(tenantEntity.getTenantId(), EnumAppPlat.TOUTIAO);
if(appInfo == null){
throw new MallinkException(ErrorCode.APP_ID_NOT_FOUND);
}
WxPayAccount payAcount = wxPayAccountService.getByIdFromRedis(appInfo.getPayId());
if(payAcount == null){
throw new MallinkException(ErrorCode.API_KEY_NOT_FOUND);
}
AppAddSubMerchant appAddSubMerchant = new AppAddSubMerchant();
appAddSubMerchant.setAppId(appInfo.getAppId());
appAddSubMerchant.setSalt(payAcount.getMerchantApiKey());
appAddSubMerchant.setSubMerchantId(merchantId);
appAddSubMerchant.setUrlType(appAddSubMerchantUrlType.getCode());
return DouYinPayHelper.appAddSubMerchant(appAddSubMerchant);
}

@Override
public ResultData delReceiver(WxProfitSharingReceiver receiver, Integer send, boolean isSync) {
public ResultData delReceiver(WxProfitSharingReceiver receiver, Integer send) {

// WxAppinfo appInfo = wxAppinfoService.getCAppInfo(receiver,EnumAppPlat.WX);
// WxPayAccount payAccount = wxPayAccountService.getById(appInfo.getPayId());
@@ -434,13 +294,11 @@ public class WxProfitSharingReceiverServiceImpl implements WxProfitSharingReceiv
))) {
//还有别的商户使用这个账号,不从微信服务器申请删除
} else {
if(isSync){
WxAppinfo appInfo = wxAppinfoService.getCAppInfo(receiver,EnumAppPlat.WX);
WxPayAccount payAccount = wxPayAccountService.getById(appInfo.getPayId());
ShareAccountResult shareResult = payServiceFactory.getPayShareAdapterService(receiver.getPlat(),payAccount.getPayVersion()).deleteShareAccount(appInfo, payAccount, receiver);
if (!shareResult.isSuccess()) {
return new ResultData(shareResult.getCode(), shareResult.getMsg());
}
WxAppinfo appInfo = wxAppinfoService.getCAppInfo(receiver,EnumAppPlat.WX);
WxPayAccount payAccount = wxPayAccountService.getById(appInfo.getPayId());
ShareAccountResult shareResult = payServiceFactory.getPayShareAdapterService(receiver.getPlat(),payAccount.getPayVersion()).deleteShareAccount(appInfo, payAccount, receiver);
if (!shareResult.isSuccess()) {
return new ResultData(shareResult.getCode(), shareResult.getMsg());
}
}

@@ -457,12 +315,12 @@ public class WxProfitSharingReceiverServiceImpl implements WxProfitSharingReceiv
}

@Override
public ResultData updateReceiver(WxMerchant merchant, WxProfitSharingReceiver receiver,boolean isSync) {
public ResultData updateReceiver(WxMerchant merchant, WxProfitSharingReceiver receiver) {

WxProfitSharingReceiver oldReceiver = new WxProfitSharingReceiver();
oldReceiver.updateTenantInfo(merchant);
oldReceiver.setMerchantId(merchant.getId());
oldReceiver.setSharingType(EnumProfitSharingType.PROFIT_SHARING_TYPE_WECHAT.getCode());
oldReceiver.setSharingType(EnumProfitSharingType.PROFIT_SHARING_TYPE_SYS.getCode());
oldReceiver.setStatus(EnumProfitSharingReceiverStatus.PROFIT_SHARING_RECEIVER_STATUS_VALID.getCode());
oldReceiver.setPlat(EnumAppPlat.WX.getCode());
List<WxProfitSharingReceiver> delList = wxProfitSharingReceiverMapper.selectList(new QueryWrapper(oldReceiver));
@@ -472,7 +330,7 @@ public class WxProfitSharingReceiverServiceImpl implements WxProfitSharingReceiv
oldReceiver = wxProfitSharingReceiverMapper.selectOne(new QueryWrapper(oldReceiver));

if (oldReceiver == null) {
return addReceiver(merchant, receiver, delList, isSync);
return addReceiver(merchant, receiver, delList);
} else {
oldReceiver.setParameter(receiver.getParameter());
oldReceiver.setUpdateTime(new Date());
@@ -486,8 +344,8 @@ public class WxProfitSharingReceiverServiceImpl implements WxProfitSharingReceiv
WxProfitSharingReceiver receiver = wxProfitSharingReceiverMapper.selectById(id);
if(receiver != null){
String key = Constant.sharingReceicerPrev + receiver.getTenantId()
+ ":" + receiver.getMerchantId()
+ ":" + receiver.getPlat() + "a" + receiver.getSharingType();
+ ":" + receiver.getPlat()
+ ":" + receiver.getMerchantId();
RedisCacheUtils.removeCache(sharingReceicerRedisTemplate, key);
}
}


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

@@ -39,6 +39,14 @@ public interface PayShareAdapterService {
*/
// public PayShareCalculateAmount calculateAmount(Integer payAmount,Integer officialCommissionRate,Integer systemAmount,WxPayAccount payAccount);
/**
* 查询商户的收款账号信息
* @param tenantEntity
* @param merchantId
* @return
*/
WxProfitPaymentReceiver getPaymantReceiver(TenantEntity tenantEntity, Long merchantId);

/**
* 查询商户的收款账号信息
* @param tenantEntity
@@ -46,7 +54,7 @@ public interface PayShareAdapterService {
* @param ttPayWay
* @return
*/
WxProfitSharingReceiver getReceiver(TenantEntity tenantEntity, Long merchantId, Integer ttPayWay,Integer mchType);
WxProfitSharingReceiver getSharingReceiver(TenantEntity tenantEntity, Long merchantId, Integer ttPayWay,Integer mchType);
/**
* 无分账接收方分账 ,钱直接分给小程序方 调用API分账


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

@@ -22,6 +22,7 @@ import com.iformall.douyin.payv2.result.ProfitSharingResult;
import com.iformall.enums.*;
import com.iformall.exception.MallinkException;
import com.iformall.mapper.*;
import com.iformall.service.WxProfitPaymentReceiverService;
import com.iformall.service.WxProfitSharingReceiverService;
import com.iformall.service.order.entity.WxComposeChildOrderShare;
import com.iformall.service.order.util.OrderHelper;
@@ -78,6 +79,10 @@ public class TtPayShareService extends PayShareBaseAdapterService{
@Autowired
WxProfitSharingReceiverService wxProfitSharingReceiverService;

@Lazy
@Autowired
WxProfitPaymentReceiverService wxProfitPaymentReceiverService;

/**
* 做为分账的扩展数据
* @param payOrder
@@ -94,6 +99,7 @@ public class TtPayShareService extends PayShareBaseAdapterService{
return EnumMerchantSubsidyType.DOUYIN.getCode();
}


// @Override
// public Integer getSharingOrderInitialStatus() {
// return EnumProfitSharingOrderStatus.PROFIT_SHARING_UNKNOWN.getCode();
@@ -308,12 +314,12 @@ public class TtPayShareService extends PayShareBaseAdapterService{
}

@Override
public WxProfitSharingReceiver getReceiver(TenantEntity tenantEntity, Long merchantId, Integer ttPayWay,Integer mchType) {
public WxProfitSharingReceiver getSharingReceiver(TenantEntity tenantEntity, Long merchantId, Integer ttPayWay,Integer mchType) {
if(merchantId == null || merchantId.equals(0L)){
return null;
}
WxProfitSharingReceiver record = wxProfitSharingReceiverService.findReceiver(tenantEntity, merchantId,EnumAppPlat.TOUTIAO,EnumProfitSharingType.PROFIT_SHARING_TYPE_DOUYIN);
WxProfitSharingReceiver record = wxProfitSharingReceiverService.findReceiver(tenantEntity, merchantId,EnumAppPlat.TOUTIAO);

if(ttPayWay != null){
if(EnumTtPayChannel.WX_PAY.getCode().equals(ttPayWay)
@@ -334,4 +340,20 @@ public class TtPayShareService extends PayShareBaseAdapterService{

}

@Override
public WxProfitPaymentReceiver getPaymantReceiver(TenantEntity tenantEntity, Long merchantId) {
if(merchantId == null || merchantId.equals(0L)){
return null;
}

WxProfitPaymentReceiver record = wxProfitPaymentReceiverService.findReceiver(tenantEntity, merchantId,EnumAppPlat.TOUTIAO,EnumProfitPaymentReceiverType.tt_merchant_number);
if(record != null && !MerchantImportStatus.improt_success.getCode().equals(record.getWxImportStatus())
&& !MerchantImportStatus.improt_success.getCode().equals(record.getAlipayImportStatus())
&& !MerchantImportStatus.improt_success.getCode().equals(record.getHzImportStatus())){
log.error("该商户未开通支付");
return null;
}
return record;
}

}

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

@@ -156,9 +156,14 @@ public class WxPayShareSFTService extends PayShareBaseAdapterService{
}

@Override
public WxProfitSharingReceiver getReceiver(TenantEntity tenantEntity, Long merchantId, Integer ttPayWay,Integer mchType) {
public WxProfitSharingReceiver getSharingReceiver(TenantEntity tenantEntity, Long merchantId, Integer ttPayWay,Integer mchType) {
return null;
}

@Override
public WxProfitPaymentReceiver getPaymantReceiver(TenantEntity tenantEntity, Long merchantId) {
return null;
}

}

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

@@ -12,6 +12,7 @@ import com.iformall.douyin.pay.enums.MerchantImportStatus;
import com.iformall.enums.*;
import com.iformall.mapper.*;

import com.iformall.service.WxProfitPaymentReceiverService;
import com.iformall.service.WxProfitSharingReceiverService;
import com.iformall.utils.*;
import net.sf.saxon.trans.Err;
@@ -52,6 +53,10 @@ public class WxPayShareService extends PayShareBaseAdapterService{
@Autowired
WxProfitSharingReceiverService wxProfitSharingReceiverService;

@Autowired
WxProfitPaymentReceiverService wxProfitPaymentReceiverService;


final JSONObject statusMap = JSON.parseObject(
"{\"ACCEPTED\":3," +
"\"PROCESSING\": 4," +
@@ -356,17 +361,26 @@ public class WxPayShareService extends PayShareBaseAdapterService{
}

@Override
public WxProfitSharingReceiver getReceiver(TenantEntity tenantEntity, Long merchantId, Integer ttPayWay,Integer mchType) {
public WxProfitSharingReceiver getSharingReceiver(TenantEntity tenantEntity, Long merchantId, Integer ttPayWay,Integer mchType) {
if(merchantId == null || merchantId.equals(0L)){
return null;
}
WxProfitSharingReceiver record = wxProfitSharingReceiverService.findReceiver(tenantEntity, merchantId,EnumAppPlat.WX,EnumProfitSharingType.PROFIT_SHARING_TYPE_WECHAT);
if(record != null && EnumProfitSharingReceiverType.PROFIT_SHARING_RECEIVER_PERSONAL_WECHATID.getCode().equals(record.getReceiverType())){
WxProfitSharingReceiver record = wxProfitSharingReceiverService.findReceiver(tenantEntity, merchantId,EnumAppPlat.WX);
if(record != null && EnumProfitPaymentReceiverType.wx_personal_wechatid.getCode().equals(record.getReceiverType())){
throw new MallinkException(ErrorCode.PROFIT_SHARING_RECEIVER_INVALID.getCode(),"该商户收款账号存在个人微信号方式,微信已停止支持,请重新设置.");
}
return record;
}

@Override
public WxProfitPaymentReceiver getPaymantReceiver(TenantEntity tenantEntity, Long merchantId) {
if(merchantId == null || merchantId.equals(0L)){
return null;
}
WxProfitPaymentReceiver record = wxProfitPaymentReceiverService.findReceiver(tenantEntity, merchantId,EnumAppPlat.WX,EnumProfitPaymentReceiverType.wx_special_merchant_number);
return record;
}

private static String queryOrderShareAmount(String mchId,String transcationId,String apiKey) {
WxProfitSharingP psCmd = new WxProfitSharingP();
psCmd.setMch_id(mchId);//服务商商户id


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

@@ -14,6 +14,7 @@ import com.iformall.domain.po.*;
import com.iformall.domain.po.base.TenantEntity;
import com.iformall.enums.*;
import com.iformall.mapper.*;
import com.iformall.service.WxProfitPaymentReceiverService;
import com.iformall.utils.Constant;
import com.iformall.utils.RedisCacheUtils;
import org.apache.commons.lang3.StringUtils;
@@ -52,6 +53,10 @@ public class WxPayShareV3Service extends PayShareBaseAdapterService{
@Lazy
@Autowired
WxProfitSharingReceiverService wxProfitSharingReceiverService;

@Lazy
@Autowired
WxProfitPaymentReceiverService wxProfitPaymentReceiverService;
@Autowired
MaUtil maUtil;
@@ -79,25 +84,27 @@ public class WxPayShareV3Service extends PayShareBaseAdapterService{


@Override
public WxProfitSharingReceiver getReceiver(TenantEntity tenantEntity, Long merchantId, Integer ttPayWay,Integer mchType) {
public WxProfitSharingReceiver getSharingReceiver(TenantEntity tenantEntity, Long merchantId, Integer ttPayWay,Integer mchType) {
if(merchantId == null || merchantId.equals(0L)){
return null;
}

//直连,必须是特约商户号
if (EnumPayMchType.DIRECT.getCode() == mchType) {
return wxProfitSharingReceiverService.findReceiver(tenantEntity, merchantId,EnumAppPlat.WX,EnumProfitSharingType.PROFIT_SHARING_TYPE_WECHAT_v2);
// 总分
}else if (EnumPayMchType.TOTAL.getCode() == mchType) {
return wxProfitSharingReceiverService.findReceiver(tenantEntity, merchantId,EnumAppPlat.WX,EnumProfitSharingType.PROFIT_SHARING_TYPE_WECHAT);
}
return wxProfitSharingReceiverService.findReceiver(tenantEntity, merchantId,EnumAppPlat.WX);

// if (null == receiver) {
// throw new MallinkException(ErrorCode.PROFIT_SHARING_RECEIVER_INVALID.getCode(),"该商户未设置分账账号.");
// }
return null;
}

@Override
public WxProfitPaymentReceiver getPaymantReceiver(TenantEntity tenantEntity, Long merchantId) {
if(merchantId == null || merchantId.equals(0L)){
return null;
}
WxProfitPaymentReceiver record = wxProfitPaymentReceiverService.findReceiver(tenantEntity, merchantId,EnumAppPlat.WX,EnumProfitPaymentReceiverType.wx_special_merchant_number);
return record;
}

//无需分账,直接解冻
@Override
public PayShareResult noReciverShare(WxAppinfo appInfo,WxPayAccount payAccount,WxProfitSharingOrder record) {


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

@@ -101,6 +101,7 @@ public class Constant {
//获取mall信息
public static final String appinfoPrev = "appinfo:";
public static final String payaccountPrev = "payAccount:";
public static final String paymentReceicerPrev = "paymentReceicer:";
public static final String sharingReceicerPrev = "sharingReceicer:";
public static final String mallinfoPrev = "mallinfo:";
public static final String subMallinfoPrev = "mallinfo:subMallinfo:";


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

@@ -0,0 +1,102 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.iformall.mapper.WxProfitPaymentReceiverMapper">
<resultMap id="BaseResultMap" type="com.iformall.domain.po.WxProfitPaymentReceiver">
<id column="id" jdbcType="BIGINT" property="id" />
<result column="tenant_id" jdbcType="VARCHAR" property="tenantId" />
<result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId"/>
<result column="merchant_id" jdbcType="BIGINT" property="merchantId" />
<result column="receiver_type" jdbcType="INTEGER" property="receiverType" />
<result column="receiver_account" jdbcType="VARCHAR" property="receiverAccount" />
<result column="receiver_comments" jdbcType="VARCHAR" property="receiverComments" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
<result column="status" jdbcType="INTEGER" property="status" />
<result column="plat" jdbcType="INTEGER" property="plat" />

<result column="tt_import_status" jdbcType="VARCHAR" property="ttImportStatus" />
<result column="tt_import_url" jdbcType="VARCHAR" property="ttImportUrl" />
<result column="tt_balance_url" jdbcType="VARCHAR" property="ttBalanceUrl" />
</resultMap>
<sql id="allColumns">
`id`,`tenant_id`,`parent_tenant_id`,`merchant_id`,
`receiver_type`,`receiver_account`,`receiver_comments`,
`create_time`,`update_time`,`status`,`plat`,
`tt_import_status`,`tt_import_url`,`tt_balance_url`
</sql>

<sql id="dynamicWhereConditions">
where 1 = 1
<if test=" null != id ">
and `id` = #{id}
</if>

<if test=" null != tenantId and '' != tenantId">
and `tenant_id` = #{tenantId}
</if>
<if test=" null != parentTenantId and '' != parentTenantId">
and `parent_tenant_id` = #{parentTenantId}
</if>

<if test=" null != merchantId ">
and `merchant_id` = #{merchantId}
</if>
<if test=" null != receiverType ">
and `receiver_type` = #{receiverType}
</if>
<if test=" null != receiverAccount and '' != receiverAccount ">
and `receiver_account` like concat('%', #{receiverAccount},'%')
</if>
<if test=" null != receiverComments ">
and `receiver_comments` like concat('%', #{receiverComments},'%')
</if>

<if test=" null != status ">
and `status` = #{status}
</if>

<if test=" null != plat ">
and `plat` = #{plat}
</if>

<if test=" null != wxImportStatus">
and `tt_import_status` -> '$.wx' = #{wxImportStatus}
</if>
<if test=" null != alipayImportStatus">
and `tt_import_status` -> '$.alipay' = #{alipayImportStatus}
</if>
<if test=" null != hzImportStatus">
and `tt_import_status` -> '$.hz' = #{hzImportStatus}
</if>

<if test=" null != ids ">
and id in
<foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
#{idItem}
</foreach>
</if>
<if test=" null != sortColumns"> order by ${sortColumns} </if>
</sql>
<select id="findList" parameterType="com.iformall.domain.po.WxProfitPaymentReceiver" resultMap="BaseResultMap">
select
<include refid="allColumns"/>
from wx_profit_payment_receiver
<include refid="dynamicWhereConditions"/>
</select>
<select id="findOne" parameterType="com.iformall.domain.po.WxProfitPaymentReceiver" resultMap="BaseResultMap">
select
<include refid="allColumns"/>
from wx_profit_payment_receiver
<include refid="dynamicWhereConditions"/>
limit 0,1
</select>
</mapper>

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

@@ -17,6 +17,7 @@
<result column="bank_code" jdbcType="VARCHAR" property="bankCode" />
<result column="status" jdbcType="INTEGER" property="status" />
<result column="parameter" jdbcType="VARCHAR" property="parameter" />
<result column="plat" jdbcType="INTEGER" property="plat" />

<result column="tt_import_status" jdbcType="VARCHAR" property="ttImportStatus" />
<result column="tt_import_url" jdbcType="VARCHAR" property="ttImportUrl" />
@@ -24,7 +25,7 @@
</resultMap>
<sql id="allColumns">
`id`,`tenant_id`,`parent_tenant_id`,`merchant_id`,`receiver_type`,`receiver_account`,`receiver_comments`,`create_time`,`update_time`,`sharing_type`,`bank_no`,`true_name`,`bank_code`,`status`,`parameter`,`is_use`
`id`,`tenant_id`,`parent_tenant_id`,`merchant_id`,`receiver_type`,`receiver_account`,`receiver_comments`,`create_time`,`update_time`,`sharing_type`,`bank_no`,`true_name`,`bank_code`,`status`,`parameter`,`plat`,`is_use`
,`tt_import_status`,`tt_import_url`,`tt_balance_url`
</sql>

@@ -98,6 +99,10 @@

</if>

<if test=" null != plat ">
and `plat` = #{plat}
</if>

<if test=" null !=isUse ">
and `is_use` = #{isUse}



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