Merge branch 'master' into cc_20250905_franchiseAgreement
# Conflicts: # coolstore-partner-common/src/main/java/com/cool/store/enums/ErrorCodeEnum.java # coolstore-partner-model/src/main/java/com/cool/store/response/AddSignFranchiseResponse.java # coolstore-partner-service/src/main/java/com/cool/store/service/impl/PushServiceImpl.java # coolstore-partner-service/src/main/java/com/cool/store/service/impl/SignFranchiseServiceImpl.java # coolstore-partner-web/src/main/java/com/cool/store/controller/webb/PCTestController.java
This commit is contained in:
@@ -0,0 +1,126 @@
|
||||
package com.cool.store.builder;
|
||||
|
||||
import com.cool.store.config.weixin.WechatMiniappProperties;
|
||||
import com.cool.store.dto.wechat.WechatTemplateMessageDTO;
|
||||
import com.cool.store.enums.wechat.WechatTemplateEnum;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @Author suzhuhong
|
||||
* @Date 2025/10/10 14:34
|
||||
* @Version 1.0
|
||||
*/
|
||||
@Component
|
||||
public class TemplateMessageBuilder {
|
||||
|
||||
@Autowired
|
||||
private WechatMiniappProperties wechatMiniappProperties;
|
||||
|
||||
/**
|
||||
* 构建普通模板消息
|
||||
*/
|
||||
public WechatTemplateMessageDTO buildNormalTemplate(String openId,
|
||||
WechatTemplateEnum template,
|
||||
Map<String, Object> data) {
|
||||
WechatTemplateMessageDTO messageDTO = new WechatTemplateMessageDTO();
|
||||
messageDTO.setToUser(openId);
|
||||
messageDTO.setTemplateId(template.getTemplateId());
|
||||
|
||||
// 设置URL(如果data中包含url)
|
||||
if (data.containsKey("url")) {
|
||||
messageDTO.setUrl((String) data.get("url"));
|
||||
}
|
||||
|
||||
// 构建模板数据
|
||||
messageDTO.setData(buildTemplateData(data));
|
||||
|
||||
return messageDTO;
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建小程序跳转模板消息
|
||||
*/
|
||||
public WechatTemplateMessageDTO buildMiniappTemplate(String openId,
|
||||
WechatTemplateEnum template,
|
||||
Map<String, Object> data,
|
||||
String miniAppPagePath) {
|
||||
WechatTemplateMessageDTO messageDTO = new WechatTemplateMessageDTO();
|
||||
messageDTO.setToUser(openId);
|
||||
messageDTO.setTemplateId(template.getTemplateId());
|
||||
|
||||
// 设置小程序跳转
|
||||
WechatTemplateMessageDTO.MiniprogramDTO miniProgram = new WechatTemplateMessageDTO.MiniprogramDTO();
|
||||
miniProgram.setAppid(wechatMiniappProperties.getAppId());
|
||||
miniProgram.setPagepath(miniAppPagePath != null ? miniAppPagePath : wechatMiniappProperties.getDefaultPagePath());
|
||||
messageDTO.setMiniprogram(miniProgram);
|
||||
|
||||
// 设置备用URL(如果data中包含url)
|
||||
if (data.containsKey("url")) {
|
||||
messageDTO.setUrl((String) data.get("url"));
|
||||
}
|
||||
|
||||
// 构建模板数据
|
||||
messageDTO.setData(buildTemplateData(data));
|
||||
|
||||
return messageDTO;
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建小程序跳转模板消息(带备用URL)
|
||||
*/
|
||||
public WechatTemplateMessageDTO buildMiniAppTemplateWithUrl(String openId,
|
||||
WechatTemplateEnum template,
|
||||
Map<String, Object> data,
|
||||
String miniAppPagePath,
|
||||
String backupUrl) {
|
||||
WechatTemplateMessageDTO messageDTO = buildMiniappTemplate(openId, template, data, miniAppPagePath);
|
||||
|
||||
// 设置备用URL
|
||||
if (backupUrl != null && !backupUrl.trim().isEmpty()) {
|
||||
messageDTO.setUrl(backupUrl);
|
||||
}
|
||||
|
||||
return messageDTO;
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建模板数据
|
||||
*/
|
||||
private Map<String, WechatTemplateMessageDTO.TemplateDataItemDTO> buildTemplateData(Map<String, Object> data) {
|
||||
Map<String, WechatTemplateMessageDTO.TemplateDataItemDTO> templateData = new HashMap<>();
|
||||
|
||||
data.forEach((key, value) -> {
|
||||
if (!"url".equals(key) && value != null) {
|
||||
WechatTemplateMessageDTO.TemplateDataItemDTO item =
|
||||
new WechatTemplateMessageDTO.TemplateDataItemDTO(
|
||||
value.toString(),
|
||||
getColorByField(key)
|
||||
);
|
||||
templateData.put(key, item);
|
||||
}
|
||||
});
|
||||
|
||||
return templateData;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据字段名获取颜色
|
||||
*/
|
||||
private String getColorByField(String fieldName) {
|
||||
switch (fieldName) {
|
||||
case "amount":
|
||||
case "refundAmount":
|
||||
case "couponValue":
|
||||
case "character_string2":
|
||||
return "#FF0000"; // 金额类字段用红色
|
||||
case "orderNo":
|
||||
case "expressNo":
|
||||
return "#173177"; // 编号类字段用蓝色
|
||||
default:
|
||||
return "#333333"; // 默认用深灰色
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.cool.store.config.weixin;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* @Author suzhuhong
|
||||
* @Date 2025/10/10 14:41
|
||||
* @Version 1.0
|
||||
*/
|
||||
@Data
|
||||
@Configuration
|
||||
@ConfigurationProperties(prefix = "wechat.miniapp")
|
||||
public class WechatMiniappProperties {
|
||||
|
||||
/**
|
||||
* 小程序appId
|
||||
*/
|
||||
private String appId;
|
||||
|
||||
/**
|
||||
* 小程序页面路径
|
||||
*/
|
||||
private String defaultPagePath ;
|
||||
|
||||
/**
|
||||
* 是否使用小程序跳转
|
||||
*/
|
||||
private boolean enabled = false;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.cool.store.config.weixin;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* @Author suzhuhong
|
||||
* @Date 2025/10/10 14:29
|
||||
* @Version 1.0
|
||||
* 微信服务号配置
|
||||
*/
|
||||
@Data
|
||||
@Configuration
|
||||
@ConfigurationProperties(prefix = "wechat.mp")
|
||||
public class WechatMpProperties {
|
||||
|
||||
/**
|
||||
* 公众号appId
|
||||
*/
|
||||
private String appId;
|
||||
|
||||
/**
|
||||
* 公众号appSecret
|
||||
*/
|
||||
private String appSecret;
|
||||
|
||||
/**
|
||||
* 获取access_token的URL
|
||||
*/
|
||||
private String accessTokenUrl = "https://api.weixin.qq.com/cgi-bin/token";
|
||||
|
||||
/**
|
||||
* 发送模板消息的URL
|
||||
*/
|
||||
private String sendTemplateMessageUrl = "https://api.weixin.qq.com/cgi-bin/message/template/send";
|
||||
}
|
||||
@@ -0,0 +1,157 @@
|
||||
package com.cool.store.handler;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.cool.store.dao.PartnerUserWechatBindDAO;
|
||||
import com.cool.store.dto.wechat.WechatUserInfoDTO;
|
||||
import com.cool.store.service.wechat.WechatTemplateService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
import org.xml.sax.InputSource;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import java.io.StringReader;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @Author suzhuhong
|
||||
* @Date 2025/10/14 14:56
|
||||
* @Version 1.0
|
||||
*/
|
||||
@Component
|
||||
@Slf4j
|
||||
public class WeChatHandler {
|
||||
|
||||
@Resource
|
||||
PartnerUserWechatBindDAO partnerUserWechatBindDAO;
|
||||
@Resource
|
||||
WechatTemplateService wechatTemplateService;
|
||||
|
||||
public Map<String, Object> parseXmlToMap(String xmlContent) throws Exception {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
|
||||
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
|
||||
factory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
|
||||
|
||||
DocumentBuilder builder = factory.newDocumentBuilder();
|
||||
Document document = builder.parse(new InputSource(new StringReader(xmlContent)));
|
||||
|
||||
NodeList nodes = document.getDocumentElement().getChildNodes();
|
||||
for (int i = 0; i < nodes.getLength(); i++) {
|
||||
Node node = nodes.item(i);
|
||||
if (node.getNodeType() == Node.ELEMENT_NODE) {
|
||||
String tagName = node.getNodeName();
|
||||
String textContent = node.getTextContent();
|
||||
result.put(tagName, textContent);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
public String processMessage(Map<String, Object> messageMap) {
|
||||
String msgType = (String) messageMap.get("MsgType");
|
||||
String event = (String) messageMap.get("Event");
|
||||
|
||||
switch (msgType) {
|
||||
case "event":
|
||||
return handleEvent(messageMap);
|
||||
|
||||
// case "text":
|
||||
// return handleTextMessage(message);
|
||||
//
|
||||
// case "image":
|
||||
// return handleImageMessage(message);
|
||||
|
||||
default:
|
||||
// 其他类型的消息直接回复success
|
||||
return "success";
|
||||
}
|
||||
}
|
||||
|
||||
private String handleEvent(Map<String, Object> messageMap) {
|
||||
String event = (String) messageMap.get("Event");
|
||||
String fromUserName = (String) messageMap.get("FromUserName");
|
||||
String toUserName = (String) messageMap.get("ToUserName");
|
||||
|
||||
switch (event) {
|
||||
case "subscribe":
|
||||
// 关注事件 - 绑定用户
|
||||
return handleSubscribeEvent(fromUserName,toUserName);
|
||||
|
||||
case "unsubscribe":
|
||||
// 取消关注事件 - 解绑用户
|
||||
return handleUnsubscribeEvent(fromUserName,toUserName);
|
||||
|
||||
default:
|
||||
return buildWelcomeReply(fromUserName, toUserName);
|
||||
}
|
||||
}
|
||||
|
||||
private String handleSubscribeEvent(String fromUserName,String toUserName) {
|
||||
try {
|
||||
|
||||
//根据openId 获取用户信息
|
||||
WechatUserInfoDTO userInfo = wechatTemplateService.getUserInfo(fromUserName, null);
|
||||
|
||||
log.info("handleSubscribeEvent: {}", JSONObject.toJSONString(userInfo));
|
||||
|
||||
//根据unionId 更新服务号ID
|
||||
if (userInfo != null) {
|
||||
partnerUserWechatBindDAO.updateByUnionId(userInfo.getUnionid(),fromUserName);
|
||||
}
|
||||
|
||||
// 立即回复欢迎消息
|
||||
return buildWelcomeReply(fromUserName, toUserName);
|
||||
|
||||
} catch (Exception e) {
|
||||
// 即使处理失败也要返回success
|
||||
return buildWelcomeReply(fromUserName, toUserName);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理取消关注事件
|
||||
*/
|
||||
private String handleUnsubscribeEvent(String fromUserName,String toUserName) {
|
||||
|
||||
// 异步处理用户解绑
|
||||
//userBindingService.unbindOfficialAccountUser(openId);
|
||||
|
||||
return "success";
|
||||
}
|
||||
|
||||
private String buildSuccessReply(String fromUser, String toUser) {
|
||||
return String.format(
|
||||
"<xml>" +
|
||||
"<ToUserName><![CDATA[%s]]></ToUserName>" +
|
||||
"<FromUserName><![CDATA[%s]]></FromUserName>" +
|
||||
"<CreateTime>%d</CreateTime>" +
|
||||
"<MsgType><![CDATA[text]]></MsgType>" +
|
||||
"<Content><![CDATA[success]]></Content>" +
|
||||
"</xml>",
|
||||
fromUser, toUser, System.currentTimeMillis() / 1000
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
private String buildWelcomeReply(String fromUser, String toUser) {
|
||||
return String.format(
|
||||
"<xml>" +
|
||||
"<ToUserName><![CDATA[%s]]></ToUserName>" +
|
||||
"<FromUserName><![CDATA[%s]]></FromUserName>" +
|
||||
"<CreateTime>%d</CreateTime>" +
|
||||
"<MsgType><![CDATA[text]]></MsgType>" +
|
||||
"<Content><![CDATA[欢迎关注!您已成功绑定通知服务,可以接收小程序的重要消息通知。]]></Content>" +
|
||||
"</xml>",
|
||||
fromUser, toUser, System.currentTimeMillis() / 1000
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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>>() {});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -8,6 +8,8 @@ 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;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
@@ -32,6 +34,10 @@ public class ConsumerClient {
|
||||
// private FeiShuEventListener feiShuEventListener;
|
||||
@Resource
|
||||
private XfsgTrainingPersonSyncListener xfsgTrainingPersonSyncListener;
|
||||
@Resource
|
||||
private StoreUserUpdateListener storeUserUpdateListener;
|
||||
@Resource
|
||||
private ShopDecorationAssignListener shopDecorationAssignListener;
|
||||
|
||||
/**
|
||||
* 获取通用配置
|
||||
@@ -85,4 +91,30 @@ public class ConsumerClient {
|
||||
// }
|
||||
|
||||
|
||||
@Bean(initMethod = "start", destroyMethod = "shutdown")
|
||||
public ConsumerBean storeUserUpdate() {
|
||||
RocketMqGroupEnum groupEnum = RocketMqGroupEnum.STORE_USER_UPDATE;
|
||||
ConsumerBean consumerBean = new ConsumerBean();
|
||||
//配置文件
|
||||
Properties properties = getCommonProperties(groupEnum);
|
||||
consumerBean.setProperties(properties);
|
||||
Map<Subscription, MessageListener> commonSubscriptionTable = getCommonSubscriptionTable(groupEnum, storeUserUpdateListener);
|
||||
//订阅多个topic如上面设置
|
||||
consumerBean.setSubscriptionTable(commonSubscriptionTable);
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
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.dto.store.StoreUserPositionDTO;
|
||||
import com.cool.store.dto.store.StoreUserUpdateDTO;
|
||||
import com.cool.store.service.PushService;
|
||||
import com.cool.store.service.StoreService;
|
||||
import com.cool.store.service.ThirdFoodService;
|
||||
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 java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author suzhuhong
|
||||
* @Date 2025/9/25 14:49
|
||||
* @Version 1.0
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class StoreUserUpdateListener implements MessageListener {
|
||||
|
||||
@Autowired
|
||||
public RedisUtilPool redisUtilPool;
|
||||
@Autowired
|
||||
StoreService storeService;
|
||||
@Autowired
|
||||
ThirdFoodService thirdFoodService;
|
||||
|
||||
@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 = "StoreUserUpdateListener:" + message.getMsgID();
|
||||
boolean lock = redisUtilPool.setNxExpire(lockKey, message.getMsgID(), CommonConstants.NORMAL_LOCK_TIMES);
|
||||
if(lock){
|
||||
try {
|
||||
List<StoreUserPositionDTO> storeUser = storeService.getStoreUser(Arrays.asList(text));
|
||||
if (CollectionUtils.isNotEmpty(storeUser)){
|
||||
//转换 否则验签不通过
|
||||
List<StoreUserUpdateDTO> storeUserUpdateDTOS = JSONObject.parseArray(JSONObject.toJSONString(storeUser), StoreUserUpdateDTO.class);
|
||||
thirdFoodService.pushStoreUser(storeUserUpdateDTOS);
|
||||
}
|
||||
}catch (Exception e){
|
||||
log.error("StoreUserUpdateListener 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;
|
||||
}
|
||||
}
|
||||
@@ -21,7 +21,7 @@ public interface BigRegionService {
|
||||
* @param keyword 关键字
|
||||
* @return
|
||||
*/
|
||||
List<BigRegionDTO> queryAllBigRegion(String keyword);
|
||||
List<BigRegionDTO> queryAllBigRegion(String keyword, Integer joinBrand);
|
||||
|
||||
/**
|
||||
* 根据门店所属大区和加盟模式查询新管家对应组织信息
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -1,5 +1,8 @@
|
||||
package com.cool.store.service;
|
||||
|
||||
import com.cool.store.userholder.CurrentUser;
|
||||
import com.cool.store.userholder.RefreshUser;
|
||||
|
||||
/**
|
||||
* @Author suzhuhong
|
||||
* @Date 2025/5/29 16:34
|
||||
@@ -13,7 +16,17 @@ public interface EnterpriseService {
|
||||
* @param mobile
|
||||
* @return
|
||||
*/
|
||||
String getAccessToken(String mobile);
|
||||
CurrentUser getLoginInfo(String mobile);
|
||||
|
||||
/**
|
||||
* 获取并缓存refreshToken
|
||||
*/
|
||||
RefreshUser getRefreshUser(String userId, String mobile);
|
||||
|
||||
/**
|
||||
* 校验用户新建分店/新建线索 可以选择加盟类型类型
|
||||
* @param userId
|
||||
* @param joinMode
|
||||
*/
|
||||
void checkUser(String userId,Integer joinMode);
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.cool.store.service;
|
||||
import com.cool.store.context.LoginUserInfo;
|
||||
import com.cool.store.dto.notice.NoticeDTO;
|
||||
import com.cool.store.request.notice.*;
|
||||
import com.cool.store.response.bigdata.ApiResponse;
|
||||
import com.cool.store.vo.PartnerUserInfoVO;
|
||||
import com.cool.store.vo.notice.*;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
@@ -51,11 +52,17 @@ public interface MessageTemplateService {
|
||||
/**
|
||||
* batch 批量发布
|
||||
* @param request
|
||||
* @param user
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
Boolean batchPublishMessageTemplate(BatchPublishRequest request, LoginUserInfo user);
|
||||
Boolean batchPublishMessageTemplate(BatchPublishRequest request, String userId);
|
||||
|
||||
/**
|
||||
* thirdMatterHandle 第三方接口处理
|
||||
* @param thirdMatterRequest
|
||||
* @return
|
||||
*/
|
||||
ApiResponse<Boolean> thirdMatterHandle(ThirdMatterRequest thirdMatterRequest);
|
||||
|
||||
/**
|
||||
* 获取列表
|
||||
@@ -84,15 +91,16 @@ public interface MessageTemplateService {
|
||||
*/
|
||||
Boolean revokeById(Long id, LoginUserInfo user);
|
||||
|
||||
List<ModuleAndMatterVO> getModuleList(String storeId,PartnerUserInfoVO userInfoVO);
|
||||
List<ModuleAndMatterVO> getModuleList(String storeId,String mobile);
|
||||
|
||||
PageInfo<StoreMessageVO> getStorePendingList(StoreMessagePendingRequest request);
|
||||
|
||||
MessageDetailVO getMessageDetail(Long id);
|
||||
|
||||
Boolean readMessage(Long id, PartnerUserInfoVO userInfoVO);
|
||||
Boolean readMessage(Long id, String mobile);
|
||||
|
||||
Boolean handleMessage(Long id, PartnerUserInfoVO userInfoVO);
|
||||
Boolean handleMessage(Long id, String userName,String mobile);
|
||||
|
||||
|
||||
ApiResponse<Boolean> thirdHandleMessage(ThirdHandleMessageRequest request);
|
||||
}
|
||||
|
||||
@@ -48,6 +48,12 @@ public interface PreparationService {
|
||||
* @param shopId
|
||||
*/
|
||||
void sysStoreCompleted(Long shopId);
|
||||
|
||||
/**
|
||||
* 营业执照和建店资料收集阶段完成后推进POS和营帐通开通
|
||||
* @param shopId 店铺id
|
||||
*/
|
||||
void businessLicenseAndBuildStoreCompleted(Long shopId);
|
||||
/**
|
||||
* 证照办理+建店资料 都完成 初始化平台建店数据
|
||||
* @param shopId
|
||||
@@ -89,6 +95,7 @@ public interface PreparationService {
|
||||
/**
|
||||
* POS 建店昨天完成
|
||||
* 选址与建店资料完成(加盟合同完成)
|
||||
* v20251024 选址与建店资料完成与营业执照完成
|
||||
* @param shopId
|
||||
* @return
|
||||
*/
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -51,4 +52,6 @@ public interface SignFranchiseService {
|
||||
|
||||
|
||||
Integer dateHandle();
|
||||
|
||||
HqtBuildRequest getHqtBuildRequest(Long shopId);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.cool.store.service;
|
||||
|
||||
import com.cool.store.dto.StoreDTO;
|
||||
import com.cool.store.dto.StoreNameDTO;
|
||||
import com.cool.store.dto.store.AuthStoreUserDTO;
|
||||
import com.cool.store.dto.store.StoreUserPositionDTO;
|
||||
import com.cool.store.response.MiniShopsResponse;
|
||||
@@ -24,6 +25,11 @@ public interface StoreService {
|
||||
*/
|
||||
PageInfo<StoreDTO> getStoreExtendFieldInfo(Integer pageSize,Integer pageNum);
|
||||
|
||||
/**
|
||||
* 分页查询接入物联网的门店
|
||||
*/
|
||||
PageInfo<StoreNameDTO> getIotStoreList(Integer pageNum, Integer pageSize);
|
||||
|
||||
PageInfo<MiniShopsResponse> getStoreListByMobile(String mobile,Integer pageNum,Integer pageSize,String storeName,String storeNum);
|
||||
|
||||
List<StoreUserPositionDTO> getStoreUser(List<String> storeCodeList);
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
package com.cool.store.service;
|
||||
|
||||
import com.cool.store.request.bigdata.LatestOrderDateRequest;
|
||||
import com.cool.store.request.bigdata.ProfitDataRequest;
|
||||
import com.cool.store.request.oppty.CityRequest;
|
||||
import com.cool.store.response.bigdata.ActDataResponse;
|
||||
import com.cool.store.response.bigdata.LatestOrderDateResponse;
|
||||
import com.cool.store.response.bigdata.ProfitDataResponse;
|
||||
import com.cool.store.response.bigdata.ProfitRateResponse;
|
||||
import com.cool.store.response.oppty.CityResponse;
|
||||
@@ -53,5 +55,11 @@ public interface ThirdBigDataService {
|
||||
*/
|
||||
ActDataResponse getActData(ProfitDataRequest requestBody);
|
||||
|
||||
/**
|
||||
* 获取门店最新订货日期
|
||||
* @param requestBody 最新订货日期Request
|
||||
* @return 最新订货日期Response列表
|
||||
*/
|
||||
List<LatestOrderDateResponse> getLatestOrderDate(LatestOrderDateRequest requestBody);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
package com.cool.store.service;
|
||||
|
||||
import com.cool.store.dto.FoodTokenDTO;
|
||||
import com.cool.store.dto.GetAccessTokenDTO;
|
||||
import com.cool.store.dto.recipe.RecipeSpLaunchDTO;
|
||||
import com.cool.store.dto.store.StoreUserUpdateDTO;
|
||||
import com.cool.store.request.recipe.RevenueDataRequest;
|
||||
import com.cool.store.response.caipin.StoreUserResponse;
|
||||
import com.cool.store.vo.recipe.RevenueDataVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 正新菜品市场api对接-埃林哲-对接人徐哲
|
||||
@@ -19,4 +25,24 @@ public interface ThirdFoodService {
|
||||
*/
|
||||
String getFoodToken(FoodTokenDTO dto);
|
||||
|
||||
/**
|
||||
* 推送门店人员信息
|
||||
* @param storeUserUpdateDTOList
|
||||
* @return
|
||||
*/
|
||||
StoreUserResponse pushStoreUser(List<StoreUserUpdateDTO> storeUserUpdateDTOList);
|
||||
|
||||
/**
|
||||
* 查询门店营收实收数据
|
||||
* @param request 营收数据Request
|
||||
* @return 营收数据VO列表
|
||||
*/
|
||||
List<RevenueDataVO> getRevenueData(RevenueDataRequest request);
|
||||
|
||||
/**
|
||||
* 查询菜品服务包上新数据
|
||||
* @param request 请求request
|
||||
* @return 服务包菜品上新DTO
|
||||
*/
|
||||
RecipeSpLaunchDTO getRecipeServiceLaunch(RevenueDataRequest request);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.cool.store.service;
|
||||
|
||||
import com.cool.store.dto.wx.MiniAppUrlLinkReqDTO;
|
||||
import com.cool.store.dto.wx.MiniProgramFreeLoginDTO;
|
||||
import com.cool.store.dto.wx.MiniProgramLoginDTO;
|
||||
import com.cool.store.request.MobileUpdateRequest;
|
||||
import com.cool.store.vo.PartnerUserInfoVO;
|
||||
@@ -28,4 +29,18 @@ public interface WechatMiniAppService {
|
||||
String getMiniAppUrl();
|
||||
|
||||
String getMiniAppUrlLink(MiniAppUrlLinkReqDTO miniAppUrlLinkReqDTO);
|
||||
|
||||
/**
|
||||
* 通过手机号获取短期token
|
||||
* @param param 小程序免登DTO
|
||||
* @return Token
|
||||
*/
|
||||
String getShortTermTokenByMobile(MiniProgramFreeLoginDTO param);
|
||||
|
||||
/**
|
||||
* 通过短期token获取用户信息
|
||||
* @param token 短期token
|
||||
* @return 用户信息VO
|
||||
*/
|
||||
PartnerUserInfoVO getUserInfoByShortTermToken(String token);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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) {
|
||||
@@ -138,13 +142,21 @@ public class ApplyLicenseServiceImpl implements ApplyLicenseService {
|
||||
ShopStageInfoDO shopSubStageInfo = shopStageInfoDAO.getShopSubStageInfo(request.getShopId(), ShopSubStageEnum.SHOP_STAGE_3);
|
||||
if (Constants.ONE_INTEGER.equals(request.getSubmitStatus()) && shopSubStageInfo.getShopSubStageStatus().equals(ShopSubStageStatusEnum.SHOP_SUB_STAGE_STATUS_30.getShopSubStageStatus())) {
|
||||
shopStageInfoDAO.updateShopStageAndAuditInfo(request.getShopId(), ShopSubStageStatusEnum.SHOP_SUB_STAGE_STATUS_33, null);
|
||||
preparationService.businessLicenseAndBuildStoreCompleted(request.getShopId());
|
||||
preparationService.licenseCompleted(request.getShopId());
|
||||
preparationService.updateShopStatus(request.getShopId());
|
||||
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));
|
||||
|
||||
@@ -25,8 +25,8 @@ public class BigRegionServiceImpl implements BigRegionService {
|
||||
BigRegionDAO bigRegionDAO;
|
||||
|
||||
@Override
|
||||
public List<BigRegionDTO> queryAllBigRegion(String keyword){
|
||||
return bigRegionDAO.queryAllBigRegion(keyword);
|
||||
public List<BigRegionDTO> queryAllBigRegion(String keyword, Integer joinBrand){
|
||||
return bigRegionDAO.queryAllBigRegion(keyword, joinBrand);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.cool.store.service.impl;
|
||||
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.cool.store.constants.CommonConstants;
|
||||
import com.cool.store.dao.*;
|
||||
import com.cool.store.entity.*;
|
||||
@@ -20,7 +21,7 @@ import com.cool.store.service.UserAuthMappingService;
|
||||
import com.cool.store.utils.RedisConstantUtil;
|
||||
import com.cool.store.utils.RedisUtilPool;
|
||||
import com.cool.store.utils.poi.StringUtils;
|
||||
import io.lettuce.core.ZAddArgs;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -38,6 +39,7 @@ import java.util.stream.Stream;
|
||||
* @createDate 2024-10-09 14:05:52
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class BuildInformationServiceImpl implements BuildInformationService {
|
||||
@Resource
|
||||
private PlatformBuildDAO platformBuildDAO;
|
||||
@@ -71,130 +73,14 @@ public class BuildInformationServiceImpl implements BuildInformationService {
|
||||
private OrderSysInfoDAO orderSysInfoDAO;
|
||||
@Autowired
|
||||
private BigRegionDAO bigRegionDAO;
|
||||
@Resource
|
||||
private AcceptanceInfoDAO acceptanceInfoDAO;
|
||||
|
||||
|
||||
@Override
|
||||
public BuildInformationResponse getBuildInformation(Long shopId) {
|
||||
BuildInformationResponse response = new BuildInformationResponse();
|
||||
ShopInfoDO shopInfo = shopInfoDAO.getShopInfo(shopId);
|
||||
if (Objects.isNull(shopInfo)) {
|
||||
throw new ServiceException(ErrorCodeEnum.SHOP_NOT_EXIST);
|
||||
}
|
||||
LineInfoDO lineInfoDO = lineInfoDAO.getLineInfo(shopInfo.getLineId());
|
||||
ShopStageInfoDO shopSubStageInfo = shopStageInfoDAO.getShopSubStageInfo(shopId, ShopSubStageEnum.SHOP_STAGE_15);
|
||||
response.setShopSubStageStatus(shopSubStageInfo.getShopSubStageStatus());
|
||||
response.setUsername(lineInfoDO.getUsername());
|
||||
response.setShopId(shopId);
|
||||
response.setShopName(shopInfo.getShopName());
|
||||
response.setShopCode(shopInfo.getShopCode());
|
||||
response.setProvince(shopInfo.getProvince());
|
||||
response.setDistrict(shopInfo.getDistrict());
|
||||
response.setCity(shopInfo.getCity());
|
||||
response.setTownship(shopInfo.getDetailAddress());
|
||||
BuildInformationDO informationDO = buildInformationDAO.selectOneByShopId(shopId);
|
||||
if (Objects.nonNull(informationDO)) {
|
||||
extracted(response, informationDO);
|
||||
}
|
||||
OrderSysInfoDO orderSysInfoDO = orderSysInfoDAO.selectByShopId(shopId);
|
||||
if (Objects.nonNull(orderSysInfoDO)) {
|
||||
response.setAddresseeName(orderSysInfoDO.getAddresseeName());
|
||||
response.setAddresseeMobile(orderSysInfoDO.getAddresseeMobile());
|
||||
response.setXgjVicePresident(orderSysInfoDO.getXgjVicePresident());
|
||||
response.setXgjRegionId(orderSysInfoDO.getXgjRegionId());
|
||||
response.setXgjRegionName(orderSysInfoDO.getXgjRegionName());
|
||||
response.setAddresseeProvince(orderSysInfoDO.getAddresseeProvince());
|
||||
response.setAddresseeCity(orderSysInfoDO.getAddresseeCity());
|
||||
response.setAddresseeDistrict(orderSysInfoDO.getAddresseeDistrict());
|
||||
response.setAddresseeAddress(orderSysInfoDO.getAddresseeAddress());
|
||||
response.setDeclareGoodsLogisticsWarehouse(orderSysInfoDO.getDeclareGoodsLogisticsWarehouse());
|
||||
response.setDeclareGoodsDate(orderSysInfoDO.getDeclareGoodsDate());
|
||||
response.setWarehouseDeliveryDate(orderSysInfoDO.getWarehouseDeliveryDate());
|
||||
response.setReceivingFirmName(orderSysInfoDO.getReceivingFirmName());
|
||||
response.setReceivingMsBankAccount(orderSysInfoDO.getReceivingMsBankAccount());
|
||||
response.setReceivingMsBankBranch(orderSysInfoDO.getReceivingMsBankBranch());
|
||||
response.setBankUnionPayAccount(orderSysInfoDO.getBankUnionPayAccount());
|
||||
WarehouseInfoDO warehouseInfoDO = warehouseInfoMapper.getByCode(orderSysInfoDO.getDeclareGoodsLogisticsWarehouse());
|
||||
if (Objects.nonNull(warehouseInfoDO)) {
|
||||
response.setDeclareGoodsLogisticsWarehouseName(warehouseInfoDO.getWarehouseName());
|
||||
}
|
||||
response.setDeclareGoodsType(orderSysInfoDO.getDeclareGoodsType());
|
||||
}
|
||||
if (StringUtils.isBlank(response.getXgjVicePresident())) {
|
||||
List<EnterpriseUserDO> userList = userAuthMappingService.getAllUserByRoleEnumAndRegionId(UserRoleEnum.VICE_PRESIDENT_IN_CHARGE, shopInfo.getRegionId());
|
||||
if (CollectionUtils.isNotEmpty(userList)) {
|
||||
List<EnumInfoDO> xgjVicePresidentList = enumInfoService.getByTypeCode(ZxjpEnum.XGJ_VICE_PRESIDENT.getCode());
|
||||
List<String> userNameSet = userList.stream().map(EnterpriseUserDO::getName).collect(Collectors.toList());
|
||||
List<String> xgjVicePresidentNameList = xgjVicePresidentList.stream().map(EnumInfoDO::getSysValue).collect(Collectors.toList());
|
||||
List<String> resultUserNameList = userNameSet.stream()
|
||||
.filter(xgjVicePresidentNameList::contains)
|
||||
.collect(Collectors.toList());
|
||||
if (CollectionUtils.isNotEmpty(resultUserNameList)){
|
||||
response.setXgjVicePresident(resultUserNameList.get(0));
|
||||
}
|
||||
}
|
||||
}
|
||||
//根据映射关系默认带出新管家组织
|
||||
if (StringUtils.isBlank(response.getXgjRegionName())) {
|
||||
Integer joinMode = shopInfo.getJoinMode() == 3 ? CommonConstants.ONE : CommonConstants.ZERO;
|
||||
BigRegionDO bigRegionDO = bigRegionDAO.queryOrgInfoByBigRegionAndJoinMode(shopInfo.getRegionId(), joinMode);
|
||||
if (Objects.nonNull(bigRegionDO)) {
|
||||
response.setXgjRegionId(bigRegionDO.getOrgId());
|
||||
response.setXgjRegionName(bigRegionDO.getOrgName());
|
||||
}
|
||||
}
|
||||
if (StringUtils.isBlank(response.getAddresseeProvince())) {
|
||||
response.setAddresseeProvince(shopInfo.getProvince());
|
||||
}
|
||||
if (StringUtils.isBlank(response.getAddresseeCity())) {
|
||||
response.setAddresseeCity(shopInfo.getCity());
|
||||
}
|
||||
if (StringUtils.isBlank(response.getAddresseeDistrict())) {
|
||||
response.setAddresseeDistrict(shopInfo.getDistrict());
|
||||
}
|
||||
if (StringUtils.isBlank(response.getAddresseeAddress())) {
|
||||
response.setAddresseeAddress(shopInfo.getDetailAddress());
|
||||
}
|
||||
|
||||
return response;
|
||||
|
||||
}
|
||||
|
||||
private static void extracted(BuildInformationResponse response, BuildInformationDO informationDO) {
|
||||
response.setShopContactName(informationDO.getShopContactName());
|
||||
response.setShopContactMobile(informationDO.getShopContactMobile());
|
||||
response.setBusinessHours(informationDO.getBusinessHours());
|
||||
response.setBusinessMobile(informationDO.getBusinessMobile());
|
||||
response.setDoorPhoto(informationDO.getDoorPhoto());
|
||||
response.setInStorePhoto(informationDO.getInStorePhoto());
|
||||
response.setJuridicalIdCardFront(informationDO.getJuridicalIdCardFront());
|
||||
response.setJuridicalName(informationDO.getJuridicalName());
|
||||
response.setJuridicalIdCardNo(informationDO.getJuridicalIdCardNo());
|
||||
response.setJuridicalIdCardReverse(informationDO.getJuridicalIdCardReverse());
|
||||
response.setJuridicalHandheldIdCardReverse(informationDO.getJuridicalHandheldIdCardReverse());
|
||||
response.setJuridicalHandheldIdCardFront(informationDO.getJuridicalHandheldIdCardFront());
|
||||
response.setJuridicalHandheldIdCardReverse(informationDO.getJuridicalHandheldIdCardReverse());
|
||||
response.setSettlerIdCardNo(informationDO.getSettlerIdCardNo());
|
||||
response.setSettlerName(informationDO.getSettlerName());
|
||||
response.setSettlerBankPhotoUrl(informationDO.getSettlerBankPhotoUrl());
|
||||
response.setSettlerIdCardFront(informationDO.getSettlerIdCardFront());
|
||||
response.setSettlerIdCardReverse(informationDO.getSettlerIdCardReverse());
|
||||
response.setSettlerBankNumber(informationDO.getSettlerBankNumber());
|
||||
response.setSettlerBankMobile(informationDO.getSettlerBankMobile());
|
||||
response.setSettlerBankName(informationDO.getSettlerBankName());
|
||||
response.setAuthorizationUrl(informationDO.getAuthorizationUrl());
|
||||
response.setRelationshipProve(informationDO.getRelationshipProve());
|
||||
response.setAccountOpeningPermit(informationDO.getAccountOpeningPermit());
|
||||
response.setSettlerInHandFrontPicture(informationDO.getSettlerInHandFrontPicture());
|
||||
response.setSettlerInHandBackPicture(informationDO.getSettlerInHandBackPicture());
|
||||
response.setMiniProgramsShopName(informationDO.getCShopName());
|
||||
response.setSettlerBankBackPhotoUrl(informationDO.getSettlerBankBackPhotoUrl());
|
||||
response.setSettlerIsSamePartner(informationDO.getSettlerIsSamePartner());
|
||||
response.setJuridicalIsSamePartner(informationDO.getJuridicalIsSamePartner());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Integer submitOrUpdate(BuildInformationRequest request) {
|
||||
log.info("提交/修改建店资料开始,shopId:{}", JSONObject.toJSONString(request));
|
||||
String lockKey = redisConstantUtil.submitBuildKey(request.getShopId());
|
||||
String lockValue = UUID.randomUUID().toString();
|
||||
boolean acquired = false;
|
||||
@@ -203,6 +89,9 @@ public class BuildInformationServiceImpl implements BuildInformationService {
|
||||
if (Boolean.TRUE.equals(acquired)) {
|
||||
ShopInfoDO shopInfoDO = shopInfoDAO.getShopInfo(request.getShopId());
|
||||
// if (JoinModeEnum.FLAGSHIP_STORE.getCode()!=shopInfoDO.getJoinMode()){
|
||||
// log.info("FLAGSHIP_STORE:{},{},{},{},{},{},{}",request.getSettlerName(),request.getSettlerIdCardFront(),
|
||||
// request.getSettlerInHandFrontPicture(),request.getSettlerBankBackPhotoUrl(),
|
||||
// request.getSettlerBankNumber(),request.getSettlerBankMobile(),request.getSettlerBankName());
|
||||
// //校验结算人非空
|
||||
// if (StringUtils.isAnyBlank(request.getSettlerName(),request.getSettlerIdCardFront(),
|
||||
// request.getSettlerInHandFrontPicture(),request.getSettlerBankBackPhotoUrl(),
|
||||
@@ -284,6 +173,133 @@ public class BuildInformationServiceImpl implements BuildInformationService {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public BuildInformationResponse getBuildInformation(Long shopId) {
|
||||
BuildInformationResponse response = new BuildInformationResponse();
|
||||
ShopInfoDO shopInfo = shopInfoDAO.getShopInfo(shopId);
|
||||
if (Objects.isNull(shopInfo)) {
|
||||
throw new ServiceException(ErrorCodeEnum.SHOP_NOT_EXIST);
|
||||
}
|
||||
LineInfoDO lineInfoDO = lineInfoDAO.getLineInfo(shopInfo.getLineId());
|
||||
ShopStageInfoDO shopSubStageInfo = shopStageInfoDAO.getShopSubStageInfo(shopId, ShopSubStageEnum.SHOP_STAGE_15);
|
||||
response.setShopSubStageStatus(shopSubStageInfo.getShopSubStageStatus());
|
||||
response.setUsername(lineInfoDO.getUsername());
|
||||
response.setShopId(shopId);
|
||||
response.setShopName(shopInfo.getShopName());
|
||||
response.setShopCode(shopInfo.getShopCode());
|
||||
response.setProvince(shopInfo.getProvince());
|
||||
response.setDistrict(shopInfo.getDistrict());
|
||||
response.setCity(shopInfo.getCity());
|
||||
response.setTownship(shopInfo.getDetailAddress());
|
||||
BuildInformationDO informationDO = buildInformationDAO.selectOneByShopId(shopId);
|
||||
if (Objects.nonNull(informationDO)) {
|
||||
extracted(response, informationDO);
|
||||
}
|
||||
OrderSysInfoDO orderSysInfoDO = orderSysInfoDAO.selectByShopId(shopId);
|
||||
if (Objects.nonNull(orderSysInfoDO)) {
|
||||
response.setAddresseeName(orderSysInfoDO.getAddresseeName());
|
||||
response.setAddresseeMobile(orderSysInfoDO.getAddresseeMobile());
|
||||
response.setXgjVicePresident(orderSysInfoDO.getXgjVicePresident());
|
||||
response.setXgjRegionId(orderSysInfoDO.getXgjRegionId());
|
||||
response.setXgjRegionName(orderSysInfoDO.getXgjRegionName());
|
||||
response.setAddresseeProvince(orderSysInfoDO.getAddresseeProvince());
|
||||
response.setAddresseeCity(orderSysInfoDO.getAddresseeCity());
|
||||
response.setAddresseeDistrict(orderSysInfoDO.getAddresseeDistrict());
|
||||
response.setAddresseeAddress(orderSysInfoDO.getAddresseeAddress());
|
||||
response.setDeclareGoodsLogisticsWarehouse(orderSysInfoDO.getDeclareGoodsLogisticsWarehouse());
|
||||
response.setDeclareGoodsDate(orderSysInfoDO.getDeclareGoodsDate());
|
||||
response.setWarehouseDeliveryDate(orderSysInfoDO.getWarehouseDeliveryDate());
|
||||
response.setReceivingFirmName(orderSysInfoDO.getReceivingFirmName());
|
||||
response.setReceivingMsBankAccount(orderSysInfoDO.getReceivingMsBankAccount());
|
||||
response.setReceivingMsBankBranch(orderSysInfoDO.getReceivingMsBankBranch());
|
||||
response.setBankUnionPayAccount(orderSysInfoDO.getBankUnionPayAccount());
|
||||
response.setOrderType(orderSysInfoDO.getOrderType());
|
||||
WarehouseInfoDO warehouseInfoDO = warehouseInfoMapper.getByCode(orderSysInfoDO.getDeclareGoodsLogisticsWarehouse());
|
||||
if (Objects.nonNull(warehouseInfoDO)) {
|
||||
response.setDeclareGoodsLogisticsWarehouseName(warehouseInfoDO.getWarehouseName());
|
||||
}
|
||||
response.setDeclareGoodsType(orderSysInfoDO.getDeclareGoodsType());
|
||||
}
|
||||
if (StringUtils.isBlank(response.getXgjVicePresident())) {
|
||||
List<EnterpriseUserDO> userList = userAuthMappingService.getAllUserByRoleEnumAndRegionId(UserRoleEnum.VICE_PRESIDENT_IN_CHARGE, shopInfo.getRegionId());
|
||||
if (CollectionUtils.isNotEmpty(userList)) {
|
||||
List<EnumInfoDO> xgjVicePresidentList = enumInfoService.getByTypeCode(ZxjpEnum.XGJ_VICE_PRESIDENT.getCode());
|
||||
List<String> userNameSet = userList.stream().map(EnterpriseUserDO::getName).collect(Collectors.toList());
|
||||
List<String> xgjVicePresidentNameList = xgjVicePresidentList.stream().map(EnumInfoDO::getSysValue).collect(Collectors.toList());
|
||||
List<String> resultUserNameList = userNameSet.stream()
|
||||
.filter(xgjVicePresidentNameList::contains)
|
||||
.collect(Collectors.toList());
|
||||
if (CollectionUtils.isNotEmpty(resultUserNameList)){
|
||||
response.setXgjVicePresident(resultUserNameList.get(0));
|
||||
}
|
||||
}
|
||||
}
|
||||
//根据映射关系默认带出新管家组织
|
||||
if (StringUtils.isBlank(response.getXgjRegionName())) {
|
||||
Integer joinMode = shopInfo.getJoinMode() == 3 ? CommonConstants.ONE : CommonConstants.ZERO;
|
||||
BigRegionDO bigRegionDO = bigRegionDAO.queryOrgInfoByBigRegionAndJoinMode(shopInfo.getRegionId(), joinMode);
|
||||
if (Objects.nonNull(bigRegionDO)) {
|
||||
response.setXgjRegionId(bigRegionDO.getOrgId());
|
||||
response.setXgjRegionName(bigRegionDO.getOrgName());
|
||||
}
|
||||
}
|
||||
if (StringUtils.isBlank(response.getAddresseeProvince())) {
|
||||
response.setAddresseeProvince(shopInfo.getProvince());
|
||||
}
|
||||
if (StringUtils.isBlank(response.getAddresseeCity())) {
|
||||
response.setAddresseeCity(shopInfo.getCity());
|
||||
}
|
||||
if (StringUtils.isBlank(response.getAddresseeDistrict())) {
|
||||
response.setAddresseeDistrict(shopInfo.getDistrict());
|
||||
}
|
||||
if (StringUtils.isBlank(response.getAddresseeAddress())) {
|
||||
response.setAddresseeAddress(shopInfo.getDetailAddress());
|
||||
}
|
||||
// 不存在的情况下从装修验收中获取
|
||||
if (StringUtils.isBlank(response.getDoorPhoto()) || StringUtils.isBlank(response.getInStorePhoto())) {
|
||||
AcceptanceInfoDO acceptanceInfoDO = acceptanceInfoDAO.selectByShopId(shopId);
|
||||
if (Objects.nonNull(acceptanceInfoDO)) {
|
||||
response.setDoorPhoto(StringUtils.isNotBlank(response.getDoorPhoto()) ? response.getDoorPhoto() : acceptanceInfoDO.getShopDoorwayPhoto());
|
||||
response.setInStorePhoto(StringUtils.isNotBlank(response.getInStorePhoto()) ? response.getInStorePhoto() : acceptanceInfoDO.getShopInteriorPhoto());
|
||||
}
|
||||
}
|
||||
return response;
|
||||
|
||||
}
|
||||
|
||||
private static void extracted(BuildInformationResponse response, BuildInformationDO informationDO) {
|
||||
response.setShopContactName(informationDO.getShopContactName());
|
||||
response.setShopContactMobile(informationDO.getShopContactMobile());
|
||||
response.setBusinessHours(informationDO.getBusinessHours());
|
||||
response.setBusinessMobile(informationDO.getBusinessMobile());
|
||||
response.setDoorPhoto(informationDO.getDoorPhoto());
|
||||
response.setInStorePhoto(informationDO.getInStorePhoto());
|
||||
response.setJuridicalIdCardFront(informationDO.getJuridicalIdCardFront());
|
||||
response.setJuridicalName(informationDO.getJuridicalName());
|
||||
response.setJuridicalIdCardNo(informationDO.getJuridicalIdCardNo());
|
||||
response.setJuridicalIdCardReverse(informationDO.getJuridicalIdCardReverse());
|
||||
response.setJuridicalHandheldIdCardReverse(informationDO.getJuridicalHandheldIdCardReverse());
|
||||
response.setJuridicalHandheldIdCardFront(informationDO.getJuridicalHandheldIdCardFront());
|
||||
response.setJuridicalHandheldIdCardReverse(informationDO.getJuridicalHandheldIdCardReverse());
|
||||
response.setSettlerIdCardNo(informationDO.getSettlerIdCardNo());
|
||||
response.setSettlerName(informationDO.getSettlerName());
|
||||
response.setSettlerBankPhotoUrl(informationDO.getSettlerBankPhotoUrl());
|
||||
response.setSettlerIdCardFront(informationDO.getSettlerIdCardFront());
|
||||
response.setSettlerIdCardReverse(informationDO.getSettlerIdCardReverse());
|
||||
response.setSettlerBankNumber(informationDO.getSettlerBankNumber());
|
||||
response.setSettlerBankMobile(informationDO.getSettlerBankMobile());
|
||||
response.setSettlerBankName(informationDO.getSettlerBankName());
|
||||
response.setAuthorizationUrl(informationDO.getAuthorizationUrl());
|
||||
response.setRelationshipProve(informationDO.getRelationshipProve());
|
||||
response.setAccountOpeningPermit(informationDO.getAccountOpeningPermit());
|
||||
response.setSettlerInHandFrontPicture(informationDO.getSettlerInHandFrontPicture());
|
||||
response.setSettlerInHandBackPicture(informationDO.getSettlerInHandBackPicture());
|
||||
response.setMiniProgramsShopName(informationDO.getCShopName());
|
||||
response.setSettlerBankBackPhotoUrl(informationDO.getSettlerBankBackPhotoUrl());
|
||||
response.setSettlerIsSamePartner(informationDO.getSettlerIsSamePartner());
|
||||
response.setJuridicalIsSamePartner(informationDO.getJuridicalIsSamePartner());
|
||||
}
|
||||
|
||||
private static @NotNull OrderSysInfoDO getOrderSysInfoDO(BuildInformationRequest request) {
|
||||
OrderSysInfoDO orderSysInfoDO = new OrderSysInfoDO();
|
||||
orderSysInfoDO.setShopId(request.getShopId());
|
||||
|
||||
@@ -1170,7 +1170,7 @@ public class DataHandlerServerImpl implements DataHandlerServer {
|
||||
shopInfoDO.setManagerRegionId(isCreateStoreDTO.getPid());
|
||||
updateList.add(shopInfoDO);
|
||||
}
|
||||
List<BigRegionDTO> bigRegionDTOS = bigRegionDAO.queryAllBigRegion(null);
|
||||
List<BigRegionDTO> bigRegionDTOS = bigRegionDAO.queryAllBigRegion(null, null);
|
||||
Map<Long, BigRegionDTO> bigRegionDTOMap = bigRegionDTOS.stream().collect(Collectors.toMap(BigRegionDTO::getRegionId, x -> x));
|
||||
//XX大区 正烧鸡
|
||||
List<Long> storeManageIds = bigRegionDTOS.stream().filter(x -> x.getStoreManageRegionId() != null).map(BigRegionDTO::getStoreManageRegionId).collect(Collectors.toList());
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.cool.store.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.cool.store.dao.*;
|
||||
import com.cool.store.entity.*;
|
||||
import com.cool.store.enums.ErrorCodeEnum;
|
||||
@@ -10,14 +12,12 @@ import com.cool.store.exception.ServiceException;
|
||||
import com.cool.store.request.*;
|
||||
import com.cool.store.service.DecorationDesignInfoService;
|
||||
import com.cool.store.utils.poi.StringUtils;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@@ -40,6 +40,8 @@ public class DecorationDesignInfoServiceImpl implements DecorationDesignInfoServ
|
||||
private ShopStageInfoDAO shopStageInfoDAO;
|
||||
@Resource
|
||||
private LineInfoDAO lineInfoDAO;
|
||||
@Resource
|
||||
private BuildInformationDAO buildInformationDAO;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@@ -277,8 +279,28 @@ public class DecorationDesignInfoServiceImpl implements DecorationDesignInfoServ
|
||||
if (shopSubStageInfo.getShopSubStageStatus().equals(ShopSubStageStatusEnum.SHOP_SUB_STAGE_STATUS_122.getShopSubStageStatus())) {
|
||||
shopStageInfoDAO.updateShopStageInfo(shopInfoDO.getId(), ShopSubStageStatusEnum.SHOP_SUB_STAGE_STATUS_123);
|
||||
}
|
||||
// 覆盖建店资料中的门头照和内景照
|
||||
BuildInformationDO buildInformation = BuildInformationDO.builder().shopId(request.getShopId()).doorPhoto(buildJson(request.getShopDoorwayPhotoUrl()))
|
||||
.inStorePhoto(buildJson(request.getShopInteriorPhotoUrl())).build();
|
||||
buildInformationDAO.updateByShopIdSelective(buildInformation);
|
||||
return true;
|
||||
}
|
||||
|
||||
public String buildJson(List<String> urls) {
|
||||
if (CollectionUtils.isEmpty(urls)) {
|
||||
return null;
|
||||
}
|
||||
JSONArray jsonArray = new JSONArray();
|
||||
for (String url : urls) {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("url", url);
|
||||
jsonObject.put("type", extractImageSuffix(url));
|
||||
jsonArray.add(jsonObject);
|
||||
}
|
||||
return jsonArray.toJSONString();
|
||||
}
|
||||
|
||||
public String extractImageSuffix(String url) {
|
||||
return url.substring(url.lastIndexOf(".") + 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -725,6 +725,7 @@ public class DeskServiceImpl implements DeskService {
|
||||
preparationCommonPendingVO.setShopManagerUserName(userNameMap.getOrDefault(shopInfoDO.getShopManagerUserId(), ""));
|
||||
preparationCommonPendingVO.setRegionNodeName(regionNameMap.getOrDefault(shopInfoDO.getRegionId(), ""));
|
||||
preparationCommonPendingVO.setUpdateTime(x.getUpdateTime());
|
||||
preparationCommonPendingVO.setFranchiseBrand(shopInfoDO.getFranchiseBrand());
|
||||
list.add(preparationCommonPendingVO);
|
||||
});
|
||||
result.setList(list);
|
||||
|
||||
@@ -1,19 +1,23 @@
|
||||
package com.cool.store.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.cool.store.constants.CommonConstants;
|
||||
import com.cool.store.constants.RedisConstant;
|
||||
import com.cool.store.dao.EnterpriseUserDAO;
|
||||
import com.cool.store.entity.EnterpriseUserDO;
|
||||
import com.cool.store.entity.SysRoleDO;
|
||||
import com.cool.store.enums.ErrorCodeEnum;
|
||||
import com.cool.store.enums.JoinModeEnum;
|
||||
import com.cool.store.enums.Role;
|
||||
import com.cool.store.enums.UserStatusEnum;
|
||||
import com.cool.store.exception.ServiceException;
|
||||
import com.cool.store.mapper.SysRoleMapper;
|
||||
import com.cool.store.service.EnterpriseService;
|
||||
import com.cool.store.userholder.CurrentUser;
|
||||
import com.cool.store.userholder.RefreshUser;
|
||||
import com.cool.store.utils.RedisUtilPool;
|
||||
import com.cool.store.utils.poi.DateUtils;
|
||||
import com.cool.store.utils.poi.constant.Constants;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.shiro.crypto.RandomNumberGenerator;
|
||||
@@ -48,7 +52,7 @@ public class EnterpriseServiceImpl implements EnterpriseService {
|
||||
private String eid;
|
||||
|
||||
@Override
|
||||
public String getAccessToken(String mobile) {
|
||||
public CurrentUser getLoginInfo(String mobile) {
|
||||
CurrentUser currentUser = new CurrentUser();
|
||||
EnterpriseUserDO enterpriseUser = enterpriseUserDAO.selectByMobile(mobile);
|
||||
if (Objects.isNull(enterpriseUser)){
|
||||
@@ -107,8 +111,36 @@ public class EnterpriseServiceImpl implements EnterpriseService {
|
||||
currentUser.setAppType("qw_self_dkf");
|
||||
currentUser.setUnionid(enterpriseUser.getUnionid());
|
||||
currentUser.setUserType(enterpriseUser.getUserType());
|
||||
redisUtilPool.setString(RedisConstant.ACCESS_TOKEN_PREFIX + currentUser.getAccessToken(), JSON.toJSONString(currentUser), 24 * 60 * 60);
|
||||
return currentUser.getAccessToken();
|
||||
redisUtilPool.setString(RedisConstant.ACCESS_TOKEN_PREFIX + currentUser.getAccessToken(), JSON.toJSONString(currentUser), CommonConstants.ACTION_TOKEN_EXPIRE);
|
||||
return currentUser;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RefreshUser getRefreshUser(String userId, String mobile) {
|
||||
if (StringUtils.isBlank(mobile)) {
|
||||
EnterpriseUserDO userInfo = enterpriseUserDAO.getUserInfoById(userId);
|
||||
mobile = userInfo.getMobile();
|
||||
}
|
||||
String refreshToken = getToken();
|
||||
RefreshUser refreshUser = new RefreshUser(userId, refreshToken, mobile);
|
||||
redisUtilPool.setString(RedisConstant.REFRESH_TOKEN_PREFIX + refreshToken, JSON.toJSONString(refreshUser), CommonConstants.REFRESH_TOKEN_EXPIRE);
|
||||
return refreshUser;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkUser(String userId,Integer joinMode) {
|
||||
EnterpriseUserDO userInfo = enterpriseUserDAO.getUserInfoById(userId);
|
||||
if (userInfo !=null){
|
||||
//校验当前人员是否是加盟部 581
|
||||
String departments = userInfo.getDepartments();
|
||||
//如果departments包含/581/ 加盟部
|
||||
if (com.cool.store.utils.poi.StringUtils.isNotBlank(departments) && departments.contains("/581/")) {
|
||||
//加盟部 FRANCHISE_COMPANIES
|
||||
if (!JoinModeEnum.isFranchise(joinMode)){
|
||||
throw new ServiceException(ErrorCodeEnum.JOIN_MODE_NOT_ALLOW_OPERATE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
@@ -75,6 +75,13 @@ public class FranchiseFeeServiceImpl implements FranchiseFeeService {
|
||||
if (!shopStageInfo.getShopSubStageStatus().equals(ShopSubStageStatusEnum.SHOP_SUB_STAGE_STATUS_70.getShopSubStageStatus())){
|
||||
throw new ServiceException(ErrorCodeEnum.NOT_ALLOW_OPERATE);
|
||||
}
|
||||
ShopInfoDO shopInfoDO = shopInfoMapper.selectByPrimaryKey(request.getShopId());
|
||||
// 三明治前端没有改这块代码,还是会传这三个字段,因此后端这三个字段置空
|
||||
if (Integer.valueOf(shopInfoDO.getFranchiseBrand()).equals(FranchiseBrandEnum.ZXSMZ.getCode())) {
|
||||
request.setFirstYearManageFee("0");
|
||||
request.setFirstYearFee("0");
|
||||
request.setYearFranchiseFee("0");
|
||||
}
|
||||
FranchiseFeeDO franchiseFeeDO = request.toFranchiseFeeDO();
|
||||
shopStageInfoDAO.updateShopStageInfo(request.getShopId(), ShopSubStageStatusEnum.SHOP_SUB_STAGE_STATUS_71);
|
||||
if (request.getId() != null) {
|
||||
@@ -89,11 +96,11 @@ public class FranchiseFeeServiceImpl implements FranchiseFeeService {
|
||||
franchiseFeeDO.setCreateTime(new Date());
|
||||
franchiseFeeMapper.insertSelective(franchiseFeeDO);
|
||||
}
|
||||
ShopInfoDO shopInfoDO = shopInfoMapper.selectByPrimaryKey(request.getShopId());
|
||||
LineInfoDO lineInfoDO = lineInfoMapper.getByLineId(shopInfoDO.getLineId());
|
||||
commonService.sendSms(lineInfoDO.getMobile(), SMSMsgEnum.PAY_FRANCHISE_FEES);
|
||||
//推送加盟费信息到新管家
|
||||
PushFranchiseFeeRequest feeRequest = new PushFranchiseFeeRequest(shopInfoDO.getId(), lineInfoDO.getUsername(), franchiseFeeDO);
|
||||
feeRequest.setJoinBrand(Integer.valueOf(shopInfoDO.getFranchiseBrand()));
|
||||
pushService.pushFranchiseFeeToXGJ(feeRequest);
|
||||
return true;
|
||||
}
|
||||
@@ -116,6 +123,7 @@ public class FranchiseFeeServiceImpl implements FranchiseFeeService {
|
||||
//推送加盟费信息到新管家
|
||||
franchiseFeeDO.setCreateTime(franchiseFeeDO1.getCreateTime());
|
||||
PushFranchiseFeeRequest feeRequest = new PushFranchiseFeeRequest(shopInfoDO.getId(), lineInfoDO.getUsername(), franchiseFeeDO);
|
||||
feeRequest.setJoinBrand(Integer.valueOf(shopInfoDO.getFranchiseBrand()));
|
||||
pushService.pushFranchiseFeeToXGJ(feeRequest);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -305,6 +305,10 @@ public class LinePayServiceImpl implements LinePayService {
|
||||
public Boolean pushPayInfo(Long shopId, LinePayDO linePayDO) {
|
||||
FranchiseFeeDO franchiseFeeDO = franchiseFeeMapper.selectByShopId(shopId);
|
||||
ReceiptRequest receiptRequest = new ReceiptRequest(shopId, franchiseFeeDO.getId().intValue(), linePayDO);
|
||||
ShopInfoDO shopInfoDO = shopInfoMapper.selectByPrimaryKey(shopId);
|
||||
if (Objects.nonNull(shopInfoDO)) {
|
||||
receiptRequest.setJoinBrand(Integer.valueOf(shopInfoDO.getFranchiseBrand()));
|
||||
}
|
||||
//推送缴费单数据到新管家
|
||||
pushService.pushReceiptToXGJ(receiptRequest);
|
||||
return Boolean.TRUE;
|
||||
|
||||
@@ -88,6 +88,8 @@ public class LineServiceImpl implements LineService {
|
||||
private RegionQrcodeConfigDao regionQrcodeConfigDao;
|
||||
@Resource
|
||||
QualificationsInfoDAO qualificationsInfoDAO;
|
||||
@Resource
|
||||
EnterpriseService enterpriseService;
|
||||
|
||||
|
||||
@Override
|
||||
@@ -514,6 +516,7 @@ public class LineServiceImpl implements LineService {
|
||||
public Boolean addLine(AddLineRequest addLineRequest, LoginUserInfo userInfo) {
|
||||
//必填参数
|
||||
log.info("addLine:{}", JSONObject.toJSONString(addLineRequest));
|
||||
enterpriseService.checkUser(userInfo.getUserId(), addLineRequest.getJoinMode());
|
||||
if (!StringUtil.isNoneBlank(addLineRequest.getMobile(), addLineRequest.getUserName())) {
|
||||
throw new ServiceException(ErrorCodeEnum.PARAMS_REQUIRED);
|
||||
}
|
||||
|
||||
@@ -5,6 +5,8 @@ import com.cool.store.context.LoginUserInfo;
|
||||
import com.cool.store.dao.MatterConfigDAO;
|
||||
import com.cool.store.dto.notice.CommonDTO;
|
||||
import com.cool.store.entity.MatterConfigDO;
|
||||
import com.cool.store.enums.ErrorCodeEnum;
|
||||
import com.cool.store.exception.ServiceException;
|
||||
import com.cool.store.request.notice.MatterConfigAddRequest;
|
||||
import com.cool.store.request.notice.MatterConfigQueryRequest;
|
||||
import com.cool.store.service.MatterConfigService;
|
||||
@@ -36,19 +38,30 @@ public class MatterConfigServiceImpl implements MatterConfigService {
|
||||
MatterConfigDO matterConfigDO = new MatterConfigDO();
|
||||
BeanUtils.copyProperties(request, matterConfigDO);
|
||||
matterConfigDO.setCreateUserId(currentUser.getUserId());
|
||||
matterConfigDO.setDefaultStoreInfo(JSONObject.toJSONString(request.getStoreInfoList()));
|
||||
matterConfigDO.setDefaultHandlePersonInfo(JSONObject.toJSONString(request.getUserInfoList()));
|
||||
if (CollectionUtils.isNotEmpty(request.getStoreInfoList())){
|
||||
matterConfigDO.setDefaultStoreInfo(JSONObject.toJSONString(request.getStoreInfoList()));
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(request.getUserInfoList())){
|
||||
matterConfigDO.setDefaultHandlePersonInfo(JSONObject.toJSONString(request.getUserInfoList()));
|
||||
}
|
||||
return matterConfigDAO.insert(matterConfigDO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int editMatterConfig(MatterConfigAddRequest request, LoginUserInfo currentUser) {
|
||||
if (request.getId() == null){
|
||||
throw new ServiceException(ErrorCodeEnum.PARAMS_VALIDATE_ERROR);
|
||||
}
|
||||
MatterConfigDO matterConfigDO = new MatterConfigDO();
|
||||
BeanUtils.copyProperties(request, matterConfigDO);
|
||||
matterConfigDO.setUpdateUserId(currentUser.getUserId());
|
||||
matterConfigDO.setUpdateTime(new Date());
|
||||
matterConfigDO.setDefaultStoreInfo(JSONObject.toJSONString(request.getStoreInfoList()));
|
||||
matterConfigDO.setDefaultHandlePersonInfo(JSONObject.toJSONString(request.getUserInfoList()));
|
||||
if (CollectionUtils.isNotEmpty(request.getStoreInfoList())){
|
||||
matterConfigDO.setDefaultStoreInfo(JSONObject.toJSONString(request.getStoreInfoList()));
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(request.getUserInfoList())){
|
||||
matterConfigDO.setDefaultHandlePersonInfo(JSONObject.toJSONString(request.getUserInfoList()));
|
||||
}
|
||||
return matterConfigDAO.updateForce(matterConfigDO);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
package com.cool.store.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollStreamUtil;
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.cool.store.dao.MessageTemplateDAO;
|
||||
import com.cool.store.entity.MessageTemplateDO;
|
||||
import com.cool.store.entity.StoreMessageDO;
|
||||
import com.cool.store.enums.ErrorCodeEnum;
|
||||
import com.cool.store.exception.ServiceException;
|
||||
import com.cool.store.vo.notice.StoreMessageVO;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.messaging.MessagingException;
|
||||
import org.springframework.messaging.simp.SimpMessagingTemplate;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 消息下发 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author wangff
|
||||
* @since 2025/9/5
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class MessageIssueService {
|
||||
private final MessageTemplateDAO messageTemplateDAO;
|
||||
private final SimpMessagingTemplate simpMessagingTemplate;
|
||||
|
||||
/**
|
||||
* 下发即时通知消息
|
||||
*
|
||||
* @param list 门店消息列表
|
||||
*/
|
||||
@Async("generalThreadPool")
|
||||
public void issueMessage(List<StoreMessageDO> list) {
|
||||
if (CollectionUtils.isEmpty(list)) return;
|
||||
log.info("下发即时通知, messageList:{}", JSONObject.toJSONString(list));
|
||||
try {
|
||||
Set<Long> messageTemplateIds = CollStreamUtil.toSet(list, StoreMessageDO::getMessageTemplateId);
|
||||
List<MessageTemplateDO> messageTemplateList = messageTemplateDAO.getByIds(new ArrayList<>(messageTemplateIds));
|
||||
Map<Long, MessageTemplateDO> messageTemplateMap = CollStreamUtil.toMap(messageTemplateList, MessageTemplateDO::getId, v -> v);
|
||||
|
||||
for (StoreMessageDO storeMessageDO : list) {
|
||||
if (StringUtils.isNotBlank(storeMessageDO.getOperatorList())) {
|
||||
String[] userIds = storeMessageDO.getOperatorList().split(",");
|
||||
if (ArrayUtil.isNotEmpty(userIds)) {
|
||||
MessageTemplateDO messageTemplateDO = messageTemplateMap.get(storeMessageDO.getMessageTemplateId());
|
||||
if (Objects.isNull(messageTemplateDO)) {
|
||||
throw new ServiceException(ErrorCodeEnum.MESSAGE_NOT_EXIST);
|
||||
}
|
||||
StoreMessageVO storeMessageVO = BeanUtil.toBean(storeMessageDO, StoreMessageVO.class);
|
||||
BeanUtil.copyProperties(messageTemplateDO, storeMessageVO, "id");
|
||||
String message = JSONObject.toJSONString(storeMessageVO);
|
||||
for (String userId : userIds) {
|
||||
try {
|
||||
simpMessagingTemplate.convertAndSend("/queue/message/" + userId, message);
|
||||
} catch (MessagingException e) {
|
||||
log.info("即时通知下发异常, userId:{}, error:{}", userId, e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.info("即时通知下发异常", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,40 +3,46 @@ package com.cool.store.service.impl;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.cool.store.context.LoginUserInfo;
|
||||
import com.cool.store.context.PartnerUserHolder;
|
||||
import com.cool.store.dao.EnterpriseUserDAO;
|
||||
import com.cool.store.dao.MessageTemplateDAO;
|
||||
import com.cool.store.dao.RegionDao;
|
||||
import com.cool.store.dao.StoreMessageDAO;
|
||||
import com.cool.store.dao.*;
|
||||
import com.cool.store.dto.notice.CommonDTO;
|
||||
import com.cool.store.dto.notice.MessageTemplateCountDTO;
|
||||
import com.cool.store.dto.notice.NoticeDTO;
|
||||
import com.cool.store.dto.store.AuthStoreUserDTO;
|
||||
import com.cool.store.dto.store.StoreAreaDTO;
|
||||
import com.cool.store.dto.wechat.ServiceAccountOpenIdDTO;
|
||||
import com.cool.store.entity.*;
|
||||
import com.cool.store.enums.ErrorCodeEnum;
|
||||
import com.cool.store.enums.notice.*;
|
||||
import com.cool.store.enums.wechat.WechatTemplateDetailEnum;
|
||||
import com.cool.store.enums.wechat.WechatTemplateEnum;
|
||||
import com.cool.store.exception.ServiceException;
|
||||
import com.cool.store.mapper.StoreGroupMappingMapper;
|
||||
import com.cool.store.mapper.StoreMapper;
|
||||
import com.cool.store.request.notice.*;
|
||||
import com.cool.store.response.bigdata.ApiResponse;
|
||||
import com.cool.store.service.MessageTemplateService;
|
||||
import com.cool.store.service.StoreService;
|
||||
import com.cool.store.service.wechat.WechatTemplateService;
|
||||
import com.cool.store.utils.CoolDateUtils;
|
||||
import com.cool.store.utils.RedisUtilPool;
|
||||
import com.cool.store.utils.poi.DateUtils;
|
||||
import com.cool.store.vo.PartnerUserInfoVO;
|
||||
import com.cool.store.vo.notice.*;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.gson.JsonObject;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.core.task.TaskExecutor;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.Duration;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -65,6 +71,18 @@ public class MessageTemplateServiceImpl implements MessageTemplateService {
|
||||
StoreMessageDAO storeMessageDAO;
|
||||
@Resource
|
||||
EnterpriseUserDAO enterpriseUserDAO;
|
||||
@Resource
|
||||
MatterConfigDAO matterConfigDAO;
|
||||
@Resource
|
||||
WechatTemplateService wechatTemplateService;
|
||||
@Resource
|
||||
RedisUtilPool redisUtilPool;
|
||||
@Resource
|
||||
TaskExecutor noticeThreadPool;
|
||||
@Resource
|
||||
HyPartnerUserInfoDAO hyPartnerUserInfoDAO;
|
||||
@Resource
|
||||
MessageIssueService messageIssueService;
|
||||
|
||||
|
||||
|
||||
@@ -82,8 +100,8 @@ public class MessageTemplateServiceImpl implements MessageTemplateService {
|
||||
|
||||
public String getMessageTemplateCode() {
|
||||
//当前日期
|
||||
String today = CoolDateUtils.getToday();
|
||||
return "16" + today + String.format("%04d", ThreadLocalRandom.current().nextInt(10000));
|
||||
String today = CoolDateUtils.getTodayMillis();
|
||||
return "16" + today + String.format("%04d", ThreadLocalRandom.current().nextInt(100));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -135,55 +153,264 @@ public class MessageTemplateServiceImpl implements MessageTemplateService {
|
||||
|
||||
|
||||
@Override
|
||||
public Boolean batchPublishMessageTemplate(BatchPublishRequest request, LoginUserInfo user) {
|
||||
public Boolean batchPublishMessageTemplate(BatchPublishRequest request, String userId) {
|
||||
log.info("batchPublishMessageTemplate:{}",JSONObject.toJSONString(request));
|
||||
if (CollectionUtils.isEmpty(request.getIds())||CollectionUtils.isEmpty(request.getStoreInfoList())||CollectionUtils.isEmpty(request.getUserInfoList())){
|
||||
throw new ServiceException(ErrorCodeEnum.PARAMS_REQUIRED);
|
||||
}
|
||||
|
||||
List<StoreAreaDTO> storeAreaDTOS = getStoreRange(request.getStoreInfoList());
|
||||
List<String> storeIds = storeAreaDTOS.stream().map(StoreAreaDTO::getStoreId).collect(Collectors.toList());
|
||||
|
||||
Map<String, List<String>> authUser = getAuthUser(request.getUserInfoList(), storeIds);
|
||||
|
||||
List<MessageTemplateDO> list = messageTemplateDAO.getByIds(request.getIds());
|
||||
//过滤 只保留未发布的
|
||||
list = list.stream().filter(x -> PublishStatusEnum.UNPUBLISHED.getCode().equals(x.getPublishStatus())).collect(Collectors.toList());
|
||||
|
||||
if (CollUtil.isEmpty(list)){
|
||||
log.info("未找到待发布消息模板");
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
|
||||
list.stream().forEach(x -> {
|
||||
List<StoreMessageDO> result = new ArrayList<>();
|
||||
storeAreaDTOS.forEach(y->{
|
||||
if (CollectionUtils.isEmpty(authUser.get(y.getStoreId()))){
|
||||
log.info("当前门店没有人员 门店名称:{}",y.getStoreName());
|
||||
return;
|
||||
}
|
||||
StoreMessageDO storeMessageDO = new StoreMessageDO();
|
||||
storeMessageDO.setStoreId(y.getStoreId());
|
||||
storeMessageDO.setStoreName(y.getStoreName());
|
||||
storeMessageDO.setStoreCode(y.getStoreCode());
|
||||
storeMessageDO.setMessageTemplateId(x.getId());
|
||||
storeMessageDO.setReadStatus(ReadStatusEnum.UNREAD.getCode());
|
||||
storeMessageDO.setReadTime(new Date());
|
||||
storeMessageDO.setProcessStatus(ProcessStatusEnum.UNTREATED.getCode());
|
||||
storeMessageDO.setProcessTime(new Date());
|
||||
String userIdStr = authUser.get(y.getStoreId()).stream().collect(Collectors.joining(","));
|
||||
storeMessageDO.setOperatorList(userIdStr);
|
||||
result.add(storeMessageDO);
|
||||
});
|
||||
storeMessageDAO.batchInsert(result);
|
||||
});
|
||||
List<String> lockKeys = list.stream()
|
||||
.map(x -> "msg_template_publish:" + x.getId())
|
||||
.collect(Collectors.toList());
|
||||
|
||||
List<Long> updateIds = list.stream().map(MessageTemplateDO::getId).collect(Collectors.toList());
|
||||
messageTemplateDAO.batchUpdateStoreInfoAndUserInfo(updateIds,
|
||||
JSONObject.toJSONString(request.getStoreInfoList()),
|
||||
JSONObject.toJSONString(request.getUserInfoList()),
|
||||
user.getUserId());
|
||||
boolean allLocksAcquired = tryAcquireLocks(lockKeys);
|
||||
if (!allLocksAcquired) {
|
||||
log.warn("存在正在发布的模板,本次操作取消。模板IDs: {}", JSONObject.toJSONString(lockKeys));
|
||||
throw new ServiceException(ErrorCodeEnum.MESSAGE_PUBLISH);
|
||||
}
|
||||
List<MessageTemplateDO> finalList = list;
|
||||
noticeThreadPool.execute(() -> {
|
||||
syncPublish(request, userId, finalList, lockKeys);
|
||||
});
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
|
||||
public Boolean syncPublish(BatchPublishRequest request, String userId, List<MessageTemplateDO> list,List<String> lockKeys){
|
||||
try {
|
||||
List<StoreAreaDTO> storeAreaDTOS = getStoreRange(request.getStoreInfoList());
|
||||
List<String> storeIds = storeAreaDTOS.stream().map(StoreAreaDTO::getStoreId).collect(Collectors.toList());
|
||||
Map<String, List<String>> authUser = getAuthUser(request.getUserInfoList(), storeIds);
|
||||
List<StoreMessageDO> realtimeMessageList = new ArrayList<>();
|
||||
list.stream().forEach(x -> {
|
||||
List<StoreMessageDO> result = new ArrayList<>();
|
||||
storeAreaDTOS.forEach(y->{
|
||||
if (CollectionUtils.isEmpty(authUser.get(y.getStoreId()))){
|
||||
log.info("当前门店没有人员 门店名称:{}",y.getStoreName());
|
||||
return;
|
||||
}
|
||||
StoreMessageDO storeMessageDO = new StoreMessageDO();
|
||||
storeMessageDO.setStoreId(y.getStoreId());
|
||||
storeMessageDO.setStoreName(y.getStoreName());
|
||||
storeMessageDO.setStoreCode(y.getStoreCode());
|
||||
storeMessageDO.setMessageTemplateId(x.getId());
|
||||
storeMessageDO.setReadStatus(ReadStatusEnum.UNREAD.getCode());
|
||||
storeMessageDO.setReadTime(new Date());
|
||||
storeMessageDO.setProcessStatus(ProcessStatusEnum.UNTREATED.getCode());
|
||||
storeMessageDO.setProcessTime(new Date());
|
||||
String userIdStr = authUser.get(y.getStoreId()).stream().collect(Collectors.joining(","));
|
||||
storeMessageDO.setOperatorList(userIdStr);
|
||||
result.add(storeMessageDO);
|
||||
});
|
||||
storeMessageDAO.batchInsert(result);
|
||||
if (MatterTypeEnum.REALTIME.getCode().equals(request.getMatterType())) {
|
||||
realtimeMessageList.addAll(result);
|
||||
}
|
||||
});
|
||||
|
||||
//存在第一个成功 第二个失败 会有问题 todo
|
||||
List<Long> updateIds = list.stream().map(MessageTemplateDO::getId).collect(Collectors.toList());
|
||||
messageTemplateDAO.batchUpdateStoreInfoAndUserInfo(updateIds,
|
||||
JSONObject.toJSONString(request.getStoreInfoList()),
|
||||
JSONObject.toJSONString(request.getUserInfoList()),
|
||||
userId);
|
||||
|
||||
//发送通知
|
||||
Set<String> userIds = authUser.values().stream().flatMap(Collection::stream).collect(Collectors.toSet());
|
||||
|
||||
//分批 查询用户信息
|
||||
List<String> openIdList = new ArrayList<>();
|
||||
Lists.partition(new ArrayList<>(userIds), 100).forEach(x->{
|
||||
List<EnterpriseUserDO> userInfoByUserIds = enterpriseUserDAO.getUserInfoByUserIds(x);
|
||||
//取出用户的手机号,过滤掉空的手机号
|
||||
List<String> mobileList = userInfoByUserIds.stream().filter(user -> StringUtils.isNotBlank(user.getMobile())).map(EnterpriseUserDO::getMobile).collect(Collectors.toList());
|
||||
if (CollectionUtils.isNotEmpty(mobileList)){
|
||||
List<ServiceAccountOpenIdDTO> serviceAccountOpenIdDTOS = hyPartnerUserInfoDAO.selectLastBindRecord(mobileList);
|
||||
if (CollectionUtils.isNotEmpty(serviceAccountOpenIdDTOS)){
|
||||
//服务号ID
|
||||
openIdList.addAll(serviceAccountOpenIdDTOS.stream().map(ServiceAccountOpenIdDTO::getServiceAccountOpenId).collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
MessageTemplateDO messageTemplateDO = list.get(0);
|
||||
Map<String, Object> data = new HashMap<>();
|
||||
data.put(WechatTemplateDetailEnum.THING6.getCode(), messageTemplateDO.getMessageTitle());
|
||||
data.put(WechatTemplateDetailEnum.TIME33.getCode(), DateUtils.parseDateToStr(DateUtils.SPECIAL_DATE_START, new Date()));
|
||||
data.put(WechatTemplateDetailEnum.CHARACTER_STRING14.getCode(), messageTemplateDO.getMessageCode());
|
||||
openIdList.forEach(x->{
|
||||
wechatTemplateService.sendMiniAppTemplate(x, WechatTemplateEnum.NEW_QUESTION_NOTICE,data,"pages/notification/index");
|
||||
});
|
||||
// 即时消息下发
|
||||
messageIssueService.issueMessage(realtimeMessageList);
|
||||
} catch (Exception e) {
|
||||
log.info("发布流程异常 e:{}",e.getMessage());
|
||||
} finally {
|
||||
releaseLocks(lockKeys);
|
||||
log.info("发布流程结束,已释放Redis锁");
|
||||
}
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 尝试获取所有Redis锁
|
||||
*/
|
||||
private boolean tryAcquireLocks(List<String> lockKeys) {
|
||||
boolean allSuccess = true;
|
||||
List<String> acquiredLocks = new ArrayList<>();
|
||||
|
||||
for (String lockKey : lockKeys) {
|
||||
try {
|
||||
// 设置锁,过期时间设为5分钟,防止死锁
|
||||
Boolean success = redisUtilPool.setNxExpire(lockKey, "locking",1000*60*5);
|
||||
if (success != null && success) {
|
||||
acquiredLocks.add(lockKey);
|
||||
} else {
|
||||
log.warn("获取Redis锁失败: {}", lockKey);
|
||||
allSuccess = false;
|
||||
break;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("获取Redis锁异常: {}", lockKey, e);
|
||||
allSuccess = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 如果任何一个锁获取失败,释放之前已经获取的锁
|
||||
if (!allSuccess) {
|
||||
releaseLocks(acquiredLocks);
|
||||
}
|
||||
|
||||
return allSuccess;
|
||||
}
|
||||
|
||||
/**
|
||||
* 释放Redis锁
|
||||
*/
|
||||
private void releaseLocks(List<String> lockKeys) {
|
||||
if (CollUtil.isEmpty(lockKeys)) {
|
||||
return;
|
||||
}
|
||||
for (String lockKey : lockKeys) {
|
||||
try {
|
||||
redisUtilPool.delKey(lockKey);
|
||||
log.debug("释放Redis锁成功: {}", lockKey);
|
||||
} catch (Exception e) {
|
||||
log.error("释放Redis锁异常: {}", lockKey, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public ApiResponse<Boolean> thirdMatterHandle(ThirdMatterRequest thirdMatterRequest) {
|
||||
log.info("thirdMatterHandle request:{}", JSONObject.toJSONString(thirdMatterRequest));
|
||||
//第三方事项处理
|
||||
MatterConfigDO matterConfig = matterConfigDAO.getById(thirdMatterRequest.getMatterConfigId());
|
||||
if (matterConfig==null||matterConfig.getStatus()==0){
|
||||
return ApiResponse.error(ErrorCodeEnum.CONFIG_NOT_EXIST);
|
||||
}
|
||||
//封装事项模版
|
||||
MessageTemplateDO messageTemplateDO = new MessageTemplateDO();
|
||||
messageTemplateDO.setMessageCode(getMessageTemplateCode());
|
||||
messageTemplateDO.setModuleCode(matterConfig.getModuleCode());
|
||||
messageTemplateDO.setMatterType(matterConfig.getMatterType());
|
||||
messageTemplateDO.setMessageTitle(thirdMatterRequest.getMatterTitle());
|
||||
messageTemplateDO.setSystemSource(matterConfig.getSystemSource());
|
||||
messageTemplateDO.setProcessType(thirdMatterRequest.getProcessType());
|
||||
messageTemplateDO.setRemindType(thirdMatterRequest.getRemindType());
|
||||
if (RemindTypeEnum.STAGE_REMINDER.getCode().equals(thirdMatterRequest.getRemindType())){
|
||||
messageTemplateDO.setRemindStartTime(thirdMatterRequest.getRemindStartTime());
|
||||
messageTemplateDO.setRemindEndTime(thirdMatterRequest.getRemindEndTime());
|
||||
}
|
||||
messageTemplateDO.setDeadline(thirdMatterRequest.getDeadline());
|
||||
messageTemplateDO.setTodayTask(thirdMatterRequest.getTodayTask());
|
||||
messageTemplateDO.setMessageImage(thirdMatterRequest.getMessageImage());
|
||||
messageTemplateDO.setPublishStatus(PublishStatusEnum.UNPUBLISHED.getCode());
|
||||
messageTemplateDO.setJumpType(matterConfig.getJumpType());
|
||||
messageTemplateDO.setJumpUrl(matterConfig.getJumpUrl());
|
||||
messageTemplateDO.setHandleKeyword(thirdMatterRequest.getHandleKeyword());
|
||||
|
||||
if (MatterTypeEnum.LOGISTICS.getCode().equals(matterConfig.getMatterType())){
|
||||
SceneEnum scene = SceneEnum.getByCode(thirdMatterRequest.getSceneCode());
|
||||
messageTemplateDO.setMessageImage(scene.getScenePicture());
|
||||
//物流直接使用传过来的地址
|
||||
messageTemplateDO.setJumpUrl(thirdMatterRequest.getJumpUrl());
|
||||
}
|
||||
//如果是盘点 截止日期去当天
|
||||
if (MatterTypeEnum.INVENTORY.getCode().equals(matterConfig.getMatterType())){
|
||||
messageTemplateDO.setDeadline(new Date());
|
||||
}
|
||||
String storeInfo = matterConfig.getDefaultStoreInfo();
|
||||
String userInfo = matterConfig.getDefaultHandlePersonInfo();
|
||||
//门店
|
||||
if (CollectionUtils.isNotEmpty(thirdMatterRequest.getShopCodeList())){
|
||||
log.info("shopCodeList:{}",JSONObject.toJSONString(thirdMatterRequest.getShopCodeList()));
|
||||
List<StoreDO> storeNumByStoreCodes = storeMapper.getStoreNumByStoreCodes(thirdMatterRequest.getShopCodeList());
|
||||
if (CollectionUtils.isNotEmpty(storeNumByStoreCodes)){
|
||||
//组装成门店信息
|
||||
List<CommonDTO> storeList = new ArrayList<>();
|
||||
storeNumByStoreCodes.forEach(x -> {
|
||||
CommonDTO store = new CommonDTO("store", x.getStoreId(), x.getStoreName());
|
||||
storeList.add(store);
|
||||
});
|
||||
storeInfo = JSONObject.toJSONString(storeList);
|
||||
}
|
||||
}
|
||||
//人员
|
||||
List<EnterpriseUserDO> userInfoByUserMobileList = enterpriseUserDAO.getUserInfoByUserMobileList(thirdMatterRequest.getMobileList());
|
||||
if (CollectionUtils.isNotEmpty(userInfoByUserMobileList)){
|
||||
//组装人员信息
|
||||
List<CommonDTO> userList = new ArrayList<>();
|
||||
userInfoByUserMobileList.forEach(x -> {
|
||||
CommonDTO user = new CommonDTO("person", x.getUserId(), x.getName());
|
||||
userList.add(user);
|
||||
});
|
||||
userInfo = JSONObject.toJSONString(userList);
|
||||
}
|
||||
Boolean publishFlag = Boolean.TRUE;
|
||||
//校验是否发布
|
||||
if (StringUtils.isEmpty(userInfo)|| StringUtils.isEmpty(storeInfo)){
|
||||
publishFlag = Boolean.FALSE;
|
||||
}
|
||||
messageTemplateDO.setCreateUserId("system");
|
||||
if (!publishFlag){
|
||||
//如果不发布 保存门店人员信息
|
||||
messageTemplateDO.setStoreInfo(storeInfo);
|
||||
messageTemplateDO.setHandlePersonInfo(userInfo);
|
||||
}
|
||||
messageTemplateDAO.insert(messageTemplateDO);
|
||||
//调用发布
|
||||
if (publishFlag){
|
||||
//开始计算人员门店
|
||||
BatchPublishRequest batchPublishRequest = new BatchPublishRequest();
|
||||
batchPublishRequest.setIds(Arrays.asList(messageTemplateDO.getId()));
|
||||
batchPublishRequest.setStoreInfoList(JSONObject.parseArray(storeInfo, CommonDTO.class));
|
||||
batchPublishRequest.setUserInfoList(JSONObject.parseArray(userInfo, CommonDTO.class));
|
||||
batchPublishRequest.setMatterType(matterConfig.getMatterType());
|
||||
try {
|
||||
batchPublishMessageTemplate(batchPublishRequest,"");
|
||||
} catch (ServiceException e) {
|
||||
return new ApiResponse(e.getErrorCode(), e.getErrorMessage(), null);
|
||||
}
|
||||
return ApiResponse.success(Boolean.TRUE);
|
||||
}
|
||||
return ApiResponse.success(Boolean.TRUE);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@@ -275,9 +502,9 @@ public class MessageTemplateServiceImpl implements MessageTemplateService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ModuleAndMatterVO> getModuleList(String storeId,PartnerUserInfoVO userInfoVO) {
|
||||
public List<ModuleAndMatterVO> getModuleList(String storeId,String mobile) {
|
||||
List<ModuleAndMatterVO> moduleAndMatterList = ModuleAndMatterVO.getModuleAndMatterList();
|
||||
EnterpriseUserDO enterpriseUserDO = enterpriseUserDAO.selectByMobile(userInfoVO.getMobile());
|
||||
EnterpriseUserDO enterpriseUserDO = enterpriseUserDAO.selectByMobile(mobile);
|
||||
if (enterpriseUserDO == null){
|
||||
enterpriseUserDO = new EnterpriseUserDO();
|
||||
}
|
||||
@@ -312,13 +539,15 @@ public class MessageTemplateServiceImpl implements MessageTemplateService {
|
||||
MessageDetailVO messageDetailVO = storeMessageDAO.getMessageDetail(id);
|
||||
if (messageDetailVO!=null&&messageDetailVO.getPublishUserId()!=null){
|
||||
EnterpriseUserDO userInfoById = enterpriseUserDAO.getUserInfoById(messageDetailVO.getPublishUserId());
|
||||
messageDetailVO.setPublishUserName(userInfoById.getName());
|
||||
if (userInfoById != null){
|
||||
messageDetailVO.setPublishUserName(userInfoById.getName());
|
||||
}
|
||||
}
|
||||
return messageDetailVO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean readMessage(Long id, PartnerUserInfoVO userInfoVO) {
|
||||
public Boolean readMessage(Long id, String mobile) {
|
||||
StoreMessageDO message = storeMessageDAO.getById(id);
|
||||
if (ProcessStatusEnum.PROCESSED.getCode().equals(message.getProcessStatus())){
|
||||
log.info("当前消息已读已处理:{}",JSONObject.toJSONString( message));
|
||||
@@ -330,7 +559,7 @@ public class MessageTemplateServiceImpl implements MessageTemplateService {
|
||||
if (ProcessTypeEnum.READ.getCode().equals(template.getProcessType())){
|
||||
message.setProcessStatus(ProcessStatusEnum.PROCESSED.getCode());
|
||||
message.setProcessTime(new Date());
|
||||
EnterpriseUserDO enterpriseUserDO = enterpriseUserDAO.selectByMobile(userInfoVO.getMobile());
|
||||
EnterpriseUserDO enterpriseUserDO = enterpriseUserDAO.selectByMobile(mobile);
|
||||
if (enterpriseUserDO != null){
|
||||
message.setActualOperatorId(enterpriseUserDO.getId());
|
||||
message.setActualOperatorName(enterpriseUserDO.getName());
|
||||
@@ -341,15 +570,15 @@ public class MessageTemplateServiceImpl implements MessageTemplateService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean handleMessage(Long id, PartnerUserInfoVO userInfoVO) {
|
||||
log.info("handleMessage request:{},处理人:{}", JSONObject.toJSONString(id), userInfoVO.getUsername());
|
||||
public Boolean handleMessage(Long id, String userName,String mobile) {
|
||||
log.info("handleMessage request:{},处理人:{}", JSONObject.toJSONString(id), userName);
|
||||
StoreMessageDO message = storeMessageDAO.getById(id);
|
||||
if (message==null){
|
||||
throw new ServiceException(ErrorCodeEnum.PARAMS_REQUIRED);
|
||||
}
|
||||
message.setProcessStatus(ProcessStatusEnum.PROCESSED.getCode());
|
||||
message.setProcessTime(new Date());
|
||||
EnterpriseUserDO enterpriseUserDO = enterpriseUserDAO.selectByMobile(userInfoVO.getMobile());
|
||||
EnterpriseUserDO enterpriseUserDO = enterpriseUserDAO.selectByMobile(mobile);
|
||||
if (enterpriseUserDO != null){
|
||||
message.setActualOperatorId(enterpriseUserDO.getId());
|
||||
message.setActualOperatorName(enterpriseUserDO.getName());
|
||||
@@ -358,6 +587,20 @@ public class MessageTemplateServiceImpl implements MessageTemplateService {
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ApiResponse<Boolean> thirdHandleMessage(ThirdHandleMessageRequest request) {
|
||||
log.info("thirdHandleMessage request:{}", JSONObject.toJSONString(request));
|
||||
MessageTemplateDO message = messageTemplateDAO.getByKeyword(request.getHandleKeyword());
|
||||
if (message==null){
|
||||
return ApiResponse.error(ErrorCodeEnum.MESSAGE_NOT_EXIST);
|
||||
}
|
||||
if (!ProcessTypeEnum.HANDLE.getCode().equals(message.getProcessType())){
|
||||
return ApiResponse.error(ErrorCodeEnum.MESSAGE_NOT_HANDLED);
|
||||
}
|
||||
storeMessageDAO.batchUpdateHandle(message.getId(), request.getShopCodeList());
|
||||
return ApiResponse.success(Boolean.TRUE);
|
||||
}
|
||||
|
||||
|
||||
public Map<String, List<String>> getAuthUser(List<CommonDTO> personInfo, List<String> storeIds){
|
||||
if (CollectionUtils.isEmpty(personInfo)){
|
||||
|
||||
@@ -143,6 +143,7 @@ public class OrderSysInfoServiceImpl implements OrderSysInfoService {
|
||||
orderSysInfoDO.setReceivingMsBankAccount(request.getReceivingMsBankAccount());
|
||||
orderSysInfoDO.setReceivingMsBankBranch(request.getReceivingMsBankBranch());
|
||||
orderSysInfoDO.setBankUnionPayAccount(request.getBankUnionPayAccount());
|
||||
orderSysInfoDO.setOrderType(request.getOrderType());
|
||||
if (shopSubStageInfo.getShopSubStageStatus().equals(SHOP_SUB_STAGE_STATUS_152.getShopSubStageStatus())) {
|
||||
if (orderSysInfoDO.getReceivingCreateTime() == null) {
|
||||
orderSysInfoDO.setReceivingCreateTime(new Date());
|
||||
@@ -293,6 +294,7 @@ public class OrderSysInfoServiceImpl implements OrderSysInfoService {
|
||||
//初始化数据
|
||||
preparationService.licenseCompleted(shopId);
|
||||
preparationService.sysStoreCompleted(shopId);
|
||||
preparationService.businessLicenseAndBuildStoreCompleted(shopId);
|
||||
preparationService.buildStoreAndDecorationComplete(shopId);
|
||||
preparationService.selectSiteAndBuildStoreComplete(shopId);
|
||||
preparationService.buildStoreComplete(shopId);
|
||||
|
||||
@@ -519,6 +519,14 @@ public class PointServiceImpl implements PointService {
|
||||
if (AuditStatusEnum.REJECT.equals(auditStatus)) {
|
||||
return auditRejectDeal(pointInfo, request.getReason());
|
||||
}
|
||||
// 如果是三明治,将地址写入门店信息表
|
||||
ShopInfoDO shopInfo = shopInfoDAO.getShopInfo(pointInfo.getShopId());
|
||||
if (Objects.nonNull(shopInfo) && Integer.valueOf(shopInfo.getFranchiseBrand()).equals(FranchiseBrandEnum.ZXSMZ.getCode())) {
|
||||
ShopInfoDO updateShopInfo = new ShopInfoDO();
|
||||
updateShopInfo.setId(pointInfo.getShopId());
|
||||
updateShopInfo.setDetailAddress(pointInfo.getAddress());
|
||||
shopInfoDAO.updateShopInfo(updateShopInfo);
|
||||
}
|
||||
//处理下一节点任务及更新point状态
|
||||
return dealNextAuditRecord(pointInfo, pointAuditRecordMap, pointTodo.getNodeNo());
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.cool.store.service.impl;
|
||||
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.cool.store.dao.*;
|
||||
import com.cool.store.entity.LineInfoDO;
|
||||
import com.cool.store.entity.PosAndOrderInfoDO;
|
||||
@@ -16,6 +17,7 @@ import com.cool.store.response.PosAndOrderResponse;
|
||||
import com.cool.store.service.PosAndOrderInfoService;
|
||||
import com.cool.store.mapper.PosAndOrderInfoMapper;
|
||||
import com.cool.store.service.PreparationService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@@ -30,6 +32,7 @@ import java.util.Objects;
|
||||
* @createDate 2024-10-09 14:39:11
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class PosAndOrderInfoServiceImpl implements PosAndOrderInfoService {
|
||||
@Resource
|
||||
private LineInfoDAO lineInfoDAO;
|
||||
@@ -46,6 +49,7 @@ public class PosAndOrderInfoServiceImpl implements PosAndOrderInfoService {
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Integer submitOrUpdate(PostAndOrderRequest request, String user) {
|
||||
log.info("PosAndOrderInfoService_submitOrUpdate:{}", JSONObject.toJSONString(request));
|
||||
PosAndOrderInfoDO posAndOrderInfoDO = posAndOrderInfoDAO.selectOneByShopId(request.getShopId(), request.getType());
|
||||
PosAndOrderInfoDO posAndOrderInfo = request.toDO();
|
||||
posAndOrderInfo.setCreateUser(user);
|
||||
|
||||
@@ -223,6 +223,22 @@ public class PreparationServiceImpl implements PreparationService {
|
||||
list.add(ShopSubStageStatusEnum.SHOP_SUB_STAGE_STATUS_160);
|
||||
list.add(ShopSubStageStatusEnum.SHOP_SUB_STAGE_STATUS_170);
|
||||
list.add(ShopSubStageStatusEnum.SHOP_SUB_STAGE_STATUS_230);
|
||||
shopStageInfoDAO.batchUpdateShopStageStatus(shopId, list);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void businessLicenseAndBuildStoreCompleted(Long shopId) {
|
||||
List<ShopStageInfoDO> shopStageInfo = shopStageInfoDAO.getShopStageInfo(shopId, null);
|
||||
if (CollectionUtils.isNotEmpty(shopStageInfo)) {
|
||||
Map<Integer, ShopStageInfoDO> shopStageInfoDOMap = shopStageInfo.stream().collect(Collectors.toMap(ShopStageInfoDO::getShopSubStage, data -> data));
|
||||
boolean flag1 = ShopSubStageStatusEnum.SHOP_SUB_STAGE_STATUS_156.getShopSubStageStatus().
|
||||
equals(shopStageInfoDOMap.get(ShopSubStageEnum.SHOP_STAGE_15.getShopSubStage()).getShopSubStageStatus());
|
||||
boolean flag2 = ShopSubStageStatusEnum.SHOP_SUB_STAGE_STATUS_33.getShopSubStageStatus().
|
||||
equals(shopStageInfoDOMap.get(ShopSubStageEnum.SHOP_STAGE_3.getShopSubStage()).getShopSubStageStatus());
|
||||
if (flag1 && flag2) {
|
||||
List<ShopSubStageStatusEnum> list = new ArrayList<>();
|
||||
list.add(ShopSubStageStatusEnum.SHOP_SUB_STAGE_STATUS_240);
|
||||
shopStageInfoDAO.batchUpdateShopStageStatus(shopId, list);
|
||||
}
|
||||
@@ -346,7 +362,7 @@ public class PreparationServiceImpl implements PreparationService {
|
||||
Boolean flag3 = ShopSubStageStatusEnum.SHOP_SUB_STAGE_STATUS_156.getShopSubStageStatus().
|
||||
equals(shopStageInfoDOMap.get(ShopSubStageEnum.SHOP_STAGE_15.getShopSubStage()).getShopSubStageStatus());
|
||||
|
||||
log.info("selectSiteAndBuildStoreComplete flag2->{} flag3->{}",flag2,flag3);
|
||||
log.info("selectSiteAndBuildStoreComplete flag2->{} flag3->{} flag4->{}",flag2,flag3);
|
||||
//都完成了 状态修改
|
||||
if (flag2 && flag3) {
|
||||
shopAccountDAO.updateStatusByShopIdAndSystemName(shopId, Arrays.asList(ShopAccountEnum.HUOMA.getSystemName()), OpenStatusEnum.OPENSTATUSENUM_2.getCode(),null,null);
|
||||
|
||||
@@ -3,7 +3,17 @@ 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;
|
||||
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.entity.EnterpriseUserDO;
|
||||
import com.cool.store.entity.StoreDO;
|
||||
import com.cool.store.enums.ErrorCodeEnum;
|
||||
import com.cool.store.enums.UserRoleEnum;
|
||||
import com.cool.store.exception.ServiceException;
|
||||
import com.cool.store.request.ZxjpApiRequest;
|
||||
import com.cool.store.request.xgj.PushFranchiseFeeRequest;
|
||||
@@ -170,6 +180,10 @@ public class PushServiceImpl implements PushService {
|
||||
|
||||
@Override
|
||||
public String getYlsToken(GetAccessTokenDTO dto) {
|
||||
String yls = redisUtilPool.getString("yls");
|
||||
if (StringUtils.isNotBlank(yls)) {
|
||||
throw new ServiceException(ErrorCodeEnum.THIRD_API_ERROR,"云流水系统修复中");
|
||||
}
|
||||
String apiUrl = ylsUrl + "/Store.axd?action=getToken";
|
||||
return executeApiCall(apiUrl, dto, String.class, ylsUsername, ylsSecret);
|
||||
}
|
||||
@@ -181,8 +195,29 @@ public class PushServiceImpl implements PushService {
|
||||
return executeApiCall(apiUrl, dto, String.class, "", "");
|
||||
}
|
||||
|
||||
@Resource
|
||||
EnterpriseUserDAO enterpriseUserDAO;
|
||||
@Resource
|
||||
EnterpriseUserRoleDao enterpriseUserRoleDao;
|
||||
@Resource
|
||||
StoreDao storeDao;
|
||||
|
||||
@Override
|
||||
public String getPosToken(GetAccessTokenDTO dto) {
|
||||
EnterpriseUserDO enterpriseUserDO = enterpriseUserDAO.selectByMobile(dto.getMobile());
|
||||
if (enterpriseUserDO != null){
|
||||
List<Long> userRoleIds = enterpriseUserRoleDao.getUserRoleIds(enterpriseUserDO.getUserId());
|
||||
//如果userRoleIds包含督导。大区总。分部负责人任何一个 使用当前门店的手机号
|
||||
if (userRoleIds.contains(UserRoleEnum.SUPERVISION.getCode()) ||
|
||||
userRoleIds.contains(UserRoleEnum.HEAD_OF_DIVISION.getCode()) ||
|
||||
userRoleIds.contains(UserRoleEnum.SERVICE_PACKAGE_DEDICATED.getCode()) ||
|
||||
userRoleIds.contains(UserRoleEnum.REGION_MANAGER.getCode())) {
|
||||
StoreDO store = storeDao.getByStoreNum(dto.getShopCode());
|
||||
if (store != null&&store.getTelephone()!=null){
|
||||
dto.setMobile(store.getTelephone());
|
||||
}
|
||||
}
|
||||
}
|
||||
String apiUrl = url + "/dzgV1/zxcrm/business_user/generateToken";
|
||||
return executeApiCall(apiUrl, dto, String.class, username, secret);
|
||||
}
|
||||
|
||||
@@ -59,6 +59,8 @@ public class ShopAccountServiceImpl implements ShopAccountService {
|
||||
ThirdXinGuanJiaService thirdXinGuanJiaService;
|
||||
@Resource
|
||||
private LineInfoDAO lineInfoDAO;
|
||||
@Resource
|
||||
private StoreDao storeDao;
|
||||
|
||||
@Override
|
||||
public List<ShopAccountDTO> getShopAccountByShopId(Long shopId) {
|
||||
@@ -244,30 +246,16 @@ public class ShopAccountServiceImpl implements ShopAccountService {
|
||||
}
|
||||
List<ShopAccountDO> accountDOS = shopAccountDAO.selectByShopId(shopId);
|
||||
if (CollectionUtils.isEmpty(accountDOS)) {
|
||||
throw new ServiceException(ErrorCodeEnum.SYSTEM_DATA_ERROR);
|
||||
return "ZXA8_"+shopInfo.getShopCode();
|
||||
}
|
||||
Map<String, ShopAccountDO> map = accountDOS.stream().collect(Collectors.toMap(ShopAccountDO::getSystemName, data -> data));
|
||||
ShopAccountDO shopAccountDO = map.get(ShopAccountEnum.YLS.getSystemName());
|
||||
if (Objects.isNull(shopAccountDO)) {
|
||||
throw new ServiceException(ErrorCodeEnum.SYSTEM_DATA_ERROR);
|
||||
return "ZXA8_"+shopInfo.getShopCode();
|
||||
}
|
||||
return StringUtil.isEmpty(shopAccountDO.getAccount()) ? shopInfo.getShopCode() : shopAccountDO.getAccount();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String shopCodeToYlsCode(String shopCode) {
|
||||
ShopInfoDO shopInfoDO = shopInfoDAO.selectByStoreCode(shopCode);
|
||||
if (!Objects.isNull(shopInfoDO)) {
|
||||
return this.shopIdToYlsCode(shopInfoDO.getId());
|
||||
}
|
||||
//查询老店关联表数据
|
||||
OldShopDO oldShopDO = oldShopDAO.getByCode(shopCode);
|
||||
if (Objects.isNull(oldShopDO)) {
|
||||
throw new ServiceException(ErrorCodeEnum.GET_YLS_CODE_FAIL);
|
||||
}
|
||||
return oldShopDO.getYlsShopCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean handleOldData() {
|
||||
@@ -316,6 +304,30 @@ public class ShopAccountServiceImpl implements ShopAccountService {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String shopCodeToYlsCode(String shopCode) {
|
||||
ShopInfoDO shopInfoDO = shopInfoDAO.selectByStoreCode(shopCode);
|
||||
if (!Objects.isNull(shopInfoDO)) {
|
||||
return this.shopIdToYlsCode(shopInfoDO.getId());
|
||||
}
|
||||
//查询老店关联表数据
|
||||
OldShopDO oldShopDO = oldShopDAO.getByCode(shopCode);
|
||||
if (Objects.isNull(oldShopDO)) {
|
||||
StoreDO storeDO = storeDao.getByStoreNum(shopCode);
|
||||
if (Objects.isNull(storeDO)) {
|
||||
throw new ServiceException(ErrorCodeEnum.GET_YLS_CODE_FAIL);
|
||||
}
|
||||
oldShopDO = OldShopDO.builder()
|
||||
.shopCode(shopCode)
|
||||
.shopName(storeDO.getStoreName())
|
||||
.mobile(storeDO.getTelephone())
|
||||
.ylsShopCode("ZXA8_" + shopCode)
|
||||
.build();
|
||||
oldShopDAO.insertSelective(oldShopDO);
|
||||
}
|
||||
return oldShopDO.getYlsShopCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean handleAccountPassword() {
|
||||
|
||||
@@ -110,6 +110,8 @@ public class ShopServiceImpl implements ShopService {
|
||||
DecorationDesignInfoDAO decorationDesignInfoDAO;
|
||||
@Resource
|
||||
StoreService storeService;
|
||||
@Resource
|
||||
EnterpriseService enterpriseService;
|
||||
|
||||
|
||||
@Override
|
||||
@@ -144,7 +146,7 @@ public class ShopServiceImpl implements ShopService {
|
||||
}
|
||||
shopInfoDAO.batchAddShop(addShopList);
|
||||
List<Long> shopIds = addShopList.stream().map(ShopInfoDO::getId).collect(Collectors.toList());
|
||||
Integer result = shopStageInfoDAO.initShopStageInfo(lineInfo.getId(), shopIds, true);
|
||||
Integer result = shopStageInfoDAO.initShopStageInfo(lineInfo.getId(), addShopList, true);
|
||||
//初始化平台账号
|
||||
HyPartnerUserInfoDO hyPartnerUserInfoDO = hyPartnerUserInfoDAO.selectByPartnerId(lineInfo.getPartnerId());
|
||||
shopAccountDAO.initShopAccount(hyPartnerUserInfoDO, shopIds);
|
||||
@@ -296,7 +298,7 @@ public class ShopServiceImpl implements ShopService {
|
||||
}
|
||||
shopInfoDAO.batchAddShop(addShopList);
|
||||
List<Long> shopIds = addShopList.stream().map(ShopInfoDO::getId).collect(Collectors.toList());
|
||||
shopStageInfoDAO.initShopStageInfo(lineInfo.getId(), shopIds, true);
|
||||
shopStageInfoDAO.initShopStageInfo(lineInfo.getId(), addShopList, true);
|
||||
return 1L;
|
||||
}
|
||||
|
||||
@@ -330,6 +332,7 @@ public class ShopServiceImpl implements ShopService {
|
||||
if (StringUtils.isBlank(request.getInvestmentManagerUserId())) {
|
||||
request.setInvestmentManagerUserId(userId);
|
||||
}
|
||||
enterpriseService.checkUser(userId, request.getJoinMode());
|
||||
LineInfoDO lineInfo = lineInfoDAO.getLineInfo(request.getLineId());
|
||||
if (lineInfo.getWorkflowSubStageStatus() < WorkflowSubStageStatusEnum.PAY_DEPOSIT_45.getCode()) {
|
||||
throw new ServiceException(ErrorCodeEnum.LINE_STATUS_NOT_ALLOW_OPERATE);
|
||||
@@ -353,7 +356,7 @@ public class ShopServiceImpl implements ShopService {
|
||||
shopInfoDO.setCreateUserId(userId);
|
||||
Long shopId = shopInfoDAO.addShopInfo(shopInfoDO);
|
||||
if (lineInfo.getWorkflowSubStageStatus().equals(WorkflowSubStageStatusEnum.SIGN_INTENT_AGREEMENT_125.getCode())) {
|
||||
shopStageInfoDAO.initShopStageInfo(request.getLineId(), Collections.singletonList(shopId), true);
|
||||
shopStageInfoDAO.initShopStageInfo(request.getLineId(), Collections.singletonList(shopInfoDO), true);
|
||||
HashMap<String, String> map = new HashMap<>();
|
||||
map.put("partnerUsername", lineInfo.getUsername());
|
||||
map.put("partnerMobile", lineInfo.getMobile());
|
||||
@@ -378,7 +381,7 @@ public class ShopServiceImpl implements ShopService {
|
||||
MessageEnum.MESSAGE_21,
|
||||
map);
|
||||
} else {
|
||||
shopStageInfoDAO.initShopStageInfo(request.getLineId(), Collections.singletonList(shopId), false);
|
||||
shopStageInfoDAO.initShopStageInfo(request.getLineId(), Collections.singletonList(shopInfoDO), false);
|
||||
}
|
||||
//初始化平台账号
|
||||
HyPartnerUserInfoDO hyPartnerUserInfoDO = hyPartnerUserInfoDAO.selectByPartnerId(lineInfo.getPartnerId());
|
||||
@@ -560,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(), ""));
|
||||
|
||||
@@ -6,15 +6,23 @@ 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;
|
||||
@@ -31,6 +39,7 @@ 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;
|
||||
@@ -40,6 +49,7 @@ import java.util.stream.Collectors;
|
||||
|
||||
import static com.cool.store.enums.UserRoleEnum.*;
|
||||
import static com.cool.store.enums.point.ShopSubStageStatusEnum.*;
|
||||
import static com.cool.store.utils.CommonUtil.convertToBig;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
@@ -129,6 +139,14 @@ public class SignFranchiseServiceImpl implements SignFranchiseService, AuditResu
|
||||
ContractConfigDAO contractConfigDAO;
|
||||
@Resource
|
||||
PushService pushService;
|
||||
@Resource
|
||||
TeamAreaMappingDAO teamAreaMappingDAO;
|
||||
@Resource
|
||||
DecorationTeamConfigDAO decorationTeamConfigDAO;
|
||||
@Resource
|
||||
ShopDecorationAssignDAO shopDecorationAssignDAO;
|
||||
@Resource
|
||||
private SimpleMessageService simpleMessageService;
|
||||
|
||||
|
||||
@Override
|
||||
@@ -186,6 +204,10 @@ public class SignFranchiseServiceImpl implements SignFranchiseService, AuditResu
|
||||
if (Objects.isNull(request.getShopId())) {
|
||||
throw new ServiceException(ErrorCodeEnum.SHOP_ID_NOT_EXIST);
|
||||
}
|
||||
//不要使用系统默认名称
|
||||
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);
|
||||
@@ -458,10 +480,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());
|
||||
@@ -600,6 +638,7 @@ public class SignFranchiseServiceImpl implements SignFranchiseService, AuditResu
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HqtBuildRequest getHqtBuildRequest(Long shopId) {
|
||||
ShopInfoDO shopInfo = shopInfoDAO.getShopInfo(shopId);
|
||||
LineInfoDO lineInfoDO = lineInfoDAO.getLineInfo(shopInfo.getLineId());
|
||||
@@ -677,11 +716,12 @@ public class SignFranchiseServiceImpl implements SignFranchiseService, AuditResu
|
||||
BeanUtils.copyProperties(signFranchiseDO, addSignFranchiseResponse);
|
||||
} else {
|
||||
if (Objects.nonNull(franchiseFeeDO)) {
|
||||
BigDecimal total = new BigDecimal(franchiseFeeDO.getYearFranchiseFee())
|
||||
.add(new BigDecimal(franchiseFeeDO.getLoanMargin()))
|
||||
.add(new BigDecimal(franchiseFeeDO.getFirstYearFee()))
|
||||
.add(new BigDecimal(franchiseFeeDO.getFirstYearManageFee()))
|
||||
.add(new BigDecimal(franchiseFeeDO.getPerformanceBond()));
|
||||
BigDecimal total = convertToBig(franchiseFeeDO.getYearFranchiseFee())
|
||||
.add(convertToBig(franchiseFeeDO.getLoanMargin()))
|
||||
.add(convertToBig(franchiseFeeDO.getFirstYearFee()))
|
||||
.add(convertToBig(franchiseFeeDO.getFirstYearManageFee()))
|
||||
.add(convertToBig(franchiseFeeDO.getPerformanceBond()))
|
||||
.add(convertToBig(franchiseFeeDO.getCashierFee()));
|
||||
addSignFranchiseResponse.setContractAmount(total.toString());
|
||||
}
|
||||
addSignFranchiseResponse.setMobile(lineInfoDO.getMobile());
|
||||
@@ -734,9 +774,9 @@ public class SignFranchiseServiceImpl implements SignFranchiseService, AuditResu
|
||||
|
||||
if (Objects.nonNull(franchiseFeeDO)) {
|
||||
addSignFranchiseResponse.setYearFranchiseFee(franchiseFeeDO.getYearFranchiseFee());
|
||||
addSignFranchiseResponse.setBigYearFranchiseFee(Convert.digitToChinese(new BigDecimal(franchiseFeeDO.getYearFranchiseFee())));
|
||||
addSignFranchiseResponse.setBigYearFranchiseFee(Convert.digitToChinese(convertToBig(franchiseFeeDO.getYearFranchiseFee())));
|
||||
addSignFranchiseResponse.setLoanMargin(franchiseFeeDO.getLoanMargin());
|
||||
addSignFranchiseResponse.setBigLoanMargin(Convert.digitToChinese(new BigDecimal(franchiseFeeDO.getLoanMargin())));
|
||||
addSignFranchiseResponse.setBigLoanMargin(Convert.digitToChinese(convertToBig(franchiseFeeDO.getLoanMargin())));
|
||||
addSignFranchiseResponse.setFirstYearStartTime(franchiseFeeDO.getFirstYearStartTime());
|
||||
addSignFranchiseResponse.setFirstYearEndTime(franchiseFeeDO.getFirstYearEndTime());
|
||||
addSignFranchiseResponse.setFirstYearFee(franchiseFeeDO.getFirstYearFee());
|
||||
@@ -748,7 +788,9 @@ public class SignFranchiseServiceImpl implements SignFranchiseService, AuditResu
|
||||
addSignFranchiseResponse.setThirdYearEndTime(franchiseFeeDO.getThirdYearEndTime());
|
||||
addSignFranchiseResponse.setThirdYearFee(franchiseFeeDO.getThirdYearFee());
|
||||
addSignFranchiseResponse.setPerformanceBond(franchiseFeeDO.getPerformanceBond());
|
||||
addSignFranchiseResponse.setBigPerformanceBond(Convert.digitToChinese(new BigDecimal(franchiseFeeDO.getPerformanceBond())));
|
||||
addSignFranchiseResponse.setBigPerformanceBond(Convert.digitToChinese(convertToBig(franchiseFeeDO.getPerformanceBond())));
|
||||
addSignFranchiseResponse.setCashierFee(franchiseFeeDO.getCashierFee());
|
||||
addSignFranchiseResponse.setBigCashierFee(Convert.digitToChinese(convertToBig(franchiseFeeDO.getCashierFee())));
|
||||
}
|
||||
return addSignFranchiseResponse;
|
||||
}
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
package com.cool.store.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollStreamUtil;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.cool.store.dto.StoreNameDTO;
|
||||
import com.cool.store.dao.store.StoreMasterSignerInfoDAO;
|
||||
import com.cool.store.dto.store.AuthStoreUserDTO;
|
||||
import com.cool.store.dao.EnterpriseUserDAO;
|
||||
import com.cool.store.dao.EnterpriseUserRoleDao;
|
||||
@@ -12,10 +16,8 @@ import com.cool.store.dto.StoreDTO;
|
||||
import com.cool.store.dto.store.StoreAreaDTO;
|
||||
import com.cool.store.dto.store.StoreUserDTO;
|
||||
import com.cool.store.dto.store.StoreUserPositionDTO;
|
||||
import com.cool.store.entity.EnterpriseUserDO;
|
||||
import com.cool.store.entity.StoreDO;
|
||||
import com.cool.store.entity.SysRoleDO;
|
||||
import com.cool.store.entity.UserAuthMappingDO;
|
||||
import com.cool.store.entity.*;
|
||||
import com.cool.store.entity.store.StoreMasterSignerInfoDO;
|
||||
import com.cool.store.enums.*;
|
||||
import com.cool.store.exception.ServiceException;
|
||||
import com.cool.store.mapper.*;
|
||||
@@ -38,6 +40,7 @@ import org.springframework.stereotype.Service;
|
||||
import javax.annotation.Resource;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* @Author suzhuhong
|
||||
@@ -70,6 +73,8 @@ public class StoreServiceImpl implements StoreService {
|
||||
EnterpriseUserMapper enterpriseUserMapper;
|
||||
@Resource
|
||||
EnterpriseUserGroupMappingMapper enterpriseUserGroupMappingMapper;
|
||||
@Resource
|
||||
StoreMasterSignerInfoDAO storeMasterSignerInfoDAO;
|
||||
|
||||
@Override
|
||||
public PageInfo<StoreDTO> getStoreExtendFieldInfo(Integer pageSize, Integer pageNum) {
|
||||
@@ -77,16 +82,42 @@ public class StoreServiceImpl implements StoreService {
|
||||
throw new ServiceException(ErrorCodeEnum.ERROR_MESSAGE,"单次最多获取200条门店数据");
|
||||
}
|
||||
PageHelper.startPage(pageNum,pageSize);
|
||||
List<StoreDO> list = storeDao.list();
|
||||
List<StoreDO> list = storeDao.list(null);
|
||||
PageInfo info = new PageInfo<>(list);
|
||||
if (CollectionUtils.isEmpty(list)){
|
||||
return info;
|
||||
}
|
||||
List<StoreDTO> storeDTOS = processStores(list);
|
||||
//使用regionId与branch 合并的集合
|
||||
Set<Long> regionIds = list.stream()
|
||||
.filter(Objects::nonNull)
|
||||
.flatMap(store -> Stream.of(store.getBranch(), store.getRegionId()))
|
||||
.filter(Objects::nonNull)
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
List<RegionDO> regionList = regionMapper.getByIds(new ArrayList<>(regionIds));
|
||||
Map<Long, String> regionNameMap = regionList.stream().collect(Collectors.toMap(RegionDO::getId, RegionDO::getName));
|
||||
|
||||
List<StoreDTO> storeDTOS = processStores(list, regionNameMap);
|
||||
info.setList(storeDTOS);
|
||||
return info;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageInfo<StoreNameDTO> getIotStoreList(Integer pageNum, Integer pageSize) {
|
||||
if (pageSize > 200) {
|
||||
throw new ServiceException(ErrorCodeEnum.ERROR_MESSAGE, "单次最多获取200条门店数据");
|
||||
}
|
||||
PageHelper.startPage(pageNum, pageSize);
|
||||
List<StoreDO> list = storeDao.list(1);
|
||||
PageInfo info = new PageInfo<>(list);
|
||||
if (CollectionUtils.isEmpty(list)){
|
||||
return info;
|
||||
}
|
||||
List<StoreNameDTO> result = list.stream().map(v -> new StoreNameDTO(v.getStoreName(), v.getStoreNum())).collect(Collectors.toList());
|
||||
info.setList(result);
|
||||
return info;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageInfo<MiniShopsResponse> getStoreListByMobile(String mobile,Integer pageNum,Integer pageSize,String storeName,String storeNum) {
|
||||
//根据手机号查询 标品userId
|
||||
@@ -97,7 +128,11 @@ public class StoreServiceImpl implements StoreService {
|
||||
List<Long> userRoleIds = enterpriseUserRoleDao.getUserRoleIds(enterpriseUserDO.getUserId());
|
||||
//查询职位详情,筛选掉店外职位
|
||||
List<SysRoleDO> roleIds = sysRoleDao.selectRoleByRoleIds(userRoleIds);
|
||||
List<SysRoleDO> sysRoleDOS = roleIds.stream().filter(role -> "store_inside".equals(role.getPositionType())).collect(Collectors.toList());
|
||||
List<SysRoleDO> sysRoleDOS = roleIds.stream().filter(role -> "store_inside".equals(role.getPositionType())
|
||||
||UserRoleEnum.SUPERVISION.getCode().equals(role.getId())
|
||||
||UserRoleEnum.HEAD_OF_DIVISION.getCode().equals(role.getId())
|
||||
||UserRoleEnum.SERVICE_PACKAGE_DEDICATED.getCode().equals(role.getId())
|
||||
||UserRoleEnum.REGION_MANAGER.getCode().equals(role.getId())).collect(Collectors.toList());
|
||||
if (CollectionUtils.isNotEmpty(sysRoleDOS)){
|
||||
//获取用户管辖区域
|
||||
List<UserAuthMappingDO> userAuthMapping = userAuthMappingService.listUserAuthMappingByUserId(enterpriseUserDO.getUserId());
|
||||
@@ -120,6 +155,8 @@ public class StoreServiceImpl implements StoreService {
|
||||
if (CollectionUtils.isEmpty(list)){
|
||||
return new ArrayList<>();
|
||||
}
|
||||
List<String> storeIds = CollStreamUtil.toList(list, StoreDO::getStoreId);
|
||||
Map<String, StoreMasterSignerInfoDO> signerMap = storeMasterSignerInfoDAO.getSignerMapByStoreIds(storeIds);
|
||||
List<StoreUserPositionDTO> result = new ArrayList<>();
|
||||
list.forEach(x->{
|
||||
StoreUserPositionDTO storeUserPositionDTO = new StoreUserPositionDTO();
|
||||
@@ -128,6 +165,7 @@ public class StoreServiceImpl implements StoreService {
|
||||
storeUserPositionDTO.setStoreId(x.getStoreId());
|
||||
storeUserPositionDTO.setStoreName(x.getStoreName());
|
||||
storeUserPositionDTO.setShopCode(x.getStoreNum());
|
||||
storeUserPositionDTO.setStoreCode(x.getStoreNum());
|
||||
List<StoreUserDTO> userList = Lists.newArrayList();
|
||||
for (String userId : storeUserDTOMap.keySet()) {
|
||||
List<StoreUserDTO> singleUserDTOList = storeUserDTOMap.get(userId);
|
||||
@@ -140,6 +178,16 @@ public class StoreServiceImpl implements StoreService {
|
||||
storeUserDTO.setPositionName(String.join(Constants.COMMA, positionNameList));
|
||||
userList.add(storeUserDTO);
|
||||
}
|
||||
StoreMasterSignerInfoDO signerInfoDO = signerMap.get(x.getStoreId());
|
||||
if (Objects.nonNull(signerInfoDO)) {
|
||||
Set<String> mobiles = CollStreamUtil.toSet(userList, StoreUserDTO::getMobile);
|
||||
if (StringUtils.isNotBlank(signerInfoDO.getSigner1Mobile()) && mobiles.add(signerInfoDO.getSigner1Mobile())) {
|
||||
userList.add(new StoreUserDTO(signerInfoDO.getSigner1Name(), signerInfoDO.getSigner1Mobile()));
|
||||
}
|
||||
if (StringUtils.isNotBlank(signerInfoDO.getSigner2Mobile()) && mobiles.add(signerInfoDO.getSigner2Mobile())) {
|
||||
userList.add(new StoreUserDTO(signerInfoDO.getSigner2Name(), signerInfoDO.getSigner2Mobile()));
|
||||
}
|
||||
}
|
||||
storeUserPositionDTO.setUserList(userList);
|
||||
result.add(storeUserPositionDTO);
|
||||
});
|
||||
@@ -342,25 +390,23 @@ public class StoreServiceImpl implements StoreService {
|
||||
}
|
||||
|
||||
|
||||
public static List<StoreDTO> processStores(List<StoreDO> stores) {
|
||||
public static List<StoreDTO> processStores(List<StoreDO> stores,Map<Long, String> regionMap) {
|
||||
// 处理每个门店
|
||||
return stores.stream().map(store -> {
|
||||
StoreDTO dto = new StoreDTO();
|
||||
dto.setStoreName(store.getStoreName());
|
||||
StoreDTO dto = BeanUtil.toBean(store, StoreDTO.class);
|
||||
dto.setStoreCode(store.getStoreNum());
|
||||
dto.setStoreAddress(store.getStoreAddress());
|
||||
dto.setStoreAvatar(store.getAvatar());
|
||||
dto.setTelephone(store.getTelephone());
|
||||
dto.setMonthlyRent(store.getMonthlyRent());
|
||||
dto.setMonthlyPersonnelSalary(store.getMonthlyPersonnelSalary());
|
||||
dto.setMonthlyOtherExpenses(store.getMonthlyOtherExpenses());
|
||||
dto.setUnifiedManagement(store.getUnifiedManagement());
|
||||
dto.setStoreType(StoreTypeEnum.getMessage(store.getStoreType()));
|
||||
dto.setJoinMode(JoinModeEnum.getByCode(store.getJoinModel()));
|
||||
dto.setBrand(FranchiseBrandEnum.getDescByCode(store.getJoinBrand()));
|
||||
dto.setOrderMiniProgramName(store.getMiniProgramOrderStoreName());
|
||||
dto.setLongitude(store.getLongitude());
|
||||
dto.setLatitude(store.getLatitude());
|
||||
dto.setStatus(StoreStatusEnum.getName(store.getStoreStatus()));
|
||||
if (store.getRegionId() != null){
|
||||
dto.setManagerSupervisionName(regionMap.get(store.getRegionId()));
|
||||
}
|
||||
if (store.getBranch()!=null){
|
||||
dto.setBranchName(regionMap.get(store.getBranch()));
|
||||
}
|
||||
return dto;
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@@ -119,6 +119,7 @@ public class SyncDataServiceImpl implements SyncDataService {
|
||||
}
|
||||
request.setPartnershipSignatory(partnershipSignatory);
|
||||
request.setBusinessModel(signFranchiseDO.getBusinessModel());
|
||||
request.setContractCode(signFranchiseDO.getContractCode());
|
||||
}
|
||||
request.setPartnerMobile(lineInfoDO.getMobile());
|
||||
request.setShopCode(shopInfo.getShopCode());
|
||||
@@ -272,6 +273,18 @@ public class SyncDataServiceImpl implements SyncDataService {
|
||||
} catch (Exception e) {
|
||||
log.info("getUrl error:{},JSON:{}", e.getMessage(), json);
|
||||
}
|
||||
return getUrlListByComma(json);
|
||||
}
|
||||
|
||||
private static List<String> getUrlListByComma(String str) {
|
||||
if (StringUtils.isBlank(str)) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
return Arrays.asList(str.split(","));
|
||||
} catch (Exception e) {
|
||||
log.info("getUrlListByComma error:{},str:{}", e.getMessage(), str);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -288,43 +301,31 @@ public class SyncDataServiceImpl implements SyncDataService {
|
||||
if (String.valueOf(FranchiseBrandEnum.ZXJP.getCode()).equals(shopInfoDO.getFranchiseBrand())) {
|
||||
//M10001
|
||||
if (shopCode.matches("M\\d*")) {
|
||||
return partnershipSignatorySecondIsNull
|
||||
? "MX" + shopInfoDO.getShopName() + "(" + signFranchiseDO.getPartnershipSignatoryFirst() + ")"
|
||||
: "MX" + shopInfoDO.getShopName() + "(" + signFranchiseDO.getPartnershipSignatoryFirst() + "/"+signFranchiseDO.getPartnershipSignatorySecond()+")";
|
||||
return "MX" + shopInfoDO.getShopName();
|
||||
}
|
||||
//FS10001
|
||||
if (shopCode.matches("FS\\d*")) {
|
||||
return partnershipSignatorySecondIsNull
|
||||
? "FS" + shopInfoDO.getShopName() + "(" + signFranchiseDO.getPartnershipSignatoryFirst() + ")"
|
||||
: "FS" + shopInfoDO.getShopName() + "(" + signFranchiseDO.getPartnershipSignatoryFirst() + "/"+signFranchiseDO.getPartnershipSignatorySecond()+")";
|
||||
return "FS" + shopInfoDO.getShopName();
|
||||
}
|
||||
// MS10001
|
||||
if (shopCode.matches("MS\\d*")) {
|
||||
return partnershipSignatorySecondIsNull
|
||||
? "MS" + shopInfoDO.getShopName() + "(" + signFranchiseDO.getPartnershipSignatoryFirst() + ")"
|
||||
: "MS" + shopInfoDO.getShopName() + "(" + signFranchiseDO.getPartnershipSignatoryFirst() + "/"+signFranchiseDO.getPartnershipSignatorySecond()+")";
|
||||
return "MS" + shopInfoDO.getShopName();
|
||||
}
|
||||
// S10001
|
||||
if (shopCode.matches("S\\d*")) {
|
||||
return partnershipSignatorySecondIsNull
|
||||
? "S" + shopInfoDO.getShopName() + "(" + signFranchiseDO.getPartnershipSignatoryFirst() + ")"
|
||||
: "S" + shopInfoDO.getShopName() + "(" + signFranchiseDO.getPartnershipSignatoryFirst() + "/"+signFranchiseDO.getPartnershipSignatorySecond()+")";
|
||||
return "S" + shopInfoDO.getShopName();
|
||||
}
|
||||
// ZX0001
|
||||
if (shopCode.matches("ZX\\d*")) {
|
||||
return "ZX" + shopInfoDO.getShopName();
|
||||
}
|
||||
if(shopCode.matches("HL\\d*")){
|
||||
return partnershipSignatorySecondIsNull
|
||||
? "HL" + shopInfoDO.getShopName() + "(" + signFranchiseDO.getPartnershipSignatoryFirst() + ")"
|
||||
: "HL" + shopInfoDO.getShopName() + "(" + signFranchiseDO.getPartnershipSignatoryFirst() + "/"+signFranchiseDO.getPartnershipSignatorySecond()+")";
|
||||
return "HL" + shopInfoDO.getShopName();
|
||||
}
|
||||
}
|
||||
if (String.valueOf(FranchiseBrandEnum.MZG.getCode()).equals(shopInfoDO.getFranchiseBrand())) {
|
||||
if (shopCode.matches("MZGM\\d*")) {
|
||||
return partnershipSignatorySecondIsNull
|
||||
? "MZGM" + shopInfoDO.getShopName() + "(" + signFranchiseDO.getPartnershipSignatoryFirst() + ")"
|
||||
: "MZGM" + shopInfoDO.getShopName() + "(" + signFranchiseDO.getPartnershipSignatoryFirst() + "/"+signFranchiseDO.getPartnershipSignatorySecond()+")";
|
||||
return "MZGM" + shopInfoDO.getShopName();
|
||||
}
|
||||
if (shopCode.matches("MZGS\\d*")) {
|
||||
return FranchiseBrandEnum.MZG.getDesc() + shopInfoDO.getShopName();
|
||||
@@ -332,19 +333,13 @@ public class SyncDataServiceImpl implements SyncDataService {
|
||||
}
|
||||
if (String.valueOf(FranchiseBrandEnum.ZJS.getCode()).equals(shopInfoDO.getFranchiseBrand())) {
|
||||
if (shopCode.matches("LX\\d*")) {
|
||||
return partnershipSignatorySecondIsNull
|
||||
? "LX" + shopInfoDO.getShopName() + "(" + signFranchiseDO.getPartnershipSignatoryFirst() + ")"
|
||||
: "LX" + shopInfoDO.getShopName() + "(" + signFranchiseDO.getPartnershipSignatoryFirst() + "/"+signFranchiseDO.getPartnershipSignatorySecond()+")";
|
||||
return "LX" + shopInfoDO.getShopName();
|
||||
}
|
||||
if (shopCode.matches("X\\d*")) {
|
||||
return partnershipSignatorySecondIsNull
|
||||
? "X" + shopInfoDO.getShopName() + "(" + signFranchiseDO.getPartnershipSignatoryFirst() + ")"
|
||||
: "X" + shopInfoDO.getShopName() + "(" + signFranchiseDO.getPartnershipSignatoryFirst() + "/"+signFranchiseDO.getPartnershipSignatorySecond()+")";
|
||||
return "X" + shopInfoDO.getShopName();
|
||||
}
|
||||
if (shopCode.matches("Q\\d*")) {
|
||||
return partnershipSignatorySecondIsNull
|
||||
? "Q" + shopInfoDO.getShopName() + "(" + signFranchiseDO.getPartnershipSignatoryFirst() + ")"
|
||||
: "Q" + shopInfoDO.getShopName() + "(" + signFranchiseDO.getPartnershipSignatoryFirst() + "/"+signFranchiseDO.getPartnershipSignatorySecond()+")";
|
||||
return "Q" + shopInfoDO.getShopName();
|
||||
}
|
||||
if (shopCode.matches("Z\\d*")) {
|
||||
return FranchiseBrandEnum.ZJS.getDesc() + shopInfoDO.getShopName();
|
||||
|
||||
@@ -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());
|
||||
@@ -160,6 +139,9 @@ public class SyncMainSysServerImpl implements SyncMainSysServer {
|
||||
PointDetailInfoDO pointDetail = pointDetailDAO.getPointDetailInfoByPointId(shopInfo.getPointId());
|
||||
if (info != null){
|
||||
storeMasterDTO.setArea(info.getProvince()+info.getCity()+info.getDistrict());
|
||||
storeMasterDTO.setProvince(info.getProvince());
|
||||
storeMasterDTO.setCity(info.getCity());
|
||||
storeMasterDTO.setDistrict(info.getDistrict());
|
||||
storeMasterDTO.setTown(info.getTownship());
|
||||
storeMasterDTO.setStoreAddress(info.getAddress());
|
||||
storeMasterDTO.setLocationAddress(info.getAddress());
|
||||
@@ -203,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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,12 +3,10 @@ package com.cool.store.service.impl;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.cool.store.enums.ErrorCodeEnum;
|
||||
import com.cool.store.exception.ServiceException;
|
||||
import com.cool.store.request.bigdata.LatestOrderDateRequest;
|
||||
import com.cool.store.request.bigdata.ProfitDataRequest;
|
||||
import com.cool.store.request.oppty.CityRequest;
|
||||
import com.cool.store.response.bigdata.ActDataResponse;
|
||||
import com.cool.store.response.bigdata.ApiResponse;
|
||||
import com.cool.store.response.bigdata.ProfitDataResponse;
|
||||
import com.cool.store.response.bigdata.ProfitRateResponse;
|
||||
import com.cool.store.response.bigdata.*;
|
||||
import com.cool.store.response.oppty.CityResponse;
|
||||
import com.cool.store.response.oppty.OpportunityApiResponse;
|
||||
import com.cool.store.response.oppty.OpportunityDetailResponse;
|
||||
@@ -96,6 +94,15 @@ public class ThirdBigDataServiceImpl implements ThirdBigDataService {
|
||||
return executeApiCall(url, requestBody, ActDataResponse.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<LatestOrderDateResponse> getLatestOrderDate(LatestOrderDateRequest requestBody) {
|
||||
String url = apiUrl + "api/web/v1/buy/latest_buy_date";
|
||||
JavaType javaType = objectMapper.getTypeFactory()
|
||||
.constructParametricType(ApiPageResponse.class, LatestOrderDateResponse.class);
|
||||
ApiPageResponse<LatestOrderDateResponse> response = executeApiCallWithGenericType(url, requestBody, javaType);
|
||||
return response.getList();
|
||||
}
|
||||
|
||||
|
||||
private <T> T executeApiCall(String url, Object requestBody, Class<T> responseType) {
|
||||
// 1. 打印请求前日志
|
||||
@@ -136,6 +143,44 @@ public class ThirdBigDataServiceImpl implements ThirdBigDataService {
|
||||
}
|
||||
}
|
||||
|
||||
private <T> T executeApiCallWithGenericType(String url, Object requestBody, JavaType responseType) {
|
||||
// 1. 打印请求前日志
|
||||
logRequest(url, requestBody);
|
||||
|
||||
try {
|
||||
Request request = buildRequest(requestBody, url);
|
||||
|
||||
try (Response response = okHttpClient.newCall(request).execute()) {
|
||||
// 2. 获取原始响应内容
|
||||
String responseBody = response.body().string();
|
||||
|
||||
// 3. 打印响应日志
|
||||
logResponse(url, response.code(), responseBody);
|
||||
|
||||
if (!response.isSuccessful()) {
|
||||
throw new ServiceException(ErrorCodeEnum.THIRD_API_ERROR,
|
||||
"HTTP请求失败,状态码: " + response.code());
|
||||
}
|
||||
|
||||
// 4. 解析响应
|
||||
JavaType javaType = objectMapper.getTypeFactory()
|
||||
.constructParametricType(OpportunityApiResponse.class, responseType);
|
||||
|
||||
OpportunityApiResponse<T> apiResponse = objectMapper.readValue(responseBody, javaType);
|
||||
|
||||
if (apiResponse.getCode() != 0) {
|
||||
throw new ServiceException(ErrorCodeEnum.THIRD_API_ERROR, apiResponse.getMsg());
|
||||
}
|
||||
|
||||
return apiResponse.getData();
|
||||
}
|
||||
} catch (ServiceException e) {
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
log.error("API调用异常 - URL: {}, 错误: {}", url, e.getMessage(), e);
|
||||
throw new ServiceException(ErrorCodeEnum.THIRD_API_ERROR, "接口调用异常: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private Request buildRequest(Object requestBody, String url) {
|
||||
Map<String, Object> params = JsonUtils.parseJsonToMap(JSONObject.toJSONString(requestBody));
|
||||
|
||||
@@ -1,14 +1,24 @@
|
||||
package com.cool.store.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.copier.CopyOptions;
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.cool.store.dao.StoreDao;
|
||||
import com.cool.store.dto.FoodTokenDTO;
|
||||
import com.cool.store.dto.GetAccessTokenDTO;
|
||||
import com.cool.store.dto.recipe.RecipeSpLaunchDTO;
|
||||
import com.cool.store.dto.recipe.RevenueDataDTO;
|
||||
import com.cool.store.dto.recipe.RevenueDataQueryDTO;
|
||||
import com.cool.store.dto.store.StoreUserUpdateDTO;
|
||||
import com.cool.store.entity.StoreDO;
|
||||
import com.cool.store.enums.ErrorCodeEnum;
|
||||
import com.cool.store.exception.ServiceException;
|
||||
import com.cool.store.request.recipe.RevenueDataRequest;
|
||||
import com.cool.store.response.caipin.StoreUserResponse;
|
||||
import com.cool.store.response.oppty.OpportunityApiResponse;
|
||||
import com.cool.store.service.ThirdFoodService;
|
||||
import com.cool.store.utils.BeanUtil;
|
||||
import com.cool.store.utils.SignatureUtils;
|
||||
import com.cool.store.vo.recipe.RevenueDataVO;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.JavaType;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -20,8 +30,9 @@ import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.net.URI;
|
||||
import java.util.Map;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @Author suzhuhong
|
||||
@@ -40,15 +51,46 @@ public class ThirdFoodServiceImpl implements ThirdFoodService {
|
||||
OkHttpClient okHttpClient;
|
||||
@Resource
|
||||
ObjectMapper objectMapper;
|
||||
@Resource
|
||||
private StoreDao storeDao;
|
||||
|
||||
|
||||
@Override
|
||||
public String getFoodToken(FoodTokenDTO dto) {
|
||||
// 1. 发送POST请求
|
||||
String url = apiUrl + "/interface/v1/user/getToken";
|
||||
String url = "/v1/user/getToken";
|
||||
return executeApiCall(url, dto, String.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public StoreUserResponse pushStoreUser(List<StoreUserUpdateDTO> dto) {
|
||||
String url = "/v1/store/updateStoreUser";
|
||||
return executeApiCall(url, dto, StoreUserResponse.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RevenueDataVO> getRevenueData(RevenueDataRequest request) {
|
||||
StoreDO storeDO = storeDao.getByStoreId(request.getStoreId());
|
||||
if (Objects.isNull(storeDO)) {
|
||||
throw new ServiceException(ErrorCodeEnum.STORE_NOT_FIND);
|
||||
}
|
||||
RevenueDataQueryDTO queryDTO = new RevenueDataQueryDTO(storeDO.getStoreNum(), request.getBusinessDateFrom(), request.getBusinessDateTo());
|
||||
String url = "/v1/store/business";
|
||||
List<RevenueDataDTO> list = executeApiCall(url, queryDTO, List.class);
|
||||
return BeanUtil.toList(list, RevenueDataVO.class, CopyOptions.create().setFieldMapping(Collections.singletonMap("storeCode", "storeNum")));
|
||||
}
|
||||
|
||||
@Override
|
||||
public RecipeSpLaunchDTO getRecipeServiceLaunch(RevenueDataRequest request) {
|
||||
StoreDO storeDO = storeDao.getByStoreId(request.getStoreId());
|
||||
if (Objects.isNull(storeDO)) {
|
||||
throw new ServiceException(ErrorCodeEnum.STORE_NOT_FIND);
|
||||
}
|
||||
RevenueDataQueryDTO queryDTO = new RevenueDataQueryDTO(storeDO.getStoreNum(), request.getBusinessDateFrom(), request.getBusinessDateTo());
|
||||
String url = "/v1/store/business/spRecipeList";
|
||||
return executeApiCall(url, queryDTO, RecipeSpLaunchDTO.class);
|
||||
}
|
||||
|
||||
|
||||
private <T> T executeApiCall(String url, Object requestBody, Class<T> responseType) {
|
||||
// 1. 打印请求前日志
|
||||
@@ -62,7 +104,7 @@ public class ThirdFoodServiceImpl implements ThirdFoodService {
|
||||
String responseBody = response.body().string();
|
||||
|
||||
// 3. 打印响应日志
|
||||
logResponse(url, response.code(), responseBody);
|
||||
logResponse(apiUrl+ url, response.code(), responseBody);
|
||||
|
||||
if (!response.isSuccessful()) {
|
||||
throw new ServiceException(ErrorCodeEnum.THIRD_API_ERROR,
|
||||
@@ -94,20 +136,24 @@ public class ThirdFoodServiceImpl implements ThirdFoodService {
|
||||
String random = RandomUtil.randomString(20);
|
||||
|
||||
String signString = null;
|
||||
String reqBody = null;
|
||||
try {
|
||||
signString = SignatureUtils.sign("POST","/v1/user/getToken", objectMapper.writeValueAsString(requestBody),timestamp,random);
|
||||
reqBody = objectMapper.writeValueAsString(requestBody);
|
||||
} catch (JsonProcessingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
signString = SignatureUtils.sign("POST",url, reqBody,timestamp,random);
|
||||
} catch (Exception e) {
|
||||
throw new ServiceException(ErrorCodeEnum.THIRD_API_SIGN_ERROR,"加密失败");
|
||||
}
|
||||
|
||||
log.info("签名生成 - 签名结果: {}", signString);
|
||||
|
||||
RequestBody body = RequestBody.create(okhttp3.MediaType.parse("application/json"),
|
||||
JSONObject.toJSONString(requestBody)
|
||||
);
|
||||
RequestBody body = RequestBody.create(okhttp3.MediaType.parse("application/json"), reqBody);
|
||||
|
||||
return new Request.Builder()
|
||||
.url(url)
|
||||
.url(apiUrl + url)
|
||||
.post(body)
|
||||
.addHeader("X-ZhengXin-Sign", signString)
|
||||
.addHeader("X-ZhengXin-SignTime", timestamp)
|
||||
|
||||
@@ -17,6 +17,7 @@ import com.cool.store.utils.UUIDUtils;
|
||||
import com.cool.store.vo.PartnerUserInfoVO;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.shiro.crypto.SecureRandomNumberGenerator;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -110,9 +111,16 @@ public class WechatMiniAppServiceImpl implements WechatMiniAppService {
|
||||
PartnerUserWechatBindDO bindDO = new PartnerUserWechatBindDO();
|
||||
bindDO.setBindTime(new Date());
|
||||
bindDO.setOpenId(openid);
|
||||
bindDO.setUnionId(unionId);
|
||||
bindDO.setPartnerId(hyPartnerUserInfoDO.getPartnerId());
|
||||
bindDO.setCreateTime(new Date());
|
||||
partnerUserWechatBindDAO.insertSelective(bindDO);
|
||||
}else {
|
||||
//维护unionId 针对老数据没有unionId
|
||||
if (zlPartnerUserBindDO.getUnionId()==null){
|
||||
zlPartnerUserBindDO.setUnionId(unionId);
|
||||
partnerUserWechatBindDAO.update(zlPartnerUserBindDO);
|
||||
}
|
||||
}
|
||||
BeanUtil.copyProperties(hyPartnerUserInfoDO, userInfoVO);
|
||||
fillLineInfo(userInfoVO, hyPartnerUserInfoDO.getPartnerId());
|
||||
@@ -252,4 +260,30 @@ public class WechatMiniAppServiceImpl implements WechatMiniAppService {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getShortTermTokenByMobile(MiniProgramFreeLoginDTO param) {
|
||||
HyPartnerUserInfoDO hyPartnerUserInfoDO = hyPartnerUserInfoDAO.selectByMobile(param.getMobile());
|
||||
if (Objects.isNull(hyPartnerUserInfoDO)) {
|
||||
return "";
|
||||
}
|
||||
PartnerUserInfoVO userInfoVO = BeanUtil.toBean(hyPartnerUserInfoDO, PartnerUserInfoVO.class);
|
||||
fillLineInfo(userInfoVO, hyPartnerUserInfoDO.getPartnerId());
|
||||
String token = new SecureRandomNumberGenerator().nextBytes().toHex();
|
||||
String key = MessageFormat.format(CommonConstants.ZXJP_MIN_PROGRAM_SHORT_TERM_LOGIN_FLAG, token);
|
||||
redisUtilPool.setString(key, JSONObject.toJSONString(userInfoVO), CommonConstants.SHORT_TERM_TOKEN_EXPIRE);
|
||||
return token;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PartnerUserInfoVO getUserInfoByShortTermToken(String token) {
|
||||
String key = MessageFormat.format(CommonConstants.ZXJP_MIN_PROGRAM_SHORT_TERM_LOGIN_FLAG, token);
|
||||
String userStr = redisUtilPool.getString(key);
|
||||
if (StringUtils.isNotBlank(userStr)) {
|
||||
PartnerUserInfoVO userInfoVO = JSONObject.parseObject(userStr, PartnerUserInfoVO.class);
|
||||
redisUtilPool.delKey(key);
|
||||
return userInfoVO;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
package com.cool.store.service.impl.xinfa;
|
||||
|
||||
import com.cool.store.dto.huoma.*;
|
||||
import com.cool.store.enums.SpecialTagEnum;
|
||||
import com.cool.store.response.ResponseResult;
|
||||
import com.cool.store.service.xinfa.XinFaBusinessService;
|
||||
import com.cool.store.service.xinfa.XinFaDeviceService;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @Author suzhuhong
|
||||
* @Date 2025/11/5 16:17
|
||||
* @Version 1.0
|
||||
*/
|
||||
@Service
|
||||
public class XinFaBusinessServiceImpl implements XinFaBusinessService {
|
||||
@Resource
|
||||
XinFaDeviceService xinFaDeviceService;
|
||||
|
||||
@Override
|
||||
public List<StoreXinFaDeviceDetail> getStoreXinFaDeviceDetail(String storeNum) {
|
||||
return xinFaDeviceService.getStoreXinFaDeviceDetail(storeNum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TagDetailDTO> getAccountAllTags(String storeNum,String deviceName) {
|
||||
//如果是广告机,不需要展示标签
|
||||
if (deviceName.contains("广告机")){
|
||||
return new ArrayList<>();
|
||||
}
|
||||
List<TagDetailDTO> accountAllTags = xinFaDeviceService.getAccountAllTags(storeNum);
|
||||
if (accountAllTags != null){
|
||||
return accountAllTags.stream()
|
||||
.filter(tag -> tag.getName() != null &&
|
||||
SpecialTagEnum.getAllTagNames().contains(tag.getName()))
|
||||
.sorted(Comparator.comparing(tag -> SpecialTagEnum.getAllTagNames().indexOf(tag.getName())))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ProgramResponseDTO> getProgramList(ProgramReqDTO programReqDTO) {
|
||||
//如果没传tag 查所有 根据更新时间倒序排
|
||||
programReqDTO.setSort("desc");
|
||||
programReqDTO.setDate("updateTime");
|
||||
if (CollectionUtils.isEmpty(programReqDTO.getTagIds())){
|
||||
//设备名称包含 广告机 只查询电子价目表
|
||||
programReqDTO.setTagIds(xinFaDeviceService.getAccountSpecialTagIds(programReqDTO.getStoreCode(), SpecialTagEnum.getElectronicPriceTagName()));
|
||||
}
|
||||
List<ProgramResponseDTO> programList = xinFaDeviceService.getProgramList(programReqDTO);
|
||||
return programList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean publishProgram(PublishDTO publishDTO) {
|
||||
return xinFaDeviceService.publish(publishDTO);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
package com.cool.store.service.login;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.cool.store.constants.CommonConstants;
|
||||
import com.cool.store.constants.RedisConstant;
|
||||
import com.cool.store.context.CurrentUserHolder;
|
||||
import com.cool.store.context.LoginUserInfo;
|
||||
import com.cool.store.dao.EnterpriseUserDAO;
|
||||
import com.cool.store.dto.login.UserLoginDTO;
|
||||
import com.cool.store.dto.login.UserRefreshLoginDTO;
|
||||
import com.cool.store.entity.EnterpriseUserDO;
|
||||
import com.cool.store.entity.login.UserLoginDO;
|
||||
import com.cool.store.enums.ErrorCodeEnum;
|
||||
import com.cool.store.response.ResponseResult;
|
||||
import com.cool.store.service.EnterpriseService;
|
||||
import com.cool.store.userholder.CurrentUser;
|
||||
import com.cool.store.userholder.RefreshUser;
|
||||
import com.cool.store.utils.RedisUtilPool;
|
||||
import com.cool.store.utils.poi.constant.Constants;
|
||||
import com.cool.store.vo.login.UserBaseInfoVO;
|
||||
import com.cool.store.vo.login.UserLoginVO;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.text.MessageFormat;
|
||||
import java.time.LocalDate;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 登录基础服务类
|
||||
* </p>
|
||||
*
|
||||
* @author wangff
|
||||
* @since 2025/9/3
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public abstract class LoginBaseService implements LoginStrategy {
|
||||
@Resource
|
||||
private RedisUtilPool redisUtilPool;
|
||||
@Resource
|
||||
private EnterpriseUserDAO enterpriseUserDAO;
|
||||
@Resource
|
||||
private EnterpriseService enterpriseService;
|
||||
|
||||
/**
|
||||
* 策略登录实现方法
|
||||
*/
|
||||
public abstract ResponseResult userLogin(UserLoginDTO param, UserLoginDO userLoginDO);
|
||||
|
||||
@Override
|
||||
public ResponseResult login(UserLoginDTO param) {
|
||||
log.info("login:{}", JSONObject.toJSONString(param));
|
||||
String errorPasswordCountKey = MessageFormat.format(RedisConstant.ERROR_PASSWORD_COUNT_KEY, LocalDate.now(), param.getMobile());
|
||||
String errorCount = redisUtilPool.getString(errorPasswordCountKey);
|
||||
//判断密码错误次数
|
||||
if (StringUtils.isNotBlank(errorCount)) {
|
||||
if (Integer.parseInt(errorCount) >= CommonConstants.MAX_ERROR_PASSWORD_COUNT) {
|
||||
return ResponseResult.fail(ErrorCodeEnum.PASSWORD_ERROR_MAX_COUNT, errorCount);
|
||||
}
|
||||
}
|
||||
EnterpriseUserDO enterpriseUserDO = enterpriseUserDAO.selectByMobile(param.getMobile());
|
||||
UserLoginDO userLoginDO = enterpriseUserDAO.getUserLoginByUnionid(enterpriseUserDO.getUnionid());
|
||||
return userLogin(param, userLoginDO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseResult refreshLogin(UserRefreshLoginDTO param) {
|
||||
String refreshTokenKey = RedisConstant.REFRESH_TOKEN_PREFIX + param.getRefreshToken();
|
||||
String refreshUserStr = redisUtilPool.getString(refreshTokenKey);
|
||||
if (StringUtils.isBlank(refreshUserStr)) {
|
||||
return ResponseResult.fail(ErrorCodeEnum.REFRESH_TOKEN_INVALID);
|
||||
}
|
||||
RefreshUser refreshUser = JSONObject.parseObject(refreshUserStr, RefreshUser.class);
|
||||
if (StringUtils.isBlank(refreshUser.getMobile())) {
|
||||
return ResponseResult.fail(ErrorCodeEnum.REFRESH_TOKEN_INVALID);
|
||||
}
|
||||
UserLoginDO userLoginDO = new UserLoginDO(refreshUser.getUserId(), refreshUser.getMobile(), null);
|
||||
return ResponseResult.success(getUserLoginInfo(userLoginDO));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseResult logout() {
|
||||
LoginUserInfo currentUser = CurrentUserHolder.getUser();
|
||||
String accessToken = currentUser.getAccessToken();
|
||||
String key = RedisConstant.ACCESS_TOKEN_PREFIX + accessToken;
|
||||
redisUtilPool.delKey(key);
|
||||
return ResponseResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取登录accessToken
|
||||
*
|
||||
* @param userLoginDO 用户登录信息
|
||||
* @return accessToken
|
||||
*/
|
||||
public UserLoginVO getUserLoginInfo(UserLoginDO userLoginDO) {
|
||||
CurrentUser currentUser = enterpriseService.getLoginInfo(userLoginDO.getMobile());
|
||||
UserBaseInfoVO userBAseInfoVO = BeanUtil.toBean(currentUser, UserBaseInfoVO.class);
|
||||
RefreshUser refreshUser = enterpriseService.getRefreshUser(userLoginDO.getUserId(), userLoginDO.getMobile());
|
||||
return new UserLoginVO(currentUser.getAccessToken(), refreshUser.getRefreshToken(), CommonConstants.ACTION_TOKEN_EXPIRE, userBAseInfoVO);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.cool.store.service.login;
|
||||
|
||||
import com.cool.store.dto.login.UserLoginDTO;
|
||||
import com.cool.store.dto.login.UserRefreshLoginDTO;
|
||||
import com.cool.store.response.ResponseResult;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 登录策略
|
||||
* </p>
|
||||
*
|
||||
* @author wangff
|
||||
* @since 2025/9/3
|
||||
*/
|
||||
public interface LoginStrategy {
|
||||
/**
|
||||
* 登录基础方法
|
||||
*/
|
||||
ResponseResult login(UserLoginDTO param);
|
||||
|
||||
/**
|
||||
* refreshToken登录
|
||||
*/
|
||||
ResponseResult refreshLogin(UserRefreshLoginDTO param);
|
||||
|
||||
/**
|
||||
* 登出
|
||||
*/
|
||||
ResponseResult logout();
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package com.cool.store.service.login.impl;
|
||||
|
||||
import com.aliyun.core.utils.StringUtils;
|
||||
import com.cool.store.constants.CommonConstants;
|
||||
import com.cool.store.constants.RedisConstant;
|
||||
import com.cool.store.dto.login.UserLoginDTO;
|
||||
import com.cool.store.entity.login.UserLoginDO;
|
||||
import com.cool.store.enums.ErrorCodeEnum;
|
||||
import com.cool.store.response.ResponseResult;
|
||||
import com.cool.store.service.login.LoginBaseService;
|
||||
import com.cool.store.utils.Md5Utils;
|
||||
import com.cool.store.utils.RedisUtilPool;
|
||||
import com.cool.store.utils.poi.constant.Constants;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.time.LocalDate;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 密码登录服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author wangff
|
||||
* @since 2025/9/4
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
public class PasswordLoginServiceImpl extends LoginBaseService {
|
||||
private final RedisUtilPool redisUtilPool;
|
||||
|
||||
@Override
|
||||
public ResponseResult userLogin(UserLoginDTO param, UserLoginDO userLoginDO) {
|
||||
if (StringUtils.isBlank(param.getPassword())) {
|
||||
return ResponseResult.fail(ErrorCodeEnum.PASSWORD_MISSING);
|
||||
}
|
||||
if (StringUtils.isBlank(userLoginDO.getPassword())) {
|
||||
return ResponseResult.fail(ErrorCodeEnum.IMPROVE_USER_INFO);
|
||||
}
|
||||
String password = Md5Utils.md5(param.getPassword() + CommonConstants.USER_AUTH_KEY);
|
||||
if (!password.equals(userLoginDO.getPassword())) {
|
||||
String errorPasswordCountKey = MessageFormat.format(RedisConstant.ERROR_PASSWORD_COUNT_KEY, LocalDate.now(), param.getMobile());
|
||||
Long errorNum = redisUtilPool.incrby(errorPasswordCountKey, 1);
|
||||
redisUtilPool.expire(errorPasswordCountKey, 24 * 60 * 60);
|
||||
if(errorNum == 1){
|
||||
return ResponseResult.fail(ErrorCodeEnum.PASSWORD_ERROR);
|
||||
}
|
||||
return ResponseResult.fail(ErrorCodeEnum.PASSWORD_ERROR_MULTI, errorNum.toString());
|
||||
}
|
||||
return ResponseResult.success(getUserLoginInfo(userLoginDO));
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,149 @@
|
||||
package com.cool.store.service.wechat;
|
||||
|
||||
import com.cool.store.builder.TemplateMessageBuilder;
|
||||
import com.cool.store.config.weixin.WechatMpProperties;
|
||||
import com.cool.store.dto.wechat.AccessTokenDTO;
|
||||
import com.cool.store.dto.wechat.WechatTemplateMessageDTO;
|
||||
import com.cool.store.dto.wechat.WechatUserInfoDTO;
|
||||
import com.cool.store.enums.wechat.WechatTemplateEnum;
|
||||
import com.cool.store.utils.OkHttpUtil;
|
||||
import com.cool.store.utils.RedisUtilPool;
|
||||
import com.cool.store.utils.poi.StringUtils;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @Author suzhuhong
|
||||
* @Date 2025/10/10 14:15
|
||||
* @Version 1.0
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class WechatTemplateService {
|
||||
|
||||
|
||||
private static final String ACCESS_TOKEN_KEY = "wechat_service_account_access_token";
|
||||
|
||||
@Autowired
|
||||
private WechatMpProperties wechatMpProperties;
|
||||
|
||||
@Autowired
|
||||
private TemplateMessageBuilder templateMessageBuilder;
|
||||
|
||||
@Autowired
|
||||
private OkHttpUtil okHttpUtil;
|
||||
@Autowired
|
||||
private ObjectMapper objectMapper;
|
||||
@Resource
|
||||
private RedisUtilPool redisUtilPool;
|
||||
|
||||
|
||||
public String getAccessToken() {
|
||||
String cachedToken = redisUtilPool.getString(ACCESS_TOKEN_KEY);
|
||||
if (StringUtils.isNotEmpty(cachedToken)) {
|
||||
log.info("从 Redis 获取 access_token: {}", cachedToken);
|
||||
return cachedToken;
|
||||
}
|
||||
String url = String.format("%s?grant_type=client_credential&appid=%s&secret=%s",
|
||||
wechatMpProperties.getAccessTokenUrl(),
|
||||
wechatMpProperties.getAppId(),
|
||||
wechatMpProperties.getAppSecret());
|
||||
try {
|
||||
String result = okHttpUtil.doGet(url);
|
||||
log.info("获取access_token响应: {}", result);
|
||||
|
||||
if (StringUtils.isNotEmpty( result)){
|
||||
AccessTokenDTO responseDTO = objectMapper.readValue(result, AccessTokenDTO.class);
|
||||
String accessToken = responseDTO.getAccess_token();
|
||||
|
||||
// 将获取到的 token 存入 Redis,设置过期时间(微信 token 有效期 7200 秒,这里设置 7000 秒)
|
||||
if (StringUtils.isNotEmpty(accessToken)) {
|
||||
redisUtilPool.setString(ACCESS_TOKEN_KEY, accessToken, 7000);
|
||||
log.info("将 access_token 存入 Redis: {}", accessToken);
|
||||
}
|
||||
return accessToken;
|
||||
}
|
||||
return null;
|
||||
} catch (IOException e) {
|
||||
log.error("获取access_token失败", e);
|
||||
} catch (Exception e) {
|
||||
log.error("解析access_token响应失败", e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public WechatUserInfoDTO getUserInfo(String openId, String lang) {
|
||||
String accessToken = getAccessToken();
|
||||
//默认中国
|
||||
lang = StringUtils.isEmpty(lang)?"zh_CN":lang;
|
||||
if (accessToken == null) {
|
||||
log.error("获取access_token失败");
|
||||
return null;
|
||||
}
|
||||
String url = String.format("https://api.weixin.qq.com/cgi-bin/user/info?access_token=%s&openid=%s",
|
||||
accessToken, openId);
|
||||
|
||||
if (lang != null && !lang.trim().isEmpty()) {
|
||||
url += "&lang=" + lang;
|
||||
}
|
||||
try {
|
||||
String result = okHttpUtil.doGet(url);
|
||||
log.debug("获取用户信息响应: {}", result);
|
||||
WechatUserInfoDTO userInfo = objectMapper.readValue(result, WechatUserInfoDTO.class);
|
||||
return userInfo;
|
||||
} catch (IOException e) {
|
||||
log.error("获取用户信息失败", e);
|
||||
return null;
|
||||
} catch (Exception e) {
|
||||
log.error("解析用户信息响应失败", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean sendNormalTemplate(String openId, WechatTemplateEnum template, Map<String, Object> data) {
|
||||
WechatTemplateMessageDTO messageDTO = templateMessageBuilder.buildNormalTemplate(openId, template, data);
|
||||
return sendTemplateMessage(messageDTO);
|
||||
}
|
||||
|
||||
public boolean sendMiniAppTemplate(String openId, WechatTemplateEnum template,
|
||||
Map<String, Object> data, String miniAppPagePath) {
|
||||
WechatTemplateMessageDTO messageDTO = templateMessageBuilder.buildMiniappTemplate(
|
||||
openId, template, data, miniAppPagePath);
|
||||
return sendTemplateMessage(messageDTO);
|
||||
}
|
||||
|
||||
public boolean sendMiniAppTemplateWithUrl(String openId, WechatTemplateEnum template,
|
||||
Map<String, Object> data, String miniAppPagePath, String backupUrl) {
|
||||
WechatTemplateMessageDTO messageDTO = templateMessageBuilder.buildMiniAppTemplateWithUrl(
|
||||
openId, template, data, miniAppPagePath, backupUrl);
|
||||
return sendTemplateMessage(messageDTO);
|
||||
}
|
||||
|
||||
private boolean sendTemplateMessage(WechatTemplateMessageDTO messageDTO) {
|
||||
String accessToken = getAccessToken();
|
||||
if (accessToken == null) {
|
||||
log.error("获取access_token失败,无法发送模板消息");
|
||||
return false;
|
||||
}
|
||||
|
||||
String url = String.format("%s?access_token=%s",
|
||||
wechatMpProperties.getSendTemplateMessageUrl(), accessToken);
|
||||
|
||||
log.info("发送模板消息: {}", messageDTO);
|
||||
try {
|
||||
String result = okHttpUtil.doPostJson(url, messageDTO);
|
||||
log.info("发送模板消息响应: {}", result);
|
||||
|
||||
return Boolean.TRUE;
|
||||
} catch (Exception e) {
|
||||
log.error("解析模板消息响应失败", e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package com.cool.store.service.xinfa;
|
||||
|
||||
import com.cool.store.dto.huoma.*;
|
||||
import com.cool.store.response.ResponseResult;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author suzhuhong
|
||||
* @Date 2025/11/5 16:15
|
||||
* @Version 1.0
|
||||
*/
|
||||
public interface XinFaBusinessService {
|
||||
|
||||
|
||||
/**
|
||||
* 获取门店信发设备列表
|
||||
* @param storeNum
|
||||
* @return
|
||||
*/
|
||||
List<StoreXinFaDeviceDetail> getStoreXinFaDeviceDetail(String storeNum);
|
||||
|
||||
/**
|
||||
* 获取账号下有哪些标签
|
||||
* @param storeNum
|
||||
* @return
|
||||
*/
|
||||
List<TagDetailDTO> getAccountAllTags(String storeNum,String deviceName);
|
||||
|
||||
/**
|
||||
* 获取账号下有哪些节目、
|
||||
* 通过门店在哪个账号下 确定账号
|
||||
* @param programReqDTO
|
||||
* @return
|
||||
*/
|
||||
List<ProgramResponseDTO> getProgramList(ProgramReqDTO programReqDTO);
|
||||
|
||||
/**
|
||||
* 发布信发设备
|
||||
* @param publishDTO
|
||||
* @return
|
||||
*/
|
||||
Boolean publishProgram(PublishDTO publishDTO);
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,535 @@
|
||||
package com.cool.store.service.xinfa;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.cool.store.constants.RedisConstant;
|
||||
import com.cool.store.dto.huoma.*;
|
||||
import com.cool.store.enums.ErrorCodeEnum;
|
||||
import com.cool.store.enums.SpecialTagEnum;
|
||||
import com.cool.store.exception.ServiceException;
|
||||
import com.cool.store.response.ResponseResult;
|
||||
import com.cool.store.utils.RedisUtilPool;
|
||||
import com.cool.store.utils.poi.constant.Constants;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import okhttp3.*;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.annotation.Resource;
|
||||
import java.io.IOException;
|
||||
import java.net.SocketTimeoutException;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @Author suzhuhong
|
||||
* @Date 2025/11/4 15:47
|
||||
* @Version 1.0
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class XinFaDeviceService {
|
||||
|
||||
@Value("${huoMa.direct.stores.account}")
|
||||
private String huoMaDirectStoresAccount;
|
||||
@Value("${huoMa.direct.stores.password}")
|
||||
private String huoMaDirectStoresPassword;
|
||||
@Value("${huoMa.franchise.stores.account}")
|
||||
private String huoMaFranchiseStoresAccount;
|
||||
@Value("${huoMa.franchise.stores.password}")
|
||||
private String huoMaFranchiseStoresPassword;
|
||||
@Value("${huoMa.restaurant.stores.account}")
|
||||
private String huoMaRestaurantStoresAccount;
|
||||
@Value("${huoMa.restaurant.stores.password}")
|
||||
private String huoMaRestaurantStoresPassword;
|
||||
@Resource
|
||||
RedisUtilPool redisUtilPool;
|
||||
@Value("${huoMa.token.url}")
|
||||
private String huoMaTokenUrl;
|
||||
@Value("${huoMa.get.point.terminal.url}")
|
||||
private String huoMaGetPointTerminalUrl;
|
||||
@Value("${huoMa.id.url}")
|
||||
private String huoMaGetStoreIdUrl;
|
||||
@Value("${huoMa.store.device.detail.url}")
|
||||
private String huoMaGetStoreXinFaDeviceDetailUrl ;
|
||||
@Value("${huoMa.get.tag.url}")
|
||||
private String huoMaGetTagUrl;
|
||||
@Value("${huoMa.get.program.url}")
|
||||
private String huoMaGetProgramUrl;
|
||||
@Value("${huoMa.get.publish.url}")
|
||||
private String huoMaGetPublishUrl;
|
||||
|
||||
|
||||
private final Map<String, HuoMaAccountDTO> accountMap = new HashMap<>();
|
||||
|
||||
private final OkHttpClient httpClient = new OkHttpClient.Builder()
|
||||
.connectTimeout(10, TimeUnit.SECONDS)
|
||||
.readTimeout(30, TimeUnit.SECONDS)
|
||||
.writeTimeout(30, TimeUnit.SECONDS)
|
||||
.build();
|
||||
|
||||
@PostConstruct
|
||||
public void initAccountMap() {
|
||||
accountMap.put("restaurant", new HuoMaAccountDTO(huoMaRestaurantStoresAccount, huoMaRestaurantStoresPassword));
|
||||
accountMap.put("direct", new HuoMaAccountDTO(huoMaDirectStoresAccount, huoMaDirectStoresPassword));
|
||||
accountMap.put("franchise", new HuoMaAccountDTO(huoMaFranchiseStoresAccount, huoMaFranchiseStoresPassword));
|
||||
}
|
||||
|
||||
public String getStoreToken(String account, String password) {
|
||||
String key = MessageFormat.format(RedisConstant.HUO_MA_TOKEN, account);
|
||||
String accessToken = redisUtilPool.getString(key);
|
||||
if (accessToken != null) {
|
||||
return accessToken;
|
||||
}
|
||||
Map<String, String> requestBody = new HashMap<>();
|
||||
requestBody.put("account", account);
|
||||
requestBody.put("password", password);
|
||||
String responseBody = sendPostRequest(JSONObject.toJSONString(requestBody), huoMaTokenUrl);
|
||||
try{
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
JsonNode rootNode = mapper.readTree(responseBody);
|
||||
String token = rootNode.path("data").path("token").asText();
|
||||
//缓存60秒
|
||||
redisUtilPool.setString(key, token,60*60);
|
||||
return token;
|
||||
}catch (Exception e){
|
||||
log.error("解析获取token失败,url:{},responseBody:{}",huoMaTokenUrl, responseBody);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public List<StoreEquipmentDTO> getStoreEquipmentDataByStoreNumList(List<String> storeNumList, String token) {
|
||||
Map<String,List<String>> requestBody = new HashMap<>();
|
||||
requestBody.put("codeList", storeNumList);
|
||||
String responseBody = sendPostRequestNoRetryByToken(JSONObject.toJSONString(requestBody), huoMaGetPointTerminalUrl,token);
|
||||
try{
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
JsonNode rootNode = mapper.readTree(responseBody);
|
||||
return mapper.convertValue(rootNode.get("data"),
|
||||
mapper.getTypeFactory().constructCollectionType(List.class, StoreEquipmentDTO.class));
|
||||
}catch (Exception e){
|
||||
log.error("解析获取data失败,url:{},responseBody:{}",huoMaTokenUrl, responseBody);
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public Integer getStoreIdByStoreNum(String storeNum, String token) {
|
||||
String houMaStoreId = redisUtilPool.hashGet(RedisConstant.HUO_MA_STORE_ID, storeNum);
|
||||
if (houMaStoreId != null) {
|
||||
try {
|
||||
return Integer.valueOf(houMaStoreId);
|
||||
} catch (NumberFormatException e) {
|
||||
// 如果缓存中的数据格式不正确,继续执行正常逻辑
|
||||
log.warn("Redis缓存中的门店ID格式不正确,storeNum: {}", storeNum);
|
||||
}
|
||||
}
|
||||
StoreRequestDTO requestBody = new StoreRequestDTO("point_report", 0, 10, storeNum);
|
||||
String responseBody = sendPostRequestNoRetryByToken(JSONObject.toJSONString(requestBody), huoMaGetStoreIdUrl,token);
|
||||
try{
|
||||
Integer storeId = extractIdsFromResponse(responseBody);
|
||||
redisUtilPool.hashSet(RedisConstant.HUO_MA_STORE_ID, storeNum, storeId.toString());
|
||||
return storeId;
|
||||
}catch (Exception e){
|
||||
log.error("解析获取data失败,url:{},responseBody:{}",huoMaTokenUrl, responseBody);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public List<StoreXinFaDeviceDetail> getStoreXinFaDeviceDetail(String storeNum) {
|
||||
String source = redisUtilPool.hashGet(RedisConstant.HUOMA_STORE_DEVICE_RESOURCE_KEY, storeNum);
|
||||
if (StringUtils.isNotBlank(source)) {
|
||||
HuoMaAccountDTO huoMaAccountDTO = accountMap.get(source);
|
||||
if (Objects.nonNull(huoMaAccountDTO)) {
|
||||
String token = getStoreToken(huoMaAccountDTO.getAccount(), huoMaAccountDTO.getPassword());
|
||||
List<StoreXinFaDeviceDetail> deviceDetailDetail = getStoreXinFaDeviceDetailDetail(storeNum, token);
|
||||
if (CollectionUtils.isNotEmpty(deviceDetailDetail)) {
|
||||
return deviceDetailDetail;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (Map.Entry<String, HuoMaAccountDTO> entry : accountMap.entrySet()) {
|
||||
HuoMaAccountDTO huoMaAccountDTO = entry.getValue();
|
||||
if (!huoMaAccountDTO.getIsQuery()) {
|
||||
String token = getStoreToken(huoMaAccountDTO.getAccount(), huoMaAccountDTO.getPassword());
|
||||
List<StoreXinFaDeviceDetail> deviceDetailDetail = getStoreXinFaDeviceDetailDetail(storeNum, token);
|
||||
if (CollectionUtils.isNotEmpty(deviceDetailDetail)) {
|
||||
redisUtilPool.hashSet(RedisConstant.HUOMA_STORE_DEVICE_RESOURCE_KEY, storeNum, entry.getKey(), Constants.REFRESH_TOKEN_EXPIRE);
|
||||
return deviceDetailDetail;
|
||||
}
|
||||
}
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
|
||||
public List<StoreXinFaDeviceDetail> getStoreXinFaDeviceDetailDetail(String storeNum, String token) {
|
||||
Integer storeIdByStoreNum = getStoreIdByStoreNum(storeNum, token);
|
||||
return getStoreXinFaDeviceDetailByPointId(storeIdByStoreNum, token);
|
||||
}
|
||||
|
||||
|
||||
public List<TagDetailDTO> getAccountAllTags(String storeNum){
|
||||
String source = redisUtilPool.hashGet(RedisConstant.HUOMA_STORE_DEVICE_RESOURCE_KEY, storeNum);
|
||||
//获取标签 必须要知道门店属于哪个账号下 获取对应账号下的标签 如果获取不到 直接返回空
|
||||
if (StringUtils.isEmpty(source)){
|
||||
log.info("门店没有找到对应的账号,storeNum: {}", storeNum);
|
||||
return new ArrayList<>();
|
||||
}
|
||||
HuoMaAccountDTO huoMaAccountDTO = accountMap.get(source);
|
||||
if (Objects.nonNull(huoMaAccountDTO)){
|
||||
huoMaAccountDTO.setIsQuery(true);
|
||||
String token = getStoreToken(huoMaAccountDTO.getAccount(), huoMaAccountDTO.getPassword());
|
||||
TagDTO tagDTO = new TagDTO("DEFAULT", 0, 30,"program");
|
||||
String responseBody = null;
|
||||
try{
|
||||
responseBody = sendPostRequestNoRetryByToken(JSONObject.toJSONString(tagDTO), huoMaGetTagUrl,token);
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
JsonNode rootNode = mapper.readTree(responseBody);
|
||||
|
||||
// 直接转换整个数组
|
||||
return mapper.convertValue(
|
||||
rootNode.path("data").path("content"),
|
||||
mapper.getTypeFactory().constructCollectionType(List.class, TagDetailDTO.class)
|
||||
);
|
||||
}catch (Exception e){
|
||||
log.error("getAccountAllTags解析获取data失败,url:{},responseBody:{}",huoMaTokenUrl, responseBody);
|
||||
}
|
||||
}
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取账号下指定标签的id 只需要一下四个
|
||||
* @param storeNum
|
||||
* @return
|
||||
*/
|
||||
public List<Integer> getAccountSpecialTagIds( String storeNum,List<String> tagList) {
|
||||
List<TagDetailDTO> accountAllTags = getAccountAllTags(storeNum);
|
||||
if (accountAllTags != null) {
|
||||
return accountAllTags.stream()
|
||||
.filter(tag -> tag.getName() != null &&
|
||||
tagList.contains(tag.getName()))
|
||||
.map(TagDetailDTO::getId)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
|
||||
public List<ProgramResponseDTO> getProgramList(ProgramReqDTO programReqDTO) {
|
||||
if (StringUtils.isEmpty(programReqDTO.getStoreCode())){
|
||||
log.info("门店没有找到对应的账号,storeNum: {}", programReqDTO.getStoreCode());
|
||||
return new ArrayList<>();
|
||||
}
|
||||
//先查询门店是属于哪个账号下
|
||||
String source = redisUtilPool.hashGet(RedisConstant.HUOMA_STORE_DEVICE_RESOURCE_KEY, programReqDTO.getStoreCode());
|
||||
//获取标签 必须要知道门店属于哪个账号下 获取对应账号下的标签 如果获取不到 直接返回空
|
||||
if (StringUtils.isEmpty(source)){
|
||||
log.info("门店没有找到对应的账号,storeNum: {}", programReqDTO.getStoreCode());
|
||||
return new ArrayList<>();
|
||||
}
|
||||
HuoMaAccountDTO huoMaAccountDTO = accountMap.get(source);
|
||||
if (huoMaAccountDTO!=null){
|
||||
String token = getStoreToken(huoMaAccountDTO.getAccount(), huoMaAccountDTO.getPassword());
|
||||
String responseBody = null;
|
||||
try{
|
||||
responseBody = sendPostRequestNoRetryByToken(JSONObject.toJSONString(programReqDTO), huoMaGetProgramUrl,token);
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
JsonNode rootNode = mapper.readTree(responseBody);
|
||||
|
||||
// 直接转换整个数组
|
||||
return mapper.convertValue(
|
||||
rootNode.path("data").path("content"),
|
||||
mapper.getTypeFactory().constructCollectionType(List.class, ProgramResponseDTO.class)
|
||||
);
|
||||
}catch (Exception e){
|
||||
log.error("getProgramList 解析获取data失败,url:{},responseBody:{}",huoMaTokenUrl, responseBody);
|
||||
}
|
||||
}
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
public Boolean publish(PublishDTO publishDTO){
|
||||
if (StringUtils.isEmpty(publishDTO.getStoreCode())){
|
||||
log.info("门店没有找到对应的账号,发布失败,storeNum: {}", publishDTO.getStoreCode());
|
||||
return Boolean.FALSE;
|
||||
}
|
||||
String source = redisUtilPool.hashGet(RedisConstant.HUOMA_STORE_DEVICE_RESOURCE_KEY, publishDTO.getStoreCode());
|
||||
//获取标签 必须要知道门店属于哪个账号下 获取对应账号下的标签 如果获取不到 直接返回空
|
||||
if (StringUtils.isEmpty(source)){
|
||||
log.info("门店没有找到对应的账号,storeNum: {}", publishDTO.getStoreCode());
|
||||
return Boolean.FALSE;
|
||||
}
|
||||
HuoMaAccountDTO huoMaAccountDTO = accountMap.get(source);
|
||||
if (huoMaAccountDTO!=null){
|
||||
String token = getStoreToken(huoMaAccountDTO.getAccount(), huoMaAccountDTO.getPassword());
|
||||
String responseBody = null;
|
||||
try{
|
||||
responseBody = sendPostRequestNoRetryByToken(JSONObject.toJSONString(publishDTO), huoMaGetPublishUrl,token);
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
JsonNode rootNode = mapper.readTree(responseBody);
|
||||
int code = rootNode.get("code").asInt();
|
||||
if (code != 0) {
|
||||
throw new RuntimeException("发布失败");
|
||||
}
|
||||
// 直接转换整个数组
|
||||
log.info("发布成功 deviceId:{},storeCode:{}",JSONObject.toJSONString(publishDTO.getDeviceIdList()), publishDTO.getStoreCode() );
|
||||
return Boolean.TRUE;
|
||||
}catch (Exception e){
|
||||
log.error("发布失败, url:{}, responseBody:{}", huoMaTokenUrl, responseBody);
|
||||
}
|
||||
}
|
||||
return Boolean.FALSE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public List<StoreXinFaDeviceDetail> getStoreXinFaDeviceDetailByPointId(Integer pointId, String token) {
|
||||
if (pointId != null){
|
||||
StoreXinFaDetailRequestDTO storeXinFaDetailRequestDTO = new StoreXinFaDetailRequestDTO(0, 10, pointId);
|
||||
String responseBody = null;
|
||||
try{
|
||||
responseBody = sendPostRequestNoRetryByToken(JSONObject.toJSONString(storeXinFaDetailRequestDTO), huoMaGetStoreXinFaDeviceDetailUrl,token);
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
JsonNode rootNode = mapper.readTree(responseBody);
|
||||
|
||||
// 直接转换整个数组
|
||||
return mapper.convertValue(
|
||||
rootNode.path("data").path("content"),
|
||||
mapper.getTypeFactory().constructCollectionType(List.class, StoreXinFaDeviceDetail.class)
|
||||
);
|
||||
}catch (Exception e){
|
||||
log.error("getStoreXinFaDeviceDetailByPointId解析获取data失败,url:{},responseBody:{}",huoMaTokenUrl, responseBody);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private Integer extractIdsFromResponse(String jsonResponse) throws IOException {
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
JsonNode rootNode = mapper.readTree(jsonResponse);
|
||||
// 遍历dataList数组提取ID
|
||||
JsonNode dataList = rootNode.path("data").path("dataList");
|
||||
for (JsonNode item : dataList) {
|
||||
if (item.has("ID")) {
|
||||
//取出第一个id
|
||||
return item.get("ID").asInt();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private String sendPostRequest(String requestBody, String requestUrl) {
|
||||
log.info("开始发送请求,url:{},requestBody:{}", requestUrl, requestBody);
|
||||
Request request = new Request.Builder()
|
||||
.url(requestUrl)
|
||||
.post(RequestBody.create(MediaType.parse("application/json"), requestBody))
|
||||
.build();
|
||||
return sendPost(requestUrl, request);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 不重试 请求接口
|
||||
* @param requestBody
|
||||
* @param requestUrl
|
||||
* @param token
|
||||
* @return
|
||||
*/
|
||||
private String sendPostRequestNoRetryByToken(String requestBody, String requestUrl, String token) {
|
||||
log.info("开始发送请求,url:{},requestBody:{}", requestUrl, requestBody);
|
||||
|
||||
try {
|
||||
Request request = new Request.Builder()
|
||||
.url(requestUrl)
|
||||
.post(RequestBody.create(MediaType.parse("application/json"), requestBody))
|
||||
.addHeader("token", token)
|
||||
.build();
|
||||
|
||||
String result = sendPost(requestUrl, request);
|
||||
|
||||
// 检查是否token失效
|
||||
if (isTokenExpired(result)) {
|
||||
log.warn("Token已失效,清除缓存并重新获取token");
|
||||
// 清除对应账号的token缓存并获取新token
|
||||
String newToken = clearAccountTokenCacheForToken(token);
|
||||
|
||||
if (newToken != null) {
|
||||
// 使用新token重新发起一次请求
|
||||
Request newRequest = new Request.Builder()
|
||||
.url(requestUrl)
|
||||
.post(RequestBody.create(MediaType.parse("application/json"), requestBody))
|
||||
.addHeader("token", newToken)
|
||||
.build();
|
||||
|
||||
result = sendPost(requestUrl, newRequest);
|
||||
} else {
|
||||
throw new ServiceException(ErrorCodeEnum.THIRD_API_ERROR, "Token失效且无法获取新token");
|
||||
}
|
||||
}
|
||||
return result;
|
||||
} catch (Exception e) {
|
||||
log.error("请求异常,错误: {}", e.getMessage());
|
||||
throw new ServiceException(ErrorCodeEnum.THIRD_API_ERROR, "请求失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 包含重试 适用于批量拉取数据 ,正常页面接口无需重试
|
||||
* @param requestBody
|
||||
* @param requestUrl
|
||||
* @param token
|
||||
* @return
|
||||
*/
|
||||
private String sendPostRequestByToken(String requestBody, String requestUrl, String token) {
|
||||
log.info("开始发送请求,url:{},requestBody:{}", requestUrl, requestBody);
|
||||
|
||||
int maxRetries = 3;
|
||||
for (int i = 0; i < maxRetries; i++) {
|
||||
try {
|
||||
Request request = new Request.Builder()
|
||||
.url(requestUrl)
|
||||
.post(RequestBody.create(MediaType.parse("application/json"), requestBody))
|
||||
.addHeader("token", token)
|
||||
.build();
|
||||
|
||||
String result = sendPost(requestUrl, request);
|
||||
|
||||
// 检查是否token失效
|
||||
if (isTokenExpired(result)) {
|
||||
log.warn("Token已失效,正在清除缓存并重试,第{}次", i + 1);
|
||||
// 直接清除对应账号的token缓存
|
||||
token = clearAccountTokenCacheForToken(token);
|
||||
|
||||
// 抛出异常触发重试
|
||||
throw new ServiceException(ErrorCodeEnum.THIRD_API_ERROR, "Token失效,需要重试");
|
||||
}
|
||||
|
||||
return result;
|
||||
} catch (ServiceException e) {
|
||||
log.warn("请求失败,第{}次重试,错误: {}", i + 1, e.getMessage());
|
||||
if (i == maxRetries - 1) {
|
||||
throw e;
|
||||
}
|
||||
try {
|
||||
Thread.sleep(1000 * (i + 1));
|
||||
} catch (InterruptedException ie) {
|
||||
Thread.currentThread().interrupt();
|
||||
throw new ServiceException(ErrorCodeEnum.THIRD_API_ERROR, "重试被中断");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.warn("请求异常,第{}次重试,错误: {}", i + 1, e.getMessage());
|
||||
if (i == maxRetries - 1) {
|
||||
throw new ServiceException(ErrorCodeEnum.THIRD_API_ERROR, "请求重试失败: " + e.getMessage());
|
||||
}
|
||||
try {
|
||||
Thread.sleep(1000 * (20*i + 1));
|
||||
} catch (InterruptedException ie) {
|
||||
Thread.currentThread().interrupt();
|
||||
throw new ServiceException(ErrorCodeEnum.THIRD_API_ERROR, "重试被中断");
|
||||
}
|
||||
}
|
||||
}
|
||||
throw new ServiceException(ErrorCodeEnum.THIRD_API_ERROR, "请求重试失败");
|
||||
}
|
||||
|
||||
private boolean isTokenExpired(String responseBody) {
|
||||
try {
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
JsonNode rootNode = mapper.readTree(responseBody);
|
||||
int code = rootNode.path("code").asInt(-1);
|
||||
String msg = rootNode.path("msg").asText("");
|
||||
|
||||
return code == 501;
|
||||
} catch (Exception e) {
|
||||
log.error("检查token失效状态时发生错误: {}", e.getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private String clearAccountTokenCacheForToken(String token) {
|
||||
try {
|
||||
// 遍历可能的账号,找到对应的缓存并删除
|
||||
String[] accounts = {
|
||||
huoMaDirectStoresAccount,
|
||||
huoMaFranchiseStoresAccount,
|
||||
huoMaRestaurantStoresAccount
|
||||
};
|
||||
|
||||
for (String account : accounts) {
|
||||
if (account != null) {
|
||||
String key = MessageFormat.format(RedisConstant.HUO_MA_TOKEN, account);
|
||||
String cachedToken = redisUtilPool.getString(key);
|
||||
if (token.equals(cachedToken)) {
|
||||
redisUtilPool.delKey(key);
|
||||
log.info("已清除账号 {} 的token缓存", account);
|
||||
|
||||
// 根据账号类型获取对应的密码并重新获取token
|
||||
String password = getPasswordForAccount(account);
|
||||
if (password != null) {
|
||||
String newToken = getStoreToken(account, password);
|
||||
if (newToken != null) {
|
||||
log.info("已为账号 {} 重新获取新的token", account);
|
||||
return newToken;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("清除token缓存或重新获取token失败: {}", e.getMessage());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
private String getPasswordForAccount(String account) {
|
||||
if (account.equals(huoMaDirectStoresAccount)) {
|
||||
return huoMaDirectStoresPassword;
|
||||
} else if (account.equals(huoMaFranchiseStoresAccount)) {
|
||||
return huoMaFranchiseStoresPassword;
|
||||
} else if (account.equals(huoMaRestaurantStoresAccount)) {
|
||||
return huoMaRestaurantStoresPassword;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private String sendPost(String requestUrl, Request request) {
|
||||
try (Response response = httpClient.newCall(request).execute()) {
|
||||
log.info("发起请求 time:{}", System.currentTimeMillis());
|
||||
if (!response.isSuccessful()) {
|
||||
log.info("HTTP请求失败,msg: " + response.message());
|
||||
throw new ServiceException(ErrorCodeEnum.THIRD_API_ERROR,
|
||||
"HTTP请求失败,状态码: " + response.code());
|
||||
}
|
||||
String responseBody = response.body().string();
|
||||
log.info("请求成功responseBody:{}", JSONObject.toJSONString(responseBody));
|
||||
return responseBody;
|
||||
} catch (SocketTimeoutException e) {
|
||||
log.error("API调用超时 - URL: {}, 错误: {}", requestUrl, e.getMessage(), e);
|
||||
throw new ServiceException(ErrorCodeEnum.THIRD_API_ERROR, "接口调用超时: " + e.getMessage());
|
||||
} catch (ServiceException e) {
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
log.error("API调用异常 - URL: {}, 错误: {}", requestUrl, e.getMessage(), e);
|
||||
throw new ServiceException(ErrorCodeEnum.THIRD_API_ERROR, "接口调用异常: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -220,6 +220,6 @@ public class Constants
|
||||
|
||||
public static final String WANG_LEI_JOB_NUMBER = "19060164";
|
||||
|
||||
|
||||
public static final int REFRESH_TOKEN_EXPIRE = 60*60*24*30;
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user