From 476dafbb993bc0bf177ed4413d19e6d894085692 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=97=B4=E8=B4=A7?= <252048765@qq.com> Date: Fri, 20 Sep 2024 20:23:45 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E5=8A=9F=E8=83=BD=E3=80=91=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E6=89=AB=E6=8F=8F=E6=9E=AA=E6=A0=B8=E9=94=80=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E3=80=81=E6=A0=B9=E6=8D=AE=E5=BD=93=E5=89=8D=E7=99=BB?= =?UTF-8?q?=E5=BD=95=E4=BA=BA=E6=9F=A5=E8=AF=A2=E8=87=AA=E6=8F=90=E7=82=B9?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E5=92=8C=E7=BB=91=E5=AE=9A=E8=87=AA=E6=8F=90?= =?UTF-8?q?=E5=91=98=E5=B7=A5=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../trade/enums/ErrorCodeConstants.java | 1 + .../DeliveryPickUpStoreController.java | 43 +++++++++- .../DeliveryPickUpStoreStaffController.java | 46 +++++++++++ .../DeliveryPickUpBindStoreStaffIdReqVO.java | 24 ++++++ .../DeliveryPickUpBindStoreStaffIdReqsVO.java | 27 +++++++ .../AppDeliverPickUpStoreController.java | 2 +- .../delivery/DeliveryPickUpStoreStaffDO.java | 2 + .../delivery/DeliveryPickUpStoreMapper.java | 6 +- .../DeliveryPickUpStoreStaffMapper.java | 21 +++++ .../delivery/DeliveryPickUpStoreService.java | 12 ++- .../DeliveryPickUpStoreServiceImpl.java | 38 ++++++++- .../DeliveryPickUpStoreStaffService.java | 42 ++++++++++ .../DeliveryPickUpStoreStaffServiceImpl.java | 79 +++++++++++++++++++ .../admin/user/vo/user/UserPageReqVO.java | 3 + .../dal/mysql/user/AdminUserMapper.java | 10 ++- .../service/user/AdminUserServiceImpl.java | 13 ++- 16 files changed, 356 insertions(+), 13 deletions(-) create mode 100644 yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/DeliveryPickUpStoreStaffController.java create mode 100644 yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/pickup/DeliveryPickUpBindStoreStaffIdReqVO.java create mode 100644 yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/pickup/DeliveryPickUpBindStoreStaffIdReqsVO.java create mode 100644 yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/delivery/DeliveryPickUpStoreStaffService.java create mode 100644 yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/delivery/DeliveryPickUpStoreStaffServiceImpl.java diff --git a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/ErrorCodeConstants.java b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/ErrorCodeConstants.java index be0ef51ae8..c7a7faf1ec 100644 --- a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/ErrorCodeConstants.java +++ b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/ErrorCodeConstants.java @@ -80,6 +80,7 @@ public interface ErrorCodeConstants { // ========== 物流 PICK_UP 模块 1-011-006-000 ========== ErrorCode PICK_UP_STORE_NOT_EXISTS = new ErrorCode(1_011_006_000, "自提门店不存在"); + ErrorCode PICK_UP_STORE_STAFF_NOT_EXISTS = new ErrorCode(1_011_006_000, "自提门店店员不存在"); // ========== 分销用户 模块 1-011-007-000 ========== ErrorCode BROKERAGE_USER_NOT_EXISTS = new ErrorCode(1_011_007_000, "分销用户不存在"); diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/DeliveryPickUpStoreController.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/DeliveryPickUpStoreController.java index b8d7f1fce2..383112cc16 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/DeliveryPickUpStoreController.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/DeliveryPickUpStoreController.java @@ -3,10 +3,14 @@ package cn.iocoder.yudao.module.trade.controller.admin.delivery; import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.security.core.LoginUser; +import cn.iocoder.yudao.module.system.api.user.AdminUserApi; import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup.*; import cn.iocoder.yudao.module.trade.convert.delivery.DeliveryPickUpStoreConvert; import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryPickUpStoreDO; +import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryPickUpStoreStaffDO; import cn.iocoder.yudao.module.trade.service.delivery.DeliveryPickUpStoreService; +import cn.iocoder.yudao.module.trade.service.delivery.DeliveryPickUpStoreStaffService; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.tags.Tag; @@ -16,10 +20,15 @@ import org.springframework.web.bind.annotation.*; import jakarta.annotation.Resource; import jakarta.validation.Valid; + +import java.util.ArrayList; import java.util.Collection; import java.util.List; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; +import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUser; +import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; +import static java.util.stream.Collectors.toList; @Tag(name = "管理后台 - 自提门店") @RestController @@ -30,6 +39,9 @@ public class DeliveryPickUpStoreController { @Resource private DeliveryPickUpStoreService deliveryPickUpStoreService; + @Resource + private DeliveryPickUpStoreStaffService deliveryPickUpStoreStaffService; + @PostMapping("/create") @Operation(summary = "创建自提门店") @PreAuthorize("@ss.hasPermission('trade:delivery:pick-up-store:create')") @@ -66,9 +78,16 @@ public class DeliveryPickUpStoreController { @GetMapping("/list-all-simple") @Operation(summary = "获得自提门店精简信息列表") public CommonResult> getSimpleDeliveryPickUpStoreList() { - List list = deliveryPickUpStoreService.getDeliveryPickUpStoreListByStatus( - CommonStatusEnum.ENABLE.getStatus()); - return success(DeliveryPickUpStoreConvert.INSTANCE.convertList1(list)); + List storeStaffDOS = deliveryPickUpStoreStaffService.selectStaffByUserId(getLoginUserId()); + List storeIds = storeStaffDOS.stream().map(DeliveryPickUpStoreStaffDO::getStoreId).toList(); + if(!storeIds.isEmpty()){ + List list = deliveryPickUpStoreService.getDeliveryPickUpStoreListByStatus( + CommonStatusEnum.ENABLE.getStatus(), storeIds); + return success(DeliveryPickUpStoreConvert.INSTANCE.convertList1(list)); + }else{ + return success(new ArrayList<>()); + } + } @GetMapping("/list") @@ -88,4 +107,22 @@ public class DeliveryPickUpStoreController { return success(DeliveryPickUpStoreConvert.INSTANCE.convertPage(pageResult)); } + @PostMapping("/bind") + @Operation(summary = "绑定自提店员") + @PreAuthorize("@ss.hasPermission('trade:delivery:pick-up-store:create')") + public CommonResult bindDeliveryPickUpBindStoreStaffId(@Valid @RequestBody DeliveryPickUpBindStoreStaffIdReqVO bindStoreStaffIdVO) { + deliveryPickUpStoreService.bindDeliveryPickUpBindStoreStaffId(bindStoreStaffIdVO); + return success(true); + } + + @GetMapping("/get-store-staff") + @Operation(summary = "查询门店绑定情况") + @Parameter(name = "id", description = "编号", required = true, example = "1024") + @PreAuthorize("@ss.hasPermission('trade:delivery:pick-up-store:query')") + public CommonResult getDeliveryPickUpStoreStaff(@RequestParam("id") Long id) { + DeliveryPickUpStoreDO deliveryPickUpStore = deliveryPickUpStoreService.getDeliveryPickUpStore(id); + return success(deliveryPickUpStoreStaffService.getDeliveryPickUpStoreStaff(deliveryPickUpStore.getId(),deliveryPickUpStore.getName())); + } + + } diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/DeliveryPickUpStoreStaffController.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/DeliveryPickUpStoreStaffController.java new file mode 100644 index 0000000000..e0df7e6df6 --- /dev/null +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/DeliveryPickUpStoreStaffController.java @@ -0,0 +1,46 @@ +package cn.iocoder.yudao.module.trade.controller.admin.delivery; + +import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; +import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.module.system.api.user.AdminUserApi; +import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup.*; +import cn.iocoder.yudao.module.trade.convert.delivery.DeliveryPickUpStoreConvert; +import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryPickUpStoreDO; +import cn.iocoder.yudao.module.trade.service.delivery.DeliveryPickUpStoreService; +import cn.iocoder.yudao.module.trade.service.delivery.DeliveryPickUpStoreStaffService; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.annotation.Resource; +import jakarta.validation.Valid; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import java.util.Collection; +import java.util.List; + +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; + +@Tag(name = "管理后台 - 自提门店店员") +@RestController +@RequestMapping("/trade/delivery/pick-up-store-staff") +@Validated +public class DeliveryPickUpStoreStaffController { + + + @Resource + private DeliveryPickUpStoreStaffService deliveryPickUpStoreStaffService; + + @DeleteMapping("/delete") + @Operation(summary = "删除自提门店店员") + @Parameter(name = "userId", description = "用户编号", required = true) + @Parameter(name = "storeId", description = "自提门店编号", required = true) + @PreAuthorize("@ss.hasPermission('trade:delivery:pick-up-store:delete')") + public CommonResult deleteDeliveryPickUpStoreStaff(@RequestParam("userId") Long id,@RequestParam("storeId") Long storeId) { + deliveryPickUpStoreStaffService.deleteDeliveryPickUpStoreStaff(id, storeId); + return success(true); + } + +} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/pickup/DeliveryPickUpBindStoreStaffIdReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/pickup/DeliveryPickUpBindStoreStaffIdReqVO.java new file mode 100644 index 0000000000..76ccd49449 --- /dev/null +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/pickup/DeliveryPickUpBindStoreStaffIdReqVO.java @@ -0,0 +1,24 @@ +package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup; + +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotNull; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; + +import java.util.List; + +@Schema(description = "管理后台 - 自提门店创建 Request VO") +@Data +@ToString(callSuper = true) +public class DeliveryPickUpBindStoreStaffIdReqVO { + + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "23128") + @NotNull(message = "编号不能为空") + private Long id; + + @Schema(description = "绑定用户编号组数", requiredMode = Schema.RequiredMode.REQUIRED, example = "23128") + @NotNull(message = "绑定用户编号组数不能未空") + private List storeStaffIds; + +} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/pickup/DeliveryPickUpBindStoreStaffIdReqsVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/pickup/DeliveryPickUpBindStoreStaffIdReqsVO.java new file mode 100644 index 0000000000..3f87767c4f --- /dev/null +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/pickup/DeliveryPickUpBindStoreStaffIdReqsVO.java @@ -0,0 +1,27 @@ +package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup; + +import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotNull; +import lombok.Builder; +import lombok.Data; +import lombok.ToString; + +import java.util.List; + +@Schema(description = "管理后台 - 自提门店创建 Request VO") +@Data +@ToString(callSuper = true) +@Builder +public class DeliveryPickUpBindStoreStaffIdReqsVO { + + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "23128") + private Long id; + + @Schema(description = "门店名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "23128") + private String name; + + @Schema(description = "绑定用户信息组数", requiredMode = Schema.RequiredMode.REQUIRED, example = "23128") + private List storeStaffs; + +} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/delivery/AppDeliverPickUpStoreController.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/delivery/AppDeliverPickUpStoreController.java index 6a923fe368..1f7109d9fc 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/delivery/AppDeliverPickUpStoreController.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/delivery/AppDeliverPickUpStoreController.java @@ -40,7 +40,7 @@ public class AppDeliverPickUpStoreController { @RequestParam(value = "latitude", required = false) Double latitude, @RequestParam(value = "longitude", required = false) Double longitude) { List list = deliveryPickUpStoreService.getDeliveryPickUpStoreListByStatus( - CommonStatusEnum.ENABLE.getStatus()); + CommonStatusEnum.ENABLE.getStatus(), null); return success(DeliveryPickUpStoreConvert.INSTANCE.convertList(list, latitude, longitude)); } diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/delivery/DeliveryPickUpStoreStaffDO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/delivery/DeliveryPickUpStoreStaffDO.java index 4c03a8e5db..ec92356553 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/delivery/DeliveryPickUpStoreStaffDO.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/delivery/DeliveryPickUpStoreStaffDO.java @@ -5,7 +5,9 @@ import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; import com.baomidou.mybatisplus.annotation.KeySequence; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Builder; import lombok.Data; +import lombok.NoArgsConstructor; // TODO @芋艿:后续再详细 review 一轮 // TODO @芋艿:可能改成 DeliveryPickUpStoreUserDO diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/delivery/DeliveryPickUpStoreMapper.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/delivery/DeliveryPickUpStoreMapper.java index b26b1c0159..7a1b91bf68 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/delivery/DeliveryPickUpStoreMapper.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/delivery/DeliveryPickUpStoreMapper.java @@ -22,8 +22,10 @@ public interface DeliveryPickUpStoreMapper extends BaseMapperX selectListByStatus(Integer status) { - return selectList(DeliveryPickUpStoreDO::getStatus, status); + default List selectListByStatus(Integer status, List storeIds) { + return selectList(new LambdaQueryWrapperX() + .eq(DeliveryPickUpStoreDO::getStatus, status) + .inIfPresent(DeliveryPickUpStoreDO::getId, storeIds)); } } diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/delivery/DeliveryPickUpStoreStaffMapper.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/delivery/DeliveryPickUpStoreStaffMapper.java index 06cc14e268..8b8a0d4074 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/delivery/DeliveryPickUpStoreStaffMapper.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/delivery/DeliveryPickUpStoreStaffMapper.java @@ -1,12 +1,33 @@ package cn.iocoder.yudao.module.trade.dal.mysql.delivery; import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryPickUpStoreStaffDO; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import org.apache.ibatis.annotations.Mapper; +import java.util.Collections; +import java.util.List; + @Mapper public interface DeliveryPickUpStoreStaffMapper extends BaseMapperX { + default Long selectStaffIdByUserIdAndStoreId(List userId, Long storeId){ + return selectOne(new LambdaQueryWrapperX() + .inIfPresent(DeliveryPickUpStoreStaffDO::getAdminUserId, userId) + .eqIfPresent(DeliveryPickUpStoreStaffDO::getStoreId, storeId)) + .getId(); + } + + default List getUserIdsByStoreId(Long id){ + return selectList(new LambdaQueryWrapperX() + .eq(DeliveryPickUpStoreStaffDO::getStoreId,id)); + } + + default void deleteStaffByUserIdsAndStoreId(List userIds, Long storeId){ + Long StaffId = selectStaffIdByUserIdAndStoreId(userIds, storeId); + deleteById(StaffId); + } } diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/delivery/DeliveryPickUpStoreService.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/delivery/DeliveryPickUpStoreService.java index 300b24d0e8..6020f4329b 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/delivery/DeliveryPickUpStoreService.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/delivery/DeliveryPickUpStoreService.java @@ -1,6 +1,7 @@ package cn.iocoder.yudao.module.trade.service.delivery; import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup.DeliveryPickUpBindStoreStaffIdReqVO; import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup.DeliveryPickUpStoreCreateReqVO; import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup.DeliveryPickUpStorePageReqVO; import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup.DeliveryPickUpStoreUpdateReqVO; @@ -67,7 +68,16 @@ public interface DeliveryPickUpStoreService { * 获得指定状态的自提门店列表 * * @param status 状态 + * @param storeIds 指定门店id * @return 自提门店列表 */ - List getDeliveryPickUpStoreListByStatus(Integer status); + List getDeliveryPickUpStoreListByStatus(Integer status, List storeIds); + + /** + * 绑定自提店员 + * + * @param bindStoreStaffIdVO 绑定数据 + * @return + */ + void bindDeliveryPickUpBindStoreStaffId(DeliveryPickUpBindStoreStaffIdReqVO bindStoreStaffIdVO); } diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/delivery/DeliveryPickUpStoreServiceImpl.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/delivery/DeliveryPickUpStoreServiceImpl.java index 278235f653..2911c661a1 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/delivery/DeliveryPickUpStoreServiceImpl.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/delivery/DeliveryPickUpStoreServiceImpl.java @@ -1,18 +1,26 @@ package cn.iocoder.yudao.module.trade.service.delivery; +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.ObjectUtil; import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; +import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup.DeliveryPickUpBindStoreStaffIdReqVO; import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup.DeliveryPickUpStoreCreateReqVO; import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup.DeliveryPickUpStorePageReqVO; import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup.DeliveryPickUpStoreUpdateReqVO; import cn.iocoder.yudao.module.trade.convert.delivery.DeliveryPickUpStoreConvert; import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryPickUpStoreDO; +import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryPickUpStoreStaffDO; import cn.iocoder.yudao.module.trade.dal.mysql.delivery.DeliveryPickUpStoreMapper; +import cn.iocoder.yudao.module.trade.dal.mysql.delivery.DeliveryPickUpStoreStaffMapper; +import com.mchange.lang.LongUtils; import org.springframework.stereotype.Service; import org.springframework.validation.annotation.Validated; import jakarta.annotation.Resource; import java.util.Collection; import java.util.List; +import java.util.stream.Collectors; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.PICK_UP_STORE_NOT_EXISTS; @@ -28,6 +36,8 @@ public class DeliveryPickUpStoreServiceImpl implements DeliveryPickUpStoreServic @Resource private DeliveryPickUpStoreMapper deliveryPickUpStoreMapper; + @Resource + private DeliveryPickUpStoreStaffMapper deliveryPickUpStoreStaffMapper; @Override public Long createDeliveryPickUpStore(DeliveryPickUpStoreCreateReqVO createReqVO) { @@ -77,8 +87,32 @@ public class DeliveryPickUpStoreServiceImpl implements DeliveryPickUpStoreServic } @Override - public List getDeliveryPickUpStoreListByStatus(Integer status) { - return deliveryPickUpStoreMapper.selectListByStatus(status); + public List getDeliveryPickUpStoreListByStatus(Integer status, List storeIds) { + return deliveryPickUpStoreMapper.selectListByStatus(status, storeIds); + } + + @Override + public void bindDeliveryPickUpBindStoreStaffId(DeliveryPickUpBindStoreStaffIdReqVO bindStoreStaffIdVO) { + //查询旧列表 + List storeStaffDOS = deliveryPickUpStoreStaffMapper.getUserIdsByStoreId(bindStoreStaffIdVO.getId()); + List oldStoreStaffIds = storeStaffDOS.stream().map(DeliveryPickUpStoreStaffDO::getAdminUserId).toList(); + List newStoreStaffIds = bindStoreStaffIdVO.getStoreStaffIds(); + List> diffList = CollectionUtils.diffList(oldStoreStaffIds, newStoreStaffIds, // id 不同,就认为是不同的记录 + ObjectUtil::equal); + // 添加 + if (CollUtil.isNotEmpty(diffList.get(0))) { + diffList.get(0).forEach(id -> { + DeliveryPickUpStoreStaffDO storeStaffDO = new DeliveryPickUpStoreStaffDO(); + storeStaffDO.setStoreId(bindStoreStaffIdVO.getId()); + storeStaffDO.setAdminUserId(id); + deliveryPickUpStoreStaffMapper.insert(storeStaffDO); + }); + } + //删除 + if (CollUtil.isNotEmpty(diffList.get(2))) { + deliveryPickUpStoreStaffMapper.deleteStaffByUserIdsAndStoreId(diffList.get(2), bindStoreStaffIdVO.getId()); + } + } } diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/delivery/DeliveryPickUpStoreStaffService.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/delivery/DeliveryPickUpStoreStaffService.java new file mode 100644 index 0000000000..a69a2bfae0 --- /dev/null +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/delivery/DeliveryPickUpStoreStaffService.java @@ -0,0 +1,42 @@ +package cn.iocoder.yudao.module.trade.service.delivery; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup.*; +import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryPickUpStoreDO; +import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryPickUpStoreStaffDO; +import cn.iocoder.yudao.module.trade.dal.mysql.delivery.DeliveryPickUpStoreStaffMapper; +import jakarta.annotation.Resource; +import jakarta.validation.Valid; + +import java.util.Collection; +import java.util.List; + +/** + * 自提门店店员 Service 接口 + * + * @author jason + */ +public interface DeliveryPickUpStoreStaffService { + + /** + * 查询门店绑定用户信息数组 + * + * @param id 门店编号 + * @return 用户信息数组 + */ + DeliveryPickUpBindStoreStaffIdReqsVO getDeliveryPickUpStoreStaff(Long id, String name); + + /** + * 删除自提门店店员 + * + * @param id 门店店员编号 + */ + void deleteDeliveryPickUpStoreStaff(Long id, Long storeId); + + /** + * 根据用户id查询自提门店店员信息 + * @param userId + * @return + */ + List selectStaffByUserId(Long userId); +} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/delivery/DeliveryPickUpStoreStaffServiceImpl.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/delivery/DeliveryPickUpStoreStaffServiceImpl.java new file mode 100644 index 0000000000..7044a95a5a --- /dev/null +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/delivery/DeliveryPickUpStoreStaffServiceImpl.java @@ -0,0 +1,79 @@ +package cn.iocoder.yudao.module.trade.service.delivery; + +import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; +import cn.iocoder.yudao.module.system.api.user.AdminUserApi; +import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; +import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup.*; +import cn.iocoder.yudao.module.trade.convert.delivery.DeliveryPickUpStoreConvert; +import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryPickUpStoreDO; +import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryPickUpStoreStaffDO; +import cn.iocoder.yudao.module.trade.dal.mysql.delivery.DeliveryPickUpStoreMapper; +import cn.iocoder.yudao.module.trade.dal.mysql.delivery.DeliveryPickUpStoreStaffMapper; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import jakarta.annotation.Resource; +import org.springframework.stereotype.Service; +import org.springframework.validation.annotation.Validated; + +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import java.util.stream.Collectors; + +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; +import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.PICK_UP_STORE_NOT_EXISTS; +import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.PICK_UP_STORE_STAFF_NOT_EXISTS; +import static java.util.stream.Collectors.toList; + +/** + * 自提门店店员 Service 实现类 + * + * @author jason + */ +@Service +@Validated +public class DeliveryPickUpStoreStaffServiceImpl implements DeliveryPickUpStoreStaffService { + + + @Resource + private DeliveryPickUpStoreStaffMapper deliveryPickUpStoreStaffMapper; + + @Resource + private AdminUserApi adminUserApi; + + + @Override + public DeliveryPickUpBindStoreStaffIdReqsVO getDeliveryPickUpStoreStaff(Long id, String name) { + //1 查询绑定对应关系 + List storeStaffDOS = deliveryPickUpStoreStaffMapper.selectList(new LambdaQueryWrapperX() + .eq(DeliveryPickUpStoreStaffDO::getStoreId, id) + .eq(DeliveryPickUpStoreStaffDO::getStatus, CommonStatusEnum.ENABLE.getStatus())); + List adminUserIds = storeStaffDOS.stream().map(DeliveryPickUpStoreStaffDO::getAdminUserId).collect(toList()); + //2 查询绑定用户信息 + List storeStaffs = adminUserApi.getUserList(adminUserIds); + return DeliveryPickUpBindStoreStaffIdReqsVO.builder().storeStaffs(storeStaffs).name(name).id(id).build(); + } + + @Override + public void deleteDeliveryPickUpStoreStaff(Long userId, Long storeId) { + //通过用户编号和自提门店id查询 + Long StaffId = deliveryPickUpStoreStaffMapper.selectStaffIdByUserIdAndStoreId(Collections.singletonList(userId), storeId); + // 校验存在 + validateDeliveryPickUpStoreStaffExists(StaffId); + // 删除 + deliveryPickUpStoreStaffMapper.deleteById(StaffId); + } + + @Override + public List selectStaffByUserId(Long userId) { + return deliveryPickUpStoreStaffMapper.selectList(new LambdaQueryWrapper().eq(DeliveryPickUpStoreStaffDO::getAdminUserId,userId)); + } + + private void validateDeliveryPickUpStoreStaffExists(Long id) { + if (deliveryPickUpStoreStaffMapper.selectById(id) == null) { + throw exception(PICK_UP_STORE_STAFF_NOT_EXISTS); + } + } +} diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/user/vo/user/UserPageReqVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/user/vo/user/UserPageReqVO.java index 525cb11c46..9ebe1a9732 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/user/vo/user/UserPageReqVO.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/user/vo/user/UserPageReqVO.java @@ -35,4 +35,7 @@ public class UserPageReqVO extends PageParam { @Schema(description = "部门编号,同时筛选子部门", example = "1024") private Long deptId; + @Schema(description = "角色id", example = "1024") + private Long roleId; + } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/user/AdminUserMapper.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/user/AdminUserMapper.java index 75bf3fa47d..cafd972c25 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/user/AdminUserMapper.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/user/AdminUserMapper.java @@ -25,14 +25,18 @@ public interface AdminUserMapper extends BaseMapperX { return selectOne(AdminUserDO::getMobile, mobile); } - default PageResult selectPage(UserPageReqVO reqVO, Collection deptIds) { - return selectPage(reqVO, new LambdaQueryWrapperX() + default PageResult selectPage(UserPageReqVO reqVO, Collection deptIds,List userIds) { + LambdaQueryWrapperX adminUserDOLambdaQueryWrapperX = new LambdaQueryWrapperX() .likeIfPresent(AdminUserDO::getUsername, reqVO.getUsername()) .likeIfPresent(AdminUserDO::getMobile, reqVO.getMobile()) .eqIfPresent(AdminUserDO::getStatus, reqVO.getStatus()) .betweenIfPresent(AdminUserDO::getCreateTime, reqVO.getCreateTime()) .inIfPresent(AdminUserDO::getDeptId, deptIds) - .orderByDesc(AdminUserDO::getId)); + .orderByDesc(AdminUserDO::getId); + if(userIds != null){ + adminUserDOLambdaQueryWrapperX.in(AdminUserDO::getId, userIds); + } + return selectPage(reqVO, adminUserDOLambdaQueryWrapperX); } default List selectListByNickname(String nickname) { diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/user/AdminUserServiceImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/user/AdminUserServiceImpl.java index cb9a73ff78..c43301c3ed 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/user/AdminUserServiceImpl.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/user/AdminUserServiceImpl.java @@ -22,8 +22,10 @@ import cn.iocoder.yudao.module.system.controller.admin.user.vo.user.UserPageReqV import cn.iocoder.yudao.module.system.controller.admin.user.vo.user.UserSaveReqVO; import cn.iocoder.yudao.module.system.dal.dataobject.dept.DeptDO; import cn.iocoder.yudao.module.system.dal.dataobject.dept.UserPostDO; +import cn.iocoder.yudao.module.system.dal.dataobject.permission.UserRoleDO; import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO; import cn.iocoder.yudao.module.system.dal.mysql.dept.UserPostMapper; +import cn.iocoder.yudao.module.system.dal.mysql.permission.UserRoleMapper; import cn.iocoder.yudao.module.system.dal.mysql.user.AdminUserMapper; import cn.iocoder.yudao.module.system.service.dept.DeptService; import cn.iocoder.yudao.module.system.service.dept.PostService; @@ -44,6 +46,7 @@ import org.springframework.transaction.annotation.Transactional; import java.io.InputStream; import java.time.LocalDateTime; import java.util.*; +import java.util.stream.Collectors; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; @@ -79,6 +82,8 @@ public class AdminUserServiceImpl implements AdminUserService { @Resource private UserPostMapper userPostMapper; + @Resource + private UserRoleMapper userRoleMapper; @Resource private FileApi fileApi; @@ -272,7 +277,13 @@ public class AdminUserServiceImpl implements AdminUserService { @Override public PageResult getUserPage(UserPageReqVO reqVO) { - return userMapper.selectPage(reqVO, getDeptCondition(reqVO.getDeptId())); + List userIds = null; + if (reqVO.getRoleId() != null){ + //查询角色信息 + List userRoleDOS = userRoleMapper.selectListByRoleIds(List.of(reqVO.getRoleId())); + userIds = userRoleDOS.stream().map(UserRoleDO::getUserId).toList(); + } + return userMapper.selectPage(reqVO, getDeptCondition(reqVO.getDeptId()), userIds); } @Override