|
|
|
@ -30,6 +30,12 @@ |
|
|
|
<result column="tail_warn" jdbcType="INTEGER" property="tailWarn"/> |
|
|
|
<result column="in_storage_status" jdbcType="INTEGER" property="inStorageStatus"/> |
|
|
|
<result column="customer_category_rule" jdbcType="VARCHAR" property="customerCategoryRule"/> |
|
|
|
<result column="attribute_list_price" jdbcType="VARCHAR" property="attributeListPrice"/> |
|
|
|
<result column="is_push" jdbcType="INTEGER" property="isPush"/> |
|
|
|
<result column="is_must" jdbcType="INTEGER" property="isMust"/> |
|
|
|
<result column="order_filed" jdbcType="INTEGER" property="orderFiled"/> |
|
|
|
<result column="sell_begin_time" jdbcType="TIMESTAMP" property="sellBeginTime"/> |
|
|
|
<result column="sell_end_time" jdbcType="TIMESTAMP" property="sellEndTime"/> |
|
|
|
</resultMap> |
|
|
|
<sql id="Example_Where_Clause"> |
|
|
|
<where> |
|
|
|
@ -95,7 +101,7 @@ |
|
|
|
id, create_by, create_time, del_flag, update_by, update_time, product_name, unit, |
|
|
|
shop_id, category_id,attr_id, attribute_list, supplier_id,supplier_name, product_sn, barcode, price, purchase_price,commission, |
|
|
|
wholesale_price, product_picture, product_video, product_intro, sales_week, print_barcode, |
|
|
|
tail_warn,in_storage_status,customer_category_rule |
|
|
|
tail_warn,in_storage_status,customer_category_rule, attribute_list_price, is_push, is_must, order_filed, sell_begin_time, sell_end_time |
|
|
|
</sql> |
|
|
|
<select id="selectByExample" parameterType="cc.hiver.mall.entity.ProductExample" resultMap="BaseResultMap"> |
|
|
|
select |
|
|
|
@ -136,7 +142,8 @@ |
|
|
|
product_sn, barcode, price, |
|
|
|
purchase_price, commission, wholesale_price, product_picture, |
|
|
|
product_video, product_intro, sales_week, |
|
|
|
print_barcode, tail_warn,in_storage_status,customer_category_rule) |
|
|
|
print_barcode, tail_warn,in_storage_status,customer_category_rule, |
|
|
|
attribute_list_price,is_push,is_must,order_filed,sell_begin_time, sell_end_time) |
|
|
|
values (#{id,jdbcType=VARCHAR}, #{createBy,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, |
|
|
|
#{delFlag,jdbcType=INTEGER}, #{updateBy,jdbcType=VARCHAR}, #{updateTime,jdbcType=TIMESTAMP}, |
|
|
|
#{productName,jdbcType=VARCHAR}, #{unit,jdbcType=VARCHAR}, #{shopId,jdbcType=VARCHAR}, |
|
|
|
@ -146,7 +153,8 @@ |
|
|
|
#{productPicture,jdbcType=VARCHAR}, |
|
|
|
#{productVideo,jdbcType=VARCHAR}, #{productIntro,jdbcType=VARCHAR}, #{salesWeek,jdbcType=TIMESTAMP}, |
|
|
|
#{printBarcode,jdbcType=VARCHAR}, #{tailWarn,jdbcType=INTEGER}, #{inStorageStatus,jdbcType=INTEGER}, |
|
|
|
#{customerCategoryRule,jdbcType=VARCHAR}) |
|
|
|
#{customerCategoryRule,jdbcType=VARCHAR},#{attributeListPrice,jdbcType=VARCHAR}, |
|
|
|
#{isPush,jdbcType=INTEGER}, #{isMust,jdbcType=INTEGER}, #{orderFiled,jdbcType=INTEGER},#{sellBeginTime,jdbcType=TIMESTAMP},#{sellEndTime,jdbcType=TIMESTAMP}) |
|
|
|
</insert> |
|
|
|
<insert id="insertSelective" parameterType="cc.hiver.mall.entity.Product"> |
|
|
|
insert into t_product |
|
|
|
@ -232,6 +240,24 @@ |
|
|
|
<if test="customerCategoryRule != null"> |
|
|
|
customer_category_rule, |
|
|
|
</if> |
|
|
|
<if test="attributeListPrice != null"> |
|
|
|
attribute_list_price, |
|
|
|
</if> |
|
|
|
<if test="isPush != null"> |
|
|
|
is_push, |
|
|
|
</if> |
|
|
|
<if test="isMust != null"> |
|
|
|
is_must |
|
|
|
</if> |
|
|
|
<if test="orderFiled != null"> |
|
|
|
order_filed |
|
|
|
</if> |
|
|
|
<if test="sellBeginTime != null"> |
|
|
|
sell_begin_time |
|
|
|
</if> |
|
|
|
<if test="sellEndTime != null"> |
|
|
|
sell_end_time |
|
|
|
</if> |
|
|
|
</trim> |
|
|
|
<trim prefix="values (" suffix=")" suffixOverrides=","> |
|
|
|
<if test="id != null"> |
|
|
|
@ -315,6 +341,24 @@ |
|
|
|
<if test="customerCategoryRule != null"> |
|
|
|
#{customerCategoryRule,jdbcType=VARCHAR}, |
|
|
|
</if> |
|
|
|
<if test="attributeListPrice != null"> |
|
|
|
#{attributeListPrice,jdbcType=VARCHAR}, |
|
|
|
</if> |
|
|
|
<if test="isPush != null"> |
|
|
|
#{isPush,jdbcType=INTEGER}, |
|
|
|
</if> |
|
|
|
<if test="isMust != null"> |
|
|
|
#{isMust,jdbcType=INTEGER}, |
|
|
|
</if> |
|
|
|
<if test="orderFiled != null"> |
|
|
|
#{orderFiled,jdbcType=INTEGER} |
|
|
|
</if> |
|
|
|
<if test="sellBeginTime != null"> |
|
|
|
#{sellBeginTime,jdbcType=TIMESTAMP}, |
|
|
|
</if> |
|
|
|
<if test="sellEndTime != null"> |
|
|
|
#{sellEndTime,jdbcType=TIMESTAMP}, |
|
|
|
</if> |
|
|
|
</trim> |
|
|
|
</insert> |
|
|
|
<select id="countByExample" parameterType="cc.hiver.mall.entity.ProductExample" resultType="java.lang.Long"> |
|
|
|
@ -407,6 +451,24 @@ |
|
|
|
<if test="record.customerCategoryRule != null"> |
|
|
|
customer_category_rule = #{record.customerCategoryRule,jdbcType=VARCHAR}, |
|
|
|
</if> |
|
|
|
<if test="record.attributeListPrice != null"> |
|
|
|
attribute_list_price = #{record.attributeListPrice,jdbcType=VARCHAR}, |
|
|
|
</if> |
|
|
|
<if test="record.isPush != null"> |
|
|
|
is_push = #{record.isPush,jdbcType=INTEGER}, |
|
|
|
</if> |
|
|
|
<if test="record.isMust != null"> |
|
|
|
is_must = #{record.isMust,jdbcType=INTEGER}, |
|
|
|
</if> |
|
|
|
<if test="record.orderFiled != null"> |
|
|
|
order_filed = #{record.orderFiled,jdbcType=INTEGER} |
|
|
|
</if> |
|
|
|
<if test="record.sellBeginTime != null"> |
|
|
|
sell_begin_time = #{record.sellBeginTime,jdbcType=TIMESTAMP}, |
|
|
|
</if> |
|
|
|
<if test="record.sellEndTime != null"> |
|
|
|
sell_end_time = #{record.sellEndTime,jdbcType=TIMESTAMP} |
|
|
|
</if> |
|
|
|
</set> |
|
|
|
<if test="_parameter != null"> |
|
|
|
<include refid="Update_By_Example_Where_Clause"/> |
|
|
|
@ -440,7 +502,13 @@ |
|
|
|
print_barcode = #{record.printBarcode,jdbcType=VARCHAR}, |
|
|
|
tail_warn = #{record.tailWarn,jdbcType=INTEGER}, |
|
|
|
in_storage_status = #{record.inStorageStatus,jdbcType=INTEGER}, |
|
|
|
customer_category_rule = #{record.customerCategoryRule,jdbcType=VARCHAR} |
|
|
|
customer_category_rule = #{record.customerCategoryRule,jdbcType=VARCHAR}, |
|
|
|
attribute_list_price = #{record.attributeListPrice,jdbcType=VARCHAR}, |
|
|
|
is_push = #{record.isPush,jdbcType=INTEGER}, |
|
|
|
is_must = #{record.isMust,jdbcType=INTEGER}, |
|
|
|
order_filed = #{record.orderFiled,jdbcType=INTEGER}, |
|
|
|
sell_begin_time = #{record.sellBeginTime,jdbcType=TIMESTAMP}, |
|
|
|
sell_end_time = #{record.sellEndTime,jdbcType=TIMESTAMP} |
|
|
|
<if test="_parameter != null"> |
|
|
|
<include refid="Update_By_Example_Where_Clause"/> |
|
|
|
</if> |
|
|
|
@ -526,6 +594,24 @@ |
|
|
|
<if test="customerCategoryRule != null"> |
|
|
|
customer_category_rule = #{customerCategoryRule,jdbcType=VARCHAR}, |
|
|
|
</if> |
|
|
|
<if test="attributeListPrice != null"> |
|
|
|
attribute_list_price = #{attributeListPrice,jdbcType=VARCHAR}, |
|
|
|
</if> |
|
|
|
<if test="isPush != null"> |
|
|
|
is_push = #{isPush,jdbcType=INTEGER}, |
|
|
|
</if> |
|
|
|
<if test="isMust != null"> |
|
|
|
is_must = #{isMust,jdbcType=INTEGER}, |
|
|
|
</if> |
|
|
|
<if test="orderFiled != null"> |
|
|
|
order_filed = #{orderFiled,jdbcType=INTEGER} |
|
|
|
</if> |
|
|
|
<if test="sellBeginTime != null"> |
|
|
|
sell_begin_time = #{sellBeginTime,jdbcType=TIMESTAMP}, |
|
|
|
</if> |
|
|
|
<if test="sellEndTime != null"> |
|
|
|
sell_end_time = #{sellEndTime,jdbcType=TIMESTAMP}, |
|
|
|
</if> |
|
|
|
</set> |
|
|
|
where id = #{id,jdbcType=VARCHAR} |
|
|
|
</update> |
|
|
|
@ -556,7 +642,13 @@ |
|
|
|
print_barcode = #{printBarcode,jdbcType=VARCHAR}, |
|
|
|
tail_warn = #{tailWarn,jdbcType=INTEGER}, |
|
|
|
in_storage_status = #{inStorageStatus,jdbcType=INTEGER}, |
|
|
|
customer_category_rule = #{customerCategoryRule,jdbcType=VARCHAR} |
|
|
|
customer_category_rule = #{customerCategoryRule,jdbcType=VARCHAR}, |
|
|
|
attribute_list_price = #{attributeListPrice,jdbcType=VARCHAR}, |
|
|
|
is_push = #{isPush,jdbcType=INTEGER}, |
|
|
|
is_must = #{isMust,jdbcType=INTEGER}, |
|
|
|
order_filed = #{orderFiled,jdbcType=INTEGER}, |
|
|
|
sell_begin_time = #{sellBeginTime,jdbcType=TIMESTAMP}, |
|
|
|
sell_end_time = #{sellEndTime,jdbcType=TIMESTAMP} |
|
|
|
where id = #{id,jdbcType=VARCHAR} |
|
|
|
</update> |
|
|
|
|
|
|
|
@ -591,49 +683,14 @@ |
|
|
|
t.tail_warn, |
|
|
|
t.in_storage_status, |
|
|
|
t.customer_category_rule, |
|
|
|
COALESCE(ss.stock_count + ss.minus_stock_count, 0) AS total_stock_count, |
|
|
|
COALESCE(ss.stock_count, 0) AS stock_count, |
|
|
|
COALESCE(ss.minus_stock_count, 0) AS minus_stock_count |
|
|
|
<if test='queryParams.startDate !=null and queryParams.startDate.trim() neq "" and queryParams.endDate !=null and queryParams.endDate.trim() neq ""'> |
|
|
|
, COALESCE(sd.total_sold, 0) AS total_sold |
|
|
|
</if> |
|
|
|
t.attribute_list_price, |
|
|
|
t.is_push, |
|
|
|
t.is_must, |
|
|
|
t.order_filed, |
|
|
|
t.sell_begin_time, |
|
|
|
t.sell_end_time |
|
|
|
FROM t_product t |
|
|
|
LEFT JOIN ( |
|
|
|
SELECT |
|
|
|
sum( CASE WHEN s.stock_count < 0 THEN 0 ELSE s.stock_count END ) AS stock_count, |
|
|
|
sum( CASE WHEN s.stock_count > 0 THEN 0 ELSE s.stock_count END ) AS minus_stock_count, |
|
|
|
shop_id, |
|
|
|
product_id |
|
|
|
FROM |
|
|
|
t_stock s |
|
|
|
GROUP BY |
|
|
|
shop_id, |
|
|
|
product_id |
|
|
|
) ss |
|
|
|
ON ss.product_id = t.id |
|
|
|
and ss.shop_id = t.shop_id |
|
|
|
<if test='queryParams.startDate !=null and queryParams.startDate.trim() neq "" and queryParams.endDate !=null and queryParams.endDate.trim() neq ""'> |
|
|
|
LEFT JOIN ( |
|
|
|
SELECT |
|
|
|
sd.product_id, |
|
|
|
SUM(sd.product_count) AS total_sold |
|
|
|
FROM |
|
|
|
t_sale_detail sd |
|
|
|
INNER JOIN t_sale s ON sd.sale_id = s.id |
|
|
|
WHERE |
|
|
|
s.del_flag = '0' |
|
|
|
AND s.status = '4' |
|
|
|
and s.create_time BETWEEN #{queryParams.startDate} AND #{queryParams.endDate} |
|
|
|
<!--<if test='(queryParams.startDate == null or queryParams.startDate eq "" ) and (queryParams.endDate == null or queryParams.endDate eq "")'> |
|
|
|
and s.create_time >= DATE_SUB(CURDATE(), INTERVAL 7 DAY) |
|
|
|
</if>--> |
|
|
|
GROUP BY |
|
|
|
product_id |
|
|
|
) sd ON t.id = sd.product_id |
|
|
|
</if> |
|
|
|
<where> |
|
|
|
<!--已上架的--> |
|
|
|
AND t.del_flag != '2' |
|
|
|
<!--店铺id--> |
|
|
|
<if test='queryParams.shopId!=null and queryParams.shopId.trim() neq ""'> |
|
|
|
AND t.shop_id = #{queryParams.shopId} |
|
|
|
@ -647,25 +704,12 @@ |
|
|
|
AND t.category_id =#{queryParams.categoryId} |
|
|
|
</if> |
|
|
|
|
|
|
|
<!--供应商id--> |
|
|
|
<if test='queryParams.supplierId!=null and queryParams.supplierId.trim() neq ""'> |
|
|
|
AND t.supplier_id =#{queryParams.supplierId} |
|
|
|
</if> |
|
|
|
|
|
|
|
<!--商品名称--> |
|
|
|
<if test='queryParams.productName!=null and queryParams.productName.trim() neq ""'> |
|
|
|
AND t.product_name like concat('%',#{queryParams.productName},'%') |
|
|
|
</if> |
|
|
|
<!--货号--> |
|
|
|
<if test='queryParams.productSn!=null and queryParams.productSn.trim() neq ""'> |
|
|
|
AND t.product_sn like concat('%',#{queryParams.productSn},'%') |
|
|
|
</if> |
|
|
|
<!--供应商名称--> |
|
|
|
<if test='queryParams.supplierName!=null and queryParams.supplierName.trim() neq ""'> |
|
|
|
AND t.supplier_name like concat('%',#{queryParams.supplierName},'%') |
|
|
|
</if> |
|
|
|
<if test='queryParams.idList!=null '> |
|
|
|
and id in |
|
|
|
and t.id in |
|
|
|
<foreach item="item" index="index" collection="queryParams.idList" open="(" close=")" separator=","> |
|
|
|
#{item} |
|
|
|
</foreach> |
|
|
|
@ -673,27 +717,17 @@ |
|
|
|
<if test="queryParams.searchStr != null and queryParams.searchStr != ''"> |
|
|
|
and ( |
|
|
|
t.product_name like concat('%',#{queryParams.searchStr},'%') |
|
|
|
or t.product_sn like concat('%',#{queryParams.searchStr},'%') |
|
|
|
or t.supplier_name like concat('%',#{queryParams.searchStr},'%') |
|
|
|
) |
|
|
|
</if> |
|
|
|
</where> |
|
|
|
ORDER BY |
|
|
|
<if test="queryParams.searchStr != null and queryParams.searchStr != ''"> |
|
|
|
LENGTH(product_sn), |
|
|
|
CASE |
|
|
|
WHEN product_sn LIKE CONCAT(#{queryParams.searchStr}, '%') THEN 1 |
|
|
|
WHEN product_sn LIKE CONCAT('%',#{queryParams.searchStr}) THEN 2 |
|
|
|
ELSE 3 |
|
|
|
END, |
|
|
|
</if> |
|
|
|
<!--销量排序--> |
|
|
|
ORDER BY t.order_filed asc, |
|
|
|
<!--销量排序 |
|
|
|
<if test='queryParams.startDate !=null and queryParams.startDate.trim() neq "" and queryParams.endDate !=null and queryParams.endDate.trim() neq ""'> |
|
|
|
<if test='queryParams.sortField!=null and queryParams.sortField.trim() neq "" and queryParams.sortField eq "totalSold"'> |
|
|
|
sd.total_sold desc, |
|
|
|
</if> |
|
|
|
</if> |
|
|
|
<!-- 如果sort字段为stockCount,则按照total_stock_count库存数排序 --> |
|
|
|
</if>--> |
|
|
|
<!-- 如果sort字段为stockCount,则按照total_stock_count库存数排序 |
|
|
|
<if test='queryParams.sort !=null and queryParams.sort.trim() eq "stockCount" and queryParams.order !=null and queryParams.order.trim() neq "" '> |
|
|
|
<if test='queryParams.order.trim() eq "desc" '> |
|
|
|
total_stock_count desc , |
|
|
|
@ -701,7 +735,7 @@ |
|
|
|
<if test='queryParams.order.trim() eq "asc" '> |
|
|
|
total_stock_count asc , |
|
|
|
</if> |
|
|
|
</if> |
|
|
|
</if> --> |
|
|
|
|
|
|
|
t.in_storage_status asc, t.del_flag desc,t.create_time desc, id |
|
|
|
</select> |
|
|
|
|