整理商品模块
This commit is contained in:
@@ -438,7 +438,6 @@ public class WebsiteController extends BaseController {
|
||||
return success("清除失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('cms:website:list')")
|
||||
@ApiOperation("分页查询网站信息记录表")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<Website>> page(WebsiteParam param) {
|
||||
|
||||
@@ -48,12 +48,21 @@ public class Website implements Serializable {
|
||||
@ApiModelProperty(value = "网站类型")
|
||||
private String websiteType;
|
||||
|
||||
@ApiModelProperty(value = "域名前缀")
|
||||
private String prefix;
|
||||
|
||||
@ApiModelProperty(value = "绑定域名")
|
||||
private String domain;
|
||||
|
||||
@ApiModelProperty(value = "后台管理地址")
|
||||
private String adminUrl;
|
||||
|
||||
@ApiModelProperty(value = "网站关键词")
|
||||
private String keywords;
|
||||
|
||||
@ApiModelProperty(value = "当前版本")
|
||||
private Integer version;
|
||||
|
||||
@ApiModelProperty(value = "服务到期时间")
|
||||
private Date expirationTime;
|
||||
|
||||
@@ -109,7 +118,7 @@ public class Website implements Serializable {
|
||||
private Integer recommend;
|
||||
|
||||
@ApiModelProperty(value = "状态")
|
||||
private Boolean status;
|
||||
private Integer status;
|
||||
|
||||
@ApiModelProperty(value = "排序号")
|
||||
private Integer sortNumber;
|
||||
|
||||
@@ -63,11 +63,11 @@ public class MybatisPlusConfig {
|
||||
"sys_tenant",
|
||||
"sys_dictionary",
|
||||
"sys_dictionary_data",
|
||||
"apps_test_data",
|
||||
"shop_users",
|
||||
"shop_order",
|
||||
"shop_order_info",
|
||||
"booking_user_invoice"
|
||||
"apps_test_data"
|
||||
// "shop_users",
|
||||
// "shop_order",
|
||||
// "shop_order_info",
|
||||
// "booking_user_invoice"
|
||||
).contains(tableName);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -2,7 +2,9 @@ package com.gxwebsoft.shop.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.oa.entity.App;
|
||||
import com.gxwebsoft.shop.entity.GoodsSku;
|
||||
import com.gxwebsoft.shop.entity.GoodsSpec;
|
||||
import com.gxwebsoft.shop.entity.SpecValue;
|
||||
@@ -25,7 +27,9 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@@ -45,6 +49,30 @@ public class GoodsController extends BaseController {
|
||||
@Resource
|
||||
private GoodsSkuService goodsSkuService;
|
||||
|
||||
@ApiOperation("统计信息")
|
||||
@GetMapping("/data")
|
||||
public ApiResult<Map<String, Integer>> data() {
|
||||
Map<String, Integer> data = new HashMap<>();
|
||||
Integer totalNum = goodsService.count(
|
||||
new LambdaQueryWrapper<Goods>().eq(Goods::getIsShow,1).gt(Goods::getStock,0)
|
||||
);
|
||||
Integer totalNum2 = goodsService.count(
|
||||
new LambdaQueryWrapper<Goods>().eq(Goods::getIsShow,0)
|
||||
);
|
||||
Integer totalNum3 = goodsService.count(
|
||||
new LambdaQueryWrapper<Goods>().eq(Goods::getStock,0)
|
||||
);
|
||||
|
||||
data.put("totalNum", totalNum);
|
||||
data.put("totalNum2", totalNum2);
|
||||
data.put("totalNum3", totalNum3);
|
||||
|
||||
// 下架已售罄的商品
|
||||
goodsService.update(new LambdaUpdateWrapper<Goods>().eq(Goods::getStock,0).eq(Goods::getIsShow,1).set(Goods::getIsShow,0));
|
||||
|
||||
return success(data);
|
||||
}
|
||||
|
||||
@ApiOperation("分页查询商品记录表")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<Goods>> page(GoodsParam param) {
|
||||
|
||||
@@ -1,59 +1,66 @@
|
||||
package com.gxwebsoft.shop.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.gxwebsoft.common.core.web.ApiResult;
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.common.core.web.BatchParam;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import com.gxwebsoft.shop.service.SpecService;
|
||||
import com.gxwebsoft.shop.entity.Spec;
|
||||
import com.gxwebsoft.shop.param.SpecParam;
|
||||
import com.gxwebsoft.shop.service.SpecService;
|
||||
import com.gxwebsoft.common.core.web.ApiResult;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import com.gxwebsoft.common.core.web.PageParam;
|
||||
import com.gxwebsoft.common.core.web.BatchParam;
|
||||
import com.gxwebsoft.common.core.annotation.OperationLog;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 商品规格控制器
|
||||
* 规格控制器
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2024-04-01 09:29:43
|
||||
* @since 2024-07-25 03:00:41
|
||||
*/
|
||||
@Api(tags = "商品规格管理")
|
||||
@Api(tags = "规格管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/shop/spec")
|
||||
public class SpecController extends BaseController {
|
||||
@Resource
|
||||
private SpecService specService;
|
||||
|
||||
@ApiOperation("分页查询商品规格")
|
||||
@ApiOperation("分页查询规格")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<Spec>> page(SpecParam param) {
|
||||
// 使用关联查询
|
||||
return success(specService.pageRel(param));
|
||||
}
|
||||
|
||||
@ApiOperation("查询全部商品规格")
|
||||
@ApiOperation("查询全部规格")
|
||||
@GetMapping()
|
||||
public ApiResult<List<Spec>> list(SpecParam param) {
|
||||
// 使用关联查询
|
||||
return success(specService.listRel(param));
|
||||
}
|
||||
|
||||
@ApiOperation("根据id查询商品规格")
|
||||
@PreAuthorize("hasAuthority('shop:spec:list')")
|
||||
@ApiOperation("根据id查询规格")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<Spec> get(@PathVariable("id") Integer id) {
|
||||
// 使用关联查询
|
||||
return success(specService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@ApiOperation("添加商品规格")
|
||||
@PreAuthorize("hasAuthority('shop:spec:save')")
|
||||
@ApiOperation("添加规格")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody Spec spec) {
|
||||
if (specService.count(new LambdaQueryWrapper<Spec>().eq(Spec::getSpecName,spec.getSpecName())) > 0) {
|
||||
return fail("规格名称已存在");
|
||||
// 记录当前登录用户id
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser != null) {
|
||||
spec.setUserId(loginUser.getUserId());
|
||||
}
|
||||
if (specService.save(spec)) {
|
||||
return success("添加成功");
|
||||
@@ -61,7 +68,8 @@ public class SpecController extends BaseController {
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@ApiOperation("修改商品规格")
|
||||
@PreAuthorize("hasAuthority('shop:spec:update')")
|
||||
@ApiOperation("修改规格")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody Spec spec) {
|
||||
if (specService.updateById(spec)) {
|
||||
@@ -70,7 +78,8 @@ public class SpecController extends BaseController {
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@ApiOperation("删除商品规格")
|
||||
@PreAuthorize("hasAuthority('shop:spec:remove')")
|
||||
@ApiOperation("删除规格")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (specService.removeById(id)) {
|
||||
@@ -79,7 +88,8 @@ public class SpecController extends BaseController {
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量添加商品规格")
|
||||
@PreAuthorize("hasAuthority('shop:spec:save')")
|
||||
@ApiOperation("批量添加规格")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<Spec> list) {
|
||||
if (specService.saveBatch(list)) {
|
||||
@@ -88,7 +98,9 @@ public class SpecController extends BaseController {
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量修改商品规格")
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:spec:update')")
|
||||
@ApiOperation("批量修改规格")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<Spec> batchParam) {
|
||||
if (batchParam.update(specService, "spec_id")) {
|
||||
@@ -96,8 +108,8 @@ public class SpecController extends BaseController {
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量删除商品规格")
|
||||
@PreAuthorize("hasAuthority('shop:spec:remove')")
|
||||
@ApiOperation("批量删除规格")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (specService.removeByIds(ids)) {
|
||||
|
||||
@@ -85,7 +85,10 @@ public class Goods implements Serializable {
|
||||
@ApiModelProperty(value = "推荐")
|
||||
private Integer recommend;
|
||||
|
||||
@ApiModelProperty(value = "状态, 0正常, 1待修,2异常已修,3异常未修")
|
||||
@ApiModelProperty(value = "1上架 0下架")
|
||||
private Integer isShow;
|
||||
|
||||
@ApiModelProperty(value = "状态, 0上架 1下架 2待审核 3审核不通过")
|
||||
private Integer status;
|
||||
|
||||
@ApiModelProperty(value = "备注")
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
package com.gxwebsoft.shop.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import java.time.LocalDateTime;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
@@ -15,39 +13,47 @@ import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 商品规格组记录表
|
||||
* 规格
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2024-04-01 09:29:43
|
||||
* @since 2024-07-25 03:00:41
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@ApiModel(value = "Spec对象", description = "商品规格组记录表")
|
||||
@ApiModel(value = "Spec对象", description = "规格")
|
||||
@TableName("shop_spec")
|
||||
public class Spec implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty(value = "规格组ID")
|
||||
@ApiModelProperty(value = "规格ID")
|
||||
@TableId(value = "spec_id", type = IdType.AUTO)
|
||||
private Integer specId;
|
||||
|
||||
@ApiModelProperty(value = "规格组名称")
|
||||
@ApiModelProperty(value = "规格名称")
|
||||
private String specName;
|
||||
|
||||
@ApiModelProperty(value = "规格值")
|
||||
private String specValue;
|
||||
|
||||
@ApiModelProperty(value = "创建用户")
|
||||
private Integer userId;
|
||||
|
||||
@ApiModelProperty(value = "更新者")
|
||||
private Integer updater;
|
||||
|
||||
@ApiModelProperty(value = "备注")
|
||||
private String comments;
|
||||
|
||||
@ApiModelProperty(value = "状态, 0正常, 1待修,2异常已修,3异常未修")
|
||||
private Integer status;
|
||||
|
||||
@ApiModelProperty(value = "排序号")
|
||||
private Integer sortNumber;
|
||||
|
||||
@ApiModelProperty(value = "状态, 0正常, 1禁用")
|
||||
private Integer status;
|
||||
|
||||
@ApiModelProperty(value = "租户id")
|
||||
private Integer tenantId;
|
||||
|
||||
@ApiModelProperty(value = "规则值列表")
|
||||
@TableField(exist = false)
|
||||
private List<SpecValue> specValues;
|
||||
@ApiModelProperty(value = "创建时间")
|
||||
private Date createTime;
|
||||
|
||||
}
|
||||
|
||||
@@ -9,10 +9,10 @@ import org.apache.ibatis.annotations.Param;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 商品规格组记录表Mapper
|
||||
* 规格Mapper
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2024-04-01 09:29:43
|
||||
* @since 2024-07-25 03:00:41
|
||||
*/
|
||||
public interface SpecMapper extends BaseMapper<Spec> {
|
||||
|
||||
|
||||
@@ -2,95 +2,103 @@
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.gxwebsoft.shop.mapper.GoodsMapper">
|
||||
|
||||
<!-- 关联查询sql -->
|
||||
<sql id="selectSql">
|
||||
SELECT a.*
|
||||
FROM shop_goods a
|
||||
<where>
|
||||
<if test="param.goodsId != null">
|
||||
AND a.goods_id = #{param.goodsId}
|
||||
</if>
|
||||
<if test="param.type != null">
|
||||
AND a.type = #{param.type}
|
||||
</if>
|
||||
<if test="param.code != null">
|
||||
AND a.code LIKE CONCAT('%', #{param.code}, '%')
|
||||
</if>
|
||||
<if test="param.goodsName != null">
|
||||
AND a.goods_name LIKE CONCAT('%', #{param.goodsName}, '%')
|
||||
</if>
|
||||
<if test="param.content != null">
|
||||
AND a.content LIKE CONCAT('%', #{param.content}, '%')
|
||||
</if>
|
||||
<if test="param.categoryId != null">
|
||||
AND a.category_id = #{param.categoryId}
|
||||
</if>
|
||||
<if test="param.parentId != null">
|
||||
AND a.category_id IN (SELECT category_id FROM shop_goods_category WHERE parent_id=#{param.parentId})
|
||||
</if>
|
||||
<if test="param.categoryParent != null">
|
||||
AND a.category_parent LIKE CONCAT('%', #{param.categoryParent}, '%')
|
||||
</if>
|
||||
<if test="param.categoryChildren != null">
|
||||
AND a.category_children LIKE CONCAT('%', #{param.categoryChildren}, '%')
|
||||
</if>
|
||||
<if test="param.specs != null">
|
||||
AND a.specs LIKE CONCAT('%', #{param.specs}, '%')
|
||||
</if>
|
||||
<if test="param.position != null">
|
||||
AND a.position LIKE CONCAT('%', #{param.position}, '%')
|
||||
</if>
|
||||
<if test="param.price != null">
|
||||
AND a.price = #{param.price}
|
||||
</if>
|
||||
<if test="param.salePrice != null">
|
||||
AND a.sale_price = #{param.salePrice}
|
||||
</if>
|
||||
<if test="param.recommend != null">
|
||||
AND a.recommend = #{param.recommend}
|
||||
</if>
|
||||
<if test="param.status != null">
|
||||
AND a.status = #{param.status}
|
||||
</if>
|
||||
<if test="param.comments != null">
|
||||
AND a.comments LIKE CONCAT('%', #{param.comments}, '%')
|
||||
</if>
|
||||
<if test="param.sortNumber != null">
|
||||
AND a.sort_number = #{param.sortNumber}
|
||||
</if>
|
||||
<if test="param.userId != null">
|
||||
AND a.user_id = #{param.userId}
|
||||
</if>
|
||||
<if test="param.merchantId != null">
|
||||
AND a.merchant_id = #{param.merchantId}
|
||||
</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.createTimeStart != null">
|
||||
AND a.create_time >= #{param.createTimeStart}
|
||||
</if>
|
||||
<if test="param.createTimeEnd != null">
|
||||
AND a.create_time <= #{param.createTimeEnd}
|
||||
</if>
|
||||
<if test="param.keywords != null">
|
||||
AND (a.comments LIKE CONCAT('%', #{param.keywords}, '%')
|
||||
)
|
||||
</if>
|
||||
</where>
|
||||
</sql>
|
||||
<!-- 关联查询sql -->
|
||||
<sql id="selectSql">
|
||||
SELECT a.*
|
||||
FROM shop_goods a
|
||||
<where>
|
||||
<if test="param.goodsId != null">
|
||||
AND a.goods_id = #{param.goodsId}
|
||||
</if>
|
||||
<if test="param.type != null">
|
||||
AND a.type = #{param.type}
|
||||
</if>
|
||||
<if test="param.code != null">
|
||||
AND a.code LIKE CONCAT('%', #{param.code}, '%')
|
||||
</if>
|
||||
<if test="param.goodsName != null">
|
||||
AND a.goods_name LIKE CONCAT('%', #{param.goodsName}, '%')
|
||||
</if>
|
||||
<if test="param.content != null">
|
||||
AND a.content LIKE CONCAT('%', #{param.content}, '%')
|
||||
</if>
|
||||
<if test="param.categoryId != null">
|
||||
AND a.category_id = #{param.categoryId}
|
||||
</if>
|
||||
<if test="param.parentId != null">
|
||||
AND a.category_id IN (SELECT category_id FROM shop_goods_category WHERE parent_id=#{param.parentId})
|
||||
</if>
|
||||
<if test="param.categoryParent != null">
|
||||
AND a.category_parent LIKE CONCAT('%', #{param.categoryParent}, '%')
|
||||
</if>
|
||||
<if test="param.categoryChildren != null">
|
||||
AND a.category_children LIKE CONCAT('%', #{param.categoryChildren}, '%')
|
||||
</if>
|
||||
<if test="param.specs != null">
|
||||
AND a.specs LIKE CONCAT('%', #{param.specs}, '%')
|
||||
</if>
|
||||
<if test="param.position != null">
|
||||
AND a.position LIKE CONCAT('%', #{param.position}, '%')
|
||||
</if>
|
||||
<if test="param.price != null">
|
||||
AND a.price = #{param.price}
|
||||
</if>
|
||||
<if test="param.salePrice != null">
|
||||
AND a.sale_price = #{param.salePrice}
|
||||
</if>
|
||||
<if test="param.recommend != null">
|
||||
AND a.recommend = #{param.recommend}
|
||||
</if>
|
||||
<if test="param.isShow != null">
|
||||
AND a.is_show = #{param.isShow}
|
||||
</if>
|
||||
<if test="param.status != null">
|
||||
AND a.status = #{param.status}
|
||||
</if>
|
||||
<if test="param.stock != null">
|
||||
AND a.stock = #{param.stock}
|
||||
</if>
|
||||
<if test="param.comments != null">
|
||||
AND a.comments LIKE CONCAT('%', #{param.comments}, '%')
|
||||
</if>
|
||||
<if test="param.sortNumber != null">
|
||||
AND a.sort_number = #{param.sortNumber}
|
||||
</if>
|
||||
<if test="param.userId != null">
|
||||
AND a.user_id = #{param.userId}
|
||||
</if>
|
||||
<if test="param.merchantId != null">
|
||||
AND a.merchant_id = #{param.merchantId}
|
||||
</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.createTimeStart != null">
|
||||
AND a.create_time >= #{param.createTimeStart}
|
||||
</if>
|
||||
<if test="param.createTimeEnd != null">
|
||||
AND a.create_time <= #{param.createTimeEnd}
|
||||
</if>
|
||||
<if test="param.keywords != null">
|
||||
AND (a.comments LIKE CONCAT('%', #{param.keywords}, '%')
|
||||
OR a.goods_name = #{param.keywords}
|
||||
OR a.code = #{param.keywords}
|
||||
)
|
||||
</if>
|
||||
</where>
|
||||
</sql>
|
||||
|
||||
<!-- 分页查询 -->
|
||||
<select id="selectPageRel" resultType="com.gxwebsoft.shop.entity.Goods">
|
||||
<include refid="selectSql"></include>
|
||||
</select>
|
||||
<!-- 分页查询 -->
|
||||
<select id="selectPageRel" resultType="com.gxwebsoft.shop.entity.Goods">
|
||||
<include refid="selectSql"></include>
|
||||
</select>
|
||||
|
||||
<!-- 查询全部 -->
|
||||
<select id="selectListRel" resultType="com.gxwebsoft.shop.entity.Goods">
|
||||
<include refid="selectSql"></include>
|
||||
</select>
|
||||
<!-- 查询全部 -->
|
||||
<select id="selectListRel" resultType="com.gxwebsoft.shop.entity.Goods">
|
||||
<include refid="selectSql"></include>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
||||
@@ -40,6 +40,8 @@
|
||||
</if>
|
||||
<if test="param.keywords != null">
|
||||
AND (a.comments LIKE CONCAT('%', #{param.keywords}, '%')
|
||||
OR a.phone = #{param.keywords}
|
||||
OR a.real_name = #{param.keywords}
|
||||
)
|
||||
</if>
|
||||
</where>
|
||||
|
||||
@@ -10,8 +10,26 @@
|
||||
<if test="param.specId != null">
|
||||
AND a.spec_id = #{param.specId}
|
||||
</if>
|
||||
<if test="param.name != null">
|
||||
AND a.name LIKE CONCAT('%', #{param.name}, '%')
|
||||
<if test="param.specName != null">
|
||||
AND a.spec_name LIKE CONCAT('%', #{param.specName}, '%')
|
||||
</if>
|
||||
<if test="param.specValue != null">
|
||||
AND a.spec_value LIKE CONCAT('%', #{param.specValue}, '%')
|
||||
</if>
|
||||
<if test="param.userId != null">
|
||||
AND a.user_id = #{param.userId}
|
||||
</if>
|
||||
<if test="param.updater != null">
|
||||
AND a.updater = #{param.updater}
|
||||
</if>
|
||||
<if test="param.comments != null">
|
||||
AND a.comments LIKE CONCAT('%', #{param.comments}, '%')
|
||||
</if>
|
||||
<if test="param.status != null">
|
||||
AND a.status = #{param.status}
|
||||
</if>
|
||||
<if test="param.sortNumber != null">
|
||||
AND a.sort_number = #{param.sortNumber}
|
||||
</if>
|
||||
<if test="param.createTimeStart != null">
|
||||
AND a.create_time >= #{param.createTimeStart}
|
||||
@@ -19,6 +37,10 @@
|
||||
<if test="param.createTimeEnd != null">
|
||||
AND a.create_time <= #{param.createTimeEnd}
|
||||
</if>
|
||||
<if test="param.keywords != null">
|
||||
AND (a.comments LIKE CONCAT('%', #{param.keywords}, '%')
|
||||
)
|
||||
</if>
|
||||
</where>
|
||||
</sql>
|
||||
|
||||
|
||||
@@ -70,10 +70,18 @@ public class GoodsParam extends BaseParam {
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer recommend;
|
||||
|
||||
@ApiModelProperty(value = "状态, 0正常, 1待修,2异常已修,3异常未修")
|
||||
@ApiModelProperty(value = "1上架 0下架")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer isShow;
|
||||
|
||||
@ApiModelProperty(value = "状态, 0上架 1下架 2待审核 3审核不通过")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer status;
|
||||
|
||||
@ApiModelProperty(value = "库存")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer stock;
|
||||
|
||||
@ApiModelProperty(value = "备注")
|
||||
private String comments;
|
||||
|
||||
|
||||
@@ -11,23 +11,45 @@ import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 商品规格组记录表查询参数
|
||||
* 规格查询参数
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2024-04-01 09:29:43
|
||||
* @since 2024-07-25 03:00:41
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
@ApiModel(value = "SpecParam对象", description = "商品规格组记录表查询参数")
|
||||
@ApiModel(value = "SpecParam对象", description = "规格查询参数")
|
||||
public class SpecParam extends BaseParam {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty(value = "规格组ID")
|
||||
@ApiModelProperty(value = "规格ID")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer specId;
|
||||
|
||||
@ApiModelProperty(value = "规格组名称")
|
||||
private String name;
|
||||
@ApiModelProperty(value = "规格名称")
|
||||
private String specName;
|
||||
|
||||
@ApiModelProperty(value = "规格值")
|
||||
private String specValue;
|
||||
|
||||
@ApiModelProperty(value = "创建用户")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer userId;
|
||||
|
||||
@ApiModelProperty(value = "更新者")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer updater;
|
||||
|
||||
@ApiModelProperty(value = "备注")
|
||||
private String comments;
|
||||
|
||||
@ApiModelProperty(value = "状态, 0正常, 1待修,2异常已修,3异常未修")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer status;
|
||||
|
||||
@ApiModelProperty(value = "排序号")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer sortNumber;
|
||||
|
||||
}
|
||||
|
||||
@@ -8,10 +8,10 @@ import com.gxwebsoft.shop.param.SpecParam;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 商品规格组记录表Service
|
||||
* 规格Service
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2024-04-01 09:29:43
|
||||
* @since 2024-07-25 03:00:41
|
||||
*/
|
||||
public interface SpecService extends IService<Spec> {
|
||||
|
||||
@@ -34,7 +34,7 @@ public interface SpecService extends IService<Spec> {
|
||||
/**
|
||||
* 根据id查询
|
||||
*
|
||||
* @param specId 规格组ID
|
||||
* @param specId 规格ID
|
||||
* @return Spec
|
||||
*/
|
||||
Spec getByIdRel(Integer specId);
|
||||
|
||||
@@ -16,6 +16,7 @@ import com.gxwebsoft.shop.service.GoodsSpecService;
|
||||
import org.apache.tomcat.util.buf.StringUtils;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
@@ -62,18 +63,22 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
|
||||
public void saveBatchByAsync(Goods goods) {
|
||||
// 保存商品规格
|
||||
final List<GoodsSpec> goodsSpecs = goods.getGoodsSpecs();
|
||||
goodsSpecs.forEach(d -> {
|
||||
d.setGoodsId(goods.getGoodsId());
|
||||
final List<String> collect = d.getValueList().stream().map(SpecValue::getSpecValue).collect(Collectors.toList());
|
||||
d.setSpecValues(StringUtils.join(collect, ','));
|
||||
});
|
||||
goodsSpecService.saveBatch(goodsSpecs);
|
||||
if (!CollectionUtils.isEmpty(goodsSpecs)) {
|
||||
goodsSpecs.forEach(d -> {
|
||||
d.setGoodsId(goods.getGoodsId());
|
||||
final List<String> collect = d.getValueList().stream().map(SpecValue::getSpecValue).collect(Collectors.toList());
|
||||
d.setSpecValues(StringUtils.join(collect, ','));
|
||||
});
|
||||
goodsSpecService.saveBatch(goodsSpecs);
|
||||
}
|
||||
// 保存商品sku表
|
||||
final List<GoodsSku> goodsSkus = goods.getGoodsSkus();
|
||||
goodsSkus.forEach(d -> {
|
||||
d.setGoodsId(goods.getGoodsId());
|
||||
});
|
||||
goodsSkuService.saveBatch(goodsSkus);
|
||||
if (!CollectionUtils.isEmpty(goodsSkus)) {
|
||||
goodsSkus.forEach(d -> {
|
||||
d.setGoodsId(goods.getGoodsId());
|
||||
});
|
||||
goodsSkuService.saveBatch(goodsSkus);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,40 +1,30 @@
|
||||
package com.gxwebsoft.shop.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.gxwebsoft.shop.entity.SpecValue;
|
||||
import com.gxwebsoft.shop.mapper.SpecMapper;
|
||||
import com.gxwebsoft.shop.param.SpecValueParam;
|
||||
import com.gxwebsoft.shop.service.SpecService;
|
||||
import com.gxwebsoft.shop.entity.Spec;
|
||||
import com.gxwebsoft.shop.param.SpecParam;
|
||||
import com.gxwebsoft.common.core.web.PageParam;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import com.gxwebsoft.shop.service.SpecValueService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 商品规格组记录表Service实现
|
||||
* 规格Service实现
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2024-04-01 09:29:43
|
||||
* @since 2024-07-25 03:00:41
|
||||
*/
|
||||
@Service
|
||||
public class SpecServiceImpl extends ServiceImpl<SpecMapper, Spec> implements SpecService {
|
||||
@Resource
|
||||
private SpecValueService specValueService;
|
||||
|
||||
@Override
|
||||
public PageResult<Spec> pageRel(SpecParam param) {
|
||||
PageParam<Spec, SpecParam> page = new PageParam<>(param);
|
||||
page.setDefaultOrder("sort_number asc");
|
||||
page.setDefaultOrder("sort_number asc, create_time desc");
|
||||
List<Spec> list = baseMapper.selectPageRel(page, param);
|
||||
list.forEach(item -> {
|
||||
item.setSpecValues(specValueService.list(new LambdaQueryWrapper<SpecValue>().eq(SpecValue::getSpecId,item.getSpecId())));
|
||||
});
|
||||
return new PageResult<>(list, page.getTotal());
|
||||
}
|
||||
|
||||
@@ -43,10 +33,7 @@ public class SpecServiceImpl extends ServiceImpl<SpecMapper, Spec> implements Sp
|
||||
List<Spec> list = baseMapper.selectListRel(param);
|
||||
// 排序
|
||||
PageParam<Spec, SpecParam> page = new PageParam<>();
|
||||
page.setDefaultOrder("sort_number asc");
|
||||
list.forEach(item -> {
|
||||
item.setSpecValues(specValueService.list(new LambdaQueryWrapper<SpecValue>().eq(SpecValue::getSpecId,item.getSpecId())));
|
||||
});
|
||||
page.setDefaultOrder("sort_number asc, create_time desc");
|
||||
return page.sortRecords(list);
|
||||
}
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ public class OrderInfoTask extends BaseController {
|
||||
final int minute = DateUtil.minute(DateUtil.date());
|
||||
final int second = DateUtil.second(DateUtil.date());
|
||||
final String startTime = String.format("%02d", hour).concat(":").concat(String.format("%02d", minute)).concat(":").concat(String.format("%02d", second));
|
||||
final List<OrderInfo> list = orderInfoService.list(new LambdaQueryWrapper<OrderInfo>().eq(OrderInfo::getOrderStatus, 0).ne(OrderInfo::getMerchantId,3028).eq(OrderInfo::getDateTime,DateUtil.today()).lt(OrderInfo::getStartTime,startTime));
|
||||
final List<OrderInfo> list = orderInfoService.list(new LambdaQueryWrapper<OrderInfo>().eq(OrderInfo::getTenantId,10150).eq(OrderInfo::getOrderStatus, 0).ne(OrderInfo::getMerchantId,3028).eq(OrderInfo::getDateTime,DateUtil.today()).lt(OrderInfo::getStartTime,startTime));
|
||||
list.forEach(d -> {
|
||||
d.setOrderStatus(1);
|
||||
order.setOrderId(d.getOrderId());
|
||||
@@ -61,7 +61,7 @@ public class OrderInfoTask extends BaseController {
|
||||
@Transactional(rollbackFor = {Exception.class})
|
||||
public void settledExpirationOrderBy3028() {
|
||||
final Order order = new Order();
|
||||
final List<OrderInfo> list = orderInfoService.list(new LambdaQueryWrapper<OrderInfo>().eq(OrderInfo::getOrderStatus, 0).eq(OrderInfo::getMerchantId,3028).eq(OrderInfo::getDateTime,DateUtil.today()).lt(OrderInfo::getStartTime,"21:30:00"));
|
||||
final List<OrderInfo> list = orderInfoService.list(new LambdaQueryWrapper<OrderInfo>().eq(OrderInfo::getTenantId,10150).eq(OrderInfo::getOrderStatus, 0).eq(OrderInfo::getMerchantId,3028).eq(OrderInfo::getDateTime,DateUtil.today()).lt(OrderInfo::getStartTime,"21:30:00"));
|
||||
list.forEach(d -> {
|
||||
d.setOrderStatus(1);
|
||||
order.setOrderId(d.getOrderId());
|
||||
|
||||
Reference in New Issue
Block a user