Merge branch 'refs/heads/master' into cc_2021104_twelve_points

# Conflicts:
#	coolstore-partner-common/src/main/java/com/cool/store/enums/ErrorCodeEnum.java
#	coolstore-partner-common/src/main/java/com/cool/store/enums/JoinModeEnum.java
This commit is contained in:
wangff
2025-12-02 19:34:14 +08:00
193 changed files with 10187 additions and 167 deletions

View File

@@ -0,0 +1,239 @@
package com.cool.store.http;
import com.alibaba.fastjson.JSONObject;
import com.cool.store.enums.ErrorCodeEnum;
import com.cool.store.exception.ServiceException;
import com.cool.store.utils.RsaSignUtil;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.extern.slf4j.Slf4j;
import okhttp3.*;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @Author suzhuhong
* @Date 2025/11/13 10:00
* @Version 1.0
*/
@Service
@Slf4j
public class WalletHttpClientRest {
@Autowired
private OkHttpClient okHttpClient;
@Autowired
private ObjectMapper objectMapper;
@Value("${cool.api.rsa.private.key}")
private String coolPrivateKey;
@Value("${wallet.api.rsa.public.key}")
private String walletPublicKey;
@Value("${wallet.api.yzt.key}")
private String yztKey;
/**
* 发送带签名的POST请求
*/
public <T> T postWithSign(String url, Object request, Class<T> responseType) {
try {
// 1. 准备请求参数
Map<String, Object> requestParams = convertToMap(request);
requestParams.put("timestamp", System.currentTimeMillis());
requestParams.put("key", yztKey);
// 2. 生成签名
String signature = RsaSignUtil.generateSign(requestParams,coolPrivateKey);
requestParams.put("sign", signature);
// 3. 发送请求
String responseJson = executePost(url, requestParams);
// 4. 解析响应
return parseResponse(responseJson, responseType);
} catch (ServiceException e) {
throw e;
} catch (Exception e) {
// 其他异常统一包装为RuntimeException
log.error("发送带签名POST请求失败: {}", url, e);
throw new RuntimeException("接口调用异常: " + e.getMessage(), e);
}
}
/**
* 发送带签名和验签的POST请求
*/
public <T> T postWithSignAndVerify(String url, Object request, Class<T> responseType) {
try {
// 1. 准备请求参数
Map<String, Object> requestParams = convertToMap(request);
requestParams.put("timestamp", System.currentTimeMillis());
// 2. 生成签名
String signature = RsaSignUtil.generateSign(requestParams,coolPrivateKey);
requestParams.put("sign", signature);
// 3. 发送请求
String responseJson = executePost(url, requestParams);
// 4. 解析响应并验证签名
return parseAndVerifyResponse(responseJson, responseType);
} catch (Exception e) {
log.error("发送带签名和验签POST请求失败: {}", url, e);
throw new RuntimeException(e.getMessage());
}
}
/**
* 发送普通POST请求无签名
*/
public <T> T post(String url, Object request, Class<T> responseType) {
try {
String responseJson = executePost(url, request);
return parseResponse(responseJson, responseType);
} catch (Exception e) {
log.error("发送POST请求失败: {}", url, e);
throw new RuntimeException("调用外部接口失败: " + e.getMessage());
}
}
/**
* 执行POST请求
*/
private String executePost(String url, Object body) throws IOException {
String jsonBody = objectMapper.writeValueAsString(body);
RequestBody requestBody = RequestBody.create( MediaType.parse("application/json; charset=utf-8"),jsonBody);
Request request = new Request.Builder()
.url(url)
.post(requestBody)
.addHeader("Content-Type", "application/json")
.build();
log.info("发送POST请求: {}, 数据: {}", url, jsonBody);
try (Response response = okHttpClient.newCall(request).execute()) {
if (!response.isSuccessful()) {
throw new ServiceException(ErrorCodeEnum.THIRD_API_ERROR,response.code() + " " + response.message());
}
String responseBody = response.body().string();
log.info("收到响应: {}", responseBody);
checkBusinessResponseCode(responseBody);
return responseBody;
}
}
private void checkBusinessResponseCode(String responseJson) throws IOException {
try {
Map<String, Object> responseMap = objectMapper.readValue(responseJson,
new TypeReference<Map<String, Object>>() {
});
Object codeObj = responseMap.get("code");
if (codeObj != null) {
int code = 0;
if (codeObj instanceof Number) {
code = ((Number) codeObj).intValue();
} else {
code = Integer.parseInt(codeObj.toString());
}
if (code != 200) {
String msg = (String) responseMap.get("msg");
// 700-799为平安银行错误
if (code >= 700 && code <= 799) {
throw new ServiceException(ErrorCodeEnum.WALLET_API_ERROR, msg);
} else {
throw new ServiceException(ErrorCodeEnum.THIRD_API_ERROR,
"code: " + code + ", msg: " + msg);
}
}
}
} catch (ServiceException e) {
throw e;
} catch (Exception e) {
// 如果解析失败,说明可能不是标准格式,继续处理
log.debug("无法解析响应码格式: {}", e.getMessage());
}
}
/**
* 解析响应
*/
@SuppressWarnings("unchecked")
private <T> T parseResponse(String responseJson, Class<T> responseType) throws Exception {
// 解析为通用响应格式
Map<String, Object> responseMap = objectMapper.readValue(responseJson,
new TypeReference<Map<String, Object>>() {});
// 如果返回类型是Map直接返回
if (responseType == Map.class) {
return (T) responseMap;
}
// 提取data字段
Object data = responseMap.get("data");
if (data != null && responseType != Object.class) {
if (data instanceof List) {
// 保持List结构让调用方处理具体类型转换
return (T)JSONObject.toJSONString(data);
}
return objectMapper.convertValue(data, responseType);
}
return objectMapper.convertValue(responseMap, responseType);
}
/**
* 解析响应并验证签名
*/
@SuppressWarnings("unchecked")
private <T> T parseAndVerifyResponse(String responseJson, Class<T> responseType) throws Exception {
// 解析为Map来验证签名
Map<String, Object> responseMap = objectMapper.readValue(responseJson,
new TypeReference<Map<String, Object>>() {});
// 验证响应签名
String responseSign = (String) responseMap.get("sign");
if (responseSign != null) {
// 移除sign字段后进行验签
Map<String, Object> verifyParams = new HashMap<>(responseMap);
boolean isValid = RsaSignUtil.verifySign(verifyParams, walletPublicKey);
if (!isValid) {
throw new SecurityException("响应签名验证失败");
}
log.debug("响应签名验证成功");
}
// 返回指定类型的数据
return parseResponse(responseJson, responseType);
}
/**
* 转换为Map
*/
@SuppressWarnings("unchecked")
private Map<String, Object> convertToMap(Object obj) {
if (obj instanceof Map) {
return (Map<String, Object>) obj;
}
return objectMapper.convertValue(obj, new TypeReference<Map<String, Object>>() {});
}
}

View File

@@ -8,6 +8,7 @@ import com.aliyun.openservices.ons.api.bean.Subscription;
import com.cool.store.constants.CommonConstants;
import com.cool.store.enums.RocketMqGroupEnum;
import com.cool.store.mq.RocketMqConfig;
import com.cool.store.mq.consumer.listener.ShopDecorationAssignListener;
import com.cool.store.mq.consumer.listener.StoreUserUpdateListener;
import com.cool.store.mq.consumer.listener.XfsgTrainingPersonSyncListener;
import com.google.common.collect.Maps;
@@ -35,6 +36,8 @@ public class ConsumerClient {
private XfsgTrainingPersonSyncListener xfsgTrainingPersonSyncListener;
@Resource
private StoreUserUpdateListener storeUserUpdateListener;
@Resource
private ShopDecorationAssignListener shopDecorationAssignListener;
/**
* 获取通用配置
@@ -101,4 +104,17 @@ public class ConsumerClient {
return consumerBean;
}
@Bean(initMethod = "start", destroyMethod = "shutdown")
public ConsumerBean shopDecorationAssign() {
RocketMqGroupEnum groupEnum = RocketMqGroupEnum.SHOP_DECORATION_ASSIGN;
ConsumerBean consumerBean = new ConsumerBean();
//配置文件
Properties properties = getCommonProperties(groupEnum);
consumerBean.setProperties(properties);
Map<Subscription, MessageListener> commonSubscriptionTable = getCommonSubscriptionTable(groupEnum, shopDecorationAssignListener);
//订阅多个topic如上面设置
consumerBean.setSubscriptionTable(commonSubscriptionTable);
return consumerBean;
}
}

View File

@@ -0,0 +1,65 @@
package com.cool.store.mq.consumer.listener;
import com.alibaba.fastjson.JSONObject;
import com.aliyun.openservices.ons.api.Action;
import com.aliyun.openservices.ons.api.ConsumeContext;
import com.aliyun.openservices.ons.api.Message;
import com.aliyun.openservices.ons.api.MessageListener;
import com.cool.store.constants.CommonConstants;
import com.cool.store.dao.decoration.ShopDecorationAssignDAO;
import com.cool.store.dto.store.StoreUserPositionDTO;
import com.cool.store.dto.store.StoreUserUpdateDTO;
import com.cool.store.entity.decoration.ShopDecorationAssignDO;
import com.cool.store.service.DecorationHandleService;
import com.cool.store.utils.RedisUtilPool;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Arrays;
import java.util.List;
/**
* @Author suzhuhong
* @Date 2025/11/3 10:13
* @Version 1.0
*/
@Slf4j
@Service
public class ShopDecorationAssignListener implements MessageListener {
@Autowired
public RedisUtilPool redisUtilPool;
@Resource
DecorationHandleService decorationHandleService;
@Resource
ShopDecorationAssignDAO shopDecorationAssignDAO;
@Override
public Action consume(Message message, ConsumeContext context) {
String text = new String(message.getBody());
if(StringUtils.isBlank(text)){
log.info("消息体为空,tag:{},messageId:{}",message.getTag(),message.getMsgID());
return Action.CommitMessage;
}
String lockKey = "ShopDecorationAssignListener:" + message.getMsgID();
boolean lock = redisUtilPool.setNxExpire(lockKey, message.getMsgID(), CommonConstants.NORMAL_LOCK_TIMES);
if(lock){
try {
ShopDecorationAssignDO shopDecorationAssignDO = shopDecorationAssignDAO.getById(Long.valueOf(text));
decorationHandleService.handleDecorationTeam(shopDecorationAssignDO);
}catch (Exception e){
log.error("ShopDecorationAssignListener consume error",e);
return Action.ReconsumeLater;
}finally {
redisUtilPool.delKey(lockKey);
}
log.info("消费成功,tag:{},messageId:{},reqBody={}",message.getTag(),message.getMsgID(),text);
return Action.CommitMessage;
}
return Action.ReconsumeLater;
}
}

View File

@@ -0,0 +1,48 @@
package com.cool.store.service;
import com.cool.store.dto.contract.ContractConfigDTO;
import com.cool.store.dto.contract.ContractListDTO;
import com.cool.store.dto.contract.QueryContractListDTO;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageInfo;
/**
* @Author suzhuhong
* @Date 2025/9/8 15:46
* @Version 1.0
*/
public interface ContractConfigService {
/**
* 新增配置
* @param addContractConfigDTO
* @return
*/
Boolean addContractConfig(ContractConfigDTO addContractConfigDTO);
/**
* 修改配置
* @param addContractConfigDTO
* @return
*/
Boolean updateContractConfig(ContractConfigDTO addContractConfigDTO);
/**
* 查询配置列表
* @param queryContractListDTO
* @return
*/
PageInfo<ContractListDTO> queryContractConfigList(QueryContractListDTO queryContractListDTO);
/**
* 删除配置
* @param id
* @return
*/
Boolean deleteContractConfig(Long id);
}

View File

@@ -0,0 +1,94 @@
package com.cool.store.service;
import com.cool.store.common.PageBasicInfo;
import com.cool.store.dto.ShopSignerInfoDTO;
import com.cool.store.dto.decoration.DecorationListDTO;
import com.cool.store.dto.decoration.DecorationTeamDTO;
import com.cool.store.entity.decoration.ShopDecorationAssignDO;
import com.cool.store.request.decoration.AddTeamRequest;
import com.cool.store.request.decoration.DecorationListRequest;
import com.cool.store.request.decoration.UpdateConstructionTeamRequest;
import com.cool.store.request.decoration.UpdateTeamRequest;
import com.github.pagehelper.PageInfo;
import java.util.List;
/**
* @Author suzhuhong
* @Date 2025/10/29 15:54
* @Version 1.0
*/
public interface DecorationHandleService {
/**
* 新增团队
* @param request
* @return
*/
Boolean addTeam(AddTeamRequest request);
/**
* 修改团队
* @param request
* @return
*/
Boolean update(UpdateTeamRequest request);
/**
* 删除团队
* @param teamId
* @return
*/
Boolean deleteByTeamId(Long teamId);
/**
* pageBasicInfo
* 根据条件查询团队
* @return
*/
PageInfo<DecorationTeamDTO> listByCondition(PageBasicInfo pageBasicInfo );
/**
* openCityId
* @param openCityId
* @return
*/
Long getDecorationTeamIdByCityId(Long openCityId);
/**
* 处理团队
* @param teamId
* @return
*/
Boolean handleDecorationTeam(ShopDecorationAssignDO shopDecorationAssignDO);
/**
* 列表
* @param request
* @return
*/
PageInfo<DecorationListDTO> getDecorationAssignList(DecorationListRequest request);
/**
* 获取门店签约信息
* @param shopId
* @return
*/
ShopSignerInfoDTO getShopSignerInfo(Long shopId);
/**
* 更新施工团队
* @param request
* @return
*/
Boolean updateConstructionTeam(UpdateConstructionTeamRequest request);
}

View File

@@ -1,9 +1,7 @@
package com.cool.store.service;
import com.cool.store.dto.GetAccessTokenDTO;
import com.cool.store.dto.HqtTokenDTO;
import com.cool.store.dto.ModifyPasswordDTO;
import com.cool.store.dto.XgjOrganizationDTO;
import com.cool.store.dto.*;
import com.cool.store.dto.contract.ContractCallbackDTO;
import com.cool.store.request.AuditRequest;
import com.cool.store.request.ZxjpApiRequest;
import com.cool.store.request.xgj.PushFranchiseFeeRequest;
@@ -94,6 +92,13 @@ public interface PushService {
*/
HqtTokenDTO getHqtToken();
/**
* 法大大一期 推送加盟合同信息
* @param contractInformationDTO
* @return
*/
ContractCallbackDTO pushContract(ContractInformationDTO contractInformationDTO);

View File

@@ -4,6 +4,7 @@ import com.cool.store.context.LoginUserInfo;
import com.cool.store.request.AddSignFranchiseRequest;
import com.cool.store.request.AuditApproveRequest;
import com.cool.store.request.AuditResultRequest;
import com.cool.store.request.HqtBuildRequest;
import com.cool.store.response.AddSignFranchiseResponse;
import com.cool.store.response.ResponseResult;
@@ -41,5 +42,16 @@ public interface SignFranchiseService {
*/
Boolean rePay(Long shopId);
/**
* 回退到缴费阶段
* @param shopId
* @return
*/
Boolean backPayFeeStage(AuditApproveRequest request, LoginUserInfo user);
Integer dateHandle();
HqtBuildRequest getHqtBuildRequest(Long shopId);
}

View File

@@ -69,6 +69,7 @@ public class AliyunServiceImpl implements AliyunService {
RecognizeIdentityCardResponse idCardResponse = client.recognizeIdentityCardAdvance(recognizeIdentityCardAdvanceRequest, runtime);
log.info("身份证解析结果:{}", JSONObject.toJSONString(idCardResponse));
RecognizeIdentityCardResponseBody.RecognizeIdentityCardResponseBodyDataFrontResult frontResult = Optional.ofNullable(idCardResponse).map(o -> o.getBody()).map(o -> o.data).map(o -> o.frontResult).orElse(null);
RecognizeIdentityCardResponseBody.RecognizeIdentityCardResponseBodyDataBackResult BackResult = Optional.ofNullable(idCardResponse).map(o -> o.getBody()).map(o -> o.data).map(o -> o.backResult).orElse(null);
if(Objects.nonNull(frontResult)){
String username = frontResult.name;
String liveAddress = frontResult.address;
@@ -80,7 +81,15 @@ public class AliyunServiceImpl implements AliyunService {
String idCard = frontResult.IDNumber;
String nation = frontResult.nationality;
IdentityCardInfoVO result = new IdentityCardInfoVO(username, liveAddress, birthdate, sex, idCard, nation);
log.info("身份证解析:{}", JSONObject.toJSONString(result));
log.info("身份证正面解析:{}", JSONObject.toJSONString(result));
return result;
}
if (Objects.nonNull(BackResult)){
String endDate = BackResult.getEndDate();
String issue = BackResult.getIssue();
String startDate = BackResult.getStartDate();
IdentityCardInfoVO result = new IdentityCardInfoVO(endDate,issue,startDate);
log.info("身份证背面解析:{}", JSONObject.toJSONString(result));
return result;
}
return null;

View File

@@ -19,6 +19,7 @@ import com.cool.store.response.GetStoreInfoByCodeResponse;
import com.cool.store.response.LicenseListResponse;
import com.cool.store.response.SubmitLicenseResponse;
import com.cool.store.service.*;
import com.cool.store.service.wallet.WalletService;
import com.cool.store.utils.RedisUtilPool;
import com.cool.store.utils.StringUtil;
import com.cool.store.utils.poi.StringUtils;
@@ -98,6 +99,9 @@ public class ApplyLicenseServiceImpl implements ApplyLicenseService {
@Resource
UserAuthMappingService userAuthMappingService;
@Resource
WalletService walletService;
@Override
public Boolean submitBusinessLicense(BusinessLicenseRequest request, PartnerUserInfoVO user) {
@@ -144,9 +148,15 @@ public class ApplyLicenseServiceImpl implements ApplyLicenseService {
preparationService.buildStoreAndDecorationComplete(request.getShopId());
preparationService.selectSiteAndBuildStoreComplete(request.getShopId());
}
addTagIfUploadLicense(request.getShopId());
return Boolean.TRUE;
}
private void addTagIfUploadLicense(Long shopId) {
ShopInfoDO shopInfo = shopInfoDAO.getShopInfo(shopId);
walletService.addTagIfUploadLicense(shopId, shopInfo.getStoreId(), shopInfo.getLineId());
}
@Override
public Boolean submitFoodLicense(FoodLicenseRequest request, PartnerUserInfoVO user) {
log.info("submitBusinessLicense request{}", JSONObject.toJSONString(request));

View File

@@ -0,0 +1,96 @@
package com.cool.store.service.impl;
import com.cool.store.dao.ContractConfigDAO;
import com.cool.store.dto.contract.ContractConfigDTO;
import com.cool.store.dto.contract.ContractListDTO;
import com.cool.store.dto.contract.QueryContractListDTO;
import com.cool.store.entity.ContractConfigDO;
import com.cool.store.enums.ErrorCodeEnum;
import com.cool.store.exception.ServiceException;
import com.cool.store.service.ContractConfigService;
import com.cool.store.utils.poi.constant.Constants;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.*;
import java.util.stream.Collectors;
/**
* @Author suzhuhong
* @Date 2025/9/8 15:47
* @Version 1.0
*/
@Service
public class ContractConfigServiceImpl implements ContractConfigService {
@Resource
private ContractConfigDAO contractConfigDAO;
@Override
public Boolean addContractConfig(ContractConfigDTO addContractConfigDTO) {
ContractConfigDO contractConfig = contractConfigDAO.queryContractConfigByBrand(addContractConfigDTO.getBrand(), addContractConfigDTO.getSerialNumber());
if (contractConfig != null){
throw new ServiceException(ErrorCodeEnum.CURRENT_BRAND_SORT_NUMBER_EXIST);
}
ContractConfigDO contractConfigDO = new ContractConfigDO();
BeanUtils.copyProperties(addContractConfigDTO, contractConfigDO);
if (addContractConfigDTO.getFranchiseModeList() != null){
String modelStr = addContractConfigDTO.getFranchiseModeList().stream().collect(Collectors.joining(","));
contractConfigDO.setFranchiseMode("," + modelStr + ",");
}
contractConfigDAO.addContractConfig(contractConfigDO);
return Boolean.TRUE;
}
@Override
public Boolean updateContractConfig(ContractConfigDTO addContractConfigDTO) {
ContractConfigDO contractConfig = contractConfigDAO.queryContractConfigByBrand(addContractConfigDTO.getBrand(), addContractConfigDTO.getSerialNumber());
if (contractConfig != null && !contractConfig.getId().equals(addContractConfigDTO.getId())){
throw new ServiceException(ErrorCodeEnum.CURRENT_BRAND_SORT_NUMBER_EXIST);
}
ContractConfigDO contractConfigDO = new ContractConfigDO();
BeanUtils.copyProperties(addContractConfigDTO, contractConfigDO);
if (addContractConfigDTO.getFranchiseModeList() != null){
String modelStr = addContractConfigDTO.getFranchiseModeList().stream().collect(Collectors.joining(","));
contractConfigDO.setFranchiseMode("," + modelStr + ",");
}
contractConfigDAO.updateContractConfig(contractConfigDO);
return Boolean.TRUE;
}
@Override
public PageInfo<ContractListDTO> queryContractConfigList(QueryContractListDTO queryContractListDTO) {
PageHelper.startPage(queryContractListDTO.getPageNum(), queryContractListDTO.getPageSize());
List<ContractConfigDO> contractConfigDOList = contractConfigDAO.queryContractConfigList(queryContractListDTO.getBrand());
if (CollectionUtils.isEmpty(contractConfigDOList)){
return new PageInfo<>();
}
PageInfo contractConfigDOPageInfo = new PageInfo<>(contractConfigDOList);
List<ContractListDTO> result = new ArrayList<>();
contractConfigDOList.forEach(contractConfigDO -> {
ContractListDTO contractListDTO = new ContractListDTO();
BeanUtils.copyProperties(contractConfigDO, contractListDTO);
result.add(contractListDTO);
});
contractConfigDOPageInfo.setList( result);
return contractConfigDOPageInfo;
}
@Override
public Boolean deleteContractConfig(Long id) {
ContractConfigDO contractConfigDO = contractConfigDAO.queryContractConfigById(id);
if (contractConfigDO == null){
throw new ServiceException(ErrorCodeEnum.CONTRACT_CONFIG_NOT_EXIST);
}
contractConfigDO.setDeleted(Constants.ONE_INTEGER);
//修改配置状态
contractConfigDAO.updateContractConfig(contractConfigDO);
return Boolean.TRUE;
}
}

View File

@@ -0,0 +1,251 @@
package com.cool.store.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.cool.store.common.PageBasicInfo;
import com.cool.store.dao.*;
import com.cool.store.dao.decoration.DecorationTeamConfigDAO;
import com.cool.store.dao.decoration.ShopDecorationAssignDAO;
import com.cool.store.dao.decoration.TeamAreaMappingDAO;
import com.cool.store.dto.ShopSignerInfoDTO;
import com.cool.store.dto.decoration.DecorationListDTO;
import com.cool.store.dto.decoration.DecorationTeamDTO;
import com.cool.store.dto.decoration.TeamAreaMappingDTO;
import com.cool.store.entity.*;
import com.cool.store.entity.decoration.DecorationTeamConfigDO;
import com.cool.store.entity.decoration.ShopDecorationAssignDO;
import com.cool.store.entity.decoration.TeamAreaMappingDO;
import com.cool.store.enums.Decoration.DecorationDescStatus;
import com.cool.store.enums.Decoration.DecorationUseSystemEnum;
import com.cool.store.enums.ErrorCodeEnum;
import com.cool.store.enums.JoinModeEnum;
import com.cool.store.enums.point.ShopSubStageStatusEnum;
import com.cool.store.exception.ServiceException;
import com.cool.store.request.decoration.AddTeamRequest;
import com.cool.store.request.decoration.DecorationListRequest;
import com.cool.store.request.decoration.UpdateConstructionTeamRequest;
import com.cool.store.request.decoration.UpdateTeamRequest;
import com.cool.store.service.DecorationHandleService;
import com.cool.store.service.HqtAPIService;
import com.cool.store.service.SignFranchiseService;
import com.cool.store.utils.RedisUtilPool;
import com.cool.store.utils.StringUtil;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Service;
import springfox.documentation.service.ApiListing;
import javax.annotation.Resource;
import java.util.*;
import java.util.stream.Collectors;
/**
* @Author suzhuhong
* @Date 2025/10/29 15:55
* @Version 1.0
*/
@Service
@Slf4j
public class DecorationHandleServiceImpl implements DecorationHandleService {
@Resource
private DecorationTeamConfigDAO decorationTeamConfigDAO;
@Resource
private TeamAreaMappingDAO teamAreaMappingDAO;
@Resource
ShopDecorationAssignDAO shopDecorationAssignDAO;
@Resource
RedisUtilPool redisUtilPool;
@Resource
private HqtAPIService hqtAPIService;
@Resource
ShopStageInfoDAO shopStageInfoDAO;
@Resource
ShopInfoDAO shopInfoDAO;
@Resource
SignFranchiseService signFranchiseService;
@Resource
RegionDao regionDao;
@Resource
LineInfoDAO lineInfoDAO;
@Resource
private SignFranchiseDAO signFranchiseDAO;
@Override
public Boolean addTeam(AddTeamRequest request) {
//校验
if (Objects.isNull(request)||CollectionUtils.isEmpty(request.getOpenCityIdList()) || StringUtil.isEmpty(request.getTeamName())){
throw new ServiceException(ErrorCodeEnum.PARAMS_REQUIRED);
}
//先删除城市团队关系
teamAreaMappingDAO.deletedIds(request.getOpenCityIdList());
DecorationTeamConfigDO decorationTeamConfigDO = new DecorationTeamConfigDO();
decorationTeamConfigDO.setTeamName(request.getTeamName());
decorationTeamConfigDO.setTeamCode(getNextNumber());
decorationTeamConfigDO.setUseSystem(request.getUserSystem());
decorationTeamConfigDAO.addTeam(decorationTeamConfigDO);
teamAreaMappingDAO.batchInsert(decorationTeamConfigDO.getId(),request.getOpenCityIdList());
return Boolean.TRUE;
}
@Override
public Boolean update(UpdateTeamRequest request) {
if (request.getId() == null||CollectionUtils.isEmpty(request.getOpenCityIdList()) || StringUtil.isEmpty(request.getTeamName())){
throw new ServiceException(ErrorCodeEnum.PARAMS_REQUIRED);
}
DecorationTeamConfigDO teamConfigDO = decorationTeamConfigDAO.getById(request.getId());
if (teamConfigDO==null){
throw new ServiceException(ErrorCodeEnum.PARAMS_VALIDATE_ERROR);
}
teamConfigDO.setTeamName(request.getTeamName());
teamConfigDO.setUseSystem(request.getUserSystem());
decorationTeamConfigDAO.updateTeam(teamConfigDO);
//删除团队城市关系
teamAreaMappingDAO.deletedByTeamId(teamConfigDO.getId());
//新增更新之后的团队城市关系
teamAreaMappingDAO.batchInsert(teamConfigDO.getId(),request.getOpenCityIdList());
return Boolean.TRUE;
}
@Override
public Boolean deleteByTeamId(Long teamId) {
DecorationTeamConfigDO teamConfigDO = decorationTeamConfigDAO.getById(teamId);
if (teamConfigDO==null){
throw new ServiceException(ErrorCodeEnum.PARAMS_VALIDATE_ERROR);
}
//查询当前团队是否有门店使用 有的话 不能删除
Integer count = shopDecorationAssignDAO.countByTeamId(teamId);
if (count != null && count > 0){
throw new ServiceException(ErrorCodeEnum.TEAM_USED);
}
teamConfigDO.setDeleted(1);
teamAreaMappingDAO.deletedByTeamId(teamId);
decorationTeamConfigDAO.updateTeam(teamConfigDO);
return Boolean.TRUE;
}
@Override
public PageInfo<DecorationTeamDTO> listByCondition(PageBasicInfo pageBasicInfo) {
PageHelper.startPage(pageBasicInfo.getPageNum(), pageBasicInfo.getPageSize());
List<DecorationTeamDTO> list = decorationTeamConfigDAO.listByCondition();
if (CollectionUtils.isEmpty(list)){
return new PageInfo<>();
}
List<Long> teamIds = list.stream().map(DecorationTeamDTO::getId).collect(Collectors.toList());
Map<Long, List<TeamAreaMappingDTO>> listMap = teamAreaMappingDAO.listByTeamIdList(teamIds);
list.forEach(x->{
x.setCityList(listMap.get(x.getId()));
});
PageInfo<DecorationTeamDTO> result = new PageInfo<>(list);
return result;
}
@Override
public Long getDecorationTeamIdByCityId(Long openCityId) {
if (openCityId==null){
throw new ServiceException(ErrorCodeEnum.PARAMS_REQUIRED);
}
TeamAreaMappingDO cityInfo = teamAreaMappingDAO.getByCityId(openCityId);
if (Objects.isNull(cityInfo)){
return null;
}
DecorationTeamConfigDO teamInfo = decorationTeamConfigDAO.getById(cityInfo.getTeamId());
return teamInfo.getId();
}
@Override
public Boolean handleDecorationTeam(ShopDecorationAssignDO shopDecorationAssign) {
//先查询
if (shopDecorationAssign == null){
log.info("handleDecorationTeam_error data not exist");
return Boolean.FALSE;
}
//如果门店是已经分配状态 则不能再次分配
if (DecorationDescStatus.ASSIGNED.getCode().equals(shopDecorationAssign.getDecorationDescStatus())){
log.info("handleDecorationTeam id:{},门店已分配", JSONObject.toJSONString(shopDecorationAssign));
}
//没有分配的门店 开始分配
ShopInfoDO shopInfoDO = shopInfoDAO.getShopInfo(shopDecorationAssign.getShopId());
//查询装修团队
DecorationTeamConfigDO teamInfo = decorationTeamConfigDAO.getById(shopDecorationAssign.getDecorationTeamId());
if (teamInfo == null){
log.info("handleDecorationTeam_error team not exist");
return Boolean.FALSE;
}
//配置的系统是红圈通 且不是加盟公司自有店 则推送数据 也就是配置了crm或者是加盟公司自有店 走crm流程
if (teamInfo.getUseSystem().equals(DecorationUseSystemEnum.HQT.getCode())&&!shopInfoDO.getJoinMode().equals(JoinModeEnum.OWN_STORE.getCode())){
hqtAPIService.pushHqtBuild(signFranchiseService.getHqtBuildRequest(shopInfoDO.getId()));
}
shopDecorationAssign.setDecorationDescStatus(DecorationDescStatus.ASSIGNED.getCode());
shopDecorationAssignDAO.update(shopDecorationAssign);
//阶段
shopStageInfoDAO.updateShopStageInfo(shopInfoDO.getId(), ShopSubStageStatusEnum.SHOP_SUB_STAGE_STATUS_861);
return Boolean.TRUE;
}
@Override
public PageInfo<DecorationListDTO> getDecorationAssignList(DecorationListRequest request) {
PageHelper.startPage(request.getPageNum(), request.getPageSize());
List<DecorationListDTO> decorationListDTOS = shopDecorationAssignDAO.listByCondition(request);
if (CollectionUtils.isEmpty(decorationListDTOS)){
return new PageInfo<>();
}
Set<String> regionIds = decorationListDTOS.stream().map(DecorationListDTO::getRegionId).collect(Collectors.toSet());
List<RegionDO> regionList = regionDao.getRegionByRegionIds(new ArrayList<>(regionIds));
//转为map
Map<String, String> regionMap = regionList.stream().collect(Collectors.toMap(RegionDO::getRegionId, RegionDO::getName));
decorationListDTOS.forEach(x->{
x.setRegionName(regionMap.get(x.getRegionId()));
});
return new PageInfo<>(decorationListDTOS);
}
@Override
public ShopSignerInfoDTO getShopSignerInfo(Long shopId) {
if (shopId==null){
throw new ServiceException(ErrorCodeEnum.PARAMS_REQUIRED);
}
ShopInfoDO shopInfo = shopInfoDAO.getShopInfo(shopId);
if (shopInfo == null){
throw new ServiceException(ErrorCodeEnum.SHOP_NOT_EXIST);
}
LineInfoDO lineInfo = lineInfoDAO.getLineInfo(shopInfo.getLineId());
ShopSignerInfoDTO shopSignerInfoDTO = new ShopSignerInfoDTO();
shopSignerInfoDTO.setPartnershipSignatoryFirst(lineInfo.getUsername());
shopSignerInfoDTO.setPartnershipSignatoryFirstMobile(lineInfo.getMobile());
SignFranchiseDO signFranchiseDO = signFranchiseDAO.selectByShopId(shopId);
if (signFranchiseDO!=null){
shopSignerInfoDTO.setPartnershipSignatorySecond(signFranchiseDO.getPartnershipSignatorySecond());
shopSignerInfoDTO.setPartnershipSignatorySecondMobile(signFranchiseDO.getPartnershipSignatorySecondMobile());
}
return shopSignerInfoDTO;
}
@Override
public Boolean updateConstructionTeam(UpdateConstructionTeamRequest request) {
//查询待分配门店信息
ShopDecorationAssignDO shopDecorationAssign = shopDecorationAssignDAO.getById(request.getId());
if (shopDecorationAssign == null){
log.info("handleDecorationTeam_error data not exist");
return Boolean.FALSE;
}
shopDecorationAssign.setDecorationTeamId(request.getTeamId());
handleDecorationTeam(shopDecorationAssign);
return Boolean.TRUE;
}
public String getNextNumber() {
Long current = redisUtilPool.incrby("counter_key", 1);
if (current == 1) {
// 如果是第一次,重新设置为 1因为 increment 从 0 开始)
redisUtilPool.setString("counter_key", "1");
current = 1L;
}
return String.format("TD%04d", current);
}
}

View File

@@ -109,9 +109,9 @@ public class FranchiseFeeServiceImpl implements FranchiseFeeService {
@Transactional(rollbackFor = Exception.class)
public Boolean update(FranchiseFeeRequest request) {
ShopStageInfoDO shopStageInfo = shopStageInfoDAO.getShopSubStageInfo(request.getShopId(), ShopSubStageEnum.SHOP_STAGE_7);
if (shopStageInfo.getShopSubStageStatus().equals(SHOP_SUB_STAGE_STATUS_73.getShopSubStageStatus())){
throw new ServiceException(ErrorCodeEnum.NOT_ALLOW_OPERATE);
}
// if (shopStageInfo.getShopSubStageStatus().equals(SHOP_SUB_STAGE_STATUS_73.getShopSubStageStatus())){
// throw new ServiceException(ErrorCodeEnum.NOT_ALLOW_OPERATE);
// }
FranchiseFeeDO franchiseFeeDO = request.toFranchiseFeeDO();
FranchiseFeeDO franchiseFeeDO1 = franchiseFeeMapper.selectByShopId(request.getShopId());
if (Objects.nonNull(franchiseFeeDO1)) {
@@ -236,9 +236,9 @@ public class FranchiseFeeServiceImpl implements FranchiseFeeService {
return ApiResponse.error(ErrorCodeEnum.SHOP_ID_NOT_EXIST);
}
FranchiseFeeDO franchiseFeeDO = franchiseFeeMapper.selectByShopId(request.getShopId());
if (XGJCollectionStatusEnum.COMPLETED.getCode().equals(franchiseFeeDO.getXgjCollectionStatus())){
return ApiResponse.error(ErrorCodeEnum.XGJ_COLLECTION_STATUS_COMPLETE);
}
// if (XGJCollectionStatusEnum.COMPLETED.getCode().equals(franchiseFeeDO.getXgjCollectionStatus())){
// return ApiResponse.error(ErrorCodeEnum.XGJ_COLLECTION_STATUS_COMPLETE);
// }
franchiseFeeDO.setXgjCollectionStatus(request.getPaymentStatus());
franchiseFeeDO.setXgjRemainderPayableAmount(request.getRemainingFee());
franchiseFeeDO.setXgjFeesPaid(request.getPaidFees());
@@ -250,11 +250,17 @@ public class FranchiseFeeServiceImpl implements FranchiseFeeService {
LinePayDO lastPay = linePayMapper.getLastPay(franchiseFeeDO.getShopId());
lastPay.setRemark(lastPay.getRemark()+"系统监测到您多缴费"+request.getPaidFees().subtract(request.getPayableFee())+"元 请申请退款或留做他用!");
linePayMapper.updateByPrimaryKeySelective(lastPay);
shopStageInfoDAO.batchUpdateShopStageStatus(request.getShopId(),Arrays.asList(SHOP_SUB_STAGE_STATUS_73,SHOP_SUB_STAGE_STATUS_80));
ShopStageInfoDO shopStageStatus = shopStageInfoDAO.getShopSubStageInfo(request.getShopId(), ShopSubStageEnum.SHOP_STAGE_8);
if (SHOP_SUB_STAGE_STATUS_00.getShopSubStageStatus().equals(shopStageStatus.getShopSubStageStatus())){
shopStageInfoDAO.batchUpdateShopStageStatus(request.getShopId(),Arrays.asList(SHOP_SUB_STAGE_STATUS_73,SHOP_SUB_STAGE_STATUS_80));
}
}
franchiseFeeMapper.updateByPrimaryKeySelective(franchiseFeeDO);
if (XGJCollectionStatusEnum.COMPLETED.getCode().equals(request.getPaymentStatus())){
shopStageInfoDAO.batchUpdateShopStageStatus(request.getShopId(),Arrays.asList(SHOP_SUB_STAGE_STATUS_73,SHOP_SUB_STAGE_STATUS_80));
ShopStageInfoDO shopStageStatus = shopStageInfoDAO.getShopSubStageInfo(request.getShopId(), ShopSubStageEnum.SHOP_STAGE_8);
if (SHOP_SUB_STAGE_STATUS_00.getShopSubStageStatus().equals(shopStageStatus.getShopSubStageStatus())){
shopStageInfoDAO.batchUpdateShopStageStatus(request.getShopId(),Arrays.asList(SHOP_SUB_STAGE_STATUS_73,SHOP_SUB_STAGE_STATUS_80));
}
}
return ApiResponse.success(Boolean.TRUE);
}

View File

@@ -32,20 +32,17 @@ import com.cool.store.service.UserAuthMappingService;
import com.cool.store.utils.CoolDateUtils;
import com.cool.store.utils.RedisConstantUtil;
import com.cool.store.utils.RedisUtilPool;
import com.cool.store.utils.UUIDUtils;
import com.cool.store.utils.poi.DateUtils;
import com.cool.store.utils.poi.StringUtils;
import com.cool.store.utils.poi.constant.Constants;
import com.cool.store.vo.LinePayVO;
import com.cool.store.vo.PartnerUserInfoVO;
import jdk.nashorn.internal.codegen.types.BooleanType;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestParam;
import javax.annotation.Resource;
import java.math.BigDecimal;
@@ -406,6 +403,9 @@ public class LinePayServiceImpl implements LinePayService {
// map);
// }
if (PayBusinessTypeEnum.INTENT_MONEY.getCode().equals(request.getPayBusinessType())) {
if (!WorkflowSubStageStatusEnum.PAY_DEPOSIT_45.getCode().equals(lineInfo.getWorkflowSubStageStatus())){
throw new ServiceException(ErrorCodeEnum.SHOP_STAGE_NOT_OPERATE);
}
lineInfo.setWorkflowSubStage(WorkflowSubStageEnum.PAY_DEPOSIT.getCode());
lineInfo.setWorkflowSubStageStatus(WorkflowSubStageStatusEnum.PAY_DEPOSIT_50.getCode());
lineInfoDAO.insertOrUpdate(lineInfo);

View File

@@ -1,6 +1,8 @@
package com.cool.store.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.cool.store.dto.*;
import com.cool.store.dto.contract.ContractCallbackDTO;
import com.cool.store.dao.EnterpriseUserDAO;
import com.cool.store.dao.EnterpriseUserRoleDao;
import com.cool.store.dao.StoreDao;
@@ -139,6 +141,11 @@ public class PushServiceImpl implements PushService {
String apiUrl = xgjUrl + "/dmp/dmp-join/open/franchiseeBill";
return executePostApiCall(apiUrl, request, Boolean.class, xgjUsername, xgjSecret,getXgjAccessToken().getAccess_token());
}
@Override
public ContractCallbackDTO pushContract(ContractInformationDTO contractInformationDTO) {
String apiUrl = xgjUrl + "/dmp/dmp-join/open/franchiseContract";
return executePostApiCall(apiUrl, contractInformationDTO, ContractCallbackDTO.class, xgjUsername, xgjSecret,getXgjAccessToken().getAccess_token());
}
@Override
public Boolean pushReceiptToXGJ(ReceiptRequest request) {
@@ -327,6 +334,7 @@ public class PushServiceImpl implements PushService {
}
}
private <T> T executeApiCall(String url, Object requestBody, Class<T> responseType, String username, String secret){
return executePostApiCall(url,requestBody,responseType,username,secret,null);
}

View File

@@ -563,6 +563,7 @@ public class ShopServiceImpl implements ShopService {
response.setLineId(dto.getLineId());
response.setUsername(dto.getUsername());
response.setMobile(dto.getMobile());
response.setStoreId(dto.getStoreId());
response.setShopName(dto.getShopName());
response.setShopCode(dto.getShopCode());
response.setRegionName(regionNameMap.getOrDefault(dto.getRegionId(), ""));

View File

@@ -5,13 +5,24 @@ import com.alibaba.fastjson.JSONObject;
import com.cool.store.constants.CommonConstants;
import com.cool.store.context.LoginUserInfo;
import com.cool.store.dao.*;
import com.cool.store.dto.ContractInformationDTO;
import com.cool.store.dao.decoration.DecorationTeamConfigDAO;
import com.cool.store.dao.decoration.ShopDecorationAssignDAO;
import com.cool.store.dao.decoration.TeamAreaMappingDAO;
import com.cool.store.dto.PartnerBankInfoDTO;
import com.cool.store.dto.contract.ContractCallbackDTO;
import com.cool.store.dto.contract.PushContractDTO;
import com.cool.store.entity.*;
import com.cool.store.entity.decoration.DecorationTeamConfigDO;
import com.cool.store.entity.decoration.ShopDecorationAssignDO;
import com.cool.store.entity.decoration.TeamAreaMappingDO;
import com.cool.store.enums.*;
import com.cool.store.enums.Decoration.DecorationDescStatus;
import com.cool.store.enums.point.ShopSubStageEnum;
import com.cool.store.enums.point.ShopSubStageStatusEnum;
import com.cool.store.exception.ServiceException;
import com.cool.store.mapper.*;
import com.cool.store.mq.producer.SimpleMessageService;
import com.cool.store.request.*;
import com.cool.store.response.AddSignFranchiseResponse;
import com.cool.store.response.ResponseResult;
@@ -25,8 +36,10 @@ import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import sun.font.Decoration;
import javax.annotation.Resource;
import java.math.BigDecimal;
@@ -60,6 +73,8 @@ public class SignFranchiseServiceImpl implements SignFranchiseService, AuditResu
private EnterpriseUserRoleDao enterpriseUserRoleDao;
@Resource
SignFranchiseMapper signFranchiseMapper;
@Resource
SignFranchiseDAO signFranchiseDAO;
@Resource
UserAuthMappingService userAuthMappingService;
@@ -120,45 +135,57 @@ public class SignFranchiseServiceImpl implements SignFranchiseService, AuditResu
OperationLogService operationLogService;
@Resource
OperationLogDAO operationLogDAO;
@Resource
ContractConfigDAO contractConfigDAO;
@Resource
PushService pushService;
@Resource
TeamAreaMappingDAO teamAreaMappingDAO;
@Resource
DecorationTeamConfigDAO decorationTeamConfigDAO;
@Resource
ShopDecorationAssignDAO shopDecorationAssignDAO;
@Resource
private SimpleMessageService simpleMessageService;
@Override
public Boolean auditResult(AuditResultRequest request) {
log.info("SignFranchiseServiceImpl auditResult request{}", JSONObject.toJSONString(request));
Long shopId = getShopId(request.getKdzBusinessId());
ShopSubStageStatusEnum shopSubStageStatusEnum = null;
if (request.getAuditResult() == 1) {
shopSubStageStatusEnum = SHOP_SUB_STAGE_STATUS_84;
} else if (request.getAuditResult() == 0) {
shopSubStageStatusEnum = ShopSubStageStatusEnum.SHOP_SUB_STAGE_STATUS_85;
}
ShopAuditInfoDO shopAuditInfoDO = new ShopAuditInfoDO();
shopAuditInfoDO.setShopId(shopId);
shopAuditInfoDO.setAuditType(AuditTypeEnum.SIGN_FRANCHISE.getCode());
shopAuditInfoDO.setSubmittedUserId("");
shopAuditInfoDO.setSubmittedUserName("");
if (Constants.ZERO_INTEGER.equals(request.getAuditResult())) {
shopAuditInfoDO.setResultType(Constants.ONE_INTEGER);
shopAuditInfoDO.setRejectReason(request.getCause());
Map<String, String> requestMap = new HashMap<>();
ShopInfoDO shopInfoDO = shopInfoMapper.selectByPrimaryKey(shopId);
LineInfoDO lineInfo = lineInfoMapper.getByLineId(shopInfoDO.getLineId());
requestMap.put("storeName", shopInfoDO.getShopName());
requestMap.put("partnerName", lineInfo.getUsername());
requestMap.put("partnerMobile", lineInfo.getMobile());
requestMap.put("lineId", String.valueOf(lineInfo.getId()));
requestMap.put("shopId", String.valueOf(shopInfoDO.getId()));
commonService.sendMessage(Collections.singletonList(lineInfo.getInvestmentManager()), MessageEnum.MESSAGE_20, requestMap);
} else if (Constants.ONE_INTEGER.equals(request.getAuditResult())) {
shopAuditInfoDO.setResultType(Constants.ZERO_INTEGER);
shopAuditInfoDO.setPassReason(request.getCause());
//校验建店与加盟签约合同是否完成 并初始化后续流程数据
//preparationService.contractAndBuildStoreCompletion(shopId);
}
shopAuditInfoMapper.insertSelective(shopAuditInfoDO);
Long auditId = shopAuditInfoDO.getId();
shopStageInfoDAO.updateShopStageAndAuditInfo(shopId, shopSubStageStatusEnum, auditId);
signFranchiseMapper.updateAuditByShopId(auditId, shopId);
// Long shopId = getShopId(request.getKdzBusinessId());
// ShopSubStageStatusEnum shopSubStageStatusEnum = null;
// if (request.getAuditResult() == 1) {
// shopSubStageStatusEnum = SHOP_SUB_STAGE_STATUS_84;
// } else if (request.getAuditResult() == 0) {
// shopSubStageStatusEnum = ShopSubStageStatusEnum.SHOP_SUB_STAGE_STATUS_85;
// }
// ShopAuditInfoDO shopAuditInfoDO = new ShopAuditInfoDO();
// shopAuditInfoDO.setShopId(shopId);
// shopAuditInfoDO.setAuditType(AuditTypeEnum.SIGN_FRANCHISE.getCode());
// shopAuditInfoDO.setSubmittedUserId("");
// shopAuditInfoDO.setSubmittedUserName("");
// if (Constants.ZERO_INTEGER.equals(request.getAuditResult())) {
// shopAuditInfoDO.setResultType(Constants.ONE_INTEGER);
// shopAuditInfoDO.setRejectReason(request.getCause());
// Map<String, String> requestMap = new HashMap<>();
// ShopInfoDO shopInfoDO = shopInfoMapper.selectByPrimaryKey(shopId);
// LineInfoDO lineInfo = lineInfoMapper.getByLineId(shopInfoDO.getLineId());
// requestMap.put("storeName", shopInfoDO.getShopName());
// requestMap.put("partnerName", lineInfo.getUsername());
// requestMap.put("partnerMobile", lineInfo.getMobile());
// requestMap.put("lineId", String.valueOf(lineInfo.getId()));
// requestMap.put("shopId", String.valueOf(shopInfoDO.getId()));
// commonService.sendMessage(Collections.singletonList(lineInfo.getInvestmentManager()), MessageEnum.MESSAGE_20, requestMap);
// } else if (Constants.ONE_INTEGER.equals(request.getAuditResult())) {
// shopAuditInfoDO.setResultType(Constants.ZERO_INTEGER);
// shopAuditInfoDO.setPassReason(request.getCause());
// //校验建店与加盟签约合同是否完成 并初始化后续流程数据
// //preparationService.contractAndBuildStoreCompletion(shopId);
// }
// shopAuditInfoMapper.insertSelective(shopAuditInfoDO);
// Long auditId = shopAuditInfoDO.getId();
// shopStageInfoDAO.updateShopStageAndAuditInfo(shopId, shopSubStageStatusEnum, auditId);
//signFranchiseMapper.updateAuditByShopId(auditId, shopId);
return true;
}
@@ -181,6 +208,10 @@ public class SignFranchiseServiceImpl implements SignFranchiseService, AuditResu
if (StringUtils.isNotEmpty(request.getShopName())&&request.getShopName().matches("^店铺.$")) {
throw new ServiceException(ErrorCodeEnum.SYSTEM_NAME_NOT__SUPPORT);
}
//校验金额
if (!feeCheck(request)){
throw new ServiceException(ErrorCodeEnum.FEE_NOT_CONSISTENT);
}
SignFranchiseDO isExist = signFranchiseMapper.selectByShopId(request.getShopId());
if (Objects.nonNull(isExist) && Objects.isNull(request.getId())) {
throw new ServiceException(ErrorCodeEnum.DUPLICATE_SUBMISSION);
@@ -197,6 +228,7 @@ public class SignFranchiseServiceImpl implements SignFranchiseService, AuditResu
if (Boolean.TRUE.equals(acquired)) {
SignFranchiseDO signFranchiseDO = request.toSignFranchiseDO();
if (Objects.isNull(request.getId())) {
signFranchiseDO.setCreateUserId(user.getUserId());
signFranchiseMapper.insertSelective(signFranchiseDO);
shopStageInfoDAO.updateShopStageInfo(request.getShopId(), ShopSubStageStatusEnum.SHOP_SUB_STAGE_STATUS_83);
//发送通知
@@ -217,7 +249,22 @@ public class SignFranchiseServiceImpl implements SignFranchiseService, AuditResu
OperationTypeEnum.OPERATION_TYPE_1, "加盟签约合同审批", OperationStatusEnum.NOT_PROCESSED);
} else {
//修改签约人信息
signFranchiseMapper.updateByPrimaryKeySelective(signFranchiseDO);
//如果已经签约 修改之后从新推送数据到新管家
ShopStageInfoDO shopSubStageInfo = shopStageInfoDAO.getShopSubStageInfo(request.getShopId(), ShopSubStageEnum.SHOP_STAGE_8);
if (shopSubStageInfo.getShopSubStageStatus().equals(ShopSubStageStatusEnum.SHOP_SUB_STAGE_STATUS_84.getShopSubStageStatus())){
//如果已经签约 修改之后从新推送数据
ContractCallbackDTO contractCallbackDTO = pushContractRequest(shopInfoDO, request.getShopId());
if (!Objects.isNull(contractCallbackDTO)){
if (StringUtils.isNoneEmpty(contractCallbackDTO.getStoreCode())){
shopInfoDO.setShopCode(contractCallbackDTO.getStoreCode());
shopInfoDAO.updateShopInfo(shopInfoDO);
}
signFranchiseDAO.updateAuditByShopId(null, request.getShopId(),contractCallbackDTO);
}
}
}
//修改shop & point
updateShopAndPoint(request, shopInfoDO, pointInfoById);
@@ -249,6 +296,10 @@ public class SignFranchiseServiceImpl implements SignFranchiseService, AuditResu
if (Objects.isNull(request.getShopId())) {
throw new ServiceException(ErrorCodeEnum.SHOP_ID_NOT_EXIST);
}
//校验金额
if (!feeCheck(request)){
throw new ServiceException(ErrorCodeEnum.FEE_NOT_CONSISTENT);
}
ShopInfoDO shopInfoDO = shopInfoMapper.selectByPrimaryKey(request.getShopId());
PointInfoDO pointInfoById = pointInfoDAO.getPointInfoById(shopInfoDO.getPointId());
SignFranchiseDO signFranchiseDO = request.toSignFranchiseDO();
@@ -279,6 +330,44 @@ public class SignFranchiseServiceImpl implements SignFranchiseService, AuditResu
return Boolean.TRUE;
}
/**
* 费用校验
* @param request
* @return
*/
private Boolean feeCheck(AddSignFranchiseRequest request){
//查询账单金额
FranchiseFeeDO franchiseFeeDO = franchiseFeeMapper.selectByShopId(request.getShopId());
//正新鸡排
if (franchiseFeeDO.getYearFranchiseFee()!=null&&request.getContractFranchiseFee()!=null&&!request.getContractFranchiseFee().equals(franchiseFeeDO.getYearFranchiseFee())){
return Boolean.FALSE;
}
//合同设计费
if (franchiseFeeDO.getPerformanceBond()!=null&&request.getContractPerformanceBond()!=null&&!request.getContractPerformanceBond().equals(franchiseFeeDO.getPerformanceBond())){
return Boolean.FALSE;
}
//品牌使用费
if (franchiseFeeDO.getFirstYearFee()!=null&&request.getContractBrandUseFee()!=null&&!request.getContractBrandUseFee().equals(franchiseFeeDO.getFirstYearFee())){
return Boolean.FALSE;
}
//合同保证金
if (franchiseFeeDO.getLoanMargin()!=null&&request.getContractLoanMargin()!=null&&!request.getContractLoanMargin().equals(franchiseFeeDO.getLoanMargin())){
return Boolean.FALSE;
}
//合同管理费
if (franchiseFeeDO.getFirstYearManageFee()!=null&&request.getContractManageFee()!=null&&!request.getContractManageFee().equals(franchiseFeeDO.getFirstYearManageFee())){
return Boolean.FALSE;
}
if (franchiseFeeDO.getCashierFee()!=null&&request.getContractSysUserFee()!=null&&!request.getContractSysUserFee().equals(franchiseFeeDO.getCashierFee())){
return Boolean.FALSE;
}
return Boolean.TRUE;
}
private void updateShopAndPoint(AddSignFranchiseRequest request, ShopInfoDO shopInfoDO, PointInfoDO pointInfoById) {
//店铺信息
shopInfoDO.setManagerRegionId(request.getManagerRegionId());
@@ -362,6 +451,7 @@ public class SignFranchiseServiceImpl implements SignFranchiseService, AuditResu
shopAuditInfoDO.setSubmittedUserId(user.getUserId());
shopAuditInfoDO.setSubmittedUserName(user.getName());
//驳回
ContractCallbackDTO contractCallbackDTO = null;
if (Constants.ZERO_INTEGER.equals(request.getAuditResult())) {
shopAuditInfoDO.setResultType(Constants.ONE_INTEGER);
shopAuditInfoDO.setRejectReason(request.getCause());
@@ -395,10 +485,26 @@ public class SignFranchiseServiceImpl implements SignFranchiseService, AuditResu
));
}else{
//,加盟公司自有店->加盟公司建店 不推送数据 再crm中完成
if ( !shopInfoDO.getJoinMode().equals(JoinModeEnum.OWN_STORE.getCode())){
hqtAPIService.pushHqtBuild(getHqtBuildRequest(request.getShopId()));
//v2.0.0 先确认装修团队
TeamAreaMappingDO city = teamAreaMappingDAO.getByCityId(shopInfoDO.getWantShopAreaId());
//默认团队
Long teamId = 1L;
if (Objects.nonNull(city)) {
//v2.0.0 确认团队
DecorationTeamConfigDO decorationTeamConfigDO = decorationTeamConfigDAO.getById(city.getTeamId());
if (Objects.nonNull(decorationTeamConfigDO)) {
//v2.0.0 确认团队
teamId = decorationTeamConfigDO.getId();
}
}
shopStageInfoDAO.updateShopStageInfo(shopId, ShopSubStageStatusEnum.SHOP_SUB_STAGE_STATUS_861);
ShopDecorationAssignDO shopDecorationAssignDO = new ShopDecorationAssignDO();
shopDecorationAssignDO.setDecorationDescStatus(DecorationDescStatus.TO_BE_ASSIGNED.getCode());
shopDecorationAssignDO.setDecorationTeamId(teamId);
shopDecorationAssignDO.setShopId(shopId);
shopDecorationAssignDAO.insert(shopDecorationAssignDO);
//新增一个延迟队列 四个小时之后确定是否手动分配 没有手动分配 直接自动分配 红圈通推送和下一个流程开始改为分配团队之后 触发
simpleMessageService.send(String.valueOf(shopDecorationAssignDO.getId()), RocketMqTagEnum.DELAY_SHOP_DECORATION_ASSIGN,System.currentTimeMillis() + 4*60*60 * 1000);
}
shopAuditInfoDO.setResultType(Constants.ZERO_INTEGER);
shopAuditInfoDO.setPassReason(request.getCause());
@@ -411,8 +517,9 @@ public class SignFranchiseServiceImpl implements SignFranchiseService, AuditResu
//初始化数据
preparationService.contractAndBuildStoreCompletion(request.getShopId());
SignFranchiseDO signFranchiseDO = signFranchiseMapper.selectByShopId(shopId);
log.info("加盟合同审批时签约类型:{}", SignTypeEnum.getDescByCode(signFranchiseDO.getSignType()));
//推送数据
contractCallbackDTO = pushContractRequest(shopInfoDO, request.getShopId());
Boolean sendNotice = Boolean.TRUE;
commonService.sendSms(lineInfoDO.getMobile(), SMSMsgEnum.SIGN_CONTRACT);
if (sendNotice) {
@@ -436,7 +543,11 @@ public class SignFranchiseServiceImpl implements SignFranchiseService, AuditResu
}
shopAuditInfoMapper.insertSelective(shopAuditInfoDO);
Long auditId = shopAuditInfoDO.getId();
signFranchiseMapper.updateAuditByShopId(auditId, shopId);
if (contractCallbackDTO!=null&&StringUtils.isNotEmpty(contractCallbackDTO.getStoreCode())){
shopInfoDO.setShopCode(contractCallbackDTO.getStoreCode());
shopInfoMapper.updateByPrimaryKeySelective(shopInfoDO);
}
signFranchiseDAO.updateAuditByShopId(auditId, shopId,contractCallbackDTO);
//审批记录表记录
List<OperationLogDO> operationLogs = operationLogDAO.getBySubStageStatusEnumAndsStatus(request.getShopId(), ShopSubStageStatusEnum.SHOP_SUB_STAGE_STATUS_83, OperationTypeEnum.OPERATION_TYPE_1.getCode());
operationLogService.batchUpdateProcessed(operationLogs, auditId, user.getUserId(), request.getCause());
@@ -454,6 +565,85 @@ public class SignFranchiseServiceImpl implements SignFranchiseService, AuditResu
}
}
/**
* 推送合同信息请求
* @param shopId
*/
private ContractCallbackDTO pushContractRequest(ShopInfoDO shopInfoDO,Long shopId){
//推送法大大数据
//查询缴费信息
FranchiseFeeDO franchiseFeeDO = franchiseFeeMapper.selectByShopId(shopId);
SignFranchiseDO signFranchiseDO = signFranchiseMapper.selectByShopId(shopId);
String userName = "";
if (signFranchiseDO != null){
userName = enterpriseUserDAO.getUserName(signFranchiseDO.getCreateUserId());
}
LineInfoDO lineInfo = lineInfoDAO.getLineInfo(shopInfoDO.getLineId());
log.info("加盟合同审批时签约类型:{}", SignTypeEnum.getDescByCode(signFranchiseDO.getSignType()));
ContractInformationDTO contractInformationDTO = new ContractInformationDTO();
if (Objects.nonNull(lineInfo)){
contractInformationDTO.setSignerAddress(lineInfo.getLiveAddress());
contractInformationDTO.setSignerPhone(lineInfo.getMobile());
}
//自营店 无缴费信息 不需要校验
if (franchiseFeeDO != null){
contractInformationDTO.setShopId(shopId);
contractInformationDTO.setJoinModel(shopInfoDO.getJoinMode());
contractInformationDTO.setShopName(shopInfoDO.getShopName());
//品牌信息
contractInformationDTO.setSign1Name(signFranchiseDO.getPartnershipSignatoryFirst());
contractInformationDTO.setSign2Name(signFranchiseDO.getPartnershipSignatorySecond());
contractInformationDTO.setFirstYearFee(franchiseFeeDO.getFirstYearFee());
contractInformationDTO.setLoanMargin(franchiseFeeDO.getLoanMargin());
contractInformationDTO.setFirstYearManagementFee(franchiseFeeDO.getFirstYearManageFee());
contractInformationDTO.setYearFranchiseFee(franchiseFeeDO.getYearFranchiseFee());
contractInformationDTO.setPerformanceBond(franchiseFeeDO.getPerformanceBond());
contractInformationDTO.setContractFranchiseFee(signFranchiseDO.getContractFranchiseFee());
contractInformationDTO.setContractManageFee(signFranchiseDO.getContractManageFee());
contractInformationDTO.setContractBrandUseFee(signFranchiseDO.getContractBrandUseFee());
contractInformationDTO.setContractPerformanceBond(signFranchiseDO.getContractPerformanceBond());
contractInformationDTO.setContractLoanMargin(signFranchiseDO.getContractLoanMargin());
contractInformationDTO.setContractSysUserFee(signFranchiseDO.getContractSysUserFee());
contractInformationDTO.setSignModality(signFranchiseDO.getSignModality());
contractInformationDTO.setFranchiseFeeFrequency(signFranchiseDO.getFranchiseFeeFrequency());
contractInformationDTO.setBrandUseFeeFrequency(signFranchiseDO.getBrandUseFeeFrequency());
contractInformationDTO.setJoinSource(signFranchiseDO.getJoinSource());
contractInformationDTO.setManageFeeFrequency(signFranchiseDO.getManageFeeFrequency());
contractInformationDTO.setDiscountAmount(signFranchiseDO.getDiscountAmount());
contractInformationDTO.setSummitUserName(userName);
contractInformationDTO.setCurrency(signFranchiseDO.getCurrency());
contractInformationDTO.setContractStartTime(DateUtils.dateTime(signFranchiseDO.getContractStartTime()));
contractInformationDTO.setContractEndTime(DateUtils.dateTime(signFranchiseDO.getContractEndTime()));
contractInformationDTO.setContractServiceLife(signFranchiseDO.getContractServiceLife());
//老店转加盟(也叫直营转加盟)
if (SignTypeEnum.DIRECT_SALES_TO_JOINING.getCode().equals(signFranchiseDO.getSignType())){
contractInformationDTO.setOldShopCode(signFranchiseDO.getOldShopCode());
}
FranchiseBrandEnum enumByCode = FranchiseBrandEnum.getEnumByCode(shopInfoDO.getFranchiseBrand());
if (enumByCode != null){
contractInformationDTO.setPayeeName(enumByCode.getPayeeName());
contractInformationDTO.setBrandOwner(enumByCode.getBrandOwner());
}
contractInformationDTO.setContractNo(signFranchiseDO.getContractCode());
try {
return pushService.pushContract(contractInformationDTO);
} catch (Exception e) {
log.error("推送合同信息失败", e);
}
}
return null;
}
@Override
public HqtBuildRequest getHqtBuildRequest(Long shopId) {
ShopInfoDO shopInfo = shopInfoDAO.getShopInfo(shopId);
LineInfoDO lineInfoDO = lineInfoDAO.getLineInfo(shopInfo.getLineId());
@@ -528,35 +718,7 @@ public class SignFranchiseServiceImpl implements SignFranchiseService, AuditResu
addSignFranchiseResponse.setManagerRegionName(managerRegion.getName());
}
if (Objects.nonNull(signFranchiseDO)) {
addSignFranchiseResponse.setUnifiedManagement(signFranchiseDO.getUnifiedManagement());
addSignFranchiseResponse.setId(signFranchiseDO.getId());
addSignFranchiseResponse.setShopId(signFranchiseDO.getShopId());
addSignFranchiseResponse.setSignType(signFranchiseDO.getSignType());
addSignFranchiseResponse.setBrandFee(signFranchiseDO.getBrandFee());
addSignFranchiseResponse.setIsBusinessLicense(signFranchiseDO.getIsBusinessLicense());
addSignFranchiseResponse.setIsFoodLicense(signFranchiseDO.getIsFoodLicense());
addSignFranchiseResponse.setContractStartTime(signFranchiseDO.getContractStartTime());
addSignFranchiseResponse.setContractStartEndTime(signFranchiseDO.getContractEndTime());
addSignFranchiseResponse.setImpressionNum(signFranchiseDO.getImpressionNum());
addSignFranchiseResponse.setBusinessStartHours(signFranchiseDO.getBusinessStartHours());
addSignFranchiseResponse.setBusinessEndHours(signFranchiseDO.getBusinessEndHours());
addSignFranchiseResponse.setIrregularReason(signFranchiseDO.getIrregularReason());
addSignFranchiseResponse.setRemark(signFranchiseDO.getRemark());
addSignFranchiseResponse.setResign(signFranchiseDO.getResign());
addSignFranchiseResponse.setMobile(signFranchiseDO.getMobile());
addSignFranchiseResponse.setContractCode(signFranchiseDO.getContractCode());
addSignFranchiseResponse.setContractAmount(signFranchiseDO.getContractAmount());
addSignFranchiseResponse.setPartnershipSignatoryFirst(signFranchiseDO.getPartnershipSignatoryFirst());
addSignFranchiseResponse.setPartnershipSignatorySecond(signFranchiseDO.getPartnershipSignatorySecond());
addSignFranchiseResponse.setBusinessModel(signFranchiseDO.getBusinessModel());
addSignFranchiseResponse.setPartnershipSignatorySecondIdNumber(signFranchiseDO.getPartnershipSignatorySecondIdNumber());
addSignFranchiseResponse.setPartnershipSignatorySecondMobile(signFranchiseDO.getPartnershipSignatorySecondMobile());
addSignFranchiseResponse.setProtectiveDistance(signFranchiseDO.getProtectiveDistance());
addSignFranchiseResponse.setIntroducer(signFranchiseDO.getIntroducer());
addSignFranchiseResponse.setIntroduceStore(signFranchiseDO.getIntroduceStore());
addSignFranchiseResponse.setIntroductionAward(signFranchiseDO.getIntroductionAward());
addSignFranchiseResponse.setPartnershipSignatoryFirstWhichStore(signFranchiseDO.getPartnershipSignatoryFirstWhichStore());
BeanUtils.copyProperties(signFranchiseDO, addSignFranchiseResponse);
} else {
if (Objects.nonNull(franchiseFeeDO)) {
BigDecimal total = convertToBig(franchiseFeeDO.getYearFranchiseFee())
@@ -651,6 +813,27 @@ public class SignFranchiseServiceImpl implements SignFranchiseService, AuditResu
return true;
}
@Override
public Boolean backPayFeeStage(AuditApproveRequest request, LoginUserInfo user) {
//回退到对账中 此阶段账单可编辑 可再次对账
shopStageInfoDAO.updateShopStageInfo(request.getShopId(), ShopSubStageStatusEnum.SHOP_SUB_STAGE_STATUS_72);
//缴费阶段回退到未开始
shopStageInfoDAO.updateShopStageToNotStarted(request.getShopId(), ShopSubStageEnum.SHOP_STAGE_8);
ShopAuditInfoDO shopAuditInfoDO = new ShopAuditInfoDO();
shopAuditInfoDO.setShopId(request.getShopId());
shopAuditInfoDO.setAuditType(AuditTypeEnum.SIGN_FRANCHISE.getCode());
shopAuditInfoDO.setSubmittedUserId(user.getUserId());
shopAuditInfoDO.setSubmittedUserName(user.getName());
shopAuditInfoDO.setResultType(Constants.ONE_INTEGER);
shopAuditInfoDO.setRejectReason(request.getCause());
shopAuditInfoMapper.insertSelective(shopAuditInfoDO);
Long auditId = shopAuditInfoDO.getId();
//审批记录表记录
List<OperationLogDO> operationLogs = operationLogDAO.getBySubStageStatusEnumAndsStatus(request.getShopId(), ShopSubStageStatusEnum.SHOP_SUB_STAGE_STATUS_83, OperationTypeEnum.OPERATION_TYPE_1.getCode());
operationLogService.batchUpdateProcessed(operationLogs, auditId, user.getUserId(), "回退到缴费阶段,"+request.getCause());
return true;
}
@Override
public Integer dateHandle() {
return signFranchiseMapper.dateHandle();

View File

@@ -1,20 +1,16 @@
package com.cool.store.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.cool.store.context.CurrentUserHolder;
import com.cool.store.dao.*;
import com.cool.store.entity.*;
import com.cool.store.enums.*;
import com.cool.store.enums.point.PaymentMethodEnum;
import com.cool.store.exception.ServiceException;
import com.cool.store.mapper.FranchiseFeeMapper;
import com.cool.store.mapper.SignFranchiseMapper;
import com.cool.store.enums.wallet.YztStoreModel;
import com.cool.store.mq.producer.SimpleMessageService;
import com.cool.store.request.StoreMasterDTO;
import com.cool.store.request.StoreRequestBody;
import com.cool.store.service.OperationLogService;
import com.cool.store.request.wallet.CreateStoreRequest;
import com.cool.store.service.SyncMainSysServer;
import com.cool.store.service.UserAuthMappingService;
import com.cool.store.service.wallet.WalletApiService;
import com.cool.store.utils.poi.StringUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
@@ -25,12 +21,6 @@ import javax.annotation.Resource;
import java.math.BigDecimal;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import static com.cool.store.enums.AuditExecuteEnum.FRANCHISEES;
import static com.cool.store.enums.ExtendFieldTypeEnum.*;
/**
* @Author: WangShuo
@@ -48,39 +38,27 @@ public class SyncMainSysServerImpl implements SyncMainSysServer {
@Resource
private SimpleMessageService simpleMessageService;
@Resource
private SignFranchiseMapper signFranchiseMapper;
@Resource
private BuildInformationDAO buildInformationDAO;
@Resource
private PointInfoDAO pointInfoDAO;
@Resource
FranchiseFeeMapper franchiseFeeMapper;
@Resource
private OperationLogDAO operationLogDAO;
@Resource
private OrderSysInfoDAO orderSysInfoDAO;
@Resource
private ShopStageInfoDAO shopStageInfoDAO;
@Resource
private PreparationServiceImpl preparationService;
@Resource
private UserAuthMappingService userAuthMappingService;
@Resource
private CommonService commonService;
@Resource
private ShopInfoDAO shopInfoDAO;
@Resource
private LineInfoDAO lineInfoDAO;
@Value("${mybatis.configuration.variables.enterpriseId}")
private String eid;
@Resource
private StoreDao storeDao;
private SignFranchiseDAO signFranchiseDAO;
@Resource
SignFranchiseDAO signFranchiseDAO;
private PointDetailInfoDAO pointDetailDAO;
@Resource
PointDetailInfoDAO pointDetailDAO;
private QualificationsInfoDAO qualificationsInfoDAO;
@Resource
QualificationsInfoDAO qualificationsInfoDAO;
private RegionDao regionDao;
@Resource
private WalletApiService walletApiService;
@Override
@Async
@@ -103,6 +81,7 @@ public class SyncMainSysServerImpl implements SyncMainSysServer {
return;
}
storeMasterDTO.setEnterpriseId(eid);
storeMasterDTO.setStoreId(shopInfo.getStoreId());
storeMasterDTO.setStoreStatus("not_open");
storeMasterDTO.setStoreName(shopInfo.getShopName());
storeMasterDTO.setStoreNum(shopInfo.getShopCode());
@@ -206,10 +185,35 @@ public class SyncMainSysServerImpl implements SyncMainSysServer {
}
storeMasterDTO.setSignerInfo(signerInfo);
simpleMessageService.send(JSONObject.toJSONString(storeMasterDTO), RocketMqTagEnum.ZXJP_CREATE_STORE);
// 推送营帐通
pushStoreToYzt(shopInfo, lineInfoDO);
} catch (Exception e) {
log.info("asdStore_error:{},shopId:{}", e.getMessage(), shopId.toString());
}
}
/**
* 钱包推送营帐通创建门店
*/
public void pushStoreToYzt(ShopInfoDO shopInfoDO, LineInfoDO lineInfoDO) {
try {
RegionDO regionDO = regionDao.getRegionById(shopInfoDO.getRegionId());
CreateStoreRequest createStoreRequest = CreateStoreRequest.builder()
.outStoreId(shopInfoDO.getStoreId())
.storeSn(shopInfoDO.getShopCode())
.storeName(shopInfoDO.getShopName())
.orgCode(String.valueOf(regionDO.getId()))
.orgName(regionDO.getName())
.phoneNumber(lineInfoDO.getMobile())
.storeMode(YztStoreModel.getYztStoreModel(Integer.valueOf(shopInfoDO.getFranchiseBrand())))
.province(shopInfoDO.getProvinceCode())
.city(shopInfoDO.getCityCode())
.district(shopInfoDO.getDistrictCode())
.address(shopInfoDO.getDetailAddress())
.build();
walletApiService.createStore(createStoreRequest);
} catch (Exception e) {
log.error("推送营帐通钱包创建门店失败", e);
}
}
}

View File

@@ -0,0 +1,231 @@
package com.cool.store.service.wallet;
import com.alibaba.fastjson.JSONObject;
import com.cool.store.dto.wallet.*;
import com.cool.store.http.WalletHttpClientRest;
import com.cool.store.request.wallet.*;
import com.cool.store.utils.StringUtil;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
/**
* @Author suzhuhong
* @Date 2025/11/13 10:51
* @Version 1.0
*/
@Service
public class WalletApiService {
@Resource
WalletHttpClientRest walletHttpClientRest;
@Value("${wallet.url}")
private String walletBaseUrl;
/**
* 在平安扫呗系统中,创建签约人账户
* @param request
* @return
*/
public StoreAccountDTO createStoreAndAccount(CreateStoreAndAccountRequest request){
return walletHttpClientRest.postWithSign(walletBaseUrl+"/open/crm/account/v1/createStoreAndAccount", request, StoreAccountDTO.class);
}
/**
* 开通失败 开通
* @param request
* @return
*/
public StoreAccountDTO updateStoreAccount(UpdateStoreAccountRequest request){
return walletHttpClientRest.postWithSign(walletBaseUrl+"/open/crm/account/v1/updateStoreAccount", request, StoreAccountDTO.class);
}
/**
* 创建门店接口
* @param request
* @return
*/
public AccountNoDTO createStore(CreateStoreRequest request){
return walletHttpClientRest.postWithSign(walletBaseUrl+"/open/crm/account/v1/createStore", request, AccountNoDTO.class);
}
/**
* 银行发送短信接口
* @param request
* @return
*/
public AccountAuthenticationDTO authentication(OutStoreIdRequest request){
return walletHttpClientRest.postWithSign(walletBaseUrl+"/open/crm/account/v1/authentication", request, AccountAuthenticationDTO.class);
}
/**
* 门店开通平安银行接口
* @param request
* @return
*/
public AccountVerifyDTO openAccount(AccountVerifyRequest request){
return walletHttpClientRest.postWithSign(walletBaseUrl+"/open/crm/account/v1/openAccount", request, AccountVerifyDTO.class);
}
/**
* 签约人账户打标升级
* @param request
* @return
*/
public AddTagDTO addTag(AccountAddTagRequest request){
return walletHttpClientRest.postWithSign(walletBaseUrl+"/open/crm/account/v1/addTag", request, AddTagDTO.class);
}
/**
* 获取账户信息
* @param request
* @return
*/
public List<AccountInfoDTO> getAccountInfo(OutStoreIdRequest request){
String accountInfoStr = walletHttpClientRest.postWithSign(walletBaseUrl+"/open/crm/account/v1/queryAccountInfo", request, String.class);
if (StringUtil.isNotEmpty(accountInfoStr)){
return JSONObject.parseArray(accountInfoStr, AccountInfoDTO.class);
}
return null;
}
/**
* 大额预支付接口
* @param request
* @return
*/
public LargePaymentDTO largePayment(LargePaymentRequest request){
return walletHttpClientRest.postWithSign(walletBaseUrl+"/open/crm/trans/v1/largePayment", request, LargePaymentDTO.class);
}
/**
* 大额预支付查询接口
* @param request
* @return
*/
public PaymentDTO largePaymentQuery(PaymentDetailRequest request){
return walletHttpClientRest.postWithSign(walletBaseUrl+"/open/crm/trans/v1/largePaymentQuery", request, PaymentDTO.class);
}
/**
* 门店账户向公司分账转账接口
* @param request
* @return
*/
public TransferDTO transfer(TransferRequest request){
return walletHttpClientRest.postWithSign(walletBaseUrl+"/open/crm/trans/v1/transfer", request, TransferDTO.class);
}
/**
* 门店签约账户,退款提现至提现卡
* @param request
* @return
*/
public WithDrawerDTO withdraw(WithDrawerRequest request){
return walletHttpClientRest.postWithSign(walletBaseUrl+"/open/crm/trans/v1/withdrawer", request, WithDrawerDTO.class);
}
/**
* 账单详情
* @param request
* @return
*/
public TradeRecordDTO getBillDetail(BillDetailRequest request){
return walletHttpClientRest.postWithSign(walletBaseUrl+"/open/crm/trans/v1/billDetail", request, TradeRecordDTO.class);
}
/**
* 获取门店账户流水
* @param request
* @return
*/
public BillPageDTO getBillPage(BillPageRequest request){
return walletHttpClientRest.postWithSign(walletBaseUrl+"/open/crm/trans/v1/billPage", request, BillPageDTO.class);
}
/**
* 获取门店账户信息
* @param request
* @return
*/
public CompanyListDTO getCompanyInfo(FindPageCompanyRequest request){
return walletHttpClientRest.postWithSign(walletBaseUrl+"/open/crm/base/v1/findPageCompany", request, CompanyListDTO.class);
}
/**
* 获取支行信息
* @param request
* @return
*/
public BankListDTO getBankList(GetBankRequest request) {
return walletHttpClientRest.postWithSign(walletBaseUrl+"/open/crm/base/v1/findPageBank", request, BankListDTO.class);
}
/**
* 修改密码
* @param request
* @return
*/
public String upholdPwd(UpdatePasswordRequest request){
return walletHttpClientRest.postWithSign(walletBaseUrl+"/open/crm/account/v1/upholdPwd", request, String.class);
}
/**
* 获取账户列表信息
* @param request
* @return
*/
public AccountPageDTO getAccountList(AccountBatchQueryRequest request){
return walletHttpClientRest.postWithSign(walletBaseUrl+"/open/crm/account/v1/findAccountPage", request, AccountPageDTO.class);
}
/**
* 获取账户激活链接
* @param request
* @return
*/
public AccountActiveUrlDTO pushAccountActiveUrl(OutStoreIdRequest request){
return walletHttpClientRest.postWithSign(walletBaseUrl+"/open/crm/account/ws/v1/create", request, AccountActiveUrlDTO.class);
}
/**
* 老店创建门店网商账户
* @param request
* @return
*/
public StoreIdDTO oldStoreOpenAccount(OldStoreAccountCreateRequest request){
return walletHttpClientRest.postWithSign(walletBaseUrl+"/open/crm/account/ws/v1/create", request, StoreIdDTO.class);
}
/**
* 获取交易记录列表
* @param request
* @return
*/
public TradeRecordListDTO getTradeRecordList(TradeRecodePageRequest request){
return walletHttpClientRest.postWithSign(walletBaseUrl+"/open/crm/trans/v1/accRecordPage", request, TradeRecordListDTO.class);
}
/**
* 网商银行重新激活发送短链接
* @param request 网商账户重新发送激活短信Request
* @return 网商激活短链DTO
*/
public TextMsgSendDTO textMsgSend(TextMsgSendRequest request){
return walletHttpClientRest.postWithSign(walletBaseUrl+"/open/crm/account/ws/v1/textMsgSend", request, TextMsgSendDTO.class);
}
/**
* 查询密码是否设置
* @param request
* @return
*/
public PasswordDTO passwordIsExist(OutStoreIdRequest request){
return walletHttpClientRest.postWithSign(walletBaseUrl+"/open/crm/account/v1/existPwd", request, PasswordDTO.class);
}
}

View File

@@ -0,0 +1,189 @@
package com.cool.store.service.wallet;
import com.cool.store.dto.wallet.*;
import com.cool.store.request.wallet.*;
import com.cool.store.vo.wallet.*;
import com.github.pagehelper.PageInfo;
import java.util.List;
/**
* <p>
* 钱包 服务类
* </p>
*
* @author wangff
* @since 2025/11/13
*/
public interface WalletService {
/**
* 平安银行钱包账号创建
* @param request 平安钱包账户创建Request
* @return 是否成功
*/
Boolean accountCreate(AccountCreateRequest request);
/**
* 鉴权申请
* @param request 门店id
* @return 是否成功
*/
AccountAuthenticationVO authentication(WalletShopRequest request);
/**
* 账号开通
* @param request 平安钱包账户开通Request
* @return 是否成功
*/
Boolean openAccount(AccountOpenRequest request);
/**
* 银行支行列表查询
* @param request 支行信息查询Request
* @return 银行支行信息列表
*/
PageInfo<BankVO> getBankList(BankListRequest request);
/**
* 判断营业执照是否已经上传,已上传则调用打标接口
* @param shopId 门店shopId
* @param storeId 主数据门店id
* @param lineId 线索id
*/
void addTagIfUploadLicense(Long shopId, String storeId, Long lineId);
/**
* 打标成功回调通知
* @param request
* @return
*/
Boolean addTagCallback(AddTagCallbackNoticeRequest request);
/**
* 大额充值 回调接口
* @param request
* @return
*/
Boolean largePaymentCallback(PaymentDTO request);
/**
* 网商银行 回调接口
* @param request
* @return
*/
Boolean onlineCommercialBankCallback(OnlineCommercialBankCallbackRequest request);
/**
* 账户交易回调
* @param request
* @return
*/
Boolean accountTradeCallback(AccountTradeCallbackRequest request);
/**
* 查询账户列表
* @param request 账户查询Request
* @return 账户信息VO列表
*/
AccountDataVO getAccountList(AccountQueryRequest request);
/**
* 根据账户编号查询账户信息
* @param request 账户查询Request
* @return 账户信息VO
*/
AccountInfoVO getAccountInfo(AccountQueryRequest request);
/**
* 交易流水
* @param request 交易流水查询Request
* @return 账户交易列表VO列表
*/
AccountBillPageVO getBillPage(AccountBillQueryRequest request);
/**
* 账户交易详情
* @param request 交易详情查询Request
* @return 交易详情VO
*/
TradeRecordDTO getBillDetail(BillDetailRequest request);
/**
* 密码维护
* @param request 账户密码维护Request
* @return 是否成功
*/
Boolean passwordUpdate(AccountPasswordRequest request);
/**
* 门店是否存在密码
* @param request
* @return
*/
PasswordDTO existPassword(OutStoreIdRequest request);
/**
* 账户充值
* @param request 账户充值Request
* @return 账户充值VO
*/
AccountPaymentVO payment(AccountPaymentRequest request);
/**
* 未完成充值订单查询
* @param request 查询request
* @return 钱包支付订单VO列表
*/
PageInfo<WalletPaymentOrderVO> nonPaymentOrderPage(LargePaymentQueryRequest request);
/**
* 根据预支付id查询收款账户详情
* @param paymentId 预支付id
* @return 账户充值VO
*/
AccountPaymentVO paymentDetail(String paymentId);
/**
* 提现
* @param request 钱包提现Request
* @return 是否成功
*/
Boolean withDrawer(WalletWithDrawerRequest request);
/**
* 批量查询账户信息 分页查询 所有门店账户
* @param request 批量查询账户信息Request
* @return 账户信息VO列表
*/
PageInfo<AccountPageVO> getAllAccountList(CoolAccountBatchQueryRequest request);
/**
* 批量查询账户交易流水
* @param request
* @return
*/
PageInfo<TradeRecordDTO> getTradeRecordList(CoolTradeRecodePageRequest request);
/**
* 通过门店Code 查询存量客户开通基本信息
* @param storeCode
* @return
*/
OpenBasicInfoDTO getOpenBasicInfo(String storeId, String storeCode);
/**
* 开通网商银行
* @param request
* @return
*/
Boolean openOnlineBankAccount(CoolOpenBasicInfoRequest request);
/**
* 网商发送激活短信
* @param request 门店idRequest
* @return 是否成功
*/
Boolean onlineBankActive(StoreShopRequest request);
}

View File

@@ -0,0 +1,667 @@
package com.cool.store.service.wallet.impl;
import cn.hutool.core.bean.copier.CopyOptions;
import cn.hutool.core.collection.CollStreamUtil;
import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSONObject;
import com.cool.store.constants.CommonConstants;
import com.cool.store.constants.RedisConstant;
import com.cool.store.dao.*;
import com.cool.store.dao.store.StoreMasterSignerInfoDAO;
import com.cool.store.dao.wallet.OpenBankInfoDAO;
import com.cool.store.dao.wallet.TempOpenWalletInfoDAO;
import com.cool.store.dao.wallet.WalletPaymentOrderDAO;
import com.cool.store.dto.wallet.*;
import com.cool.store.entity.*;
import com.cool.store.entity.store.StoreMasterSignerInfoDO;
import com.cool.store.entity.wallet.OpenBankInfoDO;
import com.cool.store.entity.wallet.TempOpenWalletInfoDO;
import com.cool.store.entity.wallet.WalletPaymentOrderDO;
import com.cool.store.enums.ErrorCodeEnum;
import com.cool.store.enums.point.ShopSubStageEnum;
import com.cool.store.enums.point.ShopSubStageStatusEnum;
import com.cool.store.enums.wallet.BankAccountTypeEnum;
import com.cool.store.enums.wallet.BankBusinessTypeEnum;
import com.cool.store.enums.wechat.WalletTypeEnum;
import com.cool.store.exception.ServiceException;
import com.cool.store.mapper.ApplyLicenseMapper;
import com.cool.store.request.wallet.*;
import com.cool.store.service.wallet.WalletApiService;
import com.cool.store.service.wallet.WalletService;
import com.cool.store.utils.BeanUtil;
import com.cool.store.utils.RedisUtilPool;
import com.cool.store.utils.UUIDUtils;
import com.cool.store.vo.wallet.*;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import java.sql.Date;
import java.text.MessageFormat;
import java.time.Duration;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.stream.Collectors;
/**
* <p>
* 钱包 服务实现类
* </p>
*
* @author wangff
* @since 2025/11/13
*/
@Service
@RequiredArgsConstructor
@Slf4j
public class WalletServiceImpl implements WalletService {
private final ShopInfoDAO shopInfoDAO;
private final ShopStageInfoDAO shopStageInfoDAO;
private final ApplyLicenseMapper applyLicenseMapper;
private final WalletApiService walletApiService;
private final WalletPaymentOrderDAO walletPaymentOrderDAO;
private final LineInfoDAO lineInfoDAO;
private final RedisUtilPool redisUtilPool;
private final QualificationsInfoDAO qualificationsInfoDAO;
private final StoreDao storeDao;
private final StoreMasterSignerInfoDAO storeMasterSignerInfoDAO;
private final TempOpenWalletInfoDAO tempOpenWalletInfoDAO;
private final OpenBankInfoDAO openBankInfoDAO;
private final static DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
@Override
public Boolean accountCreate(AccountCreateRequest request) {
ShopInfoDO shopInfo = getAndVerifyShopAndStage(request.getShopId());
// 存储银行卡信息
OpenBankInfoDO openBankInfoDO = OpenBankInfoDO.builder()
.storeId(shopInfo.getStoreId())
.settlementCard(request.getBankNumber())
.bankBranchName(request.getBankName())
.bankBranchCode(request.getBankNo())
.bankReservedPhone(request.getBankMobile())
.source(1)
.build();
openBankInfoDAO.insertOrUpdateByStoreId(openBankInfoDO);
// 调用 创建门店签约人账户接口
CreateStoreAndAccountRequest accountRequest = CreateStoreAndAccountRequest.builder()
.outStoreId(shopInfo.getStoreId())
.phoneNumber(request.getMobile())
.accountType(BankAccountTypeEnum.PRIVATE.getType())
.businessType(BankBusinessTypeEnum.PERSONAL.getType())
.legalName(request.getUserName())
.legalNo(request.getIdCardNo())
.accountAliasName(request.getUserName() + "_" + shopInfo.getStoreId())
.accountCardNo(request.getBankNumber())
.accountPhone(request.getBankMobile())
.bankNo(request.getBankNo())
.bankName(request.getBankName())
.build();
StoreAccountDTO storeAndAccount = walletApiService.createStoreAndAccount(accountRequest);
return StringUtils.isNotBlank(storeAndAccount.getAccountNo());
}
@Override
public AccountAuthenticationVO authentication(WalletShopRequest request) {
ShopInfoDO shopInfo = getAndVerifyShopAndStage(request.getShopId());
// 调用 门店签约人账户鉴权申请接口
AccountAuthenticationDTO authentication = walletApiService.authentication(new OutStoreIdRequest(shopInfo.getStoreId()));
if (Objects.nonNull(authentication)) {
if (authentication.getAccountStatus().equals(4)) {
// 判断营业执照是否已经上传,已上传则调用打标接口
addTagIfUploadLicense(request.getShopId(), shopInfo.getStoreId(), shopInfo.getLineId());
}
return new AccountAuthenticationVO(authentication.getAccountStatus());
}
throw new ServiceException(ErrorCodeEnum.WALLET_OPEN_ACCOUNT_FAIL);
}
@Override
public Boolean openAccount(AccountOpenRequest request) {
// 校验阶段是否合法
ShopInfoDO shopInfo = getAndVerifyShopAndStage(request.getShopId());
// 调用 门店签约人账户开通接口
log.info("开通账户");
AccountVerifyDTO accountVerifyDTO = walletApiService.openAccount(new AccountVerifyRequest(shopInfo.getStoreId(), request.getCode()));
if (!CommonConstants.INDEX_ONE.equals(accountVerifyDTO.getOpenStatus())) {
throw new ServiceException(ErrorCodeEnum.WALLET_OPEN_ACCOUNT_FAIL);
}
// 更新钱包开通阶段状态
List<ShopSubStageStatusEnum> updateSubStageList = new ArrayList<>();
updateSubStageList.add(ShopSubStageStatusEnum.SHOP_SUB_STAGE_STATUS_61);
// 判断一下缴费阶段是否开启,未开启则开启缴费阶段
ShopStageInfoDO payStage = shopStageInfoDAO.getShopSubStageInfo(request.getShopId(), ShopSubStageEnum.SHOP_STAGE_7);
if (ShopSubStageStatusEnum.SHOP_SUB_STAGE_STATUS_00.getShopSubStageStatus().equals(payStage.getShopSubStageStatus())) {
updateSubStageList.add(ShopSubStageStatusEnum.SHOP_SUB_STAGE_STATUS_70);
}
shopStageInfoDAO.batchUpdateShopStageStatus(request.getShopId(), updateSubStageList);
// 判断营业执照是否已经上传,已上传则调用打标接口
addTagIfUploadLicense(request.getShopId(), shopInfo.getStoreId(), shopInfo.getLineId());
return true;
}
@Override
public PageInfo<BankVO> getBankList(BankListRequest request) {
GetBankRequest getBankRequest = new GetBankRequest();
WalletBasicPageInfo pageParam = new WalletBasicPageInfo();
pageParam.setCurrentPage(request.getPageNum());
pageParam.setPageSize(request.getPageSize());
getBankRequest.setPage(pageParam);
getBankRequest.setHeadName(request.getHeadName());
getBankRequest.setKeyword(request.getKeyword());
BankListDTO bankListDTO = walletApiService.getBankList(getBankRequest);
return toPageInfo(bankListDTO.getPageData(), BankVO.class, bankListDTO.getPage());
}
public static <T, R> PageInfo<R> toPageInfo(List<T> list, Class<R> clazz, WalletBasicPageInfo page) {
PageInfo<R> result = new PageInfo<>();
result.setPageNum(page.getCurrentPage());
result.setPageSize(page.getPageSize());
result.setPages(page.getCount());
result.setTotal(page.getTotal());
result.setList(CollectionUtils.isNotEmpty(list) ? (list.get(0).getClass().equals(clazz) ? (List<R>) list : BeanUtil.toList(list, clazz)) : Collections.emptyList());
return result;
}
@Override
public void addTagIfUploadLicense(Long shopId, String storeId, Long lineId) {
LicenseTransactDO license = applyLicenseMapper.selectByShopId(shopId);
// 营业执照已上传,调用打标接口
if (Objects.nonNull(license) && StringUtils.isNotBlank(license.getCreditUrl())) {
try {
// 判断一下账户的开通状态
if (enableAddTag(storeId)) {
OpenBankInfoDO openBankInfo = getAndUpdateOpenBankInfo(storeId, lineId, license);
// 调用 签约人账户打标(升级)接口
log.info("营业执照已上传,账户打标");
AccountAddTagRequest tagRequest = AccountAddTagRequest.builder()
.outStoreId(storeId)
.licenseNo(openBankInfo.getBusinessLicenseCode())
.licenseName(openBankInfo.getBusinessLicenseName())
.legalName(openBankInfo.getLegalName())
.legalNo(openBankInfo.getLegalIdCard())
.legalPhone(openBankInfo.getLegalPhone())
.certPhotoA(openBankInfo.getLegalIdCardFront())
.certPhotoB(openBankInfo.getLegalIdCardBack())
.licensePhoto(openBankInfo.getBusinessLicensePhoto())
.signatoryPhotoA(openBankInfo.getSignerIdCardFront())
.signatoryPhotoB(openBankInfo.getSignerIdCardBack())
.build();
executeAddTag(tagRequest);
}
} catch (ServiceException e) {
// 平安打标 签约人和法人一致时同步返回失败原因从msg中取
String key = MessageFormat.format(RedisConstant.WALLET_OPEN_FAIL, storeId, WalletTypeEnum.PING_AN.getType());
redisUtilPool.setString(key, e.getErrorCode().equals(ErrorCodeEnum.WALLET_API_ERROR.getCode()) ? e.getMessage() : "系统异常");
log.info("营业执照已上传,接口异常", e);
} catch (Exception e) {
log.error("营业执照已上传,打标失败", e);
}
}
}
/**
* 执行打标接口,执行失败缓存标记
*/
private void executeAddTag(AccountAddTagRequest tagRequest) {
AddTagDTO addTagDTO = walletApiService.addTag(tagRequest);
log.info("打标接口调用成功response:{}", JSONObject.toJSONString(addTagDTO));
// 如果网商创建失败,缓存标记
if (CommonConstants.INDEX_TWO.equals(addTagDTO.getWsStatus())) {
redisUtilPool.setString(MessageFormat.format(RedisConstant.WALLET_ONLINE_BANK_TAG_FAIL, tagRequest.getOutStoreId()), "1");
} else {
// 网商创建成功,记录已激活状态
redisUtilPool.setString(MessageFormat.format(RedisConstant.WALLET_ONLINE_BANK_ACTIVATED, tagRequest.getOutStoreId()), "1");
}
}
/**
* 获取并更新门店开通网商信息
*/
private OpenBankInfoDO getAndUpdateOpenBankInfo(String storeId, Long lineId, LicenseTransactDO license) {
LineInfoDO lineInfoDO = lineInfoDAO.getLineInfo(lineId);
QualificationsInfoDO qualificationsInfoDO = qualificationsInfoDAO.getByLineId(lineId);
OpenBankInfoDO openBankInfoDO = OpenBankInfoDO.builder()
.storeId(storeId)
.signerName(lineInfoDO.getUsername())
.signerIdCard(qualificationsInfoDO.getIdCardNo())
.signerPhone(lineInfoDO.getMobile())
.signerIdCardFront(qualificationsInfoDO.getFrontOfIdCard())
.signerIdCardBack(qualificationsInfoDO.getBackOfIdCard())
.businessLicenseName(license.getBusinessLicense())
.businessLicenseCode(license.getCreditCode())
.businessLicensePhoto(license.getCreditUrl())
.legalName(license.getLicenseLegalPerson())
.legalIdCard(license.getLicenseLegalIdCardNo())
.legalPhone(license.getLicenseLegalMobile())
.legalIdCardFront(license.getLicenseLegalIdCardFront())
.legalIdCardBack(license.getLicenseLegalIdCardBack())
.build();
openBankInfoDAO.insertOrUpdateByStoreId(openBankInfoDO);
return openBankInfoDO;
}
/**
* 账户存在且未打标
*/
private boolean enableAddTag(String storeId) {
List<AccountInfoDTO> accountInfo = walletApiService.getAccountInfo(new OutStoreIdRequest(storeId));
return CollectionUtils.isNotEmpty(accountInfo) && accountInfo.size() == 1 && accountInfo.get(0).getLabelingStatus().equals(0);
}
@Override
public Boolean addTagCallback(AddTagCallbackNoticeRequest request) {
try {
String key = MessageFormat.format(RedisConstant.WALLET_OPEN_FAIL, request.getOutStoreId(), WalletTypeEnum.PING_AN.getType());
if (Integer.valueOf(2).equals(request.getStatus())) {
redisUtilPool.setString(key, request.getErrorMsg());
} else {
redisUtilPool.delKey(key);
}
} catch (Exception e) {
log.info("平安打标回调失败", e);
}
return Boolean.TRUE;
}
@Override
public Boolean largePaymentCallback(PaymentDTO request) {
try {
walletPaymentOrderDAO.updateOrderByPaymentId(request.getOutStoreId(), request.getPaymentId(), request.getOrderStatus());
} catch (Exception e) {
log.error("大额充值回调失败", e);
}
return Boolean.TRUE;
}
@Override
public Boolean onlineCommercialBankCallback(OnlineCommercialBankCallbackRequest request) {
try {
String key = MessageFormat.format(RedisConstant.WALLET_OPEN_FAIL, request.getOutStoreId(), "1");
if (Integer.valueOf(5).equals(request.getAccountStatus())) {
redisUtilPool.setString(key, request.getFailReason());
} else {
redisUtilPool.delKey(key);
}
// 如果创建成功,删除网商开通失败标识
if (Integer.valueOf(4).equals(request.getAccountStatus())) {
redisUtilPool.delKey(MessageFormat.format(RedisConstant.WALLET_ONLINE_BANK_TAG_FAIL, request.getOutStoreId()));
redisUtilPool.delKey(MessageFormat.format(RedisConstant.WALLET_ONLINE_BANK_ACTIVATED, request.getOutStoreId()));
}
} catch (Exception e) {
log.info("平安打标回调失败", e);
}
return Boolean.TRUE;
}
@Override
public Boolean accountTradeCallback(AccountTradeCallbackRequest request) {
return Boolean.TRUE;
}
@Override
public AccountDataVO getAccountList(AccountQueryRequest request) {
String storeId = getStoreId(request);
List<AccountInfoDTO> accountInfo = walletApiService.getAccountInfo(new OutStoreIdRequest(storeId));
List<AccountInfoVO> accountList = accountInfo.stream()
.filter(v -> Objects.isNull(request.getWalletType()) || request.getWalletType().equals(v.getWalletType()))
.map(v -> {
AccountInfoVO vo = BeanUtil.toBean(v, AccountInfoVO.class);
String key = MessageFormat.format(RedisConstant.WALLET_OPEN_FAIL, storeId, String.valueOf(v.getWalletType()));
vo.setFailReason(redisUtilPool.getString(key));
return vo;
}).collect(Collectors.toList());
boolean onlineBankOpenFail = false;
boolean activated = false;
if (WalletTypeEnum.ONLINE_BANK.getType().equals(request.getWalletType())) {
onlineBankOpenFail = getOnlineBankFailTag(storeId);
String key = MessageFormat.format(RedisConstant.WALLET_ONLINE_BANK_ACTIVATED, storeId);
activated = StringUtils.isNotBlank(redisUtilPool.getString(key));
}
return new AccountDataVO(onlineBankOpenFail, activated, accountList);
}
@Override
public AccountInfoVO getAccountInfo(AccountQueryRequest request) {
String storeId = getStoreId(request);
List<AccountInfoDTO> accountInfo = walletApiService.getAccountInfo(new OutStoreIdRequest(storeId));
AccountInfoDTO accountInfoDTO = accountInfo.stream().filter(v -> v.getAccountNo().equals(request.getAccountNo())).findFirst().orElse(null);
return BeanUtil.toBean(accountInfoDTO, AccountInfoVO.class);
}
@Override
public AccountBillPageVO getBillPage(AccountBillQueryRequest request) {
String storeId = getStoreId(request);
LocalDate now = LocalDate.now();
if (Objects.isNull(request.getBeginDate()) || Objects.isNull(request.getEndDate())) {
request.setBeginDate(Date.valueOf(now.withDayOfMonth(1)));
request.setEndDate(Date.valueOf(now));
}
BillPageRequest billPageRequest = BillPageRequest.builder()
.outStoreId(storeId)
.beginDate(DateUtil.format(request.getBeginDate(), "yyyy-MM-dd HH:mm:ss"))
.endDate(DateUtil.format(request.getEndDate(), "yyyy-MM-dd HH:mm:ss"))
.walletType(request.getWalletType())
.isLegal(request.getIsLegal())
.recordType(request.getRecordType())
.feeItemId(request.getFeeItemId())
.currentPage(request.getPageNum())
.pageSize(request.getPageSize())
.build();
BillPageDTO billPage = walletApiService.getBillPage(billPageRequest);
PageInfo<TradeRecordDTO> data = toPageInfo(billPage.getPageData(), TradeRecordDTO.class, billPage.getPage());
return new AccountBillPageVO(data, billPage.getGetAmount(), billPage.getUseAmount());
}
@Override
public TradeRecordDTO getBillDetail(BillDetailRequest request) {
return walletApiService.getBillDetail(request);
}
@Override
public Boolean passwordUpdate(AccountPasswordRequest request) {
String storeId = getStoreId(request);
UpdatePasswordRequest passwordRequest = BeanUtil.toBean(request, UpdatePasswordRequest.class);
passwordRequest.setOutStoreId(storeId);
walletApiService.upholdPwd(passwordRequest);
return true;
}
@Override
public PasswordDTO existPassword(OutStoreIdRequest request) {
PasswordDTO passwordDTO = walletApiService.passwordIsExist(request);
List<AccountInfoDTO> list = walletApiService.getAccountInfo(request);
Boolean isExistAccount = false;
if (CollectionUtils.isNotEmpty( list)){
isExistAccount = Boolean.TRUE;
}
passwordDTO.setIsExistAccount(isExistAccount);
return passwordDTO;
}
@Override
public AccountPaymentVO payment(AccountPaymentRequest request) {
ShopInfoDO shopInfo = null;
if (Objects.nonNull(request.getShopId())) {
shopInfo = shopInfoDAO.getShopInfo(request.getShopId());
} else if (StringUtils.isNotBlank(request.getStoreId())) {
shopInfo = shopInfoDAO.getShopInfoByStoreId(request.getStoreId());
}
if (Objects.isNull(shopInfo)) {
throw new ServiceException(ErrorCodeEnum.SHOP_NOT_EXIST);
}
String storeId = shopInfo.getStoreId();
LineInfoDO lineInfo = lineInfoDAO.getByPartnerId(shopInfo.getPartnerId());
if (Objects.isNull(lineInfo)) {
throw new ServiceException(ErrorCodeEnum.LINE_ID_IS_NOT_EXIST);
}
String paymentId = UUIDUtils.get32UUID();
LargePaymentRequest paymentRequest = new LargePaymentRequest(storeId, paymentId, lineInfo.getUsername(), request.getAmount().toString());
LargePaymentDTO resultDTO = walletApiService.largePayment(paymentRequest);
long expiryCountdown = 0;
if (StringUtils.isNotBlank(resultDTO.getExpireTime())) {
expiryCountdown = Math.max(0, Duration.between(LocalDateTime.now(), LocalDateTime.parse(resultDTO.getExpireTime(), formatter)).getSeconds());
}
WalletPaymentOrderDO orderDO = WalletPaymentOrderDO.builder()
.storeId(storeId)
.paymentId(paymentId)
.type(0)
.amount(request.getAmount())
.expireTime(resultDTO.getExpireTime())
.orderStatus(3)
.build();
walletPaymentOrderDAO.insertSelective(orderDO);
AccountPaymentVO result = BeanUtil.toBean(resultDTO, AccountPaymentVO.class);
result.setExpiryCountdown(expiryCountdown);
return result;
}
@Override
public PageInfo<WalletPaymentOrderVO> nonPaymentOrderPage(LargePaymentQueryRequest request) {
PageHelper.startPage(request.getPageNum(), request.getPageSize());
String storeId = getStoreId(request);
List<WalletPaymentOrderDO> list = walletPaymentOrderDAO.getNonPaymentList(storeId);
PageInfo<WalletPaymentOrderDO> page = new PageInfo<>(list);
return BeanUtil.toPage(page, WalletPaymentOrderVO.class);
}
@Override
public AccountPaymentVO paymentDetail(String paymentId) {
PaymentDetailRequest request = new PaymentDetailRequest();
request.setPaymentId(paymentId);
PaymentDTO resultDTO = walletApiService.largePaymentQuery(request);
long expiryCountdown = 0;
if (StringUtils.isNotBlank(resultDTO.getExpireTime())) {
expiryCountdown = Math.max(0, Duration.between(LocalDateTime.now(), LocalDateTime.parse(resultDTO.getExpireTime(), formatter)).getSeconds());
}
AccountPaymentVO result = BeanUtil.toBean(resultDTO, AccountPaymentVO.class);
result.setExpiryCountdown(expiryCountdown);
return result;
}
@Override
public Boolean withDrawer(WalletWithDrawerRequest request) {
String storeId = getStoreId(request);
String reqNo = UUIDUtils.get32UUID();
WithDrawerRequest withDrawerRequest = new WithDrawerRequest(storeId, request.getPayPwd(), reqNo, request.getAmount().toString(), "提现", request.getWalletType());
WithDrawerDTO withdraw = walletApiService.withdraw(withDrawerRequest);
if ("2".equals(withdraw.getTradeStatus())) {
throw new ServiceException(ErrorCodeEnum.WALLET_WITH_DRAWER_FAIL);
}
WalletPaymentOrderDO orderDO = WalletPaymentOrderDO.builder()
.storeId(storeId)
.paymentId(reqNo)
.type(1)
.amount(request.getAmount())
.orderStatus(1)
.build();
walletPaymentOrderDAO.insertSelective(orderDO);
return true;
}
@Override
public PageInfo<AccountPageVO> getAllAccountList(CoolAccountBatchQueryRequest request) {
AccountBatchQueryRequest accountBatchQueryRequest = request.convertToAccountBatchQueryRequest();
AccountPageDTO accountList = walletApiService.getAccountList(accountBatchQueryRequest);
List<AccountPageVO> list = BeanUtil.toList(accountList.getPageData(), AccountPageVO.class, CopyOptions.create().setFieldMapping(Collections.singletonMap("outStoreId", "storeId")));
PageInfo<AccountPageVO> page = toPageInfo(list, AccountPageVO.class, accountList.getPage());
List<String> storeIds = CollStreamUtil.toList(page.getList(), AccountPageVO::getStoreId);
Map<String, String> storeNameMap = getStoreNameMap(storeIds);
page.getList().forEach(v -> v.setStoreName(storeNameMap.get(v.getStoreId())));
return page;
}
private Map<String, String> getStoreNameMap(List<String> storeIds) {
Map<String, String> storeNameMap = new HashMap<>();
List<StoreDO> stores = storeDao.getEffectiveStoreByStoreIds(storeIds);
Map<String, String> storeMap = CollStreamUtil.toMap(stores, StoreDO::getStoreId, StoreDO::getStoreName);
storeNameMap.putAll(storeMap);
List<ShopInfoDO> shops = shopInfoDAO.getShopInfoByStoreIds(storeIds);
Map<String, String> shopMap = CollStreamUtil.toMap(shops, ShopInfoDO::getStoreId, ShopInfoDO::getShopName);
storeNameMap.putAll(shopMap);
return storeNameMap;
}
@Override
public PageInfo<TradeRecordDTO> getTradeRecordList(CoolTradeRecodePageRequest request) {
TradeRecodePageRequest tradeRecodePageRequest = request.convertToTradeRecodePageRequest();
TradeRecordListDTO tradeRecordListDTO = walletApiService.getTradeRecordList(tradeRecodePageRequest);
return toPageInfo(tradeRecordListDTO.getPageData(), TradeRecordDTO.class, tradeRecordListDTO.getPage());
}
@Override
public OpenBasicInfoDTO getOpenBasicInfo(String storeId, String storeCode) {
OpenBasicInfoDTO openBasicInfoDTO = new OpenBasicInfoDTO();
//非首次提交 获取上次提交的信息 其他情况走主数据与营账通开通数据
OpenBankInfoDO openBankInfo;
if (StringUtils.isNotBlank(storeId)) {
openBankInfo = openBankInfoDAO.getOpenBankInfoByStoreId(storeId);
} else {
openBankInfo = openBankInfoDAO.getOpenBankInfo(storeCode);
}
if (Objects.nonNull(openBankInfo)){
openBasicInfoDTO.setSignerName(openBankInfo.getSignerName());
openBasicInfoDTO.setSignerIdCard(openBankInfo.getSignerIdCard());
openBasicInfoDTO.setSignerPhone(openBankInfo.getSignerPhone());
openBasicInfoDTO.setSignerIdCardFront(openBankInfo.getSignerIdCardFront());
openBasicInfoDTO.setSignerIdCardBack(openBankInfo.getSignerIdCardBack());
openBasicInfoDTO.setBusinessLicenseName(openBankInfo.getBusinessLicenseName());
openBasicInfoDTO.setBusinessLicensePhoto(openBankInfo.getBusinessLicensePhoto());
openBasicInfoDTO.setBusinessLicenseCode(openBankInfo.getBusinessLicenseCode());
openBasicInfoDTO.setSettlementCard(openBankInfo.getSettlementCard());
openBasicInfoDTO.setBankBranchName(openBankInfo.getBankBranchName());
openBasicInfoDTO.setBankBranchCode(openBankInfo.getBankBranchCode());
openBasicInfoDTO.setBankReservedPhone(openBankInfo.getBankReservedPhone());
return openBasicInfoDTO;
}
//先查询当前门店
StoreDO store = storeDao.getByStoreNum(storeCode);
if (Objects.isNull( store)){
return null;
}
Map<String, StoreMasterSignerInfoDO> signerMapByStoreIds = storeMasterSignerInfoDAO.getSignerMapByStoreIds(Collections.singletonList(store.getStoreId()));
StoreMasterSignerInfoDO signerInfoDO = signerMapByStoreIds.get(store.getStoreId());
if (Objects.nonNull(signerInfoDO)){
openBasicInfoDTO.setSignerName(signerInfoDO.getSigner1Name());
openBasicInfoDTO.setSignerIdCard(signerInfoDO.getSigner1IdCardNo());
openBasicInfoDTO.setSignerPhone(signerInfoDO.getSigner1Mobile());
openBasicInfoDTO.setSignerIdCardFront(signerInfoDO.getSigner1IdCardFront());
openBasicInfoDTO.setSignerIdCardBack(signerInfoDO.getSigner1IdCardBack());
}
TempOpenWalletInfoDO tempOpenWalletInfoByStoreCode = tempOpenWalletInfoDAO.getTempOpenWalletInfoByStoreCode(storeCode);
if (Objects.nonNull(tempOpenWalletInfoByStoreCode)){
openBasicInfoDTO.setBusinessLicenseName(tempOpenWalletInfoByStoreCode.getBusinessRegName());
openBasicInfoDTO.setBusinessLicenseCode(tempOpenWalletInfoByStoreCode.getBusinessLicenseNo());
openBasicInfoDTO.setSettlementCard(tempOpenWalletInfoByStoreCode.getSettlementCardNo());
openBasicInfoDTO.setBankBranchName(tempOpenWalletInfoByStoreCode.getBankBranchName());
openBasicInfoDTO.setBankBranchCode(tempOpenWalletInfoByStoreCode.getBankBranchNo());
openBasicInfoDTO.setBankReservedPhone(tempOpenWalletInfoByStoreCode.getBankReservedPhone());
}
return openBasicInfoDTO;
}
@Override
public Boolean openOnlineBankAccount(CoolOpenBasicInfoRequest request) {
//首先存储提交的信息
OpenBankInfoDO openBankInfoDO = new OpenBankInfoDO();
BeanUtil.copyProperties(request, openBankInfoDO);
//查询是否有提交过
OpenBankInfoDO openBankInfo = openBankInfoDAO.getOpenBankInfo(request.getStoreCode());
if (Objects.isNull(openBankInfo)){
openBankInfoDAO.insertSelective(openBankInfoDO);
}else {
openBankInfoDAO.updateByStoreCode(openBankInfoDO);
}
// 如果是开店流程中网商开通失败,则重新调用打标接口
if (getOnlineBankFailTag(request.getStoreId())) {
onlineBankFailReOpen(request);
return true;
}
OldStoreAccountCreateRequest oldStoreAccountCreateRequest = new OldStoreAccountCreateRequest();
StoreDO store = storeDao.getByStoreNum(request.getStoreCode());
oldStoreAccountCreateRequest.setOutStoreId(store.getStoreId());
oldStoreAccountCreateRequest.setPhoneNumber(request.getSignerPhone());
oldStoreAccountCreateRequest.setAccountType(2);
oldStoreAccountCreateRequest.setLicenseNo(request.getBusinessLicenseCode());
oldStoreAccountCreateRequest.setLicenseName(request.getBusinessLicenseName());
oldStoreAccountCreateRequest.setLegalName(request.getLegalName());
oldStoreAccountCreateRequest.setLegalNo(request.getLegalIdCard());
oldStoreAccountCreateRequest.setLegalPhone(request.getLegalPhone());
oldStoreAccountCreateRequest.setLegalIdcardExpireTime(request.getLegalIdCardExpireTime());
//账户简称使用营业执照名称
oldStoreAccountCreateRequest.setAccountAliasName(request.getBusinessLicenseName());
oldStoreAccountCreateRequest.setAccountCardNo(request.getSettlementCard());
oldStoreAccountCreateRequest.setAccountPhone(request.getBankReservedPhone());
oldStoreAccountCreateRequest.setBankNo(request.getBankBranchCode());
oldStoreAccountCreateRequest.setBankName(request.getBankBranchName());
oldStoreAccountCreateRequest.setCertPhotoA(request.getLegalIdCardFront());
oldStoreAccountCreateRequest.setCertPhotoB(request.getLegalIdCardBack());
oldStoreAccountCreateRequest.setLicensePhoto(request.getBusinessLicensePhoto());
oldStoreAccountCreateRequest.setSignatoryName(request.getSignerName());
oldStoreAccountCreateRequest.setSignatoryPhone(request.getSignerPhone());
oldStoreAccountCreateRequest.setSignatoryNo(request.getSignerIdCard());
oldStoreAccountCreateRequest.setSignatoryPhotoA(request.getSignerIdCardFront());
oldStoreAccountCreateRequest.setSignatoryPhotoB(request.getSignerIdCardBack());
walletApiService.oldStoreOpenAccount(oldStoreAccountCreateRequest);
// 网商创建成功,记录已激活状态
redisUtilPool.setString(MessageFormat.format(RedisConstant.WALLET_ONLINE_BANK_ACTIVATED, store.getStoreId()), "1");
return Boolean.TRUE;
}
/**
* 获取开店流程网商银行开通失败标记
*/
private boolean getOnlineBankFailTag(String storeId) {
String key = MessageFormat.format(RedisConstant.WALLET_ONLINE_BANK_TAG_FAIL, storeId);
String flag = redisUtilPool.getString(key);
return StringUtils.isNotBlank(flag);
}
/**
* 开通流程创建网商银行账户失败的情况下,重新开通
*/
private void onlineBankFailReOpen(CoolOpenBasicInfoRequest request) {
log.info("网商钱包开通失败后重新提交打标接口");
AccountAddTagRequest tagRequest = AccountAddTagRequest.builder()
.outStoreId(request.getStoreId())
.licenseNo(request.getBusinessLicenseCode())
.licenseName(request.getBusinessLicenseName())
.legalName(request.getLegalName())
.legalNo(request.getLegalIdCard())
.legalPhone(request.getLegalPhone())
.certPhotoA(request.getLegalIdCardFront())
.certPhotoB(request.getLegalIdCardBack())
.licensePhoto(request.getBusinessLicensePhoto())
.signatoryPhotoA(request.getSignerIdCardFront())
.signatoryPhotoB(request.getSignerIdCardBack())
.build();
executeAddTag(tagRequest);
}
@Override
public Boolean onlineBankActive(StoreShopRequest request) {
String storeId = getStoreId(request);
walletApiService.textMsgSend(new TextMsgSendRequest(storeId));
return true;
}
public String getStoreId(StoreShopRequest request) {
String storeId = request.getStoreId();
if (StringUtils.isBlank(storeId) && Objects.nonNull(request.getShopId())) {
ShopInfoDO shopInfo = shopInfoDAO.getShopInfo(request.getShopId());
storeId = Objects.nonNull(shopInfo) ? shopInfo.getStoreId() : null;
}
if (StringUtils.isBlank(storeId)) {
throw new ServiceException(ErrorCodeEnum.SHOP_NOT_EXIST);
}
return storeId;
}
/**
* 查询并校验门店是否存在以及阶段是否处于平安钱包未开通状态
*/
private ShopInfoDO getAndVerifyShopAndStage(Long shopId) {
ShopInfoDO shopInfo = shopInfoDAO.getShopInfo(shopId);
if (Objects.isNull(shopInfo)) {
throw new ServiceException(ErrorCodeEnum.SHOP_NOT_EXIST);
}
ShopStageInfoDO stageInfo = shopStageInfoDAO.getShopSubStageInfo(shopId, ShopSubStageEnum.SHOP_STAGE_6);
if (!ShopSubStageStatusEnum.SHOP_SUB_STAGE_STATUS_60.getShopSubStageStatus().equals(stageInfo.getShopSubStageStatus())) {
throw new ServiceException(ErrorCodeEnum.SHOP_STAGE_NOT_OPERATE);
}
return shopInfo;
}
}