Commit be844cab authored by wlx@33.cn's avatar wlx@33.cn

Merge branch 'dev' of https://gitlab.33.cn/yimu/mall-server into dev

parents 43b36bd1 6009804f
...@@ -22,7 +22,8 @@ public enum SpuStatusEnum { ...@@ -22,7 +22,8 @@ public enum SpuStatusEnum {
CHECK_FAIL(6),//审核未通过 CHECK_FAIL(6),//审核未通过
CHECK_PASS(7),//审核通过 CHECK_PASS(7),//审核通过
CANCEL(8),//取消发布 CANCEL(8),//取消发布
DRAFT(9);//草稿 DRAFT(9),//草稿
PREHEAT(10);//预热
private Integer status; private Integer status;
......
...@@ -161,4 +161,6 @@ public interface ISpuService extends IService<Spu> { ...@@ -161,4 +161,6 @@ public interface ISpuService extends IService<Spu> {
*/ */
List<GoodsListVO> getSpuByVague(String goodsInfo, String merchantId); List<GoodsListVO> getSpuByVague(String goodsInfo, String merchantId);
List<Spu> listForPreheat();
} }
...@@ -84,12 +84,16 @@ public class SkuServiceImpl extends ServiceImpl<SkuMapper, Sku> implements ISkuS ...@@ -84,12 +84,16 @@ public class SkuServiceImpl extends ServiceImpl<SkuMapper, Sku> implements ISkuS
if (StringUtils.isBlank(kDTO.getImage())) { if (StringUtils.isBlank(kDTO.getImage())) {
sku.setThumb(thumb); sku.setThumb(thumb);
} }
if (salesType.equals(SalesTypeEnum.ORDINARY.getType())) { if (salesType == null) {
sku.setCirculation(kDTO.getStock());
sku.setPrice(kDTO.getOriginalPrice());
}
if (salesType != null && salesType.equals(SalesTypeEnum.ORDINARY.getType())) {
sku.setCirculation(kDTO.getStock()); sku.setCirculation(kDTO.getStock());
sku.setOriginalPrice(price); sku.setOriginalPrice(price);
sku.setPrice(price); sku.setPrice(price);
} }
if (salesType.equals(SalesTypeEnum.BLIND_BOX.getType())) { if (salesType != null && salesType.equals(SalesTypeEnum.BLIND_BOX.getType())) {
sku.setOriginalPrice(blindBoxPrice); sku.setOriginalPrice(blindBoxPrice);
sku.setPrice(blindBoxPrice); sku.setPrice(blindBoxPrice);
} }
...@@ -100,7 +104,7 @@ public class SkuServiceImpl extends ServiceImpl<SkuMapper, Sku> implements ISkuS ...@@ -100,7 +104,7 @@ public class SkuServiceImpl extends ServiceImpl<SkuMapper, Sku> implements ISkuS
//规格属性入库 //规格属性入库
skuPropService.add(kDTO.getPropertyList(), skuId); skuPropService.add(kDTO.getPropertyList(), skuId);
if (salesType.equals(SalesTypeEnum.BLIND_BOX.getType())) { if (salesType != null && salesType.equals(SalesTypeEnum.BLIND_BOX.getType())) {
if (commodityPass.equals(CommodityPassTypeEnum.INNER.getType())) { if (commodityPass.equals(CommodityPassTypeEnum.INNER.getType())) {
long tokenId = System.currentTimeMillis(); long tokenId = System.currentTimeMillis();
sku.setCoinName(MALLGlobalConfig.NFT_PREFIX + tokenId); sku.setCoinName(MALLGlobalConfig.NFT_PREFIX + tokenId);
...@@ -146,7 +150,7 @@ public class SkuServiceImpl extends ServiceImpl<SkuMapper, Sku> implements ISkuS ...@@ -146,7 +150,7 @@ public class SkuServiceImpl extends ServiceImpl<SkuMapper, Sku> implements ISkuS
//发行NFT //发行NFT
ExternalToken externalToken = externalTokenService.queryByLabelNameAndMerchantId(kDTO.getCoinName(), merchantId); ExternalToken externalToken = externalTokenService.queryByLabelNameAndMerchantId(kDTO.getCoinName(), merchantId);
String tokenId = externalToken.getTokenId().toString(); /*String tokenId = externalToken.getTokenId().toString();
long[] nos = new long[Math.toIntExact(kDTO.getStock())]; long[] nos = new long[Math.toIntExact(kDTO.getStock())];
String[] hashs = new String[Math.toIntExact(kDTO.getStock())]; String[] hashs = new String[Math.toIntExact(kDTO.getStock())];
for (int i = 0; i < kDTO.getStock(); i++) { for (int i = 0; i < kDTO.getStock(); i++) {
...@@ -155,15 +159,17 @@ public class SkuServiceImpl extends ServiceImpl<SkuMapper, Sku> implements ISkuS ...@@ -155,15 +159,17 @@ public class SkuServiceImpl extends ServiceImpl<SkuMapper, Sku> implements ISkuS
String hash = chainUtil.evmPublishTokenSplit(addr, suffixAll, 1L); String hash = chainUtil.evmPublishTokenSplit(addr, suffixAll, 1L);
nos[i] = suffixAll; nos[i] = suffixAll;
hashs[i] = hash; hashs[i] = hash;
} }*/
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
map.put("goodsId", goodsId); map.put("goodsId", goodsId);
map.put("hashs", hashs); // map.put("hashs", hashs);
map.put("prefix", tokenId); map.put("prefix", externalToken.getTokenId().toString());
map.put("merchantId", merchantId); map.put("merchantId", merchantId);
map.put("commodityPassId", externalToken.getCommodityPassId()); map.put("commodityPassId", externalToken.getCommodityPassId());
map.put("nos", JSONArray.toJSON(nos)); // map.put("nos", JSONArray.toJSON(nos));
map.put("stock",kDTO.getStock());
map.put("addr",addr);
producer.sendTTL(map, QueueTTLTypeEnum.NFT_USU_TTL, 10 * 1000); producer.sendTTL(map, QueueTTLTypeEnum.NFT_USU_TTL, 10 * 1000);
} }
} }
......
...@@ -31,6 +31,7 @@ import com.fzm.mall.server.admin.home_page.service.IMerchantService; ...@@ -31,6 +31,7 @@ import com.fzm.mall.server.admin.home_page.service.IMerchantService;
import com.fzm.mall.server.admin.opration.service.IFloorGoodsService; import com.fzm.mall.server.admin.opration.service.IFloorGoodsService;
import com.fzm.mall.server.admin.util.UUIDUtil; import com.fzm.mall.server.admin.util.UUIDUtil;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.dozer.DozerBeanMapper; import org.dozer.DozerBeanMapper;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -52,6 +53,7 @@ import static com.fzm.mall.server.admin.goods_center.enums.type.GoodsTypeEnum.*; ...@@ -52,6 +53,7 @@ import static com.fzm.mall.server.admin.goods_center.enums.type.GoodsTypeEnum.*;
* @since JDK 1.8 * @since JDK 1.8
*/ */
@Service @Service
@Slf4j
@Transactional @Transactional
public class SpuServiceImpl extends ServiceImpl<SpuMapper, Spu> implements ISpuService { public class SpuServiceImpl extends ServiceImpl<SpuMapper, Spu> implements ISpuService {
...@@ -110,7 +112,8 @@ public class SpuServiceImpl extends ServiceImpl<SpuMapper, Spu> implements ISpuS ...@@ -110,7 +112,8 @@ public class SpuServiceImpl extends ServiceImpl<SpuMapper, Spu> implements ISpuS
goodsId = UUIDUtil.getUUID(); goodsId = UUIDUtil.getUUID();
} }
if (pDTO.getSalesType().equals(SalesTypeEnum.ORDINARY.getType())) { log.info("salesType:" + pDTO.getSalesType());
if (pDTO.getSalesType() != null && pDTO.getSalesType().equals(SalesTypeEnum.ORDINARY.getType())) {
nftService.add(pDTO.getNftdto(), goodsId, pDTO.getName(), addr, merchantId, timestamp); nftService.add(pDTO.getNftdto(), goodsId, pDTO.getName(), addr, merchantId, timestamp);
if (pDTO.getNftdto().getTzType().equals(1)) { if (pDTO.getNftdto().getTzType().equals(1)) {
List<GoodsSkuDTO> objects = pDTO.getSkuList().stream().peek(v -> { List<GoodsSkuDTO> objects = pDTO.getSkuList().stream().peek(v -> {
...@@ -132,13 +135,14 @@ public class SpuServiceImpl extends ServiceImpl<SpuMapper, Spu> implements ISpuS ...@@ -132,13 +135,14 @@ public class SpuServiceImpl extends ServiceImpl<SpuMapper, Spu> implements ISpuS
spu = beanMapper.map(pDTO, Spu.class); spu = beanMapper.map(pDTO, Spu.class);
spu.setGoodsId(goodsId); spu.setGoodsId(goodsId);
spu.setMerchantId(merchantId); spu.setMerchantId(merchantId);
spu.setBlindBoxRule("无");
Integer status = SpuStatusEnum.WAIT_CHECK.getStatus(); Integer status = SpuStatusEnum.WAIT_CHECK.getStatus();
if ((pDTO.getCommodityPass().equals(CommodityPassTypeEnum.COPY.getType()) && pDTO.getSkuList().get(0).getNftSalesType().equals(NFTSalesTypeEnum.COPY.getType())) || pDTO.getCommodityPass().equals(CommodityPassTypeEnum.INNER.getType())) { if ((pDTO.getCommodityPass().equals(CommodityPassTypeEnum.COPY.getType()) && pDTO.getSkuList().get(0).getNftSalesType().equals(NFTSalesTypeEnum.COPY.getType())) || pDTO.getCommodityPass().equals(CommodityPassTypeEnum.INNER.getType())) {
status = SpuStatusEnum.ISSUE.getStatus(); status = SpuStatusEnum.ISSUE.getStatus();
} }
spu.setStatus(status); spu.setStatus(status);
//设置商品最大最小值 //设置商品最大最小值
if (pDTO.getSalesType().equals(SalesTypeEnum.BLIND_BOX.getType())) { if (pDTO.getSalesType() != null && pDTO.getSalesType().equals(SalesTypeEnum.BLIND_BOX.getType())) {
spu.setMaxPrice(pDTO.getBlindBoxPrice()); spu.setMaxPrice(pDTO.getBlindBoxPrice());
spu.setDefaultPrice(pDTO.getBlindBoxPrice()); spu.setDefaultPrice(pDTO.getBlindBoxPrice());
} else { } else {
...@@ -541,4 +545,12 @@ public class SpuServiceImpl extends ServiceImpl<SpuMapper, Spu> implements ISpuS ...@@ -541,4 +545,12 @@ public class SpuServiceImpl extends ServiceImpl<SpuMapper, Spu> implements ISpuS
externalTokenService.updateById(externalToken); externalTokenService.updateById(externalToken);
} }
} }
@Override
public List<Spu> listForPreheat() {
LambdaQueryWrapper<Spu> qw = new LambdaQueryWrapper<>();
qw.eq(Spu::getStatus, SpuStatusEnum.PREHEAT.getStatus());
return list(qw);
}
} }
...@@ -60,13 +60,26 @@ public class NftConsumer { ...@@ -60,13 +60,26 @@ public class NftConsumer {
public void usuCoinsPrice(Map<String, Object> obj) { public void usuCoinsPrice(Map<String, Object> obj) {
try { try {
String goodsId = obj.get("goodsId") + ""; String goodsId = obj.get("goodsId") + "";
String[] hashs = (String[]) obj.get("hashs"); // String[] hashs = (String[]) obj.get("hashs");
String prefix = obj.get("prefix") + ""; String prefix = obj.get("prefix") + "";
String nos = obj.get("nos") + ""; // String nos = obj.get("nos") + "";
String merchantId = obj.get("merchantId") + ""; String merchantId = obj.get("merchantId") + "";
String commodityPassId = obj.get("commodityPassId") + ""; String commodityPassId = obj.get("commodityPassId") + "";
// String tokenId = obj.get("tokenId") + "";
Long stock = (Long) obj.get("stock");
String addr = obj.get("addr") + "";
System.err.println("obj:" + obj); System.err.println("obj:" + obj);
long[] nos = new long[Math.toIntExact(stock)];
String[] hashs = new String[Math.toIntExact(stock)];
for (int i = 0; i < stock; i++) {
String suffix = i + 1 + "";
Long suffixAll = Long.parseLong(prefix + "00000000".substring(0, 8 - suffix.length()) + suffix);
String hash = chainUtil.evmPublishTokenSplit(addr, suffixAll, 1L);
nos[i] = suffixAll;
hashs[i] = hash;
}
int length = hashs.length; int length = hashs.length;
//发行token //发行token
......
package com.fzm.mall.server.admin.task.goods;
import com.fzm.mall.server.admin.goods_center.enums.status.SpuStatusEnum;
import com.fzm.mall.server.admin.goods_center.model.Spu;
import com.fzm.mall.server.admin.goods_center.service.ISpuService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
/**
* @author wangp
* @date 2021/6/18 10:43
* @description 订单定时任务
* @since JDK 1.8
*/
@Component
@Slf4j
@Transactional
public class GoodsTask {
@Autowired
private ISpuService spuService;
//预热商品上架
@Scheduled(cron = "10 * * * * ?")
public void yrsj() {
List<Spu> spuList = spuService.listForPreheat();
spuList.forEach(v -> {
if (v.getPreheatEndTime() < System.currentTimeMillis()) {
//修改状态为上架
spuService.updateStatus(v.getGoodsId(), SpuStatusEnum.ON.getStatus(), "");
}
});
}
}
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