|
@@ -12,6 +12,7 @@ import com.yohoufo.common.alarm.EventBusPublisher; |
|
@@ -12,6 +12,7 @@ import com.yohoufo.common.alarm.EventBusPublisher; |
12
|
import com.yohoufo.common.alarm.SmsAlarmEvent;
|
12
|
import com.yohoufo.common.alarm.SmsAlarmEvent;
|
13
|
import com.yohoufo.common.exception.GatewayException;
|
13
|
import com.yohoufo.common.exception.GatewayException;
|
14
|
import com.yohoufo.common.utils.AddressUtil;
|
14
|
import com.yohoufo.common.utils.AddressUtil;
|
|
|
15
|
+import com.yohoufo.common.utils.BigDecimalHelper;
|
15
|
import com.yohoufo.common.utils.DateUtil;
|
16
|
import com.yohoufo.common.utils.DateUtil;
|
16
|
import com.yohoufo.dal.order.*;
|
17
|
import com.yohoufo.dal.order.*;
|
17
|
import com.yohoufo.dal.order.model.*;
|
18
|
import com.yohoufo.dal.order.model.*;
|
|
@@ -23,6 +24,8 @@ import com.yohoufo.order.event.OrderCancelEvent; |
|
@@ -23,6 +24,8 @@ import com.yohoufo.order.event.OrderCancelEvent; |
23
|
import com.yohoufo.order.model.AddressInfo;
|
24
|
import com.yohoufo.order.model.AddressInfo;
|
24
|
import com.yohobuy.ufo.model.order.bo.GoodsInfo;
|
25
|
import com.yohobuy.ufo.model.order.bo.GoodsInfo;
|
25
|
import com.yohoufo.order.model.SellerOrderContext;
|
26
|
import com.yohoufo.order.model.SellerOrderContext;
|
|
|
27
|
+import com.yohoufo.order.model.dto.EarnestMoney;
|
|
|
28
|
+import com.yohoufo.order.model.dto.PlatformFeeDto;
|
26
|
import com.yohoufo.order.model.dto.SellerOrderComputeResult;
|
29
|
import com.yohoufo.order.model.dto.SellerOrderComputeResult;
|
27
|
import com.yohoufo.order.model.request.OrderListRequest;
|
30
|
import com.yohoufo.order.model.request.OrderListRequest;
|
28
|
import com.yohoufo.order.model.request.OrderRequest;
|
31
|
import com.yohoufo.order.model.request.OrderRequest;
|
|
@@ -110,13 +113,22 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi |
|
@@ -110,13 +113,22 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi |
110
|
|
113
|
|
111
|
public SoldPrdComputeBo computePublishPrd(SellerOrderComputeReq req) throws GatewayException {
|
114
|
public SoldPrdComputeBo computePublishPrd(SellerOrderComputeReq req) throws GatewayException {
|
112
|
log.info("in computePublishPrd, req {}", req);
|
115
|
log.info("in computePublishPrd, req {}", req);
|
113
|
-
|
116
|
+ int uid = req.getUid();
|
|
|
117
|
+ if(uid <= 0){
|
|
|
118
|
+ log.warn("in computePublishPrd uid illegal , req {}", req);
|
|
|
119
|
+ throw new GatewayException(400, "用户ID错误");
|
|
|
120
|
+ }
|
114
|
//
|
121
|
//
|
115
|
Integer storageId = req.getStorageId();
|
122
|
Integer storageId = req.getStorageId();
|
116
|
if (storageId <=0 ){
|
123
|
if (storageId <=0 ){
|
117
|
log.warn("in computePublishPrd storageId illegal , req {}", req);
|
124
|
log.warn("in computePublishPrd storageId illegal , req {}", req);
|
118
|
throw new GatewayException(400, "storageId 错误");
|
125
|
throw new GatewayException(400, "storageId 错误");
|
119
|
}
|
126
|
}
|
|
|
127
|
+ int num;
|
|
|
128
|
+ if ((num = req.getNum())<=0){
|
|
|
129
|
+ log.warn("in computePublishPrd num illegal , req {}", req);
|
|
|
130
|
+ throw new GatewayException(400, "非法数量值");
|
|
|
131
|
+ }
|
120
|
|
132
|
|
121
|
/*商品鉴定费 ¥10.00
|
133
|
/*商品鉴定费 ¥10.00
|
122
|
商品包装费 ¥10.00
|
134
|
商品包装费 ¥10.00
|
|
@@ -133,19 +145,15 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi |
|
@@ -133,19 +145,15 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi |
133
|
throw new GatewayException(400, "价格须为以9结尾的正整数");
|
145
|
throw new GatewayException(400, "价格须为以9结尾的正整数");
|
134
|
}
|
146
|
}
|
135
|
|
147
|
|
136
|
-
|
|
|
137
|
BigDecimal prdPrice = null;
|
148
|
BigDecimal prdPrice = null;
|
138
|
try{
|
149
|
try{
|
139
|
prdPrice = new BigDecimal(price);
|
150
|
prdPrice = new BigDecimal(price);
|
140
|
}catch (Exception e){
|
151
|
}catch (Exception e){
|
141
|
log.warn("in computePublishPrd price convert BigDecimal fail, {}", req);
|
152
|
log.warn("in computePublishPrd price convert BigDecimal fail, {}", req);
|
142
|
- return null;
|
153
|
+ throw new GatewayException(400, "非法数字");
|
143
|
}
|
154
|
}
|
144
|
-
|
|
|
145
|
checkPrice(storageId, prdPrice, false);
|
155
|
checkPrice(storageId, prdPrice, false);
|
146
|
-
|
|
|
147
|
-
|
|
|
148
|
- return buildSoldPrdComputeBo(prdPrice);
|
156
|
+ return buildSoldPrdComputeBo(uid, num, prdPrice);
|
149
|
}
|
157
|
}
|
150
|
|
158
|
|
151
|
|
159
|
|
|
@@ -481,9 +489,28 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi |
|
@@ -481,9 +489,28 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi |
481
|
|
489
|
|
482
|
|
490
|
|
483
|
|
491
|
|
|
|
492
|
+ private boolean isEnough(int uid, BigDecimal mEarestMoney){
|
|
|
493
|
+
|
|
|
494
|
+ //todo 取出入驻商家的钱包余额,判断保证金总额是否足够扣减
|
|
|
495
|
+ return false;
|
|
|
496
|
+ }
|
484
|
|
497
|
|
485
|
- public SoldPrdComputeBo buildSoldPrdComputeBo(BigDecimal prdPrice){
|
498
|
+ private SoldPrdComputeBo buildSoldPrdComputeBo(int uid, int num, BigDecimal prdPrice){
|
486
|
SellerOrderComputeResult computeResult = computeHandler.compute(prdPrice);
|
499
|
SellerOrderComputeResult computeResult = computeHandler.compute(prdPrice);
|
|
|
500
|
+ /**
|
|
|
501
|
+ * 验证是否是入驻商家
|
|
|
502
|
+ */
|
|
|
503
|
+ boolean isEntryShop = userProxyService.isEntryShop(uid);
|
|
|
504
|
+ if(isEntryShop){
|
|
|
505
|
+ BigDecimal singleEarestMoney = computeResult.getEarnestMoney().getEarnestMoney();
|
|
|
506
|
+ BigDecimal mEarestMoney = BigDecimalHelper.halfUp(new BigDecimal(num).multiply(singleEarestMoney));
|
|
|
507
|
+
|
|
|
508
|
+ boolean isEnough = isEnough(uid, mEarestMoney);
|
|
|
509
|
+ if (!isEnough){
|
|
|
510
|
+
|
|
|
511
|
+ throw new ServiceException(ServiceError.WALLET_EARNESTMONEY_IS_NOT_ENOUGH);
|
|
|
512
|
+ }
|
|
|
513
|
+ }
|
487
|
SoldPrdComputeBo computeBo = SellerOrderConvertor.computeResult2SoldPrdComputeBo(computeResult);
|
514
|
SoldPrdComputeBo computeBo = SellerOrderConvertor.computeResult2SoldPrdComputeBo(computeResult);
|
488
|
return computeBo;
|
515
|
return computeBo;
|
489
|
}
|
516
|
}
|