diff --git a/mallinkBApi/src/main/java/com/iformall/controller/WxMerchantController.java b/mallinkBApi/src/main/java/com/iformall/controller/WxMerchantController.java index 231aa4cf2..9f16613a3 100644 --- a/mallinkBApi/src/main/java/com/iformall/controller/WxMerchantController.java +++ b/mallinkBApi/src/main/java/com/iformall/controller/WxMerchantController.java @@ -1,14 +1,15 @@ package com.iformall.controller; +import com.iformall.annotation.RedisCache; import com.iformall.common.ErrorCode; import com.iformall.common.ResultData; import com.iformall.domain.po.*; +import com.iformall.douyin.pay.enums.AppAddSubMerchantUrlType; +import com.iformall.enums.EnumAppPlat; import com.iformall.enums.EnumMsgSend; import com.iformall.enums.EnumPayWay; import com.iformall.enums.EnumProfitSharingType; -import com.iformall.service.WxCUserService; -import com.iformall.service.WxMerchantService; -import com.iformall.service.WxProfitSharingReceiverService; +import com.iformall.service.*; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiOperation; @@ -32,6 +33,11 @@ public class WxMerchantController extends BaseController { @Autowired private WxCUserService cUserService; + @Autowired + private WxAppinfoService wxAppinfoService; + @Autowired + private WxPayAccountService payAccountService; + @ApiOperation("查询当前租户下商户名称列表") @GetMapping("/name_list") public ResultData nameList() { @@ -145,6 +151,42 @@ public class WxMerchantController extends BaseController { } } + @RedisCache + @ApiOperation("获取进件/余额页面") + @GetMapping("/getTtReceiverUrl") + @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) + public ResultData getTtReceiver(Long id,Integer urlType) { + log.debug("[" + getIpAddr() + "] WxMerchantController::getTtReceiver"); + if(urlType == null || id == null){ + return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"请检查传递参数"); + } + WxMerchant merchant = wxMerchantService.selectById(id); + if(merchant == null){ + return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"请检查传递参数"); + } + AppAddSubMerchantUrlType anEnum = AppAddSubMerchantUrlType.getEnum(urlType); + if(anEnum == null){ + return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"请检查传递参数"); + } + + WxAppinfo appInfo = wxAppinfoService.getCAppInfo(getTenantInfo(), EnumAppPlat.TOUTIAO); + if(appInfo == null) { + return new ResultData(ErrorCode.APP_ID_NOT_FOUND); + } + WxPayAccount payAcount = payAccountService.getById(appInfo.getPayId()); + if(payAcount == null){ + return new ResultData(ErrorCode.APP_ID_NOT_FOUND); + } + if(anEnum.equals(AppAddSubMerchantUrlType.improt_URL)){ + return wxProfitSharingReceiverService.getTtReceiverImprotURL(merchant,appInfo.getAppId(),payAcount.getApiKey()); + }else if(anEnum.equals(AppAddSubMerchantUrlType.Balance_URL)){ + return wxProfitSharingReceiverService.getTtReceiverBalanceURL(merchant,appInfo.getAppId(),payAcount.getApiKey()); + }else{ + return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"请检查传递参数"); + } + + } + public boolean hasPermission() { WxMerchantBUser user = getLoginBUser(); CUser buser = getCUser(); diff --git a/mallinkSchedule/src/main/java/com/iformall/schedule/TtMerchantReciverSchedule.java b/mallinkSchedule/src/main/java/com/iformall/schedule/TtMerchantReciverSchedule.java index ea8a754ea..5692e9d58 100644 --- a/mallinkSchedule/src/main/java/com/iformall/schedule/TtMerchantReciverSchedule.java +++ b/mallinkSchedule/src/main/java/com/iformall/schedule/TtMerchantReciverSchedule.java @@ -71,12 +71,12 @@ public class TtMerchantReciverSchedule { } for (WxMerchant m:merchants) { - try { - wxProfitSharingReceiverService.updateTtReceiver(m,appIdMap.get(m.getTenantId()),payAccountKeyMap.get(m.getTenantId())); - } catch (Exception e) { - e.printStackTrace(); - logger.error("TtMerchantReciverSchedule error.updateTtReceiver:"+m.getId(),e); - } +// try { +// wxProfitSharingReceiverService.updateTtReceiver(m,appIdMap.get(m.getTenantId()),payAccountKeyMap.get(m.getTenantId())); +// } catch (Exception e) { +// e.printStackTrace(); +// logger.error("TtMerchantReciverSchedule error.updateTtReceiver:"+m.getId(),e); +// } try { wxProfitSharingReceiverService.updateTtReceiverIsUse(m,appIdMap.get(m.getTenantId()),payAccountKeyMap.get(m.getTenantId())); } catch (Exception e) { diff --git a/mallinkService/src/main/java/com/iformall/service/WxProfitSharingReceiverService.java b/mallinkService/src/main/java/com/iformall/service/WxProfitSharingReceiverService.java index 07e0a9d4d..0c19bbea1 100644 --- a/mallinkService/src/main/java/com/iformall/service/WxProfitSharingReceiverService.java +++ b/mallinkService/src/main/java/com/iformall/service/WxProfitSharingReceiverService.java @@ -54,5 +54,9 @@ public interface WxProfitSharingReceiverService { ResultData updateTtReceiver(WxMerchant merchant, String appId, String payAccountKey); + ResultData getTtReceiverImprotURL(WxMerchant merchant, String appId, String payAccountKey); + + ResultData getTtReceiverBalanceURL(WxMerchant merchant, String appId, String payAccountKey); + ResultData updateTtReceiverIsUse(WxMerchant merchant, String appId, String payAccountKey); } 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 4d21a81aa..da1b86a00 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxProfitSharingReceiverServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxProfitSharingReceiverServiceImpl.java @@ -249,20 +249,8 @@ public class WxProfitSharingReceiverServiceImpl implements WxProfitSharingReceiv if(merchant == null || StringUtils.isBlank(appId) || StringUtils.isBlank(payAccountKey)) { return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"请检查传递参数"); } - 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); - } + WxProfitSharingReceiver wxProfitSharingReceiver = getTtSharingReceiver(merchant); + //进件页面 AppAddSubMerchantResult improt_URLResult = appAddSubMerchant(appId,payAccountKey,merchant.getId().toString(),AppAddSubMerchantUrlType.improt_URL); if(improt_URLResult.isSuccess()){ @@ -274,15 +262,71 @@ public class WxProfitSharingReceiverServiceImpl implements WxProfitSharingReceiv //余额页面 AppAddSubMerchantResult balance_URLResult = appAddSubMerchant(appId,payAccountKey,merchant.getId().toString(),AppAddSubMerchantUrlType.Balance_URL); if(balance_URLResult.isSuccess()){ - wxProfitSharingReceiver.setReceiverAccount(improt_URLResult.getMerchantId()); + wxProfitSharingReceiver.setReceiverAccount(balance_URLResult.getMerchantId()); wxProfitSharingReceiver.setTtBalanceUrl(balance_URLResult.getUrl()); }else{ - logger.error("获取余额页面 error{}"+improt_URLResult.getMsg()); + logger.error("获取余额页面 error{}"+balance_URLResult.getMsg()); } this.saveOrUpdate(wxProfitSharingReceiver); return new ResultData(); } + @Override + public ResultData getTtReceiverImprotURL(WxMerchant merchant, String appId, String payAccountKey) { + if(merchant == null || StringUtils.isBlank(appId) || StringUtils.isBlank(payAccountKey)) { + return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"请检查传递参数"); + } + WxProfitSharingReceiver wxProfitSharingReceiver = getTtSharingReceiver(merchant); + //进件页面 + AppAddSubMerchantResult improt_URLResult = appAddSubMerchant(appId,payAccountKey,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, String appId, String payAccountKey) { + if(merchant == null || StringUtils.isBlank(appId) || StringUtils.isBlank(payAccountKey)) { + return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"请检查传递参数"); + } + WxProfitSharingReceiver wxProfitSharingReceiver = getTtSharingReceiver(merchant); + //余额页面 + AppAddSubMerchantResult balance_URLResult = appAddSubMerchant(appId,payAccountKey,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, String appId, String payAccountKey) { if(merchant == null || StringUtils.isBlank(appId) || StringUtils.isBlank(payAccountKey)) {