From 6bfe6285035175b92234b6c9b41dffdaef6a8a55 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sun, 13 Oct 2024 09:47:03 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E4=BB=A3=E7=A0=81=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E3=80=91=E5=95=86=E5=9F=8E=EF=BC=9A=E9=97=A8=E5=BA=97=E8=87=AA?= =?UTF-8?q?=E6=8F=90=E7=9A=84=E5=91=98=E5=B7=A5=E7=BB=91=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/base/system/package-info.java | 4 ++ .../base/system/user/UserSimpleBaseVO.java | 19 +++++++ .../DeliveryPickUpStoreController.java | 51 +++++++++---------- ...eqVO.java => DeliveryPickUpBindReqVO.java} | 12 ++--- .../DeliveryPickUpBindStoreStaffIdReqsVO.java | 27 ---------- .../vo/pickup/DeliveryPickUpStoreRespVO.java | 5 ++ .../DeliveryPickUpStoreSimpleRespVO.java | 5 ++ .../AppDeliverPickUpStoreController.java | 2 +- .../delivery/DeliveryPickUpStoreConvert.java | 5 +- .../delivery/DeliveryPickUpStoreDO.java | 11 ++-- .../delivery/DeliveryPickUpStoreMapper.java | 10 +--- .../delivery/DeliveryPickUpStoreService.java | 35 ++++--------- .../DeliveryPickUpStoreServiceImpl.java | 47 ++++++++--------- .../admin/user/vo/user/UserPageReqVO.java | 2 +- .../dal/mysql/user/AdminUserMapper.java | 15 ++---- .../service/user/AdminUserServiceImpl.java | 19 +++---- 16 files changed, 116 insertions(+), 153 deletions(-) create mode 100644 yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/base/system/package-info.java create mode 100644 yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/base/system/user/UserSimpleBaseVO.java rename yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/pickup/{DeliveryPickUpBindStoreStaffIdReqVO.java => DeliveryPickUpBindReqVO.java} (67%) delete mode 100644 yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/pickup/DeliveryPickUpBindStoreStaffIdReqsVO.java diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/base/system/package-info.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/base/system/package-info.java new file mode 100644 index 0000000000..f1451de5f4 --- /dev/null +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/base/system/package-info.java @@ -0,0 +1,4 @@ +/** + * 占位符,可忽略 + */ +package cn.iocoder.yudao.module.trade.controller.admin.base.system; diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/base/system/user/UserSimpleBaseVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/base/system/user/UserSimpleBaseVO.java new file mode 100644 index 0000000000..39fcd66c9e --- /dev/null +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/base/system/user/UserSimpleBaseVO.java @@ -0,0 +1,19 @@ +package cn.iocoder.yudao.module.trade.controller.admin.base.system.user; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +@Schema(description = "用户精简信息 VO") +@Data +public class UserSimpleBaseVO { + + @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") + private Long id; + + @Schema(description = "用户昵称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿") + private String nickname; + + @Schema(description = "用户头像", example = "https://www.iocoder.cn/1.png") + private String avatar; + +} \ No newline at end of file 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 0aa658d88e..904c246f26 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 @@ -1,8 +1,13 @@ package cn.iocoder.yudao.module.trade.controller.admin.delivery; +import cn.hutool.core.collection.CollUtil; 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.common.util.object.BeanUtils; +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.base.system.user.UserSimpleBaseVO; 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; @@ -10,19 +15,16 @@ import cn.iocoder.yudao.module.trade.service.delivery.DeliveryPickUpStoreService 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 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.getLoginUserId; @Tag(name = "管理后台 - 自提门店") @RestController @@ -33,6 +35,9 @@ public class DeliveryPickUpStoreController { @Resource private DeliveryPickUpStoreService deliveryPickUpStoreService; + @Resource + private AdminUserApi adminUserApi; + @PostMapping("/create") @Operation(summary = "创建自提门店") @PreAuthorize("@ss.hasPermission('trade:delivery:pick-up-store:create')") @@ -63,22 +68,21 @@ public class DeliveryPickUpStoreController { @PreAuthorize("@ss.hasPermission('trade:delivery:pick-up-store:query')") public CommonResult getDeliveryPickUpStore(@RequestParam("id") Long id) { DeliveryPickUpStoreDO deliveryPickUpStore = deliveryPickUpStoreService.getDeliveryPickUpStore(id); - return success(DeliveryPickUpStoreConvert.INSTANCE.convert(deliveryPickUpStore)); + if (deliveryPickUpStore == null) { + return success(null); + } + List verifyUsers = CollUtil.isNotEmpty(deliveryPickUpStore.getVerifyUserIds()) ? + adminUserApi.getUserList(deliveryPickUpStore.getVerifyUserIds()) : null; + return success(BeanUtils.toBean(deliveryPickUpStore, DeliveryPickUpStoreRespVO.class) + .setVerifyUsers(BeanUtils.toBean(verifyUsers, UserSimpleBaseVO.class))); } - @GetMapping("/list-all-simple") + @GetMapping("/simple-list") @Operation(summary = "获得自提门店精简信息列表") public CommonResult> getSimpleDeliveryPickUpStoreList() { - List storeStaffDOS = deliveryPickUpStoreService.selectStaffByUserId(getLoginUserId()); - List storeIds = storeStaffDOS.stream().map(DeliveryPickUpStoreDO::getId).toList(); - if(!storeIds.isEmpty()){ - List list = deliveryPickUpStoreService.getDeliveryPickUpStoreListByStatus( - CommonStatusEnum.ENABLE.getStatus(), storeIds); - return success(DeliveryPickUpStoreConvert.INSTANCE.convertList1(list)); - }else{ - return success(new ArrayList<>()); - } - + List list = deliveryPickUpStoreService.getDeliveryPickUpStoreListByStatus( + CommonStatusEnum.ENABLE.getStatus()); + return success(DeliveryPickUpStoreConvert.INSTANCE.convertList1(list)); } @GetMapping("/list") @@ -101,18 +105,9 @@ public class DeliveryPickUpStoreController { @PostMapping("/bind") @Operation(summary = "绑定自提店员") @PreAuthorize("@ss.hasPermission('trade:delivery:pick-up-store:create')") - public CommonResult bindDeliveryPickUpBindStoreStaffId(@Valid @RequestBody DeliveryPickUpBindStoreStaffIdReqVO bindStoreStaffIdVO) { - deliveryPickUpStoreService.bindDeliveryPickUpBindStoreStaffId(bindStoreStaffIdVO); + public CommonResult bindDeliveryPickUpStore(@Valid @RequestBody DeliveryPickUpBindReqVO bindReqVO) { + deliveryPickUpStoreService.bindDeliveryPickUpStore(bindReqVO); 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) { - return success(deliveryPickUpStoreService.getDeliveryPickUpStoreStaff(id)); - } - - } 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/DeliveryPickUpBindReqVO.java similarity index 67% rename from yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/pickup/DeliveryPickUpBindStoreStaffIdReqVO.java rename to yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/pickup/DeliveryPickUpBindReqVO.java index 76ccd49449..7ee808977e 100644 --- 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/DeliveryPickUpBindReqVO.java @@ -1,24 +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.NotEmpty; import jakarta.validation.constraints.NotNull; import lombok.Data; -import lombok.EqualsAndHashCode; import lombok.ToString; import java.util.List; -@Schema(description = "管理后台 - 自提门店创建 Request VO") +@Schema(description = "管理后台 - 自提门店绑定核销人 Request VO") @Data @ToString(callSuper = true) -public class DeliveryPickUpBindStoreStaffIdReqVO { +public class DeliveryPickUpBindReqVO { @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; + @NotEmpty(message = "绑定用户编号组数不能未空") + private List verifyUserIds; -} +} \ No newline at end of file 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 deleted file mode 100644 index 3f87767c4f..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/pickup/DeliveryPickUpBindStoreStaffIdReqsVO.java +++ /dev/null @@ -1,27 +0,0 @@ -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/admin/delivery/vo/pickup/DeliveryPickUpStoreRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/pickup/DeliveryPickUpStoreRespVO.java index 5b5bd0d0c8..fdf39a46d7 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/pickup/DeliveryPickUpStoreRespVO.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/pickup/DeliveryPickUpStoreRespVO.java @@ -1,11 +1,13 @@ package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup; +import cn.iocoder.yudao.module.trade.controller.admin.base.system.user.UserSimpleBaseVO; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.ToString; import java.time.LocalDateTime; +import java.util.List; @Schema(description = "管理后台 - 自提门店 Response VO") @Data @@ -19,4 +21,7 @@ public class DeliveryPickUpStoreRespVO extends DeliveryPickUpStoreBaseVO { @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) private LocalDateTime createTime; + @Schema(description = "核销用户数组", requiredMode = Schema.RequiredMode.REQUIRED) + private List verifyUsers; + } diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/pickup/DeliveryPickUpStoreSimpleRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/pickup/DeliveryPickUpStoreSimpleRespVO.java index c12fc9fc3e..ac688f3f83 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/pickup/DeliveryPickUpStoreSimpleRespVO.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/pickup/DeliveryPickUpStoreSimpleRespVO.java @@ -5,6 +5,8 @@ import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; +import java.util.List; + @Schema(description = "管理后台 - 自提门店精简信息 Response VO") @Data @NoArgsConstructor @@ -29,4 +31,7 @@ public class DeliveryPickUpStoreSimpleRespVO { @Schema(description = "门店详细地址", requiredMode = Schema.RequiredMode.REQUIRED, example = "复旦大学路 188 号") private String detailAddress; + @Schema(description = "绑定用户编号组数", requiredMode = Schema.RequiredMode.REQUIRED, example = "23128") + private List verifyUserIds; + } 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 1f7109d9fc..6a923fe368 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(), null); + CommonStatusEnum.ENABLE.getStatus()); 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/convert/delivery/DeliveryPickUpStoreConvert.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/delivery/DeliveryPickUpStoreConvert.java index 1d5b360a5d..05d8a8f013 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/delivery/DeliveryPickUpStoreConvert.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/delivery/DeliveryPickUpStoreConvert.java @@ -26,8 +26,6 @@ public interface DeliveryPickUpStoreConvert { DeliveryPickUpStoreDO convert(DeliveryPickUpStoreUpdateReqVO bean); - DeliveryPickUpStoreRespVO convert(DeliveryPickUpStoreDO bean); - List convertList(List list); PageResult convertPage(PageResult page); @@ -43,14 +41,13 @@ public interface DeliveryPickUpStoreConvert { default List convertList(List list, Double latitude, Double longitude) { - List voList = CollectionUtils.convertList(list, store -> { + return CollectionUtils.convertList(list, store -> { AppDeliveryPickUpStoreRespVO storeVO = convert03(store); if (latitude != null && longitude != null) { storeVO.setDistance(NumberUtils.getDistance(latitude, longitude, storeVO.getLatitude(), storeVO.getLongitude())); } return storeVO; }); - return voList; } @Mapping(source = "areaId", target = "areaName", qualifiedByName = "convertAreaIdToAreaName") AppDeliveryPickUpStoreRespVO convert03(DeliveryPickUpStoreDO bean); diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/delivery/DeliveryPickUpStoreDO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/delivery/DeliveryPickUpStoreDO.java index 9e8015950a..93fe74f2ac 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/delivery/DeliveryPickUpStoreDO.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/delivery/DeliveryPickUpStoreDO.java @@ -3,11 +3,11 @@ package cn.iocoder.yudao.module.trade.dal.dataobject.delivery; import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; import cn.iocoder.yudao.framework.mybatis.core.type.LongListTypeHandler; +import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; import com.baomidou.mybatisplus.annotation.KeySequence; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; -import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler; import lombok.Data; import java.time.LocalTime; @@ -77,11 +77,16 @@ public class DeliveryPickUpStoreDO extends BaseDO { * 经度 */ private Double longitude; + /** - * 店员id列表 + * 核销员工用户编号数组 + * + * 订单自提核销时,只有对应门店的店员才能核销 + * + * 关联 {@link AdminUserRespDTO#getId()} 管理员编号 */ @TableField(typeHandler = LongListTypeHandler.class) - private List staffIds; + private List verifyUserIds; /** * 门店状态 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 cfe55a5faf..b26b1c0159 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,16 +22,10 @@ public interface DeliveryPickUpStoreMapper extends BaseMapperX selectListByStatus(Integer status, List storeIds) { - return selectList(new LambdaQueryWrapperX() - .eq(DeliveryPickUpStoreDO::getStatus, status) - .inIfPresent(DeliveryPickUpStoreDO::getId, storeIds)); + default List selectListByStatus(Integer status) { + return selectList(DeliveryPickUpStoreDO::getStatus, status); } - default List selectStaffByUserId(Long userId){ - return selectList(new LambdaQueryWrapperX() - .and(userId != null, w -> w.apply("FIND_IN_SET({0}, staff_ids)", userId))); - } } 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 87c9c0f7e6..fb40871b94 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 @@ -53,6 +53,14 @@ public interface DeliveryPickUpStoreService { */ List getDeliveryPickUpStoreList(Collection ids); + /** + * 获得指定状态的自提门店列表 + * + * @param status 状态 + * @return 自提门店列表 + */ + List getDeliveryPickUpStoreListByStatus(Integer status); + /** * 获得自提门店分页 * @@ -61,34 +69,11 @@ public interface DeliveryPickUpStoreService { */ PageResult getDeliveryPickUpStorePage(DeliveryPickUpStorePageReqVO pageReqVO); - /** - * 获得指定状态的自提门店列表 - * - * @param status 状态 - * @param storeIds 指定门店id - * @return 自提门店列表 - */ - List getDeliveryPickUpStoreListByStatus(Integer status, List storeIds); - /** * 绑定自提店员 * - * @param bindStoreStaffIdVO 绑定数据 - * @return + * @param bindReqVO 绑定数据 */ - void bindDeliveryPickUpBindStoreStaffId(DeliveryPickUpBindStoreStaffIdReqVO bindStoreStaffIdVO); + void bindDeliveryPickUpStore(DeliveryPickUpBindReqVO bindReqVO); - /** - * 根据门店id获取自提店员 - * @param id 门店id - * @return 自提店员 - */ - DeliveryPickUpBindStoreStaffIdReqsVO getDeliveryPickUpStoreStaff(Long id); - - /** - * 根据用户id查询自提门店店员信息 - * @param userId 用户id - * @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/DeliveryPickUpStoreServiceImpl.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/delivery/DeliveryPickUpStoreServiceImpl.java index b83673e03f..8f54fc8e25 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,16 +1,19 @@ package cn.iocoder.yudao.module.trade.service.delivery; import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; 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.controller.admin.delivery.vo.pickup.DeliveryPickUpBindReqVO; +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.mysql.delivery.DeliveryPickUpStoreMapper; +import jakarta.annotation.Resource; import org.springframework.stereotype.Service; import org.springframework.validation.annotation.Validated; -import jakarta.annotation.Resource; import java.util.Collection; import java.util.List; @@ -59,7 +62,8 @@ public class DeliveryPickUpStoreServiceImpl implements DeliveryPickUpStoreServic } private void validateDeliveryPickUpStoreExists(Long id) { - if (deliveryPickUpStoreMapper.selectById(id) == null) { + DeliveryPickUpStoreDO deliveryPickUpStore = deliveryPickUpStoreMapper.selectById(id); + if (deliveryPickUpStore == null) { throw exception(PICK_UP_STORE_NOT_EXISTS); } } @@ -74,35 +78,26 @@ public class DeliveryPickUpStoreServiceImpl implements DeliveryPickUpStoreServic return deliveryPickUpStoreMapper.selectBatchIds(ids); } + @Override + public List getDeliveryPickUpStoreListByStatus(Integer status) { + return deliveryPickUpStoreMapper.selectListByStatus(status); + } + @Override public PageResult getDeliveryPickUpStorePage(DeliveryPickUpStorePageReqVO pageReqVO) { return deliveryPickUpStoreMapper.selectPage(pageReqVO); } @Override - public List getDeliveryPickUpStoreListByStatus(Integer status, List storeIds) { - return deliveryPickUpStoreMapper.selectListByStatus(status, storeIds); - } + public void bindDeliveryPickUpStore(DeliveryPickUpBindReqVO bindReqVO) { + // 1.1 校验门店存在 + validateDeliveryPickUpStoreExists(bindReqVO.getId()); + // 1.2 校验用户存在 + adminUserApi.validateUserList(bindReqVO.getVerifyUserIds()); - @Override - public void bindDeliveryPickUpBindStoreStaffId(DeliveryPickUpBindStoreStaffIdReqVO bindStoreStaffIdVO) { - DeliveryPickUpStoreDO deliveryPickUpStoreDO = deliveryPickUpStoreMapper.selectById(bindStoreStaffIdVO.getId()); - deliveryPickUpStoreDO.setStaffIds(bindStoreStaffIdVO.getStoreStaffIds()); - deliveryPickUpStoreMapper.updateById(deliveryPickUpStoreDO); - } - - @Override - public DeliveryPickUpBindStoreStaffIdReqsVO getDeliveryPickUpStoreStaff(Long id) { - DeliveryPickUpStoreDO store = deliveryPickUpStoreMapper.selectById(id); - List adminUserIds = store.getStaffIds(); - //2 查询绑定用户信息 - List storeStaffs = adminUserApi.getUserList(adminUserIds); - return DeliveryPickUpBindStoreStaffIdReqsVO.builder().storeStaffs(storeStaffs).name(store.getName()).id(id).build(); - } - - @Override - public List selectStaffByUserId(Long userId) { - return deliveryPickUpStoreMapper.selectStaffByUserId(userId); + // 2. 更新 + DeliveryPickUpStoreDO updateObj = BeanUtils.toBean(bindReqVO, DeliveryPickUpStoreDO.class); + deliveryPickUpStoreMapper.updateById(updateObj); } } 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 9ebe1a9732..7dadb513ba 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,7 +35,7 @@ public class UserPageReqVO extends PageParam { @Schema(description = "部门编号,同时筛选子部门", example = "1024") private Long deptId; - @Schema(description = "角色id", example = "1024") + @Schema(description = "角色编号", 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 81fccd8070..c0c9be8e42 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 @@ -7,7 +7,6 @@ import cn.iocoder.yudao.module.system.controller.admin.user.vo.user.UserPageReqV import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO; import org.apache.ibatis.annotations.Mapper; -import java.util.ArrayList; import java.util.Collection; import java.util.List; @@ -26,21 +25,15 @@ public interface AdminUserMapper extends BaseMapperX { return selectOne(AdminUserDO::getMobile, mobile); } - default PageResult selectPage(UserPageReqVO reqVO, Collection deptIds,List userIds) { - LambdaQueryWrapperX adminUserDOLambdaQueryWrapperX = new LambdaQueryWrapperX() + default PageResult selectPage(UserPageReqVO reqVO, Collection deptIds, Collection userIds) { + return selectPage(reqVO, 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); - if(userIds != null){ - if(userIds.isEmpty()){ - return new PageResult().setList(new ArrayList<>()).setTotal(0L); - } - adminUserDOLambdaQueryWrapperX.in(AdminUserDO::getId, userIds); - } - return selectPage(reqVO, adminUserDOLambdaQueryWrapperX); + .inIfPresent(AdminUserDO::getId, userIds) + .orderByDesc(AdminUserDO::getId)); } 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 c43301c3ed..d491b8256f 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,10 +22,8 @@ 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; @@ -46,11 +44,9 @@ 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; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.*; import static cn.iocoder.yudao.module.system.enums.LogRecordConstants.*; @@ -82,8 +78,6 @@ public class AdminUserServiceImpl implements AdminUserService { @Resource private UserPostMapper userPostMapper; - @Resource - private UserRoleMapper userRoleMapper; @Resource private FileApi fileApi; @@ -277,12 +271,11 @@ public class AdminUserServiceImpl implements AdminUserService { @Override public PageResult getUserPage(UserPageReqVO reqVO) { - List userIds = null; - if (reqVO.getRoleId() != null){ - //查询角色信息 - List userRoleDOS = userRoleMapper.selectListByRoleIds(List.of(reqVO.getRoleId())); - userIds = userRoleDOS.stream().map(UserRoleDO::getUserId).toList(); - } + // 如果有角色编号,查询角色对应的用户编号 + Set userIds = reqVO.getRoleId() != null ? + permissionService.getUserRoleIdListByRoleId(singleton(reqVO.getRoleId())) : null; + + // 分页查询 return userMapper.selectPage(reqVO, getDeptCondition(reqVO.getDeptId()), userIds); }