...
|
...
|
@@ -31,6 +31,7 @@ import com.yohoufo.order.service.DepositService; |
|
|
import com.yohoufo.order.service.IBuyerOrderMetaService;
|
|
|
import com.yohoufo.order.service.support.codegenerator.OrderCodeGenerator;
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.slf4j.helpers.MessageFormatter;
|
...
|
...
|
@@ -74,8 +75,7 @@ public class DepositOrderService { |
|
|
* @return
|
|
|
*/
|
|
|
public DepositOrderComputeResp computePublishPrd(DepositOrderComputeReq req) {
|
|
|
StorageDeposit storageDeposit = storageDepositMapper.selectByDepositCode(req.getUid(), req.getDepositCode());
|
|
|
// TODO 不存在的时候有异常
|
|
|
StorageDeposit storageDeposit = checkStorageDeposit(req); // 不存在的时候有异常
|
|
|
|
|
|
int depositRemainDay = depositService.getRemainDay(req.getUid(), req.getDepositCode()); // 还可存放多久 单位天
|
|
|
|
...
|
...
|
@@ -88,9 +88,9 @@ public class DepositOrderService { |
|
|
goodsInfo = GoodsInfoConvertor.SellerOrderGoods2GoodsInfo(sellerOrderGoods);
|
|
|
}
|
|
|
List<BuyerOrderGoods> buyerOrderGoodses = buyerOrderGoodsMapper.selectBySkups(Lists.newArrayList(skup));
|
|
|
DepositOrderComputeResp.PriceInfo priceInfo = null;
|
|
|
DepositOrderComputeResp.PriceInfo priceInfo = getFeeInfo(orderCode);
|
|
|
if (CollectionUtils.isNotEmpty(buyerOrderGoodses)) {
|
|
|
priceInfo = DepositOrderComputeResp.PriceInfo.builder().goodPrice(buyerOrderGoodses.get(0).getGoodsAmount().toPlainString()).build();
|
|
|
priceInfo.setGoodPrice(buyerOrderGoodses.get(0).getGoodsAmount());
|
|
|
}
|
|
|
|
|
|
AddressInfo addressInfo = buyerOrderMetaService.getAddressInfo(req.getUid(), orderCode);
|
...
|
...
|
@@ -102,27 +102,46 @@ public class DepositOrderService { |
|
|
|
|
|
public OrderSubmitResponse publishDepositOrder(DepositOrderComputeReq req) {
|
|
|
Integer uid = req.getUid();
|
|
|
if (uid==null||uid <= 0){
|
|
|
if (uid == null || uid <= 0){
|
|
|
throw new ServiceException(ServiceError.ORDER_REQUEST_PARM_IS_EMPTY);
|
|
|
}
|
|
|
|
|
|
//BigDecimal amount = getValidMoney(shoppingRequest.getAmount());
|
|
|
checkStorageDeposit(req);
|
|
|
|
|
|
long orderCode = orderCodeGenerator.generate(OrderCodeType.STORAGE_MANAGEMENT);
|
|
|
|
|
|
// 生成订单数据,insert db
|
|
|
int now = (int) (System.currentTimeMillis()/1000);
|
|
|
DepositOrder depositOrder = DepositOrder.builder().uid(uid).amount(new BigDecimal(30))
|
|
|
.contractFee(new BigDecimal(15)).shipFee(new BigDecimal(15)).createTime(now).depositCode(req.getDepositCode())
|
|
|
DepositOrderComputeResp.PriceInfo priceInfo = getFeeInfo(orderCode);
|
|
|
|
|
|
DepositOrder depositOrder = DepositOrder.builder().uid(uid).amount(priceInfo.getAmount())
|
|
|
.contractFee(priceInfo.getContractFee()).shipFee(priceInfo.getShipFee()).createTime(now).depositCode(req.getDepositCode())
|
|
|
.eventType(DepositEventTypeEnum.DEPOSIT_RECALL_FEE.getCode()).orderCode(orderCode).payment(0).status(0).updateTime(now).build();
|
|
|
|
|
|
LOG.info("enter publishDepositOrder begin save depositOrder {} ",depositOrder);
|
|
|
int num = depositOrderMapper.insert(depositOrder);
|
|
|
int num = depositOrderMapper.insert(depositOrder); // 生成订单数据,insert db
|
|
|
LOG.info("enter publishDepositOrder end save depositOrder {} ,num {}",depositOrder, num);
|
|
|
|
|
|
return OrderSubmitResponse.builder().orderCode(orderCode).paymentStatus(OrderConstant.N_STR).build();
|
|
|
}
|
|
|
|
|
|
private StorageDeposit checkStorageDeposit(DepositOrderComputeReq req) {
|
|
|
StorageDeposit storageDeposit = storageDepositMapper.selectByDepositCode(req.getUid(), req.getDepositCode());
|
|
|
if (null == storageDeposit || null == storageDeposit.getSkup() || null == storageDeposit.getOrderCode()) {
|
|
|
LOG.warn("storageDepositMapper.selectByDepositCode not exist, req is {}", req);
|
|
|
throw new UfoServiceException(400, "库存不存在");
|
|
|
}
|
|
|
|
|
|
return storageDeposit;
|
|
|
}
|
|
|
|
|
|
// 查询召回所需要的费用
|
|
|
private DepositOrderComputeResp.PriceInfo getFeeInfo(Long orderCode) {
|
|
|
BigDecimal contractFee = new BigDecimal(15); // 违约金
|
|
|
BigDecimal shipFee = new BigDecimal(15); // 运费
|
|
|
BigDecimal amount = contractFee.add(shipFee);
|
|
|
|
|
|
return DepositOrderComputeResp.PriceInfo.builder().contractFee(contractFee).shipFee(shipFee).amount(amount).build();
|
|
|
}
|
|
|
|
|
|
private String getReplacedContent(String content ,Object... params) {
|
|
|
return StringUtil.getReplacedContent(content, params);
|
|
|
}
|
...
|
...
|
|