Showing
1 changed file
with
34 additions
and
34 deletions
1 | 查询购物车接口业务逻辑 | 1 | 查询购物车接口业务逻辑 |
2 | ------ | 2 | ------ |
3 | -## 一、入口和返回\n | ||
4 | -### 1.入口\n | ||
5 | -method=app.Shopping.add,参数:uid、sale_channel、shopping_key,皆非必选参数,通常传uid或shopping_key\n | ||
6 | -postman调用示例:\n | ||
7 | -http://192.168.102.205:8080/gateway?method=app.Shopping.cart&uid=8041834&debug=XYZ\n | ||
8 | -该接口由类com.yoho.gateway.controller.order.shopping的cart方法实现,\n | ||
9 | -@RequestMapping(params = "method=app.Shopping.cart")\n | ||
10 | -@ResponseBody\n | ||
11 | -public ApiResponse cart(HttpServletRequest httpServletRequest,\n | ||
12 | - @RequestParam(value = "sale_channel", required = false) String saleChannel,\n | ||
13 | - @RequestParam(value = "uid", required = false) Integer uid,\n | ||
14 | - @RequestParam(value = "shopping_key", required = false) String shoppingKey)\n | ||
15 | -### 2.返回\n | ||
16 | -主要分两类数据,预售商品和普通商品,因这两类数据是分开结算的。每类数据包括:促销信息和结算费用,各商品详情等。\n | ||
17 | -## 二、服务调用\n | ||
18 | -该接口会调用order模块的cartShopping服务,该服务会实现具体的查询业务。而该服务具体执行过程中会调用商品和促销模块的相关服务\n | ||
19 | -##三、具体实现逻辑\n | ||
20 | -1.进入gateway模块的com.yoho.gateway.controller.order.shopping.cart()方法\n | ||
21 | -2.cart方法调用order.cartShopping服务\n | ||
22 | -3.进入order模块的com.yoho.yhorder.shopping.restapi.ShoppingCartController.query()方法,该方法提供order.cartShopping服务\n | ||
23 | -4.query方法调用com.yoho.yhorder.shopping.service.impl.ShoppingCartServiceImpl.query()方法。\n | ||
24 | -5.再调用com.yoho.yhorder.shopping.service.impl.ShoppingCartQueryService.query()方法,\n | ||
25 | -6.在ShoppingCartQueryService.query()方法中开始进行业务操作,先进行普通商品算费,再进行预售商品算费,然后将两类结果包装到ShoppingQueryResponse中返回。具体如下:\n | ||
26 | -普通商品算费:\n | ||
27 | -1)构建算费参数对象ChargeParam,设置CartType=ORDINARY_CART_TYPE、ChargeType=ORDINARY_CHARGE_TYPE。\n | ||
28 | -2)生成算费上下文ChargeContext ordinaryChargeContext \n | ||
29 | -3)调用ChargerService.charge()进行算费,算费结果在ChargeContext对象的ChargeTotal中\n | ||
30 | -4)从ChargeContext中取出结果信息ShoppingChargeResult ordinaryChargeResult。\n | ||
31 | -预售商品算费:\n | ||
32 | -1)生成预售商品算费上下文ChargeContext preSaleChargeContext\n | ||
33 | -2)构建预售商品算费对象(CartType=PRESALE_CART_TYPE、ChargeType=ADVANCE_CHARGE_TYPE)并设置到上下文preSaleChargeContext中,同时将商品列表(从ordinaryChargeContext获取)和用户信息保存上下文中。\n | ||
34 | -3)调用ChargerService.charge()进行算费。\n | ||
35 | -4)从preSaleChargeContext取出结果信息ShoppingChargeResult preSaleChargeResult\n | ||
36 | -由ordinaryChargeResult和preSaleChargeResult构造结果ShoppingQueryResponse response,并返回。\n | 3 | +## 一、入口和返回 |
4 | +### 1.入口 | ||
5 | + method=app.Shopping.add,参数:uid、sale_channel、shopping_key,皆非必选参数,通常传uid或shopping_key | ||
6 | + postman调用示例: | ||
7 | + http://192.168.102.205:8080/gateway?method=app.Shopping.cart&uid=8041834&debug=XYZ | ||
8 | + 该接口由类com.yoho.gateway.controller.order.shopping的cart方法实现 | ||
9 | + @RequestMapping(params = "method=app.Shopping.cart") | ||
10 | + @ResponseBody | ||
11 | + public ApiResponse cart(HttpServletRequest httpServletRequest,\n | ||
12 | + @RequestParam(value = "sale_channel", required = false) String saleChannel, | ||
13 | + @RequestParam(value = "uid", required = false) Integer uid,\n | ||
14 | + @RequestParam(value = "shopping_key", required = false) String shoppingKey) | ||
15 | +### 2.返回 | ||
16 | + 主要分两类数据,预售商品和普通商品,因这两类数据是分开结算的。每类数据包括:促销信息和结算费用,各商品详情等。 | ||
17 | +## 二、服务调用 | ||
18 | + 该接口会调用order模块的cartShopping服务,该服务会实现具体的查询业务。而该服务具体执行过程中会调用商品和促销模块的相关服务 | ||
19 | +##三、具体实现逻辑 | ||
20 | + 1.进入gateway模块的com.yoho.gateway.controller.order.shopping.cart()方法 | ||
21 | + 2.cart方法调用order.cartShopping服务 | ||
22 | + 3.进入order模块的com.yoho.yhorder.shopping.restapi.ShoppingCartController.query()方法,该方法提供order.cartShopping服务 | ||
23 | + 4.query方法调用com.yoho.yhorder.shopping.service.impl.ShoppingCartServiceImpl.query()方法。 | ||
24 | + 5.再调用com.yoho.yhorder.shopping.service.impl.ShoppingCartQueryService.query()方法, | ||
25 | + 6.在ShoppingCartQueryService.query()方法中开始进行业务操作,先进行普通商品算费,再进行预售商品算费,然后将两类结果包装到ShoppingQueryResponse中返回。具体如下: | ||
26 | + 普通商品算费: | ||
27 | + 1)构建算费参数对象ChargeParam,设置CartType=ORDINARY_CART_TYPE、ChargeType=ORDINARY_CHARGE_TYPE。 | ||
28 | + 2)生成算费上下文ChargeContext ordinaryChargeContext | ||
29 | + 3)调用ChargerService.charge()进行算费,算费结果在ChargeContext对象的ChargeTotal中 | ||
30 | + 4)从ChargeContext中取出结果信息ShoppingChargeResult ordinaryChargeResult。 | ||
31 | + 预售商品算费: | ||
32 | + 1)生成预售商品算费上下文ChargeContext preSaleChargeContext | ||
33 | + 2)构建预售商品算费对象(CartType=PRESALE_CART_TYPE、ChargeType=ADVANCE_CHARGE_TYPE)并设置到上下文preSaleChargeContext中,同时将商品列表(从ordinaryChargeContext获取)和用户信息保存上下文中。\n | ||
34 | + 3)调用ChargerService.charge()进行算费。 | ||
35 | + 4)从preSaleChargeContext取出结果信息ShoppingChargeResult preSaleChargeResult | ||
36 | + 由ordinaryChargeResult和preSaleChargeResult构造结果ShoppingQueryResponse response,并返回。 | ||
37 | 37 | ||
38 | ### 在ShoppingCartQueryService.query()中涉及到两个公共的业务:构建算费上下文和算费。具体实现见后续文档\n | 38 | ### 在ShoppingCartQueryService.query()中涉及到两个公共的业务:构建算费上下文和算费。具体实现见后续文档\n |
-
Please register or login to post a comment