Merge branch 'dev_fast_delivery' of git.yoho.cn:ufo/yohoufo-fore into dev_fast_delivery
Showing
27 changed files
with
964 additions
and
24 deletions
@@ -4,6 +4,9 @@ package com.yohoufo.dal.order; | @@ -4,6 +4,9 @@ package com.yohoufo.dal.order; | ||
4 | import com.yohoufo.dal.order.model.OrdersPayTransfer; | 4 | import com.yohoufo.dal.order.model.OrdersPayTransfer; |
5 | import org.apache.ibatis.annotations.Param; | 5 | import org.apache.ibatis.annotations.Param; |
6 | 6 | ||
7 | +import java.util.Collection; | ||
8 | +import java.util.List; | ||
9 | + | ||
7 | public interface OrdersPayTransferMapper { | 10 | public interface OrdersPayTransferMapper { |
8 | 11 | ||
9 | int insert(OrdersPayTransfer record); | 12 | int insert(OrdersPayTransfer record); |
@@ -19,4 +22,6 @@ public interface OrdersPayTransferMapper { | @@ -19,4 +22,6 @@ public interface OrdersPayTransferMapper { | ||
19 | int updateByPrimaryKey(OrdersPayTransfer record); | 22 | int updateByPrimaryKey(OrdersPayTransfer record); |
20 | 23 | ||
21 | OrdersPayTransfer selectByBuyerOrderCode(long buyerOrderCode); | 24 | OrdersPayTransfer selectByBuyerOrderCode(long buyerOrderCode); |
25 | + | ||
26 | + List<OrdersPayTransfer> selectByBuyerOrderCodeList(@Param("orderCodes") Collection<Long> buyerOrderCode); | ||
22 | } | 27 | } |
1 | package com.yohoufo.dal.order; | 1 | package com.yohoufo.dal.order; |
2 | 2 | ||
3 | +import com.yohobuy.ufo.model.order.resp.FastDeliveryGetShelfDetailResp; | ||
3 | import com.yohoufo.dal.order.model.SellerOrderGoods; | 4 | import com.yohoufo.dal.order.model.SellerOrderGoods; |
4 | import com.yohoufo.dal.order.model.SellerOrderInfo; | 5 | import com.yohoufo.dal.order.model.SellerOrderInfo; |
5 | import org.apache.ibatis.annotations.Param; | 6 | import org.apache.ibatis.annotations.Param; |
@@ -47,6 +48,17 @@ public interface SellerOrderGoodsMapper { | @@ -47,6 +48,17 @@ public interface SellerOrderGoodsMapper { | ||
47 | 48 | ||
48 | int selectCntByUidStatusList(@Param("uid")int uid, @Param("statusList") List<Integer> statusList); | 49 | int selectCntByUidStatusList(@Param("uid")int uid, @Param("statusList") List<Integer> statusList); |
49 | 50 | ||
51 | + int selectCntByMulti(@Param("uid")int uid, @Param("status") Integer status, | ||
52 | + @Param("skup") Integer skup, @Param("orderCode") Long orderCode, | ||
53 | + @Param("startTime") Integer startTime, @Param("endTime") Integer endTime); | ||
54 | + | ||
55 | + | ||
56 | + List<FastDeliveryGetShelfDetailResp> selectInfoByMulti(@Param("uid")int uid, @Param("status") Integer status, | ||
57 | + @Param("skup") Integer skup, @Param("orderCode") Long orderCode, | ||
58 | + @Param("startTime") Integer startTime, @Param("endTime") Integer endTime, | ||
59 | + @Param("offset")Integer offset, | ||
60 | + @Param("limit")Integer limit); | ||
61 | + | ||
50 | List<SellerOrderGoods> selectByUidStatusList(@Param("uid")int uid, | 62 | List<SellerOrderGoods> selectByUidStatusList(@Param("uid")int uid, |
51 | @Param("statusList") List<Integer> statusList, | 63 | @Param("statusList") List<Integer> statusList, |
52 | @Param("offset")Integer offset, | 64 | @Param("offset")Integer offset, |
1 | package com.yohoufo.dal.order; | 1 | package com.yohoufo.dal.order; |
2 | 2 | ||
3 | +import java.util.Collection; | ||
3 | import java.util.List; | 4 | import java.util.List; |
4 | import java.util.Map; | 5 | import java.util.Map; |
5 | 6 | ||
@@ -33,6 +34,8 @@ public interface TradeBillsMapper { | @@ -33,6 +34,8 @@ public interface TradeBillsMapper { | ||
33 | 34 | ||
34 | List<TradeBills> selectByKeyProps(TradeBills condition); | 35 | List<TradeBills> selectByKeyProps(TradeBills condition); |
35 | 36 | ||
37 | + List<TradeBills> selectByOrderCodeList(@Param("orderCodes") Collection<Long> orderCodeList); | ||
38 | + | ||
36 | 39 | ||
37 | int updateLockOfUidTradeStatusAndDealTime(@Param("uid") Integer uid, @Param("tradeStatus") Integer tradeStatus, @Param("dealTime") Integer dealTime, | 40 | int updateLockOfUidTradeStatusAndDealTime(@Param("uid") Integer uid, @Param("tradeStatus") Integer tradeStatus, @Param("dealTime") Integer dealTime, |
38 | @Param("tagTradeStatus") Integer tagTradeStatus, @Param("tagDealTime") Integer tagDealTime); | 41 | @Param("tagTradeStatus") Integer tagTradeStatus, @Param("tagDealTime") Integer tagDealTime); |
@@ -18,7 +18,7 @@ public class ProductProfit { | @@ -18,7 +18,7 @@ public class ProductProfit { | ||
18 | 18 | ||
19 | private Byte delStatus; | 19 | private Byte delStatus; |
20 | 20 | ||
21 | - private BigDecimal profitMinPrice; // 费率价格下限 | 21 | + private BigDecimal profitMinPrice; |
22 | 22 | ||
23 | - private BigDecimal profitMaxPrice; // 费率价格上限 | 23 | + private BigDecimal profitMaxPrice; |
24 | } | 24 | } |
@@ -36,6 +36,7 @@ | @@ -36,6 +36,7 @@ | ||
36 | <foreach collection="skups" item="skup" separator="," open="(" close=")"> | 36 | <foreach collection="skups" item="skup" separator="," open="(" close=")"> |
37 | #{skup,jdbcType=INTEGER} | 37 | #{skup,jdbcType=INTEGER} |
38 | </foreach> | 38 | </foreach> |
39 | + order by id | ||
39 | </select> | 40 | </select> |
40 | 41 | ||
41 | <select id="selectByOrderCodeList" resultMap="BaseResultMap"> | 42 | <select id="selectByOrderCodeList" resultMap="BaseResultMap"> |
@@ -40,6 +40,16 @@ | @@ -40,6 +40,16 @@ | ||
40 | where buyer_order_code = #{buyerOrderCode,jdbcType=INTEGER} | 40 | where buyer_order_code = #{buyerOrderCode,jdbcType=INTEGER} |
41 | </select> | 41 | </select> |
42 | 42 | ||
43 | + <select id="selectByBuyerOrderCodeList" resultMap="BaseResultMap" parameterType="java.lang.Long" > | ||
44 | + select | ||
45 | + <include refid="Base_Column_List" /> | ||
46 | + from orders_pay_transfer | ||
47 | + where buyer_order_code IN | ||
48 | + <foreach collection="orderCodes" item="orderCode" open="(" separator="," close=")"> | ||
49 | + #{orderCode,jdbcType=BIGINT} | ||
50 | + </foreach> | ||
51 | + </select> | ||
52 | + | ||
43 | <select id="selectByUidAndTransferType" resultType="java.lang.Integer" parameterType="java.lang.Integer" > | 53 | <select id="selectByUidAndTransferType" resultType="java.lang.Integer" parameterType="java.lang.Integer" > |
44 | select | 54 | select |
45 | count(1) | 55 | count(1) |
@@ -151,6 +151,55 @@ | @@ -151,6 +151,55 @@ | ||
151 | select count(*) from seller_order_goods where uid = #{uid,jdbcType=INTEGER} | 151 | select count(*) from seller_order_goods where uid = #{uid,jdbcType=INTEGER} |
152 | </select> | 152 | </select> |
153 | 153 | ||
154 | + <select id="selectCntByMulti" resultType="java.lang.Integer"> | ||
155 | + select count(1) from seller_order_goods sog, seller_order so | ||
156 | + where sog.id=so.skup and so.uid= #{uid,jdbcType=INTEGER} | ||
157 | + <if test="skup != null"> | ||
158 | + and sog.id=#{skup,jdbcType=INTEGER} | ||
159 | + </if> | ||
160 | + <if test="orderCode != null"> | ||
161 | + and so.order_code=#{orderCode,jdbcType=INTEGER} | ||
162 | + </if> | ||
163 | + <if test="status != null"> | ||
164 | + and sog.status=#{status,jdbcType=INTEGER} | ||
165 | + </if> | ||
166 | + <if test="startTime != null"> | ||
167 | + and <![CDATA[ so.create_time >= #{startTime,jdbcType=INTEGER}]]> | ||
168 | + </if> | ||
169 | + <if test="endTime != null"> | ||
170 | + and <![CDATA[ so.create_time <= #{endTime,jdbcType=INTEGER}]]> | ||
171 | + </if> | ||
172 | + </select> | ||
173 | + | ||
174 | + | ||
175 | + <select id="selectInfoByMulti" resultType="com.yohobuy.ufo.model.order.resp.FastDeliveryGetShelfDetailResp"> | ||
176 | + select | ||
177 | + sog.uid, | ||
178 | + sog.id skup, so.order_code orderCode, sog.storage_id storageId, sog.product_name productName, | ||
179 | + sog.size_name sizeName, | ||
180 | + sog.product_id productId, sog.status, sog.goods_price price | ||
181 | + from seller_order_goods sog, seller_order so | ||
182 | + where sog.id=so.skup | ||
183 | + and so.uid= #{uid,jdbcType=INTEGER} | ||
184 | + <if test="skup != null"> | ||
185 | + and sog.id=#{skup,jdbcType=INTEGER} | ||
186 | + </if> | ||
187 | + <if test="orderCode != null"> | ||
188 | + and so.order_code=#{orderCode,jdbcType=INTEGER} | ||
189 | + </if> | ||
190 | + <if test="status != null"> | ||
191 | + and sog.status=#{status,jdbcType=INTEGER} | ||
192 | + </if> | ||
193 | + <if test="startTime != null"> | ||
194 | + and <![CDATA[ so.create_time >= #{startTime,jdbcType=INTEGER}]]> | ||
195 | + </if> | ||
196 | + <if test="endTime != null"> | ||
197 | + and <![CDATA[ so.create_time <= #{endTime,jdbcType=INTEGER}]]> | ||
198 | + </if> | ||
199 | + order by so.create_time desc | ||
200 | + limit #{offset, jdbcType=INTEGER}, #{limit, jdbcType=INTEGER} | ||
201 | + </select> | ||
202 | + | ||
154 | <select id="selectByUidStatusList" resultMap="BaseResultMap"> | 203 | <select id="selectByUidStatusList" resultMap="BaseResultMap"> |
155 | select <include refid="Base_Column_List" /> from seller_order_goods | 204 | select <include refid="Base_Column_List" /> from seller_order_goods |
156 | where <include refid="sql_where_4_select_UidStatusList"/> | 205 | where <include refid="sql_where_4_select_UidStatusList"/> |
@@ -204,6 +204,19 @@ | @@ -204,6 +204,19 @@ | ||
204 | </if> | 204 | </if> |
205 | </select> | 205 | </select> |
206 | 206 | ||
207 | + | ||
208 | + <select id="selectByOrderCodeList" resultMap="BaseResultMap"> | ||
209 | + select | ||
210 | + <include refid="Base_Column_List" /> | ||
211 | + from trade_bills | ||
212 | + where 1=1 and order_code in | ||
213 | + <foreach collection="orderCodes" item="orderCode" open="(" separator="," close=")"> | ||
214 | + #{orderCode,jdbcType=BIGINT} | ||
215 | + </foreach> | ||
216 | + | ||
217 | + </select> | ||
218 | + | ||
219 | + | ||
207 | <update id="updateLockOfUidTradeStatusAndDealTime" > | 220 | <update id="updateLockOfUidTradeStatusAndDealTime" > |
208 | update trade_bills | 221 | update trade_bills |
209 | set trade_status = #{tagTradeStatus,jdbcType=INTEGER},deal_time = #{tagDealTime,jdbcType=INTEGER} | 222 | set trade_status = #{tagTradeStatus,jdbcType=INTEGER},deal_time = #{tagDealTime,jdbcType=INTEGER} |
@@ -5,24 +5,41 @@ package com.yohoufo.order.common; | @@ -5,24 +5,41 @@ package com.yohoufo.order.common; | ||
5 | * Created by chao.chen on 2018/10/24. | 5 | * Created by chao.chen on 2018/10/24. |
6 | */ | 6 | */ |
7 | public enum BillTradeStatus { | 7 | public enum BillTradeStatus { |
8 | - NEW(0), | ||
9 | - TRANSFER_WAITING(90), | ||
10 | - SUCCESS(100), | ||
11 | - FAIL(200), | ||
12 | - NOT_EXIST_ALIPAY_ACCOUNT(201), | ||
13 | - AMOUNT_IS_ILLEGAL(202), | ||
14 | - HK_AMOUNT_WAIT_PAYMENT(203), | ||
15 | - YOHO_STORE_AMOUNT_WAIT_PAYMENT(204), | ||
16 | - HK_AMOUNT_PAYING(213), | ||
17 | - TRANSFER_FAIL(299); | 8 | + NEW(0, ""), |
9 | + TRANSFER_WAITING(90 ,"等待付款结果"), | ||
10 | + SUCCESS(100, "成功"), | ||
11 | + FAIL(200, "失败"), | ||
12 | + NOT_EXIST_ALIPAY_ACCOUNT(201, "没有支付宝账号"), | ||
13 | + AMOUNT_IS_ILLEGAL(202, "金额不合法"), | ||
14 | + HK_AMOUNT_WAIT_PAYMENT(203, "海外卖家等待付款"), | ||
15 | + YOHO_STORE_AMOUNT_WAIT_PAYMENT(204, ""), | ||
16 | + HK_AMOUNT_PAYING(213, ""), | ||
17 | + TRANSFER_FAIL(299, "转账失败"); | ||
18 | 18 | ||
19 | int code; | 19 | int code; |
20 | + String desc; | ||
20 | 21 | ||
21 | - BillTradeStatus(int code) { | 22 | + public String getDesc() { |
23 | + return desc; | ||
24 | + } | ||
25 | + | ||
26 | + BillTradeStatus(int code, String desc) | ||
27 | + { | ||
22 | this.code = code; | 28 | this.code = code; |
29 | + this.desc = desc; | ||
23 | } | 30 | } |
24 | 31 | ||
25 | public int getCode() { | 32 | public int getCode() { |
26 | return code; | 33 | return code; |
27 | } | 34 | } |
35 | + | ||
36 | + | ||
37 | + public static BillTradeStatus getTradeTypeByCode(int code){ | ||
38 | + for(BillTradeStatus v : values()){ | ||
39 | + if(v.code == code){ | ||
40 | + return v; | ||
41 | + } | ||
42 | + } | ||
43 | + return NEW; | ||
44 | + } | ||
28 | } | 45 | } |
1 | +package com.yohoufo.order.controller; | ||
2 | + | ||
3 | +import com.google.common.base.Throwables; | ||
4 | +import com.yohobuy.ufo.model.order.req.FastDeliveryAdjustPriceReq; | ||
5 | +import com.yohobuy.ufo.model.order.req.FastDeliveryBatchOnShelfReq; | ||
6 | +import com.yohobuy.ufo.model.order.req.FastDeliveryDownShelfReq; | ||
7 | +import com.yohobuy.ufo.model.order.req.FastDeliveryGetShelfReq; | ||
8 | +import com.yohobuy.ufo.model.order.resp.FastDeliveryGetShelfResp; | ||
9 | +import com.yohoufo.common.ApiResponse; | ||
10 | +import com.yohoufo.common.annotation.IgnoreSession; | ||
11 | +import com.yohoufo.common.annotation.IgnoreSignature; | ||
12 | +import com.yohoufo.common.exception.UfoServiceException; | ||
13 | +import com.yohoufo.order.service.IErpFastDeliveryService; | ||
14 | +import org.slf4j.Logger; | ||
15 | +import org.slf4j.LoggerFactory; | ||
16 | +import org.springframework.beans.factory.annotation.Autowired; | ||
17 | +import org.springframework.web.bind.annotation.RequestBody; | ||
18 | +import org.springframework.web.bind.annotation.RequestMapping; | ||
19 | +import org.springframework.web.bind.annotation.RestController; | ||
20 | + | ||
21 | +/** | ||
22 | + * 急速发货第三方对接接口 | ||
23 | + */ | ||
24 | +@RestController | ||
25 | +@RequestMapping("/fastDelivery") | ||
26 | +public class ErpFastDeliveryController { | ||
27 | + | ||
28 | + private final Logger logger = LoggerFactory.getLogger(this.getClass()); | ||
29 | + | ||
30 | + @Autowired | ||
31 | + IErpFastDeliveryService erpFastDeliveryService; | ||
32 | + | ||
33 | + /** | ||
34 | + * 批量上架 | ||
35 | + * @param req | ||
36 | + * @return | ||
37 | + */ | ||
38 | + @IgnoreSignature | ||
39 | + @IgnoreSession | ||
40 | + @RequestMapping("/batchOnShelf") | ||
41 | + public ApiResponse batchOnShelf(@RequestBody FastDeliveryBatchOnShelfReq req){ | ||
42 | + | ||
43 | + ApiResponse resp; | ||
44 | + int code =200; | ||
45 | + String msg = "成功"; | ||
46 | + try{ | ||
47 | + erpFastDeliveryService.batchOnShelf(req); | ||
48 | + }catch (Exception ex){ | ||
49 | + code = 500; | ||
50 | + if(ex instanceof UfoServiceException){ | ||
51 | + msg = ex.getMessage(); | ||
52 | + }else{ | ||
53 | + msg = "系统错误"; | ||
54 | + } | ||
55 | + logger.warn("batchOnShelf fail, req {}, error {}", req, Throwables.getStackTraceAsString(ex)); | ||
56 | + }finally { | ||
57 | + resp = new ApiResponse(); | ||
58 | + resp.setCode(code); | ||
59 | + resp.setMessage(msg); | ||
60 | + return resp; | ||
61 | + } | ||
62 | + } | ||
63 | + | ||
64 | + | ||
65 | + /** | ||
66 | + * 单个下架 | ||
67 | + * @param req | ||
68 | + * @return | ||
69 | + */ | ||
70 | + @IgnoreSignature | ||
71 | + @IgnoreSession | ||
72 | + @RequestMapping("/singleDownSelf") | ||
73 | + public ApiResponse singleDownSelf(@RequestBody FastDeliveryDownShelfReq req){ | ||
74 | + | ||
75 | + boolean result = erpFastDeliveryService.singleDownSelf(req); | ||
76 | + String msg = "下架成功"; | ||
77 | + if (!result) { | ||
78 | + msg = "下架失败"; | ||
79 | + } | ||
80 | + return new ApiResponse.ApiResponseBuilder().data(result).code(200).message(msg).build(); | ||
81 | + } | ||
82 | + | ||
83 | + | ||
84 | + /** | ||
85 | + * 单个调价 | ||
86 | + * @param req | ||
87 | + * @return | ||
88 | + */ | ||
89 | + @IgnoreSignature | ||
90 | + @IgnoreSession | ||
91 | + @RequestMapping("/singleAdjustPrice") | ||
92 | + public ApiResponse singleAdjustPrice(@RequestBody FastDeliveryAdjustPriceReq req){ | ||
93 | + | ||
94 | + boolean result = erpFastDeliveryService.singleAdjustPrice(req); | ||
95 | + String msg = "调价成功"; | ||
96 | + if (!result) { | ||
97 | + msg = "调价失败"; | ||
98 | + } | ||
99 | + return new ApiResponse.ApiResponseBuilder().data(result).code(200).message(msg).build(); | ||
100 | + } | ||
101 | + | ||
102 | + | ||
103 | + /** | ||
104 | + * 查询上架商品信息 | ||
105 | + * @param req | ||
106 | + * @return | ||
107 | + */ | ||
108 | + @IgnoreSignature | ||
109 | + @IgnoreSession | ||
110 | + @RequestMapping("/getShelfInfo") | ||
111 | + public ApiResponse getShelfInfo(@RequestBody FastDeliveryGetShelfReq req){ | ||
112 | + | ||
113 | + FastDeliveryGetShelfResp data = erpFastDeliveryService.getShelfInfo(req); | ||
114 | + | ||
115 | + return new ApiResponse.ApiResponseBuilder().data(data).code(200).build(); | ||
116 | + | ||
117 | + } | ||
118 | +} |
@@ -28,4 +28,13 @@ public class ImPrdNode{ | @@ -28,4 +28,13 @@ public class ImPrdNode{ | ||
28 | AddressInfo hiddenBackAddress; | 28 | AddressInfo hiddenBackAddress; |
29 | AddressInfo noHiddenBackAddress; | 29 | AddressInfo noHiddenBackAddress; |
30 | private Integer skupType; | 30 | private Integer skupType; |
31 | + | ||
32 | + /** | ||
33 | + * 货号 | ||
34 | + */ | ||
35 | + String productCode; | ||
36 | + /** | ||
37 | + * 尺寸 | ||
38 | + */ | ||
39 | + String sizeName; | ||
31 | } | 40 | } |
1 | +package com.yohoufo.order.service; | ||
2 | + | ||
3 | +import com.yohobuy.ufo.model.order.req.FastDeliveryAdjustPriceReq; | ||
4 | +import com.yohobuy.ufo.model.order.req.FastDeliveryBatchOnShelfReq; | ||
5 | +import com.yohobuy.ufo.model.order.req.FastDeliveryDownShelfReq; | ||
6 | +import com.yohobuy.ufo.model.order.req.FastDeliveryGetShelfReq; | ||
7 | +import com.yohobuy.ufo.model.order.resp.FastDeliveryGetShelfResp; | ||
8 | +import com.yohoufo.common.ApiResponse; | ||
9 | + | ||
10 | +public interface IErpFastDeliveryService { | ||
11 | + | ||
12 | + /** | ||
13 | + * 单个调价 | ||
14 | + * @param req | ||
15 | + * @return | ||
16 | + */ | ||
17 | + boolean singleAdjustPrice(FastDeliveryAdjustPriceReq req); | ||
18 | + | ||
19 | + /** | ||
20 | + * 批量上架 | ||
21 | + * @param req | ||
22 | + */ | ||
23 | + void batchOnShelf(FastDeliveryBatchOnShelfReq req); | ||
24 | + | ||
25 | + /** | ||
26 | + * 单个下架 | ||
27 | + * @param req | ||
28 | + */ | ||
29 | + boolean singleDownSelf(FastDeliveryDownShelfReq req); | ||
30 | + | ||
31 | + /** | ||
32 | + * 查询上架商品的信息 | ||
33 | + * @param req | ||
34 | + */ | ||
35 | + FastDeliveryGetShelfResp getShelfInfo(FastDeliveryGetShelfReq req); | ||
36 | +} |
@@ -101,6 +101,12 @@ public class SellerDownShelfTaskHandler extends AbstractSellerTaskHandler<SkupDo | @@ -101,6 +101,12 @@ public class SellerDownShelfTaskHandler extends AbstractSellerTaskHandler<SkupDo | ||
101 | } | 101 | } |
102 | try { | 102 | try { |
103 | 103 | ||
104 | + if (SellerGoodsHelper.isFastDelivery(sdspDto.getSkupType())){ | ||
105 | + //清理缓存 | ||
106 | + cleanCache(uid, skupDtoMap); | ||
107 | + return; | ||
108 | + } | ||
109 | + | ||
104 | boolean isQuickDeliver = SellerGoodsHelper.isQuickDeliver(sdspDto.getSkupType()); | 110 | boolean isQuickDeliver = SellerGoodsHelper.isQuickDeliver(sdspDto.getSkupType()); |
105 | if (!isQuickDeliver) { | 111 | if (!isQuickDeliver) { |
106 | boolean isSuper = sellerService.isSuperEntrySeller(uid); | 112 | boolean isSuper = sellerService.isSuperEntrySeller(uid); |
1 | +package com.yohoufo.order.service.impl; | ||
2 | + | ||
3 | +import com.alibaba.fastjson.JSON; | ||
4 | +import com.google.common.collect.Lists; | ||
5 | +import com.yohobuy.ufo.model.ProductInfo; | ||
6 | +import com.yohobuy.ufo.model.order.bo.SellerBo; | ||
7 | +import com.yohobuy.ufo.model.order.common.OrderStatus; | ||
8 | +import com.yohobuy.ufo.model.order.common.SellerFuncEnum; | ||
9 | +import com.yohobuy.ufo.model.order.common.SkupStatus; | ||
10 | +import com.yohobuy.ufo.model.order.constants.SkupType; | ||
11 | +import com.yohobuy.ufo.model.order.req.*; | ||
12 | +import com.yohobuy.ufo.model.order.resp.FastDeliveryGetShelfDetailResp; | ||
13 | +import com.yohobuy.ufo.model.order.resp.FastDeliveryGetShelfResp; | ||
14 | +import com.yohobuy.ufo.model.order.resp.OrderListInfo; | ||
15 | +import com.yohobuy.ufo.model.order.resp.PageResp; | ||
16 | +import com.yohobuy.ufo.model.request.product.ProductImportTranItemBo; | ||
17 | +import com.yohobuy.ufo.model.response.ProductDetailResp; | ||
18 | +import com.yohoufo.common.exception.UfoServiceException; | ||
19 | +import com.yohoufo.dal.order.*; | ||
20 | +import com.yohoufo.dal.order.model.*; | ||
21 | +import com.yohoufo.order.common.BillTradeStatus; | ||
22 | +import com.yohoufo.order.common.TradeType; | ||
23 | +import com.yohoufo.order.model.dto.*; | ||
24 | +import com.yohoufo.order.service.IErpFastDeliveryService; | ||
25 | +import com.yohoufo.order.service.handler.SellerDecrPriceTaskHandler; | ||
26 | +import com.yohoufo.order.service.handler.SellerDownShelfTaskHandler; | ||
27 | +import com.yohoufo.order.service.handler.SellerIncrPriceTaskHandler; | ||
28 | +import com.yohoufo.order.service.handler.SellerOrderSubmitHandler; | ||
29 | +import com.yohoufo.order.service.proxy.ProductProxyService; | ||
30 | +import com.yohoufo.order.service.seller.ImportPublishExcutor; | ||
31 | +import com.yohoufo.order.service.seller.SellerAuthCheckService; | ||
32 | +import com.yohoufo.order.service.seller.processor.AdjustPricePrepareProcessor; | ||
33 | +import com.yohoufo.order.service.seller.processor.PriceComputePrepareProcessor; | ||
34 | +import com.yohoufo.order.service.seller.processor.SellerDownShelfPrepareProcessor; | ||
35 | +import com.yohoufo.order.service.seller.processor.SellerTaskProcessor; | ||
36 | +import com.yohoufo.order.service.seller.setting.SellerFuncService; | ||
37 | +import com.yohoufo.order.service.seller.setting.SellerService; | ||
38 | +import com.yohoufo.order.service.seller.setting.SellerWrapper; | ||
39 | +import org.apache.commons.collections.CollectionUtils; | ||
40 | +import org.apache.commons.lang.StringUtils; | ||
41 | +import org.slf4j.Logger; | ||
42 | +import org.slf4j.LoggerFactory; | ||
43 | +import org.springframework.beans.factory.annotation.Autowired; | ||
44 | +import org.springframework.stereotype.Service; | ||
45 | + | ||
46 | +import java.math.BigDecimal; | ||
47 | +import java.util.*; | ||
48 | +import java.util.function.Function; | ||
49 | +import java.util.stream.Collectors; | ||
50 | + | ||
51 | +@Service | ||
52 | +public class ErpFastDeliveryServiceImpl implements IErpFastDeliveryService { | ||
53 | + | ||
54 | + private final Logger logger = LoggerFactory.getLogger(this.getClass()); | ||
55 | + | ||
56 | + @Autowired | ||
57 | + private SellerService sellerService; | ||
58 | + | ||
59 | + @Autowired | ||
60 | + private SellerAuthCheckService sellerAuthCheckService; | ||
61 | + | ||
62 | + @Autowired | ||
63 | + private SellerFuncService sellerFuncService; | ||
64 | + | ||
65 | + @Autowired | ||
66 | + ImportPublishExcutor importPublishExcutor; | ||
67 | + | ||
68 | + @Autowired | ||
69 | + private ProductProxyService productProxyService; | ||
70 | + | ||
71 | + @Autowired | ||
72 | + private SellerDownShelfPrepareProcessor sellerDownShelfPrepareProcessor; | ||
73 | + | ||
74 | + @Autowired | ||
75 | + private SellerDownShelfTaskHandler sellerDownShelfTaskHandler; | ||
76 | + | ||
77 | + @Autowired | ||
78 | + private SellerTaskProcessor sellerTaskProcessor; | ||
79 | + | ||
80 | + @Autowired | ||
81 | + private AdjustPricePrepareProcessor adjustPricePrepareProcessor; | ||
82 | + | ||
83 | + @Autowired | ||
84 | + private SellerIncrPriceTaskHandler sellerIncrPriceTaskHandler; | ||
85 | + | ||
86 | + @Autowired | ||
87 | + private SellerDecrPriceTaskHandler sellerDecrPriceTaskHandler; | ||
88 | + | ||
89 | + @Autowired | ||
90 | + PriceComputePrepareProcessor priceComputePrepareProcessor; | ||
91 | + | ||
92 | + @Autowired | ||
93 | + private SellerOrderGoodsMapper sellerOrderGoodsMapper; | ||
94 | + | ||
95 | + @Autowired | ||
96 | + private BuyerOrderMapper buyerOrderMapper; | ||
97 | + | ||
98 | + @Autowired | ||
99 | + private BuyerOrderGoodsMapper buyerOrderGoodsMapper; | ||
100 | + | ||
101 | + @Autowired | ||
102 | + private OrdersPayTransferMapper ordersPayTransferMapper; | ||
103 | + | ||
104 | + @Autowired | ||
105 | + private TradeBillsMapper tradeBillsMapper; | ||
106 | + | ||
107 | + /** | ||
108 | + * 货款收入 | ||
109 | + */ | ||
110 | + private static List<Integer> GOODS_INCOME = Lists.newArrayList(OrderStatus.JUDGE_PASS.getCode(), OrderStatus.WAITING_RECEIVE.getCode(), | ||
111 | + OrderStatus.DONE.getCode()); | ||
112 | + | ||
113 | + /** | ||
114 | + * 保证金扣除 | ||
115 | + */ | ||
116 | + private static List<Integer> DEDUCTION_EARNEST_MONEY = Lists.newArrayList(OrderStatus.SEND_OUT_TIMEOUT.getCode(), | ||
117 | + OrderStatus.CHECKING_FAKE.getCode(), | ||
118 | + OrderStatus.PLATFORM_DETECTION_NOT_PASS.getCode(), | ||
119 | + OrderStatus.QUALITY_CHECK_FAKE.getCode(), | ||
120 | + OrderStatus.SELLER_SHAM_SEND_OUT.getCode()); | ||
121 | + | ||
122 | + /** | ||
123 | + * 因为买家原因获得的收入 | ||
124 | + */ | ||
125 | + private static List<Integer> BUYER_REASON_INCOME = Lists.newArrayList(OrderStatus.BUYER_CANCEL_BEFORE_DEPOT_RECEIVE.getCode(), | ||
126 | + OrderStatus.BUYER_CANCEL_BEFORE_SELLER_DELIVER.getCode()); | ||
127 | + | ||
128 | + | ||
129 | + /** | ||
130 | + * 查询上架商品的信息 | ||
131 | + * @param req | ||
132 | + */ | ||
133 | + public FastDeliveryGetShelfResp getShelfInfo(FastDeliveryGetShelfReq req) { | ||
134 | + | ||
135 | + if (req.getUid() < 0) { | ||
136 | + logger.warn("uid is empty"); | ||
137 | + throw new UfoServiceException(400, "必须指定卖家"); | ||
138 | + } | ||
139 | + | ||
140 | + if (req.getLimit() <= 0){ | ||
141 | + req.setLimit(10); // 默认值 | ||
142 | + } | ||
143 | + | ||
144 | + if (req.getPage() <= 0){ | ||
145 | + req.setPage(1); | ||
146 | + } | ||
147 | + | ||
148 | + int total = sellerOrderGoodsMapper.selectCntByMulti(req.getUid(), req.getStatus(), req.getSkup(), | ||
149 | + req.getOrderCode(), req.getStartTime(), req.getEndTime()); | ||
150 | + if (total == 0) { | ||
151 | + return null; | ||
152 | + } | ||
153 | + | ||
154 | + int limit = req.getLimit(); | ||
155 | + int offset = (req.getPage() - 1) * limit; | ||
156 | + | ||
157 | + List<FastDeliveryGetShelfDetailResp> list = sellerOrderGoodsMapper.selectInfoByMulti(req.getUid(), req.getStatus(), | ||
158 | + req.getSkup(), req.getOrderCode(), req.getStartTime(), req.getEndTime(), offset, limit); | ||
159 | + | ||
160 | + // product_id -----> productCode | ||
161 | + Map<Integer, ProductInfo> productInfoMap = productProxyService.getProductCodeList(list.stream().map(FastDeliveryGetShelfDetailResp::getProductId).collect(Collectors.toList())); | ||
162 | + | ||
163 | + // 对账信息 以买家订单号的状态为准 | ||
164 | + List<Integer> skupLists = list.stream().map(FastDeliveryGetShelfDetailResp::getSkup).collect(Collectors.toList()); | ||
165 | + List<BuyerOrderGoods> buyerOrderGoodList = buyerOrderGoodsMapper.selectBySkups(skupLists); | ||
166 | + // skup ---> buyer orderCode (取最新的一个) | ||
167 | + Map<Integer, Long> skupToOrderCode = buyerOrderGoodList.stream().collect(Collectors.toMap(BuyerOrderGoods::getSkup, BuyerOrderGoods::getOrderCode, (key1, key2) -> key2)); | ||
168 | + | ||
169 | + Collection<Long> buyerOrderCodeList = skupToOrderCode.values(); | ||
170 | + | ||
171 | + Map<Long, BuyerOrder> orderCodeToBuyer = null; | ||
172 | + Map<Long, List<TradeBills>> buyerOrderToTradeBills = null; | ||
173 | + if (CollectionUtils.isNotEmpty(buyerOrderCodeList)){ | ||
174 | + List<BuyerOrder> buyerOrderList = buyerOrderMapper.selectByOrderCodes(buyerOrderCodeList, null); | ||
175 | + // buyer orderCode ---> buyer order | ||
176 | + orderCodeToBuyer = buyerOrderList.stream().collect(Collectors.toMap(BuyerOrder::getOrderCode, Function.identity(), (key1, key2) -> key2)); | ||
177 | + | ||
178 | + // 交易记录 | ||
179 | + List<TradeBills> tradeBillsList = tradeBillsMapper.selectByOrderCodeList(buyerOrderCodeList); | ||
180 | + // buyer orderCode ---> ordersPayTransfer | ||
181 | + buyerOrderToTradeBills = tradeBillsList.stream().collect(Collectors.groupingBy(TradeBills::getOrderCode)); | ||
182 | + } | ||
183 | + | ||
184 | + // 对账信息 | ||
185 | + // 鉴定通过 -- 货款收入 | ||
186 | + // 鉴定不通过 -- 保证金扣款 | ||
187 | + // 买家取消时 -- 扣款 | ||
188 | + Map<Long, BuyerOrder> finalOrderCodeToBuyer = orderCodeToBuyer; | ||
189 | + Map<Long, List<TradeBills>> finalBuyerOrderToTradeBills = buyerOrderToTradeBills; | ||
190 | + List<FastDeliveryGetShelfDetailResp> data = list.stream().map(sellerOrder -> { | ||
191 | + return covertToFastDeliveryShelfResp(productInfoMap, skupToOrderCode, finalOrderCodeToBuyer, finalBuyerOrderToTradeBills, sellerOrder); | ||
192 | + }).collect(Collectors.toList()); | ||
193 | + | ||
194 | + | ||
195 | + FastDeliveryGetShelfResp fastDeliveryGetShelfResp = new FastDeliveryGetShelfResp(); | ||
196 | + fastDeliveryGetShelfResp.setData(data); | ||
197 | + fastDeliveryGetShelfResp.setPage(req.getPage()); | ||
198 | + fastDeliveryGetShelfResp.setPageSize(req.getLimit()); | ||
199 | + fastDeliveryGetShelfResp.setTotal(total); | ||
200 | + fastDeliveryGetShelfResp.setPagetotal((total % limit == 0) ? (total / limit) : (total / limit + 1)); | ||
201 | + | ||
202 | + return fastDeliveryGetShelfResp; | ||
203 | + | ||
204 | + } | ||
205 | + | ||
206 | + private FastDeliveryGetShelfDetailResp covertToFastDeliveryShelfResp(Map<Integer, ProductInfo> productInfoMap, | ||
207 | + Map<Integer, Long> skupToOrderCode, | ||
208 | + Map<Long, BuyerOrder> orderCodeToBuyer, | ||
209 | + Map<Long, List<TradeBills>> buyerOrderToTradeBills, | ||
210 | + FastDeliveryGetShelfDetailResp sellerOrder) { | ||
211 | + | ||
212 | + if (productInfoMap != null){ | ||
213 | + sellerOrder.setProductCode(productInfoMap.getOrDefault(sellerOrder.getProductId(), new ProductInfo()).getProductCode()); | ||
214 | + } | ||
215 | + | ||
216 | + sellerOrder.setStatusDesc(SkupStatus.getSkupStatus(sellerOrder.getStatus()).getDesc()); | ||
217 | + | ||
218 | + // 商品是否是上架关闭 | ||
219 | + if (sellerOrder.getStatus() == SkupStatus.SELLER_CANCEL_SELL.getCode()) { | ||
220 | + // 无对账信息 | ||
221 | + return sellerOrder; | ||
222 | + } | ||
223 | + | ||
224 | + // 是否存在买家订单 | ||
225 | + Long buyerOrderCode = null; | ||
226 | + BuyerOrder buyerOrder = null; | ||
227 | + // 检查是否存在买家信息 | ||
228 | + if (skupToOrderCode == null | ||
229 | + || orderCodeToBuyer == null | ||
230 | + || (buyerOrderCode=skupToOrderCode.get(sellerOrder.getSkup()))==null | ||
231 | + || (buyerOrder=orderCodeToBuyer.get(buyerOrderCode)) == null){ | ||
232 | + return sellerOrder; | ||
233 | + } | ||
234 | + | ||
235 | + | ||
236 | + // 买家 | ||
237 | + FastDeliveryGetShelfDetailResp.BuyerOrder buyerOrderResp = new FastDeliveryGetShelfDetailResp.BuyerOrder(); | ||
238 | + buyerOrderResp.setOrderCode(buyerOrderCode); | ||
239 | + buyerOrderResp.setStatus(buyerOrder.getStatus()); | ||
240 | + buyerOrderResp.setStatusDesc(OrderStatus.getOrderStatus(buyerOrder.getStatus()).getDesc()); | ||
241 | + sellerOrder.setBuyerOrderCode(buyerOrderResp); | ||
242 | + | ||
243 | + if (buyerOrderToTradeBills == null){ | ||
244 | + return sellerOrder; | ||
245 | + } | ||
246 | + | ||
247 | + List<TradeBills> tradeBills = buyerOrderToTradeBills.get(buyerOrderCode); | ||
248 | + if (CollectionUtils.isEmpty(tradeBills)) { | ||
249 | + return sellerOrder; | ||
250 | + } | ||
251 | + | ||
252 | + FastDeliveryGetShelfDetailResp.TradeBill tradeBillResp = new FastDeliveryGetShelfDetailResp.TradeBill(); | ||
253 | + // 货款收入 incomeOutcome 1:用户收入 2:用户支出 | ||
254 | + TradeBills one = null; | ||
255 | + if (GOODS_INCOME.contains(buyerOrder.getStatus())) { | ||
256 | + one = getOneTradeBills(tradeBills, sellerOrder.getUid(), TradeType.goods_income.getCode(), 1, buyerOrderCode); | ||
257 | + if (one != null){ | ||
258 | + tradeBillResp.setGoodIncome(one.getAmount()); | ||
259 | + tradeBillResp.setStatus(BillTradeStatus.getTradeTypeByCode(one.getTradeStatus()).getDesc()); | ||
260 | + } | ||
261 | + } | ||
262 | + // 保证金扣除 | ||
263 | + else if (DEDUCTION_EARNEST_MONEY.contains(buyerOrder.getStatus())) { | ||
264 | + one = getOneTradeBills(tradeBills, buyerOrder.getUid(), TradeType.compensateIncome.getCode(), 1, buyerOrderCode); | ||
265 | + if (one != null){ | ||
266 | + tradeBillResp.setEarnestMoneyDeduction(one.getAmount()); | ||
267 | + tradeBillResp.setStatus(BillTradeStatus.getTradeTypeByCode(one.getTradeStatus()).getDesc()); | ||
268 | + } | ||
269 | + } | ||
270 | + // 罚款收入 | ||
271 | + else if (BUYER_REASON_INCOME.contains(buyerOrder.getStatus())) { | ||
272 | + one = getOneTradeBills(tradeBills, sellerOrder.getUid(), TradeType.compensateIncome.getCode(), 1, buyerOrderCode); | ||
273 | + if (one != null){ | ||
274 | + tradeBillResp.setBuyerPenaltyIncome(one.getAmount()); | ||
275 | + tradeBillResp.setStatus(BillTradeStatus.getTradeTypeByCode(one.getTradeStatus()).getDesc()); | ||
276 | + } | ||
277 | + | ||
278 | + } | ||
279 | + | ||
280 | + sellerOrder.setTradeBill(tradeBillResp); | ||
281 | + | ||
282 | + return sellerOrder; | ||
283 | + } | ||
284 | + | ||
285 | + | ||
286 | + private TradeBills getOneTradeBills(List<TradeBills> tradeBills, int uid, Integer tradeType, Integer incomeOutcome, Long orderCode){ | ||
287 | + List<TradeBills> any = tradeBills.stream().filter(trade -> trade.getUid() == uid | ||
288 | + && trade.getTradeType() == tradeType | ||
289 | + && trade.getIncomeOutcome() == incomeOutcome).collect(Collectors.toList()); | ||
290 | + if (CollectionUtils.isEmpty(any)){ | ||
291 | + logger.warn("getOneTradeBills buyerOrderCode {}", orderCode); | ||
292 | + return null; | ||
293 | + } | ||
294 | + return any.stream().sorted(Comparator.comparing(TradeBills::getCreateTime).reversed()).limit(1).findFirst().get(); | ||
295 | + } | ||
296 | + | ||
297 | + | ||
298 | + /** | ||
299 | + * 单个调价 | ||
300 | + * @param req | ||
301 | + * @return | ||
302 | + */ | ||
303 | + public boolean singleAdjustPrice(FastDeliveryAdjustPriceReq req){ | ||
304 | + | ||
305 | + if (req.getUid() < 0){ | ||
306 | + logger.warn("uid is empty"); | ||
307 | + throw new UfoServiceException(400, "参数[uid]不合法"); | ||
308 | + } | ||
309 | + | ||
310 | + if (req.getSkup() < 0){ | ||
311 | + logger.warn("skup is empty"); | ||
312 | + throw new UfoServiceException(401, "参数[skup]不合法"); | ||
313 | + } | ||
314 | + | ||
315 | + if (StringUtils.isBlank(req.getNewPrice())){ | ||
316 | + logger.warn("price is invalidate"); | ||
317 | + throw new UfoServiceException(402, "参数[newPrice]不合法"); | ||
318 | + } | ||
319 | + | ||
320 | + ChangePricePrepareDTO cppDto = adjustPricePrepareProcessor.getChangePricePreDto(req); | ||
321 | + SellerTaskDTO<ChangePricePrepareDTO> taskDTO = null; | ||
322 | + if (cppDto.getSalePrice().compareTo(cppDto.getPreSalePrice()) > 0) { | ||
323 | + //涨价 | ||
324 | + taskDTO = new SellerTaskDTO(req.getUid(), | ||
325 | + SellerWalletDetail.Type.ADD_PRICE.getValue(), | ||
326 | + sellerIncrPriceTaskHandler, | ||
327 | + JSON.toJSONString(req),cppDto); | ||
328 | + } else if (cppDto.getSalePrice().compareTo(cppDto.getPreSalePrice()) < 0) { | ||
329 | + //降价 | ||
330 | + taskDTO = new SellerTaskDTO(req.getUid(), | ||
331 | + SellerWalletDetail.Type.SUBTRACT_PRICE.getValue(), | ||
332 | + sellerDecrPriceTaskHandler, | ||
333 | + JSON.toJSONString(req),cppDto); | ||
334 | + } else { | ||
335 | + throw new UfoServiceException(400, "价格没有变化"); | ||
336 | + } | ||
337 | + | ||
338 | + SellerTaskResult result = sellerTaskProcessor.process(taskDTO); | ||
339 | + return result.successCnt > 0 ? true : false; | ||
340 | + } | ||
341 | + | ||
342 | + /** | ||
343 | + * 单个下架 | ||
344 | + * @param req | ||
345 | + */ | ||
346 | + public boolean singleDownSelf(FastDeliveryDownShelfReq req){ | ||
347 | + | ||
348 | + if (req.getUid() < 0){ | ||
349 | + logger.warn("uid is empty"); | ||
350 | + throw new UfoServiceException(400, "参数[uid]不合法"); | ||
351 | + } | ||
352 | + | ||
353 | + if (req.getSkup() < 0){ | ||
354 | + logger.warn("skup is empty"); | ||
355 | + throw new UfoServiceException(401, "参数[skup]不合法"); | ||
356 | + } | ||
357 | + | ||
358 | + SkupDownShelfPrepareDto skupDtoMap = sellerDownShelfPrepareProcessor.getDownShelfPreDto(req.getSkup()); | ||
359 | + SellerTaskDTO<SkupDownShelfPrepareDto> taskDTO = new SellerTaskDTO(req.getUid(), | ||
360 | + SellerWalletDetail.Type.SELLER_OFF.getValue(), | ||
361 | + sellerDownShelfTaskHandler, | ||
362 | + JSON.toJSONString(req), | ||
363 | + skupDtoMap); | ||
364 | + | ||
365 | + SellerTaskResult result = sellerTaskProcessor.process(taskDTO); | ||
366 | + return result.successCnt > 0 ? true : false; | ||
367 | + } | ||
368 | + | ||
369 | + @Override | ||
370 | + public void batchOnShelf(FastDeliveryBatchOnShelfReq req) { | ||
371 | + | ||
372 | + // 检查入口参数 | ||
373 | + checkBatchOnShelf(req); | ||
374 | + | ||
375 | + // 检查用户权限(批量上架权限) | ||
376 | + int uid = req.getUid(); | ||
377 | + SellerWrapper sellerWrapper = sellerService.getFullDimensionSeller(req.getUid()); | ||
378 | + SellerBo sellerBo = sellerWrapper.buildSellerBo(); | ||
379 | + if (!sellerBo.isFastDeliverySuper()){ | ||
380 | + logger.warn("batchOnShelf not legal super, uid {} ", uid); | ||
381 | + throw new UfoServiceException(501, "用户权限不合法!"); | ||
382 | + } | ||
383 | + sellerWrapper = sellerWrapper.attachSellerLevelFunc((sw)->sellerFuncService.getSellerLevelFunc(sw)); | ||
384 | + sellerAuthCheckService.checkAuth(sellerBo, null, SellerFuncEnum.BATCH_PUBLISH); | ||
385 | + | ||
386 | + // 检查货号and尺寸是否存在 | ||
387 | + List<ProductInfoReq> productInfoReqList = req.getProductInfos().stream().map(x -> { | ||
388 | + ProductInfoReq productInfoReq = new ProductInfoReq(); | ||
389 | + productInfoReq.setProductCode(x.getProductCode()); | ||
390 | + productInfoReq.setSizeName(x.getSizeName()); | ||
391 | + return productInfoReq; | ||
392 | + }).distinct().collect(Collectors.toList()); | ||
393 | + | ||
394 | + // 调用商品服务获取到商品的storageId | ||
395 | + // 无法获取则异常 | ||
396 | + | ||
397 | + // 上架 | ||
398 | + List<ProductImportTranItemBo> responseList = Lists.newArrayList(); | ||
399 | + for(FastDeliveryBatchOnShelfReq.ProductInfo productInfo : req.getProductInfos()){ | ||
400 | + Integer storageId = productInfo.getStorageId(); | ||
401 | + BigDecimal salePrice = productInfo.getConvertedPrice(); | ||
402 | + int storageNum = productInfo.getNum(); | ||
403 | + ImPrdNode node = ImPrdNode.builder().uid(uid) | ||
404 | + .sellerWrapper(sellerWrapper) | ||
405 | + .storageId(storageId).salePrice(salePrice).storageNum(storageNum).productCode(productInfo.getProductCode()).sizeName(productInfo.getSizeName()) | ||
406 | + .skupType(SkupType.FAST_DELIVERY.getCode()) | ||
407 | + .build(); | ||
408 | + int successNum=0; | ||
409 | + try{ | ||
410 | + SellerOrderSubmitHandler.ForkJoinResult fjr = importPublishExcutor.publishOne(node); | ||
411 | + successNum = Objects.isNull(fjr) || Objects.isNull(fjr.getSkupIds()) ? 0 : fjr.getSkupIds().size(); | ||
412 | + | ||
413 | + responseList.add(buildShelfResp(req, productInfo, successNum)); | ||
414 | + }catch(Exception ex){ | ||
415 | + logger.warn("in batchOnShelf.publishOne fail, uid {} productCode {} sizeName {} storageId {} salePrice {} storageNum {}", | ||
416 | + uid, productInfo.getProductCode(), productInfo.getSizeName(), storageId, salePrice, storageNum); | ||
417 | + } | ||
418 | + } | ||
419 | + | ||
420 | + if (CollectionUtils.isNotEmpty(responseList)){ | ||
421 | + productProxyService.batchAdd(responseList); | ||
422 | + }else{ | ||
423 | + logger.warn("responseList empty"); | ||
424 | + throw new UfoServiceException(502, "上架失败!"); | ||
425 | + } | ||
426 | + | ||
427 | + } | ||
428 | + | ||
429 | + private ProductImportTranItemBo buildShelfResp(FastDeliveryBatchOnShelfReq req, FastDeliveryBatchOnShelfReq.ProductInfo productInfo, int successNum) { | ||
430 | + // 构造结果对象 最终结果插入到 商品服务的product_import_tran_item表中 | ||
431 | + ProductImportTranItemBo productImportTranItemBo = new ProductImportTranItemBo(); | ||
432 | + productImportTranItemBo.setUid(req.getUid()); | ||
433 | + productImportTranItemBo.setProductCode(productInfo.getProductCode()); | ||
434 | + productImportTranItemBo.setStorageId(productInfo.getStorageId()); | ||
435 | + productImportTranItemBo.setSizeName(productInfo.getSizeName()); | ||
436 | + productImportTranItemBo.setPrice(productInfo.getConvertedPrice()); | ||
437 | + productImportTranItemBo.setNum(productInfo.getNum()); | ||
438 | + productImportTranItemBo.setSuccessdNum(successNum); | ||
439 | + productImportTranItemBo.setTranId(0); // 不关心这个值 固定为0 | ||
440 | + return productImportTranItemBo; | ||
441 | + } | ||
442 | + | ||
443 | + | ||
444 | + private void checkBatchOnShelf(FastDeliveryBatchOnShelfReq req) { | ||
445 | + | ||
446 | + if (req.getUid() < 0){ | ||
447 | + logger.warn("uid is empty"); | ||
448 | + throw new UfoServiceException(400, "参数[uid]错误"); | ||
449 | + } | ||
450 | + | ||
451 | + if (CollectionUtils.isEmpty(req.getProductInfos())){ | ||
452 | + logger.warn("productInfo is empty"); | ||
453 | + throw new UfoServiceException(400, "商品信息为空"); | ||
454 | + } | ||
455 | + | ||
456 | + for(FastDeliveryBatchOnShelfReq.ProductInfo productInfo : req.getProductInfos()){ | ||
457 | + if (StringUtils.isBlank(productInfo.getSizeName()) | ||
458 | + || StringUtils.isBlank(productInfo.getProductCode()) | ||
459 | + || productInfo.getNum() == null){ | ||
460 | + logger.warn("productInfo is invalidate {}", productInfo); | ||
461 | + throw new UfoServiceException(400, "商品信息不合法"); | ||
462 | + } | ||
463 | + | ||
464 | + // 价格已9结尾 | ||
465 | + BigDecimal salePrice = priceComputePrepareProcessor.checkAndAcquireSalePrice(productInfo.getPrice(), SkupType.FAST_DELIVERY); | ||
466 | + productInfo.setConvertedPrice(salePrice); | ||
467 | + } | ||
468 | + } | ||
469 | +} |
@@ -143,6 +143,7 @@ public class MetaConfigService { | @@ -143,6 +143,7 @@ public class MetaConfigService { | ||
143 | case FLAW: | 143 | case FLAW: |
144 | case SECOND_HAND: | 144 | case SECOND_HAND: |
145 | case HK_IN_STOCK: | 145 | case HK_IN_STOCK: |
146 | + case FAST_DELIVERY: | ||
146 | cellKey = skupType.getLocalCacheKey(); | 147 | cellKey = skupType.getLocalCacheKey(); |
147 | break; | 148 | break; |
148 | } | 149 | } |
@@ -377,6 +377,7 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServic | @@ -377,6 +377,7 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServic | ||
377 | ErpCancelSellerOrderEvent event = ErpCancelSellerOrderEvent.builder().skup(skup).build(); | 377 | ErpCancelSellerOrderEvent event = ErpCancelSellerOrderEvent.builder().skup(skup).build(); |
378 | OffShelveCancelCase offShelveCancelCase = new OffShelveCancelCase(event); | 378 | OffShelveCancelCase offShelveCancelCase = new OffShelveCancelCase(event); |
379 | offShelveCancelCase.accept(sellerOrderCancelService); | 379 | offShelveCancelCase.accept(sellerOrderCancelService); |
380 | + sellerOrderCancelService.cancel(offShelveCancelCase); | ||
380 | return true; | 381 | return true; |
381 | } | 382 | } |
382 | 383 |
1 | package com.yohoufo.order.service.proxy; | 1 | package com.yohoufo.order.service.proxy; |
2 | 2 | ||
3 | import com.google.common.base.Throwables; | 3 | import com.google.common.base.Throwables; |
4 | +import com.sun.tools.corba.se.idl.ExceptionEntry; | ||
4 | import com.yohobuy.ufo.model.ProductInfo; | 5 | import com.yohobuy.ufo.model.ProductInfo; |
5 | import com.yohobuy.ufo.model.order.bo.GoodsInfo; | 6 | import com.yohobuy.ufo.model.order.bo.GoodsInfo; |
6 | import com.yohobuy.ufo.model.order.bo.PrdPrice; | 7 | import com.yohobuy.ufo.model.order.bo.PrdPrice; |
@@ -163,6 +164,18 @@ public class ProductProxyService extends AbsProxyService{ | @@ -163,6 +164,18 @@ public class ProductProxyService extends AbsProxyService{ | ||
163 | return new HashMap<>(); | 164 | return new HashMap<>(); |
164 | } | 165 | } |
165 | 166 | ||
167 | + public Map<Integer, ProductInfo> getProductCodeList(List<Integer> storageIdList){ | ||
168 | + | ||
169 | + try{ | ||
170 | + return ufoServiceCaller.call("ufo.product.list.data", storageIdList); | ||
171 | + }catch (Exception e){ | ||
172 | + logger.warn("getProductCode storageIdList {}", storageIdList); | ||
173 | + } | ||
174 | + | ||
175 | + return null; | ||
176 | + | ||
177 | + } | ||
178 | + | ||
166 | public PrdPrice getPrdPriceRange(Integer uid, | 179 | public PrdPrice getPrdPriceRange(Integer uid, |
167 | int storageId){ | 180 | int storageId){ |
168 | StorageDataResp storage = getStorageData(storageId); | 181 | StorageDataResp storage = getStorageData(storageId); |
@@ -39,7 +39,7 @@ public class SellerAuthCheckService { | @@ -39,7 +39,7 @@ public class SellerAuthCheckService { | ||
39 | int uid = sellerBo.getUid(); | 39 | int uid = sellerBo.getUid(); |
40 | EntrySellerType est = sellerBo.getEntrySellerType(); | 40 | EntrySellerType est = sellerBo.getEntrySellerType(); |
41 | boolean excludeSkupType = SellerGoodsHelper.isQuickDeliver(skupType); | 41 | boolean excludeSkupType = SellerGoodsHelper.isQuickDeliver(skupType); |
42 | - boolean includeSellerType = sellerBo.isNormalSuper() || sellerBo.isLargeSettlementSuper(); | 42 | + boolean includeSellerType = sellerBo.isNormalSuper() || sellerBo.isLargeSettlementSuper() || sellerBo.isFastDeliverySuper(); |
43 | 43 | ||
44 | if (!excludeSkupType && includeSellerType){ | 44 | if (!excludeSkupType && includeSellerType){ |
45 | SellerLevelFuncBo slfb = sellerBo.getSellerLevelFunc(); | 45 | SellerLevelFuncBo slfb = sellerBo.getSellerLevelFunc(); |
1 | +package com.yohoufo.order.service.seller.fastDelivery; | ||
2 | + | ||
3 | +import com.yohobuy.ufo.model.order.constants.SkupType; | ||
4 | +import com.yohoufo.order.model.dto.BuyerPenalty; | ||
5 | +import com.yohoufo.order.model.dto.EarnestMoney; | ||
6 | +import com.yohoufo.order.model.dto.PlatformFeeDto; | ||
7 | +import com.yohoufo.order.model.dto.ServiceFeeRate; | ||
8 | +import com.yohoufo.order.service.seller.AbsSellerOrderComputeHandler; | ||
9 | +import com.yohoufo.order.service.seller.OrderComputeHandler; | ||
10 | +import org.springframework.stereotype.Component; | ||
11 | + | ||
12 | +import java.math.BigDecimal; | ||
13 | +import java.util.Collection; | ||
14 | + | ||
15 | +@Component | ||
16 | +public class FastDeliveryOrderComputeHandler extends AbsSellerOrderComputeHandler implements OrderComputeHandler { | ||
17 | + | ||
18 | + | ||
19 | + @Override | ||
20 | + protected SkupType getSkupType() { | ||
21 | + return SkupType.FAST_DELIVERY; | ||
22 | + } | ||
23 | + | ||
24 | + | ||
25 | + | ||
26 | + @Override | ||
27 | + protected EarnestMoney getDefaultEarnestMoney() { | ||
28 | + EarnestMoney earnestMoney = new EarnestMoney(); | ||
29 | + earnestMoney.setRate(new BigDecimal(0.04D)); | ||
30 | + earnestMoney.setMin(new BigDecimal(28)); | ||
31 | + earnestMoney.setMax(new BigDecimal(200)); | ||
32 | + return earnestMoney; | ||
33 | + } | ||
34 | + | ||
35 | + | ||
36 | + | ||
37 | + @Override | ||
38 | + protected ServiceFeeRate buildDefaultServiceFeeRate() { | ||
39 | + ServiceFeeRate serviceFeeRate = new ServiceFeeRate(); | ||
40 | + serviceFeeRate.setGoodsPaymentRate(new BigDecimal(0.05)); | ||
41 | + serviceFeeRate.setPayChannelRate(new BigDecimal(0.01)); | ||
42 | + return serviceFeeRate; | ||
43 | + } | ||
44 | + | ||
45 | + @Override | ||
46 | + protected Collection<BuyerPenalty.Fee> buildStagedCollection() { | ||
47 | + return null; | ||
48 | + } | ||
49 | + | ||
50 | + | ||
51 | + @Override | ||
52 | + protected PlatformFeeDto buildDefaultPlatformFeeDto(){ | ||
53 | + PlatformFeeDto platformFeeDto = new PlatformFeeDto(); | ||
54 | + platformFeeDto.setPackageFee(new BigDecimal(packageFee)); | ||
55 | + platformFeeDto.setAppraiseFee(new BigDecimal(appraiseFee)); | ||
56 | + return platformFeeDto; | ||
57 | + } | ||
58 | +} |
@@ -7,6 +7,7 @@ import com.yohoufo.dal.order.model.SellerOrderMeta; | @@ -7,6 +7,7 @@ import com.yohoufo.dal.order.model.SellerOrderMeta; | ||
7 | import com.yohoufo.order.constants.MetaKey; | 7 | import com.yohoufo.order.constants.MetaKey; |
8 | import com.yohobuy.ufo.model.order.vo.AddressInfo; | 8 | import com.yohobuy.ufo.model.order.vo.AddressInfo; |
9 | import com.yohoufo.order.model.SellerOrderContext; | 9 | import com.yohoufo.order.model.SellerOrderContext; |
10 | +import org.apache.commons.lang3.StringUtils; | ||
10 | import org.springframework.beans.factory.annotation.Autowired; | 11 | import org.springframework.beans.factory.annotation.Autowired; |
11 | import org.springframework.stereotype.Service; | 12 | import org.springframework.stereotype.Service; |
12 | import org.springframework.transaction.annotation.Propagation; | 13 | import org.springframework.transaction.annotation.Propagation; |
@@ -49,7 +50,11 @@ public class SellerAddressService { | @@ -49,7 +50,11 @@ public class SellerAddressService { | ||
49 | public int saveBatchSendBackAddress(SellerOrderContext ctx, List<Integer> skupIds){ | 50 | public int saveBatchSendBackAddress(SellerOrderContext ctx, List<Integer> skupIds){ |
50 | int result = 0; | 51 | int result = 0; |
51 | String value = JSONObject.toJSONString(ctx.getBackAddress()); | 52 | String value = JSONObject.toJSONString(ctx.getBackAddress()); |
53 | + | ||
52 | String hValue = JSONObject.toJSONString(ctx.getBackHiddenAddress()); | 54 | String hValue = JSONObject.toJSONString(ctx.getBackHiddenAddress()); |
55 | + if (StringUtils.isEmpty(value) || StringUtils.isBlank(hValue)){ | ||
56 | + return result; | ||
57 | + } | ||
53 | List<SellerOrderMeta> list = new ArrayList<>( 2*skupIds.size() ); | 58 | List<SellerOrderMeta> list = new ArrayList<>( 2*skupIds.size() ); |
54 | for(Integer skupId : skupIds){ | 59 | for(Integer skupId : skupIds){ |
55 | SellerOrderMeta som = new SellerOrderMeta(); | 60 | SellerOrderMeta som = new SellerOrderMeta(); |
1 | package com.yohoufo.order.service.seller.processor; | 1 | package com.yohoufo.order.service.seller.processor; |
2 | 2 | ||
3 | +import com.google.common.collect.Maps; | ||
3 | import com.yohobuy.ufo.model.order.bo.PrdPrice; | 4 | import com.yohobuy.ufo.model.order.bo.PrdPrice; |
4 | import com.yohobuy.ufo.model.order.bo.SellerBo; | 5 | import com.yohobuy.ufo.model.order.bo.SellerBo; |
5 | import com.yohobuy.ufo.model.order.common.OrderStatus; | 6 | import com.yohobuy.ufo.model.order.common.OrderStatus; |
7 | +import com.yohobuy.ufo.model.order.common.SkupStatus; | ||
6 | import com.yohobuy.ufo.model.order.constants.SkupType; | 8 | import com.yohobuy.ufo.model.order.constants.SkupType; |
9 | +import com.yohobuy.ufo.model.order.req.FastDeliveryAdjustPriceReq; | ||
7 | import com.yohobuy.ufo.model.order.req.SellerBaseChangeReq; | 10 | import com.yohobuy.ufo.model.order.req.SellerBaseChangeReq; |
8 | import com.yohoufo.common.exception.UfoServiceException; | 11 | import com.yohoufo.common.exception.UfoServiceException; |
9 | import com.yohoufo.common.utils.BigDecimalHelper; | 12 | import com.yohoufo.common.utils.BigDecimalHelper; |
@@ -78,6 +81,73 @@ public abstract class AbsEntryChangePricePrepareProcessor<T extends SellerBaseCh | @@ -78,6 +81,73 @@ public abstract class AbsEntryChangePricePrepareProcessor<T extends SellerBaseCh | ||
78 | private SellerOrderRiskWatchDog sellerOrderRiskWatchDog; | 81 | private SellerOrderRiskWatchDog sellerOrderRiskWatchDog; |
79 | 82 | ||
80 | 83 | ||
84 | + final static List<Integer> CAN_OFF_STATUS = Arrays.asList(SkupStatus.CAN_SELL.getCode()); | ||
85 | + | ||
86 | + public ChangePricePrepareDTO getChangePricePreDto(FastDeliveryAdjustPriceReq req){ | ||
87 | + | ||
88 | + /** | ||
89 | + * 1. 检查skup的状态 出售中 | ||
90 | + * 2. 对应的买家订单 状态不可是 待付款 | ||
91 | + * 3. 价格必须以9即为 | ||
92 | + * 4. 调价前后价格有变化 | ||
93 | + * 5. 重新计算费率 | ||
94 | + */ | ||
95 | + | ||
96 | + SellerOrderGoods sog = sellerOrderGoodsMapper.selectByPrimaryKey(req.getSkup()); | ||
97 | + if (sog == null || (sog.getStatus() != null && !CAN_OFF_STATUS.contains(sog.getStatus()))){ | ||
98 | + logger.warn("getChangePricePreDto has buyed, skup {}", req.getSkup()); | ||
99 | + throw new UfoServiceException(501, "商品已被下单购买"); | ||
100 | + } | ||
101 | + | ||
102 | + List<BuyerOrderGoods> buyerOrderGoodsList = buyerOrderGoodsMapper.selectOrderBySkups(req.getSkup()); | ||
103 | + List<BuyerOrder> buyerOrderList = null; | ||
104 | + if (CollectionUtils.isNotEmpty(buyerOrderGoodsList)){ | ||
105 | + List<Long> orderCodeList = buyerOrderGoodsList.parallelStream() | ||
106 | + .map(BuyerOrderGoods::getOrderCode).collect(Collectors.toList()); | ||
107 | + buyerOrderList = buyerOrderMapper.selectByOrderCodes(orderCodeList, Arrays.asList(OrderStatus.WAITING_PAY.getCode())); | ||
108 | + } | ||
109 | + if (CollectionUtils.isNotEmpty(buyerOrderList)){ | ||
110 | + List<Long> waitingPayOrderCodes = buyerOrderList.parallelStream().map(BuyerOrder::getOrderCode).collect(Collectors.toList()); | ||
111 | + logger.warn("ChangePrice checkAndAcquire exist waiting pay skup , req {} waitingPayOrderCodes {}", req, waitingPayOrderCodes); | ||
112 | + throw new UfoServiceException(400, "部分商品正在等待买家支付"); | ||
113 | + } | ||
114 | + | ||
115 | + // 构造调价的任务的skupDto | ||
116 | + Map<Integer, SkupDto> skupMap = Maps.newHashMap(); | ||
117 | + skupMap.put(req.getSkup(), SkupDto.builder().skup(sog.getId()).sellerOrderGoods(sog).batchNo(sog.getBatchNo()).build()); | ||
118 | + | ||
119 | + SkupType skupType = SkupType.getSkupType(sog.getAttributes()); | ||
120 | + | ||
121 | + // 价格已9结尾 | ||
122 | + BigDecimal salePrice = priceComputePrepareProcessor.checkAndAcquireSalePrice(req.getNewPrice(), skupType); | ||
123 | + | ||
124 | + // 调价前后 价格有无变化 | ||
125 | + changePriceCommonPrepareProcessor.checkChangeNecessary(req.getSkup(), sog.getGoodsPrice(), salePrice); | ||
126 | + | ||
127 | + SellerOrder sellerOrder = sellerOrderMapper.selectBySkup(req.getSkup()); | ||
128 | + | ||
129 | + // compute every fee from price | ||
130 | + SellerOrderComputeResult pcc = goodsAmountService.getGoodsServiceFeeRate(req.getUid(), sog.getStorageId(), null, skupType); | ||
131 | + OrderComputeHandler computeHandler = orderComputeProvider.findBySkupType(skupType); | ||
132 | + SellerOrderComputeResult computeResult = computeHandler.compute(salePrice, pcc); | ||
133 | + | ||
134 | + SellerBo sellerBo = sellerService.getSellerWithAuth(req.getUid()); | ||
135 | + | ||
136 | + return ChangePricePrepareDTO.builder() | ||
137 | + .baseSellerOrderGoods(sog) | ||
138 | + .preSalePrice(sog.getGoodsPrice()) | ||
139 | + .salePrice(salePrice) | ||
140 | + .diffEarnestMoney(BigDecimalHelper.calDiff(sellerOrder.getEarnestMoney(), computeResult.getEarnestMoney().getEarnestMoney())) | ||
141 | + .skupMap(skupMap) | ||
142 | + .computeResult(computeResult) | ||
143 | + .preEarnestMoney(sellerOrder.getEarnestMoney()) | ||
144 | + .sellerBo(sellerBo) | ||
145 | + .skupType(skupType) | ||
146 | + .build(); | ||
147 | + | ||
148 | + } | ||
149 | + | ||
150 | + | ||
81 | public ChangePricePrepareDTO checkAndAcquire(T req) { | 151 | public ChangePricePrepareDTO checkAndAcquire(T req) { |
82 | int uid = req.getUid(); | 152 | int uid = req.getUid(); |
83 | if (uid <= 0){ | 153 | if (uid <= 0){ |
@@ -70,6 +70,7 @@ public class ImportPublishProcessor | @@ -70,6 +70,7 @@ public class ImportPublishProcessor | ||
70 | supportSkupTypes = new ArrayList<>(8); | 70 | supportSkupTypes = new ArrayList<>(8); |
71 | supportSkupTypes.add(SkupType.IN_STOCK); | 71 | supportSkupTypes.add(SkupType.IN_STOCK); |
72 | supportSkupTypes.add(SkupType.HK_IN_STOCK); | 72 | supportSkupTypes.add(SkupType.HK_IN_STOCK); |
73 | + supportSkupTypes.add(SkupType.FAST_DELIVERY); | ||
73 | } | 74 | } |
74 | 75 | ||
75 | 76 |
@@ -196,7 +196,10 @@ public class PriceComputePrepareProcessor { | @@ -196,7 +196,10 @@ public class PriceComputePrepareProcessor { | ||
196 | log.info("in checkPulishAuthNPriceRange,uid {} prdPrice {}, storageId {} prdPriceRange {}", | 196 | log.info("in checkPulishAuthNPriceRange,uid {} prdPrice {}, storageId {} prdPriceRange {}", |
197 | uid, prdPrice, storageId, prdPriceRange); | 197 | uid, prdPrice, storageId, prdPriceRange); |
198 | checkPublishAuth(uid, storageId, prdPrice, prdPriceRange); | 198 | checkPublishAuth(uid, storageId, prdPrice, prdPriceRange); |
199 | - checkBasePriceRange(uid, storageId, prdPrice, prdPriceRange, isShowError); | 199 | + if (isShowError){ |
200 | + checkBasePriceRange(uid, storageId, prdPrice, prdPriceRange); | ||
201 | + } | ||
202 | + | ||
200 | return prdPriceRange; | 203 | return prdPriceRange; |
201 | } | 204 | } |
202 | /** | 205 | /** |
@@ -212,28 +215,27 @@ public class PriceComputePrepareProcessor { | @@ -212,28 +215,27 @@ public class PriceComputePrepareProcessor { | ||
212 | PrdPrice prdPriceRange = productProxyService.getPrdPriceRange(uid, storageId); | 215 | PrdPrice prdPriceRange = productProxyService.getPrdPriceRange(uid, storageId); |
213 | log.info("in checkPriceRange,uid {} prdPrice {}, storageId {} prdPriceRange {}", | 216 | log.info("in checkPriceRange,uid {} prdPrice {}, storageId {} prdPriceRange {}", |
214 | uid, prdPrice, storageId, prdPriceRange); | 217 | uid, prdPrice, storageId, prdPriceRange); |
215 | - checkBasePriceRange(uid, storageId, prdPrice, prdPriceRange, isShowError); | 218 | + |
219 | + if (isShowError){ | ||
220 | + checkBasePriceRange(uid, storageId, prdPrice, prdPriceRange); | ||
221 | + } | ||
216 | 222 | ||
217 | return prdPriceRange; | 223 | return prdPriceRange; |
218 | } | 224 | } |
219 | 225 | ||
220 | - private void checkBasePriceRange(Integer uid,int storageId, BigDecimal prdPrice, PrdPrice prdPriceRange, boolean isShowError){ | 226 | + private void checkBasePriceRange(Integer uid,int storageId, BigDecimal prdPrice, PrdPrice prdPriceRange){ |
221 | BigDecimal minPrice = prdPriceRange.getMinPrice(); | 227 | BigDecimal minPrice = prdPriceRange.getMinPrice(); |
222 | BigDecimal maxPrice = prdPriceRange.getMaxPrice(); | 228 | BigDecimal maxPrice = prdPriceRange.getMaxPrice(); |
223 | if (prdPrice.subtract(minPrice).doubleValue() < 0D){ | 229 | if (prdPrice.subtract(minPrice).doubleValue() < 0D){ |
224 | log.warn("in computePublishPrd,uid {} minPrice {}, storageId {}", | 230 | log.warn("in computePublishPrd,uid {} minPrice {}, storageId {}", |
225 | uid, minPrice, storageId); | 231 | uid, minPrice, storageId); |
226 | - if (isShowError){ | ||
227 | - throw new UfoServiceException(501, "您的出价过低"); | ||
228 | - } | 232 | + throw new UfoServiceException(501, "您的出价过低"); |
229 | } | 233 | } |
230 | 234 | ||
231 | if (prdPrice.subtract(maxPrice).doubleValue() > 0D){ | 235 | if (prdPrice.subtract(maxPrice).doubleValue() > 0D){ |
232 | log.warn("in computePublishPrd,uid {} maxPrice {}, storageId {}", | 236 | log.warn("in computePublishPrd,uid {} maxPrice {}, storageId {}", |
233 | uid, maxPrice, storageId); | 237 | uid, maxPrice, storageId); |
234 | - if (isShowError){ | ||
235 | - throw new UfoServiceException(501, "您的出价过高"); | ||
236 | - } | 238 | + throw new UfoServiceException(501, "您的出价过高"); |
237 | } | 239 | } |
238 | } | 240 | } |
239 | 241 |
1 | package com.yohoufo.order.service.seller.processor; | 1 | package com.yohoufo.order.service.seller.processor; |
2 | 2 | ||
3 | +import com.google.common.collect.Maps; | ||
3 | import com.yohobuy.ufo.model.order.common.SkupStatus; | 4 | import com.yohobuy.ufo.model.order.common.SkupStatus; |
4 | import com.yohobuy.ufo.model.order.constants.OrderDetailDesc; | 5 | import com.yohobuy.ufo.model.order.constants.OrderDetailDesc; |
5 | import com.yohobuy.ufo.model.order.constants.SkupType; | 6 | import com.yohobuy.ufo.model.order.constants.SkupType; |
@@ -79,6 +80,29 @@ public class SellerDownShelfPrepareProcessor { | @@ -79,6 +80,29 @@ public class SellerDownShelfPrepareProcessor { | ||
79 | return sdspDto; | 80 | return sdspDto; |
80 | } | 81 | } |
81 | 82 | ||
83 | + /** | ||
84 | + * 获取skup对应的商品信息 | ||
85 | + * @param skup | ||
86 | + * @return | ||
87 | + */ | ||
88 | + public SkupDownShelfPrepareDto getDownShelfPreDto(int skup){ | ||
89 | + | ||
90 | + SellerOrderGoods sog = sellerOrderGoodsMapper.selectByPrimaryKey(skup); | ||
91 | + if (sog == null || (sog.getStatus() != null && !CAN_OFF_STATUS.contains(sog.getStatus()))){ | ||
92 | + logger.warn("getSellerOrderGoodInfo has buyed, skup {}", skup); | ||
93 | + throw new UfoServiceException(501, "商品已被下单购买"); | ||
94 | + } | ||
95 | + | ||
96 | + Map<Integer, SkupDto> skupMap = Maps.newHashMap(); | ||
97 | + skupMap.put(sog.getId(), SkupDto.builder().skup(sog.getId()).sellerOrderGoods(sog).batchNo(sog.getBatchNo()).build()); | ||
98 | + | ||
99 | + SkupDownShelfPrepareDto sdspDto = SkupDownShelfPrepareDto.builder() | ||
100 | + .idSkupMap(skupMap) | ||
101 | + .skupType(SkupType.getSkupType(sog.getAttributes())) | ||
102 | + .build(); | ||
103 | + return sdspDto; | ||
104 | + } | ||
105 | + | ||
82 | private Map<Integer, SkupDto> checkNeedProcessSkups(SellerBatchChangeReq req, SkupType skupType) { | 106 | private Map<Integer, SkupDto> checkNeedProcessSkups(SellerBatchChangeReq req, SkupType skupType) { |
83 | 107 | ||
84 | SellerOrderGoods condition = new SellerOrderGoods(); | 108 | SellerOrderGoods condition = new SellerOrderGoods(); |
@@ -95,6 +95,7 @@ public class SellerWrapper { | @@ -95,6 +95,7 @@ public class SellerWrapper { | ||
95 | sellerBo.setEntrySellerType(est); | 95 | sellerBo.setEntrySellerType(est); |
96 | sellerBo.setEntryTypeCode(est.getCode()); | 96 | sellerBo.setEntryTypeCode(est.getCode()); |
97 | SellerTypeNode sellerTypeNode = SellerHelper.buildSellerType(est); | 97 | SellerTypeNode sellerTypeNode = SellerHelper.buildSellerType(est); |
98 | + sellerBo.setFastDeliverySuper(sellerTypeNode.isFastDeliverySuper()); | ||
98 | sellerBo.setCommonEntry(sellerTypeNode.isCommonEntry()); | 99 | sellerBo.setCommonEntry(sellerTypeNode.isCommonEntry()); |
99 | sellerBo.setNormalSuper(sellerTypeNode.isNormalSuper()); | 100 | sellerBo.setNormalSuper(sellerTypeNode.isNormalSuper()); |
100 | sellerBo.setSuper(sellerTypeNode.isSuper()); | 101 | sellerBo.setSuper(sellerTypeNode.isSuper()); |
@@ -93,6 +93,10 @@ public final class SellerGoodsHelper { | @@ -93,6 +93,10 @@ public final class SellerGoodsHelper { | ||
93 | return skupType != null && SkupType.QUICK_DELIVER.equals(skupType); | 93 | return skupType != null && SkupType.QUICK_DELIVER.equals(skupType); |
94 | } | 94 | } |
95 | 95 | ||
96 | + public static boolean isFastDelivery(SkupType skupType){ | ||
97 | + return skupType != null && SkupType.FAST_DELIVERY.equals(skupType); | ||
98 | + } | ||
99 | + | ||
96 | public static boolean isInStock(SkupType skupType){ | 100 | public static boolean isInStock(SkupType skupType){ |
97 | return skupType!=null && SkupType.IN_STOCK.equals(skupType); | 101 | return skupType!=null && SkupType.IN_STOCK.equals(skupType); |
98 | } | 102 | } |
@@ -58,6 +58,7 @@ public class SellerHelper { | @@ -58,6 +58,7 @@ public class SellerHelper { | ||
58 | break; | 58 | break; |
59 | case SUPER_ENTRY: | 59 | case SUPER_ENTRY: |
60 | case LARGE_SETTLEMENT: | 60 | case LARGE_SETTLEMENT: |
61 | + case FAST_DELIVERY_SUPER: | ||
61 | et = estMap.get(targetEst); | 62 | et = estMap.get(targetEst); |
62 | level = getSuperLevel(et, left); | 63 | level = getSuperLevel(et, left); |
63 | break; | 64 | break; |
@@ -91,10 +92,16 @@ public class SellerHelper { | @@ -91,10 +92,16 @@ public class SellerHelper { | ||
91 | public static boolean isSuper(EntrySellerType est){ | 92 | public static boolean isSuper(EntrySellerType est){ |
92 | boolean result = Objects.equals(est, EntrySellerType.SPECIAL_SUPER) | 93 | boolean result = Objects.equals(est, EntrySellerType.SPECIAL_SUPER) |
93 | || isNormalSuper(est) | 94 | || isNormalSuper(est) |
94 | - || isLargeSettlement(est); | 95 | + || isLargeSettlement(est) |
96 | + || isFastDeliverySuper(est) ; | ||
95 | return result; | 97 | return result; |
96 | } | 98 | } |
97 | 99 | ||
100 | + | ||
101 | + public static boolean isFastDeliverySuper(EntrySellerType est){ | ||
102 | + return Objects.equals(est, EntrySellerType.FAST_DELIVERY_SUPER); | ||
103 | + } | ||
104 | + | ||
98 | public static boolean isLargeSettlement(EntrySellerType est){ | 105 | public static boolean isLargeSettlement(EntrySellerType est){ |
99 | return Objects.equals(est, EntrySellerType.LARGE_SETTLEMENT); | 106 | return Objects.equals(est, EntrySellerType.LARGE_SETTLEMENT); |
100 | } | 107 | } |
@@ -129,6 +136,7 @@ public class SellerHelper { | @@ -129,6 +136,7 @@ public class SellerHelper { | ||
129 | if (isSuper){ | 136 | if (isSuper){ |
130 | sellerTypeNode.setSuper(isSuper); | 137 | sellerTypeNode.setSuper(isSuper); |
131 | } | 138 | } |
139 | + | ||
132 | boolean isNormalSuper = isNormalSuper(est); | 140 | boolean isNormalSuper = isNormalSuper(est); |
133 | 141 | ||
134 | if (isNormalSuper){ | 142 | if (isNormalSuper){ |
@@ -139,6 +147,10 @@ public class SellerHelper { | @@ -139,6 +147,10 @@ public class SellerHelper { | ||
139 | if (isLargeSettlement(est)){ | 147 | if (isLargeSettlement(est)){ |
140 | sellerTypeNode.setLargeSettlementSuper(true); | 148 | sellerTypeNode.setLargeSettlementSuper(true); |
141 | } | 149 | } |
150 | + | ||
151 | + if (isFastDeliverySuper(est)){ | ||
152 | + sellerTypeNode.setFastDeliverySuper(true); | ||
153 | + } | ||
142 | return sellerTypeNode; | 154 | return sellerTypeNode; |
143 | } | 155 | } |
144 | 156 |
-
Please register or login to post a comment