...
|
...
|
@@ -13,15 +13,20 @@ import com.yohobuy.ufo.model.order.req.DepositOrderComputeReq; |
|
|
import com.yohobuy.ufo.model.order.resp.DepositOrderComputeResp;
|
|
|
import com.yohobuy.ufo.model.order.vo.AddressInfo;
|
|
|
import com.yohoufo.common.exception.UfoServiceException;
|
|
|
import com.yohoufo.common.utils.AddressUtil;
|
|
|
import com.yohoufo.common.utils.StringUtil;
|
|
|
import com.yohoufo.dal.order.*;
|
|
|
import com.yohoufo.dal.order.model.*;
|
|
|
import com.yohoufo.order.convert.GoodsInfoConvertor;
|
|
|
import com.yohoufo.order.model.response.AppraiseAddressResp;
|
|
|
import com.yohoufo.order.model.response.OrderSubmitResponse;
|
|
|
import com.yohoufo.order.service.DepositService;
|
|
|
import com.yohoufo.order.service.IBuyerOrderMetaService;
|
|
|
import com.yohoufo.order.service.IBuyerOrderService;
|
|
|
import com.yohoufo.order.service.IExpressInfoService;
|
|
|
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.springframework.beans.factory.annotation.Autowired;
|
...
|
...
|
@@ -30,6 +35,7 @@ import org.springframework.stereotype.Service; |
|
|
import java.math.BigDecimal;
|
|
|
import java.util.List;
|
|
|
import java.util.Objects;
|
|
|
import java.util.Optional;
|
|
|
|
|
|
/**
|
|
|
* Created by li.ma on 2019/7/9.
|
...
|
...
|
@@ -59,6 +65,12 @@ public class DepositOrderService { |
|
|
@Autowired
|
|
|
private DepositService depositService;
|
|
|
|
|
|
@Autowired
|
|
|
private IExpressInfoService expressInfoService;
|
|
|
|
|
|
@Autowired
|
|
|
private IBuyerOrderService buyerOrderService;
|
|
|
|
|
|
/**
|
|
|
* 根据库存货号,计算需要召回的费用
|
|
|
* @param req
|
...
|
...
|
@@ -75,12 +87,14 @@ public class DepositOrderService { |
|
|
|
|
|
GoodsInfo goodsInfo = getGoodsInfo(skup); // 查询购买商品的详细信息
|
|
|
|
|
|
AddressInfo addressInfo = buyerOrderMetaService.getHiddenAddressInfo(req.getUid(), orderCode);
|
|
|
|
|
|
DepositOrderComputeResp.PriceInfo priceInfo = getFeeInfo(orderCode, req.getAddress_id()); // 获取各种费用
|
|
|
addressInfo.setAddress_id(AddressUtil.getDecryptStr(String.valueOf(addressInfo.getAddress_id())));// 加密addressId
|
|
|
|
|
|
setBuyerPrice(orderCode, priceInfo); // 设置入手价
|
|
|
DepositOrderComputeResp.PriceInfo priceInfo = getFeeInfo(orderCode, StringUtils.isEmpty(req.getAddress_id()) ?
|
|
|
String.valueOf(addressInfo.getAddress_id()) : req.getAddress_id(), req.getUid()); // 获取各种费用
|
|
|
|
|
|
AddressInfo addressInfo = buyerOrderMetaService.getHiddenAddressInfo(req.getUid(), orderCode);
|
|
|
setBuyerPrice(orderCode, priceInfo); // 设置入手价
|
|
|
|
|
|
return DepositOrderComputeResp.builder().depositRemainDay(getReplacedContent(DepositOrderComputeResp.DEPOSITREMAINDAY_TIP, depositRemainDay))
|
|
|
.userAddress(addressInfo).priceInfo(priceInfo).goodsInfo(goodsInfo).build();
|
...
|
...
|
@@ -100,7 +114,7 @@ public class DepositOrderService { |
|
|
long orderCode = orderCodeGenerator.generate(OrderCodeType.STORAGE_MANAGEMENT);
|
|
|
|
|
|
int now = (int) (System.currentTimeMillis()/1000);
|
|
|
DepositOrderComputeResp.PriceInfo priceInfo = getFeeInfo(orderCode, req.getAddress_id());
|
|
|
DepositOrderComputeResp.PriceInfo priceInfo = getFeeInfo(orderCode, req.getAddress_id(), req.getUid());
|
|
|
|
|
|
DepositOrder depositOrder = DepositOrder.builder().uid(uid).amount(priceInfo.getAmount())
|
|
|
.contractFee(priceInfo.getContractFee())
|
...
|
...
|
@@ -109,7 +123,9 @@ public class DepositOrderService { |
|
|
.eventType(DepositEventTypeEnum.DEPOSIT_RECALL_FEE.getCode()).orderCode(orderCode).payment(0).status(0).updateTime(now).build();
|
|
|
|
|
|
// TODO 创建召回地址
|
|
|
storageDeposit.getOrderCode();
|
|
|
LOG.info("enter publishRecallAddress begin save getOrderCode {} addressId is {} ", storageDeposit.getOrderCode(), req.getAddress_id());
|
|
|
buyerOrderService.modifyAddressOfDepositOrder(req.getUid(), storageDeposit.getOrderCode(), req.getAddress_id());
|
|
|
LOG.info("enter publishRecallAddress end save getOrderCode {} ", storageDeposit.getOrderCode());
|
|
|
|
|
|
LOG.info("enter publishDepositOrder begin save depositOrder {} ",depositOrder);
|
|
|
int num = depositOrderMapper.insert(depositOrder); // 生成订单数据,insert db
|
...
|
...
|
@@ -143,8 +159,8 @@ public class DepositOrderService { |
|
|
*/
|
|
|
public DepositOrderComputeResp depositOrderInfo(DepositOrderComputeReq req) {
|
|
|
StorageDeposit storageDeposit = checkStorageDeposit(req,
|
|
|
Lists.newArrayList(StorageDepositStatusEnum.WAITING_QUERY.getCode(), StorageDepositStatusEnum.WAITING_OUT.getCode()
|
|
|
, StorageDepositStatusEnum.HAS_OUT.getCode(), StorageDepositStatusEnum.HAS_END.getCode())); // 不存在的时候有异常
|
|
|
Lists.newArrayList(StorageDepositStatusEnum.WAITING_QUERY.getCode(), StorageDepositStatusEnum.WAITING_OUT.getCode(), StorageDepositStatusEnum.WAITING_IN.getCode()
|
|
|
, StorageDepositStatusEnum.HAS_OUT.getCode(), StorageDepositStatusEnum.HAS_END.getCode(), StorageDepositStatusEnum.HAS_IN.getCode())); // 不存在的时候有异常
|
|
|
|
|
|
DepositDetailBo depositDetailBo = depositService.convert(storageDeposit);
|
|
|
|
...
|
...
|
@@ -156,6 +172,8 @@ public class DepositOrderService { |
|
|
|
|
|
setBuyerPrice(storageDeposit.getOrderCode(), priceInfo); // 设置入手价
|
|
|
|
|
|
queryWaybillCode(depositDetailBo);// 查询召回(到期)后寄回的运单号
|
|
|
|
|
|
return DepositOrderComputeResp.builder().userAddress(addressInfo).priceInfo(priceInfo).goodsInfo(goodsInfo).depositDetailBo(depositDetailBo).build();
|
|
|
}
|
|
|
|
...
|
...
|
@@ -195,9 +213,12 @@ public class DepositOrderService { |
|
|
}
|
|
|
|
|
|
// 查询召回所需要的费用
|
|
|
private DepositOrderComputeResp.PriceInfo getFeeInfo(Long orderCode, String addressId) {
|
|
|
private DepositOrderComputeResp.PriceInfo getFeeInfo(Long orderCode, String addressId, int uid) {
|
|
|
|
|
|
AppraiseAddressResp resp = expressInfoService.queryByUserAddress(uid, addressId);
|
|
|
|
|
|
BigDecimal contractFee = new BigDecimal(15); // 违约金
|
|
|
BigDecimal shipFee = new BigDecimal(15); // 运费
|
|
|
BigDecimal shipFee = Optional.ofNullable(resp).map(AppraiseAddressResp::getShipFee).orElse(new BigDecimal(15)); // 运费
|
|
|
BigDecimal amount = contractFee.add(shipFee);
|
|
|
|
|
|
return DepositOrderComputeResp.PriceInfo.builder().contractFee(contractFee).shipFee(shipFee).amount(amount).build();
|
...
|
...
|
@@ -216,4 +237,8 @@ public class DepositOrderService { |
|
|
}
|
|
|
return storageDeposit;
|
|
|
}
|
|
|
|
|
|
private void queryWaybillCode(DepositDetailBo depositDetailBo) {
|
|
|
|
|
|
}
|
|
|
} |
...
|
...
|
|