超市
This commit is contained in:
		| @ -0,0 +1,115 @@ | ||||
| package cn.iocoder.yudao.framework.common.pojo; | ||||
|  | ||||
| import cn.iocoder.yudao.framework.common.exception.ErrorCode; | ||||
| import cn.iocoder.yudao.framework.common.exception.ServiceException; | ||||
| import cn.iocoder.yudao.framework.common.exception.enums.GlobalErrorCodeConstants; | ||||
| import com.fasterxml.jackson.annotation.JsonIgnore; | ||||
| import lombok.Data; | ||||
| import org.springframework.util.Assert; | ||||
|  | ||||
| import java.io.Serializable; | ||||
| import java.util.Objects; | ||||
|  | ||||
| /** | ||||
|  * 通用返回 | ||||
|  * | ||||
|  * @param <T> 数据泛型 | ||||
|  */ | ||||
| @Data | ||||
| public class StoreResult<T> implements Serializable { | ||||
|  | ||||
|     /** | ||||
|      * 错误码 | ||||
|      * | ||||
|      * @see ErrorCode#getCode() | ||||
|      */ | ||||
|     private String statusCode; | ||||
|     /** | ||||
|      * 返回数据 | ||||
|      */ | ||||
|     private T data; | ||||
|     /** | ||||
|      * 错误提示,用户可阅读 | ||||
|      * | ||||
|      * @see ErrorCode#getMsg() () | ||||
|      */ | ||||
|     private String message; | ||||
|  | ||||
|     private Boolean success; | ||||
|  | ||||
|     /** | ||||
|      * 将传入的 result 对象,转换成另外一个泛型结果的对象 | ||||
|      * | ||||
|      * 因为 A 方法返回的 CommonResult 对象,不满足调用其的 B 方法的返回,所以需要进行转换。 | ||||
|      * | ||||
|      * @param result 传入的 result 对象 | ||||
|      * @param <T>    返回的泛型 | ||||
|      * @return 新的 CommonResult 对象 | ||||
|      */ | ||||
|     public static <T> StoreResult<T> error(StoreResult<?> result) { | ||||
|         return error(result.getStatusCode(), result.getMessage()); | ||||
|     } | ||||
|  | ||||
|     public static <T> StoreResult<T> error(String code, String message) { | ||||
|         Assert.isTrue(!GlobalErrorCodeConstants.SUCCESS.getCode().equals(code), "code 必须是错误的!"); | ||||
|         StoreResult<T> result = new StoreResult<>(); | ||||
|         result.statusCode = code; | ||||
|         result.message = message; | ||||
|         return result; | ||||
|     } | ||||
|  | ||||
|     public static <T> StoreResult<T> error(ErrorCode errorCode) { | ||||
|         return error(errorCode.getCode().toString(), errorCode.getMsg()); | ||||
|     } | ||||
|  | ||||
|     public static <T> StoreResult<T> success(T data) { | ||||
|         StoreResult<T> result = new StoreResult<>(); | ||||
|         result.statusCode = "200"; | ||||
|         result.data = data; | ||||
|         result.message = ""; | ||||
|         result.success = true; | ||||
|         return result; | ||||
|     } | ||||
|  | ||||
|     public static boolean isSuccess(String code) { | ||||
|         return Objects.equals(code, GlobalErrorCodeConstants.SUCCESS.getCode().toString()); | ||||
|     } | ||||
|  | ||||
|     @JsonIgnore // 避免 jackson 序列化 | ||||
|     public boolean isSuccess() { | ||||
|         return isSuccess(statusCode); | ||||
|     } | ||||
|  | ||||
|     @JsonIgnore // 避免 jackson 序列化 | ||||
|     public boolean isError() { | ||||
|         return !isSuccess(); | ||||
|     } | ||||
|  | ||||
|     // ========= 和 Exception 异常体系集成 ========= | ||||
|  | ||||
|     /** | ||||
|      * 判断是否有异常。如果有,则抛出 {@link ServiceException} 异常 | ||||
|      */ | ||||
|     public void checkError() throws ServiceException { | ||||
|         if (isSuccess()) { | ||||
|             return; | ||||
|         } | ||||
|         // 业务异常 | ||||
|         throw new ServiceException(Integer.valueOf(statusCode), message); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * 判断是否有异常。如果有,则抛出 {@link ServiceException} 异常 | ||||
|      * 如果没有,则返回 {@link #data} 数据 | ||||
|      */ | ||||
|     @JsonIgnore // 避免 jackson 序列化 | ||||
|     public T getCheckedData() { | ||||
|         checkError(); | ||||
|         return data; | ||||
|     } | ||||
|  | ||||
|     public static <T> StoreResult<T> error(ServiceException serviceException) { | ||||
|         return error(serviceException.getCode().toString(), serviceException.getMessage()); | ||||
|     } | ||||
|  | ||||
| } | ||||
| @ -95,8 +95,12 @@ public interface ErrorCodeConstants { | ||||
|  | ||||
|     ErrorCode REFUND_NOT_EXISTS = new ErrorCode(1_007_903_001, "退款审核不存在"); | ||||
|  | ||||
|     ErrorCode STORE_GOODS_NOT_EXISTS = new ErrorCode(1_007_904_001, "商品不存在"); | ||||
|  | ||||
|     ErrorCode STORE_GOODS_TYPE_NOT_EXISTS = new ErrorCode(1_007_904_002,"商品类别不存在"); | ||||
|  | ||||
|     ErrorCode STORE_SALE_GOODS_NOT_EXISTS = new ErrorCode(1_007_904_003, "售卖商品不存在"); | ||||
|  | ||||
|     ErrorCode STORE_SALE_GOODS_NOT_NULL = new ErrorCode(1_007_904_003, "售卖商品不能为空"); | ||||
| } | ||||
|  | ||||
|  | ||||
| @ -0,0 +1,95 @@ | ||||
| package cn.iocoder.yudao.module.member.controller.admin.storegoods; | ||||
|  | ||||
| import org.springframework.web.bind.annotation.*; | ||||
| import javax.annotation.Resource; | ||||
| import org.springframework.validation.annotation.Validated; | ||||
| import org.springframework.security.access.prepost.PreAuthorize; | ||||
| import io.swagger.v3.oas.annotations.tags.Tag; | ||||
| import io.swagger.v3.oas.annotations.Parameter; | ||||
| import io.swagger.v3.oas.annotations.Operation; | ||||
|  | ||||
| import javax.validation.constraints.*; | ||||
| import javax.validation.*; | ||||
| import javax.servlet.http.*; | ||||
| import java.util.*; | ||||
| import java.io.IOException; | ||||
|  | ||||
| import cn.iocoder.yudao.framework.common.pojo.PageParam; | ||||
| import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||||
| import cn.iocoder.yudao.framework.common.pojo.CommonResult; | ||||
| import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | ||||
| import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | ||||
|  | ||||
| import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; | ||||
|  | ||||
| import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; | ||||
| import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*; | ||||
|  | ||||
| import cn.iocoder.yudao.module.member.controller.admin.storegoods.vo.*; | ||||
| import cn.iocoder.yudao.module.member.dal.dataobject.storegoods.StoreGoodsDO; | ||||
| import cn.iocoder.yudao.module.member.service.storegoods.StoreGoodsService; | ||||
|  | ||||
| @Tag(name = "管理后台 - 商品") | ||||
| @RestController | ||||
| @RequestMapping("/member/store-goods") | ||||
| @Validated | ||||
| public class StoreGoodsController { | ||||
|  | ||||
|     @Resource | ||||
|     private StoreGoodsService storeGoodsService; | ||||
|  | ||||
|     @PostMapping("/create") | ||||
|     @Operation(summary = "创建商品") | ||||
|     @PreAuthorize("@ss.hasPermission('member:store-goods:create')") | ||||
|     public CommonResult<Integer> createStoreGoods(@Valid @RequestBody StoreGoodsSaveReqVO createReqVO) { | ||||
|         return success(storeGoodsService.createStoreGoods(createReqVO)); | ||||
|     } | ||||
|  | ||||
|     @PutMapping("/update") | ||||
|     @Operation(summary = "更新商品") | ||||
|     @PreAuthorize("@ss.hasPermission('member:store-goods:update')") | ||||
|     public CommonResult<Boolean> updateStoreGoods(@Valid @RequestBody StoreGoodsSaveReqVO updateReqVO) { | ||||
|         storeGoodsService.updateStoreGoods(updateReqVO); | ||||
|         return success(true); | ||||
|     } | ||||
|  | ||||
|     @DeleteMapping("/delete") | ||||
|     @Operation(summary = "删除商品") | ||||
|     @Parameter(name = "id", description = "编号", required = true) | ||||
|     @PreAuthorize("@ss.hasPermission('member:store-goods:delete')") | ||||
|     public CommonResult<Boolean> deleteStoreGoods(@RequestParam("id") Integer id) { | ||||
|         storeGoodsService.deleteStoreGoods(id); | ||||
|         return success(true); | ||||
|     } | ||||
|  | ||||
|     @GetMapping("/get") | ||||
|     @Operation(summary = "获得商品") | ||||
|     @Parameter(name = "id", description = "编号", required = true, example = "1024") | ||||
|     @PreAuthorize("@ss.hasPermission('member:store-goods:query')") | ||||
|     public CommonResult<StoreGoodsRespVO> getStoreGoods(@RequestParam("id") Integer id) { | ||||
|         StoreGoodsDO storeGoods = storeGoodsService.getStoreGoods(id); | ||||
|         return success(BeanUtils.toBean(storeGoods, StoreGoodsRespVO.class)); | ||||
|     } | ||||
|  | ||||
|     @GetMapping("/page") | ||||
|     @Operation(summary = "获得商品分页") | ||||
|     @PreAuthorize("@ss.hasPermission('member:store-goods:query')") | ||||
|     public CommonResult<PageResult<StoreGoodsRespVO>> getStoreGoodsPage(@Valid StoreGoodsPageReqVO pageReqVO) { | ||||
|         PageResult<StoreGoodsDO> pageResult = storeGoodsService.getStoreGoodsPage(pageReqVO); | ||||
|         return success(BeanUtils.toBean(pageResult, StoreGoodsRespVO.class)); | ||||
|     } | ||||
|  | ||||
|     @GetMapping("/export-excel") | ||||
|     @Operation(summary = "导出商品 Excel") | ||||
|     @PreAuthorize("@ss.hasPermission('member:store-goods:export')") | ||||
|     @OperateLog(type = EXPORT) | ||||
|     public void exportStoreGoodsExcel(@Valid StoreGoodsPageReqVO pageReqVO, | ||||
|               HttpServletResponse response) throws IOException { | ||||
|         pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); | ||||
|         List<StoreGoodsDO> list = storeGoodsService.getStoreGoodsPage(pageReqVO).getList(); | ||||
|         // 导出 Excel | ||||
|         ExcelUtils.write(response, "商品.xls", "数据", StoreGoodsRespVO.class, | ||||
|                         BeanUtils.toBean(list, StoreGoodsRespVO.class)); | ||||
|     } | ||||
|  | ||||
| } | ||||
| @ -0,0 +1,37 @@ | ||||
| package cn.iocoder.yudao.module.member.controller.admin.storegoods.vo; | ||||
|  | ||||
| import lombok.*; | ||||
| import java.util.*; | ||||
| import io.swagger.v3.oas.annotations.media.Schema; | ||||
| import cn.iocoder.yudao.framework.common.pojo.PageParam; | ||||
| import org.springframework.format.annotation.DateTimeFormat; | ||||
| import java.time.LocalDateTime; | ||||
|  | ||||
| import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | ||||
|  | ||||
| @Schema(description = "管理后台 - 商品分页 Request VO") | ||||
| @Data | ||||
| @EqualsAndHashCode(callSuper = true) | ||||
| @ToString(callSuper = true) | ||||
| public class StoreGoodsPageReqVO extends PageParam { | ||||
|  | ||||
|     @Schema(description = "类别Id", example = "28357") | ||||
|     private Integer categoryId; | ||||
|  | ||||
|     @Schema(description = "商品名称", example = "张三") | ||||
|     private String goodsName; | ||||
|  | ||||
|     @Schema(description = "价格", example = "11124") | ||||
|     private Double price; | ||||
|  | ||||
|     @Schema(description = "售卖模式") | ||||
|     private Integer salesModel; | ||||
|  | ||||
|     @Schema(description = "设备ID") | ||||
|     private String equipmentCode; | ||||
|  | ||||
|     @Schema(description = "创建时间") | ||||
|     @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||||
|     private LocalDateTime[] createTime; | ||||
|  | ||||
| } | ||||
| @ -0,0 +1,44 @@ | ||||
| package cn.iocoder.yudao.module.member.controller.admin.storegoods.vo; | ||||
|  | ||||
| import io.swagger.v3.oas.annotations.media.Schema; | ||||
| import lombok.*; | ||||
| import java.util.*; | ||||
| import java.util.*; | ||||
| import org.springframework.format.annotation.DateTimeFormat; | ||||
| import java.time.LocalDateTime; | ||||
| import com.alibaba.excel.annotation.*; | ||||
|  | ||||
| @Schema(description = "管理后台 - 商品 Response VO") | ||||
| @Data | ||||
| @ExcelIgnoreUnannotated | ||||
| public class StoreGoodsRespVO { | ||||
|  | ||||
|     @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "32656") | ||||
|     @ExcelProperty("编号") | ||||
|     private Integer goodId; | ||||
|  | ||||
|     @Schema(description = "类别Id", example = "28357") | ||||
|     @ExcelProperty("类别Id") | ||||
|     private Integer categoryId; | ||||
|  | ||||
|     @Schema(description = "商品名称", example = "张三") | ||||
|     @ExcelProperty("商品名称") | ||||
|     private String goodsName; | ||||
|  | ||||
|     @Schema(description = "价格", example = "11124") | ||||
|     @ExcelProperty("价格") | ||||
|     private Double price; | ||||
|  | ||||
|     @Schema(description = "售卖模式") | ||||
|     @ExcelProperty("售卖模式") | ||||
|     private Integer salesModel; | ||||
|  | ||||
|     @Schema(description = "设备ID") | ||||
|     @ExcelProperty("设备ID") | ||||
|     private String equipmentCode; | ||||
|  | ||||
|     @Schema(description = "创建时间") | ||||
|     @ExcelProperty("创建时间") | ||||
|     private LocalDateTime createTime; | ||||
|  | ||||
| } | ||||
| @ -0,0 +1,30 @@ | ||||
| package cn.iocoder.yudao.module.member.controller.admin.storegoods.vo; | ||||
|  | ||||
| import io.swagger.v3.oas.annotations.media.Schema; | ||||
| import lombok.*; | ||||
| import java.util.*; | ||||
| import javax.validation.constraints.*; | ||||
|  | ||||
| @Schema(description = "管理后台 - 商品新增/修改 Request VO") | ||||
| @Data | ||||
| public class StoreGoodsSaveReqVO { | ||||
|  | ||||
|     @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "32656") | ||||
|     private Integer goodId; | ||||
|  | ||||
|     @Schema(description = "类别Id", example = "28357") | ||||
|     private Integer categoryId; | ||||
|  | ||||
|     @Schema(description = "商品名称", example = "张三") | ||||
|     private String goodsName; | ||||
|  | ||||
|     @Schema(description = "价格", example = "11124") | ||||
|     private Double price; | ||||
|  | ||||
|     @Schema(description = "售卖模式") | ||||
|     private Integer salesModel; | ||||
|  | ||||
|     @Schema(description = "设备ID") | ||||
|     private String equipmentCode; | ||||
|  | ||||
| } | ||||
| @ -0,0 +1,95 @@ | ||||
| package cn.iocoder.yudao.module.member.controller.admin.storegoodstype; | ||||
|  | ||||
| import org.springframework.web.bind.annotation.*; | ||||
| import javax.annotation.Resource; | ||||
| import org.springframework.validation.annotation.Validated; | ||||
| import org.springframework.security.access.prepost.PreAuthorize; | ||||
| import io.swagger.v3.oas.annotations.tags.Tag; | ||||
| import io.swagger.v3.oas.annotations.Parameter; | ||||
| import io.swagger.v3.oas.annotations.Operation; | ||||
|  | ||||
| import javax.validation.constraints.*; | ||||
| import javax.validation.*; | ||||
| import javax.servlet.http.*; | ||||
| import java.util.*; | ||||
| import java.io.IOException; | ||||
|  | ||||
| import cn.iocoder.yudao.framework.common.pojo.PageParam; | ||||
| import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||||
| import cn.iocoder.yudao.framework.common.pojo.CommonResult; | ||||
| import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | ||||
| import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | ||||
|  | ||||
| import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; | ||||
|  | ||||
| import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; | ||||
| import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*; | ||||
|  | ||||
| import cn.iocoder.yudao.module.member.controller.admin.storegoodstype.vo.*; | ||||
| import cn.iocoder.yudao.module.member.dal.dataobject.storegoodstype.StoreGoodsTypeDO; | ||||
| import cn.iocoder.yudao.module.member.service.storegoodstype.StoreGoodsTypeService; | ||||
|  | ||||
| @Tag(name = "管理后台 - 商品类别") | ||||
| @RestController | ||||
| @RequestMapping("/member/store-goods-type") | ||||
| @Validated | ||||
| public class StoreGoodsTypeController { | ||||
|  | ||||
|     @Resource | ||||
|     private StoreGoodsTypeService storeGoodsTypeService; | ||||
|  | ||||
|     @PostMapping("/create") | ||||
|     @Operation(summary = "创建商品类别") | ||||
|     @PreAuthorize("@ss.hasPermission('member:store-goods-type:create')") | ||||
|     public CommonResult<Integer> createStoreGoodsType(@Valid @RequestBody StoreGoodsTypeSaveReqVO createReqVO) { | ||||
|         return success(storeGoodsTypeService.createStoreGoodsType(createReqVO)); | ||||
|     } | ||||
|  | ||||
|     @PutMapping("/update") | ||||
|     @Operation(summary = "更新商品类别") | ||||
|     @PreAuthorize("@ss.hasPermission('member:store-goods-type:update')") | ||||
|     public CommonResult<Boolean> updateStoreGoodsType(@Valid @RequestBody StoreGoodsTypeSaveReqVO updateReqVO) { | ||||
|         storeGoodsTypeService.updateStoreGoodsType(updateReqVO); | ||||
|         return success(true); | ||||
|     } | ||||
|  | ||||
|     @DeleteMapping("/delete") | ||||
|     @Operation(summary = "删除商品类别") | ||||
|     @Parameter(name = "id", description = "编号", required = true) | ||||
|     @PreAuthorize("@ss.hasPermission('member:store-goods-type:delete')") | ||||
|     public CommonResult<Boolean> deleteStoreGoodsType(@RequestParam("id") Integer id) { | ||||
|         storeGoodsTypeService.deleteStoreGoodsType(id); | ||||
|         return success(true); | ||||
|     } | ||||
|  | ||||
|     @GetMapping("/get") | ||||
|     @Operation(summary = "获得商品类别") | ||||
|     @Parameter(name = "id", description = "编号", required = true, example = "1024") | ||||
|     @PreAuthorize("@ss.hasPermission('member:store-goods-type:query')") | ||||
|     public CommonResult<StoreGoodsTypeRespVO> getStoreGoodsType(@RequestParam("id") Integer id) { | ||||
|         StoreGoodsTypeDO storeGoodsType = storeGoodsTypeService.getStoreGoodsType(id); | ||||
|         return success(BeanUtils.toBean(storeGoodsType, StoreGoodsTypeRespVO.class)); | ||||
|     } | ||||
|  | ||||
|     @GetMapping("/page") | ||||
|     @Operation(summary = "获得商品类别分页") | ||||
|     @PreAuthorize("@ss.hasPermission('member:store-goods-type:query')") | ||||
|     public CommonResult<PageResult<StoreGoodsTypeRespVO>> getStoreGoodsTypePage(@Valid StoreGoodsTypePageReqVO pageReqVO) { | ||||
|         PageResult<StoreGoodsTypeDO> pageResult = storeGoodsTypeService.getStoreGoodsTypePage(pageReqVO); | ||||
|         return success(BeanUtils.toBean(pageResult, StoreGoodsTypeRespVO.class)); | ||||
|     } | ||||
|  | ||||
|     @GetMapping("/export-excel") | ||||
|     @Operation(summary = "导出商品类别 Excel") | ||||
|     @PreAuthorize("@ss.hasPermission('member:store-goods-type:export')") | ||||
|     @OperateLog(type = EXPORT) | ||||
|     public void exportStoreGoodsTypeExcel(@Valid StoreGoodsTypePageReqVO pageReqVO, | ||||
|               HttpServletResponse response) throws IOException { | ||||
|         pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); | ||||
|         List<StoreGoodsTypeDO> list = storeGoodsTypeService.getStoreGoodsTypePage(pageReqVO).getList(); | ||||
|         // 导出 Excel | ||||
|         ExcelUtils.write(response, "商品类别.xls", "数据", StoreGoodsTypeRespVO.class, | ||||
|                         BeanUtils.toBean(list, StoreGoodsTypeRespVO.class)); | ||||
|     } | ||||
|  | ||||
| } | ||||
| @ -0,0 +1,25 @@ | ||||
| package cn.iocoder.yudao.module.member.controller.admin.storegoodstype.vo; | ||||
|  | ||||
| import lombok.*; | ||||
| import java.util.*; | ||||
| import io.swagger.v3.oas.annotations.media.Schema; | ||||
| import cn.iocoder.yudao.framework.common.pojo.PageParam; | ||||
| import org.springframework.format.annotation.DateTimeFormat; | ||||
| import java.time.LocalDateTime; | ||||
|  | ||||
| import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | ||||
|  | ||||
| @Schema(description = "管理后台 - 商品类别分页 Request VO") | ||||
| @Data | ||||
| @EqualsAndHashCode(callSuper = true) | ||||
| @ToString(callSuper = true) | ||||
| public class StoreGoodsTypePageReqVO extends PageParam { | ||||
|  | ||||
|     @Schema(description = "类别名称", example = "芋艿") | ||||
|     private String categoryName; | ||||
|  | ||||
|     @Schema(description = "创建时间") | ||||
|     @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||||
|     private LocalDateTime[] createTime; | ||||
|  | ||||
| } | ||||
| @ -0,0 +1,28 @@ | ||||
| package cn.iocoder.yudao.module.member.controller.admin.storegoodstype.vo; | ||||
|  | ||||
| import io.swagger.v3.oas.annotations.media.Schema; | ||||
| import lombok.*; | ||||
| import java.util.*; | ||||
| import java.util.*; | ||||
| import org.springframework.format.annotation.DateTimeFormat; | ||||
| import java.time.LocalDateTime; | ||||
| import com.alibaba.excel.annotation.*; | ||||
|  | ||||
| @Schema(description = "管理后台 - 商品类别 Response VO") | ||||
| @Data | ||||
| @ExcelIgnoreUnannotated | ||||
| public class StoreGoodsTypeRespVO { | ||||
|  | ||||
|     @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "4141") | ||||
|     @ExcelProperty("编号") | ||||
|     private Integer id; | ||||
|  | ||||
|     @Schema(description = "类别名称", example = "芋艿") | ||||
|     @ExcelProperty("类别名称") | ||||
|     private String categoryName; | ||||
|  | ||||
|     @Schema(description = "创建时间") | ||||
|     @ExcelProperty("创建时间") | ||||
|     private LocalDateTime createTime; | ||||
|  | ||||
| } | ||||
| @ -0,0 +1,18 @@ | ||||
| package cn.iocoder.yudao.module.member.controller.admin.storegoodstype.vo; | ||||
|  | ||||
| import io.swagger.v3.oas.annotations.media.Schema; | ||||
| import lombok.*; | ||||
| import java.util.*; | ||||
| import javax.validation.constraints.*; | ||||
|  | ||||
| @Schema(description = "管理后台 - 商品类别新增/修改 Request VO") | ||||
| @Data | ||||
| public class StoreGoodsTypeSaveReqVO { | ||||
|  | ||||
|     @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "4141") | ||||
|     private Integer id; | ||||
|  | ||||
|     @Schema(description = "类别名称", example = "芋艿") | ||||
|     private String categoryName; | ||||
|  | ||||
| } | ||||
| @ -0,0 +1,95 @@ | ||||
| package cn.iocoder.yudao.module.member.controller.admin.storesalegoods; | ||||
|  | ||||
| import org.springframework.web.bind.annotation.*; | ||||
| import javax.annotation.Resource; | ||||
| import org.springframework.validation.annotation.Validated; | ||||
| import org.springframework.security.access.prepost.PreAuthorize; | ||||
| import io.swagger.v3.oas.annotations.tags.Tag; | ||||
| import io.swagger.v3.oas.annotations.Parameter; | ||||
| import io.swagger.v3.oas.annotations.Operation; | ||||
|  | ||||
| import javax.validation.constraints.*; | ||||
| import javax.validation.*; | ||||
| import javax.servlet.http.*; | ||||
| import java.util.*; | ||||
| import java.io.IOException; | ||||
|  | ||||
| import cn.iocoder.yudao.framework.common.pojo.PageParam; | ||||
| import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||||
| import cn.iocoder.yudao.framework.common.pojo.CommonResult; | ||||
| import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | ||||
| import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | ||||
|  | ||||
| import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; | ||||
|  | ||||
| import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; | ||||
| import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*; | ||||
|  | ||||
| import cn.iocoder.yudao.module.member.controller.admin.storesalegoods.vo.*; | ||||
| import cn.iocoder.yudao.module.member.dal.dataobject.storesalegoods.StoreSaleGoodsDO; | ||||
| import cn.iocoder.yudao.module.member.service.storesalegoods.StoreSaleGoodsService; | ||||
|  | ||||
| @Tag(name = "管理后台 - 售卖商品") | ||||
| @RestController | ||||
| @RequestMapping("/member/store-sale-goods") | ||||
| @Validated | ||||
| public class StoreSaleGoodsController { | ||||
|  | ||||
|     @Resource | ||||
|     private StoreSaleGoodsService storeSaleGoodsService; | ||||
|  | ||||
|     @PostMapping("/create") | ||||
|     @Operation(summary = "创建售卖商品") | ||||
|     @PreAuthorize("@ss.hasPermission('member:store-sale-goods:create')") | ||||
|     public CommonResult<Long> createStoreSaleGoods(@Valid @RequestBody StoreSaleGoodsSaveReqVO createReqVO) { | ||||
|         return success(storeSaleGoodsService.createStoreSaleGoods(createReqVO)); | ||||
|     } | ||||
|  | ||||
|     @PutMapping("/update") | ||||
|     @Operation(summary = "更新售卖商品") | ||||
|     @PreAuthorize("@ss.hasPermission('member:store-sale-goods:update')") | ||||
|     public CommonResult<Boolean> updateStoreSaleGoods(@Valid @RequestBody StoreSaleGoodsSaveReqVO updateReqVO) { | ||||
|         storeSaleGoodsService.updateStoreSaleGoods(updateReqVO); | ||||
|         return success(true); | ||||
|     } | ||||
|  | ||||
|     @DeleteMapping("/delete") | ||||
|     @Operation(summary = "删除售卖商品") | ||||
|     @Parameter(name = "id", description = "编号", required = true) | ||||
|     @PreAuthorize("@ss.hasPermission('member:store-sale-goods:delete')") | ||||
|     public CommonResult<Boolean> deleteStoreSaleGoods(@RequestParam("id") Long id) { | ||||
|         storeSaleGoodsService.deleteStoreSaleGoods(id); | ||||
|         return success(true); | ||||
|     } | ||||
|  | ||||
|     @GetMapping("/get") | ||||
|     @Operation(summary = "获得售卖商品") | ||||
|     @Parameter(name = "id", description = "编号", required = true, example = "1024") | ||||
|     @PreAuthorize("@ss.hasPermission('member:store-sale-goods:query')") | ||||
|     public CommonResult<StoreSaleGoodsRespVO> getStoreSaleGoods(@RequestParam("id") Long id) { | ||||
|         StoreSaleGoodsDO storeSaleGoods = storeSaleGoodsService.getStoreSaleGoods(id); | ||||
|         return success(BeanUtils.toBean(storeSaleGoods, StoreSaleGoodsRespVO.class)); | ||||
|     } | ||||
|  | ||||
|     @GetMapping("/page") | ||||
|     @Operation(summary = "获得售卖商品分页") | ||||
|     @PreAuthorize("@ss.hasPermission('member:store-sale-goods:query')") | ||||
|     public CommonResult<PageResult<StoreSaleGoodsRespVO>> getStoreSaleGoodsPage(@Valid StoreSaleGoodsPageReqVO pageReqVO) { | ||||
|         PageResult<StoreSaleGoodsDO> pageResult = storeSaleGoodsService.getStoreSaleGoodsPage(pageReqVO); | ||||
|         return success(BeanUtils.toBean(pageResult, StoreSaleGoodsRespVO.class)); | ||||
|     } | ||||
|  | ||||
|     @GetMapping("/export-excel") | ||||
|     @Operation(summary = "导出售卖商品 Excel") | ||||
|     @PreAuthorize("@ss.hasPermission('member:store-sale-goods:export')") | ||||
|     @OperateLog(type = EXPORT) | ||||
|     public void exportStoreSaleGoodsExcel(@Valid StoreSaleGoodsPageReqVO pageReqVO, | ||||
|               HttpServletResponse response) throws IOException { | ||||
|         pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); | ||||
|         List<StoreSaleGoodsDO> list = storeSaleGoodsService.getStoreSaleGoodsPage(pageReqVO).getList(); | ||||
|         // 导出 Excel | ||||
|         ExcelUtils.write(response, "售卖商品.xls", "数据", StoreSaleGoodsRespVO.class, | ||||
|                         BeanUtils.toBean(list, StoreSaleGoodsRespVO.class)); | ||||
|     } | ||||
|  | ||||
| } | ||||
| @ -0,0 +1,31 @@ | ||||
| package cn.iocoder.yudao.module.member.controller.admin.storesalegoods.vo; | ||||
|  | ||||
| import lombok.*; | ||||
| import java.util.*; | ||||
| import io.swagger.v3.oas.annotations.media.Schema; | ||||
| import cn.iocoder.yudao.framework.common.pojo.PageParam; | ||||
| import org.springframework.format.annotation.DateTimeFormat; | ||||
| import java.time.LocalDateTime; | ||||
|  | ||||
| import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | ||||
|  | ||||
| @Schema(description = "管理后台 - 售卖商品分页 Request VO") | ||||
| @Data | ||||
| @EqualsAndHashCode(callSuper = true) | ||||
| @ToString(callSuper = true) | ||||
| public class StoreSaleGoodsPageReqVO extends PageParam { | ||||
|  | ||||
|     @Schema(description = "商品id", example = "11772") | ||||
|     private Integer goodsId; | ||||
|  | ||||
|     @Schema(description = "数量") | ||||
|     private Integer number; | ||||
|  | ||||
|     @Schema(description = "设备ID") | ||||
|     private String equipmentCode; | ||||
|  | ||||
|     @Schema(description = "创建时间") | ||||
|     @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||||
|     private LocalDateTime[] createTime; | ||||
|  | ||||
| } | ||||
| @ -0,0 +1,36 @@ | ||||
| package cn.iocoder.yudao.module.member.controller.admin.storesalegoods.vo; | ||||
|  | ||||
| import io.swagger.v3.oas.annotations.media.Schema; | ||||
| import lombok.*; | ||||
| import java.util.*; | ||||
| import java.util.*; | ||||
| import org.springframework.format.annotation.DateTimeFormat; | ||||
| import java.time.LocalDateTime; | ||||
| import com.alibaba.excel.annotation.*; | ||||
|  | ||||
| @Schema(description = "管理后台 - 售卖商品 Response VO") | ||||
| @Data | ||||
| @ExcelIgnoreUnannotated | ||||
| public class StoreSaleGoodsRespVO { | ||||
|  | ||||
|     @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "29812") | ||||
|     @ExcelProperty("编号") | ||||
|     private Long id; | ||||
|  | ||||
|     @Schema(description = "商品id", example = "11772") | ||||
|     @ExcelProperty("商品id") | ||||
|     private Integer goodsId; | ||||
|  | ||||
|     @Schema(description = "数量") | ||||
|     @ExcelProperty("数量") | ||||
|     private Integer number; | ||||
|  | ||||
|     @Schema(description = "设备ID") | ||||
|     @ExcelProperty("设备ID") | ||||
|     private String equipmentCode; | ||||
|  | ||||
|     @Schema(description = "创建时间") | ||||
|     @ExcelProperty("创建时间") | ||||
|     private LocalDateTime createTime; | ||||
|  | ||||
| } | ||||
| @ -0,0 +1,24 @@ | ||||
| package cn.iocoder.yudao.module.member.controller.admin.storesalegoods.vo; | ||||
|  | ||||
| import io.swagger.v3.oas.annotations.media.Schema; | ||||
| import lombok.*; | ||||
| import java.util.*; | ||||
| import javax.validation.constraints.*; | ||||
|  | ||||
| @Schema(description = "管理后台 - 售卖商品新增/修改 Request VO") | ||||
| @Data | ||||
| public class StoreSaleGoodsSaveReqVO { | ||||
|  | ||||
|     @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "29812") | ||||
|     private Long id; | ||||
|  | ||||
|     @Schema(description = "商品id", example = "11772") | ||||
|     private Integer goodsId; | ||||
|  | ||||
|     @Schema(description = "数量") | ||||
|     private Integer number; | ||||
|  | ||||
|     @Schema(description = "设备ID") | ||||
|     private String equipmentCode; | ||||
|  | ||||
| } | ||||
| @ -0,0 +1,92 @@ | ||||
| package cn.iocoder.yudao.module.member.controller.app.store; | ||||
|  | ||||
| import cn.hutool.core.collection.CollectionUtil; | ||||
| import cn.iocoder.yudao.framework.common.pojo.StoreResult; | ||||
| import cn.iocoder.yudao.framework.security.core.annotations.PreAuthenticated; | ||||
| import cn.iocoder.yudao.module.member.controller.app.store.dto.StoreBaseDto; | ||||
| import cn.iocoder.yudao.module.member.controller.app.store.dto.StoreSaleGoodsDto; | ||||
| import cn.iocoder.yudao.module.member.controller.app.store.dto.StoreUserDto; | ||||
| import cn.iocoder.yudao.module.member.controller.app.store.vo.StoreGoodsVo; | ||||
| import cn.iocoder.yudao.module.member.controller.app.store.vo.StoreUserVo; | ||||
| import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO; | ||||
| import cn.iocoder.yudao.module.member.service.storegoods.StoreGoodsService; | ||||
| import cn.iocoder.yudao.module.member.service.storegoodstype.StoreGoodsTypeService; | ||||
| import cn.iocoder.yudao.module.member.service.storesalegoods.StoreSaleGoodsService; | ||||
| import cn.iocoder.yudao.module.member.service.user.MemberUserService; | ||||
| import io.swagger.v3.oas.annotations.Operation; | ||||
| import io.swagger.v3.oas.annotations.tags.Tag; | ||||
| import lombok.extern.slf4j.Slf4j; | ||||
| import org.apache.poi.ss.formula.functions.T; | ||||
| import org.springframework.validation.annotation.Validated; | ||||
| import org.springframework.web.bind.annotation.*; | ||||
|  | ||||
| import javax.annotation.PostConstruct; | ||||
| import javax.annotation.Resource; | ||||
|  | ||||
| import java.util.List; | ||||
|  | ||||
| @Tag(name = "用户 APP - 超市") | ||||
| @RestController | ||||
| @RequestMapping("/device") | ||||
| @Validated | ||||
| @Slf4j | ||||
| public class AppStoreController { | ||||
|  | ||||
|     @Resource | ||||
|     private MemberUserService userService; | ||||
|     @Resource | ||||
|     private StoreGoodsService storeGoodsService; | ||||
|     @Resource | ||||
|     private StoreGoodsTypeService goodsTypeService; | ||||
|     @Resource | ||||
|     private StoreSaleGoodsService saleGoodsService; | ||||
|  | ||||
|     @GetMapping("/mgcr/memberUser/getMenberTwoList") | ||||
|     @Operation(summary = "获取用户关联信息") | ||||
|     public StoreResult<List<StoreUserVo>> getStoreUser(@RequestBody StoreUserDto dto) { | ||||
|         List<MemberUserDO> list = userService.getStoreUser(); | ||||
|         return StoreResult.success(StoreUserVo.convert(list)); | ||||
|     } | ||||
|  | ||||
|     @GetMapping("/mgcr/equipment/goodsList") | ||||
|     @Operation(summary = "获取菜品库所有菜品") | ||||
|     public StoreResult<StoreGoodsVo> getGoods(@RequestBody StoreBaseDto dto) { | ||||
|         StoreGoodsVo storeGoodsVo = new StoreGoodsVo(); | ||||
|         storeGoodsVo.setGoodsData(storeGoodsService.getAll(null)); | ||||
|         storeGoodsVo.setCategoryData(goodsTypeService.getAll()); | ||||
|         return StoreResult.success(storeGoodsVo); | ||||
|     } | ||||
|  | ||||
|     @PostMapping("/mgcr/equipment/bindGoods") | ||||
|     @Operation(summary = "设置营业菜品") | ||||
|     public StoreResult<String> bindGoods(@RequestBody StoreSaleGoodsDto dto) { | ||||
|         Boolean b = saleGoodsService.bindGoods(dto); | ||||
|         StoreResult<String> result = new StoreResult<>(); | ||||
|  | ||||
|         if (b) { | ||||
|             result.setStatusCode("200"); | ||||
|             result.setMessage("操作成功"); | ||||
|             result.setSuccess(true); | ||||
|         }else{ | ||||
|             result.setStatusCode("300"); | ||||
|             result.setSuccess(false); | ||||
|         } | ||||
|         return result; | ||||
|     } | ||||
|  | ||||
|     @GetMapping("/mgcr/equipment/queryBindGoods") | ||||
|     @Operation(summary = "获取营业菜品") | ||||
|     public StoreResult<StoreGoodsVo> getSaleGoods(@RequestBody StoreBaseDto dto) { | ||||
|         StoreGoodsVo storeGoodsVo = new StoreGoodsVo(); | ||||
|  | ||||
|         List<Integer> goodsIds = saleGoodsService.getGoodsIds(dto.getEquipmentCode()); | ||||
|         if(CollectionUtil.isEmpty(goodsIds)){ | ||||
|             return StoreResult.success(storeGoodsVo); | ||||
|         } | ||||
|         storeGoodsVo.setGoodsData(storeGoodsService.getAll(goodsIds)); | ||||
|         storeGoodsVo.setCategoryData(goodsTypeService.getAll()); | ||||
|         return StoreResult.success(storeGoodsVo); | ||||
|     } | ||||
|  | ||||
|  | ||||
| } | ||||
| @ -0,0 +1,8 @@ | ||||
| package cn.iocoder.yudao.module.member.controller.app.store.dto; | ||||
|  | ||||
| import lombok.Data; | ||||
|  | ||||
| @Data | ||||
| public class StoreBaseDto { | ||||
|     private String equipmentCode; | ||||
| } | ||||
| @ -0,0 +1,10 @@ | ||||
| package cn.iocoder.yudao.module.member.controller.app.store.dto; | ||||
|  | ||||
| import lombok.Data; | ||||
|  | ||||
| @Data | ||||
| public class StoreGoodsDto { | ||||
|     private Integer goodsId; | ||||
|     private Double customPrice; | ||||
|     private Integer number; | ||||
| } | ||||
| @ -0,0 +1,10 @@ | ||||
| package cn.iocoder.yudao.module.member.controller.app.store.dto; | ||||
|  | ||||
| import lombok.Data; | ||||
|  | ||||
| import java.util.List; | ||||
|  | ||||
| @Data | ||||
| public class StoreSaleGoodsDto extends StoreBaseDto{ | ||||
|       private List<StoreGoodsDto> equipmentGoodsCustoms; | ||||
| } | ||||
| @ -0,0 +1,12 @@ | ||||
| package cn.iocoder.yudao.module.member.controller.app.store.dto; | ||||
|  | ||||
| import lombok.Data; | ||||
|  | ||||
| import java.security.PrivateKey; | ||||
|  | ||||
| @Data | ||||
| public class StoreUserDto extends StoreBaseDto{ | ||||
|     private Integer offset; | ||||
|     private Integer limit; | ||||
|  | ||||
| } | ||||
| @ -0,0 +1,15 @@ | ||||
| package cn.iocoder.yudao.module.member.controller.app.store.vo; | ||||
|  | ||||
| import cn.iocoder.yudao.module.member.dal.dataobject.storegoods.StoreGoodsDO; | ||||
| import cn.iocoder.yudao.module.member.dal.dataobject.storegoodstype.StoreGoodsTypeDO; | ||||
| import lombok.Data; | ||||
|  | ||||
| import java.util.List; | ||||
|  | ||||
| @Data | ||||
| public class StoreGoodsVo { | ||||
|  | ||||
|     private List<StoreGoodsDO> goodsData; | ||||
|     private List<StoreGoodsTypeDO> categoryData; | ||||
|  | ||||
| } | ||||
| @ -0,0 +1,39 @@ | ||||
| package cn.iocoder.yudao.module.member.controller.app.store.vo; | ||||
|  | ||||
| import cn.hutool.core.util.StrUtil; | ||||
| import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO; | ||||
| import lombok.Data; | ||||
|  | ||||
| import java.util.ArrayList; | ||||
| import java.util.List; | ||||
|  | ||||
| @Data | ||||
| public class StoreUserVo { | ||||
|     private Integer userId; | ||||
|     private String userName; | ||||
|     private String cardNumber; | ||||
|     private String faceId; | ||||
|     private String openId; | ||||
|  | ||||
|  | ||||
|  | ||||
|     public static List<StoreUserVo> convert(List<MemberUserDO> list){ | ||||
|  | ||||
|  | ||||
|         List<StoreUserVo> voList = new ArrayList<>(); | ||||
|  | ||||
|         for (MemberUserDO memberUserDO : list) { | ||||
|             if(StrUtil.isBlank(memberUserDO.getCardId())){ | ||||
|                 continue; | ||||
|             } | ||||
|             StoreUserVo vo = new StoreUserVo(); | ||||
|             vo.setUserId(memberUserDO.getId().intValue()); | ||||
|             vo.setUserName(memberUserDO.getNickname()); | ||||
|             vo.setCardNumber(memberUserDO.getCardId()); | ||||
|             vo.setFaceId(memberUserDO.getFaceId().toString()); | ||||
|             vo.setOpenId(memberUserDO.getFaceId().toString()); | ||||
|             voList.add(vo); | ||||
|         } | ||||
|         return voList; | ||||
|     } | ||||
| } | ||||
| @ -0,0 +1,51 @@ | ||||
| package cn.iocoder.yudao.module.member.dal.dataobject.storegoods; | ||||
|  | ||||
| import lombok.*; | ||||
| import java.util.*; | ||||
| import java.time.LocalDateTime; | ||||
| import java.time.LocalDateTime; | ||||
| import com.baomidou.mybatisplus.annotation.*; | ||||
| import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; | ||||
|  | ||||
| /** | ||||
|  * 商品 DO | ||||
|  * | ||||
|  * @author 管理员 | ||||
|  */ | ||||
| @TableName("member_store_goods") | ||||
| @KeySequence("member_store_goods_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 | ||||
| @Data | ||||
| @EqualsAndHashCode(callSuper = true) | ||||
| @ToString(callSuper = true) | ||||
| @Builder | ||||
| @NoArgsConstructor | ||||
| @AllArgsConstructor | ||||
| public class StoreGoodsDO extends BaseDO { | ||||
|  | ||||
|     /** | ||||
|      * 编号 | ||||
|      */ | ||||
|     @TableId | ||||
|     private Integer goodId; | ||||
|     /** | ||||
|      * 类别Id | ||||
|      */ | ||||
|     private Integer categoryId; | ||||
|     /** | ||||
|      * 商品名称 | ||||
|      */ | ||||
|     private String goodsName; | ||||
|     /** | ||||
|      * 价格 | ||||
|      */ | ||||
|     private Double price; | ||||
|     /** | ||||
|      * 售卖模式 | ||||
|      */ | ||||
|     private Integer salesModel; | ||||
|     /** | ||||
|      * 设备ID | ||||
|      */ | ||||
|     private String equipmentCode; | ||||
|  | ||||
| } | ||||
| @ -0,0 +1,35 @@ | ||||
| package cn.iocoder.yudao.module.member.dal.dataobject.storegoodstype; | ||||
|  | ||||
| import lombok.*; | ||||
| import java.util.*; | ||||
| import java.time.LocalDateTime; | ||||
| import java.time.LocalDateTime; | ||||
| import com.baomidou.mybatisplus.annotation.*; | ||||
| import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; | ||||
|  | ||||
| /** | ||||
|  * 商品类别 DO | ||||
|  * | ||||
|  * @author 管理员 | ||||
|  */ | ||||
| @TableName("member_store_goods_type") | ||||
| @KeySequence("member_store_goods_type_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 | ||||
| @Data | ||||
| @EqualsAndHashCode(callSuper = true) | ||||
| @ToString(callSuper = true) | ||||
| @Builder | ||||
| @NoArgsConstructor | ||||
| @AllArgsConstructor | ||||
| public class StoreGoodsTypeDO extends BaseDO { | ||||
|  | ||||
|     /** | ||||
|      * 编号 | ||||
|      */ | ||||
|     @TableId | ||||
|     private Integer id; | ||||
|     /** | ||||
|      * 类别名称 | ||||
|      */ | ||||
|     private String categoryName; | ||||
|  | ||||
| } | ||||
| @ -0,0 +1,43 @@ | ||||
| package cn.iocoder.yudao.module.member.dal.dataobject.storesalegoods; | ||||
|  | ||||
| import lombok.*; | ||||
| import java.util.*; | ||||
| import java.time.LocalDateTime; | ||||
| import java.time.LocalDateTime; | ||||
| import com.baomidou.mybatisplus.annotation.*; | ||||
| import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; | ||||
|  | ||||
| /** | ||||
|  * 售卖商品 DO | ||||
|  * | ||||
|  * @author 管理员 | ||||
|  */ | ||||
| @TableName("member_store_sale_goods") | ||||
| @KeySequence("member_store_sale_goods_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 | ||||
| @Data | ||||
| @EqualsAndHashCode(callSuper = true) | ||||
| @ToString(callSuper = true) | ||||
| @Builder | ||||
| @NoArgsConstructor | ||||
| @AllArgsConstructor | ||||
| public class StoreSaleGoodsDO extends BaseDO { | ||||
|  | ||||
|     /** | ||||
|      * 编号 | ||||
|      */ | ||||
|     @TableId | ||||
|     private Long id; | ||||
|     /** | ||||
|      * 商品id | ||||
|      */ | ||||
|     private Integer goodsId; | ||||
|     /** | ||||
|      * 数量 | ||||
|      */ | ||||
|     private Integer number; | ||||
|     /** | ||||
|      * 设备ID | ||||
|      */ | ||||
|     private String equipmentCode; | ||||
|  | ||||
| } | ||||
| @ -0,0 +1,31 @@ | ||||
| package cn.iocoder.yudao.module.member.dal.mysql.storegoods; | ||||
|  | ||||
| import java.util.*; | ||||
|  | ||||
| import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||||
| import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; | ||||
| import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | ||||
| import cn.iocoder.yudao.module.member.dal.dataobject.storegoods.StoreGoodsDO; | ||||
| import org.apache.ibatis.annotations.Mapper; | ||||
| import cn.iocoder.yudao.module.member.controller.admin.storegoods.vo.*; | ||||
|  | ||||
| /** | ||||
|  * 商品 Mapper | ||||
|  * | ||||
|  * @author 管理员 | ||||
|  */ | ||||
| @Mapper | ||||
| public interface StoreGoodsMapper extends BaseMapperX<StoreGoodsDO> { | ||||
|  | ||||
|     default PageResult<StoreGoodsDO> selectPage(StoreGoodsPageReqVO reqVO) { | ||||
|         return selectPage(reqVO, new LambdaQueryWrapperX<StoreGoodsDO>() | ||||
|                 .eqIfPresent(StoreGoodsDO::getCategoryId, reqVO.getCategoryId()) | ||||
|                 .likeIfPresent(StoreGoodsDO::getGoodsName, reqVO.getGoodsName()) | ||||
|                 .eqIfPresent(StoreGoodsDO::getPrice, reqVO.getPrice()) | ||||
|                 .eqIfPresent(StoreGoodsDO::getSalesModel, reqVO.getSalesModel()) | ||||
|                 .eqIfPresent(StoreGoodsDO::getEquipmentCode, reqVO.getEquipmentCode()) | ||||
|                 .betweenIfPresent(StoreGoodsDO::getCreateTime, reqVO.getCreateTime()) | ||||
|                 .orderByDesc(StoreGoodsDO::getCategoryId)); | ||||
|     } | ||||
|  | ||||
| } | ||||
| @ -0,0 +1,27 @@ | ||||
| package cn.iocoder.yudao.module.member.dal.mysql.storegoodstype; | ||||
|  | ||||
| import java.util.*; | ||||
|  | ||||
| import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||||
| import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; | ||||
| import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | ||||
| import cn.iocoder.yudao.module.member.dal.dataobject.storegoodstype.StoreGoodsTypeDO; | ||||
| import org.apache.ibatis.annotations.Mapper; | ||||
| import cn.iocoder.yudao.module.member.controller.admin.storegoodstype.vo.*; | ||||
|  | ||||
| /** | ||||
|  * 商品类别 Mapper | ||||
|  * | ||||
|  * @author 管理员 | ||||
|  */ | ||||
| @Mapper | ||||
| public interface StoreGoodsTypeMapper extends BaseMapperX<StoreGoodsTypeDO> { | ||||
|  | ||||
|     default PageResult<StoreGoodsTypeDO> selectPage(StoreGoodsTypePageReqVO reqVO) { | ||||
|         return selectPage(reqVO, new LambdaQueryWrapperX<StoreGoodsTypeDO>() | ||||
|                 .likeIfPresent(StoreGoodsTypeDO::getCategoryName, reqVO.getCategoryName()) | ||||
|                 .betweenIfPresent(StoreGoodsTypeDO::getCreateTime, reqVO.getCreateTime()) | ||||
|                 .orderByDesc(StoreGoodsTypeDO::getId)); | ||||
|     } | ||||
|  | ||||
| } | ||||
| @ -0,0 +1,29 @@ | ||||
| package cn.iocoder.yudao.module.member.dal.mysql.storesalegoods; | ||||
|  | ||||
| import java.util.*; | ||||
|  | ||||
| import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||||
| import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; | ||||
| import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | ||||
| import cn.iocoder.yudao.module.member.dal.dataobject.storesalegoods.StoreSaleGoodsDO; | ||||
| import org.apache.ibatis.annotations.Mapper; | ||||
| import cn.iocoder.yudao.module.member.controller.admin.storesalegoods.vo.*; | ||||
|  | ||||
| /** | ||||
|  * 售卖商品 Mapper | ||||
|  * | ||||
|  * @author 管理员 | ||||
|  */ | ||||
| @Mapper | ||||
| public interface StoreSaleGoodsMapper extends BaseMapperX<StoreSaleGoodsDO> { | ||||
|  | ||||
|     default PageResult<StoreSaleGoodsDO> selectPage(StoreSaleGoodsPageReqVO reqVO) { | ||||
|         return selectPage(reqVO, new LambdaQueryWrapperX<StoreSaleGoodsDO>() | ||||
|                 .eqIfPresent(StoreSaleGoodsDO::getGoodsId, reqVO.getGoodsId()) | ||||
|                 .eqIfPresent(StoreSaleGoodsDO::getNumber, reqVO.getNumber()) | ||||
|                 .eqIfPresent(StoreSaleGoodsDO::getEquipmentCode, reqVO.getEquipmentCode()) | ||||
|                 .betweenIfPresent(StoreSaleGoodsDO::getCreateTime, reqVO.getCreateTime()) | ||||
|                 .orderByDesc(StoreSaleGoodsDO::getId)); | ||||
|     } | ||||
|  | ||||
| } | ||||
| @ -0,0 +1,58 @@ | ||||
| package cn.iocoder.yudao.module.member.service.storegoods; | ||||
|  | ||||
| import java.util.*; | ||||
| import javax.validation.*; | ||||
| import cn.iocoder.yudao.module.member.controller.admin.storegoods.vo.*; | ||||
| import cn.iocoder.yudao.module.member.dal.dataobject.storegoods.StoreGoodsDO; | ||||
| import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||||
| import cn.iocoder.yudao.framework.common.pojo.PageParam; | ||||
|  | ||||
| /** | ||||
|  * 商品 Service 接口 | ||||
|  * | ||||
|  * @author 管理员 | ||||
|  */ | ||||
| public interface StoreGoodsService { | ||||
|  | ||||
|     /** | ||||
|      * 创建商品 | ||||
|      * | ||||
|      * @param createReqVO 创建信息 | ||||
|      * @return 编号 | ||||
|      */ | ||||
|     Integer createStoreGoods(@Valid StoreGoodsSaveReqVO createReqVO); | ||||
|  | ||||
|     /** | ||||
|      * 更新商品 | ||||
|      * | ||||
|      * @param updateReqVO 更新信息 | ||||
|      */ | ||||
|     void updateStoreGoods(@Valid StoreGoodsSaveReqVO updateReqVO); | ||||
|  | ||||
|     /** | ||||
|      * 删除商品 | ||||
|      * | ||||
|      * @param id 编号 | ||||
|      */ | ||||
|     void deleteStoreGoods(Integer id); | ||||
|  | ||||
|     /** | ||||
|      * 获得商品 | ||||
|      * | ||||
|      * @param id 编号 | ||||
|      * @return 商品 | ||||
|      */ | ||||
|     StoreGoodsDO getStoreGoods(Integer id); | ||||
|  | ||||
|     /** | ||||
|      * 获得商品分页 | ||||
|      * | ||||
|      * @param pageReqVO 分页查询 | ||||
|      * @return 商品分页 | ||||
|      */ | ||||
|     PageResult<StoreGoodsDO> getStoreGoodsPage(StoreGoodsPageReqVO pageReqVO); | ||||
|  | ||||
|  | ||||
|     List<StoreGoodsDO>  getAll(List<Integer> goodsIds); | ||||
|  | ||||
| } | ||||
| @ -0,0 +1,85 @@ | ||||
| package cn.iocoder.yudao.module.member.service.storegoods; | ||||
|  | ||||
| import cn.hutool.core.collection.CollectionUtil; | ||||
| import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | ||||
| import org.springframework.stereotype.Service; | ||||
| import javax.annotation.Resource; | ||||
| import org.springframework.validation.annotation.Validated; | ||||
| import org.springframework.transaction.annotation.Transactional; | ||||
|  | ||||
| import java.util.*; | ||||
| import cn.iocoder.yudao.module.member.controller.admin.storegoods.vo.*; | ||||
| import cn.iocoder.yudao.module.member.dal.dataobject.storegoods.StoreGoodsDO; | ||||
| import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||||
| import cn.iocoder.yudao.framework.common.pojo.PageParam; | ||||
| import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | ||||
|  | ||||
| import cn.iocoder.yudao.module.member.dal.mysql.storegoods.StoreGoodsMapper; | ||||
|  | ||||
| import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | ||||
| import static cn.iocoder.yudao.module.member.enums.ErrorCodeConstants.*; | ||||
|  | ||||
| /** | ||||
|  * 商品 Service 实现类 | ||||
|  * | ||||
|  * @author 管理员 | ||||
|  */ | ||||
| @Service | ||||
| @Validated | ||||
| public class StoreGoodsServiceImpl implements StoreGoodsService { | ||||
|  | ||||
|     @Resource | ||||
|     private StoreGoodsMapper storeGoodsMapper; | ||||
|  | ||||
|     @Override | ||||
|     public Integer createStoreGoods(StoreGoodsSaveReqVO createReqVO) { | ||||
|         // 插入 | ||||
|         StoreGoodsDO storeGoods = BeanUtils.toBean(createReqVO, StoreGoodsDO.class); | ||||
|         storeGoodsMapper.insert(storeGoods); | ||||
|         // 返回 | ||||
|         return storeGoods.getGoodId(); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public void updateStoreGoods(StoreGoodsSaveReqVO updateReqVO) { | ||||
|         // 校验存在 | ||||
|         validateStoreGoodsExists(updateReqVO.getGoodId()); | ||||
|         // 更新 | ||||
|         StoreGoodsDO updateObj = BeanUtils.toBean(updateReqVO, StoreGoodsDO.class); | ||||
|         storeGoodsMapper.updateById(updateObj); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public void deleteStoreGoods(Integer id) { | ||||
|         // 校验存在 | ||||
|         validateStoreGoodsExists(id); | ||||
|         // 删除 | ||||
|         storeGoodsMapper.deleteById(id); | ||||
|     } | ||||
|  | ||||
|     private void validateStoreGoodsExists(Integer id) { | ||||
|         if (storeGoodsMapper.selectById(id) == null) { | ||||
|             throw exception(STORE_GOODS_NOT_EXISTS); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public StoreGoodsDO getStoreGoods(Integer id) { | ||||
|         return storeGoodsMapper.selectById(id); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public PageResult<StoreGoodsDO> getStoreGoodsPage(StoreGoodsPageReqVO pageReqVO) { | ||||
|         return storeGoodsMapper.selectPage(pageReqVO); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public List<StoreGoodsDO> getAll(List<Integer> goodsIds) { | ||||
|         if (CollectionUtil.isEmpty(goodsIds)) { | ||||
|             return storeGoodsMapper.selectList(); | ||||
|         }else { | ||||
|             return storeGoodsMapper.selectList(new LambdaQueryWrapper<StoreGoodsDO>().in(StoreGoodsDO::getGoodId, goodsIds)); | ||||
|         } | ||||
|  | ||||
|     } | ||||
| } | ||||
| @ -0,0 +1,56 @@ | ||||
| package cn.iocoder.yudao.module.member.service.storegoodstype; | ||||
|  | ||||
| import java.util.*; | ||||
| import javax.validation.*; | ||||
| import cn.iocoder.yudao.module.member.controller.admin.storegoodstype.vo.*; | ||||
| import cn.iocoder.yudao.module.member.dal.dataobject.storegoodstype.StoreGoodsTypeDO; | ||||
| import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||||
| import cn.iocoder.yudao.framework.common.pojo.PageParam; | ||||
|  | ||||
| /** | ||||
|  * 商品类别 Service 接口 | ||||
|  * | ||||
|  * @author 管理员 | ||||
|  */ | ||||
| public interface StoreGoodsTypeService { | ||||
|  | ||||
|     /** | ||||
|      * 创建商品类别 | ||||
|      * | ||||
|      * @param createReqVO 创建信息 | ||||
|      * @return 编号 | ||||
|      */ | ||||
|     Integer createStoreGoodsType(@Valid StoreGoodsTypeSaveReqVO createReqVO); | ||||
|  | ||||
|     /** | ||||
|      * 更新商品类别 | ||||
|      * | ||||
|      * @param updateReqVO 更新信息 | ||||
|      */ | ||||
|     void updateStoreGoodsType(@Valid StoreGoodsTypeSaveReqVO updateReqVO); | ||||
|  | ||||
|     /** | ||||
|      * 删除商品类别 | ||||
|      * | ||||
|      * @param id 编号 | ||||
|      */ | ||||
|     void deleteStoreGoodsType(Integer id); | ||||
|  | ||||
|     /** | ||||
|      * 获得商品类别 | ||||
|      * | ||||
|      * @param id 编号 | ||||
|      * @return 商品类别 | ||||
|      */ | ||||
|     StoreGoodsTypeDO getStoreGoodsType(Integer id); | ||||
|  | ||||
|     /** | ||||
|      * 获得商品类别分页 | ||||
|      * | ||||
|      * @param pageReqVO 分页查询 | ||||
|      * @return 商品类别分页 | ||||
|      */ | ||||
|     PageResult<StoreGoodsTypeDO> getStoreGoodsTypePage(StoreGoodsTypePageReqVO pageReqVO); | ||||
|  | ||||
|     List<StoreGoodsTypeDO> getAll(); | ||||
| } | ||||
| @ -0,0 +1,78 @@ | ||||
| package cn.iocoder.yudao.module.member.service.storegoodstype; | ||||
|  | ||||
| import org.springframework.stereotype.Service; | ||||
| import javax.annotation.Resource; | ||||
| import org.springframework.validation.annotation.Validated; | ||||
| import org.springframework.transaction.annotation.Transactional; | ||||
|  | ||||
| import java.util.*; | ||||
| import cn.iocoder.yudao.module.member.controller.admin.storegoodstype.vo.*; | ||||
| import cn.iocoder.yudao.module.member.dal.dataobject.storegoodstype.StoreGoodsTypeDO; | ||||
| import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||||
| import cn.iocoder.yudao.framework.common.pojo.PageParam; | ||||
| import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | ||||
|  | ||||
| import cn.iocoder.yudao.module.member.dal.mysql.storegoodstype.StoreGoodsTypeMapper; | ||||
|  | ||||
| import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | ||||
| import static cn.iocoder.yudao.module.member.enums.ErrorCodeConstants.*; | ||||
|  | ||||
| /** | ||||
|  * 商品类别 Service 实现类 | ||||
|  * | ||||
|  * @author 管理员 | ||||
|  */ | ||||
| @Service | ||||
| @Validated | ||||
| public class StoreGoodsTypeServiceImpl implements StoreGoodsTypeService { | ||||
|  | ||||
|     @Resource | ||||
|     private StoreGoodsTypeMapper storeGoodsTypeMapper; | ||||
|  | ||||
|     @Override | ||||
|     public Integer createStoreGoodsType(StoreGoodsTypeSaveReqVO createReqVO) { | ||||
|         // 插入 | ||||
|         StoreGoodsTypeDO storeGoodsType = BeanUtils.toBean(createReqVO, StoreGoodsTypeDO.class); | ||||
|         storeGoodsTypeMapper.insert(storeGoodsType); | ||||
|         // 返回 | ||||
|         return storeGoodsType.getId(); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public void updateStoreGoodsType(StoreGoodsTypeSaveReqVO updateReqVO) { | ||||
|         // 校验存在 | ||||
|         validateStoreGoodsTypeExists(updateReqVO.getId()); | ||||
|         // 更新 | ||||
|         StoreGoodsTypeDO updateObj = BeanUtils.toBean(updateReqVO, StoreGoodsTypeDO.class); | ||||
|         storeGoodsTypeMapper.updateById(updateObj); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public void deleteStoreGoodsType(Integer id) { | ||||
|         // 校验存在 | ||||
|         validateStoreGoodsTypeExists(id); | ||||
|         // 删除 | ||||
|         storeGoodsTypeMapper.deleteById(id); | ||||
|     } | ||||
|  | ||||
|     private void validateStoreGoodsTypeExists(Integer id) { | ||||
|         if (storeGoodsTypeMapper.selectById(id) == null) { | ||||
|             throw exception(STORE_GOODS_TYPE_NOT_EXISTS); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public StoreGoodsTypeDO getStoreGoodsType(Integer id) { | ||||
|         return storeGoodsTypeMapper.selectById(id); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public PageResult<StoreGoodsTypeDO> getStoreGoodsTypePage(StoreGoodsTypePageReqVO pageReqVO) { | ||||
|         return storeGoodsTypeMapper.selectPage(pageReqVO); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public List<StoreGoodsTypeDO> getAll() { | ||||
|         return storeGoodsTypeMapper.selectList(); | ||||
|     } | ||||
| } | ||||
| @ -0,0 +1,60 @@ | ||||
| package cn.iocoder.yudao.module.member.service.storesalegoods; | ||||
|  | ||||
| import java.util.*; | ||||
| import javax.validation.*; | ||||
| import cn.iocoder.yudao.module.member.controller.admin.storesalegoods.vo.*; | ||||
| import cn.iocoder.yudao.module.member.controller.app.store.dto.StoreSaleGoodsDto; | ||||
| import cn.iocoder.yudao.module.member.dal.dataobject.storesalegoods.StoreSaleGoodsDO; | ||||
| import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||||
| import cn.iocoder.yudao.framework.common.pojo.PageParam; | ||||
| import org.springframework.web.bind.annotation.RequestBody; | ||||
|  | ||||
| /** | ||||
|  * 售卖商品 Service 接口 | ||||
|  * | ||||
|  * @author 管理员 | ||||
|  */ | ||||
| public interface StoreSaleGoodsService { | ||||
|  | ||||
|     /** | ||||
|      * 创建售卖商品 | ||||
|      * | ||||
|      * @param createReqVO 创建信息 | ||||
|      * @return 编号 | ||||
|      */ | ||||
|     Long createStoreSaleGoods(@Valid StoreSaleGoodsSaveReqVO createReqVO); | ||||
|  | ||||
|     /** | ||||
|      * 更新售卖商品 | ||||
|      * | ||||
|      * @param updateReqVO 更新信息 | ||||
|      */ | ||||
|     void updateStoreSaleGoods(@Valid StoreSaleGoodsSaveReqVO updateReqVO); | ||||
|  | ||||
|     /** | ||||
|      * 删除售卖商品 | ||||
|      * | ||||
|      * @param id 编号 | ||||
|      */ | ||||
|     void deleteStoreSaleGoods(Long id); | ||||
|  | ||||
|     /** | ||||
|      * 获得售卖商品 | ||||
|      * | ||||
|      * @param id 编号 | ||||
|      * @return 售卖商品 | ||||
|      */ | ||||
|     StoreSaleGoodsDO getStoreSaleGoods(Long id); | ||||
|  | ||||
|     /** | ||||
|      * 获得售卖商品分页 | ||||
|      * | ||||
|      * @param pageReqVO 分页查询 | ||||
|      * @return 售卖商品分页 | ||||
|      */ | ||||
|     PageResult<StoreSaleGoodsDO> getStoreSaleGoodsPage(StoreSaleGoodsPageReqVO pageReqVO); | ||||
|  | ||||
|     Boolean bindGoods(StoreSaleGoodsDto dto); | ||||
|  | ||||
|     List<Integer> getGoodsIds(String equipmentCode); | ||||
| } | ||||
| @ -0,0 +1,109 @@ | ||||
| package cn.iocoder.yudao.module.member.service.storesalegoods; | ||||
|  | ||||
| import cn.hutool.core.bean.BeanUtil; | ||||
| import cn.hutool.core.collection.CollectionUtil; | ||||
| import cn.iocoder.yudao.module.member.controller.app.store.dto.StoreGoodsDto; | ||||
| import cn.iocoder.yudao.module.member.controller.app.store.dto.StoreSaleGoodsDto; | ||||
| import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | ||||
| import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | ||||
| import org.springframework.stereotype.Service; | ||||
| import javax.annotation.Resource; | ||||
| import org.springframework.validation.annotation.Validated; | ||||
| import org.springframework.transaction.annotation.Transactional; | ||||
|  | ||||
| import java.util.*; | ||||
| import java.util.stream.Collectors; | ||||
|  | ||||
| import cn.iocoder.yudao.module.member.controller.admin.storesalegoods.vo.*; | ||||
| import cn.iocoder.yudao.module.member.dal.dataobject.storesalegoods.StoreSaleGoodsDO; | ||||
| import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||||
| import cn.iocoder.yudao.framework.common.pojo.PageParam; | ||||
| import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | ||||
|  | ||||
| import cn.iocoder.yudao.module.member.dal.mysql.storesalegoods.StoreSaleGoodsMapper; | ||||
|  | ||||
| import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | ||||
| import static cn.iocoder.yudao.module.member.enums.ErrorCodeConstants.*; | ||||
|  | ||||
| /** | ||||
|  * 售卖商品 Service 实现类 | ||||
|  * | ||||
|  * @author 管理员 | ||||
|  */ | ||||
| @Service | ||||
| @Validated | ||||
| public class StoreSaleGoodsServiceImpl implements StoreSaleGoodsService { | ||||
|  | ||||
|     @Resource | ||||
|     private StoreSaleGoodsMapper storeSaleGoodsMapper; | ||||
|  | ||||
|     @Override | ||||
|     public Long createStoreSaleGoods(StoreSaleGoodsSaveReqVO createReqVO) { | ||||
|         // 插入 | ||||
|         StoreSaleGoodsDO storeSaleGoods = BeanUtils.toBean(createReqVO, StoreSaleGoodsDO.class); | ||||
|         storeSaleGoodsMapper.insert(storeSaleGoods); | ||||
|         // 返回 | ||||
|         return storeSaleGoods.getId(); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public void updateStoreSaleGoods(StoreSaleGoodsSaveReqVO updateReqVO) { | ||||
|         // 校验存在 | ||||
|         validateStoreSaleGoodsExists(updateReqVO.getId()); | ||||
|         // 更新 | ||||
|         StoreSaleGoodsDO updateObj = BeanUtils.toBean(updateReqVO, StoreSaleGoodsDO.class); | ||||
|         storeSaleGoodsMapper.updateById(updateObj); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public void deleteStoreSaleGoods(Long id) { | ||||
|         // 校验存在 | ||||
|         validateStoreSaleGoodsExists(id); | ||||
|         // 删除 | ||||
|         storeSaleGoodsMapper.deleteById(id); | ||||
|     } | ||||
|  | ||||
|     private void validateStoreSaleGoodsExists(Long id) { | ||||
|         if (storeSaleGoodsMapper.selectById(id) == null) { | ||||
|             throw exception(STORE_SALE_GOODS_NOT_EXISTS); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public StoreSaleGoodsDO getStoreSaleGoods(Long id) { | ||||
|         return storeSaleGoodsMapper.selectById(id); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public PageResult<StoreSaleGoodsDO> getStoreSaleGoodsPage(StoreSaleGoodsPageReqVO pageReqVO) { | ||||
|         return storeSaleGoodsMapper.selectPage(pageReqVO); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public Boolean bindGoods(StoreSaleGoodsDto dto) { | ||||
|  | ||||
|         if(CollectionUtil.isEmpty(dto.getEquipmentGoodsCustoms())){ | ||||
|             throw exception(STORE_SALE_GOODS_NOT_NULL); | ||||
|         } | ||||
|         //清空 | ||||
|         storeSaleGoodsMapper.delete(new LambdaQueryWrapper<StoreSaleGoodsDO>().eq(StoreSaleGoodsDO::getEquipmentCode, dto.getEquipmentCode())); | ||||
|         ArrayList<StoreSaleGoodsDO> list = new ArrayList<>(); | ||||
|         for (StoreGoodsDto storeGoodsDto : dto.getEquipmentGoodsCustoms()) { | ||||
|             StoreSaleGoodsDO storeSaleGoodsDO = new StoreSaleGoodsDO(); | ||||
|             BeanUtil.copyProperties(storeGoodsDto, storeSaleGoodsDO); | ||||
|             storeSaleGoodsDO.setEquipmentCode(dto.getEquipmentCode()); | ||||
|             list.add(storeSaleGoodsDO); | ||||
|         } | ||||
|         return storeSaleGoodsMapper.insertBatch(list); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public List<Integer> getGoodsIds(String equipmentCode) { | ||||
|         List<StoreSaleGoodsDO> storeSaleGoodsDOS = storeSaleGoodsMapper.selectList(new LambdaQueryWrapper<StoreSaleGoodsDO>().eq(StoreSaleGoodsDO::getEquipmentCode, equipmentCode)); | ||||
|         if (CollectionUtil.isEmpty(storeSaleGoodsDOS)){ | ||||
|             return Collections.emptyList(); | ||||
|         }else { | ||||
|             return storeSaleGoodsDOS.stream().map(StoreSaleGoodsDO::getGoodsId).collect(Collectors.toList()); | ||||
|         } | ||||
|     } | ||||
| } | ||||
| @ -246,4 +246,6 @@ public interface MemberUserService { | ||||
|     BigDecimal getReductionAmount(Long userId,BigDecimal money,LocalDateTime time); | ||||
|  | ||||
|     String getFaceUrl(Long userId); | ||||
|  | ||||
|     List<MemberUserDO> getStoreUser(); | ||||
| } | ||||
|  | ||||
| @ -774,6 +774,11 @@ public class MemberUserServiceImpl implements MemberUserService { | ||||
|         return memberUserMapper.getFace(userId); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public List<MemberUserDO> getStoreUser() { | ||||
|         return memberUserMapper.selectList(); | ||||
|     } | ||||
|  | ||||
|     public BigDecimal countAmount(MemberTagDO memberTagDO, BigDecimal money, String timePeriod ){ | ||||
|         if(memberTagDO.getType().equals("1")){ | ||||
|             if (memberTagDO.getTimeFlag().equals("0")){ | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 seesaw
					seesaw