From 3a5067deb00a1c985cc960bcf37fbaa3b59c9fc7 Mon Sep 17 00:00:00 2001 From: zjf <1799650030@qq.com> Date: Thu, 2 Jan 2025 11:48:21 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E8=B6=85=E5=B8=82=E6=89=A3=E5=87=8F?= =?UTF-8?q?=E5=BA=93=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/SupermarketSpuUpdateStockReqDTO.java | 47 +++++++++++++++++++ .../controller/SupermarketSpuController.java | 8 +++- .../controller/SupermarketUnitController.java | 3 ++ .../entity/SupermarketSpuEntity.java | 4 ++ .../mapper/SupermarketSpuMapper.java | 24 ++++++++++ .../service/SupermarketSpuService.java | 9 ++++ .../service/SupermarketUnitService.java | 1 + .../impl/SupermarketSpuServiceImpl.java | 17 +++++++ .../resources/mapper/SupermarketSpuMapper.xml | 1 + 9 files changed, 113 insertions(+), 1 deletion(-) create mode 100644 pjcloud-supermarket/pjcloud-supermarket-api/src/main/java/com/bsd/pjcloud/supermarket/dto/SupermarketSpuUpdateStockReqDTO.java diff --git a/pjcloud-supermarket/pjcloud-supermarket-api/src/main/java/com/bsd/pjcloud/supermarket/dto/SupermarketSpuUpdateStockReqDTO.java b/pjcloud-supermarket/pjcloud-supermarket-api/src/main/java/com/bsd/pjcloud/supermarket/dto/SupermarketSpuUpdateStockReqDTO.java new file mode 100644 index 000000000..952654286 --- /dev/null +++ b/pjcloud-supermarket/pjcloud-supermarket-api/src/main/java/com/bsd/pjcloud/supermarket/dto/SupermarketSpuUpdateStockReqDTO.java @@ -0,0 +1,47 @@ +package com.bsd.pjcloud.supermarket.dto; + +import jakarta.validation.constraints.NotNull; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * 商品 SKU 更新库存 Request DTO + * + * @author LeeYan9 + * @since 2022-08-26 + */ +@Data +@NoArgsConstructor +@AllArgsConstructor +public class SupermarketSpuUpdateStockReqDTO { + + /** + * 商品 SKU + */ + @NotNull(message = "商品 SPU 不能为空") + private List items; + + @Data + public static class Item { + + /** + * 商品 SKU 编号 + */ + @NotNull(message = "商品 SPU 编号不能为空") + private Long id; + + /** + * 库存变化数量 + * + * 正数:增加库存 + * 负数:扣减库存 + */ + @NotNull(message = "库存变化数量不能为空") + private Integer incrCount; + + } + +} diff --git a/pjcloud-supermarket/pjcloud-supermarket-biz/src/main/java/com/bsd/pjcloud/supermarket/controller/SupermarketSpuController.java b/pjcloud-supermarket/pjcloud-supermarket-biz/src/main/java/com/bsd/pjcloud/supermarket/controller/SupermarketSpuController.java index 688247a24..7bfe61426 100644 --- a/pjcloud-supermarket/pjcloud-supermarket-biz/src/main/java/com/bsd/pjcloud/supermarket/controller/SupermarketSpuController.java +++ b/pjcloud-supermarket/pjcloud-supermarket-biz/src/main/java/com/bsd/pjcloud/supermarket/controller/SupermarketSpuController.java @@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.bsd.pjcloud.common.core.util.R; import com.bsd.pjcloud.common.log.annotation.SysLog; +import com.bsd.pjcloud.supermarket.dto.SupermarketSpuUpdateStockReqDTO; import com.bsd.pjcloud.supermarket.entity.SupermarketSpuEntity; import com.bsd.pjcloud.supermarket.service.SupermarketSpuService; import org.springframework.security.access.prepost.PreAuthorize; @@ -21,7 +22,6 @@ import lombok.RequiredArgsConstructor; import org.springframework.web.bind.annotation.*; import java.util.List; -import java.util.Objects; /** * 商品spu @@ -120,4 +120,10 @@ public class SupermarketSpuController { public List export(SupermarketSpuEntity supermarketSpu,Long[] ids) { return supermarketSpuService.list(Wrappers.lambdaQuery(supermarketSpu).in(ArrayUtil.isNotEmpty(ids), SupermarketSpuEntity::getId, ids)); } + + @PostMapping("/ad/updateSpuStock") + @SysLog("更新商品库存") + public R updateSkuStock(@RequestBody SupermarketSpuUpdateStockReqDTO updateStockReqDTO){ + return supermarketSpuService.updateSpuStock(updateStockReqDTO); + } } \ No newline at end of file diff --git a/pjcloud-supermarket/pjcloud-supermarket-biz/src/main/java/com/bsd/pjcloud/supermarket/controller/SupermarketUnitController.java b/pjcloud-supermarket/pjcloud-supermarket-biz/src/main/java/com/bsd/pjcloud/supermarket/controller/SupermarketUnitController.java index e548b2cee..7c5945e9f 100644 --- a/pjcloud-supermarket/pjcloud-supermarket-biz/src/main/java/com/bsd/pjcloud/supermarket/controller/SupermarketUnitController.java +++ b/pjcloud-supermarket/pjcloud-supermarket-biz/src/main/java/com/bsd/pjcloud/supermarket/controller/SupermarketUnitController.java @@ -119,4 +119,7 @@ public class SupermarketUnitController { public List export(SupermarketUnitEntity supermarketUnit,Long[] ids) { return supermarketUnitService.list(Wrappers.lambdaQuery(supermarketUnit).in(ArrayUtil.isNotEmpty(ids), SupermarketUnitEntity::getId, ids)); } + + + } \ No newline at end of file diff --git a/pjcloud-supermarket/pjcloud-supermarket-biz/src/main/java/com/bsd/pjcloud/supermarket/entity/SupermarketSpuEntity.java b/pjcloud-supermarket/pjcloud-supermarket-biz/src/main/java/com/bsd/pjcloud/supermarket/entity/SupermarketSpuEntity.java index 558ee43f2..7d78ef2d4 100644 --- a/pjcloud-supermarket/pjcloud-supermarket-biz/src/main/java/com/bsd/pjcloud/supermarket/entity/SupermarketSpuEntity.java +++ b/pjcloud-supermarket/pjcloud-supermarket-biz/src/main/java/com/bsd/pjcloud/supermarket/entity/SupermarketSpuEntity.java @@ -309,6 +309,10 @@ public class SupermarketSpuEntity extends Model { @Schema(description="租户编号") private Long tenantId; + + @Schema(description = "销量") + private Integer salesCount; + @Schema(description = "辅助条码集合对象") @TableField(exist = false) private List supermarketAuxiliaryCodeEntityList; diff --git a/pjcloud-supermarket/pjcloud-supermarket-biz/src/main/java/com/bsd/pjcloud/supermarket/mapper/SupermarketSpuMapper.java b/pjcloud-supermarket/pjcloud-supermarket-biz/src/main/java/com/bsd/pjcloud/supermarket/mapper/SupermarketSpuMapper.java index cdb018253..63e578a50 100644 --- a/pjcloud-supermarket/pjcloud-supermarket-biz/src/main/java/com/bsd/pjcloud/supermarket/mapper/SupermarketSpuMapper.java +++ b/pjcloud-supermarket/pjcloud-supermarket-biz/src/main/java/com/bsd/pjcloud/supermarket/mapper/SupermarketSpuMapper.java @@ -1,5 +1,6 @@ package com.bsd.pjcloud.supermarket.mapper; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.bsd.pjcloud.common.data.datascope.PjcloudBaseMapper; import com.bsd.pjcloud.supermarket.entity.SupermarketSpuEntity; import org.apache.ibatis.annotations.Mapper; @@ -8,4 +9,27 @@ import org.apache.ibatis.annotations.Mapper; public interface SupermarketSpuMapper extends PjcloudBaseMapper { + /** + * 更新商品 SPU 库存 + * + * @param id 商品 SPU 编号 + * @param incrCount 增加的库存数量 + */ + default int updateStock(Long id, Integer incrCount) { + // 拼接 SQL + if (incrCount == 0) { + return 0; + } + String sql; + if (incrCount > 0) { + sql = " stock = stock + " + incrCount + ", sales_count = sales_count - " + incrCount; + } else { + sql = " stock = stock - " + Math.abs(incrCount) + ", sales_count = sales_count + " + Math.abs(incrCount); + } + // 执行更新 + LambdaUpdateWrapper updateWrapper = new LambdaUpdateWrapper() + .setSql(sql) + .eq(SupermarketSpuEntity::getId, id); + return update(null, updateWrapper); + } } \ No newline at end of file diff --git a/pjcloud-supermarket/pjcloud-supermarket-biz/src/main/java/com/bsd/pjcloud/supermarket/service/SupermarketSpuService.java b/pjcloud-supermarket/pjcloud-supermarket-biz/src/main/java/com/bsd/pjcloud/supermarket/service/SupermarketSpuService.java index b88405738..e332ec451 100644 --- a/pjcloud-supermarket/pjcloud-supermarket-biz/src/main/java/com/bsd/pjcloud/supermarket/service/SupermarketSpuService.java +++ b/pjcloud-supermarket/pjcloud-supermarket-biz/src/main/java/com/bsd/pjcloud/supermarket/service/SupermarketSpuService.java @@ -2,6 +2,7 @@ package com.bsd.pjcloud.supermarket.service; import com.baomidou.mybatisplus.extension.service.IService; import com.bsd.pjcloud.common.core.util.R; +import com.bsd.pjcloud.supermarket.dto.SupermarketSpuUpdateStockReqDTO; import com.bsd.pjcloud.supermarket.entity.SupermarketSpuEntity; import java.util.ArrayList; @@ -16,4 +17,12 @@ public interface SupermarketSpuService extends IService { Object removeSpuBatchByIds(ArrayList list); + + + /** + * 更新商品库存 + * @param updateStockReqDTO + * @return + */ + R updateSpuStock(SupermarketSpuUpdateStockReqDTO updateStockReqDTO); } \ No newline at end of file diff --git a/pjcloud-supermarket/pjcloud-supermarket-biz/src/main/java/com/bsd/pjcloud/supermarket/service/SupermarketUnitService.java b/pjcloud-supermarket/pjcloud-supermarket-biz/src/main/java/com/bsd/pjcloud/supermarket/service/SupermarketUnitService.java index 634f8ba31..ec3eb3031 100644 --- a/pjcloud-supermarket/pjcloud-supermarket-biz/src/main/java/com/bsd/pjcloud/supermarket/service/SupermarketUnitService.java +++ b/pjcloud-supermarket/pjcloud-supermarket-biz/src/main/java/com/bsd/pjcloud/supermarket/service/SupermarketUnitService.java @@ -5,4 +5,5 @@ import com.bsd.pjcloud.supermarket.entity.SupermarketUnitEntity; public interface SupermarketUnitService extends IService { + } \ No newline at end of file diff --git a/pjcloud-supermarket/pjcloud-supermarket-biz/src/main/java/com/bsd/pjcloud/supermarket/service/impl/SupermarketSpuServiceImpl.java b/pjcloud-supermarket/pjcloud-supermarket-biz/src/main/java/com/bsd/pjcloud/supermarket/service/impl/SupermarketSpuServiceImpl.java index 1425e56c9..6f09adddf 100644 --- a/pjcloud-supermarket/pjcloud-supermarket-biz/src/main/java/com/bsd/pjcloud/supermarket/service/impl/SupermarketSpuServiceImpl.java +++ b/pjcloud-supermarket/pjcloud-supermarket-biz/src/main/java/com/bsd/pjcloud/supermarket/service/impl/SupermarketSpuServiceImpl.java @@ -3,6 +3,7 @@ package com.bsd.pjcloud.supermarket.service.impl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.bsd.pjcloud.common.core.util.R; +import com.bsd.pjcloud.supermarket.dto.SupermarketSpuUpdateStockReqDTO; import com.bsd.pjcloud.supermarket.entity.SupermarketAuxiliaryCodeEntity; import com.bsd.pjcloud.supermarket.entity.SupermarketSpuEntity; import com.bsd.pjcloud.supermarket.entity.SupermarketUnitEntity; @@ -106,4 +107,20 @@ public class SupermarketSpuServiceImpl extends ServiceImpl { + int i = baseMapper.updateStock(item.getId(), item.getIncrCount()); + if (item.getIncrCount() < 0) { + if (i == 0) { + R.failed("商品库存不足"); + } + } + }); + + return R.ok(); + } } \ No newline at end of file diff --git a/pjcloud-supermarket/pjcloud-supermarket-biz/src/main/resources/mapper/SupermarketSpuMapper.xml b/pjcloud-supermarket/pjcloud-supermarket-biz/src/main/resources/mapper/SupermarketSpuMapper.xml index 675c8c4de..3bb75673d 100644 --- a/pjcloud-supermarket/pjcloud-supermarket-biz/src/main/resources/mapper/SupermarketSpuMapper.xml +++ b/pjcloud-supermarket/pjcloud-supermarket-biz/src/main/resources/mapper/SupermarketSpuMapper.xml @@ -50,5 +50,6 @@ + \ No newline at end of file From 9ab12753b8a63a50c95204ad5695490a4f926c8b Mon Sep 17 00:00:00 2001 From: zjf <1799650030@qq.com> Date: Thu, 2 Jan 2025 17:58:55 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E8=B6=85=E5=B8=82=EF=BC=8C=E9=A3=9F?= =?UTF-8?q?=E5=A0=82=E6=A8=A1=E5=9D=97=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../feign/RemoteCanteenCategoryService.java | 44 ++++++++++ .../api/feign/RemoteCanteenSpuService.java | 57 +++++++++++++ .../bsd/pjcloud/canteen/dto/DailyMenuAll.java | 2 +- .../canteen/vo/ADCanteenSpuListVO.java | 82 +++++++++++++++++++ .../controller/CanteenCategoryController.java | 4 +- .../controller/CanteenSpuController.java | 11 +++ .../service/CanteenCategoryService.java | 10 +++ .../canteen/service/CanteenSpuService.java | 7 ++ .../impl/CanteenCategoryServiceImpl.java | 5 ++ .../service/impl/CanteenSpuServiceImpl.java | 11 +++ .../core/constant/ServiceNameConstants.java | 10 +++ .../RemoteSupermarketCategoryService.java | 46 +++++++++++ .../feign/RemoteSupermarketSpuService.java | 42 ++++++++++ .../SupermarketCategoryController.java | 2 +- .../controller/SupermarketSpuController.java | 17 +++- .../service/SupermarketSpuService.java | 18 ++++ .../impl/SupermarketSpuServiceImpl.java | 15 ++++ 17 files changed, 378 insertions(+), 5 deletions(-) create mode 100644 pjcloud-canteen/pjcloud-canteen-api/src/main/java/com/bsd/pjcloud/canteen/api/feign/RemoteCanteenCategoryService.java create mode 100644 pjcloud-canteen/pjcloud-canteen-api/src/main/java/com/bsd/pjcloud/canteen/api/feign/RemoteCanteenSpuService.java create mode 100644 pjcloud-canteen/pjcloud-canteen-api/src/main/java/com/bsd/pjcloud/canteen/vo/ADCanteenSpuListVO.java create mode 100644 pjcloud-supermarket/pjcloud-supermarket-api/src/main/java/com/bsd/pjcloud/supermarket/api/feign/RemoteSupermarketCategoryService.java create mode 100644 pjcloud-supermarket/pjcloud-supermarket-api/src/main/java/com/bsd/pjcloud/supermarket/api/feign/RemoteSupermarketSpuService.java diff --git a/pjcloud-canteen/pjcloud-canteen-api/src/main/java/com/bsd/pjcloud/canteen/api/feign/RemoteCanteenCategoryService.java b/pjcloud-canteen/pjcloud-canteen-api/src/main/java/com/bsd/pjcloud/canteen/api/feign/RemoteCanteenCategoryService.java new file mode 100644 index 000000000..d498550d7 --- /dev/null +++ b/pjcloud-canteen/pjcloud-canteen-api/src/main/java/com/bsd/pjcloud/canteen/api/feign/RemoteCanteenCategoryService.java @@ -0,0 +1,44 @@ +/* + * + * Copyright (c) 2018-2025, pjcloud All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: pjcloud + * + */ + +package com.bsd.pjcloud.canteen.api.feign; + + +import com.bsd.pjcloud.common.core.constant.ServiceNameConstants; +import com.bsd.pjcloud.common.core.util.R; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.*; + +/** + * @author zjf + * @date 2018/6/22 + */ +@FeignClient(contextId = "remoteUserService", value = ServiceNameConstants.CANTEEN_SERVICE) +public interface RemoteCanteenCategoryService { + + + /** + * 查询所有的菜品分类 + * @param categoryType 餐段类型,1早餐 2中 3晚餐 不传默认所有 + * @return R + */ + @GetMapping("/canteenCategory/getAllSimple") + R getAllSimple(@RequestParam(value = "categoryType",required = false) String categoryType); + +} diff --git a/pjcloud-canteen/pjcloud-canteen-api/src/main/java/com/bsd/pjcloud/canteen/api/feign/RemoteCanteenSpuService.java b/pjcloud-canteen/pjcloud-canteen-api/src/main/java/com/bsd/pjcloud/canteen/api/feign/RemoteCanteenSpuService.java new file mode 100644 index 000000000..02351e614 --- /dev/null +++ b/pjcloud-canteen/pjcloud-canteen-api/src/main/java/com/bsd/pjcloud/canteen/api/feign/RemoteCanteenSpuService.java @@ -0,0 +1,57 @@ +/* + * + * Copyright (c) 2018-2025, pjcloud All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: pjcloud + * + */ + +package com.bsd.pjcloud.canteen.api.feign; + + +import com.bsd.pjcloud.canteen.dto.CanteenSpuUpdateStockReqDTO; +import com.bsd.pjcloud.common.core.constant.ServiceNameConstants; +import com.bsd.pjcloud.common.core.util.R; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestParam; + +/** + * @author zjf + * @date 2018/6/22 + */ +@FeignClient(contextId = "remoteUserService", value = ServiceNameConstants.CANTEEN_SERVICE) +public interface RemoteCanteenSpuService { + + + /** + * 获取菜品列表 + * @param categoryId 不填默认查全部 + * @return + */ + @GetMapping("/canteenSpu/ad/getCanteenSpuList") + R getCanteenSpuList(@RequestParam(value = "categoryId",required = false)String categoryId); + + + /** + * 扣减菜品库存 + * @param updateStockReqDTO + * @return + */ + @PostMapping("/canteenSpu/ad/updateSkuStock") + R getAllSimple(@RequestBody CanteenSpuUpdateStockReqDTO updateStockReqDTO); + +} diff --git a/pjcloud-canteen/pjcloud-canteen-api/src/main/java/com/bsd/pjcloud/canteen/dto/DailyMenuAll.java b/pjcloud-canteen/pjcloud-canteen-api/src/main/java/com/bsd/pjcloud/canteen/dto/DailyMenuAll.java index cdfebdb7e..480ecff37 100644 --- a/pjcloud-canteen/pjcloud-canteen-api/src/main/java/com/bsd/pjcloud/canteen/dto/DailyMenuAll.java +++ b/pjcloud-canteen/pjcloud-canteen-api/src/main/java/com/bsd/pjcloud/canteen/dto/DailyMenuAll.java @@ -7,7 +7,7 @@ import java.util.List; /** * @author ml - * 菜品下拉框主页展示 + * 后台每日菜谱菜品下拉框 */ @Data public class DailyMenuAll { diff --git a/pjcloud-canteen/pjcloud-canteen-api/src/main/java/com/bsd/pjcloud/canteen/vo/ADCanteenSpuListVO.java b/pjcloud-canteen/pjcloud-canteen-api/src/main/java/com/bsd/pjcloud/canteen/vo/ADCanteenSpuListVO.java new file mode 100644 index 000000000..76ca68bff --- /dev/null +++ b/pjcloud-canteen/pjcloud-canteen-api/src/main/java/com/bsd/pjcloud/canteen/vo/ADCanteenSpuListVO.java @@ -0,0 +1,82 @@ +package com.bsd.pjcloud.canteen.vo; + + +import com.baomidou.mybatisplus.annotation.*; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.time.LocalDateTime; + +@Data +@Schema(description = "安卓机在线点餐获取菜品信息") +public class ADCanteenSpuListVO { + + + /** + * 商品 SPU 编号,自增 + */ + @Schema(description="商品 SPU 编号,自增") + private Long id; + + /** + * 商品名称 + */ + @Schema(description="商品名称") + private String name; + + + /** + * 商品分类编号 + */ + @Schema(description="商品分类编号") + private Long categoryId; + + /** + * 商品封面图 + */ + @Schema(description="商品封面图") + private String picUrl; + + + /** + * 商品价格,单位使用:分 + */ + @Schema(description="商品价格,单位使用:分") + private Integer price; + + + /** + * 市场价,单位使用:分 + */ + @Schema(description="市场价,单位使用:分") + private Integer marketPrice; + + + /** + * 库存 + */ + @Schema(description="库存") + private Integer stock; + + + /** + * 商品销量 + */ + @Schema(description="商品销量") + private Integer salesCount; + + + /** + * 商户编号 + */ + @Schema(description="商户编号") + private Long merchantId; + + /** + * 部门id + */ + @Schema(description="部门id") + private Long deptId; + + +} diff --git a/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/controller/CanteenCategoryController.java b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/controller/CanteenCategoryController.java index aaa456975..2b627c938 100644 --- a/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/controller/CanteenCategoryController.java +++ b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/controller/CanteenCategoryController.java @@ -134,8 +134,8 @@ public class CanteenCategoryController { public R getAllSimple(@RequestParam(value = "categoryType",required = false)String categoryType) { LambdaQueryWrapper wrapper = Wrappers.lambdaQuery(); wrapper.orderByAsc(CanteenCategoryEntity::getSort); - wrapper.eq(StringUtils.isNotEmpty(categoryType),CanteenCategoryEntity::getCategoryType,categoryType); - List list = canteenCategoryService.list(wrapper); + wrapper.apply(StringUtils.isNotEmpty(categoryType),"FIND_IN_SET({0}, your_column_name)",categoryType); + List list = canteenCategoryService.listScope(wrapper); return R.ok(list); } } \ No newline at end of file diff --git a/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/controller/CanteenSpuController.java b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/controller/CanteenSpuController.java index 4919cb4ac..839bf5000 100644 --- a/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/controller/CanteenSpuController.java +++ b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/controller/CanteenSpuController.java @@ -131,8 +131,19 @@ public class CanteenSpuController { // --------------APP----------------- + /** + * 获取菜品列表 + * @param categoryId 分类编号,不传默认查询全部 + * @return + */ + @GetMapping("/ad/getCanteenSpuList") + public R getCanteenSpuList(@RequestParam(value = "categoryId",required = false)String categoryId){ + return canteenSpuService.getCanteenSpuList(categoryId); + } + @PostMapping("/ad/updateSkuStock") @SysLog("更新菜品库存") + @PreAuthorize("@pms.hasPermission('canteen_canteenSpu_edit')" ) public R updateSkuStock(@RequestBody CanteenSpuUpdateStockReqDTO updateStockReqDTO){ return canteenSpuService.updateSkuStock(updateStockReqDTO); } diff --git a/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/service/CanteenCategoryService.java b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/service/CanteenCategoryService.java index e22131df3..d6924a47f 100644 --- a/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/service/CanteenCategoryService.java +++ b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/service/CanteenCategoryService.java @@ -5,6 +5,8 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.IService; import com.bsd.pjcloud.canteen.entity.CanteenCategoryEntity; +import java.util.List; + public interface CanteenCategoryService extends IService { @@ -15,4 +17,12 @@ public interface CanteenCategoryService extends IService * @return */ Page selectPageByScope(Page page, LambdaQueryWrapper wrapper); + + + /** + * 获取菜品分类 + * @param wrapper + * @return + */ + List listScope(LambdaQueryWrapper wrapper); } \ No newline at end of file diff --git a/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/service/CanteenSpuService.java b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/service/CanteenSpuService.java index 158f5bdd2..e0963b5f4 100644 --- a/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/service/CanteenSpuService.java +++ b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/service/CanteenSpuService.java @@ -27,4 +27,11 @@ public interface CanteenSpuService extends IService { */ R updateSkuStock(CanteenSpuUpdateStockReqDTO updateStockReqDTO); + + /** + * 根据菜品分类id获取菜品信息 + * @param categoryId + * @return + */ + R getCanteenSpuList(String categoryId); } \ No newline at end of file diff --git a/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/service/impl/CanteenCategoryServiceImpl.java b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/service/impl/CanteenCategoryServiceImpl.java index 2d446376b..c954f8c32 100644 --- a/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/service/impl/CanteenCategoryServiceImpl.java +++ b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/service/impl/CanteenCategoryServiceImpl.java @@ -26,4 +26,9 @@ public class CanteenCategoryServiceImpl extends ServiceImpl listScope(LambdaQueryWrapper wrapper) { + return baseMapper.selectListByScope(wrapper,DataScope.of()); + } } \ No newline at end of file diff --git a/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/service/impl/CanteenSpuServiceImpl.java b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/service/impl/CanteenSpuServiceImpl.java index 6cbca93d9..5ce70a262 100644 --- a/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/service/impl/CanteenSpuServiceImpl.java +++ b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/service/impl/CanteenSpuServiceImpl.java @@ -8,12 +8,15 @@ import com.bsd.pjcloud.canteen.entity.CanteenSpuEntity; import com.bsd.pjcloud.canteen.mapper.CanteenSpuMapper; import com.bsd.pjcloud.canteen.service.CanteenDailyMenuService; import com.bsd.pjcloud.canteen.service.CanteenSpuService; +import com.bsd.pjcloud.canteen.vo.ADCanteenSpuListVO; +import com.bsd.pjcloud.common.core.util.BeanUtils; import com.bsd.pjcloud.common.core.util.R; import com.bsd.pjcloud.common.data.datascope.DataScope; import com.github.yulichang.wrapper.MPJLambdaWrapper; import lombok.AllArgsConstructor; import lombok.Data; import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -51,6 +54,14 @@ public class CanteenSpuServiceImpl extends ServiceImpl canteenSpuEntities = baseMapper.selectListByScope(new LambdaQueryWrapper() + .eq(StringUtils.isNotEmpty(categoryId), CanteenSpuEntity::getCategoryId, categoryId),DataScope.of()); + List bean = BeanUtils.toBean(canteenSpuEntities, ADCanteenSpuListVO.class); + return R.ok(bean); + + } } \ No newline at end of file diff --git a/pjcloud-common/pjcloud-common-core/src/main/java/com/bsd/pjcloud/common/core/constant/ServiceNameConstants.java b/pjcloud-common/pjcloud-common-core/src/main/java/com/bsd/pjcloud/common/core/constant/ServiceNameConstants.java index 7ff46284e..8d6157d26 100644 --- a/pjcloud-common/pjcloud-common-core/src/main/java/com/bsd/pjcloud/common/core/constant/ServiceNameConstants.java +++ b/pjcloud-common/pjcloud-common-core/src/main/java/com/bsd/pjcloud/common/core/constant/ServiceNameConstants.java @@ -67,6 +67,16 @@ public interface ServiceNameConstants { */ String CANTEEN_SERVICE = "pjcloud-canteen-biz"; + /** + * 超市服务 + */ + String SUPERMARKET_SERVICE = "pjcloud-supermarket-biz"; + + /** + * 超市erp服务 + */ + String SUPERMARKET_ERP_SERVICE = "pjcloud-supermarket-erp-biz"; + /** * 钱包模块 */ diff --git a/pjcloud-supermarket/pjcloud-supermarket-api/src/main/java/com/bsd/pjcloud/supermarket/api/feign/RemoteSupermarketCategoryService.java b/pjcloud-supermarket/pjcloud-supermarket-api/src/main/java/com/bsd/pjcloud/supermarket/api/feign/RemoteSupermarketCategoryService.java new file mode 100644 index 000000000..07dcde2a9 --- /dev/null +++ b/pjcloud-supermarket/pjcloud-supermarket-api/src/main/java/com/bsd/pjcloud/supermarket/api/feign/RemoteSupermarketCategoryService.java @@ -0,0 +1,46 @@ +/* + * + * Copyright (c) 2018-2025, pjcloud All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: pjcloud + * + */ + +package com.bsd.pjcloud.supermarket.api.feign; + + +import com.bsd.pjcloud.common.core.constant.ServiceNameConstants; +import com.bsd.pjcloud.common.core.util.R; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestParam; + +/** + * @author zjf + * @date 2018/6/22 + */ +@FeignClient(contextId = "remoteUserService", value = ServiceNameConstants.SUPERMARKET_SERVICE) +public interface RemoteSupermarketCategoryService { + + + + + /** + * 查询所有的分类 + * @return R + */ + @GetMapping("/supermarketCategory/simpleAll") + R getSimpleAll(); + +} diff --git a/pjcloud-supermarket/pjcloud-supermarket-api/src/main/java/com/bsd/pjcloud/supermarket/api/feign/RemoteSupermarketSpuService.java b/pjcloud-supermarket/pjcloud-supermarket-api/src/main/java/com/bsd/pjcloud/supermarket/api/feign/RemoteSupermarketSpuService.java new file mode 100644 index 000000000..4f63d4d4a --- /dev/null +++ b/pjcloud-supermarket/pjcloud-supermarket-api/src/main/java/com/bsd/pjcloud/supermarket/api/feign/RemoteSupermarketSpuService.java @@ -0,0 +1,42 @@ +/* + * + * Copyright (c) 2018-2025, pjcloud All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: pjcloud + * + */ + +package com.bsd.pjcloud.supermarket.api.feign; + + +import com.bsd.pjcloud.common.core.constant.ServiceNameConstants; +import com.bsd.pjcloud.common.core.util.R; +import com.bsd.pjcloud.common.feign.annotation.NoToken; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * @author zjf + * @date 2018/6/22 + */ +@FeignClient(contextId = "remoteUserService", value = ServiceNameConstants.SUPERMARKET_SERVICE) +public interface RemoteSupermarketSpuService { + + + + + +} diff --git a/pjcloud-supermarket/pjcloud-supermarket-biz/src/main/java/com/bsd/pjcloud/supermarket/controller/SupermarketCategoryController.java b/pjcloud-supermarket/pjcloud-supermarket-biz/src/main/java/com/bsd/pjcloud/supermarket/controller/SupermarketCategoryController.java index fc129aa86..e796ae06a 100644 --- a/pjcloud-supermarket/pjcloud-supermarket-biz/src/main/java/com/bsd/pjcloud/supermarket/controller/SupermarketCategoryController.java +++ b/pjcloud-supermarket/pjcloud-supermarket-biz/src/main/java/com/bsd/pjcloud/supermarket/controller/SupermarketCategoryController.java @@ -123,7 +123,7 @@ public class SupermarketCategoryController { /** - * 下拉查询 + * 获取所有分类 * @return */ @Operation(summary = "下拉查询") diff --git a/pjcloud-supermarket/pjcloud-supermarket-biz/src/main/java/com/bsd/pjcloud/supermarket/controller/SupermarketSpuController.java b/pjcloud-supermarket/pjcloud-supermarket-biz/src/main/java/com/bsd/pjcloud/supermarket/controller/SupermarketSpuController.java index 7bfe61426..da6177bc8 100644 --- a/pjcloud-supermarket/pjcloud-supermarket-biz/src/main/java/com/bsd/pjcloud/supermarket/controller/SupermarketSpuController.java +++ b/pjcloud-supermarket/pjcloud-supermarket-biz/src/main/java/com/bsd/pjcloud/supermarket/controller/SupermarketSpuController.java @@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.bsd.pjcloud.common.core.util.R; import com.bsd.pjcloud.common.log.annotation.SysLog; +import com.bsd.pjcloud.common.security.util.SecurityUtils; import com.bsd.pjcloud.supermarket.dto.SupermarketSpuUpdateStockReqDTO; import com.bsd.pjcloud.supermarket.entity.SupermarketSpuEntity; import com.bsd.pjcloud.supermarket.service.SupermarketSpuService; @@ -52,7 +53,7 @@ public class SupermarketSpuController { wrapper.eq(StrUtil.isNotBlank(supermarketSpu.getProductCode()),SupermarketSpuEntity::getProductCode,supermarketSpu.getProductCode()); wrapper.eq(StrUtil.isNotBlank(supermarketSpu.getBarcode()),SupermarketSpuEntity::getBarcode,supermarketSpu.getBarcode()); wrapper.eq(StrUtil.isNotBlank(supermarketSpu.getProductName()),SupermarketSpuEntity::getProductName,supermarketSpu.getProductName()); - return R.ok(supermarketSpuService.page(page, wrapper)); + return R.ok(supermarketSpuService.pageScope(page, wrapper)); } @@ -78,6 +79,7 @@ public class SupermarketSpuController { @PostMapping @PreAuthorize("@pms.hasPermission('supermarket_supermarketSpu_add')" ) public R save(@RequestBody SupermarketSpuEntity supermarketSpu) { + supermarketSpu.setDeptId(SecurityUtils.getUser().getDeptId()); return supermarketSpuService.saveSpu(supermarketSpu); } @@ -126,4 +128,17 @@ public class SupermarketSpuController { public R updateSkuStock(@RequestBody SupermarketSpuUpdateStockReqDTO updateStockReqDTO){ return supermarketSpuService.updateSpuStock(updateStockReqDTO); } + + + /** + * 条件查询 + * @param supermarketSpu 商品spu + * @return + */ + @Operation(summary = "条件查询所有" , description = "条件查询所有" ) + @GetMapping("/selectListAll" ) + @PreAuthorize("@pms.hasPermission('supermarket_supermarketSpu_view')" ) + public R getSupermarketSpuPage(@ParameterObject SupermarketSpuEntity supermarketSpu) { + return R.ok(supermarketSpuService.selectListAllScope(supermarketSpu)); + } } \ No newline at end of file diff --git a/pjcloud-supermarket/pjcloud-supermarket-biz/src/main/java/com/bsd/pjcloud/supermarket/service/SupermarketSpuService.java b/pjcloud-supermarket/pjcloud-supermarket-biz/src/main/java/com/bsd/pjcloud/supermarket/service/SupermarketSpuService.java index e332ec451..db1e0fa0d 100644 --- a/pjcloud-supermarket/pjcloud-supermarket-biz/src/main/java/com/bsd/pjcloud/supermarket/service/SupermarketSpuService.java +++ b/pjcloud-supermarket/pjcloud-supermarket-biz/src/main/java/com/bsd/pjcloud/supermarket/service/SupermarketSpuService.java @@ -1,5 +1,7 @@ package com.bsd.pjcloud.supermarket.service; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.IService; import com.bsd.pjcloud.common.core.util.R; import com.bsd.pjcloud.supermarket.dto.SupermarketSpuUpdateStockReqDTO; @@ -25,4 +27,20 @@ public interface SupermarketSpuService extends IService { * @return */ R updateSpuStock(SupermarketSpuUpdateStockReqDTO updateStockReqDTO); + + + /** + * 分页查询 + * @param page + * @param wrapper + * @return + */ + Object pageScope(Page page, LambdaQueryWrapper wrapper); + + /** + * 根据条件查询所有数据,app/收银机接口 + * @param supermarketSpu + * @return + */ + Object selectListAllScope(SupermarketSpuEntity supermarketSpu); } \ No newline at end of file diff --git a/pjcloud-supermarket/pjcloud-supermarket-biz/src/main/java/com/bsd/pjcloud/supermarket/service/impl/SupermarketSpuServiceImpl.java b/pjcloud-supermarket/pjcloud-supermarket-biz/src/main/java/com/bsd/pjcloud/supermarket/service/impl/SupermarketSpuServiceImpl.java index 6f09adddf..ee5cdda03 100644 --- a/pjcloud-supermarket/pjcloud-supermarket-biz/src/main/java/com/bsd/pjcloud/supermarket/service/impl/SupermarketSpuServiceImpl.java +++ b/pjcloud-supermarket/pjcloud-supermarket-biz/src/main/java/com/bsd/pjcloud/supermarket/service/impl/SupermarketSpuServiceImpl.java @@ -1,8 +1,10 @@ package com.bsd.pjcloud.supermarket.service.impl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.bsd.pjcloud.common.core.util.R; +import com.bsd.pjcloud.common.data.datascope.DataScope; import com.bsd.pjcloud.supermarket.dto.SupermarketSpuUpdateStockReqDTO; import com.bsd.pjcloud.supermarket.entity.SupermarketAuxiliaryCodeEntity; import com.bsd.pjcloud.supermarket.entity.SupermarketSpuEntity; @@ -123,4 +125,17 @@ public class SupermarketSpuServiceImpl extends ServiceImpl wrapper) { + return baseMapper.selectPageByScope(page, wrapper, DataScope.of()); + } + + @Override + public Object selectListAllScope(SupermarketSpuEntity supermarketSpu) { + + return null; + + + } } \ No newline at end of file From 93b4cdcf7c9b837e2d6f4f5c3313c8b1ff37655a Mon Sep 17 00:00:00 2001 From: zjf <1799650030@qq.com> Date: Fri, 3 Jan 2025 10:07:18 +0800 Subject: [PATCH 3/6] =?UTF-8?q?=E8=B6=85=E5=B8=82=EF=BC=8C=E9=A3=9F?= =?UTF-8?q?=E5=A0=82=E6=A8=A1=E5=9D=97=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../feign/RemoteCanteenCategoryService.java | 2 +- .../api/feign/RemoteCanteenSpuService.java | 2 +- .../RemoteSupermarketCategoryService.java | 21 +------------------ .../feign/RemoteSupermarketSpuService.java | 2 +- 4 files changed, 4 insertions(+), 23 deletions(-) diff --git a/pjcloud-canteen/pjcloud-canteen-api/src/main/java/com/bsd/pjcloud/canteen/api/feign/RemoteCanteenCategoryService.java b/pjcloud-canteen/pjcloud-canteen-api/src/main/java/com/bsd/pjcloud/canteen/api/feign/RemoteCanteenCategoryService.java index d498550d7..76c4c7a31 100644 --- a/pjcloud-canteen/pjcloud-canteen-api/src/main/java/com/bsd/pjcloud/canteen/api/feign/RemoteCanteenCategoryService.java +++ b/pjcloud-canteen/pjcloud-canteen-api/src/main/java/com/bsd/pjcloud/canteen/api/feign/RemoteCanteenCategoryService.java @@ -29,7 +29,7 @@ import org.springframework.web.bind.annotation.*; * @author zjf * @date 2018/6/22 */ -@FeignClient(contextId = "remoteUserService", value = ServiceNameConstants.CANTEEN_SERVICE) +@FeignClient(contextId = "remoteCanteenCategoryService", value = ServiceNameConstants.CANTEEN_SERVICE) public interface RemoteCanteenCategoryService { diff --git a/pjcloud-canteen/pjcloud-canteen-api/src/main/java/com/bsd/pjcloud/canteen/api/feign/RemoteCanteenSpuService.java b/pjcloud-canteen/pjcloud-canteen-api/src/main/java/com/bsd/pjcloud/canteen/api/feign/RemoteCanteenSpuService.java index 02351e614..a2f953eeb 100644 --- a/pjcloud-canteen/pjcloud-canteen-api/src/main/java/com/bsd/pjcloud/canteen/api/feign/RemoteCanteenSpuService.java +++ b/pjcloud-canteen/pjcloud-canteen-api/src/main/java/com/bsd/pjcloud/canteen/api/feign/RemoteCanteenSpuService.java @@ -33,7 +33,7 @@ import org.springframework.web.bind.annotation.RequestParam; * @author zjf * @date 2018/6/22 */ -@FeignClient(contextId = "remoteUserService", value = ServiceNameConstants.CANTEEN_SERVICE) +@FeignClient(contextId = "remoteCanteenSpuService", value = ServiceNameConstants.CANTEEN_SERVICE) public interface RemoteCanteenSpuService { diff --git a/pjcloud-supermarket/pjcloud-supermarket-api/src/main/java/com/bsd/pjcloud/supermarket/api/feign/RemoteSupermarketCategoryService.java b/pjcloud-supermarket/pjcloud-supermarket-api/src/main/java/com/bsd/pjcloud/supermarket/api/feign/RemoteSupermarketCategoryService.java index 07dcde2a9..51e1015d4 100644 --- a/pjcloud-supermarket/pjcloud-supermarket-api/src/main/java/com/bsd/pjcloud/supermarket/api/feign/RemoteSupermarketCategoryService.java +++ b/pjcloud-supermarket/pjcloud-supermarket-api/src/main/java/com/bsd/pjcloud/supermarket/api/feign/RemoteSupermarketCategoryService.java @@ -1,22 +1,3 @@ -/* - * - * Copyright (c) 2018-2025, pjcloud All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * Neither the name of the pig4cloud.com developer nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * Author: pjcloud - * - */ - package com.bsd.pjcloud.supermarket.api.feign; @@ -30,7 +11,7 @@ import org.springframework.web.bind.annotation.RequestParam; * @author zjf * @date 2018/6/22 */ -@FeignClient(contextId = "remoteUserService", value = ServiceNameConstants.SUPERMARKET_SERVICE) +@FeignClient(contextId = "remoteSupermarketCategoryServic", value = ServiceNameConstants.SUPERMARKET_SERVICE) public interface RemoteSupermarketCategoryService { diff --git a/pjcloud-supermarket/pjcloud-supermarket-api/src/main/java/com/bsd/pjcloud/supermarket/api/feign/RemoteSupermarketSpuService.java b/pjcloud-supermarket/pjcloud-supermarket-api/src/main/java/com/bsd/pjcloud/supermarket/api/feign/RemoteSupermarketSpuService.java index 4f63d4d4a..00cb5c234 100644 --- a/pjcloud-supermarket/pjcloud-supermarket-api/src/main/java/com/bsd/pjcloud/supermarket/api/feign/RemoteSupermarketSpuService.java +++ b/pjcloud-supermarket/pjcloud-supermarket-api/src/main/java/com/bsd/pjcloud/supermarket/api/feign/RemoteSupermarketSpuService.java @@ -32,7 +32,7 @@ import java.util.List; * @author zjf * @date 2018/6/22 */ -@FeignClient(contextId = "remoteUserService", value = ServiceNameConstants.SUPERMARKET_SERVICE) +@FeignClient(contextId = "remoteSupermarketSpuService", value = ServiceNameConstants.SUPERMARKET_SERVICE) public interface RemoteSupermarketSpuService { From 2ff1876f9f7236aa77a58af59db02169c271e663 Mon Sep 17 00:00:00 2001 From: zjf <1799650030@qq.com> Date: Fri, 3 Jan 2025 13:08:43 +0800 Subject: [PATCH 4/6] =?UTF-8?q?=E8=B6=85=E5=B8=82=EF=BC=8C=E9=A3=9F?= =?UTF-8?q?=E5=A0=82=E6=A8=A1=E5=9D=97=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AppUserAutoLoginController.java | 36 ++++++++++++------- .../controller/SupermarketSpuController.java | 17 ++++++++- .../feign/RemoterThirdPartyAuthService.java | 4 +++ .../pjcloud/thirdparty/dto/SHJNSSODTO.java | 14 ++++++++ .../controller/ThirdPartyOAth2Cotroller.java | 11 ++++-- 5 files changed, 66 insertions(+), 16 deletions(-) create mode 100644 pjcloud-thirdparty/pjcloud-thirdparty-api/src/main/java/com/bsd/pjcloud/thirdparty/dto/SHJNSSODTO.java diff --git a/pjcloud-app-server/pjcloud-app-server-biz/src/main/java/com/bsd/pjcloud/app/controller/AppUserAutoLoginController.java b/pjcloud-app-server/pjcloud-app-server-biz/src/main/java/com/bsd/pjcloud/app/controller/AppUserAutoLoginController.java index caf0dc476..e61a57f5c 100644 --- a/pjcloud-app-server/pjcloud-app-server-biz/src/main/java/com/bsd/pjcloud/app/controller/AppUserAutoLoginController.java +++ b/pjcloud-app-server/pjcloud-app-server-biz/src/main/java/com/bsd/pjcloud/app/controller/AppUserAutoLoginController.java @@ -27,6 +27,7 @@ import com.bsd.pjcloud.app.service.AppUserService; import com.bsd.pjcloud.common.core.util.R; import com.bsd.pjcloud.common.security.annotation.Inner; import com.bsd.pjcloud.thirdparty.api.feign.RemoterThirdPartyAuthService; +import com.bsd.pjcloud.thirdparty.dto.SHJNSSODTO; import com.bsd.pjcloud.thirdparty.dto.ZZDUserDTO; import com.bsd.pjcloud.thirdparty.entity.ThirdPartyUserEntity; import com.fasterxml.jackson.core.JsonProcessingException; @@ -34,6 +35,8 @@ import com.fasterxml.jackson.databind.ObjectMapper; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.security.SecurityRequirement; import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.validation.Valid; +import lombok.AllArgsConstructor; import lombok.RequiredArgsConstructor; import org.apache.seata.spring.annotation.GlobalTransactional; import org.springframework.http.HttpHeaders; @@ -51,7 +54,7 @@ import java.util.Map; /** * app用户表 * - * @author aeizzz + * @author zjf * @date 2022-12-07 09:52:03 */ @RestController @@ -178,23 +181,29 @@ public class AppUserAutoLoginController { } + /** * 诗画sdk获取参数 * * @param * @return */ -// @PostMapping("/shjnsso") -// @Inner(value = false) -// @Operation(summary = "诗画江南单点登录") -// public R shjnsso(@RequestBody @Valid SHJNSSOReqVO shjnsso) { -// ZZDUserDTO zzdUserDTO=ssoApi.shjnsso(shjnsso.getAccountId(),shjnsso.getSessionId()); -// ZZDUserDTO.Ext ext = zzdUserDTO.getExt(); -// String mobile = zzdUserDTO.getMobile(); -// AdminUserRespDTO userByMobileOrEmployeeCode = adminUserApi.getUserByMobileOrEmployeeCode(null, mobile); -// if(userByMobileOrEmployeeCode!=null){ -// return createTokenAfterLoginSuccess(userByMobileOrEmployeeCode.getId(), mobile, LoginLogTypeEnum.LOGIN_SSO); -// } + @PostMapping("/shjnsso") + @Inner(value = false) + @Operation(summary = "诗画江南单点登录") + public R shjnsso(@RequestBody @Valid SHJNSSODTO shjnsso) { + R rdata = remoterThirdPartyAuthService.shjnsso(shjnsso.getAccountId(), shjnsso.getSessionId()); + ZZDUserDTO zzdUserDTO = (ZZDUserDTO) rdata.getData(); + ZZDUserDTO.Ext ext = zzdUserDTO.getExt(); + String mobile = zzdUserDTO.getMobile(); + R> rListSysUser = remoteUserService.getUserByMobileOrEmployeeCode(null, mobile); + List sysUsers = rListSysUser.getData(); + if(!CollectionUtils.isEmpty(sysUsers)){ + //登录成功生成token + UserTokenDTO userTokenDTO = new UserTokenDTO(); + userTokenDTO.setSysUser(sysUsers.get(0)); + remoteTokenService.generateToken(userTokenDTO); + } // log.info("用户不存在,尝试创建用户"); // CreateUserDto createUserDto = new CreateUserDto(); // createUserDto.setUsername(zzdUserDTO.getUsername()); @@ -207,7 +216,8 @@ public class AppUserAutoLoginController { // AdminUserRespDTO adminUserRespDTONew=adminUserApi.createSysUser(createUserDto); // log.info("创建用户成功,用户id为:{}",adminUserRespDTONew.getId()); // return createTokenAfterLoginSuccess(adminUserRespDTONew.getId(), mobile, LoginLogTypeEnum.LOGIN_SSO); -// } + return R.failed("不存在用户"); + } @Inner(value = false) diff --git a/pjcloud-supermarket/pjcloud-supermarket-biz/src/main/java/com/bsd/pjcloud/supermarket/controller/SupermarketSpuController.java b/pjcloud-supermarket/pjcloud-supermarket-biz/src/main/java/com/bsd/pjcloud/supermarket/controller/SupermarketSpuController.java index da6177bc8..c7017eee2 100644 --- a/pjcloud-supermarket/pjcloud-supermarket-biz/src/main/java/com/bsd/pjcloud/supermarket/controller/SupermarketSpuController.java +++ b/pjcloud-supermarket/pjcloud-supermarket-biz/src/main/java/com/bsd/pjcloud/supermarket/controller/SupermarketSpuController.java @@ -10,8 +10,12 @@ import com.bsd.pjcloud.common.core.util.R; import com.bsd.pjcloud.common.log.annotation.SysLog; import com.bsd.pjcloud.common.security.util.SecurityUtils; import com.bsd.pjcloud.supermarket.dto.SupermarketSpuUpdateStockReqDTO; +import com.bsd.pjcloud.supermarket.entity.SupermarketAuxiliaryCodeEntity; import com.bsd.pjcloud.supermarket.entity.SupermarketSpuEntity; +import com.bsd.pjcloud.supermarket.entity.SupermarketUnitEntity; +import com.bsd.pjcloud.supermarket.service.SupermarketAuxiliaryCodeService; import com.bsd.pjcloud.supermarket.service.SupermarketSpuService; +import com.bsd.pjcloud.supermarket.service.SupermarketUnitService; import org.springframework.security.access.prepost.PreAuthorize; import com.bsd.pjcloud.common.excel.annotation.ResponseExcel; import io.swagger.v3.oas.annotations.security.SecurityRequirement; @@ -39,6 +43,10 @@ public class SupermarketSpuController { private final SupermarketSpuService supermarketSpuService; + private final SupermarketUnitService supermarketUnitService; + + private final SupermarketAuxiliaryCodeService supermarketAuxiliaryCodeService; + /** * 分页查询 * @param page 分页对象 @@ -66,7 +74,14 @@ public class SupermarketSpuController { @GetMapping("/{id}" ) @PreAuthorize("@pms.hasPermission('supermarket_supermarketSpu_view')" ) public R getById(@PathVariable("id" ) Long id) { - return R.ok(supermarketSpuService.getById(id)); + SupermarketSpuEntity supermarketSpuEntity = supermarketSpuService.getById(id); + List list = supermarketUnitService.list(new LambdaQueryWrapper().eq(SupermarketUnitEntity::getSpuId, id)); + supermarketSpuEntity.setSupermarketUnitEntityList(list); + supermarketSpuEntity.setSupermarketAuxiliaryCodeEntityList( + supermarketAuxiliaryCodeService.list(new LambdaQueryWrapper().eq(SupermarketAuxiliaryCodeEntity::getSpuId, id)) + ); + + return R.ok(id); } /** diff --git a/pjcloud-thirdparty/pjcloud-thirdparty-api/src/main/java/com/bsd/pjcloud/thirdparty/api/feign/RemoterThirdPartyAuthService.java b/pjcloud-thirdparty/pjcloud-thirdparty-api/src/main/java/com/bsd/pjcloud/thirdparty/api/feign/RemoterThirdPartyAuthService.java index 96b738fcb..c4f00fb7f 100644 --- a/pjcloud-thirdparty/pjcloud-thirdparty-api/src/main/java/com/bsd/pjcloud/thirdparty/api/feign/RemoterThirdPartyAuthService.java +++ b/pjcloud-thirdparty/pjcloud-thirdparty-api/src/main/java/com/bsd/pjcloud/thirdparty/api/feign/RemoterThirdPartyAuthService.java @@ -44,6 +44,10 @@ public interface RemoterThirdPartyAuthService { R zzdsso(@RequestParam("token") String token); + @NoToken + @GetMapping("/thirdPartyOAth2/zzd/shjnsso") + R shjnsso(@RequestParam("accountId") String accountId,@RequestParam("sessionId") String sessionId); + /** * 根据钉钉号查询第三方表里面是否有这个人,也就是浙政钉总体系人员表 * @param employeeCode diff --git a/pjcloud-thirdparty/pjcloud-thirdparty-api/src/main/java/com/bsd/pjcloud/thirdparty/dto/SHJNSSODTO.java b/pjcloud-thirdparty/pjcloud-thirdparty-api/src/main/java/com/bsd/pjcloud/thirdparty/dto/SHJNSSODTO.java new file mode 100644 index 000000000..01606dde4 --- /dev/null +++ b/pjcloud-thirdparty/pjcloud-thirdparty-api/src/main/java/com/bsd/pjcloud/thirdparty/dto/SHJNSSODTO.java @@ -0,0 +1,14 @@ +package com.bsd.pjcloud.thirdparty.dto; + +import jakarta.validation.constraints.NotNull; +import lombok.Data; + +@Data +public class SHJNSSODTO { + + @NotNull(message = "账号id不能为空") + private String accountId; + + @NotNull(message = "会员id不能为空") + private String sessionId; +} diff --git a/pjcloud-thirdparty/pjcloud-thirdparty-biz/src/main/java/com/bsd/pjcloud/thirdparty/controller/ThirdPartyOAth2Cotroller.java b/pjcloud-thirdparty/pjcloud-thirdparty-biz/src/main/java/com/bsd/pjcloud/thirdparty/controller/ThirdPartyOAth2Cotroller.java index 6afa26eb9..62501b322 100644 --- a/pjcloud-thirdparty/pjcloud-thirdparty-biz/src/main/java/com/bsd/pjcloud/thirdparty/controller/ThirdPartyOAth2Cotroller.java +++ b/pjcloud-thirdparty/pjcloud-thirdparty-biz/src/main/java/com/bsd/pjcloud/thirdparty/controller/ThirdPartyOAth2Cotroller.java @@ -26,8 +26,15 @@ public class ThirdPartyOAth2Cotroller { @Operation(summary = "浙政钉token" ) @GetMapping("/zzd/sso" ) - public R getThirdPartyDeptPage(@RequestParam("token")String token) { + public R getThirdPartyzzdsso(@RequestParam("token")String token) { + return R.ok(thirdPartyOAuth2Service.getZZDUserInfo(token)); + + } + + @Operation(summary = "诗画token" ) + @GetMapping("/sh/sso" ) + public R getThirdPartyshsso(@RequestParam("accountId") String accountId,@RequestParam("sessionId") String sessionId) { + return R.ok(thirdPartyOAuth2Service.shjnsso(accountId,sessionId)); - return R.ok(); } } From bb329d04779de51079dda0e65efcc23ec3ae3175 Mon Sep 17 00:00:00 2001 From: zjf <1799650030@qq.com> Date: Fri, 3 Jan 2025 13:11:53 +0800 Subject: [PATCH 5/6] =?UTF-8?q?=E8=B6=85=E5=B8=82=EF=BC=8C=E9=A3=9F?= =?UTF-8?q?=E5=A0=82=E6=A8=A1=E5=9D=97=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../supermarket/controller/SupermarketSpuController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pjcloud-supermarket/pjcloud-supermarket-biz/src/main/java/com/bsd/pjcloud/supermarket/controller/SupermarketSpuController.java b/pjcloud-supermarket/pjcloud-supermarket-biz/src/main/java/com/bsd/pjcloud/supermarket/controller/SupermarketSpuController.java index c7017eee2..f64e521c7 100644 --- a/pjcloud-supermarket/pjcloud-supermarket-biz/src/main/java/com/bsd/pjcloud/supermarket/controller/SupermarketSpuController.java +++ b/pjcloud-supermarket/pjcloud-supermarket-biz/src/main/java/com/bsd/pjcloud/supermarket/controller/SupermarketSpuController.java @@ -81,7 +81,7 @@ public class SupermarketSpuController { supermarketAuxiliaryCodeService.list(new LambdaQueryWrapper().eq(SupermarketAuxiliaryCodeEntity::getSpuId, id)) ); - return R.ok(id); + return R.ok(supermarketSpuEntity); } /** From 80c48753388aa335a48ae03829f822421656bd34 Mon Sep 17 00:00:00 2001 From: zjf <1799650030@qq.com> Date: Fri, 3 Jan 2025 14:02:29 +0800 Subject: [PATCH 6/6] .. --- .../java/com/bsd/pjcloud/wallet/mapper/WalletStrideMapper.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/mapper/WalletStrideMapper.java b/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/mapper/WalletStrideMapper.java index 01ebc0ec3..b0ddddf25 100644 --- a/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/mapper/WalletStrideMapper.java +++ b/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/mapper/WalletStrideMapper.java @@ -1,7 +1,8 @@ package com.bsd.pjcloud.wallet.mapper; + import com.bsd.pjcloud.common.data.datascope.PjcloudBaseMapper; -import com.bsd.pjcloud.admin.entity.WalletStrideEntity; +import com.bsd.pjcloud.wallet.api.entity.WalletStrideEntity; import org.apache.ibatis.annotations.Mapper; @Mapper