From 22bb4c6d15bc3fea998cc7de520c7722ed717eb8 Mon Sep 17 00:00:00 2001 From: liuyingfang <1357764963@qq.com> Date: Mon, 8 Apr 2024 17:35:32 +0800 Subject: [PATCH 01/13] =?UTF-8?q?=E9=A6=96=E9=A1=B5=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dao/SysDictDetailMapper.java | 4 + .../dao/TagProductDeptsMapper.java | 91 ++++++++++++++ .../entity/TagProductDepts.java | 53 ++++++++ .../cashierservice/entity/TbShopInfo.java | 12 ++ .../cashierservice/entity/vo/HomeVO.java | 16 +++ .../entity/vo/TagProductVO.java | 34 +++++ .../service/HomePageService.java | 28 +++-- .../system/cashierservice/util/DateUtils.java | 35 ++++++ .../mapper/TagProductDeptsMapper.xml | 117 ++++++++++++++++++ .../resources/mapper/TbShopInfoMapper.xml | 2 +- 10 files changed, 380 insertions(+), 12 deletions(-) create mode 100644 src/main/java/com/chaozhanggui/system/cashierservice/dao/TagProductDeptsMapper.java create mode 100644 src/main/java/com/chaozhanggui/system/cashierservice/entity/TagProductDepts.java create mode 100644 src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/TagProductVO.java create mode 100644 src/main/resources/mapper/TagProductDeptsMapper.xml 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 d8fad88..70a1981 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/dao/SysDictDetailMapper.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/dao/SysDictDetailMapper.java @@ -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); diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TagProductDeptsMapper.java b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TagProductDeptsMapper.java new file mode 100644 index 0000000..0b63548 --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TagProductDeptsMapper.java @@ -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 queryAllByLimit(TagProductDepts tagProductDepts, @Param("pageable") Pageable pageable); + + List queryTagAndProduct(@Param("list") List list); + + /** + * 统计总行数 + * + * @param tagProductDepts 查询条件 + * @return 总行数 + */ + long count(TagProductDepts tagProductDepts); + + /** + * 新增数据 + * + * @param tagProductDepts 实例对象 + * @return 影响行数 + */ + int insert(TagProductDepts tagProductDepts); + + /** + * 批量新增数据(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 tagProductDepts 实例对象 + * @return 影响行数 + */ + int update(TagProductDepts tagProductDepts); + + /** + * 通过主键删除数据 + * + * @param tagId 主键 + * @return 影响行数 + */ + int deleteById(Integer tagId); + +} + diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TagProductDepts.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TagProductDepts.java new file mode 100644 index 0000000..37e6904 --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TagProductDepts.java @@ -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; + } + +} + 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 54863e8..f257a2b 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopInfo.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopInfo.java @@ -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; 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 8e39f17..bd9350b 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 @@ -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; diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/TagProductVO.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/TagProductVO.java new file mode 100644 index 0000000..939d5cc --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/TagProductVO.java @@ -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; + } +} 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 046a935..9fa2e6d 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/HomePageService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/HomePageService.java @@ -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 shopIds = new ArrayList<>(); List productIds = new ArrayList<>(); + List productIdsInt = new ArrayList<>(); for (TbMerchantCoupon coupon : tbMerchantCoupons) { shopIds.add(coupon.getShopId()); productIds.add(coupon.getRelationIds()); + productIdsInt.add(Integer.valueOf(coupon.getRelationIds())); } CompletableFuture> shopInfo = CompletableFuture.supplyAsync(() -> shopInfoMapper.selectByIds(shopIds)); @@ -60,26 +65,21 @@ public class HomePageService { 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; + CompletableFuture> dictPro = CompletableFuture.supplyAsync(() -> + tagProductDeptsMapper.queryTagAndProduct(productIdsInt)); + Threads.call(shopInfo,product,productSku,dictPro); + //组装 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()); + 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); } diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/util/DateUtils.java b/src/main/java/com/chaozhanggui/system/cashierservice/util/DateUtils.java index 040b90e..2b57fa2 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/util/DateUtils.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/util/DateUtils.java @@ -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 diff --git a/src/main/resources/mapper/TagProductDeptsMapper.xml b/src/main/resources/mapper/TagProductDeptsMapper.xml new file mode 100644 index 0000000..17e44e5 --- /dev/null +++ b/src/main/resources/mapper/TagProductDeptsMapper.xml @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + insert into tag_product_depts(product_id, create_time) + values (#{productId}, #{createTime}) + + + + insert into tag_product_depts(product_id, create_time) + values + + (#{entity.productId}, #{entity.createTime}) + + + + + insert into tag_product_depts(product_id, create_time) + values + + (#{entity.productId}, #{entity.createTime}) + + on duplicate key update + product_id = values(product_id), + create_time = values(create_time) + + + + + update tag_product_depts + + + product_id = #{productId}, + + + create_time = #{createTime}, + + + where tag_id = #{tagId} + + + + + delete from tag_product_depts where tag_id = #{tagId} + + + + diff --git a/src/main/resources/mapper/TbShopInfoMapper.xml b/src/main/resources/mapper/TbShopInfoMapper.xml index a16fbc7..e5635e9 100644 --- a/src/main/resources/mapper/TbShopInfoMapper.xml +++ b/src/main/resources/mapper/TbShopInfoMapper.xml @@ -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 view From d2550475b48088211b3673626ddab3ab3d74bdcc Mon Sep 17 00:00:00 2001 From: wangw <1594593906@qq.com> Date: Mon, 8 Apr 2024 17:51:10 +0800 Subject: [PATCH 02/13] =?UTF-8?q?=E5=85=A8=E5=B1=80=E8=B7=A8=E5=9F=9F?= =?UTF-8?q?=E5=A4=84=E7=90=86=20=E5=AD=97=E5=85=B8isChild=20=E5=9B=9E?= =?UTF-8?q?=E6=98=BE=20=E5=AD=97=E5=85=B8=E6=A0=87=E7=AD=BE=E5=9B=9E?= =?UTF-8?q?=E6=98=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cashierservice/config/CorsFilter.java | 2 +- .../dao/TbMerchantCouponMapper.java | 5 +++ .../system/cashierservice/entity/SysDict.java | 9 +++++ .../cashierservice/entity/vo/DicDetailVO.java | 15 +++++++-- .../service/HomePageService.java | 33 ++++++++++--------- .../cashierservice/util/LocationUtils.java | 2 +- 6 files changed, 45 insertions(+), 21 deletions(-) diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/config/CorsFilter.java b/src/main/java/com/chaozhanggui/system/cashierservice/config/CorsFilter.java index 31e33e6..7285a31 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/config/CorsFilter.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/config/CorsFilter.java @@ -28,7 +28,7 @@ public class CorsFilter implements Filter { response.setHeader("Access-Control-Allow-Origin", curOrigin == null ? "true" : curOrigin); response.setHeader("Access-Control-Allow-Methods", "*"); response.setHeader("Access-Control-Max-Age", "3600"); - response.setHeader("Access-Control-Allow-Headers", "x-requested-with,signature"); + response.setHeader("Access-Control-Allow-Headers", "environment,type,version,token"); response.setHeader("Access-Control-Allow-Credentials", "true"); chain.doFilter(req, resp); } diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbMerchantCouponMapper.java b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbMerchantCouponMapper.java index 572b1fa..96c03c3 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbMerchantCouponMapper.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbMerchantCouponMapper.java @@ -1,8 +1,11 @@ package com.chaozhanggui.system.cashierservice.dao; import com.chaozhanggui.system.cashierservice.entity.TbMerchantCoupon; +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; /** @@ -11,6 +14,8 @@ import java.util.List; * @author lyf * @since 2024-04-02 09:24:16 */ +@Component +@Mapper public interface TbMerchantCouponMapper { /** 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 bc3797d..533f143 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/entity/SysDict.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/SysDict.java @@ -5,6 +5,7 @@ import java.util.Date; public class SysDict implements Serializable { private Long dictId; + private String dictName; private String name; @@ -22,6 +23,14 @@ public class SysDict implements Serializable { private static final long serialVersionUID = 1L; + public String getDictName() { + return dictName; + } + + public void setDictName(String dictName) { + this.dictName = dictName; + } + public Integer getIsChild() { return isChild; } 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 index 9de0cfa..aa84863 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/DicDetailVO.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/DicDetailVO.java @@ -9,18 +9,27 @@ import java.util.List; */ public class DicDetailVO { private String name; + private String dictName; private String description; private List detail; - private Integer isChild; + private Boolean isChild; - public Integer getIsChild() { + public String getDictName() { + return dictName; + } + + public void setDictName(String dictName) { + this.dictName = dictName; + } + + public Boolean getIsChild() { return isChild; } - public void setIsChild(Integer isChild) { + public void setIsChild(Boolean isChild) { this.isChild = isChild; } 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 9fa2e6d..bc82814 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/HomePageService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/HomePageService.java @@ -41,11 +41,11 @@ public class HomePageService { private TagProductDeptsMapper tagProductDeptsMapper; - public Result homePage(HomeDto homeDto,String environmen) throws ExecutionException, InterruptedException { + public Result homePage(HomeDto homeDto, String environmen) throws ExecutionException, InterruptedException { int beginNo; - if(homeDto.getPage() <=0){ + if (homeDto.getPage() <= 0) { beginNo = 0; - }else{ + } else { beginNo = (homeDto.getPage() - 1) * homeDto.getSize(); } //优惠卷 @@ -71,7 +71,7 @@ public class HomePageService { //组装 List homeVOList = new ArrayList<>(); - for (TbMerchantCoupon o :tbMerchantCoupons) { + for (TbMerchantCoupon o : tbMerchantCoupons) { HomeVO homeVO = new HomeVO(); homeVO.setDiscount(o.getRatio()); for (TbShopInfo tbShopInfo : shopInfo.get()) { @@ -82,17 +82,17 @@ public class HomePageService { homeVO.setShopTag(tbPlatformDict == null?"":tbPlatformDict.getName()); } } - for (TbProduct tbProduct :product.get()) { + for (TbProduct tbProduct : product.get()) { if (o.getRelationIds().equals(tbProduct.getId().toString())) { homeVO.setProductName(tbProduct.getName()); homeVO.setImage(tbProduct.getCoverImg()); homeVO.setId(tbProduct.getId()); } } - for (TbProductSku tbProductSku :productSku.get()) { + 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())); + 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"))))); @@ -108,26 +108,27 @@ public class HomePageService { homeVOList.add(homeVO); } - return Result.success(CodeEnum.SUCCESS,homeVOList); + return Result.success(CodeEnum.SUCCESS, homeVOList); } - public Result homePageUp(String environment){ + public Result homePageUp(String environment) { HomeUpVO homeUpVO = new HomeUpVO(); //轮播图 - List carouselList = platformDictMapper.queryAllByType("carousel",environment); + List carouselList = platformDictMapper.queryAllByType("carousel", environment); homeUpVO.setCarousel(carouselList); //金刚区 - List districtList = platformDictMapper.queryAllByType("homeDistrict",environment); + 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.setDictName(sysDictsList.getDictName()); dicDetailVOList.setName(sysDictsList.getName()); dicDetailVOList.setDescription(sysDictsList.getDescription()); dicDetailVOList.setDetail(sysDictDetailMapper.selectByDictId(sysDictsList.getDictId())); - dicDetailVOList.setIsChild(sysDictsList.getIsChild()); + dicDetailVOList.setIsChild((sysDictsList.getIsChild() == null || sysDictsList.getIsChild() == 0) ? false : true); dicDetailVO.add(dicDetailVOList); } homeUpVO.setMenu(dicDetailVO); @@ -137,10 +138,10 @@ public class HomePageService { 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); + if (originPrice.compareTo(BigDecimal.ZERO) != 0) { + BigDecimal multiply = o.getSalePrice().divide(o.getOriginPrice(), 2, RoundingMode.DOWN).multiply(BigDecimal.TEN); o.setDiscount(multiply.floatValue()); - }else { + } else { o.setDiscount(null); } } @@ -155,7 +156,7 @@ public class HomePageService { TodayRankingVO todayRankingVO = new TodayRankingVO(); todayRankingVO.setTodayList(homeVODay); homeUpVO.setTodayList(todayRankingVO); - return Result.success(CodeEnum.SUCCESS,homeUpVO); + return Result.success(CodeEnum.SUCCESS, homeUpVO); } diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/util/LocationUtils.java b/src/main/java/com/chaozhanggui/system/cashierservice/util/LocationUtils.java index ad4ccb9..a98a272 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/util/LocationUtils.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/util/LocationUtils.java @@ -13,7 +13,7 @@ public class LocationUtils { //超掌柜生活-用户端 param.put("key","7a7f2e4790ea222660a027352ee3af39"); param.put("keywords",keywords); - param.put("subdistrict","1"); + param.put("subdistrict","2"); param.put("extensions","base"); String s = HttpClientUtil.doGet("https://restapi.amap.com/v3/config/district", param); return s; From dd81edb51e05e2b8c551302167f0ec4efb95feec Mon Sep 17 00:00:00 2001 From: liuyingfang <1357764963@qq.com> Date: Tue, 9 Apr 2024 10:56:26 +0800 Subject: [PATCH 03/13] =?UTF-8?q?=E6=9B=B4=E6=94=B9MQ=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../system/cashierservice/entity/vo/HomeVO.java | 13 +++++++------ .../system/cashierservice/rabbit/CartConsumer.java | 3 ++- .../system/cashierservice/rabbit/RabbitConfig.java | 9 +++++---- .../cashierservice/rabbit/RabbitProducer.java | 5 ++++- .../cashierservice/service/HomePageService.java | 11 ++++++++--- src/main/resources/application-dev.yml | 6 ++++-- src/main/resources/application-prod.yml | 3 ++- src/main/resources/application-prod2.yml | 5 +++-- 8 files changed, 35 insertions(+), 20 deletions(-) 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 bd9350b..06eda3f 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 @@ -4,6 +4,7 @@ import org.springframework.format.annotation.DateTimeFormat; import java.math.BigDecimal; import java.util.Date; +import java.util.List; /** * @author lyf @@ -47,11 +48,11 @@ public class HomeVO { /** * 店铺标签 */ - private String shopTag; + private List shopTag; /** * 商品标签 */ - private String proTag; + private List proTag; /** * 距离 */ @@ -88,19 +89,19 @@ public class HomeVO { this.distances = distances; } - public String getShopTag() { + public List getShopTag() { return shopTag; } - public void setShopTag(String shopTag) { + public void setShopTag(List shopTag) { this.shopTag = shopTag; } - public String getProTag() { + public List getProTag() { return proTag; } - public void setProTag(String proTag) { + public void setProTag(List proTag) { this.proTag = proTag; } diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/rabbit/CartConsumer.java b/src/main/java/com/chaozhanggui/system/cashierservice/rabbit/CartConsumer.java index a1edf56..97be65c 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/rabbit/CartConsumer.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/rabbit/CartConsumer.java @@ -29,7 +29,7 @@ import java.util.*; @Slf4j @Component -@RabbitListener(queues = {RabbitConstants.CART_QUEUE_PUT}) +//@RabbitListener(queues = {RabbitConstants.CART_QUEUE_PUT}) @Service public class CartConsumer { @@ -39,6 +39,7 @@ public class CartConsumer { @Autowired private CartService cartService; @RabbitHandler + @RabbitListener(queues = {"${queue}"}) public void listener(String message) { try { JSONObject jsonObject = JSON.parseObject(message); diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/rabbit/RabbitConfig.java b/src/main/java/com/chaozhanggui/system/cashierservice/rabbit/RabbitConfig.java index d3380a9..04b1fb2 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/rabbit/RabbitConfig.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/rabbit/RabbitConfig.java @@ -27,7 +27,8 @@ public class RabbitConfig { @Value("${spring.rabbitmq.password}") private String password; - + @Value("${prod}") + private String prod; @Bean @@ -49,17 +50,17 @@ public class RabbitConfig { } @Bean public DirectExchange defaultExchange_Register() { - return new DirectExchange(RabbitConstants.CART_PUT); + return new DirectExchange(RabbitConstants.CART_PUT+prod); } @Bean public Queue queuePut_Register() { - return new Queue(RabbitConstants.CART_QUEUE_PUT, true); //队列持久 + return new Queue(RabbitConstants.CART_QUEUE_PUT+prod, true); //队列持久 } @Bean public Binding bindingPut_Register() { - return BindingBuilder.bind(queuePut_Register()).to(defaultExchange_Register()).with(RabbitConstants.CART_ROUTINGKEY_PUT); + return BindingBuilder.bind(queuePut_Register()).to(defaultExchange_Register()).with(RabbitConstants.CART_ROUTINGKEY_PUT+prod); } diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/rabbit/RabbitProducer.java b/src/main/java/com/chaozhanggui/system/cashierservice/rabbit/RabbitProducer.java index 2627adf..cdd9970 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/rabbit/RabbitProducer.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/rabbit/RabbitProducer.java @@ -7,6 +7,7 @@ import org.slf4j.LoggerFactory; import org.springframework.amqp.rabbit.connection.CorrelationData; import org.springframework.amqp.rabbit.core.RabbitTemplate; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; @@ -17,6 +18,8 @@ public class RabbitProducer implements RabbitTemplate.ConfirmCallback { private RabbitTemplate rabbitTemplate; + @Value("${prod}") + private String prod; @Autowired public RabbitProducer(RabbitTemplate rabbitTemplate) { this.rabbitTemplate = rabbitTemplate; @@ -25,7 +28,7 @@ public class RabbitProducer implements RabbitTemplate.ConfirmCallback { public void putCart(String content) { CorrelationData correlationId = new CorrelationData(UUID.randomUUID().toString()); - rabbitTemplate.convertAndSend(RabbitConstants.CART_PUT, RabbitConstants.CART_ROUTINGKEY_PUT, content, correlationId); + rabbitTemplate.convertAndSend(RabbitConstants.CART_PUT+prod, RabbitConstants.CART_ROUTINGKEY_PUT+prod, content, correlationId); } public void putOrderCollect(String content) { CorrelationData correlationId = new CorrelationData(UUID.randomUUID().toString()); 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 bc82814..3bd90cf 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/HomePageService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/HomePageService.java @@ -15,6 +15,7 @@ import javax.annotation.Resource; import java.math.BigDecimal; import java.math.RoundingMode; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ExecutionException; @@ -78,8 +79,12 @@ public class HomePageService { 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()); + if (tbShopInfo.getTag() == null){ + homeVO.setShopTag(new ArrayList<>()); + }else { + TbPlatformDict tbPlatformDict = platformDictMapper.queryById(Integer.valueOf(tbShopInfo.getTag())); + homeVO.setShopTag(tbPlatformDict == null ? new ArrayList<>() : Collections.singletonList(tbPlatformDict.getName())); + } } } for (TbProduct tbProduct : product.get()) { @@ -101,7 +106,7 @@ public class HomePageService { } for (TagProductVO tagProductVO :dictPro.get()) { if (o.getRelationIds().equals(tagProductVO.getProductId().toString())){ - homeVO.setProTag(tagProductVO.getTags()); + homeVO.setProTag(Collections.singletonList(tagProductVO.getTags())); } } homeVO.setEndTime(DateUtils.getTodayEndTimeAsString()); diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml index 5cf8b4d..ca785fb 100644 --- a/src/main/resources/application-dev.yml +++ b/src/main/resources/application-dev.yml @@ -15,7 +15,8 @@ spring: # redis数据库索引(默认为0),我们使用索引为3的数据库,避免和其他数据库冲突 database: 5 # redis服务器地址(默认为localhost) - host: 101.37.12.135 +# host: 101.37.12.135 + host: 127.0.0.1 # redis端口(默认为6379) port: 6379 # redis访问密码(默认为空) @@ -54,6 +55,7 @@ ysk: callBackurl: https://p40312246f.goho.co/cashierService/notify/notifyCallBack callBackIn: https://p40312246f.goho.co/cashierService/notify/memberInCallBack default: 18710449883 - +prod: prod1 +queue: cart_queue_putprod1 diff --git a/src/main/resources/application-prod.yml b/src/main/resources/application-prod.yml index f8e8e1d..5491e73 100644 --- a/src/main/resources/application-prod.yml +++ b/src/main/resources/application-prod.yml @@ -56,6 +56,7 @@ ysk: callBackurl: https://cashier.sxczgkj.cn/cashierService/notify/notifyCallBack callBackIn: https://cashier.sxczgkj.cn/cashierService/notify/memberInCallBack default: 19191703856 - +prod: prod1 +queue: cart_queue_put1prod1 diff --git a/src/main/resources/application-prod2.yml b/src/main/resources/application-prod2.yml index f8e8e1d..d88e348 100644 --- a/src/main/resources/application-prod2.yml +++ b/src/main/resources/application-prod2.yml @@ -1,5 +1,5 @@ server: - port: 9888 + port: 9889 spring: datasource: url: jdbc:mysql://rm-bp1b572nblln4jho2.mysql.rds.aliyuncs.com/fycashier?useUnicode=true&characterEncoding=utf8&characterSetResults=utf8&useJDBCCompliantTimezoneShift=true&serverTimezone=Asia/Shanghai&useSSL=false @@ -56,6 +56,7 @@ ysk: callBackurl: https://cashier.sxczgkj.cn/cashierService/notify/notifyCallBack callBackIn: https://cashier.sxczgkj.cn/cashierService/notify/memberInCallBack default: 19191703856 - +prod: prod2 +queue: cart_queue_put1prod2 From 1b9d069bc6675d2a2beccdbe87ab00a1aba338a1 Mon Sep 17 00:00:00 2001 From: liuyingfang <1357764963@qq.com> Date: Wed, 10 Apr 2024 14:15:41 +0800 Subject: [PATCH 04/13] =?UTF-8?q?=E5=95=86=E5=93=81=E8=AF=A6=E6=83=85?= =?UTF-8?q?=E5=BC=80=E5=B7=A5=EF=BC=8C=E5=95=86=E5=93=81=E9=A6=96=E9=A1=B5?= =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/ProductController.java | 4 + .../cashierservice/dao/TbProductMapper.java | 3 + .../cashierservice/entity/TbProduct.java | 10 ++ .../entity/TbSystemCoupons.java | 107 ++++++++++++++++++ .../cashierservice/entity/vo/BannerVO.java | 31 +++++ .../cashierservice/entity/vo/HomeUpVO.java | 12 ++ .../cashierservice/entity/vo/HomeVO.java | 7 +- .../entity/vo/productInfoVo.java | 41 +++++++ .../service/HomePageService.java | 27 ++++- .../service/ProductService.java | 5 + .../system/cashierservice/util/DateUtils.java | 13 +++ src/main/resources/application-dev2.yml | 62 ++++++++++ src/main/resources/mapper/TbProductMapper.xml | 3 + 13 files changed, 318 insertions(+), 7 deletions(-) create mode 100644 src/main/java/com/chaozhanggui/system/cashierservice/entity/TbSystemCoupons.java create mode 100644 src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/BannerVO.java create mode 100644 src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/productInfoVo.java create mode 100644 src/main/resources/application-dev2.yml diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/controller/ProductController.java b/src/main/java/com/chaozhanggui/system/cashierservice/controller/ProductController.java index 07ed28d..5bcca82 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/controller/ProductController.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/controller/ProductController.java @@ -40,5 +40,9 @@ public class ProductController { return productService.queryProductSku(shopId,productId,spec_tag); } +// @GetMapping("/productInfo") +// public Result productInfo(@RequestParam Integer productId){ +// return productService.productInfo() +// } } 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 91c8f2b..52c6da8 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbProductMapper.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbProductMapper.java @@ -2,6 +2,7 @@ package com.chaozhanggui.system.cashierservice.dao; import com.chaozhanggui.system.cashierservice.entity.TbProduct; import com.chaozhanggui.system.cashierservice.entity.TbProductWithBLOBs; +import com.chaozhanggui.system.cashierservice.entity.TbSystemCoupons; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; import org.springframework.stereotype.Component; @@ -32,4 +33,6 @@ public interface TbProductMapper { 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); + + TbSystemCoupons selectLimit(); } \ No newline at end of file diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbProduct.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbProduct.java index c828f9c..9d2e3ea 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbProduct.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbProduct.java @@ -40,6 +40,8 @@ public class TbProduct implements Serializable { private String shareImg; + private String images; + private String videoCoverImg; private Integer sort; @@ -128,6 +130,14 @@ public class TbProduct implements Serializable { private String cartNumber="0"; + public String getImages() { + return images; + } + + public void setImages(String images) { + this.images = images; + } + public String getCartNumber() { return cartNumber; } diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbSystemCoupons.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbSystemCoupons.java new file mode 100644 index 0000000..9c6e0b7 --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbSystemCoupons.java @@ -0,0 +1,107 @@ +package com.chaozhanggui.system.cashierservice.entity; + +import java.util.Date; +import java.io.Serializable; + +/** + * (TbSystemCoupons)实体类 + * + * @author lyf + * @since 2024-04-09 18:27:08 + */ +public class TbSystemCoupons implements Serializable { + private static final long serialVersionUID = -42549701370854624L; + + private Integer id; + + private String name; + + private Double couponsPrice; + + private Double couponsAmount; + + private String status; + + private Date createTime; + + private Date updateTime; + + private Date endTime; + + private Integer dayNum; + + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Double getCouponsPrice() { + return couponsPrice; + } + + public void setCouponsPrice(Double couponsPrice) { + this.couponsPrice = couponsPrice; + } + + public Double getCouponsAmount() { + return couponsAmount; + } + + public void setCouponsAmount(Double couponsAmount) { + this.couponsAmount = couponsAmount; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public Date getCreateTime() { + return createTime; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + public Date getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(Date updateTime) { + this.updateTime = updateTime; + } + + public Date getEndTime() { + return endTime; + } + + public void setEndTime(Date endTime) { + this.endTime = endTime; + } + + public Integer getDayNum() { + return dayNum; + } + + public void setDayNum(Integer dayNum) { + this.dayNum = dayNum; + } + +} + diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/BannerVO.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/BannerVO.java new file mode 100644 index 0000000..efe8b20 --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/BannerVO.java @@ -0,0 +1,31 @@ +package com.chaozhanggui.system.cashierservice.entity.vo; + +import com.chaozhanggui.system.cashierservice.entity.TbPlatformDict; + +import java.util.List; + +/** + * @author 12847 + */ +public class BannerVO { + + private String coupons; + + private List logo; + + public String getCoupons() { + return coupons; + } + + public void setCoupons(String coupons) { + this.coupons = coupons; + } + + public List getLogo() { + return logo; + } + + public void setLogo(List logo) { + this.logo = logo; + } +} 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 b3104e2..d1ea0a6 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 @@ -31,6 +31,18 @@ public class HomeUpVO { * 销量飙升 */ HotRankingVO salesList; + /** + * 小横幅 + */ + BannerVO bannerVO; + + public BannerVO getBannerVO() { + return bannerVO; + } + + public void setBannerVO(BannerVO bannerVO) { + this.bannerVO = bannerVO; + } public TodayRankingVO getTodayList() { return todayList; 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 06eda3f..dc77381 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 @@ -62,14 +62,13 @@ public class HomeVO { /** * 结束时间 */ - @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") - private String endTime; + private Long endTime; - public String getEndTime() { + public Long getEndTime() { return endTime; } - public void setEndTime(String endTime) { + public void setEndTime(Long endTime) { this.endTime = endTime; } diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/productInfoVo.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/productInfoVo.java new file mode 100644 index 0000000..0073c6e --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/productInfoVo.java @@ -0,0 +1,41 @@ +package com.chaozhanggui.system.cashierservice.entity.vo; + +import java.math.BigDecimal; +import java.util.List; + +/** + * @author lyf + */ +public class productInfoVo { + /** + * 商品图片 + */ + private Listimages; + + /** + * 原价 + */ + private BigDecimal originPrice; + /** + * 现价 + */ + private BigDecimal salePrice; + /** + * 折扣 + */ + private Float discount; + /** + * 共省金额 + */ + private BigDecimal save; + + /** + * 销量 + */ + private BigDecimal realSalesNumber; + + /** + * 结束时间 + */ + private Long endTime; +} 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 3bd90cf..2e8773d 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/HomePageService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/HomePageService.java @@ -15,6 +15,7 @@ import javax.annotation.Resource; import java.math.BigDecimal; import java.math.RoundingMode; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.concurrent.CompletableFuture; @@ -83,7 +84,8 @@ public class HomePageService { homeVO.setShopTag(new ArrayList<>()); }else { TbPlatformDict tbPlatformDict = platformDictMapper.queryById(Integer.valueOf(tbShopInfo.getTag())); - homeVO.setShopTag(tbPlatformDict == null ? new ArrayList<>() : Collections.singletonList(tbPlatformDict.getName())); + + homeVO.setShopTag(tbPlatformDict == null ? new ArrayList<>() : Collections.singletonList(tbPlatformDict.getName())); } } } @@ -106,16 +108,25 @@ public class HomePageService { } for (TagProductVO tagProductVO :dictPro.get()) { if (o.getRelationIds().equals(tagProductVO.getProductId().toString())){ - homeVO.setProTag(Collections.singletonList(tagProductVO.getTags())); + homeVO.setProTag(tagList(tagProductVO.getTags())); } } - homeVO.setEndTime(DateUtils.getTodayEndTimeAsString()); + homeVO.setEndTime(DateUtils.getDayEndLong()); homeVOList.add(homeVO); } return Result.success(CodeEnum.SUCCESS, homeVOList); } + private List tagList(String tag){ + if (tag == null){ + return new ArrayList<>(); + }else { + String[] arr = tag.split(","); + return new ArrayList<>(Arrays.asList(arr)); + } + } + public Result homePageUp(String environment) { HomeUpVO homeUpVO = new HomeUpVO(); //轮播图 @@ -161,6 +172,16 @@ public class HomePageService { TodayRankingVO todayRankingVO = new TodayRankingVO(); todayRankingVO.setTodayList(homeVODay); homeUpVO.setTodayList(todayRankingVO); + /** + * 小条幅 + */ + TbSystemCoupons tbSystemCoupons = productMapper.selectLimit(); + BannerVO bannerVO = new BannerVO(); + bannerVO.setCoupons(tbSystemCoupons == null?"":tbSystemCoupons.getName()); + List tbPlatformDicts = platformDictMapper.queryAllByType("icon", environment); + bannerVO.setLogo(tbPlatformDicts); + homeUpVO.setBannerVO(bannerVO); + return Result.success(CodeEnum.SUCCESS, homeUpVO); } diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/ProductService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/ProductService.java index 4942b0e..8581305 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/ProductService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/ProductService.java @@ -118,4 +118,9 @@ public class ProductService { return Result.success(CodeEnum.SUCCESS,tbProductSkuWithBLOBs); } + + +// public Result productInfo(Integer productId){ +// TbShopInfo tbShopInfo = tbShopInfoMapper.selectByPrimaryKey(productId); +// } } diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/util/DateUtils.java b/src/main/java/com/chaozhanggui/system/cashierservice/util/DateUtils.java index 2b57fa2..9d910a0 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/util/DateUtils.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/util/DateUtils.java @@ -6,6 +6,7 @@ import java.text.SimpleDateFormat; import java.time.LocalDate; import java.time.LocalDateTime; import java.time.LocalTime; +import java.time.ZoneOffset; import java.time.format.DateTimeFormatter; import java.util.Calendar; import java.util.Date; @@ -259,6 +260,18 @@ public class DateUtils { cal.set(Calendar.MILLISECOND, 999); return cal.getTime(); } + public static Long getDayEndLong() { + // 获取今天的日期和时间(00:00:00) + LocalDateTime todayStart = LocalDateTime.now().toLocalDate().atStartOfDay(); + + // 将时间设置为今天的结束时间(23:59:59.999999999) + LocalDateTime endOfDay = todayStart.plusDays(1).minusNanos(1); + + // 转换为UTC时间戳(毫秒) + long timestampInMillis = endOfDay.toInstant(ZoneOffset.UTC).toEpochMilli(); + + return timestampInMillis; + } public static String getTodayEndTimeAsString() { // 获取今天的日期 diff --git a/src/main/resources/application-dev2.yml b/src/main/resources/application-dev2.yml new file mode 100644 index 0000000..42f1606 --- /dev/null +++ b/src/main/resources/application-dev2.yml @@ -0,0 +1,62 @@ +spring: + datasource: + url: jdbc:mysql://121.40.128.145:3306/fycashier?useUnicode=true&characterEncoding=utf8&characterSetResults=utf8&useJDBCCompliantTimezoneShift=true&serverTimezone=Asia/Shanghai&useSSL=false + username: root + password: mysqlroot@123 + driver-class-name: com.mysql.cj.jdbc.Driver + initialSize: 5 + minIdle: 5 + maxActive: 20 + maxWait: 60000 + logging: + level: + com.chaozhanggui.system.openness: info + redis: + # redis数据库索引(默认为0),我们使用索引为3的数据库,避免和其他数据库冲突 + database: 5 + # redis服务器地址(默认为localhost) +# host: 101.37.12.135 + host: 127.0.0.1 + # redis端口(默认为6379) + port: 6379 + # redis访问密码(默认为空) + password: 111111 + # redis连接超时时间(单位为毫秒) + timeout: 1000 + block-when-exhausted: true + # redis连接池配置 + jedis: + pool: + max-active: 8 + max-idle: 1024 + min-idle: 0 + max-wait: -1 + main: + allow-circular-references: true + rabbitmq: + host: 101.37.12.135 + port: 5672 + username: admin + password: Czg666888 +#分页配置 +pagehelper: + supportMethodsArguments: true + reasonable: true + helperDialect: mysql + params: count=countSql + +mybatis: + configuration: + map-underscore-to-camel-case: true + log-impl: org.apache.ibatis.logging.stdout.StdOutImpl + mapper-locations: classpath:mapper/*.xml +ysk: + url: https://gatewaytestapi.sxczgkj.cn/gate-service/ + callBackurl: https://p40312246f.goho.co/cashierService/notify/notifyCallBack + callBackIn: https://p40312246f.goho.co/cashierService/notify/memberInCallBack + default: 18710449883 +prod: prod2 +queue: cart_queue_putprod2 + + + diff --git a/src/main/resources/mapper/TbProductMapper.xml b/src/main/resources/mapper/TbProductMapper.xml index 3940301..3fb1404 100644 --- a/src/main/resources/mapper/TbProductMapper.xml +++ b/src/main/resources/mapper/TbProductMapper.xml @@ -933,4 +933,7 @@ #{item} + \ No newline at end of file From 9a6f6eb5b6e2bcd88946bb165165083e79d2f109 Mon Sep 17 00:00:00 2001 From: wangw <1594593906@qq.com> Date: Thu, 11 Apr 2024 14:26:35 +0800 Subject: [PATCH 05/13] =?UTF-8?q?=E9=A6=96=E9=A1=B5=20=E9=87=91=E5=88=9A?= =?UTF-8?q?=E5=8C=BA=20=E6=A0=87=E7=AD=BE=20=E8=AF=A6=E6=83=85=20=E6=A0=87?= =?UTF-8?q?=E7=AD=BEVO=E4=B8=80=E5=A0=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/ProductController.java | 9 +- .../dao/TagProductDeptsMapper.java | 73 +----- .../dao/TbPlatformDictMapper.java | 57 +---- .../dao/TbProductSkuMapper.java | 1 + .../dao/TbPurchaseNoticeMapper.java | 22 ++ .../entity/TagProductDepts.java | 53 ----- .../cashierservice/entity/TbPlatformDict.java | 40 +++- .../entity/TbPurchaseNotice.java | 160 +++++++++++++ .../cashierservice/entity/vo/HomeUpVO.java | 14 +- .../cashierservice/entity/vo/HomeVO.java | 16 +- .../entity/vo/ProductInfoVo.java | 73 ++++++ .../cashierservice/entity/vo/ProductVo.java | 30 +++ .../entity/vo/TagProductVO.java | 36 +-- .../entity/vo/productInfoVo.java | 41 ---- .../service/HomePageService.java | 20 +- .../service/ProductService.java | 176 +++++++++++---- .../system/cashierservice/util/JSONUtil.java | 20 ++ .../mapper/TagProductDeptsMapper.xml | 129 +++-------- .../resources/mapper/TbPlatformDictMapper.xml | 213 ++---------------- .../resources/mapper/TbProductSkuMapper.xml | 8 + .../mapper/TbPurchaseNoticeMapper.xml | 34 +++ 21 files changed, 592 insertions(+), 633 deletions(-) create mode 100644 src/main/java/com/chaozhanggui/system/cashierservice/dao/TbPurchaseNoticeMapper.java delete mode 100644 src/main/java/com/chaozhanggui/system/cashierservice/entity/TagProductDepts.java create mode 100644 src/main/java/com/chaozhanggui/system/cashierservice/entity/TbPurchaseNotice.java create mode 100644 src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/ProductInfoVo.java create mode 100644 src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/ProductVo.java delete mode 100644 src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/productInfoVo.java create mode 100644 src/main/resources/mapper/TbPurchaseNoticeMapper.xml diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/controller/ProductController.java b/src/main/java/com/chaozhanggui/system/cashierservice/controller/ProductController.java index 5bcca82..2af5a4f 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/controller/ProductController.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/controller/ProductController.java @@ -9,6 +9,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import java.util.Map; +import java.util.concurrent.ExecutionException; @CrossOrigin(origins = "*") @RestController @@ -40,9 +41,9 @@ public class ProductController { return productService.queryProductSku(shopId,productId,spec_tag); } -// @GetMapping("/productInfo") -// public Result productInfo(@RequestParam Integer productId){ -// return productService.productInfo() -// } + @GetMapping("/productInfo") + public Result productInfo(@RequestParam Integer productId) throws Exception { + return productService.productInfo(productId); + } } diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TagProductDeptsMapper.java b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TagProductDeptsMapper.java index 0b63548..d595e87 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TagProductDeptsMapper.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TagProductDeptsMapper.java @@ -1,16 +1,14 @@ 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)表数据库访问层 + * (TagProductDepts) 商品标签 表数据库访问层 * * @author lyf * @since 2024-04-08 15:03:49 @@ -18,74 +16,7 @@ import java.util.List; @Component @Mapper public interface TagProductDeptsMapper { - - /** - * 通过ID查询单条数据 - * - * @param tagId 主键 - * @return 实例对象 - */ - TagProductDepts queryById(Integer tagId); - - /** - * 查询指定行数据 - * - * @param tagProductDepts 查询条件 - * @param pageable 分页对象 - * @return 对象列表 - */ - List queryAllByLimit(TagProductDepts tagProductDepts, @Param("pageable") Pageable pageable); - List queryTagAndProduct(@Param("list") List list); - - /** - * 统计总行数 - * - * @param tagProductDepts 查询条件 - * @return 总行数 - */ - long count(TagProductDepts tagProductDepts); - - /** - * 新增数据 - * - * @param tagProductDepts 实例对象 - * @return 影响行数 - */ - int insert(TagProductDepts tagProductDepts); - - /** - * 批量新增数据(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 tagProductDepts 实例对象 - * @return 影响行数 - */ - int update(TagProductDepts tagProductDepts); - - /** - * 通过主键删除数据 - * - * @param tagId 主键 - * @return 影响行数 - */ - int deleteById(Integer tagId); - + List queryTagByProductId(@Param("productId") String productId); } diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbPlatformDictMapper.java b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbPlatformDictMapper.java index fa1ce5b..3c7cd23 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbPlatformDictMapper.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbPlatformDictMapper.java @@ -22,64 +22,9 @@ public interface TbPlatformDictMapper { */ TbPlatformDict queryById(Integer id); - /** - * 查询指定行数据 - * - * @param tbPlatformDict 查询条件 - * @param pageable 分页对象 - * @return 对象列表 - */ - List queryAllByLimit(TbPlatformDict tbPlatformDict, @Param("pageable") Pageable pageable); + List queryByIdList(List idList); List queryAllByType(@Param("type") String type,@Param("environment") String environment); - /** - * 统计总行数 - * - * @param tbPlatformDict 查询条件 - * @return 总行数 - */ - long count(TbPlatformDict tbPlatformDict); - - /** - * 新增数据 - * - * @param tbPlatformDict 实例对象 - * @return 影响行数 - */ - int insert(TbPlatformDict tbPlatformDict); - - /** - * 批量新增数据(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 tbPlatformDict 实例对象 - * @return 影响行数 - */ - int update(TbPlatformDict tbPlatformDict); - - /** - * 通过主键删除数据 - * - * @param id 主键 - * @return 影响行数 - */ - int deleteById(Integer id); } 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 018ec3e..7edb951 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbProductSkuMapper.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbProductSkuMapper.java @@ -38,4 +38,5 @@ public interface TbProductSkuMapper { List selectDownSku(@Param("list") List productId); List selectSkus(@Param("list") List productId); + List selectSku(@Param("productId") String productId); } \ No newline at end of file diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbPurchaseNoticeMapper.java b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbPurchaseNoticeMapper.java new file mode 100644 index 0000000..d1fa563 --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbPurchaseNoticeMapper.java @@ -0,0 +1,22 @@ +package com.chaozhanggui.system.cashierservice.dao; + +import com.chaozhanggui.system.cashierservice.entity.TbPurchaseNotice; + +/** + * 购买须知(关联tb_merchant_coupon)(TbPurchaseNotice)表数据库访问层 + * + * @author ww + * @since 2024-04-11 10:00:23 + */ +public interface TbPurchaseNoticeMapper { + + /** + * 通过ID查询单条数据 + * + * @param id 主键 + * @return 实例对象 + */ + TbPurchaseNotice queryById(Integer id); + +} + diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TagProductDepts.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TagProductDepts.java deleted file mode 100644 index 37e6904..0000000 --- a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TagProductDepts.java +++ /dev/null @@ -1,53 +0,0 @@ -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; - } - -} - diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbPlatformDict.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbPlatformDict.java index 55e42cf..9dbb00a 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbPlatformDict.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbPlatformDict.java @@ -12,10 +12,16 @@ public class TbPlatformDict implements Serializable { private static final long serialVersionUID = -34581903392247717L; private Integer id; + /** + * 标签前图标 + */ + private String shareImg; /** * 描述 同类型下 name唯一 */ private String name; + private String fontColor; + private String backColor; /** * homeDistrict--金刚区(首页) carousel--轮播图 tag--标签 */ @@ -24,10 +30,6 @@ public class TbPlatformDict implements Serializable { * 封面图 */ private String coverImg; - /** - * 分享图 - */ - private String shareImg; /** * 视频URL地址 */ @@ -36,10 +38,8 @@ public class TbPlatformDict implements Serializable { * 视频封面图 */ private String videoCoverImg; - /** - * 相对跳转地址 - */ - private String relUrl; + + private String jumpType; /** * 绝对跳转地址 */ @@ -78,6 +78,22 @@ public class TbPlatformDict implements Serializable { this.id = id; } + public String getFontColor() { + return fontColor; + } + + public void setFontColor(String fontColor) { + this.fontColor = fontColor; + } + + public String getBackColor() { + return backColor; + } + + public void setBackColor(String backColor) { + this.backColor = backColor; + } + public String getName() { return name; } @@ -126,12 +142,12 @@ public class TbPlatformDict implements Serializable { this.videoCoverImg = videoCoverImg; } - public String getRelUrl() { - return relUrl; + public String getJumpType() { + return jumpType; } - public void setRelUrl(String relUrl) { - this.relUrl = relUrl; + public void setJumpType(String jumpType) { + this.jumpType = jumpType; } public String getAbsUrl() { diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbPurchaseNotice.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbPurchaseNotice.java new file mode 100644 index 0000000..1085810 --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbPurchaseNotice.java @@ -0,0 +1,160 @@ +package com.chaozhanggui.system.cashierservice.entity; + +import java.io.Serializable; + +/** + * 购买须知(关联tb_merchant_coupon)(TbPurchaseNotice)实体类 + * + * @author ww + * @since 2024-04-11 10:00:23 + */ +public class TbPurchaseNotice implements Serializable { + private static final long serialVersionUID = 811103518413221387L; + /** + * 自增 + */ + private Integer id; + /** + * 商户卷Id + */ + private Integer couponId; + /** + * 使用日期说明 + */ + private String dateUsed; + /** + * 可用时间说明 + */ + private String availableTime; + /** + * 预约方式 + */ + private String bookingType; + /** + * 退款说明 + */ + private String refundPolicy; + /** + * 使用规则 + */ + private String usageRules; + /** + * 发票说明 + */ + private String invoiceInfo; + /** + * 团购价说明 + */ + private String groupPurInfo; + /** + * 门市价/划线价说明 + */ + private String marketPriceInfo; + /** + * 折扣说明 + */ + private String discountInfo; + /** + * 平台温馨提示 + */ + private String platformTips; + + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public Integer getCouponId() { + return couponId; + } + + public void setCouponId(Integer couponId) { + this.couponId = couponId; + } + + public String getDateUsed() { + return dateUsed; + } + + public void setDateUsed(String dateUsed) { + this.dateUsed = dateUsed; + } + + public String getAvailableTime() { + return availableTime; + } + + public void setAvailableTime(String availableTime) { + this.availableTime = availableTime; + } + + public String getBookingType() { + return bookingType; + } + + public void setBookingType(String bookingType) { + this.bookingType = bookingType; + } + + public String getRefundPolicy() { + return refundPolicy; + } + + public void setRefundPolicy(String refundPolicy) { + this.refundPolicy = refundPolicy; + } + + public String getUsageRules() { + return usageRules; + } + + public void setUsageRules(String usageRules) { + this.usageRules = usageRules; + } + + public String getInvoiceInfo() { + return invoiceInfo; + } + + public void setInvoiceInfo(String invoiceInfo) { + this.invoiceInfo = invoiceInfo; + } + + public String getGroupPurInfo() { + return groupPurInfo; + } + + public void setGroupPurInfo(String groupPurInfo) { + this.groupPurInfo = groupPurInfo; + } + + public String getMarketPriceInfo() { + return marketPriceInfo; + } + + public void setMarketPriceInfo(String marketPriceInfo) { + this.marketPriceInfo = marketPriceInfo; + } + + public String getDiscountInfo() { + return discountInfo; + } + + public void setDiscountInfo(String discountInfo) { + this.discountInfo = discountInfo; + } + + public String getPlatformTips() { + return platformTips; + } + + public void setPlatformTips(String platformTips) { + this.platformTips = platformTips; + } + +} + 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 d1ea0a6..02728f4 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,8 +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; import java.util.List; @@ -14,11 +12,11 @@ public class HomeUpVO { /** * 轮播图 */ - List carousel; + List carousel; /** * 金刚区 */ - List district; + List district; /** * 条件查询 */ @@ -60,19 +58,19 @@ public class HomeUpVO { this.salesList = salesList; } - public List getCarousel() { + public List getCarousel() { return carousel; } - public void setCarousel(List carousel) { + public void setCarousel(List carousel) { this.carousel = carousel; } - public List getDistrict() { + public List getDistrict() { return district; } - public void setDistrict(List district) { + public void setDistrict(List district) { this.district = district; } 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 dc77381..a97c41a 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 @@ -1,9 +1,7 @@ package com.chaozhanggui.system.cashierservice.entity.vo; -import org.springframework.format.annotation.DateTimeFormat; - import java.math.BigDecimal; -import java.util.Date; +import java.util.ArrayList; import java.util.List; /** @@ -48,11 +46,11 @@ public class HomeVO { /** * 店铺标签 */ - private List shopTag; + private List shopTag; /** * 商品标签 */ - private List proTag; + private List proTag=new ArrayList<>(); /** * 距离 */ @@ -88,19 +86,19 @@ public class HomeVO { this.distances = distances; } - public List getShopTag() { + public List getShopTag() { return shopTag; } - public void setShopTag(List shopTag) { + public void setShopTag(List shopTag) { this.shopTag = shopTag; } - public List getProTag() { + public List getProTag() { return proTag; } - public void setProTag(List proTag) { + public void setProTag(List proTag) { this.proTag = proTag; } diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/ProductInfoVo.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/ProductInfoVo.java new file mode 100644 index 0000000..394eca8 --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/ProductInfoVo.java @@ -0,0 +1,73 @@ +package com.chaozhanggui.system.cashierservice.entity.vo; + +import com.alibaba.fastjson.JSONArray; +import com.chaozhanggui.system.cashierservice.entity.TbPurchaseNotice; +import lombok.Data; + +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.List; + +/** + * @author lyf + */ +@Data +public class ProductInfoVo { + /** + * 商品图片 + */ + private JSONArray images; + + /** + * 现价 + */ + private BigDecimal salePrice; + /** + * 折扣 + */ + private Float discount; + /** + * 原价 + */ + private BigDecimal originPrice; + + /** + * 销量 + */ + private BigDecimal realSalesNumber; + + /** + * 商品名称 + */ + private String productName; + /** + * 店铺名称 + */ + private String shopName; + /** + * 联系方式 + */ + private String phone; + /** + * 营业时间 + */ + private String businessTime; + /** + * 距离 + */ + private String distances = "100"; + /** + * 地址 + */ + private String address; + + /** + * 套餐详情 + */ + List productList = new ArrayList<>(); + + /** + * 购买须知/价格说明 + */ + private TbPurchaseNotice purchaseNotice; +} diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/ProductVo.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/ProductVo.java new file mode 100644 index 0000000..05c9af4 --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/ProductVo.java @@ -0,0 +1,30 @@ +package com.chaozhanggui.system.cashierservice.entity.vo; + +import lombok.Data; + +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.List; + +@Data +public class ProductVo { + //选几个 + private Integer number; + + //类别 + private String title; + + //食物 + private List foods=new ArrayList<>(); // 食品列表 + + @Data + public static class Food { + private String name; // 商品名称 + private BigDecimal price; // 售价 + private String unit; // 单位 + /** + * 商品标签 + */ + private List proTag=new ArrayList<>(); + } +} diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/TagProductVO.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/TagProductVO.java index 939d5cc..1fbda4d 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/TagProductVO.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/TagProductVO.java @@ -1,34 +1,22 @@ package com.chaozhanggui.system.cashierservice.entity.vo; +import lombok.Data; + /** + * 商品 标签 * @author lyf */ +@Data public class TagProductVO { + //商品id private Integer productId; + //标签前 小图标 + private String shareImg; + //标签 名称 private String name; - private String tags; + //字体颜色 + private String fontColor; + //背景色 + private String backColor; - 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; - } } diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/productInfoVo.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/productInfoVo.java deleted file mode 100644 index 0073c6e..0000000 --- a/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/productInfoVo.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.chaozhanggui.system.cashierservice.entity.vo; - -import java.math.BigDecimal; -import java.util.List; - -/** - * @author lyf - */ -public class productInfoVo { - /** - * 商品图片 - */ - private Listimages; - - /** - * 原价 - */ - private BigDecimal originPrice; - /** - * 现价 - */ - private BigDecimal salePrice; - /** - * 折扣 - */ - private Float discount; - /** - * 共省金额 - */ - private BigDecimal save; - - /** - * 销量 - */ - private BigDecimal realSalesNumber; - - /** - * 结束时间 - */ - private Long endTime; -} 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 2e8773d..f59fd8a 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/HomePageService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/HomePageService.java @@ -7,8 +7,10 @@ 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.JSONUtil; import com.chaozhanggui.system.cashierservice.util.Threads; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; import javax.annotation.Resource; @@ -20,6 +22,7 @@ import java.util.Collections; import java.util.List; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ExecutionException; +import java.util.stream.Collectors; /** * @author lyf @@ -80,12 +83,14 @@ public class HomePageService { if (o.getShopId().equals(tbShopInfo.getId().toString())) { homeVO.setShopName(tbShopInfo.getShopName()); homeVO.setImage(tbShopInfo.getLogo()); - if (tbShopInfo.getTag() == null){ + if (StringUtils.isBlank(tbShopInfo.getTag())){ homeVO.setShopTag(new ArrayList<>()); }else { - TbPlatformDict tbPlatformDict = platformDictMapper.queryById(Integer.valueOf(tbShopInfo.getTag())); - - homeVO.setShopTag(tbPlatformDict == null ? new ArrayList<>() : Collections.singletonList(tbPlatformDict.getName())); + List shopTagIds = Arrays.stream(tbShopInfo.getTag().split(",")) + .map(Integer::parseInt) + .collect(Collectors.toList()); + List tbPlatformDicts = platformDictMapper.queryByIdList(shopTagIds); + homeVO.setShopTag(JSONUtil.parseListTNewList(tbPlatformDicts, TagVo.class)); } } } @@ -108,7 +113,7 @@ public class HomePageService { } for (TagProductVO tagProductVO :dictPro.get()) { if (o.getRelationIds().equals(tagProductVO.getProductId().toString())){ - homeVO.setProTag(tagList(tagProductVO.getTags())); + homeVO.getProTag().add(tagProductVO); } } homeVO.setEndTime(DateUtils.getDayEndLong()); @@ -131,10 +136,11 @@ public class HomePageService { HomeUpVO homeUpVO = new HomeUpVO(); //轮播图 List carouselList = platformDictMapper.queryAllByType("carousel", environment); - homeUpVO.setCarousel(carouselList); + homeUpVO.setCarousel(JSONUtil.parseListTNewList(carouselList, HomeCarouselVo.class)); //金刚区 List districtList = platformDictMapper.queryAllByType("homeDistrict", environment); - homeUpVO.setDistrict(districtList); + homeUpVO.setDistrict(JSONUtil.parseListTNewList(districtList, HomeDistrictVo.class)); + //菜单 List sysDicts = sysDictDetailMapper.selectByAll(); List dicDetailVO = new ArrayList<>(); diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/ProductService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/ProductService.java index 8581305..53cfa05 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/ProductService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/ProductService.java @@ -2,21 +2,32 @@ package com.chaozhanggui.system.cashierservice.service; import cn.hutool.core.util.ObjectUtil; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; import com.chaozhanggui.system.cashierservice.dao.*; import com.chaozhanggui.system.cashierservice.entity.*; +import com.chaozhanggui.system.cashierservice.entity.vo.ProductInfoVo; +import com.chaozhanggui.system.cashierservice.entity.vo.ProductVo; +import com.chaozhanggui.system.cashierservice.entity.vo.TagProductVO; import com.chaozhanggui.system.cashierservice.sign.CodeEnum; import com.chaozhanggui.system.cashierservice.sign.Result; import com.chaozhanggui.system.cashierservice.socket.AppWebSocketServer; +import com.chaozhanggui.system.cashierservice.util.Threads; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import javax.annotation.Resource; +import java.math.BigDecimal; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Set; +import java.util.concurrent.CompletableFuture; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; +import java.util.concurrent.ExecutionException; @Service @Slf4j @@ -37,90 +48,165 @@ public class ProductService { @Autowired private TbShopTableMapper tbShopTableMapper; - - + @Resource + private TagProductDeptsMapper tagProductDeptsMapper; + @Resource + private TbMerchantCouponMapper merchantCouponMapper; + @Resource + private TbPlatformDictMapper platformDictMapper; + @Resource + private TbShopUnitMapper unitMapper; + @Resource + private TbShopCategoryMapper categoryMapper; + @Resource + private TbPurchaseNoticeMapper purchaseNoticeMapper; @Autowired TbProductSkuMapper tbProductSkuMapper; + public Result queryProduct(String code, String productGroupId) { + ConcurrentMap concurrentMap = new ConcurrentHashMap<>(); - - - - public Result queryProduct(String code,String productGroupId){ - - ConcurrentMap concurrentMap=new ConcurrentHashMap<>(); - - TbShopTable tbShopTable= tbShopTableMapper.selectQRcode(code); - if(ObjectUtil.isEmpty(tbShopTable)||ObjectUtil.isNull(tbShopTable)){ + TbShopTable tbShopTable = tbShopTableMapper.selectQRcode(code); + if (ObjectUtil.isEmpty(tbShopTable) || ObjectUtil.isNull(tbShopTable)) { return Result.fail("台桌信息不存在"); } - Integer id= ObjectUtil.isNotEmpty(productGroupId)?Integer.valueOf(productGroupId):null; - List groupList=tbProductGroupMapper.selectByQrcode(code,id); - if(ObjectUtil.isNotEmpty(groupList)&&groupList.size()>0){ + Integer id = ObjectUtil.isNotEmpty(productGroupId) ? Integer.valueOf(productGroupId) : null; + List groupList = tbProductGroupMapper.selectByQrcode(code, id); + if (ObjectUtil.isNotEmpty(groupList) && groupList.size() > 0) { - TbProductGroup group= groupList.get(0); - TbShopInfo shopInfo= tbShopInfoMapper.selectByPrimaryKey(group.getShopId()) ; - concurrentMap.put("shopTableInfo",tbShopTable); - concurrentMap.put("storeInfo",shopInfo); - groupList.parallelStream().forEach(g->{ - String in=g.getProductIds().substring(1,g.getProductIds().length()-1); + TbProductGroup group = groupList.get(0); + TbShopInfo shopInfo = tbShopInfoMapper.selectByPrimaryKey(group.getShopId()); + concurrentMap.put("shopTableInfo", tbShopTable); + concurrentMap.put("storeInfo", shopInfo); + groupList.parallelStream().forEach(g -> { + String in = g.getProductIds().substring(1, g.getProductIds().length() - 1); - if(ObjectUtil.isNotEmpty(in)&&ObjectUtil.isNotNull(in)){ - log.info("请求参数:{}",in); - List products= tbProductMapper.selectByIdIn(in); - if(ObjectUtil.isNotEmpty(products)&&products.size()>0){ - products.parallelStream().forEach(it->{ + if (ObjectUtil.isNotEmpty(in) && ObjectUtil.isNotNull(in)) { + log.info("请求参数:{}", in); + List products = tbProductMapper.selectByIdIn(in); + if (ObjectUtil.isNotEmpty(products) && products.size() > 0) { + products.parallelStream().forEach(it -> { Integer sum = 0; - if (AppWebSocketServer.userMap.containsKey(code)){ + if (AppWebSocketServer.userMap.containsKey(code)) { Set userSet = AppWebSocketServer.userMap.get(code); - if (userSet.isEmpty()){ - sum= tbProductMapper.selectByQcode(code,it.getId(),it.getShopId()); - }else { + if (userSet.isEmpty()) { + sum = tbProductMapper.selectByQcode(code, it.getId(), it.getShopId()); + } else { List userList = new ArrayList<>(userSet); - sum= tbProductMapper.selectByNewQcode(code,it.getId(),it.getShopId(),userList); + sum = tbProductMapper.selectByNewQcode(code, it.getId(), it.getShopId(), userList); } - }else { - sum= tbProductMapper.selectByQcode(code,it.getId(),it.getShopId()); + } else { + sum = tbProductMapper.selectByQcode(code, it.getId(), it.getShopId()); } - it.setCartNumber(sum==null?"0":String.valueOf(sum)); - TbProductSkuResult skuResult= tbProductSkuResultMapper.selectByPrimaryKey(it.getId()); + it.setCartNumber(sum == null ? "0" : String.valueOf(sum)); + TbProductSkuResult skuResult = tbProductSkuResultMapper.selectByPrimaryKey(it.getId()); it.setProductSkuResult(skuResult); }); g.setProducts(products); - }else { + } else { g.setProducts(new ArrayList<>()); } - }else { + } else { g.setProducts(new ArrayList<>()); } }); - concurrentMap.put("productInfo",groupList); + concurrentMap.put("productInfo", groupList); } - return Result.success(CodeEnum.SUCCESS,concurrentMap); + return Result.success(CodeEnum.SUCCESS, concurrentMap); } - public Result queryProductSku(String shopId, String productId, String spec_tag){ - if(ObjectUtil.isEmpty(shopId)||ObjectUtil.isEmpty(productId)){ + public Result queryProductSku(String shopId, String productId, String spec_tag) { + if (ObjectUtil.isEmpty(shopId) || ObjectUtil.isEmpty(productId)) { return Result.fail("参数错误"); } - TbProductSkuWithBLOBs tbProductSkuWithBLOBs= tbProductSkuMapper.selectByShopIdAndProductIdAndSpec(shopId,productId,spec_tag); - return Result.success(CodeEnum.SUCCESS,tbProductSkuWithBLOBs); + TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByShopIdAndProductIdAndSpec(shopId, productId, spec_tag); + return Result.success(CodeEnum.SUCCESS, tbProductSkuWithBLOBs); } -// public Result productInfo(Integer productId){ -// TbShopInfo tbShopInfo = tbShopInfoMapper.selectByPrimaryKey(productId); -// } + public Result productInfo(Integer productId) throws Exception { + TbMerchantCoupon tbMerchantCoupon = merchantCouponMapper.queryById(productId); + + CompletableFuture shopInfo = CompletableFuture.supplyAsync(() -> + tbShopInfoMapper.selectByPrimaryKey(Integer.valueOf(tbMerchantCoupon.getShopId()))); + CompletableFuture product = CompletableFuture.supplyAsync(() -> + tbProductMapper.selectById(Integer.valueOf(tbMerchantCoupon.getRelationIds()))); + CompletableFuture> productSku = CompletableFuture.supplyAsync(() -> + tbProductSkuMapper.selectSku(tbMerchantCoupon.getRelationIds())); + CompletableFuture> dictPro = CompletableFuture.supplyAsync(() -> + tagProductDeptsMapper.queryTagByProductId(tbMerchantCoupon.getRelationIds())); + CompletableFuture purchaseNotice = CompletableFuture.supplyAsync(() -> + purchaseNoticeMapper.queryById(tbMerchantCoupon.getId())); + Threads.call(shopInfo, product, productSku, dictPro); + + ProductInfoVo productInfo = new ProductInfoVo(); + // 图片组装 + TbProduct tbProduct = product.get(); + TbShopInfo tbShopInfo = shopInfo.get(); + if (StringUtils.isNotBlank(tbProduct.getImages())) { + productInfo.setImages(JSON.parseArray(tbProduct.getImages())); + } else { + productInfo.setImages(new JSONArray()); + } + //折扣 + productInfo.setDiscount(tbMerchantCoupon.getRatio()); + //价格组装 + for (TbProductSku tbProductSku : productSku.get()) { + productInfo.setOriginPrice(tbProductSku.getSalePrice()); + productInfo.setRealSalesNumber(tbProductSku.getRealSalesNumber() == null ? BigDecimal.ZERO : new BigDecimal(tbProductSku.getRealSalesNumber())); + Float discount = productInfo.getDiscount(); + BigDecimal discountDecimal = new BigDecimal(discount); + productInfo.setSalePrice(tbProductSku.getSalePrice().multiply((discountDecimal.multiply(new BigDecimal("0.1"))))); + } + //名称 + productInfo.setProductName(tbProduct.getName()); + //店铺 + productInfo.setShopName(tbShopInfo.getShopName() + (StringUtils.isNotBlank(tbShopInfo.getChainName()) ? "(" + tbShopInfo.getChainName() + ")" : "")); + productInfo.setPhone(tbShopInfo.getPhone()); + productInfo.setBusinessTime(tbShopInfo.getBusinessTime()); +// productInfo.setDistances();//距离 + productInfo.setAddress(tbShopInfo.getAddress()); + + //商品 暂时只做单商品 + ProductVo productVo = new ProductVo(); + TbShopUnit tbShopUnit = unitMapper.selectByPrimaryKey(Integer.valueOf(tbProduct.getUnitId())); + TbShopCategory tbShopCategory = categoryMapper.selectByPrimaryKey(Integer.valueOf(tbProduct.getCategoryId())); + productVo.setTitle(tbShopCategory.getName()); + productVo.setNumber(1); + ProductVo.Food food = new ProductVo.Food(); + food.setName(tbProduct.getName()); + food.setUnit(tbShopUnit.getName()); + food.setPrice(tbProduct.getLowPrice()); + + for (TagProductVO tagProductVO : dictPro.get()) { + food.getProTag().add(tagProductVO); + } + productVo.getFoods().add(food); + productInfo.getProductList().add(productVo); + + productInfo.setPurchaseNotice(purchaseNotice.get()); + + return Result.success(CodeEnum.SUCCESS, productInfo); + } + + private List tagList(String tag) { + if (tag == null) { + return new ArrayList<>(); + } else { + String[] arr = tag.split(","); + return new ArrayList<>(Arrays.asList(arr)); + } + } } diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/util/JSONUtil.java b/src/main/java/com/chaozhanggui/system/cashierservice/util/JSONUtil.java index 69ff2ee..0020938 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/util/JSONUtil.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/util/JSONUtil.java @@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.serializer.SerializeConfig; import com.alibaba.fastjson.serializer.SerializerFeature; +import com.fasterxml.jackson.databind.ObjectMapper; import java.util.*; @@ -172,6 +173,25 @@ public class JSONUtil { } } + /** + * @param list 某集合 + * @param clazz 要转成的实体 + * @return + * @param + */ + public static List parseListTNewList(List list, Class clazz) { + ObjectMapper objectMapper = new ObjectMapper(); // 创建JSON转换器 + try { + // 将List转换为JSON字符串 + String json = objectMapper.writeValueAsString(list); + // 将JSON字符串转换为List + return objectMapper.readValue(json, objectMapper.getTypeFactory().constructCollectionType(List.class, clazz)); + } catch (Exception e) { + e.printStackTrace(); + return null; + } + } + public static class JSONEntity { public JSONEntity() { } diff --git a/src/main/resources/mapper/TagProductDeptsMapper.xml b/src/main/resources/mapper/TagProductDeptsMapper.xml index 17e44e5..3501c77 100644 --- a/src/main/resources/mapper/TagProductDeptsMapper.xml +++ b/src/main/resources/mapper/TagProductDeptsMapper.xml @@ -2,116 +2,39 @@ - - - - - - - - - - - - - - - - - insert into tag_product_depts(product_id, create_time) - values (#{productId}, #{createTime}) - - - - insert into tag_product_depts(product_id, create_time) - values - - (#{entity.productId}, #{entity.createTime}) - - - - - insert into tag_product_depts(product_id, create_time) - values - - (#{entity.productId}, #{entity.createTime}) - - on duplicate key update - product_id = values(product_id), - create_time = values(create_time) - - - - - update tag_product_depts - - - product_id = #{productId}, - - - create_time = #{createTime}, - - - where tag_id = #{tagId} - - - - - delete from tag_product_depts where tag_id = #{tagId} - + diff --git a/src/main/resources/mapper/TbPlatformDictMapper.xml b/src/main/resources/mapper/TbPlatformDictMapper.xml index bac90db..46e3530 100644 --- a/src/main/resources/mapper/TbPlatformDictMapper.xml +++ b/src/main/resources/mapper/TbPlatformDictMapper.xml @@ -4,13 +4,15 @@ + + + - - + @@ -23,121 +25,25 @@ - - select - id, name, type, cover_img, share_img, video, video_cover_img, rel_url, abs_url, created_at, updated_at, is_show_cash, is_show_mall, is_show_app, sort + id, name, type, font_color, back_color, cover_img, share_img, video, video_cover_img, jump_type, abs_url, created_at, updated_at, is_show_cash, is_show_mall, is_show_app, sort from tb_platform_dict - - - and id = #{id} - - - and name = #{name} - - - and type = #{type} - - - and cover_img = #{coverImg} - - - and share_img = #{shareImg} - - - and video = #{video} - - - and video_cover_img = #{videoCoverImg} - - - and rel_url = #{relUrl} - - - and abs_url = #{absUrl} - - - and created_at = #{createdAt} - - - and updated_at = #{updatedAt} - - - and is_show_cash = #{isShowCash} - - - and is_show_mall = #{isShowMall} - - - and is_show_app = #{isShowApp} - - - and sort = #{sort} - - - limit #{pageable.offset}, #{pageable.pageSize} + where id IN + + #{id} + - - - - - - insert into tb_platform_dict(name, type, cover_img, share_img, video, video_cover_img, rel_url, abs_url, created_at, updated_at, is_show_cash, is_show_mall, is_show_app, sort) - values (#{name}, #{type}, #{coverImg}, #{shareImg}, #{video}, #{videoCoverImg}, #{relUrl}, #{absUrl}, #{createdAt}, #{updatedAt}, #{isShowCash}, #{isShowMall}, #{isShowApp}, #{sort}) - - - - insert into tb_platform_dict(name, type, cover_img, share_img, video, video_cover_img, rel_url, abs_url, created_at, updated_at, is_show_cash, is_show_mall, is_show_app, sort) - values - - (#{entity.name}, #{entity.type}, #{entity.coverImg}, #{entity.shareImg}, #{entity.video}, #{entity.videoCoverImg}, #{entity.relUrl}, #{entity.absUrl}, #{entity.createdAt}, #{entity.updatedAt}, #{entity.isShowCash}, #{entity.isShowMall}, #{entity.isShowApp}, #{entity.sort}) - - - - - insert into tb_platform_dict(name, type, cover_img, share_img, video, video_cover_img, rel_url, abs_url, created_at, updated_at, is_show_cash, is_show_mall, is_show_app, sort) - values - - (#{entity.name}, #{entity.type}, #{entity.coverImg}, #{entity.shareImg}, #{entity.video}, #{entity.videoCoverImg}, #{entity.relUrl}, #{entity.absUrl}, #{entity.createdAt}, #{entity.updatedAt}, #{entity.isShowCash}, #{entity.isShowMall}, #{entity.isShowApp}, #{entity.sort}) - - on duplicate key update - name = values(name), - type = values(type), - cover_img = values(cover_img), - share_img = values(share_img), - video = values(video), - video_cover_img = values(video_cover_img), - rel_url = values(rel_url), - abs_url = values(abs_url), - created_at = values(created_at), - updated_at = values(updated_at), - is_show_cash = values(is_show_cash), - is_show_mall = values(is_show_mall), - is_show_app = values(is_show_app), - sort = values(sort) - - - - - update tb_platform_dict - - - name = #{name}, - - - type = #{type}, - - - cover_img = #{coverImg}, - - - share_img = #{shareImg}, - - - video = #{video}, - - - video_cover_img = #{videoCoverImg}, - - - rel_url = #{relUrl}, - - - abs_url = #{absUrl}, - - - created_at = #{createdAt}, - - - updated_at = #{updatedAt}, - - - is_show_cash = #{isShowCash}, - - - is_show_mall = #{isShowMall}, - - - is_show_app = #{isShowApp}, - - - sort = #{sort}, - - - where id = #{id} - - - - - delete from tb_platform_dict where id = #{id} - - diff --git a/src/main/resources/mapper/TbProductSkuMapper.xml b/src/main/resources/mapper/TbProductSkuMapper.xml index 2f30e56..44b1a0d 100644 --- a/src/main/resources/mapper/TbProductSkuMapper.xml +++ b/src/main/resources/mapper/TbProductSkuMapper.xml @@ -381,6 +381,14 @@ GROUP BY product_id + + select + + + from tb_purchase_notice + where id = #{id} + + + + From f71e1af8234106402c1ec883b0b945b5eb9fb3ff Mon Sep 17 00:00:00 2001 From: wangw <1594593906@qq.com> Date: Thu, 11 Apr 2024 14:26:54 +0800 Subject: [PATCH 06/13] =?UTF-8?q?=E6=A0=87=E7=AD=BEVO=E4=B8=80=E5=A0=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../entity/vo/HomeCarouselVo.java | 29 +++++++++++++++++ .../entity/vo/HomeDistrictVo.java | 31 +++++++++++++++++++ .../cashierservice/entity/vo/TagVo.java | 23 ++++++++++++++ 3 files changed, 83 insertions(+) create mode 100644 src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/HomeCarouselVo.java create mode 100644 src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/HomeDistrictVo.java create mode 100644 src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/TagVo.java diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/HomeCarouselVo.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/HomeCarouselVo.java new file mode 100644 index 0000000..8822002 --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/HomeCarouselVo.java @@ -0,0 +1,29 @@ +package com.chaozhanggui.system.cashierservice.entity.vo; + +import lombok.Data; + +/** + * 轮播图VO + */ +@Data +public class HomeCarouselVo { + + /** + * 描述 同类型下 name唯一 + */ + private String name; + /** + * 轮播图url + */ + private String coverImg; + /** + * 跳转类型 如 拉起相机 跳转小程序 跳转第三方url + */ + private String jumpType; + /** + * 绝对跳转地址 + */ + private String absUrl; + +} + diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/HomeDistrictVo.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/HomeDistrictVo.java new file mode 100644 index 0000000..d0626bf --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/HomeDistrictVo.java @@ -0,0 +1,31 @@ +package com.chaozhanggui.system.cashierservice.entity.vo; + +import lombok.Data; + +/** + * 首页金刚区Vo + */ +@Data +public class HomeDistrictVo{ + /** + * 展示图url + */ + private String coverImg; + /** + * 描述 同类型下 name唯一 + */ + private String name; + /** + * 字体颜色 + */ + private String fontColor; + /** + * 类型: scan:拉起相机;relative:内部页面;absolute:外链url + */ + private String jumpType; + /** + * 绝对跳转地址 + */ + private String absUrl; +} + diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/TagVo.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/TagVo.java new file mode 100644 index 0000000..cc63339 --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/TagVo.java @@ -0,0 +1,23 @@ +package com.chaozhanggui.system.cashierservice.entity.vo; + +import lombok.Data; + +@Data +public class TagVo { + /** + * 标签前 小图标 + */ + private String shareImg; + /** + * 描述 同类型下 name唯一 + */ + private String name; + /** + * 字体颜色 + */ + private String fontColor; + /** + * 背景色 + */ + private String backColor; +} From ae61959743f35ab04d80487f3d2eae2e32bf7094 Mon Sep 17 00:00:00 2001 From: wangw <1594593906@qq.com> Date: Thu, 11 Apr 2024 14:51:44 +0800 Subject: [PATCH 07/13] =?UTF-8?q?=E5=AE=9E=E4=BD=93=E8=BD=AC=E6=8D=A2?= =?UTF-8?q?=E7=9A=84bug=20sql=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../system/cashierservice/dao/TbPlatformDictMapper.java | 2 +- .../system/cashierservice/entity/vo/HomeCarouselVo.java | 2 ++ .../system/cashierservice/entity/vo/HomeDistrictVo.java | 2 ++ .../com/chaozhanggui/system/cashierservice/entity/vo/TagVo.java | 2 ++ .../com/chaozhanggui/system/cashierservice/util/JSONUtil.java | 1 + 5 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbPlatformDictMapper.java b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbPlatformDictMapper.java index 3c7cd23..eaaae04 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbPlatformDictMapper.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbPlatformDictMapper.java @@ -22,7 +22,7 @@ public interface TbPlatformDictMapper { */ TbPlatformDict queryById(Integer id); - List queryByIdList(List idList); + List queryByIdList(@Param("idList")List idList); List queryAllByType(@Param("type") String type,@Param("environment") String environment); diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/HomeCarouselVo.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/HomeCarouselVo.java index 8822002..8e71a04 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/HomeCarouselVo.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/HomeCarouselVo.java @@ -1,11 +1,13 @@ package com.chaozhanggui.system.cashierservice.entity.vo; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import lombok.Data; /** * 轮播图VO */ @Data +@JsonIgnoreProperties(ignoreUnknown = true) public class HomeCarouselVo { /** diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/HomeDistrictVo.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/HomeDistrictVo.java index d0626bf..7acaead 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/HomeDistrictVo.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/HomeDistrictVo.java @@ -1,11 +1,13 @@ package com.chaozhanggui.system.cashierservice.entity.vo; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import lombok.Data; /** * 首页金刚区Vo */ @Data +@JsonIgnoreProperties(ignoreUnknown = true) public class HomeDistrictVo{ /** * 展示图url diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/TagVo.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/TagVo.java index cc63339..24885d6 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/TagVo.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/TagVo.java @@ -1,8 +1,10 @@ package com.chaozhanggui.system.cashierservice.entity.vo; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import lombok.Data; @Data +@JsonIgnoreProperties(ignoreUnknown = true) public class TagVo { /** * 标签前 小图标 diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/util/JSONUtil.java b/src/main/java/com/chaozhanggui/system/cashierservice/util/JSONUtil.java index 0020938..ba451d2 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/util/JSONUtil.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/util/JSONUtil.java @@ -176,6 +176,7 @@ public class JSONUtil { /** * @param list 某集合 * @param clazz 要转成的实体 + * 需要在目标实体增加注解 忽略未知属性 @JsonIgnoreProperties(ignoreUnknown = true) * @return * @param */ From 05bf58173444feed6d55fd41c7f41b299ef938c0 Mon Sep 17 00:00:00 2001 From: wangw <1594593906@qq.com> Date: Thu, 11 Apr 2024 15:59:54 +0800 Subject: [PATCH 08/13] =?UTF-8?q?=E9=A6=96=E9=A1=B5=E4=B8=8B=E5=8D=8A?= =?UTF-8?q?=E9=83=A8=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../system/cashierservice/service/HomePageService.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 f59fd8a..c86702c 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/HomePageService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/HomePageService.java @@ -78,6 +78,7 @@ public class HomePageService { List homeVOList = new ArrayList<>(); for (TbMerchantCoupon o : tbMerchantCoupons) { HomeVO homeVO = new HomeVO(); + homeVO.setId(o.getId()); homeVO.setDiscount(o.getRatio()); for (TbShopInfo tbShopInfo : shopInfo.get()) { if (o.getShopId().equals(tbShopInfo.getId().toString())) { @@ -98,7 +99,7 @@ public class HomePageService { if (o.getRelationIds().equals(tbProduct.getId().toString())) { homeVO.setProductName(tbProduct.getName()); homeVO.setImage(tbProduct.getCoverImg()); - homeVO.setId(tbProduct.getId()); + homeVO.setProductId(tbProduct.getId()); } } for (TbProductSku tbProductSku : productSku.get()) { From 5946c78cf99eab5436399460c86c3197680ad709 Mon Sep 17 00:00:00 2001 From: liuyingfang <1357764963@qq.com> Date: Thu, 11 Apr 2024 16:31:59 +0800 Subject: [PATCH 09/13] =?UTF-8?q?=E5=B0=8F=E6=A8=AA=E5=B9=85=E6=9B=B4?= =?UTF-8?q?=E6=94=B9=EF=BC=8C=E6=9B=B4=E6=94=B9=E6=9D=A1=E4=BB=B6=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cashierservice/entity/Enum/LogoEnum.java | 87 +++++++++++++++++++ .../cashierservice/entity/dto/HomeDto.java | 17 ++-- .../entity/vo/BannerInfoVo.java | 43 +++++++++ .../cashierservice/entity/vo/BannerVO.java | 14 +-- .../cashierservice/entity/vo/HomeVO.java | 13 +++ .../service/HomePageService.java | 34 ++++++-- .../cashierservice/util/RandomUtil.java | 36 ++++++++ .../cashierservice/util/StringUtil.java | 22 +++++ 8 files changed, 246 insertions(+), 20 deletions(-) create mode 100644 src/main/java/com/chaozhanggui/system/cashierservice/entity/Enum/LogoEnum.java create mode 100644 src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/BannerInfoVo.java create mode 100644 src/main/java/com/chaozhanggui/system/cashierservice/util/RandomUtil.java diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/Enum/LogoEnum.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/Enum/LogoEnum.java new file mode 100644 index 0000000..4c04b56 --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/Enum/LogoEnum.java @@ -0,0 +1,87 @@ +package com.chaozhanggui.system.cashierservice.entity.Enum; + +import com.github.pagehelper.util.StringUtil; + +/** + * @author 12847 + */ + +public enum LogoEnum { + url1(1,"https://cashier-oss.oss-cn-beijing.aliyuncs.com/status/%E6%BE%B6%E6%9D%91%E5%84%9A/IMG_0299.PNG"), + url2(2,"https://cashier-oss.oss-cn-beijing.aliyuncs.com/status/%E6%BE%B6%E6%9D%91%E5%84%9A/ffaab08f6a62103593646bf36dbaa24c.jpeg"), + url3(3,"https://cashier-oss.oss-cn-beijing.aliyuncs.com/status/%E6%BE%B6%E6%9D%91%E5%84%9A/fe6c4572004f9aa7716bff89c4c56783.jpeg"), + url4(4,"https://cashier-oss.oss-cn-beijing.aliyuncs.com/status/%E6%BE%B6%E6%9D%91%E5%84%9A/fb56ef7c59d46835e6ff4b5c494aed5a.jpeg"), + url5(5,"https://cashier-oss.oss-cn-beijing.aliyuncs.com/status/%E6%BE%B6%E6%9D%91%E5%84%9A/f8469a7760c7f584ab55e47b60cd3829.jpeg"), + url6(6,"https://cashier-oss.oss-cn-beijing.aliyuncs.com/status/%E6%BE%B6%E6%9D%91%E5%84%9A/f73810e20530a70dd068e0e0a82677d4.jpeg"), + url7(7,"https://cashier-oss.oss-cn-beijing.aliyuncs.com/status/%E6%BE%B6%E6%9D%91%E5%84%9A/f66361c48515ba9b2a03d9d72829d675.jpeg"), + url8(8,"https://cashier-oss.oss-cn-beijing.aliyuncs.com/status/%E6%BE%B6%E6%9D%91%E5%84%9A/f2be456f85849922ba838e7eb4694272.jpeg"), + url9(9,"https://cashier-oss.oss-cn-beijing.aliyuncs.com/status/%E6%BE%B6%E6%9D%91%E5%84%9A/e9fca54f0320644291848338184b6c08.jpeg"), + url10(10,"https://cashier-oss.oss-cn-beijing.aliyuncs.com/status/%E6%BE%B6%E6%9D%91%E5%84%9A/e9e574fdedb43831801697a610603044.jpeg"), + url11(11,"https://cashier-oss.oss-cn-beijing.aliyuncs.com/status/%E6%BE%B6%E6%9D%91%E5%84%9A/e913ec3afe3520b9a638e16d298b401f.jpeg"), + url12(12,"https://cashier-oss.oss-cn-beijing.aliyuncs.com/status/%E6%BE%B6%E6%9D%91%E5%84%9A/e87d19da0cb5af9b53f485117b665cc9.jpeg"), + url13(13,"https://cashier-oss.oss-cn-beijing.aliyuncs.com/status/%E6%BE%B6%E6%9D%91%E5%84%9A/e847667f37d86dc4a48ffcf69bb1a964.jpeg"), + url14(14,"https://cashier-oss.oss-cn-beijing.aliyuncs.com/status/%E6%BE%B6%E6%9D%91%E5%84%9A/e731f8a883ab1ef2a71487f2eb5b0e38.jpeg"), + url15(15,"https://cashier-oss.oss-cn-beijing.aliyuncs.com/status/%E6%BE%B6%E6%9D%91%E5%84%9A/e681a9a281760f275f4b9d11c01a5869.jpeg"), + url16(16,"https://cashier-oss.oss-cn-beijing.aliyuncs.com/status/%E6%BE%B6%E6%9D%91%E5%84%9A/e41fa3916c86d43904a66d1174b81080.jpeg"), + url17(17,"https://cashier-oss.oss-cn-beijing.aliyuncs.com/status/%E6%BE%B6%E6%9D%91%E5%84%9A/e138425037e7ba3eded9ab828e3f39d2.jpeg"), + url18(18,"https://cashier-oss.oss-cn-beijing.aliyuncs.com/status/%E6%BE%B6%E6%9D%91%E5%84%9A/e0d4e933083418e6c4795fb6bf5db628.jpeg"), + url19(19,"https://cashier-oss.oss-cn-beijing.aliyuncs.com/status/%E6%BE%B6%E6%9D%91%E5%84%9A/e07b1933b0ad75f428339ffc79ee4fef.jpeg"), + url20(20,"https://cashier-oss.oss-cn-beijing.aliyuncs.com/status/%E6%BE%B6%E6%9D%91%E5%84%9A/d4ac63680f417b49210aa54cf6e03e77.jpeg"), + url21(21,"https://cashier-oss.oss-cn-beijing.aliyuncs.com/status/%E6%BE%B6%E6%9D%91%E5%84%9A/d44a8bccd46f4fa6c340e825bba5c338.jpeg"), + url22(22,"https://cashier-oss.oss-cn-beijing.aliyuncs.com/status/%E6%BE%B6%E6%9D%91%E5%84%9A/cd794c0c5dd3b212e7c46eaa7c3a85cc.jpeg"), + url23(23,"https://cashier-oss.oss-cn-beijing.aliyuncs.com/status/%E6%BE%B6%E6%9D%91%E5%84%9A/ccf1f255cd30c2aed0b421213df01863.jpeg"), + url24(24,"https://cashier-oss.oss-cn-beijing.aliyuncs.com/status/%E6%BE%B6%E6%9D%91%E5%84%9A/cbe7897bee2d057eaaeaa1604d5bd167.jpeg"), + url25(25,"https://cashier-oss.oss-cn-beijing.aliyuncs.com/status/%E6%BE%B6%E6%9D%91%E5%84%9A/cae19ed2c2c1c749e388730ef1cbb596.jpeg"), + url26(26,"https://cashier-oss.oss-cn-beijing.aliyuncs.com/status/%E6%BE%B6%E6%9D%91%E5%84%9A/c90a7e5d7a9a95a48dac8aecfab5c8e1.jpeg"), + url27(27,"https://cashier-oss.oss-cn-beijing.aliyuncs.com/status/%E6%BE%B6%E6%9D%91%E5%84%9A/c72ec32dbb7c0a42ca6a0a483a0d99ab.jpeg"), + url28(28,"https://cashier-oss.oss-cn-beijing.aliyuncs.com/status/%E6%BE%B6%E6%9D%91%E5%84%9A/c72ec32dbb7c0a42ca6a0a483a0d99ab.jpeg"), + url29(29,"https://cashier-oss.oss-cn-beijing.aliyuncs.com/status/%E6%BE%B6%E6%9D%91%E5%84%9A/c451f57dde1fcbbe4afe5766184084da.jpeg"), + url30(30,"https://cashier-oss.oss-cn-beijing.aliyuncs.com/status/%E6%BE%B6%E6%9D%91%E5%84%9A/a9a9e9eb047009f79bc22290470c2932.jpeg"), + url31(31,"https://cashier-oss.oss-cn-beijing.aliyuncs.com/status/%E6%BE%B6%E6%9D%91%E5%84%9A/aef489a444793e37e2f33aeb3fe1fe13.jpeg"), + url32(32,"https://cashier-oss.oss-cn-beijing.aliyuncs.com/status/%E6%BE%B6%E6%9D%91%E5%84%9A/b0f4a2d7ab851fb2ea01446b722c5631.jpeg"), + url33(33,"https://cashier-oss.oss-cn-beijing.aliyuncs.com/status/%E6%BE%B6%E6%9D%91%E5%84%9A/b2d643c11850042ff2932451c84940c3.jpeg"), + url34(34,"https://cashier-oss.oss-cn-beijing.aliyuncs.com/status/%E6%BE%B6%E6%9D%91%E5%84%9A/bdf1ebd620f759f703631b805216ca11.jpeg"), + url35(35,"https://cashier-oss.oss-cn-beijing.aliyuncs.com/status/%E6%BE%B6%E6%9D%91%E5%84%9A/be1e70097583d1a08a9951925d66ef33.jpeg"), + url36(36,"https://cashier-oss.oss-cn-beijing.aliyuncs.com/status/%E6%BE%B6%E6%9D%91%E5%84%9A/c3f38f6604713f13474a5e2f1145e481.jpeg"), + url37(37,"https://cashier-oss.oss-cn-beijing.aliyuncs.com/status/%E6%BE%B6%E6%9D%91%E5%84%9A/c27da8b2c154998ebf7300c49cef649a.jpeg"), + url38(38,"https://cashier-oss.oss-cn-beijing.aliyuncs.com/status/%E6%BE%B6%E6%9D%91%E5%84%9A/c26400a670209b60abcd28bfc6d22171.jpeg"), + url39(39,"https://cashier-oss.oss-cn-beijing.aliyuncs.com/status/%E6%BE%B6%E6%9D%91%E5%84%9A/a906414986b1bee60cec709dabf2103b.jpeg"), + url40(40,"https://cashier-oss.oss-cn-beijing.aliyuncs.com/status/%E6%BE%B6%E6%9D%91%E5%84%9A/a6d8629c155b59814e4d772fb5e6ec6a.jpeg"), + url41(41,"https://cashier-oss.oss-cn-beijing.aliyuncs.com/status/%E6%BE%B6%E6%9D%91%E5%84%9A/a6a78d2a64c49cf62e37475eb66e351c.jpeg"), + url42(42,"https://cashier-oss.oss-cn-beijing.aliyuncs.com/status/%E6%BE%B6%E6%9D%91%E5%84%9A/a571ccde02b075656f354b593533b00c.jpeg"), + url43(43,"https://cashier-oss.oss-cn-beijing.aliyuncs.com/status/%E6%BE%B6%E6%9D%91%E5%84%9A/a0be3632c238d1a8e24e51ff8942efc6.jpeg"), + url44(44,"https://cashier-oss.oss-cn-beijing.aliyuncs.com/status/%E6%BE%B6%E6%9D%91%E5%84%9A/9fca88b43ed09ddbeb4803ceab4f356f.jpeg"), + url45(45,"https://cashier-oss.oss-cn-beijing.aliyuncs.com/status/%E6%BE%B6%E6%9D%91%E5%84%9A/86ad712e29369b9f56ca93a94f7a5d67.jpeg"), + url46(46,"https://cashier-oss.oss-cn-beijing.aliyuncs.com/status/%E6%BE%B6%E6%9D%91%E5%84%9A/88d4ca4146196992b48a52f62a690bf0.jpeg"), + ; + + private Integer key; + + private String url; + + public Integer getKey() { + return key; + } + + public String getUrl() { + return url; + } + + LogoEnum(Integer key, String url) { + this.key = key; + this.url = url; + } + + public static String getValueByKey(Integer key) { + if(key == null){ + return ""; + } + LogoEnum[] urlEnums = values(); + for (LogoEnum logo : urlEnums) { + if (logo.key.equals(key)) { + return logo.getUrl(); + } + } + return ""; + } +} 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 abbcbbb..74f70e2 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 @@ -1,8 +1,11 @@ package com.chaozhanggui.system.cashierservice.entity.dto; +import lombok.Data; + /** * @author 12847 */ +@Data public class HomeDto { /** * 地址 @@ -17,10 +20,8 @@ public class HomeDto { * 1.理我最近 2.销量优先 3.价格优先 */ private Integer orderBy; - /** - * 附近1KM 1选中 0未选中 - */ - private Integer distance; + + private Integer other; private Integer page; @@ -50,12 +51,12 @@ public class HomeDto { this.orderBy = orderBy; } - public Integer getDistance() { - return distance; + public Integer getOther() { + return other; } - public void setDistance(Integer distance) { - this.distance = distance; + public void setOther(Integer other) { + this.other = other; } public Integer getPage() { diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/BannerInfoVo.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/BannerInfoVo.java new file mode 100644 index 0000000..f34831f --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/BannerInfoVo.java @@ -0,0 +1,43 @@ +package com.chaozhanggui.system.cashierservice.entity.vo; + +import lombok.Data; + +import java.math.BigDecimal; + +/** + * @author lyf + */ +@Data +public class BannerInfoVo { + /** + * 昵称 + */ + private String name; + /** + * 昵称 + */ + private String logo; + + /** + * 免单了多少钱 + */ + private BigDecimal money; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getLogo() { + return logo; + } + + public void setLogo(String logo) { + this.logo = logo; + } + + +} diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/BannerVO.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/BannerVO.java index efe8b20..b98784c 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/BannerVO.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/BannerVO.java @@ -8,10 +8,12 @@ import java.util.List; * @author 12847 */ public class BannerVO { - + /** + * 有多少人参与了免单 + */ private String coupons; - private List logo; + private List counponsInfo; public String getCoupons() { return coupons; @@ -21,11 +23,11 @@ public class BannerVO { this.coupons = coupons; } - public List getLogo() { - return logo; + public List getCounponsInfo() { + return counponsInfo; } - public void setLogo(List logo) { - this.logo = logo; + public void setCounponsInfo(List counponsInfo) { + this.counponsInfo = counponsInfo; } } 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 a97c41a..aa73d32 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 @@ -12,6 +12,11 @@ public class HomeVO { * 店铺名称 */ private String shopName; + + /** + * 店铺名称 + */ + private String shopImage; /** * 商品名称 */ @@ -62,6 +67,14 @@ public class HomeVO { */ private Long endTime; + public String getShopImage() { + return shopImage; + } + + public void setShopImage(String shopImage) { + this.shopImage = shopImage; + } + public Long getEndTime() { return endTime; } 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 c86702c..a21a61d 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/HomePageService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/HomePageService.java @@ -2,14 +2,18 @@ package com.chaozhanggui.system.cashierservice.service; import com.chaozhanggui.system.cashierservice.dao.*; import com.chaozhanggui.system.cashierservice.entity.*; +import com.chaozhanggui.system.cashierservice.entity.Enum.LogoEnum; import com.chaozhanggui.system.cashierservice.entity.dto.HomeDto; import com.chaozhanggui.system.cashierservice.entity.vo.*; +import com.chaozhanggui.system.cashierservice.redis.RedisUtil; import com.chaozhanggui.system.cashierservice.sign.CodeEnum; import com.chaozhanggui.system.cashierservice.sign.Result; +import com.chaozhanggui.system.cashierservice.util.*; import com.chaozhanggui.system.cashierservice.util.DateUtils; import com.chaozhanggui.system.cashierservice.util.JSONUtil; import com.chaozhanggui.system.cashierservice.util.Threads; import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; @@ -44,6 +48,8 @@ public class HomePageService { private SysDictDetailMapper sysDictDetailMapper; @Resource private TagProductDeptsMapper tagProductDeptsMapper; + @Autowired + private RedisUtil redisUtil; public Result homePage(HomeDto homeDto, String environmen) throws ExecutionException, InterruptedException { @@ -182,15 +188,31 @@ public class HomePageService { /** * 小条幅 */ - TbSystemCoupons tbSystemCoupons = productMapper.selectLimit(); - BannerVO bannerVO = new BannerVO(); - bannerVO.setCoupons(tbSystemCoupons == null?"":tbSystemCoupons.getName()); - List tbPlatformDicts = platformDictMapper.queryAllByType("icon", environment); - bannerVO.setLogo(tbPlatformDicts); - homeUpVO.setBannerVO(bannerVO); + homeUpVO.setBannerVO(bannerVoRandom()); return Result.success(CodeEnum.SUCCESS, homeUpVO); } + /** + * 小条幅随机数据 + * @return + */ + + private BannerVO bannerVoRandom(){ + BannerVO bannerVO = new BannerVO(); + List bannerInfoList = new ArrayList<>(); + for (int i = 0; i < 10; i++) { + BannerInfoVo bannerInfoVo = new BannerInfoVo(); + bannerInfoVo.setName(StringUtil.generateRandomNickname(5)); + bannerInfoVo.setLogo(LogoEnum.getValueByKey(RandomUtil.randomInt())); + bannerInfoVo.setMoney(RandomUtil.randomDecimalGenerator()); + bannerInfoList.add(bannerInfoVo); + } + bannerVO.setCounponsInfo(bannerInfoList); + bannerVO.setCoupons(redisUtil.getMessage("num")); + return bannerVO; + } + + } diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/util/RandomUtil.java b/src/main/java/com/chaozhanggui/system/cashierservice/util/RandomUtil.java new file mode 100644 index 0000000..8b3a124 --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/util/RandomUtil.java @@ -0,0 +1,36 @@ +package com.chaozhanggui.system.cashierservice.util; +import java.math.BigDecimal; +import java.math.RoundingMode; +import java.util.Random; +/** + * @author lyf + */ +public class RandomUtil { + public static BigDecimal randomDecimalGenerator(){ + + double number = generateRandomInt(2, 40); + BigDecimal bdNumber = BigDecimal.valueOf(number); + BigDecimal bdMultiplier = BigDecimal.valueOf(5); + + BigDecimal result = bdNumber.setScale(1, RoundingMode.HALF_UP); + BigDecimal multiply = result.multiply(bdMultiplier); + return multiply; + } + private static double generateRandomInt(double min, double max) { + Random random = new Random(); + return min + (max-min) * random.nextDouble(); + } + public static void main(String[] args) { + for (int i = 0; i < 20; i++) { + System.out.println("随机数为"+randomDecimalGenerator()); + } + } + + public static Integer randomInt() { + Random random = new Random(); + + // 生成1到27之间的随机整数(包括1和27) + + return random.nextInt(46) + 1; + } +} diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/util/StringUtil.java b/src/main/java/com/chaozhanggui/system/cashierservice/util/StringUtil.java index 922be6c..f54a858 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/util/StringUtil.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/util/StringUtil.java @@ -61,4 +61,26 @@ public class StringUtil { return result; } + private static final String CHINESE_CHARS = "你我他她它们这里那里多少是否好坏快慢上下左右前后高低大小长短方圆胖瘦黑白红绿蓝黄紫粉红桔红橙黄棕灰褐"; + + // 生成随机中文昵称 + public static String generateRandomNickname(int length) { + StringBuilder sb = new StringBuilder(); + Random random = new Random(); + for (int i = 0; i < length; i++) { + int index = random.nextInt(CHINESE_CHARS.length()); + char randomChar = CHINESE_CHARS.charAt(index); + sb.append(randomChar); + } + return desensitizeNickname(sb.toString()); + } + + // 对昵称进行脱敏处理 + public static String desensitizeNickname(String nickname) { + if (nickname == null || nickname.length() != 5) { + return nickname; + } + return nickname.charAt(0) + "***" + nickname.charAt(4); + } + } From f8c53d35485b9bdb4bf843563a0b66756c97d597 Mon Sep 17 00:00:00 2001 From: wangw <1594593906@qq.com> Date: Thu, 11 Apr 2024 16:55:40 +0800 Subject: [PATCH 10/13] =?UTF-8?q?=E8=8F=9C=E5=8D=95=20=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E5=8F=82=E6=95=B0=20=E7=94=A8=E6=88=B7=E9=BB=98=E8=AE=A4?= =?UTF-8?q?=E5=A4=B4=E5=83=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dao/SysDictDetailMapper.java | 13 -- .../system/cashierservice/entity/SysDict.java | 86 +---------- .../cashierservice/entity/SysDictDetail.java | 91 +---------- .../service/HomePageService.java | 9 -- .../cashierservice/service/LoginService.java | 2 +- .../resources/mapper/SysDictDetailMapper.xml | 146 +----------------- 6 files changed, 11 insertions(+), 336 deletions(-) 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 70a1981..61e55c5 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/dao/SysDictDetailMapper.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/dao/SysDictDetailMapper.java @@ -11,21 +11,8 @@ import java.util.List; @Component @Mapper public interface SysDictDetailMapper { - int deleteByPrimaryKey(Long detailId); - - int insert(SysDictDetail record); - - int insertSelective(SysDictDetail record); - - 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); } \ No newline at end of file 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 533f143..4ef8a18 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/entity/SysDict.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/SysDict.java @@ -1,97 +1,19 @@ package com.chaozhanggui.system.cashierservice.entity; +import lombok.Data; + import java.io.Serializable; import java.util.Date; +@Data public class SysDict implements Serializable { private Long dictId; + private String dictName; private String name; private String description; - private String createBy; - - private String updateBy; - - private Date createTime; - - private Date updateTime; - private Integer isChild; - - private static final long serialVersionUID = 1L; - - public String getDictName() { - return dictName; - } - - public void setDictName(String dictName) { - this.dictName = dictName; - } - - public Integer getIsChild() { - return isChild; - } - - public void setIsChild(Integer isChild) { - this.isChild = isChild; - } - - public Long getDictId() { - return dictId; - } - - public void setDictId(Long dictId) { - this.dictId = dictId; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name == null ? null : name.trim(); - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description == null ? null : description.trim(); - } - - public String getCreateBy() { - return createBy; - } - - public void setCreateBy(String createBy) { - this.createBy = createBy == null ? null : createBy.trim(); - } - - public String getUpdateBy() { - return updateBy; - } - - public void setUpdateBy(String updateBy) { - this.updateBy = updateBy == null ? null : updateBy.trim(); - } - - public Date getCreateTime() { - return createTime; - } - - public void setCreateTime(Date createTime) { - this.createTime = createTime; - } - - public Date getUpdateTime() { - return updateTime; - } - - public void setUpdateTime(Date updateTime) { - this.updateTime = updateTime; - } } \ No newline at end of file diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/SysDictDetail.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/SysDictDetail.java index 6e74012..7a43ee2 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/entity/SysDictDetail.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/SysDictDetail.java @@ -1,98 +1,15 @@ package com.chaozhanggui.system.cashierservice.entity; +import lombok.Data; + import java.io.Serializable; import java.util.Date; +@Data public class SysDictDetail implements Serializable { - private Long detailId; - - private Long dictId; + private String dictName; private String label; private String value; - - private Integer dictSort; - - private String createBy; - - private String updateBy; - - private Date createTime; - - private Date updateTime; - - private static final long serialVersionUID = 1L; - - public Long getDetailId() { - return detailId; - } - - public void setDetailId(Long detailId) { - this.detailId = detailId; - } - - public Long getDictId() { - return dictId; - } - - public void setDictId(Long dictId) { - this.dictId = dictId; - } - - public String getLabel() { - return label; - } - - public void setLabel(String label) { - this.label = label == null ? null : label.trim(); - } - - public String getValue() { - return value; - } - - public void setValue(String value) { - this.value = value == null ? null : value.trim(); - } - - public Integer getDictSort() { - return dictSort; - } - - public void setDictSort(Integer dictSort) { - this.dictSort = dictSort; - } - - public String getCreateBy() { - return createBy; - } - - public void setCreateBy(String createBy) { - this.createBy = createBy == null ? null : createBy.trim(); - } - - public String getUpdateBy() { - return updateBy; - } - - public void setUpdateBy(String updateBy) { - this.updateBy = updateBy == null ? null : updateBy.trim(); - } - - public Date getCreateTime() { - return createTime; - } - - public void setCreateTime(Date createTime) { - this.createTime = createTime; - } - - public Date getUpdateTime() { - return updateTime; - } - - public void setUpdateTime(Date updateTime) { - this.updateTime = updateTime; - } } \ No newline at end of file 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 a21a61d..fee0efe 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/HomePageService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/HomePageService.java @@ -130,15 +130,6 @@ public class HomePageService { return Result.success(CodeEnum.SUCCESS, homeVOList); } - private List tagList(String tag){ - if (tag == null){ - return new ArrayList<>(); - }else { - String[] arr = tag.split(","); - return new ArrayList<>(Arrays.asList(arr)); - } - } - public Result homePageUp(String environment) { HomeUpVO homeUpVO = new HomeUpVO(); //轮播图 diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/LoginService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/LoginService.java index 0e9532c..d8127b8 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/LoginService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/LoginService.java @@ -167,7 +167,7 @@ public class LoginService { userInfo.setConsumeAmount(BigDecimal.ZERO); userInfo.setTotalScore(0); userInfo.setLockScore(0); - userInfo.setHeadImg(""); + userInfo.setHeadImg("https://cashier-oss.oss-cn-beijing.aliyuncs.com/upload/20240411/a2be5869bfa24d72a4782f695cc53ed1.png");//默认头像 userInfo.setNickName(nickName); userInfo.setTelephone(phone); userInfo.setStatus(Byte.parseByte("1")); diff --git a/src/main/resources/mapper/SysDictDetailMapper.xml b/src/main/resources/mapper/SysDictDetailMapper.xml index 4fb74ac..3201417 100644 --- a/src/main/resources/mapper/SysDictDetailMapper.xml +++ b/src/main/resources/mapper/SysDictDetailMapper.xml @@ -1,155 +1,13 @@ - - - - - - - - - - - - - detail_id, dict_id, label, value, dict_sort, create_by, update_by, create_time, update_time - - + - + - - delete from sys_dict_detail - where detail_id = #{detailId,jdbcType=BIGINT} - - - insert into sys_dict_detail (detail_id, dict_id, label, - value, dict_sort, create_by, - update_by, create_time, update_time - ) - values (#{detailId,jdbcType=BIGINT}, #{dictId,jdbcType=BIGINT}, #{label,jdbcType=VARCHAR}, - #{value,jdbcType=VARCHAR}, #{dictSort,jdbcType=INTEGER}, #{createBy,jdbcType=VARCHAR}, - #{updateBy,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP} - ) - - - insert into sys_dict_detail - - - detail_id, - - - dict_id, - - - label, - - - value, - - - dict_sort, - - - create_by, - - - update_by, - - - create_time, - - - update_time, - - - - - #{detailId,jdbcType=BIGINT}, - - - #{dictId,jdbcType=BIGINT}, - - - #{label,jdbcType=VARCHAR}, - - - #{value,jdbcType=VARCHAR}, - - - #{dictSort,jdbcType=INTEGER}, - - - #{createBy,jdbcType=VARCHAR}, - - - #{updateBy,jdbcType=VARCHAR}, - - - #{createTime,jdbcType=TIMESTAMP}, - - - #{updateTime,jdbcType=TIMESTAMP}, - - - - - update sys_dict_detail - - - dict_id = #{dictId,jdbcType=BIGINT}, - - - label = #{label,jdbcType=VARCHAR}, - - - value = #{value,jdbcType=VARCHAR}, - - - dict_sort = #{dictSort,jdbcType=INTEGER}, - - - create_by = #{createBy,jdbcType=VARCHAR}, - - - update_by = #{updateBy,jdbcType=VARCHAR}, - - - create_time = #{createTime,jdbcType=TIMESTAMP}, - - - update_time = #{updateTime,jdbcType=TIMESTAMP}, - - - where detail_id = #{detailId,jdbcType=BIGINT} - - - update sys_dict_detail - set dict_id = #{dictId,jdbcType=BIGINT}, - label = #{label,jdbcType=VARCHAR}, - value = #{value,jdbcType=VARCHAR}, - dict_sort = #{dictSort,jdbcType=INTEGER}, - create_by = #{createBy,jdbcType=VARCHAR}, - update_by = #{updateBy,jdbcType=VARCHAR}, - create_time = #{createTime,jdbcType=TIMESTAMP}, - update_time = #{updateTime,jdbcType=TIMESTAMP} - where detail_id = #{detailId,jdbcType=BIGINT} - \ No newline at end of file From 7d3fe9deb7e930b9211a26d7c5c796829d0e6da7 Mon Sep 17 00:00:00 2001 From: wangw <1594593906@qq.com> Date: Fri, 12 Apr 2024 09:56:32 +0800 Subject: [PATCH 11/13] =?UTF-8?q?=E7=BB=8F=E7=BA=AC=E5=BA=A6=20=E8=A7=92?= =?UTF-8?q?=E7=82=B9=E8=AE=A1=E7=AE=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cashierservice/auth/LoginFilter.java | 2 +- .../service/HomePageService.java | 1 + .../cashierservice/util/LocationUtils.java | 78 +++++++++++++------ 3 files changed, 55 insertions(+), 26 deletions(-) diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/auth/LoginFilter.java b/src/main/java/com/chaozhanggui/system/cashierservice/auth/LoginFilter.java index 23e64c9..2c96100 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/auth/LoginFilter.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/auth/LoginFilter.java @@ -78,7 +78,7 @@ public class LoginFilter implements Filter { // 判断用户TOKEN是否存在 String token = request.getHeader("token"); if (StringUtils.isBlank(token)) { - Result result = new Result(CodeEnum.TOKEN_EXEIST); + Result result = new Result(CodeEnum.TOKEN_EXPIRED); String jsonString = JSONObject.toJSONString(result); JSONObject jsonObject = JSONObject.parseObject(jsonString, JSONObject.class); response.getWriter().print(jsonObject); 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 fee0efe..9f6c2c4 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/HomePageService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/HomePageService.java @@ -99,6 +99,7 @@ public class HomePageService { List tbPlatformDicts = platformDictMapper.queryByIdList(shopTagIds); homeVO.setShopTag(JSONUtil.parseListTNewList(tbPlatformDicts, TagVo.class)); } + } } for (TbProduct tbProduct : product.get()) { diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/util/LocationUtils.java b/src/main/java/com/chaozhanggui/system/cashierservice/util/LocationUtils.java index a98a272..791eb32 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/util/LocationUtils.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/util/LocationUtils.java @@ -9,30 +9,18 @@ import static java.lang.Math.sin; public class LocationUtils { public static String district(String keywords) { - Map param=new HashMap<>(); + Map param = new HashMap<>(); //超掌柜生活-用户端 - param.put("key","7a7f2e4790ea222660a027352ee3af39"); - param.put("keywords",keywords); - param.put("subdistrict","2"); - param.put("extensions","base"); + param.put("key", "7a7f2e4790ea222660a027352ee3af39"); + param.put("keywords", keywords); + param.put("subdistrict", "2"); + param.put("extensions", "base"); String s = HttpClientUtil.doGet("https://restapi.amap.com/v3/config/district", param); return s; } - /** - * 将角度转化为弧度 - */ - public static double radians(double d) { - return d * Math.PI / 180.0; - } /** * 根据两点经纬度坐标计算直线距离 - *

- * S = 2arcsin√sin²(a/2)+cos(lat1)*cos(lat2)*sin²(b/2) ̄*6378.137 - *

- * 1. lng1 lat1 表示A点经纬度,lng2 lat2 表示B点经纬度;
- * 2. a=lat1 – lat2 为两点纬度之差 b=lng1 -lng2 为两点经度之差;
- * 3. 6378.137为地球赤道半径,单位为千米; * * @param lng1 点1经度 * @param lat1 点1纬度 @@ -43,7 +31,7 @@ public class LocationUtils { */ public static double getDistanceFrom2LngLat(double lng1, double lat1, double lng2, double lat2) { //将角度转化为弧度 - double radLng1 = radians(lng1); + double radLng1 = radians(lng1);//d * Math.PI / 180.0; double radLat1 = radians(lat1); double radLng2 = radians(lng2); double radLat2 = radians(lat2); @@ -54,16 +42,56 @@ public class LocationUtils { return 2 * asin(sqrt(sin(a / 2) * sin(a / 2) + cos(radLat1) * cos(radLat2) * sin(b / 2) * sin(b / 2))) * 6378.137; } + /** + * @param longitude 经度 + * @param latitude 纬度 + * @param distanceInKm 范围(千米) + * return Map stringMap + * 右顶点 double[] leftTopPoints = stringMap.get("rightTopPoint"); + * 左顶点 double[] leftBottomPoints = stringMap.get("leftBottomPoint"); + */ + public static Map returnLLSquarePoint(double longitude, double latitude, double distanceInKm) { + Map squareMap = new HashMap<>(); + // 地球平均半径,单位:千米 + double earthRadius = 6378.137; + // 将距离转换为弧度 + double radialDistance = distanceInKm / earthRadius; + // 计算纬度上变化对应的角度 + double dLatitude = Math.toDegrees(2 * Math.asin(Math.sin(radialDistance / 2) / Math.cos(Math.toRadians(latitude)))); + // 计算经度上变化对应的角度,这里需要考虑纬度对距离的影响 + // 使用Haversine公式来估算在给定纬度上,距离对应的经度变化 + double estimatedLongitudeDistance = getDistanceFrom2LngLat(latitude, longitude, latitude, longitude + 0.01); // 假设0.01度经度变化对应的距离 + double dLongitude = distanceInKm / estimatedLongitudeDistance * 0.0192736; // 根据比例计算经度变化 + // 正方形四个顶点的坐标 + double[] rightTopPoint = {latitude + dLatitude / 2, longitude + dLongitude / 2}; + double[] leftBottomPoint = {latitude - dLatitude / 2, longitude - dLongitude / 2}; + squareMap.put("rightTopPoint", rightTopPoint); + squareMap.put("leftBottomPoint", leftBottomPoint); + // 打印结果 +// System.out.println("rightTop:" + rightTopPoint[0] + "======" + rightTopPoint[1]); +// System.out.println("leftBottom:" + leftBottomPoint[0] + "======" + leftBottomPoint[1]); + return squareMap; + } + + /** + * 将角度转化为弧度 + */ + public static double radians(double d) { + return d * Math.PI / 180.0; + } + // public static void main(String[] args) { -// // 示例经纬度坐标 -// double lat1 = 108.954398; -// double lon1 = 34.308687; +// Map stringMap = returnLLSquarePoint(108.954398, 34.308687, 1); +// double[] leftTopPoints = stringMap.get("rightTopPoint"); +// double[] leftBottomPoints = stringMap.get("leftBottomPoint"); // -// double lat2 = 108.953555; -// double lon2 = 34.276169; +// double lat2 = 108.954398; +// double lon2 = 34.308687; // // // 计算距离 -// double distance = getDistanceFrom2LngLat(lat1, lon1, lat2, lon2); -// System.out.println("Distance between the two points is: " + distance + " km"); +// double distance1 = getDistanceFrom2LngLat(leftTopPoints[1], leftTopPoints[0], lat2, lon2); +// double distance2 = getDistanceFrom2LngLat(leftBottomPoints[1], leftBottomPoints[0], lat2, lon2); +// System.out.println("Distance between the two points is: " + distance1 + " km"); +// System.out.println("Distance between the two points is: " + distance2 + " km"); // } } From d7dfeee1592155d9580966cfdaa2b79d57b84bf4 Mon Sep 17 00:00:00 2001 From: wangw <1594593906@qq.com> Date: Mon, 15 Apr 2024 10:07:53 +0800 Subject: [PATCH 12/13] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=20=E5=A4=B4=E5=83=8F/=E6=98=B5=E7=A7=B0=20?= =?UTF-8?q?=E8=A7=86=E9=A2=91=E5=8F=B7/=E5=B0=8F=E7=A8=8B=E5=BA=8F/?= =?UTF-8?q?=E5=85=AC=E4=BC=97=E5=8F=B7mapper=20=20=E6=9A=82=E6=9C=AA?= =?UTF-8?q?=E6=8A=95=E5=85=A5=E4=BD=BF=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cashierservice/auth/LoginFilter.java | 16 +- .../controller/LoginContoller.java | 9 + .../cashierservice/dao/TbShopVideoMapper.java | 32 ++++ .../cashierservice/entity/TbShopVideo.java | 159 ++++++++++++++++++ .../cashierservice/service/LoginService.java | 9 + .../service/TbShopVideoService.java | 38 +++++ .../resources/mapper/TbShopVideoMapper.xml | 78 +++++++++ 7 files changed, 337 insertions(+), 4 deletions(-) create mode 100644 src/main/java/com/chaozhanggui/system/cashierservice/dao/TbShopVideoMapper.java create mode 100644 src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopVideo.java create mode 100644 src/main/java/com/chaozhanggui/system/cashierservice/service/TbShopVideoService.java create mode 100644 src/main/resources/mapper/TbShopVideoMapper.xml diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/auth/LoginFilter.java b/src/main/java/com/chaozhanggui/system/cashierservice/auth/LoginFilter.java index 2c96100..ad78a3c 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/auth/LoginFilter.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/auth/LoginFilter.java @@ -67,6 +67,7 @@ public class LoginFilter implements Filter { chain.doFilter(req, resp); return; } + //environment 环境标识 wx app 后续environment不可为空 String environment = request.getHeader("environment"); //token校验目前只对app生效 @@ -85,10 +86,17 @@ public class LoginFilter implements Filter { response.getWriter().flush();//流里边的缓存刷出 return; } - //获取当前登录人的用户id - String loginName = TokenUtil.parseParamFromToken(token).getString("userId"); - //获取redis中的token - String message = redisUtil.getMessage(RedisCst.ONLINE_APP_USER.concat(loginName)); + String message = ""; + if(environment.equals("app")){ + //获取当前登录人的用户id + String loginName = TokenUtil.parseParamFromToken(token).getString("userId"); + //获取redis中的token + message = redisUtil.getMessage(RedisCst.ONLINE_APP_USER.concat(loginName)); + }else if(environment.equals("wx")){ + //获取当前登录人的用户id + String openId = TokenUtil.parseParamFromToken(token).getString("openId"); + message = redisUtil.getMessage(RedisCst.ONLINE_USER.concat(openId)); + } if (StringUtils.isBlank(message)) { Result result = new Result(CodeEnum.TOKEN_EXPIRED); String jsonString = JSONObject.toJSONString(result); diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/controller/LoginContoller.java b/src/main/java/com/chaozhanggui/system/cashierservice/controller/LoginContoller.java index 1e669b3..c6bbeb9 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/controller/LoginContoller.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/controller/LoginContoller.java @@ -6,6 +6,7 @@ import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.chaozhanggui.system.cashierservice.dao.TbMerchantAccountMapper; import com.chaozhanggui.system.cashierservice.entity.TbMerchantAccount; +import com.chaozhanggui.system.cashierservice.entity.TbUserInfo; import com.chaozhanggui.system.cashierservice.entity.dto.AuthUserDto; import com.chaozhanggui.system.cashierservice.entity.dto.OnlineUserDto; import com.chaozhanggui.system.cashierservice.redis.RedisCst; @@ -221,6 +222,14 @@ public class LoginContoller { return loginService.userInfo(userId, shopId); } + @PostMapping("/upUserInfo") + public Result userInfo(@RequestHeader String token, @RequestBody TbUserInfo userInfo) { + String userId = TokenUtil.parseParamFromToken(token).getString("userId"); + userInfo.setId(Integer.valueOf(userId)); + userInfo.setUpdatedAt(System.currentTimeMillis()); + return loginService.upUserInfo(userInfo); + } + /** * 用户注册 diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbShopVideoMapper.java b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbShopVideoMapper.java new file mode 100644 index 0000000..7fa42de --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbShopVideoMapper.java @@ -0,0 +1,32 @@ +package com.chaozhanggui.system.cashierservice.dao; + +import com.chaozhanggui.system.cashierservice.entity.TbShopVideo; + +import java.util.List; + +/** + * (TbShopVideo)表数据库访问层 + * + * @author ww + * @since 2024-04-12 14:50:09 + */ +public interface TbShopVideoMapper { + + /** + * 通过ID查询单条数据 + * + * @param id 主键 + * @return 实例对象 + */ + TbShopVideo queryById(Integer id); + + /** + * 查询数据 + * + * @param tbShopVideo 查询条件 + * @return 对象列表 + */ + List queryAll(TbShopVideo tbShopVideo); + +} + diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopVideo.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopVideo.java new file mode 100644 index 0000000..6123ff4 --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopVideo.java @@ -0,0 +1,159 @@ +package com.chaozhanggui.system.cashierservice.entity; + +import java.util.Date; +import java.io.Serializable; + +/** + * 商户视频号(TbShopVideo)实体类 + * + * @author ww + * @since 2024-04-12 14:50:09 + */ +public class TbShopVideo implements Serializable { + private static final long serialVersionUID = 521986900418854409L; + + private Integer id; + /** + * 店铺id + */ + private Integer shopId; + /** + * 1-公众号;2-小程序;3-视频号 + */ + private Integer type; + /** + * 描述信息 + */ + private String name; + /** + * 渠道id(视频号id) + */ + private Integer channelId; + /** + * 创建时间 + */ + private Date createdTime; + /** + * 更新时间 + */ + private Date updateTime; + /** + * 资源Id(视频号id)(公众号id) + */ + private Integer sourceId; + /** + * 资源地址 + */ + private String sourceUrl; + /** + * 0:关闭;1:开启; + */ + private Integer status; + /** + * 视频id + */ + private Integer videoId; + /** + * 视频地址 + */ + private String videoUrl; + + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public Integer getShopId() { + return shopId; + } + + public void setShopId(Integer shopId) { + this.shopId = shopId; + } + + public Integer getType() { + return type; + } + + public void setType(Integer type) { + this.type = type; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Integer getChannelId() { + return channelId; + } + + public void setChannelId(Integer channelId) { + this.channelId = channelId; + } + + public Date getCreatedTime() { + return createdTime; + } + + public void setCreatedTime(Date createdTime) { + this.createdTime = createdTime; + } + + public Date getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(Date updateTime) { + this.updateTime = updateTime; + } + + public Integer getSourceId() { + return sourceId; + } + + public void setSourceId(Integer sourceId) { + this.sourceId = sourceId; + } + + public String getSourceUrl() { + return sourceUrl; + } + + public void setSourceUrl(String sourceUrl) { + this.sourceUrl = sourceUrl; + } + + public Integer getStatus() { + return status; + } + + public void setStatus(Integer status) { + this.status = status; + } + + public Integer getVideoId() { + return videoId; + } + + public void setVideoId(Integer videoId) { + this.videoId = videoId; + } + + public String getVideoUrl() { + return videoUrl; + } + + public void setVideoUrl(String videoUrl) { + this.videoUrl = videoUrl; + } + +} + diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/LoginService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/LoginService.java index d8127b8..57217a6 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/LoginService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/LoginService.java @@ -123,7 +123,11 @@ public class LoginService { tbShopUser.setUserId(userInfo.getId().toString()); tbShopUser.setMiniOpenId(openId); tbShopUser.setCreatedAt(System.currentTimeMillis()); + tbShopUser.setUpdatedAt(System.currentTimeMillis()); tbShopUserMapper.insert(tbShopUser); + }else { + tbShopUser.setUpdatedAt(System.currentTimeMillis()); + tbShopUserMapper.updateByPrimaryKey(tbShopUser); } shopMap.put("shopId", tbShopUser.getShopId()); shopMap.put("name", tbShopInfo.getShopName()); @@ -304,6 +308,11 @@ public class LoginService { return Result.success(CodeEnum.ENCRYPT, map); } + public Result upUserInfo(TbUserInfo userInfo){ + tbUserInfoMapper.updateByPrimaryKeySelective(userInfo); + return Result.success(CodeEnum.SUCCESS); + } + public static void main(String[] args) { for (int i = 0; i < 10; i++) { System.out.println(RandomUtil.randomNumbers(10)); diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/TbShopVideoService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/TbShopVideoService.java new file mode 100644 index 0000000..4ef257f --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/TbShopVideoService.java @@ -0,0 +1,38 @@ +package com.chaozhanggui.system.cashierservice.service; + +import com.chaozhanggui.system.cashierservice.dao.TbShopVideoMapper; +import com.chaozhanggui.system.cashierservice.entity.TbShopVideo; +import com.chaozhanggui.system.cashierservice.sign.CodeEnum; +import com.chaozhanggui.system.cashierservice.sign.Result; + +import javax.annotation.Resource; + +/** + * 视频号 公众号 + * @author ww + * @since 2024-04-12 14:50:10 + */ +public class TbShopVideoService { + + @Resource + private TbShopVideoMapper tbShopVideoMapper; + + /** + * 通过ID查询单条数据 + * + * @param id 主键 + * @return 实例对象 + */ + public Result queryById(Integer id) { + return Result.success(CodeEnum.ENCRYPT,tbShopVideoMapper.queryById(id)); + } + + /** + * @param tbShopVideo 筛选条件 + * @return 查询结果 + */ + public Result queryAll(TbShopVideo tbShopVideo) { + tbShopVideo.setStatus(1); + return Result.success(CodeEnum.ENCRYPT,tbShopVideoMapper.queryAll(tbShopVideo)); + } +} diff --git a/src/main/resources/mapper/TbShopVideoMapper.xml b/src/main/resources/mapper/TbShopVideoMapper.xml new file mode 100644 index 0000000..bf6fc25 --- /dev/null +++ b/src/main/resources/mapper/TbShopVideoMapper.xml @@ -0,0 +1,78 @@ + + + + + + + + + + + + + + + + + + + id + , shop_id, type, name, channel_id, source_id, source_url, status ,created_time, update_time + + + + + + + + + From 46cd954abf568dae505ec70a32c64bf66b54f76b Mon Sep 17 00:00:00 2001 From: liuyingfang <1357764963@qq.com> Date: Mon, 15 Apr 2024 10:15:16 +0800 Subject: [PATCH 13/13] =?UTF-8?q?=E9=A6=96=E9=A1=B5=E4=B8=8B=E5=8D=8A?= =?UTF-8?q?=E6=9B=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dao/TbMerchantCouponMapper.java | 6 +- .../entity/TbMerchantCoupon.java | 1 + .../cashierservice/entity/dto/HomeDto.java | 60 ++++--------------- .../entity/vo/CouAndShopVo.java | 41 +++++++++++++ .../cashierservice/entity/vo/HomeVO.java | 6 +- .../service/HomePageService.java | 47 ++++++++++----- .../cashierservice/util/LocationUtils.java | 45 ++++++++------ .../mapper/TbMerchantCouponMapper.xml | 46 +++++++++++--- 8 files changed, 157 insertions(+), 95 deletions(-) create mode 100644 src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/CouAndShopVo.java diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbMerchantCouponMapper.java b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbMerchantCouponMapper.java index 96c03c3..76d881b 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbMerchantCouponMapper.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbMerchantCouponMapper.java @@ -1,6 +1,8 @@ package com.chaozhanggui.system.cashierservice.dao; import com.chaozhanggui.system.cashierservice.entity.TbMerchantCoupon; +import com.chaozhanggui.system.cashierservice.entity.dto.HomeDto; +import com.chaozhanggui.system.cashierservice.entity.vo.CouAndShopVo; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; import org.springframework.data.domain.Pageable; @@ -36,7 +38,9 @@ public interface TbMerchantCouponMapper { List queryAllByLimit(TbMerchantCoupon tbMerchantCoupon, @Param("pageable") Pageable pageable); - List queryAllByPage(@Param("page")Integer page, @Param("size")Integer size); + List queryAllByPage(@Param("pageable")Integer page, @Param("sizeable")Integer size, @Param("rightTopLng") Double rightTopLng, + @Param("rightTopLat")Double rightTopLat, @Param("leftBottomLng")Double leftBottomLng, @Param("leftBottomLat")Double leftBottomLat, + @Param("cities")String cities, @Param("order")String order,@Param("lng")String lng,@Param("lat")String lat); /** * 统计总行数 * diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbMerchantCoupon.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbMerchantCoupon.java index 8e922e5..c71db04 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbMerchantCoupon.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbMerchantCoupon.java @@ -135,6 +135,7 @@ public class TbMerchantCoupon implements Serializable { private String merchantId; + public Integer getId() { return id; } 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 74f70e2..a0a4a63 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 @@ -12,12 +12,20 @@ public class HomeDto { */ private String address; /** - * 品类 + * 经度 + */ + private String lat; + /** + * 纬度 + */ + private String lng; + /** + * 品类 1.附近1Km */ private String type; /** - * 1.理我最近 2.销量优先 3.价格优先 + * 1.离我最近 2.销量优先 3.价格优先 */ private Integer orderBy; @@ -26,52 +34,4 @@ public class HomeDto { private Integer page; private Integer size; - - public String getAddress() { - return address; - } - - public void setAddress(String address) { - this.address = address; - } - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - - public Integer getOrderBy() { - return orderBy; - } - - public void setOrderBy(Integer orderBy) { - this.orderBy = orderBy; - } - - public Integer getOther() { - return other; - } - - public void setOther(Integer other) { - this.other = other; - } - - public Integer getPage() { - return page; - } - - public void setPage(Integer page) { - this.page = page; - } - - public Integer getSize() { - return size; - } - - public void setSize(Integer size) { - this.size = size; - } } diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/CouAndShopVo.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/CouAndShopVo.java new file mode 100644 index 0000000..1610d4f --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/CouAndShopVo.java @@ -0,0 +1,41 @@ +package com.chaozhanggui.system.cashierservice.entity.vo; + +import lombok.Data; + +/** + * @author lyf + */ +@Data +public class CouAndShopVo { + /** + * 自增 + */ + private Integer id; + /** + * 优惠券名称 + */ + private String title; + + private String shopId; + /** + * 优惠金额 + */ + private Double amount; + /** + * 发放数量 + */ + private Integer number; + /** + * 折扣 ,一位小数 + */ + private Float ratio; + + /** + * 关联商品Id + */ + private String relationIds; + + private String shopName; + + private String logo; +} 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 aa73d32..fb05d93 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 @@ -36,7 +36,7 @@ public class HomeVO { /** * 折扣 */ - private Float discount; + private BigDecimal discount; /** * 共省金额 */ @@ -164,11 +164,11 @@ public class HomeVO { this.salePrice = salePrice; } - public Float getDiscount() { + public BigDecimal getDiscount() { return discount; } - public void setDiscount(Float discount) { + public void setDiscount(BigDecimal discount) { this.discount = discount; } 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 9f6c2c4..b4267bc 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/HomePageService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/HomePageService.java @@ -19,11 +19,9 @@ import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.math.BigDecimal; +import java.math.BigInteger; import java.math.RoundingMode; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; +import java.util.*; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ExecutionException; import java.util.stream.Collectors; @@ -59,13 +57,23 @@ public class HomePageService { } else { beginNo = (homeDto.getPage() - 1) * homeDto.getSize(); } - //优惠卷 - List tbMerchantCoupons = merchantCouponMapper.queryAllByPage(beginNo, homeDto.getSize()); + //经纬度(附近一km) + Map topAndBottomMap = new HashMap<>(); + List tbMerchantCoupons = new ArrayList<>(); + if (homeDto.getOther() != null && homeDto.getOther() == 1){ + topAndBottomMap = LocationUtils.returnLLSquarePoint(Double.parseDouble(homeDto.getLng()), Double.parseDouble(homeDto.getLat()), 1); + tbMerchantCoupons = merchantCouponMapper.queryAllByPage(beginNo, homeDto.getSize(), topAndBottomMap.get("rightTopPoint")[0],topAndBottomMap.get("rightTopPoint")[1], + topAndBottomMap.get("leftBottomPoint")[0],topAndBottomMap.get("leftBottomPoint")[1],homeDto.getAddress(),homeDto.getOrderBy().toString(),homeDto.getLng(),homeDto.getLat()); + }else { + tbMerchantCoupons = merchantCouponMapper.queryAllByPage(beginNo, homeDto.getSize(), null,null,null,null, + homeDto.getAddress(),homeDto.getOrderBy().toString(),homeDto.getLng(),homeDto.getLat()); + } + //统计shopId,以及productId List shopIds = new ArrayList<>(); List productIds = new ArrayList<>(); List productIdsInt = new ArrayList<>(); - for (TbMerchantCoupon coupon : tbMerchantCoupons) { + for (CouAndShopVo coupon : tbMerchantCoupons) { shopIds.add(coupon.getShopId()); productIds.add(coupon.getRelationIds()); productIdsInt.add(Integer.valueOf(coupon.getRelationIds())); @@ -82,10 +90,9 @@ public class HomePageService { //组装 List homeVOList = new ArrayList<>(); - for (TbMerchantCoupon o : tbMerchantCoupons) { + for (CouAndShopVo o : tbMerchantCoupons) { HomeVO homeVO = new HomeVO(); homeVO.setId(o.getId()); - homeVO.setDiscount(o.getRatio()); for (TbShopInfo tbShopInfo : shopInfo.get()) { if (o.getShopId().equals(tbShopInfo.getId().toString())) { homeVO.setShopName(tbShopInfo.getShopName()); @@ -104,18 +111,26 @@ public class HomePageService { } for (TbProduct tbProduct : product.get()) { if (o.getRelationIds().equals(tbProduct.getId().toString())) { - homeVO.setProductName(tbProduct.getName()); + homeVO.setProductName(o.getTitle()); homeVO.setImage(tbProduct.getCoverImg()); homeVO.setProductId(tbProduct.getId()); } } 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"))))); + //原价 + if (tbProductSku.getSalePrice().compareTo(BigDecimal.ZERO)==0){ + homeVO.setOriginPrice(BigDecimal.ZERO); + homeVO.setDiscount(BigDecimal.ZERO); + }else { + homeVO.setOriginPrice(tbProductSku.getSalePrice()); + homeVO.setDiscount(new BigDecimal(o.getAmount()).divide(tbProductSku.getSalePrice(),2,RoundingMode.DOWN).multiply(BigDecimal.TEN)); + } + //销量 + homeVO.setRealSalesNumber(new BigDecimal(o.getNumber())); + //现价 + homeVO.setSalePrice(new BigDecimal(o.getAmount().toString())); + // 共省金额 homeVO.setSave(homeVO.getOriginPrice().subtract(homeVO.getSalePrice())); } } @@ -161,7 +176,7 @@ public class HomePageService { 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()); + o.setDiscount(multiply); } else { o.setDiscount(null); } diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/util/LocationUtils.java b/src/main/java/com/chaozhanggui/system/cashierservice/util/LocationUtils.java index 791eb32..8066463 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/util/LocationUtils.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/util/LocationUtils.java @@ -43,12 +43,14 @@ public class LocationUtils { } /** - * @param longitude 经度 - * @param latitude 纬度 + * @param longitude 经度 108 + * @param latitude 纬度 34 * @param distanceInKm 范围(千米) + * 大于左下的经度lat,小于右上的经度lat + * 大于左下的纬度lng,小于右上的纬度lng * return Map stringMap - * 右顶点 double[] leftTopPoints = stringMap.get("rightTopPoint"); - * 左顶点 double[] leftBottomPoints = stringMap.get("leftBottomPoint"); + * 右上顶点 double[] leftTopPoints = stringMap.get("rightTopPoint"); + * 左下点 double[] leftBottomPoints = stringMap.get("leftBottomPoint"); */ public static Map returnLLSquarePoint(double longitude, double latitude, double distanceInKm) { Map squareMap = new HashMap<>(); @@ -67,31 +69,38 @@ public class LocationUtils { double[] leftBottomPoint = {latitude - dLatitude / 2, longitude - dLongitude / 2}; squareMap.put("rightTopPoint", rightTopPoint); squareMap.put("leftBottomPoint", leftBottomPoint); - // 打印结果 -// System.out.println("rightTop:" + rightTopPoint[0] + "======" + rightTopPoint[1]); -// System.out.println("leftBottom:" + leftBottomPoint[0] + "======" + leftBottomPoint[1]); + // 打印结果rightTopPoint[0]纬度lng,rightTopPoint[1]经度lat + System.out.println("rightTop:" + rightTopPoint[0] + "======" + rightTopPoint[1]); + System.out.println("leftBottom:" + leftBottomPoint[0] + "======" + leftBottomPoint[1]); return squareMap; } + /** * 将角度转化为弧度 */ public static double radians(double d) { return d * Math.PI / 180.0; } + //1KM + public static void main(String[] args) { + Map stringMap = returnLLSquarePoint(108.954398, 34.308687, 1); + double[] leftTopPoints = stringMap.get("rightTopPoint"); + double[] leftBottomPoints = stringMap.get("leftBottomPoint"); + double lat2 = 108.975418; + double lon2 = 34.280890; + double distance3 = getDistanceFrom2LngLat(109.019993, 34.342849, lat2, lon2); + System.out.println(distance3); + + // 计算距离 + double distance1 = getDistanceFrom2LngLat(leftTopPoints[1], leftTopPoints[0], lat2, lon2); + double distance2 = getDistanceFrom2LngLat(leftBottomPoints[1], leftBottomPoints[0], lat2, lon2); + System.out.println("Distance between the two points is: " + distance1 + " km"); + System.out.println("Distance between the two points is: " + distance2 + " km"); + } // public static void main(String[] args) { -// Map stringMap = returnLLSquarePoint(108.954398, 34.308687, 1); -// double[] leftTopPoints = stringMap.get("rightTopPoint"); -// double[] leftBottomPoints = stringMap.get("leftBottomPoint"); +// Map stringMap = returnLLSquarePoint(34.342849, 109.019993, 1); // -// double lat2 = 108.954398; -// double lon2 = 34.308687; -// -// // 计算距离 -// double distance1 = getDistanceFrom2LngLat(leftTopPoints[1], leftTopPoints[0], lat2, lon2); -// double distance2 = getDistanceFrom2LngLat(leftBottomPoints[1], leftBottomPoints[0], lat2, lon2); -// System.out.println("Distance between the two points is: " + distance1 + " km"); -// System.out.println("Distance between the two points is: " + distance2 + " km"); // } } diff --git a/src/main/resources/mapper/TbMerchantCouponMapper.xml b/src/main/resources/mapper/TbMerchantCouponMapper.xml index 5dbcdc5..85c3d5d 100644 --- a/src/main/resources/mapper/TbMerchantCouponMapper.xml +++ b/src/main/resources/mapper/TbMerchantCouponMapper.xml @@ -268,13 +268,45 @@ - + SELECT + cou.id as id, + cou.title as title, + cou.shop_id as shopId, + cou.amount as amount, + cou.number as number, + cou.ratio as ratio, + cou.relation_ids as relationIds, + info.shop_name as shopName, + info.logo + FROM + tb_merchant_coupon as cou + LEFT JOIN tb_shop_info as info ON cou.shop_id = info.id + + cou.class_type = 'product' + AND cou.`status` = 1 + AND info.cities =#{cities} + + AND info.lng BETWEEN #{leftBottomLng} AND #{rightTopLng} + AND info.lat BETWEEN #{leftBottomLat} AND #{rightTopLat} + + + + + + ORDER BY (ABS(info.lat - #{lat}) + ABS(info.lng - #{lng})) ASC + + + ORDER BY cou.number ASC + + + ORDER BY cou.amount ASC + + + ORDER BY cou.id ASC + + + limit #{pageable}, #{sizeable}