增加商品分润基础业务功能
This commit is contained in:
@@ -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<PageResult<ShopGoodsProfit>> page(ShopGoodsProfitParam param) {
|
||||||
|
// 使用关联查询
|
||||||
|
return success(shopGoodsProfitService.pageRel(param));
|
||||||
|
}
|
||||||
|
|
||||||
|
// @PreAuthorize("hasAuthority('shop:shopGoodsProfit:list')")
|
||||||
|
@Operation(summary = "查询全部商品分润设定")
|
||||||
|
@GetMapping()
|
||||||
|
public ApiResult<List<ShopGoodsProfit>> list(ShopGoodsProfitParam param) {
|
||||||
|
// 使用关联查询
|
||||||
|
return success(shopGoodsProfitService.listRel(param));
|
||||||
|
}
|
||||||
|
|
||||||
|
// @PreAuthorize("hasAuthority('shop:shopGoodsProfit:list')")
|
||||||
|
@Operation(summary = "根据id查询商品分润设定")
|
||||||
|
@GetMapping("/{id}")
|
||||||
|
public ApiResult<ShopGoodsProfit> 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("删除失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
65
src/main/java/com/gxwebsoft/shop/entity/ShopGoodsProfit.java
Normal file
65
src/main/java/com/gxwebsoft/shop/entity/ShopGoodsProfit.java
Normal file
@@ -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;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -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<ShopGoodsProfit> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页查询
|
||||||
|
*
|
||||||
|
* @param page 分页对象
|
||||||
|
* @param param 查询参数
|
||||||
|
* @return List<ShopGoodsProfit>
|
||||||
|
*/
|
||||||
|
List<ShopGoodsProfit> selectPageRel(@Param("page") IPage<ShopGoodsProfit> page,
|
||||||
|
@Param("param") ShopGoodsProfitParam param);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询全部
|
||||||
|
*
|
||||||
|
* @param param 查询参数
|
||||||
|
* @return List<User>
|
||||||
|
*/
|
||||||
|
List<ShopGoodsProfit> selectListRel(@Param("param") ShopGoodsProfitParam param);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,63 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.gxwebsoft.shop.mapper.ShopGoodsProfitMapper">
|
||||||
|
|
||||||
|
<!-- 关联查询sql -->
|
||||||
|
<sql id="selectSql">
|
||||||
|
SELECT a.*
|
||||||
|
FROM shop_goods_profit a
|
||||||
|
<where>
|
||||||
|
<if test="param.id != null">
|
||||||
|
AND a.id = #{param.id}
|
||||||
|
</if>
|
||||||
|
<if test="param.type != null">
|
||||||
|
AND a.type = #{param.type}
|
||||||
|
</if>
|
||||||
|
<if test="param.goodsId != null">
|
||||||
|
AND a.goods_id = #{param.goodsId}
|
||||||
|
</if>
|
||||||
|
<if test="param.userId != null">
|
||||||
|
AND a.user_id = #{param.userId}
|
||||||
|
</if>
|
||||||
|
<if test="param.profit != null">
|
||||||
|
AND a.profit = #{param.profit}
|
||||||
|
</if>
|
||||||
|
<if test="param.status != null">
|
||||||
|
AND a.status = #{param.status}
|
||||||
|
</if>
|
||||||
|
<if test="param.creator != null">
|
||||||
|
AND a.creator = #{param.creator}
|
||||||
|
</if>
|
||||||
|
<if test="param.createTimeStart != null">
|
||||||
|
AND a.create_time >= #{param.createTimeStart}
|
||||||
|
</if>
|
||||||
|
<if test="param.createTimeEnd != null">
|
||||||
|
AND a.create_time <= #{param.createTimeEnd}
|
||||||
|
</if>
|
||||||
|
<if test="param.updater != null">
|
||||||
|
AND a.updater = #{param.updater}
|
||||||
|
</if>
|
||||||
|
<if test="param.deleted != null">
|
||||||
|
AND a.deleted = #{param.deleted}
|
||||||
|
</if>
|
||||||
|
<if test="param.deleted == null">
|
||||||
|
AND a.deleted = 0
|
||||||
|
</if>
|
||||||
|
<if test="param.keywords != null">
|
||||||
|
AND (a.comments LIKE CONCAT('%', #{param.keywords}, '%')
|
||||||
|
)
|
||||||
|
</if>
|
||||||
|
</where>
|
||||||
|
</sql>
|
||||||
|
|
||||||
|
<!-- 分页查询 -->
|
||||||
|
<select id="selectPageRel" resultType="com.gxwebsoft.shop.entity.ShopGoodsProfit">
|
||||||
|
<include refid="selectSql"></include>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<!-- 查询全部 -->
|
||||||
|
<select id="selectListRel" resultType="com.gxwebsoft.shop.entity.ShopGoodsProfit">
|
||||||
|
<include refid="selectSql"></include>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
</mapper>
|
||||||
@@ -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;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -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<ShopGoodsProfit> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页关联查询
|
||||||
|
*
|
||||||
|
* @param param 查询参数
|
||||||
|
* @return PageResult<ShopGoodsProfit>
|
||||||
|
*/
|
||||||
|
PageResult<ShopGoodsProfit> pageRel(ShopGoodsProfitParam param);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 关联查询全部
|
||||||
|
*
|
||||||
|
* @param param 查询参数
|
||||||
|
* @return List<ShopGoodsProfit>
|
||||||
|
*/
|
||||||
|
List<ShopGoodsProfit> listRel(ShopGoodsProfitParam param);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据id查询
|
||||||
|
*
|
||||||
|
* @param id 主键ID
|
||||||
|
* @return ShopGoodsProfit
|
||||||
|
*/
|
||||||
|
ShopGoodsProfit getByIdRel(Integer id);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -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<ShopGoodsProfitMapper, ShopGoodsProfit> implements ShopGoodsProfitService {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PageResult<ShopGoodsProfit> pageRel(ShopGoodsProfitParam param) {
|
||||||
|
PageParam<ShopGoodsProfit, ShopGoodsProfitParam> page = new PageParam<>(param);
|
||||||
|
page.setDefaultOrder("sort_number asc, create_time desc");
|
||||||
|
List<ShopGoodsProfit> list = baseMapper.selectPageRel(page, param);
|
||||||
|
return new PageResult<>(list, page.getTotal());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<ShopGoodsProfit> listRel(ShopGoodsProfitParam param) {
|
||||||
|
List<ShopGoodsProfit> list = baseMapper.selectListRel(param);
|
||||||
|
// 排序
|
||||||
|
PageParam<ShopGoodsProfit, ShopGoodsProfitParam> 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));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user