Authored by chenchao

define api

@@ -2,6 +2,7 @@ package com.yohoufo.order.service.impl; @@ -2,6 +2,7 @@ package com.yohoufo.order.service.impl;
2 2
3 import com.alibaba.fastjson.JSONObject; 3 import com.alibaba.fastjson.JSONObject;
4 import com.yohobuy.ufo.model.order.bo.AppraiseOrderGoodsBo; 4 import com.yohobuy.ufo.model.order.bo.AppraiseOrderGoodsBo;
  5 +import com.yohobuy.ufo.model.order.common.AppraiseOrderStatus;
5 import com.yohobuy.ufo.model.order.vo.AddressInfo; 6 import com.yohobuy.ufo.model.order.vo.AddressInfo;
6 import com.yohoufo.dal.order.AppraiseOrderGoodsMapper; 7 import com.yohoufo.dal.order.AppraiseOrderGoodsMapper;
7 import com.yohoufo.dal.order.AppraiseOrderMapper; 8 import com.yohoufo.dal.order.AppraiseOrderMapper;
@@ -55,7 +56,7 @@ public class AppraiseOrderCreateService { @@ -55,7 +56,7 @@ public class AppraiseOrderCreateService {
55 pao.setOrderCode(orderCode); 56 pao.setOrderCode(orderCode);
56 pao.setAmount(ctx.getFee()); 57 pao.setAmount(ctx.getFee());
57 //TODO 58 //TODO
58 - pao.setStatus(0); 59 + pao.setStatus(AppraiseOrderStatus.WAITING_PAY.getCode());
59 appraiseOrderMapper.insertSelective(pao); 60 appraiseOrderMapper.insertSelective(pao);
60 // 61 //
61 AppraiseOrderGoodsBo aogb = ctx.getGoodsBo(); 62 AppraiseOrderGoodsBo aogb = ctx.getGoodsBo();
@@ -3,6 +3,7 @@ package com.yohoufo.order.service.impl; @@ -3,6 +3,7 @@ package com.yohoufo.order.service.impl;
3 import com.yoho.error.ServiceError; 3 import com.yoho.error.ServiceError;
4 import com.yoho.error.exception.ServiceException; 4 import com.yoho.error.exception.ServiceException;
5 import com.yohobuy.ufo.model.order.bo.AppraiseOrderGoodsBo; 5 import com.yohobuy.ufo.model.order.bo.AppraiseOrderGoodsBo;
  6 +import com.yohobuy.ufo.model.order.common.OrderAttributes;
6 import com.yohobuy.ufo.model.order.common.OrderCodeType; 7 import com.yohobuy.ufo.model.order.common.OrderCodeType;
7 import com.yohobuy.ufo.model.order.req.AppraiseOrderComputeReq; 8 import com.yohobuy.ufo.model.order.req.AppraiseOrderComputeReq;
8 import com.yohobuy.ufo.model.order.req.AppraiseOrderDetailReq; 9 import com.yohobuy.ufo.model.order.req.AppraiseOrderDetailReq;
@@ -28,6 +29,10 @@ import org.slf4j.Logger; @@ -28,6 +29,10 @@ import org.slf4j.Logger;
28 import org.springframework.beans.factory.annotation.Autowired; 29 import org.springframework.beans.factory.annotation.Autowired;
29 import org.springframework.stereotype.Service; 30 import org.springframework.stereotype.Service;
30 31
  32 +import java.util.ArrayList;
  33 +import java.util.List;
  34 +import java.util.Objects;
  35 +
31 @Service 36 @Service
32 public class AppraiseOrderService { 37 public class AppraiseOrderService {
33 private final Logger logger = LoggerUtils.getBuyerOrderLogger(); 38 private final Logger logger = LoggerUtils.getBuyerOrderLogger();
@@ -59,11 +64,40 @@ public class AppraiseOrderService { @@ -59,11 +64,40 @@ public class AppraiseOrderService {
59 if (productId <= 0){ 64 if (productId <= 0){
60 throw new UfoServiceException(400, "商品ID错误"); 65 throw new UfoServiceException(400, "商品ID错误");
61 } 66 }
  67 + int orderType = req.getOrderType();
  68 + OrderAttributes orderAttributes = checkOrderType(orderType);
  69 + double fee = 0D;
  70 + switch (orderAttributes){
  71 + case DEPOSITE:{
  72 + fee = 15D;
  73 + break;
  74 + }
  75 +
  76 + case APPRAISE:{
  77 + fee = 31D;
  78 + break;
  79 + }
  80 + default:{
  81 + throw new UfoServiceException(400, "orderType错误");
  82 + }
  83 + }
62 84
63 - double fee = 15D;  
64 return AppraiseOrderComputeResp.builder().fee(String.valueOf(fee)).build(); 85 return AppraiseOrderComputeResp.builder().fee(String.valueOf(fee)).build();
65 } 86 }
66 87
  88 + private static final List<OrderAttributes> legalOrderTypes = new ArrayList<OrderAttributes>(2){
  89 + {
  90 + add(OrderAttributes.DEPOSITE);
  91 + add(OrderAttributes.APPRAISE);
  92 + }
  93 + };
  94 + private OrderAttributes checkOrderType(int orderType){
  95 + OrderAttributes oa = OrderAttributes.getOrderAttributes(orderType);
  96 + if (Objects.isNull(oa) || !legalOrderTypes.contains(oa)){
  97 + throw new UfoServiceException(400, "orderType错误");
  98 + }
  99 + return oa;
  100 + }
67 101
68 102
69 103
@@ -106,6 +140,7 @@ public class AppraiseOrderService { @@ -106,6 +140,7 @@ public class AppraiseOrderService {
106 int productId; 140 int productId;
107 AddressInfo hiddenBackAddress; 141 AddressInfo hiddenBackAddress;
108 AddressInfo noHiddenBackAddress; 142 AddressInfo noHiddenBackAddress;
  143 + OrderAttributes orderAttributes;
109 } 144 }
110 145
111 private PreparedNode checkAndAcquire(AppraiseOrderSubmitReq req){ 146 private PreparedNode checkAndAcquire(AppraiseOrderSubmitReq req){
@@ -117,6 +152,7 @@ public class AppraiseOrderService { @@ -117,6 +152,7 @@ public class AppraiseOrderService {
117 if (productId <= 0){ 152 if (productId <= 0){
118 throw new UfoServiceException(400, "商品ID错误"); 153 throw new UfoServiceException(400, "商品ID错误");
119 } 154 }
  155 + OrderAttributes orderAttributes = OrderAttributes.APPRAISE;
120 156
121 int addressId = AddressUtil.getDecryptStr(req.getAddressId()); 157 int addressId = AddressUtil.getDecryptStr(req.getAddressId());
122 if (addressId < 0){ 158 if (addressId < 0){
@@ -139,6 +175,7 @@ public class AppraiseOrderService { @@ -139,6 +175,7 @@ public class AppraiseOrderService {
139 .productId(productId) 175 .productId(productId)
140 .hiddenBackAddress(hiddenBackAddress) 176 .hiddenBackAddress(hiddenBackAddress)
141 .noHiddenBackAddress(noHiddenBackAddress) 177 .noHiddenBackAddress(noHiddenBackAddress)
  178 + .orderAttributes(orderAttributes)
142 .build(); 179 .build();
143 } 180 }
144 181
@@ -15,8 +15,8 @@ public class CodeTest { @@ -15,8 +15,8 @@ public class CodeTest {
15 // System.out.print(result); 15 // System.out.print(result);
16 // System.out.println(" 反解结果: "+ orderCodeGenerator.expId(result)); 16 // System.out.println(" 反解结果: "+ orderCodeGenerator.expId(result));
17 // } 17 // }
18 -  
19 - CodeMeta meta = orderCodeGenerator.expId(9926176890695l); 18 + Long ordercode = 19952220626966L;
  19 + CodeMeta meta = orderCodeGenerator.expId(ordercode);
20 System.out.println(meta); 20 System.out.println(meta);
21 21
22 // System.out.println(1<<3); 22 // System.out.println(1<<3);