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-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..76c4c7a31 --- /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 = "remoteCanteenCategoryService", 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..a2f953eeb --- /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 = "remoteCanteenSpuService", 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..51e1015d4 --- /dev/null +++ b/pjcloud-supermarket/pjcloud-supermarket-api/src/main/java/com/bsd/pjcloud/supermarket/api/feign/RemoteSupermarketCategoryService.java @@ -0,0 +1,27 @@ +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 = "remoteSupermarketCategoryServic", 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..00cb5c234 --- /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 = "remoteSupermarketSpuService", value = ServiceNameConstants.SUPERMARKET_SERVICE) +public interface RemoteSupermarketSpuService { + + + + + +} 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/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 688247a24..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 @@ -8,8 +8,14 @@ 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.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; @@ -21,7 +27,6 @@ import lombok.RequiredArgsConstructor; import org.springframework.web.bind.annotation.*; import java.util.List; -import java.util.Objects; /** * 商品spu @@ -38,6 +43,10 @@ public class SupermarketSpuController { private final SupermarketSpuService supermarketSpuService; + private final SupermarketUnitService supermarketUnitService; + + private final SupermarketAuxiliaryCodeService supermarketAuxiliaryCodeService; + /** * 分页查询 * @param page 分页对象 @@ -52,7 +61,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)); } @@ -65,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(supermarketSpuEntity); } /** @@ -78,6 +94,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); } @@ -120,4 +137,23 @@ 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); + } + + + /** + * 条件查询 + * @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/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..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,7 +1,10 @@ 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; import com.bsd.pjcloud.supermarket.entity.SupermarketSpuEntity; import java.util.ArrayList; @@ -16,4 +19,28 @@ public interface SupermarketSpuService extends IService { Object removeSpuBatchByIds(ArrayList list); + + + /** + * 更新商品库存 + * @param updateStockReqDTO + * @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/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..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,11 @@ 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; import com.bsd.pjcloud.supermarket.entity.SupermarketUnitEntity; @@ -106,4 +109,33 @@ 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(); + } + + @Override + public Object pageScope(Page page, LambdaQueryWrapper wrapper) { + return baseMapper.selectPageByScope(page, wrapper, DataScope.of()); + } + + @Override + public Object selectListAllScope(SupermarketSpuEntity supermarketSpu) { + + return null; + + + } } \ 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 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(); } }