diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/controller/HomeController.java b/src/main/java/com/chaozhanggui/system/cashierservice/controller/HomeController.java index 31409a7..0a26bbe 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/controller/HomeController.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/controller/HomeController.java @@ -21,8 +21,8 @@ public class HomeController { private HomePageService homePageService; @PostMapping - public Result homePage(@RequestBody HomeDto homeDto){ - return homePageService.homePage(homeDto); + public Result homePage(@RequestBody HomeDto homeDto,@RequestHeader("environment") String environmen)throws Exception{ + return homePageService.homePage(homeDto, environmen); } @PostMapping("/homePageUp") public Result homePageUp(@RequestHeader("environment") String environment){ diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/dao/SysDictDetailMapper.java b/src/main/java/com/chaozhanggui/system/cashierservice/dao/SysDictDetailMapper.java index db7547e..d8fad88 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/dao/SysDictDetailMapper.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/dao/SysDictDetailMapper.java @@ -1,6 +1,10 @@ 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.Param; + +import java.util.List; public interface SysDictDetailMapper { int deleteByPrimaryKey(Long detailId); @@ -11,6 +15,12 @@ public interface SysDictDetailMapper { SysDictDetail selectByPrimaryKey(Long detailId); + List selectByAll(); + + List selectByAllDetail(@Param("list") List dictId); + + List selectByDictId(@Param("dictId") Long dictId); + int updateByPrimaryKeySelective(SysDictDetail record); int updateByPrimaryKey(SysDictDetail record); diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbMerchantCouponMapper.java b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbMerchantCouponMapper.java new file mode 100644 index 0000000..572b1fa --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbMerchantCouponMapper.java @@ -0,0 +1,85 @@ +package com.chaozhanggui.system.cashierservice.dao; + +import com.chaozhanggui.system.cashierservice.entity.TbMerchantCoupon; +import org.apache.ibatis.annotations.Param; +import org.springframework.data.domain.Pageable; +import java.util.List; + +/** + * 优惠券(TbMerchantCoupon)表数据库访问层 + * + * @author lyf + * @since 2024-04-02 09:24:16 + */ +public interface TbMerchantCouponMapper { + + /** + * 通过ID查询单条数据 + * + * @param id 主键 + * @return 实例对象 + */ + TbMerchantCoupon queryById(Integer id); + + /** + * 查询指定行数据 + * + * @param tbMerchantCoupon 查询条件 + * @param pageable 分页对象 + * @return 对象列表 + */ + List queryAllByLimit(TbMerchantCoupon tbMerchantCoupon, @Param("pageable") Pageable pageable); + + + List queryAllByPage(@Param("page")Integer page, @Param("size")Integer size); + /** + * 统计总行数 + * + * @param tbMerchantCoupon 查询条件 + * @return 总行数 + */ + long count(TbMerchantCoupon tbMerchantCoupon); + + /** + * 新增数据 + * + * @param tbMerchantCoupon 实例对象 + * @return 影响行数 + */ + int insert(TbMerchantCoupon tbMerchantCoupon); + + /** + * 批量新增数据(MyBatis原生foreach方法) + * + * @param entities List 实例对象列表 + * @return 影响行数 + */ + int insertBatch(@Param("entities") List entities); + + /** + * 批量新增或按主键更新数据(MyBatis原生foreach方法) + * + * @param entities List 实例对象列表 + * @return 影响行数 + * @throws org.springframework.jdbc.BadSqlGrammarException 入参是空List的时候会抛SQL语句错误的异常,请自行校验入参 + */ + int insertOrUpdateBatch(@Param("entities") List entities); + + /** + * 修改数据 + * + * @param tbMerchantCoupon 实例对象 + * @return 影响行数 + */ + int update(TbMerchantCoupon tbMerchantCoupon); + + /** + * 通过主键删除数据 + * + * @param id 主键 + * @return 影响行数 + */ + int deleteById(Integer id); + +} + diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbProductMapper.java b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbProductMapper.java index a11ccb6..91c8f2b 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbProductMapper.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbProductMapper.java @@ -29,7 +29,7 @@ public interface TbProductMapper { List selectByIdIn(@Param("ids") String ids); - + List selectByIds(@Param("list") List ids); Integer selectByQcode(@Param("code") String code,@Param("productId") Integer productId,@Param("shopId") String shopId); Integer selectByNewQcode(@Param("code") String code,@Param("productId") Integer productId,@Param("shopId") String shopId,@Param("list") List list); } \ No newline at end of file diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbProductSkuMapper.java b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbProductSkuMapper.java index aaeecbb..018ec3e 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbProductSkuMapper.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbProductSkuMapper.java @@ -2,6 +2,7 @@ package com.chaozhanggui.system.cashierservice.dao; import com.chaozhanggui.system.cashierservice.entity.TbProductSku; import com.chaozhanggui.system.cashierservice.entity.TbProductSkuWithBLOBs; +import com.chaozhanggui.system.cashierservice.entity.vo.HomeVO; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; import org.springframework.stereotype.Component; @@ -20,7 +21,9 @@ public interface TbProductSkuMapper { TbProductSkuWithBLOBs selectByPrimaryKey(Integer id); Integer selectBySpecSnap(@Param("shopId")String shopId,@Param("tableId") Integer tableId,@Param("specSnap") String specSnap); int updateByPrimaryKeySelective(TbProductSkuWithBLOBs record); + List selectSale(); + List selectDay(); int updateByPrimaryKeyWithBLOBs(TbProductSkuWithBLOBs record); int updateByPrimaryKey(TbProductSku record); @@ -33,4 +36,6 @@ public interface TbProductSkuMapper { List selectAll(); List selectDownSku(@Param("list") List productId); + + List selectSkus(@Param("list") List productId); } \ No newline at end of file diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbShopInfoMapper.java b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbShopInfoMapper.java index 66d027e..7567a21 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbShopInfoMapper.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbShopInfoMapper.java @@ -19,6 +19,7 @@ public interface TbShopInfoMapper { int insertSelective(TbShopInfo record); TbShopInfo selectByPrimaryKey(Integer id); + List selectByIds(@Param("list") List ids); int updateByPrimaryKeySelective(TbShopInfo record); diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/SysDict.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/SysDict.java index 2317260..bc3797d 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/entity/SysDict.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/SysDict.java @@ -18,8 +18,18 @@ public class SysDict implements Serializable { private Date updateTime; + private Integer isChild; + private static final long serialVersionUID = 1L; + public Integer getIsChild() { + return isChild; + } + + public void setIsChild(Integer isChild) { + this.isChild = isChild; + } + public Long getDictId() { return dictId; } diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbMerchantCoupon.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbMerchantCoupon.java new file mode 100644 index 0000000..8e922e5 --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbMerchantCoupon.java @@ -0,0 +1,411 @@ +package com.chaozhanggui.system.cashierservice.entity; + +import java.util.Date; +import java.io.Serializable; + +/** + * 优惠券(TbMerchantCoupon)实体类 + * + * @author lyf + * @since 2024-04-02 09:22:41 + */ +public class TbMerchantCoupon implements Serializable { + private static final long serialVersionUID = 391103766508753856L; + /** + * 自增 + */ + private Integer id; + /** + * 状态0-关闭 1 正常 + */ + private Integer status; + /** + * 优惠券名称 + */ + private String title; + + private String templateId; + + private String shopId; + + private String shopSnap; + /** + * 开始时间 + */ + private Date fromTime; + /** + * 到期时间 + */ + private Date toTime; + /** + * 限领数量 + */ + private String limitNumber; + /** + * 发放数量 + */ + private Integer number; + /** + * 剩余数量 + */ + private String leftNumber; + /** + * 优惠金额 + */ + private Double amount; + /** + * 订单满赠金额 + */ + private Double limitAmount; + /** + * 是否显示0-不显示 1显示 + */ + private Integer isShow; + /** + * 图标 + */ + private String pic; + /** + * 0-满减 1-折扣 + */ + private Integer type; + /** + * 折扣 ,一位小数 + */ + private Float ratio; + /** + * 最大折扣金额 + */ + private Double maxRatioAmount; + /** + * 优惠券途径,首充|分销 + */ + private String track; + /** + * 品类product 商品券 ---cateogry 品类券common -通 用券 + */ + private String classType; + /** + * 有效期类型:0-toTime有效 1-effectDays有效 + */ + private Integer effectType; + /** + * 领取之日有效天数 + */ + private Integer effectDays; + /** + * 关联商品Id + */ + private String relationIds; + + private String relationList; + /** + * 发放人 + */ + private String editor; + /** + * 说明 + */ + private String note; + + private Long createdAt; + + private Long updatedAt; + /** + * 支持堂食 + */ + private Integer furnishMeal; + /** + * 支持配送 + */ + private Integer furnishExpress; + /** + * 支持自提 + */ + private Integer furnishDraw; + /** + * 支持虚拟 + */ + private Integer furnishVir; + + private Integer disableDistribute; + /** + * 商户Id + */ + private String merchantId; + + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public Integer getStatus() { + return status; + } + + public void setStatus(Integer status) { + this.status = status; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getTemplateId() { + return templateId; + } + + public void setTemplateId(String templateId) { + this.templateId = templateId; + } + + public String getShopId() { + return shopId; + } + + public void setShopId(String shopId) { + this.shopId = shopId; + } + + public String getShopSnap() { + return shopSnap; + } + + public void setShopSnap(String shopSnap) { + this.shopSnap = shopSnap; + } + + public Date getFromTime() { + return fromTime; + } + + public void setFromTime(Date fromTime) { + this.fromTime = fromTime; + } + + public Date getToTime() { + return toTime; + } + + public void setToTime(Date toTime) { + this.toTime = toTime; + } + + public String getLimitNumber() { + return limitNumber; + } + + public void setLimitNumber(String limitNumber) { + this.limitNumber = limitNumber; + } + + public Integer getNumber() { + return number; + } + + public void setNumber(Integer number) { + this.number = number; + } + + public String getLeftNumber() { + return leftNumber; + } + + public void setLeftNumber(String leftNumber) { + this.leftNumber = leftNumber; + } + + public Double getAmount() { + return amount; + } + + public void setAmount(Double amount) { + this.amount = amount; + } + + public Double getLimitAmount() { + return limitAmount; + } + + public void setLimitAmount(Double limitAmount) { + this.limitAmount = limitAmount; + } + + public Integer getIsShow() { + return isShow; + } + + public void setIsShow(Integer isShow) { + this.isShow = isShow; + } + + public String getPic() { + return pic; + } + + public void setPic(String pic) { + this.pic = pic; + } + + public Integer getType() { + return type; + } + + public void setType(Integer type) { + this.type = type; + } + + public Float getRatio() { + return ratio; + } + + public void setRatio(Float ratio) { + this.ratio = ratio; + } + + public Double getMaxRatioAmount() { + return maxRatioAmount; + } + + public void setMaxRatioAmount(Double maxRatioAmount) { + this.maxRatioAmount = maxRatioAmount; + } + + public String getTrack() { + return track; + } + + public void setTrack(String track) { + this.track = track; + } + + public String getClassType() { + return classType; + } + + public void setClassType(String classType) { + this.classType = classType; + } + + public Integer getEffectType() { + return effectType; + } + + public void setEffectType(Integer effectType) { + this.effectType = effectType; + } + + public Integer getEffectDays() { + return effectDays; + } + + public void setEffectDays(Integer effectDays) { + this.effectDays = effectDays; + } + + public String getRelationIds() { + return relationIds; + } + + public void setRelationIds(String relationIds) { + this.relationIds = relationIds; + } + + public String getRelationList() { + return relationList; + } + + public void setRelationList(String relationList) { + this.relationList = relationList; + } + + public String getEditor() { + return editor; + } + + public void setEditor(String editor) { + this.editor = editor; + } + + public String getNote() { + return note; + } + + public void setNote(String note) { + this.note = note; + } + + public Long getCreatedAt() { + return createdAt; + } + + public void setCreatedAt(Long createdAt) { + this.createdAt = createdAt; + } + + public Long getUpdatedAt() { + return updatedAt; + } + + public void setUpdatedAt(Long updatedAt) { + this.updatedAt = updatedAt; + } + + public Integer getFurnishMeal() { + return furnishMeal; + } + + public void setFurnishMeal(Integer furnishMeal) { + this.furnishMeal = furnishMeal; + } + + public Integer getFurnishExpress() { + return furnishExpress; + } + + public void setFurnishExpress(Integer furnishExpress) { + this.furnishExpress = furnishExpress; + } + + public Integer getFurnishDraw() { + return furnishDraw; + } + + public void setFurnishDraw(Integer furnishDraw) { + this.furnishDraw = furnishDraw; + } + + public Integer getFurnishVir() { + return furnishVir; + } + + public void setFurnishVir(Integer furnishVir) { + this.furnishVir = furnishVir; + } + + public Integer getDisableDistribute() { + return disableDistribute; + } + + public void setDisableDistribute(Integer disableDistribute) { + this.disableDistribute = disableDistribute; + } + + public String getMerchantId() { + return merchantId; + } + + public void setMerchantId(String merchantId) { + this.merchantId = merchantId; + } + +} + diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopInfo.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopInfo.java index c311e8a..54863e8 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopInfo.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopInfo.java @@ -91,6 +91,18 @@ public class TbShopInfo implements Serializable { private String proxyId; private String view; + /** + * 商家二维码 + */ + private String shopQrcode; + + public String getShopQrcode() { + return shopQrcode; + } + + public void setShopQrcode(String shopQrcode) { + this.shopQrcode = shopQrcode; + } private static final long serialVersionUID = 1L; diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/HomeDto.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/HomeDto.java index caaf363..abbcbbb 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/HomeDto.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/HomeDto.java @@ -18,7 +18,7 @@ public class HomeDto { */ private Integer orderBy; /** - * 附近1KM 1 0 + * 附近1KM 1选中 0未选中 */ private Integer distance; diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/DicDetailVO.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/DicDetailVO.java new file mode 100644 index 0000000..9de0cfa --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/DicDetailVO.java @@ -0,0 +1,50 @@ +package com.chaozhanggui.system.cashierservice.entity.vo; + +import com.chaozhanggui.system.cashierservice.entity.SysDictDetail; + +import java.util.List; + +/** + * @author lyf + */ +public class DicDetailVO { + private String name; + + private String description; + + private List detail; + + private Integer isChild; + + public Integer getIsChild() { + return isChild; + } + + public void setIsChild(Integer isChild) { + this.isChild = isChild; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public List getDetail() { + return detail; + } + + public void setDetail(List detail) { + this.detail = detail; + } +} diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/HomeUpVO.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/HomeUpVO.java index 0d45eac..b3104e2 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/HomeUpVO.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/HomeUpVO.java @@ -1,5 +1,6 @@ package com.chaozhanggui.system.cashierservice.entity.vo; +import com.chaozhanggui.system.cashierservice.entity.SysDict; import com.chaozhanggui.system.cashierservice.entity.TbPlatformDict; import lombok.Data; @@ -8,7 +9,7 @@ import java.util.List; /** * @author lyf */ -@Data + public class HomeUpVO { /** * 轮播图 @@ -18,5 +19,56 @@ public class HomeUpVO { * 金刚区 */ List district; + /** + * 条件查询 + */ + List menu; + /** + * 今日上新 + */ + TodayRankingVO todayList; + /** + * 销量飙升 + */ + HotRankingVO salesList; + public TodayRankingVO getTodayList() { + return todayList; + } + + public void setTodayList(TodayRankingVO todayList) { + this.todayList = todayList; + } + + public HotRankingVO getSalesList() { + return salesList; + } + + public void setSalesList(HotRankingVO salesList) { + this.salesList = salesList; + } + + public List getCarousel() { + return carousel; + } + + public void setCarousel(List carousel) { + this.carousel = carousel; + } + + public List getDistrict() { + return district; + } + + public void setDistrict(List district) { + this.district = district; + } + + public List getMenu() { + return menu; + } + + public void setMenu(List menu) { + this.menu = menu; + } } diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/HomeVO.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/HomeVO.java index de2d5fb..8e39f17 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/HomeVO.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/HomeVO.java @@ -10,10 +10,6 @@ public class HomeVO { * 店铺名称 */ private String shopName; - /** - * 距离 - */ - private String distance; /** * 商品名称 */ @@ -33,7 +29,7 @@ public class HomeVO { /** * 折扣 */ - private BigDecimal discount; + private Float discount; /** * 共省金额 */ @@ -45,6 +41,52 @@ public class HomeVO { private BigDecimal realSalesNumber; private Integer productId; + /** + * 店铺标签 + */ + private String shopTag; + /** + * 商品标签 + */ + private String proTag; + /** + * 距离 + */ + private String distances ="100"; + + private Integer id; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getDistances() { + return distances; + } + + public void setDistances(String distances) { + this.distances = distances; + } + + public String getShopTag() { + return shopTag; + } + + public void setShopTag(String shopTag) { + this.shopTag = shopTag; + } + + public String getProTag() { + return proTag; + } + + public void setProTag(String proTag) { + this.proTag = proTag; + } public Integer getProductId() { return productId; @@ -62,13 +104,6 @@ public class HomeVO { this.shopName = shopName; } - public String getDistance() { - return distance; - } - - public void setDistance(String distance) { - this.distance = distance; - } public String getProductName() { return productName; @@ -102,11 +137,11 @@ public class HomeVO { this.salePrice = salePrice; } - public BigDecimal getDiscount() { + public Float getDiscount() { return discount; } - public void setDiscount(BigDecimal discount) { + public void setDiscount(Float discount) { this.discount = discount; } diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/HotRankingVO.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/HotRankingVO.java new file mode 100644 index 0000000..d8d685e --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/HotRankingVO.java @@ -0,0 +1,40 @@ +package com.chaozhanggui.system.cashierservice.entity.vo; + +import java.util.List; + +/** + * @author lyf + */ +public class HotRankingVO { + /** + * 榜单名称 + */ + private String name = "飙升热榜"; + + private String Date = "8点更新"; + List hotList; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDate() { + return Date; + } + + public void setDate(String date) { + Date = date; + } + + public List getHotList() { + return hotList; + } + + public void setHotList(List hotList) { + this.hotList = hotList; + } +} diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/OrderVo.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/OrderVo.java index b40a451..b179b01 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/OrderVo.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/OrderVo.java @@ -17,6 +17,7 @@ public class OrderVo { private String status; private String tableName; + private String shopQrcode; private List details; diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/TodayRankingVO.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/TodayRankingVO.java new file mode 100644 index 0000000..c0f19cc --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/TodayRankingVO.java @@ -0,0 +1,40 @@ +package com.chaozhanggui.system.cashierservice.entity.vo; + +import java.util.List; + +/** + * @author lyf + */ +public class TodayRankingVO { + /** + * 榜单名称 + */ + private String name = "今日上新"; + + private String Date = "10点更新"; + List todayList; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDate() { + return Date; + } + + public void setDate(String date) { + Date = date; + } + + public List getTodayList() { + return todayList; + } + + public void setTodayList(List todayList) { + this.todayList = todayList; + } +} diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/HomePageService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/HomePageService.java index 1478255..046a935 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/HomePageService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/HomePageService.java @@ -1,16 +1,12 @@ package com.chaozhanggui.system.cashierservice.service; -import com.chaozhanggui.system.cashierservice.dao.TbPlatformDictMapper; -import com.chaozhanggui.system.cashierservice.dao.TbProductSkuMapper; -import com.chaozhanggui.system.cashierservice.dao.TbShopInfoMapper; -import com.chaozhanggui.system.cashierservice.entity.TbPlatformDict; -import com.chaozhanggui.system.cashierservice.entity.TbProductSku; +import com.chaozhanggui.system.cashierservice.dao.*; +import com.chaozhanggui.system.cashierservice.entity.*; import com.chaozhanggui.system.cashierservice.entity.dto.HomeDto; -import com.chaozhanggui.system.cashierservice.entity.vo.HomeUpVO; -import com.chaozhanggui.system.cashierservice.entity.vo.HomeVO; -import com.chaozhanggui.system.cashierservice.entity.vo.UserDutyVo; +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.Threads; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; @@ -19,6 +15,8 @@ import java.math.BigDecimal; import java.math.RoundingMode; import java.util.ArrayList; import java.util.List; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutionException; /** * @author lyf @@ -32,52 +30,79 @@ public class HomePageService { private TbProductSkuMapper productSkuMapper; @Resource private TbPlatformDictMapper platformDictMapper; + @Resource + private TbMerchantCouponMapper merchantCouponMapper; + @Resource + private TbProductMapper productMapper; + @Resource + private SysDictDetailMapper sysDictDetailMapper; - public Result homePage(HomeDto homeDto){ + public Result homePage(HomeDto homeDto,String environmen) throws ExecutionException, InterruptedException { int beginNo; if(homeDto.getPage() <=0){ beginNo = 0; }else{ beginNo = (homeDto.getPage() - 1) * homeDto.getSize(); } - List homeVO = shopInfoMapper.selectShopInfo(beginNo,homeDto.getSize()); - List objects = new ArrayList<>(); - for (HomeVO o :homeVO) { - objects.add(o.getProductId()); + //优惠卷 + List tbMerchantCoupons = merchantCouponMapper.queryAllByPage(beginNo, homeDto.getSize()); + //统计shopId,以及productId + List shopIds = new ArrayList<>(); + List productIds = new ArrayList<>(); + for (TbMerchantCoupon coupon : tbMerchantCoupons) { + shopIds.add(coupon.getShopId()); + productIds.add(coupon.getRelationIds()); } - //原价现价 - List tbProductSkus = productSkuMapper.selectDownSku(objects); - //销量 - List userDutyVos = shopInfoMapper.searchUserDutyDetail(objects); - //组装数据 - for (HomeVO o :homeVO) { - for (TbProductSku sku :tbProductSkus) { - if (o.getProductId().toString().equals(sku.getProductId())){ - o.setOriginPrice(sku.getOriginPrice() == null?BigDecimal.ZERO:sku.getOriginPrice()); - o.setSalePrice(sku.getSalePrice() == null?BigDecimal.ZERO:sku.getSalePrice()); + CompletableFuture> shopInfo = CompletableFuture.supplyAsync(() -> + shopInfoMapper.selectByIds(shopIds)); + CompletableFuture> product = CompletableFuture.supplyAsync(() -> + productMapper.selectByIds((productIds))); + CompletableFuture> productSku = CompletableFuture.supplyAsync(() -> + productSkuMapper.selectSkus((productIds))); + CompletableFuture> dictPro = CompletableFuture.supplyAsync(() -> + platformDictMapper.queryAllByType("proTag",environmen)); + CompletableFuture> dictShop = CompletableFuture.supplyAsync(() -> + platformDictMapper.queryAllByType("shopTag",environmen)); + Threads.call(shopInfo,product,productSku,dictPro,dictShop); + boolean isFirstAdded = true; + //组装 + List 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()); } } - if (userDutyVos == null){ - o.setRealSalesNumber(BigDecimal.ZERO); - }else { - for (UserDutyVo duty : userDutyVos) { - if (o.getProductId().equals(duty.getProductId())) { - o.setRealSalesNumber(duty.getNumber()); - }else { - o.setRealSalesNumber(BigDecimal.ZERO); - } + for (TbProduct tbProduct :product.get()) { + if (o.getRelationIds().equals(tbProduct.getId().toString())) { + homeVO.setProductName(tbProduct.getName()); + homeVO.setImage(tbProduct.getCoverImg()); + homeVO.setId(tbProduct.getId()); } } - //共省金额 - o.setSave(o.getOriginPrice().subtract(o.getSalePrice())); - if (o.getOriginPrice().compareTo(BigDecimal.ZERO) == 0){ - o.setDiscount(null); - }else { - o.setDiscount(o.getSalePrice().divide(o.getOriginPrice(), 2, RoundingMode.DOWN).multiply(new BigDecimal("10"))); + for (TbProductSku tbProductSku :productSku.get()) { + if (o.getRelationIds().equals(tbProductSku.getProductId())) { + homeVO.setOriginPrice(tbProductSku.getSalePrice()); + homeVO.setRealSalesNumber(tbProductSku.getRealSalesNumber() == null?BigDecimal.ZERO: new BigDecimal(tbProductSku.getRealSalesNumber())); + Float discount = homeVO.getDiscount(); + BigDecimal discountDecimal = new BigDecimal(discount); + homeVO.setSalePrice(tbProductSku.getSalePrice().multiply((discountDecimal.multiply(new BigDecimal("0.1"))))); + homeVO.setSave(homeVO.getOriginPrice().subtract(homeVO.getSalePrice())); + } } + homeVOList.add(homeVO); } - return Result.success(CodeEnum.SUCCESS,homeVO); + + return Result.success(CodeEnum.SUCCESS,homeVOList); } public Result homePageUp(String environment){ @@ -88,6 +113,44 @@ public class HomePageService { //金刚区 List districtList = platformDictMapper.queryAllByType("homeDistrict",environment); homeUpVO.setDistrict(districtList); + //菜单 + List sysDicts = sysDictDetailMapper.selectByAll(); + List dicDetailVO = new ArrayList<>(); + for (SysDict sysDictsList : sysDicts) { + DicDetailVO dicDetailVOList = new DicDetailVO(); + dicDetailVOList.setName(sysDictsList.getName()); + dicDetailVOList.setDescription(sysDictsList.getDescription()); + dicDetailVOList.setDetail(sysDictDetailMapper.selectByDictId(sysDictsList.getDictId())); + dicDetailVOList.setIsChild(sysDictsList.getIsChild()); + dicDetailVO.add(dicDetailVOList); + } + homeUpVO.setMenu(dicDetailVO); + /** + * 销量榜 + */ + List homeVOs = productSkuMapper.selectSale(); + for (HomeVO o : homeVOs) { + BigDecimal originPrice = o.getOriginPrice(); + if (originPrice.compareTo(BigDecimal.ZERO)!= 0){ + BigDecimal multiply = o.getSalePrice().divide(o.getOriginPrice(),2,RoundingMode.DOWN).multiply(BigDecimal.TEN); + o.setDiscount(multiply.floatValue()); + }else { + o.setDiscount(null); + } + } + + HotRankingVO hotRankingVO = new HotRankingVO(); + hotRankingVO.setHotList(homeVOs); + homeUpVO.setSalesList(hotRankingVO); + /** + *每日榜 + */ + List homeVODay = productSkuMapper.selectDay(); + TodayRankingVO todayRankingVO = new TodayRankingVO(); + todayRankingVO.setTodayList(homeVODay); + homeUpVO.setTodayList(todayRankingVO); return Result.success(CodeEnum.SUCCESS,homeUpVO); } + + } diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/OrderService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/OrderService.java index 08cb26d..33463dd 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/OrderService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/OrderService.java @@ -165,7 +165,8 @@ public class OrderService { OrderVo orderVo = new OrderVo(); orderVo.setName(tbShopInfo.getShopName()); orderVo.setStatus(orderInfo.getStatus()); - + //TODO 增加商家二维码 + orderVo.setShopQrcode(tbShopInfo.getShopQrcode()); orderVo.setDetails(details); orderVo.setOrderNo(orderInfo.getOrderNo()); orderVo.setTime(orderInfo.getCreatedAt()); diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/util/Threads.java b/src/main/java/com/chaozhanggui/system/cashierservice/util/Threads.java new file mode 100644 index 0000000..a8696c6 --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/util/Threads.java @@ -0,0 +1,114 @@ +package com.chaozhanggui.system.cashierservice.util; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.concurrent.*; + +/** + * 线程相关工具类. + * + * @author ruoyi + */ +public class Threads +{ + private static final Logger logger = LoggerFactory.getLogger(Threads.class); + + /** + * sleep等待,单位为毫秒 + */ + public static void sleep(long milliseconds) + { + try + { + Thread.sleep(milliseconds); + } + catch (InterruptedException e) + { + return; + } + } + + /** + * 停止线程池 + * 先使用shutdown, 停止接收新任务并尝试完成所有已存在任务. + * 如果超时, 则调用shutdownNow, 取消在workQueue中Pending的任务,并中断所有阻塞函数. + * 如果仍然超時,則強制退出. + * 另对在shutdown时线程本身被调用中断做了处理. + */ + public static void shutdownAndAwaitTermination(ExecutorService pool) + { + if (pool != null && !pool.isShutdown()) + { + pool.shutdown(); + try + { + if (!pool.awaitTermination(120, TimeUnit.SECONDS)) + { + pool.shutdownNow(); + if (!pool.awaitTermination(120, TimeUnit.SECONDS)) + { + logger.info("Pool did not terminate"); + } + } + } + catch (InterruptedException ie) + { + pool.shutdownNow(); + Thread.currentThread().interrupt(); + } + } + } + + /** + * 打印线程异常信息 + */ + public static void printException(Runnable r, Throwable t) + { + if (t == null && r instanceof Future) + { + try + { + Future future = (Future) r; + if (future.isDone()) + { + future.get(); + } + } + catch (CancellationException ce) + { + t = ce; + } + catch (ExecutionException ee) + { + t = ee.getCause(); + } + catch (InterruptedException ie) + { + Thread.currentThread().interrupt(); + } + } + if (t != null) + { + logger.error(t.getMessage(), t); + } + } + + /** + * 并行调用 + * @param value + * @return + */ + public static CompletableFuture parallel(T value){ + return CompletableFuture.supplyAsync(() -> + value); + } + + /** + * 并行执行 + * @param cfs + */ + public static void call(CompletableFuture... cfs){ + CompletableFuture.allOf(cfs); + } +} diff --git a/src/main/resources/mapper/SysDictDetailMapper.xml b/src/main/resources/mapper/SysDictDetailMapper.xml index 273765a..4fb74ac 100644 --- a/src/main/resources/mapper/SysDictDetailMapper.xml +++ b/src/main/resources/mapper/SysDictDetailMapper.xml @@ -21,6 +21,20 @@ from sys_dict_detail where detail_id = #{detailId,jdbcType=BIGINT} + + + delete from sys_dict_detail where detail_id = #{detailId,jdbcType=BIGINT} diff --git a/src/main/resources/mapper/TbMerchantCouponMapper.xml b/src/main/resources/mapper/TbMerchantCouponMapper.xml new file mode 100644 index 0000000..5dbcdc5 --- /dev/null +++ b/src/main/resources/mapper/TbMerchantCouponMapper.xml @@ -0,0 +1,449 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + insert into tb_merchant_coupon(status, title, template_id, shop_id, shop_snap, from_time, to_time, limit_number, number, left_number, amount, limit_amount, is_show, pic, type, ratio, max_ratio_amount, track, class_type, effect_type, effect_days, relation_ids, relation_list, editor, note, created_at, updated_at, furnish_meal, furnish_express, furnish_draw, furnish_vir, disable_distribute, merchant_id) + values (#{status}, #{title}, #{templateId}, #{shopId}, #{shopSnap}, #{fromTime}, #{toTime}, #{limitNumber}, #{number}, #{leftNumber}, #{amount}, #{limitAmount}, #{isShow}, #{pic}, #{type}, #{ratio}, #{maxRatioAmount}, #{track}, #{classType}, #{effectType}, #{effectDays}, #{relationIds}, #{relationList}, #{editor}, #{note}, #{createdAt}, #{updatedAt}, #{furnishMeal}, #{furnishExpress}, #{furnishDraw}, #{furnishVir}, #{disableDistribute}, #{merchantId}) + + + + insert into tb_merchant_coupon(status, title, template_id, shop_id, shop_snap, from_time, to_time, limit_number, number, left_number, amount, limit_amount, is_show, pic, type, ratio, max_ratio_amount, track, class_type, effect_type, effect_days, relation_ids, relation_list, editor, note, created_at, updated_at, furnish_meal, furnish_express, furnish_draw, furnish_vir, disable_distribute, merchant_id) + values + + (#{entity.status}, #{entity.title}, #{entity.templateId}, #{entity.shopId}, #{entity.shopSnap}, #{entity.fromTime}, #{entity.toTime}, #{entity.limitNumber}, #{entity.number}, #{entity.leftNumber}, #{entity.amount}, #{entity.limitAmount}, #{entity.isShow}, #{entity.pic}, #{entity.type}, #{entity.ratio}, #{entity.maxRatioAmount}, #{entity.track}, #{entity.classType}, #{entity.effectType}, #{entity.effectDays}, #{entity.relationIds}, #{entity.relationList}, #{entity.editor}, #{entity.note}, #{entity.createdAt}, #{entity.updatedAt}, #{entity.furnishMeal}, #{entity.furnishExpress}, #{entity.furnishDraw}, #{entity.furnishVir}, #{entity.disableDistribute}, #{entity.merchantId}) + + + + + insert into tb_merchant_coupon(status, title, template_id, shop_id, shop_snap, from_time, to_time, limit_number, number, left_number, amount, limit_amount, is_show, pic, type, ratio, max_ratio_amount, track, class_type, effect_type, effect_days, relation_ids, relation_list, editor, note, created_at, updated_at, furnish_meal, furnish_express, furnish_draw, furnish_vir, disable_distribute, merchant_id) + values + + (#{entity.status}, #{entity.title}, #{entity.templateId}, #{entity.shopId}, #{entity.shopSnap}, #{entity.fromTime}, #{entity.toTime}, #{entity.limitNumber}, #{entity.number}, #{entity.leftNumber}, #{entity.amount}, #{entity.limitAmount}, #{entity.isShow}, #{entity.pic}, #{entity.type}, #{entity.ratio}, #{entity.maxRatioAmount}, #{entity.track}, #{entity.classType}, #{entity.effectType}, #{entity.effectDays}, #{entity.relationIds}, #{entity.relationList}, #{entity.editor}, #{entity.note}, #{entity.createdAt}, #{entity.updatedAt}, #{entity.furnishMeal}, #{entity.furnishExpress}, #{entity.furnishDraw}, #{entity.furnishVir}, #{entity.disableDistribute}, #{entity.merchantId}) + + on duplicate key update + status = values(status), + title = values(title), + template_id = values(template_id), + shop_id = values(shop_id), + shop_snap = values(shop_snap), + from_time = values(from_time), + to_time = values(to_time), + limit_number = values(limit_number), + number = values(number), + left_number = values(left_number), + amount = values(amount), + limit_amount = values(limit_amount), + is_show = values(is_show), + pic = values(pic), + type = values(type), + ratio = values(ratio), + max_ratio_amount = values(max_ratio_amount), + track = values(track), + class_type = values(class_type), + effect_type = values(effect_type), + effect_days = values(effect_days), + relation_ids = values(relation_ids), + relation_list = values(relation_list), + editor = values(editor), + note = values(note), + created_at = values(created_at), + updated_at = values(updated_at), + furnish_meal = values(furnish_meal), + furnish_express = values(furnish_express), + furnish_draw = values(furnish_draw), + furnish_vir = values(furnish_vir), + disable_distribute = values(disable_distribute), + merchant_id = values(merchant_id) + + + + + update tb_merchant_coupon + + + status = #{status}, + + + title = #{title}, + + + template_id = #{templateId}, + + + shop_id = #{shopId}, + + + shop_snap = #{shopSnap}, + + + from_time = #{fromTime}, + + + to_time = #{toTime}, + + + limit_number = #{limitNumber}, + + + number = #{number}, + + + left_number = #{leftNumber}, + + + amount = #{amount}, + + + limit_amount = #{limitAmount}, + + + is_show = #{isShow}, + + + pic = #{pic}, + + + type = #{type}, + + + ratio = #{ratio}, + + + max_ratio_amount = #{maxRatioAmount}, + + + track = #{track}, + + + class_type = #{classType}, + + + effect_type = #{effectType}, + + + effect_days = #{effectDays}, + + + relation_ids = #{relationIds}, + + + relation_list = #{relationList}, + + + editor = #{editor}, + + + note = #{note}, + + + created_at = #{createdAt}, + + + updated_at = #{updatedAt}, + + + furnish_meal = #{furnishMeal}, + + + furnish_express = #{furnishExpress}, + + + furnish_draw = #{furnishDraw}, + + + furnish_vir = #{furnishVir}, + + + disable_distribute = #{disableDistribute}, + + + merchant_id = #{merchantId}, + + + where id = #{id} + + + + + delete from tb_merchant_coupon where id = #{id} + + + + diff --git a/src/main/resources/mapper/TbPlatformDictMapper.xml b/src/main/resources/mapper/TbPlatformDictMapper.xml index fa4182b..bac90db 100644 --- a/src/main/resources/mapper/TbPlatformDictMapper.xml +++ b/src/main/resources/mapper/TbPlatformDictMapper.xml @@ -143,12 +143,12 @@ type = #{type} - - and is_show_mall = 1 - - + and is_show_app = 1 + + and is_show_mall = 1 + diff --git a/src/main/resources/mapper/TbProductMapper.xml b/src/main/resources/mapper/TbProductMapper.xml index 41f3706..3940301 100644 --- a/src/main/resources/mapper/TbProductMapper.xml +++ b/src/main/resources/mapper/TbProductMapper.xml @@ -886,7 +886,6 @@ select * from tb_product where id in (${ids}) and is_show_mall =1 - + \ No newline at end of file diff --git a/src/main/resources/mapper/TbProductSkuMapper.xml b/src/main/resources/mapper/TbProductSkuMapper.xml index 969e918..2f30e56 100644 --- a/src/main/resources/mapper/TbProductSkuMapper.xml +++ b/src/main/resources/mapper/TbProductSkuMapper.xml @@ -368,6 +368,53 @@ GROUP BY product_id + + + \ No newline at end of file diff --git a/src/main/resources/mapper/TbShopInfoMapper.xml b/src/main/resources/mapper/TbShopInfoMapper.xml index 0634beb..a16fbc7 100644 --- a/src/main/resources/mapper/TbShopInfoMapper.xml +++ b/src/main/resources/mapper/TbShopInfoMapper.xml @@ -68,6 +68,9 @@ from tb_shop_info where id = #{id,jdbcType=INTEGER} + + + delete from tb_shop_info where id = #{id,jdbcType=INTEGER} @@ -644,4 +647,15 @@ GROUP BY product_id + \ No newline at end of file