商品校验调整

This commit is contained in:
wangw 2024-11-19 16:37:03 +08:00
parent 2fce514c38
commit 51c160aa26
3 changed files with 145 additions and 91 deletions

View File

@ -1,13 +1,20 @@
package com.chaozhanggui.system.cashierservice.entity;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalTime;
import java.io.Serializable;
import java.util.List;
/**
* (TbProduct)实体类
*
* @author ww
* @since 2024-11-19 15:23:12
*/
@Data
public class TbProduct implements Serializable {
private static final long serialVersionUID = 371589032559725924L;
/**
* id
*/
@ -20,10 +27,6 @@ public class TbProduct implements Serializable {
* 商品规格
*/
private Integer specId;
/**
* 商户Id
*/
private String merchantId;
private String shopId;
/**
@ -35,9 +38,14 @@ public class TbProduct implements Serializable {
*/
private String shortTitle;
/**
* 商品类型属性:普通商品 normal 套餐商品 package 称重商品 weigh 团购券商品 coupon
* 普通商品 normal 套餐商品 package 称重商品 weigh 团购券 coupon
*/
private String type;
/**
* 计量商品 normal
* 多规格商品 sku
*/
private String typeEnum;
/**
* 包装费
*/
@ -47,12 +55,10 @@ public class TbProduct implements Serializable {
*/
private BigDecimal lowPrice;
private BigDecimal lowMemberPrice;
/**
* 单位Id
*/
private Integer unitId;
private String unitSnap;
/**
* 商品封面图
*/
@ -69,22 +75,10 @@ public class TbProduct implements Serializable {
* 0--待审核 1审核通过 -1审核失败 -2违规下架
*/
private Integer status;
/**
* 审核失败原因
*/
private String failMsg;
/**
* 是否热销
*/
private Integer isHot;
/**
* 计量商品 normal
* 称重商品 weight
* 多规格商品 sku
* 套餐商品 group
* 时价商品 currentPrice
*/
private String typeEnum;
/**
* 是否回收站 0-1回收站
*/
@ -101,6 +95,10 @@ public class TbProduct implements Serializable {
private Long createdAt;
private Long updatedAt;
/**
* 0 固定套餐 1可选套餐
*/
private Integer groupType;
/**
* 套餐内容
*/
@ -141,6 +139,42 @@ public class TbProduct implements Serializable {
* 库存警戒线
*/
private Integer warnLine;
/**
* 堂食 table 自取 dine 配送 delivery 快递 express
*/
private String showType;
/**
* 称重 价格/千克
*/
private BigDecimal weight;
/**
* 是否允许临时改价
*/
private Integer isTempPrice;
/**
* 日销售上限
*/
private Integer dayLimit;
/**
* 每单销售上限
*/
private Integer singleOrderLimit;
/**
* 每人销售上限
*/
private Integer singlePeopleLimit;
/**
* 数组 周一,周二,周日
*/
private String days;
/**
* 可用开始时间
*/
private LocalTime startTime;
/**
* 可用结束时间
*/
private LocalTime endTime;
private int orderCount;
@ -152,6 +186,4 @@ public class TbProduct implements Serializable {
private List<?> skuList;
private static final long serialVersionUID = 1L;
}

View File

@ -70,33 +70,33 @@ public class ProductService {
}
public Result queryCommodityInfo(String shopId, String categoryId, String commdityName, Integer page, Integer pageSize, String masterId){
List<TbProduct> TbProduct=null;
if(ObjectUtil.isEmpty(categoryId)){
TbProduct=tbProductMapper.selectByShopId(shopId,commdityName);
}else {
TbProduct=tbProductMapper.selectByShopIdAndShopType(shopId,categoryId,commdityName);
public Result queryCommodityInfo(String shopId, String categoryId, String commdityName, Integer page, Integer pageSize, String masterId) {
List<TbProduct> tbProducts = null;
if (ObjectUtil.isEmpty(categoryId)) {
tbProducts = tbProductMapper.selectByShopId(shopId, commdityName);
} else {
tbProducts = tbProductMapper.selectByShopIdAndShopType(shopId, categoryId, commdityName);
}
String day = DateUtils.getDay();
if(ObjectUtil.isNotEmpty(TbProduct)){
TbProduct.parallelStream().forEach(it->{
Integer orderCount=tbProductMapper.countOrderByshopIdAndProductId(it.getShopId(),it.getId().toString(),masterId,day, "");
it.setOrderCount((ObjectUtil.isNull(orderCount)||ObjectUtil.isEmpty(orderCount))?0:orderCount);
TbProductSpec tbProductSpec= tbProductSpecMapper.selectByPrimaryKey(it.getSpecId());
if(ObjectUtil.isEmpty(tbProductSpec)){
tbProductSpec=new TbProductSpec();
if (ObjectUtil.isNotEmpty(tbProducts)) {
tbProducts.parallelStream().forEach(it -> {
Integer orderCount = tbProductMapper.countOrderByshopIdAndProductId(it.getShopId(), it.getId().toString(), masterId, day, "");
it.setOrderCount((ObjectUtil.isNull(orderCount) || ObjectUtil.isEmpty(orderCount)) ? 0 : orderCount);
TbProductSpec tbProductSpec = tbProductSpecMapper.selectByPrimaryKey(it.getSpecId());
if (ObjectUtil.isEmpty(tbProductSpec)) {
tbProductSpec = new TbProductSpec();
}
it.setTbProductSpec(tbProductSpec);
TbProductSkuResult skuResult=tbProductSkuResultMapper.selectByPrimaryKey(it.getId());
if(ObjectUtil.isEmpty(skuResult)){
skuResult=new TbProductSkuResult();
TbProductSkuResult skuResult = tbProductSkuResultMapper.selectByPrimaryKey(it.getId());
if (ObjectUtil.isEmpty(skuResult)) {
skuResult = new TbProductSkuResult();
}
it.setProductSkuResult(skuResult);
});
}
return Result.success(CodeEnum.SUCCESS,TbProduct);
return Result.success(CodeEnum.SUCCESS, tbProducts);
}

View File

@ -1,24 +1,22 @@
<?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.chaozhanggui.system.cashierservice.dao.TbProductMapper">
<resultMap type="com.chaozhanggui.system.cashierservice.entity.TbProduct" id="BaseResultMap">
<result property="id" column="id" jdbcType="INTEGER"/>
<result property="categoryId" column="category_id" jdbcType="VARCHAR"/>
<result property="specId" column="spec_id" jdbcType="INTEGER"/>
<result property="merchantId" column="merchant_id" jdbcType="VARCHAR"/>
<result property="shopId" column="shop_id" jdbcType="VARCHAR"/>
<result property="name" column="name" jdbcType="VARCHAR"/>
<result property="shortTitle" column="short_title" jdbcType="VARCHAR"/>
<result property="type" column="type" jdbcType="VARCHAR"/>
<result property="packFee" column="pack_fee" jdbcType="DECIMAL"/>
<result property="lowPrice" column="low_price" jdbcType="DECIMAL"/>
<result property="lowMemberPrice" column="low_member_price" jdbcType="DECIMAL"/>
<result property="packFee" column="pack_fee" jdbcType="NUMERIC"/>
<result property="lowPrice" column="low_price" jdbcType="NUMERIC"/>
<result property="unitId" column="unit_id" jdbcType="INTEGER"/>
<result property="coverImg" column="cover_img" jdbcType="VARCHAR"/>
<result property="images" column="images" jdbcType="VARCHAR"/>
<result property="sort" column="sort" jdbcType="INTEGER"/>
<result property="status" column="status" jdbcType="INTEGER"/>
<result property="failMsg" column="fail_msg" jdbcType="VARCHAR"/>
<result property="isHot" column="is_hot" jdbcType="INTEGER"/>
<result property="typeEnum" column="type_enum" jdbcType="VARCHAR"/>
<result property="isDel" column="is_del" jdbcType="INTEGER"/>
@ -26,20 +24,36 @@
<result property="isPauseSale" column="is_pause_sale" jdbcType="INTEGER"/>
<result property="createdAt" column="created_at" jdbcType="INTEGER"/>
<result property="updatedAt" column="updated_at" jdbcType="INTEGER"/>
<result property="groupType" column="group_type" jdbcType="INTEGER"/>
<result property="groupSnap" column="group_snap" jdbcType="VARCHAR"/>
<result property="specInfo" column="spec_info" jdbcType="VARCHAR"/>
<result property="selectSpec" column="select_spec" jdbcType="VARCHAR"/>
<result property="specTableHeaders" column="spec_table_headers" jdbcType="VARCHAR"/>
<result property="groupCategoryId" column="group_category_id" jdbcType="VARCHAR"/>
<result property="realSalesNumber" column="real_sales_number" jdbcType="INTEGER"/>
<result property="stockNumber" column="stock_number" jdbcType="INTEGER"/>
<result property="isGrounding" column="is_grounding" jdbcType="INTEGER"/>
<result property="isRefundStock" column="is_refund_stock" jdbcType="INTEGER"/>
<result property="warnLine" column="warn_line" jdbcType="INTEGER"/>
<result property="showType" column="show_type" jdbcType="VARCHAR"/>
<result property="weight" column="weight" jdbcType="NUMERIC"/>
<result property="isTempPrice" column="is_temp_price" jdbcType="INTEGER"/>
<result property="dayLimit" column="day_limit" jdbcType="INTEGER"/>
<result property="singleOrderLimit" column="single_order_limit" jdbcType="INTEGER"/>
<result property="singlePeopleLimit" column="single_people_limit" jdbcType="INTEGER"/>
<result property="days" column="days" jdbcType="VARCHAR"/>
<result property="startTime" column="start_time" jdbcType="VARCHAR"/>
<result property="endTime" column="end_time" jdbcType="VARCHAR"/>
</resultMap>
<sql id="Base_Column_List">
id
, category_id, spec_id, merchant_id, shop_id, name, short_title, type, pack_fee, low_price, low_member_price,
unit_id, cover_img, images, sort, status, fail_msg, is_hot, type_enum, is_del, is_stock, is_pause_sale,
created_at, updated_at, group_snap, spec_info, select_spec,
spec_table_headers, group_category_id, real_sales_number, stock_number, is_grounding, is_refund_stock, warn_line </sql>
id, category_id, spec_id, merchant_id, shop_id, name, short_title,
type, pack_fee, low_price, unit_id, cover_img, images, sort, status,
is_hot, type_enum, is_del, is_stock, is_pause_sale, created_at, updated_at,
group_type, group_snap, spec_info, select_spec, spec_table_headers,
group_category_id, real_sales_number, stock_number, is_grounding,
is_refund_stock, warn_line, show_type, weight, is_temp_price,
day_limit, single_order_limit, single_people_limit, days, start_time, end_time </sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select
@ -49,7 +63,7 @@
</select>
<select id="selectByShopId" resultMap="BaseResultMap">
select * from tb_product where shop_id=#{shopId} and status=1 and is_del = 0 and is_grounding = 1 and type_enum in ('normal','sku','currentPrice','weight')
select * from tb_product where shop_id=#{shopId} and status=1 and is_del = 0 and is_grounding = 1 and type != 'coupon'
<if test="commdityName != null and commdityName!='' ">
and name like CONCAT('%',#{commdityName},'%')
</if>
@ -58,19 +72,21 @@
</select>
<select id="selectByShopIdAndCheckGrounding" resultMap="BaseResultMap">
select a.* from tb_product as a
left join tb_product_sku as b on a.id = b.product_id
where a.shop_id=#{shopId} and a.status=1 and a.is_del = 0 and a.is_grounding = 1 and a.type_enum in ('normal','sku','currentPrice','weight')
left join tb_product_sku as b on a.id = b.product_id and b.is_grounding=1 and b.is_del=0
where a.shop_id=#{shopId} and a.status = 1 and a.is_grounding = 1
and a.type != 'coupon' and a.is_del = 0
and a.days LIKE concat('%',DAYNAME(CURRENT_DATE),'%') and a.start_time &lt;= CURRENT_TIMESTAMP and a.end_time &gt;= CURRENT_TIMESTAMP
<if test="commdityName != null and commdityName!='' ">
and a.name like CONCAT('%',#{commdityName},'%')
</if>
and b.is_grounding=1 GROUP BY a.id ORDER BY a.`sort`
GROUP BY a.id ORDER BY a.`sort`
</select>
<select id="selectByShopIdAndShopType" resultMap="BaseResultMap">
select * from tb_product where shop_id=#{shopId} and status=1 and category_id=#{categoryId} and is_del = 0 and is_grounding = 1 and type_enum in ('normal','sku','currentPrice','weight')
select * from tb_product where shop_id=#{shopId} and status=1 and category_id=#{categoryId} and is_del = 0 and is_grounding = 1 and type != 'coupon'
<if test="commdityName != null and commdityName!='' ">
and name like CONCAT('%',#{commdityName},'%')
@ -84,7 +100,9 @@
select a.* from tb_product as a
left join tb_product_sku as b on a.id = b.product_id
where a.shop_id=#{shopId} and a.status=1 and a.category_id=#{categoryId} and a.is_del = 0 and a.is_grounding = 1 and a.type_enum in ('normal','sku','currentPrice','weight')
where a.shop_id=#{shopId} and a.status=1 and a.category_id=#{categoryId} and a.is_grounding = 1
and a.type != 'coupon' and a.is_del = 0
and a.days LIKE concat('%',DAYNAME(CURRENT_DATE),'%') and a.start_time &lt;= CURRENT_TIMESTAMP and a.end_time &gt;= CURRENT_TIMESTAMP
<if test="commdityName != null and commdityName!='' ">
and a.name like CONCAT('%',#{commdityName},'%')
@ -96,15 +114,19 @@
select a.* from tb_product as a
left join tb_product_sku as b on a.id = b.product_id
where a.shop_id=#{shopId} and a.status=1 and a.is_del = 0 and a.is_grounding = 1 and a.type_enum in ('normal','sku','currentPrice','weight')
where a.shop_id=#{shopId} and a.status=1 and a.is_grounding = 0
and a.type != 'coupon' and a.is_del = 0
and a.days LIKE concat('%',DAYNAME(CURRENT_DATE),'%') and a.start_time &lt;= CURRENT_TIMESTAMP and a.end_time &gt;= CURRENT_TIMESTAMP
<if test="commdityName != null and commdityName!='' ">
and a.name like CONCAT('%',#{commdityName},'%')
</if>
and b.is_grounding=0 GROUP BY a.id ORDER BY a.`sort`
GROUP BY a.id ORDER BY a.`sort`
</select>
<select id="countOrderByshopIdAndProductId" resultType="INTEGER">
SELECT
IFNULL(sum( number ) ,0)