首页数据
This commit is contained in:
@@ -2,10 +2,14 @@ package com.chaozhanggui.system.cashierservice.dao;
|
||||
|
||||
import com.chaozhanggui.system.cashierservice.entity.SysDict;
|
||||
import com.chaozhanggui.system.cashierservice.entity.SysDictDetail;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Component
|
||||
@Mapper
|
||||
public interface SysDictDetailMapper {
|
||||
int deleteByPrimaryKey(Long detailId);
|
||||
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
package com.chaozhanggui.system.cashierservice.dao;
|
||||
|
||||
import com.chaozhanggui.system.cashierservice.entity.TagProductDepts;
|
||||
import com.chaozhanggui.system.cashierservice.entity.vo.TagProductVO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* (TagProductDepts)表数据库访问层
|
||||
*
|
||||
* @author lyf
|
||||
* @since 2024-04-08 15:03:49
|
||||
*/
|
||||
@Component
|
||||
@Mapper
|
||||
public interface TagProductDeptsMapper {
|
||||
|
||||
/**
|
||||
* 通过ID查询单条数据
|
||||
*
|
||||
* @param tagId 主键
|
||||
* @return 实例对象
|
||||
*/
|
||||
TagProductDepts queryById(Integer tagId);
|
||||
|
||||
/**
|
||||
* 查询指定行数据
|
||||
*
|
||||
* @param tagProductDepts 查询条件
|
||||
* @param pageable 分页对象
|
||||
* @return 对象列表
|
||||
*/
|
||||
List<TagProductDepts> queryAllByLimit(TagProductDepts tagProductDepts, @Param("pageable") Pageable pageable);
|
||||
|
||||
List<TagProductVO> queryTagAndProduct(@Param("list") List<Integer> list);
|
||||
|
||||
/**
|
||||
* 统计总行数
|
||||
*
|
||||
* @param tagProductDepts 查询条件
|
||||
* @return 总行数
|
||||
*/
|
||||
long count(TagProductDepts tagProductDepts);
|
||||
|
||||
/**
|
||||
* 新增数据
|
||||
*
|
||||
* @param tagProductDepts 实例对象
|
||||
* @return 影响行数
|
||||
*/
|
||||
int insert(TagProductDepts tagProductDepts);
|
||||
|
||||
/**
|
||||
* 批量新增数据(MyBatis原生foreach方法)
|
||||
*
|
||||
* @param entities List<TagProductDepts> 实例对象列表
|
||||
* @return 影响行数
|
||||
*/
|
||||
int insertBatch(@Param("entities") List<TagProductDepts> entities);
|
||||
|
||||
/**
|
||||
* 批量新增或按主键更新数据(MyBatis原生foreach方法)
|
||||
*
|
||||
* @param entities List<TagProductDepts> 实例对象列表
|
||||
* @return 影响行数
|
||||
* @throws org.springframework.jdbc.BadSqlGrammarException 入参是空List的时候会抛SQL语句错误的异常,请自行校验入参
|
||||
*/
|
||||
int insertOrUpdateBatch(@Param("entities") List<TagProductDepts> entities);
|
||||
|
||||
/**
|
||||
* 修改数据
|
||||
*
|
||||
* @param tagProductDepts 实例对象
|
||||
* @return 影响行数
|
||||
*/
|
||||
int update(TagProductDepts tagProductDepts);
|
||||
|
||||
/**
|
||||
* 通过主键删除数据
|
||||
*
|
||||
* @param tagId 主键
|
||||
* @return 影响行数
|
||||
*/
|
||||
int deleteById(Integer tagId);
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.chaozhanggui.system.cashierservice.entity;
|
||||
|
||||
import java.util.Date;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* (TagProductDepts)实体类
|
||||
*
|
||||
* @author lyf
|
||||
* @since 2024-04-08 14:57:05
|
||||
*/
|
||||
public class TagProductDepts implements Serializable {
|
||||
private static final long serialVersionUID = -39116122966010022L;
|
||||
/**
|
||||
* 标签id
|
||||
*/
|
||||
private Integer tagId;
|
||||
/**
|
||||
* 商品id
|
||||
*/
|
||||
private Integer productId;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
|
||||
public Integer getTagId() {
|
||||
return tagId;
|
||||
}
|
||||
|
||||
public void setTagId(Integer tagId) {
|
||||
this.tagId = tagId;
|
||||
}
|
||||
|
||||
public Integer getProductId() {
|
||||
return productId;
|
||||
}
|
||||
|
||||
public void setProductId(Integer productId) {
|
||||
this.productId = productId;
|
||||
}
|
||||
|
||||
public Date getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public void setCreateTime(Date createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -95,6 +95,18 @@ public class TbShopInfo implements Serializable {
|
||||
* 商家二维码
|
||||
*/
|
||||
private String shopQrcode;
|
||||
/**
|
||||
* 商户标签
|
||||
*/
|
||||
private String tag;
|
||||
|
||||
public String getTag() {
|
||||
return tag;
|
||||
}
|
||||
|
||||
public void setTag(String tag) {
|
||||
this.tag = tag;
|
||||
}
|
||||
|
||||
public String getShopQrcode() {
|
||||
return shopQrcode;
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
package com.chaozhanggui.system.cashierservice.entity.vo;
|
||||
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author lyf
|
||||
@@ -55,6 +58,19 @@ public class HomeVO {
|
||||
private String distances ="100";
|
||||
|
||||
private Integer id;
|
||||
/**
|
||||
* 结束时间
|
||||
*/
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private String endTime;
|
||||
|
||||
public String getEndTime() {
|
||||
return endTime;
|
||||
}
|
||||
|
||||
public void setEndTime(String endTime) {
|
||||
this.endTime = endTime;
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.chaozhanggui.system.cashierservice.entity.vo;
|
||||
|
||||
/**
|
||||
* @author lyf
|
||||
*/
|
||||
public class TagProductVO {
|
||||
private Integer productId;
|
||||
private String name;
|
||||
private String tags;
|
||||
|
||||
public Integer getProductId() {
|
||||
return productId;
|
||||
}
|
||||
|
||||
public void setProductId(Integer productId) {
|
||||
this.productId = productId;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getTags() {
|
||||
return tags;
|
||||
}
|
||||
|
||||
public void setTags(String tags) {
|
||||
this.tags = tags;
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@ import com.chaozhanggui.system.cashierservice.entity.dto.HomeDto;
|
||||
import com.chaozhanggui.system.cashierservice.entity.vo.*;
|
||||
import com.chaozhanggui.system.cashierservice.sign.CodeEnum;
|
||||
import com.chaozhanggui.system.cashierservice.sign.Result;
|
||||
import com.chaozhanggui.system.cashierservice.util.DateUtils;
|
||||
import com.chaozhanggui.system.cashierservice.util.Threads;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -36,6 +37,8 @@ public class HomePageService {
|
||||
private TbProductMapper productMapper;
|
||||
@Resource
|
||||
private SysDictDetailMapper sysDictDetailMapper;
|
||||
@Resource
|
||||
private TagProductDeptsMapper tagProductDeptsMapper;
|
||||
|
||||
|
||||
public Result homePage(HomeDto homeDto,String environmen) throws ExecutionException, InterruptedException {
|
||||
@@ -50,9 +53,11 @@ public class HomePageService {
|
||||
//统计shopId,以及productId
|
||||
List<String> shopIds = new ArrayList<>();
|
||||
List<String> productIds = new ArrayList<>();
|
||||
List<Integer> productIdsInt = new ArrayList<>();
|
||||
for (TbMerchantCoupon coupon : tbMerchantCoupons) {
|
||||
shopIds.add(coupon.getShopId());
|
||||
productIds.add(coupon.getRelationIds());
|
||||
productIdsInt.add(Integer.valueOf(coupon.getRelationIds()));
|
||||
}
|
||||
CompletableFuture<List<TbShopInfo>> shopInfo = CompletableFuture.supplyAsync(() ->
|
||||
shopInfoMapper.selectByIds(shopIds));
|
||||
@@ -60,26 +65,21 @@ public class HomePageService {
|
||||
productMapper.selectByIds((productIds)));
|
||||
CompletableFuture<List<TbProductSku>> productSku = CompletableFuture.supplyAsync(() ->
|
||||
productSkuMapper.selectSkus((productIds)));
|
||||
CompletableFuture<List<TbPlatformDict>> dictPro = CompletableFuture.supplyAsync(() ->
|
||||
platformDictMapper.queryAllByType("proTag",environmen));
|
||||
CompletableFuture<List<TbPlatformDict>> dictShop = CompletableFuture.supplyAsync(() ->
|
||||
platformDictMapper.queryAllByType("shopTag",environmen));
|
||||
Threads.call(shopInfo,product,productSku,dictPro,dictShop);
|
||||
boolean isFirstAdded = true;
|
||||
CompletableFuture<List<TagProductVO>> dictPro = CompletableFuture.supplyAsync(() ->
|
||||
tagProductDeptsMapper.queryTagAndProduct(productIdsInt));
|
||||
Threads.call(shopInfo,product,productSku,dictPro);
|
||||
|
||||
//组装
|
||||
List<HomeVO> homeVOList = new ArrayList<>();
|
||||
for (TbMerchantCoupon o :tbMerchantCoupons) {
|
||||
HomeVO homeVO = new HomeVO();
|
||||
homeVO.setDiscount(o.getRatio());
|
||||
if (isFirstAdded){
|
||||
homeVO.setShopTag(dictShop.get().get(0).getName());
|
||||
homeVO.setProTag(dictPro.get().get(0).getName());
|
||||
isFirstAdded = false;
|
||||
}
|
||||
for (TbShopInfo tbShopInfo : shopInfo.get()) {
|
||||
if (o.getShopId().equals(tbShopInfo.getId().toString())) {
|
||||
homeVO.setShopName(tbShopInfo.getShopName());
|
||||
homeVO.setImage(tbShopInfo.getLogo());
|
||||
TbPlatformDict tbPlatformDict = platformDictMapper.queryById(Integer.valueOf(tbShopInfo.getTag()));
|
||||
homeVO.setShopTag(tbPlatformDict == null?"":tbPlatformDict.getName());
|
||||
}
|
||||
}
|
||||
for (TbProduct tbProduct :product.get()) {
|
||||
@@ -99,6 +99,12 @@ public class HomePageService {
|
||||
homeVO.setSave(homeVO.getOriginPrice().subtract(homeVO.getSalePrice()));
|
||||
}
|
||||
}
|
||||
for (TagProductVO tagProductVO :dictPro.get()) {
|
||||
if (o.getRelationIds().equals(tagProductVO.getProductId().toString())){
|
||||
homeVO.setProTag(tagProductVO.getTags());
|
||||
}
|
||||
}
|
||||
homeVO.setEndTime(DateUtils.getTodayEndTimeAsString());
|
||||
homeVOList.add(homeVO);
|
||||
}
|
||||
|
||||
|
||||
@@ -3,8 +3,13 @@ package com.chaozhanggui.system.cashierservice.util;
|
||||
import java.text.DateFormat;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.GregorianCalendar;
|
||||
|
||||
/**
|
||||
* Created by SEELE on 2018/4/19.
|
||||
@@ -242,6 +247,36 @@ public class DateUtils {
|
||||
return date;
|
||||
}
|
||||
|
||||
/**
|
||||
* 今天结束时间
|
||||
* @return
|
||||
*/
|
||||
public static Date getDayEnd() {
|
||||
Calendar cal = new GregorianCalendar();
|
||||
cal.set(Calendar.HOUR_OF_DAY, 23);
|
||||
cal.set(Calendar.MINUTE, 59);
|
||||
cal.set(Calendar.SECOND, 59);
|
||||
cal.set(Calendar.MILLISECOND, 999);
|
||||
return cal.getTime();
|
||||
}
|
||||
|
||||
public static String getTodayEndTimeAsString() {
|
||||
// 获取今天的日期
|
||||
LocalDate today = LocalDate.now();
|
||||
|
||||
// 创建今天的结束时间(23:59:59.999)
|
||||
LocalTime endTime = LocalTime.of(23, 59, 59, 999_000_000);
|
||||
|
||||
// 组合日期和时间
|
||||
LocalDateTime todayEndTime = LocalDateTime.of(today, endTime);
|
||||
|
||||
// 格式化时间
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS");
|
||||
|
||||
// 转换为字符串
|
||||
return todayEndTime.format(formatter);
|
||||
}
|
||||
|
||||
/**
|
||||
* 得到n天之后是周几
|
||||
* @param days
|
||||
|
||||
117
src/main/resources/mapper/TagProductDeptsMapper.xml
Normal file
117
src/main/resources/mapper/TagProductDeptsMapper.xml
Normal file
@@ -0,0 +1,117 @@
|
||||
<?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.TagProductDeptsMapper">
|
||||
|
||||
<resultMap type="com.chaozhanggui.system.cashierservice.entity.TagProductDepts" id="TagProductDeptsMap">
|
||||
<result property="tagId" column="tag_id" jdbcType="INTEGER"/>
|
||||
<result property="productId" column="product_id" jdbcType="INTEGER"/>
|
||||
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
|
||||
</resultMap>
|
||||
|
||||
<!--查询单个-->
|
||||
<select id="queryById" resultMap="TagProductDeptsMap">
|
||||
select
|
||||
tag_id, product_id, create_time
|
||||
from tag_product_depts
|
||||
where tag_id = #{tagId}
|
||||
</select>
|
||||
|
||||
<!--查询指定行数据-->
|
||||
<select id="queryAllByLimit" resultMap="TagProductDeptsMap">
|
||||
select
|
||||
tag_id, product_id, create_time
|
||||
from tag_product_depts
|
||||
<where>
|
||||
<if test="tagId != null">
|
||||
and tag_id = #{tagId}
|
||||
</if>
|
||||
<if test="productId != null">
|
||||
and product_id = #{productId}
|
||||
</if>
|
||||
<if test="createTime != null">
|
||||
and create_time = #{createTime}
|
||||
</if>
|
||||
</where>
|
||||
limit #{pageable.offset}, #{pageable.pageSize}
|
||||
</select>
|
||||
|
||||
<!--统计总行数-->
|
||||
<select id="count" resultType="java.lang.Long">
|
||||
select count(1)
|
||||
from tag_product_depts
|
||||
<where>
|
||||
<if test="tagId != null">
|
||||
and tag_id = #{tagId}
|
||||
</if>
|
||||
<if test="productId != null">
|
||||
and product_id = #{productId}
|
||||
</if>
|
||||
<if test="createTime != null">
|
||||
and create_time = #{createTime}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
<select id="queryTagAndProduct" resultType="com.chaozhanggui.system.cashierservice.entity.vo.TagProductVO">
|
||||
SELECT
|
||||
pro.id AS productId,
|
||||
pro.`name` AS `name`,
|
||||
GROUP_CONCAT(dict.`name`) AS tags
|
||||
FROM
|
||||
tag_product_depts AS depts
|
||||
LEFT JOIN tb_product AS pro ON depts.product_id = pro.id
|
||||
LEFT JOIN tb_platform_dict AS dict ON dict.id = depts.tag_id
|
||||
WHERE
|
||||
<foreach collection="list" index="index" item="item" open="(" separator="," close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
GROUP BY
|
||||
pro.id,
|
||||
pro.name;
|
||||
</select>
|
||||
|
||||
<!--新增所有列-->
|
||||
<insert id="insert" keyProperty="tagId" useGeneratedKeys="true">
|
||||
insert into tag_product_depts(product_id, create_time)
|
||||
values (#{productId}, #{createTime})
|
||||
</insert>
|
||||
|
||||
<insert id="insertBatch" keyProperty="tagId" useGeneratedKeys="true">
|
||||
insert into tag_product_depts(product_id, create_time)
|
||||
values
|
||||
<foreach collection="entities" item="entity" separator=",">
|
||||
(#{entity.productId}, #{entity.createTime})
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<insert id="insertOrUpdateBatch" keyProperty="tagId" useGeneratedKeys="true">
|
||||
insert into tag_product_depts(product_id, create_time)
|
||||
values
|
||||
<foreach collection="entities" item="entity" separator=",">
|
||||
(#{entity.productId}, #{entity.createTime})
|
||||
</foreach>
|
||||
on duplicate key update
|
||||
product_id = values(product_id),
|
||||
create_time = values(create_time)
|
||||
</insert>
|
||||
|
||||
<!--通过主键修改数据-->
|
||||
<update id="update">
|
||||
update tag_product_depts
|
||||
<set>
|
||||
<if test="productId != null">
|
||||
product_id = #{productId},
|
||||
</if>
|
||||
<if test="createTime != null">
|
||||
create_time = #{createTime},
|
||||
</if>
|
||||
</set>
|
||||
where tag_id = #{tagId}
|
||||
</update>
|
||||
|
||||
<!--通过主键删除-->
|
||||
<delete id="deleteById">
|
||||
delete from tag_product_depts where tag_id = #{tagId}
|
||||
</delete>
|
||||
|
||||
</mapper>
|
||||
|
||||
@@ -55,7 +55,7 @@
|
||||
detail, lat, lng, mch_id, register_type, is_wx_ma_independent, address, city, type,
|
||||
industry, industry_name, business_time, post_time, post_amount_line, on_sale, settle_type,
|
||||
settle_time, enter_at, expire_at, status, average, order_wait_pay_minute, support_device_number,
|
||||
distribute_level, created_at, updated_at, proxy_id
|
||||
distribute_level, created_at, updated_at, proxy_id, shop_qrcode, tag
|
||||
</sql>
|
||||
<sql id="Blob_Column_List">
|
||||
view
|
||||
|
||||
Reference in New Issue
Block a user