Merge branch 'cc_20250813_storeMaster' into 'master'

Cc 20250813 store master

See merge request hangzhou/java/custom_zxjp!154
This commit is contained in:
苏竹红
2025-08-21 09:10:08 +00:00
8 changed files with 352 additions and 83 deletions

View File

@@ -5,10 +5,12 @@ 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.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.service.SyncMainSysServer;
@@ -20,6 +22,7 @@ import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
import java.util.HashMap;
@@ -72,76 +75,137 @@ public class SyncMainSysServerImpl implements SyncMainSysServer {
private String eid;
@Resource
private StoreDao storeDao;
@Resource
SignFranchiseDAO signFranchiseDAO;
@Resource
PointDetailInfoDAO pointDetailDAO;
@Resource
QualificationsInfoDAO qualificationsInfoDAO;
@Override
@Async
public void syncStore(Long shopId) {
StoreRequestBody requestBody = new StoreRequestBody();
ShopInfoDO shopInfo = shopInfoDAO.getShopInfo(shopId);
StoreDO storeDO = storeDao.getByStoreNum(shopInfo.getShopCode());
if (Objects.nonNull(storeDO)) {
throw new ServiceException(ErrorCodeEnum.STORE_IS_EXIST);
}
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(shopInfo.getProvince());
requestBody.setCity(shopInfo.getCity());
requestBody.setCounty(shopInfo.getDistrict());
requestBody.setLocation_address(shopInfo.getDetailAddress());
requestBody.setStore_address(shopInfo.getDetailAddress());
if (shopInfo.getManagerRegionId() == null) {
BigRegionDO byRegionId = bigRegionDAO.getByRegionId(shopInfo.getRegionId());
if (byRegionId != null) {
requestBody.setStore_area(byRegionId.getStoreManageRegionId() == null
? shopInfo.getRegionId().toString() : byRegionId.getStoreManageRegionId().toString());
} else {
requestBody.setStore_area(shopInfo.getRegionId().toString());
}
} else {
requestBody.setStore_area(shopInfo.getManagerRegionId().toString());
}
//未开业
requestBody.setStore_status("not_open");
if (pointInfoDO != null) {
requestBody.setStore_acreage(pointInfoDO.getPointArea());
requestBody.setLongitude_latitude(pointInfoDO.getLongitude() + "," + pointInfoDO.getLatitude());
}
requestBody.setTelephone(buildInformationDO.getBusinessMobile());
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_STORE_MANAGER_MOBILE.getMsg()).getKey(), "");
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);
requestBody.setPartnerName(lineInfoDO.getUsername());
requestBody.setPartnerMobile(lineInfoDO.getMobile());
requestBody.setPartnerRoleId(UserRoleEnum.FRANCHISEES.getCode());
simpleMessageService.send(JSONObject.toJSONString(requestBody), RocketMqTagEnum.ZXJP_CREATE_STORE);
log.info("开始同步门店 syncStore:{}", shopId);
addStore(shopId);
}
/**
* 添加门店
* @param shopId
*/
public void addStore(Long shopId) {
try {
StoreMasterDTO storeMasterDTO = new StoreMasterDTO();
ShopInfoDO shopInfo = shopInfoDAO.getShopInfo(shopId);
if (shopInfo == null){
log.info("门店不存在:{}", shopId);
return;
}
storeMasterDTO.setEnterpriseId(eid);
storeMasterDTO.setStoreStatus("not_open");
storeMasterDTO.setStoreName(shopInfo.getShopName());
storeMasterDTO.setStoreNum(shopInfo.getShopCode());
storeMasterDTO.setJoinBrand(StringUtils.isNotEmpty(shopInfo.getFranchiseBrand())?Integer.valueOf(shopInfo.getFranchiseBrand()):null);
storeMasterDTO.setJoinModel(shopInfo.getJoinMode());
storeMasterDTO.setStoreType(shopInfo.getStoreType());
SignFranchiseDO signFranchiseDO = signFranchiseDAO.selectByShopId(shopId);
storeMasterDTO.setManageModel(signFranchiseDO.getBusinessModel());
storeMasterDTO.setSignType(signFranchiseDO.getSignType());
storeMasterDTO.setProtectiveDistance(signFranchiseDO.getProtectiveDistance());
BigRegionDO region = bigRegionDAO.getByRegionId(shopInfo.getRegionId());
storeMasterDTO.setBloc(region.getGroupName());
storeMasterDTO.setBranch(region.getRegionId());
storeMasterDTO.setRegionId(shopInfo.getManagerRegionId());
storeMasterDTO.setJoinSupervision(shopInfo.getInvestmentManager());
BuildInformationDO buildInformationDO = buildInformationDAO.selectOneByShopId(shopId);
if (buildInformationDO != null){
storeMasterDTO.setMiniProgramOrderStoreName(buildInformationDO.getCShopName());
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);
storeMasterDTO.setBusinessHours(startMillis + "," + endMillis);
} catch (Exception e) {
log.info("时间转换异常:{},shopId:{},time:{}", e.getMessage(), shopId.toString(), buildInformationDO.getBusinessHours());
}
}
StoreMasterDTO.SettlerInfo settlerInfo = new StoreMasterDTO.SettlerInfo();
settlerInfo.setSettlerName(buildInformationDO.getSettlerName());
settlerInfo.setSettlerIdCardNo(buildInformationDO.getSettlerIdCardNo());
settlerInfo.setSettlerIdCardFront(buildInformationDO.getSettlerIdCardFront());
settlerInfo.setSettlerIdCardReverse(buildInformationDO.getSettlerIdCardReverse());
settlerInfo.setSettlerInHandFrontPicture(buildInformationDO.getSettlerInHandFrontPicture());
settlerInfo.setSettlerInHandBackPicture(buildInformationDO.getSettlerInHandBackPicture());
settlerInfo.setSettlerBankName(buildInformationDO.getSettlerBankName());
settlerInfo.setSettlerBankBranchName(buildInformationDO.getSettlerBankName());
settlerInfo.setSettlerBankNumber(buildInformationDO.getSettlerBankNumber());
settlerInfo.setSettlerBankMobile(buildInformationDO.getSettlerBankMobile());
settlerInfo.setSettlerBankPhotoUrl(buildInformationDO.getSettlerBankPhotoUrl());
settlerInfo.setSettlerBankBackPhotoUrl(buildInformationDO.getSettlerBankBackPhotoUrl());
storeMasterDTO.setSettlerInfo(settlerInfo);
}
if (shopInfo.getPointId()!=null){
PointInfoDO info = pointInfoDAO.getPointInfoById(shopInfo.getPointId());
PointDetailInfoDO pointDetail = pointDetailDAO.getPointDetailInfoByPointId(shopInfo.getPointId());
if (info != null){
storeMasterDTO.setArea(info.getProvince()+info.getCity()+info.getDistrict());
storeMasterDTO.setTown(info.getTownship());
storeMasterDTO.setStoreAddress(info.getAddress());
storeMasterDTO.setLocationAddress(info.getAddress());
storeMasterDTO.setPointCode(info.getPointCode());
storeMasterDTO.setLongitude(info.getLongitude());
storeMasterDTO.setLatitude(info.getLatitude());
try {
if (StringUtils.isNotEmpty(pointDetail.getMonthRent())&&pointDetail.getPaymentMethod()!=null){
//获取支付方式
PaymentMethodEnum paymentMethodEnum = PaymentMethodEnum.getByCode(pointDetail.getPaymentMethod());
BigDecimal monthlyRent = new BigDecimal(pointDetail.getMonthRent()).divide(new BigDecimal(paymentMethodEnum.getTotalMonth()));
storeMasterDTO.setMonthlyRent(monthlyRent);
}
} catch (Exception e) {
log.info("月租转换异常:{},shopId:{},time:{}", e.getMessage(), shopId.toString(), pointDetail.getMonthRent());
}
}
}
OrderSysInfoDO orderSysInfoDO = orderSysInfoDAO.selectByShopId(shopId);
if (orderSysInfoDO != null){
storeMasterDTO.setAddresseeName(orderSysInfoDO.getAddresseeName());
storeMasterDTO.setAddresseeMobile(orderSysInfoDO.getAddresseeMobile());
storeMasterDTO.setAddresseeArea(orderSysInfoDO.getAddresseeProvince()+orderSysInfoDO.getAddresseeCity()+orderSysInfoDO.getAddresseeDistrict());
storeMasterDTO.setAddresseeAddress(orderSysInfoDO.getAddresseeAddress());
storeMasterDTO.setDeclareGoodsLogisticsWarehouse(orderSysInfoDO.getDeclareGoodsLogisticsWarehouse());
storeMasterDTO.setDeclareGoodsType(Integer.valueOf(orderSysInfoDO.getDeclareGoodsType()));
storeMasterDTO.setDeclareGoodsDate(orderSysInfoDO.getDeclareGoodsDate());
}
LineInfoDO lineInfoDO = lineInfoDAO.getLineInfo(shopInfo.getLineId());
StoreMasterDTO.SignerInfo signerInfo = new StoreMasterDTO.SignerInfo();
if (lineInfoDO != null){
signerInfo.setSigner1Name(lineInfoDO.getUsername());
signerInfo.setSigner1Mobile(lineInfoDO.getMobile());
signerInfo.setPartnerRoleId(UserRoleEnum.FRANCHISEES.getCode());
}
QualificationsInfoDO infoDO = qualificationsInfoDAO.getByLineId(shopInfo.getLineId());
if (infoDO != null){
signerInfo.setSigner1IdCard(infoDO.getIdCardNo());
signerInfo.setSigner1IdCardPhoto(infoDO.getFrontOfIdCard());
signerInfo.setSigner1IdCardPhotoBack(infoDO.getBackOfIdCard());
}
storeMasterDTO.setSignerInfo(signerInfo);
simpleMessageService.send(JSONObject.toJSONString(storeMasterDTO), RocketMqTagEnum.ZXJP_CREATE_STORE);
} catch (Exception e) {
log.info("asdStore_error:{},shopId:{}", e.getMessage(), shopId.toString());
}
}
}