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

Commit 1bbc2fdf authored by Administrator's avatar Administrator 🎨

Merge branch 'pre' into 'master'

Pre

See merge request !247
parents 6716f87c c5e12ba3
...@@ -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());
}*/
}
...@@ -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;
} }
......
...@@ -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;
/** /**
* 应付金额 * 应付金额
*/ */
......
...@@ -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>
...@@ -170,7 +170,7 @@ public abstract class AbstractOrderCloseReceiver implements StreamListener<Strin ...@@ -170,7 +170,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);
...@@ -180,6 +180,14 @@ public abstract class AbstractOrderCloseReceiver implements StreamListener<Strin ...@@ -180,6 +180,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());
} }
// 订单状态 // 订单状态
......
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);
} }
......
package com.liquidnet.service.goblin.controller;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.time.format.DateTimeFormatter;
import java.util.Calendar;
import java.util.Date;
import java.util.SimpleTimeZone;
@Slf4j
//@Api(tags = "正在下单相关")
@RestController
@RequestMapping("/zhengzai/app")
public class testController {
public static void main(String[] args) {
/*SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
DateFormat dateInstance = SimpleDateFormat.getDateInstance();
String format = dateInstance.format("2022-01-01 22:22:22");
Date parse = simpleDateFormat.parse("2022-01-01 22:22:22");
DateTimeFormatter.ofLocalizedTime();
Calendar.getInstance()*/
}
}
class person implements Comparable {
@Override
public int compareTo(Object o) {
return 0;
}
}
class eumue {
private final String name;
private final int num;
private eumue(String name, int num) {
this.name = name;
this.num = num;
}
}
\ No newline at end of file
...@@ -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;
......
...@@ -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);
} }
} }
......
...@@ -810,12 +810,14 @@ public class GoblinRedisUtils { ...@@ -810,12 +810,14 @@ public class GoblinRedisUtils {
public HashMap<String, Object> getGoodsSkuInfoVo(LocalDateTime now, String skuId) { public HashMap<String, Object> getGoodsSkuInfoVo(LocalDateTime now, String skuId) {
GoblinGoodsSkuInfoVo vo = getGoodsSkuInfoVo(skuId); GoblinGoodsSkuInfoVo vo = getGoodsSkuInfoVo(skuId);
HashMap<String, Object> map = CollectionUtil.mapStringObject(); HashMap<String, Object> map = CollectionUtil.mapStringObject();
LocalDateTime nextSaleStartTime = null;
if (null == vo.getSaleStartTime() || now.isAfter(vo.getSaleStartTime())) {//普通商品已开售 if (null == vo.getSaleStartTime() || now.isAfter(vo.getSaleStartTime())) {//普通商品已开售
map.put("vo", vo); map.put("vo", vo);
map.put("tagType", null); map.put("tagType", null);
map.put("listId", null); map.put("listId", null);
map.put("whiteType", null); map.put("whiteType", null);
map.put("baseSaleStartTime", vo.getSaleStartTime()); map.put("baseSaleStartTime", vo.getSaleStartTime());
map.put("nextSaleStartTime", null);
} else {//未开售 } else {//未开售
GoblinListCollectVo collectVo = getCollectByNow(now, skuId); GoblinListCollectVo collectVo = getCollectByNow(now, skuId);
Integer tagType = null; Integer tagType = null;
...@@ -830,19 +832,26 @@ public class GoblinRedisUtils { ...@@ -830,19 +832,26 @@ public class GoblinRedisUtils {
vo.setSaleStopTime(collectVo.getTimeEnd()); vo.setSaleStopTime(collectVo.getTimeEnd());
listId = collectVo.getListId(); listId = collectVo.getListId();
whiteType = collectVo.getWhiteType(); whiteType = collectVo.getWhiteType();
tagType = collectVo.getTagType();
} }
GoblinListCollectVo collectNext = getCollectByNowNext(now, skuId); GoblinListCollectVo collectNext = getCollectByNowNext(now, skuId);
if (collectNext != null) { if (collectNext != null) {
if (tagType == null) {
tagType = collectNext.getTagType(); tagType = collectNext.getTagType();
}
//todo 逻辑修改 开售时间 //todo 逻辑修改 开售时间
if (collectVo == null) {
vo.setSaleStartTime(collectNext.getTimeStart()); vo.setSaleStartTime(collectNext.getTimeStart());
vo.setSaleStopTime(collectNext.getTimeEnd()); vo.setSaleStopTime(collectNext.getTimeEnd());
} }
nextSaleStartTime = collectNext.getTimeStart();
}
map.put("vo", vo); map.put("vo", vo);
map.put("tagType", tagType); map.put("tagType", tagType);
map.put("listId", listId); map.put("listId", listId);
map.put("whiteType", whiteType); map.put("whiteType", whiteType);
map.put("baseSaleStartTime", baseSaleStartTime); map.put("baseSaleStartTime", baseSaleStartTime);
map.put("nextSaleStartTime", nextSaleStartTime);
} }
return map; return map;
} }
...@@ -884,13 +893,13 @@ public class GoblinRedisUtils { ...@@ -884,13 +893,13 @@ public class GoblinRedisUtils {
* @param skuId * @param skuId
* @return * @return
*/ */
public void goblinNftListStock(LocalDateTime now, String skuId,LocalDateTime saleStartTime) { public void goblinNftListStock(LocalDateTime now, String skuId, LocalDateTime saleStartTime) {
GoblinListCollectVo collectVo = null; GoblinListCollectVo collectVo = null;
GoblinListCollectVo collectTemp = null; GoblinListCollectVo collectTemp = null;
List<GoblinListCollectVo> collectVos = getGoblinListCollect(skuId); List<GoblinListCollectVo> collectVos = getGoblinListCollect(skuId);
if(now.isAfter(saleStartTime)){ if (now.isAfter(saleStartTime)) {
lastStockToLastStock(0, collectVos, null, skuId); lastStockToLastStock(0, collectVos, null, skuId);
}else { } else {
for (int i = 0; i < collectVos.size(); i++) { for (int i = 0; i < collectVos.size(); i++) {
GoblinListCollectVo collectVoItem = collectVos.get(i); GoblinListCollectVo collectVoItem = collectVos.get(i);
if (now.isAfter(collectVoItem.getTimeStart()) && collectVoItem.getTimeEnd() == null) { if (now.isAfter(collectVoItem.getTimeStart()) && collectVoItem.getTimeEnd() == null) {
...@@ -949,12 +958,14 @@ public class GoblinRedisUtils { ...@@ -949,12 +958,14 @@ public class GoblinRedisUtils {
collectTemp = null; collectTemp = null;
} }
} }
if (collectVo == null && collectTemp != null) { // if (collectVo == null && collectTemp != null) {
collectVo = collectTemp; // collectVo = collectTemp;
} else if (collectVo == null) { // } else
collectVo = collectNext; // if (collectVo == null) {
} // collectVo = collectNext;
return collectVo; // }
// return collectVo;
return collectNext;
} }
/** /**
...@@ -968,7 +979,21 @@ public class GoblinRedisUtils { ...@@ -968,7 +979,21 @@ public class GoblinRedisUtils {
public void lastStockToLastStock(Integer type, List<GoblinListCollectVo> collectVos, GoblinListCollectVo vo, String skuId) { public void lastStockToLastStock(Integer type, List<GoblinListCollectVo> collectVos, GoblinListCollectVo vo, String skuId) {
if (vo == null && type == 0) {//已开售逻辑 if (vo == null && type == 0) {//已开售逻辑
for (GoblinListCollectVo collectVoItem : collectVos) { for (GoblinListCollectVo collectVoItem : collectVos) {
int lastStock = getSkuStock(collectVoItem.getListId(), skuId); List<String> skuIds = getGoblinListRelationBox(skuId, collectVoItem.getListId());
int lastStock;
if (skuIds.size() > 0) {//盲盒逻辑
for (String skuIdItem : skuIds) {
lastStock = getSkuStock(collectVoItem.getListId(), skuIdItem);
log.debug("all stock = " + lastStock);
int restStock = decrSkuStock(collectVoItem.getListId(), skuIdItem, lastStock);
if (restStock < 0) {
incrSkuStock(collectVoItem.getListId(), skuIdItem, lastStock);
} else {
incrSkuStock(null, skuIdItem, lastStock);
}
}
} else {
lastStock = getSkuStock(collectVoItem.getListId(), skuId);
log.debug("all stock = " + lastStock); log.debug("all stock = " + lastStock);
int restStock = decrSkuStock(collectVoItem.getListId(), skuId, lastStock); int restStock = decrSkuStock(collectVoItem.getListId(), skuId, lastStock);
if (restStock < 0) { if (restStock < 0) {
...@@ -977,10 +1002,9 @@ public class GoblinRedisUtils { ...@@ -977,10 +1002,9 @@ public class GoblinRedisUtils {
incrSkuStock(null, skuId, lastStock); incrSkuStock(null, skuId, lastStock);
} }
} }
}
} else if (vo != null && type == 1) { } else if (vo != null && type == 1) {
LocalDateTime st = vo.getTimeStart(); LocalDateTime st = vo.getTimeStart();
// GoblinListCollectVo collectVo = null;
// GoblinListCollectVo collectTemp = null;
//获取上个分配购的vo //获取上个分配购的vo
List<GoblinListCollectVo> collectVosList = ObjectUtil.getGoblinListCollectVo(); List<GoblinListCollectVo> collectVosList = ObjectUtil.getGoblinListCollectVo();
for (GoblinListCollectVo collectVoItem : collectVos) { for (GoblinListCollectVo collectVoItem : collectVos) {
...@@ -996,24 +1020,23 @@ public class GoblinRedisUtils { ...@@ -996,24 +1020,23 @@ public class GoblinRedisUtils {
break; break;
} }
} }
// if (collectVo == null) {
// collectVo = collectTemp;
// }
// if (collectVo != null) {
// //减少上个时间段sku库存
// int lastStock = getSkuStock(collectVo.getListId(), skuId);
// int restStock = decrSkuStock(collectVo.getListId(), skuId, lastStock);
// if (restStock < 0) {
// //库存超过销售量 操作失败回滚库存
// incrSkuStock(collectVo.getListId(), skuId, lastStock);
// } else {
// //上个时间段的库存增加到当前时间段
// incrSkuStock(vo.getListId(), skuId, lastStock);
// }
// }
for (GoblinListCollectVo itemVo : collectVosList) { for (GoblinListCollectVo itemVo : collectVosList) {
int lastStock;
List<String> skuIds = getGoblinListRelationBox(skuId, itemVo.getListId());
if (skuIds.size() > 0) {//盲盒逻辑
for (String skuIdItem : skuIds) {
lastStock = getSkuStock(itemVo.getListId(), skuIdItem);
log.debug("temp stock = " + lastStock);
int restStock = decrSkuStock(itemVo.getListId(), skuIdItem, lastStock);
if (restStock < 0) {
incrSkuStock(itemVo.getListId(), skuIdItem, lastStock);
} else {
incrSkuStock(vo.getListId(), skuIdItem, lastStock);
}
}
} else {
//减少上个时间段sku库存 //减少上个时间段sku库存
int lastStock = getSkuStock(itemVo.getListId(), skuId); lastStock = getSkuStock(itemVo.getListId(), skuId);
log.debug("temp stock = " + lastStock); log.debug("temp stock = " + lastStock);
int restStock = decrSkuStock(itemVo.getListId(), skuId, lastStock); int restStock = decrSkuStock(itemVo.getListId(), skuId, lastStock);
if (restStock < 0) { if (restStock < 0) {
...@@ -1026,6 +1049,7 @@ public class GoblinRedisUtils { ...@@ -1026,6 +1049,7 @@ public class GoblinRedisUtils {
} }
} }
} }
}
/** /**
* 分批购是否可购买 * 分批购是否可购买
...@@ -1048,7 +1072,7 @@ public class GoblinRedisUtils { ...@@ -1048,7 +1072,7 @@ public class GoblinRedisUtils {
} }
if (whiteType == -1) { if (whiteType == -1) {
return true; return true;
}else if (whiteType == 0) {//会员 } else if (whiteType == 0) {//会员
return memberStage != null; return memberStage != null;
} else {//白名单 } else {//白名单
return wResult; return wResult;
...@@ -2080,12 +2104,51 @@ public class GoblinRedisUtils { ...@@ -2080,12 +2104,51 @@ public class GoblinRedisUtils {
public int getSkuAllStatusStock(GoblinGoodsSkuInfoVo info, String listId) { public int getSkuAllStatusStock(GoblinGoodsSkuInfoVo info, String listId) {
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.getHitRatio() || info.getHitRatio().compareTo(BigDecimal.ZERO) > 0) && (null == info.getHitRatio() || info.getHitRatio().compareTo(BigDecimal.ZERO) > 0)
&& (null == info.getSkuCanbuy() || info.getSkuCanbuy().equals("1")) && (null == info.getSkuCanbuy() || info.getSkuCanbuy().equals("1"))
) {// 可以返回库存 ) {// 可以返回库存
// 外面只有盲盒才能请求进来 里面只有不是分批购才判断盲盒里藏品的开售时间
if (null == listId) {
if (LocalDateTime.now().isAfter(info.getSaleStartTime())) {
return getSkuStock(listId, info.getSkuId()); return getSkuStock(listId, info.getSkuId());
} else {
return 0;
}
} else {
return getSkuStock(listId, info.getSkuId());
}
} else {// 不计入库存
return 0;
}
}
// 各种状态下判断藏品总库存
public Integer getSkuTotalStockShelvesStatus3(GoblinGoodsSkuInfoVo info) {
if (
info != null
&& (null == info.getShelvesStatus() || info.getShelvesStatus().equals("3"))
// && LocalDateTime.now().isAfter(info.getSaleStartTime())
// && (null == info.getSoldoutStatus() || info.getSoldoutStatus().equals("0"))
// && (null == info.getHitRatio() || info.getHitRatio().compareTo(BigDecimal.ZERO) > 0)
) {// 可以返回库存
return info.getSkuStock();
} else {// 不计入库存
return 0;
}
}
// 获取盲盒下藏品的库存 各种状态下不能算库存的排除掉
public int getSkuAllStatusStockType1(GoblinGoodsSkuInfoVo info) {
if (
info != null
&& (null == info.getSoldoutStatus() || info.getSoldoutStatus().equals("0"))
&& (null == info.getHitRatio() || info.getHitRatio().compareTo(BigDecimal.ZERO) > 0)
&& (null == info.getSkuCanbuy() || info.getSkuCanbuy().equals("1")
&& (null == info.getShelvesStatus() || info.getShelvesStatus().equals("3")))
) {// 可以返回库存
return getSkuStock(null, info.getSkuId());
} else {// 不计入库存 } else {// 不计入库存
return 0; return 0;
} }
...@@ -2242,6 +2305,29 @@ public class GoblinRedisUtils { ...@@ -2242,6 +2305,29 @@ public class GoblinRedisUtils {
} }
} }
/**
* 设置 盲盒skuId 关联 的skuId
*/
public void addGoblinListRelationBox(String skuId, String listId, String relationSkuId) {
String rdk = GoblinRedisConst.LIST_RELATION_BOX.concat(skuId).concat(":" + listId);
ArrayList<String> list = getGoblinListRelationBox(skuId, listId);
list.add(relationSkuId);
redisUtil.set(rdk, list);
}
/**
* 获取 盲盒skuId 关联 的skuId
*/
public ArrayList<String> getGoblinListRelationBox(String skuId, String listId) {
String rdk = GoblinRedisConst.LIST_RELATION_BOX.concat(skuId).concat(":" + listId);
Object obj = redisUtil.get(rdk);
if (obj == null) {
return CollectionUtil.arrayListString();
} else {
return (ArrayList<String>) obj;
}
}
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | NFT三要素认证缓存的<ID_TYPE+ID_NO, "ID_NAME,MOBILE"> */ /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | NFT三要素认证缓存的<ID_TYPE+ID_NO, "ID_NAME,MOBILE"> */
public boolean setCertmetaJunk(int idType, String idNo, String idName, String mobile) { public boolean setCertmetaJunk(int idType, String idNo, String idName, String mobile) {
......
...@@ -3,7 +3,6 @@ package com.liquidnet.service.order.service.impl; ...@@ -3,7 +3,6 @@ package com.liquidnet.service.order.service.impl;
import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.databind.node.ObjectNode;
import com.liquidnet.commons.lang.util.*; import com.liquidnet.commons.lang.util.*;
import com.liquidnet.service.base.ErrorMapping;
import com.liquidnet.service.base.ResponseDto; import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.base.SqlMapping; import com.liquidnet.service.base.SqlMapping;
import com.liquidnet.service.base.UserPathDto; import com.liquidnet.service.base.UserPathDto;
...@@ -26,13 +25,14 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -26,13 +25,14 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.LinkedMultiValueMap; import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode; import java.math.RoundingMode;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.*; import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static com.liquidnet.commons.lang.util.DateUtil.DTF_YMD_HMS; import static com.liquidnet.commons.lang.util.DateUtil.DTF_YMD_HMS;
...@@ -82,7 +82,6 @@ public class GoblinNftOrderServiceImpl implements IGoblinNftOrderService { ...@@ -82,7 +82,6 @@ public class GoblinNftOrderServiceImpl implements IGoblinNftOrderService {
LocalDateTime nowTime = LocalDateTime.now(); LocalDateTime nowTime = LocalDateTime.now();
HashMap<String, Object> map = goblinRedisUtils.getGoodsSkuInfoVo(nowTime, skuId); HashMap<String, Object> map = goblinRedisUtils.getGoodsSkuInfoVo(nowTime, skuId);
GoblinGoodsSkuInfoVo skuVo = (GoblinGoodsSkuInfoVo) map.get("vo"); GoblinGoodsSkuInfoVo skuVo = (GoblinGoodsSkuInfoVo) map.get("vo");
Object tagType = map.get("tagType");
String listId = (String) map.get("listId"); String listId = (String) map.get("listId");
Integer whiteType = (Integer) map.get("whiteType"); Integer whiteType = (Integer) map.get("whiteType");
...@@ -159,15 +158,16 @@ public class GoblinNftOrderServiceImpl implements IGoblinNftOrderService { ...@@ -159,15 +158,16 @@ public class GoblinNftOrderServiceImpl implements IGoblinNftOrderService {
if (CollectionUtil.isEmpty(skuIdList)) { if (CollectionUtil.isEmpty(skuIdList)) {
return ResponseDto.failure("该商品SPU不存在~"); return ResponseDto.failure("该商品SPU不存在~");
} else { } else {
HashMap<String, Object> lotteryDrawMap = lotteryDraw(skuIdList, number, nowTime); // HashMap<String, Object> lotteryDrawMap = lotteryDraw(skuIdList, number, nowTime);
if (null == lotteryDrawMap) { GoblinGoodsSkuInfoVo skuInfoVo = lotteryDraw(skuIdList, number, nowTime, listId);
if (null == skuInfoVo) {
goblinRedisUtils.decrSkuCountByUid(uid, skuId, number); goblinRedisUtils.decrSkuCountByUid(uid, skuId, number);
return ResponseDto.failure("盲盒库存不足啦~"); return ResponseDto.failure("盲盒库存不足啦~");
} }
GoblinGoodsSkuInfoVo skuInfoVo = (GoblinGoodsSkuInfoVo) lotteryDrawMap.get("goodsSkuInfoVo"); // GoblinGoodsSkuInfoVo skuInfoVo = (GoblinGoodsSkuInfoVo) lotteryDrawMap.get("goodsSkuInfoVo");
boxSkuId = skuInfoVo.getSkuId(); boxSkuId = skuInfoVo.getSkuId();
stockSkuId = boxSkuId; stockSkuId = boxSkuId;
listId = (String) lotteryDrawMap.get("listId"); // listId = (String) lotteryDrawMap.get("listId");
} }
} else {// 普通藏品逻辑 } else {// 普通藏品逻辑
// 判断库存 // 判断库存
...@@ -215,14 +215,14 @@ public class GoblinNftOrderServiceImpl implements IGoblinNftOrderService { ...@@ -215,14 +215,14 @@ public class GoblinNftOrderServiceImpl implements IGoblinNftOrderService {
// 下单数据 // 下单数据
int orderType1 = GoblinStatusConst.NftStatus.ORDER_TYPE_1.getValue(); int orderType1 = GoblinStatusConst.NftStatus.ORDER_TYPE_1.getValue();
GoblinNftOrder nftOrder = order(payParam, skuVo.getStoreId(), uid, spuId, number, orderId, orderCode, totalPrice, voucherPrice, storeVoucherPrice, boxSkuId, skuVo.getName() + " " + skuVo.getSubtitle(), orderType1); GoblinNftOrder nftOrder = order(payParam, skuVo.getStoreId(), uid, spuId, number, orderId, orderCode, totalPrice, voucherPrice, storeVoucherPrice, boxSkuId, skuVo.getName() + " " + skuVo.getSubtitle(), orderType1, listId, "");
if (null == nftOrder) { if (null == nftOrder) {
nftOrderUtils.backSkuCountAndStock(listId, uid, stockSkuId, skuId, number); nftOrderUtils.backSkuCountAndStock(listId, uid, stockSkuId, skuId, number);
return ResponseDto.failure("下单失败~"); return ResponseDto.failure("下单失败~");
} }
// 下单唤起支付 // 下单唤起支付
GoblinNftPayResultVo nftPayResultVo = payOrder(nftOrder, uid, payParam, skuVo.getProductId()); GoblinNftPayResultVo nftPayResultVo = payOrder(nftOrder, payParam, skuVo.getProductId());
if (null == nftPayResultVo) { if (null == nftPayResultVo) {
nftOrderUtils.backSkuCountAndStock(listId, uid, stockSkuId, skuId, number); nftOrderUtils.backSkuCountAndStock(listId, uid, stockSkuId, skuId, number);
return ResponseDto.failure("下单失败啦~"); return ResponseDto.failure("下单失败啦~");
...@@ -238,14 +238,15 @@ public class GoblinNftOrderServiceImpl implements IGoblinNftOrderService { ...@@ -238,14 +238,15 @@ public class GoblinNftOrderServiceImpl implements IGoblinNftOrderService {
} }
} }
private HashMap<String, Object> lotteryDraw(List<String> skuIdList, int number, LocalDateTime nowTime) { private GoblinGoodsSkuInfoVo lotteryDraw(List<String> skuIdList, int number, LocalDateTime nowTime, String listId) {
// private HashMap<String, Object> lotteryDraw(List<String> skuIdList, int number, LocalDateTime nowTime) {
try { try {
ArrayList<GoblinGoodsSkuInfoVo> skuInfoVos = ObjectUtil.cloneArrayGoblinGoodsSkuInfoListVo(); ArrayList<GoblinGoodsSkuInfoVo> skuInfoVos = ObjectUtil.cloneArrayGoblinGoodsSkuInfoListVo();
ArrayList<String> listIds = ObjectUtil.cloneArrayListString(); // ArrayList<String> listIds = ObjectUtil.cloneArrayListString();
for (String kid : skuIdList) { for (String kid : skuIdList) {
HashMap<String, Object> map = goblinRedisUtils.getGoodsSkuInfoVo(nowTime, kid); HashMap<String, Object> map = goblinRedisUtils.getGoodsSkuInfoVo(nowTime, kid);
GoblinGoodsSkuInfoVo skuInfoVo = (GoblinGoodsSkuInfoVo) map.get("vo"); GoblinGoodsSkuInfoVo skuInfoVo = (GoblinGoodsSkuInfoVo) map.get("vo");
String listId = (String) map.get("listId"); // String listId = (String) map.get("listId");
// 是盲盒的扔掉 // 是盲盒的扔掉
if (skuInfoVo.getUnbox().equals("1")) { if (skuInfoVo.getUnbox().equals("1")) {
continue; continue;
...@@ -253,7 +254,7 @@ public class GoblinNftOrderServiceImpl implements IGoblinNftOrderService { ...@@ -253,7 +254,7 @@ public class GoblinNftOrderServiceImpl implements IGoblinNftOrderService {
// 不能购买的 没库存的 概率是0的 过滤 // 不能购买的 没库存的 概率是0的 过滤
if (nftOrderUtils.getSkuAllStatusShow(skuInfoVo) && nftOrderUtils.getSkuAllStatusStock(listId, skuInfoVo) > 0) { if (nftOrderUtils.getSkuAllStatusShow(skuInfoVo) && nftOrderUtils.getSkuAllStatusStock(listId, skuInfoVo) > 0) {
skuInfoVos.add(skuInfoVo); skuInfoVos.add(skuInfoVo);
listIds.add(listId); // listIds.add(listId);
} }
} }
if (CollectionUtil.isEmpty(skuInfoVos)) { if (CollectionUtil.isEmpty(skuInfoVos)) {
...@@ -281,7 +282,7 @@ public class GoblinNftOrderServiceImpl implements IGoblinNftOrderService { ...@@ -281,7 +282,7 @@ public class GoblinNftOrderServiceImpl implements IGoblinNftOrderService {
// 未设置概率的写入概率 // 未设置概率的写入概率
ArrayList<GoblinGoodsSkuInfoVo> newSkuInfoVos = ObjectUtil.cloneArrayGoblinGoodsSkuInfoListVo(); ArrayList<GoblinGoodsSkuInfoVo> newSkuInfoVos = ObjectUtil.cloneArrayGoblinGoodsSkuInfoListVo();
ArrayList<String> newListIds = ObjectUtil.cloneArrayListString(); // ArrayList<String> newListIds = ObjectUtil.cloneArrayListString();
int skuListSize = skuInfoVos.size(); int skuListSize = skuInfoVos.size();
for (int i = 0; i < skuListSize; i++) { for (int i = 0; i < skuListSize; i++) {
GoblinGoodsSkuInfoVo infoVo = skuInfoVos.get(i); GoblinGoodsSkuInfoVo infoVo = skuInfoVos.get(i);
...@@ -302,7 +303,7 @@ public class GoblinNftOrderServiceImpl implements IGoblinNftOrderService { ...@@ -302,7 +303,7 @@ public class GoblinNftOrderServiceImpl implements IGoblinNftOrderService {
infoVo.setHitRatio(skuInfoVos.get(i - 1).getHitRatio().add(infoVo.getHitRatio())); infoVo.setHitRatio(skuInfoVos.get(i - 1).getHitRatio().add(infoVo.getHitRatio()));
} }
newSkuInfoVos.add(infoVo); newSkuInfoVos.add(infoVo);
newListIds.add(listIds.get(i)); // newListIds.add(listIds.get(i));
} }
...@@ -324,17 +325,18 @@ public class GoblinNftOrderServiceImpl implements IGoblinNftOrderService { ...@@ -324,17 +325,18 @@ public class GoblinNftOrderServiceImpl implements IGoblinNftOrderService {
int index = hitRatioList.indexOf(nextDoubleNew); int index = hitRatioList.indexOf(nextDoubleNew);
GoblinGoodsSkuInfoVo goodsSkuInfoVo = newSkuInfoVos.get(index); GoblinGoodsSkuInfoVo goodsSkuInfoVo = newSkuInfoVos.get(index);
String endListId = newListIds.get(index); // String endListId = newListIds.get(index);
// 判断库存 // 判断库存
int surplusGeneral = goblinRedisUtils.decrSkuStock(endListId, goodsSkuInfoVo.getSkuId(), number); int surplusGeneral = goblinRedisUtils.decrSkuStock(listId, goodsSkuInfoVo.getSkuId(), number);
if (surplusGeneral < 0) { if (surplusGeneral < 0) {
goblinRedisUtils.incrSkuStock(endListId, goodsSkuInfoVo.getSkuId(), number); goblinRedisUtils.incrSkuStock(listId, goodsSkuInfoVo.getSkuId(), number);
return lotteryDraw(skuIdList, number, nowTime); return lotteryDraw(skuIdList, number, nowTime, listId);
} else { } else {
HashMap<String, Object> map = CollectionUtil.mapStringObject(); // HashMap<String, Object> map = CollectionUtil.mapStringObject();
map.put("goodsSkuInfoVo", goodsSkuInfoVo); // map.put("goodsSkuInfoVo", goodsSkuInfoVo);
map.put("listId", endListId); // map.put("listId", endListId);
return map; // return map;
return goodsSkuInfoVo;
} }
} }
} catch (Exception e) { } catch (Exception e) {
...@@ -347,7 +349,7 @@ public class GoblinNftOrderServiceImpl implements IGoblinNftOrderService { ...@@ -347,7 +349,7 @@ public class GoblinNftOrderServiceImpl implements IGoblinNftOrderService {
GoblinNftOrderPayParam payParam, String storeId, String uid, String spuId, int number, GoblinNftOrderPayParam payParam, String storeId, String uid, String spuId, int number,
String orderId, String orderCode, String orderId, String orderCode,
BigDecimal totalPrice, BigDecimal voucherPrice, BigDecimal storeVoucherPrice, String boxSkuId, String skuTitle BigDecimal totalPrice, BigDecimal voucherPrice, BigDecimal storeVoucherPrice, String boxSkuId, String skuTitle
, int orderType , int orderType, String listId, String exCode
) { ) {
try { try {
LocalDateTime now = LocalDateTime.now(); LocalDateTime now = LocalDateTime.now();
...@@ -360,6 +362,8 @@ public class GoblinNftOrderServiceImpl implements IGoblinNftOrderService { ...@@ -360,6 +362,8 @@ public class GoblinNftOrderServiceImpl implements IGoblinNftOrderService {
GoblinStoreInfoVo storeInfoVo = goblinRedisUtils.getStoreInfoVo(storeId); GoblinStoreInfoVo storeInfoVo = goblinRedisUtils.getStoreInfoVo(storeId);
String storeName = storeInfoVo.getStoreName(); String storeName = storeInfoVo.getStoreName();
listId = (null == listId) ? "" : listId;
// 生成订单 // 生成订单
GoblinNftOrder nftOrder = GoblinNftOrder.getNew(); GoblinNftOrder nftOrder = GoblinNftOrder.getNew();
nftOrder.setOrderId(orderId); nftOrder.setOrderId(orderId);
...@@ -379,6 +383,8 @@ public class GoblinNftOrderServiceImpl implements IGoblinNftOrderService { ...@@ -379,6 +383,8 @@ public class GoblinNftOrderServiceImpl implements IGoblinNftOrderService {
nftOrder.setUserName(StringUtils.defaultString(((String) token.get(CurrentUtil.TOKEN_NICKNAME)), "")); nftOrder.setUserName(StringUtils.defaultString(((String) token.get(CurrentUtil.TOKEN_NICKNAME)), ""));
nftOrder.setUserMobile(StringUtils.defaultString(((String) token.get(CurrentUtil.TOKEN_MOBILE)), "")); nftOrder.setUserMobile(StringUtils.defaultString(((String) token.get(CurrentUtil.TOKEN_MOBILE)), ""));
} }
nftOrder.setListId(listId);
nftOrder.setExCode(exCode);
nftOrder.setPriceTotal(totalPrice); nftOrder.setPriceTotal(totalPrice);
nftOrder.setPriceCoupon(voucherPrice); nftOrder.setPriceCoupon(voucherPrice);
nftOrder.setStorePriceCoupon(storeVoucherPrice); nftOrder.setStorePriceCoupon(storeVoucherPrice);
...@@ -408,7 +414,7 @@ public class GoblinNftOrderServiceImpl implements IGoblinNftOrderService { ...@@ -408,7 +414,7 @@ public class GoblinNftOrderServiceImpl implements IGoblinNftOrderService {
} }
} }
private GoblinNftPayResultVo payOrder(GoblinNftOrder nftOrder, String uid, GoblinNftOrderPayParam payParam, String productId) { private GoblinNftPayResultVo payOrder(GoblinNftOrder nftOrder, GoblinNftOrderPayParam payParam, String productId) {
try { try {
// 是否免费 // 是否免费
boolean isFree = false; boolean isFree = false;
...@@ -488,7 +494,7 @@ public class GoblinNftOrderServiceImpl implements IGoblinNftOrderService { ...@@ -488,7 +494,7 @@ public class GoblinNftOrderServiceImpl implements IGoblinNftOrderService {
nftOrder.getNum(), nftOrder.getStoreId(), nftOrder.getStoreName(), nftOrder.getOrderCode(), nftOrder.getUserId(), nftOrder.getUserName(), nftOrder.getUserMobile(), nftOrder.getPriceTotal(), nftOrder.getPriceCoupon(), nftOrder.getNum(), nftOrder.getStoreId(), nftOrder.getStoreName(), nftOrder.getOrderCode(), nftOrder.getUserId(), nftOrder.getUserName(), nftOrder.getUserMobile(), nftOrder.getPriceTotal(), nftOrder.getPriceCoupon(),
nftOrder.getStorePriceCoupon(), nftOrder.getPriceRedEnvelope(), nftOrder.getPriceVoucher(), nftOrder.getPriceActual(), nftOrder.getUcouponId(), nftOrder.getStoreCouponId(), nftOrder.getRedEnvelopeCode(), nftOrder.getStatus(), nftOrder.getSource(), nftOrder.getStorePriceCoupon(), nftOrder.getPriceRedEnvelope(), nftOrder.getPriceVoucher(), nftOrder.getPriceActual(), nftOrder.getUcouponId(), nftOrder.getStoreCouponId(), nftOrder.getRedEnvelopeCode(), nftOrder.getStatus(), nftOrder.getSource(),
nftOrder.getOrderType(), nftOrder.getPayType(), nftOrder.getDeviceFrom(), nftOrder.getVersion(), nftOrder.getPayCountdownMinute(), nftOrder.getIpAddress(), nftOrder.getCreatedAt(), nftOrder.getPayCode(), nftOrder.getOrderType(), nftOrder.getPayType(), nftOrder.getDeviceFrom(), nftOrder.getVersion(), nftOrder.getPayCountdownMinute(), nftOrder.getIpAddress(), nftOrder.getCreatedAt(), nftOrder.getPayCode(),
nftOrder.getSkuTitle() nftOrder.getSkuTitle(), nftOrder.getListId(), nftOrder.getExCode()
}); });
// 订单vo // 订单vo
...@@ -810,6 +816,11 @@ public class GoblinNftOrderServiceImpl implements IGoblinNftOrderService { ...@@ -810,6 +816,11 @@ public class GoblinNftOrderServiceImpl implements IGoblinNftOrderService {
if (null == uid) { if (null == uid) {
uid = CurrentUtil.getCurrentUid(); uid = CurrentUtil.getCurrentUid();
} }
// 去除字符串中的空格、回车、换行符、制表符
Pattern pattern = Pattern.compile("\\s*|\t|\r|\n");
Matcher matcher = pattern.matcher(code);
code = matcher.replaceAll("");
boolean isLock = nftOrderUtils.setNftOrderExLock(code); boolean isLock = nftOrderUtils.setNftOrderExLock(code);
if (!isLock) { if (!isLock) {
return ResponseDto.failure("处理未完成,请稍等~"); return ResponseDto.failure("处理未完成,请稍等~");
...@@ -853,7 +864,7 @@ public class GoblinNftOrderServiceImpl implements IGoblinNftOrderService { ...@@ -853,7 +864,7 @@ public class GoblinNftOrderServiceImpl implements IGoblinNftOrderService {
BigDecimal totalPrice = BigDecimal.ZERO; BigDecimal totalPrice = BigDecimal.ZERO;
String boxSkuId = goblinNftExCodeVo.getBoxSkuId(); String boxSkuId = goblinNftExCodeVo.getBoxSkuId();
GoblinGoodsSkuInfoVo skuVo = goblinRedisUtils.getGoodsSkuInfoVo(goblinNftExCodeVo.getSkuId()); GoblinGoodsSkuInfoVo skuVo = goblinRedisUtils.getGoodsSkuInfoVo(goblinNftExCodeVo.getSkuId());
GoblinNftOrder nftOrder = order(payParam, goblinNftExCodeVo.getStoreId(), uid, goblinNftExCodeVo.getSpuId(), 1, orderId, orderCode, totalPrice, totalPrice, totalPrice, null == boxSkuId ? "" : boxSkuId, skuVo.getName() + " " + skuVo.getSubtitle(), orderType); GoblinNftOrder nftOrder = order(payParam, goblinNftExCodeVo.getStoreId(), uid, goblinNftExCodeVo.getSpuId(), 1, orderId, orderCode, totalPrice, totalPrice, totalPrice, null == boxSkuId ? "" : boxSkuId, skuVo.getName() + " " + skuVo.getSubtitle(), orderType, "", code);
if (null == nftOrder) { if (null == nftOrder) {
return ResponseDto.failure("兑换失败~"); return ResponseDto.failure("兑换失败~");
} }
...@@ -878,7 +889,7 @@ public class GoblinNftOrderServiceImpl implements IGoblinNftOrderService { ...@@ -878,7 +889,7 @@ public class GoblinNftOrderServiceImpl implements IGoblinNftOrderService {
nftOrder.getNum(), nftOrder.getStoreId(), nftOrder.getStoreName(), nftOrder.getOrderCode(), nftOrder.getUserId(), nftOrder.getUserName(), nftOrder.getUserMobile(), nftOrder.getPriceTotal(), nftOrder.getPriceCoupon(), nftOrder.getNum(), nftOrder.getStoreId(), nftOrder.getStoreName(), nftOrder.getOrderCode(), nftOrder.getUserId(), nftOrder.getUserName(), nftOrder.getUserMobile(), nftOrder.getPriceTotal(), nftOrder.getPriceCoupon(),
nftOrder.getStorePriceCoupon(), nftOrder.getPriceRedEnvelope(), nftOrder.getPriceVoucher(), nftOrder.getPriceActual(), nftOrder.getUcouponId(), nftOrder.getStoreCouponId(), nftOrder.getRedEnvelopeCode(), orderVo.getStatus(), nftOrder.getSource(), nftOrder.getStorePriceCoupon(), nftOrder.getPriceRedEnvelope(), nftOrder.getPriceVoucher(), nftOrder.getPriceActual(), nftOrder.getUcouponId(), nftOrder.getStoreCouponId(), nftOrder.getRedEnvelopeCode(), orderVo.getStatus(), nftOrder.getSource(),
nftOrder.getOrderType(), orderVo.getPayType(), nftOrder.getDeviceFrom(), nftOrder.getVersion(), nftOrder.getPayCountdownMinute(), nftOrder.getIpAddress(), nftOrder.getCreatedAt(), orderVo.getPayCode(), nftOrder.getOrderType(), orderVo.getPayType(), nftOrder.getDeviceFrom(), nftOrder.getVersion(), nftOrder.getPayCountdownMinute(), nftOrder.getIpAddress(), nftOrder.getCreatedAt(), orderVo.getPayCode(),
nftOrder.getSkuTitle() nftOrder.getSkuTitle(), nftOrder.getListId(), nftOrder.getExCode()
}); });
String sqlData = SqlMapping.gets(sqls, sqlDataCode, sqlDataOrder); String sqlData = SqlMapping.gets(sqls, sqlDataCode, sqlDataOrder);
queueUtils.sendMsgByRedis(MQConst.GoblinQueue.GOBLIN_NFT_ORDER.getKey(), sqlData); queueUtils.sendMsgByRedis(MQConst.GoblinQueue.GOBLIN_NFT_ORDER.getKey(), sqlData);
......
...@@ -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);
} }
} }
...@@ -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();
......
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