创建门店
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
package com.cool.store.service;
|
||||
|
||||
/**
|
||||
* @Author: WangShuo
|
||||
* @Date: 2025/07/10/17:14
|
||||
* @Version 1.0
|
||||
* @注释:
|
||||
*/
|
||||
public interface SyncMainSysServer {
|
||||
|
||||
void syncStore(Long shopId);
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
package com.cool.store.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.cool.store.dao.*;
|
||||
import com.cool.store.entity.*;
|
||||
import com.cool.store.enums.*;
|
||||
import com.cool.store.mapper.FranchiseFeeMapper;
|
||||
import com.cool.store.mapper.SignFranchiseMapper;
|
||||
import com.cool.store.mq.producer.SimpleMessageService;
|
||||
import com.cool.store.request.StoreRequestBody;
|
||||
import com.cool.store.service.OperationLogService;
|
||||
import com.cool.store.service.SyncMainSysServer;
|
||||
import com.cool.store.service.UserAuthMappingService;
|
||||
import com.cool.store.utils.poi.StringUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.LocalTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.cool.store.enums.ExtendFieldTypeEnum.*;
|
||||
|
||||
/**
|
||||
* @Author: WangShuo
|
||||
* @Date: 2025/07/10/17:14
|
||||
* @Version 1.0
|
||||
* @注释:
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class SyncMainSysServerImpl implements SyncMainSysServer {
|
||||
@Value("${spring.profiles.active}")
|
||||
private String active;
|
||||
@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;
|
||||
|
||||
@Override
|
||||
//@Async
|
||||
public void syncStore(Long shopId) {
|
||||
StoreRequestBody requestBody = new StoreRequestBody();
|
||||
ShopInfoDO shopInfo = shopInfoDAO.getShopInfo(shopId);
|
||||
LineInfoDO lineInfoDO = lineInfoDAO.getLineInfo(shopInfo.getLineId());
|
||||
PointInfoDO pointInfoDO = pointInfoDAO.getPointInfoById(shopInfo.getPointId());
|
||||
BuildInformationDO buildInformationDO = buildInformationDAO.selectOneByShopId(shopId);
|
||||
SignFranchiseDO signFranchiseDO = signFranchiseMapper.selectByShopId(shopId);
|
||||
|
||||
requestBody.setStore_name(shopInfo.getShopName());
|
||||
requestBody.setStore_num(shopInfo.getShopCode());
|
||||
requestBody.setProvince(pointInfoDO.getProvince());
|
||||
requestBody.setCity(pointInfoDO.getCity());
|
||||
requestBody.setCounty(pointInfoDO.getDistrict());
|
||||
requestBody.setLocation_address(shopInfo.getDetailAddress());
|
||||
requestBody.setStore_address(shopInfo.getDetailAddress());
|
||||
//todo 等待王硕确认
|
||||
requestBody.setStore_area(shopInfo.getManagerSupervisor());
|
||||
//未开业
|
||||
requestBody.setStore_status("not_open");
|
||||
requestBody.setStore_acreage(pointInfoDO.getPointArea());
|
||||
requestBody.setLongitude_latitude(pointInfoDO.getLongitude() + "," + pointInfoDO.getLatitude());
|
||||
|
||||
if (StringUtils.isNotBlank(buildInformationDO.getBusinessHours())) {
|
||||
try {
|
||||
String[] times = buildInformationDO.getBusinessHours().split("~");
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("HH:mm");
|
||||
LocalTime startTime = LocalTime.parse(times[0], formatter);
|
||||
LocalTime endTime = LocalTime.parse(times[1], formatter);
|
||||
String startMillis = String.valueOf(startTime.toSecondOfDay() * 1000L);
|
||||
String endMillis = String.valueOf(endTime.toSecondOfDay() * 1000L);
|
||||
requestBody.setBusiness_hours(startMillis + "," + endMillis);
|
||||
} catch (Exception e) {
|
||||
log.info("时间转换异常:{},shopId:{},time:{}", e.getMessage(), shopId.toString(), buildInformationDO.getBusinessHours());
|
||||
}
|
||||
}
|
||||
Map<String, ExtendFieldTypeEnum> configMapByActive = ExtendFieldTypeEnum.getConfigMapByActive(active);
|
||||
Map<String, String> extendField = new HashMap<>();
|
||||
extendField.put(configMapByActive.get(ONLINE_SIGNATORY_NAME_1.getMsg()).getKey(), signFranchiseDO.getPartnershipSignatoryFirst());
|
||||
extendField.put(configMapByActive.get(ONLINE_SIGNATORY_MOBILE_1.getMsg()).getKey(), lineInfoDO.getMobile());
|
||||
extendField.put(configMapByActive.get(ONLINE_SIGNATORY_NAME_2.getMsg()).getKey(), signFranchiseDO.getPartnershipSignatorySecond());
|
||||
extendField.put(configMapByActive.get(ONLINE_SIGNATORY_MOBILE_2.getMsg()).getKey(), signFranchiseDO.getPartnershipSignatorySecondMobile());
|
||||
extendField.put(configMapByActive.get(ONLINE_ORDER_NAME.getMsg()).getKey(), buildInformationDO.getCShopName());
|
||||
extendField.put(configMapByActive.get(ONLINE_JOIN_MODE.getMsg()).getKey(), JoinModeEnum.getByCode(shopInfo.getJoinMode()));
|
||||
extendField.put(configMapByActive.get(ONLINE_STORE_TYPE.getMsg()).getKey(), StoreTypeEnum.getMessage(shopInfo.getStoreType()));
|
||||
extendField.put(configMapByActive.get(ONLINE_BRAND.getMsg()).getKey(), FranchiseBrandEnum.getDescByCode(shopInfo.getFranchiseBrand()));
|
||||
requestBody.setExtend_field(JSONObject.toJSONString(extendField));
|
||||
requestBody.setEid(eid);
|
||||
simpleMessageService.send(JSONObject.toJSONString(requestBody), RocketMqTagEnum.ZXJP_CREATE_STORE);
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user