Merge branch 'master' of http://git.yoho.cn/ufo/yohoufo-fore
Showing
23 changed files
with
535 additions
and
151 deletions
@@ -14,19 +14,19 @@ public class AddressUtil { | @@ -14,19 +14,19 @@ public class AddressUtil { | ||
14 | * @param str | 14 | * @param str |
15 | * @return | 15 | * @return |
16 | */ | 16 | */ |
17 | - public static String getDecryptStr(String str){ | 17 | + public static int getDecryptStr(String str){ |
18 | 18 | ||
19 | String decryptStr = str; | 19 | String decryptStr = str; |
20 | try{ | 20 | try{ |
21 | str = str.replace(' ','+'); | 21 | str = str.replace(' ','+'); |
22 | decryptStr = AES.decrypt(DynamicPropertyFactory.getInstance().getStringProperty("password.aes.key", "yoho9646yoho9646").get(), str); | 22 | decryptStr = AES.decrypt(DynamicPropertyFactory.getInstance().getStringProperty("password.aes.key", "yoho9646yoho9646").get(), str); |
23 | + return Integer.parseInt(decryptStr); | ||
23 | }catch (Exception e){ | 24 | }catch (Exception e){ |
24 | logger.error("getDecryptStr failed. str is {}, e is {}", str, e); | 25 | logger.error("getDecryptStr failed. str is {}, e is {}", str, e); |
25 | } | 26 | } |
26 | - | ||
27 | logger.info("getDecryptStr, str is {}, decryptStr is {}", str, decryptStr); | 27 | logger.info("getDecryptStr, str is {}, decryptStr is {}", str, decryptStr); |
28 | 28 | ||
29 | - return decryptStr; | 29 | + return -1; |
30 | 30 | ||
31 | } | 31 | } |
32 | } | 32 | } |
@@ -11,7 +11,7 @@ import java.util.Objects; | @@ -11,7 +11,7 @@ import java.util.Objects; | ||
11 | * Created by chunhua.zhang@yoho.cn on 2015/12/15. | 11 | * Created by chunhua.zhang@yoho.cn on 2015/12/15. |
12 | */ | 12 | */ |
13 | public class BigDecimalHelper { | 13 | public class BigDecimalHelper { |
14 | - public static final String FORMAT_TWOBITAFTERPOINT = "###.00"; | 14 | + public static final String FORMAT_TWOBITAFTERPOINT = "##0.00"; |
15 | 15 | ||
16 | private static Map<String,DecimalFormat> DecimalFormatCache = new HashMap<>(); | 16 | private static Map<String,DecimalFormat> DecimalFormatCache = new HashMap<>(); |
17 | 17 |
@@ -13,7 +13,7 @@ public interface BuyerOrderMapper { | @@ -13,7 +13,7 @@ public interface BuyerOrderMapper { | ||
13 | 13 | ||
14 | BuyerOrder selectByPrimaryKey(Integer id); | 14 | BuyerOrder selectByPrimaryKey(Integer id); |
15 | 15 | ||
16 | - BuyerOrder selectByOrderCode(@Param("orderCode") Long orderCode); | 16 | + BuyerOrder selectByOrderCode(@Param("orderCode") Long orderCode, @Param("uid") int uid); |
17 | 17 | ||
18 | int updateByPrimaryKeySelective(BuyerOrder record); | 18 | int updateByPrimaryKeySelective(BuyerOrder record); |
19 | 19 |
@@ -12,7 +12,7 @@ public interface SellerOrderMapper { | @@ -12,7 +12,7 @@ public interface SellerOrderMapper { | ||
12 | 12 | ||
13 | SellerOrder selectByPrimaryKey(Integer id); | 13 | SellerOrder selectByPrimaryKey(Integer id); |
14 | 14 | ||
15 | - SellerOrder selectByOrderCode(@Param("orderCode") long orderCode); | 15 | + SellerOrder selectByOrderCode(@Param("orderCode") long orderCode, @Param("uid") int uid); |
16 | 16 | ||
17 | SellerOrder selectBySkup(@Param("skup") Integer skup); | 17 | SellerOrder selectBySkup(@Param("skup") Integer skup); |
18 | 18 |
@@ -32,11 +32,12 @@ | @@ -32,11 +32,12 @@ | ||
32 | </select> | 32 | </select> |
33 | 33 | ||
34 | 34 | ||
35 | - <select id="selectByOrderCode" parameterType="java.lang.Long" resultMap="BaseResultMap"> | 35 | + <select id="selectByOrderCode" resultMap="BaseResultMap"> |
36 | select | 36 | select |
37 | <include refid="Base_Column_List" /> | 37 | <include refid="Base_Column_List" /> |
38 | from buyer_order | 38 | from buyer_order |
39 | where order_code = #{orderCode,jdbcType=BIGINT} | 39 | where order_code = #{orderCode,jdbcType=BIGINT} |
40 | + and uid = #{uid,jdbcType=INTEGER} | ||
40 | limit 1 | 41 | limit 1 |
41 | </select> | 42 | </select> |
42 | 43 |
@@ -27,11 +27,12 @@ | @@ -27,11 +27,12 @@ | ||
27 | </select> | 27 | </select> |
28 | 28 | ||
29 | 29 | ||
30 | - <select id="selectByOrderCode" parameterType="java.lang.Long" resultMap="BaseResultMap"> | 30 | + <select id="selectByOrderCode" resultMap="BaseResultMap"> |
31 | select | 31 | select |
32 | <include refid="Base_Column_List" /> | 32 | <include refid="Base_Column_List" /> |
33 | from seller_order | 33 | from seller_order |
34 | where order_code = #{orderCode,jdbcType=BIGINT} | 34 | where order_code = #{orderCode,jdbcType=BIGINT} |
35 | + and uid = #{uid,jdbcType=INTEGER} | ||
35 | limit 1 | 36 | limit 1 |
36 | </select> | 37 | </select> |
37 | 38 |
@@ -8,5 +8,11 @@ public interface MetaKey { | @@ -8,5 +8,11 @@ public interface MetaKey { | ||
8 | 8 | ||
9 | String BACK_2_SELLER_DELIVERY_ADDRESS = "back_delivery_address"; | 9 | String BACK_2_SELLER_DELIVERY_ADDRESS = "back_delivery_address"; |
10 | 10 | ||
11 | + /** | ||
12 | + * 买家收货地址 | ||
13 | + */ | ||
14 | + String BUYER_DELIVERY_ADDRESS = "delivery_address"; | ||
15 | + | ||
16 | + | ||
11 | String SELLER_FEE = "fee"; | 17 | String SELLER_FEE = "fee"; |
12 | } | 18 | } |
@@ -5,17 +5,17 @@ import com.yohoufo.common.ApiResponse; | @@ -5,17 +5,17 @@ import com.yohoufo.common.ApiResponse; | ||
5 | import com.yohoufo.order.request.ShoppingRequest; | 5 | import com.yohoufo.order.request.ShoppingRequest; |
6 | import com.yohoufo.order.response.OrderSubmitResponse; | 6 | import com.yohoufo.order.response.OrderSubmitResponse; |
7 | import com.yohoufo.order.response.ShoppingPaymentResponse; | 7 | import com.yohoufo.order.response.ShoppingPaymentResponse; |
8 | -import com.yohoufo.order.service.IShoppingService; | 8 | +import com.yohoufo.order.service.IBuyerOrderService; |
9 | import org.springframework.beans.factory.annotation.Autowired; | 9 | import org.springframework.beans.factory.annotation.Autowired; |
10 | import org.springframework.web.bind.annotation.*; | 10 | import org.springframework.web.bind.annotation.*; |
11 | 11 | ||
12 | @RestController | 12 | @RestController |
13 | @RequestMapping(value = "/shopping") | 13 | @RequestMapping(value = "/shopping") |
14 | -public class ShoppingController { | 14 | +public class BuyerOrderController { |
15 | 15 | ||
16 | 16 | ||
17 | @Autowired | 17 | @Autowired |
18 | - IShoppingService shoppingService; | 18 | + IBuyerOrderService buyerOrderService; |
19 | 19 | ||
20 | 20 | ||
21 | /** | 21 | /** |
@@ -26,7 +26,7 @@ public class ShoppingController { | @@ -26,7 +26,7 @@ public class ShoppingController { | ||
26 | public ApiResponse payment(@RequestParam(name = "uid") int uid, | 26 | public ApiResponse payment(@RequestParam(name = "uid") int uid, |
27 | @RequestParam(name = "skup") int skup){ | 27 | @RequestParam(name = "skup") int skup){ |
28 | 28 | ||
29 | - ShoppingPaymentResponse paymentResponse = shoppingService.payment(ShoppingRequest.builder().uid(uid).skup(skup).build()); | 29 | + ShoppingPaymentResponse paymentResponse = buyerOrderService.payment(ShoppingRequest.builder().uid(uid).skup(skup).build()); |
30 | return new ApiResponse.ApiResponseBuilder().code(200).data(paymentResponse).message("结算成功").build(); | 30 | return new ApiResponse.ApiResponseBuilder().code(200).data(paymentResponse).message("结算成功").build(); |
31 | } | 31 | } |
32 | 32 | ||
@@ -43,7 +43,7 @@ public class ShoppingController { | @@ -43,7 +43,7 @@ public class ShoppingController { | ||
43 | @RequestParam(name = "clientType") String clientType){ | 43 | @RequestParam(name = "clientType") String clientType){ |
44 | 44 | ||
45 | ShoppingRequest request = ShoppingRequest.builder().uid(uid).skup(skup).channelNo(channelNo).clientType(clientType).addressId(addressId).build(); | 45 | ShoppingRequest request = ShoppingRequest.builder().uid(uid).skup(skup).channelNo(channelNo).clientType(clientType).addressId(addressId).build(); |
46 | - OrderSubmitResponse paymentResponse = shoppingService.submit(request); | 46 | + OrderSubmitResponse paymentResponse = buyerOrderService.submit(request); |
47 | return new ApiResponse.ApiResponseBuilder().code(200).data(paymentResponse).message("提交订单SUCCESS").build(); | 47 | return new ApiResponse.ApiResponseBuilder().code(200).data(paymentResponse).message("提交订单SUCCESS").build(); |
48 | } | 48 | } |
49 | 49 |
@@ -12,6 +12,7 @@ import org.springframework.beans.factory.annotation.Autowired; | @@ -12,6 +12,7 @@ import org.springframework.beans.factory.annotation.Autowired; | ||
12 | import org.springframework.stereotype.Controller; | 12 | import org.springframework.stereotype.Controller; |
13 | import org.springframework.web.bind.annotation.RequestMapping; | 13 | import org.springframework.web.bind.annotation.RequestMapping; |
14 | import org.springframework.web.bind.annotation.RequestParam; | 14 | import org.springframework.web.bind.annotation.RequestParam; |
15 | +import org.springframework.web.bind.annotation.ResponseBody; | ||
15 | 16 | ||
16 | /** | 17 | /** |
17 | * Created by chenchao on 2018/9/13. | 18 | * Created by chenchao on 2018/9/13. |
@@ -34,6 +35,7 @@ public class SellerOrderController { | @@ -34,6 +35,7 @@ public class SellerOrderController { | ||
34 | * @throws GatewayException | 35 | * @throws GatewayException |
35 | */ | 36 | */ |
36 | @RequestMapping(params = "method=ufo.sellerOrder.computePublishPrd") | 37 | @RequestMapping(params = "method=ufo.sellerOrder.computePublishPrd") |
38 | + @ResponseBody | ||
37 | public ApiResponse computePublishPrd(@RequestParam(name = "uid", required = true)int uid, | 39 | public ApiResponse computePublishPrd(@RequestParam(name = "uid", required = true)int uid, |
38 | @RequestParam(name = "storage_id", required = true)int storage_id, | 40 | @RequestParam(name = "storage_id", required = true)int storage_id, |
39 | @RequestParam(name="price", required = true)String price) throws GatewayException { | 41 | @RequestParam(name="price", required = true)String price) throws GatewayException { |
@@ -58,6 +60,7 @@ public class SellerOrderController { | @@ -58,6 +60,7 @@ public class SellerOrderController { | ||
58 | * @throws GatewayException | 60 | * @throws GatewayException |
59 | */ | 61 | */ |
60 | @RequestMapping(params = "method=ufo.sellerOrder.publishPrd") | 62 | @RequestMapping(params = "method=ufo.sellerOrder.publishPrd") |
63 | + @ResponseBody | ||
61 | public ApiResponse publishPrd(@RequestParam(name = "uid", required = true)int uid, | 64 | public ApiResponse publishPrd(@RequestParam(name = "uid", required = true)int uid, |
62 | @RequestParam(name = "storage_id", required = true)int storage_id, | 65 | @RequestParam(name = "storage_id", required = true)int storage_id, |
63 | @RequestParam(name="price", required = true)String price, | 66 | @RequestParam(name="price", required = true)String price, |
1 | package com.yohoufo.order.model.dto; | 1 | package com.yohoufo.order.model.dto; |
2 | 2 | ||
3 | 3 | ||
4 | +import com.yoho.service.model.response.UserAddressRspBO; | ||
4 | import lombok.Data; | 5 | import lombok.Data; |
5 | import lombok.ToString; | 6 | import lombok.ToString; |
6 | import lombok.experimental.Builder; | 7 | import lombok.experimental.Builder; |
@@ -30,4 +31,11 @@ public class OrderBuilder { | @@ -30,4 +31,11 @@ public class OrderBuilder { | ||
30 | * 运费 | 31 | * 运费 |
31 | */ | 32 | */ |
32 | BigDecimal shipFee; | 33 | BigDecimal shipFee; |
34 | + | ||
35 | + /** | ||
36 | + * 用户地址 | ||
37 | + */ | ||
38 | + UserAddressRspBO addressInfo; | ||
39 | + | ||
40 | + | ||
33 | } | 41 | } |
@@ -5,7 +5,7 @@ import com.yohoufo.order.request.ShoppingRequest; | @@ -5,7 +5,7 @@ import com.yohoufo.order.request.ShoppingRequest; | ||
5 | import com.yohoufo.order.response.OrderSubmitResponse; | 5 | import com.yohoufo.order.response.OrderSubmitResponse; |
6 | import com.yohoufo.order.response.ShoppingPaymentResponse; | 6 | import com.yohoufo.order.response.ShoppingPaymentResponse; |
7 | 7 | ||
8 | -public interface IShoppingService { | 8 | +public interface IBuyerOrderService { |
9 | 9 | ||
10 | /** | 10 | /** |
11 | * 结算页数据 | 11 | * 结算页数据 |
@@ -256,10 +256,6 @@ public class SellerOrderService { | @@ -256,10 +256,6 @@ public class SellerOrderService { | ||
256 | 256 | ||
257 | 257 | ||
258 | 258 | ||
259 | - | ||
260 | - | ||
261 | - | ||
262 | - | ||
263 | private String formatFee(BigDecimal fee){ | 259 | private String formatFee(BigDecimal fee){ |
264 | return PriceFormater.addCnCurrencySymbol(BigDecimalHelper.formatNumber(fee, BigDecimalHelper.FORMAT_TWOBITAFTERPOINT)); | 260 | return PriceFormater.addCnCurrencySymbol(BigDecimalHelper.formatNumber(fee, BigDecimalHelper.FORMAT_TWOBITAFTERPOINT)); |
265 | } | 261 | } |
1 | package com.yohoufo.order.service.impl; | 1 | package com.yohoufo.order.service.impl; |
2 | 2 | ||
3 | +import com.yoho.core.rest.client.ServiceCaller; | ||
3 | import com.yoho.error.ServiceError; | 4 | import com.yoho.error.ServiceError; |
4 | import com.yoho.error.exception.ServiceException; | 5 | import com.yoho.error.exception.ServiceException; |
6 | +import com.yoho.service.model.request.UserAddressReqBO; | ||
7 | +import com.yoho.service.model.response.UserAddressRspBO; | ||
8 | +import com.yohoufo.common.utils.AddressUtil; | ||
5 | import com.yohoufo.dal.order.SellerOrderGoodsMapper; | 9 | import com.yohoufo.dal.order.SellerOrderGoodsMapper; |
6 | import com.yohoufo.dal.order.model.SellerOrderGoods; | 10 | import com.yohoufo.dal.order.model.SellerOrderGoods; |
7 | import com.yohoufo.order.common.OrderCodeType; | 11 | import com.yohoufo.order.common.OrderCodeType; |
@@ -11,20 +15,22 @@ import com.yohoufo.order.model.dto.OrderBuilder; | @@ -11,20 +15,22 @@ import com.yohoufo.order.model.dto.OrderBuilder; | ||
11 | import com.yohoufo.order.request.ShoppingRequest; | 15 | import com.yohoufo.order.request.ShoppingRequest; |
12 | import com.yohoufo.order.response.OrderSubmitResponse; | 16 | import com.yohoufo.order.response.OrderSubmitResponse; |
13 | import com.yohoufo.order.response.ShoppingPaymentResponse; | 17 | import com.yohoufo.order.response.ShoppingPaymentResponse; |
18 | +import com.yohoufo.order.service.IBuyerOrderService; | ||
14 | import com.yohoufo.order.service.IOrdeCreationService; | 19 | import com.yohoufo.order.service.IOrdeCreationService; |
15 | -import com.yohoufo.order.service.IShoppingService; | ||
16 | import com.yohoufo.order.service.support.ShoppingSupport; | 20 | import com.yohoufo.order.service.support.ShoppingSupport; |
17 | import com.yohoufo.order.service.support.codegenerator.OrderCodeGenerator; | 21 | import com.yohoufo.order.service.support.codegenerator.OrderCodeGenerator; |
18 | import org.apache.commons.lang3.StringUtils; | 22 | import org.apache.commons.lang3.StringUtils; |
19 | import org.slf4j.Logger; | 23 | import org.slf4j.Logger; |
20 | import org.slf4j.LoggerFactory; | 24 | import org.slf4j.LoggerFactory; |
21 | import org.springframework.beans.factory.annotation.Autowired; | 25 | import org.springframework.beans.factory.annotation.Autowired; |
26 | +import org.springframework.stereotype.Service; | ||
27 | + | ||
22 | import java.math.BigDecimal; | 28 | import java.math.BigDecimal; |
23 | import java.util.Arrays; | 29 | import java.util.Arrays; |
24 | -import org.springframework.stereotype.Service; | 30 | +import java.util.concurrent.TimeUnit; |
25 | 31 | ||
26 | @Service | 32 | @Service |
27 | -public class ShoppingServiceImpl implements IShoppingService{ | 33 | +public class BuyerOrderServiceImpl implements IBuyerOrderService { |
28 | 34 | ||
29 | private final Logger logger = LoggerFactory.getLogger(getClass()); | 35 | private final Logger logger = LoggerFactory.getLogger(getClass()); |
30 | 36 | ||
@@ -40,9 +46,12 @@ public class ShoppingServiceImpl implements IShoppingService{ | @@ -40,9 +46,12 @@ public class ShoppingServiceImpl implements IShoppingService{ | ||
40 | @Autowired | 46 | @Autowired |
41 | IOrdeCreationService ordeCreationService; | 47 | IOrdeCreationService ordeCreationService; |
42 | 48 | ||
49 | + @Autowired | ||
50 | + ServiceCaller serviceCaller; | ||
51 | + | ||
43 | /** | 52 | /** |
44 | * 结算页数据 | 53 | * 结算页数据 |
45 | - * @param shoppingRequest | 54 | + * @param request |
46 | * @return | 55 | * @return |
47 | */ | 56 | */ |
48 | public ShoppingPaymentResponse payment(ShoppingRequest request){ | 57 | public ShoppingPaymentResponse payment(ShoppingRequest request){ |
@@ -53,20 +62,8 @@ public class ShoppingServiceImpl implements IShoppingService{ | @@ -53,20 +62,8 @@ public class ShoppingServiceImpl implements IShoppingService{ | ||
53 | throw new ServiceException(ServiceError.ORDER_REQUEST_PARM_IS_EMPTY); | 62 | throw new ServiceException(ServiceError.ORDER_REQUEST_PARM_IS_EMPTY); |
54 | } | 63 | } |
55 | 64 | ||
56 | - // skup是否是可售状态 | ||
57 | - SellerOrderGoods skupGood = sellerOrderGoodsMapper.selectByPrimaryKey(request.getSkup()); | ||
58 | - if (skupGood == null){ | ||
59 | - logger.warn("payment skup not exist, skup is {}", request.getSkup()); | ||
60 | - // TODO | ||
61 | - throw new ServiceException(ServiceError.ORDER_REQUEST_ERROR); | ||
62 | - } | ||
63 | - | ||
64 | - // 不可售 | ||
65 | - if (skupGood.getStatus()!=null | ||
66 | - && skupGood.getStatus().intValue() != SkupStatus.CAN_SELL.getCode()){ | ||
67 | - logger.warn("payment skup status, skup is {}", request.getSkup()); | ||
68 | - throw new ServiceException(ServiceError.ORDER_REQUEST_ERROR); | ||
69 | - } | 65 | + // 检查 商品sku是否可售 |
66 | + SellerOrderGoods skupGood = checkSkupSellOrNot(request.getSkup()); | ||
70 | 67 | ||
71 | ShoppingPaymentResponse response = new ShoppingPaymentResponse(); | 68 | ShoppingPaymentResponse response = new ShoppingPaymentResponse(); |
72 | response.setPaymentWay(shoppingSupport.getPaymentWay()); | 69 | response.setPaymentWay(shoppingSupport.getPaymentWay()); |
@@ -75,11 +72,28 @@ public class ShoppingServiceImpl implements IShoppingService{ | @@ -75,11 +72,28 @@ public class ShoppingServiceImpl implements IShoppingService{ | ||
75 | response.setPromotionFormulaList(shoppingSupport.getPromotionFormula(skupGood)); | 72 | response.setPromotionFormulaList(shoppingSupport.getPromotionFormula(skupGood)); |
76 | 73 | ||
77 | // TODO 赔偿金计算 | 74 | // TODO 赔偿金计算 |
78 | - response.setDamagesDesc(shoppingSupport.getDamagesDesc(null)); | 75 | +// response.setDamagesDesc(shoppingSupport.getDamagesDesc(null)); |
79 | 76 | ||
80 | return response; | 77 | return response; |
81 | } | 78 | } |
82 | 79 | ||
80 | + private SellerOrderGoods checkSkupSellOrNot(int skup) { | ||
81 | + // skup是否是可售状态 | ||
82 | + SellerOrderGoods skupGood = sellerOrderGoodsMapper.selectByPrimaryKey(skup); | ||
83 | + if (skupGood == null){ | ||
84 | + logger.warn("payment skup not exist, skup is {}", skup); | ||
85 | + throw new ServiceException(ServiceError.ORDER_SKUP_CANNOT_SELL); | ||
86 | + } | ||
87 | + | ||
88 | + // 不可售 | ||
89 | + if (skupGood.getStatus() == null | ||
90 | + || skupGood.getStatus().intValue() == SkupStatus.CAN_NOT_SELL.getCode()){ | ||
91 | + logger.warn("payment skup status, skup is {}", skup); | ||
92 | + throw new ServiceException(ServiceError.ORDER_SKUP_CANNOT_SELL); | ||
93 | + } | ||
94 | + return skupGood; | ||
95 | + } | ||
96 | + | ||
83 | 97 | ||
84 | /** | 98 | /** |
85 | * 提交订单 | 99 | * 提交订单 |
@@ -93,29 +107,25 @@ public class ShoppingServiceImpl implements IShoppingService{ | @@ -93,29 +107,25 @@ public class ShoppingServiceImpl implements IShoppingService{ | ||
93 | || shoppingRequest.getUid() < 0 | 107 | || shoppingRequest.getUid() < 0 |
94 | || StringUtils.isEmpty(shoppingRequest.getAddressId())){ | 108 | || StringUtils.isEmpty(shoppingRequest.getAddressId())){ |
95 | logger.warn("submit param is null"); | 109 | logger.warn("submit param is null"); |
96 | - // TODO | ||
97 | - throw new ServiceException(ServiceError.ORDER_REQUEST_ERROR); | 110 | + throw new ServiceException(ServiceError.ORDER_REQUEST_PARM_IS_EMPTY); |
98 | } | 111 | } |
99 | 112 | ||
100 | - // 创建订单 | ||
101 | - // 校验 skup是否是可售 | ||
102 | - SellerOrderGoods skup = sellerOrderGoodsMapper.selectByPrimaryKey(shoppingRequest.getSkup()); | ||
103 | - if (skup == null){ | ||
104 | - logger.warn("payment skup not exist, skup is {}", shoppingRequest.getSkup()); | ||
105 | - // TODO | ||
106 | - throw new ServiceException(ServiceError.ORDER_REQUEST_ERROR); | 113 | + // 检查地址是否合法 |
114 | + int addressId = AddressUtil.getDecryptStr(shoppingRequest.getAddressId()); | ||
115 | + if (addressId < 0){ | ||
116 | + logger.warn("submit addressId invalidate, uid is {}, skup is {}, addressId is {}", shoppingRequest.getUid(), | ||
117 | + shoppingRequest.getSkup(), shoppingRequest.getAddressId()); | ||
118 | + throw new ServiceException(ServiceError.ORDER_ADDRESSID_INVALIDATE); | ||
107 | } | 119 | } |
108 | 120 | ||
109 | - // 不可售 | ||
110 | - if (skup.getStatus()!=null | ||
111 | - && skup.getStatus().intValue() != SkupStatus.CAN_SELL.getCode()){ | ||
112 | - logger.warn("payment skup status, skup is {}", shoppingRequest.getSkup()); | ||
113 | - throw new ServiceException(ServiceError.ORDER_REQUEST_ERROR); | ||
114 | - } | 121 | + // 检查skup是否可售 |
122 | + SellerOrderGoods skup = checkSkupSellOrNot(shoppingRequest.getSkup()); | ||
115 | 123 | ||
116 | - // 生成订单号 TODO | 124 | + // 生成订单号 |
117 | long orderCode = orderCodeGenerator.generate(OrderCodeType.BUYER_TYPE); | 125 | long orderCode = orderCodeGenerator.generate(OrderCodeType.BUYER_TYPE); |
118 | 126 | ||
127 | + UserAddressRspBO addressInfo = getAddressInfo(shoppingRequest, addressId); | ||
128 | + | ||
119 | // 减库存,skup更新成不可售,入库 | 129 | // 减库存,skup更新成不可售,入库 |
120 | BigDecimal shipFee = new BigDecimal(OrderConstant.DELIVERY_WAY_SF_COST); | 130 | BigDecimal shipFee = new BigDecimal(OrderConstant.DELIVERY_WAY_SF_COST); |
121 | OrderBuilder orderBuilder = OrderBuilder.builder() | 131 | OrderBuilder orderBuilder = OrderBuilder.builder() |
@@ -128,10 +138,9 @@ public class ShoppingServiceImpl implements IShoppingService{ | @@ -128,10 +138,9 @@ public class ShoppingServiceImpl implements IShoppingService{ | ||
128 | .channelNo(shoppingRequest.getChannelNo()) | 138 | .channelNo(shoppingRequest.getChannelNo()) |
129 | .amount(skup.getGoodsPrice().add(shipFee)) | 139 | .amount(skup.getGoodsPrice().add(shipFee)) |
130 | .shipFee(shipFee) | 140 | .shipFee(shipFee) |
141 | + .addressInfo(addressInfo) | ||
131 | .build(); | 142 | .build(); |
132 | 143 | ||
133 | - // 收货地址信息, 入口参数:uid, address_id TODO | ||
134 | - | ||
135 | ordeCreationService.create(orderBuilder); | 144 | ordeCreationService.create(orderBuilder); |
136 | 145 | ||
137 | 146 | ||
@@ -140,7 +149,27 @@ public class ShoppingServiceImpl implements IShoppingService{ | @@ -140,7 +149,27 @@ public class ShoppingServiceImpl implements IShoppingService{ | ||
140 | 149 | ||
141 | } | 150 | } |
142 | 151 | ||
143 | - | 152 | + /** |
153 | + * 获取用户信息 | ||
154 | + * @param shoppingRequest | ||
155 | + * @param addressId | ||
156 | + * @return | ||
157 | + */ | ||
158 | + private UserAddressRspBO getAddressInfo(ShoppingRequest shoppingRequest, int addressId) { | ||
159 | + // 收货地址信息, 入口参数:uid, address_id | ||
160 | + UserAddressReqBO userAddressReqBO = new UserAddressReqBO(); | ||
161 | + userAddressReqBO.setUid(shoppingRequest.getUid()); | ||
162 | + userAddressReqBO.setId(addressId); | ||
163 | + | ||
164 | + //超时,使用默认地址,后续需要手动补充地址 | ||
165 | + UserAddressRspBO defaultResponse = new UserAddressRspBO(); | ||
166 | + defaultResponse.setAreaCode(OrderConstant.EMPTY_ADDRESS_CODE); | ||
167 | + defaultResponse.setId(String.valueOf(addressId)); | ||
168 | + UserAddressRspBO userAddressBO = serviceCaller.asyncCall("users.getAddress", userAddressReqBO, | ||
169 | + UserAddressRspBO.class, defaultResponse).get(500, TimeUnit.MILLISECONDS); | ||
170 | + | ||
171 | + return userAddressBO; | ||
172 | + } | ||
144 | 173 | ||
145 | 174 | ||
146 | } | 175 | } |
1 | package com.yohoufo.order.service.impl; | 1 | package com.yohoufo.order.service.impl; |
2 | 2 | ||
3 | +import com.alibaba.fastjson.JSONObject; | ||
3 | import com.yoho.core.common.utils.DateUtil; | 4 | import com.yoho.core.common.utils.DateUtil; |
4 | import com.yoho.error.ServiceError; | 5 | import com.yoho.error.ServiceError; |
5 | import com.yoho.error.exception.ServiceException; | 6 | import com.yoho.error.exception.ServiceException; |
7 | +import com.yohoufo.common.ApiResponse; | ||
6 | import com.yohoufo.common.caller.UfoServiceCaller; | 8 | import com.yohoufo.common.caller.UfoServiceCaller; |
7 | import com.yohoufo.dal.order.*; | 9 | import com.yohoufo.dal.order.*; |
8 | -import com.yohoufo.dal.order.model.BuyerOrder; | ||
9 | -import com.yohoufo.dal.order.model.BuyerOrderGoods; | ||
10 | -import com.yohoufo.dal.order.model.SellerOrder; | ||
11 | -import com.yohoufo.dal.order.model.SellerOrderGoods; | 10 | +import com.yohoufo.dal.order.model.*; |
12 | import com.yohoufo.order.common.OrderStatus; | 11 | import com.yohoufo.order.common.OrderStatus; |
13 | import com.yohoufo.order.common.SellerOrderStatus; | 12 | import com.yohoufo.order.common.SellerOrderStatus; |
14 | import com.yohoufo.order.common.SkupStatus; | 13 | import com.yohoufo.order.common.SkupStatus; |
14 | +import com.yohoufo.order.constants.MetaKey; | ||
15 | import com.yohoufo.order.model.dto.OrderBuilder; | 15 | import com.yohoufo.order.model.dto.OrderBuilder; |
16 | import com.yohoufo.order.service.IOrdeCreationService; | 16 | import com.yohoufo.order.service.IOrdeCreationService; |
17 | +import com.yohoufo.product.controller.ProductController; | ||
18 | +import org.slf4j.Logger; | ||
19 | +import org.slf4j.LoggerFactory; | ||
17 | import org.springframework.beans.factory.annotation.Autowired; | 20 | import org.springframework.beans.factory.annotation.Autowired; |
18 | import org.springframework.stereotype.Service; | 21 | import org.springframework.stereotype.Service; |
19 | import org.springframework.transaction.annotation.Transactional; | 22 | import org.springframework.transaction.annotation.Transactional; |
@@ -21,6 +24,8 @@ import org.springframework.transaction.annotation.Transactional; | @@ -21,6 +24,8 @@ import org.springframework.transaction.annotation.Transactional; | ||
21 | @Service | 24 | @Service |
22 | public class OrdeCreationServiceImpl implements IOrdeCreationService { | 25 | public class OrdeCreationServiceImpl implements IOrdeCreationService { |
23 | 26 | ||
27 | + private final Logger logger = LoggerFactory.getLogger(ProductController.class); | ||
28 | + | ||
24 | @Autowired | 29 | @Autowired |
25 | SellerOrderGoodsMapper sellerOrderGoodsMapper; | 30 | SellerOrderGoodsMapper sellerOrderGoodsMapper; |
26 | 31 | ||
@@ -36,7 +41,6 @@ public class OrdeCreationServiceImpl implements IOrdeCreationService { | @@ -36,7 +41,6 @@ public class OrdeCreationServiceImpl implements IOrdeCreationService { | ||
36 | @Autowired | 41 | @Autowired |
37 | BuyerOrderMetaMapper buyerOrderMetaMapper; | 42 | BuyerOrderMetaMapper buyerOrderMetaMapper; |
38 | 43 | ||
39 | - | ||
40 | @Autowired | 44 | @Autowired |
41 | private UfoServiceCaller serviceCaller; | 45 | private UfoServiceCaller serviceCaller; |
42 | 46 | ||
@@ -48,47 +52,59 @@ public class OrdeCreationServiceImpl implements IOrdeCreationService { | @@ -48,47 +52,59 @@ public class OrdeCreationServiceImpl implements IOrdeCreationService { | ||
48 | @Transactional | 52 | @Transactional |
49 | public void create(OrderBuilder orderBuilder){ | 53 | public void create(OrderBuilder orderBuilder){ |
50 | 54 | ||
55 | + boolean increaseNeed = false; | ||
51 | try{ | 56 | try{ |
52 | 57 | ||
53 | - // 扣减库存,入口参数:skup, product_id TODO | ||
54 | - | ||
55 | - // 1.skup不可售 | ||
56 | - // 2.卖家订单,skup已经售出 | ||
57 | - SellerOrderGoods sellerOrderGoods = new SellerOrderGoods(); | ||
58 | - sellerOrderGoods.setId(orderBuilder.getSkup()); | ||
59 | - sellerOrderGoods.setStatus(SkupStatus.CAN_NOT_SELL.getCode()); | ||
60 | - sellerOrderGoodsMapper.updateByPrimaryKeySelective(sellerOrderGoods); | ||
61 | - | ||
62 | - | ||
63 | - // 根据skup 查询卖家订单 ==> 卖家uid | ||
64 | - SellerOrder sellerOrder = sellerOrderMapper.selectBySkup(orderBuilder.getSkup()); | ||
65 | - sellerOrder.setUpdateTime(DateUtil.getCurrentTimeSecond()); | ||
66 | - sellerOrder.setStatus(SellerOrderStatus.HAS_SELLED.getCode()); | ||
67 | - sellerOrderMapper.updateByPrimaryKeySelective(sellerOrder); | ||
68 | - | ||
69 | - // 订单入口 | ||
70 | - BuyerOrder buyerOrder = new BuyerOrder(); | ||
71 | - buyerOrder.setUid(orderBuilder.getUid()); | ||
72 | - buyerOrder.setOrderCode(orderBuilder.getOrderCode()); | ||
73 | - buyerOrder.setSellerUid(sellerOrder.getUid()); | ||
74 | - buyerOrder.setPaymentType((byte) orderBuilder.getPaymentType()); | ||
75 | - buyerOrder.setAmount(orderBuilder.getAmount()); | ||
76 | - buyerOrder.setShipFee(orderBuilder.getShipFee()); | ||
77 | - buyerOrder.setChannelNo(orderBuilder.getChannelNo()); | ||
78 | - int now = DateUtil.getCurrentTimeSecond(); | ||
79 | - buyerOrder.setCreateTime(now); | ||
80 | - buyerOrder.setUpdateTime(now); | ||
81 | - buyerOrder.setStatus((byte)OrderStatus.WAITING_PAY.getCode()); | ||
82 | - buyerOrderMapper.insert(buyerOrder); | ||
83 | - | ||
84 | - BuyerOrderGoods buyerOrderGoods = new BuyerOrderGoods(); | ||
85 | - buyerOrderGoods.setSkup(orderBuilder.getSkup()); | ||
86 | - buyerOrderGoods.setOrderCode(orderBuilder.getOrderCode()); | ||
87 | - buyerOrderGoods.setGoodsPrice(sellerOrderGoods.getGoodsPrice()); | ||
88 | - buyerOrderGoods.setGoodsAmount(sellerOrderGoods.getGoodsPrice()); | ||
89 | - buyerOrderGoodsMapper.insertSelective(buyerOrderGoods); | 58 | + // 扣减库存 |
59 | + // 入口参数:skup, product_id | ||
60 | + ApiResponse apiResponse = serviceCaller.call("ufo.product.saleSkup", | ||
61 | + ApiResponse.class, orderBuilder.getProductId(), orderBuilder.getSkup()); | ||
62 | + // 减库存失败 | ||
63 | + if (apiResponse.getCode() != 200){ | ||
64 | + logger.warn("submit create order, decrease storage faile, orderCode is {}, uid is {}, skup is {}, productId is {}", | ||
65 | + orderBuilder.getOrderCode(), orderBuilder.getUid(), orderBuilder.getSkup(), orderBuilder.getProductId()); | ||
66 | + throw new ServiceException(ServiceError.ORDER_SKUP_CANNOT_SELL); | ||
67 | + } | ||
68 | + | ||
69 | + // product处减库存失败 | ||
70 | + increaseNeed = true; | ||
71 | + | ||
72 | + /** | ||
73 | + * 1.更新 表seller_order_goods skup的状态为不可售 | ||
74 | + * 2.更新 表seller_order 状态为已经售出 | ||
75 | + * 3.插入订单 表buyer_order | ||
76 | + * 4.插入订单商品 buyer_order_goods | ||
77 | + * 5.插入收货地址 buyer_order_meta | ||
78 | + */ | ||
79 | + | ||
80 | + // 1.表seller_order_goods ==> 不可售 | ||
81 | + SellerOrderGoods sellerOrderGoods = updSellerOrderGoods(orderBuilder); | ||
82 | + | ||
83 | + // 2.更新 表seller_order 状态 ==> 已售出 | ||
84 | + SellerOrder sellerOrder = updSellerOrder(orderBuilder); | ||
85 | + | ||
86 | + // 3.插入订单 表buyer_order | ||
87 | + insertOrder(orderBuilder, sellerOrder.getUid()); | ||
88 | + | ||
89 | + // 4.插入订单商品 buyer_order_goods | ||
90 | + insertOrderGoods(orderBuilder, sellerOrderGoods); | ||
91 | + | ||
92 | + // 5.插入收货地址 buyer_order_meta 买家收货地址 | ||
93 | + insertOrderMeta(orderBuilder); | ||
94 | + | ||
90 | 95 | ||
91 | }catch (Exception ex){ | 96 | }catch (Exception ex){ |
97 | + | ||
98 | + if (increaseNeed){ | ||
99 | + // order处 更新状态失败,需要补库存 | ||
100 | + ApiResponse apiResponse = serviceCaller.call("ufo.product.cancelSaleSkup",ApiResponse.class, orderBuilder.getSkup()); | ||
101 | + // 补库存失败,需要报警手动补库存 TODO | ||
102 | + if (apiResponse.getCode() != 200){ | ||
103 | + | ||
104 | + } | ||
105 | + } | ||
106 | + | ||
107 | + | ||
92 | if (!(ex instanceof ServiceException)) { | 108 | if (!(ex instanceof ServiceException)) { |
93 | //上报告警事件 | 109 | //上报告警事件 |
94 | // EventBusPublisher.publishEvent(new SmsAlarmEvent(OrderHanders.submit, "submit", "订单(" + order.getOrderCode() + ")创建失败")); | 110 | // EventBusPublisher.publishEvent(new SmsAlarmEvent(OrderHanders.submit, "submit", "订单(" + order.getOrderCode() + ")创建失败")); |
@@ -98,4 +114,54 @@ public class OrdeCreationServiceImpl implements IOrdeCreationService { | @@ -98,4 +114,54 @@ public class OrdeCreationServiceImpl implements IOrdeCreationService { | ||
98 | } | 114 | } |
99 | 115 | ||
100 | } | 116 | } |
117 | + | ||
118 | + private void insertOrderMeta(OrderBuilder orderBuilder) { | ||
119 | + BuyerOrderMeta buyerOrderMeta = new BuyerOrderMeta(); | ||
120 | + buyerOrderMeta.setUid(orderBuilder.getUid()); | ||
121 | + buyerOrderMeta.setOrderCode(orderBuilder.getOrderCode()); | ||
122 | + buyerOrderMeta.setMetaKey(MetaKey.BUYER_DELIVERY_ADDRESS); | ||
123 | + buyerOrderMeta.setMetaValue(JSONObject.toJSONString(orderBuilder.getAddressInfo())); | ||
124 | + buyerOrderMetaMapper.insert(buyerOrderMeta); | ||
125 | + } | ||
126 | + | ||
127 | + private void insertOrderGoods(OrderBuilder orderBuilder, SellerOrderGoods sellerOrderGoods) { | ||
128 | + BuyerOrderGoods buyerOrderGoods = new BuyerOrderGoods(); | ||
129 | + buyerOrderGoods.setSkup(orderBuilder.getSkup()); | ||
130 | + buyerOrderGoods.setOrderCode(orderBuilder.getOrderCode()); | ||
131 | + buyerOrderGoods.setGoodsPrice(sellerOrderGoods.getGoodsPrice()); | ||
132 | + buyerOrderGoods.setGoodsAmount(sellerOrderGoods.getGoodsPrice()); | ||
133 | + buyerOrderGoodsMapper.insertSelective(buyerOrderGoods); | ||
134 | + } | ||
135 | + | ||
136 | + private void insertOrder(OrderBuilder orderBuilder, int sellerUid) { | ||
137 | + BuyerOrder buyerOrder = new BuyerOrder(); | ||
138 | + buyerOrder.setUid(orderBuilder.getUid()); | ||
139 | + buyerOrder.setOrderCode(orderBuilder.getOrderCode()); | ||
140 | + buyerOrder.setSellerUid(sellerUid); | ||
141 | + buyerOrder.setPaymentType((byte) orderBuilder.getPaymentType()); | ||
142 | + buyerOrder.setAmount(orderBuilder.getAmount()); | ||
143 | + buyerOrder.setShipFee(orderBuilder.getShipFee()); | ||
144 | + buyerOrder.setChannelNo(orderBuilder.getChannelNo()); | ||
145 | + int now = DateUtil.getCurrentTimeSecond(); | ||
146 | + buyerOrder.setCreateTime(now); | ||
147 | + buyerOrder.setUpdateTime(now); | ||
148 | + buyerOrder.setStatus((byte) OrderStatus.WAITING_PAY.getCode()); | ||
149 | + buyerOrderMapper.insert(buyerOrder); | ||
150 | + } | ||
151 | + | ||
152 | + private SellerOrder updSellerOrder(OrderBuilder orderBuilder) { | ||
153 | + SellerOrder sellerOrder = sellerOrderMapper.selectBySkup(orderBuilder.getSkup()); | ||
154 | + sellerOrder.setUpdateTime(DateUtil.getCurrentTimeSecond()); | ||
155 | + sellerOrder.setStatus(SellerOrderStatus.HAS_SELLED.getCode()); | ||
156 | + sellerOrderMapper.updateByPrimaryKeySelective(sellerOrder); | ||
157 | + return sellerOrder; | ||
158 | + } | ||
159 | + | ||
160 | + private SellerOrderGoods updSellerOrderGoods(OrderBuilder orderBuilder) { | ||
161 | + SellerOrderGoods sellerOrderGoods = new SellerOrderGoods(); | ||
162 | + sellerOrderGoods.setId(orderBuilder.getSkup()); | ||
163 | + sellerOrderGoods.setStatus(SkupStatus.CAN_NOT_SELL.getCode()); | ||
164 | + sellerOrderGoodsMapper.updateByPrimaryKeySelective(sellerOrderGoods); | ||
165 | + return sellerOrderGoods; | ||
166 | + } | ||
101 | } | 167 | } |
@@ -154,7 +154,7 @@ public class PaymentServiceImpl implements IPaymentService { | @@ -154,7 +154,7 @@ public class PaymentServiceImpl implements IPaymentService { | ||
154 | 154 | ||
155 | logger.info("payment orderCode is {} ,uid is {}, type is {}",request.getOrderCode(), request.getUid(), codeMeta.getType()); | 155 | logger.info("payment orderCode is {} ,uid is {}, type is {}",request.getOrderCode(), request.getUid(), codeMeta.getType()); |
156 | 156 | ||
157 | - // 卖家订单号 | 157 | + // 买家订单号 |
158 | if (codeMeta.getType() == OrderCodeType.BUYER_TYPE.getType()){ | 158 | if (codeMeta.getType() == OrderCodeType.BUYER_TYPE.getType()){ |
159 | return checkUpdBuyerOrderCode(request); | 159 | return checkUpdBuyerOrderCode(request); |
160 | }else{ | 160 | }else{ |
@@ -165,7 +165,7 @@ public class PaymentServiceImpl implements IPaymentService { | @@ -165,7 +165,7 @@ public class PaymentServiceImpl implements IPaymentService { | ||
165 | 165 | ||
166 | private BigDecimal checkUpdSellerOrderCode(PaymentRequest request) { | 166 | private BigDecimal checkUpdSellerOrderCode(PaymentRequest request) { |
167 | // 订单状态 | 167 | // 订单状态 |
168 | - SellerOrder sellerOrder = sellerOrderMapper.selectByOrderCode(request.getOrderCode()); | 168 | + SellerOrder sellerOrder = sellerOrderMapper.selectByOrderCode(request.getOrderCode(), request.getUid()); |
169 | if (sellerOrder == null){ | 169 | if (sellerOrder == null){ |
170 | logger.warn("payment orderCode not exist, orderCode is {}", request.getOrderCode(), request.getUid()); | 170 | logger.warn("payment orderCode not exist, orderCode is {}", request.getOrderCode(), request.getUid()); |
171 | throw new ServiceException(ServiceError.ORDER_NULL); | 171 | throw new ServiceException(ServiceError.ORDER_NULL); |
@@ -178,7 +178,7 @@ public class PaymentServiceImpl implements IPaymentService { | @@ -178,7 +178,7 @@ public class PaymentServiceImpl implements IPaymentService { | ||
178 | } | 178 | } |
179 | 179 | ||
180 | // 检查实付金额 | 180 | // 检查实付金额 |
181 | - if (sellerOrder.getEarnestMoney() == null){ | 181 | + if (sellerOrder.getEarnestMoney() == null || sellerOrder.getEarnestMoney().compareTo(new BigDecimal(0)) <=0 ){ |
182 | logger.warn("payment amount null, orderCode is {}", request.getOrderCode()); | 182 | logger.warn("payment amount null, orderCode is {}", request.getOrderCode()); |
183 | throw new ServiceException(ServiceError.ORDER_NULL); | 183 | throw new ServiceException(ServiceError.ORDER_NULL); |
184 | } | 184 | } |
@@ -197,7 +197,7 @@ public class PaymentServiceImpl implements IPaymentService { | @@ -197,7 +197,7 @@ public class PaymentServiceImpl implements IPaymentService { | ||
197 | */ | 197 | */ |
198 | private BigDecimal checkUpdBuyerOrderCode(PaymentRequest request) { | 198 | private BigDecimal checkUpdBuyerOrderCode(PaymentRequest request) { |
199 | // 订单状态 | 199 | // 订单状态 |
200 | - BuyerOrder buyerOrder = buyerOrderMapper.selectByOrderCode(request.getOrderCode()); | 200 | + BuyerOrder buyerOrder = buyerOrderMapper.selectByOrderCode(request.getOrderCode(), request.getUid()); |
201 | if (buyerOrder == null){ | 201 | if (buyerOrder == null){ |
202 | logger.warn("payment orderCode not exist, orderCode is {}", request.getOrderCode(), request.getUid()); | 202 | logger.warn("payment orderCode not exist, orderCode is {}", request.getOrderCode(), request.getUid()); |
203 | throw new ServiceException(ServiceError.ORDER_NULL); | 203 | throw new ServiceException(ServiceError.ORDER_NULL); |
@@ -210,7 +210,7 @@ public class PaymentServiceImpl implements IPaymentService { | @@ -210,7 +210,7 @@ public class PaymentServiceImpl implements IPaymentService { | ||
210 | } | 210 | } |
211 | 211 | ||
212 | // 检查实付金额 | 212 | // 检查实付金额 |
213 | - if (buyerOrder.getAmount() == null){ | 213 | + if (buyerOrder.getAmount() == null || buyerOrder.getAmount().compareTo(new BigDecimal(0)) <= 0){ |
214 | logger.warn("payment amount null, orderCode is {}", request.getOrderCode()); | 214 | logger.warn("payment amount null, orderCode is {}", request.getOrderCode()); |
215 | throw new ServiceException(ServiceError.ORDER_NULL); | 215 | throw new ServiceException(ServiceError.ORDER_NULL); |
216 | } | 216 | } |
@@ -84,15 +84,15 @@ public class ProductController { | @@ -84,15 +84,15 @@ public class ProductController { | ||
84 | @ApiOperation(name = "ufo.product.storage.leastprice", desc="sku的最低价") | 84 | @ApiOperation(name = "ufo.product.storage.leastprice", desc="sku的最低价") |
85 | @RequestMapping(params = "method=ufo.product.storage.leastprice") | 85 | @RequestMapping(params = "method=ufo.product.storage.leastprice") |
86 | //@Cachable(expire=600) | 86 | //@Cachable(expire=600) |
87 | - public ApiResponse queryStorageLeastprice( | 87 | + public StorageLeastPriceResp queryStorageLeastprice( |
88 | @RequestParam(value = "storage_id", required = true) Integer storageId) { | 88 | @RequestParam(value = "storage_id", required = true) Integer storageId) { |
89 | 89 | ||
90 | if (storageId == null) { | 90 | if (storageId == null) { |
91 | - return new ApiResponse(500, "storageId Is Null", null); | 91 | + return null; |
92 | } | 92 | } |
93 | 93 | ||
94 | StorageLeastPriceResp resp = productService.queryStorageLeastPrice(storageId); | 94 | StorageLeastPriceResp resp = productService.queryStorageLeastPrice(storageId); |
95 | - return new ApiResponse.ApiResponseBuilder().data(queryStorageLeastprice()).code(200).message("storage.leastprice").build(); | 95 | + return queryStorageLeastprice(); |
96 | } | 96 | } |
97 | 97 | ||
98 | 98 | ||
@@ -105,16 +105,16 @@ public class ProductController { | @@ -105,16 +105,16 @@ public class ProductController { | ||
105 | @ApiOperation(name = "ufo.product.storage.data", desc="sku信息") | 105 | @ApiOperation(name = "ufo.product.storage.data", desc="sku信息") |
106 | @RequestMapping(params = "method=ufo.product.storage.data") | 106 | @RequestMapping(params = "method=ufo.product.storage.data") |
107 | //@Cachable(expire=600) | 107 | //@Cachable(expire=600) |
108 | - public ApiResponse queryStorageInfo( | 108 | + public StorageDataResp queryStorageInfo( |
109 | @RequestParam(value = "storage_id", required = true) Integer storageId) { | 109 | @RequestParam(value = "storage_id", required = true) Integer storageId) { |
110 | 110 | ||
111 | if (storageId == null) { | 111 | if (storageId == null) { |
112 | - return new ApiResponse(500, "storageId Is Null", null); | 112 | + return null; |
113 | } | 113 | } |
114 | 114 | ||
115 | StorageDataResp resp = productService.queryStorageInfo(storageId); | 115 | StorageDataResp resp = productService.queryStorageInfo(storageId); |
116 | 116 | ||
117 | - return new ApiResponse.ApiResponseBuilder().data(queryStorageData()).code(200).message("storage.data").build(); | 117 | + return queryStorageData(); |
118 | } | 118 | } |
119 | 119 | ||
120 | 120 |
@@ -18,13 +18,6 @@ | @@ -18,13 +18,6 @@ | ||
18 | </properties> | 18 | </properties> |
19 | 19 | ||
20 | <dependencies> | 20 | <dependencies> |
21 | - <dependency> | ||
22 | - <groupId>junit</groupId> | ||
23 | - <artifactId>junit</artifactId> | ||
24 | - <version>3.8.1</version> | ||
25 | - <scope>test</scope> | ||
26 | - </dependency> | ||
27 | - | ||
28 | <dependency> | 21 | <dependency> |
29 | <groupId>com.yohoufo.fore</groupId> | 22 | <groupId>com.yohoufo.fore</groupId> |
30 | <artifactId>yohoufo-fore-dal</artifactId> | 23 | <artifactId>yohoufo-fore-dal</artifactId> |
@@ -8,6 +8,7 @@ import org.springframework.beans.factory.annotation.Autowired; | @@ -8,6 +8,7 @@ import org.springframework.beans.factory.annotation.Autowired; | ||
8 | import org.springframework.web.bind.annotation.RequestBody; | 8 | import org.springframework.web.bind.annotation.RequestBody; |
9 | import org.springframework.web.bind.annotation.RequestMapping; | 9 | import org.springframework.web.bind.annotation.RequestMapping; |
10 | import org.springframework.web.bind.annotation.RequestMethod; | 10 | import org.springframework.web.bind.annotation.RequestMethod; |
11 | +import org.springframework.web.bind.annotation.RequestParam; | ||
11 | import org.springframework.web.bind.annotation.ResponseBody; | 12 | import org.springframework.web.bind.annotation.ResponseBody; |
12 | import org.springframework.web.bind.annotation.RestController; | 13 | import org.springframework.web.bind.annotation.RestController; |
13 | 14 | ||
@@ -41,4 +42,19 @@ public class ResourcesController { | @@ -41,4 +42,19 @@ public class ResourcesController { | ||
41 | return new ApiResponse.ApiResponseBuilder().data(data).code(200).message("resources data").build(); | 42 | return new ApiResponse.ApiResponseBuilder().data(data).code(200).message("resources data").build(); |
42 | 43 | ||
43 | } | 44 | } |
45 | + | ||
46 | + @RequestMapping(params = "method=ufo.resource.get") | ||
47 | + public ApiResponse payment(@RequestParam(name = "contentCode") String contentCode, | ||
48 | + @RequestParam(name = "clientType") String clientType) { | ||
49 | + | ||
50 | + ResourcesRequestBody request = new ResourcesRequestBody(); | ||
51 | + request.setClientType(clientType); | ||
52 | + request.setContentCode(contentCode); | ||
53 | + logger.info("Get resources by content code[{}] and client type [{}].", request.getContentCode(), | ||
54 | + request.getClientType()); | ||
55 | + List<Object> data = resourcesService.get(request); | ||
56 | + logger.info("Get resources by content code[{}] and client type [{}] success.", request.getContentCode(), | ||
57 | + request.getClientType()); | ||
58 | + return new ApiResponse.ApiResponseBuilder().data(data).code(200).message("resources data").build(); | ||
59 | + } | ||
44 | } | 60 | } |
1 | +package com.yohoufo.resource.service.impl.cache; | ||
2 | + | ||
3 | +import com.alibaba.fastjson.JSONArray; | ||
4 | +import com.alibaba.fastjson.JSONObject; | ||
5 | +import com.alibaba.fastjson.serializer.IntegerCodec; | ||
6 | +import com.yoho.core.cache.LocalCache; | ||
7 | +import com.yoho.core.cache.LocalCacheCallback; | ||
8 | +import com.yoho.core.rest.client.ServiceCaller; | ||
9 | +import com.yoho.core.rest.client.hystrix.AsyncFuture; | ||
10 | +import com.yoho.product.model.ShopsBo; | ||
11 | +import com.yoho.product.request.BatchBaseRequest; | ||
12 | +import com.yoho.service.model.resource.request.RecommendReqVO; | ||
13 | +import org.slf4j.Logger; | ||
14 | +import org.slf4j.LoggerFactory; | ||
15 | +import org.springframework.beans.factory.annotation.Autowired; | ||
16 | +import org.springframework.stereotype.Component; | ||
17 | + | ||
18 | +import javax.annotation.PostConstruct; | ||
19 | +import java.util.List; | ||
20 | +import java.util.concurrent.TimeUnit; | ||
21 | + | ||
22 | +/** | ||
23 | + * Created by oneway.wang on 2017/7/14. | ||
24 | + */ | ||
25 | +@Component | ||
26 | +public class FocusCacheService { | ||
27 | + private static final Logger LOGGER = LoggerFactory.getLogger(FocusCacheService.class); | ||
28 | + | ||
29 | + private LocalCache localCache = new LocalCache(); | ||
30 | + @Autowired | ||
31 | + private ServiceCaller serviceCaller; | ||
32 | + | ||
33 | + private static final String REC_POS = "100047"; | ||
34 | + //存储JSON格式,存在转义问题,修改为String | ||
35 | + @PostConstruct | ||
36 | + private void init() { | ||
37 | + localCache.init("focus Cache", ExpireTime.RESOURCES_LOCAL_CACHE, TimeUnit.HOURS, new LocalCacheCallback() { | ||
38 | + @Override | ||
39 | + public Object load(String key, Object oldValue) throws Exception { | ||
40 | + RecommendReqVO recommendReqVO = new RecommendReqVO(); | ||
41 | + recommendReqVO.setUid(0); | ||
42 | + recommendReqVO.setChannelId(Integer.parseInt(key)); | ||
43 | + recommendReqVO.setRec_pos(REC_POS); | ||
44 | + JSONObject result = null; | ||
45 | + result = serviceCaller.call("bigdata.getFocusShop", recommendReqVO, JSONObject.class); | ||
46 | + if (result != null && result.getIntValue("code") == 200) { | ||
47 | + return result; | ||
48 | + } | ||
49 | + return null; | ||
50 | + } | ||
51 | + }); | ||
52 | + } | ||
53 | + | ||
54 | + public JSONObject getData(int cid){ | ||
55 | + JSONObject result = (JSONObject) localCache.get(String.valueOf(cid)); | ||
56 | + return result; | ||
57 | + } | ||
58 | + | ||
59 | +} |
1 | package com.yohoufo.resource.service.impl.resource; | 1 | package com.yohoufo.resource.service.impl.resource; |
2 | 2 | ||
3 | -import java.io.Serializable; | ||
4 | - | 3 | +import com.alibaba.fastjson.JSON; |
4 | +import com.alibaba.fastjson.JSONArray; | ||
5 | +import com.alibaba.fastjson.JSONObject; | ||
6 | +import com.yoho.core.common.utils.URIBuilder; | ||
7 | +import com.yoho.core.rest.client.ServiceCaller; | ||
8 | +import com.yoho.product.model.ShopActivityInfoBo; | ||
9 | +import com.yoho.product.request.ShopsFocusRequest; | ||
10 | +import com.yoho.service.model.resource.request.RecommendReqVO; | ||
11 | +import com.yoho.service.model.resource.resource.FocusParsedResource; | ||
12 | +import com.yohoufo.common.redis.NoSyncGracefulRedisTemplate; | ||
13 | +import com.yohoufo.resource.helper.MakeUrlService; | ||
14 | +import com.yohoufo.resource.service.IResourceParse; | ||
15 | +import com.yohoufo.resource.service.Resource; | ||
16 | +import com.yohoufo.resource.service.impl.cache.ExpireTime; | ||
17 | +import com.yohoufo.resource.service.impl.cache.FocusCacheService; | ||
18 | +import com.yohoufo.resource.util.JSONConvert; | ||
19 | +import com.yohoufo.resource.util.ResourcesKeyBuilder; | ||
5 | import org.slf4j.Logger; | 20 | import org.slf4j.Logger; |
6 | import org.slf4j.LoggerFactory; | 21 | import org.slf4j.LoggerFactory; |
7 | import org.springframework.beans.factory.annotation.Autowired; | 22 | import org.springframework.beans.factory.annotation.Autowired; |
8 | import org.springframework.stereotype.Service; | 23 | import org.springframework.stereotype.Service; |
24 | +import org.springframework.util.StringUtils; | ||
9 | 25 | ||
10 | -import com.alibaba.fastjson.JSONObject; | ||
11 | -import com.yohoufo.resource.helper.MakeUrlService; | ||
12 | -import com.yohoufo.resource.service.IResourceParse; | ||
13 | -import com.yohoufo.resource.service.Resource; | 26 | +import java.util.ArrayList; |
27 | +import java.util.Collections; | ||
28 | +import java.util.List; | ||
14 | 29 | ||
15 | /** | 30 | /** |
16 | - * Created by wangwei on 2016/11/8. | 31 | + * 处理焦点图数据 |
17 | */ | 32 | */ |
18 | @Service | 33 | @Service |
19 | -public class FocusResourceParse implements IResourceParse{ | 34 | +public class FocusResourceParse implements IResourceParse { |
35 | + | ||
36 | + @javax.annotation.Resource | ||
37 | + private MakeUrlService makeUrlService; | ||
20 | 38 | ||
21 | - private static final Logger logger = LoggerFactory.getLogger(FocusResourceParse.class); | 39 | + private static final String REC_POS = "100047"; |
22 | 40 | ||
23 | - public static final String TEMPLATE_NAME="focus"; | 41 | + @javax.annotation.Resource(name="NoSyncGracefulRedisTemplate") |
42 | + private NoSyncGracefulRedisTemplate resourcesRedisCache; | ||
24 | 43 | ||
25 | @Autowired | 44 | @Autowired |
26 | - private MakeUrlService makeUrlService; | 45 | + private ServiceCaller serviceCaller; |
46 | + @Autowired | ||
47 | + private FocusCacheService focusCacheService; | ||
48 | + | ||
49 | + Logger logger = LoggerFactory.getLogger(this.getClass()); | ||
27 | 50 | ||
28 | - @Override | ||
29 | - public Serializable parse(Resource resource) { | ||
30 | - try { | ||
31 | - return parseData(resource); | ||
32 | - } catch (Exception e) { | ||
33 | - logger.warn("Parse focus resource fail, resource code [{}] exception: {}", resource.getCode(), e); | ||
34 | - return resource.getData(); | 51 | + public FocusParsedResource parse(Resource resource) { |
52 | + int uid = resource.getUid()==null?0:resource.getUid(); | ||
53 | + String udid = resource.getUdid(); | ||
54 | + String clientType = resource.getClientType(); | ||
55 | + int channel; | ||
56 | + if(resource.getGender()==null||resource.getGender().equals("1,3")){ | ||
57 | + channel = 1; | ||
58 | + }else { | ||
59 | + channel = 2; | ||
35 | } | 60 | } |
61 | + FocusParsedResource parsedResource = new FocusParsedResource(); | ||
62 | + if(getRecommendSize(resource.getData().getJSONObject("data"))>0){ | ||
63 | + parsedResource.setOriginalTemplateId(resource.getOriginalId()); | ||
64 | + } | ||
65 | + parsedResource.setTemplateId(resource.getId().toString()); | ||
66 | + parsedResource.setFocusType(resource.getData().getString("focus_type")); | ||
67 | + parsedResource.setTemplateIntro(resource.getData().getString("template_intro")); | ||
68 | + parsedResource.setData(parseData(resource.getData().getJSONObject("data"), resource.getClientType(),channel,uid,udid,clientType)); | ||
69 | + String isNewFocus = StringUtils.isEmpty(resource.getData().getString("isNewFocus"))?"":resource.getData().getString("isNewFocus"); | ||
70 | + parsedResource.setTemplateName(isNewFocus.equals("1")?"newFocus":"focus"); | ||
71 | + return parsedResource; | ||
36 | } | 72 | } |
37 | 73 | ||
74 | + private List<FocusParsedResource.Data> parseData(JSONObject data, String clientTpe,int channel,int uid,String udid,String clientType) { | ||
75 | + if (data == null) { | ||
76 | + return Collections.emptyList(); | ||
77 | + } | ||
78 | + List<FocusParsedResource.Data> parsedResourceDataList = new ArrayList<>(); | ||
79 | + JSONArray dataArray = JSONConvert.transform2JSONArray(data); | ||
80 | + int recommendSize = getRecommendSize(data); | ||
81 | + if(recommendSize>0) { | ||
82 | + JSONArray shopArray = buildShopInfo(getRecommendShopIds(channel, uid, udid),channel); | ||
83 | + for (Object obj : dataArray) { | ||
84 | + if (obj instanceof JSONObject) { | ||
85 | + JSONObject val = (JSONObject) obj; | ||
86 | + FocusParsedResource.Data tmp = new FocusParsedResource.Data(); | ||
87 | + if (val.getInteger("isFocusRec") != null && val.getIntValue("isFocusRec") == 1 && shopArray.size() > 0) { | ||
88 | + JSONObject shopInfo = (JSONObject) shopArray.get(0); | ||
89 | + String src = shopInfo.getString("focusUrl"); | ||
90 | + String url; | ||
91 | + //如果不能获取链接,参数拼接 | ||
92 | + if(StringUtils.isEmpty(shopInfo.getString("url"))){ | ||
93 | + url = makeShopUrl(shopInfo.getInteger("shopsId"), clientType, shopInfo.getString("shopName"), shopInfo.getString("shopTemplateType"), shopInfo.getString("isRedShop")); | ||
94 | + }else{ | ||
95 | + url = shopInfo.getString("url"); | ||
96 | + } | ||
38 | 97 | ||
39 | - private JSONObject parseData(Resource resource) { | 98 | + if(StringUtils.isEmpty(src)||StringUtils.isEmpty(url)){ |
99 | + tmp.setSrc(val.getString("src")); | ||
100 | + tmp.setUrl(makeUrlService.makeUrl(val.getJSONObject("url"), clientTpe)); | ||
101 | + tmp.setTitle(val.getString("alt")); | ||
102 | + if (val.containsKey("bgColor")) { | ||
103 | + tmp.setBgColor(val.getString("bgColor")); | ||
104 | + } | ||
105 | + }else{ | ||
106 | + //推荐店铺增加标识用于大数据统计 | ||
107 | + tmp.setIsFocusRec("1"); | ||
108 | + tmp.setSrc(src + "?imageView2/{mode}/w/{width}/h/{height}"); | ||
109 | + tmp.setUrl(url); | ||
110 | + } | ||
40 | 111 | ||
41 | - JSONObject returnJSON=new JSONObject(); | ||
42 | - //加入最基础的东西 | ||
43 | - returnJSON.put("template_id",resource.getId().toString()); | ||
44 | - returnJSON.put("template_name",this.TEMPLATE_NAME); | ||
45 | - returnJSON.put("template_intro",resource.getData().getString("template_intro")); | 112 | + logger.info("shopInfo:url={},src={}", url, shopInfo.getString("focusUrl")); |
113 | + shopArray.remove(shopInfo); | ||
114 | + } else { | ||
115 | + tmp.setSrc(val.getString("src")); | ||
116 | + tmp.setUrl(makeUrlService.makeUrl(val.getJSONObject("url"), clientTpe)); | ||
117 | + tmp.setTitle(val.getString("alt")); | ||
118 | + if (val.containsKey("bgColor")) { | ||
119 | + tmp.setBgColor(val.getString("bgColor")); | ||
120 | + } | ||
121 | + } | ||
122 | + parsedResourceDataList.add(tmp); | ||
123 | + } | ||
124 | + } | ||
125 | + }else{ | ||
126 | + for(Object obj : dataArray){ | ||
127 | + if (obj instanceof JSONObject) { | ||
128 | + JSONObject val = (JSONObject) obj; | ||
129 | + FocusParsedResource.Data tmp = new FocusParsedResource.Data(); | ||
130 | + tmp.setSrc(val.getString("src")); | ||
131 | + tmp.setUrl(makeUrlService.makeUrl(val.getJSONObject("url"), clientTpe)); | ||
46 | 132 | ||
47 | - // 处理 data(充分利用原数据库中数据转成的JSONObject,只是遍历之后把URLObject替换成解析之后的数据) | ||
48 | - JSONObject data = resource.getData().getJSONObject("data"); | ||
49 | - for (String index: data.keySet()) { | ||
50 | - makeUrl(data.getJSONObject(index), resource.getClientType()); | 133 | + tmp.setTitle(val.getString("alt")); |
134 | + if (val.containsKey("bgColor")) { | ||
135 | + tmp.setBgColor(val.getString("bgColor")); | ||
136 | + } | ||
137 | + parsedResourceDataList.add(tmp); | ||
138 | + } | ||
139 | + } | ||
51 | } | 140 | } |
52 | - returnJSON.put("data",data); | ||
53 | - return returnJSON; | 141 | + return parsedResourceDataList; |
54 | } | 142 | } |
55 | 143 | ||
56 | - private void makeUrl(JSONObject jsonElement, String clientType) { | ||
57 | - JSONObject jsonUrl = jsonElement.getJSONObject("url"); | ||
58 | - String strUrl = makeUrlService.makeUrl(jsonUrl, clientType); | ||
59 | - jsonElement.put("url", strUrl); | 144 | + private int getRecommendSize(JSONObject data) { |
145 | + JSONArray dataArray = JSONConvert.transform2JSONArray(data); | ||
146 | + int recommendSize = 0; | ||
147 | + for(Object obj : dataArray){ | ||
148 | + if (obj instanceof JSONObject) { | ||
149 | + JSONObject val = (JSONObject) obj; | ||
150 | + //FocusParsedResource.Data tmp = new FocusParsedResource.Data(); | ||
151 | + if(val.getInteger("isFocusRec")!=null&&val.getIntValue("isFocusRec")==1){ | ||
152 | + recommendSize++; | ||
153 | + } | ||
154 | + } | ||
155 | + } | ||
156 | + return recommendSize; | ||
157 | + } | ||
158 | + | ||
159 | + | ||
160 | + private List<Integer> getRecommendShopIds(int cId,Integer uid,String udid){ | ||
161 | + if(uid==null){ | ||
162 | + uid = 0; | ||
163 | + } | ||
164 | + RecommendReqVO recommendReqVO = new RecommendReqVO(); | ||
165 | + recommendReqVO.setUid(uid); | ||
166 | + recommendReqVO.setChannelId(cId); | ||
167 | + recommendReqVO.setRec_pos(REC_POS); | ||
168 | + recommendReqVO.setUdid(udid); | ||
169 | + JSONObject result = null; | ||
170 | + try{ | ||
171 | + logger.info("getFromBigData,uid={},cId={}",uid,cId); | ||
172 | + //查询缓存 | ||
173 | + result = resourcesRedisCache.get(ResourcesKeyBuilder.generateFocusRecKey(REC_POS,uid,cId,udid),JSONObject.class); | ||
174 | + if(result==null){ | ||
175 | + result = serviceCaller.call("bigdata.getFocusShop", recommendReqVO, JSONObject.class); | ||
176 | + if (result == null || result.getIntValue("code") == 505) { | ||
177 | + //大数据调用失败 | ||
178 | + result = getBackupCache(cId); | ||
179 | + }else if (result != null && result.getIntValue("code") == 200) { | ||
180 | + // 大数据调用成功,刷新一、二级缓存 | ||
181 | + resourcesRedisCache.setEx(ResourcesKeyBuilder.generateFocusRecKey(REC_POS,uid,cId,udid),result, ExpireTime.FOCUS_CACHE); | ||
182 | + getBackupCache(cId); | ||
183 | + } | ||
184 | + } | ||
185 | + | ||
186 | + }catch(Exception e){ | ||
187 | + //查询二级缓存 | ||
188 | + result = getBackupCache(cId); | ||
189 | + } | ||
190 | + return getArrayFromJSON(result); | ||
191 | + } | ||
192 | + | ||
193 | + //二级缓存 | ||
194 | + private JSONObject getBackupCache(int cid){ | ||
195 | + JSONObject result = focusCacheService.getData(cid); | ||
196 | + logger.info("invoke backupCache,cid={},result={}",cid,result); | ||
197 | + return result; | ||
198 | + } | ||
199 | + private List<Integer> getArrayFromJSON(JSONObject result){ | ||
200 | + List<Integer> shopRecommendArray = new ArrayList<>(); | ||
201 | + JSONArray jsonArray = new JSONArray(); | ||
202 | + jsonArray = JSON.parseArray(result.getString("data")); | ||
203 | + //组织返回 | ||
204 | + shopRecommendArray = JSON.parseObject(jsonArray.toString(), List.class); | ||
205 | + return shopRecommendArray; | ||
206 | + } | ||
207 | + | ||
208 | + | ||
209 | + //根据店铺id获取店铺url | ||
210 | + private String makeShopUrl(Integer shopId,String clientType,String shopName,String shopTemplateType,String isRedShop){ | ||
211 | + URIBuilder uriBuilder = new URIBuilder("https://m.yohobuy.com"); | ||
212 | + JSONObject jsonUrl = new JSONObject(); | ||
213 | +// http://m.yohobuy.com?openby:yohobuy= | ||
214 | +// {\"action\":\"go.shop\",\"params\":{\"shop_id\":\"%zd\", \"shop_template_type\":\"%@\", \"shop_name\":\"%@\", \"is_red_shop\":\"%zd\"} | ||
215 | + uriBuilder.addParameter("shop_id",String.valueOf(shopId)); | ||
216 | + uriBuilder.addParameter("shop_name",shopName); | ||
217 | + uriBuilder.addParameter("shop_template_type",shopTemplateType); | ||
218 | + uriBuilder.addParameter("is_red_shop",isRedShop); | ||
219 | + jsonUrl.put("action",makeUrlService.SHOP_ACTION); | ||
220 | + String url = uriBuilder.build(); | ||
221 | + jsonUrl.put("url",url); | ||
222 | + return makeUrlService.makeUrl(jsonUrl, clientType,""); | ||
223 | + } | ||
224 | + //查询店铺信息 | ||
225 | + private JSONArray buildShopInfo( List<Integer> shopIdList,int channel) { | ||
226 | + JSONArray shopArray = resourcesRedisCache.get(ResourcesKeyBuilder.generateFocusShopInfoKey(shopIdList),JSONArray.class); | ||
227 | + if(shopArray==null||shopArray.size()==0){ | ||
228 | + Integer appType = 0;//默认yoho app | ||
229 | + ShopsFocusRequest shopRequest = new ShopsFocusRequest(); | ||
230 | + shopRequest.setShopIdList(shopIdList); | ||
231 | + shopRequest.setChannel(channel); | ||
232 | + shopRequest.setAppType(appType);//默认yoho app | ||
233 | + ShopActivityInfoBo[] shopList = serviceCaller.asyncCall("product.queryShopFocusIntroList", shopRequest, ShopActivityInfoBo[].class).get(3); | ||
234 | + shopArray = new JSONArray(); | ||
235 | + for(ShopActivityInfoBo shopsBo:shopList){ | ||
236 | + JSONObject jsonObject = new JSONObject(); | ||
237 | + jsonObject.put("isRedShop",shopsBo.getIsRedShop()); | ||
238 | + jsonObject.put("shopTemplateType",shopsBo.getShopTemplateType()); | ||
239 | + jsonObject.put("shopsId",shopsBo.getShopsId()); | ||
240 | + jsonObject.put("shopName",shopsBo.getShopName()); | ||
241 | + jsonObject.put("focusUrl",shopsBo.getFocusUrl()); | ||
242 | + //6.5添加的链接地址 | ||
243 | + jsonObject.put("url",shopsBo.getUrl()); | ||
244 | + shopArray.add(jsonObject); | ||
245 | + } | ||
246 | + resourcesRedisCache.setEx(ResourcesKeyBuilder.generateFocusShopInfoKey(shopIdList),shopArray,ExpireTime.FOCUS_CACHE); | ||
247 | + } | ||
248 | + return shopArray; | ||
60 | } | 249 | } |
61 | } | 250 | } |
@@ -44,6 +44,9 @@ public class HotSeriesResourceParse implements IResourceParse{ | @@ -44,6 +44,9 @@ public class HotSeriesResourceParse implements IResourceParse{ | ||
44 | returnJSON.put("template_name",this.TEMPLATE_NAME); | 44 | returnJSON.put("template_name",this.TEMPLATE_NAME); |
45 | returnJSON.put("template_intro",resource.getData().getString("template_intro")); | 45 | returnJSON.put("template_intro",resource.getData().getString("template_intro")); |
46 | 46 | ||
47 | + JSONObject moreUrl = resource.getData().getJSONObject("more_url"); | ||
48 | + returnJSON.put("more_url", makeMoreUrl(moreUrl,resource.getClientType())); | ||
49 | + | ||
47 | // 处理 data(充分利用原数据库中数据转成的JSONObject,只是遍历之后把URLObject替换成解析之后的数据) | 50 | // 处理 data(充分利用原数据库中数据转成的JSONObject,只是遍历之后把URLObject替换成解析之后的数据) |
48 | JSONObject data = resource.getData().getJSONObject("data"); | 51 | JSONObject data = resource.getData().getJSONObject("data"); |
49 | for (String index: data.keySet()) { | 52 | for (String index: data.keySet()) { |
@@ -58,4 +61,9 @@ public class HotSeriesResourceParse implements IResourceParse{ | @@ -58,4 +61,9 @@ public class HotSeriesResourceParse implements IResourceParse{ | ||
58 | String strUrl = makeUrlService.makeUrl(jsonUrl, clientType); | 61 | String strUrl = makeUrlService.makeUrl(jsonUrl, clientType); |
59 | jsonElement.put("url", strUrl); | 62 | jsonElement.put("url", strUrl); |
60 | } | 63 | } |
64 | + | ||
65 | + private String makeMoreUrl(JSONObject jsonUrl, String clientType) { | ||
66 | + String strUrl = makeUrlService.makeUrl(jsonUrl, clientType,""); | ||
67 | + return strUrl; | ||
68 | + } | ||
61 | } | 69 | } |
@@ -48,7 +48,7 @@ uic.service.url=http://192.168.103.73:8096/uic | @@ -48,7 +48,7 @@ uic.service.url=http://192.168.103.73:8096/uic | ||
48 | 48 | ||
49 | #signature encrypt key salt | 49 | #signature encrypt key salt |
50 | gateway.signature.key.salt=mQyMTMwZjlmZTZmYjY4UjkNmYwZGM0OTk0Y | 50 | gateway.signature.key.salt=mQyMTMwZjlmZTZmYjY4UjkNmYwZGM0OTk0Y |
51 | -trace.enabled=true | 51 | +trace.enabled=false |
52 | 52 | ||
53 | # yoho api docs | 53 | # yoho api docs |
54 | yoho.api.docs.switch=off | 54 | yoho.api.docs.switch=off |
@@ -74,3 +74,10 @@ unionpay.pay.mid=898310148160568 | @@ -74,3 +74,10 @@ unionpay.pay.mid=898310148160568 | ||
74 | unionpay.pay.tid=00000001 | 74 | unionpay.pay.tid=00000001 |
75 | unionPay.pay.signKey=fcAmtnx7MwismjWNhNKdHC44mNXtnEQeJkRrhKJwyrW2ysRR | 75 | unionPay.pay.signKey=fcAmtnx7MwismjWNhNKdHC44mNXtnEQeJkRrhKJwyrW2ysRR |
76 | 76 | ||
77 | + | ||
78 | +redis.readonly.proxy.address=192.168.102.45 | ||
79 | +redis.readonly.proxy.auth=redis9646 | ||
80 | +redis.readonly.proxy.port=6379 | ||
81 | +redis.proxy.address=192.168.102.45 | ||
82 | +redis.proxy.auth=redis9646 | ||
83 | +redis.proxy.port=6379 |
-
Please register or login to post a comment