Merge remote-tracking branch 'origin/test' into test
This commit is contained in:
@@ -9,6 +9,7 @@ import org.apache.ibatis.annotations.Update;
|
|||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
@Mapper
|
@Mapper
|
||||||
@@ -20,7 +21,7 @@ public interface TbProductMapper {
|
|||||||
|
|
||||||
List<TbProduct> selectByIdIn(@Param("ids") String ids);
|
List<TbProduct> selectByIdIn(@Param("ids") String ids);
|
||||||
List<TbProduct> selectByIdInAndCheck(@Param("ids") String ids);
|
List<TbProduct> selectByIdInAndCheck(@Param("ids") String ids);
|
||||||
List<TbProduct> selectHot(@Param("shopId") String shopId);
|
List<TbProduct> selectHot(@Param("shopId") String shopId,@Param("list") Set<Integer> proIds);
|
||||||
|
|
||||||
List<TbProduct> selectIsSpecialty(@Param("shopId") Integer shopId);
|
List<TbProduct> selectIsSpecialty(@Param("shopId") Integer shopId);
|
||||||
|
|
||||||
|
|||||||
@@ -23,6 +23,11 @@ public class TbProductGroup implements Serializable {
|
|||||||
|
|
||||||
private String style;
|
private String style;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 排序方式 0-默认 1-价格从高到低 2-销量由高到低
|
||||||
|
*/
|
||||||
|
private String sortMode;
|
||||||
|
|
||||||
private Integer sort;
|
private Integer sort;
|
||||||
|
|
||||||
private Long createdAt;
|
private Long createdAt;
|
||||||
@@ -186,4 +191,12 @@ public class TbProductGroup implements Serializable {
|
|||||||
public void setIsSale(Integer isSale) {
|
public void setIsSale(Integer isSale) {
|
||||||
this.isSale = isSale;
|
this.isSale = isSale;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getSortMode() {
|
||||||
|
return sortMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSortMode(String sortMode) {
|
||||||
|
this.sortMode = sortMode;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -228,25 +228,41 @@ public class ProductService {
|
|||||||
TbShopInfo shopInfo = mpShopInfoMapper.selectById(shopId);
|
TbShopInfo shopInfo = mpShopInfoMapper.selectById(shopId);
|
||||||
concurrentMap.put("hots", handleDate(tbProducts,true,1,false, shopInfo));
|
concurrentMap.put("hots", handleDate(tbProducts,true,1,false, shopInfo));
|
||||||
List<TbProductGroup> groupList = tbProductGroupMapper.selectByShopId(shopId, id);
|
List<TbProductGroup> groupList = tbProductGroupMapper.selectByShopId(shopId, id);
|
||||||
if (ObjectUtil.isNotEmpty(groupList) && groupList.size() > 0) {
|
Set<Integer> proSets = new HashSet<>();
|
||||||
//热销
|
if (ObjectUtil.isNotEmpty(groupList)) {
|
||||||
TbProductGroup hot = new TbProductGroup();
|
|
||||||
hot.setName("热销");
|
|
||||||
List<TbProduct> hots = tbProductMapper.selectHot(shopId);
|
|
||||||
hot.setProducts(handleDate(hots,true,1,false, shopInfo));
|
|
||||||
//商品
|
//商品
|
||||||
groupList.parallelStream().forEach(g -> {
|
groupList.parallelStream().forEach(g -> {
|
||||||
if (g.getUseTime()==1) g.setIsSale(getIsSale(g.getSaleStartTime(),g.getSaleEndTime()));
|
if (g.getUseTime()==1) g.setIsSale(getIsSale(g.getSaleStartTime(),g.getSaleEndTime()));
|
||||||
String in = g.getProductIds().substring(1, g.getProductIds().length() - 1);
|
String in = g.getProductIds().substring(1, g.getProductIds().length() - 1);
|
||||||
if (ObjectUtil.isNotEmpty(in) && ObjectUtil.isNotNull(in)) {
|
if (ObjectUtil.isNotEmpty(in) && ObjectUtil.isNotNull(in)) {
|
||||||
|
|
||||||
|
String[] idArray = in.split(",");
|
||||||
|
Set<Integer> proSet = Arrays.stream(idArray)
|
||||||
|
.map(Integer::parseInt)
|
||||||
|
.collect(Collectors.toSet());
|
||||||
|
proSets.addAll(proSet);
|
||||||
|
|
||||||
List<TbProduct> products = tbProductMapper.selectByIdInAndCheck(in);
|
List<TbProduct> products = tbProductMapper.selectByIdInAndCheck(in);
|
||||||
g.setProducts(handleDate(products,false,g.getIsSale(),false, shopInfo));
|
products = handleDate(products, false, g.getIsSale(), false, shopInfo);
|
||||||
|
if(StringUtils.isNotBlank(g.getSortMode()) && "1".equals(g.getSortMode())){
|
||||||
|
products.sort(Comparator.comparing(TbProduct::getLowPrice, Comparator.nullsLast(Comparator.reverseOrder())));
|
||||||
|
}else if (StringUtils.isNotBlank(g.getSortMode()) && "2".equals(g.getSortMode())) {
|
||||||
|
products.sort(Comparator.comparing(TbProduct::getStockNumber, Comparator.nullsLast(Comparator.reverseOrder())));
|
||||||
|
}
|
||||||
|
g.setProducts(products);
|
||||||
} else {
|
} else {
|
||||||
g.setProducts(new ArrayList<>());
|
g.setProducts(new ArrayList<>());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
groupList.sort(Comparator.comparingInt(TbProductGroup::getIsSale).reversed());
|
groupList.sort(Comparator.comparingInt(TbProductGroup::getIsSale).reversed());
|
||||||
|
|
||||||
|
//热销
|
||||||
|
TbProductGroup hot = new TbProductGroup();
|
||||||
|
hot.setName("热销");
|
||||||
|
List<TbProduct> hots = tbProductMapper.selectHot(shopId,proSets);
|
||||||
|
hot.setProducts(handleDate(hots,true,1,false, shopInfo));
|
||||||
groupList.add(0, hot);
|
groupList.add(0, hot);
|
||||||
|
|
||||||
concurrentMap.put("productInfo", groupList);
|
concurrentMap.put("productInfo", groupList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
<result column="detail" jdbcType="VARCHAR" property="detail" />
|
<result column="detail" jdbcType="VARCHAR" property="detail" />
|
||||||
<result column="style" jdbcType="VARCHAR" property="style" />
|
<result column="style" jdbcType="VARCHAR" property="style" />
|
||||||
<result column="sort" jdbcType="INTEGER" property="sort" />
|
<result column="sort" jdbcType="INTEGER" property="sort" />
|
||||||
|
<result column="sort_mode" jdbcType="VARCHAR" property="sortMode" />
|
||||||
<result column="use_time" jdbcType="INTEGER" property="useTime" />
|
<result column="use_time" jdbcType="INTEGER" property="useTime" />
|
||||||
<result column="sale_start_time" jdbcType="INTEGER" property="saleStartTime" />
|
<result column="sale_start_time" jdbcType="INTEGER" property="saleStartTime" />
|
||||||
<result column="sale_end_time" jdbcType="INTEGER" property="saleEndTime" />
|
<result column="sale_end_time" jdbcType="INTEGER" property="saleEndTime" />
|
||||||
@@ -21,7 +22,7 @@
|
|||||||
<result column="product_ids" jdbcType="LONGVARCHAR" property="productIds" />
|
<result column="product_ids" jdbcType="LONGVARCHAR" property="productIds" />
|
||||||
</resultMap>
|
</resultMap>
|
||||||
<sql id="Base_Column_List">
|
<sql id="Base_Column_List">
|
||||||
id, name, merchant_id, shop_id, pic, is_show, detail, style, sort, created_at, updated_at , use_time, sale_start_time, sale_end_time
|
id, name, merchant_id, shop_id, pic, is_show, detail, style, sort, sort_mode, created_at, updated_at , use_time, sale_start_time, sale_end_time
|
||||||
</sql>
|
</sql>
|
||||||
<sql id="Blob_Column_List">
|
<sql id="Blob_Column_List">
|
||||||
product_ids
|
product_ids
|
||||||
@@ -41,12 +42,12 @@
|
|||||||
<insert id="insert" parameterType="com.chaozhanggui.system.cashierservice.entity.TbProductGroup">
|
<insert id="insert" parameterType="com.chaozhanggui.system.cashierservice.entity.TbProductGroup">
|
||||||
insert into tb_product_group (id, name, merchant_id,
|
insert into tb_product_group (id, name, merchant_id,
|
||||||
shop_id, pic, is_show,
|
shop_id, pic, is_show,
|
||||||
detail, style, sort,
|
detail, style, sort, sort_mode,
|
||||||
created_at, updated_at, product_ids
|
created_at, updated_at, product_ids
|
||||||
)
|
)
|
||||||
values (#{id,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, #{merchantId,jdbcType=VARCHAR},
|
values (#{id,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, #{merchantId,jdbcType=VARCHAR},
|
||||||
#{shopId,jdbcType=INTEGER}, #{pic,jdbcType=VARCHAR}, #{isShow,jdbcType=TINYINT},
|
#{shopId,jdbcType=INTEGER}, #{pic,jdbcType=VARCHAR}, #{isShow,jdbcType=TINYINT},
|
||||||
#{detail,jdbcType=VARCHAR}, #{style,jdbcType=VARCHAR}, #{sort,jdbcType=INTEGER},
|
#{detail,jdbcType=VARCHAR}, #{style,jdbcType=VARCHAR}, #{sort,jdbcType=INTEGER}, #{sortMode,jdbcType=VARCHAR},
|
||||||
#{createdAt,jdbcType=BIGINT}, #{updatedAt,jdbcType=BIGINT}, #{productIds,jdbcType=LONGVARCHAR}
|
#{createdAt,jdbcType=BIGINT}, #{updatedAt,jdbcType=BIGINT}, #{productIds,jdbcType=LONGVARCHAR}
|
||||||
)
|
)
|
||||||
</insert>
|
</insert>
|
||||||
@@ -80,6 +81,9 @@
|
|||||||
<if test="sort != null">
|
<if test="sort != null">
|
||||||
sort,
|
sort,
|
||||||
</if>
|
</if>
|
||||||
|
<if test="sortMode != null">
|
||||||
|
sort_mode,
|
||||||
|
</if>
|
||||||
<if test="createdAt != null">
|
<if test="createdAt != null">
|
||||||
created_at,
|
created_at,
|
||||||
</if>
|
</if>
|
||||||
@@ -118,6 +122,9 @@
|
|||||||
<if test="sort != null">
|
<if test="sort != null">
|
||||||
#{sort,jdbcType=INTEGER},
|
#{sort,jdbcType=INTEGER},
|
||||||
</if>
|
</if>
|
||||||
|
<if test="sortMode != null">
|
||||||
|
#{sortMode,jdbcType=INTEGER},
|
||||||
|
</if>
|
||||||
<if test="createdAt != null">
|
<if test="createdAt != null">
|
||||||
#{createdAt,jdbcType=BIGINT},
|
#{createdAt,jdbcType=BIGINT},
|
||||||
</if>
|
</if>
|
||||||
@@ -156,6 +163,9 @@
|
|||||||
<if test="sort != null">
|
<if test="sort != null">
|
||||||
sort = #{sort,jdbcType=INTEGER},
|
sort = #{sort,jdbcType=INTEGER},
|
||||||
</if>
|
</if>
|
||||||
|
<if test="sortMode != null">
|
||||||
|
sort_mode = #{sort,jdbcType=VARCHAR},
|
||||||
|
</if>
|
||||||
<if test="createdAt != null">
|
<if test="createdAt != null">
|
||||||
created_at = #{createdAt,jdbcType=BIGINT},
|
created_at = #{createdAt,jdbcType=BIGINT},
|
||||||
</if>
|
</if>
|
||||||
@@ -178,6 +188,7 @@
|
|||||||
detail = #{detail,jdbcType=VARCHAR},
|
detail = #{detail,jdbcType=VARCHAR},
|
||||||
style = #{style,jdbcType=VARCHAR},
|
style = #{style,jdbcType=VARCHAR},
|
||||||
sort = #{sort,jdbcType=INTEGER},
|
sort = #{sort,jdbcType=INTEGER},
|
||||||
|
sort_mode = #{sortMode,jdbcType=VARCHAR},
|
||||||
created_at = #{createdAt,jdbcType=BIGINT},
|
created_at = #{createdAt,jdbcType=BIGINT},
|
||||||
updated_at = #{updatedAt,jdbcType=BIGINT},
|
updated_at = #{updatedAt,jdbcType=BIGINT},
|
||||||
product_ids = #{productIds,jdbcType=LONGVARCHAR}
|
product_ids = #{productIds,jdbcType=LONGVARCHAR}
|
||||||
@@ -193,6 +204,7 @@
|
|||||||
detail = #{detail,jdbcType=VARCHAR},
|
detail = #{detail,jdbcType=VARCHAR},
|
||||||
style = #{style,jdbcType=VARCHAR},
|
style = #{style,jdbcType=VARCHAR},
|
||||||
sort = #{sort,jdbcType=INTEGER},
|
sort = #{sort,jdbcType=INTEGER},
|
||||||
|
sort_mode = #{sortMode,jdbcType=VARCHAR},
|
||||||
created_at = #{createdAt,jdbcType=BIGINT},
|
created_at = #{createdAt,jdbcType=BIGINT},
|
||||||
updated_at = #{updatedAt,jdbcType=BIGINT}
|
updated_at = #{updatedAt,jdbcType=BIGINT}
|
||||||
where id = #{id,jdbcType=INTEGER}
|
where id = #{id,jdbcType=INTEGER}
|
||||||
|
|||||||
@@ -922,49 +922,51 @@
|
|||||||
select min( sku.suit ) as suit,tb.*
|
select min( sku.suit ) as suit,tb.*
|
||||||
from tb_product tb
|
from tb_product tb
|
||||||
LEFT JOIN tb_product_sku sku ON tb.id = sku.product_id
|
LEFT JOIN tb_product_sku sku ON tb.id = sku.product_id
|
||||||
where tb.id in (${ids}) and is_show_mall =1 and sku.is_del = 0
|
where tb.id in (${ids}) and sku.is_del = 0
|
||||||
group by tb.id
|
group by tb.id
|
||||||
order by tb.sort asc
|
order by tb.sort asc
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectByIdInAndCheck" resultMap="BaseResultMap">
|
<select id="selectByIdInAndCheck" resultMap="BaseResultMap">
|
||||||
select min( sku.suit ) as suit,tb.*
|
select min( sku.suit ) as suit,tb.*,sum(sku.real_sales_number) as stockNumber
|
||||||
from tb_product tb
|
from tb_product tb
|
||||||
LEFT JOIN tb_product_sku sku ON tb.id = sku.product_id
|
LEFT JOIN tb_product_sku sku ON tb.id = sku.product_id and sku.is_del = 0
|
||||||
where tb.id in (${ids}) and is_show_mall =1 and sku.is_del = 0 and sku.is_grounding=1 and tb.type_enum!='group' and tb.status = 1
|
where tb.id in (${ids}) and tb.is_grounding=1 and tb.type_enum!='group' and tb.status = 1
|
||||||
group by tb.id
|
group by tb.id
|
||||||
order by tb.sort asc
|
order by tb.sort asc
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectHot" resultMap="BaseResultMap">
|
<select id="selectHot" resultMap="BaseResultMap">
|
||||||
select min(sku.suit) as suit, tb.*
|
select min(sku.suit) as suit, tb.* ,realSalesNumber as stockNumber
|
||||||
from tb_product tb
|
from tb_product tb
|
||||||
LEFT JOIN tb_product_sku sku ON tb.id = sku.product_id
|
LEFT JOIN tb_product_sku sku ON tb.id = sku.product_id
|
||||||
JOIN (SELECT product_id
|
JOIN (SELECT product_id ,SUM(real_sales_number) as realSalesNumber
|
||||||
FROM tb_product_sku
|
FROM tb_product_sku
|
||||||
WHERE shop_id = #{shopId}
|
WHERE shop_id = #{shopId}
|
||||||
|
and is_del = 0
|
||||||
|
AND product_id IN
|
||||||
|
<foreach collection="list" item="item" index="index" open="(" close=")" separator=",">
|
||||||
|
#{item}
|
||||||
|
</foreach>
|
||||||
GROUP BY product_id
|
GROUP BY product_id
|
||||||
ORDER BY SUM(real_sales_number) DESC LIMIT 3) AS top_products ON tb.id = top_products.product_id
|
ORDER BY stockNumber DESC LIMIT 3) AS top_products ON tb.id = top_products.product_id
|
||||||
where is_show_mall = 1
|
where
|
||||||
and tb.status = 1
|
tb.status = 1
|
||||||
and tb.type_enum != 'group'
|
and tb.type_enum != 'group'
|
||||||
and sku.is_del = 0
|
and tb.is_grounding = 1
|
||||||
and sku.is_grounding = 1
|
|
||||||
group by tb.id
|
group by tb.id
|
||||||
order by tb.sort asc
|
order by stockNumber desc
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|
||||||
<select id="selectIsSpecialty" resultMap="BaseResultMap">
|
<select id="selectIsSpecialty" resultMap="BaseResultMap">
|
||||||
select min(sku.suit) as suit, tb.*
|
select min(sku.suit) as suit, tb.*
|
||||||
from tb_product tb
|
from tb_product tb
|
||||||
LEFT JOIN tb_product_sku sku ON tb.id = sku.product_id
|
LEFT JOIN tb_product_sku sku ON tb.id = sku.product_id and sku.is_del = 0
|
||||||
where is_hot = 1
|
where is_hot = 1
|
||||||
and is_show_mall = 1
|
|
||||||
and tb.shop_id = #{shopId}
|
and tb.shop_id = #{shopId}
|
||||||
and tb.status = 1
|
and tb.status = 1
|
||||||
and sku.is_del = 0
|
and tb.is_grounding = 1
|
||||||
and sku.is_grounding = 1
|
|
||||||
and tb.type_enum != 'group'
|
and tb.type_enum != 'group'
|
||||||
group by tb.id
|
group by tb.id
|
||||||
order by tb.sort asc
|
order by tb.sort asc
|
||||||
|
|||||||
Reference in New Issue
Block a user