Authored by chenchao

define api

... ... @@ -2,6 +2,7 @@ package com.yohoufo.order.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.yohobuy.ufo.model.order.bo.AppraiseOrderGoodsBo;
import com.yohobuy.ufo.model.order.common.AppraiseOrderStatus;
import com.yohobuy.ufo.model.order.vo.AddressInfo;
import com.yohoufo.dal.order.AppraiseOrderGoodsMapper;
import com.yohoufo.dal.order.AppraiseOrderMapper;
... ... @@ -55,7 +56,7 @@ public class AppraiseOrderCreateService {
pao.setOrderCode(orderCode);
pao.setAmount(ctx.getFee());
//TODO
pao.setStatus(0);
pao.setStatus(AppraiseOrderStatus.WAITING_PAY.getCode());
appraiseOrderMapper.insertSelective(pao);
//
AppraiseOrderGoodsBo aogb = ctx.getGoodsBo();
... ...
... ... @@ -3,6 +3,7 @@ package com.yohoufo.order.service.impl;
import com.yoho.error.ServiceError;
import com.yoho.error.exception.ServiceException;
import com.yohobuy.ufo.model.order.bo.AppraiseOrderGoodsBo;
import com.yohobuy.ufo.model.order.common.OrderAttributes;
import com.yohobuy.ufo.model.order.common.OrderCodeType;
import com.yohobuy.ufo.model.order.req.AppraiseOrderComputeReq;
import com.yohobuy.ufo.model.order.req.AppraiseOrderDetailReq;
... ... @@ -28,6 +29,10 @@ import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
@Service
public class AppraiseOrderService {
private final Logger logger = LoggerUtils.getBuyerOrderLogger();
... ... @@ -59,11 +64,40 @@ public class AppraiseOrderService {
if (productId <= 0){
throw new UfoServiceException(400, "商品ID错误");
}
int orderType = req.getOrderType();
OrderAttributes orderAttributes = checkOrderType(orderType);
double fee = 0D;
switch (orderAttributes){
case DEPOSITE:{
fee = 15D;
break;
}
case APPRAISE:{
fee = 31D;
break;
}
default:{
throw new UfoServiceException(400, "orderType错误");
}
}
double fee = 15D;
return AppraiseOrderComputeResp.builder().fee(String.valueOf(fee)).build();
}
private static final List<OrderAttributes> legalOrderTypes = new ArrayList<OrderAttributes>(2){
{
add(OrderAttributes.DEPOSITE);
add(OrderAttributes.APPRAISE);
}
};
private OrderAttributes checkOrderType(int orderType){
OrderAttributes oa = OrderAttributes.getOrderAttributes(orderType);
if (Objects.isNull(oa) || !legalOrderTypes.contains(oa)){
throw new UfoServiceException(400, "orderType错误");
}
return oa;
}
... ... @@ -106,6 +140,7 @@ public class AppraiseOrderService {
int productId;
AddressInfo hiddenBackAddress;
AddressInfo noHiddenBackAddress;
OrderAttributes orderAttributes;
}
private PreparedNode checkAndAcquire(AppraiseOrderSubmitReq req){
... ... @@ -117,6 +152,7 @@ public class AppraiseOrderService {
if (productId <= 0){
throw new UfoServiceException(400, "商品ID错误");
}
OrderAttributes orderAttributes = OrderAttributes.APPRAISE;
int addressId = AddressUtil.getDecryptStr(req.getAddressId());
if (addressId < 0){
... ... @@ -139,6 +175,7 @@ public class AppraiseOrderService {
.productId(productId)
.hiddenBackAddress(hiddenBackAddress)
.noHiddenBackAddress(noHiddenBackAddress)
.orderAttributes(orderAttributes)
.build();
}
... ...
... ... @@ -15,8 +15,8 @@ public class CodeTest {
// System.out.print(result);
// System.out.println(" 反解结果: "+ orderCodeGenerator.expId(result));
// }
CodeMeta meta = orderCodeGenerator.expId(9926176890695l);
Long ordercode = 19952220626966L;
CodeMeta meta = orderCodeGenerator.expId(ordercode);
System.out.println(meta);
// System.out.println(1<<3);
... ...