记得上下班打卡 | git大法好,push需谨慎

Commit 2c0acaee authored by 胡佳晨's avatar 胡佳晨

Merge branch 'master' into hjc_kylin_stock

parents e00a0eff 831f4547
...@@ -247,6 +247,7 @@ public class GoblinRedisConst { ...@@ -247,6 +247,7 @@ public class GoblinRedisConst {
public static final String REDIS_WHITE = PREFIX.concat("white:");//白名单 key:$listId:$skuId:$mobile public static final String REDIS_WHITE = PREFIX.concat("white:");//白名单 key:$listId:$skuId:$mobile
public static final String LIST_COLLECT = PREFIX.concat("list:collect");//名单列表详情 $key:$skuId public static final String LIST_COLLECT = PREFIX.concat("list:collect");//名单列表详情 $key:$skuId
public static final String ADAM_IS_MEMBER = "kylin:member:uid:";//是否会员 $key:$uid public static final String ADAM_IS_MEMBER = "kylin:member:uid:";//是否会员 $key:$uid
public static final String LIST_RELATION_BOX = PREFIX.concat("list:relation:box");//名单列表详情 $key:$skuId:$listId
/** /**
* nft兑换活动配置 * nft兑换活动配置
*/ */
......
...@@ -25,5 +25,7 @@ public class GoblinStoreMgtGoodsSkuFilterParam implements Serializable { ...@@ -25,5 +25,7 @@ public class GoblinStoreMgtGoodsSkuFilterParam implements Serializable {
private String keyword; private String keyword;
@ApiModelProperty(position = 14, required = false, value = "商品上架状态[0-待上架|1-下架|2-违规|3-上架|4-已上架未开售]", allowableValues = "0,1,2,3") @ApiModelProperty(position = 14, required = false, value = "商品上架状态[0-待上架|1-下架|2-违规|3-上架|4-已上架未开售]", allowableValues = "0,1,2,3")
private String shelvesStatus; private String shelvesStatus;
@ApiModelProperty(position = 15, required = false, value = "类型[0-普通|1-分批购]")
private Integer type;
} }
package com.liquidnet.service.goblin.dto.vo;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
@ApiModel(value = "GoblinGoodsInfoListVo", description = "商品SPU List")
@Data
@JsonIgnoreProperties(ignoreUnknown = true)
public class GoblinGoodsInfoListVoo implements Serializable, Cloneable {
private List<GoblinGoodsInfoListVo> list;
@ApiModelProperty(position = 55, value = "数量")
private long count;
private static final GoblinGoodsInfoListVoo obj = new GoblinGoodsInfoListVoo();
public static GoblinGoodsInfoListVoo getNew() {
try {
return (GoblinGoodsInfoListVoo) obj.clone();
} catch (CloneNotSupportedException e) {
return new GoblinGoodsInfoListVoo();
}
}
/* public int compareTo(GoblinGoodsInfoVo arg0) {
return this.getCount().compareTo(arg0.getCount());
}*/
}
...@@ -110,6 +110,7 @@ public class GoblinNftExSkuVo { ...@@ -110,6 +110,7 @@ public class GoblinNftExSkuVo {
@ApiModelProperty(position = 20,required = true,value ="修改时间") @ApiModelProperty(position = 20,required = true,value ="修改时间")
private LocalDateTime updatedAt; private LocalDateTime updatedAt;
// redis 覆盖暂时无用
private String rdStartTime; private String rdStartTime;
private String rdStopTime; private String rdStopTime;
......
...@@ -105,6 +105,9 @@ public class GoblinNftGoodsSkuInfoVo implements Serializable, Cloneable { ...@@ -105,6 +105,9 @@ public class GoblinNftGoodsSkuInfoVo implements Serializable, Cloneable {
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = DateUtil.DATE_FULL_STR) @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = DateUtil.DATE_FULL_STR)
@ApiModelProperty(position = 69, value = "sku正常开售时间") @ApiModelProperty(position = 69, value = "sku正常开售时间")
private LocalDateTime baseSaleStartTime; private LocalDateTime baseSaleStartTime;
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = DateUtil.DATE_FULL_STR)
@ApiModelProperty(position = 70, value = "下个分段购开始时间,如果为null则没有")
private LocalDateTime nextSaleStartTime;
private static final GoblinNftGoodsSkuInfoVo obj = new GoblinNftGoodsSkuInfoVo(); private static final GoblinNftGoodsSkuInfoVo obj = new GoblinNftGoodsSkuInfoVo();
......
...@@ -61,6 +61,12 @@ public class GoblinNftOrderVo implements Serializable, Cloneable { ...@@ -61,6 +61,12 @@ public class GoblinNftOrderVo implements Serializable, Cloneable {
@ApiModelProperty(value = "用户手机号") @ApiModelProperty(value = "用户手机号")
private String userMobile; private String userMobile;
@ApiModelProperty(value = "分批购ID")
private String listId;
@ApiModelProperty(value = "兑换码")
private String exCode;
@ApiModelProperty(value = "应付金额") @ApiModelProperty(value = "应付金额")
private BigDecimal priceTotal; private BigDecimal priceTotal;
...@@ -150,6 +156,8 @@ public class GoblinNftOrderVo implements Serializable, Cloneable { ...@@ -150,6 +156,8 @@ public class GoblinNftOrderVo implements Serializable, Cloneable {
this.setUserId(source.getUserId()); this.setUserId(source.getUserId());
this.setUserName(source.getUserName()); this.setUserName(source.getUserName());
this.setUserMobile(source.getUserMobile()); this.setUserMobile(source.getUserMobile());
this.setListId(source.getListId());
this.setExCode(source.getExCode());
this.setPriceTotal(source.getPriceTotal()); this.setPriceTotal(source.getPriceTotal());
this.setPriceCoupon(source.getPriceCoupon()); this.setPriceCoupon(source.getPriceCoupon());
this.setStorePriceCoupon(source.getStorePriceCoupon()); this.setStorePriceCoupon(source.getStorePriceCoupon());
......
...@@ -39,4 +39,8 @@ public class GoblinNftOrderListParam { ...@@ -39,4 +39,8 @@ public class GoblinNftOrderListParam {
private String payTimeStart; private String payTimeStart;
@ApiModelProperty(value = "支付结束时间") @ApiModelProperty(value = "支付结束时间")
private String payTimeEnd; private String payTimeEnd;
@ApiModelProperty(value = "兑换码")
private String exCode;
@ApiModelProperty(value = "用户手机号")
private String userMobile;
} }
...@@ -35,4 +35,8 @@ public class GoblinNftOrderRefundListParam { ...@@ -35,4 +35,8 @@ public class GoblinNftOrderRefundListParam {
private String payType; private String payType;
@ApiModelProperty(value = "订单状态") @ApiModelProperty(value = "订单状态")
private Integer status; private Integer status;
@ApiModelProperty(value = "支付开始时间")
private String payTimeStart;
@ApiModelProperty(value = "支付结束时间")
private String payTimeEnd;
} }
...@@ -6,6 +6,6 @@ import javax.servlet.http.HttpServletResponse; ...@@ -6,6 +6,6 @@ import javax.servlet.http.HttpServletResponse;
public interface IGoblinExportService { public interface IGoblinExportService {
//导出商城订单信息 //导出商城订单信息
ResponseDto<Boolean> exportMallOrder(HttpServletResponse response, String beginTime, String endTime, String state, Integer mailType,String storeId); ResponseDto<String> exportMallOrder(HttpServletResponse response, String beginTime, String endTime, String state, Integer mailType,String storeId);
} }
...@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSON; ...@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSON;
import com.liquidnet.client.admin.common.core.controller.BaseController; import com.liquidnet.client.admin.common.core.controller.BaseController;
import com.liquidnet.client.admin.common.core.domain.AjaxResult; import com.liquidnet.client.admin.common.core.domain.AjaxResult;
import com.liquidnet.client.admin.zhengzai.goblin.service.impl.GoblinFrontCubeServiceImpl; import com.liquidnet.client.admin.zhengzai.goblin.service.impl.GoblinFrontCubeServiceImpl;
import com.liquidnet.commons.lang.util.StringUtil;
import com.liquidnet.service.goblin.entity.GoblinFrontCube; import com.liquidnet.service.goblin.entity.GoblinFrontCube;
import com.liquidnet.service.goblin.param.GoblinFrontCubeParam; import com.liquidnet.service.goblin.param.GoblinFrontCubeParam;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
...@@ -52,6 +53,12 @@ public class GoblinFrontCubeController extends BaseController { ...@@ -52,6 +53,12 @@ public class GoblinFrontCubeController extends BaseController {
public AjaxResult updateOrCreate(@RequestBody List<GoblinFrontCubeParam> list) { public AjaxResult updateOrCreate(@RequestBody List<GoblinFrontCubeParam> list) {
List<GoblinFrontCube> list1=new ArrayList<>(); List<GoblinFrontCube> list1=new ArrayList<>();
for(GoblinFrontCubeParam goblinFrontCubeParam:list){ for(GoblinFrontCubeParam goblinFrontCubeParam:list){
if(StringUtil.isBlank(goblinFrontCubeParam.getSpuId())||goblinFrontCubeParam.getSpuId().equals("undefined")){
return error("spuId必传,请填写");
}
if(goblinFrontCubeParam.getSpuId().split(",").length==0){
return error("spuId必传,请填写");
}
GoblinFrontCube goblinFrontCube=new GoblinFrontCube(); GoblinFrontCube goblinFrontCube=new GoblinFrontCube();
BeanUtils.copyProperties(goblinFrontCubeParam,goblinFrontCube); BeanUtils.copyProperties(goblinFrontCubeParam,goblinFrontCube);
list1.add(goblinFrontCube); list1.add(goblinFrontCube);
......
...@@ -27,10 +27,6 @@ ...@@ -27,10 +27,6 @@
<label>订单编号:</label> <label>订单编号:</label>
<input type="text" name="orderCode"/> <input type="text" name="orderCode"/>
</li> </li>
<li>
<label>哈希值:</label>
<input type="text" name="nftId"/>
</li>
</div> </div>
<div class="col-sm-12"> <div class="col-sm-12">
<li> <li>
...@@ -52,7 +48,7 @@ ...@@ -52,7 +48,7 @@
</select> </select>
</li> </li>
<li> <li>
<label>订单状态:</label> <label>退款状态:</label>
<select name="status"> <select name="status">
<option value="">全部</option> <option value="">全部</option>
<option value="1">申请退款</option> <option value="1">申请退款</option>
...@@ -60,6 +56,18 @@ ...@@ -60,6 +56,18 @@
<option value="3">退款失败</option> <option value="3">退款失败</option>
</select> </select>
</li> </li>
<li class="select-time">
<label>支付时间: </label>
<input type="text" class="time-input" placeholder="开始日期" name="payTimeStart"/>
<span>-</span>
<input type="text" class="time-input" placeholder="结束日期" name="payTimeEnd"/>
</li>
</div>
<div class="col-sm-12">
<li>
<label>哈希值:</label>
<input type="text" name="nftId"/>
</li>
<li> <li>
<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
class="fa fa-search"></i>&nbsp;搜索</a> class="fa fa-search"></i>&nbsp;搜索</a>
......
...@@ -27,10 +27,6 @@ ...@@ -27,10 +27,6 @@
<label>订单编号:</label> <label>订单编号:</label>
<input type="text" name="orderCode"/> <input type="text" name="orderCode"/>
</li> </li>
<li>
<label>哈希值:</label>
<input type="text" name="nftId"/>
</li>
</div> </div>
<div class="col-sm-12"> <div class="col-sm-12">
<li> <li>
...@@ -66,6 +62,20 @@ ...@@ -66,6 +62,20 @@
<span>-</span> <span>-</span>
<input type="text" class="time-input" placeholder="结束日期" name="payTimeEnd"/> <input type="text" class="time-input" placeholder="结束日期" name="payTimeEnd"/>
</li> </li>
</div>
<div class="col-sm-12">
<li>
<label>哈希值:</label>
<input type="text" name="nftId"/>
</li>
<li>
<label>兑换码:</label>
<input type="text" name="exCode"/>
</li>
<li>
<label>用户手机号:</label>
<input type="text" name="userMobile"/>
</li>
<li> <li>
<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
class="fa fa-search"></i>&nbsp;搜索</a> class="fa fa-search"></i>&nbsp;搜索</a>
...@@ -135,8 +145,12 @@ ...@@ -135,8 +145,12 @@
{ {
field: 'payType', field: 'payType',
title: '支付方式', title: '支付方式',
formatter: function (value) { formatter: function (value, row) {
if (row.orderType == 2 || row.orderType == 4) {
return row.exCode;
} else {
return $.table.selectDictLabel(payTypeDic, value); return $.table.selectDictLabel(payTypeDic, value);
}
}, },
}, },
{ {
...@@ -160,7 +174,21 @@ ...@@ -160,7 +174,21 @@
}, },
{ {
field: 'name', field: 'name',
title: '藏品名称' title: '藏品名称',
formatter: function (value) {
return value.trim().split(" ")[0];
}
},
{
field: 'boxSkuId',
title: '藏品类型',
formatter: function (value) {
if (value) {
return "盲盒";
} else {
return "明盒";
}
}
}, },
{ {
field: 'tradingAt', field: 'tradingAt',
......
...@@ -24,7 +24,7 @@ public class GoblinNftOrderListExcelDto implements Serializable, Cloneable { ...@@ -24,7 +24,7 @@ public class GoblinNftOrderListExcelDto implements Serializable, Cloneable {
private String priceActual; private String priceActual;
@Excel(name = "订单状态") @Excel(name = "订单状态")
private String status; private String status;
@Excel(name = "下大美时间") @Excel(name = "下时间")
private String createdAt; private String createdAt;
@Excel(name = "支付时间") @Excel(name = "支付时间")
private String payTime; private String payTime;
...@@ -59,6 +59,9 @@ public class GoblinNftOrderListExcelDto implements Serializable, Cloneable { ...@@ -59,6 +59,9 @@ public class GoblinNftOrderListExcelDto implements Serializable, Cloneable {
case 3: case 3:
this.setOrderType("演出赠送"); this.setOrderType("演出赠送");
break; break;
case 4:
this.setOrderType("空投赠送");
break;
default: default:
this.setOrderType("未知"); this.setOrderType("未知");
break; break;
......
...@@ -67,6 +67,17 @@ public class GoblinFrontCubeServiceImpl extends ServiceImpl<GoblinFrontCubeMappe ...@@ -67,6 +67,17 @@ public class GoblinFrontCubeServiceImpl extends ServiceImpl<GoblinFrontCubeMappe
public boolean updateOrCreate(List<GoblinFrontCube> list) { public boolean updateOrCreate(List<GoblinFrontCube> list) {
for(GoblinFrontCube goblinFrontCube:list){ for(GoblinFrontCube goblinFrontCube:list){
if (goblinFrontCube.getMid() == 0) { if (goblinFrontCube.getMid() == 0) {
String spuIds="";
for(String spuId:goblinFrontCube.getSpuId().split(",")){
if(spuId.equals("")||spuId.equals("undefined")){
}else{
spuIds=spuIds.concat(spuId).concat(",");
}
}
if(spuIds.length()>0){
goblinFrontCube.setSpuId(spuIds.substring(0,spuIds.length()-1));
}
this.create(goblinFrontCube); this.create(goblinFrontCube);
} else { } else {
goblinFrontCube.setUpdateTime(LocalDateTime.now()); goblinFrontCube.setUpdateTime(LocalDateTime.now());
...@@ -79,7 +90,10 @@ public class GoblinFrontCubeServiceImpl extends ServiceImpl<GoblinFrontCubeMappe ...@@ -79,7 +90,10 @@ public class GoblinFrontCubeServiceImpl extends ServiceImpl<GoblinFrontCubeMappe
spuIds=spuIds.concat(spuId).concat(","); spuIds=spuIds.concat(spuId).concat(",");
} }
} }
goblinFrontCube.setSpuId(spuIds); if(spuIds.length()>0){
goblinFrontCube.setSpuId(spuIds.substring(0,spuIds.length()-1));
}
goblinFrontCubeMapper.updateById(goblinFrontCube); goblinFrontCubeMapper.updateById(goblinFrontCube);
} }
} }
...@@ -107,7 +121,9 @@ public class GoblinFrontCubeServiceImpl extends ServiceImpl<GoblinFrontCubeMappe ...@@ -107,7 +121,9 @@ public class GoblinFrontCubeServiceImpl extends ServiceImpl<GoblinFrontCubeMappe
List<GoblinGoods> goodsList= goblinGoodsMapper.selectList(queryWrappers); List<GoblinGoods> goodsList= goblinGoodsMapper.selectList(queryWrappers);
GoblinFrontCubeParam goblinFrontCubeParam=new GoblinFrontCubeParam(); GoblinFrontCubeParam goblinFrontCubeParam=new GoblinFrontCubeParam();
BeanUtils.copyProperties(goblinFrontCube,goblinFrontCubeParam); BeanUtils.copyProperties(goblinFrontCube,goblinFrontCubeParam);
if(null!=goodsList&&goodsList.size()>0){
goblinFrontCubeParam.setGoblinGoods(goodsList.get(0)); goblinFrontCubeParam.setGoblinGoods(goodsList.get(0));
}
list1.add(goblinFrontCubeParam); list1.add(goblinFrontCubeParam);
} }
} }
...@@ -139,6 +155,8 @@ public class GoblinFrontCubeServiceImpl extends ServiceImpl<GoblinFrontCubeMappe ...@@ -139,6 +155,8 @@ public class GoblinFrontCubeServiceImpl extends ServiceImpl<GoblinFrontCubeMappe
} }
//redis //redis
redisDataSourceUtil.getRedisGoblinUtil().set(GoblinRedisConst.FRONT_GOBLINFRONTCUBE,list); redisDataSourceUtil.getRedisGoblinUtil().set(GoblinRedisConst.FRONT_GOBLINFRONTCUBE,list);
}else{
redisDataSourceUtil.getRedisGoblinUtil().set(GoblinRedisConst.FRONT_GOBLINFRONTCUBE,list);
} }
return true; return true;
...@@ -164,6 +182,8 @@ public class GoblinFrontCubeServiceImpl extends ServiceImpl<GoblinFrontCubeMappe ...@@ -164,6 +182,8 @@ public class GoblinFrontCubeServiceImpl extends ServiceImpl<GoblinFrontCubeMappe
} }
//redis //redis
redisDataSourceUtil.getRedisGoblinUtil().set(GoblinRedisConst.FRONT_GOBLIN_RECOMMEND,list); redisDataSourceUtil.getRedisGoblinUtil().set(GoblinRedisConst.FRONT_GOBLIN_RECOMMEND,list);
}else{
redisDataSourceUtil.getRedisGoblinUtil().set(GoblinRedisConst.FRONT_GOBLIN_RECOMMEND,list);
} }
return true; return true;
} }
......
...@@ -116,9 +116,9 @@ public class ZxlnftSdkServiceImpl implements ZxlnftSdkService ...@@ -116,9 +116,9 @@ public class ZxlnftSdkServiceImpl implements ZxlnftSdkService
} }
log.info("nft003RegisterPersonPlatform--->>> response : {} ",response); log.info("nft003RegisterPersonPlatform--->>> response : {} ",response);
if (StringUtils.isEmpty(response)) { // if (StringUtils.isEmpty(response)) {
return null; // return null;
} // }
/** /**
* 构造返回结果 * 构造返回结果
...@@ -488,10 +488,6 @@ public class ZxlnftSdkServiceImpl implements ZxlnftSdkService ...@@ -488,10 +488,6 @@ public class ZxlnftSdkServiceImpl implements ZxlnftSdkService
} }
log.info("nft014IdentityBindSubmitByTrusted--->>> response : {} ",response); log.info("nft014IdentityBindSubmitByTrusted--->>> response : {} ",response);
if (StringUtils.isEmpty(response)) {
return null;
}
/** /**
* 构造返回结果 * 构造返回结果
*/ */
......
...@@ -2,6 +2,7 @@ package com.liquidnet.common.third.zxlnft.util; ...@@ -2,6 +2,7 @@ package com.liquidnet.common.third.zxlnft.util;
import com.liquidnet.common.third.zxlnft.biz.ZxlnftBiz; import com.liquidnet.common.third.zxlnft.biz.ZxlnftBiz;
import com.liquidnet.common.third.zxlnft.config.ZxlnftConfig; import com.liquidnet.common.third.zxlnft.config.ZxlnftConfig;
import com.liquidnet.common.third.zxlnft.constant.ZxlErrorEnum;
import com.liquidnet.common.third.zxlnft.dto.*; import com.liquidnet.common.third.zxlnft.dto.*;
import com.liquidnet.common.third.zxlnft.dto.nft.*; import com.liquidnet.common.third.zxlnft.dto.nft.*;
import com.liquidnet.common.third.zxlnft.exception.ZxlNftException; import com.liquidnet.common.third.zxlnft.exception.ZxlNftException;
...@@ -90,6 +91,8 @@ public class ZxlnftSdkUtil { ...@@ -90,6 +91,8 @@ public class ZxlnftSdkUtil {
BeanUtil.copy(resp,respDto); BeanUtil.copy(resp,respDto);
}catch(ZxlNftException e){ }catch(ZxlNftException e){
return ZxlnftResponseDto.failure(e.getCode()+","+e.getMessage()); return ZxlnftResponseDto.failure(e.getCode()+","+e.getMessage());
}catch(Exception e){
return ZxlnftResponseDto.failure(ZxlErrorEnum.SERVER_INNER_ERROR.getCode(),ZxlErrorEnum.SERVER_INNER_ERROR.getMsg());
} }
return ZxlnftResponseDto.success(respDto); return ZxlnftResponseDto.success(respDto);
} }
...@@ -316,6 +319,8 @@ public class ZxlnftSdkUtil { ...@@ -316,6 +319,8 @@ public class ZxlnftSdkUtil {
BeanUtil.copy(resp,respDto); BeanUtil.copy(resp,respDto);
}catch(ZxlNftException e){ }catch(ZxlNftException e){
return ZxlnftResponseDto.failure(e.getCode()+","+e.getMessage()); return ZxlnftResponseDto.failure(e.getCode()+","+e.getMessage());
}catch(Exception e){
return ZxlnftResponseDto.failure(ZxlErrorEnum.SERVER_INNER_ERROR.getCode(),ZxlErrorEnum.SERVER_INNER_ERROR.getMsg());
} }
return ZxlnftResponseDto.success(respDto); return ZxlnftResponseDto.success(respDto);
} }
......
...@@ -15,4 +15,6 @@ public class GoblinNftOrderListDto { ...@@ -15,4 +15,6 @@ public class GoblinNftOrderListDto {
private String name; private String name;
private String tradingAt; private String tradingAt;
private String nftId; private String nftId;
private String exCode;
private String boxSkuId;
} }
...@@ -85,6 +85,16 @@ public class GoblinNftOrder implements Serializable, Cloneable { ...@@ -85,6 +85,16 @@ public class GoblinNftOrder implements Serializable, Cloneable {
*/ */
private String userMobile; private String userMobile;
/**
* 分批购ID
*/
private String listId;
/**
* 兑换码
*/
private String exCode;
/** /**
* 应付金额 * 应付金额
*/ */
......
...@@ -94,4 +94,12 @@ public interface GoblinNftExCodeMapper extends BaseMapper<GoblinNftExCode> { ...@@ -94,4 +94,12 @@ public interface GoblinNftExCodeMapper extends BaseMapper<GoblinNftExCode> {
* @return * @return
*/ */
int updateCodeAdminUids(@Param("codes") String codes, @Param("adminUid") String adminUid); int updateCodeAdminUids(@Param("codes") String codes, @Param("adminUid") String adminUid);
/**
* excel导出打乱兑换码顺序
* @param goblinNftExCode
* @return
*/
List<GoblinNftExCode> selectGoblinNftCodeExcel(GoblinNftExCode goblinNftExCode);
} }
...@@ -129,6 +129,58 @@ ...@@ -129,6 +129,58 @@
</select> </select>
<select id="selectGoblinNftCodeExcel" parameterType="com.liquidnet.service.goblin.entity.GoblinNftExCode"
resultMap="BeseResult">
select
DISTINCT
gnec.code,gnec.code_id,gnec.sku_id,gnec.box_sku_id,gnec.activity_id,gnec.state,gnec.redeem_uid,gnec.redeem_at,gnec.admin_uid,gnec.created_at
from goblin_nft_ex_code gnec inner join goblin_nft_ex_sku gnes on gnec.sku_id = gnes.sku_id and gnes.activity_id
= gnec.activity_id
<where>
<if test="code != null and code != ''">
and gnec.code = #{code,jdbcType=VARCHAR}
</if>
<if test="activityId != null and activityId != ''">
and gnec.activity_id = #{activityId,jdbcType=VARCHAR}
</if>
<if test="state != null">
<choose>
<when test="state == 1">
and (now() BETWEEN gnes.ex_start_time and gnes.ex_stop_time) and
gnec.state =1
</when>
<when test="state == 2">
and gnec.state = 2
</when>
<when test="state == 3">
and (((now() &gt; gnes.ex_stop_time) AND gnec.state = 1) ||
gnec.state = 3)
</when>
</choose>
</if>
<if test="redeemUid != null and redeemUid != ''">
and gnec.redeem_uid = #{redeemUid,jdbcType=VARCHAR}
</if>
<if test="skuId != null and skuId != ''">
and gnec.sku_id in
<foreach collection="skuId.split(',')" item="sId" open="(" separator="," close=")">
#{sId,jdbcType=VARCHAR}
</foreach>
</if>
<if test="isDrivi != null">
<choose>
<when test="isDrivi == 1">
and gnec.admin_uid = ''
</when>
<when test="isDrivi == 2">
and gnec.admin_uid != ''
</when>
</choose>
</if>
</where>
ORDER BY gnec.code desc
</select>
<select id="selectCodeAvailableByActivityId" resultMap="BeseResult"> <select id="selectCodeAvailableByActivityId" resultMap="BeseResult">
select DISTINCT gnec.code, select DISTINCT gnec.code,
gnec.code_id, gnec.code_id,
......
...@@ -3,48 +3,56 @@ ...@@ -3,48 +3,56 @@
<mapper namespace="com.liquidnet.service.goblin.mapper.GoblinNftOrderMapper"> <mapper namespace="com.liquidnet.service.goblin.mapper.GoblinNftOrderMapper">
<select id="searchList" resultType="com.liquidnet.service.goblin.dto.admin.GoblinNftOrderListDto"> <select id="searchList" resultType="com.liquidnet.service.goblin.dto.admin.GoblinNftOrderListDto">
select select c.trading_at, c.nft_id, a.* from (select
a.user_id,a.order_code,a.order_type,a.pay_type,a.price_actual,a.status,a.pay_time,a.created_at, user_id,order_code,order_id,order_type,pay_type,price_actual,
b.name, status,pay_time,created_at,sku_title as name, mid, ex_code, box_sku_id
c.trading_at, c.nft_id from goblin_nft_order
from goblin_nft_order as a
left join goblin_goods_sku as b on b.sku_id = a.sku_id
left join goblin_user_digital_artwork as c on c.order_id = a.order_id and c.del_flg = '0'
<where> <where>
<if test="name!=''"> <if test="name!=''">
and b.name like concat('%', #{name}, '%') and sku_title like concat('%', #{name}, '%')
</if> </if>
<if test="userId!=''"> <if test="userId!=''">
and a.user_id = #{userId} and user_id = #{userId}
</if>
<if test="userMobile!=''">
and user_mobile = #{userMobile}
</if> </if>
<if test="shortOrderCode!=''"> <if test="shortOrderCode!=''">
and a.order_code like concat('%', #{shortOrderCode}, '%') and order_code like concat('%', #{shortOrderCode}, '%')
</if> </if>
<if test="orderCode!=''"> <if test="orderCode!=''">
and a.order_code = #{orderCode} and order_code = #{orderCode}
</if>
<if test="nftId!=''">
and c.nft_id = #{nftId}
</if> </if>
<if test="orderType != null and orderType!=''"> <if test="orderType != null and orderType!=''">
and a.order_type = #{orderType} and order_type = #{orderType}
</if> </if>
<if test="payType!=''"> <if test="payType!=''">
and a.pay_type = #{payType} and pay_type = #{payType}
</if> </if>
<if test="status != null and status!=''"> <if test="status != null and status!=''">
and a.status = #{status} and status = #{status}
</if> </if>
<if test="payTimeStart != null and payTimeStart != ''"> <if test="payTimeStart != null and payTimeStart != ''">
<!-- and amo.payment_at &gt; #{paymentAtStart} --> <!-- and amo.payment_at &gt; #{paymentAtStart} -->
and a.pay_time <![CDATA[>=]]> #{payTimeStart} and pay_time <![CDATA[>=]]> #{payTimeStart}
</if> </if>
<if test="payTimeEnd != null and payTimeEnd != ''"> <if test="payTimeEnd != null and payTimeEnd != ''">
<!-- and amo.payment_at &lt; #{paymentAtEnd} --> <!-- and amo.payment_at &lt; #{paymentAtEnd} -->
and a.pay_time <![CDATA[<=]]> #{payTimeEnd} and pay_time <![CDATA[<=]]> #{payTimeEnd}
</if>
<if test="exCode!=''">
and ex_code = #{exCode}
</if>
</where>
) as a
left join goblin_user_digital_artwork as c on c.order_id = a.order_id and c.del_flg = '0'
<where>
<if test="nftId!=''">
and c.nft_id = #{nftId}
</if> </if>
</where> </where>
group by a.order_id -- group by a.order_id
order by a.created_at desc -- order by a.created_at desc
order by a.mid desc
</select> </select>
</mapper> </mapper>
...@@ -37,8 +37,17 @@ ...@@ -37,8 +37,17 @@
<if test="status != null and status!=''"> <if test="status != null and status!=''">
and d.status = #{status} and d.status = #{status}
</if> </if>
<if test="payTimeStart != null and payTimeStart != ''">
<!-- and amo.payment_at &gt; #{paymentAtStart} -->
and a.pay_time <![CDATA[>=]]> #{payTimeStart}
</if>
<if test="payTimeEnd != null and payTimeEnd != ''">
<!-- and amo.payment_at &lt; #{paymentAtEnd} -->
and a.pay_time <![CDATA[<=]]> #{payTimeEnd}
</if>
</where> </where>
group by a.order_id -- group by a.order_id
order by d.created_at desc -- order by d.created_at desc
order by d.mid desc
</select> </select>
</mapper> </mapper>
...@@ -103,7 +103,8 @@ ...@@ -103,7 +103,8 @@
// LocalDateTime now = LocalDateTime.now(); // LocalDateTime now = LocalDateTime.now();
// //
// GoblinUserDigitalArtworkVo digitalArtworkVo = GoblinUserDigitalArtworkVo.getNew(); // GoblinUserDigitalArtworkVo digitalArtworkVo = GoblinUserDigitalArtworkVo.getNew();
// String artworkId = IDGenerator.nextMilliId2(); //// String artworkId = IDGenerator.nextMilliId2();
// String artworkId = IDGenerator.nextSnowId();
// digitalArtworkVo.setArtworkId(artworkId); // digitalArtworkVo.setArtworkId(artworkId);
// digitalArtworkVo.setSkuId(skuId); // digitalArtworkVo.setSkuId(skuId);
// digitalArtworkVo.setUid(uid); // digitalArtworkVo.setUid(uid);
......
...@@ -185,7 +185,7 @@ public abstract class AbstractOrderCloseReceiver implements StreamListener<Strin ...@@ -185,7 +185,7 @@ public abstract class AbstractOrderCloseReceiver implements StreamListener<Strin
// 库存购买数量回滚 // 库存购买数量回滚
goblinNftUtils.decrSkuCountByUid(nftOrder.getUserId(), nftOrder.getSkuId(), nftOrder.getNum()); goblinNftUtils.decrSkuCountByUid(nftOrder.getUserId(), nftOrder.getSkuId(), nftOrder.getNum());
LocalDateTime nowTime = LocalDateTime.now(); LocalDateTime nowTime = LocalDateTime.now();
if (StringUtils.isEmpty(nftOrder.getBoxSkuId())) {// 购买藏品 /*if (StringUtils.isEmpty(nftOrder.getBoxSkuId())) {// 购买藏品
GoblinListCollectVo goblinListCollectVo = goblinNftUtils.getCollectByNowNext(nowTime, nftOrder.getSkuId()); GoblinListCollectVo goblinListCollectVo = goblinNftUtils.getCollectByNowNext(nowTime, nftOrder.getSkuId());
String listId = (null == goblinListCollectVo) ? null : goblinListCollectVo.getListId(); String listId = (null == goblinListCollectVo) ? null : goblinListCollectVo.getListId();
log.debug("listId : {}", listId); log.debug("listId : {}", listId);
...@@ -195,6 +195,14 @@ public abstract class AbstractOrderCloseReceiver implements StreamListener<Strin ...@@ -195,6 +195,14 @@ public abstract class AbstractOrderCloseReceiver implements StreamListener<Strin
String listId = (null == goblinListCollectVo) ? null : goblinListCollectVo.getListId(); String listId = (null == goblinListCollectVo) ? null : goblinListCollectVo.getListId();
log.debug("listId : {}", listId); log.debug("listId : {}", listId);
goblinNftUtils.incrSkuStock(listId, nftOrder.getBoxSkuId(), nftOrder.getNum()); goblinNftUtils.incrSkuStock(listId, nftOrder.getBoxSkuId(), nftOrder.getNum());
}*/
GoblinListCollectVo goblinListCollectVo = goblinNftUtils.getCollectByNowNext(nowTime, nftOrder.getSkuId());
String listId = (null == goblinListCollectVo) ? null : goblinListCollectVo.getListId();
log.debug("listId : {}",listId);
if (StringUtils.isEmpty(nftOrder.getBoxSkuId())) {// 购买藏品
goblinNftUtils.incrSkuStock(listId, nftOrder.getSkuId(), nftOrder.getNum());
} else {// 购买盲盒
goblinNftUtils.incrSkuStock(listId, nftOrder.getBoxSkuId(), nftOrder.getNum());
} }
// 订单状态 // 订单状态
......
...@@ -103,7 +103,8 @@ package com.liquidnet.service.consumer.slowly.receiver;//package com.liquidnet.s ...@@ -103,7 +103,8 @@ package com.liquidnet.service.consumer.slowly.receiver;//package com.liquidnet.s
// LocalDateTime now = LocalDateTime.now(); // LocalDateTime now = LocalDateTime.now();
// //
// GoblinUserDigitalArtworkVo digitalArtworkVo = GoblinUserDigitalArtworkVo.getNew(); // GoblinUserDigitalArtworkVo digitalArtworkVo = GoblinUserDigitalArtworkVo.getNew();
// String artworkId = IDGenerator.nextMilliId2(); //// String artworkId = IDGenerator.nextMilliId2();
// String artworkId = IDGenerator.nextSnowId();
// digitalArtworkVo.setArtworkId(artworkId); // digitalArtworkVo.setArtworkId(artworkId);
// digitalArtworkVo.setSkuId(skuId); // digitalArtworkVo.setSkuId(skuId);
// digitalArtworkVo.setUid(uid); // digitalArtworkVo.setUid(uid);
......
...@@ -171,9 +171,13 @@ public class ZxinUserCommonBiz { ...@@ -171,9 +171,13 @@ public class ZxinUserCommonBiz {
if(nft003Resp.isSuccess()){ if(nft003Resp.isSuccess()){
userIdentification = nft003Resp.getData().getUserIdentification(); userIdentification = nft003Resp.getData().getUserIdentification();
isRealNameAuthSuccess = true; isRealNameAuthSuccess = true;
}else{
if(nft003Resp.getCode().equals(ZxlErrorEnum.SERVER_INNER_ERROR.getCode())){
throw new ZxlNftException(nft003Resp.getCode(),nft003Resp.getMessage());
}else{ }else{
throw new GalaxyNftUserException(nft003Resp.getCode(),nft003Resp.getMessage()); throw new GalaxyNftUserException(nft003Resp.getCode(),nft003Resp.getMessage());
} }
}
//如果实名认证成功,并且该身份证已经开通过数字账户 //如果实名认证成功,并且该身份证已经开通过数字账户
if(isRealNameAuthSuccess){ if(isRealNameAuthSuccess){
...@@ -291,8 +295,8 @@ public class ZxinUserCommonBiz { ...@@ -291,8 +295,8 @@ public class ZxinUserCommonBiz {
//是否开通数字账户 //是否开通数字账户
boolean isOpenAccount = false; boolean isOpenAccount = false;
//开通失败错误信息 //开通失败错误信息
String resultCode = null; String resultCode = NftAccStatusEnum.StatusAcc.ING.getCode();
String resultMessage = null; String resultMessage = NftAccStatusEnum.StatusAcc.ING.getMsg();
//实名成功+绑定区块链地址成功 //实名成功+绑定区块链地址成功
if(isRealNameAuthSuccess && isBindBlockAddressSuccess){ if(isRealNameAuthSuccess && isBindBlockAddressSuccess){
...@@ -305,8 +309,13 @@ public class ZxinUserCommonBiz { ...@@ -305,8 +309,13 @@ public class ZxinUserCommonBiz {
if(!isOpenAccount){ if(!isOpenAccount){
//实名失败 //实名失败
if(!isRealNameAuthSuccess){ if(!isRealNameAuthSuccess){
if(StringUtil.isNotEmpty(bizFailDesc)){
resultCode = NftAccStatusEnum.StatusAcc.FAILURE1.getCode(); resultCode = NftAccStatusEnum.StatusAcc.FAILURE1.getCode();
resultMessage = NftAccStatusEnum.StatusAcc.FAILURE1.getMsg(); resultMessage = NftAccStatusEnum.StatusAcc.FAILURE1.getMsg();
}else if(StringUtil.isNotEmpty(sysFailDesc)){
resultCode = NftAccStatusEnum.StatusAcc.FAILURE2.getCode();
resultMessage = NftAccStatusEnum.StatusAcc.FAILURE2.getMsg();
}
}else{ }else{
//地址绑定失败 //地址绑定失败
if(!isBindBlockAddressSuccess){ if(!isBindBlockAddressSuccess){
...@@ -350,7 +359,7 @@ public class ZxinUserCommonBiz { ...@@ -350,7 +359,7 @@ public class ZxinUserCommonBiz {
} }
//设置错误信息到redis //设置错误信息到redis
if(StringUtil.isNotEmpty(resultCode)&&!resultCode.equalsIgnoreCase(NftAccStatusEnum.StatusAcc.SUCCESS.getCode())){ if(StringUtil.isNotEmpty(resultCode)&&resultCode.equalsIgnoreCase(NftAccStatusEnum.StatusAcc.FAILURE1.getCode())){
//开户失败记录缓存 {goblin:nft:certmeta:{idType+idNo},{idname,mobile}} //开户失败记录缓存 {goblin:nft:certmeta:{idType+idNo},{idname,mobile}}
dataUtils.getRedisUtil().set(GoblinRedisConst.REDIS_GOBLIN_NFT_CERTMETA_JUNK.concat(reqDto.getIdCardType().concat(reqDto.getIdCard())) dataUtils.getRedisUtil().set(GoblinRedisConst.REDIS_GOBLIN_NFT_CERTMETA_JUNK.concat(reqDto.getIdCardType().concat(reqDto.getIdCard()))
,reqDto.getUserName().concat(",").concat(reqDto.getMobile()),openAccFailKeyExpireTime); ,reqDto.getUserName().concat(",").concat(reqDto.getMobile()),openAccFailKeyExpireTime);
......
USE dev_ln_scene;
ALTER TABLE goblin_nft_order ADD list_id VARCHAR(64) NOT NULL DEFAULT '' COMMENT '分批购ID' after user_mobile;
ALTER TABLE goblin_nft_order ADD ex_code VARCHAR(64) NOT NULL DEFAULT '' COMMENT '兑换码' after list_id;
\ No newline at end of file
package com.liquidnet.service.goblin.controller; package com.liquidnet.service.goblin.controller;
import com.liquidnet.common.cache.redis.util.RedisUtil;
import com.liquidnet.commons.lang.util.StringUtil; import com.liquidnet.commons.lang.util.StringUtil;
import com.liquidnet.service.base.ResponseDto; import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.goblin.dto.vo.*; import com.liquidnet.service.goblin.dto.vo.*;
import com.liquidnet.service.goblin.entity.GoblinFrontHotWord; import com.liquidnet.service.goblin.entity.GoblinFrontHotWord;
import com.liquidnet.service.goblin.service.GoblinFrontService;
import com.liquidnet.service.goblin.service.impl.GoblinFrontServiceImpl; import com.liquidnet.service.goblin.service.impl.GoblinFrontServiceImpl;
import com.liquidnet.service.goblin.util.GoblinRedisUtils;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -134,9 +131,9 @@ public class GoblinFrontController { ...@@ -134,9 +131,9 @@ public class GoblinFrontController {
@GetMapping("searchGoodesName") @GetMapping("searchGoodesName")
@ApiOperation("搜索商品名字、或商铺名字") @ApiOperation("搜索商品名字、或商铺名字")
public ResponseDto<List<GoblinGoodsInfoListVo>> searchGoodesName(@RequestParam(name = "name", required = true) String name) throws ParseException { public ResponseDto<GoblinGoodsInfoListVoo> searchGoodesName(@RequestParam(name = "name", required = true) String name,@RequestParam(name = "page", required = true) int page,@RequestParam(name = "pageSize", required = true) int pageSize) throws ParseException {
if (StringUtil.isNotBlank(name)) { if (StringUtil.isNotBlank(name)) {
return ResponseDto.success(goblinFrontService.searchGoodesName(name)); return ResponseDto.success(goblinFrontService.searchGoodesName(name,page,pageSize));
} }
return ResponseDto.success(null); return ResponseDto.success(null);
} }
......
...@@ -380,6 +380,8 @@ public class GoblinFrontServiceImpl implements GoblinFrontService { ...@@ -380,6 +380,8 @@ public class GoblinFrontServiceImpl implements GoblinFrontService {
} }
goblinFrontCubeVo.setGoblinGoodsInfoVoList(goblinGoodsInfoVoArrayList); goblinFrontCubeVo.setGoblinGoodsInfoVoList(goblinGoodsInfoVoArrayList);
}else{
return null;
} }
return goblinFrontCubeVo; return goblinFrontCubeVo;
} }
...@@ -463,7 +465,7 @@ public class GoblinFrontServiceImpl implements GoblinFrontService { ...@@ -463,7 +465,7 @@ public class GoblinFrontServiceImpl implements GoblinFrontService {
} }
public List<GoblinGoodsInfoListVo> searchGoodesName(String name) { public GoblinGoodsInfoListVoo searchGoodesName(String name,int page,int pageSize) {
List<String> listStore = mongoUtils.getStoreInfoVoRegexName(name); List<String> listStore = mongoUtils.getStoreInfoVoRegexName(name);
Pattern pattern = Pattern.compile("^.*" + name + ".*$", Pattern.CASE_INSENSITIVE); Pattern pattern = Pattern.compile("^.*" + name + ".*$", Pattern.CASE_INSENSITIVE);
Query query = new Query(); Query query = new Query();
...@@ -475,11 +477,15 @@ public class GoblinFrontServiceImpl implements GoblinFrontService { ...@@ -475,11 +477,15 @@ public class GoblinFrontServiceImpl implements GoblinFrontService {
), ),
new Criteria().orOperator(Criteria.where("spuType").exists(false), (Criteria.where("spuType").is(0))) new Criteria().orOperator(Criteria.where("spuType").exists(false), (Criteria.where("spuType").is(0)))
)); ));
query.with(PageRequest.of(0, 20)).with(Sort.by( long count = mongoTemplate.count(query, GoblinGoodsInfoVo.class.getSimpleName());
query.with(PageRequest.of(page, pageSize)).with(Sort.by(
//Sort.Order.desc("count"), //Sort.Order.desc("count"),
Sort.Order.desc("shelvesAt") Sort.Order.desc("shelvesAt")
)); ));
List<GoblinGoodsInfoVo> list = mongoTemplate.find(query, GoblinGoodsInfoVo.class, GoblinGoodsInfoVo.class.getSimpleName()); List<GoblinGoodsInfoVo> list = mongoTemplate.find(query, GoblinGoodsInfoVo.class, GoblinGoodsInfoVo.class.getSimpleName());
GoblinGoodsInfoListVoo goblinGoodsInfoListVoo=GoblinGoodsInfoListVoo.getNew();
goblinGoodsInfoListVoo.setCount(count);
ArrayList<GoblinGoodsInfoListVo> list1 = ObjectUtil.getGoblinGoodsInfoListVo(); ArrayList<GoblinGoodsInfoListVo> list1 = ObjectUtil.getGoblinGoodsInfoListVo();
//遍历 //遍历
for (GoblinGoodsInfoVo goblinGoodsInfoVo : list) { for (GoblinGoodsInfoVo goblinGoodsInfoVo : list) {
...@@ -507,7 +513,9 @@ public class GoblinFrontServiceImpl implements GoblinFrontService { ...@@ -507,7 +513,9 @@ public class GoblinFrontServiceImpl implements GoblinFrontService {
list1.add(goblinGoodsInfoListVo); list1.add(goblinGoodsInfoListVo);
} }
} }
return list1; goblinGoodsInfoListVoo.setList(list1);
return goblinGoodsInfoListVoo;
//return list1;
} }
public GoblinFrontCategoryListVo getStoreGoodes(String storeId, String categoryId, String name) { public GoblinFrontCategoryListVo getStoreGoodes(String storeId, String categoryId, String name) {
......
...@@ -148,6 +148,7 @@ public class GoblinNftGoodsAppServiceImpl implements IGoblinNftGoodsAppService { ...@@ -148,6 +148,7 @@ public class GoblinNftGoodsAppServiceImpl implements IGoblinNftGoodsAppService {
Integer tagType = (Integer) map.get("tagType"); Integer tagType = (Integer) map.get("tagType");
String listId = (String) map.get("listId"); String listId = (String) map.get("listId");
LocalDateTime baseSaleStartTime = (LocalDateTime) map.get("baseSaleStartTime"); LocalDateTime baseSaleStartTime = (LocalDateTime) map.get("baseSaleStartTime");
LocalDateTime nextSaleStartTime = (LocalDateTime) map.get("nextSaleStartTime");
if (goblinRedisUtils.getSkuAllStatusShow(skuInfoVo)) { if (goblinRedisUtils.getSkuAllStatusShow(skuInfoVo)) {
//获取预约相关 //获取预约相关
AnticipateValueVo anticipateValueVo = goblinGoodsAnticipateMgService.getAnticipateValueBySkuId(skuId, 1); AnticipateValueVo anticipateValueVo = goblinGoodsAnticipateMgService.getAnticipateValueBySkuId(skuId, 1);
...@@ -178,6 +179,8 @@ public class GoblinNftGoodsAppServiceImpl implements IGoblinNftGoodsAppService { ...@@ -178,6 +179,8 @@ public class GoblinNftGoodsAppServiceImpl implements IGoblinNftGoodsAppService {
nftGoodsSkuInfoVo.setTagType(tagType); nftGoodsSkuInfoVo.setTagType(tagType);
nftGoodsSkuInfoVo.setListId(listId); nftGoodsSkuInfoVo.setListId(listId);
nftGoodsSkuInfoVo.setBaseSaleStartTime(baseSaleStartTime); nftGoodsSkuInfoVo.setBaseSaleStartTime(baseSaleStartTime);
nftGoodsSkuInfoVo.setNextSaleStartTime(nextSaleStartTime);
// 是否开启兑换 // 是否开启兑换
nftGoodsSkuInfoVo.setIsExchange(goblinRedisUtils.getIsExchange(skuId)); nftGoodsSkuInfoVo.setIsExchange(goblinRedisUtils.getIsExchange(skuId));
return nftGoodsSkuInfoVo; return nftGoodsSkuInfoVo;
......
...@@ -77,6 +77,9 @@ public class GoblinUserDigitalArtworkServiceImpl implements IGoblinUserDigitalAr ...@@ -77,6 +77,9 @@ public class GoblinUserDigitalArtworkServiceImpl implements IGoblinUserDigitalAr
LocalDateTime now = LocalDateTime.now(), toCheckTime = now.minusSeconds(15); LocalDateTime now = LocalDateTime.now(), toCheckTime = now.minusSeconds(15);
for (int i = 0, subSize = subArtworkIdList.size(); i < subSize; i++) { for (int i = 0, subSize = subArtworkIdList.size(); i < subSize; i++) {
GoblinUserDigitalArtworkVo userDigitalArtworkVo = goblinRedisUtils.getUserDigitalArtworkVo(subArtworkIdList.get(i)); GoblinUserDigitalArtworkVo userDigitalArtworkVo = goblinRedisUtils.getUserDigitalArtworkVo(subArtworkIdList.get(i));
if (null == userDigitalArtworkVo || !userDigitalArtworkVo.getUid().equals(uid)) {
continue;
}
GoblinGoodsSkuInfoVo goodsSkuInfoVo = goblinRedisUtils.getGoodsSkuInfoVo(userDigitalArtworkVo.getSkuId()); GoblinGoodsSkuInfoVo goodsSkuInfoVo = goblinRedisUtils.getGoodsSkuInfoVo(userDigitalArtworkVo.getSkuId());
GoblinUserDigitalArtworkListVo listVo = GoblinUserDigitalArtworkListVo.getNew().copy(userDigitalArtworkVo); GoblinUserDigitalArtworkListVo listVo = GoblinUserDigitalArtworkListVo.getNew().copy(userDigitalArtworkVo);
...@@ -188,7 +191,8 @@ public class GoblinUserDigitalArtworkServiceImpl implements IGoblinUserDigitalAr ...@@ -188,7 +191,8 @@ public class GoblinUserDigitalArtworkServiceImpl implements IGoblinUserDigitalAr
userDigitalArtworkBoxVo.setDeletedAt(now); userDigitalArtworkBoxVo.setDeletedAt(now);
// if (goblinMongoUtils.updateUserDigitalArtworkVoByUnboxing(userDigitalArtworkBoxVo)) { // if (goblinMongoUtils.updateUserDigitalArtworkVoByUnboxing(userDigitalArtworkBoxVo)) {
String artworkId = IDGenerator.nextMilliId2(); // String artworkId = IDGenerator.nextMilliId2();
String artworkId = IDGenerator.nextSnowId();
String orderId = userDigitalArtworkBoxVo.getOrderId(); String orderId = userDigitalArtworkBoxVo.getOrderId();
GoblinNftOrderVo orderVo = goblinRedisUtils.getGoblinNftOrder(orderId); GoblinNftOrderVo orderVo = goblinRedisUtils.getGoblinNftOrder(orderId);
...@@ -206,7 +210,9 @@ public class GoblinUserDigitalArtworkServiceImpl implements IGoblinUserDigitalAr ...@@ -206,7 +210,9 @@ public class GoblinUserDigitalArtworkServiceImpl implements IGoblinUserDigitalAr
// unboxDigitalArtworkListVo.setOpeningTime(now); // unboxDigitalArtworkListVo.setOpeningTime(now);
String skuId = orderVo.getBoxSkuId(), spuId = orderVo.getSpuId(); String skuId = orderVo.getBoxSkuId(), spuId = orderVo.getSpuId();
Integer source = 1; // Integer source = 1;
Integer orderType = orderVo.getOrderType();
Integer source = orderType == 1 ? 1 : (orderType == 2 ? 2 : (orderType == 3 ? 3 : (orderType == 4 ? 31 : 0)));
// if (goblinRedisUtils.hasGenUserDigitalArtwork(uid, skuId, orderId)) {// 已生成 // if (goblinRedisUtils.hasGenUserDigitalArtwork(uid, skuId, orderId)) {// 已生成
// log.warn("#UNBOX_ARTWORK EXIST_ART[uid={},skuId={},orderId={},source={}]", uid, skuId, orderId, source); // log.warn("#UNBOX_ARTWORK EXIST_ART[uid={},skuId={},orderId={},source={}]", uid, skuId, orderId, source);
// return unboxDigitalArtworkListVo; // return unboxDigitalArtworkListVo;
......
...@@ -14,19 +14,16 @@ import com.liquidnet.service.goblin.param.GoblinListCreateItemParam; ...@@ -14,19 +14,16 @@ import com.liquidnet.service.goblin.param.GoblinListCreateItemParam;
import com.liquidnet.service.goblin.param.GoblinListCreateParam; import com.liquidnet.service.goblin.param.GoblinListCreateParam;
import com.liquidnet.service.goblin.param.GoblinListUpdateParam; import com.liquidnet.service.goblin.param.GoblinListUpdateParam;
import com.liquidnet.service.goblin.service.manage.IGoblinListService; import com.liquidnet.service.goblin.service.manage.IGoblinListService;
import com.liquidnet.service.goblin.util.GoblinMongoUtils; import com.liquidnet.service.goblin.util.*;
import com.liquidnet.service.goblin.util.GoblinRedisUtils; import lombok.extern.slf4j.Slf4j;
import com.liquidnet.service.goblin.util.ObjectUtil;
import com.liquidnet.service.goblin.util.QueueUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.text.DateFormat; import java.text.DateFormat;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.HashMap; import java.util.*;
import java.util.LinkedList;
import java.util.List;
import static com.liquidnet.commons.lang.util.DateUtil.DTF_YMD_HMS; import static com.liquidnet.commons.lang.util.DateUtil.DTF_YMD_HMS;
...@@ -39,6 +36,7 @@ import static com.liquidnet.commons.lang.util.DateUtil.DTF_YMD_HMS; ...@@ -39,6 +36,7 @@ import static com.liquidnet.commons.lang.util.DateUtil.DTF_YMD_HMS;
* @since 2022-04-29 * @since 2022-04-29
*/ */
@Service @Service
@Slf4j
public class GoblinListServiceImpl implements IGoblinListService { public class GoblinListServiceImpl implements IGoblinListService {
@Autowired @Autowired
...@@ -47,6 +45,8 @@ public class GoblinListServiceImpl implements IGoblinListService { ...@@ -47,6 +45,8 @@ public class GoblinListServiceImpl implements IGoblinListService {
GoblinMongoUtils mongoUtils; GoblinMongoUtils mongoUtils;
@Autowired @Autowired
QueueUtils queueUtils; QueueUtils queueUtils;
@Autowired
GoblinNftBoxUtils nftBoxUtils;
@Override @Override
public ResponseDto<PageInfo<GoblinListVo>> getList(String name, Integer page) { public ResponseDto<PageInfo<GoblinListVo>> getList(String name, Integer page) {
...@@ -78,7 +78,16 @@ public class GoblinListServiceImpl implements IGoblinListService { ...@@ -78,7 +78,16 @@ public class GoblinListServiceImpl implements IGoblinListService {
for (GoblinListDetailsItemVo item : vo.getItemVo()) { for (GoblinListDetailsItemVo item : vo.getItemVo()) {
GoblinGoodsSkuInfoVo skuVo = redisUtils.getGoodsSkuInfoVo(item.getSkuId()); GoblinGoodsSkuInfoVo skuVo = redisUtils.getGoodsSkuInfoVo(item.getSkuId());
item.setSkuName(skuVo.getName()); item.setSkuName(skuVo.getName());
if (skuVo.getUnbox().equals("1")) {
int stock = 0;
ArrayList<String> skuIdList = redisUtils.getGoblinListRelationBox(skuVo.getSkuId(), vo.getListId());
for (String relationSkuId : skuIdList) {
stock += redisUtils.getSkuStock(listId, relationSkuId);
}
item.setSurplusStock(stock);
} else {
item.setSurplusStock(redisUtils.getSkuStock(listId, skuVo.getSkuId())); item.setSurplusStock(redisUtils.getSkuStock(listId, skuVo.getSkuId()));
}
// if (skuVo.getUnbox().equals("0")) { // if (skuVo.getUnbox().equals("0")) {
// item.setSurplusStock(redisUtils.getSkuStock(null, item.getSkuId())); // item.setSurplusStock(redisUtils.getSkuStock(null, item.getSkuId()));
// item.setStock(skuVo.getSkuStock()); // item.setStock(skuVo.getSkuStock());
...@@ -116,7 +125,7 @@ public class GoblinListServiceImpl implements IGoblinListService { ...@@ -116,7 +125,7 @@ public class GoblinListServiceImpl implements IGoblinListService {
return ResponseDto.failure("只能配置一个sku"); return ResponseDto.failure("只能配置一个sku");
} }
//判断重名 //判断重名
if(mongoUtils.hasGoblinListDetailsVoByName(param.getName())){ if (mongoUtils.hasGoblinListDetailsVoByName(param.getName())) {
return ResponseDto.failure("活动名称重复"); return ResponseDto.failure("活动名称重复");
} }
String skuId = param.getItemParams().get(0).getSkuId(); String skuId = param.getItemParams().get(0).getSkuId();
...@@ -135,7 +144,7 @@ public class GoblinListServiceImpl implements IGoblinListService { ...@@ -135,7 +144,7 @@ public class GoblinListServiceImpl implements IGoblinListService {
collectVos = redisUtils.getGoblinListCollect(skuId); collectVos = redisUtils.getGoblinListCollect(skuId);
boolean isSame = judgeTime(st, et, collectVos); boolean isSame = judgeTime(st, et, collectVos);
if(isSame){ if (isSame) {
return ResponseDto.failure("sku时间不能重合"); return ResponseDto.failure("sku时间不能重合");
} }
for (GoblinListCollectVo collectItem : collectVos) { for (GoblinListCollectVo collectItem : collectVos) {
...@@ -199,6 +208,74 @@ public class GoblinListServiceImpl implements IGoblinListService { ...@@ -199,6 +208,74 @@ public class GoblinListServiceImpl implements IGoblinListService {
itemVo.setSkuStock(item.getSkuStock()); itemVo.setSkuStock(item.getSkuStock());
itemVo.setProductId(item.getProductId()); itemVo.setProductId(item.getProductId());
voItemList.add(itemVo); voItemList.add(itemVo);
if (skuInfoVo.getUnbox().equals("1")) {//盲盒逻辑
//计算盲盒对应sku数量
HashMap<String, BigDecimal> map = CollectionUtil.mapStringBigDecimal();
GoblinGoodsInfoVo spuInfoVo = redisUtils.getGoodsInfoVo(item.getSpuId());
// int countStockNumber = 0;
// int checkNumberSku = 0;
// 是否存在概率为空
boolean isHit = false;
// 概率相加
BigDecimal hitRatioCount = new BigDecimal(0);
for (String itemSkuId : spuInfoVo.getSkuIdList()) {
GoblinGoodsSkuInfoVo skuItemVo = redisUtils.getGoodsSkuInfoVo(itemSkuId);
if (skuItemVo.getUnbox().equals("1")) {
continue;
}
// // 判断开售、停售时间
// LocalDateTime saleStartTime = skuItemVo.getSaleStartTime();
// LocalDateTime saleStopTime = skuItemVo.getSaleStopTime();
// LocalDateTime nowTime = LocalDateTime.now();
// if (nowTime.isBefore(saleStartTime)) {
// continue;
// } else if (null != saleStopTime && nowTime.isAfter(saleStopTime)) {
// continue;
// }
//是否购买
if (!skuItemVo.getSkuCanbuy().equals("1")) {
continue;
}
if (nftBoxUtils.getSkuAllStatusShow(skuItemVo) && nftBoxUtils.getSkuAllStatusStock(skuItemVo) > 0) {
if (skuItemVo.getHitRatio() == null) {
isHit = true;
} else {
hitRatioCount = hitRatioCount.add(skuItemVo.getHitRatio());
}
// countStockNumber += goblinRedisUtils.getSkuStock(goblinGoodsSku.getSkuId());
map.put(skuItemVo.getSkuId(), skuItemVo.getHitRatio());
// checkNumberSku++;
}
}
// if (checkNumberSku <= 0) {
// return ResponseDto.failure("盲盒下没有可生成兑换码的sku!");
// }
//
// if (countStockNumber < stockNumber) {
// ResponseDto.failure("配置库存大于sku总库存!");
// }
if (isHit && hitRatioCount.doubleValue() < 100.00 && map.size() > 0) {
nftBoxUtils.arrangeHitRatioMap(map, hitRatioCount);
}
Map<String, Integer> skuMap = nftBoxUtils.getSkuHitRatio(item.getSkuStock(), map);
for (String key : skuMap.keySet()) {
Integer stockNum = skuMap.get(key);
//库存
int skuStock = redisUtils.decrSkuStock(null, key, stockNum);
log.info("盲盒库存 SKUID = " + key + " 数量 = " + stockNum);
if (skuStock < 0) {
redisUtils.incrSkuStock(null, key, stockNum);
return ResponseDto.failure("库存不足");
} else {
redisUtils.setSkuStock(vo.getListId(), key, stockNum);
redisUtils.addGoblinListRelationBox(itemVo.getSkuId(), vo.getListId(), key);
}
}
} else {//非盲盒逻辑
//库存 //库存
int skuStock = redisUtils.decrSkuStock(null, itemVo.getSkuId(), itemVo.getSkuStock()); int skuStock = redisUtils.decrSkuStock(null, itemVo.getSkuId(), itemVo.getSkuStock());
if (skuStock < 0) { if (skuStock < 0) {
...@@ -207,6 +284,8 @@ public class GoblinListServiceImpl implements IGoblinListService { ...@@ -207,6 +284,8 @@ public class GoblinListServiceImpl implements IGoblinListService {
} else { } else {
redisUtils.setSkuStock(vo.getListId(), itemVo.getSkuId(), itemVo.getSkuStock()); redisUtils.setSkuStock(vo.getListId(), itemVo.getSkuId(), itemVo.getSkuStock());
} }
}
//集合 //集合
GoblinListCollectVo collectVo = GoblinListCollectVo.getNew(); GoblinListCollectVo collectVo = GoblinListCollectVo.getNew();
collectVo.setSpuId(itemVo.getSpuId()); collectVo.setSpuId(itemVo.getSpuId());
...@@ -215,7 +294,7 @@ public class GoblinListServiceImpl implements IGoblinListService { ...@@ -215,7 +294,7 @@ public class GoblinListServiceImpl implements IGoblinListService {
collectVo.setPriceV(itemVo.getPriceV()); collectVo.setPriceV(itemVo.getPriceV());
collectVo.setProductId(itemVo.getProductId()); collectVo.setProductId(itemVo.getProductId());
collectVo.setWhiteType(vo.getWhiteType()); collectVo.setWhiteType(vo.getWhiteType());
if(vo.getWhiteType().equals(1) && vo.getWhiteUrl().equals("")){ if (vo.getWhiteType().equals(1) && vo.getWhiteUrl().equals("")) {
collectVo.setWhiteType(-1); collectVo.setWhiteType(-1);
} }
collectVo.setTimeStart(st); collectVo.setTimeStart(st);
...@@ -277,7 +356,7 @@ public class GoblinListServiceImpl implements IGoblinListService { ...@@ -277,7 +356,7 @@ public class GoblinListServiceImpl implements IGoblinListService {
for (GoblinListCollectVo itemVo : collectVos) { for (GoblinListCollectVo itemVo : collectVos) {
if (itemVo.getListId().equals(param.getListId())) { if (itemVo.getListId().equals(param.getListId())) {
itemVo.setWhiteType(vo.getWhiteType()); itemVo.setWhiteType(vo.getWhiteType());
if(vo.getWhiteType().equals(1) && vo.getWhiteUrl().equals("")){ if (vo.getWhiteType().equals(1) && vo.getWhiteUrl().equals("")) {
itemVo.setWhiteType(-1); itemVo.setWhiteType(-1);
} }
break; break;
...@@ -306,11 +385,23 @@ public class GoblinListServiceImpl implements IGoblinListService { ...@@ -306,11 +385,23 @@ public class GoblinListServiceImpl implements IGoblinListService {
queueUtils.sendMsgByRedisXls(vo.getListId(), "", vo.getBlackUrl(), "4", item.getSkuId()); queueUtils.sendMsgByRedisXls(vo.getListId(), "", vo.getBlackUrl(), "4", item.getSkuId());
} }
//获取skuVo
GoblinGoodsSkuInfoVo skuVo = redisUtils.getGoodsSkuInfoVo(vo.getItemVo().get(0).getSkuId());
if (skuVo.getUnbox().equals("1")) {
ArrayList<String> skuIdList = redisUtils.getGoblinListRelationBox(skuVo.getSkuId(), vo.getListId());
for (String relationSkuId : skuIdList) {
int restStock = redisUtils.getSkuStock(vo.getListId(), relationSkuId);
if (restStock > 0) {
redisUtils.incrSkuStock(null, relationSkuId, restStock);
}
}
} else {
//库存 //库存
int restStock = redisUtils.getSkuStock(vo.getListId(), vo.getItemVo().get(0).getSkuId()); int restStock = redisUtils.getSkuStock(vo.getListId(), vo.getItemVo().get(0).getSkuId());
if (restStock > 0) { if (restStock > 0) {
redisUtils.incrSkuStock(null, vo.getItemVo().get(0).getSkuId(), restStock); redisUtils.incrSkuStock(null, vo.getItemVo().get(0).getSkuId(), restStock);
} }
}
redisUtils.delGoblinListCollect(vo.getItemVo().get(0).getSkuId(), listId); redisUtils.delGoblinListCollect(vo.getItemVo().get(0).getSkuId(), listId);
redisUtils.delGoblinListDetailsVo(listId); redisUtils.delGoblinListDetailsVo(listId);
......
...@@ -105,6 +105,9 @@ public class GoblinStoreMgtGoodsServiceImpl implements IGoblinstoreMgtGoodsServi ...@@ -105,6 +105,9 @@ public class GoblinStoreMgtGoodsServiceImpl implements IGoblinstoreMgtGoodsServi
@Override @Override
public PagedResult<GoblinStoreMgtGoodsSkuListVo> skusList(GoblinStoreMgtGoodsSkuFilterParam mgtGoodsSkuFilterParam) { public PagedResult<GoblinStoreMgtGoodsSkuListVo> skusList(GoblinStoreMgtGoodsSkuFilterParam mgtGoodsSkuFilterParam) {
if(mgtGoodsSkuFilterParam.getType()==null){
mgtGoodsSkuFilterParam.setType(0);
}
PagedResult<GoblinStoreMgtGoodsSkuListVo> voList = goblinMongoUtils.getSkuSearch(mgtGoodsSkuFilterParam); PagedResult<GoblinStoreMgtGoodsSkuListVo> voList = goblinMongoUtils.getSkuSearch(mgtGoodsSkuFilterParam);
return voList; return voList;
} }
......
...@@ -1645,19 +1645,27 @@ public class GoblinMongoUtils { ...@@ -1645,19 +1645,27 @@ public class GoblinMongoUtils {
mgtGoodsSkuListVo.setSurplusStock(redisUtils.getSkuStock(null, vo.getSkuId())); mgtGoodsSkuListVo.setSurplusStock(redisUtils.getSkuStock(null, vo.getSkuId()));
} else { } else {
List<String> skuIdList = redisUtils.getGoodsInfoVo(vo.getSpuId()).getSkuIdList(); List<String> skuIdList = redisUtils.getGoodsInfoVo(vo.getSpuId()).getSkuIdList();
int restStock = 0;
int stock = 0; int stock = 0;
for (String skuIdItem : skuIdList) {// 盲盒计算所有sku库存总数 for (String skuIdItem : skuIdList) {// 盲盒计算所有sku库存总数
if (skuIdItem.equals(vo.getSkuId())) {// 过滤自己 if (skuIdItem.equals(vo.getSkuId())) {// 过滤自己
continue; continue;
} }
GoblinGoodsSkuInfoVo itemVo = redisUtils.getGoodsSkuInfoVo(skuIdItem); GoblinGoodsSkuInfoVo itemVo = redisUtils.getGoodsSkuInfoVo(skuIdItem);
if (filterParam.getType().equals(0)) {
if ("4".equals(filterParam.getShelvesStatus())) { if ("4".equals(filterParam.getShelvesStatus())) {
stock += redisUtils.getSkuAllStatusStockStatus4(itemVo); restStock += redisUtils.getSkuAllStatusStockStatus4(itemVo);
} else { } else {
stock += redisUtils.getSkuAllStatusStock(itemVo, null); restStock += redisUtils.getSkuAllStatusStock(itemVo, null);
} }
} else if (filterParam.getType().equals(1)) {
restStock += redisUtils.getSkuAllStatusStockType1(itemVo);
} }
mgtGoodsSkuListVo.setSurplusStock(stock); stock +=redisUtils.getSkuTotalStockShelvesStatus3(itemVo);
}
mgtGoodsSkuListVo.setSurplusStock(restStock);
mgtGoodsSkuListVo.setSkuStock(stock);
} }
mgtGoodsSkuListVo.setSysTime(sysTime); mgtGoodsSkuListVo.setSysTime(sysTime);
voList.add(mgtGoodsSkuListVo); voList.add(mgtGoodsSkuListVo);
......
package com.liquidnet.service.goblin.util;
import com.liquidnet.commons.lang.util.CollectionUtil;
import com.liquidnet.service.goblin.constant.GoblinRedisConst;
import com.liquidnet.service.goblin.dto.vo.GoblinGoodsSkuInfoVo;
import com.liquidnet.service.goblin.entity.GoblinGoodsSku;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
@Slf4j
@Component
public class GoblinNftBoxUtils {
@Autowired
GoblinRedisUtils redisUtils;
/**
* 获取每个sku的兑换码生成数量
* <p>
* sku兑换码数 = 生码总数 * sku概率/总概率
* 若sku兑换码数 > sku剩余库存
* 用 sku兑换码数 - sku剩余库存 * (其他sku概率/其他总概率)
* <p>
* 例:生成兑换码 120 有sku1,sku2,sku3
* sku1 库存5 概率 10%
* sku2 库存100 概率 20%
* sku3 库存100 概率 30%
* <p>
* sku1兑换码数=120 * (10/60) = 20 >5
* sku2兑换码数=120 * (20/60) = 40 <100
* sku3兑换码数=120 * (30/60) = 60 <100
* <p>
* sku2第二轮兑换码数 = (20-5) * (20/50) = 6 < 60
* sku3第二轮兑换码数 = (20-5) * (30/50) = 9 < 40
* <p>
* 总兑换码 = sku1兑换码数+sku2兑换码数+sku3兑换码数+sku2第二轮兑换码数+sku3第二轮兑换码数
*
* @return
*/
public Map<String, Integer> getSkuHitRatio(Integer exStock, Map<String, BigDecimal> map) {
// 获取sku总概率
BigDecimal hitRatioCount = new BigDecimal(0);
// Map<String, Map<String, Object>> mapMap = new HashMap<>();
// sku --> 概率/库存
Integer countStockNumber = 0;
HashMap<String, Map<String, Object>> mapMap = CollectionUtil.mapHashMap();
for (String key : map.keySet()) {
BigDecimal skuHitRatio = BigDecimal.valueOf(Double.valueOf(map.get(key).toString()));
HashMap<String, Object> objectMap = CollectionUtil.mapStringObject();
if (skuHitRatio == null) {
continue;
}
hitRatioCount = hitRatioCount.add(skuHitRatio);
objectMap.put("hitRatio", skuHitRatio);
objectMap.put("stock", redisUtils.getSkuStock(null,key));
countStockNumber += redisUtils.getSkuStock(null,key);
mapMap.put(key, objectMap);
}
// sku ---> 库存
HashMap<String, Integer> stockMap = CollectionUtil.mapStringInteger();
ArrayList<String> eliminateSkuIdList = CollectionUtil.arrayListString();
getStock(exStock, hitRatioCount, mapMap, stockMap, countStockNumber, eliminateSkuIdList);
return stockMap;
}
/**
* 获取单个sku库存
*
* @param exStock
* @param hitRatioCount
* @param mapMap
* @return
*/
private static void getStock(Integer exStock, BigDecimal hitRatioCount, Map<String, Map<String, Object>> mapMap, Map<String, Integer> stockMap, Integer countStockNumber, ArrayList<String> eliminateSkuIdList) {
if (exStock <= 0 || countStockNumber == 0) {
return;
}
// 单个sku ---> 当前循环权重
HashMap<String, BigDecimal> bigDecimalHashMap = CollectionUtil.mapStringBigDecimal();
int subNumber = 0;
for (String key : mapMap.keySet()) {
Object stock = mapMap.get(key).get("stock");
Object hitRatio = mapMap.get(key).get("hitRatio");
if (Integer.valueOf(stock.toString()) <= 0) {
continue;
}
BigDecimal bigDecimal = BigDecimal.valueOf(exStock).multiply((new BigDecimal(hitRatio.toString()).divide(hitRatioCount, 5, BigDecimal.ROUND_HALF_UP)));
bigDecimalHashMap.put(key, bigDecimal);
// 要减去的库存
int subStock = BigDecimal.valueOf(exStock).multiply((new BigDecimal(hitRatio.toString()).divide(hitRatioCount, 5, BigDecimal.ROUND_HALF_UP))).setScale(0, BigDecimal.ROUND_UP).intValue();
if (subStock > Integer.valueOf(stock.toString())) {
subNumber += Integer.valueOf(stock.toString());
countStockNumber -= Integer.valueOf(stock.toString());
mapMap.get(key).put("stock", 0);
if (stockMap.get(key) == null) {
stockMap.put(key, Integer.valueOf(stock.toString()));
} else {
stockMap.put(key, stockMap.get(key) + Integer.valueOf(stock.toString()));
}
} else {
countStockNumber -= subStock;
mapMap.get(key).put("stock", Integer.valueOf(stock.toString()) - subStock);
subNumber += subStock;
if (stockMap.get(key) == null) {
stockMap.put(key, subStock);
} else {
stockMap.put(key, stockMap.get(key) + subStock);
}
}
}
if (subNumber > exStock) {
int usNumber = subNumber - exStock;
ArrayList<String> skuIdList = CollectionUtil.arrayListString();
for (int k = 0; k < usNumber; k++) {
String subKey = "";
double maxValue = Double.MAX_VALUE;
for (String key : bigDecimalHashMap.keySet()) {
if (skuIdList.contains(key) || stockMap.get(key) == 0) {
continue;
}
Double compare = Double.valueOf(bigDecimalHashMap.get(key).toString());
if (maxValue > compare) {
maxValue = compare;
subKey = key;
}
}
Integer stock = stockMap.get(subKey);
stockMap.put(subKey, stock - 1);
skuIdList.add(subKey);
}
return;
}
exStock -= subNumber;
if (exStock > 0) {
for (String key : mapMap.keySet()) {
Object hitRatio = mapMap.get(key).get("hitRatio");
Object stock = mapMap.get(key).get("stock");
if (Integer.valueOf(stock.toString()) <= 0 && !eliminateSkuIdList.contains(key)) {
eliminateSkuIdList.add(key);
hitRatioCount = hitRatioCount.subtract(new BigDecimal(hitRatio.toString()));
}
}
getStock(exStock, hitRatioCount, mapMap, stockMap, countStockNumber, eliminateSkuIdList);
}
}
// 各种状态下判断藏品是否可以展示
public boolean getSkuAllStatusShow(GoblinGoodsSkuInfoVo info) {
if (
info != null
&& info.getSkuType() == 1
&& info.getStatus().equals("3")
&& info.getShelvesStatus().equals("3")
// && (info.getSkuAppear() == null || info.getSkuAppear().equals("0"))
&& info.getDelFlg().equals("0")
) {
return true;
} else {
return false;
}
}
/**
* 整理map集合中存在空概率的值
*
* @param map,hitRatioCount
*/
public void arrangeHitRatioMap(Map<String, BigDecimal> map, BigDecimal hitRatioCount) {
// 定义最大概率
BigDecimal maxHitRatio = new BigDecimal(100);
// 剩余概率
BigDecimal remainHitRatio = maxHitRatio.subtract(hitRatioCount);
// 获取值为空的数量
int number = 0;
for (String key : map.keySet()) {
if (map.get(key) == null) {
number++;
}
}
// 平均值
BigDecimal averageNumber = remainHitRatio.divide(BigDecimal.valueOf(number), 2, BigDecimal.ROUND_DOWN);
for (String key : map.keySet()) {
if (map.get(key) == null) {
map.put(key, averageNumber);
}
}
}
// 获取盲盒下藏品的库存 各种状态下不能算库存的排除掉
public int getSkuAllStatusStock(GoblinGoodsSkuInfoVo info) {
if (
info != null
// && LocalDateTime.now().isAfter(info.getSaleStartTime())
&& (null == info.getSoldoutStatus() || info.getSoldoutStatus().equals("0"))
&& (null == info.getHitRatio() || info.getHitRatio().compareTo(BigDecimal.ZERO) > 0)
) {// 可以返回库存
return (int)redisUtils.getSkuStock(null,info.getSkuId());
} else {// 不计入库存
return 0;
}
}
}
...@@ -106,8 +106,9 @@ public class GoblinOrderUtils { ...@@ -106,8 +106,9 @@ public class GoblinOrderUtils {
} }
HashMap<String, Object> map = redisUtils.getGoodsSkuInfoVo(LocalDateTime.now(), skuIdItem); HashMap<String, Object> map = redisUtils.getGoodsSkuInfoVo(LocalDateTime.now(), skuIdItem);
GoblinGoodsSkuInfoVo itemVo = (GoblinGoodsSkuInfoVo) map.get("vo"); GoblinGoodsSkuInfoVo itemVo = (GoblinGoodsSkuInfoVo) map.get("vo");
String listId2 = (String) map.get("listId"); // String listId2 = (String) map.get("listId");
surplusStock += redisUtils.getSkuAllStatusStock(itemVo, listId2); // surplusStock += redisUtils.getSkuAllStatusStock(itemVo, listId2);
surplusStock += redisUtils.getSkuAllStatusStock(itemVo, listId);
totalStock += redisUtils.getSkuTotalStock(itemVo); totalStock += redisUtils.getSkuTotalStock(itemVo);
} }
} }
......
...@@ -422,12 +422,21 @@ public class GoblinNftOrderUtils { ...@@ -422,12 +422,21 @@ public class GoblinNftOrderUtils {
public int getSkuAllStatusStock(String listId, GoblinGoodsSkuInfoVo info) { public int getSkuAllStatusStock(String listId, GoblinGoodsSkuInfoVo info) {
if ( if (
info != null info != null
&& LocalDateTime.now().isAfter(info.getSaleStartTime()) // && LocalDateTime.now().isAfter(info.getSaleStartTime())
&& (null == info.getSoldoutStatus() || info.getSoldoutStatus().equals("0")) && (null == info.getSoldoutStatus() || info.getSoldoutStatus().equals("0"))
&& (null == info.getSkuCanbuy() || info.getSkuCanbuy().equals("1")) && (null == info.getSkuCanbuy() || info.getSkuCanbuy().equals("1"))
&& (null == info.getHitRatio() || info.getHitRatio().compareTo(BigDecimal.ZERO) > 0) && (null == info.getHitRatio() || info.getHitRatio().compareTo(BigDecimal.ZERO) > 0)
) {// 可以返回库存 ) {// 可以返回库存
// 外面只有盲盒才能请求进来 里面只有不是分批购才判断盲盒里藏品的开售时间
if (null == listId) {
if (LocalDateTime.now().isAfter(info.getSaleStartTime())) {
return goblinRedisUtils.getSkuStock(listId, info.getSkuId()); return goblinRedisUtils.getSkuStock(listId, info.getSkuId());
} else {
return 0;
}
} else {
return goblinRedisUtils.getSkuStock(listId, info.getSkuId());
}
} else {// 不计入库存 } else {// 不计入库存
return 0; return 0;
} }
......
...@@ -47,7 +47,7 @@ goblin_order.store.refundLog=INSERT INTO goblin_back_order_log (`back_order_log_ ...@@ -47,7 +47,7 @@ goblin_order.store.refundLog=INSERT INTO goblin_back_order_log (`back_order_log_
goblin_order.store.backOrder=INSERT INTO goblin_back_order (`back_order_id`,`back_code`,`order_id`,`order_code`,`store_id`,`user_id`,`sku_id_nums`,`type`,`reason`,`describes`,`real_back_price`,`status`,`created_at`,`audit_at`,`error_reason`) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) goblin_order.store.backOrder=INSERT INTO goblin_back_order (`back_order_id`,`back_code`,`order_id`,`order_code`,`store_id`,`user_id`,`sku_id_nums`,`type`,`reason`,`describes`,`real_back_price`,`status`,`created_at`,`audit_at`,`error_reason`) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
#-------- NFT ------- #-------- NFT -------
goblin_nft_order.insert=INSERT INTO goblin_nft_order (`order_id`,`spu_id`,`sku_id`,`box_sku_id`,`num`,`store_id`,`store_name`,`order_code`,`user_id`,`user_name`,`user_mobile`,`price_total`,`price_coupon`,`store_price_coupon`,`price_red_envelope`,`price_voucher`,`price_actual`,`ucoupon_id`,`store_coupon_id`,`red_envelope_code`,`status`,`source`,`order_type`,`pay_type`,`device_from`,`version`,`pay_countdown_minute`,`ip_address`,`created_at`,`pay_code`,sku_title) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) goblin_nft_order.insert=INSERT INTO goblin_nft_order (`order_id`,`spu_id`,`sku_id`,`box_sku_id`,`num`,`store_id`,`store_name`,`order_code`,`user_id`,`user_name`,`user_mobile`,`price_total`,`price_coupon`,`store_price_coupon`,`price_red_envelope`,`price_voucher`,`price_actual`,`ucoupon_id`,`store_coupon_id`,`red_envelope_code`,`status`,`source`,`order_type`,`pay_type`,`device_from`,`version`,`pay_countdown_minute`,`ip_address`,`created_at`,`pay_code`,sku_title,list_id,ex_code) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
goblin_nft_order.update.pay=UPDATE goblin_nft_order SET payment_type = ?, payment_id=?, pay_code = ?, pay_time = ?, status = ?, updated_at = ? WHERE order_id = ? and (updated_at <= ? or created_at = ? or updated_at is null) goblin_nft_order.update.pay=UPDATE goblin_nft_order SET payment_type = ?, payment_id=?, pay_code = ?, pay_time = ?, status = ?, updated_at = ? WHERE order_id = ? and (updated_at <= ? or created_at = ? or updated_at is null)
goblin_nft_order.update.refund=UPDATE goblin_nft_order SET status = ?, updated_at = ? WHERE order_id = ? and (updated_at <= ? or created_at = ? or updated_at is null) goblin_nft_order.update.refund=UPDATE goblin_nft_order SET status = ?, updated_at = ? WHERE order_id = ? and (updated_at <= ? or created_at = ? or updated_at is null)
goblin_nft_order_refund.insert=INSERT INTO goblin_nft_order_refund (`order_refund_id`,`refund_code`,`order_id`,`order_code`,`store_id`,`user_id`,`price`,`status`,`error_reason`,`created_at`) VALUES (?,?,?,?,?,?,?,?,?,?) goblin_nft_order_refund.insert=INSERT INTO goblin_nft_order_refund (`order_refund_id`,`refund_code`,`order_id`,`order_code`,`store_id`,`user_id`,`price`,`status`,`error_reason`,`created_at`) VALUES (?,?,?,?,?,?,?,?,?,?)
......
package com.liquidnet.service.platform.controller.goblin; package com.liquidnet.service.platform.controller.goblin;
import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.goblin.service.IGoblinExportService; import com.liquidnet.service.goblin.service.IGoblinExportService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
...@@ -11,6 +12,7 @@ import org.springframework.validation.annotation.Validated; ...@@ -11,6 +12,7 @@ import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
...@@ -32,6 +34,7 @@ public class GoblinExportDataController { ...@@ -32,6 +34,7 @@ public class GoblinExportDataController {
*/ */
@GetMapping("/exportMallOrder") @GetMapping("/exportMallOrder")
@ApiOperation(value = "excel订单信息导出") @ApiOperation(value = "excel订单信息导出")
@ResponseBody
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(type = "form", required = true, dataType = "String", name = "beginTime", value = "开始时间"), @ApiImplicitParam(type = "form", required = true, dataType = "String", name = "beginTime", value = "开始时间"),
@ApiImplicitParam(type = "form", required = true, dataType = "String", name = "storeId", value = "店铺id"), @ApiImplicitParam(type = "form", required = true, dataType = "String", name = "storeId", value = "店铺id"),
...@@ -39,9 +42,9 @@ public class GoblinExportDataController { ...@@ -39,9 +42,9 @@ public class GoblinExportDataController {
@ApiImplicitParam(type = "form", required = true, dataType = "String", name = "state", value = "状态逗号隔开字符串[0-待付款(用户刚下单)|2-代发货(用户付完款 等待商城发货)|3-代收货(商城已经发货 等待用户确认收货)|4-已完成(用户已经确认收货 订单结束)|5-取消订单(用户未付款前取消订单)|6-退款通过(用户已经付款但是商城还未发货,用户发出退款申请,商城同意退款)|7-退货通过(用户已经确认收货后用户发出退货申请,商城同意所有退货申请 ,一个订单可能有多个单品)|61-6的发起状态|71-7的发起状态】"), @ApiImplicitParam(type = "form", required = true, dataType = "String", name = "state", value = "状态逗号隔开字符串[0-待付款(用户刚下单)|2-代发货(用户付完款 等待商城发货)|3-代收货(商城已经发货 等待用户确认收货)|4-已完成(用户已经确认收货 订单结束)|5-取消订单(用户未付款前取消订单)|6-退款通过(用户已经付款但是商城还未发货,用户发出退款申请,商城同意退款)|7-退货通过(用户已经确认收货后用户发出退货申请,商城同意所有退货申请 ,一个订单可能有多个单品)|61-6的发起状态|71-7的发起状态】"),
@ApiImplicitParam(type = "form", required = true, dataType = "String", name = "mailType", value = "快递状态[0-全部|1-未发货|2-已发货]"), @ApiImplicitParam(type = "form", required = true, dataType = "String", name = "mailType", value = "快递状态[0-全部|1-未发货|2-已发货]"),
}) })
public void exportMallOrder(HttpServletResponse response, @RequestParam("beginTime") String beginTime, @RequestParam("endTime") String endTime, public ResponseDto<String> exportMallOrder(HttpServletResponse response, @RequestParam("beginTime") String beginTime, @RequestParam("endTime") String endTime,
@RequestParam("state") String state, @RequestParam("mailType") Integer mailType, @RequestParam("storeId") String storeId) { @RequestParam("state") String state, @RequestParam("mailType") Integer mailType, @RequestParam("storeId") String storeId) {
iGoblinExportService.exportMallOrder(response, beginTime, endTime, state, mailType, storeId); return iGoblinExportService.exportMallOrder(response, beginTime, endTime, state, mailType, storeId);
} }
} }
...@@ -4,8 +4,10 @@ package com.liquidnet.service.platform.controller.kylin; ...@@ -4,8 +4,10 @@ package com.liquidnet.service.platform.controller.kylin;
import com.liquidnet.service.base.ResponseDto; import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.kylin.dto.vo.KylinTimePerformanceVo; import com.liquidnet.service.kylin.dto.vo.KylinTimePerformanceVo;
import com.liquidnet.service.kylin.dto.vo.PerformanceOrderStatisticalVo; import com.liquidnet.service.kylin.dto.vo.PerformanceOrderStatisticalVo;
import com.liquidnet.service.kylin.dto.vo.mongo.KylinOrderTicketVo;
import com.liquidnet.service.kylin.service.partner.IKylinPerformancesPartnerService; import com.liquidnet.service.kylin.service.partner.IKylinPerformancesPartnerService;
import com.liquidnet.service.platform.utils.PerformanceVoTask; import com.liquidnet.service.platform.utils.PerformanceVoTask;
import com.mongodb.BasicDBObject;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse; import io.swagger.annotations.ApiResponse;
...@@ -14,6 +16,7 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -14,6 +16,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate; import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria; import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query; import org.springframework.data.mongodb.core.query.Query;
import org.springframework.data.mongodb.core.query.Update;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
...@@ -70,6 +73,11 @@ public class KylinPerformancesController { ...@@ -70,6 +73,11 @@ public class KylinPerformancesController {
performancesPartnerService.outLinePerformance(item.getPerformanceId()); performancesPartnerService.outLinePerformance(item.getPerformanceId());
log.info("[FINISH OUT LINE TASK] performanceId = " + item.getPerformanceId() + " time = " + item.getTime()); log.info("[FINISH OUT LINE TASK] performanceId = " + item.getPerformanceId() + " time = " + item.getTime());
} }
if (item.getTaskType() != 0) {
mongoTemplate.getCollection(KylinTimePerformanceVo.class.getSimpleName()).updateMany(
Query.query(Criteria.where("performanceId").is(item.getPerformanceId())).getQueryObject(),
Update.update("taskType", 0).getUpdateObject());
}
} }
} }
return ResponseDto.success(true); return ResponseDto.success(true);
......
...@@ -31,7 +31,7 @@ public class GoblinExportServiceImpl implements IGoblinExportService { ...@@ -31,7 +31,7 @@ public class GoblinExportServiceImpl implements IGoblinExportService {
GoblinStoreOrderMapper goblinStoreOrderMapper; GoblinStoreOrderMapper goblinStoreOrderMapper;
@Override @Override
public ResponseDto<Boolean> exportMallOrder(HttpServletResponse response, String beginTime, String endTime, String state, Integer mailType, String storeId) { public ResponseDto<String> exportMallOrder(HttpServletResponse response, String beginTime, String endTime, String state, Integer mailType, String storeId) {
if (!timeIsNotNull(beginTime, endTime)) { if (!timeIsNotNull(beginTime, endTime)) {
return ResponseDto.failure("起始和结束时间不能为空!"); return ResponseDto.failure("起始和结束时间不能为空!");
} }
...@@ -145,6 +145,8 @@ public class GoblinExportServiceImpl implements IGoblinExportService { ...@@ -145,6 +145,8 @@ public class GoblinExportServiceImpl implements IGoblinExportService {
.head(head(header)) .head(head(header))
// 当然这里数据也可以用 List<List<String>> 去传入 // 当然这里数据也可以用 List<List<String>> 去传入
.doWrite(objectList); .doWrite(objectList);
}else{
return ResponseDto.failure("无数据");
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
......
...@@ -284,7 +284,7 @@ public class GoblinNftExCodeServiceImpl implements IGoblinNftExCodeService { ...@@ -284,7 +284,7 @@ public class GoblinNftExCodeServiceImpl implements IGoblinNftExCodeService {
// PageHelper.startPage(goblinNftExCodeParam.getPageNum(), 20, true); // PageHelper.startPage(goblinNftExCodeParam.getPageNum(), 20, true);
List<GoblinNftExCode> goblinNftExCodes = goblinNftExCodeMapper.selectGoblinNftCode(goblinNftExCode); List<GoblinNftExCode> goblinNftExCodes = goblinNftExCodeMapper.selectGoblinNftCodeExcel(goblinNftExCode);
StringBuffer skuIds = new StringBuffer(); StringBuffer skuIds = new StringBuffer();
StringBuffer acticityIds = new StringBuffer(); StringBuffer acticityIds = new StringBuffer();
......
...@@ -190,26 +190,30 @@ public class GoblinNftExCodeTaskServiceImpl implements IGoblinNftExCodeTaskServi ...@@ -190,26 +190,30 @@ public class GoblinNftExCodeTaskServiceImpl implements IGoblinNftExCodeTaskServi
Boolean bolTime = false; Boolean bolTime = false;
if (!StringUtil.isEmpty(goblinNftExSkuVo)) { if (!StringUtil.isEmpty(goblinNftExSkuVo)) {
// redis存储 单个sku的开始和结束时间
LocalDateTime rdExStartTime = LocalDateTime.parse(goblinNftExSkuVo.getRdStartTime(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
LocalDateTime rdExStopTime = LocalDateTime.parse(goblinNftExSkuVo.getRdStopTime(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
// 时间比对 // 时间比对
if (exStartTime.isBefore(rdExStartTime)) { if (goblinNftExSkuVo.getExStartTime() != null && exStartTime.isBefore(goblinNftExSkuVo.getExStartTime())) { // 当操作时间小于red存储时间时为true
goblinNftExSku.setExStartTime(exStartTime); goblinNftExSku.setExStartTime(exStartTime);
goblinNftExSku.setRdStartTime(exStartTime.toString()); goblinNftExSku.setRdStartTime(exStartTime.toString());
bolTime = true; bolTime = true;
}else {
goblinNftExSku.setExStartTime(goblinNftExSkuVo.getExStartTime());
goblinNftExSku.setRdStartTime(goblinNftExSkuVo.getExStartTime().toString());
} }
if (exStopTime.isAfter(rdExStopTime)) {
if (goblinNftExSkuVo.getExStopTime() != null && exStopTime.isAfter(goblinNftExSkuVo.getExStopTime())) { // 当操作时间大于red存储时间为true
goblinNftExSku.setExStopTime(exStopTime); goblinNftExSku.setExStopTime(exStopTime);
goblinNftExSku.setRdStopTime(exStopTime.toString()); goblinNftExSku.setRdStopTime(exStopTime.toString());
bolTime = true; bolTime = true;
}else {
goblinNftExSku.setExStopTime(goblinNftExSkuVo.getExStopTime());
goblinNftExSku.setRdStopTime(goblinNftExSkuVo.getExStopTime().toString());
} }
} else { } else {
bolTime = true; bolTime = true;
goblinNftExSku.setExStartTime(exStartTime); goblinNftExSku.setExStartTime(exStartTime);
goblinNftExSku.setExStopTime(exStopTime);
goblinNftExSku.setRdStartTime(exStartTime.toString()); goblinNftExSku.setRdStartTime(exStartTime.toString());
goblinNftExSku.setExStopTime(exStopTime);
goblinNftExSku.setRdStopTime(exStopTime.toString()); goblinNftExSku.setRdStopTime(exStopTime.toString());
} }
...@@ -242,8 +246,6 @@ public class GoblinNftExCodeTaskServiceImpl implements IGoblinNftExCodeTaskServi ...@@ -242,8 +246,6 @@ public class GoblinNftExCodeTaskServiceImpl implements IGoblinNftExCodeTaskServi
LocalDateTime localDateTime2 = LocalDateTime.parse(time2, dtf2); LocalDateTime localDateTime2 = LocalDateTime.parse(time2, dtf2);
System.out.println(localDateTime2.isBefore(LocalDateTime.now()));//你的时间小于当前时间是true System.out.println(localDateTime2.isBefore(LocalDateTime.now()));//你的时间小于当前时间是true
System.out.println(localDateTime2.isAfter(LocalDateTime.now()));//你的时间小于在当前时间是false System.out.println(localDateTime2.isAfter(LocalDateTime.now()));//你的时间小于在当前时间是false
} }
......
...@@ -106,10 +106,18 @@ public class GoblinNftExSkuServiceImpl implements IGoblinNftExSkuService { ...@@ -106,10 +106,18 @@ public class GoblinNftExSkuServiceImpl implements IGoblinNftExSkuService {
List<GoblinGoodsSku> goblinGoodsSkus = goblinGoodsSkuMapper.selectBySpuIds(spuIds.toString()); List<GoblinGoodsSku> goblinGoodsSkus = goblinGoodsSkuMapper.selectBySpuIds(spuIds.toString());
int countStockNumber = 0; int countStockNumber = 0;
int checkNumberSku = 0; int checkNumberSku = 0;
// 是否存在概率为空
boolean isHit = false;
// 概率相加
BigDecimal hitRatioCount = new BigDecimal(0);
for (GoblinGoodsSku goblinGoodsSku : goblinGoodsSkus) { for (GoblinGoodsSku goblinGoodsSku : goblinGoodsSkus) {
if (goblinGoodsSku.getUnbox().equals("1")) { if (goblinGoodsSku.getUnbox().equals("1")) {
continue; continue;
} }
// 判断开售、停售时间 // 判断开售、停售时间
LocalDateTime saleStartTime = goblinGoodsSku.getSaleStartTime(); LocalDateTime saleStartTime = goblinGoodsSku.getSaleStartTime();
LocalDateTime saleStopTime = goblinGoodsSku.getSaleStopTime(); LocalDateTime saleStopTime = goblinGoodsSku.getSaleStopTime();
...@@ -124,8 +132,15 @@ public class GoblinNftExSkuServiceImpl implements IGoblinNftExSkuService { ...@@ -124,8 +132,15 @@ public class GoblinNftExSkuServiceImpl implements IGoblinNftExSkuService {
if (!goblinGoodsSku.getSkuCanbuy().equals("1")) { if (!goblinGoodsSku.getSkuCanbuy().equals("1")) {
continue; continue;
} }
// 不能购买的 没库存的 概率是0的 过滤 // 不能购买的 没库存的 概率是0的 过滤
if (getSkuAllStatusShow(goblinGoodsSku) && goblinRedisUtils.getSkuAllStatusStock(goblinGoodsSku) > 0 && goblinGoodsSku.getHitRatio() != null) { if (getSkuAllStatusShow(goblinGoodsSku) && goblinRedisUtils.getSkuAllStatusStock(goblinGoodsSku) > 0) {
log.debug("skuId:"+goblinGoodsSku.getSkuId()+"----hitRatio:"+goblinGoodsSku.getHitRatio());
if (goblinGoodsSku.getHitRatio() == null) {
isHit = true;
} else {
hitRatioCount = hitRatioCount.add(goblinGoodsSku.getHitRatio());
}
countStockNumber += goblinRedisUtils.getSkuStock(goblinGoodsSku.getSkuId()); countStockNumber += goblinRedisUtils.getSkuStock(goblinGoodsSku.getSkuId());
map.put(goblinGoodsSku.getSkuId(), goblinGoodsSku.getHitRatio()); map.put(goblinGoodsSku.getSkuId(), goblinGoodsSku.getHitRatio());
checkNumberSku++; checkNumberSku++;
...@@ -140,6 +155,12 @@ public class GoblinNftExSkuServiceImpl implements IGoblinNftExSkuService { ...@@ -140,6 +155,12 @@ public class GoblinNftExSkuServiceImpl implements IGoblinNftExSkuService {
ResponseDto.failure("配置库存大于sku总库存!"); ResponseDto.failure("配置库存大于sku总库存!");
} }
if (isHit && hitRatioCount.doubleValue() < 100.00 && map.size() > 0) {
arrangeHitRatioMap(map, hitRatioCount);
}
} }
...@@ -220,6 +241,7 @@ public class GoblinNftExSkuServiceImpl implements IGoblinNftExSkuService { ...@@ -220,6 +241,7 @@ public class GoblinNftExSkuServiceImpl implements IGoblinNftExSkuService {
return ResponseDto.success(true); return ResponseDto.success(true);
} }
/** /**
* 获取每个sku的兑换码生成数量 * 获取每个sku的兑换码生成数量
* <p> * <p>
...@@ -284,50 +306,94 @@ public class GoblinNftExSkuServiceImpl implements IGoblinNftExSkuService { ...@@ -284,50 +306,94 @@ public class GoblinNftExSkuServiceImpl implements IGoblinNftExSkuService {
Map<String, Map<String, Object>> mapMap = new HashMap<>(); Map<String, Map<String, Object>> mapMap = new HashMap<>();
Map<String, Object> objectMap = new HashMap<>(); Map<String, Object> objectMap = new HashMap<>();
objectMap.put("hitRatio", 30); objectMap.put("hitRatio", 3.33);
objectMap.put("stock", 900); objectMap.put("stock", 100);
mapMap.put("1", objectMap); mapMap.put("1", objectMap);
Map<String, Object> objectMap1 = new HashMap<>(); Map<String, Object> objectMap1 = new HashMap<>();
objectMap1.put("hitRatio", 0.3); objectMap1.put("hitRatio", 57.7);
objectMap1.put("stock", 9); objectMap1.put("stock", 20);
mapMap.put("2", objectMap1); mapMap.put("2", objectMap1);
Map<String, Object> objectMap2 = new HashMap<>(); Map<String, Object> objectMap2 = new HashMap<>();
objectMap2.put("hitRatio", 23.3); objectMap2.put("hitRatio", 9);
objectMap2.put("stock", 697); objectMap2.put("stock", 30);
mapMap.put("3", objectMap2); mapMap.put("3", objectMap2);
Map<String, Object> objectMap3 = new HashMap<>(); Map<String, Object> objectMap3 = new HashMap<>();
objectMap3.put("hitRatio", 2.2); objectMap3.put("hitRatio", 1);
objectMap3.put("stock", 66); objectMap3.put("stock", 50);
mapMap.put("4", objectMap3); mapMap.put("4", objectMap3);
Map<String, Object> objectMap4 = new HashMap<>(); /* Map<String, Object> objectMap4 = new HashMap<>();
objectMap4.put("hitRatio", 26.7); objectMap4.put("hitRatio", 26.7);
objectMap4.put("stock", 797); objectMap4.put("stock", 165);
mapMap.put("5", objectMap4); mapMap.put("5", objectMap4);
Map<String, Object> objectMap5 = new HashMap<>(); Map<String, Object> objectMap5 = new HashMap<>();
objectMap5.put("hitRatio", 2.2); objectMap5.put("hitRatio", 2.2);
objectMap5.put("stock", 66); objectMap5.put("stock", 12);
mapMap.put("6", objectMap5); mapMap.put("6", objectMap5);
Map<String, Object> objectMap6 = new HashMap<>(); Map<String, Object> objectMap6 = new HashMap<>();
objectMap6.put("hitRatio", 15.3); objectMap6.put("hitRatio", 15.6);
objectMap6.put("stock", 458); objectMap6.put("stock", 90);
mapMap.put("7", objectMap6); mapMap.put("7", objectMap6);*/
Map<String, Integer> stockMap = new HashMap<>(); Map<String, Integer> stockMap = new HashMap<>();
ArrayList<String> eliminateSkuIdList = CollectionUtil.arrayListString(); ArrayList<String> eliminateSkuIdList = CollectionUtil.arrayListString();
getStock(594, new BigDecimal(100), mapMap, stockMap, 2993, eliminateSkuIdList); getStock(155, new BigDecimal(71.03), mapMap, stockMap, 179, eliminateSkuIdList);
for (String key : stockMap.keySet()) { for (String key : stockMap.keySet()) {
System.out.println("skuId" + key + "***********数量" + stockMap.get(key)); System.out.println("skuId:" + key + "***********数量:" + stockMap.get(key));
} }
System.out.println("kkk"); System.out.println("kkk");
/* Map<String, BigDecimal> hmap = new HashMap<>();
hmap.put("1", new BigDecimal(40));
hmap.put("2", new BigDecimal(49));
hmap.put("3", null);
hmap.put("4", null);
hmap.put("5", null);
arrangeHitRatioMap(hmap, new BigDecimal(89));
for (String key : hmap.keySet()) {
}*/
} }
/**
* 整理map集合中存在空概率的值
*
* @param map,hitRatioCount
*/
private static void arrangeHitRatioMap(Map<String, BigDecimal> map, BigDecimal hitRatioCount) {
// 定义最大概率
BigDecimal maxHitRatio = new BigDecimal(100);
// 剩余概率
BigDecimal remainHitRatio = maxHitRatio.subtract(hitRatioCount);
// 获取值为空的数量
int number = 0;
for (String key : map.keySet()) {
if (map.get(key) == null) {
number++;
}
}
// 平均值
BigDecimal averageNumber = remainHitRatio.divide(BigDecimal.valueOf(number), 2, BigDecimal.ROUND_DOWN);
for (String key : map.keySet()) {
if (map.get(key) == null) {
map.put(key, averageNumber);
}
}
}
/** /**
* 获取单个sku库存 * 获取单个sku库存
* *
...@@ -351,11 +417,11 @@ public class GoblinNftExSkuServiceImpl implements IGoblinNftExSkuService { ...@@ -351,11 +417,11 @@ public class GoblinNftExSkuServiceImpl implements IGoblinNftExSkuService {
continue; continue;
} }
BigDecimal bigDecimal = BigDecimal.valueOf(exStock).multiply((new BigDecimal(hitRatio.toString()).divide(hitRatioCount, 2, BigDecimal.ROUND_HALF_UP))); BigDecimal bigDecimal = BigDecimal.valueOf(exStock).multiply((new BigDecimal(hitRatio.toString()).divide(hitRatioCount, 5, BigDecimal.ROUND_HALF_UP)));
bigDecimalHashMap.put(key, bigDecimal); bigDecimalHashMap.put(key, bigDecimal);
// 要减去的库存 // 要减去的库存
int subStock = BigDecimal.valueOf(exStock).multiply((new BigDecimal(hitRatio.toString()).divide(hitRatioCount, 2, BigDecimal.ROUND_HALF_UP))).setScale(0, BigDecimal.ROUND_UP).intValue(); int subStock = BigDecimal.valueOf(exStock).multiply((new BigDecimal(hitRatio.toString()).divide(hitRatioCount, 5, BigDecimal.ROUND_HALF_UP))).setScale(0, BigDecimal.ROUND_UP).intValue();
if (subStock > Integer.valueOf(stock.toString())) { if (subStock > Integer.valueOf(stock.toString())) {
subNumber += Integer.valueOf(stock.toString()); subNumber += Integer.valueOf(stock.toString());
......
...@@ -257,12 +257,11 @@ public class GoblinRedisUtils { ...@@ -257,12 +257,11 @@ public class GoblinRedisUtils {
*/ */
public GoblinNftExSkuVo getSkuTime(String skuId) { public GoblinNftExSkuVo getSkuTime(String skuId) {
String key = GoblinRedisConst.ACTIVITY_SKU_TIME.concat(skuId); String key = GoblinRedisConst.ACTIVITY_SKU_TIME.concat(skuId);
GoblinNftExSkuVo goblinNftExSkuVo = null; Object val = getRedis().get(key);
if (!StringUtil.isEmpty(getRedis().get(key))){ if (!StringUtil.isEmpty(val)){
ObjectMapper objectMapper = new ObjectMapper(); return (GoblinNftExSkuVo)val;
objectMapper.convertValue (getRedis().get(key), GoblinNftExSkuVo.class);
} }
return goblinNftExSkuVo; return null;
} }
/** /**
......
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