diff --git a/mallinkBApi/src/main/java/com/iformall/controller/WxProfitSharingReceiverApplyController.java b/mallinkBApi/src/main/java/com/iformall/controller/WxProfitSharingReceiverApplyController.java index 38373978a..a23387535 100644 --- a/mallinkBApi/src/main/java/com/iformall/controller/WxProfitSharingReceiverApplyController.java +++ b/mallinkBApi/src/main/java/com/iformall/controller/WxProfitSharingReceiverApplyController.java @@ -118,4 +118,18 @@ public class WxProfitSharingReceiverApplyController extends BaseController { } } + @ApiOperation("提交申请单") + @PostMapping("/applyment") + public ResultData applyment(@RequestBody WxProfitSharingReceiverApply receiverAdd) { + log.debug("[" + getIpAddr() + "] merchantProfitSharingReceiver::applyment"); + if(receiverAdd == null){ + receiverAdd = new WxProfitSharingReceiverApply(); + } + receiverAdd.updateTenantInfo(getTenantInfo()); + if(receiverAdd.getId() == null){ + return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "商户ID不能为空"); + } + return wxProfitSharingReceiverApplyService.applyment(receiverAdd); + } + } diff --git a/mallinkService/src/main/java/com/iformall/domain/po/WxProfitSharingReceiverApply.java b/mallinkService/src/main/java/com/iformall/domain/po/WxProfitSharingReceiverApply.java index 924359d8b..f21f97382 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/WxProfitSharingReceiverApply.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/WxProfitSharingReceiverApply.java @@ -1,16 +1,10 @@ package com.iformall.domain.po; -import com.alibaba.fastjson.JSONObject; -import com.aliyun.openservices.shade.io.netty.util.internal.logging.InternalLogger; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableName; import com.iformall.domain.po.base.TenantEntity; -import com.iformall.enums.EnumSharingReceiverOrganizationType; import lombok.Data; import lombok.EqualsAndHashCode; -import org.apache.commons.lang3.StringUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import java.util.Date; @@ -77,7 +71,7 @@ public class WxProfitSharingReceiverApply extends TenantEntity { private String businessAdditionDesc; @io.swagger.annotations.ApiModelProperty(value="微信支付申请单号",name="applymentId") - private Integer applymentId; + private String applymentId; @io.swagger.annotations.ApiModelProperty(value="EnumSharingReceiverApplymentState 申请状态",name="applymentState") private Integer applymentState; @io.swagger.annotations.ApiModelProperty(value="申请状态描述",name="applymentStateDesc") @@ -110,7 +104,7 @@ public class WxProfitSharingReceiverApply extends TenantEntity { @io.swagger.annotations.ApiModelProperty(value="",name="updateTime") private Date updateTime; - @io.swagger.annotations.ApiModelProperty(value="是否完成主题资质",name="finishMain") + @io.swagger.annotations.ApiModelProperty(value="是否完成主体资质",name="finishMain") @TableField(exist = false) private Boolean finishMain; @io.swagger.annotations.ApiModelProperty(value="是否完成经营信息",name="finishBusiness") diff --git a/mallinkService/src/main/java/com/iformall/service/WxProfitSharingReceiverApplyService.java b/mallinkService/src/main/java/com/iformall/service/WxProfitSharingReceiverApplyService.java index 880f89832..6fdff4aeb 100644 --- a/mallinkService/src/main/java/com/iformall/service/WxProfitSharingReceiverApplyService.java +++ b/mallinkService/src/main/java/com/iformall/service/WxProfitSharingReceiverApplyService.java @@ -17,7 +17,6 @@ public interface WxProfitSharingReceiverApplyService { */ PageInfo listAsPage(WxProfitSharingReceiverApply record, Integer pageIndex, Integer pageSize); - WxProfitSharingReceiverApply selectById(Long id); WxProfitSharingReceiverApply selectByPlat(TenantEntity tenantEntity, Long merchantId, EnumAppPlat plat); @@ -26,5 +25,6 @@ public interface WxProfitSharingReceiverApplyService { ResultData saveOrUpdate(WxProfitSharingReceiverApply receiverAdd); + ResultData applyment(WxProfitSharingReceiverApply receiverAdd); } diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxProfitSharingReceiverApplyServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxProfitSharingReceiverApplyServiceImpl.java index c80941e78..f63a6ba32 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxProfitSharingReceiverApplyServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxProfitSharingReceiverApplyServiceImpl.java @@ -4,8 +4,14 @@ import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.github.binarywang.wxpay.bean.applyment.WxPayApplyment4SubCreateRequest; +import com.github.binarywang.wxpay.bean.applyment.WxPayApplymentCreateResult; +import com.github.binarywang.wxpay.bean.bank.BankingResult; +import com.github.binarywang.wxpay.exception.WxPayException; +import com.github.binarywang.wxpay.service.WxPayService; 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.po.*; @@ -13,6 +19,8 @@ import com.iformall.domain.po.base.TenantEntity; import com.iformall.enums.*; import com.iformall.mapper.WxProfitSharingReceiverApplyMapper; import com.iformall.service.WxAppinfoService; +import com.iformall.service.WxMerchantService; +import com.iformall.service.WxPayAccountService; import com.iformall.service.WxProfitSharingReceiverApplyService; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; @@ -37,6 +45,12 @@ public class WxProfitSharingReceiverApplyServiceImpl implements WxProfitSharingR @Autowired WxAppinfoService wxAppinfoService; + @Autowired + WxMerchantService wxMerchantService; + + @Autowired + WxPayAccountService wxPayAccountService; + @Override public PageInfo listAsPage(WxProfitSharingReceiverApply record, Integer pageIndex, Integer pageSize) { return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxProfitSharingReceiverApplyMapper.findList(record)); @@ -88,6 +102,52 @@ public class WxProfitSharingReceiverApplyServiceImpl implements WxProfitSharingR return new ResultData(receiverAdd); } + @Override + public ResultData applyment(WxProfitSharingReceiverApply record) { + WxProfitSharingReceiverApply receiverApply = this.selectById(record.getId()); + if(receiverApply == null){ + return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "未找到数据"); + } + WxMerchant merchant = wxMerchantService.selectById(receiverApply.getMerchantId()); + if(merchant == null || EnumMerchantStatus.NOT_VALID.getCode().equals(merchant.getStatus())){ + return new ResultData(ErrorCode.MERCHANT_INFO_NOT_VALID.getCode(),"商户不存在或已停用"); + } + if(receiverApply.getApplymentState() != null && !EnumSharingReceiverApplymentState.getUpdList().contains(receiverApply.getApplymentState())){ + return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "该商户进件流程中,无法申请"); + } + + if(!this.isFinishMain(receiverApply)){ + return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "未完成主体资质"); + } + if(!this.isFinishBusiness(receiverApply)){ + return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "未完成经营信息"); + } + if(!this.isFinishSettlement(receiverApply)){ + return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "未完成行业资质"); + } + if(!this.isFinishBankAccount(receiverApply)){ + return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "未完成结算帐号"); + } + if(!this.isFinishContact(receiverApply)){ + return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "未完成超级管理员"); + } + + ResultData result = this.applyment4subApplyment(receiverApply); + if(result.code == 200){ + WxProfitSharingReceiverApply receiverUpd = new WxProfitSharingReceiverApply(); + receiverUpd.updateTenantInfo(receiverApply); + receiverUpd.setId(receiverApply.getId()); + receiverUpd.setApplymentId((String) result.data); + receiverUpd.setApplymentState(EnumSharingReceiverApplymentState.APPLYMENT_STATE_AUDITING.getCode()); + receiverUpd.setApplymentStateDesc(EnumSharingReceiverApplymentState.APPLYMENT_STATE_AUDITING.getMessage()); + receiverUpd.setUpdateTime(new Date()); + wxProfitSharingReceiverApplyMapper.updateById(receiverUpd); + return result; + }else{ + return result; + } + } + //------------------------------------------------------------------------------------------------------------------ @@ -107,7 +167,6 @@ public class WxProfitSharingReceiverApplyServiceImpl implements WxProfitSharingR receiverAdd.setSalesInfo(JSON.toJSONString(salesInfoMap)); } - } private boolean isFinishMain(WxProfitSharingReceiverApply record){ @@ -652,5 +711,18 @@ public class WxProfitSharingReceiverApplyServiceImpl implements WxProfitSharingR return true; } + private ResultData applyment4subApplyment(WxProfitSharingReceiverApply receiverApply){ + WxPayService wxPayService = wxPayAccountService.getWxPayService(receiverApply.getTenantId()); + try { + WxPayApplyment4SubCreateRequest request = new WxPayApplyment4SubCreateRequest(); + + WxPayApplymentCreateResult wxPayApplymentCreateResult = wxPayService.getApplyment4SubService().createApply(request); + return new ResultData(wxPayApplymentCreateResult.getApplymentId()); + } catch (WxPayException e) { + e.printStackTrace(); + return new ResultData(ErrorCode.SYS_SERVER_ERROR.getCode(),e.getMessage()); + } + } + } diff --git a/mallinkService/src/main/resources/mapper/WxProfitSharingReceiverApplyMapper.xml b/mallinkService/src/main/resources/mapper/WxProfitSharingReceiverApplyMapper.xml index cbc5beede..5866540a2 100644 --- a/mallinkService/src/main/resources/mapper/WxProfitSharingReceiverApplyMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxProfitSharingReceiverApplyMapper.xml @@ -33,7 +33,7 @@ - + @@ -95,7 +95,7 @@ and `organization_type` = #{organizationType} - + and `applyment_id` = #{applymentId}