Merge #91 into master from cc_20230331_device

feat:添加阶段状态

* cc_20230331_device: (21 commits squashed)

  - feat:添加采购审批

  - Merge branch 'master' into cc_20230331_device

  - feat:设备发货阶段

  - feat:设备发货

  - feat:设备发货

  - feat:接口调整

  - feat:接口调整

  - feat:接口调整

  - feat:接口调整

  - feat:接口调整

  - feat:接口调整

  - feat:接口调整

  - feat:接口调整

  - feat:查询订单设备明细

  - feat:测试

  - feat:短信模板切换

  - feat:getPendingList

  - feat:代办调整

  - feat:处理人

  - feat:添加阶段状态

  - Merge branch 'master' into cc_20230331_device
    
    # Conflicts:
    #	coolstore-partner-service/src/main/java/com/cool/store/service/order/impl/MiniStoreOrderServiceImpl.java
    #	coolstore-partner-web/src/main/java/com/cool/store/controller/webc/TestController.java

Signed-off-by: 正新 <accounts_6964c7bcd2a2c377c5bbd01b@mail.teambition.com>
Merged-by: 正新 <accounts_6964c7bcd2a2c377c5bbd01b@mail.teambition.com>

CR-link: https://codeup.aliyun.com/692ea314dec569489f6f167c/hangzhou/java/custom_zxjp/change/91
This commit is contained in:
正新
2026-04-12 09:16:48 +00:00
parent 77ca18b6fc
commit 1a77d8fc37
48 changed files with 1874 additions and 106 deletions

View File

@@ -235,4 +235,7 @@ public interface DeskService {
*/
PageInfo<OperationsConsultantAssignVO> assignPendingList(AssignPendingRequest request,LoginUserInfo user);
PageInfo<DeliveryPendingVO> deliveryPendingList(AssignPendingRequest request,LoginUserInfo user);
}

View File

@@ -7,6 +7,7 @@ import com.cool.store.request.FranchiseReportRequest;
import com.cool.store.request.order.PCStoreOrderQueryRequest;
import com.cool.store.request.visit.VisitRecordQueryRequest;
import com.cool.store.request.PointPageRequest;
import com.cool.store.request.visit.VisitRecordQueryRequest;
import com.cool.store.response.BranchShopResponse;
import com.cool.store.response.FranchiseReportResponse;
import com.cool.store.response.ShopReportResponse;
@@ -14,10 +15,10 @@ import com.cool.store.response.ShopReportResponse;
import java.util.List;
/**
* @Author: WangShuo
* @Date: 2024/10/29/下午1:57
* @Version 1.0
* @注释:
* @Author: WangShuo
* @Date: 2024/10/29/下午1:57
* @Version 1.0
* @注释:
*/
public interface ExportRealizeService {
@@ -43,6 +44,12 @@ public interface ExportRealizeService {
void exportOrderRecord(PCStoreOrderQueryRequest request, ImportTaskDO importTaskDO);
void exportPoint(AllPointPageRequest request, ImportTaskDO importTaskDO);
void myExportPoint(PointPageRequest request, String userId, ImportTaskDO importTaskDO);
/**
* 导出订单设备明细
* @param orderId 订单ID
* @param importTaskDO 导出任务
*/
void exportOrderDeviceDetail(Long orderId, ImportTaskDO importTaskDO);
}

View File

@@ -77,4 +77,12 @@ public interface ExportService {
* @return 记录总数
*/
Long myPointExport(PointPageRequest request, LoginUserInfo user);
/**
* 订单设备明细导出
* @param orderId 订单ID
* @param user 当前用户
* @return 记录总数
*/
Long exportOrderDeviceDetail(Long orderId, LoginUserInfo user);
}

View File

@@ -7,10 +7,7 @@ import com.cool.store.dto.InvestmentCountDTO;
import com.cool.store.dto.PendingCountDTO;
import com.cool.store.dto.openPreparation.PlanLineDTO;
import com.cool.store.entity.*;
import com.cool.store.enums.ErrorCodeEnum;
import com.cool.store.enums.ShopAccountEnum;
import com.cool.store.enums.UserRoleEnum;
import com.cool.store.enums.WorkflowSubStageStatusEnum;
import com.cool.store.enums.*;
import com.cool.store.enums.point.PayBusinessTypeEnum;
import com.cool.store.enums.point.ShopSubStageEnum;
import com.cool.store.enums.point.ShopSubStageStatusEnum;
@@ -104,6 +101,8 @@ public class DeskServiceImpl implements DeskService {
OperationsConsultantAssignDAO operationsConsultantAssignDAO;
@Resource
private RegionDao regionDao;
@Resource
ShopDeliveryPlanDAO shopDeliveryPlanDAO;
@Override
public PageInfo<IntendPendingVO> intendPendingList(Integer pageNum, Integer pageSize, String userId, String keyword) {
@@ -848,6 +847,60 @@ public class DeskServiceImpl implements DeskService {
return page;
}
@Override
public PageInfo<DeliveryPendingVO> deliveryPendingList(AssignPendingRequest request,LoginUserInfo user) {
List<Long> userRoleIds = enterpriseUserRoleMapper.getUserRoleIds(user.getUserId());
List<Integer> subStageStatusList = new ArrayList<>();
Boolean isAdmin = sysRoleService.checkIsAdmin(user.getUserId());
Boolean flag = userRoleIds.contains(UserRoleEnum.DEVICE_SHIPMENT_HM.getCode()) && userRoleIds.contains(UserRoleEnum.DEVICE_SHIPMENT_CG.getCode());
if (isAdmin||flag){
//返回所有数据
List<DeliveryPendingVO> pendingList = shopDeliveryPlanDAO.getPendingList(request.getKeyword(), null);
return convert(pendingList);
}
Integer type = null;
//采购
if (userRoleIds.contains(UserRoleEnum.DEVICE_SHIPMENT_CG.getCode())){
type = DeliveryItemTypeEnum.PURCHASE_DEVICE.getCode();
}
//火码
if (userRoleIds.contains(UserRoleEnum.DEVICE_SHIPMENT_HM.getCode())){
type = DeliveryItemTypeEnum.FIRE_CODE_DEVICE.getCode();
}
if(type!=null){
List<DeliveryPendingVO> pendingList = shopDeliveryPlanDAO.getPendingList(request.getKeyword(), type);
return convert(pendingList);
}
return new PageInfo<>();
}
private PageInfo<DeliveryPendingVO> convert(List<DeliveryPendingVO> pendingList){
if (CollectionUtils.isEmpty(pendingList)){
return new PageInfo<>();
}
PageInfo<DeliveryPendingVO> result = new PageInfo<>(pendingList);
List<Long> lineIdList = pendingList.stream().map(DeliveryPendingVO::getLineId).collect(Collectors.toList());
List<LineInfoDO> lineInfoDOList = lineInfoDAO.getByLineIds(lineIdList);
Map<Long, String> lineMap = lineInfoDOList.stream().collect(Collectors.toMap(LineInfoDO::getId, LineInfoDO::getUsername));
List<Long> regionIds = pendingList.stream().filter(x->x.getRegionId()!=null).map(DeliveryPendingVO::getRegionId).collect(Collectors.toList());
List<Long> investRegionIds = pendingList.stream().filter(x->x.getInvestRegionId()!=null).map(DeliveryPendingVO::getRegionId).collect(Collectors.toList());
regionIds.addAll(investRegionIds);
Map<Long, String> regionNameMap = regionDao.getRegionNameMap(regionIds);
List<Long> shopIdList = pendingList.stream().map(DeliveryPendingVO::getShopId).collect(Collectors.toList());
List<ShopStageInfoDO> stageByShopSubStage = shopStageInfoDAO.getStageByShopSubStage(shopIdList, ShopSubStageEnum.SHOP_STAGE_29.getShopSubStage());
Map<Long, Integer> stageStatusMap = stageByShopSubStage.stream().collect(Collectors.toMap(ShopStageInfoDO::getShopId, ShopStageInfoDO::getShopSubStageStatus));
result.getList().stream().forEach(x->{
x.setPartnerName(lineMap.get(x.getLineId()));
x.setRegionName(regionNameMap.get(x.getRegionId()));
x.setInvestRegionName(regionNameMap.get(x.getInvestRegionId()));
x.setSubStageStatus(stageStatusMap.get(x.getShopId()));
});
return result;
}
/**
* 通用查询

View File

@@ -33,6 +33,8 @@ import com.cool.store.utils.easyExcel.EasyExcelUtil;
import com.cool.store.utils.poi.DateUtils;
import com.cool.store.utils.poi.StringUtils;
import com.cool.store.vo.order.OrderDeviceDetailExportVO;
import com.cool.store.vo.order.OrderDeviceDetailVO;
import com.cool.store.vo.order.PCStoreOrderListVO;
import com.cool.store.vo.visit.VisitRecordListVO;
import com.cool.store.vo.point.PointExportVO;
@@ -856,6 +858,29 @@ public class ExportRealizeServiceImpl implements ExportRealizeService {
return o.toString();
}
@Override
@Async("generalThreadPool")
public void exportOrderDeviceDetail(Long orderId, ImportTaskDO importTaskDO) {
String url = "";
try {
List<OrderDeviceDetailVO> list = miniStoreOrderService.queryOrderDeviceDetailByOrderId(orderId);
if (CollectionUtils.isEmpty(list)) {
throw new ServiceException("订单设备明细数据为空");
}
List<OrderDeviceDetailExportVO> exportList = OrderDeviceDetailExportVO.convert(list);
url = easyExcelUtil.exportExcel(OrderDeviceDetailExportVO.class, exportList, null,
FileTypeEnum.ORDER_DEVICE_DETAIL_EXPORT.getDesc() + DateUtils.parseDateToStr(SPECIAL_DATE_START_1, new Date()),
FileTypeEnum.ORDER_DEVICE_DETAIL_EXPORT.getDesc() + DateUtils.parseDateToStr(SPECIAL_DATE_START_1, new Date()));
importTaskDO.setStatus(ImportStatusEnum.success.getCode());
importTaskDO.setFileUrl(url);
} catch (Exception e) {
log.error("订单设备明细导出失败", e);
importTaskDO.setStatus(ImportStatusEnum.fail.getCode());
} finally {
importTaskMapper.update(eid, importTaskDO);
}
}
private List<Date> JsonToDate(String json) {
if (StringUtils.isBlank(json)) {
return new ArrayList<>();

View File

@@ -334,5 +334,20 @@ public class ExportServiceImpl implements ExportService {
return count;
}
@Override
public Long exportOrderDeviceDetail(Long orderId, LoginUserInfo user) {
ImportTaskDO importTaskDO = new ImportTaskDO();
importTaskDO.setStatus(ImportStatusEnum.Ongoing.getCode());
importTaskDO.setFileName(FileTypeEnum.ORDER_DEVICE_DETAIL_EXPORT.getDesc() + DateUtils.parseDateToStr(DateUtils.SPECIAL_DATE_START_1, new Date()));
importTaskDO.setIsImport(Boolean.FALSE);
importTaskDO.setFileType(FileTypeEnum.ORDER_DEVICE_DETAIL_EXPORT.getFileType());
importTaskDO.setCreateUserId(user.getUserId());
importTaskDO.setCreateTime(new Date().getTime());
importTaskDO.setCreateName(user.getName());
importTaskMapper.insert(eid, importTaskDO);
exportRealizeService.exportOrderDeviceDetail(orderId, importTaskDO);
return 1L;
}
}

View File

@@ -206,6 +206,7 @@ public class PreparationServiceImpl implements PreparationService {
list.add(ShopSubStageStatusEnum.SHOP_SUB_STAGE_STATUS_85_1);
list.add(ShopSubStageStatusEnum.SHOP_SUB_STAGE_STATUS_140);
list.add(ShopSubStageStatusEnum.SHOP_SUB_STAGE_STATUS_150);
list.add(ShopSubStageStatusEnum.SHOP_SUB_STAGE_STATUS_290);
shopStageInfoDAO.batchUpdateShopStageStatus(shopId, list);
}
}

View File

@@ -1037,6 +1037,8 @@ public class ShopServiceImpl implements ShopService {
return getUsersByRoleAndRegion(ORDER_GROUP, shopInfo.getRegionId());
case SHOP_SUB_STAGE_STATUS_281:
return getUsersByRole(AI_STORE_TYPE_APPROVE);
case SHOP_SUB_STAGE_STATUS_281_2:
return getUsersByRole(DEVICE_SHIPMENT_CG);
default:
return Collections.emptyList();
}

View File

@@ -8,6 +8,7 @@ import com.cool.store.vo.order.MiniStoreOrderDetailVO;
import com.cool.store.vo.order.MiniStoreOrderListVO;
import com.cool.store.vo.order.MiniStoreWishlistDetailVO;
import com.cool.store.vo.order.MiniStoreWishlistListVO;
import com.cool.store.vo.order.OrderDeviceDetailVO;
import com.cool.store.vo.order.PCStoreOrderListVO;
import com.cool.store.vo.order.WalletPayVO;
import com.github.pagehelper.PageInfo;
@@ -29,9 +30,9 @@ public interface MiniStoreOrderService {
Long updateOrder(MiniStoreOrderUpdateRequest request,PartnerUserInfoVO user);
Boolean withdraw(Long orderId);
Boolean cancel(Long orderId);
// Boolean withdraw(Long orderId);
//
// Boolean cancel(Long orderId);
PageInfo<MiniStoreOrderListVO> queryPageByLineId(MiniStoreOrderLineQueryRequest request);
@@ -68,4 +69,13 @@ public interface MiniStoreOrderService {
Boolean changeWishlist(ChangeWishlistRequest request);
List<OrderDeviceDetailVO> queryOrderDeviceDetailByShopId(Long shopId);
/**
* 查询订单设备明细
* @param orderId 订单ID
* @return 订单设备明细列表
*/
List<OrderDeviceDetailVO> queryOrderDeviceDetailByOrderId(Long orderId);
}

View File

@@ -63,12 +63,7 @@ import com.cool.store.vo.PartnerUserInfoVO;
import com.cool.store.vo.config.ConfigItemCategoryVO;
import com.cool.store.vo.config.ConfigItemVO;
import com.cool.store.vo.dict.DictColumnVO;
import com.cool.store.vo.order.MiniStoreOrderDetailVO;
import com.cool.store.vo.order.MiniStoreOrderListVO;
import com.cool.store.vo.order.MiniStoreWishlistDetailVO;
import com.cool.store.vo.order.MiniStoreWishlistListVO;
import com.cool.store.vo.order.PCStoreOrderListVO;
import com.cool.store.vo.order.WalletPayVO;
import com.cool.store.vo.order.*;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
@@ -590,6 +585,26 @@ public class MiniStoreOrderServiceImpl implements MiniStoreOrderService {
throw new ServiceException(ErrorCodeEnum.CURRENT_ORDER_NOT_SUPPORT);
}
if (WAIT_CONFIRM.getCode().equals(currentStatus)){
//修改订单状态
order.setStatus(DEVICE_CONFIRM.getCode());
storeOrderDAO.updateSelective(order);
//修改阶段数据
shopStageInfoDAO.updateShopStageInfo(order.getShopId(),ShopSubStageStatusEnum.SHOP_SUB_STAGE_STATUS_281_2);
//处理审批记录 通过
handleAudit(order.getShopId(),user,0,request.getRemark(),ShopSubStageStatusEnum.SHOP_SUB_STAGE_STATUS_281);
//下一级审批记录
SysRoleRequest sysRoleRequest = new SysRoleRequest();
sysRoleRequest.setRoleName(AI_STORE_TYPE_APPROVE.getDesc());
List<EnterpriseUserDO> userListByRole = userAuthMappingService.findUserListByRole(sysRoleRequest, false);
operationLogService.addOperationLog(order.getShopId(), ShopSubStageStatusEnum.SHOP_SUB_STAGE_STATUS_281_2,
user.getUserId(), userListByRole,
OperationTypeEnum.OPERATION_TYPE_1, "待采购设备确认", OperationStatusEnum.NOT_PROCESSED, 1);
}
if (DEVICE_CONFIRM.getCode().equals(currentStatus)){
//修改订单状态
order.setStatus(INVEST_MANAGER_CONFIRM.getCode());
storeOrderDAO.updateSelective(order);
@@ -598,7 +613,7 @@ public class MiniStoreOrderServiceImpl implements MiniStoreOrderService {
shopStageInfoDAO.updateShopStageInfo(order.getShopId(),ShopSubStageStatusEnum.SHOP_SUB_STAGE_STATUS_281_5);
//处理审批记录 通过
handleAudit(order.getShopId(),user,0,request.getRemark(),ShopSubStageStatusEnum.SHOP_SUB_STAGE_STATUS_281);
handleAudit(order.getShopId(),user,0,request.getRemark(),ShopSubStageStatusEnum.SHOP_SUB_STAGE_STATUS_281_2);
}
if (INVEST_MANAGER_CONFIRM.getCode().equals(currentStatus)){
@@ -878,65 +893,65 @@ public class MiniStoreOrderServiceImpl implements MiniStoreOrderService {
return order.getId();
}
@Override
@Transactional
public Boolean withdraw(Long orderId) {
if (orderId == null) {
throw new ServiceException(ErrorCodeEnum.PARAMS_VALIDATE_ERROR);
}
// 1. 查询订单
StoreOrderDO order = storeOrderDAO.getById(orderId);
if (order == null) {
throw new ServiceException(ErrorCodeEnum.STORE_ORDER_NOT_FOUND);
}
// 2. 校验状态:仅待确认(5)和待支付(15)状态允许撤回
Integer status = order.getStatus();
if (!StoreOrderStatusEnum.canWithdraw(status)) {
throw new ServiceException(ErrorCodeEnum.STORE_ORDER_WITHDRAW_FORBIDDEN);
}
// 3. 更新订单状态为草稿(0)
StoreOrderDO updateOrder = StoreOrderDO.builder()
.id(orderId)
.status(StoreOrderStatusEnum.DRAFT.getCode())
.updateTime(new Date())
.build();
shopStageInfoDAO.updateShopStageInfo(order.getShopId(),ShopSubStageStatusEnum.SHOP_SUB_STAGE_STATUS_280);
return storeOrderDAO.updateSelective(updateOrder);
}
@Override
@Transactional
public Boolean cancel(Long orderId) {
if (orderId == null) {
throw new ServiceException(ErrorCodeEnum.PARAMS_VALIDATE_ERROR);
}
// 1. 查询订单
StoreOrderDO order = storeOrderDAO.getById(orderId);
if (order == null) {
throw new ServiceException(ErrorCodeEnum.STORE_ORDER_NOT_FOUND);
}
// 2. 校验状态:仅草稿(0)状态允许作废
if (!StoreOrderStatusEnum.DRAFT.getCode().equals(order.getStatus())) {
throw new ServiceException(ErrorCodeEnum.STORE_ORDER_CANCEL_FORBIDDEN);
}
// 3. 更新订单状态为已结束(25)
StoreOrderDO updateOrder = StoreOrderDO.builder()
.id(orderId)
.status(StoreOrderStatusEnum.CLOSED.getCode()) // 已结束状态
.updateTime(new Date())
.build();
return storeOrderDAO.updateSelective(updateOrder);
}
// @Override
// @Transactional
// public Boolean withdraw(Long orderId) {
// if (orderId == null) {
// throw new ServiceException(ErrorCodeEnum.PARAMS_VALIDATE_ERROR);
// }
//
// // 1. 查询订单
// StoreOrderDO order = storeOrderDAO.getById(orderId);
// if (order == null) {
// throw new ServiceException(ErrorCodeEnum.STORE_ORDER_NOT_FOUND);
// }
//
// // 2. 校验状态:仅待确认(5)和待支付(15)状态允许撤回
// Integer status = order.getStatus();
// if (!StoreOrderStatusEnum.canWithdraw(status)) {
// throw new ServiceException(ErrorCodeEnum.STORE_ORDER_WITHDRAW_FORBIDDEN);
// }
//
// // 3. 更新订单状态为草稿(0)
// StoreOrderDO updateOrder = StoreOrderDO.builder()
// .id(orderId)
// .status(StoreOrderStatusEnum.DRAFT.getCode())
// .updateTime(new Date())
// .build();
//
// shopStageInfoDAO.updateShopStageInfo(order.getShopId(),ShopSubStageStatusEnum.SHOP_SUB_STAGE_STATUS_280);
//
// return storeOrderDAO.updateSelective(updateOrder);
// }
//
// @Override
// @Transactional
// public Boolean cancel(Long orderId) {
// if (orderId == null) {
// throw new ServiceException(ErrorCodeEnum.PARAMS_VALIDATE_ERROR);
// }
//
// // 1. 查询订单
// StoreOrderDO order = storeOrderDAO.getById(orderId);
// if (order == null) {
// throw new ServiceException(ErrorCodeEnum.STORE_ORDER_NOT_FOUND);
// }
//
// // 2. 校验状态:仅草稿(0)状态允许作废
// if (!StoreOrderStatusEnum.DRAFT.getCode().equals(order.getStatus())) {
// throw new ServiceException(ErrorCodeEnum.STORE_ORDER_CANCEL_FORBIDDEN);
// }
//
// // 3. 更新订单状态为已结束(25)
// StoreOrderDO updateOrder = StoreOrderDO.builder()
// .id(orderId)
// .status(StoreOrderStatusEnum.CLOSED.getCode()) // 已结束状态
// .updateTime(new Date())
// .build();
//
//
// return storeOrderDAO.updateSelective(updateOrder);
// }
@Override
@Transactional
@@ -2001,4 +2016,99 @@ public class MiniStoreOrderServiceImpl implements MiniStoreOrderService {
.filter(v -> StringUtils.isNotBlank(v.getColumnCode()))
.collect(Collectors.toMap(DictColumnVO::getColumnCode, DictColumnVO::getColumnName, (a, b) -> a));
}
@Override
public List<OrderDeviceDetailVO> queryOrderDeviceDetailByShopId(Long shopId) {
StoreOrderDO order = storeOrderDAO.getLatestOrderByShopId(shopId);
return queryOrderDeviceDetailByOrderId(order.getId());
}
@Override
public List<OrderDeviceDetailVO> queryOrderDeviceDetailByOrderId(Long orderId) {
if (orderId == null) {
return Collections.emptyList();
}
// 查询订单快照列表
List<StoreOrderOptionSnapshotDO> snapshotList = snapshotDAO.listByOrderId(orderId);
if (CollectionUtils.isEmpty(snapshotList)) {
return Collections.emptyList();
}
// 查询订单信息获取店型ID
StoreOrderDO orderDO = storeOrderDAO.getById(orderId);
if (orderDO == null) {
return Collections.emptyList();
}
// 获取费用类型字典映射(费用名称)
Map<String, String> expenseTypeNameMap = buildDictNameMap(32L);
// 获取配置大类名称映射
Set<String> categoryCodeSet = snapshotList.stream()
.map(StoreOrderOptionSnapshotDO::getCategoryCode)
.filter(StringUtils::isNotBlank)
.collect(Collectors.toSet());
Map<String, String> categoryNameMap = configItemCategoryDAO.nameMap(new ArrayList<>(categoryCodeSet));
// 获取配置项名称映射
Set<String> itemCodeSet = snapshotList.stream()
.map(StoreOrderOptionSnapshotDO::getItemCode)
.filter(StringUtils::isNotBlank)
.collect(Collectors.toSet());
Map<String, String> itemNameMap = configItemDAO.nameMap(new ArrayList<>(itemCodeSet));
// 查询店型选项绑定(获取默认数量)
Set<Long> optionIdSet = snapshotList.stream()
.map(StoreOrderOptionSnapshotDO::getOptionId)
.filter(Objects::nonNull)
.collect(Collectors.toSet());
List<StoreTypeOptionDO> storeTypeOptionList = new ArrayList<>();
if (CollectionUtils.isNotEmpty(optionIdSet)) {
storeTypeOptionList = storeTypeOptionDAO.selectByIds(new ArrayList<>(optionIdSet), orderDO.getStoreTypeId());
}
Map<Long, BigDecimal> defaultQuantityMap = storeTypeOptionList.stream()
.collect(Collectors.toMap(StoreTypeOptionDO::getOptionId, StoreTypeOptionDO::getDefaultQuantity, (a, b) -> a));
// 按费用类型分组
Map<String, List<StoreOrderOptionSnapshotDO>> expenseTypeGroupMap = snapshotList.stream()
.filter(v -> StringUtils.isNotBlank(v.getExpenseTypeCode()))
.collect(Collectors.groupingBy(StoreOrderOptionSnapshotDO::getExpenseTypeCode));
List<OrderDeviceDetailVO> resultList = new ArrayList<>();
for (Map.Entry<String, List<StoreOrderOptionSnapshotDO>> expenseEntry : expenseTypeGroupMap.entrySet()) {
String expenseTypeCode = expenseEntry.getKey();
OrderDeviceDetailVO expenseVO = new OrderDeviceDetailVO();
expenseVO.setExpenseTypeCode(expenseTypeCode);
expenseVO.setExpenseTypeName(expenseTypeNameMap.getOrDefault(expenseTypeCode, expenseTypeCode));
// 转换为配置项明细
List<OrderDeviceConfigItemVO> configItemList = expenseEntry.getValue().stream()
.map(snapshot -> {
OrderDeviceConfigItemVO configItem = new OrderDeviceConfigItemVO();
configItem.setExpenseTypeCode(snapshot.getExpenseTypeCode());
configItem.setCategoryCode(snapshot.getCategoryCode());
configItem.setCategoryName(categoryNameMap.getOrDefault(snapshot.getCategoryCode(), snapshot.getCategoryCode()));
configItem.setItemCode(snapshot.getItemCode());
configItem.setItemName(itemNameMap.getOrDefault(snapshot.getItemCode(), snapshot.getItemCode()));
configItem.setOptionName(snapshot.getOptionName());
configItem.setOriginalOptionPrice(snapshot.getOriginalOptionPrice());
configItem.setOptionPrice(snapshot.getOptionPrice());
configItem.setQuantity(snapshot.getQuantity());
configItem.setAmount(snapshot.getAmount());
configItem.setOptionUnit(snapshot.getOptionUnit());
// 从店型选项绑定获取默认数量
configItem.setDefaultQuantity(defaultQuantityMap.get(snapshot.getOptionId()));
return configItem;
})
.collect(Collectors.toList());
expenseVO.setItems(configItemList);
resultList.add(expenseVO);
}
return resultList;
}
}

View File

@@ -0,0 +1,42 @@
package com.cool.store.service.plan;
import com.cool.store.enums.DeliveryPlanStageEnum;
import com.cool.store.enums.DeliveryStatusEnum;
import com.cool.store.request.plan.NotifyDeliveryRequest;
import com.cool.store.request.plan.UpdateDeliveryItemRequest;
import com.cool.store.vo.plan.DeliveryDetailVO;
import com.cool.store.vo.plan.DeliveryInfoVO;
/**
* 门店发货阶段服务接口
*/
public interface ShopDeliveryPlanService {
/**
* 通知发货
* @param request 通知发货请求
* @return 发货阶段枚举:待发货(1)
*/
Boolean notifyDelivery(NotifyDeliveryRequest request);
/**
* 查询发货信息
* @param shopId 门店ID
* @return 发货信息VO
*/
DeliveryInfoVO queryDeliveryInfo(Long shopId);
/**
* 更新发货项信息
* @param request 更新发货项请求
* @return 发货阶段枚举:待发货(1)、部分发货(2)、已完成(3)
*/
Boolean updateDeliveryItem(UpdateDeliveryItemRequest request);
/**
* 根据门店查询发货详细信息
* @param shopId 门店ID
* @return 发货详细信息VO
*/
DeliveryDetailVO queryDeliveryDetail(Long shopId);
}

View File

@@ -0,0 +1,227 @@
package com.cool.store.service.plan.impl;
import cn.hutool.core.date.DateUtil;
import com.cool.store.context.CurrentUserHolder;
import com.cool.store.dao.*;
import com.cool.store.dao.order.StoreOrderDAO;
import com.cool.store.entity.EnterpriseUserDO;
import com.cool.store.entity.LineInfoDO;
import com.cool.store.entity.ShopInfoDO;
import com.cool.store.entity.SysRoleDO;
import com.cool.store.entity.order.StoreOrderDO;
import com.cool.store.entity.plan.ShopDeliveryPlanDO;
import com.cool.store.entity.plan.ShopDeliveryPlanItemDO;
import com.cool.store.enums.*;
import com.cool.store.enums.point.ShopSubStageStatusEnum;
import com.cool.store.exception.ServiceException;
import com.cool.store.mapper.EnterpriseUserRoleMapper;
import com.cool.store.request.plan.NotifyDeliveryRequest;
import com.cool.store.request.plan.UpdateDeliveryItemRequest;
import com.cool.store.service.UserAuthMappingService;
import com.cool.store.service.impl.CommonService;
import com.cool.store.service.plan.ShopDeliveryPlanService;
import com.cool.store.utils.BeanUtil;
import com.cool.store.utils.CoolDateUtils;
import com.cool.store.vo.plan.DeliveryDetailVO;
import com.cool.store.vo.plan.DeliveryInfoVO;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
/**
* 门店发货阶段服务实现类
*/
@Service
@RequiredArgsConstructor
@Slf4j
public class ShopDeliveryPlanServiceImpl implements ShopDeliveryPlanService {
private final ShopDeliveryPlanDAO shopDeliveryPlanDAO;
private final ShopDeliveryPlanItemDAO shopDeliveryPlanItemDAO;
private final ShopStageInfoDAO shopStageInfoDAO;
private final StoreOrderDAO storeOrderDAO;
private final CommonService commonService;
private final EnterpriseUserDAO enterpriseUserDAO;
private final EnterpriseUserRoleMapper enterpriseUserRoleMapper;
private final ShopInfoDAO shopInfoDAO;
private final LineInfoDAO lineInfoDAO;
@Override
@Transactional(rollbackFor = Exception.class)
public Boolean notifyDelivery(NotifyDeliveryRequest request) {
// 校验门店是否已存在发货计划
ShopDeliveryPlanDO existingPlan = shopDeliveryPlanDAO.getByShopId(request.getShopId());
if (existingPlan != null) {
throw new ServiceException("该门店已存在发货计划,不能重复通知发货");
}
// 创建发货计划主表
ShopDeliveryPlanDO planDO = new ShopDeliveryPlanDO();
planDO.setShopId(request.getShopId());
planDO.setExpectedDeliveryTime(request.getExpectedDeliveryDate());
planDO.setRemark(request.getRemark());
planDO.setCreateUser(CurrentUserHolder.getUser().getName());
int result = shopDeliveryPlanDAO.insert(planDO);
if (result <= 0) {
throw new ServiceException("创建发货计划失败");
}
// 创建默认的发货项明细(采购设备和火码设备,初始状态为未发货)
List<ShopDeliveryPlanItemDO> list = new ArrayList<>();
ShopDeliveryPlanItemDO purchaseItem = new ShopDeliveryPlanItemDO();
purchaseItem.setPlanId(planDO.getId());
purchaseItem.setItemType(DeliveryItemTypeEnum.PURCHASE_DEVICE.getCode());
purchaseItem.setDeliveryStatus(DeliveryStatusEnum.NOT_DELIVERED.getCode());
list.add(purchaseItem);
ShopDeliveryPlanItemDO fireCodeItem = new ShopDeliveryPlanItemDO();
fireCodeItem.setPlanId(planDO.getId());
fireCodeItem.setItemType(DeliveryItemTypeEnum.FIRE_CODE_DEVICE.getCode());
fireCodeItem.setDeliveryStatus(DeliveryStatusEnum.NOT_DELIVERED.getCode());
list.add(fireCodeItem);
shopDeliveryPlanItemDAO.batchInsert(list);
log.info("通知发货成功门店ID{}发货计划ID{}", request.getShopId(), planDO.getId());
//阶段变为待发货
shopStageInfoDAO.updateShopStageInfo(planDO.getShopId(), ShopSubStageStatusEnum.SHOP_SUB_STAGE_STATUS_291);
//发送短信通知
List<String> userIds = enterpriseUserRoleMapper.getUserIdsByRoleIdList(Arrays.asList(UserRoleEnum.DEVICE_SHIPMENT_HM.getCode(), UserRoleEnum.DEVICE_SHIPMENT_CG.getCode()));
List<EnterpriseUserDO> userInfoByUserIds = enterpriseUserDAO.getUserInfoByUserIds(userIds);
userInfoByUserIds = userInfoByUserIds.stream().filter(x->StringUtils.isNotBlank(x.getMobile())).collect(Collectors.toList());
Map<String, String> templateParam = new HashMap<>();
ShopInfoDO shopInfo = shopInfoDAO.getShopInfo(request.getShopId());
LineInfoDO lineInfo = lineInfoDAO.getLineInfo(shopInfo.getLineId());
templateParam.put("partnerName",lineInfo.getUsername());
templateParam.put("shopName",shopInfo.getShopName());
templateParam.put("shippingDate", DateUtil.format(request.getExpectedDeliveryDate(), CoolDateUtils.DATE_FORMAT_DAY));
userInfoByUserIds.stream().forEach(x->{
commonService.sendSms(x.getMobile(), SMSMsgEnum.DEVICE_NOTICE, templateParam);
});
return Boolean.TRUE;
}
@Override
public DeliveryInfoVO queryDeliveryInfo(Long shopId) {
if (shopId == null) {
return null;
}
ShopDeliveryPlanDO planDO = shopDeliveryPlanDAO.getByShopId(shopId);
if (planDO == null) {
return null;
}
return BeanUtil.toBean(planDO, DeliveryInfoVO.class);
}
@Override
@Transactional(rollbackFor = Exception.class)
public Boolean updateDeliveryItem(UpdateDeliveryItemRequest request) {
// 查询发货计划
ShopDeliveryPlanDO planDO = shopDeliveryPlanDAO.getByShopId(request.getShopId());
if (planDO == null) {
throw new ServiceException("该门店不存在发货计划");
}
// 查询对应的发货项
ShopDeliveryPlanItemDO itemDO = shopDeliveryPlanItemDAO.getByPlanIdAndItemType(planDO.getId(), request.getItemType());
if (itemDO == null) {
throw new ServiceException("发货项不存在");
}
// 更新发货项信息
itemDO.setDeliveryStatus(request.getDeliveryStatus());
if (StringUtils.isNotBlank(request.getDeliveryRemark())) {
itemDO.setDeliveryRemark(request.getDeliveryRemark());
}
int result = shopDeliveryPlanItemDAO.update(itemDO);
if (result <= 0) {
throw new ServiceException("更新发货项失败");
}
ShopSubStageStatusEnum shopSubStageStatusEnum = calculateDeliveryStage(planDO.getId());
shopStageInfoDAO.updateShopStageInfo(planDO.getShopId(),shopSubStageStatusEnum );
// 重新计算发货阶段
return Boolean.TRUE;
}
@Override
public DeliveryDetailVO queryDeliveryDetail(Long shopId) {
if (shopId == null) {
return null;
}
DeliveryDetailVO vo = new DeliveryDetailVO();
StoreOrderDO latestOrderByShopId = storeOrderDAO.getLatestOrderByShopId(shopId);
if (latestOrderByShopId!=null){
vo.setOrderId(latestOrderByShopId.getId());
}
ShopDeliveryPlanDO planDO = shopDeliveryPlanDAO.getByShopId(shopId);
if (planDO == null) {
return vo;
}
BeanUtils.copyProperties(planDO,vo,"orderId");
// 查询发货项明细
List<ShopDeliveryPlanItemDO> items = shopDeliveryPlanItemDAO.listByPlanId(planDO.getId());
if (CollectionUtils.isNotEmpty(items)) {
for (ShopDeliveryPlanItemDO item : items) {
if (DeliveryItemTypeEnum.PURCHASE_DEVICE.getCode().equals(item.getItemType())) {
vo.setPurchaseDeviceDeliveryStatus(item.getDeliveryStatus());
vo.setPurchaseDeviceDeliveryRemark(item.getDeliveryRemark());
} else if (DeliveryItemTypeEnum.FIRE_CODE_DEVICE.getCode().equals(item.getItemType())) {
vo.setFireCodeDeviceDeliveryStatus(item.getDeliveryStatus());
vo.setFireCodeDeviceDeliveryRemark(item.getDeliveryRemark());
}
}
}
// 计算发货阶段
return vo;
}
/**
* 计算发货阶段
* @param planId 发货计划ID
* @return 发货阶段枚举
*/
private ShopSubStageStatusEnum calculateDeliveryStage(Long planId) {
List<ShopDeliveryPlanItemDO> items = shopDeliveryPlanItemDAO.listByPlanId(planId);
if (CollectionUtils.isEmpty(items)) {
return ShopSubStageStatusEnum.SHOP_SUB_STAGE_STATUS_291;
}
int deliveredCount = 0;
int totalCount = items.size();
for (ShopDeliveryPlanItemDO item : items) {
if (DeliveryStatusEnum.DELIVERED.getCode().equals(item.getDeliveryStatus())) {
deliveredCount++;
}
}
if (deliveredCount == 0) {
return ShopSubStageStatusEnum.SHOP_SUB_STAGE_STATUS_291;
} else if (deliveredCount == totalCount) {
return ShopSubStageStatusEnum.SHOP_SUB_STAGE_STATUS_294;
} else {
return ShopSubStageStatusEnum.SHOP_SUB_STAGE_STATUS_292;
}
}
}

View File

@@ -141,7 +141,7 @@ public class PreAllocationRecordServiceImpl implements PreAllocationRecordServic
continue;
}
if (BigDecimal.ZERO.compareTo(item.getPayAmount())>=0){
throw new ServiceException(ErrorCodeEnum.ERROR_MESSAGE);
throw new ServiceException(ErrorCodeEnum.AMOUNT_GEN_ZERO);
}
Long id = item.getId();
if (id == null) {
@@ -276,6 +276,7 @@ public class PreAllocationRecordServiceImpl implements PreAllocationRecordServic
throw new ServiceException(ErrorCodeEnum.NOT_ENOUGH_BALANCE);
}
//首次缴款 校验总金额
log.info("batchTrans total:{},orderAmount",total,storeOrder.getTotalAmount());
if (req.getSubStage()==ShopSubStageEnum.SHOP_STAGE_28.getShopSubStage()){
if (total.compareTo(storeOrder.getTotalAmount())<0) {
throw new ServiceException(ErrorCodeEnum.NOT_ENOUGH_BALANCE);