首页 金刚区 标签 详情 标签VO一堆

This commit is contained in:
2024-04-11 14:26:35 +08:00
parent 1b9d069bc6
commit 9a6f6eb5b6
21 changed files with 592 additions and 633 deletions

View File

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

View File

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

View File

@@ -22,64 +22,9 @@ public interface TbPlatformDictMapper {
*/
TbPlatformDict queryById(Integer id);
/**
* 查询指定行数据
*
* @param tbPlatformDict 查询条件
* @param pageable 分页对象
* @return 对象列表
*/
List<TbPlatformDict> queryAllByLimit(TbPlatformDict tbPlatformDict, @Param("pageable") Pageable pageable);
List<TbPlatformDict> queryByIdList(List<Integer> idList);
List<TbPlatformDict> 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<TbPlatformDict> 实例对象列表
* @return 影响行数
*/
int insertBatch(@Param("entities") List<TbPlatformDict> entities);
/**
* 批量新增或按主键更新数据MyBatis原生foreach方法
*
* @param entities List<TbPlatformDict> 实例对象列表
* @return 影响行数
* @throws org.springframework.jdbc.BadSqlGrammarException 入参是空List的时候会抛SQL语句错误的异常请自行校验入参
*/
int insertOrUpdateBatch(@Param("entities") List<TbPlatformDict> entities);
/**
* 修改数据
*
* @param tbPlatformDict 实例对象
* @return 影响行数
*/
int update(TbPlatformDict tbPlatformDict);
/**
* 通过主键删除数据
*
* @param id 主键
* @return 影响行数
*/
int deleteById(Integer id);
}

View File

@@ -38,4 +38,5 @@ public interface TbProductSkuMapper {
List<TbProductSku> selectDownSku(@Param("list") List<Integer> productId);
List<TbProductSku> selectSkus(@Param("list") List<String> productId);
List<TbProductSku> selectSku(@Param("productId") String productId);
}

View File

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

View File

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

View File

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

View File

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

View File

@@ -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<TbPlatformDict> carousel;
List<HomeCarouselVo> carousel;
/**
* 金刚区
*/
List<TbPlatformDict> district;
List<HomeDistrictVo> district;
/**
* 条件查询
*/
@@ -60,19 +58,19 @@ public class HomeUpVO {
this.salesList = salesList;
}
public List<TbPlatformDict> getCarousel() {
public List<HomeCarouselVo> getCarousel() {
return carousel;
}
public void setCarousel(List<TbPlatformDict> carousel) {
public void setCarousel(List<HomeCarouselVo> carousel) {
this.carousel = carousel;
}
public List<TbPlatformDict> getDistrict() {
public List<HomeDistrictVo> getDistrict() {
return district;
}
public void setDistrict(List<TbPlatformDict> district) {
public void setDistrict(List<HomeDistrictVo> district) {
this.district = district;
}

View File

@@ -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<String> shopTag;
private List<TagVo> shopTag;
/**
* 商品标签
*/
private List<String> proTag;
private List<TagProductVO> proTag=new ArrayList<>();
/**
* 距离
*/
@@ -88,19 +86,19 @@ public class HomeVO {
this.distances = distances;
}
public List<String> getShopTag() {
public List<TagVo> getShopTag() {
return shopTag;
}
public void setShopTag(List<String> shopTag) {
public void setShopTag(List<TagVo> shopTag) {
this.shopTag = shopTag;
}
public List<String> getProTag() {
public List<TagProductVO> getProTag() {
return proTag;
}
public void setProTag(List<String> proTag) {
public void setProTag(List<TagProductVO> proTag) {
this.proTag = proTag;
}

View File

@@ -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<ProductVo> productList = new ArrayList<>();
/**
* 购买须知/价格说明
*/
private TbPurchaseNotice purchaseNotice;
}

View File

@@ -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<Food> foods=new ArrayList<>(); // 食品列表
@Data
public static class Food {
private String name; // 商品名称
private BigDecimal price; // 售价
private String unit; // 单位
/**
* 商品标签
*/
private List<TagProductVO> proTag=new ArrayList<>();
}
}

View File

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

View File

@@ -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 List<String>images;
/**
* 原价
*/
private BigDecimal originPrice;
/**
* 现价
*/
private BigDecimal salePrice;
/**
* 折扣
*/
private Float discount;
/**
* 共省金额
*/
private BigDecimal save;
/**
* 销量
*/
private BigDecimal realSalesNumber;
/**
* 结束时间
*/
private Long endTime;
}

View File

@@ -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<Integer> shopTagIds = Arrays.stream(tbShopInfo.getTag().split(","))
.map(Integer::parseInt)
.collect(Collectors.toList());
List<TbPlatformDict> 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<TbPlatformDict> carouselList = platformDictMapper.queryAllByType("carousel", environment);
homeUpVO.setCarousel(carouselList);
homeUpVO.setCarousel(JSONUtil.parseListTNewList(carouselList, HomeCarouselVo.class));
//金刚区
List<TbPlatformDict> districtList = platformDictMapper.queryAllByType("homeDistrict", environment);
homeUpVO.setDistrict(districtList);
homeUpVO.setDistrict(JSONUtil.parseListTNewList(districtList, HomeDistrictVo.class));
//菜单
List<SysDict> sysDicts = sysDictDetailMapper.selectByAll();
List<DicDetailVO> dicDetailVO = new ArrayList<>();

View File

@@ -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<String, Object> concurrentMap = new ConcurrentHashMap<>();
public Result queryProduct(String code,String productGroupId){
ConcurrentMap<String,Object> 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<TbProductGroup> groupList=tbProductGroupMapper.selectByQrcode(code,id);
if(ObjectUtil.isNotEmpty(groupList)&&groupList.size()>0){
Integer id = ObjectUtil.isNotEmpty(productGroupId) ? Integer.valueOf(productGroupId) : null;
List<TbProductGroup> 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<TbProduct> 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<TbProduct> 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<String> 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<String> 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<TbShopInfo> shopInfo = CompletableFuture.supplyAsync(() ->
tbShopInfoMapper.selectByPrimaryKey(Integer.valueOf(tbMerchantCoupon.getShopId())));
CompletableFuture<TbProduct> product = CompletableFuture.supplyAsync(() ->
tbProductMapper.selectById(Integer.valueOf(tbMerchantCoupon.getRelationIds())));
CompletableFuture<List<TbProductSku>> productSku = CompletableFuture.supplyAsync(() ->
tbProductSkuMapper.selectSku(tbMerchantCoupon.getRelationIds()));
CompletableFuture<List<TagProductVO>> dictPro = CompletableFuture.supplyAsync(() ->
tagProductDeptsMapper.queryTagByProductId(tbMerchantCoupon.getRelationIds()));
CompletableFuture<TbPurchaseNotice> 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<String> tagList(String tag) {
if (tag == null) {
return new ArrayList<>();
} else {
String[] arr = tag.split(",");
return new ArrayList<>(Arrays.asList(arr));
}
}
}

View File

@@ -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 <T>
*/
public static <T> List<T> parseListTNewList(List<?> list, Class<T> clazz) {
ObjectMapper objectMapper = new ObjectMapper(); // 创建JSON转换器
try {
// 将List<?>转换为JSON字符串
String json = objectMapper.writeValueAsString(list);
// 将JSON字符串转换为List<T>
return objectMapper.readValue(json, objectMapper.getTypeFactory().constructCollectionType(List.class, clazz));
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
public static class JSONEntity {
public JSONEntity() {
}

View File

@@ -2,116 +2,39 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.chaozhanggui.system.cashierservice.dao.TagProductDeptsMapper">
<resultMap type="com.chaozhanggui.system.cashierservice.entity.TagProductDepts" id="TagProductDeptsMap">
<result property="tagId" column="tag_id" jdbcType="INTEGER"/>
<result property="productId" column="product_id" jdbcType="INTEGER"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
</resultMap>
<!--查询单个-->
<select id="queryById" resultMap="TagProductDeptsMap">
select
tag_id, product_id, create_time
from tag_product_depts
where tag_id = #{tagId}
</select>
<!--查询指定行数据-->
<select id="queryAllByLimit" resultMap="TagProductDeptsMap">
select
tag_id, product_id, create_time
from tag_product_depts
<where>
<if test="tagId != null">
and tag_id = #{tagId}
</if>
<if test="productId != null">
and product_id = #{productId}
</if>
<if test="createTime != null">
and create_time = #{createTime}
</if>
</where>
limit #{pageable.offset}, #{pageable.pageSize}
</select>
<!--统计总行数-->
<select id="count" resultType="java.lang.Long">
select count(1)
from tag_product_depts
<where>
<if test="tagId != null">
and tag_id = #{tagId}
</if>
<if test="productId != null">
and product_id = #{productId}
</if>
<if test="createTime != null">
and create_time = #{createTime}
</if>
</where>
</select>
<select id="queryTagAndProduct" resultType="com.chaozhanggui.system.cashierservice.entity.vo.TagProductVO">
SELECT
pro.id AS productId,
pro.`name` AS `name`,
GROUP_CONCAT(dict.`name`) AS tags
depts.product_id AS productId,
dict.share_img AS shareImg,
dict.name AS name,
dict.font_color AS fontColor,
dict.back_color AS backColor
FROM
tag_product_depts AS depts
LEFT JOIN tb_product AS pro ON depts.product_id = pro.id
LEFT JOIN tb_platform_dict AS dict ON dict.id = depts.tag_id
WHERE
dict.type='proTag' AND
depts.product_id IN
<foreach collection="list" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
GROUP BY
pro.id,
pro.name;
order by dict.sort
</select>
<!--新增所有列-->
<insert id="insert" keyProperty="tagId" useGeneratedKeys="true">
insert into tag_product_depts(product_id, create_time)
values (#{productId}, #{createTime})
</insert>
<insert id="insertBatch" keyProperty="tagId" useGeneratedKeys="true">
insert into tag_product_depts(product_id, create_time)
values
<foreach collection="entities" item="entity" separator=",">
(#{entity.productId}, #{entity.createTime})
</foreach>
</insert>
<insert id="insertOrUpdateBatch" keyProperty="tagId" useGeneratedKeys="true">
insert into tag_product_depts(product_id, create_time)
values
<foreach collection="entities" item="entity" separator=",">
(#{entity.productId}, #{entity.createTime})
</foreach>
on duplicate key update
product_id = values(product_id),
create_time = values(create_time)
</insert>
<!--通过主键修改数据-->
<update id="update">
update tag_product_depts
<set>
<if test="productId != null">
product_id = #{productId},
</if>
<if test="createTime != null">
create_time = #{createTime},
</if>
</set>
where tag_id = #{tagId}
</update>
<!--通过主键删除-->
<delete id="deleteById">
delete from tag_product_depts where tag_id = #{tagId}
</delete>
<select id="queryTagByProductId" resultType="com.chaozhanggui.system.cashierservice.entity.vo.TagProductVO">
SELECT
depts.product_id AS productId,
dict.share_img AS shareImg,
dict.name AS name,
dict.font_color AS fontColor,
dict.back_color AS backColor
FROM
tag_product_depts AS depts
LEFT JOIN tb_platform_dict AS dict ON dict.id = depts.tag_id
WHERE
depts.product_id=#{productId}
ORDER BY dict.sort
</select>
</mapper>

View File

@@ -4,13 +4,15 @@
<resultMap type="com.chaozhanggui.system.cashierservice.entity.TbPlatformDict" id="TbPlatformDictMap">
<result property="id" column="id" jdbcType="INTEGER"/>
<result property="shareImg" column="share_img" jdbcType="VARCHAR"/>
<result property="name" column="name" jdbcType="VARCHAR"/>
<result property="fontColor" column="font_color" jdbcType="VARCHAR"/>
<result property="backColor" column="back_color" jdbcType="VARCHAR"/>
<result property="type" column="type" jdbcType="VARCHAR"/>
<result property="coverImg" column="cover_img" jdbcType="VARCHAR"/>
<result property="shareImg" column="share_img" jdbcType="VARCHAR"/>
<result property="video" column="video" jdbcType="VARCHAR"/>
<result property="videoCoverImg" column="video_cover_img" jdbcType="VARCHAR"/>
<result property="relUrl" column="rel_url" jdbcType="VARCHAR"/>
<result property="jumpType" column="jump_type" jdbcType="VARCHAR"/>
<result property="absUrl" column="abs_url" jdbcType="VARCHAR"/>
<result property="createdAt" column="created_at" jdbcType="INTEGER"/>
<result property="updatedAt" column="updated_at" jdbcType="INTEGER"/>
@@ -23,121 +25,25 @@
<!--查询单个-->
<select id="queryById" resultMap="TbPlatformDictMap">
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
where id = #{id}
</select>
<!--查询指定行数据-->
<select id="queryAllByLimit" resultMap="TbPlatformDictMap">
<select id="queryByIdList" resultMap="TbPlatformDictMap">
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
<where>
<if test="id != null">
and id = #{id}
</if>
<if test="name != null and name != ''">
and name = #{name}
</if>
<if test="type != null and type != ''">
and type = #{type}
</if>
<if test="coverImg != null and coverImg != ''">
and cover_img = #{coverImg}
</if>
<if test="shareImg != null and shareImg != ''">
and share_img = #{shareImg}
</if>
<if test="video != null and video != ''">
and video = #{video}
</if>
<if test="videoCoverImg != null and videoCoverImg != ''">
and video_cover_img = #{videoCoverImg}
</if>
<if test="relUrl != null and relUrl != ''">
and rel_url = #{relUrl}
</if>
<if test="absUrl != null and absUrl != ''">
and abs_url = #{absUrl}
</if>
<if test="createdAt != null">
and created_at = #{createdAt}
</if>
<if test="updatedAt != null">
and updated_at = #{updatedAt}
</if>
<if test="isShowCash != null">
and is_show_cash = #{isShowCash}
</if>
<if test="isShowMall != null">
and is_show_mall = #{isShowMall}
</if>
<if test="isShowApp != null">
and is_show_app = #{isShowApp}
</if>
<if test="sort != null">
and sort = #{sort}
</if>
</where>
limit #{pageable.offset}, #{pageable.pageSize}
where id IN
<foreach collection="idList" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</select>
<!--统计总行数-->
<select id="count" resultType="java.lang.Long">
select count(1)
from tb_platform_dict
<where>
<if test="id != null">
and id = #{id}
</if>
<if test="name != null and name != ''">
and name = #{name}
</if>
<if test="type != null and type != ''">
and type = #{type}
</if>
<if test="coverImg != null and coverImg != ''">
and cover_img = #{coverImg}
</if>
<if test="shareImg != null and shareImg != ''">
and share_img = #{shareImg}
</if>
<if test="video != null and video != ''">
and video = #{video}
</if>
<if test="videoCoverImg != null and videoCoverImg != ''">
and video_cover_img = #{videoCoverImg}
</if>
<if test="relUrl != null and relUrl != ''">
and rel_url = #{relUrl}
</if>
<if test="absUrl != null and absUrl != ''">
and abs_url = #{absUrl}
</if>
<if test="createdAt != null">
and created_at = #{createdAt}
</if>
<if test="updatedAt != null">
and updated_at = #{updatedAt}
</if>
<if test="isShowCash != null">
and is_show_cash = #{isShowCash}
</if>
<if test="isShowMall != null">
and is_show_mall = #{isShowMall}
</if>
<if test="isShowApp != null">
and is_show_app = #{isShowApp}
</if>
<if test="sort != null">
and sort = #{sort}
</if>
</where>
</select>
<select id="queryAllByType" resultType="com.chaozhanggui.system.cashierservice.entity.TbPlatformDict">
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
<where>
<if test="type != null and type != ''">
@@ -151,98 +57,5 @@
</if>
</where>
</select>
<!--新增所有列-->
<insert id="insert" keyProperty="id" useGeneratedKeys="true">
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>
<insert id="insertBatch" keyProperty="id" useGeneratedKeys="true">
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
<foreach collection="entities" item="entity" separator=",">
(#{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})
</foreach>
</insert>
<insert id="insertOrUpdateBatch" keyProperty="id" useGeneratedKeys="true">
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
<foreach collection="entities" item="entity" separator=",">
(#{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})
</foreach>
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)
</insert>
<!--通过主键修改数据-->
<update id="update">
update tb_platform_dict
<set>
<if test="name != null and name != ''">
name = #{name},
</if>
<if test="type != null and type != ''">
type = #{type},
</if>
<if test="coverImg != null and coverImg != ''">
cover_img = #{coverImg},
</if>
<if test="shareImg != null and shareImg != ''">
share_img = #{shareImg},
</if>
<if test="video != null and video != ''">
video = #{video},
</if>
<if test="videoCoverImg != null and videoCoverImg != ''">
video_cover_img = #{videoCoverImg},
</if>
<if test="relUrl != null and relUrl != ''">
rel_url = #{relUrl},
</if>
<if test="absUrl != null and absUrl != ''">
abs_url = #{absUrl},
</if>
<if test="createdAt != null">
created_at = #{createdAt},
</if>
<if test="updatedAt != null">
updated_at = #{updatedAt},
</if>
<if test="isShowCash != null">
is_show_cash = #{isShowCash},
</if>
<if test="isShowMall != null">
is_show_mall = #{isShowMall},
</if>
<if test="isShowApp != null">
is_show_app = #{isShowApp},
</if>
<if test="sort != null">
sort = #{sort},
</if>
</set>
where id = #{id}
</update>
<!--通过主键删除-->
<delete id="deleteById">
delete from tb_platform_dict where id = #{id}
</delete>
</mapper>

View File

@@ -381,6 +381,14 @@
GROUP BY
product_id
</select>
<select id="selectSku" resultType="com.chaozhanggui.system.cashierservice.entity.TbProductSku">
SELECT
*
FROM
tb_product_sku
WHERE
product_id = #{productId}
</select>
<select id="selectSale" resultType="com.chaozhanggui.system.cashierservice.entity.vo.HomeVO">
SELECT
pro.id as id,

View File

@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.chaozhanggui.system.cashierservice.dao.TbPurchaseNoticeMapper">
<resultMap type="com.chaozhanggui.system.cashierservice.entity.TbPurchaseNotice" id="TbPurchaseNoticeMap">
<result property="id" column="id" jdbcType="INTEGER"/>
<result property="couponId" column="coupon_id" jdbcType="INTEGER"/>
<result property="dateUsed" column="date_used" jdbcType="VARCHAR"/>
<result property="availableTime" column="available_time" jdbcType="VARCHAR"/>
<result property="bookingType" column="booking_type" jdbcType="VARCHAR"/>
<result property="refundPolicy" column="refund_policy" jdbcType="VARCHAR"/>
<result property="usageRules" column="usage_rules" jdbcType="VARCHAR"/>
<result property="invoiceInfo" column="invoice_info" jdbcType="VARCHAR"/>
<result property="groupPurInfo" column="group_pur_info" jdbcType="VARCHAR"/>
<result property="marketPriceInfo" column="market_price_Info" jdbcType="VARCHAR"/>
<result property="discountInfo" column="discount_Info" jdbcType="VARCHAR"/>
<result property="platformTips" column="platform_tips" jdbcType="VARCHAR"/>
</resultMap>
<sql id="Base_Column_List">
id
, coupon_id, date_used, available_time, booking_type, refund_policy, usage_rules, invoice_info, group_pur_info, market_price_Info, discount_Info, platform_tips </sql>
<!--查询单个-->
<select id="queryById" resultMap="TbPurchaseNoticeMap">
select
<include refid="Base_Column_List"/>
from tb_purchase_notice
where id = #{id}
</select>
</mapper>