Merge #144 into master from cc_20260520_unify_merge
0520需求汇总
* cc_20260520_unify_merge: (22 commits squashed)
- fix:正新鸡排信发自动开通改造
- fix:环境配置
- fix
- fix:信发门店设备信息接口入参修改
- fix:信发门店设备信息接口入参修改
- fix:新增根据门店id查询设备接口
- fix
- fix:限制设备数量
- fix:问题修复
- fix:网点信息获取转义;网点/设备创建异常抛出
- fix:更新开业报备流程完成日期、首次在营业状态时间
- fix
- fix:云流水&新管家账号关闭接口传入闭店原因;新增闭店原因违约闭店
- fix:闭店信息新增字段
- Merge branch 'master' into cc_20260518_store_date
- fix:开店流程完成状态判断排除食安阶段
- fix
- fix
- Merge branch 'cc_20260514_xinfa_modify' into cc_20260520_unify_merge
# Conflicts:
#	coolstore-partner-common/src/main/java/com/cool/store/enums/ErrorCodeEnum.java
- Merge branch 'cc_20260518_store_date' into cc_20260520_unify_merge
- Merge branch 'cc_20260520_close_store_optimize' into cc_20260520_unify_merge
- Merge remote-tracking branch 'origin/cc_20260518_close_reason' into cc_20260520_unify_merge
Signed-off-by: 王非凡 <accounts_67eba0c5fee9c49c80c8e2b4@mail.teambition.com>
Merged-by: 正新 <accounts_6964c7bcd2a2c377c5bbd01b@mail.teambition.com>
CR-link: https://codeup.aliyun.com/692ea314dec569489f6f167c/hangzhou/java/custom_zxjp/change/144
This commit is contained in:
@@ -125,6 +125,10 @@ public interface DeskService {
|
||||
* 信发系统
|
||||
*/
|
||||
PageInfo<PreparationCommonPendingVO> xinFaListPendingList(DeskRequest deskRequest, LoginUserInfo user );
|
||||
/**
|
||||
* 信发系统开通(填写设备数量)
|
||||
*/
|
||||
PageInfo<PreparationCommonPendingVO> xinFaFillNumPendingList(DeskRequest deskRequest, LoginUserInfo user );
|
||||
/**
|
||||
* pos
|
||||
*/
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.cool.store.service.close;
|
||||
|
||||
import com.cool.store.entity.CloseStoreInfoDO;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 账号关闭
|
||||
@@ -14,7 +16,7 @@ public interface AccountCloseStrategy {
|
||||
* 申请账号关闭
|
||||
* @return 是否成功
|
||||
*/
|
||||
Boolean accountClose(String storeId);
|
||||
Boolean accountClose(CloseStoreInfoDO closeStoreInfoDO);
|
||||
|
||||
/**
|
||||
* 获取系统code
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.cool.store.service.close.impl;
|
||||
|
||||
import com.cool.store.dao.StoreDao;
|
||||
import com.cool.store.entity.CloseStoreInfoDO;
|
||||
import com.cool.store.entity.StoreDO;
|
||||
import com.cool.store.enums.ErrorCodeEnum;
|
||||
import com.cool.store.exception.ServiceException;
|
||||
@@ -22,7 +23,7 @@ public abstract class AbstractAccountClose implements AccountCloseStrategy {
|
||||
private StoreDao storeDao;
|
||||
|
||||
@Override
|
||||
public Boolean accountClose(String storeId) {
|
||||
public Boolean accountClose(CloseStoreInfoDO closeStoreInfoDO) {
|
||||
// 各平台待对接
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ public class CloseStoreAccountServiceImpl implements CloseStoreAccountService {
|
||||
CloseStoreInfoDO closeStoreInfoDO = closeStoreInfoDAO.getById(accountInfo.getCloseStoreId());
|
||||
// 申请关闭
|
||||
AccountCloseStrategy accountClose = accountCloseFactory.getByCode(accountInfo.getSystemCode());
|
||||
if (Objects.nonNull(accountClose) && accountClose.accountClose(closeStoreInfoDO.getStoreId())) {
|
||||
if (Objects.nonNull(accountClose) && accountClose.accountClose(closeStoreInfoDO)) {
|
||||
closeStoreAccountInfoDAO.updateStatus(id, CloseStoreAccountStatusEnum.CLOSED.getStatus());
|
||||
verifyAndUpdateStage(accountInfo.getCloseStoreId());
|
||||
return true;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.cool.store.service.close.impl;
|
||||
|
||||
import com.cool.store.entity.CloseStoreInfoDO;
|
||||
import com.cool.store.entity.StoreDO;
|
||||
import com.cool.store.request.huoma.AccountCloseRequest;
|
||||
import com.cool.store.service.HuoMaService;
|
||||
@@ -25,8 +26,8 @@ public class HuomaAccountClose extends AbstractAccountClose {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean accountClose(String storeId) {
|
||||
StoreDO storeDO = getStore(storeId);
|
||||
public Boolean accountClose(CloseStoreInfoDO closeStoreInfoDO) {
|
||||
StoreDO storeDO = getStore(closeStoreInfoDO.getStoreId());
|
||||
AccountCloseRequest request = new AccountCloseRequest();
|
||||
request.setShop_sn(storeDO.getStoreNum());
|
||||
request.setEnable(0);
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.cool.store.service.close.impl;
|
||||
|
||||
import com.cool.store.entity.CloseStoreInfoDO;
|
||||
import com.cool.store.entity.StoreDO;
|
||||
import com.cool.store.enums.master.StoreCloseReasonEnum;
|
||||
import com.cool.store.request.xgj.XgjAccountCloseRequest;
|
||||
import com.cool.store.service.ThirdXgjService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -28,10 +30,11 @@ public class XinguanjiaAccountClose extends AbstractAccountClose {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean accountClose(String storeId) {
|
||||
StoreDO storeDO = getStore(storeId);
|
||||
public Boolean accountClose(CloseStoreInfoDO closeStoreInfoDO) {
|
||||
StoreDO storeDO = getStore(closeStoreInfoDO.getStoreId());
|
||||
String closeTime = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
||||
thirdXgjService.accountClose(new XgjAccountCloseRequest(storeDO.getStoreNum(), closeTime));
|
||||
String closeReason = StoreCloseReasonEnum.getDescByCode(closeStoreInfoDO.getCloseReason());
|
||||
thirdXgjService.accountClose(new XgjAccountCloseRequest(storeDO.getStoreNum(), closeTime, closeReason));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.cool.store.service.impl;
|
||||
|
||||
import com.cool.store.context.CurrentUserHolder;
|
||||
import com.cool.store.context.LoginUserInfo;
|
||||
import com.cool.store.dao.*;
|
||||
import com.cool.store.dto.DeskStageDTO;
|
||||
@@ -381,6 +382,13 @@ public class DeskServiceImpl implements DeskService {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageInfo<PreparationCommonPendingVO> xinFaFillNumPendingList(DeskRequest deskRequest, LoginUserInfo user) {
|
||||
return commonPendingVOPageInfo(deskRequest, CurrentUserHolder.getUser(), ShopSubStageEnum.SHOP_STAGE_23,
|
||||
Collections.singletonList(ShopSubStageStatusEnum.SHOP_SUB_STAGE_STATUS_233.getShopSubStageStatus()), Boolean.TRUE);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageInfo<PreparationCommonPendingVO> posListPendingList(DeskRequest deskRequest, LoginUserInfo user) {
|
||||
|
||||
|
||||
@@ -2,7 +2,12 @@ package com.cool.store.service.impl;
|
||||
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.aliyun.core.utils.StringUtils;
|
||||
import com.cool.store.dao.*;
|
||||
import com.cool.store.dto.huoma.CreatePointDTO;
|
||||
import com.cool.store.dto.huoma.CreatePointResponseDTO;
|
||||
import com.cool.store.dto.huoma.CreateTerminalDTO;
|
||||
import com.cool.store.dto.huoma.CreateTerminalResponseDTO;
|
||||
import com.cool.store.entity.LineInfoDO;
|
||||
import com.cool.store.entity.PosAndOrderInfoDO;
|
||||
import com.cool.store.entity.ShopInfoDO;
|
||||
@@ -16,17 +21,16 @@ import com.cool.store.request.PostAndOrderRequest;
|
||||
import com.cool.store.request.xgj.UpdateTrainCompleteRequest;
|
||||
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 com.cool.store.service.PushService;
|
||||
import com.cool.store.service.xinfa.XinFaDeviceService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Date;
|
||||
import java.util.Objects;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author EDY
|
||||
@@ -50,6 +54,9 @@ public class PosAndOrderInfoServiceImpl implements PosAndOrderInfoService {
|
||||
private PreparationService preparationService;
|
||||
@Resource
|
||||
PushService pushService;
|
||||
@Resource
|
||||
private XinFaDeviceService xinFaDeviceService;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Integer submitOrUpdate(PostAndOrderRequest request, String user) {
|
||||
@@ -82,6 +89,14 @@ public class PosAndOrderInfoServiceImpl implements PosAndOrderInfoService {
|
||||
}
|
||||
shopStageInfoDAO.updateShopStageInfo(request.getShopId(), subStageStatus);
|
||||
} else if (request.getType().equals(PosAndOrderEnum.XIN_FA_SYS.getCode())) {
|
||||
ShopStageInfoDO stageInfo = shopStageInfoDAO.getShopSubStageInfo(request.getShopId(), ShopSubStageEnum.SHOP_STAGE_23);
|
||||
if (stageInfo.getShopSubStageStatus().equals(ShopSubStageStatusEnum.SHOP_SUB_STAGE_STATUS_233.getShopSubStageStatus())) {
|
||||
// 自动创建信发设备
|
||||
JSONObject jsonObject = JSONObject.parseObject(request.getPassword());
|
||||
Integer tvNum = jsonObject.getInteger("tvNum");
|
||||
Integer adNum = jsonObject.getInteger("adNum");
|
||||
autoCreateXinfaDevice(request.getShopId(), tvNum, adNum);
|
||||
}
|
||||
shopStageInfoDAO.updateShopStageInfo(request.getShopId(), ShopSubStageStatusEnum.SHOP_SUB_STAGE_STATUS_235);
|
||||
} else if (request.getType().equals(PosAndOrderEnum.TENT_PASS.getCode())) {
|
||||
shopStageInfoDAO.updateShopStageInfo(request.getShopId(), ShopSubStageStatusEnum.SHOP_SUB_STAGE_STATUS_245);
|
||||
@@ -93,6 +108,68 @@ public class PosAndOrderInfoServiceImpl implements PosAndOrderInfoService {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 自动创建网点及设备
|
||||
* @param shopId 门店id
|
||||
* @param tvNum 电视机数量
|
||||
* @param adNum 广告机数量
|
||||
*/
|
||||
private void autoCreateXinfaDevice(Long shopId, Integer tvNum, Integer adNum) {
|
||||
if ((Objects.isNull(tvNum) || tvNum == 0) && (Objects.isNull(adNum) || adNum == 0)) {
|
||||
log.info("无广告机或电视机");
|
||||
return;
|
||||
}
|
||||
if (tvNum > 5 || adNum > 5) {
|
||||
throw new ServiceException(ErrorCodeEnum.XIN_FA_DEVICE_NUM_LIMIT);
|
||||
}
|
||||
ShopInfoDO shopInfo = shopInfoDAO.getShopInfo(shopId);
|
||||
if (Objects.isNull(shopInfo)) {
|
||||
throw new ServiceException(ErrorCodeEnum.STORE_NOT_FIND);
|
||||
}
|
||||
if (StringUtils.isBlank(shopInfo.getShopCode())) {
|
||||
throw new ServiceException(ErrorCodeEnum.STORE_NUM_NOT_FOUND);
|
||||
}
|
||||
log.info("创建网点, shopId:{}", shopInfo.getId());
|
||||
// 创建网点
|
||||
CreatePointDTO createPointDTO = new CreatePointDTO(shopInfo.getShopCode(), shopInfo.getShopName());
|
||||
CreatePointResponseDTO pointResponse = xinFaDeviceService.createPoint(createPointDTO);
|
||||
if (pointResponse == null || pointResponse.getId() == null) {
|
||||
throw new ServiceException(ErrorCodeEnum.THIRD_API_ERROR, "创建网点失败");
|
||||
}
|
||||
Integer pointId = pointResponse.getId();
|
||||
log.info("创建设备");
|
||||
// 创建设备
|
||||
int successCount = 0;
|
||||
int failCount = 0;
|
||||
for (int i = 1; i <= tvNum + adNum; i++) {
|
||||
boolean isAdMachine = i > tvNum;
|
||||
String deviceName = CreateTerminalDTO.buildDeviceName(shopInfo.getShopName(), i, isAdMachine);
|
||||
try {
|
||||
CreateTerminalDTO terminalDTO = CreateTerminalDTO.of(pointId, shopInfo.getShopName(), shopInfo.getShopCode(), i, isAdMachine);
|
||||
CreateTerminalResponseDTO terminalResponse = xinFaDeviceService.createTerminal(terminalDTO);
|
||||
if (Objects.nonNull(terminalResponse)) {
|
||||
successCount++;
|
||||
log.info("创建设备成功,门店:{},设备名称:{},设备ID:{}",
|
||||
shopInfo.getShopName(), deviceName, terminalResponse.getId());
|
||||
} else {
|
||||
failCount++;
|
||||
log.error("设备{}创建失败:接口返回空", deviceName);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
failCount++;
|
||||
log.error("设备{}创建失败", deviceName, e);
|
||||
}
|
||||
}
|
||||
|
||||
// 如果没有成功,抛出异常
|
||||
if (successCount == 0) {
|
||||
throw new ServiceException(ErrorCodeEnum.CREATE_XIN_FA_DEVICE_ERROR);
|
||||
}
|
||||
log.info("自动创建网点及设备完成,shopId:{},网点ID:{},成功创建{}台设备,失败{}台设备",
|
||||
shopInfo.getId(), pointId, successCount, failCount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PosAndOrderResponse get(Long shopId, Integer type) {
|
||||
PosAndOrderResponse response = new PosAndOrderResponse();
|
||||
|
||||
@@ -60,6 +60,8 @@ public class PreparationServiceImpl implements PreparationService {
|
||||
private AcceptanceInfoDAO acceptanceInfoDAO;
|
||||
@Resource
|
||||
private DecorationService decorationService;
|
||||
@Resource
|
||||
private StoreDao storeDao;
|
||||
|
||||
@Override
|
||||
public PageInfo<PreparationScheduleVO> getPreparationSchedule(PreparationRequest request) {
|
||||
@@ -223,7 +225,13 @@ public class PreparationServiceImpl implements PreparationService {
|
||||
List<ShopSubStageStatusEnum> list = new ArrayList<>();
|
||||
list.add(ShopSubStageStatusEnum.SHOP_SUB_STAGE_STATUS_160);
|
||||
list.add(ShopSubStageStatusEnum.SHOP_SUB_STAGE_STATUS_170);
|
||||
list.add(ShopSubStageStatusEnum.SHOP_SUB_STAGE_STATUS_230);
|
||||
ShopInfoDO shopInfo = shopInfoDAO.getShopInfo(shopId);
|
||||
// 正新鸡排走自动创建信发流程
|
||||
if (String.valueOf(FranchiseBrandEnum.ZXJP.getCode()).equals(shopInfo.getFranchiseBrand())) {
|
||||
list.add(ShopSubStageStatusEnum.SHOP_SUB_STAGE_STATUS_233);
|
||||
} else {
|
||||
list.add(ShopSubStageStatusEnum.SHOP_SUB_STAGE_STATUS_230);
|
||||
}
|
||||
shopStageInfoDAO.batchUpdateShopStageStatus(shopId, list);
|
||||
}
|
||||
}
|
||||
@@ -292,11 +300,19 @@ public class PreparationServiceImpl implements PreparationService {
|
||||
public void updateShopStatus(Long shopId) {
|
||||
ShopInfoDO shopInfo = shopInfoDAO.getShopInfo(shopId);
|
||||
if (shopInfo.getShopStatus().equals(ShopStatusEnum.ING.getCode())) {
|
||||
ScheduleDTO scheduleAll = shopStageInfoDAO.getScheduleAll(shopId);
|
||||
// 20260520门店状态判断排除食安阶段
|
||||
ScheduleDTO scheduleAll = shopStageInfoDAO.getScheduleAllExcludeFoodLicense(shopId);
|
||||
ShopInfoDO shopInfoDO = new ShopInfoDO();
|
||||
if (scheduleAll.getTotalColumn().equals(scheduleAll.getCompletionColumn())) {
|
||||
shopInfoDO.setShopStatus(ShopStatusEnum.DONE.getCode());
|
||||
}
|
||||
if (shopInfoDO.getShopStatus() == ShopStatusEnum.DONE.getCode()) {
|
||||
// 更新门店开店流程完成时间
|
||||
StoreDO store = storeDao.getByStoreNum(shopInfo.getShopCode());
|
||||
if (Objects.nonNull(store)) {
|
||||
storeDao.insertOrUpdateOpenReportTime(store.getStoreId(), new Date());
|
||||
}
|
||||
}
|
||||
shopInfoDO.setUpdateTime(new Date());
|
||||
shopInfoDO.setId(shopId);
|
||||
shopInfoDAO.updateShopInfo(shopInfoDO);
|
||||
|
||||
@@ -609,8 +609,8 @@ public class ShopServiceImpl implements ShopService {
|
||||
if (Objects.isNull(shopInfo)) {
|
||||
throw new ServiceException(ErrorCodeEnum.PARAMS_VALIDATE_ERROR);
|
||||
}
|
||||
Integer completionCount = shopStageInfoDAO.getCompletionCount(shopId);
|
||||
if (completionCount.equals(ShopSubStageEnum.getTotalStageIsLocationAndPreparation(shopInfo.getUseStandardStore()))) {
|
||||
ScheduleDTO scheduleAll = shopStageInfoDAO.getScheduleAllExcludeFoodLicense(shopId);
|
||||
if (scheduleAll.getTotalColumn().equals(scheduleAll.getCompletionColumn())) {
|
||||
shopInfo.setShopStatus(ShopStatusEnum.DONE.getCode());
|
||||
} else {
|
||||
shopInfo.setShopStatus(ShopStatusEnum.ING.getCode());
|
||||
@@ -1017,6 +1017,8 @@ public class ShopServiceImpl implements ShopService {
|
||||
|
||||
case SHOP_SUB_STAGE_STATUS_230:
|
||||
return getUsersByRoleAndRegion(UserRoleEnum.XIN_FA_SYS_CUSTOMER, shopInfo.getRegionId());
|
||||
case SHOP_SUB_STAGE_STATUS_233:
|
||||
return getUsersByRoleAndRegion(UserRoleEnum.INVESTMENT_MANGER, shopInfo.getRegionId());
|
||||
|
||||
case SHOP_SUB_STAGE_STATUS_240:
|
||||
return getUsersByRoleAndRegion(UserRoleEnum.TENT_PASS_CUSTOMER, shopInfo.getRegionId());
|
||||
|
||||
@@ -1,10 +1,14 @@
|
||||
package com.cool.store.service.impl.xinfa;
|
||||
|
||||
import com.cool.store.dao.ShopInfoDAO;
|
||||
import com.cool.store.dao.StoreDao;
|
||||
import com.cool.store.dto.huoma.*;
|
||||
import com.cool.store.entity.ShopInfoDO;
|
||||
import com.cool.store.entity.StoreDO;
|
||||
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.request.huoma.XinfaTerminalCreateRequest;
|
||||
import com.cool.store.service.xinfa.XinFaBusinessService;
|
||||
import com.cool.store.service.xinfa.XinFaDeviceService;
|
||||
import com.cool.store.utils.poi.StringUtils;
|
||||
@@ -12,10 +16,7 @@ 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.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@@ -27,6 +28,10 @@ import java.util.stream.Collectors;
|
||||
public class XinFaBusinessServiceImpl implements XinFaBusinessService {
|
||||
@Resource
|
||||
XinFaDeviceService xinFaDeviceService;
|
||||
@Resource
|
||||
StoreDao storeDao;
|
||||
@Resource
|
||||
ShopInfoDAO shopInfoDAO;
|
||||
|
||||
@Override
|
||||
public List<StoreXinFaDeviceDetail> getStoreXinFaDeviceDetail(String storeNum) {
|
||||
@@ -36,6 +41,28 @@ public class XinFaBusinessServiceImpl implements XinFaBusinessService {
|
||||
return xinFaDeviceService.getStoreXinFaDeviceDetail(storeNum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<StoreXinFaDeviceDetail> getStoreXinFaDeviceDetailByStoreId(String storeId, Long shopId) {
|
||||
if (StringUtils.isBlank(storeId) && Objects.isNull(shopId)) {
|
||||
throw new ServiceException(ErrorCodeEnum.PARAMS_VALIDATE_ERROR);
|
||||
}
|
||||
String storeNum;
|
||||
if (StringUtils.isNotBlank(storeId)) {
|
||||
StoreDO storeDO = storeDao.getEffectiveByStoreId(storeId);
|
||||
if (Objects.isNull(storeDO)) {
|
||||
throw new ServiceException(ErrorCodeEnum.STORE_NOT_FIND);
|
||||
}
|
||||
storeNum = storeDO.getStoreNum();
|
||||
} else {
|
||||
ShopInfoDO shopInfo = shopInfoDAO.getShopInfo(shopId);
|
||||
if (Objects.isNull(shopInfo)) {
|
||||
throw new ServiceException(ErrorCodeEnum.STORE_NOT_FIND);
|
||||
}
|
||||
storeNum = shopInfo.getShopCode();
|
||||
}
|
||||
return getStoreXinFaDeviceDetail(storeNum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TagDetailDTO> getAccountAllTags(String storeNum,String deviceName) {
|
||||
//如果是广告机,不需要展示标签
|
||||
@@ -70,4 +97,35 @@ public class XinFaBusinessServiceImpl implements XinFaBusinessService {
|
||||
public Boolean publishProgram(PublishDTO publishDTO) {
|
||||
return xinFaDeviceService.publish(publishDTO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public XinfaPointInfoDTO getPointInfo(String storeNum) {
|
||||
if (StringUtils.isEmpty(storeNum)) {
|
||||
throw new ServiceException(ErrorCodeEnum.PARAMS_VALIDATE_ERROR);
|
||||
}
|
||||
return xinFaDeviceService.getPointInfo(storeNum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean createTerminal(XinfaTerminalCreateRequest request) {
|
||||
StoreDO storeDO = storeDao.getEffectiveByStoreId(request.getStoreId());
|
||||
if (Objects.isNull(storeDO)) {
|
||||
throw new ServiceException(ErrorCodeEnum.STORE_NOT_FIND);
|
||||
}
|
||||
XinfaPointInfoDTO pointInfo = xinFaDeviceService.getPointInfo(storeDO.getStoreNum());
|
||||
Integer pointId;
|
||||
if (Objects.nonNull(pointInfo)) {
|
||||
pointId = pointInfo.getId();
|
||||
} else {
|
||||
CreatePointDTO createPointDTO = new CreatePointDTO(storeDO.getStoreNum(), storeDO.getStoreName());
|
||||
CreatePointResponseDTO point = xinFaDeviceService.createPoint(createPointDTO);
|
||||
if (Objects.isNull(point)) {
|
||||
throw new ServiceException(ErrorCodeEnum.THIRD_API_ERROR, "创建网点失败");
|
||||
}
|
||||
pointId = point.getId();
|
||||
}
|
||||
CreateTerminalDTO createTerminalDTO = CreateTerminalDTO.of(pointId, request.getName(), request.getCode());
|
||||
CreateTerminalResponseDTO terminal = xinFaDeviceService.createTerminal(createTerminalDTO);
|
||||
return Objects.nonNull(terminal);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
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 com.cool.store.request.huoma.XinfaTerminalCreateRequest;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -21,6 +20,8 @@ public interface XinFaBusinessService {
|
||||
*/
|
||||
List<StoreXinFaDeviceDetail> getStoreXinFaDeviceDetail(String storeNum);
|
||||
|
||||
List<StoreXinFaDeviceDetail> getStoreXinFaDeviceDetailByStoreId(String storeId, Long shopId);
|
||||
|
||||
/**
|
||||
* 获取账号下有哪些标签
|
||||
* @param storeNum
|
||||
@@ -43,6 +44,13 @@ public interface XinFaBusinessService {
|
||||
*/
|
||||
Boolean publishProgram(PublishDTO publishDTO);
|
||||
|
||||
/**
|
||||
* 获取门店网点信息
|
||||
*/
|
||||
XinfaPointInfoDTO getPointInfo(String storeNum);
|
||||
|
||||
|
||||
/**
|
||||
* 新增信发设备
|
||||
*/
|
||||
Boolean createTerminal(XinfaTerminalCreateRequest request);
|
||||
}
|
||||
|
||||
@@ -4,11 +4,10 @@ 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.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -18,7 +17,6 @@ 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;
|
||||
@@ -66,6 +64,10 @@ public class XinFaDeviceService {
|
||||
private String huoMaGetProgramUrl;
|
||||
@Value("${huoMa.get.publish.url}")
|
||||
private String huoMaGetPublishUrl;
|
||||
@Value("${huoMa.create.point.url}")
|
||||
private String huoMaCreatePointUrl;
|
||||
@Value("${huoMa.create.terminal.url}")
|
||||
private String huoMaCreateTerminalUrl;
|
||||
|
||||
|
||||
private final Map<String, HuoMaAccountDTO> accountMap = new HashMap<>();
|
||||
@@ -295,8 +297,138 @@ public class XinFaDeviceService {
|
||||
return Boolean.FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建网点
|
||||
* 使用 huoMa.franchise.stores.account 账号的token
|
||||
* @param createPointDTO 创建网点请求参数
|
||||
* @return 创建网点响应
|
||||
*/
|
||||
public CreatePointResponseDTO createPoint(CreatePointDTO createPointDTO) {
|
||||
String token = getFranchiseStoresToken();
|
||||
if (StringUtils.isEmpty(token)) {
|
||||
log.error("获取franchise账号token失败");
|
||||
return null;
|
||||
}
|
||||
String responseBody = null;
|
||||
try {
|
||||
responseBody = sendPostRequestNoRetryByToken(JSONObject.toJSONString(createPointDTO), huoMaCreatePointUrl, token);
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
JsonNode rootNode = mapper.readTree(responseBody);
|
||||
int code = rootNode.get("code").asInt();
|
||||
if (code != 0) {
|
||||
String msg = rootNode.path("msg").asText("");
|
||||
log.error("创建网点失败, code:{}, msg:{}", code, msg);
|
||||
throw new ServiceException(ErrorCodeEnum.THIRD_API_ERROR, msg);
|
||||
}
|
||||
return mapper.convertValue(rootNode.get("data"), CreatePointResponseDTO.class);
|
||||
} catch (JsonProcessingException e) {
|
||||
throw new ServiceException(ErrorCodeEnum.THIRD_API_ERROR, e.getMessage());
|
||||
} catch (Exception e) {
|
||||
log.error("创建网点失败, url:{}, responseBody:{}, exception:{}", huoMaCreatePointUrl, responseBody, e.getMessage());
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 设备创建
|
||||
* 使用 huoMa.franchise.stores.account 号的token
|
||||
* @param createTerminalDTO 设备创建请求参数
|
||||
* @return 设备创建响应
|
||||
*/
|
||||
public CreateTerminalResponseDTO createTerminal(CreateTerminalDTO createTerminalDTO) {
|
||||
String token = getFranchiseStoresToken();
|
||||
if (StringUtils.isEmpty(token)) {
|
||||
log.error("获取franchise账号token失败");
|
||||
return null;
|
||||
}
|
||||
String responseBody = null;
|
||||
try {
|
||||
responseBody = sendPostRequestNoRetryByToken(JSONObject.toJSONString(createTerminalDTO), huoMaCreateTerminalUrl, token);
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
JsonNode rootNode = mapper.readTree(responseBody);
|
||||
int code = rootNode.get("code").asInt();
|
||||
if (code != 0) {
|
||||
String msg = rootNode.path("msg").asText("");
|
||||
log.error("设备创建失败, code:{}, msg:{}", code, msg);
|
||||
throw new ServiceException(ErrorCodeEnum.THIRD_API_ERROR, msg);
|
||||
}
|
||||
return mapper.convertValue(rootNode.get("data"), CreateTerminalResponseDTO.class);
|
||||
} catch (JsonProcessingException e) {
|
||||
throw new ServiceException(ErrorCodeEnum.THIRD_API_ERROR, e.getMessage());
|
||||
} catch (Exception e) {
|
||||
log.error("设备创建失败, url:{}, responseBody:{}, exception:{}", huoMaCreateTerminalUrl, responseBody, e.getMessage());
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取门店网点信息
|
||||
*/
|
||||
public XinfaPointInfoDTO getPointInfo(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());
|
||||
XinfaPointInfoDTO pointInfo = getPointInfoByStoreNum(storeNum, token);
|
||||
if (Objects.nonNull(pointInfo)) {
|
||||
return pointInfo;
|
||||
}else {
|
||||
//如果在该账号下没有数据 清除缓存
|
||||
redisUtilPool.hashDel(RedisConstant.HUOMA_STORE_DEVICE_RESOURCE_KEY, storeNum);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (Map.Entry<String, HuoMaAccountDTO> entry : accountMap.entrySet()) {
|
||||
HuoMaAccountDTO huoMaAccountDTO = entry.getValue();
|
||||
String token = getStoreToken(huoMaAccountDTO.getAccount(), huoMaAccountDTO.getPassword());
|
||||
XinfaPointInfoDTO pointInfo = getPointInfoByStoreNum(storeNum, token);
|
||||
if (Objects.nonNull(pointInfo)) {
|
||||
redisUtilPool.hashSet(RedisConstant.HUOMA_STORE_DEVICE_RESOURCE_KEY, storeNum, entry.getKey(), Constants.REFRESH_TOKEN_EXPIRE);
|
||||
return pointInfo;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取门店网点信息
|
||||
* @param storeNum 门店编码
|
||||
* @param token token
|
||||
* @return 网点信息
|
||||
*/
|
||||
private XinfaPointInfoDTO getPointInfoByStoreNum(String storeNum, String token) {
|
||||
StoreRequestDTO requestBody = new StoreRequestDTO("point_report", 0, 10, storeNum);
|
||||
String responseBody = null;
|
||||
try {
|
||||
responseBody = sendPostRequestNoRetryByToken(JSONObject.toJSONString(requestBody), huoMaGetStoreIdUrl,token);
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
JsonNode rootNode = mapper.readTree(responseBody);
|
||||
int code = rootNode.get("code").asInt();
|
||||
if (code != 0) {
|
||||
String msg = rootNode.path("msg").asText("");
|
||||
throw new ServiceException(ErrorCodeEnum.THIRD_API_ERROR, msg);
|
||||
}
|
||||
JsonNode dataList = rootNode.get("data").path("dataList");
|
||||
if (Objects.nonNull(dataList) && !dataList.isEmpty()) {
|
||||
return mapper.convertValue(dataList.get(0), XinfaPointInfoDTO.class);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("网点信息获取失败, url:{}, responseBody:{}, exception:{}", huoMaGetStoreIdUrl, responseBody, e.getMessage());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取franchise账号的token
|
||||
* @return token
|
||||
*/
|
||||
private String getFranchiseStoresToken() {
|
||||
return getStoreToken(huoMaFranchiseStoresAccount, huoMaFranchiseStoresPassword);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public List<StoreXinFaDeviceDetail> getStoreXinFaDeviceDetailByPointId(String storeNum,Integer pointId, String token) {
|
||||
if (pointId != null){
|
||||
StoreXinFaDetailRequestDTO storeXinFaDetailRequestDTO = new StoreXinFaDetailRequestDTO(0, 10, pointId);
|
||||
|
||||
Reference in New Issue
Block a user