Commit f6560013 authored by shiyu's avatar shiyu

盲盒专区

parent 05cfcdff
...@@ -46,6 +46,7 @@ public class SysItemSkuServiceImpl implements SysItemSkuService { ...@@ -46,6 +46,7 @@ public class SysItemSkuServiceImpl implements SysItemSkuService {
ItemSku itemSku = new ItemSku(); ItemSku itemSku = new ItemSku();
EntityMapper.copyAttribute(dto, itemSku); EntityMapper.copyAttribute(dto, itemSku);
itemSku.setSkuCode(UUID.fastUUID().toString(true)); itemSku.setSkuCode(UUID.fastUUID().toString(true));
itemSku.setSort(dto.getSort() == null ? 1 : dto.getSort());
itemSku.setPrice(PriceUtil.convertPriceFromStr(StringUtils.isEmpty(dto.getPrice())?"0":dto.getPrice())); itemSku.setPrice(PriceUtil.convertPriceFromStr(StringUtils.isEmpty(dto.getPrice())?"0":dto.getPrice()));
itemSku.setImages(dto.getImages()); itemSku.setImages(dto.getImages());
if (StringUtils.hasLength(dto.getVideos())) { if (StringUtils.hasLength(dto.getVideos())) {
......
...@@ -53,6 +53,22 @@ public class StringUtil { ...@@ -53,6 +53,22 @@ public class StringUtil {
} }
public static String anonymizeUsername(String username) {
if (username == null || username.isEmpty()) {
return "****";
}
String lastChar = username.substring(username.length() - 1);
StringBuilder anonymized = new StringBuilder();
for (int i = 0; i < username.length() - 1; i++) {
anonymized.append('*');
}
anonymized.append(lastChar);
return anonymized.toString();
}
/** /**
* 创建sku编码 * 创建sku编码
* 商品id * 商品id
......
...@@ -67,6 +67,14 @@ public interface DistributionOrderDao { ...@@ -67,6 +67,14 @@ public interface DistributionOrderDao {
*/ */
DistributionOrder findLastedByBuyerId(long buyerId); DistributionOrder findLastedByBuyerId(long buyerId);
/**
* 根据商品id查询购买记录
* @param itemId
* @return
*/
List<DistributionOrder> findBuyRecordByItemId(long itemId);
/** /**
* 根据买家id查询对于这个商品的历史有效购买记录,排除已取消的订单 * 根据买家id查询对于这个商品的历史有效购买记录,排除已取消的订单
* @param buyerId * @param buyerId
......
package com.wwdz.ch.db.domain.distribution; package com.wwdz.ch.db.domain.distribution;
import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Date; import java.util.Date;
import com.xxdxxs.entity.Entity; import com.xxdxxs.entity.Entity;
import lombok.Data; import lombok.Data;
...@@ -56,6 +54,11 @@ public class ItemSku implements Entity { ...@@ -56,6 +54,11 @@ public class ItemSku implements Entity {
*/ */
private Date updateTime; private Date updateTime;
/**
* 排序字段
*/
private Integer sort;
/** /**
* 图片 * 图片
*/ */
...@@ -88,6 +91,7 @@ public class ItemSku implements Entity { ...@@ -88,6 +91,7 @@ public class ItemSku implements Entity {
sb.append(", isDeleted=").append(isDeleted); sb.append(", isDeleted=").append(isDeleted);
sb.append(", createTime=").append(createTime); sb.append(", createTime=").append(createTime);
sb.append(", updateTime=").append(updateTime); sb.append(", updateTime=").append(updateTime);
sb.append(", sort=").append(sort);
sb.append(", images=").append(images); sb.append(", images=").append(images);
sb.append(", videos=").append(videos); sb.append(", videos=").append(videos);
sb.append(", description=").append(description); sb.append(", description=").append(description);
...@@ -117,6 +121,7 @@ public class ItemSku implements Entity { ...@@ -117,6 +121,7 @@ public class ItemSku implements Entity {
&& (this.getIsDeleted() == null ? other.getIsDeleted() == null : this.getIsDeleted().equals(other.getIsDeleted())) && (this.getIsDeleted() == null ? other.getIsDeleted() == null : this.getIsDeleted().equals(other.getIsDeleted()))
&& (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime())) && (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime()))
&& (this.getUpdateTime() == null ? other.getUpdateTime() == null : this.getUpdateTime().equals(other.getUpdateTime())) && (this.getUpdateTime() == null ? other.getUpdateTime() == null : this.getUpdateTime().equals(other.getUpdateTime()))
&& (this.getSort() == null ? other.getSort() == null : this.getSort().equals(other.getSort()))
&& (this.getImages() == null ? other.getImages() == null : this.getImages().equals(other.getImages())) && (this.getImages() == null ? other.getImages() == null : this.getImages().equals(other.getImages()))
&& (this.getVideos() == null ? other.getVideos() == null : this.getVideos().equals(other.getVideos())) && (this.getVideos() == null ? other.getVideos() == null : this.getVideos().equals(other.getVideos()))
&& (this.getDescription() == null ? other.getDescription() == null : this.getDescription().equals(other.getDescription())); && (this.getDescription() == null ? other.getDescription() == null : this.getDescription().equals(other.getDescription()));
...@@ -135,6 +140,7 @@ public class ItemSku implements Entity { ...@@ -135,6 +140,7 @@ public class ItemSku implements Entity {
result = prime * result + ((getIsDeleted() == null) ? 0 : getIsDeleted().hashCode()); result = prime * result + ((getIsDeleted() == null) ? 0 : getIsDeleted().hashCode());
result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode()); result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode());
result = prime * result + ((getUpdateTime() == null) ? 0 : getUpdateTime().hashCode()); result = prime * result + ((getUpdateTime() == null) ? 0 : getUpdateTime().hashCode());
result = prime * result + ((getSort() == null) ? 0 : getSort().hashCode());
result = prime * result + ((getImages() == null) ? 0 : getImages().hashCode()); result = prime * result + ((getImages() == null) ? 0 : getImages().hashCode());
result = prime * result + ((getVideos() == null) ? 0 : getVideos().hashCode()); result = prime * result + ((getVideos() == null) ? 0 : getVideos().hashCode());
result = prime * result + ((getDescription() == null) ? 0 : getDescription().hashCode()); result = prime * result + ((getDescription() == null) ? 0 : getDescription().hashCode());
...@@ -158,6 +164,7 @@ public class ItemSku implements Entity { ...@@ -158,6 +164,7 @@ public class ItemSku implements Entity {
isDeleted("is_deleted", "isDeleted", "BIT", false), isDeleted("is_deleted", "isDeleted", "BIT", false),
createTime("create_time", "createTime", "TIMESTAMP", false), createTime("create_time", "createTime", "TIMESTAMP", false),
updateTime("update_time", "updateTime", "TIMESTAMP", false), updateTime("update_time", "updateTime", "TIMESTAMP", false),
sort("sort", "sort", "INTEGER", false),
images("images", "images", "LONGVARCHAR", false), images("images", "images", "LONGVARCHAR", false),
videos("videos", "videos", "LONGVARCHAR", false), videos("videos", "videos", "LONGVARCHAR", false),
description("description", "description", "LONGVARCHAR", false); description("description", "description", "LONGVARCHAR", false);
......
...@@ -1365,6 +1365,138 @@ public class ItemSkuExample { ...@@ -1365,6 +1365,138 @@ public class ItemSkuExample {
addCriterion("update_time not between", value1, value2, "updateTime"); addCriterion("update_time not between", value1, value2, "updateTime");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andSortIsNull() {
addCriterion("sort is null");
return (Criteria) this;
}
public Criteria andSortIsNotNull() {
addCriterion("sort is not null");
return (Criteria) this;
}
public Criteria andSortEqualTo(Integer value) {
addCriterion("sort =", value, "sort");
return (Criteria) this;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table item_sku
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public Criteria andSortEqualToColumn(ItemSku.Column column) {
addCriterion(new StringBuilder("sort = ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
public Criteria andSortNotEqualTo(Integer value) {
addCriterion("sort <>", value, "sort");
return (Criteria) this;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table item_sku
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public Criteria andSortNotEqualToColumn(ItemSku.Column column) {
addCriterion(new StringBuilder("sort <> ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
public Criteria andSortGreaterThan(Integer value) {
addCriterion("sort >", value, "sort");
return (Criteria) this;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table item_sku
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public Criteria andSortGreaterThanColumn(ItemSku.Column column) {
addCriterion(new StringBuilder("sort > ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
public Criteria andSortGreaterThanOrEqualTo(Integer value) {
addCriterion("sort >=", value, "sort");
return (Criteria) this;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table item_sku
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public Criteria andSortGreaterThanOrEqualToColumn(ItemSku.Column column) {
addCriterion(new StringBuilder("sort >= ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
public Criteria andSortLessThan(Integer value) {
addCriterion("sort <", value, "sort");
return (Criteria) this;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table item_sku
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public Criteria andSortLessThanColumn(ItemSku.Column column) {
addCriterion(new StringBuilder("sort < ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
public Criteria andSortLessThanOrEqualTo(Integer value) {
addCriterion("sort <=", value, "sort");
return (Criteria) this;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table item_sku
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public Criteria andSortLessThanOrEqualToColumn(ItemSku.Column column) {
addCriterion(new StringBuilder("sort <= ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
public Criteria andSortIn(List<Integer> values) {
addCriterion("sort in", values, "sort");
return (Criteria) this;
}
public Criteria andSortNotIn(List<Integer> values) {
addCriterion("sort not in", values, "sort");
return (Criteria) this;
}
public Criteria andSortBetween(Integer value1, Integer value2) {
addCriterion("sort between", value1, value2, "sort");
return (Criteria) this;
}
public Criteria andSortNotBetween(Integer value1, Integer value2) {
addCriterion("sort not between", value1, value2, "sort");
return (Criteria) this;
}
} }
public static class Criteria extends GeneratedCriteria { public static class Criteria extends GeneratedCriteria {
......
...@@ -41,6 +41,11 @@ public class ItemSkuRequestDto extends BaseRequestDto implements Entity { ...@@ -41,6 +41,11 @@ public class ItemSkuRequestDto extends BaseRequestDto implements Entity {
*/ */
private Boolean isDeleted; private Boolean isDeleted;
/**
* 排序字段
*/
private Integer sort;
/** /**
* 创建时间 * 创建时间
*/ */
......
...@@ -85,6 +85,17 @@ public class DistributionOrderDaoImpl implements DistributionOrderDao { ...@@ -85,6 +85,17 @@ public class DistributionOrderDaoImpl implements DistributionOrderDao {
return distributionOrderMapper.selectOneByExample(example); return distributionOrderMapper.selectOneByExample(example);
} }
@Override
public List<DistributionOrder> findBuyRecordByItemId(long itemId) {
DistributionOrderExample example = new DistributionOrderExample();
DistributionOrderExample.Criteria criteria = example.createCriteria();
criteria.andItemIdEqualTo(itemId);
criteria.andPayTimeIsNotNull();
criteria.andStateNotEqualTo(101);
example.setOrderByClause("pay_time desc");
return distributionOrderMapper.selectByExample(example);
}
@Override @Override
public List<DistributionOrder> findValidOrderOfItemIdByBuyerId(long buyerId, long itemId) { public List<DistributionOrder> findValidOrderOfItemIdByBuyerId(long buyerId, long itemId) {
DistributionOrderExample example = new DistributionOrderExample(); DistributionOrderExample example = new DistributionOrderExample();
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
<result column="is_deleted" jdbcType="BIT" property="isDeleted" /> <result column="is_deleted" jdbcType="BIT" property="isDeleted" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" /> <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" /> <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
<result column="sort" jdbcType="INTEGER" property="sort" />
</resultMap> </resultMap>
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="com.wwdz.ch.db.domain.distribution.ItemSku"> <resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="com.wwdz.ch.db.domain.distribution.ItemSku">
<result column="images" jdbcType="LONGVARCHAR" property="images" /> <result column="images" jdbcType="LONGVARCHAR" property="images" />
...@@ -76,7 +77,8 @@ ...@@ -76,7 +77,8 @@
</where> </where>
</sql> </sql>
<sql id="Base_Column_List"> <sql id="Base_Column_List">
id, sku_code, `name`, item_id, default_image, price, is_deleted, create_time, update_time id, sku_code, `name`, item_id, default_image, price, is_deleted, create_time, update_time,
sort
</sql> </sql>
<sql id="Blob_Column_List"> <sql id="Blob_Column_List">
images, videos, description images, videos, description
...@@ -125,14 +127,14 @@ ...@@ -125,14 +127,14 @@
distinct distinct
</if> </if>
<choose> <choose>
<when test="selective != null and selective.length > 0"> <when test="selective != null and selective.length &gt; 0">
<foreach collection="selective" item="column" separator=","> <foreach collection="selective" item="column" separator=",">
${column.escapedColumnName} ${column.escapedColumnName}
</foreach> </foreach>
</when> </when>
<otherwise> <otherwise>
id, sku_code, `name`, item_id, default_image, price, is_deleted, create_time, update_time, id, sku_code, `name`, item_id, default_image, price, is_deleted, create_time, update_time,
images, videos, description sort, images, videos, description
</otherwise> </otherwise>
</choose> </choose>
from item_sku from item_sku
...@@ -159,14 +161,14 @@ ...@@ -159,14 +161,14 @@
--> -->
select select
<choose> <choose>
<when test="selective != null and selective.length > 0"> <when test="selective != null and selective.length &gt; 0">
<foreach collection="selective" item="column" separator=","> <foreach collection="selective" item="column" separator=",">
${column.escapedColumnName} ${column.escapedColumnName}
</foreach> </foreach>
</when> </when>
<otherwise> <otherwise>
id, sku_code, `name`, item_id, default_image, price, is_deleted, create_time, update_time, id, sku_code, `name`, item_id, default_image, price, is_deleted, create_time, update_time,
images, videos, description sort, images, videos, description
</otherwise> </otherwise>
</choose> </choose>
from item_sku from item_sku
...@@ -188,12 +190,14 @@ ...@@ -188,12 +190,14 @@
</selectKey> </selectKey>
insert into item_sku (sku_code, `name`, item_id, insert into item_sku (sku_code, `name`, item_id,
default_image, price, is_deleted, default_image, price, is_deleted,
create_time, update_time, images, create_time, update_time, sort,
videos, description) images, videos, description
)
values (#{skuCode,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{itemId,jdbcType=BIGINT}, values (#{skuCode,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{itemId,jdbcType=BIGINT},
#{defaultImage,jdbcType=VARCHAR}, #{price,jdbcType=BIGINT}, #{isDeleted,jdbcType=BIT}, #{defaultImage,jdbcType=VARCHAR}, #{price,jdbcType=BIGINT}, #{isDeleted,jdbcType=BIT},
#{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}, #{images,jdbcType=LONGVARCHAR}, #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}, #{sort,jdbcType=INTEGER},
#{videos,jdbcType=LONGVARCHAR}, #{description,jdbcType=LONGVARCHAR}) #{images,jdbcType=LONGVARCHAR}, #{videos,jdbcType=LONGVARCHAR}, #{description,jdbcType=LONGVARCHAR}
)
</insert> </insert>
<insert id="insertSelective" parameterType="com.wwdz.ch.db.domain.distribution.ItemSku"> <insert id="insertSelective" parameterType="com.wwdz.ch.db.domain.distribution.ItemSku">
<selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long"> <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long">
...@@ -225,6 +229,9 @@ ...@@ -225,6 +229,9 @@
<if test="updateTime != null"> <if test="updateTime != null">
update_time, update_time,
</if> </if>
<if test="sort != null">
sort,
</if>
<if test="images != null"> <if test="images != null">
images, images,
</if> </if>
...@@ -260,6 +267,9 @@ ...@@ -260,6 +267,9 @@
<if test="updateTime != null"> <if test="updateTime != null">
#{updateTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP},
</if> </if>
<if test="sort != null">
#{sort,jdbcType=INTEGER},
</if>
<if test="images != null"> <if test="images != null">
#{images,jdbcType=LONGVARCHAR}, #{images,jdbcType=LONGVARCHAR},
</if> </if>
...@@ -307,6 +317,9 @@ ...@@ -307,6 +317,9 @@
<if test="record.updateTime != null"> <if test="record.updateTime != null">
update_time = #{record.updateTime,jdbcType=TIMESTAMP}, update_time = #{record.updateTime,jdbcType=TIMESTAMP},
</if> </if>
<if test="record.sort != null">
sort = #{record.sort,jdbcType=INTEGER},
</if>
<if test="record.images != null"> <if test="record.images != null">
images = #{record.images,jdbcType=LONGVARCHAR}, images = #{record.images,jdbcType=LONGVARCHAR},
</if> </if>
...@@ -332,6 +345,7 @@ ...@@ -332,6 +345,7 @@
is_deleted = #{record.isDeleted,jdbcType=BIT}, is_deleted = #{record.isDeleted,jdbcType=BIT},
create_time = #{record.createTime,jdbcType=TIMESTAMP}, create_time = #{record.createTime,jdbcType=TIMESTAMP},
update_time = #{record.updateTime,jdbcType=TIMESTAMP}, update_time = #{record.updateTime,jdbcType=TIMESTAMP},
sort = #{record.sort,jdbcType=INTEGER},
images = #{record.images,jdbcType=LONGVARCHAR}, images = #{record.images,jdbcType=LONGVARCHAR},
videos = #{record.videos,jdbcType=LONGVARCHAR}, videos = #{record.videos,jdbcType=LONGVARCHAR},
description = #{record.description,jdbcType=LONGVARCHAR} description = #{record.description,jdbcType=LONGVARCHAR}
...@@ -349,7 +363,8 @@ ...@@ -349,7 +363,8 @@
price = #{record.price,jdbcType=BIGINT}, price = #{record.price,jdbcType=BIGINT},
is_deleted = #{record.isDeleted,jdbcType=BIT}, is_deleted = #{record.isDeleted,jdbcType=BIT},
create_time = #{record.createTime,jdbcType=TIMESTAMP}, create_time = #{record.createTime,jdbcType=TIMESTAMP},
update_time = #{record.updateTime,jdbcType=TIMESTAMP} update_time = #{record.updateTime,jdbcType=TIMESTAMP},
sort = #{record.sort,jdbcType=INTEGER}
<if test="_parameter != null"> <if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" /> <include refid="Update_By_Example_Where_Clause" />
</if> </if>
...@@ -381,6 +396,9 @@ ...@@ -381,6 +396,9 @@
<if test="updateTime != null"> <if test="updateTime != null">
update_time = #{updateTime,jdbcType=TIMESTAMP}, update_time = #{updateTime,jdbcType=TIMESTAMP},
</if> </if>
<if test="sort != null">
sort = #{sort,jdbcType=INTEGER},
</if>
<if test="images != null"> <if test="images != null">
images = #{images,jdbcType=LONGVARCHAR}, images = #{images,jdbcType=LONGVARCHAR},
</if> </if>
...@@ -403,6 +421,7 @@ ...@@ -403,6 +421,7 @@
is_deleted = #{isDeleted,jdbcType=BIT}, is_deleted = #{isDeleted,jdbcType=BIT},
create_time = #{createTime,jdbcType=TIMESTAMP}, create_time = #{createTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP}, update_time = #{updateTime,jdbcType=TIMESTAMP},
sort = #{sort,jdbcType=INTEGER},
images = #{images,jdbcType=LONGVARCHAR}, images = #{images,jdbcType=LONGVARCHAR},
videos = #{videos,jdbcType=LONGVARCHAR}, videos = #{videos,jdbcType=LONGVARCHAR},
description = #{description,jdbcType=LONGVARCHAR} description = #{description,jdbcType=LONGVARCHAR}
...@@ -417,7 +436,8 @@ ...@@ -417,7 +436,8 @@
price = #{price,jdbcType=BIGINT}, price = #{price,jdbcType=BIGINT},
is_deleted = #{isDeleted,jdbcType=BIT}, is_deleted = #{isDeleted,jdbcType=BIT},
create_time = #{createTime,jdbcType=TIMESTAMP}, create_time = #{createTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP} update_time = #{updateTime,jdbcType=TIMESTAMP},
sort = #{sort,jdbcType=INTEGER}
where id = #{id,jdbcType=BIGINT} where id = #{id,jdbcType=BIGINT}
</update> </update>
<select id="selectOneByExample" parameterType="com.wwdz.ch.db.domain.distribution.ItemSkuExample" resultMap="BaseResultMap"> <select id="selectOneByExample" parameterType="com.wwdz.ch.db.domain.distribution.ItemSkuExample" resultMap="BaseResultMap">
...@@ -467,14 +487,14 @@ ...@@ -467,14 +487,14 @@
select select
'true' as QUERYID, 'true' as QUERYID,
<choose> <choose>
<when test="selective != null and selective.length > 0"> <when test="selective != null and selective.length &gt; 0">
<foreach collection="selective" item="column" separator=","> <foreach collection="selective" item="column" separator=",">
${column.escapedColumnName} ${column.escapedColumnName}
</foreach> </foreach>
</when> </when>
<otherwise> <otherwise>
id, sku_code, `name`, item_id, default_image, price, is_deleted, create_time, update_time, id, sku_code, `name`, item_id, default_image, price, is_deleted, create_time, update_time,
images, videos, description sort, images, videos, description
</otherwise> </otherwise>
</choose> </choose>
from item_sku from item_sku
......
package com.wwdz.ch.wx.entity.vo.distribution;
import com.xxdxxs.entity.Entity;
import lombok.Data;
@Data
public class BlindBoxDetailVo implements Entity {
}
package com.wwdz.ch.wx.entity.vo.distribution;
import com.xxdxxs.entity.Entity;
import lombok.Data;
import java.util.List;
@Data
public class BlindBoxInfoVo implements Entity {
/**
* 名称
*/
private String name;
/**
* 价格
*/
private String price;
/**
* 图片
* 默认展示前五个sku图片
*/
private List<String> imageList;
/**
* 盲盒总sku数量
*/
private Long totalNum;
/**
* 剩下sku数量
*/
private Long remainNum;
/**
* 购买记录
*/
private String buyRecord;
/**
* 优惠活动
*/
private String sellActivity;
/**
* 背景图
*/
private String backgroundImage;
}
...@@ -7,6 +7,12 @@ import java.util.List; ...@@ -7,6 +7,12 @@ import java.util.List;
@Data @Data
public class BlindBoxVo implements Entity { public class BlindBoxVo implements Entity {
/**
* 优惠活动描述
*/
private String desc;
/** /**
* 优惠活动 * 优惠活动
*/ */
......
package com.wwdz.ch.wx.impl.distribution; package com.wwdz.ch.wx.impl.distribution;
import com.github.pagehelper.PageInfo;
import com.wwdz.ch.core.consts.DistributionEnum; import com.wwdz.ch.core.consts.DistributionEnum;
import com.wwdz.ch.core.type.Result; import com.wwdz.ch.core.type.Result;
import com.wwdz.ch.core.util.CacheUtil;
import com.wwdz.ch.core.util.PriceUtil;
import com.wwdz.ch.core.util.StringUtil;
import com.wwdz.ch.db.dao.distribution.DistributionOrderDao;
import com.wwdz.ch.db.dao.distribution.ItemSkuDao; import com.wwdz.ch.db.dao.distribution.ItemSkuDao;
import com.wwdz.ch.db.dao.distribution.SupplierItemDao; import com.wwdz.ch.db.dao.distribution.SupplierItemDao;
import com.wwdz.ch.db.domain.User;
import com.wwdz.ch.db.domain.distribution.DistributionOrder;
import com.wwdz.ch.db.domain.distribution.ItemSku; import com.wwdz.ch.db.domain.distribution.ItemSku;
import com.wwdz.ch.db.domain.distribution.SupplierItem; import com.wwdz.ch.db.domain.distribution.SupplierItem;
import com.wwdz.ch.db.dto.request.distribution.ItemSkuRequestDto; import com.wwdz.ch.db.dto.request.distribution.ItemSkuRequestDto;
import com.wwdz.ch.db.dto.request.distribution.SupplierItemRequestDto; import com.wwdz.ch.db.dto.request.distribution.SupplierItemRequestDto;
import com.wwdz.ch.wx.entity.vo.distribution.BlindBoxInfoVo;
import com.wwdz.ch.wx.entity.vo.distribution.BlindBoxVo; import com.wwdz.ch.wx.entity.vo.distribution.BlindBoxVo;
import com.wwdz.ch.wx.service.distribution.BlindBoxService; import com.wwdz.ch.wx.service.distribution.BlindBoxService;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
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 org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date;
import java.util.List; import java.util.List;
@Service @Service
...@@ -29,6 +40,12 @@ public class BlindBoxServiceImpl implements BlindBoxService { ...@@ -29,6 +40,12 @@ public class BlindBoxServiceImpl implements BlindBoxService {
@Autowired @Autowired
ItemSkuDao itemSkuDao; ItemSkuDao itemSkuDao;
@Autowired
DistributionOrderDao distributionOrderDao;
@Autowired
CacheUtil cacheUtil;
@Override @Override
public Result findForHomePage(SupplierItemRequestDto dto) { public Result findForHomePage(SupplierItemRequestDto dto) {
try { try {
...@@ -51,7 +68,7 @@ public class BlindBoxServiceImpl implements BlindBoxService { ...@@ -51,7 +68,7 @@ public class BlindBoxServiceImpl implements BlindBoxService {
itemList.add(imageList); itemList.add(imageList);
} }
BlindBoxVo blindBoxVo = new BlindBoxVo(); BlindBoxVo blindBoxVo = new BlindBoxVo();
blindBoxVo.setSellActivity("全场限时立减五元"); blindBoxVo.setSellActivity("全场限时 立减5元");
blindBoxVo.setItemList(itemList); blindBoxVo.setItemList(itemList);
return Result.success(blindBoxVo); return Result.success(blindBoxVo);
} catch (Exception e) { } catch (Exception e) {
...@@ -64,7 +81,52 @@ public class BlindBoxServiceImpl implements BlindBoxService { ...@@ -64,7 +81,52 @@ public class BlindBoxServiceImpl implements BlindBoxService {
@Override @Override
public Result findList(SupplierItemRequestDto dto) { public Result findList(SupplierItemRequestDto dto) {
try { try {
List<BlindBoxInfoVo> blindBoxInfoVoList = new ArrayList<>();
dto.setType(DistributionEnum.DistributionTypeEnum.BLACK_COLLECTION.getCode());
dto.setStock(0);
dto.setIsDeleted(false);
List<SupplierItem> supplierItemList = supplierItemDao.findList(dto);
for (SupplierItem supplierItem : supplierItemList) {
BlindBoxInfoVo blindBoxInfoVo = new BlindBoxInfoVo();
long itemId = supplierItem.getId();
ItemSkuRequestDto itemSkuRequestDto = new ItemSkuRequestDto();
itemSkuRequestDto.setItemId(itemId);
itemSkuRequestDto.setLimit(5);
List<ItemSku> itemSkuList = itemSkuDao.findByPage(itemSkuRequestDto);
PageInfo pageInfo = new PageInfo<>(itemSkuList);
List<String> imageList = new ArrayList<>();
for (ItemSku itemSku : itemSkuList) {
imageList.add(itemSku.getDefaultImage());
}
blindBoxInfoVo.setImageList(imageList);
blindBoxInfoVo.setName(supplierItem.getName());
blindBoxInfoVo.setPrice(PriceUtil.convertPriceFenToYuan(supplierItem.getDistributionPrice()));
blindBoxInfoVo.setTotalNum(pageInfo.getTotal());
blindBoxInfoVo.setRemainNum(supplierItem.getStock().longValue());
//查询最近的购买记录
List<DistributionOrder> distributionOrderList = distributionOrderDao.findBuyRecordByItemId(itemId);
if (!CollectionUtils.isEmpty(distributionOrderList)) {
DistributionOrder lastedRecord = distributionOrderList.get(0);
long buyerId = lastedRecord.getBuyerId();
User user = cacheUtil.appletUserInfoCache.get(buyerId).get();
String nickName = StringUtils.isEmpty(user.getNickname()) ? "微信用户" : user.getNickname();
nickName = StringUtil.anonymizeUsername(nickName);
long diffInMillies = Math.abs(new Date().getTime() - lastedRecord.getPayTime().getTime());
long diffInHours = diffInMillies / (60 * 1000 * 60);
String buyRecord = "";
if (diffInHours >= 1 && diffInHours < 24) {
buyRecord = nickName + " " + diffInHours + "小时前下单";
} else if (diffInHours > 24) {
long diffInDays = diffInMillies / (60 * 1000 * 60 * 24);
buyRecord = nickName + " " + diffInDays + "天前下单";
} else {
buyRecord = nickName + " 1小时内下单";
}
blindBoxInfoVo.setBuyRecord(buyRecord);
}
blindBoxInfoVoList.add(blindBoxInfoVo);
}
return Result.success(blindBoxInfoVoList);
} catch (Exception e) { } catch (Exception e) {
logger.error("查询盲袋商品列表 error : {}", e); logger.error("查询盲袋商品列表 error : {}", e);
} }
...@@ -78,13 +140,12 @@ public class BlindBoxServiceImpl implements BlindBoxService { ...@@ -78,13 +140,12 @@ public class BlindBoxServiceImpl implements BlindBoxService {
dto.setType(DistributionEnum.DistributionTypeEnum.BLACK_COLLECTION.getCode()); dto.setType(DistributionEnum.DistributionTypeEnum.BLACK_COLLECTION.getCode());
dto.setStock(0); dto.setStock(0);
dto.setIsDeleted(false); dto.setIsDeleted(false);
dto.setLimit(3);
List<SupplierItem> supplierItemList = supplierItemDao.findList(dto); List<SupplierItem> supplierItemList = supplierItemDao.findList(dto);
for (SupplierItem supplierItem : supplierItemList) { for (SupplierItem supplierItem : supplierItemList) {
long itemId = supplierItem.getId(); long itemId = supplierItem.getId();
ItemSkuRequestDto itemSkuRequestDto = new ItemSkuRequestDto(); ItemSkuRequestDto itemSkuRequestDto = new ItemSkuRequestDto();
itemSkuRequestDto.setItemId(itemId); itemSkuRequestDto.setItemId(itemId);
itemSkuRequestDto.setLimit(3); itemSkuRequestDto.setLimit(5);
List<ItemSku> itemSkuList = itemSkuDao.findByPage(itemSkuRequestDto); List<ItemSku> itemSkuList = itemSkuDao.findByPage(itemSkuRequestDto);
List<String> imageList = new ArrayList<>(); List<String> imageList = new ArrayList<>();
for (ItemSku itemSku : itemSkuList) { for (ItemSku itemSku : itemSkuList) {
......
...@@ -9,7 +9,7 @@ import com.wwdz.ch.db.dto.request.distribution.SupplierItemRequestDto; ...@@ -9,7 +9,7 @@ import com.wwdz.ch.db.dto.request.distribution.SupplierItemRequestDto;
public interface BlindBoxService { public interface BlindBoxService {
/** /**
* 查询首页福袋 * 查询首页福袋专区信息
* @param dto * @param dto
* @return * @return
*/ */
......
package com.wwdz.ch.wx.web.distribution;
import com.alibaba.fastjson.JSON;
import com.wwdz.ch.core.type.Result;
import com.wwdz.ch.db.dto.request.distribution.SupplierItemRequestDto;
import com.wwdz.ch.wx.service.distribution.BlindBoxService;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/wx/blindBox")
public class BlindBoxController {
private static final Logger logger = LoggerFactory.getLogger(BlindBoxController.class);
@Autowired
BlindBoxService blindBoxService;
@ApiOperation(value = "查询首页福袋专区信息")
@PostMapping("/findForHomePage")
public Result findForHomePage(@RequestBody SupplierItemRequestDto dto) {
logger.info("查询首页福袋专区信息,请求参数:{}", JSON.toJSONString(dto));
return blindBoxService.findForHomePage(dto);
}
@ApiOperation(value = "查询福袋列表")
@PostMapping("/findList")
public Result findList(@RequestBody SupplierItemRequestDto dto) {
logger.info("查询福袋列表,请求参数:{}", JSON.toJSONString(dto));
return blindBoxService.findList(dto);
}
@ApiOperation(value = "查询福袋详情")
@PostMapping("/findDetail")
public Result findDetail(@RequestBody SupplierItemRequestDto dto) {
logger.info("查询福袋详情,请求参数:{}", JSON.toJSONString(dto));
return blindBoxService.findDetail(dto);
}
}
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