Authored by tanling

Merge branch 'test6.9.8' of http://git.yoho.cn/ufo/yohoufo-fore into test6.9.8

package com.yohoufo.dal.order.model;
public class StorageDeposit {
private Integer id;
private Integer productId;
private Integer goodsId;
private Integer storageId;
private String depositCode;
private String shelfCode;
private Integer ownerUid;
private Long orderCode;
private Long skup;
private Integer status;
private Integer orderStatus;
private Integer updateTime;
private Integer createTime;
private Integer depositStartTime;
private Integer depositEndTime;
private Integer editPid;
private Integer delStatus;
private Integer outType;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public Integer getProductId() {
return productId;
}
public void setProductId(Integer productId) {
this.productId = productId;
}
public Integer getGoodsId() {
return goodsId;
}
public void setGoodsId(Integer goodsId) {
this.goodsId = goodsId;
}
public Integer getStorageId() {
return storageId;
}
public void setStorageId(Integer storageId) {
this.storageId = storageId;
}
public String getDepositCode() {
return depositCode;
}
public void setDepositCode(String depositCode) {
this.depositCode = depositCode == null ? null : depositCode.trim();
}
public String getShelfCode() {
return shelfCode;
}
public void setShelfCode(String shelfCode) {
this.shelfCode = shelfCode == null ? null : shelfCode.trim();
}
public Integer getOwnerUid() {
return ownerUid;
}
public void setOwnerUid(Integer ownerUid) {
this.ownerUid = ownerUid;
}
public Long getOrderCode() {
return orderCode;
}
public void setOrderCode(Long orderCode) {
this.orderCode = orderCode;
}
public Long getSkup() {
return skup;
}
public void setSkup(Long skup) {
this.skup = skup;
}
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
public Integer getOrderStatus() {
return orderStatus;
}
public void setOrderStatus(Integer orderStatus) {
this.orderStatus = orderStatus;
}
public Integer getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Integer updateTime) {
this.updateTime = updateTime;
}
public Integer getCreateTime() {
return createTime;
}
public void setCreateTime(Integer createTime) {
this.createTime = createTime;
}
public Integer getDepositStartTime() {
return depositStartTime;
}
public void setDepositStartTime(Integer depositStartTime) {
this.depositStartTime = depositStartTime;
}
public Integer getDepositEndTime() {
return depositEndTime;
}
public void setDepositEndTime(Integer depositEndTime) {
this.depositEndTime = depositEndTime;
}
public Integer getEditPid() {
return editPid;
}
public void setEditPid(Integer editPid) {
this.editPid = editPid;
}
public Integer getDelStatus() {
return delStatus;
}
public void setDelStatus(Integer delStatus) {
this.delStatus = delStatus;
}
public Integer getOutType() {
return outType;
}
public void setOutType(Integer outType) {
this.outType = outType;
}
}
\ No newline at end of file
... ...
package com.yohoufo.dal.order.model;
import lombok.Data;
@Data
public class StorageDepositCount {
private Integer productId;
private Integer storageIdCount;
private Integer storageCount;
private Integer unShelfStorageCount;
}
\ No newline at end of file
... ...
package com.yohoufo.dal.product;
import com.yohoufo.dal.order.model.StorageDeposit;
import com.yohoufo.dal.order.model.StorageDepositCount;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface StorageDepositMapper {
int deleteByPrimaryKey(Integer id);
int insert(StorageDeposit record);
int insertSelective(StorageDeposit record);
StorageDeposit selectByPrimaryKey(Integer id);
int updateByPrimaryKeySelective(StorageDeposit record);
int updateByPrimaryKey(StorageDeposit record);
int queryUserDepositProductCount(Integer uid);
List<Integer> queryUserDepositProductId(@Param("uid") Integer uid, @Param("start") Integer start, @Param("count") Integer count);
List<StorageDepositCount> queryUserDepositProduct(@Param("uid") Integer uid, @Param("productIdList") List<Integer> productIdList);
int queryUserDopositBackCount(Integer uid);
List<StorageDeposit> queryUserDopositBack(@Param("uid") Integer uid, @Param("start") Integer start, @Param("count") Integer count);
}
\ No newline at end of file
... ...
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.yohoufo.dal.product.StorageDepositMapper" >
<resultMap id="BaseResultMap" type="com.yohoufo.dal.order.model.StorageDeposit" >
<id column="id" property="id" jdbcType="INTEGER" />
<result column="product_id" property="productId" jdbcType="INTEGER" />
<result column="goods_id" property="goodsId" jdbcType="INTEGER" />
<result column="storage_id" property="storageId" jdbcType="INTEGER" />
<result column="deposit_code" property="depositCode" jdbcType="VARCHAR" />
<result column="shelf_code" property="shelfCode" jdbcType="VARCHAR" />
<result column="owner_uid" property="ownerUid" jdbcType="INTEGER" />
<result column="order_code" property="orderCode" jdbcType="BIGINT" />
<result column="skup" property="skup" jdbcType="BIGINT" />
<result column="status" property="status" jdbcType="INTEGER" />
<result column="order_status" property="orderStatus" jdbcType="INTEGER" />
<result column="update_time" property="updateTime" jdbcType="INTEGER" />
<result column="create_time" property="createTime" jdbcType="INTEGER" />
<result column="deposit_start_time" property="depositStartTime" jdbcType="INTEGER" />
<result column="deposit_end_time" property="depositEndTime" jdbcType="INTEGER" />
<result column="edit_pid" property="editPid" jdbcType="INTEGER" />
<result column="del_status" property="delStatus" jdbcType="INTEGER" />
<result column="out_type" property="outType" jdbcType="INTEGER" />
</resultMap>
<resultMap id="CountResultMap" type="com.yohoufo.dal.order.model.StorageDepositCount" >
<result column="product_id" property="productId" jdbcType="INTEGER" />
<result column="storage_id_count" property="storageIdCount" jdbcType="INTEGER" />
<result column="storage_count" property="storageCount" jdbcType="INTEGER" />
<result column="un_shelf_storage_count" property="unShelfStorageCount" jdbcType="INTEGER" />
</resultMap>
<sql id="Base_Column_List" >
id, product_id, goods_id, storage_id, deposit_code, shelf_code, owner_uid, order_code,
skup, status, order_status, update_time, create_time, deposit_start_time, deposit_end_time,
edit_pid, del_status, out_type
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
select
<include refid="Base_Column_List" />
from storage_deposit
where id = #{id,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
delete from storage_deposit
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.yohoufo.dal.order.model.StorageDeposit" >
insert into storage_deposit (id, product_id, goods_id,
storage_id, deposit_code, shelf_code,
owner_uid, order_code, skup,
status, order_status, update_time,
create_time, deposit_start_time, deposit_end_time,
edit_pid, del_status, out_type
)
values (#{id,jdbcType=INTEGER}, #{productId,jdbcType=INTEGER}, #{goodsId,jdbcType=INTEGER},
#{storageId,jdbcType=INTEGER}, #{depositCode,jdbcType=VARCHAR}, #{shelfCode,jdbcType=VARCHAR},
#{ownerUid,jdbcType=INTEGER}, #{orderCode,jdbcType=BIGINT}, #{skup,jdbcType=BIGINT},
#{status,jdbcType=INTEGER}, #{orderStatus,jdbcType=INTEGER}, #{updateTime,jdbcType=INTEGER},
#{createTime,jdbcType=INTEGER}, #{depositStartTime,jdbcType=INTEGER}, #{depositEndTime,jdbcType=INTEGER},
#{editPid,jdbcType=INTEGER}, #{delStatus,jdbcType=INTEGER}, #{outType,jdbcType=INTEGER}
)
</insert>
<insert id="insertSelective" parameterType="com.yohoufo.dal.order.model.StorageDeposit" >
insert into storage_deposit
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="id != null" >
id,
</if>
<if test="productId != null" >
product_id,
</if>
<if test="goodsId != null" >
goods_id,
</if>
<if test="storageId != null" >
storage_id,
</if>
<if test="depositCode != null" >
deposit_code,
</if>
<if test="shelfCode != null" >
shelf_code,
</if>
<if test="ownerUid != null" >
owner_uid,
</if>
<if test="orderCode != null" >
order_code,
</if>
<if test="skup != null" >
skup,
</if>
<if test="status != null" >
status,
</if>
<if test="orderStatus != null" >
order_status,
</if>
<if test="updateTime != null" >
update_time,
</if>
<if test="createTime != null" >
create_time,
</if>
<if test="depositStartTime != null" >
deposit_start_time,
</if>
<if test="depositEndTime != null" >
deposit_end_time,
</if>
<if test="editPid != null" >
edit_pid,
</if>
<if test="delStatus != null" >
del_status,
</if>
<if test="outType != null" >
out_type,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="id != null" >
#{id,jdbcType=INTEGER},
</if>
<if test="productId != null" >
#{productId,jdbcType=INTEGER},
</if>
<if test="goodsId != null" >
#{goodsId,jdbcType=INTEGER},
</if>
<if test="storageId != null" >
#{storageId,jdbcType=INTEGER},
</if>
<if test="depositCode != null" >
#{depositCode,jdbcType=VARCHAR},
</if>
<if test="shelfCode != null" >
#{shelfCode,jdbcType=VARCHAR},
</if>
<if test="ownerUid != null" >
#{ownerUid,jdbcType=INTEGER},
</if>
<if test="orderCode != null" >
#{orderCode,jdbcType=BIGINT},
</if>
<if test="skup != null" >
#{skup,jdbcType=BIGINT},
</if>
<if test="status != null" >
#{status,jdbcType=INTEGER},
</if>
<if test="orderStatus != null" >
#{orderStatus,jdbcType=INTEGER},
</if>
<if test="updateTime != null" >
#{updateTime,jdbcType=INTEGER},
</if>
<if test="createTime != null" >
#{createTime,jdbcType=INTEGER},
</if>
<if test="depositStartTime != null" >
#{depositStartTime,jdbcType=INTEGER},
</if>
<if test="depositEndTime != null" >
#{depositEndTime,jdbcType=INTEGER},
</if>
<if test="editPid != null" >
#{editPid,jdbcType=INTEGER},
</if>
<if test="delStatus != null" >
#{delStatus,jdbcType=INTEGER},
</if>
<if test="outType != null" >
#{outType,jdbcType=INTEGER},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.yohoufo.dal.order.model.StorageDeposit" >
update storage_deposit
<set >
<if test="productId != null" >
product_id = #{productId,jdbcType=INTEGER},
</if>
<if test="goodsId != null" >
goods_id = #{goodsId,jdbcType=INTEGER},
</if>
<if test="storageId != null" >
storage_id = #{storageId,jdbcType=INTEGER},
</if>
<if test="depositCode != null" >
deposit_code = #{depositCode,jdbcType=VARCHAR},
</if>
<if test="shelfCode != null" >
shelf_code = #{shelfCode,jdbcType=VARCHAR},
</if>
<if test="ownerUid != null" >
owner_uid = #{ownerUid,jdbcType=INTEGER},
</if>
<if test="orderCode != null" >
order_code = #{orderCode,jdbcType=BIGINT},
</if>
<if test="skup != null" >
skup = #{skup,jdbcType=BIGINT},
</if>
<if test="status != null" >
status = #{status,jdbcType=INTEGER},
</if>
<if test="orderStatus != null" >
order_status = #{orderStatus,jdbcType=INTEGER},
</if>
<if test="updateTime != null" >
update_time = #{updateTime,jdbcType=INTEGER},
</if>
<if test="createTime != null" >
create_time = #{createTime,jdbcType=INTEGER},
</if>
<if test="depositStartTime != null" >
deposit_start_time = #{depositStartTime,jdbcType=INTEGER},
</if>
<if test="depositEndTime != null" >
deposit_end_time = #{depositEndTime,jdbcType=INTEGER},
</if>
<if test="editPid != null" >
edit_pid = #{editPid,jdbcType=INTEGER},
</if>
<if test="delStatus != null" >
del_status = #{delStatus,jdbcType=INTEGER},
</if>
<if test="outType != null" >
out_type = #{outType,jdbcType=INTEGER},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.yohoufo.dal.order.model.StorageDeposit" >
update storage_deposit
set product_id = #{productId,jdbcType=INTEGER},
goods_id = #{goodsId,jdbcType=INTEGER},
storage_id = #{storageId,jdbcType=INTEGER},
deposit_code = #{depositCode,jdbcType=VARCHAR},
shelf_code = #{shelfCode,jdbcType=VARCHAR},
owner_uid = #{ownerUid,jdbcType=INTEGER},
order_code = #{orderCode,jdbcType=BIGINT},
skup = #{skup,jdbcType=BIGINT},
status = #{status,jdbcType=INTEGER},
order_status = #{orderStatus,jdbcType=INTEGER},
update_time = #{updateTime,jdbcType=INTEGER},
create_time = #{createTime,jdbcType=INTEGER},
deposit_start_time = #{depositStartTime,jdbcType=INTEGER},
deposit_end_time = #{depositEndTime,jdbcType=INTEGER},
edit_pid = #{editPid,jdbcType=INTEGER},
del_status = #{delStatus,jdbcType=INTEGER},
out_type = #{outType,jdbcType=INTEGER}
where id = #{id,jdbcType=INTEGER}
</update>
<select id="queryUserDepositProductCount" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
select count(distinct product_id) from storage_deposit
where owner_uid = #{uid} and status=1 and del_status=0
</select>
<select id="queryUserDepositProductId" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
select distinct product_id from storage_deposit
where owner_uid = #{uid} and status=1 and del_status=0 limit #{start}, #{count}
</select>
<select id="queryUserDepositProduct" resultMap="CountResultMap">
select product_id , count(distinct storage_id) as storage_id_count,count(*) as storage_count,sum( if( order_status = 0, 1, 0)) as un_shelf_storage_count from storage_deposit
where owner_uid = #{uid} and status=1 and del_status=0 limit #{start}, #{count}
and product_id in
<foreach item="item" index="index" collection="productIdList" open="(" separator="," close=")">
#{item}
</foreach>
group by product_id
</select>
<select id="queryUserDopositBackCount" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
select count(*) from storage_deposit
where owner_uid = #{uid} and status in(2,3,4) and out_type in(0,1) and del_status=0
</select>
<select id="queryUserDopositBack" resultMap="BaseResultMap">
select * from storage_deposit
where owner_uid = #{uid} and status in(2,3,4) and out_type in(0,1) and del_status=0
limit #{start}, #{count}
</select>
</mapper>
\ No newline at end of file
... ...
package com.yohoufo.order.controller;
import com.yohobuy.ufo.model.order.bo.DepositDetailBo;
import com.yohobuy.ufo.model.order.bo.DepositProductBo;
import com.yohoufo.common.ApiResponse;
import com.yohoufo.order.service.DepositService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@RestController
public class DepositController {
private final Logger LOG = LoggerFactory.getLogger(this.getClass());
@Autowired
private DepositService depositService;
@RequestMapping(params = "method=ufo.deposit.queryUserDoposit")
public ApiResponse queryUserDoposit(@RequestParam("uid") Integer uid
, @RequestParam(value = "limit", required = false)Integer limit
, @RequestParam(value = "page", required = false)Integer page
) {
if(uid == null || uid < 1) {
LOG.warn("queryUserDoposit failed, invalid uid: {}", uid);
return new ApiResponse.ApiResponseBuilder().code(500).message("查询失败").build();
}
List<DepositProductBo> depositProductBoList = depositService.queryUserDoposit(uid, page, limit);
LOG.info("queryStoreInfoById result: {}", depositProductBoList);
return new ApiResponse.ApiResponseBuilder().code(200).data(depositProductBoList).build();
}
@RequestMapping(params = "method=ufo.deposit.queryUserDopositBackDetail")
public ApiResponse queryUserDopositBackDetail(@RequestParam("uid") Integer uid
, @RequestParam(value = "limit", required = false)Integer limit
, @RequestParam(value = "page", required = false)Integer page
) {
if(uid == null || uid < 1) {
LOG.warn("queryUserDopositBackDetail failed, invalid uid: {}", uid);
return new ApiResponse.ApiResponseBuilder().code(500).message("查询失败").build();
}
List<DepositDetailBo> depositDetailBoList = depositService.queryUserDopositBackDetail(uid, page, limit);
LOG.info("queryUserDopositBackDetail result: {}", depositDetailBoList);
return new ApiResponse.ApiResponseBuilder().code(200).data(depositDetailBoList).build();
}
}
... ...
package com.yohoufo.order.service;
import com.yohobuy.ufo.model.order.bo.DepositDetailBo;
import com.yohobuy.ufo.model.order.bo.DepositProductBo;
import java.util.Collection;
import java.util.List;
public interface DepositService {
List<DepositProductBo> queryUserDoposit(Integer uid, Integer page, Integer limit);
List<DepositDetailBo> queryUserDopositBackDetail(Integer uid, Integer page, Integer limit);
List<DepositDetailBo> queryUserProductDopositDetail(Integer uid, Integer productId, Integer page, Integer limit);
}
... ...
package com.yohoufo.order.service.impl;
import com.yohobuy.ufo.model.order.bo.ButtonShowBo;
import com.yohobuy.ufo.model.order.bo.DepositDetailBo;
import com.yohobuy.ufo.model.order.bo.DepositProductBo;
import com.yohobuy.ufo.model.order.common.ButtonShow;
import com.yohobuy.ufo.model.order.constants.StorageDepositStatusEnum;
import com.yohoufo.common.helper.ImageUrlAssist;
import com.yohoufo.dal.order.SellerOrderGoodsMapper;
import com.yohoufo.dal.order.model.SellerOrderGoods;
import com.yohoufo.dal.order.model.StorageDeposit;
import com.yohoufo.dal.order.model.StorageDepositCount;
import com.yohoufo.dal.product.StorageDepositMapper;
import com.yohoufo.dal.product.model.Goods;
import com.yohoufo.dal.product.model.GoodsImages;
import com.yohoufo.dal.product.model.Product;
import com.yohoufo.order.service.DepositService;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
@Service
public class DepositServiceImpl implements DepositService {
private final Logger LOGGER = LoggerFactory.getLogger(DepositServiceImpl.class);
@Autowired
private StorageDepositMapper storageDepositMapper;
@Autowired
private SellerOrderGoodsMapper sellerOrderGoodsMapper;
@Override
public List<DepositProductBo> queryUserDoposit(Integer uid, Integer page, Integer limit) {
int count = storageDepositMapper.queryUserDepositProductCount(uid);
if (count == 0) {
return new ArrayList<>();
}
List<Integer> productIdList = storageDepositMapper.queryUserDepositProductId(uid, (page - 1) * limit, limit);
List<StorageDepositCount> countInfoList = storageDepositMapper.queryUserDepositProduct(uid, productIdList);
/*// 商品名称
List<Product> productList = productMapper.selectByIds(productIdList);
// 颜色
List<Goods> goodsList = goodsMapper.selectByProductIds(productIdList);
// 图片
List<GoodsImages> goodsImagesList = goodsImagesMapper.selectByGoodsIdList(goodsList.stream().map(Goods::getId).collect(Collectors.toList()));
Map<Integer, StorageDepositCount> countInfoMap = countInfoList.stream().map(Function.identity()).collect(Collectors.toMap(StorageDepositCount::getProductId, Function.identity()));
Map<Integer, Product> productMap = productList.stream().map(Function.identity()).collect(Collectors.toMap(Product::getId, Function.identity()));
Map<Integer, Goods> goodsMap = goodsList.stream().map(Function.identity()).collect(Collectors.toMap(Goods::getProductId, Function.identity()));
Map<Integer, GoodsImages> goodsImagesMap = goodsImagesList.stream().map(Function.identity()).collect(Collectors.toMap(GoodsImages::getProductId, Function.identity()));
List<DepositProductBo> result = new ArrayList<>();
for (Integer productId : productIdList) {
DepositProductBo bo = new DepositProductBo();
bo.setProductId(productId);
Product p = productMap.get(productId);
if (p != null) {
bo.setProductName(p.getProductName());
}
Goods g = goodsMap.get(productId);
if (g != null) {
bo.setColorName(StringUtils.isBlank(g.getGoodsName()) ? g.getColorName() : g.getGoodsName());
}
GoodsImages gi = goodsImagesMap.get(productId);
if (gi != null) {
bo.setPic(ImageUrlAssist.getAllProductPicUrl(gi.getImageUrl(), "goodsimg", "center", "d2hpdGU="));
}
StorageDepositCount countInfo = countInfoMap.get(productId);
if (countInfo != null) {
bo.setSizeCount(countInfo.getStorageIdCount());
bo.setStorageCount(countInfo.getStorageCount());
bo.setShelfStatus(countInfo.getStorageIdCount() == 0 ? "全部已上架" : ("有" + countInfo.getStorageIdCount() + "件未上架"));
}
result.add(bo);
}*/
return null;
}
@Override
public List<DepositDetailBo> queryUserDopositBackDetail(Integer uid, Integer page, Integer limit) {
int count = storageDepositMapper.queryUserDopositBackCount(uid);
if (count == 0) {
return new ArrayList<>();
}
// 召回或者到期退回的
List<StorageDeposit> depositList = storageDepositMapper.queryUserDopositBack(uid, (page - 1) * limit, limit);
List<DepositDetailBo> result = new ArrayList<>();
for (StorageDeposit depo : depositList) {
DepositDetailBo bo = new DepositDetailBo();
bo.setButtons(Arrays.asList(ButtonShowBo.detail()));
result.add(bo);
}
return result;
}
@Override
public List<DepositDetailBo> queryUserProductDopositDetail(Integer uid, Integer productId, Integer page, Integer limit) {
int count = storageDepositMapper.queryUserDopositBackCount(uid);
if (count == 0) {
return new ArrayList<>();
}
// 召回或者到期退回的
List<StorageDeposit> depositList = storageDepositMapper.queryUserDopositBack(uid, (page - 1) * limit, limit);
List<DepositDetailBo> result = new ArrayList<>();
/*for (StorageDeposit depo : depositList) {
DepositDetailBo bo = new DepositDetailBo();
if (depo.getStatus() > StorageDepositStatusEnum.HAS_OUT.getCode()) {
bo.setButtons(Arrays.asList(Button.delete()));
} else {
bo.setButtons(Arrays.asList(Button.detail()));
}
result.add(bo);
}*/
return result;
}
}
... ...