首页 金刚区 标签 详情 标签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() {
}