Authored by mali

寄存订单试算

... ... @@ -6,6 +6,7 @@ import com.yohobuy.ufo.model.order.req.SellerOrderComputeReq;
import com.yohobuy.ufo.model.order.resp.DepositOrderComputeResp;
import com.yohoufo.common.ApiResponse;
import com.yohoufo.common.exception.GatewayException;
import com.yohoufo.order.model.response.OrderSubmitResponse;
import com.yohoufo.order.service.deposit.DepositOrderService;
import com.yohoufo.order.utils.LoggerUtils;
import org.slf4j.Logger;
... ... @@ -45,4 +46,24 @@ public class DepositOrderController {
return new ApiResponse.ApiResponseBuilder().code(200).data(resp).message("算费成功").build();
}
/**
* 创建召回订单
* @param uid
* @param deposit_code 库存货号
* @param price
* @return
* @throws GatewayException
*/
@RequestMapping(params = "method=ufo.deposit.publishDepositOrder")
@ResponseBody
public ApiResponse publishDepositOrder(@RequestParam(name = "uid", required = true)int uid,
@RequestParam(name = "deposit_code", required = true)String depositCode) throws GatewayException {
DepositOrderComputeReq req = DepositOrderComputeReq.builder().uid(uid).depositCode(depositCode).build();
LOG.info("in ufo.deposit.publishDepositOrder, req {}", req);
OrderSubmitResponse resp = depositOrderService.publishDepositOrder(req);
return new ApiResponse.ApiResponseBuilder().code(200).data(resp).message("创建成功").build();
}
}
... ...
package com.yohoufo.order.service.deposit;
import com.google.common.collect.Lists;
import com.yoho.error.ServiceError;
import com.yoho.error.exception.ServiceException;
import com.yohobuy.ufo.model.order.bo.GoodsInfo;
import com.yohobuy.ufo.model.order.common.EntrySellerDepositType;
import com.yohobuy.ufo.model.order.common.EntrySellerType;
import com.yohobuy.ufo.model.order.common.OrderCodeType;
import com.yohobuy.ufo.model.order.constants.DepositEventTypeEnum;
import com.yohobuy.ufo.model.order.constants.OrderConstant;
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.DateUtil;
import com.yohoufo.dal.order.BuyerOrderGoodsMapper;
import com.yohoufo.dal.order.DepositOrderMapper;
import com.yohoufo.dal.order.SellerOrderGoodsMapper;
import com.yohoufo.dal.order.SellerOrderMapper;
import com.yohoufo.dal.order.model.BuyerOrderGoods;
import com.yohoufo.dal.order.model.DepositOrder;
import com.yohoufo.dal.order.model.SellerOrderGoods;
import com.yohoufo.dal.order.model.StorageDeposit;
import com.yohoufo.dal.order.model.*;
import com.yohoufo.dal.product.StorageDepositMapper;
import com.yohoufo.order.convert.GoodsInfoConvertor;
import com.yohoufo.order.model.response.OrderSubmitResponse;
import com.yohoufo.order.service.IBuyerOrderMetaService;
import com.yohoufo.order.service.support.codegenerator.OrderCodeGenerator;
import org.apache.commons.collections.CollectionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.helpers.MessageFormatter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.List;
/**
... ... @@ -29,6 +39,8 @@ import java.util.List;
*/
@Service
public class DepositOrderService {
private final Logger LOG = LoggerFactory.getLogger(this.getClass());
@Autowired
private DepositOrderMapper depositOrderMapper;
... ... @@ -44,6 +56,9 @@ public class DepositOrderService {
@Autowired
private IBuyerOrderMetaService buyerOrderMetaService;
@Autowired
private OrderCodeGenerator orderCodeGenerator;
public int insert(DepositOrder record) {
... ... @@ -88,6 +103,29 @@ public class DepositOrderService {
.userAddress(addressInfo).priceInfo(priceInfo).goodsInfo(goodsInfo).build();
}
public OrderSubmitResponse publishDepositOrder(DepositOrderComputeReq req) {
Integer uid = req.getUid();
if (uid==null||uid <= 0){
throw new ServiceException(ServiceError.ORDER_REQUEST_PARM_IS_EMPTY);
}
//BigDecimal amount = getValidMoney(shoppingRequest.getAmount());
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)).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);
LOG.info("enter publishDepositOrder end save depositOrder {} ,num {}",depositOrder, num);
return OrderSubmitResponse.builder().orderCode(orderCode).paymentStatus(OrderConstant.N_STR).build();
}
private String getReplacedContent(String content ,Object... params) {
return MessageFormatter.arrayFormat(content, params).getMessage();
}
... ...