From 30363735dff6807d920bd61f22242db9e592c3c3 Mon Sep 17 00:00:00 2001 From: xm <1350250847@qq.com> Date: Wed, 27 May 2026 10:59:00 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=95=86=E5=93=81=E5=88=86?= =?UTF-8?q?=E6=B6=A6=E5=9F=BA=E7=A1=80=E4=B8=9A=E5=8A=A1=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/ShopGoodsProfitController.java | 93 +++++++++++++++++++ .../shop/entity/ShopGoodsProfit.java | 65 +++++++++++++ .../shop/mapper/ShopGoodsProfitMapper.java | 37 ++++++++ .../shop/mapper/xml/ShopGoodsProfitMapper.xml | 63 +++++++++++++ .../shop/param/ShopGoodsProfitParam.java | 61 ++++++++++++ .../shop/service/ShopGoodsProfitService.java | 42 +++++++++ .../impl/ShopGoodsProfitServiceImpl.java | 49 ++++++++++ 7 files changed, 410 insertions(+) create mode 100644 src/main/java/com/gxwebsoft/shop/controller/ShopGoodsProfitController.java create mode 100644 src/main/java/com/gxwebsoft/shop/entity/ShopGoodsProfit.java create mode 100644 src/main/java/com/gxwebsoft/shop/mapper/ShopGoodsProfitMapper.java create mode 100644 src/main/java/com/gxwebsoft/shop/mapper/xml/ShopGoodsProfitMapper.xml create mode 100644 src/main/java/com/gxwebsoft/shop/param/ShopGoodsProfitParam.java create mode 100644 src/main/java/com/gxwebsoft/shop/service/ShopGoodsProfitService.java create mode 100644 src/main/java/com/gxwebsoft/shop/service/impl/ShopGoodsProfitServiceImpl.java diff --git a/src/main/java/com/gxwebsoft/shop/controller/ShopGoodsProfitController.java b/src/main/java/com/gxwebsoft/shop/controller/ShopGoodsProfitController.java new file mode 100644 index 0000000..c7e8ecf --- /dev/null +++ b/src/main/java/com/gxwebsoft/shop/controller/ShopGoodsProfitController.java @@ -0,0 +1,93 @@ +package com.gxwebsoft.shop.controller; + +import com.gxwebsoft.common.core.annotation.OperationLog; +import com.gxwebsoft.common.core.web.ApiResult; +import com.gxwebsoft.common.core.web.BaseController; +import com.gxwebsoft.common.core.web.PageResult; +import com.gxwebsoft.common.system.entity.User; +import com.gxwebsoft.shop.entity.ShopGoodsProfit; +import com.gxwebsoft.shop.param.ShopGoodsProfitParam; +import com.gxwebsoft.shop.service.ShopGoodsProfitService; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import java.util.List; + +/** + * 商品分润设定控制器 + * + * @author xm + * @since 2026-05-20 14:33:00 + */ +@Tag(name = "商品分润设定管理") +@RestController +@RequestMapping("/api/shop/shop-goods-profit") +public class ShopGoodsProfitController extends BaseController { + @Resource + private ShopGoodsProfitService shopGoodsProfitService; + +// @PreAuthorize("hasAuthority('shop:shopGoodsProfit:list')") + @Operation(summary = "分页查询商品分润设定") + @GetMapping("/page") + public ApiResult> page(ShopGoodsProfitParam param) { + // 使用关联查询 + return success(shopGoodsProfitService.pageRel(param)); + } + +// @PreAuthorize("hasAuthority('shop:shopGoodsProfit:list')") + @Operation(summary = "查询全部商品分润设定") + @GetMapping() + public ApiResult> list(ShopGoodsProfitParam param) { + // 使用关联查询 + return success(shopGoodsProfitService.listRel(param)); + } + +// @PreAuthorize("hasAuthority('shop:shopGoodsProfit:list')") + @Operation(summary = "根据id查询商品分润设定") + @GetMapping("/{id}") + public ApiResult get(@PathVariable("id") Integer id) { + // 使用关联查询 + return success(shopGoodsProfitService.getByIdRel(id)); + } + +// @PreAuthorize("hasAuthority('shop:shopGoodsProfit:save')") + @OperationLog + @Operation(summary = "添加商品分润设定") + @PostMapping() + public ApiResult save(@RequestBody ShopGoodsProfit shopGoodsProfit) { + // 记录当前登录用户id + User loginUser = getLoginUser(); + if (loginUser != null) { + shopGoodsProfit.setUserId(loginUser.getUserId()); + } + if (shopGoodsProfitService.save(shopGoodsProfit)) { + return success("添加成功"); + } + return fail("添加失败"); + } + +// @PreAuthorize("hasAuthority('shop:shopGoodsProfit:update')") + @OperationLog + @Operation(summary = "修改商品分润设定") + @PutMapping() + public ApiResult update(@RequestBody ShopGoodsProfit shopGoodsProfit) { + if (shopGoodsProfitService.updateById(shopGoodsProfit)) { + return success("修改成功"); + } + return fail("修改失败"); + } + +// @PreAuthorize("hasAuthority('shop:shopGoodsProfit:remove')") + @OperationLog + @Operation(summary = "删除商品分润设定") + @DeleteMapping("/{id}") + public ApiResult remove(@PathVariable("id") Integer id) { + if (shopGoodsProfitService.removeById(id)) { + return success("删除成功"); + } + return fail("删除失败"); + } + +} diff --git a/src/main/java/com/gxwebsoft/shop/entity/ShopGoodsProfit.java b/src/main/java/com/gxwebsoft/shop/entity/ShopGoodsProfit.java new file mode 100644 index 0000000..d679966 --- /dev/null +++ b/src/main/java/com/gxwebsoft/shop/entity/ShopGoodsProfit.java @@ -0,0 +1,65 @@ +package com.gxwebsoft.shop.entity; + +import java.math.BigDecimal; +import com.baomidou.mybatisplus.annotation.IdType; +import java.time.LocalDateTime; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableLogic; +import java.io.Serializable; +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * 商品分润设定 + * + * @author xm + * @since 2026-05-20 14:33:00 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Schema(name = "ShopGoodsProfit对象", description = "商品分润设定") +@TableName("shop_goods_profit") +public class ShopGoodsProfit implements Serializable { + private static final long serialVersionUID = 1L; + + @Schema(description = "主键ID") + @TableId(value = "id", type = IdType.AUTO) + private Integer id; + + @Schema(description = "类型 1-股东分红 2-其他") + private Integer type; + + @Schema(description = "商品ID") + private Integer goodsId; + + @Schema(description = "用户ID") + private Integer userId; + + @Schema(description = "分佣比例 百分比") + private BigDecimal profit; + + @Schema(description = "开启状态 0-未开启 1-开启") + private Integer status; + + @Schema(description = "租户ID") + private Integer tenantId; + + @Schema(description = "创建人") + private Integer creator; + + @Schema(description = "创建时间") + private LocalDateTime createTime; + + @Schema(description = "更新人") + private Integer updater; + + @Schema(description = "更新人") + private LocalDateTime updateTime; + + @Schema(description = "删除 0-未删 1-已删") + @TableLogic + private Integer deleted; + +} diff --git a/src/main/java/com/gxwebsoft/shop/mapper/ShopGoodsProfitMapper.java b/src/main/java/com/gxwebsoft/shop/mapper/ShopGoodsProfitMapper.java new file mode 100644 index 0000000..6ef99c6 --- /dev/null +++ b/src/main/java/com/gxwebsoft/shop/mapper/ShopGoodsProfitMapper.java @@ -0,0 +1,37 @@ +package com.gxwebsoft.shop.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.gxwebsoft.shop.entity.ShopGoodsProfit; +import com.gxwebsoft.shop.param.ShopGoodsProfitParam; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 商品分润设定Mapper + * + * @author xm + * @since 2026-05-20 14:33:00 + */ +public interface ShopGoodsProfitMapper extends BaseMapper { + + /** + * 分页查询 + * + * @param page 分页对象 + * @param param 查询参数 + * @return List + */ + List selectPageRel(@Param("page") IPage page, + @Param("param") ShopGoodsProfitParam param); + + /** + * 查询全部 + * + * @param param 查询参数 + * @return List + */ + List selectListRel(@Param("param") ShopGoodsProfitParam param); + +} diff --git a/src/main/java/com/gxwebsoft/shop/mapper/xml/ShopGoodsProfitMapper.xml b/src/main/java/com/gxwebsoft/shop/mapper/xml/ShopGoodsProfitMapper.xml new file mode 100644 index 0000000..79bf817 --- /dev/null +++ b/src/main/java/com/gxwebsoft/shop/mapper/xml/ShopGoodsProfitMapper.xml @@ -0,0 +1,63 @@ + + + + + + + SELECT a.* + FROM shop_goods_profit a + + + AND a.id = #{param.id} + + + AND a.type = #{param.type} + + + AND a.goods_id = #{param.goodsId} + + + AND a.user_id = #{param.userId} + + + AND a.profit = #{param.profit} + + + AND a.status = #{param.status} + + + AND a.creator = #{param.creator} + + + AND a.create_time >= #{param.createTimeStart} + + + AND a.create_time <= #{param.createTimeEnd} + + + AND a.updater = #{param.updater} + + + AND a.deleted = #{param.deleted} + + + AND a.deleted = 0 + + + AND (a.comments LIKE CONCAT('%', #{param.keywords}, '%') + ) + + + + + + + + + + + diff --git a/src/main/java/com/gxwebsoft/shop/param/ShopGoodsProfitParam.java b/src/main/java/com/gxwebsoft/shop/param/ShopGoodsProfitParam.java new file mode 100644 index 0000000..1014418 --- /dev/null +++ b/src/main/java/com/gxwebsoft/shop/param/ShopGoodsProfitParam.java @@ -0,0 +1,61 @@ +package com.gxwebsoft.shop.param; + +import java.math.BigDecimal; +import com.gxwebsoft.common.core.annotation.QueryField; +import com.gxwebsoft.common.core.annotation.QueryType; +import com.gxwebsoft.common.core.web.BaseParam; +import com.fasterxml.jackson.annotation.JsonInclude; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * 商品分润设定查询参数 + * + * @author xm + * @since 2026-05-20 14:33:00 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@JsonInclude(JsonInclude.Include.NON_NULL) +@Schema(name = "ShopGoodsProfitParam对象", description = "商品分润设定查询参数") +public class ShopGoodsProfitParam extends BaseParam { + private static final long serialVersionUID = 1L; + + @Schema(description = "主键ID") + @QueryField(type = QueryType.EQ) + private Integer id; + + @Schema(description = "类型 1-股东分红 2-其他") + @QueryField(type = QueryType.EQ) + private Integer type; + + @Schema(description = "商品ID") + @QueryField(type = QueryType.EQ) + private Integer goodsId; + + @Schema(description = "用户ID") + @QueryField(type = QueryType.EQ) + private Integer userId; + + @Schema(description = "分佣比例 百分比") + @QueryField(type = QueryType.EQ) + private BigDecimal profit; + + @Schema(description = "开启状态 0-未开启 1-开启") + @QueryField(type = QueryType.EQ) + private Integer status; + + @Schema(description = "创建人") + @QueryField(type = QueryType.EQ) + private Integer creator; + + @Schema(description = "更新人") + @QueryField(type = QueryType.EQ) + private Integer updater; + + @Schema(description = "删除 0-未删 1-已删") + @QueryField(type = QueryType.EQ) + private Integer deleted; + +} diff --git a/src/main/java/com/gxwebsoft/shop/service/ShopGoodsProfitService.java b/src/main/java/com/gxwebsoft/shop/service/ShopGoodsProfitService.java new file mode 100644 index 0000000..aaa31bf --- /dev/null +++ b/src/main/java/com/gxwebsoft/shop/service/ShopGoodsProfitService.java @@ -0,0 +1,42 @@ +package com.gxwebsoft.shop.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.gxwebsoft.common.core.web.PageResult; +import com.gxwebsoft.shop.entity.ShopGoodsProfit; +import com.gxwebsoft.shop.param.ShopGoodsProfitParam; + +import java.util.List; + +/** + * 商品分润设定Service + * + * @author xm + * @since 2026-05-20 14:33:00 + */ +public interface ShopGoodsProfitService extends IService { + + /** + * 分页关联查询 + * + * @param param 查询参数 + * @return PageResult + */ + PageResult pageRel(ShopGoodsProfitParam param); + + /** + * 关联查询全部 + * + * @param param 查询参数 + * @return List + */ + List listRel(ShopGoodsProfitParam param); + + /** + * 根据id查询 + * + * @param id 主键ID + * @return ShopGoodsProfit + */ + ShopGoodsProfit getByIdRel(Integer id); + +} diff --git a/src/main/java/com/gxwebsoft/shop/service/impl/ShopGoodsProfitServiceImpl.java b/src/main/java/com/gxwebsoft/shop/service/impl/ShopGoodsProfitServiceImpl.java new file mode 100644 index 0000000..f860f18 --- /dev/null +++ b/src/main/java/com/gxwebsoft/shop/service/impl/ShopGoodsProfitServiceImpl.java @@ -0,0 +1,49 @@ +package com.gxwebsoft.shop.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.gxwebsoft.shop.mapper.ShopGoodsProfitMapper; +import com.gxwebsoft.shop.service.ShopGoodsProfitService; +import com.gxwebsoft.shop.entity.ShopGoodsProfit; +import com.gxwebsoft.shop.param.ShopGoodsProfitParam; +import com.gxwebsoft.common.core.web.PageParam; +import com.gxwebsoft.common.core.web.PageResult; +import lombok.AllArgsConstructor; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * 商品分润设定Service实现 + * + * @author xm + * @since 2026-05-20 14:33:00 + */ +@Service +@AllArgsConstructor +public class ShopGoodsProfitServiceImpl extends ServiceImpl implements ShopGoodsProfitService { + + @Override + public PageResult pageRel(ShopGoodsProfitParam param) { + PageParam page = new PageParam<>(param); + page.setDefaultOrder("sort_number asc, create_time desc"); + List list = baseMapper.selectPageRel(page, param); + return new PageResult<>(list, page.getTotal()); + } + + @Override + public List listRel(ShopGoodsProfitParam param) { + List list = baseMapper.selectListRel(param); + // 排序 + PageParam page = new PageParam<>(); + page.setDefaultOrder("sort_number asc, create_time desc"); + return page.sortRecords(list); + } + + @Override + public ShopGoodsProfit getByIdRel(Integer id) { + ShopGoodsProfitParam param = new ShopGoodsProfitParam(); + param.setId(id); + return param.getOne(baseMapper.selectListRel(param)); + } + +}