Authored by caoyan

二手

... ... @@ -5,16 +5,9 @@ import java.util.List;
import org.apache.ibatis.annotations.Param;
import com.yoho.product.model.SecondhandInfo;
import com.yoho.product.model.SecondhandReq;
public interface SecondhandInfoMapper {
int selectCountByStatus(@Param("status")Integer status);
int selectTotalByCondition(@Param("secondhandReq") SecondhandReq req);
List<SecondhandInfo> selectByCondition(@Param("secondhandReq") SecondhandReq req);
List<SecondhandInfo> selectBySkups(@Param("skupList")List<Integer> skupList);
int updateAuditInfoBySkup(SecondhandInfo secondhandInfo);
... ...
... ... @@ -18,8 +18,6 @@ public class SecondhandInfo {
private Integer createTime;
private Integer status;
private Integer auditUid;
private String auditName;
... ... @@ -76,14 +74,6 @@ public class SecondhandInfo {
this.createTime = createTime;
}
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
public Integer getAuditUid() {
return auditUid;
}
... ...
... ... @@ -16,4 +16,6 @@ public interface GoodsImagesMapper {
int deleteByGoodsId(Integer goodsId);
List<GoodsImages> selectByGoodsId(Integer goodsId);
List<GoodsImages> selectDefaultByGoodsIdList(List<Integer> goodsIdList);
}
\ No newline at end of file
... ...
... ... @@ -4,6 +4,8 @@ import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import com.yoho.product.model.SecondhandInfo;
import com.yoho.product.model.SecondhandReq;
import com.yoho.ufo.dal.model.ExportStoragePrice;
import com.yoho.ufo.dal.model.ExportStoragePriceInner;
import org.apache.ibatis.annotations.Param;
... ... @@ -76,5 +78,11 @@ public interface StoragePriceMapper {
List<StoragePrice> selectBySkupList(@Param("skupList") List<Integer> skupList);
int updateStatusBySkup(@Param("status") Integer status, @Param("skup") Integer skup);
int updateSecondhandStatusBySkup(@Param("status") Integer status, @Param("skup") Integer skup);
int selectSecondCntByStatus(@Param("status")Integer status);
int selectSecondTotalByCondition(@Param("secondhandReq") SecondhandReq req);
List<StoragePrice> selectSecondByCondition(@Param("secondhandReq") SecondhandReq req);
}
\ No newline at end of file
... ...
... ... @@ -45,4 +45,13 @@
from goods_images
where goods_id = #{goodsId,jdbcType=INTEGER}
</select>
<select id="selectDefaultByGoodsIdList" resultMap="BaseResultMap">
select id, goods_id, product_id, is_default, image_url, order_by
from goods_images
where is_default='Y' and goods_id in
<foreach collection="list" item="goodsId" open="(" close=")" separator=",">
#{goodsId}
</foreach>
</select>
</mapper>
\ No newline at end of file
... ...
... ... @@ -8,48 +8,15 @@
<result column="flaw_attr" property="flawAttr" jdbcType="VARCHAR" />
<result column="describe_info" property="describeInfo" jdbcType="VARCHAR" />
<result column="create_time" property="createTime" jdbcType="INTEGER" />
<result column="status" property="status" jdbcType="INTEGER" />
<result column="audit_uid" property="auditUid" jdbcType="INTEGER" />
<result column="audit_name" property="auditName" jdbcType="VARCHAR" />
<result column="audit_time" property="auditTime" jdbcType="INTEGER" />
<result column="reject_reason" property="rejectReason" jdbcType="VARCHAR" />
</resultMap>
<sql id="Base_Column_List" >
id, skup, flaw_id, flaw_attr, describe_info, create_time, status, audit_uid, audit_name, audit_time, reject_reason
id, skup, flaw_id, flaw_attr, describe_info, create_time, audit_uid, audit_name, audit_time, reject_reason
</sql>
<select id="selectCountByStatus" resultType="java.lang.Integer">
select count(1)
from secondhand_info where status != 0
<if test="status != null">
and status = #{status}
</if>
</select>
<sql id="Query_Order_Sql" >
<if test="secondhandReq.status != null">
and status = #{secondhandReq.status}
</if>
</sql>
<select id="selectTotalByCondition" resultType="java.lang.Integer" parameterType="com.yoho.product.model.SecondhandReq">
select count(1)
from secondhand_info
where status != 0
<include refid="Query_Order_Sql" />
</select>
<select id="selectByCondition" resultMap="BaseResultMap" parameterType="com.yoho.product.model.SecondhandReq">
select <include refid="Base_Column_List"></include>
from secondhand_info
where status != 0
<include refid="Query_Order_Sql" />
order by create_time desc
<if test="secondhandReq.start!=null and secondhandReq.size != null">
limit #{secondhandReq.start},#{secondhandReq.size}
</if>
</select>
<select id="selectBySkups" resultMap="BaseResultMap" >
select <include refid="Base_Column_List" />
from secondhand_info where skup in
... ... @@ -60,7 +27,7 @@
<update id="updateAuditInfoBySkup" parameterType="com.yoho.product.model.SecondhandInfo">
update secondhand_info
set status=#{status}, reject_reason=#{rejectReason},
set reject_reason=#{rejectReason},
audit_uid=#{auditUid}, audit_name=#{auditName}, audit_time=#{auditTime}
where skup=#{skup}
</update>
... ...
... ... @@ -371,7 +371,40 @@
</foreach>
</select>
<update id="updateStatusBySkup">
update storage_price set status=#{status}, update_time=unix_timestamp() where skup=#{skup}
<select id="selectSecondCntByStatus" resultType="java.lang.Integer">
select count(1)
from storage_price where pre_sale_flag in (5,6) and status in (10,11,1)
<if test="status != null">
and status = #{status}
</if>
</select>
<sql id="Query_Second_Sql" >
<if test="secondhandReq.status != null">
and status = #{secondhandReq.status}
</if>
</sql>
<select id="selectSecondTotalByCondition" resultType="java.lang.Integer" parameterType="com.yoho.product.model.SecondhandReq">
select count(1)
from storage_price
where pre_sale_flag in (5,6) and status in (10,11,1)
<include refid="Query_Second_Sql" />
</select>
<select id="selectSecondByCondition" resultMap="BaseResultMap" parameterType="com.yoho.product.model.SecondhandReq">
select id, skup, product_id, goods_id, storage_id, depot_num, seller_uid, price,
status, update_time, create_time, pre_sale_flag
from storage_price
where pre_sale_flag in (5,6) and status in (10,11,1)
<include refid="Query_Second_Sql" />
order by create_time desc
<if test="secondhandReq.start!=null and secondhandReq.size != null">
limit #{secondhandReq.start},#{secondhandReq.size}
</if>
</select>
<update id="updateSecondhandStatusBySkup">
update storage_price set status=#{status}, update_time=unix_timestamp() where skup=#{skup} and status=10
</update>
</mapper>
\ No newline at end of file
... ...
... ... @@ -26,10 +26,13 @@ import com.yoho.product.model.SecondhandImages;
import com.yoho.product.model.SecondhandInfo;
import com.yoho.product.model.SecondhandReq;
import com.yoho.product.model.SecondhandRsp;
import com.yoho.ufo.dal.GoodsImagesMapper;
import com.yoho.ufo.dal.ProductMapper;
import com.yoho.ufo.dal.StoragePriceMapper;
import com.yoho.ufo.dal.model.GoodsImages;
import com.yoho.ufo.dal.model.Product;
import com.yoho.ufo.dal.model.StoragePrice;
import com.yoho.ufo.exception.CommonException;
import com.yoho.ufo.service.ISecondhandProductService;
import com.yoho.ufo.service.model.PageResponseBO;
import com.yoho.ufo.util.DateUtil;
... ... @@ -62,6 +65,9 @@ public class SecondhandProductService implements ISecondhandProductService{
private SecondhandFlawMapper secondhandFlawMapper;
@Autowired
private GoodsImagesMapper goodsImagesMapper;
@Autowired
private ServiceCaller serviceCaller;
private static final Integer STATUS_NEW = 0;
... ... @@ -75,10 +81,10 @@ public class SecondhandProductService implements ISecondhandProductService{
@Override
public Map<String, Integer> getCountByStatus(){
int totalNum = secondhandInfoMapper.selectCountByStatus(null);
int toBeAuditedNum = secondhandInfoMapper.selectCountByStatus(STATUS_WAIT_TO_BE_AUDITED);
int auditPassNum = secondhandInfoMapper.selectCountByStatus(STATUS_AUDIT_PASS);
int auditRejectNum = secondhandInfoMapper.selectCountByStatus(STATUS_AUDIT_REJECT);
int totalNum = storagePriceMapper.selectSecondCntByStatus(null);
int toBeAuditedNum = storagePriceMapper.selectSecondCntByStatus(STATUS_WAIT_TO_BE_AUDITED);
int auditPassNum = storagePriceMapper.selectSecondCntByStatus(STATUS_AUDIT_PASS);
int auditRejectNum = storagePriceMapper.selectSecondCntByStatus(STATUS_AUDIT_REJECT);
Map<String, Integer> resultMap = Maps.newHashMap();
resultMap.put("totalNum", totalNum);
... ... @@ -92,23 +98,26 @@ public class SecondhandProductService implements ISecondhandProductService{
@Override
public PageResponseBO<SecondhandRsp> querySecondhandSkupList(SecondhandReq req) {
int total = secondhandInfoMapper.selectTotalByCondition(req);
int total = storagePriceMapper.selectSecondTotalByCondition(req);
if(total == 0) {
return null;
}
List<SecondhandInfo> infoList = secondhandInfoMapper.selectByCondition(req);
if(CollectionUtils.isEmpty(infoList)) {
List<StoragePrice> storagePriceList = storagePriceMapper.selectSecondByCondition(req);
if(CollectionUtils.isEmpty(storagePriceList)) {
return null;
}
List<Integer> skupList = storagePriceList.stream().map(StoragePrice::getSkup).collect(Collectors.toList());
//查询secondhand_info
List<SecondhandInfo> infoList = secondhandInfoMapper.selectBySkups(skupList);
//查询secondhand_images
List<Integer> skupList = infoList.stream().map(SecondhandInfo::getSkup).collect(Collectors.toList());
List<SecondhandImages> imageList = secondhandImagesMapper.selectBySkups(skupList);
Map<Integer, List<SecondhandImages>> skupImageMap = imageList.stream().collect(Collectors.groupingBy(SecondhandImages::getSkup));
//查询storage_price
List<StoragePrice> storagePriceList = storagePriceMapper.selectBySkupList(skupList);
Map<Integer, StoragePrice> storagePriceMap = storagePriceList.stream().collect(Collectors.toMap(StoragePrice::getSkup, s->s));
//查询seller_order_goods
... ... @@ -125,8 +134,13 @@ public class SecondhandProductService implements ISecondhandProductService{
List<SecondhandFlaw> flawList = secondhandFlawMapper.selectBatchByIds(getFlawIdList(flawIdStrList));
Map<Integer, String> flawMap = flawList.stream().collect(Collectors.toMap(SecondhandFlaw::getId, SecondhandFlaw::getName));
//查询goods_images
List<Integer> goodsIdList = storagePriceList.stream().map(StoragePrice::getGoodsId).collect(Collectors.toList());
List<GoodsImages> goodsImagesList = goodsImagesMapper.selectDefaultByGoodsIdList(goodsIdList);
Map<Integer, String> goodsIdImageMap = goodsImagesList.stream().collect(Collectors.toMap(GoodsImages::getGoodsId, GoodsImages::getImageUrl));
//组装
List<SecondhandRsp> respList = convertToResp(infoList, skupImageMap, storagePriceMap, sellerGoodsMap, productIdNameMap, flawMap);
List<SecondhandRsp> respList = convertToResp(infoList, skupImageMap, storagePriceMap, sellerGoodsMap, productIdNameMap, flawMap, goodsIdImageMap);
PageResponseBO<SecondhandRsp> result=new PageResponseBO<>();
result.setList(respList);
... ... @@ -139,10 +153,15 @@ public class SecondhandProductService implements ISecondhandProductService{
@Override
public int updateStatus(SecondhandReq req) {
//查询storage_price中status
Integer status = storagePriceMapper.selectBySkup(req.getSkup()).getStatus();
if(!ProductSkupStatusEnum.CHECKING.getStatus().equals(status)) {//如果不是待审核状态,直接返回
throw new CommonException(400, "不是待审核状态,当前状态是"+ProductSkupStatusEnum.getTypeName(status));
}
SecondhandInfo auditInfo = new SecondhandInfo();
UserHelper userInfo = new UserHelper();
auditInfo.setSkup(req.getSkup());
auditInfo.setStatus(req.getStatus());
auditInfo.setRejectReason(req.getRejectReason());
auditInfo.setAuditName(userInfo.getUserName());
auditInfo.setAuditUid(userInfo.getUserId());
... ... @@ -152,7 +171,7 @@ public class SecondhandProductService implements ISecondhandProductService{
return num;
}
//更新storage_price
num = storagePriceMapper.updateStatusBySkup(req.getStatus(), req.getSkup());
num = storagePriceMapper.updateSecondhandStatusBySkup(req.getStatus(), req.getSkup());
if(num == 0) {
return num;
}
... ... @@ -204,7 +223,7 @@ public class SecondhandProductService implements ISecondhandProductService{
private List<SecondhandRsp> convertToResp(List<SecondhandInfo> infoList, Map<Integer, List<SecondhandImages>> skupImageMap,
Map<Integer, StoragePrice> storagePriceMap, Map<Integer, SellerOrderGoods> sellerGoodsMap,
Map<Integer, String> productIdNameMap, Map<Integer, String> flawMap){
Map<Integer, String> productIdNameMap, Map<Integer, String> flawMap, Map<Integer, String> goodsIdImageMap){
List<SecondhandRsp> respList = Lists.newArrayList();
for(SecondhandInfo item : infoList) {
SecondhandRsp rsp = new SecondhandRsp();
... ... @@ -225,13 +244,13 @@ public class SecondhandProductService implements ISecondhandProductService{
if(null == sellerGoods) {
continue;
}
rsp.setProductImage(ImagesHelper.getImageAbsoluteUrl(sellerGoods.getImageUrl(), "goodsimg"));
rsp.setProductImage(ImagesHelper.getImageAbsoluteUrl(goodsIdImageMap.get(storagePrice.getGoodsId()), "goodsimg"));
rsp.setColorName(sellerGoods.getColorName());
rsp.setSizeName(sellerGoods.getSizeName());
rsp.setSellerUid(storagePrice.getSellerUid());
rsp.setPrice(String.valueOf(storagePrice.getPrice()));
rsp.setStatus(item.getStatus());
rsp.setStatusStr(ProductSkupStatusEnum.getTypeName(item.getStatus()));
rsp.setStatus(storagePrice.getStatus());
// rsp.setStatusStr(ProductSkupStatusEnum.getTypeName(storagePrice.getStatus()));
rsp.setCreateTimeStr(DateUtil.getDateFormatFromInt(item.getCreateTime(), "yyyy-MM-dd HH:mm:ss"));
rsp.setAuditTimeStr(null == item.getAuditTime() ? "" : DateUtil.getDateFormatFromInt(item.getAuditTime(), "yyyy-MM-dd HH:mm:ss"));
rsp.setAuditName(null == item.getAuditName() ? "" : item.getAuditName());
... ...
... ... @@ -288,7 +288,12 @@ function getTableColumn() {
width: 20,
align: "center",
formatter: function (value, rowData, rowIndex) {
var auditInfo = rowData.statusStr;
var auditInfo = "待审核";
if(rowData.status == 11){
auditInfo = "审核不通过";
}else if(rowData.status == 1){
auditInfo = "审核通过";
}
if(rowData.status==11){//审核不通过
auditInfo += "(<font color='red' >原因:"+ rowData.rejectReason + "</font>)"
}
... ...