diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/basic/WxMerchantController.java b/mallinkAdmin/src/main/java/com/iformall/controller/basic/WxMerchantController.java index 3d325760b..d5358a037 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/basic/WxMerchantController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/basic/WxMerchantController.java @@ -193,14 +193,14 @@ public class WxMerchantController extends BaseController { return wxMerchantService.updateMerchant(wxMerchant); } - @ApiOperation("更新账户接口") - @PostMapping("updateMerchantAccount") - @SystemControllerLog(description = "商户-更新账户") - public ResultData updateMerchantAccount(@RequestBody WxMerchant wxMerchant) { - logger.debug("[" + getIpAddr() + "] WxMerchantController::updateMerchantAccount"); - wxMerchant.updateTenantInfo(getTenantInfo()); - return wxMerchantService.updateMerchantAccount(wxMerchant,EnumPayWay.PAY_WAY_WECHAT); - } +// @ApiOperation("更新账户接口") +// @PostMapping("updateMerchantAccount") +// @SystemControllerLog(description = "商户-更新账户") +// public ResultData updateMerchantAccount(@RequestBody WxMerchant wxMerchant) { +// logger.debug("[" + getIpAddr() + "] WxMerchantController::updateMerchantAccount"); +// wxMerchant.updateTenantInfo(getTenantInfo()); +// return wxMerchantService.updateMerchantAccount(wxMerchant,EnumPayWay.PAY_WAY_WECHAT); +// } @ApiOperation("更新管理员接口") @PostMapping("updateMerchantAdmin") diff --git a/mallinkBApi/src/main/java/com/iformall/controller/WxMerchantController.java b/mallinkBApi/src/main/java/com/iformall/controller/WxMerchantController.java index 7e9114bd4..7c0311ff0 100644 --- a/mallinkBApi/src/main/java/com/iformall/controller/WxMerchantController.java +++ b/mallinkBApi/src/main/java/com/iformall/controller/WxMerchantController.java @@ -4,8 +4,10 @@ import com.iformall.annotation.RedisCache; import com.iformall.common.ErrorCode; import com.iformall.common.ResultData; import com.iformall.domain.po.*; +import com.iformall.domain.po.base.TenantEntity; import com.iformall.douyin.pay.enums.AppAddSubMerchantUrlType; import com.iformall.enums.*; +import com.iformall.exception.MallinkException; import com.iformall.service.*; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; @@ -50,8 +52,22 @@ public class WxMerchantController extends BaseController { if (wxMerchant.getId() == null) { return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "商户ID不能为空"); } - wxMerchant.updateTenantInfo(getTenantInfo()); - return new ResultData(wxProfitSharingReceiverService.findReceiver(wxMerchant, EnumProfitSharingType.PROFIT_SHARING_TYPE_WECHAT)); + TenantEntity tenantInfo = getTenantInfo(); + wxMerchant.updateTenantInfo(tenantInfo); + + WxPayAccount payAccount = payAccountService.getPayAccount(tenantInfo, EnumAppPlat.WX); + 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)); } @ApiOperation("查询账户信息") @@ -63,7 +79,7 @@ public class WxMerchantController extends BaseController { return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "商户ID不能为空"); } wxMerchant.updateTenantInfo(getTenantInfo()); - return new ResultData(wxProfitSharingReceiverService.findReceiver(wxMerchant,EnumProfitSharingType.PROFIT_SHARING_TYPE_DOUYIN)); + return new ResultData(wxProfitSharingReceiverService.findReceiver(getTenantInfo(),wxMerchant.getId(), EnumAppPlat.TOUTIAO,EnumProfitSharingType.PROFIT_SHARING_TYPE_DOUYIN)); } @ApiOperation("更新收款账户信息:必填项 id(商户ID) name(商户名称) accountId(账号ID) accountTypeValue(账号类型) accountName(账号名称)") @@ -89,7 +105,7 @@ public class WxMerchantController extends BaseController { return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "账号名称不能为空"); } wxMerchant.updateTenantInfo(getTenantInfo()); - return wxMerchantService.updateMerchantAccount(wxMerchant,EnumPayWay.PAY_WAY_WECHAT); + return wxMerchantService.updateMerchantAccount(wxMerchant); } @ApiOperation("删除分账账户") diff --git a/mallinkService/src/main/java/com/iformall/domain/po/WxMerchant.java b/mallinkService/src/main/java/com/iformall/domain/po/WxMerchant.java index a7c359f88..9f9072b62 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/WxMerchant.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/WxMerchant.java @@ -94,55 +94,52 @@ public class WxMerchant extends TenantEntity { } @TableField(exist = false) - @Excel(name="账户类型",width = 20,orderNum = "8",replace = {"_null","商户号_0","微信号_1","OPENID_3"}) @io.swagger.annotations.ApiModelProperty(value="账户类型",name="accountTypeValue") private Integer accountTypeValue; @TableField(exist = false) - @Excel(name="账户号",width = 20,orderNum = "9") @io.swagger.annotations.ApiModelProperty(value="账户ID",name="accountId") private String accountId; @TableField(exist = false) - @Excel(name="账户名",width = 20,orderNum = "10") @io.swagger.annotations.ApiModelProperty(value="账户名",name="accountName") private String accountName; - @Excel(name="创建时间",width = 20,format="yyyy-MM-dd",orderNum = "11") + @Excel(name="创建时间",width = 20,format="yyyy-MM-dd",orderNum = "8") @io.swagger.annotations.ApiModelProperty(value="创建时间",name="createDate") private Date createDate; - @Excel(name="是否展示",width = 20,orderNum = "12",replace = {"否_0","是_1"}) + @Excel(name="是否展示",width = 20,orderNum = "9",replace = {"否_0","是_1"}) @io.swagger.annotations.ApiModelProperty(value = "是否显示在C端", name = "isPublic") private Integer isPublic; - @Excel(name = "待缴提醒", width = 20, orderNum = "13") + @Excel(name = "待缴提醒", width = 20, orderNum = "10") @io.swagger.annotations.ApiModelProperty(value = "待缴提醒", name = "billSetting") private Integer billSetting; @TableField(exist = false) - @Excel(name = "业态", width = 20, orderNum = "14") + @Excel(name = "业态", width = 20, orderNum = "11") @io.swagger.annotations.ApiModelProperty(value="经营业态ID:参照wx_business表",name="businessId") private String businessName; @TableField(exist = false) - @Excel(name = "子业态", width = 20, orderNum = "15") + @Excel(name = "子业态", width = 20, orderNum = "12") @io.swagger.annotations.ApiModelProperty(value="子业态",name="subBusinessId") private String subBusinessName; @TableField(exist = false) - @Excel(name = "商铺", width = 20, orderNum = "16") + @Excel(name = "商铺", width = 20, orderNum = "13") private String shopsStr; @TableField(exist = false) - @Excel(name = "管理员", width = 20, orderNum = "17") + @Excel(name = "管理员", width = 20, orderNum = "14") private String usersStr; - @Excel(name = "主谈人", width = 20, orderNum = "18") + @Excel(name = "主谈人", width = 20, orderNum = "15") @io.swagger.annotations.ApiModelProperty(value = "主谈人", name = "talkUserMain") private String talkUserMain; - @Excel(name = "辅谈人", width = 20, orderNum = "19") + @Excel(name = "辅谈人", width = 20, orderNum = "16") @io.swagger.annotations.ApiModelProperty(value = "辅谈人", name = "talkUserAux") private String talkUserAux; @@ -269,7 +266,7 @@ public class WxMerchant extends TenantEntity { private String linkLinePhone; @TableField(exist = false) - private WxProfitSharingReceiver wxProfitSharingReceiver; + private List wxProfitSharingReceiver; public String getWeappPath() { if(id == null) diff --git a/mallinkService/src/main/java/com/iformall/enums/EnumProfitSharingType.java b/mallinkService/src/main/java/com/iformall/enums/EnumProfitSharingType.java index c4790bf0e..427ba2141 100644 --- a/mallinkService/src/main/java/com/iformall/enums/EnumProfitSharingType.java +++ b/mallinkService/src/main/java/com/iformall/enums/EnumProfitSharingType.java @@ -7,7 +7,8 @@ public enum EnumProfitSharingType { PROFIT_SHARING_TYPE_WECHAT(1, "微信分账"), PROFIT_SHARING_TYPE_BANK(2, "银行卡分账"), - PROFIT_SHARING_TYPE_DOUYIN(3, "抖音分账"), + PROFIT_SHARING_TYPE_DOUYIN(3, "抖音进件"), + PROFIT_SHARING_TYPE_WECHAT_v2(4, "微信进件"), ; public static EnumProfitSharingType getEnum(Integer code) { diff --git a/mallinkService/src/main/java/com/iformall/mapper/WxProfitSharingReceiverMapper.java b/mallinkService/src/main/java/com/iformall/mapper/WxProfitSharingReceiverMapper.java index b8dabefad..c4c92e5ad 100644 --- a/mallinkService/src/main/java/com/iformall/mapper/WxProfitSharingReceiverMapper.java +++ b/mallinkService/src/main/java/com/iformall/mapper/WxProfitSharingReceiverMapper.java @@ -10,6 +10,5 @@ public interface WxProfitSharingReceiverMapper extends CommonMapper findMerchantIdList(WxProfitSharingReceiver wxProfitSharingReceiver); } diff --git a/mallinkService/src/main/java/com/iformall/service/WxMerchantService.java b/mallinkService/src/main/java/com/iformall/service/WxMerchantService.java index aae83982c..dbdb16a13 100644 --- a/mallinkService/src/main/java/com/iformall/service/WxMerchantService.java +++ b/mallinkService/src/main/java/com/iformall/service/WxMerchantService.java @@ -130,7 +130,7 @@ public interface WxMerchantService { ResultData updateMerchant(WxMerchant wxMerchant); - ResultData updateMerchantAccount(WxMerchant wxMerchant,EnumPayWay payWay); + ResultData updateMerchantAccount(WxMerchant wxMerchant); ResultData updateMerchantAdmin(WxMerchant wxMerchant); diff --git a/mallinkService/src/main/java/com/iformall/service/WxPayAccountService.java b/mallinkService/src/main/java/com/iformall/service/WxPayAccountService.java index fa5aaf956..94a71e4e3 100644 --- a/mallinkService/src/main/java/com/iformall/service/WxPayAccountService.java +++ b/mallinkService/src/main/java/com/iformall/service/WxPayAccountService.java @@ -4,6 +4,8 @@ import com.github.binarywang.wxpay.service.WxPayService; import com.github.pagehelper.PageInfo; import com.iformall.domain.po.WxPayAccount; import com.iformall.domain.po.WxProjectConfig; +import com.iformall.domain.po.base.TenantEntity; +import com.iformall.enums.EnumAppPlat; public interface WxPayAccountService { @@ -40,5 +42,7 @@ public interface WxPayAccountService { void deleteById(Long id); + WxPayAccount getPayAccount(TenantEntity tenantEntity, EnumAppPlat appPlat); + WxPayService getWxPayService(String tenantId); } diff --git a/mallinkService/src/main/java/com/iformall/service/WxProfitSharingReceiverApplyService.java b/mallinkService/src/main/java/com/iformall/service/WxProfitSharingReceiverApplyService.java new file mode 100644 index 000000000..fda20d3a2 --- /dev/null +++ b/mallinkService/src/main/java/com/iformall/service/WxProfitSharingReceiverApplyService.java @@ -0,0 +1,17 @@ +package com.iformall.service; + +import com.github.pagehelper.PageInfo; +import com.iformall.domain.po.WxProfitSharingReceiverApply; + +public interface WxProfitSharingReceiverApplyService { + + /** + * 根据实体查询分页列表 + * + * @param record + * @return + */ + PageInfo listAsPage(WxProfitSharingReceiverApply record, Integer pageIndex, Integer pageSize); + + +} diff --git a/mallinkService/src/main/java/com/iformall/service/WxProfitSharingReceiverService.java b/mallinkService/src/main/java/com/iformall/service/WxProfitSharingReceiverService.java index 7581bc7c8..d088e906e 100644 --- a/mallinkService/src/main/java/com/iformall/service/WxProfitSharingReceiverService.java +++ b/mallinkService/src/main/java/com/iformall/service/WxProfitSharingReceiverService.java @@ -5,6 +5,7 @@ import com.iformall.common.ResultData; import com.iformall.domain.po.WxMerchant; import com.iformall.domain.po.WxProfitSharingReceiver; import com.iformall.domain.po.base.TenantEntity; +import com.iformall.enums.EnumAppPlat; import com.iformall.enums.EnumPayWay; import com.iformall.enums.EnumProfitSharingType; @@ -42,13 +43,15 @@ public interface WxProfitSharingReceiverService { */ void deleteById(Long id); - WxProfitSharingReceiver findReceiver(WxMerchant merchant, EnumProfitSharingType sharingType); + WxProfitSharingReceiver findReceiver(TenantEntity tenantEntity,Long merchantId, EnumAppPlat plat,EnumProfitSharingType sharingType); - ResultData addReceiver(WxMerchant merchant, WxProfitSharingReceiver receiver, List delList,EnumPayWay payWay); + List findReceivers(TenantEntity tenantEntity,Long merchantId); + + ResultData addReceiver(WxMerchant merchant, WxProfitSharingReceiver receiver, List delList); ResultData delReceiver(WxProfitSharingReceiver receiver, Integer send); - ResultData updateReceiver(WxMerchant merchant, WxProfitSharingReceiver receiver,EnumPayWay payWay); + ResultData updateReceiver(WxMerchant merchant, WxProfitSharingReceiver receiver); void sendMsg(String phone, String account, String merchant, String time, Integer modelType, TenantEntity tenantEntity); diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxMerchantServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxMerchantServiceImpl.java index 3587462c1..da49fb64f 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxMerchantServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxMerchantServiceImpl.java @@ -355,12 +355,9 @@ public class WxMerchantServiceImpl implements WxMerchantService { } //分账信息 - WxProfitSharingReceiver receiver = wxProfitSharingReceiverService.findReceiver(wxMerchant,EnumProfitSharingType.PROFIT_SHARING_TYPE_WECHAT); + List receiver = wxProfitSharingReceiverService.findReceivers(wxMerchant,wxMerchant.getId()); if (receiver != null) { wxMerchant.setWxProfitSharingReceiver(receiver); - wxMerchant.setAccountId(receiver.getReceiverAccount()); - wxMerchant.setAccountName(receiver.getTrueName()); - wxMerchant.setAccountTypeValue(receiver.getReceiverType()); } WxMerchantCorp wxMerchantCorp = new WxMerchantCorp(); @@ -726,7 +723,7 @@ public class WxMerchantServiceImpl implements WxMerchantService { @Transactional(isolation=Isolation.SERIALIZABLE, propagation = Propagation.REQUIRED, rollbackFor = {Exception.class}) @Override - public ResultData updateMerchantAccount(WxMerchant wxMerchant,EnumPayWay payWay) { + public ResultData updateMerchantAccount(WxMerchant wxMerchant) { try { if (wxMerchant.getId() == null) { return new ResultData(ErrorCode.MERCHANT_INFO_NOT_FOUND); @@ -742,7 +739,7 @@ public class WxMerchantServiceImpl implements WxMerchantService { receiver.setReceiverType(wxMerchant.getAccountTypeValue()); receiver.setTrueName(wxMerchant.getAccountName()); receiver.setParameter(wxMerchant.getAccountParameter()); - return wxProfitSharingReceiverService.updateReceiver(wxMerchant, receiver,payWay); + return wxProfitSharingReceiverService.updateReceiver(wxMerchant, receiver); } } catch (Exception e) { logger.error("db failed: 账户操作失败, e:" + e.getMessage(),e); @@ -929,13 +926,13 @@ public class WxMerchantServiceImpl implements WxMerchantService { List list = wxMerchantMapper.findList(wxMerchant); list.stream().forEach(m->{ - //分账信息 - WxProfitSharingReceiver receiver = wxProfitSharingReceiverService.findReceiver(m,EnumProfitSharingType.PROFIT_SHARING_TYPE_WECHAT); - if (receiver != null) { - m.setAccountId(receiver.getReceiverAccount()); - m.setAccountName(receiver.getTrueName()); - m.setAccountTypeValue(receiver.getReceiverType()); - } + //分账信息 可能有多个, 先干掉 +// WxProfitSharingReceiver receiver = wxProfitSharingReceiverService.findReceiver(m,EnumProfitSharingType.PROFIT_SHARING_TYPE_WECHAT); +// if (receiver != null) { +// m.setAccountId(receiver.getReceiverAccount()); +// m.setAccountName(receiver.getTrueName()); +// m.setAccountTypeValue(receiver.getReceiverType()); +// } WxRentContract wxRentContract = new WxRentContract(); wxRentContract.setMerchantId(m.getId()); List lrc = wxRentContractMapper.selectRentContractByMerchantId(wxRentContract); diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxParkServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxParkServiceImpl.java index b10aaefc1..7a32afe63 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxParkServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxParkServiceImpl.java @@ -92,19 +92,6 @@ public class WxParkServiceImpl implements WxParkService { wxMerchant.setCreateDate(now); wxMerchant.setUpdateDate(now); wxMerchantMapper.insert(wxMerchant); - WxProfitSharingReceiver wxProfitSharingReceiver = new WxProfitSharingReceiver(); - wxProfitSharingReceiver.setId(idWorker.nextId()); - wxProfitSharingReceiver.setTenantId(record.getTenantId()); - wxProfitSharingReceiver.setMerchantId(wxMerchant.getId()); - wxProfitSharingReceiver.setReceiverType(1); - wxProfitSharingReceiver.setReceiverAccount("wxid_ppufk303mdrs12"); - wxProfitSharingReceiver.setReceiverComments(wxMerchant.getName()); - wxProfitSharingReceiver.setSharingType(1); - wxProfitSharingReceiver.setTrueName(wxMerchant.getName()); - wxProfitSharingReceiver.setStatus(0); - wxProfitSharingReceiver.setCreateTime(now); - wxProfitSharingReceiver.setUpdateTime(now); - wxProfitSharingReceiverMapper.insert(wxProfitSharingReceiver); } else { record.setUpdateDate(now); diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxPayAccountServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxPayAccountServiceImpl.java index f1c5664ae..b222b08a0 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxPayAccountServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxPayAccountServiceImpl.java @@ -59,6 +59,17 @@ public class WxPayAccountServiceImpl implements WxPayAccountService { wxPayAccountMapper.deleteById(id); } + @Override + public WxPayAccount getPayAccount(TenantEntity tenantEntity, EnumAppPlat appPlat) { + if(appPlat != null){ + WxAppinfo cAppInfo = wxAppinfoService.getCAppInfo(tenantEntity, appPlat); + if(cAppInfo != null){ + return this.getById(cAppInfo.getPayId()); + } + } + return null; + } + @Override public WxPayService getWxPayService(String tenantId) { TenantEntity tenantEntity = new TenantEntity(); diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxProfitSharingReceiverApplyServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxProfitSharingReceiverApplyServiceImpl.java new file mode 100644 index 000000000..65a3f21b9 --- /dev/null +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxProfitSharingReceiverApplyServiceImpl.java @@ -0,0 +1,28 @@ +package com.iformall.service.impl; + +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; +import com.iformall.domain.po.*; +import com.iformall.mapper.WxProfitSharingReceiverApplyMapper; +import com.iformall.service.WxProfitSharingReceiverApplyService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + + +@Service +public class WxProfitSharingReceiverApplyServiceImpl implements WxProfitSharingReceiverApplyService { + + private final Logger logger = LoggerFactory.getLogger(this.getClass()); + + @Autowired + WxProfitSharingReceiverApplyMapper wxProfitSharingReceiverApplyMapper; + + @Override + public PageInfo listAsPage(WxProfitSharingReceiverApply record, Integer pageIndex, Integer pageSize) { + return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxProfitSharingReceiverApplyMapper.findList(record)); + } + + +} diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxProfitSharingReceiverServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxProfitSharingReceiverServiceImpl.java index 73cf2accd..25e80c5ef 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxProfitSharingReceiverServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxProfitSharingReceiverServiceImpl.java @@ -22,6 +22,7 @@ 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.WxAppinfoMapper; import com.iformall.mapper.WxMerchantMapper; import com.iformall.mapper.WxPayAccountMapper; @@ -30,13 +31,16 @@ import com.iformall.mq.MqBaseProducer; import com.iformall.pay.WxPayment; import com.iformall.pay.WxProfitSharing; import com.iformall.pay.WxProfitSharingReceiverP; +import com.iformall.service.WxAppinfoService; import com.iformall.service.WxMerchantService; +import com.iformall.service.WxPayAccountService; import com.iformall.service.WxProfitSharingReceiverService; import com.iformall.service.pay.PayServiceFactory; import com.iformall.service.pay.service.share.entity.ShareAccountResult; import com.iformall.utils.BeanUtils; import com.iformall.utils.DateUtils; import com.iformall.utils.Utility; +import net.sf.saxon.trans.Err; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -67,9 +71,9 @@ public class WxProfitSharingReceiverServiceImpl implements WxProfitSharingReceiv @Autowired WxProfitSharingReceiverMapper wxProfitSharingReceiverMapper; @Autowired - WxAppinfoMapper wxAppinfoMapper; + WxAppinfoService wxAppinfoService; @Autowired - WxPayAccountMapper wxPayAccountMapper; + WxPayAccountService wxPayAccountService; @Lazy @Autowired @@ -113,32 +117,33 @@ public class WxProfitSharingReceiverServiceImpl implements WxProfitSharingReceiv } - //todo 微信和抖音分账可能存在两个分账信息 + @Override - public WxProfitSharingReceiver findReceiver(WxMerchant merchant, EnumProfitSharingType sharingType) { + public WxProfitSharingReceiver findReceiver(TenantEntity tenantEntity,Long merchantId, EnumAppPlat plat,EnumProfitSharingType sharingType) { WxProfitSharingReceiver receiver = new WxProfitSharingReceiver(); - receiver.updateTenantInfo(merchant); - receiver.setMerchantId(merchant.getId()); + receiver.updateTenantInfo(tenantEntity); + receiver.setMerchantId(merchantId); + receiver.setPlat(plat.getCode()); receiver.setSharingType(sharingType.getCode()); receiver.setStatus(EnumProfitSharingReceiverStatus.PROFIT_SHARING_RECEIVER_STATUS_VALID.getCode()); - List list = wxProfitSharingReceiverMapper.findList(receiver); - if(list != null && list.size() > 0){ - return list.get(0); - } - return null; + return wxProfitSharingReceiverMapper.findOne(receiver); } - @Override - public ResultData addReceiver(WxMerchant merchant, WxProfitSharingReceiver receiver, List delList,EnumPayWay payWay) { + public List findReceivers(TenantEntity tenantEntity, Long merchantId) { + WxProfitSharingReceiver receiver = new WxProfitSharingReceiver(); + receiver.updateTenantInfo(tenantEntity); + receiver.setMerchantId(merchantId); + receiver.setStatus(EnumProfitSharingReceiverStatus.PROFIT_SHARING_RECEIVER_STATUS_VALID.getCode()); + return wxProfitSharingReceiverMapper.findList(receiver); + } - WxAppinfo appInfo = new WxAppinfo(); - appInfo.updateTenantInfo(merchant); - appInfo.setPlat(EnumPayWay.getEnum(payWay.getCode()).getPlat().getCode()); - appInfo.setType(EnumAppType.C.getCode()); - appInfo = wxAppinfoMapper.findList(appInfo).get(0); - WxPayAccount payAccount = wxPayAccountMapper.selectById(appInfo.getPayId()); + @Override + public ResultData addReceiver(WxMerchant merchant, WxProfitSharingReceiver receiver, List delList) { + + WxAppinfo appInfo = wxAppinfoService.getCAppInfo(merchant,EnumAppPlat.WX); + WxPayAccount payAccount = wxPayAccountService.getById(appInfo.getPayId()); receiver.updateTenantInfo(merchant); receiver.setMerchantId(merchant.getId()); @@ -149,7 +154,7 @@ public class WxProfitSharingReceiverServiceImpl implements WxProfitSharingReceiv receiver.setUpdateTime(date); receiver.setStatus(EnumProfitSharingReceiverStatus.PROFIT_SHARING_RECEIVER_STATUS_VALID.getCode()); // receiver.setIsUse(EnumProfitSharingUse.APPLY.getCode()); - receiver.setPlat(payWay.getPlat().getCode()); + receiver.setPlat(EnumAppPlat.WX.getCode()); //passed from uplevel //receiver.setReceiverAccount(receiverParam.getReceiverAccount()); //receiver.setReceiverComments(receiverParam.getReceiverComments()); @@ -157,7 +162,8 @@ public class WxProfitSharingReceiverServiceImpl implements WxProfitSharingReceiv //receiver.setTrueName(receiverParam.getTrueName()); //添加分账账户 - ShareAccountResult createResult = payServiceFactory.getPayShareAdapterService(payWay.getCode(),payAccount.getPayVersion()).createShareAccount(appInfo, payAccount, receiver); + 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()); } @@ -369,12 +375,9 @@ public class WxProfitSharingReceiverServiceImpl implements WxProfitSharingReceiv @Override public ResultData delReceiver(WxProfitSharingReceiver receiver, Integer send) { - WxAppinfo appInfo = new WxAppinfo(); - appInfo.updateTenantInfo(receiver); - appInfo.setType(EnumAppType.C.getCode()); - appInfo = wxAppinfoMapper.findList(appInfo).get(0); - WxPayAccount payAccount = wxPayAccountMapper.selectById(appInfo.getPayId()); + WxAppinfo appInfo = wxAppinfoService.getCAppInfo(receiver,EnumAppPlat.WX); + WxPayAccount payAccount = wxPayAccountService.getById(appInfo.getPayId()); receiver = wxProfitSharingReceiverMapper.selectById(receiver.getId()); @@ -414,14 +417,14 @@ public class WxProfitSharingReceiverServiceImpl implements WxProfitSharingReceiv } @Override - public ResultData updateReceiver(WxMerchant merchant, WxProfitSharingReceiver receiver,EnumPayWay payWay) { + 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.setStatus(EnumProfitSharingReceiverStatus.PROFIT_SHARING_RECEIVER_STATUS_VALID.getCode()); - oldReceiver.setPlat(payWay.getPlat().getCode()); + oldReceiver.setPlat(EnumAppPlat.WX.getCode()); List delList = wxProfitSharingReceiverMapper.selectList(new QueryWrapper(oldReceiver)); oldReceiver.setReceiverAccount(receiver.getReceiverAccount()); oldReceiver.setReceiverType(receiver.getReceiverType()); @@ -429,7 +432,7 @@ public class WxProfitSharingReceiverServiceImpl implements WxProfitSharingReceiv oldReceiver = wxProfitSharingReceiverMapper.selectOne(new QueryWrapper(oldReceiver)); if (oldReceiver == null) { - return addReceiver(merchant, receiver, delList,payWay); + return addReceiver(merchant, receiver, delList); } else { oldReceiver.setParameter(receiver.getParameter()); oldReceiver.setUpdateTime(new Date()); diff --git a/mallinkTTAdmin/src/main/java/com/iformall/controller/basic/WxMerchantController.java b/mallinkTTAdmin/src/main/java/com/iformall/controller/basic/WxMerchantController.java index 9916b91c8..495917096 100644 --- a/mallinkTTAdmin/src/main/java/com/iformall/controller/basic/WxMerchantController.java +++ b/mallinkTTAdmin/src/main/java/com/iformall/controller/basic/WxMerchantController.java @@ -183,15 +183,6 @@ public class WxMerchantController extends BaseController { return wxMerchantService.updateMerchant(wxMerchant); } - @ApiOperation("更新账户接口") - @PostMapping("updateMerchantAccount") - @SystemControllerLog(description = "商户-更新账户") - public ResultData updateMerchantAccount(@RequestBody WxMerchant wxMerchant) { - logger.debug("[" + getIpAddr() + "] WxMerchantController::updateMerchantAccount"); - wxMerchant.updateTenantInfo(getTenantInfo()); - return wxMerchantService.updateMerchantAccount(wxMerchant,EnumPayWay.PAY_WAY_WECHAT); - } - @ApiOperation("更新管理员接口") @PostMapping("updateMerchantAdmin") @SystemControllerLog(description = "商户-更新管理员")