1
|
package com.yohoufo.order.service.deposit;
|
1
|
package com.yohoufo.order.service.deposit;
|
2
|
|
2
|
|
3
|
import com.google.common.collect.Lists;
|
3
|
import com.google.common.collect.Lists;
|
|
|
4
|
+import com.yoho.error.ServiceError;
|
|
|
5
|
+import com.yoho.error.exception.ServiceException;
|
4
|
import com.yohobuy.ufo.model.order.bo.GoodsInfo;
|
6
|
import com.yohobuy.ufo.model.order.bo.GoodsInfo;
|
|
|
7
|
+import com.yohobuy.ufo.model.order.common.EntrySellerDepositType;
|
|
|
8
|
+import com.yohobuy.ufo.model.order.common.EntrySellerType;
|
|
|
9
|
+import com.yohobuy.ufo.model.order.common.OrderCodeType;
|
|
|
10
|
+import com.yohobuy.ufo.model.order.constants.DepositEventTypeEnum;
|
|
|
11
|
+import com.yohobuy.ufo.model.order.constants.OrderConstant;
|
5
|
import com.yohobuy.ufo.model.order.req.DepositOrderComputeReq;
|
12
|
import com.yohobuy.ufo.model.order.req.DepositOrderComputeReq;
|
6
|
import com.yohobuy.ufo.model.order.resp.DepositOrderComputeResp;
|
13
|
import com.yohobuy.ufo.model.order.resp.DepositOrderComputeResp;
|
7
|
import com.yohobuy.ufo.model.order.vo.AddressInfo;
|
14
|
import com.yohobuy.ufo.model.order.vo.AddressInfo;
|
|
|
15
|
+import com.yohoufo.common.exception.UfoServiceException;
|
8
|
import com.yohoufo.common.utils.DateUtil;
|
16
|
import com.yohoufo.common.utils.DateUtil;
|
9
|
import com.yohoufo.dal.order.BuyerOrderGoodsMapper;
|
17
|
import com.yohoufo.dal.order.BuyerOrderGoodsMapper;
|
10
|
import com.yohoufo.dal.order.DepositOrderMapper;
|
18
|
import com.yohoufo.dal.order.DepositOrderMapper;
|
11
|
import com.yohoufo.dal.order.SellerOrderGoodsMapper;
|
19
|
import com.yohoufo.dal.order.SellerOrderGoodsMapper;
|
12
|
import com.yohoufo.dal.order.SellerOrderMapper;
|
20
|
import com.yohoufo.dal.order.SellerOrderMapper;
|
13
|
-import com.yohoufo.dal.order.model.BuyerOrderGoods;
|
|
|
14
|
-import com.yohoufo.dal.order.model.DepositOrder;
|
|
|
15
|
-import com.yohoufo.dal.order.model.SellerOrderGoods;
|
|
|
16
|
-import com.yohoufo.dal.order.model.StorageDeposit;
|
21
|
+import com.yohoufo.dal.order.model.*;
|
17
|
import com.yohoufo.dal.product.StorageDepositMapper;
|
22
|
import com.yohoufo.dal.product.StorageDepositMapper;
|
18
|
import com.yohoufo.order.convert.GoodsInfoConvertor;
|
23
|
import com.yohoufo.order.convert.GoodsInfoConvertor;
|
|
|
24
|
+import com.yohoufo.order.model.response.OrderSubmitResponse;
|
19
|
import com.yohoufo.order.service.IBuyerOrderMetaService;
|
25
|
import com.yohoufo.order.service.IBuyerOrderMetaService;
|
|
|
26
|
+import com.yohoufo.order.service.support.codegenerator.OrderCodeGenerator;
|
20
|
import org.apache.commons.collections.CollectionUtils;
|
27
|
import org.apache.commons.collections.CollectionUtils;
|
|
|
28
|
+import org.slf4j.Logger;
|
|
|
29
|
+import org.slf4j.LoggerFactory;
|
21
|
import org.slf4j.helpers.MessageFormatter;
|
30
|
import org.slf4j.helpers.MessageFormatter;
|
22
|
import org.springframework.beans.factory.annotation.Autowired;
|
31
|
import org.springframework.beans.factory.annotation.Autowired;
|
23
|
import org.springframework.stereotype.Service;
|
32
|
import org.springframework.stereotype.Service;
|
24
|
|
33
|
|
|
|
34
|
+import java.math.BigDecimal;
|
25
|
import java.util.List;
|
35
|
import java.util.List;
|
26
|
|
36
|
|
27
|
/**
|
37
|
/**
|
|
@@ -29,6 +39,8 @@ import java.util.List; |
|
@@ -29,6 +39,8 @@ import java.util.List; |
29
|
*/
|
39
|
*/
|
30
|
@Service
|
40
|
@Service
|
31
|
public class DepositOrderService {
|
41
|
public class DepositOrderService {
|
|
|
42
|
+ private final Logger LOG = LoggerFactory.getLogger(this.getClass());
|
|
|
43
|
+
|
32
|
@Autowired
|
44
|
@Autowired
|
33
|
private DepositOrderMapper depositOrderMapper;
|
45
|
private DepositOrderMapper depositOrderMapper;
|
34
|
|
46
|
|
|
@@ -44,6 +56,9 @@ public class DepositOrderService { |
|
@@ -44,6 +56,9 @@ public class DepositOrderService { |
44
|
@Autowired
|
56
|
@Autowired
|
45
|
private IBuyerOrderMetaService buyerOrderMetaService;
|
57
|
private IBuyerOrderMetaService buyerOrderMetaService;
|
46
|
|
58
|
|
|
|
59
|
+ @Autowired
|
|
|
60
|
+ private OrderCodeGenerator orderCodeGenerator;
|
|
|
61
|
+
|
47
|
public int insert(DepositOrder record) {
|
62
|
public int insert(DepositOrder record) {
|
48
|
|
63
|
|
49
|
|
64
|
|
|
@@ -88,6 +103,29 @@ public class DepositOrderService { |
|
@@ -88,6 +103,29 @@ public class DepositOrderService { |
88
|
.userAddress(addressInfo).priceInfo(priceInfo).goodsInfo(goodsInfo).build();
|
103
|
.userAddress(addressInfo).priceInfo(priceInfo).goodsInfo(goodsInfo).build();
|
89
|
}
|
104
|
}
|
90
|
|
105
|
|
|
|
106
|
+
|
|
|
107
|
+ public OrderSubmitResponse publishDepositOrder(DepositOrderComputeReq req) {
|
|
|
108
|
+ Integer uid = req.getUid();
|
|
|
109
|
+ if (uid==null||uid <= 0){
|
|
|
110
|
+ throw new ServiceException(ServiceError.ORDER_REQUEST_PARM_IS_EMPTY);
|
|
|
111
|
+ }
|
|
|
112
|
+
|
|
|
113
|
+ //BigDecimal amount = getValidMoney(shoppingRequest.getAmount());
|
|
|
114
|
+
|
|
|
115
|
+ long orderCode = orderCodeGenerator.generate(OrderCodeType.STORAGE_MANAGEMENT);
|
|
|
116
|
+
|
|
|
117
|
+ // 生成订单数据,insert db
|
|
|
118
|
+ int now = (int) (System.currentTimeMillis()/1000);
|
|
|
119
|
+ DepositOrder depositOrder = DepositOrder.builder().uid(uid).amount(new BigDecimal(30)).createTime(now).depositCode(req.getDepositCode())
|
|
|
120
|
+ .eventType(DepositEventTypeEnum.DEPOSIT_RECALL_FEE.getCode()).orderCode(orderCode).payment(0).status(0).updateTime(now).build();
|
|
|
121
|
+
|
|
|
122
|
+ LOG.info("enter publishDepositOrder begin save depositOrder {} ",depositOrder);
|
|
|
123
|
+ int num = depositOrderMapper.insert(depositOrder);
|
|
|
124
|
+ LOG.info("enter publishDepositOrder end save depositOrder {} ,num {}",depositOrder, num);
|
|
|
125
|
+
|
|
|
126
|
+ return OrderSubmitResponse.builder().orderCode(orderCode).paymentStatus(OrderConstant.N_STR).build();
|
|
|
127
|
+ }
|
|
|
128
|
+
|
91
|
private String getReplacedContent(String content ,Object... params) {
|
129
|
private String getReplacedContent(String content ,Object... params) {
|
92
|
return MessageFormatter.arrayFormat(content, params).getMessage();
|
130
|
return MessageFormatter.arrayFormat(content, params).getMessage();
|
93
|
}
|
131
|
}
|