Authored by Lixiaodi

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

# Conflicts:
#	dal/src/main/java/com/yohoufo/dal/order/SellerWalletMapper.java
#	dal/src/main/resources/META-INF/mybatis/order/SellerWalletMapper.xml
Showing 21 changed files with 729 additions and 180 deletions
@@ -5,7 +5,6 @@ import org.apache.ibatis.annotations.Param; @@ -5,7 +5,6 @@ import org.apache.ibatis.annotations.Param;
5 import com.yohoufo.dal.order.model.SellerWallet; 5 import com.yohoufo.dal.order.model.SellerWallet;
6 6
7 public interface SellerWalletMapper { 7 public interface SellerWalletMapper {
8 - int deleteByPrimaryKey(Integer id);  
9 8
10 int insert(SellerWallet record); 9 int insert(SellerWallet record);
11 10
@@ -17,10 +16,14 @@ public interface SellerWalletMapper { @@ -17,10 +16,14 @@ public interface SellerWalletMapper {
17 16
18 int updateByPrimaryKey(SellerWallet record); 17 int updateByPrimaryKey(SellerWallet record);
19 18
  19 +<<<<<<< HEAD
20 SellerWallet selectByUidAndType(@Param("uid") Integer uid, @Param("type") int type); 20 SellerWallet selectByUidAndType(@Param("uid") Integer uid, @Param("type") int type);
21 21
22 int addMoney(SellerWallet sw); 22 int addMoney(SellerWallet sw);
23 23
24 int returnMoney(SellerWallet sw); 24 int returnMoney(SellerWallet sw);
25 25
  26 +=======
  27 + SellerWallet selectByUidNType(SellerWallet condition);
  28 +>>>>>>> 988aa54ed0e0d3be7e1329ab598ffaf885dfe261
26 } 29 }
  1 +package com.yohoufo.dal.order;
  2 +
  3 +import com.yohoufo.dal.order.model.SkupBatch;
  4 +
  5 +public interface SkupBatchMapper {
  6 + int deleteByPrimaryKey(Long id);
  7 +
  8 + int insert(SkupBatch record);
  9 +
  10 + int insertSelective(SkupBatch record);
  11 +
  12 + SkupBatch selectByPrimaryKey(Long id);
  13 +
  14 + int updateByPrimaryKeySelective(SkupBatch record);
  15 +
  16 + int updateByPrimaryKey(SkupBatch record);
  17 +}
  1 +package com.yohoufo.dal.order.model;
  2 +
  3 +public class SkupBatch {
  4 + private Long id;
  5 +
  6 + private Integer uid;
  7 +
  8 + private Integer num;
  9 +
  10 + private Integer createTime;
  11 +
  12 + public Long getId() {
  13 + return id;
  14 + }
  15 +
  16 + public void setId(Long id) {
  17 + this.id = id;
  18 + }
  19 +
  20 + public Integer getUid() {
  21 + return uid;
  22 + }
  23 +
  24 + public void setUid(Integer uid) {
  25 + this.uid = uid;
  26 + }
  27 +
  28 + public Integer getNum() {
  29 + return num;
  30 + }
  31 +
  32 + public void setNum(Integer num) {
  33 + this.num = num;
  34 + }
  35 +
  36 + public Integer getCreateTime() {
  37 + return createTime;
  38 + }
  39 +
  40 + public void setCreateTime(Integer createTime) {
  41 + this.createTime = createTime;
  42 + }
  43 +}
@@ -24,4 +24,6 @@ public interface StorageMapper { @@ -24,4 +24,6 @@ public interface StorageMapper {
24 int addStorageNum(@Param("storageId")Integer storageId, @Param("storageNum")Integer storageNum); 24 int addStorageNum(@Param("storageId")Integer storageId, @Param("storageNum")Integer storageNum);
25 25
26 List<Storage> selectByGoodsId(Integer goodsId); 26 List<Storage> selectByGoodsId(Integer goodsId);
  27 +
  28 + int batchAddStorageNum(@Param("storageList")List<Storage> storageList);
27 } 29 }
@@ -10,6 +10,8 @@ public interface StoragePriceMapper { @@ -10,6 +10,8 @@ public interface StoragePriceMapper {
10 int deleteByPrimaryKey(Integer id); 10 int deleteByPrimaryKey(Integer id);
11 11
12 int insert(StoragePrice record); 12 int insert(StoragePrice record);
  13 +
  14 + int insertBatch(@Param("storagePriceList")List<StoragePrice> storagePriceList);
13 15
14 StoragePrice selectByPrimaryKey(Integer id); 16 StoragePrice selectByPrimaryKey(Integer id);
15 17
@@ -25,9 +27,13 @@ public interface StoragePriceMapper { @@ -25,9 +27,13 @@ public interface StoragePriceMapper {
25 27
26 int updateStatus(@Param("skup")Integer skup, @Param("status")Integer status, @Param("beforeStatus")Integer beforeStatus); 28 int updateStatus(@Param("skup")Integer skup, @Param("status")Integer status, @Param("beforeStatus")Integer beforeStatus);
27 29
  30 + int batchUpdateStatus(@Param("skupList")List<Integer> skupList, @Param("status")Integer status);
  31 +
28 int updateDepotNum(@Param("skup")Integer skup, @Param("depotNum")Integer depotNum); 32 int updateDepotNum(@Param("skup")Integer skup, @Param("depotNum")Integer depotNum);
29 33
30 StoragePrice selectLeastPrice(Integer storageId); 34 StoragePrice selectLeastPrice(Integer storageId);
31 35
32 List<StoragePrice> selectByStorageIds(List<Integer> storageIds); 36 List<StoragePrice> selectByStorageIds(List<Integer> storageIds);
  37 +
  38 + List<StoragePrice> selectBySkupList(@Param("skupList")List<Integer> skupList);
33 } 39 }
@@ -24,6 +24,15 @@ @@ -24,6 +24,15 @@
24 where id = #{id,jdbcType=INTEGER} 24 where id = #{id,jdbcType=INTEGER}
25 </delete> 25 </delete>
26 <insert id="insert" parameterType="com.yohoufo.dal.order.model.SellerWallet" keyColumn="id" keyProperty="id" useGeneratedKeys="true"> 26 <insert id="insert" parameterType="com.yohoufo.dal.order.model.SellerWallet" keyColumn="id" keyProperty="id" useGeneratedKeys="true">
  27 +
  28 + <select id="selectByUidNType" resultMap="BaseResultMap" parameterType="com.yohoufo.dal.order.model.SellerWallet" >
  29 + select
  30 + <include refid="Base_Column_List" />
  31 + from seller_wallet
  32 + where uid = #{uid,jdbcType=INTEGER} and `type` = #{type,jdbcType=TINYINT} limit 1
  33 + </select>
  34 +
  35 + <insert id="insert" parameterType="com.yohoufo.dal.order.model.SellerWallet" >
27 insert into seller_wallet (id, uid, amount, 36 insert into seller_wallet (id, uid, amount,
28 status, type, create_time, 37 status, type, create_time,
29 update_time) 38 update_time)
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3 +<mapper namespace="com.yohoufo.dal.order.SkupBatchMapper">
  4 + <resultMap id="BaseResultMap" type="com.yohoufo.dal.order.model.SkupBatch">
  5 + <id column="id" jdbcType="BIGINT" property="id" />
  6 + <result column="uid" jdbcType="INTEGER" property="uid" />
  7 + <result column="num" jdbcType="INTEGER" property="num" />
  8 + <result column="create_time" jdbcType="INTEGER" property="createTime" />
  9 + </resultMap>
  10 + <sql id="Base_Column_List">
  11 + id, uid, num, create_time
  12 + </sql>
  13 + <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
  14 + select
  15 + <include refid="Base_Column_List" />
  16 + from skup_batch
  17 + where id = #{id,jdbcType=BIGINT}
  18 + </select>
  19 + <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
  20 + delete from skup_batch
  21 + where id = #{id,jdbcType=BIGINT}
  22 + </delete>
  23 + <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.yohoufo.dal.order.model.SkupBatch" useGeneratedKeys="true">
  24 + insert into skup_batch (uid, num, create_time
  25 + )
  26 + values (#{uid,jdbcType=INTEGER}, #{num,jdbcType=INTEGER}, #{createTime,jdbcType=INTEGER}
  27 + )
  28 + </insert>
  29 + <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.yohoufo.dal.order.model.SkupBatch" useGeneratedKeys="true">
  30 + insert into skup_batch
  31 + <trim prefix="(" suffix=")" suffixOverrides=",">
  32 + <if test="uid != null">
  33 + uid,
  34 + </if>
  35 + <if test="num != null">
  36 + num,
  37 + </if>
  38 + <if test="createTime != null">
  39 + create_time,
  40 + </if>
  41 + </trim>
  42 + <trim prefix="values (" suffix=")" suffixOverrides=",">
  43 + <if test="uid != null">
  44 + #{uid,jdbcType=INTEGER},
  45 + </if>
  46 + <if test="num != null">
  47 + #{num,jdbcType=INTEGER},
  48 + </if>
  49 + <if test="createTime != null">
  50 + #{createTime,jdbcType=INTEGER},
  51 + </if>
  52 + </trim>
  53 + </insert>
  54 + <update id="updateByPrimaryKeySelective" parameterType="com.yohoufo.dal.order.model.SkupBatch">
  55 + update skup_batch
  56 + <set>
  57 + <if test="uid != null">
  58 + uid = #{uid,jdbcType=INTEGER},
  59 + </if>
  60 + <if test="num != null">
  61 + num = #{num,jdbcType=INTEGER},
  62 + </if>
  63 + <if test="createTime != null">
  64 + create_time = #{createTime,jdbcType=INTEGER},
  65 + </if>
  66 + </set>
  67 + where id = #{id,jdbcType=BIGINT}
  68 + </update>
  69 + <update id="updateByPrimaryKey" parameterType="com.yohoufo.dal.order.model.SkupBatch">
  70 + update skup_batch
  71 + set uid = #{uid,jdbcType=INTEGER},
  72 + num = #{num,jdbcType=INTEGER},
  73 + create_time = #{createTime,jdbcType=INTEGER}
  74 + where id = #{id,jdbcType=BIGINT}
  75 + </update>
  76 +</mapper>
@@ -62,5 +62,25 @@ @@ -62,5 +62,25 @@
62 update_time = unix_timestamp() 62 update_time = unix_timestamp()
63 where id = #{storageId,jdbcType=INTEGER} 63 where id = #{storageId,jdbcType=INTEGER}
64 </update> 64 </update>
65 - 65 + <update id="batchAddStorageNum" parameterType="java.util.List">
  66 + update storage
  67 + <trim prefix="set" suffixOverrides=",">
  68 + <trim prefix="storage_num =case" suffix="end,">
  69 + <foreach collection="storageList" item="item" index="index">
  70 + <if test="item.storageNum!=null">
  71 + when id=#{item.id,jdbcType=INTEGER} then storage_num + #{item.storageNum,jdbcType=INTEGER}
  72 + </if>
  73 + </foreach>
  74 + </trim>
  75 + <trim prefix="update_time =case" suffix="end,">
  76 + <foreach collection="storageList" item="item" index="index">
  77 + when id=#{item.id,jdbcType=INTEGER} then unix_timestamp()
  78 + </foreach>
  79 + </trim>
  80 + </trim>
  81 + where
  82 + <foreach collection="storageList" separator="or" item="item" index="index" >
  83 + id= #{item.id,jdbcType=INTEGER}
  84 + </foreach>
  85 + </update>
66 </mapper> 86 </mapper>
@@ -28,6 +28,21 @@ @@ -28,6 +28,21 @@
28 #{price,jdbcType=DECIMAL}, #{status,jdbcType=INTEGER}, #{updateTime,jdbcType=INTEGER}, 28 #{price,jdbcType=DECIMAL}, #{status,jdbcType=INTEGER}, #{updateTime,jdbcType=INTEGER},
29 #{createTime,jdbcType=INTEGER}) 29 #{createTime,jdbcType=INTEGER})
30 </insert> 30 </insert>
  31 +
  32 + <insert id="insertBatch">
  33 + insert into storage_price (skup, product_id, goods_id,
  34 + storage_id, depot_num, seller_uid,
  35 + price, status, update_time,
  36 + create_time)
  37 + values
  38 + <foreach collection="storagePriceList" item="item" index="index" separator="," >
  39 + (#{item.skup,jdbcType=INTEGER}, #{item.productId,jdbcType=INTEGER},
  40 + #{item.goodsId,jdbcType=INTEGER},#{item.storageId,jdbcType=INTEGER}, #{item.depotNum,jdbcType=INTEGER}, #{item.sellerUid,jdbcType=INTEGER},
  41 + #{item.price,jdbcType=DECIMAL}, #{item.status,jdbcType=INTEGER}, #{item.updateTime,jdbcType=INTEGER},
  42 + #{item.createTime,jdbcType=INTEGER})
  43 + </foreach>
  44 + </insert>
  45 +
31 <update id="updateByPrimaryKey" parameterType="com.yohoufo.dal.product.model.StoragePrice"> 46 <update id="updateByPrimaryKey" parameterType="com.yohoufo.dal.product.model.StoragePrice">
32 update storage_price 47 update storage_price
33 set skup = #{skup,jdbcType=INTEGER}, 48 set skup = #{skup,jdbcType=INTEGER},
@@ -81,6 +96,16 @@ @@ -81,6 +96,16 @@
81 #{item} 96 #{item}
82 </foreach> 97 </foreach>
83 </select> 98 </select>
  99 + <select id="selectBySkupList" resultMap="BaseResultMap">
  100 + select id, skup, product_id, goods_id, storage_id, depot_num, seller_uid, price, status,
  101 + update_time, create_time
  102 + from storage_price
  103 + where skup in
  104 + <foreach item="item" index="index" collection="skupList"
  105 + open="(" separator="," close=")">
  106 + #{item}
  107 + </foreach>
  108 + </select>
84 <update id="updateStatus"> 109 <update id="updateStatus">
85 update storage_price set status = #{status,jdbcType=INTEGER}, 110 update storage_price set status = #{status,jdbcType=INTEGER},
86 update_time = unix_timestamp() 111 update_time = unix_timestamp()
@@ -95,5 +120,12 @@ @@ -95,5 +120,12 @@
95 where skup = #{skup,jdbcType=INTEGER} 120 where skup = #{skup,jdbcType=INTEGER}
96 and status = 100 121 and status = 100
97 </update> 122 </update>
98 - 123 + <update id="batchUpdateStatus">
  124 + update storage_price set status = #{status,jdbcType=INTEGER},
  125 + update_time = unix_timestamp()
  126 + where skup in
  127 + <foreach item="skup" index="index" collection="skupList" open="(" separator="," close=")">
  128 + #{skup}
  129 + </foreach>
  130 + </update>
99 </mapper> 131 </mapper>
@@ -10,7 +10,6 @@ import com.yohoufo.common.exception.GatewayException; @@ -10,7 +10,6 @@ import com.yohoufo.common.exception.GatewayException;
10 import com.yohoufo.dal.order.model.SellerOrder; 10 import com.yohoufo.dal.order.model.SellerOrder;
11 import com.yohoufo.order.model.response.OrderSubmitResp; 11 import com.yohoufo.order.model.response.OrderSubmitResp;
12 import com.yohoufo.order.service.handler.SellerOrderComputeHandler; 12 import com.yohoufo.order.service.handler.SellerOrderComputeHandler;
13 -import com.yohoufo.order.service.impl.SellerOrderCancelService;  
14 import com.yohoufo.order.service.impl.SellerOrderService; 13 import com.yohoufo.order.service.impl.SellerOrderService;
15 import org.slf4j.Logger; 14 import org.slf4j.Logger;
16 import org.slf4j.LoggerFactory; 15 import org.slf4j.LoggerFactory;
@@ -50,7 +49,8 @@ public class SellerOrderController { @@ -50,7 +49,8 @@ public class SellerOrderController {
50 @RequestParam(name = "storage_id", required = true)int storage_id, 49 @RequestParam(name = "storage_id", required = true)int storage_id,
51 @RequestParam(name="price", required = true)String price, 50 @RequestParam(name="price", required = true)String price,
52 @RequestParam(name="num", defaultValue = "1", required = false)int num) throws GatewayException { 51 @RequestParam(name="num", defaultValue = "1", required = false)int num) throws GatewayException {
53 - SellerOrderComputeReq req = SellerOrderComputeReq.builder().uid(uid).storageId(storage_id).price(price).build(); 52 + SellerOrderComputeReq req = SellerOrderComputeReq.builder().uid(uid).storageId(storage_id).price(price)
  53 + .num(num).build();
54 logger.info("in ufo.sellerOrder.computePublishPrd, req {}", req); 54 logger.info("in ufo.sellerOrder.computePublishPrd, req {}", req);
55 SoldPrdComputeBo computeBo = sellerOrderService.computePublishPrd(req); 55 SoldPrdComputeBo computeBo = sellerOrderService.computePublishPrd(req);
56 return new ApiResponse.ApiResponseBuilder().code(200).data(computeBo).message("算费成功").build(); 56 return new ApiResponse.ApiResponseBuilder().code(200).data(computeBo).message("算费成功").build();
@@ -96,11 +96,12 @@ public class SellerOrderController { @@ -96,11 +96,12 @@ public class SellerOrderController {
96 @ResponseBody 96 @ResponseBody
97 public ApiResponse batchCancel(@RequestParam(name = "uid", required = true)int uid, 97 public ApiResponse batchCancel(@RequestParam(name = "uid", required = true)int uid,
98 @RequestParam(name = "batchNo", required = true)String batchNo, 98 @RequestParam(name = "batchNo", required = true)String batchNo,
99 - @RequestParam(name="num", defaultValue = "1", required = false)int num 99 + @RequestParam(name="num", defaultValue = "1", required = false)int num,
  100 + @RequestParam(name = "skupList", required = true)String skupList
100 101
101 ) throws GatewayException { 102 ) throws GatewayException {
102 SellerOrderBatchCancelReq req = SellerOrderBatchCancelReq.builder() 103 SellerOrderBatchCancelReq req = SellerOrderBatchCancelReq.builder()
103 - .uid(uid).batchNo(batchNo).storageNum(num) 104 + .uid(uid).batchNo(batchNo).storageNum(num).skupList(skupList)
104 .build(); 105 .build();
105 logger.info("in ufo.sellerOrder.batchCancel, req {}", req); 106 logger.info("in ufo.sellerOrder.batchCancel, req {}", req);
106 boolean result = sellerOrderService.batchCancel(req); 107 boolean result = sellerOrderService.batchCancel(req);
@@ -196,11 +197,12 @@ public class SellerOrderController { @@ -196,11 +197,12 @@ public class SellerOrderController {
196 public ApiResponse batchChangePrice(@RequestParam(name = "uid", required = true)int uid, 197 public ApiResponse batchChangePrice(@RequestParam(name = "uid", required = true)int uid,
197 @RequestParam(name = "price", required = true)String price, 198 @RequestParam(name = "price", required = true)String price,
198 @RequestParam(name = "batchNo", required = true)String batchNo, 199 @RequestParam(name = "batchNo", required = true)String batchNo,
199 - @RequestParam(name="num", defaultValue = "1", required = false)int num 200 + @RequestParam(name = "skupList", required = true)String skupList
  201 +
200 ) throws GatewayException { 202 ) throws GatewayException {
201 BatchChangePriceReq req = BatchChangePriceReq.builder() 203 BatchChangePriceReq req = BatchChangePriceReq.builder()
202 - .uid(uid).price(price).storageNum(num)  
203 - .batchNo(batchNo) 204 + .uid(uid).price(price)
  205 + .batchNo(batchNo).skupList(skupList)
204 .build(); 206 .build();
205 logger.info("in ufo.sellerOrder.batchChangePrice, req {}", req); 207 logger.info("in ufo.sellerOrder.batchChangePrice, req {}", req);
206 BatchChangePriceResp result = sellerOrderService.batchChangePrice(req); 208 BatchChangePriceResp result = sellerOrderService.batchChangePrice(req);
@@ -4,10 +4,7 @@ import com.alibaba.fastjson.JSONObject; @@ -4,10 +4,7 @@ import com.alibaba.fastjson.JSONObject;
4 import com.yoho.error.ServiceError; 4 import com.yoho.error.ServiceError;
5 import com.yoho.error.exception.ServiceException; 5 import com.yoho.error.exception.ServiceException;
6 import com.yohobuy.ufo.model.order.bo.SoldPrdComputeBo; 6 import com.yohobuy.ufo.model.order.bo.SoldPrdComputeBo;
7 -import com.yohobuy.ufo.model.order.common.OrderCodeType;  
8 -import com.yohobuy.ufo.model.order.common.OrderStatus;  
9 -import com.yohobuy.ufo.model.order.common.SkupStatus;  
10 -import com.yohobuy.ufo.model.order.common.TabType; 7 +import com.yohobuy.ufo.model.order.common.*;
11 import com.yohobuy.ufo.model.order.resp.ExpressInfoDetail; 8 import com.yohobuy.ufo.model.order.resp.ExpressInfoDetail;
12 import com.yohobuy.ufo.model.order.resp.ExpressInfoRespBo; 9 import com.yohobuy.ufo.model.order.resp.ExpressInfoRespBo;
13 import com.yohoufo.common.constant.ExpressInfoConstant; 10 import com.yohoufo.common.constant.ExpressInfoConstant;
@@ -26,6 +23,7 @@ import com.yohoufo.order.model.response.GoodsInfo; @@ -26,6 +23,7 @@ import com.yohoufo.order.model.response.GoodsInfo;
26 import com.yohoufo.order.model.response.OrderDetailInfo; 23 import com.yohoufo.order.model.response.OrderDetailInfo;
27 import com.yohoufo.order.service.IOrderDetailService; 24 import com.yohoufo.order.service.IOrderDetailService;
28 import com.yohoufo.order.service.cache.OrderCacheService; 25 import com.yohoufo.order.service.cache.OrderCacheService;
  26 +import com.yohoufo.order.service.proxy.UserProxyService;
29 import com.yohoufo.order.service.support.codegenerator.OrderCodeGenerator; 27 import com.yohoufo.order.service.support.codegenerator.OrderCodeGenerator;
30 import com.yohoufo.order.service.support.codegenerator.bean.CodeMeta; 28 import com.yohoufo.order.service.support.codegenerator.bean.CodeMeta;
31 29
@@ -73,6 +71,9 @@ public class SellerOrderDetailService extends AbsOrderDetailService implements I @@ -73,6 +71,9 @@ public class SellerOrderDetailService extends AbsOrderDetailService implements I
73 @Autowired 71 @Autowired
74 private OrderCacheService orderCacheService; 72 private OrderCacheService orderCacheService;
75 73
  74 + @Autowired
  75 + private UserProxyService userProxyService;
  76 +
76 private static List<SkupStatus> noNeedShowOrderCode = Arrays.asList(SkupStatus.CAN_NOT_SELL,SkupStatus.CAN_SELL, 77 private static List<SkupStatus> noNeedShowOrderCode = Arrays.asList(SkupStatus.CAN_NOT_SELL,SkupStatus.CAN_SELL,
77 SkupStatus.SELF_CANCEL_PAY, SkupStatus.TIMEOUT_CANCEL, 78 SkupStatus.SELF_CANCEL_PAY, SkupStatus.TIMEOUT_CANCEL,
78 SkupStatus.SELLER_CANCEL_SELL, SkupStatus.YOHO_CANCEL_SELL); 79 SkupStatus.SELLER_CANCEL_SELL, SkupStatus.YOHO_CANCEL_SELL);
@@ -103,12 +104,14 @@ public class SellerOrderDetailService extends AbsOrderDetailService implements I @@ -103,12 +104,14 @@ public class SellerOrderDetailService extends AbsOrderDetailService implements I
103 logger.warn("can not find seller order, req {}", orderRequest); 104 logger.warn("can not find seller order, req {}", orderRequest);
104 return null; 105 return null;
105 } 106 }
  107 + boolean isEntry = userProxyService.isEntryShop(uid);
  108 + SellerType sellerType = isEntry ? SellerType.ENTRY : SellerType.COMMON;
106 Integer skup = sellerOrder.getSkup(); 109 Integer skup = sellerOrder.getSkup();
107 SellerOrderGoods sellerOrderGoods = sellerOrderGoodsMapper.selectByPrimaryKey(skup); 110 SellerOrderGoods sellerOrderGoods = sellerOrderGoodsMapper.selectByPrimaryKey(skup);
108 Integer skupStatusCode = sellerOrderGoods.getStatus(); 111 Integer skupStatusCode = sellerOrderGoods.getStatus();
109 SkupStatus skupStatus = SkupStatus.getSkupStatus(skupStatusCode); 112 SkupStatus skupStatus = SkupStatus.getSkupStatus(skupStatusCode);
110 AddressInfo addressInfo = sellerAddressService.getHiddenAddressInfo(uid, skup); 113 AddressInfo addressInfo = sellerAddressService.getHiddenAddressInfo(uid, skup);
111 - orderDetailInfo = buildOrderDetail(sellerOrder, skupStatus, sellerOrderGoods, addressInfo); 114 + orderDetailInfo = buildOrderDetail(sellerOrder, skupStatus, sellerOrderGoods, addressInfo, sellerType);
112 }else{ 115 }else{
113 orderDetailInfo = super.getOrderDetail(orderRequest); 116 orderDetailInfo = super.getOrderDetail(orderRequest);
114 } 117 }
@@ -273,12 +276,13 @@ public class SellerOrderDetailService extends AbsOrderDetailService implements I @@ -273,12 +276,13 @@ public class SellerOrderDetailService extends AbsOrderDetailService implements I
273 } 276 }
274 277
275 private OrderDetailInfo buildOrderDetail(SellerOrder order, SkupStatus skupStatus, 278 private OrderDetailInfo buildOrderDetail(SellerOrder order, SkupStatus skupStatus,
276 - SellerOrderGoods sellerOrderGoods, AddressInfo addressInfo 279 + SellerOrderGoods sellerOrderGoods, AddressInfo addressInfo,
  280 + SellerType sellerType
277 ) { 281 ) {
278 OrderDetailInfo orderDetailInfo = new OrderDetailInfo(); 282 OrderDetailInfo orderDetailInfo = new OrderDetailInfo();
279 orderDetailInfo.setUid(order.getUid()); 283 orderDetailInfo.setUid(order.getUid());
280 orderDetailInfo.setOrderCode(getOrderCode(skupStatus, order)); 284 orderDetailInfo.setOrderCode(getOrderCode(skupStatus, order));
281 - orderDetailInfo.setButtons(skupStatus.getDetailButtons()); 285 + orderDetailInfo.setButtons(skupStatus.getDetailButtons(sellerType));
282 orderDetailInfo.setSubmitOrderTimeStr(DateUtil.formatDate(order.getCreateTime(), DateUtil.yyyy_MM_dd_HH_mm_SS)); 286 orderDetailInfo.setSubmitOrderTimeStr(DateUtil.formatDate(order.getCreateTime(), DateUtil.yyyy_MM_dd_HH_mm_SS));
283 orderDetailInfo.setUserAddress(addressInfo); 287 orderDetailInfo.setUserAddress(addressInfo);
284 //卖家 288 //卖家
@@ -5,6 +5,7 @@ import com.yoho.error.exception.ServiceException; @@ -5,6 +5,7 @@ import com.yoho.error.exception.ServiceException;
5 import com.yohobuy.ufo.model.order.bo.GoodsInfo; 5 import com.yohobuy.ufo.model.order.bo.GoodsInfo;
6 import com.yohobuy.ufo.model.order.common.SellerOrderListType; 6 import com.yohobuy.ufo.model.order.common.SellerOrderListType;
7 import com.yohobuy.ufo.model.order.common.SellerOrderStatus; 7 import com.yohobuy.ufo.model.order.common.SellerOrderStatus;
  8 +import com.yohobuy.ufo.model.order.common.SellerType;
8 import com.yohobuy.ufo.model.order.common.SkupStatus; 9 import com.yohobuy.ufo.model.order.common.SkupStatus;
9 import com.yohobuy.ufo.model.order.resp.OrderListInfo; 10 import com.yohobuy.ufo.model.order.resp.OrderListInfo;
10 import com.yohobuy.ufo.model.order.resp.PageResp; 11 import com.yohobuy.ufo.model.order.resp.PageResp;
@@ -22,6 +23,7 @@ import com.yohoufo.dal.order.model.SellerOrderGoods; @@ -22,6 +23,7 @@ import com.yohoufo.dal.order.model.SellerOrderGoods;
22 import com.yohoufo.order.model.request.OrderListRequest; 23 import com.yohoufo.order.model.request.OrderListRequest;
23 import com.yohoufo.order.service.IOrderListService; 24 import com.yohoufo.order.service.IOrderListService;
24 import com.yohoufo.order.service.cache.OrderCacheService; 25 import com.yohoufo.order.service.cache.OrderCacheService;
  26 +import com.yohoufo.order.service.proxy.UserProxyService;
25 import lombok.extern.slf4j.Slf4j; 27 import lombok.extern.slf4j.Slf4j;
26 import org.apache.commons.collections.CollectionUtils; 28 import org.apache.commons.collections.CollectionUtils;
27 import org.springframework.beans.factory.annotation.Autowired; 29 import org.springframework.beans.factory.annotation.Autowired;
@@ -54,6 +56,9 @@ public class SellerOrderListService extends AbsOrderListService implements IOrde @@ -54,6 +56,9 @@ public class SellerOrderListService extends AbsOrderListService implements IOrde
54 @Autowired 56 @Autowired
55 private OrderCacheService orderCacheService; 57 private OrderCacheService orderCacheService;
56 58
  59 + @Autowired
  60 + private UserProxyService userProxyService;
  61 +
57 62
58 @Override 63 @Override
59 public PageResp<OrderListInfo> getOrderList(OrderListRequest request){ 64 public PageResp<OrderListInfo> getOrderList(OrderListRequest request){
@@ -73,7 +78,8 @@ public class SellerOrderListService extends AbsOrderListService implements IOrde @@ -73,7 +78,8 @@ public class SellerOrderListService extends AbsOrderListService implements IOrde
73 int type; 78 int type;
74 if ((type=request.getType()) == SellerOrderListType.IN_SALE.getType()){ 79 if ((type=request.getType()) == SellerOrderListType.IN_SALE.getType()){
75 List<Integer> statusList = initOrderListRequest(request); 80 List<Integer> statusList = initOrderListRequest(request);
76 - 81 + boolean isEntry = userProxyService.isEntryShop(request.getUid());
  82 + final SellerType sellerType = isEntry ? SellerType.ENTRY : SellerType.COMMON;
77 int total = sellerOrderGoodsMapper.selectCntByUidStatusList(request.getUid(), statusList); 83 int total = sellerOrderGoodsMapper.selectCntByUidStatusList(request.getUid(), statusList);
78 int limit = request.getLimit(); 84 int limit = request.getLimit();
79 respBuilder = PageResp.builder() 85 respBuilder = PageResp.builder()
@@ -98,7 +104,7 @@ public class SellerOrderListService extends AbsOrderListService implements IOrde @@ -98,7 +104,7 @@ public class SellerOrderListService extends AbsOrderListService implements IOrde
98 List<SellerOrder> sellerOrders = sellerOrderMapper.selectBySkups(skupList); 104 List<SellerOrder> sellerOrders = sellerOrderMapper.selectBySkups(skupList);
99 List<OrderListInfo> data ; 105 List<OrderListInfo> data ;
100 data = sellerOrders.parallelStream() 106 data = sellerOrders.parallelStream()
101 - .map(sellerOrder -> buildOrderListInfo(skupSellerOrderGoodsMap.get(sellerOrder.getSkup()), sellerOrder)) 107 + .map(sellerOrder -> buildOrderListInfo(skupSellerOrderGoodsMap.get(sellerOrder.getSkup()), sellerOrder, sellerType))
102 .filter(oli -> Objects.nonNull(oli)) 108 .filter(oli -> Objects.nonNull(oli))
103 .collect(Collectors.toList()); 109 .collect(Collectors.toList());
104 110
@@ -132,7 +138,7 @@ public class SellerOrderListService extends AbsOrderListService implements IOrde @@ -132,7 +138,7 @@ public class SellerOrderListService extends AbsOrderListService implements IOrde
132 } 138 }
133 139
134 OrderListInfo buildOrderListInfo(SellerOrderGoods sellerOrderGoods, 140 OrderListInfo buildOrderListInfo(SellerOrderGoods sellerOrderGoods,
135 - SellerOrder sellerOrder) { 141 + SellerOrder sellerOrder, SellerType sellerType) {
136 142
137 OrderListInfo orderListInfo = new OrderListInfo(); 143 OrderListInfo orderListInfo = new OrderListInfo();
138 orderListInfo.setUid(sellerOrder.getUid()); 144 orderListInfo.setUid(sellerOrder.getUid());
@@ -152,7 +158,7 @@ public class SellerOrderListService extends AbsOrderListService implements IOrde @@ -152,7 +158,7 @@ public class SellerOrderListService extends AbsOrderListService implements IOrde
152 orderListInfo.setStatuStr(skupStatus.getDesc()); 158 orderListInfo.setStatuStr(skupStatus.getDesc());
153 159
154 // 按钮显示 160 // 按钮显示
155 - orderListInfo.setButtons(skupStatus.getListButtons()); 161 + orderListInfo.setButtons(skupStatus.getListButtons(sellerType));
156 162
157 // 当订单状态是待付款, 显示leftTime 163 // 当订单状态是待付款, 显示leftTime
158 if (sellerOrderGoods.getStatus() == SkupStatus.CAN_NOT_SELL.getCode()){ 164 if (sellerOrderGoods.getStatus() == SkupStatus.CAN_NOT_SELL.getCode()){
@@ -2,32 +2,35 @@ package com.yohoufo.order.service.impl; @@ -2,32 +2,35 @@ package com.yohoufo.order.service.impl;
2 2
3 import com.yoho.error.ServiceError; 3 import com.yoho.error.ServiceError;
4 import com.yoho.error.exception.ServiceException; 4 import com.yoho.error.exception.ServiceException;
  5 +import com.yohobuy.ufo.model.order.bo.GoodsInfo;
5 import com.yohobuy.ufo.model.order.bo.SoldPrdComputeBo; 6 import com.yohobuy.ufo.model.order.bo.SoldPrdComputeBo;
6 import com.yohobuy.ufo.model.order.common.*; 7 import com.yohobuy.ufo.model.order.common.*;
7 import com.yohobuy.ufo.model.order.req.*; 8 import com.yohobuy.ufo.model.order.req.*;
8 import com.yohobuy.ufo.model.order.resp.BatchChangePriceResp; 9 import com.yohobuy.ufo.model.order.resp.BatchChangePriceResp;
9 import com.yohobuy.ufo.model.order.resp.OrderCntResp; 10 import com.yohobuy.ufo.model.order.resp.OrderCntResp;
  11 +import com.yohobuy.ufo.model.order.resp.OrderListInfo;
10 import com.yohobuy.ufo.model.order.resp.PageResp; 12 import com.yohobuy.ufo.model.order.resp.PageResp;
11 import com.yohoufo.common.alarm.EventBusPublisher; 13 import com.yohoufo.common.alarm.EventBusPublisher;
12 import com.yohoufo.common.alarm.SmsAlarmEvent; 14 import com.yohoufo.common.alarm.SmsAlarmEvent;
13 import com.yohoufo.common.exception.GatewayException; 15 import com.yohoufo.common.exception.GatewayException;
14 -import com.yohoufo.common.utils.AddressUtil;  
15 import com.yohoufo.common.utils.DateUtil; 16 import com.yohoufo.common.utils.DateUtil;
16 -import com.yohoufo.dal.order.*;  
17 -import com.yohoufo.dal.order.model.*;  
18 -import com.yohoufo.order.common.*; 17 +import com.yohoufo.dal.order.BuyerOrderMapper;
  18 +import com.yohoufo.dal.order.SellerOrderGoodsMapper;
  19 +import com.yohoufo.dal.order.SellerOrderMapper;
  20 +import com.yohoufo.dal.order.model.BuyerOrder;
  21 +import com.yohoufo.dal.order.model.SellerOrder;
  22 +import com.yohoufo.dal.order.model.SellerOrderGoods;
  23 +import com.yohoufo.order.common.ActionStatusHold;
  24 +import com.yohoufo.order.common.DelStatus;
19 import com.yohoufo.order.convert.SellerOrderConvertor; 25 import com.yohoufo.order.convert.SellerOrderConvertor;
20 import com.yohoufo.order.event.ErpCancelSellerOrderEvent; 26 import com.yohoufo.order.event.ErpCancelSellerOrderEvent;
21 import com.yohoufo.order.event.EventHandlerContainer; 27 import com.yohoufo.order.event.EventHandlerContainer;
22 import com.yohoufo.order.event.OrderCancelEvent; 28 import com.yohoufo.order.event.OrderCancelEvent;
23 -import com.yohoufo.order.model.AddressInfo;  
24 -import com.yohobuy.ufo.model.order.bo.GoodsInfo;  
25 import com.yohoufo.order.model.SellerOrderContext; 29 import com.yohoufo.order.model.SellerOrderContext;
26 import com.yohoufo.order.model.dto.SellerOrderComputeResult; 30 import com.yohoufo.order.model.dto.SellerOrderComputeResult;
27 import com.yohoufo.order.model.request.OrderListRequest; 31 import com.yohoufo.order.model.request.OrderListRequest;
28 import com.yohoufo.order.model.request.OrderRequest; 32 import com.yohoufo.order.model.request.OrderRequest;
29 import com.yohoufo.order.model.response.OrderDetailInfo; 33 import com.yohoufo.order.model.response.OrderDetailInfo;
30 -import com.yohobuy.ufo.model.order.resp.OrderListInfo;  
31 import com.yohoufo.order.model.response.OrderSubmitResp; 34 import com.yohoufo.order.model.response.OrderSubmitResp;
32 import com.yohoufo.order.model.response.OrderSummaryResp; 35 import com.yohoufo.order.model.response.OrderSummaryResp;
33 import com.yohoufo.order.service.IOrderDetailService; 36 import com.yohoufo.order.service.IOrderDetailService;
@@ -36,16 +39,12 @@ import com.yohoufo.order.service.cache.CacheCleaner; @@ -36,16 +39,12 @@ import com.yohoufo.order.service.cache.CacheCleaner;
36 import com.yohoufo.order.service.cache.OrderCacheService; 39 import com.yohoufo.order.service.cache.OrderCacheService;
37 import com.yohoufo.order.service.handler.SellerOrderComputeHandler; 40 import com.yohoufo.order.service.handler.SellerOrderComputeHandler;
38 import com.yohoufo.order.service.handler.SellerOrderSubmitHandler; 41 import com.yohoufo.order.service.handler.SellerOrderSubmitHandler;
  42 +import com.yohoufo.order.service.impl.processor.SellerOrderPrepareProcessor;
39 import com.yohoufo.order.service.impl.visitor.OffShelveCancelCase; 43 import com.yohoufo.order.service.impl.visitor.OffShelveCancelCase;
40 import com.yohoufo.order.service.impl.visitor.UserCancelCase; 44 import com.yohoufo.order.service.impl.visitor.UserCancelCase;
41 import com.yohoufo.order.service.proxy.ProductProxyService; 45 import com.yohoufo.order.service.proxy.ProductProxyService;
42 -import com.yohoufo.order.service.proxy.UserProxyService;  
43 import com.yohoufo.order.service.support.codegenerator.OrderCodeGenerator; 46 import com.yohoufo.order.service.support.codegenerator.OrderCodeGenerator;
44 import com.yohoufo.order.service.support.codegenerator.bean.CodeMeta; 47 import com.yohoufo.order.service.support.codegenerator.bean.CodeMeta;
45 -import com.yohoufo.order.utils.AddressHelper;  
46 -import com.yohoufo.product.model.GoodsSize;  
47 -import com.yohoufo.product.model.ProductInfo;  
48 -import com.yohoufo.product.response.StorageDataResp;  
49 import lombok.extern.slf4j.Slf4j; 48 import lombok.extern.slf4j.Slf4j;
50 import org.apache.commons.lang3.StringUtils; 49 import org.apache.commons.lang3.StringUtils;
51 import org.springframework.beans.factory.annotation.Autowired; 50 import org.springframework.beans.factory.annotation.Autowired;
@@ -64,7 +63,6 @@ import java.util.stream.Collectors; @@ -64,7 +63,6 @@ import java.util.stream.Collectors;
64 @Slf4j 63 @Slf4j
65 public class SellerOrderService implements IOrderListService, IOrderDetailService { 64 public class SellerOrderService implements IOrderListService, IOrderDetailService {
66 65
67 -  
68 @Autowired 66 @Autowired
69 private SellerOrderMapper sellerOrderMapper; 67 private SellerOrderMapper sellerOrderMapper;
70 68
@@ -81,9 +79,6 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi @@ -81,9 +79,6 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi
81 private SellerOrderSubmitHandler orderSubmitHandler; 79 private SellerOrderSubmitHandler orderSubmitHandler;
82 80
83 @Autowired 81 @Autowired
84 - private UserProxyService userProxyService;  
85 -  
86 - @Autowired  
87 private SellerOrderListService sellerOrderListService; 82 private SellerOrderListService sellerOrderListService;
88 83
89 @Autowired 84 @Autowired
@@ -107,16 +102,27 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi @@ -107,16 +102,27 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi
107 @Autowired 102 @Autowired
108 private CacheCleaner cacheCleaner; 103 private CacheCleaner cacheCleaner;
109 104
  105 + @Autowired
  106 + private SellerOrderPrepareProcessor sellerOrderPrepareProcessor;
110 107
111 public SoldPrdComputeBo computePublishPrd(SellerOrderComputeReq req) throws GatewayException { 108 public SoldPrdComputeBo computePublishPrd(SellerOrderComputeReq req) throws GatewayException {
112 log.info("in computePublishPrd, req {}", req); 109 log.info("in computePublishPrd, req {}", req);
113 - 110 + int uid = req.getUid();
  111 + if(uid <= 0){
  112 + log.warn("in computePublishPrd uid illegal , req {}", req);
  113 + throw new GatewayException(400, "用户ID错误");
  114 + }
114 // 115 //
115 Integer storageId = req.getStorageId(); 116 Integer storageId = req.getStorageId();
116 if (storageId <=0 ){ 117 if (storageId <=0 ){
117 log.warn("in computePublishPrd storageId illegal , req {}", req); 118 log.warn("in computePublishPrd storageId illegal , req {}", req);
118 throw new GatewayException(400, "storageId 错误"); 119 throw new GatewayException(400, "storageId 错误");
119 } 120 }
  121 + int num;
  122 + if ((num = req.getNum())<=0){
  123 + log.warn("in computePublishPrd num illegal , req {}", req);
  124 + throw new GatewayException(400, "非法数量值");
  125 + }
120 126
121 /*商品鉴定费 ¥10.00 127 /*商品鉴定费 ¥10.00
122 商品包装费 ¥10.00 128 商品包装费 ¥10.00
@@ -133,42 +139,15 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi @@ -133,42 +139,15 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi
133 throw new GatewayException(400, "价格须为以9结尾的正整数"); 139 throw new GatewayException(400, "价格须为以9结尾的正整数");
134 } 140 }
135 141
136 -  
137 BigDecimal prdPrice = null; 142 BigDecimal prdPrice = null;
138 try{ 143 try{
139 prdPrice = new BigDecimal(price); 144 prdPrice = new BigDecimal(price);
140 }catch (Exception e){ 145 }catch (Exception e){
141 log.warn("in computePublishPrd price convert BigDecimal fail, {}", req); 146 log.warn("in computePublishPrd price convert BigDecimal fail, {}", req);
142 - return null;  
143 - }  
144 -  
145 - checkPrice(storageId, prdPrice, false);  
146 -  
147 -  
148 - return buildSoldPrdComputeBo(prdPrice);  
149 - }  
150 -  
151 -  
152 - void checkPrice(int storageId, BigDecimal prdPrice, boolean validateMaxPrice) throws GatewayException {  
153 - ProductInfo productInfo = productProxyService.getPrdPriceRange(storageId);  
154 - BigDecimal minPrice = productInfo.getMinPrice();  
155 - BigDecimal maxPrice = productInfo.getMaxPrice();  
156 - if (prdPrice.subtract(minPrice).doubleValue() < 0D){  
157 - log.warn("in computePublishPrd,minPrice {}, storageId {}", minPrice, storageId);  
158 - throw new GatewayException(501, "您的出价过低");  
159 - }  
160 -  
161 - if (validateMaxPrice && prdPrice.subtract(maxPrice).doubleValue() > 0D){  
162 - log.warn("in computePublishPrd,maxPrice {}, storageId {}", maxPrice, storageId);  
163 - throw new GatewayException(501, "您的出价过高");  
164 - }  
165 - }  
166 -  
167 - void checkIncome(int storageId, BigDecimal income) throws GatewayException {  
168 - if (income == null || income.compareTo(BigDecimal.ZERO) <= 0){  
169 - log.warn("in checkIncome,storageId {}, income {}", income);  
170 - throw new GatewayException(501, "别闹了,这个售价没有收入"); 147 + throw new GatewayException(400, "非法数字");
171 } 148 }
  149 + sellerOrderPrepareProcessor.checkPrice(storageId, prdPrice, false);
  150 + return buildSoldPrdComputeBo(uid, num, prdPrice);
172 } 151 }
173 152
174 /** 153 /**
@@ -179,22 +158,22 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi @@ -179,22 +158,22 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi
179 */ 158 */
180 159
181 public OrderSubmitResp publishPrd(SellerOrderSubmitReq req) throws GatewayException { 160 public OrderSubmitResp publishPrd(SellerOrderSubmitReq req) throws GatewayException {
182 - SellerOrderContext context = buildSellerOrderContext(req); 161 + SellerOrderContext context = sellerOrderPrepareProcessor.buildSellerOrderContext(req);
183 int storageId = context.getStorageId(); 162 int storageId = context.getStorageId();
184 int uid = context.getUid(); 163 int uid = context.getUid();
185 //step 1: rpc get product detail by storage id 164 //step 1: rpc get product detail by storage id
186 //ufo.product.storage.data 165 //ufo.product.storage.data
187 - GoodsInfo goodsInfo = getProductDetail(context); 166 + GoodsInfo goodsInfo = sellerOrderPrepareProcessor.getProductDetail(context);
188 //step 2: generate skup ,action :set price status(unsaleable) 167 //step 2: generate skup ,action :set price status(unsaleable)
189 if (Objects.isNull(goodsInfo)){ 168 if (Objects.isNull(goodsInfo)){
190 - log.warn("in computePublishPrd storageId not exist in prd , uid {}, storageId {}", uid, storageId); 169 + log.warn("in publishPrd storageId not exist in prd service , uid {}, storageId {}", uid, storageId);
191 throw new ServiceException(ServiceError.ORDER_ORDERS_GOODS_IS_EMPTY); 170 throw new ServiceException(ServiceError.ORDER_ORDERS_GOODS_IS_EMPTY);
192 } 171 }
193 context.setSoldProduct(goodsInfo); 172 context.setSoldProduct(goodsInfo);
194 - checkPrice(storageId, goodsInfo.getPrice(), true); 173 + sellerOrderPrepareProcessor.checkPrice(storageId, goodsInfo.getPrice(), true);
195 // compute every fee from price 174 // compute every fee from price
196 SellerOrderComputeResult computeResult = computeHandler.compute(goodsInfo.getPrice()); 175 SellerOrderComputeResult computeResult = computeHandler.compute(goodsInfo.getPrice());
197 - checkIncome(storageId, computeResult.getIncome()); 176 + sellerOrderPrepareProcessor.checkIncome(storageId, computeResult.getIncome());
198 log.info("in publishPrd , uid {}, storageId {}, price {}, computeResult {}", uid, storageId, 177 log.info("in publishPrd , uid {}, storageId {}, price {}, computeResult {}", uid, storageId,
199 goodsInfo.getPrice(), computeResult); 178 goodsInfo.getPrice(), computeResult);
200 context.setSellerOrderComputeResult(computeResult); 179 context.setSellerOrderComputeResult(computeResult);
@@ -240,98 +219,6 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi @@ -240,98 +219,6 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi
240 } 219 }
241 220
242 221
243 -  
244 - private GoodsInfo getProductDetail(SellerOrderContext context){  
245 - int uid = context.getUid();  
246 - int storageId = context.getStorageId();  
247 - BigDecimal salePrice = context.getSalePrice();  
248 - try {  
249 - StorageDataResp prdResp = productProxyService.getStorageData(storageId);  
250 -  
251 - if (!Integer.valueOf(1).equals(prdResp.getStatus())) {  
252 - log.info("in getProductDetail occur product out shelve, uid {}, storageId {}", uid, storageId);  
253 - return null;  
254 - }  
255 -  
256 - GoodsInfo goodsInfo = new GoodsInfo();  
257 - goodsInfo.setUid(uid);  
258 - goodsInfo.setProductId(prdResp.getProductId());  
259 - goodsInfo.setProductName(prdResp.getProductName());  
260 - goodsInfo.setColorId(Objects.isNull(prdResp.getColorId()) ? null : Integer.valueOf(prdResp.getColorId()));  
261 - goodsInfo.setColorName(prdResp.getColorName());  
262 - GoodsSize size;  
263 - if (Objects.nonNull(size =prdResp.getSize())){  
264 - goodsInfo.setSizeName(size.getSizeName());  
265 - goodsInfo.setSizeId(size.getSizeId());  
266 - }  
267 - goodsInfo.setImageUrl(prdResp.getImageUrl());  
268 - goodsInfo.setPrice(salePrice);  
269 - goodsInfo.setStorageId(context.getStorageId());  
270 - return goodsInfo;  
271 - }catch (Exception ex){  
272 - log.warn("in getProductDetail occur error, uid {}, storageId {}", uid, storageId);  
273 - return null;  
274 - }  
275 - }  
276 -  
277 -  
278 - private SellerOrderContext buildSellerOrderContext(SellerOrderSubmitReq req) throws GatewayException {  
279 - int uid = req.getUid();  
280 - if (uid <= 0){  
281 - log.warn("uid illegal , uid {}", uid);  
282 - throw new GatewayException(400, "Uid 错误");  
283 - }  
284 - Integer storageId = req.getStorageId();  
285 - if (storageId <=0 ){  
286 - log.warn("storageId illegal , uid {}", uid);  
287 - throw new GatewayException(400, "storageId 错误");  
288 - }  
289 - String price = req.getPrice();  
290 - if (StringUtils.isBlank(price)){  
291 - log.warn("in buildSellerOrderContext price illegal , req {}", req);  
292 - throw new GatewayException(400, "没有价格");  
293 - }  
294 -  
295 - if(!price.endsWith("9")){  
296 - log.warn("in buildSellerOrderContext price illegal , req {}", req);  
297 - throw new GatewayException(400, "价格须为以9结尾的正整数");  
298 - }  
299 -  
300 - BigDecimal salePrice;  
301 - try{  
302 - salePrice = new BigDecimal(req.getPrice());  
303 - }catch (Exception ex){  
304 - log.warn("storageId illegal , uid {}", uid);  
305 - throw new GatewayException(400, "售价格式错误");  
306 - }  
307 -  
308 - int addressId = AddressUtil.getDecryptStr(req.getAddressId());  
309 - if (addressId < 0){  
310 - log.warn("seller submit order addressId invalidate, uid {}, storageId {}, addressId is {}",  
311 - uid, storageId, req.getAddressId());  
312 - throw new ServiceException(ServiceError.ORDER_ADDRESSID_INVALIDATE);  
313 - }  
314 -  
315 - //the address of send back 2 seller  
316 - //  
317 - AddressInfo hiddenBackAddress = userProxyService.getHiddenAddressInfo(uid, addressId);  
318 - AddressInfo noHiddenBackAddress = userProxyService.getAddressInfoNotHidden(uid, addressId);  
319 - if(AddressHelper.isNeedUpdate(noHiddenBackAddress)){  
320 - log.warn("seller submit addressId need update, uid is {}, storageId is {}, addressId is {}",  
321 - uid, storageId, addressId);  
322 - throw new ServiceException(ServiceError.ORDER_ADDRESS_NEED_UPDATE);  
323 - }  
324 - //  
325 - SellerOrderContext context = new SellerOrderContext();  
326 - context.setUid(uid);  
327 - context.setStorageId(storageId);  
328 - context.setSalePrice(salePrice);  
329 - //  
330 - context.setBackAddress(noHiddenBackAddress);  
331 - context.setBackHiddenAddress(hiddenBackAddress);  
332 - return context;  
333 - }  
334 -  
335 /** 222 /**
336 * 卖家支付完成后调用 223 * 卖家支付完成后调用
337 * @param uid 224 * @param uid
@@ -353,6 +240,21 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi @@ -353,6 +240,21 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi
353 240
354 } 241 }
355 242
  243 + @Autowired
  244 + private SkupBatchService skupBatchService;
  245 +
  246 + public void batchPublishPrds(SellerOrderSubmitReq req) throws GatewayException {
  247 + // 一串校验
  248 + SellerOrderContext ctx = sellerOrderPrepareProcessor.buildBatchSellerOrderContext(req);
  249 + //TODO 扣减保证金
  250 + //TODO (异步实现)记录保证金流水
  251 + //TODO 生成批次号
  252 + skupBatchService.generateBatchNo(req.getUid(), req.getNum());
  253 + //TODO 批量生成订单(订单表,meta 地址,算费)--> 需要用到多线程并行处理
  254 + //TODO(异步实现)同步数据到prd,记录支付,
  255 +
  256 + }
  257 +
356 258
357 public boolean offShelveByErp(int skup){ 259 public boolean offShelveByErp(int skup){
358 if (skup <= 0 ){ 260 if (skup <= 0 ){
@@ -439,16 +341,14 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi @@ -439,16 +341,14 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi
439 341
440 if(OrderCodeType.BUYER_TYPE.getType() == codeMeta.getType()){ 342 if(OrderCodeType.BUYER_TYPE.getType() == codeMeta.getType()){
441 BuyerOrder buyerOrder = buyerOrderMapper.selectAllByOrderCode(orderCode); 343 BuyerOrder buyerOrder = buyerOrderMapper.selectAllByOrderCode(orderCode);
442 - //todo 判断状态后更新 344 + //判断状态后更新
443 checkBuyCanDelStatus(buyerOrder.getStatus()); 345 checkBuyCanDelStatus(buyerOrder.getStatus());
444 -  
445 BuyerOrder target = new BuyerOrder(); 346 BuyerOrder target = new BuyerOrder();
446 target.setId(buyerOrder.getId()); 347 target.setId(buyerOrder.getId());
447 target.setSellerOrderStatus(DelStatus.IS_DEL.getCode()); 348 target.setSellerOrderStatus(DelStatus.IS_DEL.getCode());
448 target.setUpdateTime(DateUtil.getCurrentTimeSecond()); 349 target.setUpdateTime(DateUtil.getCurrentTimeSecond());
449 buyerOrderMapper.updateByPrimaryKeySelective(target); 350 buyerOrderMapper.updateByPrimaryKeySelective(target);
450 } 351 }
451 -  
452 cacheCleaner.cleanList(uid, TabType.SELL.getValue()); 352 cacheCleaner.cleanList(uid, TabType.SELL.getValue());
453 return true; 353 return true;
454 } 354 }
@@ -480,10 +380,12 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi @@ -480,10 +380,12 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi
480 } 380 }
481 381
482 382
483 -  
484 -  
485 - public SoldPrdComputeBo buildSoldPrdComputeBo(BigDecimal prdPrice){ 383 + private SoldPrdComputeBo buildSoldPrdComputeBo(int uid, int num, BigDecimal prdPrice){
486 SellerOrderComputeResult computeResult = computeHandler.compute(prdPrice); 384 SellerOrderComputeResult computeResult = computeHandler.compute(prdPrice);
  385 + /**
  386 + * 验证是否是入驻商家
  387 + */
  388 + sellerOrderPrepareProcessor.checkNGetMergeEarnestMoney(uid, computeResult, num, prdPrice);
487 SoldPrdComputeBo computeBo = SellerOrderConvertor.computeResult2SoldPrdComputeBo(computeResult); 389 SoldPrdComputeBo computeBo = SellerOrderConvertor.computeResult2SoldPrdComputeBo(computeResult);
488 return computeBo; 390 return computeBo;
489 } 391 }
@@ -501,8 +403,6 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi @@ -501,8 +403,6 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi
501 return sellerOrderDetailService.getOrderDetail(orderRequest); 403 return sellerOrderDetailService.getOrderDetail(orderRequest);
502 } 404 }
503 405
504 -  
505 -  
506 /** 406 /**
507 * 根据用户id查询卖的单数 407 * 根据用户id查询卖的单数
508 * 出售栏目显示的数量=出售tab下商品“出售中”状态的数量+待发货tab下所有的订单数+已发货tab下所有订单数 408 * 出售栏目显示的数量=出售tab下商品“出售中”状态的数量+待发货tab下所有的订单数+已发货tab下所有订单数
  1 +package com.yohoufo.order.service.impl;
  2 +
  3 +import com.yohoufo.common.utils.DateUtil;
  4 +import com.yohoufo.dal.order.SkupBatchMapper;
  5 +import com.yohoufo.dal.order.model.SkupBatch;
  6 +import org.slf4j.Logger;
  7 +import org.slf4j.LoggerFactory;
  8 +import org.springframework.stereotype.Service;
  9 +
  10 +/**
  11 + * Created by chao.chen on 2018/11/19.
  12 + */
  13 +@Service
  14 +public class SkupBatchService {
  15 +
  16 + private final Logger logger = LoggerFactory.getLogger(getClass());
  17 +
  18 + private SkupBatchMapper skupBatchMapper;
  19 +
  20 + public Long generateBatchNo(int uid, int num){
  21 + SkupBatch record = new SkupBatch();
  22 + record.setUid(uid);
  23 + record.setNum(num);
  24 + record.setCreateTime(DateUtil.getCurrentTimeSecond());
  25 + skupBatchMapper.insertSelective(record);
  26 + return record.getId();
  27 + }
  28 +}
1 package com.yohoufo.order.service.impl; 1 package com.yohoufo.order.service.impl;
2 2
3 import com.yoho.core.dal.datasource.annotation.Database; 3 import com.yoho.core.dal.datasource.annotation.Database;
  4 +import com.yohobuy.ufo.model.order.req.SellerOrderSubmitReq;
4 import com.yohoufo.dal.order.SellerOrderGoodsMapper; 5 import com.yohoufo.dal.order.SellerOrderGoodsMapper;
  6 +import com.yohoufo.dal.order.SkupBatchMapper;
5 import com.yohoufo.dal.order.model.SellerOrderGoods; 7 import com.yohoufo.dal.order.model.SellerOrderGoods;
6 import com.yohobuy.ufo.model.order.common.SkupStatus; 8 import com.yohobuy.ufo.model.order.common.SkupStatus;
7 import com.yohobuy.ufo.model.order.bo.GoodsInfo; 9 import com.yohobuy.ufo.model.order.bo.GoodsInfo;
@@ -24,6 +26,9 @@ public class SkupService { @@ -24,6 +26,9 @@ public class SkupService {
24 @Autowired 26 @Autowired
25 private SellerOrderGoodsMapper sellerOrderGoodsMapper; 27 private SellerOrderGoodsMapper sellerOrderGoodsMapper;
26 28
  29 + @Autowired
  30 + private SkupBatchMapper skupBatchMapper;
  31 +
27 @Transactional(propagation = Propagation.REQUIRED) 32 @Transactional(propagation = Propagation.REQUIRED)
28 @Database(ForceMaster=true, DataSource="ufo_order") 33 @Database(ForceMaster=true, DataSource="ufo_order")
29 public SellerOrderGoods addSkup(GoodsInfo goodsInfo){ 34 public SellerOrderGoods addSkup(GoodsInfo goodsInfo){
@@ -58,6 +63,10 @@ public class SkupService { @@ -58,6 +63,10 @@ public class SkupService {
58 return sellerOrderGoods; 63 return sellerOrderGoods;
59 } 64 }
60 65
  66 + public void batchPublishPrds(SellerOrderSubmitReq req){
  67 +
  68 +
  69 + }
61 70
62 71
63 } 72 }
  1 +package com.yohoufo.order.service.impl.processor;
  2 +
  3 +import com.yoho.error.ServiceError;
  4 +import com.yoho.error.exception.ServiceException;
  5 +import com.yohobuy.ufo.model.order.bo.GoodsInfo;
  6 +import com.yohobuy.ufo.model.order.common.SellerWalletType;
  7 +import com.yohobuy.ufo.model.order.req.SellerOrderSubmitReq;
  8 +import com.yohoufo.common.exception.GatewayException;
  9 +import com.yohoufo.common.utils.AddressUtil;
  10 +import com.yohoufo.common.utils.BigDecimalHelper;
  11 +import com.yohoufo.dal.order.SellerWalletMapper;
  12 +import com.yohoufo.dal.order.model.SellerWallet;
  13 +import com.yohoufo.order.model.AddressInfo;
  14 +import com.yohoufo.order.model.SellerOrderContext;
  15 +import com.yohoufo.order.model.dto.SellerOrderComputeResult;
  16 +import com.yohoufo.order.service.handler.SellerOrderComputeHandler;
  17 +import com.yohoufo.order.service.proxy.ProductProxyService;
  18 +import com.yohoufo.order.service.proxy.UserProxyService;
  19 +import com.yohoufo.order.utils.AddressHelper;
  20 +import com.yohoufo.product.model.GoodsSize;
  21 +import com.yohoufo.product.model.ProductInfo;
  22 +import com.yohoufo.product.response.StorageDataResp;
  23 +import org.apache.commons.lang3.StringUtils;
  24 +import org.slf4j.Logger;
  25 +import org.slf4j.LoggerFactory;
  26 +import org.springframework.beans.factory.annotation.Autowired;
  27 +import org.springframework.stereotype.Service;
  28 +
  29 +import java.math.BigDecimal;
  30 +import java.util.Objects;
  31 +
  32 +/**
  33 + * Created by chao.chen on 2018/11/19.
  34 + */
  35 +@Service
  36 +public class SellerOrderPrepareProcessor {
  37 +
  38 + private final Logger log = LoggerFactory.getLogger(getClass());
  39 +
  40 + @Autowired
  41 + private UserProxyService userProxyService;
  42 +
  43 + @Autowired
  44 + private ProductProxyService productProxyService;
  45 +
  46 + @Autowired
  47 + private SellerOrderComputeHandler computeHandler;
  48 +
  49 + @Autowired
  50 + private SellerWalletMapper sellerWalletMapper;
  51 +
  52 + public SellerOrderContext buildBatchSellerOrderContext(SellerOrderSubmitReq req) throws GatewayException {
  53 + SellerOrderContext ctx = buildSellerOrderContext(req);
  54 + int storageId = ctx.getStorageId();
  55 + int uid = ctx.getUid();
  56 + int storageNum = req.getNum();
  57 + if (storageNum <=0){
  58 + log.warn("in buildBatchSellerOrderContext storageNum illegal , uid {}, storageId {} storageNum {}",
  59 + uid, storageId, storageNum);
  60 + throw new ServiceException(ServiceError.ORDER_ORDERS_GOODS_IS_EMPTY);
  61 + }
  62 + //step 1: rpc get product detail by storage id
  63 + //ufo.product.storage.data
  64 + GoodsInfo goodsInfo = getProductDetail(ctx);
  65 + //step 2: generate skup ,action :set price status(unsaleable)
  66 + if (Objects.isNull(goodsInfo)){
  67 + log.warn("in buildBatchSellerOrderContext storageId not exist in prd , uid {}, storageId {}", uid, storageId);
  68 + throw new ServiceException(ServiceError.ORDER_ORDERS_GOODS_IS_EMPTY);
  69 + }
  70 +
  71 + goodsInfo.setStorageNum(storageNum);
  72 + ctx.setSoldProduct(goodsInfo);
  73 + checkPrice(storageId, goodsInfo.getPrice(), true);
  74 + // compute every fee from price
  75 + SellerOrderComputeResult computeResult = computeHandler.compute(goodsInfo.getPrice());
  76 + checkIncome(storageId, computeResult.getIncome());
  77 + checkNGetMergeEarnestMoney(uid, computeResult, storageNum, goodsInfo.getPrice());
  78 + return ctx;
  79 + }
  80 +
  81 +
  82 + public SellerOrderContext buildSellerOrderContext(SellerOrderSubmitReq req) throws GatewayException {
  83 + int uid = req.getUid();
  84 + if (uid <= 0){
  85 + log.warn("uid illegal , uid {}", uid);
  86 + throw new GatewayException(400, "Uid 错误");
  87 + }
  88 + Integer storageId = req.getStorageId();
  89 + if (storageId <=0 ){
  90 + log.warn("storageId illegal , uid {}", uid);
  91 + throw new GatewayException(400, "storageId 错误");
  92 + }
  93 + String price = req.getPrice();
  94 + if (StringUtils.isBlank(price)){
  95 + log.warn("in buildSellerOrderContext price illegal , req {}", req);
  96 + throw new GatewayException(400, "没有价格");
  97 + }
  98 +
  99 + if(!price.endsWith("9")){
  100 + log.warn("in buildSellerOrderContext price illegal , req {}", req);
  101 + throw new GatewayException(400, "价格须为以9结尾的正整数");
  102 + }
  103 +
  104 + BigDecimal salePrice;
  105 + try{
  106 + salePrice = new BigDecimal(req.getPrice());
  107 + }catch (Exception ex){
  108 + log.warn("storageId illegal , uid {}", uid);
  109 + throw new GatewayException(400, "售价格式错误");
  110 + }
  111 +
  112 + int addressId = AddressUtil.getDecryptStr(req.getAddressId());
  113 + if (addressId < 0){
  114 + log.warn("seller submit order addressId invalidate, uid {}, storageId {}, addressId is {}",
  115 + uid, storageId, req.getAddressId());
  116 + throw new ServiceException(ServiceError.ORDER_ADDRESSID_INVALIDATE);
  117 + }
  118 +
  119 + //the address of send back 2 seller
  120 + //
  121 + AddressInfo hiddenBackAddress = userProxyService.getHiddenAddressInfo(uid, addressId);
  122 + AddressInfo noHiddenBackAddress = userProxyService.getAddressInfoNotHidden(uid, addressId);
  123 + if(AddressHelper.isNeedUpdate(noHiddenBackAddress)){
  124 + log.warn("seller submit addressId need update, uid is {}, storageId is {}, addressId is {}",
  125 + uid, storageId, addressId);
  126 + throw new ServiceException(ServiceError.ORDER_ADDRESS_NEED_UPDATE);
  127 + }
  128 + //
  129 + SellerOrderContext context = new SellerOrderContext();
  130 + context.setUid(uid);
  131 + context.setStorageId(storageId);
  132 + context.setSalePrice(salePrice);
  133 + //
  134 + context.setBackAddress(noHiddenBackAddress);
  135 + context.setBackHiddenAddress(hiddenBackAddress);
  136 + return context;
  137 + }
  138 +
  139 + public GoodsInfo getProductDetail(SellerOrderContext context){
  140 + int uid = context.getUid();
  141 + int storageId = context.getStorageId();
  142 + BigDecimal salePrice = context.getSalePrice();
  143 + try {
  144 + StorageDataResp prdResp = productProxyService.getStorageData(storageId);
  145 + if (!Integer.valueOf(1).equals(prdResp.getStatus())) {
  146 + log.info("in getProductDetail occur product out shelve, uid {}, storageId {}", uid, storageId);
  147 + return null;
  148 + }
  149 + GoodsInfo goodsInfo = new GoodsInfo();
  150 + goodsInfo.setUid(uid);
  151 + goodsInfo.setProductId(prdResp.getProductId());
  152 + goodsInfo.setProductName(prdResp.getProductName());
  153 + goodsInfo.setColorId(Objects.isNull(prdResp.getColorId()) ? null : Integer.valueOf(prdResp.getColorId()));
  154 + goodsInfo.setColorName(prdResp.getColorName());
  155 + GoodsSize size;
  156 + if (Objects.nonNull(size = prdResp.getSize())){
  157 + goodsInfo.setSizeName(size.getSizeName());
  158 + goodsInfo.setSizeId(size.getSizeId());
  159 + }
  160 + goodsInfo.setImageUrl(prdResp.getImageUrl());
  161 + goodsInfo.setPrice(salePrice);
  162 + goodsInfo.setStorageId(context.getStorageId());
  163 + return goodsInfo;
  164 + }catch (Exception ex){
  165 + log.warn("in getProductDetail occur error, uid {}, storageId {}", uid, storageId);
  166 + return null;
  167 + }
  168 + }
  169 +
  170 + public void checkPrice(int storageId, BigDecimal prdPrice, boolean validateMaxPrice) throws GatewayException {
  171 + ProductInfo productInfo = productProxyService.getPrdPriceRange(storageId);
  172 + BigDecimal minPrice = productInfo.getMinPrice();
  173 + BigDecimal maxPrice = productInfo.getMaxPrice();
  174 + if (prdPrice.subtract(minPrice).doubleValue() < 0D){
  175 + log.warn("in computePublishPrd,minPrice {}, storageId {}", minPrice, storageId);
  176 + throw new GatewayException(501, "您的出价过低");
  177 + }
  178 +
  179 + if (validateMaxPrice && prdPrice.subtract(maxPrice).doubleValue() > 0D){
  180 + log.warn("in computePublishPrd,maxPrice {}, storageId {}", maxPrice, storageId);
  181 + throw new GatewayException(501, "您的出价过高");
  182 + }
  183 + }
  184 +
  185 + public void checkIncome(int storageId, BigDecimal income) throws GatewayException {
  186 + if (income == null || income.compareTo(BigDecimal.ZERO) <= 0){
  187 + log.warn("in checkIncome,storageId {}, income {}", storageId, income);
  188 + throw new GatewayException(501, "别闹了,这个售价没有收入");
  189 + }
  190 + }
  191 +
  192 + public BigDecimal checkNGetMergeEarnestMoney(int uid, SellerOrderComputeResult computeResult, int num, BigDecimal prdPrice){
  193 + boolean isEntryShop = userProxyService.isEntryShop(uid);
  194 + BigDecimal mEarestMoney = null;
  195 + if(isEntryShop){
  196 + BigDecimal singleEarestMoney = computeResult.getEarnestMoney().getEarnestMoney();
  197 + mEarestMoney = BigDecimalHelper.halfUp(new BigDecimal(num).multiply(singleEarestMoney));
  198 + boolean isEnough = isEnough(uid, mEarestMoney);
  199 + if (!isEnough){
  200 + log.warn("in buildSoldPrdComputeBo,wallet is not enough,uid {} num {} prdPrice {} singleEarestMoney {}",
  201 + uid, num, prdPrice, singleEarestMoney);
  202 + throw new ServiceException(ServiceError.WALLET_EARNESTMONEY_IS_NOT_ENOUGH);
  203 + }
  204 + }
  205 + return mEarestMoney;
  206 + }
  207 +
  208 + /**
  209 + *
  210 + * @param uid
  211 + * @param mEarestMoney
  212 + * @return
  213 + */
  214 + private boolean isEnough(int uid, BigDecimal mEarestMoney){
  215 + //取出入驻商家的钱包余额,判断保证金总额是否足够扣减
  216 + SellerWallet condition = new SellerWallet();
  217 + condition.setUid(uid);
  218 + condition.setType(SellerWalletType.EARNEAST_MONEY.getCode());
  219 + SellerWallet psw = sellerWalletMapper.selectByUidNType(condition);
  220 + log.info("in compare price, uid {}, mEarestMoney {}, SellerWallet {}", uid, mEarestMoney, psw);
  221 + if (psw !=null && psw.getAmount().compareTo(mEarestMoney) >= 0){
  222 + return true;
  223 + }
  224 + return false;
  225 + }
  226 +}
@@ -8,6 +8,7 @@ import com.yoho.error.ServiceError; @@ -8,6 +8,7 @@ import com.yoho.error.ServiceError;
8 import com.yoho.error.exception.ServiceException; 8 import com.yoho.error.exception.ServiceException;
9 import com.yoho.service.model.request.UserAddressReqBO; 9 import com.yoho.service.model.request.UserAddressReqBO;
10 import com.yohoufo.common.ApiResponse; 10 import com.yohoufo.common.ApiResponse;
  11 +import com.yohoufo.common.caller.UfoServiceCaller;
11 import com.yohoufo.order.convert.AddressInfoConvertor; 12 import com.yohoufo.order.convert.AddressInfoConvertor;
12 import com.yohoufo.order.model.AddressInfo; 13 import com.yohoufo.order.model.AddressInfo;
13 import org.apache.commons.lang3.StringUtils; 14 import org.apache.commons.lang3.StringUtils;
@@ -38,6 +39,9 @@ public class UserProxyService { @@ -38,6 +39,9 @@ public class UserProxyService {
38 39
39 @Value("${uic.url:http://uic.yohoops.org/uic}") 40 @Value("${uic.url:http://uic.yohoops.org/uic}")
40 private String uicUrl; 41 private String uicUrl;
  42 +
  43 + @Autowired
  44 + private UfoServiceCaller ufoServiceCaller;
41 /** 45 /**
42 * 获取用户信息 46 * 获取用户信息
43 * @param uid 47 * @param uid
@@ -133,4 +137,18 @@ public class UserProxyService { @@ -133,4 +137,18 @@ public class UserProxyService {
133 } 137 }
134 return mobile; 138 return mobile;
135 } 139 }
  140 +
  141 + public boolean isEntryShop(int uid){
  142 +
  143 + //入驻商户 method=ufo.user.isStoredSeller ,入参 uid
  144 + ApiResponse userInfo ;
  145 + try {
  146 + userInfo = ufoServiceCaller.call("ufo.user.isStoredSeller", uid);
  147 + }catch (Exception ex){
  148 + logger.warn("in getMobile fail, uid {}", uid, ex);
  149 + throw new ServiceException(ServiceError.USER_IS_NOT_EXIST);
  150 + }
  151 + logger.info("judge user is entry shop, uid {} resp {}", uid, userInfo);
  152 + return (userInfo == null || userInfo.getData() == null) ? false : (boolean) userInfo.getData();
  153 + }
136 } 154 }
@@ -6,7 +6,7 @@ @@ -6,7 +6,7 @@
6 <parent> 6 <parent>
7 <groupId>com.yoho</groupId> 7 <groupId>com.yoho</groupId>
8 <artifactId>parent</artifactId> 8 <artifactId>parent</artifactId>
9 - <version>1.4.7-SNAPSHOT</version> 9 + <version>1.4.8-SNAPSHOT</version>
10 </parent> 10 </parent>
11 11
12 <groupId>com.yohoufo.fore</groupId> 12 <groupId>com.yohoufo.fore</groupId>
@@ -18,7 +18,7 @@ @@ -18,7 +18,7 @@
18 <properties> 18 <properties>
19 <qiniu.version>7.0.5</qiniu.version> 19 <qiniu.version>7.0.5</qiniu.version>
20 <project-name>yohoufo-fore</project-name> 20 <project-name>yohoufo-fore</project-name>
21 - <model.version>test-1.0-SNAPSHOT</model.version> 21 + <model.version>2.0-SNAPSHOT</model.version>
22 </properties> 22 </properties>
23 23
24 <dependencyManagement> 24 <dependencyManagement>
1 package com.yohoufo.product.controller; 1 package com.yohoufo.product.controller;
2 2
  3 +import java.util.List;
3 import java.util.concurrent.ExecutorService; 4 import java.util.concurrent.ExecutorService;
4 import java.util.concurrent.Executors; 5 import java.util.concurrent.Executors;
  6 +import java.util.stream.Collectors;
5 7
  8 +import org.apache.commons.collections.CollectionUtils;
6 import org.apache.commons.lang3.StringUtils; 9 import org.apache.commons.lang3.StringUtils;
7 import org.slf4j.Logger; 10 import org.slf4j.Logger;
8 import org.slf4j.LoggerFactory; 11 import org.slf4j.LoggerFactory;
@@ -171,6 +174,24 @@ public class ProductController { @@ -171,6 +174,24 @@ public class ProductController {
171 } 174 }
172 } 175 }
173 176
  177 + /**
  178 + * 批量创建skup
  179 + * @param skupBo
  180 + * @return
  181 + */
  182 + @RequestMapping(params = "method=ufo.product.batchCreateSkup")
  183 + public ApiResponse batchCreateSkup(@RequestBody List<StoragePriceBo> skupBoList) {
  184 + LOG.info("in method=ufo.product.batchCreateSkup skupBoList = {}", skupBoList);
  185 + try {
  186 + productService.batchCreateSkup(skupBoList);
  187 + return new ApiResponse(200, "创建成功!", Boolean.TRUE);
  188 + } catch (Exception e) {
  189 + LOG.error("创建SKUP失败!", e);
  190 + int code = (e instanceof ServiceException) ? ((ServiceException) e).getCode() : 500;
  191 + return new ApiResponse(code, e.getMessage(), Boolean.FALSE);
  192 + }
  193 + }
  194 +
174 // 卖家修改状态:*1:可售(支付保证金),2:取消支付保证金,3:超时未支付保证金,4:支付保证金后取消售卖 195 // 卖家修改状态:*1:可售(支付保证金),2:取消支付保证金,3:超时未支付保证金,4:支付保证金后取消售卖
175 @RequestMapping(params = "method=ufo.product.sellerUpdateStatus") 196 @RequestMapping(params = "method=ufo.product.sellerUpdateStatus")
176 public ApiResponse sellerUpdateStatus(@RequestBody StoragePriceBo skupBo) { 197 public ApiResponse sellerUpdateStatus(@RequestBody StoragePriceBo skupBo) {
@@ -189,6 +210,34 @@ public class ProductController { @@ -189,6 +210,34 @@ public class ProductController {
189 } 210 }
190 } 211 }
191 212
  213 + // 商家修改状态:1:上架 2:下架
  214 + @RequestMapping(params = "method=ufo.product.sellerBatchUpdateStatus")
  215 + public ApiResponse sellerBatchUpdateStatus(@RequestParam(value = "skupList", required = true) List<Integer> skupList,
  216 + @RequestParam(value = "status", required = true) Integer status){
  217 + LOG.info("in method=ufo.product.sellerBatchUpdateStatus skupList is {}, status is {}", skupList, status);
  218 + int dbStatus = 1;//上架
  219 + if(1 != status.intValue() && 2 != status.intValue()) {
  220 + throw new ServiceException(400, "status值不对,只能传1或2!");
  221 + }
  222 + //下架
  223 + if(2 == status.intValue()) {
  224 + dbStatus = 104;
  225 + }
  226 +
  227 + try {
  228 + productService.sellerBatchUpdateStatus(skupList, dbStatus);
  229 + //清缓存
  230 + LOG.info("sellerUpdateStatus success and async clearProductCache skupList = {}", skupList);
  231 + clearBatchProductCache(skupList);
  232 +
  233 + return new ApiResponse(200, "更新成功!", Boolean.TRUE);
  234 + } catch (Exception e) {
  235 + LOG.error("sellerBatchUpdateStatus失败!", e);
  236 + int code = (e instanceof ServiceException) ? ((ServiceException) e).getCode() : 500;
  237 + return new ApiResponse(code, e.getMessage(), Boolean.FALSE);
  238 + }
  239 + }
  240 +
192 // 设置鉴定中心 241 // 设置鉴定中心
193 @RequestMapping(params = "method=ufo.product.setDepotNum") 242 @RequestMapping(params = "method=ufo.product.setDepotNum")
194 public ApiResponse setDepotNum( 243 public ApiResponse setDepotNum(
@@ -257,4 +306,35 @@ public class ProductController { @@ -257,4 +306,35 @@ public class ProductController {
257 } 306 }
258 }); 307 });
259 } 308 }
  309 +
  310 + private void clearBatchProductCache(List<Integer> skupList) {
  311 + executors.execute(() -> {
  312 + try {
  313 + LOG.info("in clearBatchProductCache skupList = {}", skupList);
  314 + List<StoragePrice> spList = productService.getStoragePriceBySkupList(skupList);
  315 + List<Integer> productIdList = spList.stream().map(StoragePrice::getProductId).collect(Collectors.toList());
  316 + List<Integer> storageIdList = spList.stream().map(StoragePrice::getStorageId).collect(Collectors.toList());
  317 + if(CollectionUtils.isNotEmpty(productIdList)) {
  318 + for(Integer productId : productIdList) {
  319 + LOG.info("clearCache queryProductDetailById productId = {}, ", productId);
  320 + //商品详情
  321 + cacheAop.clearCache(
  322 + ProductController.class.getMethod("queryProductDetailById", new Class[] { Integer.class }),
  323 + new Object[] { productId });
  324 + }
  325 + }
  326 + if(CollectionUtils.isNotEmpty(storageIdList)) {
  327 + for(Integer storageId : storageIdList) {
  328 + // sku最低价
  329 + LOG.info("clearCache queryStorageLeastprice storageId = {}, ", storageId);
  330 + cacheAop.clearCache(
  331 + ProductController.class.getMethod("queryStorageLeastprice", new Class[] { Integer.class }),
  332 + new Object[] { storageId });
  333 + }
  334 + }
  335 + } catch (Exception e) {
  336 + LOG.error("删除商品缓存失败!", e);
  337 + }
  338 + });
  339 + }
260 } 340 }
1 package com.yohoufo.product.service; 1 package com.yohoufo.product.service;
2 2
3 -import com.yoho.core.dal.datasource.annotation.Database; 3 +import java.util.List;
  4 +
4 import com.yohoufo.dal.product.model.StoragePrice; 5 import com.yohoufo.dal.product.model.StoragePrice;
5 import com.yohoufo.product.request.StoragePriceBo; 6 import com.yohoufo.product.request.StoragePriceBo;
6 -import com.yohoufo.product.response.*;  
7 -import org.springframework.transaction.annotation.Transactional; 7 +import com.yohoufo.product.response.ProductDetailResp;
  8 +import com.yohoufo.product.response.ProductSeriesTemplateResp;
  9 +import com.yohoufo.product.response.ProductSimpleResp;
  10 +import com.yohoufo.product.response.ProductSortTemplateResp;
  11 +import com.yohoufo.product.response.StorageDataResp;
  12 +import com.yohoufo.product.response.StorageLeastPriceResp;
8 13
9 public interface ProductService { 14 public interface ProductService {
10 15
@@ -34,4 +39,15 @@ public interface ProductService { @@ -34,4 +39,15 @@ public interface ProductService {
34 39
35 // 查询商品的基本信息 40 // 查询商品的基本信息
36 ProductDetailResp queryProductBaseInfo(Integer productId); 41 ProductDetailResp queryProductBaseInfo(Integer productId);
  42 +
  43 + void batchCreateSkup(List<StoragePriceBo> skupBoList);
  44 +
  45 + /**
  46 + * 卖家上架或下架商品
  47 + * @param skupList
  48 + * @param status
  49 + */
  50 + void sellerBatchUpdateStatus(List<Integer> skupList, int status);
  51 +
  52 + List<StoragePrice> getStoragePriceBySkupList(List<Integer> skupList);
37 } 53 }
@@ -6,20 +6,20 @@ import java.util.Comparator; @@ -6,20 +6,20 @@ import java.util.Comparator;
6 import java.util.HashMap; 6 import java.util.HashMap;
7 import java.util.List; 7 import java.util.List;
8 import java.util.Map; 8 import java.util.Map;
  9 +import java.util.Map.Entry;
9 import java.util.Objects; 10 import java.util.Objects;
10 import java.util.function.BinaryOperator; 11 import java.util.function.BinaryOperator;
11 import java.util.function.Function; 12 import java.util.function.Function;
12 import java.util.stream.Collectors; 13 import java.util.stream.Collectors;
13 14
14 -import com.yoho.core.dal.datasource.annotation.Database;  
15 import org.apache.commons.lang3.StringUtils; 15 import org.apache.commons.lang3.StringUtils;
16 import org.slf4j.Logger; 16 import org.slf4j.Logger;
17 import org.slf4j.LoggerFactory; 17 import org.slf4j.LoggerFactory;
18 import org.springframework.beans.factory.annotation.Autowired; 18 import org.springframework.beans.factory.annotation.Autowired;
19 import org.springframework.stereotype.Service; 19 import org.springframework.stereotype.Service;
20 -import org.springframework.transaction.annotation.Transactional;  
21 import org.springframework.util.CollectionUtils; 20 import org.springframework.util.CollectionUtils;
22 21
  22 +import com.google.common.collect.Lists;
23 import com.yoho.core.common.helpers.ImagesHelper; 23 import com.yoho.core.common.helpers.ImagesHelper;
24 import com.yoho.error.exception.ServiceException; 24 import com.yoho.error.exception.ServiceException;
25 import com.yohoufo.common.utils.DateUtil; 25 import com.yohoufo.common.utils.DateUtil;
@@ -169,6 +169,11 @@ public class ProductServiceImpl implements ProductService{ @@ -169,6 +169,11 @@ public class ProductServiceImpl implements ProductService{
169 public StoragePrice getStoragePriceBySkup(Integer skup) { 169 public StoragePrice getStoragePriceBySkup(Integer skup) {
170 return storagePriceMapper.selectBySkup(skup); 170 return storagePriceMapper.selectBySkup(skup);
171 } 171 }
  172 +
  173 + @Override
  174 + public List<StoragePrice> getStoragePriceBySkupList(List<Integer> skupList) {
  175 + return storagePriceMapper.selectBySkupList(skupList);
  176 + }
172 177
173 @Override 178 @Override
174 public ProductSortTemplateResp querySortTemplateData(String productIds) { 179 public ProductSortTemplateResp querySortTemplateData(String productIds) {
@@ -235,6 +240,22 @@ public class ProductServiceImpl implements ProductService{ @@ -235,6 +240,22 @@ public class ProductServiceImpl implements ProductService{
235 } 240 }
236 241
237 @Override 242 @Override
  243 + public void batchCreateSkup(List<StoragePriceBo> skupBoList) {
  244 + if(CollectionUtils.isEmpty(skupBoList)) {
  245 + throw new ServiceException(400, "skupBoList为空!");
  246 + }
  247 +
  248 + List<StoragePrice> spList = Lists.newArrayList();
  249 + //校验
  250 + for(int i=0; i<skupBoList.size(); i++) {
  251 + StoragePrice sp = exchangeCreateSkupBo(skupBoList.get(i));
  252 + spList.add(sp);
  253 + }
  254 + //批量插入数据库
  255 + storagePriceMapper.insertBatch(spList);
  256 + }
  257 +
  258 + @Override
238 public void sellerUpdateStatus(StoragePriceBo skupBo) { 259 public void sellerUpdateStatus(StoragePriceBo skupBo) {
239 // 卖家修改状态:*1:可售(支付保证金),2:取消支付保证金,3:超时未支付保证金,4:支付保证金后取消售卖 260 // 卖家修改状态:*1:可售(支付保证金),2:取消支付保证金,3:超时未支付保证金,4:支付保证金后取消售卖
240 if (skupBo == null) { 261 if (skupBo == null) {
@@ -280,6 +301,37 @@ public class ProductServiceImpl implements ProductService{ @@ -280,6 +301,37 @@ public class ProductServiceImpl implements ProductService{
280 } 301 }
281 302
282 @Override 303 @Override
  304 + public void sellerBatchUpdateStatus(List<Integer> skupList, int status) {
  305 + LOGGER.info("sellerBatchUpdateStatus in, skupList is {}, status is {}", skupList, status);
  306 + // 卖家修改上下架状态:*1:可售(支付保证金),商家上架,104:商家下架
  307 +
  308 + int updateNum = storagePriceMapper.batchUpdateStatus(skupList, status);
  309 + if(updateNum == 0) {
  310 + throw new ServiceException(400, "更新上架状态失败!");
  311 + }
  312 + //获取storageId
  313 + List<StoragePrice> storagePriceList = storagePriceMapper.selectBySkupList(skupList);
  314 + Map<Integer, List<StoragePrice>> storagePriceMap = storagePriceList.stream().collect(Collectors.groupingBy(StoragePrice::getStorageId));
  315 + List<Storage> storageReqList = Lists.newArrayList();
  316 + for(Entry<Integer, List<StoragePrice>> entry : storagePriceMap.entrySet()) {
  317 + Storage storage = new Storage();
  318 + storage.setId(entry.getKey());
  319 + if(status == 1) {
  320 + storage.setStorageNum(entry.getValue().size());
  321 + }else if(status == 104) {
  322 + storage.setStorageNum(-entry.getValue().size());
  323 + }
  324 +
  325 + storageReqList.add(storage);
  326 + }
  327 +
  328 + updateNum = storageMapper.batchAddStorageNum(storageReqList);
  329 + if(updateNum != storageReqList.size()) {
  330 + throw new ServiceException(400, "更新库存数量失败!");
  331 + }
  332 + }
  333 +
  334 + @Override
283 public void saleSkup(Integer productId, Integer skup) { 335 public void saleSkup(Integer productId, Integer skup) {
284 checkParamValid(productId, skup); 336 checkParamValid(productId, skup);
285 checkProductStatus(productId); 337 checkProductStatus(productId);