| | |
| | | package com.ruoyi.shop.service.impl.shop; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.github.binarywang.wxpay.bean.ecommerce.ApplymentsStatusResult; |
| | | import com.google.common.base.Joiner; |
| | | import com.ruoyi.shop.domain.pojo.shop.ShopAuthentication; |
| | | import com.ruoyi.shop.enums.WxApplyMentSignStateEnum; |
| | | import com.ruoyi.shop.enums.WxApplyMentStateEnum; |
| | | import com.ruoyi.shop.enums.dict.IDict; |
| | | import com.ruoyi.shop.mapper.shop.ShopAuthenticationMapper; |
| | | import com.ruoyi.shop.service.shop.ShopAuthenticationService; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | @Service |
| | | public class ShopAuthenticationServiceImpl extends ServiceImpl<ShopAuthenticationMapper, ShopAuthentication> implements ShopAuthenticationService { |
| | | |
| | | @Override |
| | | public List<ShopAuthentication> getShopAuthNeedUpdateStatus() { |
| | | List<Integer> auditStatusList = Arrays.asList(1, 2, 3, 5); |
| | | |
| | | LambdaQueryWrapper<ShopAuthentication> queryWrapper = Wrappers.lambdaQuery(); |
| | | queryWrapper.in(ShopAuthentication::getAuditStatus, auditStatusList); |
| | | queryWrapper.isNotNull(ShopAuthentication::getApplymentId); |
| | | return this.list(queryWrapper); |
| | | } |
| | | |
| | | @Override |
| | | public void updateAuditStatusByApplymentId(String applymentId, ApplymentsStatusResult result) { |
| | | // WxApplyMentStateEnum |
| | | String applymentState = result.getApplymentState(); |
| | | Integer auditStatus = IDict.getCodeByText(WxApplyMentStateEnum.class, applymentState); |
| | | |
| | | Integer signState = IDict.getCodeByText(WxApplyMentSignStateEnum.class, result.getSignState()); |
| | | |
| | | LambdaUpdateWrapper<ShopAuthentication> updateWrapper = Wrappers.lambdaUpdate(); |
| | | updateWrapper.eq(ShopAuthentication::getApplymentId, applymentId) |
| | | .set(ShopAuthentication::getAuditStatus, auditStatus) |
| | | .set(ShopAuthentication::getSignState, signState); |
| | | |
| | | if(WxApplyMentStateEnum.ACCOUNT_NEED_VERIFY.getCode().equals(auditStatus)){ |
| | | // ACCOUNT_NEED_VERIFY 待账户验证 |
| | | updateWrapper.set(ShopAuthentication::getLegalValidationUrl, result.getLegalValidationUrl()); |
| | | ApplymentsStatusResult.AccountValidation accountValidation = result.getAccountValidation(); |
| | | if(null != accountValidation) { |
| | | updateWrapper.set(ShopAuthentication::getAvAccountName, accountValidation.getAccountName()) |
| | | .set(ShopAuthentication::getAvAccountNo, accountValidation.getAccountNo()) |
| | | .set(ShopAuthentication::getAvPayAmount, accountValidation.getPayAmount()) |
| | | .set(ShopAuthentication::getDaNumber, accountValidation.getDestinationAccountNumber()) |
| | | .set(ShopAuthentication::getDaName, accountValidation.getDestinationAccountName()) |
| | | .set(ShopAuthentication::getDaBank, accountValidation.getDestinationAccountBank()) |
| | | .set(ShopAuthentication::getDaCity, accountValidation.getCity()) |
| | | .set(ShopAuthentication::getDaRemark, accountValidation.getRemark()) |
| | | .set(ShopAuthentication::getDaDeadline, accountValidation.getDeadline()); |
| | | } |
| | | } else if(WxApplyMentStateEnum.NEED_SIGN.getCode().equals(auditStatus)){ |
| | | // NEED_SIGN 待签约 |
| | | updateWrapper.set(ShopAuthentication::getSignUrl, result.getSignUrl()); |
| | | updateWrapper.set(ShopAuthentication::getSubMchid, result.getSubMchid()); |
| | | |
| | | } else if(WxApplyMentStateEnum.FINISH.getCode().equals(auditStatus)){ |
| | | // FINISH 完成 |
| | | updateWrapper.set(ShopAuthentication::getSubMchid, result.getSubMchid()); |
| | | |
| | | } else if(WxApplyMentStateEnum.REJECTED.getCode().equals(auditStatus) |
| | | || WxApplyMentStateEnum.FROZEN.getCode().equals(auditStatus)){ |
| | | List<ApplymentsStatusResult.AuditDetail> auditDetail = result.getAuditDetail(); |
| | | if(null != auditDetail && !auditDetail.isEmpty()){ |
| | | List<String> paramNameList = auditDetail.stream().map(ApplymentsStatusResult.AuditDetail::getParamName).collect(Collectors.toList()); |
| | | List<String> rejectReason = auditDetail.stream().map(ApplymentsStatusResult.AuditDetail::getRejectReason).collect(Collectors.toList()); |
| | | updateWrapper.set(ShopAuthentication::getAdParamName, Joiner.on(";").join(paramNameList)) |
| | | .set(ShopAuthentication::getAdRejectReason, Joiner.on(";").join(rejectReason)); |
| | | } |
| | | |
| | | } |
| | | this.update(updateWrapper); |
| | | } |
| | | |
| | | @Override |
| | | public ShopAuthentication getByShopId(Long shopId) { |
| | | LambdaQueryWrapper<ShopAuthentication> queryWrapper = Wrappers.lambdaQuery(); |
| | | queryWrapper.eq(ShopAuthentication::getShopId, shopId) |
| | | .last(" limit 1 "); |
| | | return this.getOne(queryWrapper); |
| | | } |
| | | } |