Commit 6546af76 authored by 童得柱's avatar 童得柱

添加溯源hash,商品销量和发行量

parent a9215cf4
...@@ -62,4 +62,8 @@ public class UserAsset implements Serializable { ...@@ -62,4 +62,8 @@ public class UserAsset implements Serializable {
@ApiModelProperty(value = "库存总价") @ApiModelProperty(value = "库存总价")
@TableField(exist = false) @TableField(exist = false)
private BigDecimal totalPrice; private BigDecimal totalPrice;
@ApiModelProperty(value = "溯源hash")
@TableField(exist = false)
private String hash;
} }
package com.fzm.mall.server.front.asset.model.vo.asset; package com.fzm.mall.server.front.asset.model.vo.asset;
import com.baomidou.mybatisplus.annotation.TableField;
import com.fzm.mall.server.front.goods.model.vo.SkuVo; import com.fzm.mall.server.front.goods.model.vo.SkuVo;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
...@@ -30,5 +31,7 @@ public class UserAssetVo { ...@@ -30,5 +31,7 @@ public class UserAssetVo {
private String logo; private String logo;
@ApiModelProperty("关键字查询") @ApiModelProperty("关键字查询")
private String keyWord; private String keyWord;
@ApiModelProperty(value = "溯源hash")
@TableField(exist = false)
private String hash;
} }
...@@ -22,8 +22,10 @@ import com.fzm.mall.server.front.base.PageVO; ...@@ -22,8 +22,10 @@ import com.fzm.mall.server.front.base.PageVO;
import com.fzm.mall.server.front.constant.StateConst; import com.fzm.mall.server.front.constant.StateConst;
import com.fzm.mall.server.front.enums.CoinNameEnum; import com.fzm.mall.server.front.enums.CoinNameEnum;
import com.fzm.mall.server.front.enums.QueueTTLTypeEnum; import com.fzm.mall.server.front.enums.QueueTTLTypeEnum;
import com.fzm.mall.server.front.goods.model.GoodSpu;
import com.fzm.mall.server.front.goods.model.vo.PageVo; import com.fzm.mall.server.front.goods.model.vo.PageVo;
import com.fzm.mall.server.front.goods.model.vo.SkuVo; import com.fzm.mall.server.front.goods.model.vo.SkuVo;
import com.fzm.mall.server.front.goods.service.IGoodSpuService;
import com.fzm.mall.server.front.goods.service.ISkuService; import com.fzm.mall.server.front.goods.service.ISkuService;
import com.fzm.mall.server.front.mq.MsgProducer; import com.fzm.mall.server.front.mq.MsgProducer;
import com.fzm.mall.server.front.order.model.po.TranDto; import com.fzm.mall.server.front.order.model.po.TranDto;
...@@ -70,6 +72,8 @@ public class UserAssetServiceImpl extends ServiceImpl<UserAssetMapper, UserAsset ...@@ -70,6 +72,8 @@ public class UserAssetServiceImpl extends ServiceImpl<UserAssetMapper, UserAsset
private final IUserAssetRecordService userAssetRecordService; private final IUserAssetRecordService userAssetRecordService;
private final ISkuService skuService; private final ISkuService skuService;
private final ISysConfigService sysConfigService; private final ISysConfigService sysConfigService;
private final IGoodSpuService goodSpuService;
/** /**
* 分页查询用户资产 * 分页查询用户资产
...@@ -86,14 +90,14 @@ public class UserAssetServiceImpl extends ServiceImpl<UserAssetMapper, UserAsset ...@@ -86,14 +90,14 @@ public class UserAssetServiceImpl extends ServiceImpl<UserAssetMapper, UserAsset
if (type == 1 && !StringUtil.isNullOrEmpty(keyWord)) { if (type == 1 && !StringUtil.isNullOrEmpty(keyWord)) {
//模糊查询库存 //模糊查询库存
list = coinDao.searchAssetLike(uid, type, keyWord); list = coinDao.searchAssetLike(uid, type, keyWord);
}else{ } else {
list = list(qw); list = list(qw);
} }
for (UserAsset i : list) { for (UserAsset i : list) {
BigDecimal amount = i.getAmount(); BigDecimal amount = i.getAmount();
i.setAmount(amount.setScale(2, BigDecimal.ROUND_DOWN)); i.setAmount(amount.setScale(2, BigDecimal.ROUND_DOWN));
i.setFrozen(i.getFrozen().setScale(2, BigDecimal.ROUND_DOWN)); i.setFrozen(i.getFrozen().setScale(2, BigDecimal.ROUND_DOWN));
if(StringUtil.isNullOrEmpty(i.getCoin())){ if (StringUtil.isNullOrEmpty(i.getCoin())) {
continue; continue;
} }
SkuVo skuVo = skuService.querySkuByCoin(i.getCoin()); SkuVo skuVo = skuService.querySkuByCoin(i.getCoin());
...@@ -101,6 +105,11 @@ public class UserAssetServiceImpl extends ServiceImpl<UserAssetMapper, UserAsset ...@@ -101,6 +105,11 @@ public class UserAssetServiceImpl extends ServiceImpl<UserAssetMapper, UserAsset
BigDecimal totalPrice = amount.multiply(skuVo.getOriginalPrice()).setScale(2, BigDecimal.ROUND_DOWN); BigDecimal totalPrice = amount.multiply(skuVo.getOriginalPrice()).setScale(2, BigDecimal.ROUND_DOWN);
i.setTotalPrice(totalPrice); i.setTotalPrice(totalPrice);
i.setSkuVo(skuVo); i.setSkuVo(skuVo);
String goodsId = skuVo.getGoodsId();
GoodSpu goodSpu = goodSpuService.goodSpu(goodsId);
if (goodSpu != null) {
i.setHash(goodSpu.getHash());
}
} }
} }
PageVO<UserAsset> pageVO = new PageVO<>(); PageVO<UserAsset> pageVO = new PageVO<>();
...@@ -122,6 +131,14 @@ public class UserAssetServiceImpl extends ServiceImpl<UserAssetMapper, UserAsset ...@@ -122,6 +131,14 @@ public class UserAssetServiceImpl extends ServiceImpl<UserAssetMapper, UserAsset
asset.setAmount(asset.getAmount().setScale(2, BigDecimal.ROUND_DOWN)); asset.setAmount(asset.getAmount().setScale(2, BigDecimal.ROUND_DOWN));
asset.setFrozen(asset.getFrozen().setScale(2, BigDecimal.ROUND_DOWN)); asset.setFrozen(asset.getFrozen().setScale(2, BigDecimal.ROUND_DOWN));
BeanUtils.copyProperties(asset, userAssetVo); BeanUtils.copyProperties(asset, userAssetVo);
SkuVo skuVo = skuService.querySkuByCoin(asset.getCoin());
if (skuVo != null) {
String goodsId = skuVo.getGoodsId();
GoodSpu goodSpu = goodSpuService.goodSpu(goodsId);
if (goodSpu != null) {
userAssetVo.setHash(goodSpu.getHash());
}
}
SysConfig sysConfig = sysConfigService.getByKey("coin_logo"); SysConfig sysConfig = sysConfigService.getByKey("coin_logo");
if (sysConfig != null) { if (sysConfig != null) {
userAssetVo.setLogo(sysConfig.getDictValue()); userAssetVo.setLogo(sysConfig.getDictValue());
...@@ -556,6 +573,6 @@ public class UserAssetServiceImpl extends ServiceImpl<UserAssetMapper, UserAsset ...@@ -556,6 +573,6 @@ public class UserAssetServiceImpl extends ServiceImpl<UserAssetMapper, UserAsset
@Override @Override
public int deleteAmount(Long id, BigDecimal amount) { public int deleteAmount(Long id, BigDecimal amount) {
return coinDao.deleteAmount(id,amount); return coinDao.deleteAmount(id, amount);
} }
} }
...@@ -23,6 +23,7 @@ import jdk.nashorn.internal.ir.annotations.Ignore; ...@@ -23,6 +23,7 @@ import jdk.nashorn.internal.ir.annotations.Ignore;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore; import springfox.documentation.annotations.ApiIgnore;
...@@ -80,6 +81,10 @@ public class GoodsController { ...@@ -80,6 +81,10 @@ public class GoodsController {
@Autowired @Autowired
private IFootService footService; private IFootService footService;
@Autowired
private ICountService countService;
@ApiOperation(value = "热搜词") @ApiOperation(value = "热搜词")
@PostMapping("/without/getHotSearchKey") @PostMapping("/without/getHotSearchKey")
public ResponseVO<List<String>> getHotSearchKey() { public ResponseVO<List<String>> getHotSearchKey() {
...@@ -155,7 +160,7 @@ public class GoodsController { ...@@ -155,7 +160,7 @@ public class GoodsController {
List<String> categoryIds = iSpuService.getCategoryId(goodsVo.getGoodsId()); List<String> categoryIds = iSpuService.getCategoryId(goodsVo.getGoodsId());
List<UserCouponVo> userCouponVos = couponService.getCouponByGoodsId(header.getUid(), goodsVo.getGoodsId(), header.getType(), PLATFORM_MERCHANT_ID, goodsVo.getMerchantId()); List<UserCouponVo> userCouponVos = couponService.getCouponByGoodsId(header.getUid(), goodsVo.getGoodsId(), header.getType(), PLATFORM_MERCHANT_ID, goodsVo.getMerchantId());
goodsVo.setMarketingCoupons(userCouponVos); goodsVo.setMarketingCoupons(userCouponVos);
PromotionVo promotionVo = marketingPromotionService.getByGoodsId(goodsVo.getGoodsId(), header.getType(),goodsVo.getMerchantId()); PromotionVo promotionVo = marketingPromotionService.getByGoodsId(goodsVo.getGoodsId(), header.getType(), goodsVo.getMerchantId());
goodsVo.setPromotionVo(promotionVo); goodsVo.setPromotionVo(promotionVo);
} }
SearchGoods searchGoods = new SearchGoods(); SearchGoods searchGoods = new SearchGoods();
...@@ -175,7 +180,7 @@ public class GoodsController { ...@@ -175,7 +180,7 @@ public class GoodsController {
return new ResponseVO<>(MallResponseEnum.GOOD_NOT_EXIST); return new ResponseVO<>(MallResponseEnum.GOOD_NOT_EXIST);
} }
BigDecimal comment = goodCommentService.getScope(goodsVo.getMerchantId()); BigDecimal comment = goodCommentService.getScope(goodsVo.getMerchantId());
goodsVo.setComment(comment==null?BigDecimal.ZERO:comment.setScale(2, RoundingMode.HALF_UP)); goodsVo.setComment(comment == null ? BigDecimal.ZERO : comment.setScale(2, RoundingMode.HALF_UP));
//生成浏览记录 //生成浏览记录
if (!StringUtil.isNullOrEmpty(uid)) { if (!StringUtil.isNullOrEmpty(uid)) {
footService.addRecord(uid, goodsId); footService.addRecord(uid, goodsId);
...@@ -196,16 +201,23 @@ public class GoodsController { ...@@ -196,16 +201,23 @@ public class GoodsController {
} }
goodsVo.setMarketingCoupons(userCouponVos); goodsVo.setMarketingCoupons(userCouponVos);
//促销活动 //促销活动
PromotionVo byGoodsId = marketingPromotionService.getByGoodsId(goodsId, type,goodsVo.getMerchantId()); PromotionVo byGoodsId = marketingPromotionService.getByGoodsId(goodsId, type, goodsVo.getMerchantId());
goodsVo.setPromotionVo(byGoodsId); goodsVo.setPromotionVo(byGoodsId);
List<SkuVo> skus = iSkuService.getByGoodsId(goodsId); List<SkuVo> skus = iSkuService.getByGoodsId(goodsId);
System.out.println(skus.size()); System.out.println(skus.size());
Long sum = 0L;
Long sales = 0L;
if (!CollectionUtils.isEmpty(skus)) {
for (SkuVo skuVo : skus) { for (SkuVo skuVo : skus) {
System.out.println(skuVo.getSkuId()); System.out.println(skuVo.getSkuId());
List<SkuProp> skuProps = iSkuPropService.getBySkuId(skuVo.getSkuId()); List<SkuProp> skuProps = iSkuPropService.getBySkuId(skuVo.getSkuId());
skuVo.setSkuProps(skuProps); skuVo.setSkuProps(skuProps);
} }
sum = skus.stream().mapToLong(SkuVo::getCirculation).sum();
sales = skus.stream().mapToLong(SkuVo::getSales).sum();
}
goodsVo.setCirculation(sum);
goodsVo.setSales(sales);
goodsVo.setSkus(skus); goodsVo.setSkus(skus);
return new ResponseVO<>(MallResponseEnum.SUCCESS, goodsVo); return new ResponseVO<>(MallResponseEnum.SUCCESS, goodsVo);
} }
...@@ -302,7 +314,7 @@ public class GoodsController { ...@@ -302,7 +314,7 @@ public class GoodsController {
System.err.println(userCouponId); System.err.println(userCouponId);
CouponVo couponVos = couponService.getAll(userCouponId, type); CouponVo couponVos = couponService.getAll(userCouponId, type);
if (couponVos.getRangeType() == 1) { if (couponVos.getRangeType() == 1) {
if (couponVos.getMerchantId().equals(PLATFORM_MERCHANT_ID)||merchantId.contains(couponVos.getMerchantId())) { if (couponVos.getMerchantId().equals(PLATFORM_MERCHANT_ID) || merchantId.contains(couponVos.getMerchantId())) {
couponVos.setSkuIds(skuIds); couponVos.setSkuIds(skuIds);
couponVoList.add(couponVos); couponVoList.add(couponVos);
} }
...@@ -311,7 +323,7 @@ public class GoodsController { ...@@ -311,7 +323,7 @@ public class GoodsController {
Set<String> skuId = new HashSet<>(); Set<String> skuId = new HashSet<>();
for (MarketingCouponCategory marketingCouponCategorie : marketingCouponCategories) { for (MarketingCouponCategory marketingCouponCategorie : marketingCouponCategories) {
if (categoryId.contains(marketingCouponCategorie.getCategoryId())) { if (categoryId.contains(marketingCouponCategorie.getCategoryId())) {
if(couponVos.getMerchantId().equals(PLATFORM_MERCHANT_ID)||merchantId.contains(couponVos.getMerchantId())){ if (couponVos.getMerchantId().equals(PLATFORM_MERCHANT_ID) || merchantId.contains(couponVos.getMerchantId())) {
skuId.addAll(categorySku.get(marketingCouponCategorie.getCategoryId())); skuId.addAll(categorySku.get(marketingCouponCategorie.getCategoryId()));
} }
...@@ -366,7 +378,7 @@ public class GoodsController { ...@@ -366,7 +378,7 @@ public class GoodsController {
public String stringArray2Strin(List<String> strings) { public String stringArray2Strin(List<String> strings) {
StringBuffer sb = new StringBuffer(); StringBuffer sb = new StringBuffer();
for (String s:strings) { for (String s : strings) {
sb.append("'").append(s).append("'").append(","); sb.append("'").append(s).append("'").append(",");
} }
return sb.toString(); return sb.toString();
...@@ -380,7 +392,7 @@ public class GoodsController { ...@@ -380,7 +392,7 @@ public class GoodsController {
GoodsVo goodsVo = iSpuService.getByGoodId(goodsId); GoodsVo goodsVo = iSpuService.getByGoodId(goodsId);
Nft nft = nftService.getByGoodsId(goodsId); Nft nft = nftService.getByGoodsId(goodsId);
goodsVo.setNft(nft); goodsVo.setNft(nft);
return new ResponseVO<GoodsVo>(MallResponseEnum.SUCCESS,goodsVo); return new ResponseVO<GoodsVo>(MallResponseEnum.SUCCESS, goodsVo);
} }
} }
......
...@@ -33,7 +33,7 @@ public class Count implements Serializable { ...@@ -33,7 +33,7 @@ public class Count implements Serializable {
private Long id; private Long id;
@ApiModelProperty(value = "商品编号") @ApiModelProperty(value = "商品编号")
private String gid; private String goodsId;
@ApiModelProperty(value = "商品销量") @ApiModelProperty(value = "商品销量")
private Integer sales; private Integer sales;
......
...@@ -141,6 +141,8 @@ public class GoodSpu implements Serializable { ...@@ -141,6 +141,8 @@ public class GoodSpu implements Serializable {
private Integer nftSalesType; private Integer nftSalesType;
private String nftFile; private String nftFile;
@ApiModelProperty(value = "溯源hash")
private String hash;
public void initTokenId() { public void initTokenId() {
if (commodityPass.equals(COMMODITY_PASS_OUT)){ if (commodityPass.equals(COMMODITY_PASS_OUT)){
......
...@@ -66,6 +66,13 @@ public class GoodsVo { ...@@ -66,6 +66,13 @@ public class GoodsVo {
private List<String> imgListJson; private List<String> imgListJson;
@ApiModelProperty(value = "商品销量")
@TableField(exist = false)
private Long sales;
@ApiModelProperty(value = "发行量")
@TableField(exist = false)
private Long circulation;
@ApiModelProperty(value = "nft") @ApiModelProperty(value = "nft")
@TableField(exist = false) @TableField(exist = false)
private Nft nft; private Nft nft;
......
...@@ -17,6 +17,8 @@ import java.util.List; ...@@ -17,6 +17,8 @@ import java.util.List;
* @since 2021-03-05 * @since 2021-03-05
*/ */
public interface ICountService extends IService<Count> { public interface ICountService extends IService<Count> {
Count getCountByGid(String goodsId);
List<SaleHotVo> getTopTenSaleHotVo(PageVO pageVo); List<SaleHotVo> getTopTenSaleHotVo(PageVO pageVo);
List<SaleHotVo> getList(PageVo pageVo); List<SaleHotVo> getList(PageVo pageVo);
......
package com.fzm.mall.server.front.goods.service.impl; package com.fzm.mall.server.front.goods.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.fzm.mall.server.front.base.PageVO; import com.fzm.mall.server.front.base.PageVO;
import com.fzm.mall.server.front.goods.mapper.CustomMapper; import com.fzm.mall.server.front.goods.mapper.CustomMapper;
import com.fzm.mall.server.front.goods.model.Count; import com.fzm.mall.server.front.goods.model.Count;
import com.fzm.mall.server.front.goods.mapper.CountMapper; import com.fzm.mall.server.front.goods.mapper.CountMapper;
import com.fzm.mall.server.front.goods.model.OprationFunction;
import com.fzm.mall.server.front.goods.model.qo.UserAuctionQO; import com.fzm.mall.server.front.goods.model.qo.UserAuctionQO;
import com.fzm.mall.server.front.goods.model.vo.PageVo; import com.fzm.mall.server.front.goods.model.vo.PageVo;
import com.fzm.mall.server.front.goods.model.vo.SaleHotVo; import com.fzm.mall.server.front.goods.model.vo.SaleHotVo;
...@@ -36,6 +38,13 @@ public class CountServiceImpl extends ServiceImpl<CountMapper, Count> implements ...@@ -36,6 +38,13 @@ public class CountServiceImpl extends ServiceImpl<CountMapper, Count> implements
return countMapper.getList(start, end); return countMapper.getList(start, end);
} }
@Override
public Count getCountByGid(String goodsId) {
QueryWrapper<Count> q = new QueryWrapper<>();
q.eq("goods_id",goodsId);
return getOne(q);
}
/** /**
* 查询前十的值得买商品 * 查询前十的值得买商品
*/ */
......
...@@ -62,12 +62,12 @@ public class SkuServiceImpl extends ServiceImpl<SkuMapper, Sku> implements ISkuS ...@@ -62,12 +62,12 @@ public class SkuServiceImpl extends ServiceImpl<SkuMapper, Sku> implements ISkuS
@Override @Override
public Boolean checkOrder(OrderVo orderVo) { public Boolean checkOrder(OrderVo orderVo) {
List<MerchantGoodsVo> merchantGoodsVos = orderVo.getMerchantGoodsVos(); List<MerchantGoodsVo> merchantGoodsVos = orderVo.getMerchantGoodsVos();
for (MerchantGoodsVo merchantGoodsVo:merchantGoodsVos) { for (MerchantGoodsVo merchantGoodsVo : merchantGoodsVos) {
String merchantId = merchantGoodsVo.getMerchantId(); String merchantId = merchantGoodsVo.getMerchantId();
List<OrderSkuVo> orderSkuVos = merchantGoodsVo.getOrderSkuVos(); List<OrderSkuVo> orderSkuVos = merchantGoodsVo.getOrderSkuVos();
for (OrderSkuVo orderSkuVo:orderSkuVos) { for (OrderSkuVo orderSkuVo : orderSkuVos) {
boolean b = checkMerchantIdAndSkuId(merchantId,orderSkuVo.getSkuId()); boolean b = checkMerchantIdAndSkuId(merchantId, orderSkuVo.getSkuId());
if(!b){ if (!b) {
return false; return false;
} }
} }
...@@ -82,9 +82,9 @@ public class SkuServiceImpl extends ServiceImpl<SkuMapper, Sku> implements ISkuS ...@@ -82,9 +82,9 @@ public class SkuServiceImpl extends ServiceImpl<SkuMapper, Sku> implements ISkuS
private boolean checkMerchantIdAndSkuId(String merchantId, String skuId) { private boolean checkMerchantIdAndSkuId(String merchantId, String skuId) {
SkuVo skuVo = skuMapper.getBySkuId(skuId); SkuVo skuVo = skuMapper.getBySkuId(skuId);
if(merchantId.equals(skuVo.getMerchantId())){ if (merchantId.equals(skuVo.getMerchantId())) {
return true; return true;
}else{ } else {
return false; return false;
} }
} }
...@@ -92,17 +92,20 @@ public class SkuServiceImpl extends ServiceImpl<SkuMapper, Sku> implements ISkuS ...@@ -92,17 +92,20 @@ public class SkuServiceImpl extends ServiceImpl<SkuMapper, Sku> implements ISkuS
@Override @Override
public SkuVo querySkuByCoin(String coin) { public SkuVo querySkuByCoin(String coin) {
QueryWrapper<Sku> qw = new QueryWrapper<>(); QueryWrapper<Sku> qw = new QueryWrapper<>();
if(StringUtil.isNullOrEmpty(coin)){ if (StringUtil.isNullOrEmpty(coin)) {
return null; return null;
} }
qw.eq("coin_name", coin); qw.eq("coin_name", coin);
Sku sku = getOne(qw); Sku sku = getOne(qw);
SkuVo skuVo = new SkuVo(); if (sku == null) {
if (sku != null) { return null;
skuVo = skuMapper.getBySkuId(sku.getSkuId()); }
SkuVo skuVo = skuMapper.getBySkuId(sku.getSkuId());
if (skuVo == null) {
return null;
}
List<SkuProp> list = skuPropService.getBySkuId(skuVo.getSkuId()); List<SkuProp> list = skuPropService.getBySkuId(skuVo.getSkuId());
skuVo.setSkuProps(list); skuVo.setSkuProps(list);
}
return skuVo; return skuVo;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment