This commit is contained in:
19991905653
2024-04-09 09:11:12 +08:00
26 changed files with 1529 additions and 67 deletions

View File

@@ -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){

View File

@@ -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<SysDict> selectByAll();
List<SysDictDetail> selectByAllDetail(@Param("list") List<Long> dictId);
List<SysDictDetail> selectByDictId(@Param("dictId") Long dictId);
int updateByPrimaryKeySelective(SysDictDetail record);
int updateByPrimaryKey(SysDictDetail record);

View File

@@ -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<TbMerchantCoupon> queryAllByLimit(TbMerchantCoupon tbMerchantCoupon, @Param("pageable") Pageable pageable);
List<TbMerchantCoupon> 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<TbMerchantCoupon> 实例对象列表
* @return 影响行数
*/
int insertBatch(@Param("entities") List<TbMerchantCoupon> entities);
/**
* 批量新增或按主键更新数据MyBatis原生foreach方法
*
* @param entities List<TbMerchantCoupon> 实例对象列表
* @return 影响行数
* @throws org.springframework.jdbc.BadSqlGrammarException 入参是空List的时候会抛SQL语句错误的异常请自行校验入参
*/
int insertOrUpdateBatch(@Param("entities") List<TbMerchantCoupon> entities);
/**
* 修改数据
*
* @param tbMerchantCoupon 实例对象
* @return 影响行数
*/
int update(TbMerchantCoupon tbMerchantCoupon);
/**
* 通过主键删除数据
*
* @param id 主键
* @return 影响行数
*/
int deleteById(Integer id);
}

View File

@@ -29,7 +29,7 @@ public interface TbProductMapper {
List<TbProduct> selectByIdIn(@Param("ids") String ids);
List<TbProduct> selectByIds(@Param("list") List<String> 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<String> list);
}

View File

@@ -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<HomeVO> selectSale();
List<HomeVO> selectDay();
int updateByPrimaryKeyWithBLOBs(TbProductSkuWithBLOBs record);
int updateByPrimaryKey(TbProductSku record);
@@ -33,4 +36,6 @@ public interface TbProductSkuMapper {
List<TbProductSku> selectAll();
List<TbProductSku> selectDownSku(@Param("list") List<Integer> productId);
List<TbProductSku> selectSkus(@Param("list") List<String> productId);
}

View File

@@ -19,6 +19,7 @@ public interface TbShopInfoMapper {
int insertSelective(TbShopInfo record);
TbShopInfo selectByPrimaryKey(Integer id);
List<TbShopInfo> selectByIds(@Param("list") List<String> ids);
int updateByPrimaryKeySelective(TbShopInfo record);

View File

@@ -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;
}

View File

@@ -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;
}
}

View File

@@ -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;

View File

@@ -18,7 +18,7 @@ public class HomeDto {
*/
private Integer orderBy;
/**
* 附近1KM 1 0
* 附近1KM 1选中 0未选中
*/
private Integer distance;

View File

@@ -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<SysDictDetail> 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<SysDictDetail> getDetail() {
return detail;
}
public void setDetail(List<SysDictDetail> detail) {
this.detail = detail;
}
}

View File

@@ -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<TbPlatformDict> district;
/**
* 条件查询
*/
List<DicDetailVO> 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<TbPlatformDict> getCarousel() {
return carousel;
}
public void setCarousel(List<TbPlatformDict> carousel) {
this.carousel = carousel;
}
public List<TbPlatformDict> getDistrict() {
return district;
}
public void setDistrict(List<TbPlatformDict> district) {
this.district = district;
}
public List<DicDetailVO> getMenu() {
return menu;
}
public void setMenu(List<DicDetailVO> menu) {
this.menu = menu;
}
}

View File

@@ -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;
}

View File

@@ -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<HomeVO> 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<HomeVO> getHotList() {
return hotList;
}
public void setHotList(List<HomeVO> hotList) {
this.hotList = hotList;
}
}

View File

@@ -17,6 +17,7 @@ public class OrderVo {
private String status;
private String tableName;
private String shopQrcode;
private List<TbOrderDetail> details;

View File

@@ -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<HomeVO> 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<HomeVO> getTodayList() {
return todayList;
}
public void setTodayList(List<HomeVO> todayList) {
this.todayList = todayList;
}
}

View File

@@ -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> homeVO = shopInfoMapper.selectShopInfo(beginNo,homeDto.getSize());
List<Integer> objects = new ArrayList<>();
for (HomeVO o :homeVO) {
objects.add(o.getProductId());
//优惠卷
List<TbMerchantCoupon> tbMerchantCoupons = merchantCouponMapper.queryAllByPage(beginNo, homeDto.getSize());
//统计shopId以及productId
List<String> shopIds = new ArrayList<>();
List<String> productIds = new ArrayList<>();
for (TbMerchantCoupon coupon : tbMerchantCoupons) {
shopIds.add(coupon.getShopId());
productIds.add(coupon.getRelationIds());
}
//原价现价
List<TbProductSku> tbProductSkus = productSkuMapper.selectDownSku(objects);
//销量
List<UserDutyVo> 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<List<TbShopInfo>> shopInfo = CompletableFuture.supplyAsync(() ->
shopInfoMapper.selectByIds(shopIds));
CompletableFuture<List<TbProduct>> product = CompletableFuture.supplyAsync(() ->
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;
//组装
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());
}
}
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<TbPlatformDict> districtList = platformDictMapper.queryAllByType("homeDistrict",environment);
homeUpVO.setDistrict(districtList);
//菜单
List<SysDict> sysDicts = sysDictDetailMapper.selectByAll();
List<DicDetailVO> 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<HomeVO> 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<HomeVO> homeVODay = productSkuMapper.selectDay();
TodayRankingVO todayRankingVO = new TodayRankingVO();
todayRankingVO.setTodayList(homeVODay);
homeUpVO.setTodayList(todayRankingVO);
return Result.success(CodeEnum.SUCCESS,homeUpVO);
}
}

View File

@@ -185,7 +185,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());

View File

@@ -125,12 +125,13 @@ public class FeieyunPrintUtil {
if(productName.length()>4||remark.length()>4){
builder.append("<B><BOLD>"+productName+" "+number+"</BOLD></B><BR><BR>");
builder.append("<B><BOLD>"+remark+" </BOLD></B><BR>");
builder.append("<B><BOLD>"+remark+" </BOLD></B><BR><BR><BR>");
}else {
builder.append("<B><BOLD>"+productName+" "+number+"</BOLD></B><BR><BR>");
builder.append("<B><BOLD>"+remark+" </BOLD></B><BR>");
builder.append("<B><BOLD>"+remark+" </BOLD></B><BR><BR><BR>");
}
builder.append("<CUT>");
// builder.append("<CUT>");
String content=builder.toString();

View File

@@ -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 <T> CompletableFuture<T> parallel(T value){
return CompletableFuture.supplyAsync(() ->
value);
}
/**
* 并行执行
* @param cfs
*/
public static void call(CompletableFuture<?>... cfs){
CompletableFuture.allOf(cfs);
}
}