• 测试提效1-电商一键创单的实现


    因电商项目不同场景下单特别多,而走前端流程特别慢。所以在某些测试场景需要特定配送方式 和 特定配送状态数据,本次实现快速创建。

    1、前端页面
    前端页面采用vue ,页面需要的属性或字段,打算包括 环境env、店铺(准备了3种不同模式店铺)、配送方式、状态(基于配送方式)。

    环境和店铺可以融合在一起,因为不同环境我准备了不同店铺id,根据所选店铺,就决定了不同的环境。
    配送方式和状态融合在一起,根据所选在前端代码里处理。
    在这里插入图片描述
    页面元素选用
    下拉选择el-select ,页面数据加载使用的属性,然后通过v-model绑定
    列表使用el-table,数据是在新增后拿到json数据扔到数组里,给table使用

    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48

    vue的属性,方法,计算属性等,都采用vue里的基本方式。
    接口请求进行了封装,基于axios
    我会通过拿到选中的值,进行切割后,入参给后端接口店铺id,商品类型,快递方式、需要的订单状态。 然后后端接口去处理。

    
    
    
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62
    • 63
    • 64
    • 65
    • 66
    • 67
    • 68
    • 69
    • 70
    • 71
    • 72
    • 73
    • 74
    • 75
    • 76
    • 77
    • 78
    • 79
    • 80
    • 81
    • 82
    • 83
    • 84
    • 85
    • 86
    • 87
    • 88
    • 89
    • 90
    • 91
    • 92
    • 93
    • 94
    • 95
    • 96
    • 97
    • 98
    • 99
    • 100
    • 101
    • 102
    • 103
    • 104
    • 105
    • 106
    • 107
    • 108
    • 109
    • 110
    • 111
    • 112
    • 113
    • 114
    • 115
    • 116
    • 117
    • 118

    在路由router里,对此页面按照层级设置好即可。

    {
            path: '/quickcreateOrder/',
            name: 'quickcreateOrder',
            component: () =>
                import ('@/views/quicktools/createOrder'),
            meta: { title: '一键创单' }
        },
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7

    2、后端实现

    创建Controller
    创建CreateOrderController,使用注解@RestController

    参数上是前端入参的,且必要的参数。为了简单点,没使用对象入参,使用了RequestParam注解。

       @RequestMapping(value = "/testPlatormCreateOrder",method = RequestMethod.POST)
        public Resp postTestPlatormCreateOrder(@RequestParam String shopId, @RequestParam String productType, @RequestParam String delivery,@RequestParam String orderStatus)
    
    • 1
    • 2

    组装数据
    不同的店铺或商品类型选择,我需要手动去准备数据。
    主要包括环境和域名,商品id,使用的用户或卖家的token。
    例如:

      if(shopId.equals("xxx")){
    
                    //67137店铺
                    //环境相关的
                    envMap = new HashMap<>();
                    envMap.put("business","xxx");
                    envMap.put("templateId","xxx");
                    envMap.put("order_create_url",qa_specialty_url+"/shoppingCart/createOrder");
                    envMap.put("order_deliver_url",qa_specialty_gw_url+"/shop-gw/order/newgate/order/merchant/send");
                    envMap.put("order_receive_url",qa_specialty_gw_url+"/shop-gw/order/newgate/order/receive/customer");
                    envMap.put("order_writeOff_url",qa_specialty_gw_url+"/shop-gw/order/newgate/order/writeOff/coupon/merchant");
                    envMap.put("token","xxx");
                    envMap.put("cappid","xxx");
                    envMap.put("bappid","xxx");
    
                    //下单相关的
                    orderInfoMap = new HashMap<>();
                    orderInfoMap.put("ownerCookie","SessionToken=xxxx;OpenId=;");
                    orderInfoMap.put("buyerCookie","SessionToken=xxx;OpenId=");
                    orderInfoMap.put("relationId","xxx");
                    orderInfoMap.put("shop_id","xxx");
                    orderInfoMap.put("buyeraddressId","xxx");
                    orderInfoMap.put("selfPickupAddressId","xxx");
                    orderInfoMap.put("buyerphone","xxx");
                    orderInfoMap.put("buyeruserkey","xxx");
                    //实物
                    orderInfoMap.put("materialSpuid","xxx");
                    orderInfoMap.put("materialSkuid","xxx");
                    orderInfoMap.put("materialPrice","0.1");
                    orderInfoMap.put("materialSpuname","不要下架单规格商品");
                    //服务类
                    orderInfoMap.put("serviceSpuid","xxx");
                    orderInfoMap.put("serviceSkuid","xxxx");
                    orderInfoMap.put("servicePrice","0.1");
                    orderInfoMap.put("serviceSpuname","不要下架服务类商品");
                }else if(shopId.equals("1000000001373")){
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36

    使用service调用不同的方法

       if(productType.equals("MATERIAL") && delivery.equals("EXPRESS")){
    
                return createOrderService.materialOrder(envMap,orderInfoMap,"EXPRESS",orderStatus);
    
            }else if(productType.equals("MATERIAL") && delivery.equals("MERCHANT_POST")){
    
                return createOrderService.materialOrder(envMap,orderInfoMap,"MERCHANT_POST",orderStatus);
    
            }else if(productType.equals("MATERIAL") && delivery.equals("SELF_PICKUP")){
    
                return createOrderService.materialOrder(envMap,orderInfoMap,"SELF_PICKUP",orderStatus);
            }else if (productType.equals("SERVICE") && delivery.equals("EXPRESS")){
    
                return  createOrderService.serviceOrder(envMap,orderInfoMap,orderStatus);
            }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15

    Service中实现
    我对于不同的实现方法尽量融合,然后去内部细细划分实现。

    public interface CreateOrderService {
    
     //实物
     public Resp materialOrder(Map envMap, Map orderInfoMap, String delivery, String orderStatus);
    
    //服务类
     public Resp  serviceOrder(Map envMap, Map orderInfoMap, String orderStatus);
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8

    实现类中,根据不同的场景进行组装并判断

    @Service
    public class CreateOrderServiceImpl  implements CreateOrderService{
    
        @Autowired
        public RestUtils requests;
    
    
        //实物订单
        @Override
        public Resp   materialOrder(Map envMap, Map orderInfoMap, String delivery, String orderStatus) {
    
            String order_create_url =  envMap.get("order_create_url");
            String order_deliver_url =  envMap.get("order_deliver_url");
            String order_receive_url = envMap.get("order_receive_url");
    
            String business = envMap.get("business");
            String templateId = envMap.get("templateId");
    
            String shop_id = orderInfoMap.get("shop_id");
            String skuid = orderInfoMap.get("materialSkuid");
            String price = orderInfoMap.get("materialPrice");
    
            //c请求头
            HttpHeaders cHeaders = new HttpHeaders();
            //请求头初始化
            {
                cHeaders.add("actionFrom","C");
                cHeaders.add("appid", envMap.get("cappid"));
                cHeaders.add("cookie",orderInfoMap.get("buyerCookie"));
                cHeaders.add("content-type","application/json");
                cHeaders.add("token", envMap.get("token"));
                cHeaders.add("traceSource", "traceSource");
                cHeaders.add("AuthVersion","V2");
                cHeaders.add("business",business);
            }
    
            //b请求头
            HttpHeaders bHeaders = new HttpHeaders();
            {
                bHeaders.add("actionFrom","B");
                bHeaders.add("appid", envMap.get("bappid"));
                bHeaders.add("cookie",orderInfoMap.get("ownerCookie"));
                bHeaders.add("content-type","application/json");
                bHeaders.add("token", envMap.get("token"));
                bHeaders.add("traceSource", "traceSource");
                bHeaders.add("AuthVersion","V2");
                bHeaders.add("business", business);
                bHeaders.add("relationId",orderInfoMap.get("relationId"));
    
            }
    
            //c入参json
            JSONObject cParams = new JSONObject();
            //入参初始化
            {
                cParams.put("business",business);
                cParams.put("templateId",templateId);
                cParams.put("settleProductTypeEnum","MATERIAL");
                cParams.put("phoneNum",orderInfoMap.get("buyerphone"));
                cParams.put("allShopSkuAmount",0);
                cParams.put("allShopSkuCount",1);
                cParams.put("allShopSkuDiscountAmount",0);
                cParams.put("allShopSkuShippingFee",0);
                cParams.put("createOrderOriginEnum","FROM_PRODUCT_PAGE");
                cParams.put("reservationDate","");
                cParams.put("allShopSkuPointsAmount",0);
                cParams.put("yeePayChannel","WECHAT");
                cParams.put("requiredFundType",0);
                cParams.put("sourceChannelEnum","MINI_APP");
    
                //自提的走自提点地址
                String addressId = delivery.equals("SELF_PICKUP")? orderInfoMap.get("selfPickupAddressId"):orderInfoMap.get("buyeraddressId");
                cParams.put("addressId",addressId);
    
                JSONObject sku = new JSONObject();
                sku.put("count",1);
                sku.put("skuId",skuid);
                JSONArray skuList = new JSONArray();
                skuList.add(sku);
    
                JSONObject orderDelivery = new JSONObject();
                orderDelivery.put("selected",true);
    
               if(delivery.equals("EXPRESS")){
    
                   orderDelivery.put("shipDesc","快递配送");
                   orderDelivery.put("shipType","EXPRESS");
    
               }else if (delivery.equals("MERCHANT_POST")){
    
                   orderDelivery.put("shipDesc","商家配送");
                   orderDelivery.put("shipType","MERCHANT_POST");
    
               }else if(delivery.equals("SELF_PICKUP")){
    
                   orderDelivery.put("shipDesc","买家自提");
                   orderDelivery.put("shipType","SELF_PICKUP");
    
                   cParams.put("reservedPhone",orderInfoMap.get("buyerphone"));
                   //自提订单的时间
                   String selfPickupDate = new SimpleDateFormat("YYYY-MM-dd").format(new Date());
                   JSONArray selfPickupHour = new JSONArray();
                   selfPickupHour.add("09:00");
                   selfPickupHour.add("17:00");
                   cParams.put("selfPickupDate",selfPickupDate);
                   cParams.put("selfPickupHour",selfPickupHour);
                   cParams.put("selfPickUsername","买家提货人");
    
    
               }
    
                JSONArray appendInfoReqList = new JSONArray();
    
                JSONObject confirmOrderShopBalance = new JSONObject();
                confirmOrderShopBalance.put("confirmOrderUseBalance",true);
                confirmOrderShopBalance.put("confirmOrderUseBalanceAmount",price);
    
                JSONObject ownerShopInfoList1 = new JSONObject();
                ownerShopInfoList1.put("confirmOrderShopCoupon",null);
                ownerShopInfoList1.put("confirmOrderShopDeduction",null);
                ownerShopInfoList1.put("orderDelivery",orderDelivery);
                ownerShopInfoList1.put("itemBelongShopId",shop_id);
                ownerShopInfoList1.put("remark","wjw测试平台快捷创单,备注信息");
                ownerShopInfoList1.put("skuList",skuList);
                ownerShopInfoList1.put("appendInfoReqList",appendInfoReqList);
                ownerShopInfoList1.put("confirmOrderShopBalance",confirmOrderShopBalance);
    
                JSONArray ownerShopInfoList = new JSONArray();
                ownerShopInfoList.add(ownerShopInfoList1);
    
                JSONObject shopInfoList1 = new JSONObject();
                shopInfoList1.put("shopId",orderInfoMap.get("shop_id"));
                shopInfoList1.put("ownerShopInfoList",ownerShopInfoList);
    
                JSONArray shopInfoList = new JSONArray();
                shopInfoList.add(shopInfoList1);
    
                cParams.put("shopInfoList",shopInfoList);
            }
    
    
            if(orderStatus.equals("WAIT_SEND")){
                //买家创单
                JSONObject orderObj = buyerCreateMaterialOrder(orderInfoMap,cHeaders,cParams,delivery,order_create_url);
                orderObj.put("status","待发货");
    
                return RespUtil.success(orderObj);
    
            }else if(orderStatus.equals("WAIT_RECEIVE")){
                //买家创单
                JSONObject orderObj = buyerCreateMaterialOrder(orderInfoMap,cHeaders,cParams,delivery,order_create_url);
               //店主发货
                sellerSend(business,templateId,orderObj.getString("subOrderNo"),bHeaders,order_deliver_url,delivery);
    
                orderObj.put("status",delivery.equals("SELF_PICKUP") ? "待自提":"待收货");
    
                return RespUtil.success(orderObj);
    
            }else if(orderStatus.equals("FINISHED")){
                //买家创单
                JSONObject orderObj = buyerCreateMaterialOrder(orderInfoMap,cHeaders,cParams,delivery,order_create_url);
                //店主发货
                sellerSend(business,templateId,orderObj.getString("subOrderNo"),bHeaders,order_deliver_url,"EXPRESS");
                //买家收货
                buyerReceive(business,templateId,orderObj.getString("subOrderNo"),cHeaders,order_receive_url);
                orderObj.put("status","订单完成");
    
                return RespUtil.success(orderObj);
            }
    
    
            return RespUtil.error(CodeEnum.RESPONSE_ERROR_PARAMS_MISS,"参数[CreateOrderServiceImpl+expressOrder]所属模块缺失");
        }
    
    
        //买家创快递单
        public JSONObject buyerCreateMaterialOrder(Map orderInfoMap, HttpHeaders cHeaders, JSONObject cParams, String delivery, String order_create_url){
    
    
            System.out.println("========================================准备请求============================================================");
            System.out.println("【请求url】======="+ order_create_url);
            System.out.println("【请求参数】======="+ ContentUtil.JsonPrint(cParams));
            System.out.println("【请求头】======="+ cHeaders);
    
            //发起请求
            ResEntity resEntity = requests.postForResEntity(order_create_url,cHeaders,cParams);
            //结果
            JSONObject result = resEntity.getBody();
            Assert.assertEquals(200,resEntity.getCode());
            Assert.assertEquals(0,Integer.parseInt(result.get("code").toString()));
    
            System.out.println("========================================响应结果============================================================");
            System.out.println("【响应结果】======="+ result);
    
            //组装响应
            JSONObject orderObj = new JSONObject();
            orderObj.put("shopid",orderInfoMap.get("shop_id"));
            orderObj.put("buyeruserkey",orderInfoMap.get("buyeruserkey"));
            orderObj.put("spuid",orderInfoMap.get("materialSpuid"));
            orderObj.put("skuid",orderInfoMap.get("materialSkuid"));
            orderObj.put("price",orderInfoMap.get("materialPrice"));
            orderObj.put("spuname",orderInfoMap.get("materialSpuname"));
            orderObj.put("mainOrderNo",result.getJSONObject("data").getString("orderNo"));
            orderObj.put("subOrderNo",result.getJSONObject("data").getJSONArray("subOrderNos").get(0));
    
            if(delivery.equals("EXPRESS")){
                orderObj.put("delivery","实物-快递");
            }else if (delivery.equals("MERCHANT_POST")) {
                orderObj.put("delivery","实物-商家配送");
            }else if (delivery.equals("SELF_PICKUP") ){
                orderObj.put("delivery","实物-自提");
            }
            return orderObj;
        }
    
    
        //卖家发货
        public void sellerSend(String business,String templateId,String subOrderNo,HttpHeaders bHeaders,String order_deliver_url,String delivery){
    
            //入参json
            JSONObject bParams = new JSONObject();
            {
               if(delivery.equals("EXPRESS")){
                   JSONArray logisticsNoList = new JSONArray();
                   JSONObject logisticsNo = new JSONObject();
                   logisticsNo.put("logisticsCompany","EMS");
                   logisticsNo.put("logisticsNo","123456");
                   logisticsNoList.add(logisticsNo);
                   bParams.put("logisticsNoList",logisticsNoList);
               }
    
                bParams.put("actionFrom","B");
                bParams.put("business",business);
                bParams.put("templateId",templateId);
                bParams.put("orderNo",subOrderNo);
            }
    
            System.out.println("========================================准备请求============================================================");
            System.out.println("【请求url】======="+ order_deliver_url);
            System.out.println("【请求参数】======="+ ContentUtil.JsonPrint(bParams));
            System.out.println("【请求头】======="+ bHeaders);
    
            //发起请求
            ResEntity resEntity = requests.postForResEntity(order_deliver_url,bHeaders,bParams);
    
            //结果
            JSONObject result = resEntity.getBody();
            Assert.assertEquals(200,resEntity.getCode());
            Assert.assertEquals(0,Integer.parseInt(result.get("code").toString()));
            System.out.println("========================================响应结果============================================================");
            System.out.println("【响应结果】======="+ result);
        }
    
        //买家收货
        public void buyerReceive(String business,String templateId,String subOrderNo,HttpHeaders cHeaders,String order_receive_url){
    
            //入参json
            JSONObject cParams = new JSONObject();
            {
                cParams.put("cancelReason","");
                cParams.put("business",business);
                cParams.put("templateId",templateId);
                cParams.put("orderNo",subOrderNo);
            }
    
            System.out.println("========================================准备请求============================================================");
            System.out.println("【请求url】======="+ order_receive_url);
            System.out.println("【请求参数】======="+ ContentUtil.JsonPrint(cParams));
            System.out.println("【请求头】======="+ cHeaders);
    
            //发起请求
            ResEntity resEntity = requests.postForResEntity(order_receive_url,cHeaders,cParams);
    
            //结果
            JSONObject result = resEntity.getBody();
            Assert.assertEquals(200,resEntity.getCode());
            Assert.assertEquals(0,Integer.parseInt(result.get("code").toString()));
            System.out.println("========================================响应结果============================================================");
            System.out.println("【响应结果】======="+ result);
        }
    
    
        //服务类订单
        @Override
        public Resp serviceOrder( Map envMap, Map orderInfoMap, String orderStatus) {
    
            String order_create_url =  envMap.get("order_create_url");
    
            String business = envMap.get("business");
            String templateId = envMap.get("templateId");
    
            String shop_id = orderInfoMap.get("shop_id");
            String skuid = orderInfoMap.get("serviceSkuid");
            String price = orderInfoMap.get("servicePrice");
    
            //c请求头
            HttpHeaders cHeaders = new HttpHeaders();
            //请求头初始化
            {
                cHeaders.add("actionFrom","C");
                cHeaders.add("appid", envMap.get("cappid"));
                cHeaders.add("cookie",orderInfoMap.get("buyerCookie"));
                cHeaders.add("content-type","application/json");
                cHeaders.add("token", envMap.get("token"));
                cHeaders.add("traceSource", "traceSource");
                cHeaders.add("AuthVersion","V2");
                cHeaders.add("business",business);
            }
    
            //b请求头
            HttpHeaders bHeaders = new HttpHeaders();
            {
                bHeaders.add("actionFrom","B");
                bHeaders.add("appid", envMap.get("bappid"));
                bHeaders.add("cookie",orderInfoMap.get("ownerCookie"));
                bHeaders.add("content-type","application/json");
                bHeaders.add("token", envMap.get("token"));
                bHeaders.add("traceSource", "traceSource");
                bHeaders.add("AuthVersion","V2");
                bHeaders.add("business", business);
                bHeaders.add("relationId",orderInfoMap.get("relationId"));
    
            }
    
    
            //c入参json
            JSONObject cParams = new JSONObject();
            //入参初始化
            {
                cParams.put("business",business);
                cParams.put("templateId",templateId);
                cParams.put("settleProductTypeEnum","SERVICE");
                cParams.put("phoneNum",orderInfoMap.get("buyerphone"));
                cParams.put("allShopSkuAmount",0);
                cParams.put("allShopSkuCount",1);
                cParams.put("allShopSkuDiscountAmount",0);
                cParams.put("allShopSkuShippingFee",0);
                cParams.put("createOrderOriginEnum","FROM_PRODUCT_PAGE");
                cParams.put("reservationDate","");
                cParams.put("allShopSkuPointsAmount",0);
                cParams.put("yeePayChannel","WECHAT");
                cParams.put("requiredFundType",0);
                cParams.put("sourceChannelEnum","MINI_APP");
    
                 cParams.put("addressId",orderInfoMap.get("buyeraddressId"));
    
                JSONObject sku = new JSONObject();
                sku.put("count",1);
                sku.put("skuId",skuid);
                JSONArray skuList = new JSONArray();
                skuList.add(sku);
    
                JSONObject orderDelivery = new JSONObject();
                orderDelivery.put("selected",true);
                orderDelivery.put("shipDesc","快递配送");
                orderDelivery.put("shipType","EXPRESS");
    
                JSONArray appendInfoReqList = new JSONArray();
    
                JSONObject confirmOrderShopBalance = new JSONObject();
                confirmOrderShopBalance.put("confirmOrderUseBalance",true);
                confirmOrderShopBalance.put("confirmOrderUseBalanceAmount",price);
    
                JSONObject ownerShopInfoList1 = new JSONObject();
                ownerShopInfoList1.put("confirmOrderShopCoupon",null);
                ownerShopInfoList1.put("confirmOrderShopDeduction",null);
                ownerShopInfoList1.put("orderDelivery",orderDelivery);
                ownerShopInfoList1.put("itemBelongShopId",shop_id);
                ownerShopInfoList1.put("remark","自动化快捷创单,备注信息");
                ownerShopInfoList1.put("skuList",skuList);
                ownerShopInfoList1.put("appendInfoReqList",appendInfoReqList);
                ownerShopInfoList1.put("confirmOrderShopBalance",confirmOrderShopBalance);
    
                JSONArray ownerShopInfoList = new JSONArray();
                ownerShopInfoList.add(ownerShopInfoList1);
    
                JSONObject shopInfoList1 = new JSONObject();
                shopInfoList1.put("shopId",orderInfoMap.get("shop_id"));
                shopInfoList1.put("ownerShopInfoList",ownerShopInfoList);
    
                JSONArray shopInfoList = new JSONArray();
                shopInfoList.add(shopInfoList1);
    
                cParams.put("shopInfoList",shopInfoList);
            }
    
    
            if(orderStatus.equals("WAIT_USE")){
    
                //买家创单
                JSONObject orderObj = buyerCreateServiceOrder(orderInfoMap,cHeaders,cParams,order_create_url);
                orderObj.put("status","待核销");
    
                return RespUtil.success(orderObj);
    
            }else if(orderStatus.equals("FINISHED")){
                //买家创单
                JSONObject orderObj = buyerCreateServiceOrder(orderInfoMap,cHeaders,cParams,order_create_url);
                sellerWriteOff(business,templateId,orderObj.getString("subOrderNo"),bHeaders,envMap.get("order_writeOff_url"));
                orderObj.put("status","订单完成");
    
                return RespUtil.success(orderObj);
            }
    
            return RespUtil.error(CodeEnum.RESPONSE_ERROR_PARAMS_MISS,"参数[CreateOrderServiceImpl+serviceOrder]所属模块缺失");
        }
    
    
        //买家创快递单
        public JSONObject buyerCreateServiceOrder(Map orderInfoMap, HttpHeaders cHeaders, JSONObject cParams,  String order_create_url){
    
            System.out.println("========================================准备请求============================================================");
            System.out.println("【请求url】======="+ order_create_url);
            System.out.println("【请求参数】======="+ ContentUtil.JsonPrint(cParams));
            System.out.println("【请求头】======="+ cHeaders);
    
            //发起请求
            ResEntity resEntity = requests.postForResEntity(order_create_url,cHeaders,cParams);
            //结果
            JSONObject result = resEntity.getBody();
            Assert.assertEquals(200,resEntity.getCode());
            Assert.assertEquals(0,Integer.parseInt(result.get("code").toString()));
    
            System.out.println("========================================响应结果============================================================");
            System.out.println("【响应结果】======="+ result);
    
    
            //组装响应
            JSONObject orderObj = new JSONObject();
            orderObj.put("shopid",orderInfoMap.get("shop_id"));
            orderObj.put("buyeruserkey",orderInfoMap.get("buyeruserkey"));
            orderObj.put("spuid",orderInfoMap.get("serviceSpuid"));
            orderObj.put("skuid",orderInfoMap.get("serviceSkuid"));
            orderObj.put("price",orderInfoMap.get("servicePrice"));
            orderObj.put("spuname",orderInfoMap.get("serviceSpuname"));
            orderObj.put("mainOrderNo",result.getJSONObject("data").getString("orderNo"));
            orderObj.put("subOrderNo",result.getJSONObject("data").getJSONArray("subOrderNos").get(0));
            orderObj.put("delivery","服务类商品");
    
            return orderObj;
        }
    
    
        //店主核销
        public void sellerWriteOff(String business,String templateId,String subOrderNo,HttpHeaders bHeaders,String order_writeOff_url){
    
            //入参json
            JSONObject bParams = new JSONObject();
            {
                bParams.put("business",business);
                bParams.put("templateId",templateId);
                bParams.put("orderNo",subOrderNo);
            }
    
            System.out.println("========================================准备请求============================================================");
            System.out.println("【请求url】======="+ order_writeOff_url);
            System.out.println("【请求参数】======="+ ContentUtil.JsonPrint(bParams));
            System.out.println("【请求头】======="+ bHeaders);
    
            //发起请求
            ResEntity resEntity = requests.postForResEntity(order_writeOff_url,bHeaders,bParams);
    
            //结果
            JSONObject result = resEntity.getBody();
            Assert.assertEquals(200,resEntity.getCode());
            Assert.assertEquals(0,Integer.parseInt(result.get("code").toString()));
            System.out.println("========================================响应结果============================================================");
            System.out.println("【响应结果】======="+ result);
        }
    
    
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62
    • 63
    • 64
    • 65
    • 66
    • 67
    • 68
    • 69
    • 70
    • 71
    • 72
    • 73
    • 74
    • 75
    • 76
    • 77
    • 78
    • 79
    • 80
    • 81
    • 82
    • 83
    • 84
    • 85
    • 86
    • 87
    • 88
    • 89
    • 90
    • 91
    • 92
    • 93
    • 94
    • 95
    • 96
    • 97
    • 98
    • 99
    • 100
    • 101
    • 102
    • 103
    • 104
    • 105
    • 106
    • 107
    • 108
    • 109
    • 110
    • 111
    • 112
    • 113
    • 114
    • 115
    • 116
    • 117
    • 118
    • 119
    • 120
    • 121
    • 122
    • 123
    • 124
    • 125
    • 126
    • 127
    • 128
    • 129
    • 130
    • 131
    • 132
    • 133
    • 134
    • 135
    • 136
    • 137
    • 138
    • 139
    • 140
    • 141
    • 142
    • 143
    • 144
    • 145
    • 146
    • 147
    • 148
    • 149
    • 150
    • 151
    • 152
    • 153
    • 154
    • 155
    • 156
    • 157
    • 158
    • 159
    • 160
    • 161
    • 162
    • 163
    • 164
    • 165
    • 166
    • 167
    • 168
    • 169
    • 170
    • 171
    • 172
    • 173
    • 174
    • 175
    • 176
    • 177
    • 178
    • 179
    • 180
    • 181
    • 182
    • 183
    • 184
    • 185
    • 186
    • 187
    • 188
    • 189
    • 190
    • 191
    • 192
    • 193
    • 194
    • 195
    • 196
    • 197
    • 198
    • 199
    • 200
    • 201
    • 202
    • 203
    • 204
    • 205
    • 206
    • 207
    • 208
    • 209
    • 210
    • 211
    • 212
    • 213
    • 214
    • 215
    • 216
    • 217
    • 218
    • 219
    • 220
    • 221
    • 222
    • 223
    • 224
    • 225
    • 226
    • 227
    • 228
    • 229
    • 230
    • 231
    • 232
    • 233
    • 234
    • 235
    • 236
    • 237
    • 238
    • 239
    • 240
    • 241
    • 242
    • 243
    • 244
    • 245
    • 246
    • 247
    • 248
    • 249
    • 250
    • 251
    • 252
    • 253
    • 254
    • 255
    • 256
    • 257
    • 258
    • 259
    • 260
    • 261
    • 262
    • 263
    • 264
    • 265
    • 266
    • 267
    • 268
    • 269
    • 270
    • 271
    • 272
    • 273
    • 274
    • 275
    • 276
    • 277
    • 278
    • 279
    • 280
    • 281
    • 282
    • 283
    • 284
    • 285
    • 286
    • 287
    • 288
    • 289
    • 290
    • 291
    • 292
    • 293
    • 294
    • 295
    • 296
    • 297
    • 298
    • 299
    • 300
    • 301
    • 302
    • 303
    • 304
    • 305
    • 306
    • 307
    • 308
    • 309
    • 310
    • 311
    • 312
    • 313
    • 314
    • 315
    • 316
    • 317
    • 318
    • 319
    • 320
    • 321
    • 322
    • 323
    • 324
    • 325
    • 326
    • 327
    • 328
    • 329
    • 330
    • 331
    • 332
    • 333
    • 334
    • 335
    • 336
    • 337
    • 338
    • 339
    • 340
    • 341
    • 342
    • 343
    • 344
    • 345
    • 346
    • 347
    • 348
    • 349
    • 350
    • 351
    • 352
    • 353
    • 354
    • 355
    • 356
    • 357
    • 358
    • 359
    • 360
    • 361
    • 362
    • 363
    • 364
    • 365
    • 366
    • 367
    • 368
    • 369
    • 370
    • 371
    • 372
    • 373
    • 374
    • 375
    • 376
    • 377
    • 378
    • 379
    • 380
    • 381
    • 382
    • 383
    • 384
    • 385
    • 386
    • 387
    • 388
    • 389
    • 390
    • 391
    • 392
    • 393
    • 394
    • 395
    • 396
    • 397
    • 398
    • 399
    • 400
    • 401
    • 402
    • 403
    • 404
    • 405
    • 406
    • 407
    • 408
    • 409
    • 410
    • 411
    • 412
    • 413
    • 414
    • 415
    • 416
    • 417
    • 418
    • 419
    • 420
    • 421
    • 422
    • 423
    • 424
    • 425
    • 426
    • 427
    • 428
    • 429
    • 430
    • 431
    • 432
    • 433
    • 434
    • 435
    • 436
    • 437
    • 438
    • 439
    • 440
    • 441
    • 442
    • 443
    • 444
    • 445
    • 446
    • 447
    • 448
    • 449
    • 450
    • 451
    • 452
    • 453
    • 454
    • 455
    • 456
    • 457
    • 458
    • 459
    • 460
    • 461
    • 462
    • 463
    • 464
    • 465
    • 466
    • 467
    • 468
    • 469
    • 470
    • 471
    • 472
  • 相关阅读:
    中移链(基于EOS)DDC-SDK实战-如何集成中移链DDC-SDK
    NLP:如何计算两个句子的相似度
    github中RabbitMq延迟插件rabbitmq-delayed-message-exchange查找并下载
    设置npm下载源,加快组件下载
    记录因Sharding Jdbc批量操作引发的一次fullGC
    重写 hashcode()真有那么简单嘛?
    cv面试百问day2
    Leetcode 858. Mirror Reflection
    Servlet基本原理与常见API方法的应用
    关于稳定扩散最详细的介绍
  • 原文地址:https://blog.csdn.net/wang391752/article/details/130843372