From 74e37a73c68968f19f7643319e6d0b1b6add71eb Mon Sep 17 00:00:00 2001 From: zhangchenbiao Date: Mon, 15 Apr 2024 09:50:21 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=89=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/cool/store/enums/ErrorCodeEnum.java | 10 ++ ...tus.java => PointRecommendStatusEnum.java} | 18 +-- .../cool/store/enums/point/ShopStageEnum.java | 4 + .../store/enums/point/ShopSubStageEnum.java | 58 +++++++-- .../com/cool/store/dao/PointRecommendDAO.java | 29 ++++- .../java/com/cool/store/dao/ShopInfoDAO.java | 12 ++ .../com/cool/store/dao/ShopStageInfoDAO.java | 15 ++- .../store/mapper/PointRecommendMapper.java | 19 +++ .../resources/mapper/PointRecommendMapper.xml | 37 ++++++ .../resources/mapper/ShopStageInfoMapper.xml | 19 ++- .../store/dto/point/MiniPointPageDTO.java | 41 +++++++ .../cool/store/entity/ShopStageInfoDO.java | 18 +++ .../request/LineRecommendPointRequest.java | 4 +- .../store/request/MiniPointPageRequest.java | 27 +++++ .../request/PointRecommendLineRequest.java | 4 +- .../store/request/SelectPointRequest.java | 29 +++++ .../com/cool/store/vo/LineAuditInfoVO.java | 6 +- .../cool/store/vo/point/MiniPointPageVO.java | 77 ++++++++++++ .../cool/store/vo/shop/MiniShopPageVO.java | 1 - .../cool/store/vo/shop/ShopStageInfoVO.java | 27 ++++- .../com/cool/store/service/PointService.java | 13 +++ .../cool/store/service/ShopServiceImpl.java | 18 ++- .../store/service/impl/PointServiceImpl.java | 110 ++++++++++++++++-- .../controller/webb/PointController.java | 2 +- .../controller/webc/MiniShopController.java | 37 +++++- 25 files changed, 572 insertions(+), 63 deletions(-) rename coolstore-partner-common/src/main/java/com/cool/store/enums/point/{PointRecommendStatus.java => PointRecommendStatusEnum.java} (66%) create mode 100644 coolstore-partner-model/src/main/java/com/cool/store/dto/point/MiniPointPageDTO.java create mode 100644 coolstore-partner-model/src/main/java/com/cool/store/request/MiniPointPageRequest.java create mode 100644 coolstore-partner-model/src/main/java/com/cool/store/request/SelectPointRequest.java create mode 100644 coolstore-partner-model/src/main/java/com/cool/store/vo/point/MiniPointPageVO.java diff --git a/coolstore-partner-common/src/main/java/com/cool/store/enums/ErrorCodeEnum.java b/coolstore-partner-common/src/main/java/com/cool/store/enums/ErrorCodeEnum.java index 54bbfc18b..577079acb 100644 --- a/coolstore-partner-common/src/main/java/com/cool/store/enums/ErrorCodeEnum.java +++ b/coolstore-partner-common/src/main/java/com/cool/store/enums/ErrorCodeEnum.java @@ -21,6 +21,8 @@ public enum ErrorCodeEnum { PUBLIC_LINE_NOT_FOLLOW(419, "该线索已存在公海,无跟进人", null), LINE_EXIST_FOLLOW(420, "该线索已存在,跟进人为【{0},{1}】", null), + ERROR_MESSAGE(421, "{0}", null), + /** * 000000 未知错误 @@ -92,6 +94,14 @@ public enum ErrorCodeEnum { USER_NOT_ALLOW_ENTER_ROOM(600007, "当前用户不允许进入面试房间", null), SHOP_STAGE_ERROR(600008, "店铺阶段错误", null), + SHOP_NOT_EXIST(600009, "店铺不存在", null), + POINT_IS_SELECTED(600010, "该铺位已被其他人选择", null), + POINT_ALREADY_SELECT(600011, "该铺位已被您选择", null), + SHOP_IS_SELECTED(600012, "该店铺已选址", null), + SHOP_STAGE_NOT_OPERATE(600013, "当前店铺所处阶段不允许该操作", null), + POINT_IS_LOCK(600014, "当前铺位已被锁定,刷新后再试", null), + POINT_IS_INVALID(600015, "该铺位已失效", null), + POINT_SELECTED(600016, "该铺位已被选择", null), INTERVIEW_ENTER_FAIL(1021101, "进入面审间失败", null), DINGDING_USER_NOT_EXIST(1021102, "用户钉钉信息不存在,无法发起资质审核!", null), diff --git a/coolstore-partner-common/src/main/java/com/cool/store/enums/point/PointRecommendStatus.java b/coolstore-partner-common/src/main/java/com/cool/store/enums/point/PointRecommendStatusEnum.java similarity index 66% rename from coolstore-partner-common/src/main/java/com/cool/store/enums/point/PointRecommendStatus.java rename to coolstore-partner-common/src/main/java/com/cool/store/enums/point/PointRecommendStatusEnum.java index 9473d5539..3c269d265 100644 --- a/coolstore-partner-common/src/main/java/com/cool/store/enums/point/PointRecommendStatus.java +++ b/coolstore-partner-common/src/main/java/com/cool/store/enums/point/PointRecommendStatusEnum.java @@ -9,7 +9,7 @@ import java.util.List; * @Description: * @date 2024-04-01 14:38 */ -public enum PointRecommendStatus { +public enum PointRecommendStatusEnum { //状态 1.待选择 2.已选择 3.已被他人选择 4.已签约 5.已拒绝 6.已失效 POINT_RECOMMEND_STATUS_1(1, "待选择"), @@ -24,7 +24,7 @@ public enum PointRecommendStatus { private String desc; - PointRecommendStatus(Integer code, String desc) { + PointRecommendStatusEnum(Integer code, String desc) { this.code = code; this.desc = desc; } @@ -37,19 +37,19 @@ public enum PointRecommendStatus { return desc; } - public static PointRecommendStatus getByCode(Integer code) { - for (PointRecommendStatus pointRecommendStatus : PointRecommendStatus.values()) { - if (pointRecommendStatus.getCode().equals(code)) { - return pointRecommendStatus; + public static PointRecommendStatusEnum getByCode(Integer code) { + for (PointRecommendStatusEnum pointRecommendStatusEnum : PointRecommendStatusEnum.values()) { + if (pointRecommendStatusEnum.getCode().equals(code)) { + return pointRecommendStatusEnum; } } return null; } public static String getDescByCode(Integer code) { - for (PointRecommendStatus pointRecommendStatus : PointRecommendStatus.values()) { - if (pointRecommendStatus.getCode().equals(code)) { - return pointRecommendStatus.getDesc(); + for (PointRecommendStatusEnum pointRecommendStatusEnum : PointRecommendStatusEnum.values()) { + if (pointRecommendStatusEnum.getCode().equals(code)) { + return pointRecommendStatusEnum.getDesc(); } } return null; diff --git a/coolstore-partner-common/src/main/java/com/cool/store/enums/point/ShopStageEnum.java b/coolstore-partner-common/src/main/java/com/cool/store/enums/point/ShopStageEnum.java index e84260f04..5f178398e 100644 --- a/coolstore-partner-common/src/main/java/com/cool/store/enums/point/ShopStageEnum.java +++ b/coolstore-partner-common/src/main/java/com/cool/store/enums/point/ShopStageEnum.java @@ -14,10 +14,14 @@ public enum ShopStageEnum { SHOP_STAGE_3(3, "开业"), ; + //店铺阶段 private Integer shopStage; + //阶段名称 private String stageName; + + ShopStageEnum(Integer shopStage, String stageName) { this.shopStage = shopStage; this.stageName = stageName; diff --git a/coolstore-partner-common/src/main/java/com/cool/store/enums/point/ShopSubStageEnum.java b/coolstore-partner-common/src/main/java/com/cool/store/enums/point/ShopSubStageEnum.java index af5ef5547..aee93331b 100644 --- a/coolstore-partner-common/src/main/java/com/cool/store/enums/point/ShopSubStageEnum.java +++ b/coolstore-partner-common/src/main/java/com/cool/store/enums/point/ShopSubStageEnum.java @@ -1,5 +1,6 @@ package com.cool.store.enums.point; +import java.time.LocalDate; import java.util.ArrayList; import java.util.List; @@ -11,17 +12,17 @@ import java.util.List; */ public enum ShopSubStageEnum { - SHOP_STAGE_1(ShopStageEnum.SHOP_STAGE_1, 10, "选址"), - SHOP_STAGE_2(ShopStageEnum.SHOP_STAGE_1, 20, "上传租赁合同"), - SHOP_STAGE_3(ShopStageEnum.SHOP_STAGE_2, 30, "系统建店"), - SHOP_STAGE_4(ShopStageEnum.SHOP_STAGE_2, 40, "证照办理"), - SHOP_STAGE_5(ShopStageEnum.SHOP_STAGE_2, 50, "员工招聘"), - SHOP_STAGE_6(ShopStageEnum.SHOP_STAGE_2, 60, "加盟商/员工培训"), - SHOP_STAGE_7(ShopStageEnum.SHOP_STAGE_2, 70, "缴纳加盟费/保证金"), - SHOP_STAGE_8(ShopStageEnum.SHOP_STAGE_2, 80, "加盟合同签约"), - SHOP_STAGE_9(ShopStageEnum.SHOP_STAGE_2, 90, "设计阶段"), - SHOP_STAGE_10(ShopStageEnum.SHOP_STAGE_2, 100, "施工阶段"), - SHOP_STAGE_11(ShopStageEnum.SHOP_STAGE_2, 110, "三方验收"), + SHOP_STAGE_1(ShopStageEnum.SHOP_STAGE_1, 10, "选址", 3), + SHOP_STAGE_2(ShopStageEnum.SHOP_STAGE_1, 20, "上传租赁合同", 2), + SHOP_STAGE_3(ShopStageEnum.SHOP_STAGE_2, 30, "系统建店", 2), + SHOP_STAGE_4(ShopStageEnum.SHOP_STAGE_2, 40, "证照办理", 2), + SHOP_STAGE_5(ShopStageEnum.SHOP_STAGE_2, 50, "员工招聘", 2), + SHOP_STAGE_6(ShopStageEnum.SHOP_STAGE_2, 60, "加盟商/员工培训", 2), + SHOP_STAGE_7(ShopStageEnum.SHOP_STAGE_2, 70, "缴纳加盟费/保证金", 2), + SHOP_STAGE_8(ShopStageEnum.SHOP_STAGE_2, 80, "加盟合同签约", 2), + SHOP_STAGE_9(ShopStageEnum.SHOP_STAGE_2, 90, "设计阶段", 2), + SHOP_STAGE_10(ShopStageEnum.SHOP_STAGE_2, 100, "施工阶段", 2), + SHOP_STAGE_11(ShopStageEnum.SHOP_STAGE_2, 110, "三方验收", 2), ; //阶段 @@ -33,10 +34,14 @@ public enum ShopSubStageEnum { //子阶段名称 private String shopSubStageName; - ShopSubStageEnum(ShopStageEnum shopStageEnum, Integer shopSubStage, String shopSubStageName) { + //计划完成天数 + private Integer planCompleteDays; + + ShopSubStageEnum(ShopStageEnum shopStageEnum, Integer shopSubStage, String shopSubStageName, Integer planCompleteDays) { this.shopStageEnum = shopStageEnum; this.shopSubStage = shopSubStage; this.shopSubStageName = shopSubStageName; + this.planCompleteDays = planCompleteDays; } public static List getShopStageEnum(Integer shopStage) { @@ -61,6 +66,10 @@ public enum ShopSubStageEnum { return shopSubStageName; } + public Integer getPlanCompleteDays() { + return planCompleteDays; + } + /** * 获取各阶段的初始状态 * @return @@ -94,4 +103,29 @@ public enum ShopSubStageEnum { } } + public static Integer getSelectStageMaxDays() { + return Math.max(ShopSubStageEnum.SHOP_STAGE_1.getPlanCompleteDays(), ShopSubStageEnum.SHOP_STAGE_2.getPlanCompleteDays()); + + } + + public String getPlanCompleteTime(LocalDate planCompleteTime, LocalDate planSelectPointCompleteDate) { + switch (this){ + case SHOP_STAGE_1: + case SHOP_STAGE_2: + case SHOP_STAGE_5: + case SHOP_STAGE_6: + case SHOP_STAGE_7: + case SHOP_STAGE_8: + return planCompleteTime.plusDays(getPlanCompleteDays()).toString(); + case SHOP_STAGE_3: + case SHOP_STAGE_4: + case SHOP_STAGE_9: + case SHOP_STAGE_10: + case SHOP_STAGE_11: + return planSelectPointCompleteDate.plusDays(getPlanCompleteDays()).toString(); + default: + return null; + } + } + } diff --git a/coolstore-partner-dao/src/main/java/com/cool/store/dao/PointRecommendDAO.java b/coolstore-partner-dao/src/main/java/com/cool/store/dao/PointRecommendDAO.java index 1d24503df..905b461c8 100644 --- a/coolstore-partner-dao/src/main/java/com/cool/store/dao/PointRecommendDAO.java +++ b/coolstore-partner-dao/src/main/java/com/cool/store/dao/PointRecommendDAO.java @@ -1,9 +1,13 @@ package com.cool.store.dao; import com.cool.store.dto.point.LineCountDTO; +import com.cool.store.dto.point.MiniPointPageDTO; import com.cool.store.entity.PointRecommendDO; -import com.cool.store.enums.point.PointRecommendStatus; +import com.cool.store.enums.point.PointRecommendStatusEnum; import com.cool.store.mapper.PointRecommendMapper; +import com.cool.store.request.MiniPointPageRequest; +import com.github.pagehelper.Page; +import com.github.pagehelper.PageHelper; import com.google.common.collect.Lists; import com.google.common.collect.Maps; import org.apache.commons.collections4.CollectionUtils; @@ -33,7 +37,7 @@ public class PointRecommendDAO { * @param status * @return */ - public Integer updateRecommendStatus(Long pointId, PointRecommendStatus status) { + public Integer updateRecommendStatus(Long pointId, PointRecommendStatusEnum status) { if(Objects.isNull(status)){ return 0; } @@ -47,11 +51,11 @@ public class PointRecommendDAO { * @param statusList * @return */ - public Integer updateRecommendStatusByStatusAndPointId(Long pointId, PointRecommendStatus status, List statusList) { + public Integer updateRecommendStatusByStatusAndPointId(Long pointId, PointRecommendStatusEnum status, List statusList) { if(Objects.isNull(status) || CollectionUtils.isEmpty(statusList)){ return 0; } - List statusCodeList = statusList.stream().map(PointRecommendStatus::getCode).collect(Collectors.toList()); + List statusCodeList = statusList.stream().map(PointRecommendStatusEnum::getCode).collect(Collectors.toList()); return pointRecommendMapper.updateRecommendStatusByStatusAndPointId(pointId, status.getCode(), statusCodeList); } @@ -92,4 +96,21 @@ public class PointRecommendDAO { public Integer deleteUnselectedRecommendPointByLineId(Long lineId) { return pointRecommendMapper.deleteUnselectedRecommendPointByLineId(lineId); } + + /** + * 线索获取推荐列表 + * @param request + * @return + */ + public Page getLineRecommendPointPage(MiniPointPageRequest request){ + PageHelper.startPage(request.getPageNum(), request.getPageSize()); + return pointRecommendMapper.getLineRecommendPointPage(request); + } + + public Integer updateStatusByPointIdAndLineId(Long pointId, Long lineId){ + if(Objects.isNull(pointId) || Objects.isNull(lineId)){ + return 0; + } + return pointRecommendMapper.updateStatusByPointIdAndLineId(pointId, lineId); + } } diff --git a/coolstore-partner-dao/src/main/java/com/cool/store/dao/ShopInfoDAO.java b/coolstore-partner-dao/src/main/java/com/cool/store/dao/ShopInfoDAO.java index 58cc78413..b90c084ad 100644 --- a/coolstore-partner-dao/src/main/java/com/cool/store/dao/ShopInfoDAO.java +++ b/coolstore-partner-dao/src/main/java/com/cool/store/dao/ShopInfoDAO.java @@ -3,8 +3,11 @@ package com.cool.store.dao; import com.cool.store.constants.CommonConstants; import com.cool.store.entity.LineInfoDO; import com.cool.store.entity.ShopInfoDO; +import com.cool.store.enums.ErrorCodeEnum; +import com.cool.store.exception.ServiceException; import com.cool.store.mapper.ShopInfoMapper; import com.cool.store.utils.NumberConverter; +import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.CollectionUtils; import org.springframework.stereotype.Repository; @@ -19,6 +22,7 @@ import java.util.Objects; * @Description: * @date 2024-03-29 10:14 */ +@Slf4j @Repository public class ShopInfoDAO { @@ -63,4 +67,12 @@ public class ShopInfoDAO { return shopInfo.getId(); } + public Integer updateShopInfo(ShopInfoDO shopInfo){ + if(Objects.isNull(shopInfo) || Objects.isNull(shopInfo.getId())){ + log.info("店铺为空 或者店铺id为空"); + throw new ServiceException(ErrorCodeEnum.PARAMS_VALIDATE_ERROR); + } + return shopInfoMapper.updateByPrimaryKeySelective(shopInfo); + } + } diff --git a/coolstore-partner-dao/src/main/java/com/cool/store/dao/ShopStageInfoDAO.java b/coolstore-partner-dao/src/main/java/com/cool/store/dao/ShopStageInfoDAO.java index abf4f808a..20323304b 100644 --- a/coolstore-partner-dao/src/main/java/com/cool/store/dao/ShopStageInfoDAO.java +++ b/coolstore-partner-dao/src/main/java/com/cool/store/dao/ShopStageInfoDAO.java @@ -11,6 +11,7 @@ import org.apache.commons.collections4.CollectionUtils; import org.springframework.stereotype.Repository; import javax.annotation.Resource; +import java.time.LocalDate; import java.util.ArrayList; import java.util.List; import java.util.Objects; @@ -34,24 +35,26 @@ public class ShopStageInfoDAO { * @param shopStageEnum * @return */ - public Integer initShopStageInfo(Long lineId, List shopIds, ShopStageEnum shopStageEnum) { - if(CollectionUtils.isEmpty(shopIds) || Objects.isNull(shopStageEnum)){ + public Integer initShopStageInfo(Long lineId, List shopIds) { + if(CollectionUtils.isEmpty(shopIds)){ return CommonConstants.ZERO; } - Integer shopStage = shopStageEnum.getShopStage(); - List shopStageEnumList = ShopSubStageEnum.getShopStageEnum(shopStage); List addShopStageList = new ArrayList<>(); + LocalDate selectStartDate = LocalDate.now(); + LocalDate planSelectPointCompleteDate = selectStartDate.plusDays(ShopSubStageEnum.getSelectStageMaxDays()); for (Long shopId : shopIds) { - for (ShopSubStageEnum shopSubStageEnum : shopStageEnumList) { + for (ShopSubStageEnum shopSubStageEnum : ShopSubStageEnum.values()) { ShopStageInfoDO shopStageInfo = new ShopStageInfoDO(); shopStageInfo.setLineId(lineId); shopStageInfo.setShopId(shopId); - shopStageInfo.setShopStage(shopStage); + ShopStageEnum shopStageEnum = shopSubStageEnum.getShopStageEnum(); + shopStageInfo.setShopStage(shopStageEnum.getShopStage()); shopStageInfo.setShopSubStage(shopSubStageEnum.getShopSubStage()); ShopSubStageStatusEnum initStatus = shopSubStageEnum.getInitStatus(); shopStageInfo.setShopSubStageStatus(initStatus.getShopSubStageStatus()); shopStageInfo.setRemark(shopSubStageEnum.getShopSubStageName() + CommonConstants.PATH_BAR +shopSubStageEnum.getInitStatus().getShopSubStageStatusName()); shopStageInfo.setIsTerminated(initStatus.isTerminated()); + shopStageInfo.setPlanCompleteTime(shopSubStageEnum.getPlanCompleteTime(selectStartDate, planSelectPointCompleteDate)); addShopStageList.add(shopStageInfo); } } diff --git a/coolstore-partner-dao/src/main/java/com/cool/store/mapper/PointRecommendMapper.java b/coolstore-partner-dao/src/main/java/com/cool/store/mapper/PointRecommendMapper.java index 92ecc917e..8e891fb6f 100644 --- a/coolstore-partner-dao/src/main/java/com/cool/store/mapper/PointRecommendMapper.java +++ b/coolstore-partner-dao/src/main/java/com/cool/store/mapper/PointRecommendMapper.java @@ -1,7 +1,10 @@ package com.cool.store.mapper; import com.cool.store.dto.point.LineCountDTO; +import com.cool.store.dto.point.MiniPointPageDTO; import com.cool.store.entity.PointRecommendDO; +import com.cool.store.request.MiniPointPageRequest; +import com.github.pagehelper.Page; import org.apache.ibatis.annotations.Param; import tk.mybatis.mapper.common.Mapper; @@ -53,4 +56,20 @@ public interface PointRecommendMapper extends Mapper { * @return */ Integer deleteUnselectedRecommendPointByLineId(@Param("lineId") Long lineId); + + /** + * 线索获取推荐铺位列表 + * @param request + * @return + */ + Page getLineRecommendPointPage(@Param("request") MiniPointPageRequest request); + + /** + * 更新推荐选择状态 + * @param pointId + * @param lineId + * @return + */ + Integer updateStatusByPointIdAndLineId(@Param("pointId") Long pointId, @Param("lineId") Long lineId); + } \ No newline at end of file diff --git a/coolstore-partner-dao/src/main/resources/mapper/PointRecommendMapper.xml b/coolstore-partner-dao/src/main/resources/mapper/PointRecommendMapper.xml index e3d50c168..90a0d7cac 100644 --- a/coolstore-partner-dao/src/main/resources/mapper/PointRecommendMapper.xml +++ b/coolstore-partner-dao/src/main/resources/mapper/PointRecommendMapper.xml @@ -62,4 +62,41 @@ update xfsg_point_recommend set deleted = 1 where line_id = #{lineId} and deleted = 0 and status in (0,2) + + + + + update + xfsg_point_recommend + set + status = if(line_id = #{lineId}, 2, 3) + where point_id = #{pointId} and deleted = 0 + \ No newline at end of file diff --git a/coolstore-partner-dao/src/main/resources/mapper/ShopStageInfoMapper.xml b/coolstore-partner-dao/src/main/resources/mapper/ShopStageInfoMapper.xml index e2db371e7..9c9bd22bf 100644 --- a/coolstore-partner-dao/src/main/resources/mapper/ShopStageInfoMapper.xml +++ b/coolstore-partner-dao/src/main/resources/mapper/ShopStageInfoMapper.xml @@ -9,20 +9,23 @@ + + + - id, line_id, shop_id, shop_stage, shop_sub_stage, shop_sub_stage_status, is_terminated, remark, deleted, create_time, update_time + id, line_id, shop_id, shop_stage, shop_sub_stage, shop_sub_stage_status, is_terminated, plan_complete_time, actual_complete_time, remark, audit_id, deleted, create_time, update_time - INSERT INTO xfsg_shop_stage_info(line_id, shop_id, shop_stage, shop_sub_stage, shop_sub_stage_status, is_terminated, remark) - VALUES(#{shop.lineId}, #{shop.shopId}, #{shop.shopStage}, #{shop.shopSubStage}, #{shop.shopSubStageStatus}, #{shop.isTerminated}, #{shop.remark}) + INSERT INTO xfsg_shop_stage_info(line_id, shop_id, shop_stage, shop_sub_stage, shop_sub_stage_status, is_terminated, plan_complete_time, remark) + VALUES(#{shop.lineId}, #{shop.shopId}, #{shop.shopStage}, #{shop.shopSubStage}, #{shop.shopSubStageStatus}, #{shop.isTerminated}, #{shop.planCompleteTime}, #{shop.remark}) @@ -39,7 +42,15 @@ - update xfsg_shop_stage_info set shop_sub_stage_status = #{shopSubStageStatus}, is_terminated = #{isTerminated}, remark = #{remark} where shop_id = #{shopId} and shop_sub_stage = #{shopSubStage} + update + xfsg_shop_stage_info + set + shop_sub_stage_status = #{shopSubStageStatus}, + is_terminated = #{isTerminated}, + remark = #{remark}, + actual_complete_time = if(is_terminated, now(), null) + where + shop_id = #{shopId} and shop_sub_stage = #{shopSubStage} \ No newline at end of file diff --git a/coolstore-partner-model/src/main/java/com/cool/store/dto/point/MiniPointPageDTO.java b/coolstore-partner-model/src/main/java/com/cool/store/dto/point/MiniPointPageDTO.java new file mode 100644 index 000000000..06112fa25 --- /dev/null +++ b/coolstore-partner-model/src/main/java/com/cool/store/dto/point/MiniPointPageDTO.java @@ -0,0 +1,41 @@ +package com.cool.store.dto.point; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +@Data +public class MiniPointPageDTO { + + @ApiModelProperty("店铺id") + private Long pointId; + + @ApiModelProperty("线索id") + private Long lineId; + + @ApiModelProperty("铺位名称") + private String pointName; + + @ApiModelProperty("铺位编号") + private String pointCode; + + @ApiModelProperty("所属站区") + private Long regionId; + + @ApiModelProperty("地址") + private String address; + + @ApiModelProperty("铺位得分") + private Integer pointScore; + + @ApiModelProperty("铺位面积") + private String pointArea; + + @ApiModelProperty("铺位状态 1.采集中、2.已评估、3.待审核、5.已审核、6.已签约、7.已失效") + private Integer pointStatus; + + @ApiModelProperty("选择状态0.未选择, 1.已被选择") + private Integer selectStatus; + + @ApiModelProperty("1.待选择 2.已选择 3.已被他人选择 4.已签约 5.已拒绝 6.已失效") + private Integer recommendStatus; +} \ No newline at end of file diff --git a/coolstore-partner-model/src/main/java/com/cool/store/entity/ShopStageInfoDO.java b/coolstore-partner-model/src/main/java/com/cool/store/entity/ShopStageInfoDO.java index 203e80d22..3e5f0ffd3 100644 --- a/coolstore-partner-model/src/main/java/com/cool/store/entity/ShopStageInfoDO.java +++ b/coolstore-partner-model/src/main/java/com/cool/store/entity/ShopStageInfoDO.java @@ -45,11 +45,29 @@ public class ShopStageInfoDO { @Column(name = "is_terminated") private Boolean isTerminated; + /** + * 计划完成时间 + */ + @Column(name = "plan_complete_time") + private String planCompleteTime; + + /** + * 实际完成时间 + */ + @Column(name = "actual_complete_time") + private String actualCompleteTime; + /** * 备注 */ private String remark; + /** + * 审核id + */ + @Column(name = "audit_id") + private Long auditId; + /** * 删除标识 */ diff --git a/coolstore-partner-model/src/main/java/com/cool/store/request/LineRecommendPointRequest.java b/coolstore-partner-model/src/main/java/com/cool/store/request/LineRecommendPointRequest.java index 2977834dc..f1751b7ac 100644 --- a/coolstore-partner-model/src/main/java/com/cool/store/request/LineRecommendPointRequest.java +++ b/coolstore-partner-model/src/main/java/com/cool/store/request/LineRecommendPointRequest.java @@ -1,7 +1,7 @@ package com.cool.store.request; import com.cool.store.entity.PointRecommendDO; -import com.cool.store.enums.point.PointRecommendStatus; +import com.cool.store.enums.point.PointRecommendStatusEnum; import com.google.common.collect.Lists; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -38,7 +38,7 @@ public class LineRecommendPointRequest { pointRecommendDO.setLineId(this.lineId); pointRecommendDO.setDevelopmentManager(this.developmentManager); pointRecommendDO.setPointId(pointId); - pointRecommendDO.setStatus(PointRecommendStatus.POINT_RECOMMEND_STATUS_1.getCode()); + pointRecommendDO.setStatus(PointRecommendStatusEnum.POINT_RECOMMEND_STATUS_1.getCode()); return pointRecommendDO; }).collect(Collectors.toList()); } diff --git a/coolstore-partner-model/src/main/java/com/cool/store/request/MiniPointPageRequest.java b/coolstore-partner-model/src/main/java/com/cool/store/request/MiniPointPageRequest.java new file mode 100644 index 000000000..8ae5a0478 --- /dev/null +++ b/coolstore-partner-model/src/main/java/com/cool/store/request/MiniPointPageRequest.java @@ -0,0 +1,27 @@ +package com.cool.store.request; + +import com.cool.store.common.PageBasicInfo; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.Max; +import javax.validation.constraints.Min; + +/** + * @author zhangchenbiao + * @FileName: MiniPointPageRequest + * @Description: + * @date 2024-04-12 14:33 + */ +@Data +public class MiniPointPageRequest extends PageBasicInfo { + + @Min(value = 1, message = "status不能小于1") + @Max(value = 3, message = "status不能大于3") + @ApiModelProperty("1.待选择 2.已选择 3.拒绝/失效") + private Integer status; + + @ApiModelProperty(value = "线索id",hidden = true) + private Long lineId; + +} diff --git a/coolstore-partner-model/src/main/java/com/cool/store/request/PointRecommendLineRequest.java b/coolstore-partner-model/src/main/java/com/cool/store/request/PointRecommendLineRequest.java index 85229a9f9..e4ec2b377 100644 --- a/coolstore-partner-model/src/main/java/com/cool/store/request/PointRecommendLineRequest.java +++ b/coolstore-partner-model/src/main/java/com/cool/store/request/PointRecommendLineRequest.java @@ -1,7 +1,7 @@ package com.cool.store.request; import com.cool.store.entity.PointRecommendDO; -import com.cool.store.enums.point.PointRecommendStatus; +import com.cool.store.enums.point.PointRecommendStatusEnum; import com.google.common.collect.Lists; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -38,7 +38,7 @@ public class PointRecommendLineRequest { pointRecommendDO.setLineId(lineId); pointRecommendDO.setDevelopmentManager(this.developmentManager); pointRecommendDO.setPointId(pointId); - pointRecommendDO.setStatus(PointRecommendStatus.POINT_RECOMMEND_STATUS_1.getCode()); + pointRecommendDO.setStatus(PointRecommendStatusEnum.POINT_RECOMMEND_STATUS_1.getCode()); return pointRecommendDO; }).collect(Collectors.toList()); } diff --git a/coolstore-partner-model/src/main/java/com/cool/store/request/SelectPointRequest.java b/coolstore-partner-model/src/main/java/com/cool/store/request/SelectPointRequest.java new file mode 100644 index 000000000..27d98a839 --- /dev/null +++ b/coolstore-partner-model/src/main/java/com/cool/store/request/SelectPointRequest.java @@ -0,0 +1,29 @@ +package com.cool.store.request; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotNull; + + +/** + * @author zhangchenbiao + * @FileName: SelectPointRequest + * @Description: + * @date 2024-04-12 15:08 + */ +@Data +public class SelectPointRequest { + + @NotNull + @ApiModelProperty("店铺id") + private Long shopId; + + @NotNull + @ApiModelProperty("铺位id") + private Long pointId; + + @ApiModelProperty(value = "当前线索id", hidden = true) + private Long lineId; + +} diff --git a/coolstore-partner-model/src/main/java/com/cool/store/vo/LineAuditInfoVO.java b/coolstore-partner-model/src/main/java/com/cool/store/vo/LineAuditInfoVO.java index 5a8904334..409425f48 100644 --- a/coolstore-partner-model/src/main/java/com/cool/store/vo/LineAuditInfoVO.java +++ b/coolstore-partner-model/src/main/java/com/cool/store/vo/LineAuditInfoVO.java @@ -6,6 +6,7 @@ import lombok.Data; import javax.persistence.*; import java.util.Date; +import java.util.Objects; @Data public class LineAuditInfoVO { @@ -28,10 +29,13 @@ public class LineAuditInfoVO { @ApiModelProperty("明文件或凭证") private String certifyFile; - @ApiModelProperty("审批事件") + @ApiModelProperty("审批时间") private Date createTime; public static LineAuditInfoVO convertVO(LineAuditInfoDO auditInfo) { + if(Objects.isNull(auditInfo)){ + return null; + } LineAuditInfoVO result = new LineAuditInfoVO(); result.setAuditId(auditInfo.getId()); result.setResultType(auditInfo.getResultType()); diff --git a/coolstore-partner-model/src/main/java/com/cool/store/vo/point/MiniPointPageVO.java b/coolstore-partner-model/src/main/java/com/cool/store/vo/point/MiniPointPageVO.java new file mode 100644 index 000000000..5c625de48 --- /dev/null +++ b/coolstore-partner-model/src/main/java/com/cool/store/vo/point/MiniPointPageVO.java @@ -0,0 +1,77 @@ +package com.cool.store.vo.point; + +import com.cool.store.dto.point.MiniPointPageDTO; +import com.cool.store.entity.PointInfoDO; +import com.cool.store.enums.point.PointRecommendStatusEnum; +import com.cool.store.enums.point.PointStatusEnum; +import com.cool.store.enums.point.SelectStatusEnum; +import com.google.common.collect.Lists; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import org.apache.commons.collections4.CollectionUtils; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +@Data +public class MiniPointPageVO { + + @ApiModelProperty("店铺id") + private Long pointId; + + @ApiModelProperty("铺位名称") + private String pointName; + + @ApiModelProperty("铺位编号") + private String pointCode; + + @ApiModelProperty("所属站区") + private String regionNodeName; + + @ApiModelProperty("地址") + private String address; + + @ApiModelProperty("铺位得分") + private Integer pointScore; + + @ApiModelProperty("铺位面积") + private String pointArea; + + @ApiModelProperty("1.待选择 2.已选择 3.已被他人选择 4.已签约 5.已拒绝 6.已失效") + private Integer recommendStatus; + + public static List convertVO(List pointList, Map regionNameMap, Long curLineId) { + if(CollectionUtils.isEmpty(pointList)){ + return Lists.newArrayList(); + } + List resultList = new ArrayList<>(); + for (MiniPointPageDTO pointInfo : pointList) { + MiniPointPageVO pointPageVO = new MiniPointPageVO(); + pointPageVO.setPointId(pointInfo.getPointId()); + pointPageVO.setPointName(pointInfo.getPointName()); + pointPageVO.setPointCode(pointInfo.getPointCode()); + pointPageVO.setRegionNodeName(regionNameMap.get(pointInfo.getRegionId())); + pointPageVO.setAddress(pointInfo.getAddress()); + pointPageVO.setPointScore(pointInfo.getPointScore()); + pointPageVO.setPointArea(pointInfo.getPointArea()); + pointPageVO.setRecommendStatus(getRecommendStatus(curLineId, pointInfo.getLineId(), pointInfo.getPointStatus(), pointInfo.getSelectStatus(), pointInfo.getRecommendStatus())); + resultList.add(pointPageVO); + } + return resultList; + } + + public static Integer getRecommendStatus(Long curLineId, Long lineId, Integer pointStatus, Integer selectStatus, Integer recommendStatus) { + if(PointStatusEnum.POINT_STATUS_7.getCode().equals(pointStatus)){ + return PointRecommendStatusEnum.POINT_RECOMMEND_STATUS_6.getCode(); + } + if(SelectStatusEnum.SELECT_STATUS_1.getCode().equals(selectStatus)){ + //已选择 判断线索id是否是自己 + if(curLineId.equals(lineId)){ + return PointRecommendStatusEnum.POINT_RECOMMEND_STATUS_2.getCode(); + } + return PointRecommendStatusEnum.POINT_RECOMMEND_STATUS_3.getCode(); + } + return recommendStatus; + } +} \ No newline at end of file diff --git a/coolstore-partner-model/src/main/java/com/cool/store/vo/shop/MiniShopPageVO.java b/coolstore-partner-model/src/main/java/com/cool/store/vo/shop/MiniShopPageVO.java index f70bc7d70..cdb952de8 100644 --- a/coolstore-partner-model/src/main/java/com/cool/store/vo/shop/MiniShopPageVO.java +++ b/coolstore-partner-model/src/main/java/com/cool/store/vo/shop/MiniShopPageVO.java @@ -22,7 +22,6 @@ public class MiniShopPageVO { @ApiModelProperty("店铺名称") private String shopName; - public MiniShopPageVO(Long shopId, String shopName) { this.shopId = shopId; this.shopName = shopName; diff --git a/coolstore-partner-model/src/main/java/com/cool/store/vo/shop/ShopStageInfoVO.java b/coolstore-partner-model/src/main/java/com/cool/store/vo/shop/ShopStageInfoVO.java index 8eb4a6533..43eb86f95 100644 --- a/coolstore-partner-model/src/main/java/com/cool/store/vo/shop/ShopStageInfoVO.java +++ b/coolstore-partner-model/src/main/java/com/cool/store/vo/shop/ShopStageInfoVO.java @@ -1,13 +1,19 @@ package com.cool.store.vo.shop; +import com.cool.store.entity.LineAuditInfoDO; import com.cool.store.entity.ShopStageInfoDO; +import com.cool.store.vo.LineAuditInfoVO; import com.google.common.collect.Lists; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import org.apache.commons.collections4.CollectionUtils; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; +import java.util.function.Function; +import java.util.stream.Collectors; /** * @author zhangchenbiao @@ -30,20 +36,37 @@ public class ShopStageInfoVO { @ApiModelProperty("当前阶段是否结束 0未结束 1已结束") private Boolean isTerminated; + @ApiModelProperty("预估完成时间") + private String planCompleteTime; + + @ApiModelProperty("实际完成时间") + private String actualCompleteTime; + + @ApiModelProperty("阶段审核信息") + private LineAuditInfoVO auditInfo; + public ShopStageInfoVO(Integer shopStage, Integer shopSubStage, Integer shopSubStageStatus, Boolean isTerminated) { this.shopStage = shopStage; this.shopSubStage = shopSubStage; this.shopSubStageStatus = shopSubStageStatus; this.isTerminated = isTerminated; + } - public static List convertList(List stageList){ + public static List convertList(List stageList, List auditList){ if(CollectionUtils.isEmpty(stageList)){ return Lists.newArrayList(); } + Map auditMap = auditList.stream().collect(Collectors.toMap(LineAuditInfoDO::getId, Function.identity())); List resultList = new ArrayList<>(); for (ShopStageInfoDO stageInfo : stageList) { - resultList.add(new ShopStageInfoVO(stageInfo.getShopStage(), stageInfo.getShopSubStage(), stageInfo.getShopSubStageStatus(), stageInfo.getIsTerminated())); + ShopStageInfoVO shopStageInfo = new ShopStageInfoVO(stageInfo.getShopStage(), stageInfo.getShopSubStage(), stageInfo.getShopSubStageStatus(), stageInfo.getIsTerminated()); + LineAuditInfoDO auditInfo = auditMap.get(stageInfo.getAuditId()); + LineAuditInfoVO auditInfoVO = LineAuditInfoVO.convertVO(auditInfo); + shopStageInfo.setAuditInfo(auditInfoVO); + shopStageInfo.setPlanCompleteTime(stageInfo.getPlanCompleteTime()); + shopStageInfo.setActualCompleteTime(stageInfo.getActualCompleteTime()); + resultList.add(shopStageInfo); } return resultList; } diff --git a/coolstore-partner-service/src/main/java/com/cool/store/service/PointService.java b/coolstore-partner-service/src/main/java/com/cool/store/service/PointService.java index 52fc90f6a..50663dc19 100644 --- a/coolstore-partner-service/src/main/java/com/cool/store/service/PointService.java +++ b/coolstore-partner-service/src/main/java/com/cool/store/service/PointService.java @@ -193,4 +193,17 @@ public interface PointService { */ PageInfo getTodoList(PointTodoPageRequest request); + /** + * 获取线索推荐店铺列表 + * @param request + * @return + */ + PageInfo getLineRecommendPointPage(MiniPointPageRequest request); + + /** + * 线索选址铺位 + * @param request + * @return + */ + Integer lineSelectPoint(SelectPointRequest request); } diff --git a/coolstore-partner-service/src/main/java/com/cool/store/service/ShopServiceImpl.java b/coolstore-partner-service/src/main/java/com/cool/store/service/ShopServiceImpl.java index 9fcdd269d..73f604bd2 100644 --- a/coolstore-partner-service/src/main/java/com/cool/store/service/ShopServiceImpl.java +++ b/coolstore-partner-service/src/main/java/com/cool/store/service/ShopServiceImpl.java @@ -1,7 +1,9 @@ package com.cool.store.service; +import com.cool.store.dao.LineAuditInfoDAO; import com.cool.store.dao.ShopInfoDAO; import com.cool.store.dao.ShopStageInfoDAO; +import com.cool.store.entity.LineAuditInfoDO; import com.cool.store.entity.LineInfoDO; import com.cool.store.entity.ShopInfoDO; import com.cool.store.entity.ShopStageInfoDO; @@ -33,6 +35,8 @@ public class ShopServiceImpl implements ShopService { private ShopInfoDAO shopInfoDAO; @Resource private ShopStageInfoDAO shopStageInfoDAO; + @Resource + private LineAuditInfoDAO lineAuditInfoDAO; @Override @Transactional(rollbackFor = Exception.class) @@ -53,7 +57,7 @@ public class ShopServiceImpl implements ShopService { shopInfoDAO.batchAddShop(addShopList); List shopList = shopInfoDAO.getShopList(lineInfo.getId()); List shopIds = shopList.stream().map(ShopInfoDO::getId).collect(Collectors.toList()); - return shopStageInfoDAO.initShopStageInfo(lineInfo.getId(), shopIds, ShopStageEnum.SHOP_STAGE_1); + return shopStageInfoDAO.initShopStageInfo(lineInfo.getId(), shopIds); } @Override @@ -64,11 +68,15 @@ public class ShopServiceImpl implements ShopService { @Override public List getShopStageInfo(Long lineId, Long shopId, Integer shopStage) { - ShopStageEnum shopStageEnum = ShopStageEnum.getShopStageEnum(shopStage); - if(Objects.isNull(shopStageEnum)){ - throw new ServiceException(ErrorCodeEnum.SHOP_STAGE_ERROR); + if(Objects.nonNull(shopStage)){ + ShopStageEnum shopStageEnum = ShopStageEnum.getShopStageEnum(shopStage); + if(Objects.isNull(shopStageEnum)){ + throw new ServiceException(ErrorCodeEnum.SHOP_STAGE_ERROR); + } } List shopStageInfo = shopStageInfoDAO.getShopStageInfo(shopId, shopStage); - return ShopStageInfoVO.convertList(shopStageInfo); + List auditIds = shopStageInfo.stream().map(ShopStageInfoDO::getAuditId).collect(Collectors.toList()); + List auditList = lineAuditInfoDAO.getLineAuditInfoList(auditIds); + return ShopStageInfoVO.convertList(shopStageInfo, auditList); } } diff --git a/coolstore-partner-service/src/main/java/com/cool/store/service/impl/PointServiceImpl.java b/coolstore-partner-service/src/main/java/com/cool/store/service/impl/PointServiceImpl.java index 246e38a69..31ee11ad5 100644 --- a/coolstore-partner-service/src/main/java/com/cool/store/service/impl/PointServiceImpl.java +++ b/coolstore-partner-service/src/main/java/com/cool/store/service/impl/PointServiceImpl.java @@ -1,17 +1,15 @@ 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.dto.point.AuditNodeDTO; +import com.cool.store.dto.point.MiniPointPageDTO; import com.cool.store.entity.*; import com.cool.store.enums.AuditStatusEnum; import com.cool.store.enums.ErrorCodeEnum; import com.cool.store.enums.NodeNoEnum; import com.cool.store.enums.WorkflowStageEnum; -import com.cool.store.enums.point.PointRecommendStatus; -import com.cool.store.enums.point.PointStatusEnum; -import com.cool.store.enums.point.SelectStatusEnum; +import com.cool.store.enums.point.*; import com.cool.store.exception.ServiceException; import com.cool.store.request.*; import com.cool.store.service.LabelService; @@ -29,10 +27,12 @@ import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.ListUtils; import org.apache.commons.lang3.tuple.Pair; +import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; +import java.text.MessageFormat; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.util.*; @@ -74,8 +74,13 @@ public class PointServiceImpl implements PointService { private LabelService labelService; @Resource private HyOpenAreaInfoDAO hyOpenAreaInfoDAO; + @Resource + private ShopStageInfoDAO shopStageInfoDAO; + @Value("${mybatis.configuration.variables.enterpriseId}") + private String enterpriseId; - private static final String AUDIT_SETTING_KEY = "audit_setting_key"; + private static final String AUDIT_SETTING_KEY = "audit_setting_key:{0}"; + private static final String POINT_SELECT_KEY = "point_select_key:{0}:{1}"; @Override @Transactional(rollbackFor = Exception.class) @@ -148,7 +153,7 @@ public class PointServiceImpl implements PointService { updatePoint.setId(pointId); updatePoint.setPointStatus(PointStatusEnum.POINT_STATUS_7.getCode()); pointInfoDAO.updatePointInfo(updatePoint); - return pointRecommendDAO.updateRecommendStatus(pointId, PointRecommendStatus.POINT_RECOMMEND_STATUS_6); + return pointRecommendDAO.updateRecommendStatus(pointId, PointRecommendStatusEnum.POINT_RECOMMEND_STATUS_6); } @Override @@ -167,7 +172,7 @@ public class PointServiceImpl implements PointService { updatePoint.setSelectStatus(SelectStatusEnum.SELECT_STATUS_0.getCode()); pointInfoDAO.updatePointInfo(updatePoint); //将已选择、已被他人选择的状态更新成待选泽 - return pointRecommendDAO.updateRecommendStatusByStatusAndPointId(pointId, PointRecommendStatus.POINT_RECOMMEND_STATUS_1, Arrays.asList(PointRecommendStatus.POINT_RECOMMEND_STATUS_2, PointRecommendStatus.POINT_RECOMMEND_STATUS_3)); + return pointRecommendDAO.updateRecommendStatusByStatusAndPointId(pointId, PointRecommendStatusEnum.POINT_RECOMMEND_STATUS_1, Arrays.asList(PointRecommendStatusEnum.POINT_RECOMMEND_STATUS_2, PointRecommendStatusEnum.POINT_RECOMMEND_STATUS_3)); } @Override @@ -228,8 +233,9 @@ public class PointServiceImpl implements PointService { @Override public Integer auditSetting(AuditSettingRequest request) { + String cacheKey = MessageFormat.format(AUDIT_SETTING_KEY, enterpriseId); request.setSecondApproval(Arrays.asList(UserAndPositionRequest.convert("position", null, "战区营运"))); - redisUtilPool.setString(AUDIT_SETTING_KEY, JSONObject.toJSONString(request)); + redisUtilPool.setString(cacheKey, JSONObject.toJSONString(request)); return null; } @@ -432,7 +438,7 @@ public class PointServiceImpl implements PointService { List regionIds = pointList.stream().map(PointInfoDO::getRegionId).distinct().collect(Collectors.toList()); List developmentManagers = pointList.stream().map(PointInfoDO::getDevelopmentManager).distinct().collect(Collectors.toList()); Map userNameMap = enterpriseUserDAO.getUserNameMap(developmentManagers); - Map regionNameMap = new HashMap<>(); + Map regionNameMap = regionService.getBelongWarRegionNameMap(regionIds); return PointRecommendPageVO.convertVO(recommendPointList, pointList, userNameMap, regionNameMap); } @@ -454,12 +460,36 @@ public class PointServiceImpl implements PointService { @Override public Integer lineRecommendPoint(LineRecommendPointRequest request) { + List pointIds = request.getPointIds(); + List pointList = pointInfoDAO.getPointListByIds(pointIds); + List selectList = pointList.stream().filter(o -> SelectStatusEnum.SELECT_STATUS_1.getCode().equals(o.getSelectStatus())).collect(Collectors.toList()); + if(CollectionUtils.isNotEmpty(selectList)){ + String pointNames = selectList.stream().map(PointInfoDO::getPointName).collect(Collectors.joining(",")); + throw new ServiceException(ErrorCodeEnum.ERROR_MESSAGE, pointNames + ",已经被选"); + } + List invalidList = pointList.stream().filter(o -> PointStatusEnum.POINT_STATUS_7.getCode().equals(o.getPointStatus())).collect(Collectors.toList()); + if(CollectionUtils.isNotEmpty(invalidList)){ + String pointNames = invalidList.stream().map(PointInfoDO::getPointName).collect(Collectors.joining(",")); + throw new ServiceException(ErrorCodeEnum.ERROR_MESSAGE, pointNames + ",已失效"); + } List recommendList = request.convertList(); return pointRecommendDAO.addRecommendPoint(recommendList); } @Override public Integer pointRecommendLine(PointRecommendLineRequest request) { + Long pointId = request.getPointId(); + List lineIds = request.getLineIds(); + PointInfoDO pointInfo = pointInfoDAO.getPointInfoById(pointId); + if(Objects.isNull(pointInfo)){ + throw new ServiceException(ErrorCodeEnum.POINT_NOT_EXIST); + } + if(PointStatusEnum.POINT_STATUS_7.getCode().equals(pointInfo.getPointStatus())){ + throw new ServiceException(ErrorCodeEnum.POINT_IS_INVALID); + } + if(SelectStatusEnum.SELECT_STATUS_1.getCode().equals(pointInfo.getSelectStatus())){ + throw new ServiceException(ErrorCodeEnum.POINT_SELECTED); + } List recommendList = request.convertList(); return pointRecommendDAO.addRecommendPoint(recommendList); } @@ -510,6 +540,68 @@ public class PointServiceImpl implements PointService { return resultPage; } + @Override + public PageInfo getLineRecommendPointPage(MiniPointPageRequest request) { + Page pointPage = pointRecommendDAO.getLineRecommendPointPage(request); + List resultList = new ArrayList<>(); + if(Objects.nonNull(pointPage) && CollectionUtils.isNotEmpty(pointPage.getResult())){ + List regionIds = pointPage.getResult().stream().map(MiniPointPageDTO::getRegionId).distinct().collect(Collectors.toList()); + Map regionNameMap = regionService.getBelongWarRegionNameMap(regionIds); + resultList = MiniPointPageVO.convertVO(pointPage, regionNameMap, request.getLineId()); + } + PageInfo resultPage = new PageInfo(pointPage); + resultPage.setList(resultList); + return resultPage; + } + + @Override + @Transactional(rollbackFor = Exception.class) + public Integer lineSelectPoint(SelectPointRequest request) { + Long pointId = request.getPointId(), shopId = request.getShopId(), lineId = request.getLineId(); + String lockKey = MessageFormat.format(POINT_SELECT_KEY, enterpriseId, pointId); + if(!redisUtilPool.setNxExpire(lockKey, JSONObject.toJSONString(request), 30)){ + throw new ServiceException(ErrorCodeEnum.POINT_IS_LOCK); + } + try { + ShopInfoDO shopInfo = shopInfoDAO.getShopInfo(shopId); + if(Objects.isNull(shopInfo)){ + throw new ServiceException(ErrorCodeEnum.SHOP_NOT_EXIST); + } + if(!ShopStageEnum.SHOP_STAGE_1.getShopStage().equals(shopInfo.getShopStage())){ + throw new ServiceException(ErrorCodeEnum.SHOP_STAGE_NOT_OPERATE); + } + if(Objects.nonNull(shopInfo.getPointId())){ + throw new ServiceException(ErrorCodeEnum.SHOP_IS_SELECTED); + } + PointInfoDO pointInfo = pointInfoDAO.getPointInfoById(pointId); + if(Objects.isNull(pointInfo)){ + throw new ServiceException(ErrorCodeEnum.POINT_NOT_EXIST); + } + if(SelectStatusEnum.SELECT_STATUS_1.getCode().equals(pointInfo.getSelectStatus())){ + if(lineId.equals(pointInfo.getLineId())){ + throw new ServiceException(ErrorCodeEnum.POINT_ALREADY_SELECT); + } + throw new ServiceException(ErrorCodeEnum.POINT_IS_SELECTED); + } + PointInfoDO updatePoint = new PointInfoDO(); + updatePoint.setId(pointId); + updatePoint.setSelectStatus(SelectStatusEnum.SELECT_STATUS_1.getCode()); + updatePoint.setLineId(lineId); + updatePoint.setShopId(shopId); + pointInfoDAO.updatePointInfo(updatePoint); + ShopInfoDO updateShop = new ShopInfoDO(); + updateShop.setId(shopId); + updateShop.setPointId(pointId); + shopInfoDAO.updateShopInfo(shopInfo); + shopStageInfoDAO.updateShopStageInfo(shopId, ShopSubStageStatusEnum.SHOP_SUB_STAGE_STATUS_1); + return pointRecommendDAO.updateStatusByPointIdAndLineId(pointId, lineId); + } catch (ServiceException e) { + throw e; + } finally { + redisUtilPool.delKey(lockKey); + } + } + public List dealAuditNode(AuditSettingVO auditSetting, Long regionId, String operateUserId, String developmentManager) { List roleIds = new ArrayList<>(); //审核人 diff --git a/coolstore-partner-web/src/main/java/com/cool/store/controller/webb/PointController.java b/coolstore-partner-web/src/main/java/com/cool/store/controller/webb/PointController.java index a5c44f3c4..db83d7d17 100644 --- a/coolstore-partner-web/src/main/java/com/cool/store/controller/webb/PointController.java +++ b/coolstore-partner-web/src/main/java/com/cool/store/controller/webb/PointController.java @@ -24,7 +24,7 @@ import java.util.List; * @Description: * @date 2024-03-29 15:36 */ -@Api(tags = "选址/铺位") +@Api(tags = "选址&铺位") @RestController @RequestMapping("/pc/point") public class PointController { diff --git a/coolstore-partner-web/src/main/java/com/cool/store/controller/webc/MiniShopController.java b/coolstore-partner-web/src/main/java/com/cool/store/controller/webc/MiniShopController.java index f72e59d34..60693c4b9 100644 --- a/coolstore-partner-web/src/main/java/com/cool/store/controller/webc/MiniShopController.java +++ b/coolstore-partner-web/src/main/java/com/cool/store/controller/webc/MiniShopController.java @@ -1,18 +1,23 @@ package com.cool.store.controller.webc; import com.cool.store.context.PartnerUserHolder; +import com.cool.store.request.MiniPointPageRequest; +import com.cool.store.request.PointRecommendLineRequest; +import com.cool.store.request.SelectPointRequest; import com.cool.store.response.ResponseResult; import com.cool.store.service.PointService; import com.cool.store.service.ShopService; +import com.cool.store.vo.point.MiniPointPageVO; +import com.cool.store.vo.point.PointDetailVO; +import com.cool.store.vo.point.PointPageVO; import com.cool.store.vo.shop.MiniShopPageVO; import com.cool.store.vo.shop.ShopStageInfoVO; import com.cool.store.vo.shop.ShopStageVO; +import com.github.pagehelper.PageInfo; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import java.util.List; @@ -42,7 +47,7 @@ public class MiniShopController { @ApiOperation("获取店铺的阶段信息") @GetMapping("/getShopStageInfo") - public ResponseResult> getShopStageInfo(@RequestParam("shopId")Long shopId, @RequestParam("shopStage")Integer shopStage) { + public ResponseResult> getShopStageInfo(@RequestParam("shopId")Long shopId, @RequestParam(value = "shopStage", required = false)Integer shopStage) { Long lineId = PartnerUserHolder.getUser().getLineId(); return ResponseResult.success(shopService.getShopStageInfo(lineId, shopId, shopStage)); } @@ -53,4 +58,26 @@ public class MiniShopController { return ResponseResult.success(ShopStageVO.getShopStageList()); } + @ApiOperation("获取推荐给我的铺位") + @PostMapping("/getLineRecommendPointPage") + public ResponseResult> getLineRecommendPointPage(@RequestBody MiniPointPageRequest request) { + Long lineId = PartnerUserHolder.getUser().getLineId(); + request.setLineId(lineId); + return ResponseResult.success(pointService.getLineRecommendPointPage(request)); + } + + @ApiOperation("铺位详情") + @GetMapping("/detail") + public ResponseResult getPointDetailInfo(@RequestParam("pointId")Long pointId) { + return ResponseResult.success(pointService.getPointDetailInfo(pointId)); + } + + @ApiOperation("选址铺位") + @PostMapping("/selectPoint") + public ResponseResult lineSelectPoint(@RequestBody @Validated SelectPointRequest request) { + Long lineId = PartnerUserHolder.getUser().getLineId(); + request.setLineId(lineId); + return ResponseResult.success(pointService.lineSelectPoint(request)); + } + }