Merge branch 'test6.8.9' of http://git.yoho.cn/ufo/yohoufo-fore into test6.8.9
Showing
34 changed files
with
834 additions
and
181 deletions
1 | +package com.yohoufo.dal.order; | ||
2 | + | ||
3 | +import com.yohoufo.dal.order.model.SellerChangePriceRecord; | ||
4 | +import org.apache.ibatis.annotations.Param; | ||
5 | + | ||
6 | +import java.util.Collection; | ||
7 | +import java.util.List; | ||
8 | + | ||
9 | +public interface SellerChangePriceRecordMapper { | ||
10 | + | ||
11 | + int insert(SellerChangePriceRecord record); | ||
12 | + | ||
13 | + int insertSelective(SellerChangePriceRecord record); | ||
14 | + | ||
15 | + SellerChangePriceRecord selectByPrimaryKey(Integer id); | ||
16 | + | ||
17 | + int updateByPrimaryKeySelective(SellerChangePriceRecord record); | ||
18 | + | ||
19 | + List<SellerChangePriceRecord> selectByPreOrderCode(Long preOrderCode); | ||
20 | + | ||
21 | + List<SellerChangePriceRecord> selectByPreOrderCodeNStatus(@Param("preOrderCode") Long preOrderCode, | ||
22 | + @Param("statusList") Collection<Short> statusList); | ||
23 | + | ||
24 | + SellerChangePriceRecord selectByOrderCode(Long orderCode); | ||
25 | +} |
1 | +package com.yohoufo.dal.order.model; | ||
2 | + | ||
3 | +public class SellerChangePriceRecord { | ||
4 | + private Integer id; | ||
5 | + | ||
6 | + private Integer preSkup; | ||
7 | + | ||
8 | + private Long preOrderCode; | ||
9 | + | ||
10 | + private Integer skup; | ||
11 | + | ||
12 | + private Long orderCode; | ||
13 | + | ||
14 | + private Short status; | ||
15 | + | ||
16 | + private String remark; | ||
17 | + | ||
18 | + private Integer createTime; | ||
19 | + | ||
20 | + private Integer updateTime; | ||
21 | + | ||
22 | + public Integer getId() { | ||
23 | + return id; | ||
24 | + } | ||
25 | + | ||
26 | + public void setId(Integer id) { | ||
27 | + this.id = id; | ||
28 | + } | ||
29 | + | ||
30 | + public Integer getPreSkup() { | ||
31 | + return preSkup; | ||
32 | + } | ||
33 | + | ||
34 | + public void setPreSkup(Integer preSkup) { | ||
35 | + this.preSkup = preSkup; | ||
36 | + } | ||
37 | + | ||
38 | + public Long getPreOrderCode() { | ||
39 | + return preOrderCode; | ||
40 | + } | ||
41 | + | ||
42 | + public void setPreOrderCode(Long preOrderCode) { | ||
43 | + this.preOrderCode = preOrderCode; | ||
44 | + } | ||
45 | + | ||
46 | + public Integer getSkup() { | ||
47 | + return skup; | ||
48 | + } | ||
49 | + | ||
50 | + public void setSkup(Integer skup) { | ||
51 | + this.skup = skup; | ||
52 | + } | ||
53 | + | ||
54 | + public Long getOrderCode() { | ||
55 | + return orderCode; | ||
56 | + } | ||
57 | + | ||
58 | + public void setOrderCode(Long orderCode) { | ||
59 | + this.orderCode = orderCode; | ||
60 | + } | ||
61 | + | ||
62 | + public Short getStatus() { | ||
63 | + return status; | ||
64 | + } | ||
65 | + | ||
66 | + public void setStatus(Short status) { | ||
67 | + this.status = status; | ||
68 | + } | ||
69 | + | ||
70 | + public String getRemark() { | ||
71 | + return remark; | ||
72 | + } | ||
73 | + | ||
74 | + public void setRemark(String remark) { | ||
75 | + this.remark = remark == null ? null : remark.trim(); | ||
76 | + } | ||
77 | + | ||
78 | + public Integer getCreateTime() { | ||
79 | + return createTime; | ||
80 | + } | ||
81 | + | ||
82 | + public void setCreateTime(Integer createTime) { | ||
83 | + this.createTime = createTime; | ||
84 | + } | ||
85 | + | ||
86 | + public Integer getUpdateTime() { | ||
87 | + return updateTime; | ||
88 | + } | ||
89 | + | ||
90 | + public void setUpdateTime(Integer updateTime) { | ||
91 | + this.updateTime = updateTime; | ||
92 | + } | ||
93 | +} |
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.SellerChangePriceRecordMapper"> | ||
4 | + <resultMap id="BaseResultMap" type="com.yohoufo.dal.order.model.SellerChangePriceRecord"> | ||
5 | + <id column="id" jdbcType="INTEGER" property="id" /> | ||
6 | + <result column="pre_skup" jdbcType="INTEGER" property="preSkup" /> | ||
7 | + <result column="pre_order_code" jdbcType="BIGINT" property="preOrderCode" /> | ||
8 | + <result column="skup" jdbcType="INTEGER" property="skup" /> | ||
9 | + <result column="order_code" jdbcType="BIGINT" property="orderCode" /> | ||
10 | + <result column="status" jdbcType="SMALLINT" property="status" /> | ||
11 | + <result column="remark" jdbcType="VARCHAR" property="remark" /> | ||
12 | + <result column="create_time" jdbcType="INTEGER" property="createTime" /> | ||
13 | + <result column="update_time" jdbcType="INTEGER" property="updateTime" /> | ||
14 | + </resultMap> | ||
15 | + <sql id="Base_Column_List"> | ||
16 | + id, pre_skup, pre_order_code, skup, order_code, status, remark, create_time, update_time | ||
17 | + </sql> | ||
18 | + <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap"> | ||
19 | + select | ||
20 | + <include refid="Base_Column_List" /> | ||
21 | + from seller_change_price_record | ||
22 | + where id = #{id,jdbcType=INTEGER} | ||
23 | + </select> | ||
24 | + | ||
25 | + <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.yohoufo.dal.order.model.SellerChangePriceRecord" useGeneratedKeys="true"> | ||
26 | + insert into seller_change_price_record (pre_skup, pre_order_code, skup, | ||
27 | + order_code, status, remark, | ||
28 | + create_time, update_time) | ||
29 | + values (#{preSkup,jdbcType=INTEGER}, #{preOrderCode,jdbcType=BIGINT}, #{skup,jdbcType=INTEGER}, | ||
30 | + #{orderCode,jdbcType=BIGINT}, #{status,jdbcType=SMALLINT}, #{remark,jdbcType=VARCHAR}, | ||
31 | + #{createTime,jdbcType=INTEGER}, #{updateTime,jdbcType=INTEGER}) | ||
32 | + </insert> | ||
33 | + <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.yohoufo.dal.order.model.SellerChangePriceRecord" useGeneratedKeys="true"> | ||
34 | + insert into seller_change_price_record | ||
35 | + <trim prefix="(" suffix=")" suffixOverrides=","> | ||
36 | + <if test="preSkup != null"> | ||
37 | + pre_skup, | ||
38 | + </if> | ||
39 | + <if test="preOrderCode != null"> | ||
40 | + pre_order_code, | ||
41 | + </if> | ||
42 | + <if test="skup != null"> | ||
43 | + skup, | ||
44 | + </if> | ||
45 | + <if test="orderCode != null"> | ||
46 | + order_code, | ||
47 | + </if> | ||
48 | + <if test="status != null"> | ||
49 | + status, | ||
50 | + </if> | ||
51 | + <if test="remark != null"> | ||
52 | + remark, | ||
53 | + </if> | ||
54 | + <if test="createTime != null"> | ||
55 | + create_time, | ||
56 | + </if> | ||
57 | + <if test="updateTime != null"> | ||
58 | + update_time, | ||
59 | + </if> | ||
60 | + </trim> | ||
61 | + <trim prefix="values (" suffix=")" suffixOverrides=","> | ||
62 | + <if test="preSkup != null"> | ||
63 | + #{preSkup,jdbcType=INTEGER}, | ||
64 | + </if> | ||
65 | + <if test="preOrderCode != null"> | ||
66 | + #{preOrderCode,jdbcType=BIGINT}, | ||
67 | + </if> | ||
68 | + <if test="skup != null"> | ||
69 | + #{skup,jdbcType=INTEGER}, | ||
70 | + </if> | ||
71 | + <if test="orderCode != null"> | ||
72 | + #{orderCode,jdbcType=BIGINT}, | ||
73 | + </if> | ||
74 | + <if test="status != null"> | ||
75 | + #{status,jdbcType=SMALLINT}, | ||
76 | + </if> | ||
77 | + <if test="remark != null"> | ||
78 | + #{remark,jdbcType=VARCHAR}, | ||
79 | + </if> | ||
80 | + <if test="createTime != null"> | ||
81 | + #{createTime,jdbcType=INTEGER}, | ||
82 | + </if> | ||
83 | + <if test="updateTime != null"> | ||
84 | + #{updateTime,jdbcType=INTEGER}, | ||
85 | + </if> | ||
86 | + </trim> | ||
87 | + </insert> | ||
88 | + <update id="updateByPrimaryKeySelective" parameterType="com.yohoufo.dal.order.model.SellerChangePriceRecord"> | ||
89 | + update seller_change_price_record | ||
90 | + <set> | ||
91 | + <if test="status != null"> | ||
92 | + status = #{status,jdbcType=SMALLINT}, | ||
93 | + </if> | ||
94 | + <if test="remark != null"> | ||
95 | + remark = #{remark,jdbcType=VARCHAR}, | ||
96 | + </if> | ||
97 | + <if test="updateTime != null"> | ||
98 | + update_time = #{updateTime,jdbcType=INTEGER}, | ||
99 | + </if> | ||
100 | + </set> | ||
101 | + where order_code = #{orderCode,jdbcType=BIGINT} | ||
102 | + </update> | ||
103 | + | ||
104 | + <select id="selectByPreOrderCode" parameterType="java.lang.Long" resultMap="BaseResultMap"> | ||
105 | + select | ||
106 | + <include refid="Base_Column_List" /> | ||
107 | + from seller_change_price_record | ||
108 | + where pre_order_code = #{preOrderCode,jdbcType=BIGINT} | ||
109 | + </select> | ||
110 | + | ||
111 | + <select id="selectByOrderCode" resultMap="BaseResultMap"> | ||
112 | + select | ||
113 | + <include refid="Base_Column_List" /> | ||
114 | + from seller_change_price_record | ||
115 | + where order_code = #{orderCode,jdbcType=BIGINT} | ||
116 | + </select> | ||
117 | + | ||
118 | + <select id="selectByPreOrderCodeNStatus" resultMap="BaseResultMap"> | ||
119 | + select | ||
120 | + <include refid="Base_Column_List" /> | ||
121 | + from seller_change_price_record | ||
122 | + where pre_order_code = #{preOrderCode,jdbcType=BIGINT} | ||
123 | + <if test="status != null"> | ||
124 | + and status in | ||
125 | + <foreach collection="statusList" item="status" open="(" close=")" separator=","> | ||
126 | + #{status,jdbcType=SMALLINT} | ||
127 | + </foreach> | ||
128 | + </if> | ||
129 | + </select> | ||
130 | +</mapper> |
@@ -16,7 +16,7 @@ import lombok.experimental.Builder; | @@ -16,7 +16,7 @@ import lombok.experimental.Builder; | ||
16 | @NoArgsConstructor | 16 | @NoArgsConstructor |
17 | @AllArgsConstructor | 17 | @AllArgsConstructor |
18 | public class BatchPublishTailEvent extends Event { | 18 | public class BatchPublishTailEvent extends Event { |
19 | - | 19 | + private int sellerUid; |
20 | private SellerOrderSubmitHandler.ForkJoinResult fjr; | 20 | private SellerOrderSubmitHandler.ForkJoinResult fjr; |
21 | private SellerWallet sellerWallet; | 21 | private SellerWallet sellerWallet; |
22 | private boolean isSurper; | 22 | private boolean isSurper; |
1 | +package com.yohoufo.order.model.dto; | ||
2 | + | ||
3 | +import com.yohobuy.ufo.model.order.vo.AddressInfo; | ||
4 | +import com.yohoufo.dal.order.model.SellerWallet; | ||
5 | +import lombok.AllArgsConstructor; | ||
6 | +import lombok.Data; | ||
7 | +import lombok.NoArgsConstructor; | ||
8 | +import lombok.experimental.Builder; | ||
9 | + | ||
10 | +import java.math.BigDecimal; | ||
11 | + | ||
12 | +/** | ||
13 | + * Created by chao.chen on 2019/3/22. | ||
14 | + */ | ||
15 | +@Builder | ||
16 | +@Data | ||
17 | +@AllArgsConstructor | ||
18 | +@NoArgsConstructor | ||
19 | +public class ImPrdNode{ | ||
20 | + Integer uid; | ||
21 | + boolean isSuper; | ||
22 | + SellerWallet sellerWallet; | ||
23 | + Integer storageId; | ||
24 | + BigDecimal salePrice; | ||
25 | + int storageNum; | ||
26 | + BigDecimal goodsPaymentRate; | ||
27 | + AddressInfo hiddenBackAddress; | ||
28 | + AddressInfo noHiddenBackAddress; | ||
29 | +} |
@@ -7,6 +7,7 @@ import com.yoho.core.dal.datasource.annotation.Database; | @@ -7,6 +7,7 @@ import com.yoho.core.dal.datasource.annotation.Database; | ||
7 | import com.yoho.error.ServiceError; | 7 | import com.yoho.error.ServiceError; |
8 | import com.yoho.error.exception.ServiceException; | 8 | import com.yoho.error.exception.ServiceException; |
9 | import com.yohobuy.ufo.model.order.common.TabType; | 9 | import com.yohobuy.ufo.model.order.common.TabType; |
10 | +import com.yohoufo.common.alarm.EventBusPublisher; | ||
10 | import com.yohoufo.dal.order.SellerOrderGoodsMapper; | 11 | import com.yohoufo.dal.order.SellerOrderGoodsMapper; |
11 | import com.yohoufo.dal.order.SellerOrderMapper; | 12 | import com.yohoufo.dal.order.SellerOrderMapper; |
12 | import com.yohoufo.dal.order.SellerOrderMetaMapper; | 13 | import com.yohoufo.dal.order.SellerOrderMetaMapper; |
@@ -18,6 +19,7 @@ import com.yohobuy.ufo.model.order.common.OrderCodeType; | @@ -18,6 +19,7 @@ import com.yohobuy.ufo.model.order.common.OrderCodeType; | ||
18 | import com.yohobuy.ufo.model.order.common.SellerOrderStatus; | 19 | import com.yohobuy.ufo.model.order.common.SellerOrderStatus; |
19 | import com.yohoufo.order.constants.MetaKey; | 20 | import com.yohoufo.order.constants.MetaKey; |
20 | import com.yohobuy.ufo.model.order.bo.OrderInfo; | 21 | import com.yohobuy.ufo.model.order.bo.OrderInfo; |
22 | +import com.yohoufo.order.event.SellerOrderPriceChangeEvent; | ||
21 | import com.yohoufo.order.model.request.PaymentRequest; | 23 | import com.yohoufo.order.model.request.PaymentRequest; |
22 | import com.yohoufo.order.model.response.PrepayResponse; | 24 | import com.yohoufo.order.model.response.PrepayResponse; |
23 | import com.yohoufo.order.mq.DelayTime; | 25 | import com.yohoufo.order.mq.DelayTime; |
@@ -78,14 +80,18 @@ public class SellerOrderPaymentService extends AbstractOrderPaymentService { | @@ -78,14 +80,18 @@ public class SellerOrderPaymentService extends AbstractOrderPaymentService { | ||
78 | int updateCnt = sellerOrderMapper.updateByOrderCode(sellerOrder); | 80 | int updateCnt = sellerOrderMapper.updateByOrderCode(sellerOrder); |
79 | if (1 == updateCnt) { | 81 | if (1 == updateCnt) { |
80 | // | 82 | // |
83 | + int skup; | ||
81 | SellerOrderGoods targetSog = new SellerOrderGoods(); | 84 | SellerOrderGoods targetSog = new SellerOrderGoods(); |
82 | - targetSog.setId(orderInfo.getSkup()); | 85 | + targetSog.setId(skup=orderInfo.getSkup()); |
83 | targetSog.setStatus(soTargetStatus.getSkupStatus().getCode()); | 86 | targetSog.setStatus(soTargetStatus.getSkupStatus().getCode()); |
84 | sellerOrderGoodsMapper.updateByPrimaryKeySelective(targetSog); | 87 | sellerOrderGoodsMapper.updateByPrimaryKeySelective(targetSog); |
85 | //sync 2 product biz model | 88 | //sync 2 product biz model |
86 | SellerOrderGoods tsog = new SellerOrderGoods(); | 89 | SellerOrderGoods tsog = new SellerOrderGoods(); |
87 | - tsog.setId(orderInfo.getSkup()); | 90 | + tsog.setId(skup); |
88 | productProxyService.syncSkup(tsog, soTargetStatus.getSkupStatus()); | 91 | productProxyService.syncSkup(tsog, soTargetStatus.getSkupStatus()); |
92 | + SellerOrderPriceChangeEvent sopcEvent = SellerOrderPriceChangeEvent.builder() | ||
93 | + .sellerUid(orderInfo.getUid()).skup(skup).build(); | ||
94 | + EventBusPublisher.publishEvent(sopcEvent); | ||
89 | } | 95 | } |
90 | return updateCnt; | 96 | return updateCnt; |
91 | } | 97 | } |
@@ -5,6 +5,7 @@ import com.google.common.collect.Lists; | @@ -5,6 +5,7 @@ import com.google.common.collect.Lists; | ||
5 | import com.yoho.core.dal.datasource.annotation.Database; | 5 | import com.yoho.core.dal.datasource.annotation.Database; |
6 | import com.yoho.core.redis.cluster.operations.serializer.RedisKeyBuilder; | 6 | import com.yoho.core.redis.cluster.operations.serializer.RedisKeyBuilder; |
7 | import com.yohobuy.ufo.model.order.common.TabType; | 7 | import com.yohobuy.ufo.model.order.common.TabType; |
8 | +import com.yohoufo.common.alarm.EventBusPublisher; | ||
8 | import com.yohoufo.common.exception.UfoServiceException; | 9 | import com.yohoufo.common.exception.UfoServiceException; |
9 | import com.yohoufo.common.utils.DateUtil; | 10 | import com.yohoufo.common.utils.DateUtil; |
10 | import com.yohoufo.dal.order.SellerOrderGoodsMapper; | 11 | import com.yohoufo.dal.order.SellerOrderGoodsMapper; |
@@ -16,6 +17,7 @@ import com.yohoufo.dal.order.model.SellerOrderGoods; | @@ -16,6 +17,7 @@ import com.yohoufo.dal.order.model.SellerOrderGoods; | ||
16 | import com.yohoufo.dal.order.model.SellerOrderMeta; | 17 | import com.yohoufo.dal.order.model.SellerOrderMeta; |
17 | import com.yohoufo.dal.order.model.SellerTaskDetail; | 18 | import com.yohoufo.dal.order.model.SellerTaskDetail; |
18 | import com.yohoufo.order.constants.MetaKey; | 19 | import com.yohoufo.order.constants.MetaKey; |
20 | +import com.yohoufo.order.event.SellerOrderPriceChangeEvent; | ||
19 | import com.yohoufo.order.model.dto.*; | 21 | import com.yohoufo.order.model.dto.*; |
20 | import com.yohoufo.order.service.MerchantOrderPaymentService; | 22 | import com.yohoufo.order.service.MerchantOrderPaymentService; |
21 | import com.yohoufo.order.service.cache.CacheKeyBuilder; | 23 | import com.yohoufo.order.service.cache.CacheKeyBuilder; |
@@ -162,6 +164,10 @@ public abstract class AbstractSellerAdjustPriceTaskHandler extends AbstractSelle | @@ -162,6 +164,10 @@ public abstract class AbstractSellerAdjustPriceTaskHandler extends AbstractSelle | ||
162 | //通知商品 | 164 | //通知商品 |
163 | try { | 165 | try { |
164 | productProxyService.batchUpdatePrice(successSkups, newSalePrice); | 166 | productProxyService.batchUpdatePrice(successSkups, newSalePrice); |
167 | + SellerOrderPriceChangeEvent sopcEvent = SellerOrderPriceChangeEvent.builder() | ||
168 | + .sellerUid(uid).skup(successSkups.iterator().next()).build(); | ||
169 | + EventBusPublisher.publishEvent(sopcEvent); | ||
170 | + | ||
165 | log.info("[{}-{}] notify product to update price for skups:{},salePrice:{} success", uid, taskId, successSkups, newSalePrice); | 171 | log.info("[{}-{}] notify product to update price for skups:{},salePrice:{} success", uid, taskId, successSkups, newSalePrice); |
166 | } catch (Exception ex) { | 172 | } catch (Exception ex) { |
167 | log.error("[{}-{}] exception happened when notify product to update price,skups:{},salePrice:{}", | 173 | log.error("[{}-{}] exception happened when notify product to update price,skups:{},salePrice:{}", |
@@ -2,9 +2,11 @@ package com.yohoufo.order.service.handler; | @@ -2,9 +2,11 @@ package com.yohoufo.order.service.handler; | ||
2 | 2 | ||
3 | import com.google.common.eventbus.Subscribe; | 3 | import com.google.common.eventbus.Subscribe; |
4 | import com.yohobuy.ufo.model.order.bo.OrderInfo; | 4 | import com.yohobuy.ufo.model.order.bo.OrderInfo; |
5 | +import com.yohoufo.common.alarm.EventBusPublisher; | ||
5 | import com.yohoufo.common.alarm.IEventHandler; | 6 | import com.yohoufo.common.alarm.IEventHandler; |
6 | import com.yohoufo.dal.order.model.SellerWallet; | 7 | import com.yohoufo.dal.order.model.SellerWallet; |
7 | import com.yohoufo.order.event.BatchPublishTailEvent; | 8 | import com.yohoufo.order.event.BatchPublishTailEvent; |
9 | +import com.yohoufo.order.event.SellerOrderPriceChangeEvent; | ||
8 | import com.yohoufo.order.service.MerchantOrderPaymentService; | 10 | import com.yohoufo.order.service.MerchantOrderPaymentService; |
9 | import com.yohoufo.order.service.proxy.ProductProxyService; | 11 | import com.yohoufo.order.service.proxy.ProductProxyService; |
10 | import com.yohoufo.order.utils.LoggerUtils; | 12 | import com.yohoufo.order.utils.LoggerUtils; |
@@ -31,10 +33,12 @@ public class BatchPublishTailHandler implements IEventHandler<BatchPublishTailEv | @@ -31,10 +33,12 @@ public class BatchPublishTailHandler implements IEventHandler<BatchPublishTailEv | ||
31 | @Subscribe | 33 | @Subscribe |
32 | public void handle(BatchPublishTailEvent event) { | 34 | public void handle(BatchPublishTailEvent event) { |
33 | logger.info("in handle BatchPublishTailEvent event {}", event); | 35 | logger.info("in handle BatchPublishTailEvent event {}", event); |
34 | - batchPublishTailProcess(event.getFjr(), event.getSellerWallet(), event.isSurper()); | 36 | + batchPublishTailProcess(event.getFjr(), event.getSellerWallet(), event.isSurper(), event.getSellerUid()); |
35 | } | 37 | } |
36 | 38 | ||
37 | - private void batchPublishTailProcess(SellerOrderSubmitHandler.ForkJoinResult fjr, SellerWallet sellerWallet, boolean isSurper){ | 39 | + private void batchPublishTailProcess(SellerOrderSubmitHandler.ForkJoinResult fjr, |
40 | + SellerWallet sellerWallet, boolean isSurper, | ||
41 | + int sellerUid){ | ||
38 | 42 | ||
39 | // (异步实现)记录保证金流水 | 43 | // (异步实现)记录保证金流水 |
40 | if(!isSurper) { | 44 | if(!isSurper) { |
@@ -46,7 +50,11 @@ public class BatchPublishTailHandler implements IEventHandler<BatchPublishTailEv | @@ -46,7 +50,11 @@ public class BatchPublishTailHandler implements IEventHandler<BatchPublishTailEv | ||
46 | } | 50 | } |
47 | //(异步实现)同步数据到prd,记录支付, | 51 | //(异步实现)同步数据到prd,记录支付, |
48 | productProxyService.batchCreateSkup(fjr.getSellerOrderGoodsList()); | 52 | productProxyService.batchCreateSkup(fjr.getSellerOrderGoodsList()); |
49 | - productProxyService.sellerBatchUpdateStatus(fjr.getSkupIds(), ProductProxyService.PrdShelvelStatus.on); | ||
50 | - | 53 | + List<Integer> skups; |
54 | + productProxyService.sellerBatchUpdateStatus(skups=fjr.getSkupIds(), ProductProxyService.PrdShelvelStatus.on); | ||
55 | + //通知其他卖家价格 | ||
56 | + SellerOrderPriceChangeEvent sopcEvent = SellerOrderPriceChangeEvent.builder() | ||
57 | + .sellerUid(sellerUid).skup(skups.get(0)).build(); | ||
58 | + EventBusPublisher.publishEvent(sopcEvent); | ||
51 | } | 59 | } |
52 | } | 60 | } |
@@ -9,7 +9,6 @@ import com.yohobuy.ufo.model.order.constants.OrderConstant; | @@ -9,7 +9,6 @@ import com.yohobuy.ufo.model.order.constants.OrderConstant; | ||
9 | import com.yohobuy.ufo.model.order.constants.SkupType; | 9 | import com.yohobuy.ufo.model.order.constants.SkupType; |
10 | import com.yohobuy.ufo.model.order.resp.ExpressInfoDetail; | 10 | import com.yohobuy.ufo.model.order.resp.ExpressInfoDetail; |
11 | import com.yohobuy.ufo.model.order.vo.AddressInfo; | 11 | import com.yohobuy.ufo.model.order.vo.AddressInfo; |
12 | -import com.yohoufo.common.utils.BigDecimalHelper; | ||
13 | import com.yohoufo.common.utils.DateUtil; | 12 | import com.yohoufo.common.utils.DateUtil; |
14 | import com.yohoufo.dal.order.*; | 13 | import com.yohoufo.dal.order.*; |
15 | import com.yohoufo.dal.order.model.*; | 14 | import com.yohoufo.dal.order.model.*; |
@@ -28,7 +27,7 @@ import com.yohoufo.order.mq.DelayTime; | @@ -28,7 +27,7 @@ import com.yohoufo.order.mq.DelayTime; | ||
28 | import com.yohoufo.order.service.AbsSellerOrderViewService; | 27 | import com.yohoufo.order.service.AbsSellerOrderViewService; |
29 | import com.yohoufo.order.service.IOrderDetailService; | 28 | import com.yohoufo.order.service.IOrderDetailService; |
30 | import com.yohoufo.order.service.cache.OrderCacheService; | 29 | import com.yohoufo.order.service.cache.OrderCacheService; |
31 | -import com.yohoufo.order.service.impl.processor.SellerOrderPrepareProcessor; | 30 | +import com.yohoufo.order.service.seller.processor.SellerOrderPrepareProcessor; |
32 | import com.yohoufo.order.service.proxy.ProductProxyService; | 31 | import com.yohoufo.order.service.proxy.ProductProxyService; |
33 | import com.yohoufo.order.service.proxy.UserProxyService; | 32 | import com.yohoufo.order.service.proxy.UserProxyService; |
34 | import com.yohoufo.order.service.support.codegenerator.OrderCodeGenerator; | 33 | import com.yohoufo.order.service.support.codegenerator.OrderCodeGenerator; |
@@ -23,10 +23,7 @@ import com.yohoufo.dal.order.model.*; | @@ -23,10 +23,7 @@ import com.yohoufo.dal.order.model.*; | ||
23 | import com.yohoufo.order.common.ActionStatusHold; | 23 | import com.yohoufo.order.common.ActionStatusHold; |
24 | import com.yohoufo.order.common.DelStatus; | 24 | import com.yohoufo.order.common.DelStatus; |
25 | import com.yohoufo.order.convert.SellerOrderConvertor; | 25 | import com.yohoufo.order.convert.SellerOrderConvertor; |
26 | -import com.yohoufo.order.event.BatchPublishTailEvent; | ||
27 | -import com.yohoufo.order.event.ErpCancelSellerOrderEvent; | ||
28 | -import com.yohoufo.order.event.EventHandlerContainer; | ||
29 | -import com.yohoufo.order.event.OrderCancelEvent; | 26 | +import com.yohoufo.order.event.*; |
30 | import com.yohoufo.order.model.SellerOrderContext; | 27 | import com.yohoufo.order.model.SellerOrderContext; |
31 | import com.yohoufo.order.model.dto.*; | 28 | import com.yohoufo.order.model.dto.*; |
32 | import com.yohoufo.order.model.request.OrderListRequest; | 29 | import com.yohoufo.order.model.request.OrderListRequest; |
@@ -44,7 +41,7 @@ import com.yohoufo.order.service.cache.CacheKeyBuilder; | @@ -44,7 +41,7 @@ import com.yohoufo.order.service.cache.CacheKeyBuilder; | ||
44 | import com.yohoufo.order.service.cache.OrderCacheService; | 41 | import com.yohoufo.order.service.cache.OrderCacheService; |
45 | import com.yohoufo.order.service.concurrent.ThreadPoolFactory; | 42 | import com.yohoufo.order.service.concurrent.ThreadPoolFactory; |
46 | import com.yohoufo.order.service.handler.*; | 43 | import com.yohoufo.order.service.handler.*; |
47 | -import com.yohoufo.order.service.impl.processor.*; | 44 | +import com.yohoufo.order.service.seller.processor.*; |
48 | import com.yohoufo.order.service.impl.visitor.OffShelveCancelCase; | 45 | import com.yohoufo.order.service.impl.visitor.OffShelveCancelCase; |
49 | import com.yohoufo.order.service.impl.visitor.UserCancelCase; | 46 | import com.yohoufo.order.service.impl.visitor.UserCancelCase; |
50 | import com.yohoufo.order.service.proxy.InBoxFacade; | 47 | import com.yohoufo.order.service.proxy.InBoxFacade; |
@@ -215,7 +212,7 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServic | @@ -215,7 +212,7 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServic | ||
215 | 212 | ||
216 | 213 | ||
217 | 214 | ||
218 | - private OrderSubmitResp publishSinglePrd(SellerOrderSubmitReq req, SellerOrderContext context) throws GatewayException { | 215 | + public OrderSubmitResp publishSinglePrd(SellerOrderSubmitReq req, SellerOrderContext context){ |
219 | int storageId = context.getStorageId(); | 216 | int storageId = context.getStorageId(); |
220 | int uid = context.getUid(); | 217 | int uid = context.getUid(); |
221 | // step 2: create order, set status(not pay) | 218 | // step 2: create order, set status(not pay) |
@@ -668,6 +665,10 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServic | @@ -668,6 +665,10 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServic | ||
668 | List<RedisKeyBuilder> skupDetailRKBs = getSkupDetailRKBs(sampleSog); | 665 | List<RedisKeyBuilder> skupDetailRKBs = getSkupDetailRKBs(sampleSog); |
669 | skupDetailRKBs.add(CacheKeyBuilder.orderListKey(req.getUid(), TabType.SELL.getValue())); | 666 | skupDetailRKBs.add(CacheKeyBuilder.orderListKey(req.getUid(), TabType.SELL.getValue())); |
670 | cacheCleaner.delete(skupDetailRKBs); | 667 | cacheCleaner.delete(skupDetailRKBs); |
668 | + // | ||
669 | + SellerOrderPriceChangeEvent sopcEvent = SellerOrderPriceChangeEvent.builder() | ||
670 | + .sellerUid(uid).skup(skupSet.iterator().next()).build(); | ||
671 | + EventBusPublisher.publishEvent(sopcEvent); | ||
671 | }else { | 672 | }else { |
672 | //1.2 划账失败后 | 673 | //1.2 划账失败后 |
673 | failCnt = skupMap.size(); | 674 | failCnt = skupMap.size(); |
@@ -794,9 +795,12 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServic | @@ -794,9 +795,12 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServic | ||
794 | cacheCleaner.cleanList(uid, TabType.SELL.getValue()); | 795 | cacheCleaner.cleanList(uid, TabType.SELL.getValue()); |
795 | // (异步实现)记录保证金流水 | 796 | // (异步实现)记录保证金流水 |
796 | //(异步实现)同步数据到prd,记录支付, | 797 | //(异步实现)同步数据到prd,记录支付, |
797 | - BatchPublishTailEvent bpte = BatchPublishTailEvent.builder().isSurper(isSurper) | 798 | + BatchPublishTailEvent bpte = BatchPublishTailEvent.builder() |
799 | + .sellerUid(uid) | ||
800 | + .isSurper(isSurper) | ||
798 | .fjr(fjr).sellerWallet(sellerWallet).build(); | 801 | .fjr(fjr).sellerWallet(sellerWallet).build(); |
799 | EventBusPublisher.publishEvent(bpte); | 802 | EventBusPublisher.publishEvent(bpte); |
803 | + | ||
800 | countDownLatch.countDown(); | 804 | countDownLatch.countDown(); |
801 | }catch (Exception ex){ | 805 | }catch (Exception ex){ |
802 | countDownLatch.countDown(); | 806 | countDownLatch.countDown(); |
@@ -911,9 +915,4 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServic | @@ -911,9 +915,4 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServic | ||
911 | } | 915 | } |
912 | 916 | ||
913 | 917 | ||
914 | - | ||
915 | - | ||
916 | - | ||
917 | - | ||
918 | - | ||
919 | } | 918 | } |
@@ -21,7 +21,7 @@ import com.yohoufo.dal.order.model.SellerOrderGoods; | @@ -21,7 +21,7 @@ import com.yohoufo.dal.order.model.SellerOrderGoods; | ||
21 | import com.yohoufo.order.model.dto.PrdOverPriceDTO; | 21 | import com.yohoufo.order.model.dto.PrdOverPriceDTO; |
22 | import com.yohoufo.order.model.request.OrderListRequest; | 22 | import com.yohoufo.order.model.request.OrderListRequest; |
23 | import com.yohoufo.order.model.request.SellerGoodsListRequest; | 23 | import com.yohoufo.order.model.request.SellerGoodsListRequest; |
24 | -import com.yohoufo.order.service.impl.processor.SellerOrderPrepareProcessor; | 24 | +import com.yohoufo.order.service.seller.processor.SellerOrderPrepareProcessor; |
25 | import com.yohoufo.order.service.proxy.ProductProxyService; | 25 | import com.yohoufo.order.service.proxy.ProductProxyService; |
26 | import com.yohoufo.order.service.proxy.UserProxyService; | 26 | import com.yohoufo.order.service.proxy.UserProxyService; |
27 | import com.yohoufo.order.utils.LoggerUtils; | 27 | import com.yohoufo.order.utils.LoggerUtils; |
1 | package com.yohoufo.order.service.seller; | 1 | package com.yohoufo.order.service.seller; |
2 | 2 | ||
3 | import com.yohobuy.ufo.model.order.req.BatchImportPrdReq; | 3 | import com.yohobuy.ufo.model.order.req.BatchImportPrdReq; |
4 | -import com.yohobuy.ufo.model.order.vo.AddressInfo; | ||
5 | import com.yohobuy.ufo.model.request.product.ProductImportTranItemBo; | 4 | import com.yohobuy.ufo.model.request.product.ProductImportTranItemBo; |
6 | import com.yohoufo.common.alarm.EventBusPublisher; | 5 | import com.yohoufo.common.alarm.EventBusPublisher; |
7 | -import com.yohoufo.dal.order.model.SellerWallet; | ||
8 | import com.yohoufo.order.event.BatchPublishTailEvent; | 6 | import com.yohoufo.order.event.BatchPublishTailEvent; |
9 | import com.yohoufo.order.model.SellerOrderContext; | 7 | import com.yohoufo.order.model.SellerOrderContext; |
8 | +import com.yohoufo.order.model.dto.ImPrdNode; | ||
10 | import com.yohoufo.order.service.handler.SellerOrderSubmitHandler; | 9 | import com.yohoufo.order.service.handler.SellerOrderSubmitHandler; |
11 | import com.yohoufo.order.service.impl.SellerService; | 10 | import com.yohoufo.order.service.impl.SellerService; |
12 | import com.yohoufo.order.service.impl.SkupBatchService; | 11 | import com.yohoufo.order.service.impl.SkupBatchService; |
13 | -import com.yohoufo.order.service.impl.processor.SellerOrderPrepareProcessor; | ||
14 | import com.yohoufo.order.service.proxy.ProductProxyService; | 12 | import com.yohoufo.order.service.proxy.ProductProxyService; |
15 | -import lombok.Data; | ||
16 | -import lombok.experimental.Builder; | 13 | +import com.yohoufo.order.service.seller.processor.ImportPublishPrepareProcessor; |
17 | import org.apache.commons.collections.CollectionUtils; | 14 | import org.apache.commons.collections.CollectionUtils; |
18 | import org.springframework.beans.factory.annotation.Autowired; | 15 | import org.springframework.beans.factory.annotation.Autowired; |
19 | import org.springframework.stereotype.Service; | 16 | import org.springframework.stereotype.Service; |
@@ -28,24 +25,12 @@ import java.util.Objects; | @@ -28,24 +25,12 @@ import java.util.Objects; | ||
28 | @Service | 25 | @Service |
29 | public class ImportPublishExcutor implements PublishExcutor<BatchImportPrdReq, SellerOrderSubmitHandler.ForkJoinResult>{ | 26 | public class ImportPublishExcutor implements PublishExcutor<BatchImportPrdReq, SellerOrderSubmitHandler.ForkJoinResult>{ |
30 | 27 | ||
31 | - @Builder | ||
32 | - @Data | ||
33 | - private static class ImPrdNode{ | ||
34 | - Integer uid; | ||
35 | - boolean isSuper; | ||
36 | - SellerWallet sellerWallet; | ||
37 | - Integer storageId; | ||
38 | - BigDecimal salePrice; | ||
39 | - int storageNum; | ||
40 | - BigDecimal goodsPaymentRate; | ||
41 | - AddressInfo hiddenBackAddress; | ||
42 | - AddressInfo noHiddenBackAddress; | ||
43 | - } | 28 | + |
44 | @Autowired | 29 | @Autowired |
45 | private SellerOrderSubmitHandler orderSubmitHandler; | 30 | private SellerOrderSubmitHandler orderSubmitHandler; |
46 | 31 | ||
47 | @Autowired | 32 | @Autowired |
48 | - private SellerOrderPrepareProcessor sellerOrderPrepareProcessor; | 33 | + private ImportPublishPrepareProcessor importPublishPrepareProcessor; |
49 | 34 | ||
50 | @Autowired | 35 | @Autowired |
51 | private ProductProxyService productProxyService; | 36 | private ProductProxyService productProxyService; |
@@ -98,29 +83,21 @@ public class ImportPublishExcutor implements PublishExcutor<BatchImportPrdReq, S | @@ -98,29 +83,21 @@ public class ImportPublishExcutor implements PublishExcutor<BatchImportPrdReq, S | ||
98 | 83 | ||
99 | 84 | ||
100 | public SellerOrderSubmitHandler.ForkJoinResult publishOne(ImPrdNode node){ | 85 | public SellerOrderSubmitHandler.ForkJoinResult publishOne(ImPrdNode node){ |
101 | - Integer uid = node.uid; | ||
102 | - boolean isSuper = node.isSuper; | ||
103 | - | ||
104 | - Integer storageId = node.storageId; | ||
105 | - BigDecimal salePrice = node.salePrice; | ||
106 | - int storageNum = node.storageNum; | ||
107 | - AddressInfo hiddenBackAddress = node.hiddenBackAddress; | ||
108 | - AddressInfo noHiddenBackAddress = node.noHiddenBackAddress; | 86 | + Integer uid = node.getUid(); |
109 | //add GoodsPaymentRate | 87 | //add GoodsPaymentRate |
110 | - SellerOrderContext ctx = sellerOrderPrepareProcessor.buildImportPrdCxt(uid, storageId, salePrice, storageNum, | ||
111 | - node.getGoodsPaymentRate()); | ||
112 | - ctx.setBackAddress(noHiddenBackAddress); | ||
113 | - ctx.setBackHiddenAddress(hiddenBackAddress); | 88 | + SellerOrderContext ctx = importPublishPrepareProcessor.buildPublishCtx(node); |
89 | + int storageNum = node.getStorageNum(); | ||
114 | long batchNo = skupBatchService.generateBatchNo(uid, storageNum); | 90 | long batchNo = skupBatchService.generateBatchNo(uid, storageNum); |
115 | ctx.getSoldProduct().setBatchNo(batchNo); | 91 | ctx.getSoldProduct().setBatchNo(batchNo); |
116 | 92 | ||
117 | - | ||
118 | SellerOrderSubmitHandler.ForkJoinResult fjr; | 93 | SellerOrderSubmitHandler.ForkJoinResult fjr; |
119 | - | ||
120 | fjr = orderSubmitHandler.submitMultiple(ctx, storageNum); | 94 | fjr = orderSubmitHandler.submitMultiple(ctx, storageNum); |
121 | // (异步实现)记录保证金流水 | 95 | // (异步实现)记录保证金流水 |
122 | //(异步实现)同步数据到prd,记录支付, | 96 | //(异步实现)同步数据到prd,记录支付, |
123 | - BatchPublishTailEvent bpte = BatchPublishTailEvent.builder().isSurper(isSuper) | 97 | + boolean isSuper = node.isSuper(); |
98 | + BatchPublishTailEvent bpte = BatchPublishTailEvent.builder() | ||
99 | + .sellerUid(uid) | ||
100 | + .isSurper(isSuper) | ||
124 | .fjr(fjr).sellerWallet(null).build(); | 101 | .fjr(fjr).sellerWallet(null).build(); |
125 | EventBusPublisher.publishEvent(bpte); | 102 | EventBusPublisher.publishEvent(bpte); |
126 | return fjr; | 103 | return fjr; |
order/src/main/java/com/yohoufo/order/service/seller/changePrice/NESChangePricePublishExcutor.java
0 → 100644
1 | +package com.yohoufo.order.service.seller.changePrice; | ||
2 | + | ||
3 | +import com.yohobuy.ufo.model.order.req.SellerOrderSubmitReq; | ||
4 | +import com.yohoufo.order.model.SellerOrderContext; | ||
5 | +import com.yohoufo.order.model.response.OrderSubmitResp; | ||
6 | +import com.yohoufo.order.service.impl.SellerOrderService; | ||
7 | +import com.yohoufo.order.service.seller.PublishExcutor; | ||
8 | +import com.yohoufo.order.utils.LoggerUtils; | ||
9 | +import org.slf4j.Logger; | ||
10 | +import org.springframework.beans.factory.annotation.Autowired; | ||
11 | +import org.springframework.stereotype.Service; | ||
12 | + | ||
13 | +/** | ||
14 | + * Created by chao.chen on 2019/3/22. | ||
15 | + */ | ||
16 | +@Service | ||
17 | +public class NESChangePricePublishExcutor implements PublishExcutor<SellerOrderContext, OrderSubmitResp> { | ||
18 | + | ||
19 | + private Logger logger = LoggerUtils.getSellerOrderLogger(); | ||
20 | + | ||
21 | + | ||
22 | + | ||
23 | + @Autowired | ||
24 | + SellerOrderService sellerOrderService; | ||
25 | + | ||
26 | + @Override | ||
27 | + public OrderSubmitResp publish(SellerOrderContext ctx) { | ||
28 | + | ||
29 | + SellerOrderSubmitReq req = SellerOrderSubmitReq.builder() | ||
30 | + .uid(ctx.getUid()) | ||
31 | + .storageId(ctx.getStorageId()).build(); | ||
32 | + OrderSubmitResp resp = sellerOrderService.publishSinglePrd(req, ctx); | ||
33 | + logger.info("out NESChangePricePublishExcutor.publish req {} OrderSubmitResp {}", | ||
34 | + req, resp); | ||
35 | + return resp; | ||
36 | + } | ||
37 | +} |
1 | package com.yohoufo.order.service.seller.changePrice; | 1 | package com.yohoufo.order.service.seller.changePrice; |
2 | 2 | ||
3 | +import com.google.common.collect.Lists; | ||
3 | import com.yohobuy.ufo.model.order.bo.SoldPrdComputeBo; | 4 | import com.yohobuy.ufo.model.order.bo.SoldPrdComputeBo; |
5 | +import com.yohobuy.ufo.model.order.constants.ChangePriceStatus; | ||
4 | import com.yohobuy.ufo.model.order.req.NESChangePriceReq; | 6 | import com.yohobuy.ufo.model.order.req.NESChangePriceReq; |
7 | +import com.yohoufo.dal.order.SellerChangePriceRecordMapper; | ||
8 | +import com.yohoufo.dal.order.model.SellerChangePriceRecord; | ||
9 | +import com.yohoufo.dal.order.model.SellerOrder; | ||
10 | +import com.yohoufo.dal.order.model.SellerOrderGoods; | ||
5 | import com.yohoufo.order.convert.SellerOrderConvertor; | 11 | import com.yohoufo.order.convert.SellerOrderConvertor; |
12 | +import com.yohoufo.order.model.NESCPOrderContext; | ||
6 | import com.yohoufo.order.model.dto.ChangePricePrepareDTO; | 13 | import com.yohoufo.order.model.dto.ChangePricePrepareDTO; |
7 | import com.yohoufo.order.model.response.OrderSubmitResp; | 14 | import com.yohoufo.order.model.response.OrderSubmitResp; |
8 | -import com.yohoufo.order.service.impl.processor.NESChangePricePrepareProcessor; | 15 | +import com.yohoufo.order.service.seller.processor.NESChangePricePrepareProcessor; |
16 | +import com.yohoufo.order.service.seller.processor.NESChangePricePublishPrepareProcessor; | ||
9 | import com.yohoufo.order.utils.LoggerUtils; | 17 | import com.yohoufo.order.utils.LoggerUtils; |
18 | +import org.apache.commons.collections.CollectionUtils; | ||
10 | import org.slf4j.Logger; | 19 | import org.slf4j.Logger; |
11 | import org.springframework.beans.factory.annotation.Autowired; | 20 | import org.springframework.beans.factory.annotation.Autowired; |
12 | import org.springframework.stereotype.Service; | 21 | import org.springframework.stereotype.Service; |
13 | 22 | ||
23 | +import java.util.List; | ||
24 | + | ||
14 | /** | 25 | /** |
26 | + * 非入驻的卖家 变价服务类 | ||
27 | + * 涉及场景 | ||
28 | + * TODO case1: 变价计算 | ||
29 | + * TODO case2:变价待支付订单生成 | ||
30 | + * TODO case2.1 : 首次 -> | ||
31 | + * TODO case2.2: 非首次 -> | ||
32 | + * TODO case3:预支付 -> | ||
33 | + * TODO case4:支付回调 -> | ||
34 | + * TODO case5:主动取消 -> | ||
35 | + * TODO case6:超时取消 -> | ||
36 | + * TODO case7:订单列表 详情 可售商品 变价入口控制 | ||
37 | + * 功能点 | ||
38 | + * TODO F1:记录变价历史 | ||
39 | + * TODO F2: 失败时 对应变价记录 状态更新 备注原因 | ||
40 | + * TODO F3: 成功后 变价记录状态 订单状态 商品上架 | ||
41 | + * TODO F4:并发控制 :是否被并发下单 购买, | ||
15 | * Created by chao.chen on 2019/3/21. | 42 | * Created by chao.chen on 2019/3/21. |
16 | */ | 43 | */ |
17 | @Service | 44 | @Service |
18 | public class NotEntrySellerChangePriceService { | 45 | public class NotEntrySellerChangePriceService { |
19 | private final Logger logger = LoggerUtils.getSellerOrderLogger(); | 46 | private final Logger logger = LoggerUtils.getSellerOrderLogger(); |
20 | 47 | ||
48 | + @Autowired | ||
49 | + private SellerChangePriceRecordMapper sellerChangePriceRecordMapper; | ||
21 | 50 | ||
22 | @Autowired | 51 | @Autowired |
23 | private NESChangePricePrepareProcessor nesChangePricePrepareProcessor; | 52 | private NESChangePricePrepareProcessor nesChangePricePrepareProcessor; |
24 | 53 | ||
54 | + @Autowired | ||
55 | + NESChangePricePublishPrepareProcessor nesChangePricePublishPrepareProcessor; | ||
56 | + | ||
57 | + @Autowired | ||
58 | + NESChangePricePublishExcutor nesChangePricePublishExcutor; | ||
59 | + | ||
60 | + | ||
61 | + public boolean isChangePriceOrder(int skup){ | ||
62 | + | ||
63 | + return false; | ||
64 | + } | ||
65 | + | ||
66 | + | ||
67 | + public boolean isChangePriceOrder(long orderCode){ | ||
68 | + //todo | ||
69 | + return false; | ||
70 | + } | ||
71 | + | ||
25 | /** | 72 | /** |
26 | * compute Change Price4 NES(Not Entry Seller) | 73 | * compute Change Price4 NES(Not Entry Seller) |
27 | * @param req | 74 | * @param req |
28 | * @return | 75 | * @return |
29 | */ | 76 | */ |
30 | public SoldPrdComputeBo computeChangePrice(NESChangePriceReq req){ | 77 | public SoldPrdComputeBo computeChangePrice(NESChangePriceReq req){ |
31 | - logger.info("in computeChangePrice4NES, req {}", req); | 78 | + logger.info("in NotEntrySellerChangePriceService.computeChangePrice, req {}", req); |
32 | ChangePricePrepareDTO cppDto = nesChangePricePrepareProcessor.checkAndAcquire(req); | 79 | ChangePricePrepareDTO cppDto = nesChangePricePrepareProcessor.checkAndAcquire(req); |
33 | SoldPrdComputeBo computeBo = SellerOrderConvertor.computeResult2SoldPrdComputeBo(cppDto.getComputeResult()); | 80 | SoldPrdComputeBo computeBo = SellerOrderConvertor.computeResult2SoldPrdComputeBo(cppDto.getComputeResult()); |
34 | return computeBo; | 81 | return computeBo; |
@@ -41,14 +88,36 @@ public class NotEntrySellerChangePriceService { | @@ -41,14 +88,36 @@ public class NotEntrySellerChangePriceService { | ||
41 | * @return | 88 | * @return |
42 | */ | 89 | */ |
43 | public OrderSubmitResp changePrice(NESChangePriceReq req){ | 90 | public OrderSubmitResp changePrice(NESChangePriceReq req){ |
91 | + logger.info("in NotEntrySellerChangePriceService.changePrice, req {}", req); | ||
92 | + NESCPOrderContext ctx = nesChangePricePublishPrepareProcessor.buildPublishCtx(req); | ||
44 | //TODO | 93 | //TODO |
45 | - /*1. 屏蔽待变价skup | ||
46 | - * 1.1 何时恢复 | ||
47 | - * | ||
48 | - * 生成待支付订单,将订单号返回给客户端 | 94 | + /* |
95 | + step 1. 检查变价记录 seller_change_price_record | ||
96 | + 1.1 存在时 -> step 3 | ||
97 | + 1.2 不存在时 -> step 2 | ||
98 | + step 2. 屏蔽待变价skup | ||
99 | + 2.1 何时恢复 | ||
100 | + step 3. 取消已有的待支付订单 (修改订单 商品状态 ,变价记录是否记录失败原因) | ||
101 | + step 4. 生成待支付订单 待上架的商品,将订单号返回给客户端 | ||
102 | + | ||
103 | + step 5. 记录变价记录(新的订单号,新skup) | ||
49 | */ | 104 | */ |
105 | + SellerOrderGoods psog = ctx.getSellerOrderGoods(); | ||
106 | + int skup = psog.getId(); | ||
107 | + SellerOrder sellerOrder = ctx.getSellerOrder(); | ||
108 | + Long preOrderCode = sellerOrder.getOrderCode(); | ||
109 | + List<Short> scprs = Lists.newArrayListWithCapacity(2); | ||
110 | + scprs.add(ChangePriceStatus.WAITING_DEAL.getCode()); | ||
111 | + scprs.add(ChangePriceStatus.SUCCESS.getCode()); | ||
50 | 112 | ||
113 | + List<SellerChangePriceRecord> scprList = sellerChangePriceRecordMapper.selectByPreOrderCodeNStatus(preOrderCode, scprs); | ||
114 | + if (CollectionUtils.isEmpty(scprList)){ | ||
115 | + //首次 或 全部失败 | ||
116 | + return nesChangePricePublishExcutor.publish(ctx); | ||
117 | + } | ||
118 | + //存在成功处理,有且只有一条才对(不完全正确,多终端操作同一个待变价商品) | ||
51 | 119 | ||
120 | + //没有一条成功处理,但是存在等待处理 | ||
52 | return null; | 121 | return null; |
53 | } | 122 | } |
54 | 123 | ||
@@ -62,4 +131,7 @@ public class NotEntrySellerChangePriceService { | @@ -62,4 +131,7 @@ public class NotEntrySellerChangePriceService { | ||
62 | 131 | ||
63 | } | 132 | } |
64 | 133 | ||
134 | + | ||
135 | + | ||
136 | + | ||
65 | } | 137 | } |
1 | -package com.yohoufo.order.service.impl.processor; | 1 | +package com.yohoufo.order.service.seller.processor; |
2 | 2 | ||
3 | import com.yohoufo.common.exception.UfoServiceException; | 3 | import com.yohoufo.common.exception.UfoServiceException; |
4 | import com.yohoufo.dal.order.BuyerOrderGoodsMapper; | 4 | import com.yohoufo.dal.order.BuyerOrderGoodsMapper; |
1 | -package com.yohoufo.order.service.impl.processor; | 1 | +package com.yohoufo.order.service.seller.processor; |
2 | 2 | ||
3 | import com.yohobuy.ufo.model.order.bo.PrdPrice; | 3 | import com.yohobuy.ufo.model.order.bo.PrdPrice; |
4 | import com.yohobuy.ufo.model.order.common.OrderStatus; | 4 | import com.yohobuy.ufo.model.order.common.OrderStatus; |
order/src/main/java/com/yohoufo/order/service/seller/processor/AbsPublishPrepareProcessor.java
0 → 100644
1 | +package com.yohoufo.order.service.seller.processor; | ||
2 | + | ||
3 | +import com.yohobuy.ufo.model.GoodsSize; | ||
4 | +import com.yohobuy.ufo.model.order.bo.GoodsInfo; | ||
5 | +import com.yohobuy.ufo.model.order.vo.AddressInfo; | ||
6 | +import com.yohobuy.ufo.model.response.StorageDataResp; | ||
7 | +import com.yohoufo.order.model.SellerOrderContext; | ||
8 | +import com.yohoufo.order.service.proxy.ProductProxyService; | ||
9 | +import com.yohoufo.order.service.seller.PublishPrepareProcessor; | ||
10 | +import org.slf4j.Logger; | ||
11 | +import org.springframework.beans.factory.annotation.Autowired; | ||
12 | + | ||
13 | +import java.math.BigDecimal; | ||
14 | +import java.util.Objects; | ||
15 | + | ||
16 | +/** | ||
17 | + * Created by chao.chen on 2019/3/22. | ||
18 | + */ | ||
19 | +public abstract class AbsPublishPrepareProcessor<I,O> extends AbsChangePricePrepareProcessor | ||
20 | +implements PublishPrepareProcessor<I,O> { | ||
21 | + protected abstract Logger getLogger(); | ||
22 | + | ||
23 | + @Autowired | ||
24 | + private ProductProxyService productProxyService; | ||
25 | + | ||
26 | + public GoodsInfo getProductDetail(SellerOrderContext context){ | ||
27 | + int uid = context.getUid(); | ||
28 | + int storageId = context.getStorageId(); | ||
29 | + BigDecimal salePrice = context.getSalePrice(); | ||
30 | + try { | ||
31 | + StorageDataResp prdResp = productProxyService.getStorageData(storageId); | ||
32 | + if (!Integer.valueOf(1).equals(prdResp.getStatus())) { | ||
33 | + getLogger().info("in getProductDetail occur product out shelve, uid {}, storageId {}", uid, storageId); | ||
34 | + return null; | ||
35 | + } | ||
36 | + GoodsInfo goodsInfo = new GoodsInfo(); | ||
37 | + goodsInfo.setUid(uid); | ||
38 | + goodsInfo.setProductId(prdResp.getProductId()); | ||
39 | + goodsInfo.setProductName(prdResp.getProductName()); | ||
40 | + goodsInfo.setColorId(Objects.isNull(prdResp.getColorId()) ? null : Integer.valueOf(prdResp.getColorId())); | ||
41 | + goodsInfo.setColorName(prdResp.getColorName()); | ||
42 | + GoodsSize size; | ||
43 | + if (Objects.nonNull(size = prdResp.getSize())){ | ||
44 | + goodsInfo.setSizeName(size.getSizeName()); | ||
45 | + goodsInfo.setSizeId(size.getSizeId()); | ||
46 | + } | ||
47 | + goodsInfo.setImageUrl(prdResp.getImageUrl()); | ||
48 | + goodsInfo.setPrice(salePrice); | ||
49 | + goodsInfo.setStorageId(context.getStorageId()); | ||
50 | + goodsInfo.setSkupType(context.getSkupType()); | ||
51 | + return goodsInfo; | ||
52 | + }catch (Exception ex){ | ||
53 | + getLogger().warn("in getProductDetail occur error, uid {}, storageId {}", uid, storageId); | ||
54 | + return null; | ||
55 | + } | ||
56 | + } | ||
57 | + | ||
58 | +} |
1 | -package com.yohoufo.order.service.impl.processor; | 1 | +package com.yohoufo.order.service.seller.processor; |
2 | 2 | ||
3 | import com.yohobuy.ufo.model.order.common.SkupStatus; | 3 | import com.yohobuy.ufo.model.order.common.SkupStatus; |
4 | import com.yohobuy.ufo.model.order.req.SellerBatchChangeReq; | 4 | import com.yohobuy.ufo.model.order.req.SellerBatchChangeReq; |
5 | import com.yohoufo.common.exception.UfoServiceException; | 5 | import com.yohoufo.common.exception.UfoServiceException; |
6 | -import com.yohoufo.dal.order.SellerOrderGoodsMapper; | ||
7 | import com.yohoufo.dal.order.model.SellerOrderGoods; | 6 | import com.yohoufo.dal.order.model.SellerOrderGoods; |
8 | import com.yohoufo.order.common.Payment; | 7 | import com.yohoufo.order.common.Payment; |
9 | import com.yohoufo.order.model.dto.SkupDto; | 8 | import com.yohoufo.order.model.dto.SkupDto; |
10 | import org.slf4j.Logger; | 9 | import org.slf4j.Logger; |
11 | -import org.springframework.beans.factory.annotation.Autowired; | ||
12 | import org.springframework.stereotype.Service; | 10 | import org.springframework.stereotype.Service; |
13 | import org.springframework.util.Assert; | 11 | import org.springframework.util.Assert; |
14 | 12 |
1 | -package com.yohoufo.order.service.impl.processor; | 1 | +package com.yohoufo.order.service.seller.processor; |
2 | 2 | ||
3 | import com.google.common.base.Splitter; | 3 | import com.google.common.base.Splitter; |
4 | import com.yohobuy.ufo.model.order.common.SkupStatus; | 4 | import com.yohobuy.ufo.model.order.common.SkupStatus; |
5 | import com.yohobuy.ufo.model.order.req.BatchChangePriceReq; | 5 | import com.yohobuy.ufo.model.order.req.BatchChangePriceReq; |
6 | -import com.yohoufo.common.exception.GatewayException; | ||
7 | import com.yohoufo.common.exception.UfoServiceException; | 6 | import com.yohoufo.common.exception.UfoServiceException; |
8 | -import com.yohoufo.dal.order.SellerOrderGoodsMapper; | ||
9 | import com.yohoufo.dal.order.model.SellerOrderGoods; | 7 | import com.yohoufo.dal.order.model.SellerOrderGoods; |
10 | import com.yohoufo.order.model.dto.ChangePricePrepareDTO; | 8 | import com.yohoufo.order.model.dto.ChangePricePrepareDTO; |
11 | import com.yohoufo.order.model.dto.SkupDto; | 9 | import com.yohoufo.order.model.dto.SkupDto; |
12 | import org.apache.commons.lang3.StringUtils; | 10 | import org.apache.commons.lang3.StringUtils; |
13 | import org.slf4j.Logger; | 11 | import org.slf4j.Logger; |
14 | -import org.springframework.beans.factory.annotation.Autowired; | ||
15 | import org.springframework.stereotype.Service; | 12 | import org.springframework.stereotype.Service; |
16 | import org.springframework.util.Assert; | 13 | import org.springframework.util.Assert; |
17 | 14 |
order/src/main/java/com/yohoufo/order/service/seller/processor/ImportPublishPrepareProcessor.java
0 → 100644
1 | +package com.yohoufo.order.service.seller.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.bo.PrdPrice; | ||
7 | +import com.yohobuy.ufo.model.order.constants.SkupType; | ||
8 | +import com.yohobuy.ufo.model.order.vo.AddressInfo; | ||
9 | +import com.yohoufo.common.exception.UfoServiceException; | ||
10 | +import com.yohoufo.order.model.SellerOrderContext; | ||
11 | +import com.yohoufo.order.model.dto.ImPrdNode; | ||
12 | +import com.yohoufo.order.model.dto.SellerOrderComputeResult; | ||
13 | +import com.yohoufo.order.service.seller.OrderComputeHandler; | ||
14 | +import com.yohoufo.order.service.seller.PublishPrepareProcessor; | ||
15 | +import com.yohoufo.order.utils.LoggerUtils; | ||
16 | +import com.yohoufo.order.utils.OrderAssist; | ||
17 | +import org.slf4j.Logger; | ||
18 | +import org.springframework.stereotype.Service; | ||
19 | + | ||
20 | +import java.math.BigDecimal; | ||
21 | +import java.util.Objects; | ||
22 | + | ||
23 | +/** | ||
24 | + * Created by chao.chen on 2019/3/22. | ||
25 | + */ | ||
26 | +@Service | ||
27 | +public class ImportPublishPrepareProcessor extends AbsPublishPrepareProcessor<ImPrdNode,SellerOrderContext> | ||
28 | + implements PublishPrepareProcessor<ImPrdNode,SellerOrderContext> | ||
29 | +{ | ||
30 | + Logger logger = LoggerUtils.getSellerOrderLogger(); | ||
31 | + | ||
32 | + | ||
33 | + | ||
34 | + @Override | ||
35 | + protected Logger getLogger() { | ||
36 | + return logger; | ||
37 | + } | ||
38 | + | ||
39 | + | ||
40 | + @Override | ||
41 | + public SellerOrderContext buildPublishCtx(ImPrdNode node) { | ||
42 | + Integer uid = node.getUid(); | ||
43 | + Integer storageId = node.getStorageId(); | ||
44 | + BigDecimal salePrice = node.getSalePrice(); | ||
45 | + int storageNum = node.getStorageNum(); | ||
46 | + SellerOrderContext ctx = buildImportPrdCxt(uid, storageId, salePrice, storageNum, | ||
47 | + node.getGoodsPaymentRate()); | ||
48 | + | ||
49 | + AddressInfo hiddenBackAddress = node.getHiddenBackAddress(); | ||
50 | + AddressInfo noHiddenBackAddress = node.getNoHiddenBackAddress(); | ||
51 | + ctx.setBackAddress(noHiddenBackAddress); | ||
52 | + ctx.setBackHiddenAddress(hiddenBackAddress); | ||
53 | + | ||
54 | + | ||
55 | + return ctx; | ||
56 | + } | ||
57 | + | ||
58 | + /** | ||
59 | + * 批量导入时 构建单个skup使用 | ||
60 | + * @param uid | ||
61 | + * @param storageId | ||
62 | + * @param salePrice | ||
63 | + * @param storageNum | ||
64 | + * @return | ||
65 | + */ | ||
66 | + private SellerOrderContext buildImportPrdCxt(Integer uid, Integer storageId, BigDecimal salePrice, int storageNum, | ||
67 | + BigDecimal goodsPaymentRate){ | ||
68 | + if (uid <= 0){ | ||
69 | + logger.warn("buildImportPrdCxt uid illegal , uid {}", uid); | ||
70 | + throw new UfoServiceException(400, "Uid 错误"); | ||
71 | + } | ||
72 | + if (storageId <=0 ){ | ||
73 | + logger.warn("buildImportPrdCxt storageId illegal , uid {}", uid); | ||
74 | + throw new UfoServiceException(400, "storageId 错误"); | ||
75 | + } | ||
76 | + | ||
77 | + // | ||
78 | + SellerOrderContext context = new SellerOrderContext(); | ||
79 | + context.setUid(uid); | ||
80 | + context.setStorageId(storageId); | ||
81 | + context.setSalePrice(salePrice); | ||
82 | + SkupType skupType = SkupType.IN_STOCK; | ||
83 | + context.setSkupType(skupType); | ||
84 | + //TODO set noHiddenBackAddress & hiddenBackAddress | ||
85 | + //context.setBackAddress(noHiddenBackAddress); | ||
86 | + //context.setBackHiddenAddress(hiddenBackAddress); | ||
87 | + //step 1: rpc get product detail by storage id | ||
88 | + //ufo.product.storage.data | ||
89 | + GoodsInfo goodsInfo = getProductDetail(context); | ||
90 | + //step 2: generate skup ,action :set price status(unsaleable) | ||
91 | + if (Objects.isNull(goodsInfo)){ | ||
92 | + logger.warn("in buildImportPrdCxt storageId not exist in prd service , uid {}, storageId {}", uid, storageId); | ||
93 | + throw new ServiceException(ServiceError.ORDER_ORDERS_GOODS_IS_EMPTY); | ||
94 | + } | ||
95 | + context.setSoldProduct(goodsInfo); | ||
96 | + if (storageNum <=0){ | ||
97 | + logger.warn("in buildBatchSellerOrderContext storageNum illegal , uid {}, storageId {} storageNum {}", | ||
98 | + uid, storageId, storageNum); | ||
99 | + throw new ServiceException(ServiceError.SELLER_PUBLISH_PRD_NUM_ILLEGAL); | ||
100 | + } | ||
101 | + //step 1: rpc get product detail by storage id | ||
102 | + //ufo.product.storage.data | ||
103 | + goodsInfo.setStorageNum(storageNum); | ||
104 | + | ||
105 | + // compute every fee from price | ||
106 | + PrdPrice prdPrice = new PrdPrice(); | ||
107 | + prdPrice.setCanPublish(true); | ||
108 | + prdPrice.setGoodsPaymentRate(goodsPaymentRate); | ||
109 | + SellerOrderComputeResult pcc = OrderAssist.buildPersonalComputeConfig(prdPrice); | ||
110 | + OrderComputeHandler computeHandler = orderComputeProvider.findBySkupType(skupType); | ||
111 | + SellerOrderComputeResult computeResult = computeHandler.compute(goodsInfo.getPrice(), pcc); | ||
112 | + logger.info("in buildImportPrdCxt , uid {}, storageId {}, price {}, computeResult {}", uid, storageId, | ||
113 | + goodsInfo.getPrice(), computeResult); | ||
114 | + context.setSellerOrderComputeResult(computeResult); | ||
115 | + return context; | ||
116 | + } | ||
117 | + | ||
118 | + } |
1 | -package com.yohoufo.order.service.impl.processor; | 1 | +package com.yohoufo.order.service.seller.processor; |
2 | 2 | ||
3 | import com.google.common.collect.Lists; | 3 | import com.google.common.collect.Lists; |
4 | +import com.google.common.collect.Maps; | ||
4 | import com.yohobuy.ufo.model.order.bo.PrdPrice; | 5 | import com.yohobuy.ufo.model.order.bo.PrdPrice; |
5 | import com.yohobuy.ufo.model.order.common.OrderStatus; | 6 | import com.yohobuy.ufo.model.order.common.OrderStatus; |
6 | import com.yohobuy.ufo.model.order.common.SkupStatus; | 7 | import com.yohobuy.ufo.model.order.common.SkupStatus; |
@@ -25,6 +26,7 @@ import org.springframework.stereotype.Service; | @@ -25,6 +26,7 @@ import org.springframework.stereotype.Service; | ||
25 | import java.math.BigDecimal; | 26 | import java.math.BigDecimal; |
26 | import java.util.Arrays; | 27 | import java.util.Arrays; |
27 | import java.util.List; | 28 | import java.util.List; |
29 | +import java.util.Map; | ||
28 | import java.util.Objects; | 30 | import java.util.Objects; |
29 | import java.util.stream.Collectors; | 31 | import java.util.stream.Collectors; |
30 | 32 | ||
@@ -37,7 +39,7 @@ public class NESChangePricePrepareProcessor extends AbsChangePricePrepareProcess | @@ -37,7 +39,7 @@ public class NESChangePricePrepareProcessor extends AbsChangePricePrepareProcess | ||
37 | protected final Logger logger = LoggerUtils.getSellerOrderLogger(); | 39 | protected final Logger logger = LoggerUtils.getSellerOrderLogger(); |
38 | 40 | ||
39 | 41 | ||
40 | - private void checkGoodsStatus(SellerOrderGoods psog){ | 42 | + public void checkGoodsStatus(SellerOrderGoods psog){ |
41 | if (SkupStatus.CAN_SELL.getCode() != psog.getStatus().intValue()){ | 43 | if (SkupStatus.CAN_SELL.getCode() != psog.getStatus().intValue()){ |
42 | logger.warn("in NESChangePricePrepareProcessor.checkGoodsStatus not can sale, SellerOrderGoods {}", psog); | 44 | logger.warn("in NESChangePricePrepareProcessor.checkGoodsStatus not can sale, SellerOrderGoods {}", psog); |
43 | throw new UfoServiceException(400, "商品不是可售状态"); | 45 | throw new UfoServiceException(400, "商品不是可售状态"); |
@@ -105,8 +107,13 @@ public class NESChangePricePrepareProcessor extends AbsChangePricePrepareProcess | @@ -105,8 +107,13 @@ public class NESChangePricePrepareProcessor extends AbsChangePricePrepareProcess | ||
105 | BigDecimal targetEM = computeResult.getEarnestMoney().getEarnestMoney(); | 107 | BigDecimal targetEM = computeResult.getEarnestMoney().getEarnestMoney(); |
106 | BigDecimal diffEarnestMoney = calDiffOfEM(sourceEM,targetEM); | 108 | BigDecimal diffEarnestMoney = calDiffOfEM(sourceEM,targetEM); |
107 | 109 | ||
110 | + //build one skup Map | ||
111 | + Map<Integer, SkupDto> skupMap = Maps.newHashMapWithExpectedSize(1); | ||
112 | + SkupDto skupDto = SkupDto.builder().sellerOrder(sellerOrder).sellerOrderGoods(psog).build(); | ||
113 | + skupMap.put(skup, skupDto); | ||
108 | return ChangePricePrepareDTO.builder() | 114 | return ChangePricePrepareDTO.builder() |
109 | .baseSellerOrderGoods(psog) | 115 | .baseSellerOrderGoods(psog) |
116 | + .skupMap(skupMap) | ||
110 | .prdPrice(prdPrice) | 117 | .prdPrice(prdPrice) |
111 | .salePrice(salePrice) | 118 | .salePrice(salePrice) |
112 | .diffEarnestMoney(diffEarnestMoney) | 119 | .diffEarnestMoney(diffEarnestMoney) |
1 | +package com.yohoufo.order.service.seller.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.bo.PrdPrice; | ||
7 | +import com.yohobuy.ufo.model.order.constants.SkupType; | ||
8 | +import com.yohobuy.ufo.model.order.req.NESChangePriceReq; | ||
9 | +import com.yohobuy.ufo.model.order.vo.AddressInfo; | ||
10 | +import com.yohoufo.common.exception.UfoServiceException; | ||
11 | +import com.yohoufo.common.utils.AddressUtil; | ||
12 | +import com.yohoufo.dal.order.model.SellerOrder; | ||
13 | +import com.yohoufo.dal.order.model.SellerOrderGoods; | ||
14 | +import com.yohoufo.order.model.NESCPOrderContext; | ||
15 | +import com.yohoufo.order.model.SellerOrderContext; | ||
16 | +import com.yohoufo.order.model.dto.SellerOrderComputeResult; | ||
17 | +import com.yohoufo.order.model.dto.SkupDto; | ||
18 | +import com.yohoufo.order.model.request.PrdQueryReq; | ||
19 | +import com.yohoufo.order.service.seller.OrderComputeHandler; | ||
20 | +import com.yohoufo.order.service.seller.PublishPrepareProcessor; | ||
21 | +import com.yohoufo.order.utils.AddressHelper; | ||
22 | +import com.yohoufo.order.utils.LoggerUtils; | ||
23 | +import com.yohoufo.order.utils.OrderAssist; | ||
24 | +import org.slf4j.Logger; | ||
25 | +import org.springframework.beans.factory.annotation.Autowired; | ||
26 | +import org.springframework.stereotype.Service; | ||
27 | + | ||
28 | +import java.math.BigDecimal; | ||
29 | +import java.util.Objects; | ||
30 | + | ||
31 | +/** | ||
32 | + * Created by chao.chen on 2019/3/22. | ||
33 | + */ | ||
34 | +@Service | ||
35 | +public class NESChangePricePublishPrepareProcessor extends AbsPublishPrepareProcessor<NESChangePriceReq, SellerOrderContext> | ||
36 | + implements PublishPrepareProcessor<NESChangePriceReq, SellerOrderContext> { | ||
37 | + | ||
38 | + | ||
39 | + final Logger logger = LoggerUtils.getSellerOrderLogger(); | ||
40 | + | ||
41 | + @Autowired | ||
42 | + private NESChangePricePrepareProcessor nesChangePricePrepareProcessor; | ||
43 | + | ||
44 | + @Override | ||
45 | + public NESCPOrderContext buildPublishCtx(NESChangePriceReq im) { | ||
46 | + return buildSellerOrderContext(im); | ||
47 | + } | ||
48 | + | ||
49 | + private NESCPOrderContext buildSellerOrderContext(NESChangePriceReq req) { | ||
50 | + | ||
51 | + int uid = req.getUid(); | ||
52 | + if (uid <= 0){ | ||
53 | + logger.warn("ChangePrice checkAndAcquire uid illegal , req {}", req); | ||
54 | + throw new UfoServiceException(400, "参数[uid]错误"); | ||
55 | + } | ||
56 | + if (uid <=0){ | ||
57 | + logger.warn("in ChangePrice uid illegal, req {}", req); | ||
58 | + throw new UfoServiceException(400, "参数uid非法"); | ||
59 | + } | ||
60 | + int skup = req.getSkup(); | ||
61 | + if (skup<=0){ | ||
62 | + logger.warn("in ChangePrice find illegal skup code, req {}", req); | ||
63 | + throw new UfoServiceException(400, "参数skup非法"); | ||
64 | + } | ||
65 | + SellerOrderGoods psog = sellerOrderGoodsMapper.selectByPrimaryKey(skup); | ||
66 | + if (Objects.isNull(psog)){ | ||
67 | + logger.warn("in ChangePrice can not find skup in sys, req {}", req); | ||
68 | + throw new UfoServiceException(400, "商品不存在"); | ||
69 | + } | ||
70 | + //检查是否有买家下单 | ||
71 | + nesChangePricePrepareProcessor.checkGoodsStatus(psog); | ||
72 | + | ||
73 | + Integer puid = psog.getUid(); | ||
74 | + if (!puid.equals(uid)){ | ||
75 | + logger.warn("in ChangePrice can not find one hacker , req {} sys-uid {}", req, puid); | ||
76 | + throw new UfoServiceException(400, "你是猴子么"); | ||
77 | + } | ||
78 | + //check whether exists waiting pay order of skup | ||
79 | + SkupDto skupOfUnChange = nesChangePricePrepareProcessor.checkExistWaitingBuyerPay(psog); | ||
80 | + | ||
81 | + BigDecimal salePrice = priceComputePrepareProcessor.checkAndAcquireSalePrice(req.getPrice()); | ||
82 | + BigDecimal preSalePrice = psog.getGoodsPrice(); | ||
83 | + //check old price vs new price | ||
84 | + checkChangeNecessary(skup, preSalePrice, salePrice); | ||
85 | + | ||
86 | + | ||
87 | + String tips = null; | ||
88 | + PrdPrice prdPrice; | ||
89 | + int storageId = psog.getStorageId(); | ||
90 | + PrdQueryReq pqr = PrdQueryReq.builder() | ||
91 | + .uid(uid).prdPrice(salePrice).storageId(storageId).build(); | ||
92 | + prdPrice = priceComputePrepareProcessor.checkPriceRange(pqr, true); | ||
93 | + SkupType skupType = SkupType.getSkupType(psog.getAttributes()); | ||
94 | + try { | ||
95 | + priceComputePrepareProcessor.checkSuggestPrice(prdPrice, salePrice, skupType); | ||
96 | + }catch (UfoServiceException ex){ | ||
97 | + tips = ex.getErrorMessage(); | ||
98 | + } | ||
99 | + // compute every fee from price | ||
100 | + SellerOrderComputeResult pcc = OrderAssist.buildPersonalComputeConfig(prdPrice); | ||
101 | + OrderComputeHandler computeHandler = orderComputeProvider.findBySkupType(skupType); | ||
102 | + SellerOrderComputeResult computeResult = computeHandler.compute(salePrice, pcc); | ||
103 | + //check income | ||
104 | + priceComputePrepareProcessor.checkIncome(storageId, computeResult.getIncome()); | ||
105 | + //calculate different of earnest Money | ||
106 | + SellerOrder sellerOrder = sellerOrderMapper.selectBySkup(psog.getId()); | ||
107 | + BigDecimal sourceEM = sellerOrder.getEarnestMoney(); | ||
108 | + BigDecimal targetEM = computeResult.getEarnestMoney().getEarnestMoney(); | ||
109 | + BigDecimal diffEarnestMoney = calDiffOfEM(sourceEM,targetEM); | ||
110 | + | ||
111 | + | ||
112 | + /* | ||
113 | + //the address of send back 2 seller | ||
114 | + AddressInfo hiddenBackAddress = userProxyService.getHiddenAddressInfo(uid, addressId); | ||
115 | + AddressInfo noHiddenBackAddress = userProxyService.getAddressInfoNotHidden(uid, addressId); | ||
116 | + if(AddressHelper.isNeedUpdate(noHiddenBackAddress)){ | ||
117 | + logger.warn("seller submit addressId need update, uid is {}, storageId is {}, addressId is {}", | ||
118 | + uid, storageId, addressId); | ||
119 | + throw new ServiceException(ServiceError.ORDER_ADDRESS_NEED_UPDATE); | ||
120 | + }*/ | ||
121 | + // | ||
122 | + NESCPOrderContext context = new NESCPOrderContext(); | ||
123 | + context.setUid(uid); | ||
124 | + context.setStorageId(storageId); | ||
125 | + context.setSalePrice(salePrice); | ||
126 | + // | ||
127 | + //context.setBackAddress(noHiddenBackAddress); | ||
128 | + //context.setBackHiddenAddress(hiddenBackAddress); | ||
129 | + // | ||
130 | + context.setSkupType(skupType); | ||
131 | + //step 1: rpc get product detail by storage id | ||
132 | + //ufo.product.storage.data | ||
133 | + GoodsInfo goodsInfo = getProductDetail(context); | ||
134 | + //step 2: generate skup ,action :set price status(unsaleable) | ||
135 | + if (Objects.isNull(goodsInfo)){ | ||
136 | + logger.warn("in buildSellerOrderContext storageId not exist in prd service , uid {}, storageId {}", uid, storageId); | ||
137 | + throw new ServiceException(ServiceError.ORDER_ORDERS_GOODS_IS_EMPTY); | ||
138 | + } | ||
139 | + context.setSoldProduct(goodsInfo); | ||
140 | + | ||
141 | + | ||
142 | + | ||
143 | + logger.info("in build not entry Seller Order Context , uid {}, storageId {}, price {}, computeResult {}", uid, storageId, | ||
144 | + goodsInfo.getPrice(), computeResult); | ||
145 | + context.setSellerOrderComputeResult(computeResult); | ||
146 | + context.setPriceOverFlowTips(tips); | ||
147 | + return context; | ||
148 | + } | ||
149 | + | ||
150 | + @Override | ||
151 | + protected Logger getLogger() { | ||
152 | + return this.logger; | ||
153 | + } | ||
154 | +} |
1 | -package com.yohoufo.order.service.impl.processor; | 1 | +package com.yohoufo.order.service.seller.processor; |
2 | 2 | ||
3 | import com.yohobuy.ufo.model.order.bo.SellerBo; | 3 | import com.yohobuy.ufo.model.order.bo.SellerBo; |
4 | import com.yohobuy.ufo.model.order.bo.SellerLevelFuncBo; | 4 | import com.yohobuy.ufo.model.order.bo.SellerLevelFuncBo; |
1 | -package com.yohoufo.order.service.impl.processor; | 1 | +package com.yohoufo.order.service.seller.processor; |
2 | 2 | ||
3 | import com.google.common.base.Splitter; | 3 | import com.google.common.base.Splitter; |
4 | import com.yohobuy.ufo.model.order.common.SkupStatus; | 4 | import com.yohobuy.ufo.model.order.common.SkupStatus; |
@@ -12,7 +12,6 @@ import lombok.Data; | @@ -12,7 +12,6 @@ import lombok.Data; | ||
12 | import org.apache.commons.collections.CollectionUtils; | 12 | import org.apache.commons.collections.CollectionUtils; |
13 | import org.apache.commons.lang3.StringUtils; | 13 | import org.apache.commons.lang3.StringUtils; |
14 | import org.slf4j.Logger; | 14 | import org.slf4j.Logger; |
15 | -import org.slf4j.LoggerFactory; | ||
16 | import org.springframework.beans.factory.annotation.Autowired; | 15 | import org.springframework.beans.factory.annotation.Autowired; |
17 | import org.springframework.stereotype.Service; | 16 | import org.springframework.stereotype.Service; |
18 | 17 |
1 | -package com.yohoufo.order.service.impl.processor; | 1 | +package com.yohoufo.order.service.seller.processor; |
2 | 2 | ||
3 | import com.yohobuy.ufo.model.order.common.SkupStatus; | 3 | import com.yohobuy.ufo.model.order.common.SkupStatus; |
4 | import com.yohobuy.ufo.model.order.req.SellerBatchChangeReq; | 4 | import com.yohobuy.ufo.model.order.req.SellerBatchChangeReq; |
1 | -package com.yohoufo.order.service.impl.processor; | 1 | +package com.yohoufo.order.service.seller.processor; |
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; |
@@ -19,6 +19,7 @@ import com.yohoufo.order.service.proxy.ProductProxyService; | @@ -19,6 +19,7 @@ import com.yohoufo.order.service.proxy.ProductProxyService; | ||
19 | import com.yohoufo.order.service.proxy.UserProxyService; | 19 | import com.yohoufo.order.service.proxy.UserProxyService; |
20 | import com.yohoufo.order.service.seller.OrderComputeHandler; | 20 | import com.yohoufo.order.service.seller.OrderComputeHandler; |
21 | import com.yohoufo.order.service.seller.OrderComputeProvider; | 21 | import com.yohoufo.order.service.seller.OrderComputeProvider; |
22 | +import com.yohoufo.order.service.seller.PublishPrepareProcessor; | ||
22 | import com.yohoufo.order.utils.AddressHelper; | 23 | import com.yohoufo.order.utils.AddressHelper; |
23 | import com.yohoufo.order.utils.LoggerUtils; | 24 | import com.yohoufo.order.utils.LoggerUtils; |
24 | import com.yohoufo.order.utils.OrderAssist; | 25 | import com.yohoufo.order.utils.OrderAssist; |
@@ -33,23 +34,21 @@ import java.util.Objects; | @@ -33,23 +34,21 @@ import java.util.Objects; | ||
33 | * Created by chao.chen on 2018/11/19. | 34 | * Created by chao.chen on 2018/11/19. |
34 | */ | 35 | */ |
35 | @Service | 36 | @Service |
36 | -public class SellerOrderPrepareProcessor { | 37 | +public class SellerOrderPrepareProcessor extends AbsPublishPrepareProcessor<SellerOrderSubmitReq, SellerOrderContext> |
38 | + implements PublishPrepareProcessor<SellerOrderSubmitReq, SellerOrderContext> { | ||
37 | 39 | ||
38 | private final Logger log = LoggerUtils.getSellerOrderLogger(); | 40 | private final Logger log = LoggerUtils.getSellerOrderLogger(); |
39 | 41 | ||
40 | @Autowired | 42 | @Autowired |
41 | private UserProxyService userProxyService; | 43 | private UserProxyService userProxyService; |
42 | 44 | ||
43 | - @Autowired | ||
44 | - private ProductProxyService productProxyService; | ||
45 | - | ||
46 | - @Autowired | ||
47 | - private OrderComputeProvider orderComputeProvider; | 45 | + //@Autowired |
46 | + //private OrderComputeProvider orderComputeProvider; | ||
48 | 47 | ||
49 | - @Autowired | ||
50 | - private PriceComputePrepareProcessor priceComputePrepareProcessor; | 48 | + //@Autowired |
49 | + //private PriceComputePrepareProcessor priceComputePrepareProcessor; | ||
51 | 50 | ||
52 | - public SellerOrderContext buildPublishPrdCtx(SellerOrderSubmitReq req) throws GatewayException { | 51 | + public SellerOrderContext buildPublishPrdCtx(SellerOrderSubmitReq req) { |
53 | SellerOrderContext ctx = buildSellerOrderContext(req); | 52 | SellerOrderContext ctx = buildSellerOrderContext(req); |
54 | int uid = ctx.getUid(); | 53 | int uid = ctx.getUid(); |
55 | boolean isEntryShop = userProxyService.isEntryShop(uid); | 54 | boolean isEntryShop = userProxyService.isEntryShop(uid); |
@@ -60,7 +59,7 @@ public class SellerOrderPrepareProcessor { | @@ -60,7 +59,7 @@ public class SellerOrderPrepareProcessor { | ||
60 | return ctx; | 59 | return ctx; |
61 | } | 60 | } |
62 | 61 | ||
63 | - public void buildBatchSellerOrderContext(SellerOrderSubmitReq req, SellerOrderContext ctx) throws GatewayException { | 62 | + private void buildBatchSellerOrderContext(SellerOrderSubmitReq req, SellerOrderContext ctx) { |
64 | int storageId = ctx.getStorageId(); | 63 | int storageId = ctx.getStorageId(); |
65 | int uid = ctx.getUid(); | 64 | int uid = ctx.getUid(); |
66 | int storageNum = req.getNum(); | 65 | int storageNum = req.getNum(); |
@@ -80,7 +79,7 @@ public class SellerOrderPrepareProcessor { | @@ -80,7 +79,7 @@ public class SellerOrderPrepareProcessor { | ||
80 | } | 79 | } |
81 | 80 | ||
82 | 81 | ||
83 | - public SellerOrderContext buildSellerOrderContext(SellerOrderSubmitReq req) { | 82 | + private SellerOrderContext buildSellerOrderContext(SellerOrderSubmitReq req) { |
84 | int uid = req.getUid(); | 83 | int uid = req.getUid(); |
85 | if (uid <= 0){ | 84 | if (uid <= 0){ |
86 | log.warn("uid illegal , uid {}", uid); | 85 | log.warn("uid illegal , uid {}", uid); |
@@ -152,102 +151,21 @@ public class SellerOrderPrepareProcessor { | @@ -152,102 +151,21 @@ public class SellerOrderPrepareProcessor { | ||
152 | return context; | 151 | return context; |
153 | } | 152 | } |
154 | 153 | ||
155 | - public GoodsInfo getProductDetail(SellerOrderContext context){ | ||
156 | - int uid = context.getUid(); | ||
157 | - int storageId = context.getStorageId(); | ||
158 | - BigDecimal salePrice = context.getSalePrice(); | ||
159 | - try { | ||
160 | - StorageDataResp prdResp = productProxyService.getStorageData(storageId); | ||
161 | - if (!Integer.valueOf(1).equals(prdResp.getStatus())) { | ||
162 | - log.info("in getProductDetail occur product out shelve, uid {}, storageId {}", uid, storageId); | ||
163 | - return null; | ||
164 | - } | ||
165 | - GoodsInfo goodsInfo = new GoodsInfo(); | ||
166 | - goodsInfo.setUid(uid); | ||
167 | - goodsInfo.setProductId(prdResp.getProductId()); | ||
168 | - goodsInfo.setProductName(prdResp.getProductName()); | ||
169 | - goodsInfo.setColorId(Objects.isNull(prdResp.getColorId()) ? null : Integer.valueOf(prdResp.getColorId())); | ||
170 | - goodsInfo.setColorName(prdResp.getColorName()); | ||
171 | - GoodsSize size; | ||
172 | - if (Objects.nonNull(size = prdResp.getSize())){ | ||
173 | - goodsInfo.setSizeName(size.getSizeName()); | ||
174 | - goodsInfo.setSizeId(size.getSizeId()); | ||
175 | - } | ||
176 | - goodsInfo.setImageUrl(prdResp.getImageUrl()); | ||
177 | - goodsInfo.setPrice(salePrice); | ||
178 | - goodsInfo.setStorageId(context.getStorageId()); | ||
179 | - goodsInfo.setSkupType(context.getSkupType()); | ||
180 | - return goodsInfo; | ||
181 | - }catch (Exception ex){ | ||
182 | - log.warn("in getProductDetail occur error, uid {}, storageId {}", uid, storageId); | ||
183 | - return null; | ||
184 | - } | ||
185 | - } | ||
186 | 154 | ||
187 | 155 | ||
188 | public boolean checkIsEntry(int uid){ | 156 | public boolean checkIsEntry(int uid){ |
189 | return userProxyService.isEntryShop(uid); | 157 | return userProxyService.isEntryShop(uid); |
190 | } | 158 | } |
191 | 159 | ||
192 | - /** | ||
193 | - * 批量导入时 构建单个skup使用 | ||
194 | - * @param uid | ||
195 | - * @param storageId | ||
196 | - * @param salePrice | ||
197 | - * @param storageNum | ||
198 | - * @return | ||
199 | - */ | ||
200 | - public SellerOrderContext buildImportPrdCxt(Integer uid, Integer storageId, BigDecimal salePrice, int storageNum, | ||
201 | - BigDecimal goodsPaymentRate){ | ||
202 | - if (uid <= 0){ | ||
203 | - log.warn("buildImportPrdCxt uid illegal , uid {}", uid); | ||
204 | - throw new UfoServiceException(400, "Uid 错误"); | ||
205 | - } | ||
206 | - if (storageId <=0 ){ | ||
207 | - log.warn("buildImportPrdCxt storageId illegal , uid {}", uid); | ||
208 | - throw new UfoServiceException(400, "storageId 错误"); | ||
209 | - } | ||
210 | 160 | ||
211 | - // | ||
212 | - SellerOrderContext context = new SellerOrderContext(); | ||
213 | - context.setUid(uid); | ||
214 | - context.setStorageId(storageId); | ||
215 | - context.setSalePrice(salePrice); | ||
216 | - SkupType skupType = SkupType.IN_STOCK; | ||
217 | - context.setSkupType(skupType); | ||
218 | - //TODO set noHiddenBackAddress & hiddenBackAddress | ||
219 | - //context.setBackAddress(noHiddenBackAddress); | ||
220 | - //context.setBackHiddenAddress(hiddenBackAddress); | ||
221 | - //step 1: rpc get product detail by storage id | ||
222 | - //ufo.product.storage.data | ||
223 | - GoodsInfo goodsInfo = getProductDetail(context); | ||
224 | - //step 2: generate skup ,action :set price status(unsaleable) | ||
225 | - if (Objects.isNull(goodsInfo)){ | ||
226 | - log.warn("in buildImportPrdCxt storageId not exist in prd service , uid {}, storageId {}", uid, storageId); | ||
227 | - throw new ServiceException(ServiceError.ORDER_ORDERS_GOODS_IS_EMPTY); | ||
228 | - } | ||
229 | - context.setSoldProduct(goodsInfo); | ||
230 | - if (storageNum <=0){ | ||
231 | - log.warn("in buildBatchSellerOrderContext storageNum illegal , uid {}, storageId {} storageNum {}", | ||
232 | - uid, storageId, storageNum); | ||
233 | - throw new ServiceException(ServiceError.SELLER_PUBLISH_PRD_NUM_ILLEGAL); | ||
234 | - } | ||
235 | - //step 1: rpc get product detail by storage id | ||
236 | - //ufo.product.storage.data | ||
237 | - goodsInfo.setStorageNum(storageNum); | ||
238 | 161 | ||
239 | - // compute every fee from price | ||
240 | - PrdPrice prdPrice = new PrdPrice(); | ||
241 | - prdPrice.setCanPublish(true); | ||
242 | - prdPrice.setGoodsPaymentRate(goodsPaymentRate); | ||
243 | - SellerOrderComputeResult pcc = OrderAssist.buildPersonalComputeConfig(prdPrice); | ||
244 | - OrderComputeHandler computeHandler = orderComputeProvider.findBySkupType(skupType); | ||
245 | - SellerOrderComputeResult computeResult = computeHandler.compute(goodsInfo.getPrice(), pcc); | ||
246 | - log.info("in buildImportPrdCxt , uid {}, storageId {}, price {}, computeResult {}", uid, storageId, | ||
247 | - goodsInfo.getPrice(), computeResult); | ||
248 | - context.setSellerOrderComputeResult(computeResult); | ||
249 | - return context; | 162 | + @Override |
163 | + public SellerOrderContext buildPublishCtx(SellerOrderSubmitReq req) { | ||
164 | + return buildPublishPrdCtx(req); | ||
250 | } | 165 | } |
251 | 166 | ||
252 | - | 167 | + @Override |
168 | + protected Logger getLogger() { | ||
169 | + return this.log; | ||
170 | + } | ||
253 | } | 171 | } |
1 | -package com.yohoufo.order.service.impl.processor; | 1 | +package com.yohoufo.order.service.seller.processor; |
2 | 2 | ||
3 | import com.yohoufo.common.alarm.CommonAlarmEventPublisher; | 3 | import com.yohoufo.common.alarm.CommonAlarmEventPublisher; |
4 | import com.yohoufo.common.utils.DateUtil; | 4 | import com.yohoufo.common.utils.DateUtil; |
@@ -4,7 +4,7 @@ import com.alibaba.fastjson.JSONObject; | @@ -4,7 +4,7 @@ import com.alibaba.fastjson.JSONObject; | ||
4 | import com.yohobuy.ufo.model.order.bo.SellerBo; | 4 | import com.yohobuy.ufo.model.order.bo.SellerBo; |
5 | import com.yohobuy.ufo.model.order.common.SellerFuncEnum; | 5 | import com.yohobuy.ufo.model.order.common.SellerFuncEnum; |
6 | import com.yohoufo.order.BaseWebTest; | 6 | import com.yohoufo.order.BaseWebTest; |
7 | -import com.yohoufo.order.service.impl.processor.SellerAuthCheckService; | 7 | +import com.yohoufo.order.service.seller.processor.SellerAuthCheckService; |
8 | import org.junit.Test; | 8 | import org.junit.Test; |
9 | import org.springframework.beans.factory.annotation.Autowired; | 9 | import org.springframework.beans.factory.annotation.Autowired; |
10 | 10 |
@@ -90,6 +90,7 @@ datasources: | @@ -90,6 +90,7 @@ datasources: | ||
90 | - com.yohoufo.dal.order.OrderOverTimeMapper | 90 | - com.yohoufo.dal.order.OrderOverTimeMapper |
91 | - com.yohoufo.dal.order.BuyerOrderViewMapper | 91 | - com.yohoufo.dal.order.BuyerOrderViewMapper |
92 | - com.yohoufo.dal.order.SellerJoinHistoryMapper | 92 | - com.yohoufo.dal.order.SellerJoinHistoryMapper |
93 | + - com.yohoufo.dal.order.SellerChangePriceRecordMapper | ||
93 | 94 | ||
94 | ufo_promotion: | 95 | ufo_promotion: |
95 | servers: | 96 | servers: |
@@ -89,6 +89,7 @@ datasources: | @@ -89,6 +89,7 @@ datasources: | ||
89 | - com.yohoufo.dal.order.OrderOverTimeMapper | 89 | - com.yohoufo.dal.order.OrderOverTimeMapper |
90 | - com.yohoufo.dal.order.BuyerOrderViewMapper | 90 | - com.yohoufo.dal.order.BuyerOrderViewMapper |
91 | - com.yohoufo.dal.order.SellerJoinHistoryMapper | 91 | - com.yohoufo.dal.order.SellerJoinHistoryMapper |
92 | + - com.yohoufo.dal.order.SellerChangePriceRecordMapper | ||
92 | 93 | ||
93 | ufo_promotion: | 94 | ufo_promotion: |
94 | servers: | 95 | servers: |
-
Please register or login to post a comment