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

news2024/11/19 6:21:04

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

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

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

<template>
  <div class="app-container">

    <el-divider content-position="left">不同业务场景快速创建订单</el-divider>

    <div id = "msg">
      1、100174业务线使用7137店铺 <br>
      2、独立业务线业务线使用TCXD3店铺,业务线=300079<br>
      3、平台商子店铺,使用子店铺7137店铺,业务线=300103<br>
      4、店主和买家使用同一个账号,不同user_key固定写死<br>
      5、每次创建一个订单,创建的数据会展示于列表,刷新页面后消失。<br>
    </div>

    <el-select v-model="shop_value" placeholder="请选择店铺">
      <el-option
        v-for="item in shop_options"
        :key="item.value"
        :label="item.label"
        :value="item.value"/>
    </el-select>

    <el-select v-model="scene_value" style="margin-left: 50px;" placeholder="请选择业务场景">
      <el-option
        v-for="item in scene_options"
        :key="item.value"
        :label="item.label"
        :value="item.value"/>
    </el-select>

    <el-button :loading="btnflag" type="primary" @click="createOrderNow()">确定创单</el-button>

    <el-table
      :data="orderData"
      style="width: 100%">
      <el-table-column prop="shopid" label="shopid" width="150"/>
      <el-table-column prop="delivery" label="配送方式" width="120"/>
      <el-table-column prop="status" label="订单状态" width="100"/>
      <el-table-column prop="mainOrderNo" label="订单主单" width="180"/>
      <el-table-column prop="subOrderNo" label="订单子单" width="210"/>
      <el-table-column prop="spuname" label="商品名称" width="150"/>
      <el-table-column prop="spuid" label="spuid" width="180"/>
      <el-table-column prop="skuid" label="skuid" width="180"/>
      <el-table-column prop="price" label="price" width="60"/>
      <el-table-column prop="buyeruserkey" label="买家userkey" width="280"/>
    </el-table>

  </div>
</template>

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

<script>
import request from '@/utils/request'
export default {
  name: 'CreateOrder',
  components: { },
  data() {
    return {
      shop_value: ''xxxx',
      shop_options: [{
        value: 'xxxx',
        label: '店铺1'
      }, {
        value: 'xxx',
        label: '店铺2'
      }, {
        value: 'xxx',
        label: '店铺3'
      }],
      scene_value: 'MATERIAL&EXPRESS&WAIT_SEND',
      scene_options: [
        {
          value: 'MATERIAL&EXPRESS&WAIT_SEND',
          label: '实物-快递-待发货'
        }, {
          value: 'MATERIAL&EXPRESS&WAIT_RECEIVE',
          label: '实物-快递-待收货'
        }, {
          value: 'MATERIAL&EXPRESS&FINISHED',
          label: '实物-快递-已完成'
        }, {
          value: 'MATERIAL&MERCHANT_POST&WAIT_SEND',
          label: '实物-商家配送-待发货'
        }, {
          value: 'MATERIAL&MERCHANT_POST&WAIT_RECEIVE',
          label: '实物-商家配送-待收货'
        }, {
          value: 'MATERIAL&MERCHANT_POST&FINISHED',
          label: '实物-商家配送-已完成'
        }, {
          value: 'MATERIAL&SELF_PICKUP&WAIT_SEND',
          label: '实物-自提-待备货'
        }, {
          value: 'MATERIAL&SELF_PICKUP&WAIT_RECEIVE',
          label: '实物-自提-待自提'
        }, {
          value: 'MATERIAL&SELF_PICKUP&FINISHED',
          label: '实物-自提-已完成'
        }, {
          value: 'SERVICE&EXPRESS&WAIT_USE',
          label: '服务类-待核销'
        }, {
          value: 'SERVICE&EXPRESS&FINISHED',
          label: '服务类-已完成'
        }],
      orderData: [],
      btnflag: false

    }
  },
  created() {

  },
  methods: {

    createOrderNow() {
      console.log('店铺 = ' + this.shop_value)
      console.log('scene_value = ' + this.scene_value)
      console.log('商品类型 = ' + this.scene_value.split('&')[0])
      console.log('快递方式 = ' + this.scene_value.split('&')[1])
      console.log('状态 = ' + this.scene_value.split('&')[2])

      this.btnflag = true
      request({
        method: 'post',
        url: '/testPlatormCreateOrder',
        params: {
          shopId: this.shop_value,
          productType: this.scene_value.split('&')[0],
          delivery: this.scene_value.split('&')[1],
          orderStatus: this.scene_value.split('&')[2]
        }
      }).then((res) => {
        // 做判断操作
        if (res.data.code.toString() !== '2000') {
          this.$notify({
            title: '提示',
            message: res.data.msg,
            type: 'error',
            duration: 2000
          })
        } else {
          this.btnflag = false
          this.$notify({
            title: '提示',
            message: '创建成功!',
            type: 'success',
            duration: 2000
          })
        }

        this.orderData.push(res.data.data)
      })
    }
  }
}
</script>


<style scoped>

  #msg{
    margin: 30px;
    text-align: left;
    color:darkgray;
    font-size: 14px;
  }

</style>

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

{
        path: '/quickcreateOrder/',
        name: 'quickcreateOrder',
        component: () =>
            import ('@/views/quicktools/createOrder'),
        meta: { title: '一键创单' }
    },

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)

组装数据
不同的店铺或商品类型选择,我需要手动去准备数据。
主要包括环境和域名,商品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")){

使用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);
        }

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

public interface CreateOrderService {

 //实物
 public Resp materialOrder(Map<String,String> envMap, Map<String,String> orderInfoMap, String delivery, String orderStatus);

//服务类
 public Resp  serviceOrder(Map<String,String> envMap, Map<String,String> orderInfoMap, String orderStatus);
}

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

@Service
public class CreateOrderServiceImpl  implements CreateOrderService{

    @Autowired
    public RestUtils requests;


    //实物订单
    @Override
    public Resp   materialOrder(Map<String,String> envMap, Map<String,String> 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<String,String> 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<String,String> envMap, Map<String,String> 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<String,String> 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);
    }


}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/562941.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

一种新的爬虫网络解锁器

事出原由 遇到一个需要采集境外电商的需求&#xff0c;相比国内各种层出不穷的反爬手段&#xff0c;境外产品更注重于用户行为和指纹上。 所以笔者在想是否有类似于指纹浏览器的环境可以提供给爬虫采集器使用。 经过检索&#xff0c;找到了一种名为爬虫网络解锁器的新兴产品…

SAP: 建立HTTPS 连接时,报错 ICM_HTTP_SSL_PEER_CERT_UNTRUSTED

报错1&#xff1a; SSL handshake with tpm-uat.jlbry.cn:443 failed: SSSLERR_PEER_CERT_UNTRUSTED (-102)#The peers X.509 Certificate (chain) is untrusted##SapSSLSessionStartNB()SSSLERR_PEER_CERT_UNTRUSTED# SSL:SSL_read() failed (536872221/0x2000051d)# >…

【正点原子STM32连载】第十四章 蜂鸣器实验 摘自【正点原子】STM32F103 战舰开发指南V1.2

1&#xff09;实验平台&#xff1a;正点原子stm32f103战舰开发板V4 2&#xff09;平台购买地址&#xff1a;https://detail.tmall.com/item.htm?id609294757420 3&#xff09;全套实验源码手册视频下载地址&#xff1a; http://www.openedv.com/thread-340252-1-1.html 第十四…

【无标题】ELISA-3(加装跟踪装置)—让群体协作更智能!

群体智能是近年来发展迅速的一个人工智能学科领域&#xff0c;通过对蚂蚁、蜜蜂等为代表的社会性昆虫群体行为的研究&#xff0c;实现分布式等智能行为。作为新一代人工智能的重要方向&#xff0c;群体智能通常用于无人机、机器人集群的协同作业。目前&#xff0c;群体智能在基…

零操作难度,轻松进行应用测试,App专项测试之Monkey测试完全指南!

目录 前言&#xff1a; 一、 Monkey测试的基础参数 1.1 事件类型参数&#xff1a; 1.2 覆盖包 1.3 事件数量 二、 Monkey测试的高级参数 2.1 稳定性级别 2.2 策略参数 2.3 包含选项参数 三、 附加代码 四、 总结 前言&#xff1a; 在移动应用的开发过程中&#xff0…

数据结构(C语言):有序顺序表的设计及相关操作函数

一、题目 有序顺序表的设计 实验要求&#xff1a; 有序顺序表的操作&#xff0c;包括初始化&#xff0c;求数据元素个数&#xff0c;插入&#xff0c;删除和取数据元素。放在头文件中&#xff08;建议尝试用动态数组实现有序顺序表&#xff09;&#xff1b;注意有序顺序表的…

【正点原子STM32连载】 第十七章 串口通信实验摘自【正点原子】STM32F103 战舰开发指南V1.2

1&#xff09;实验平台&#xff1a;正点原子stm32f103战舰开发板V4 2&#xff09;平台购买地址&#xff1a;https://detail.tmall.com/item.htm?id609294757420 3&#xff09;全套实验源码手册视频下载地址&#xff1a; http://www.openedv.com/thread-340252-1-1.html 第十七…

2023年25个Java8面试问题和答案

Java是一种非常流行的编程语言&#xff0c;从Android应用程序到物联网&#xff08;IoT&#xff09;无处不在。事实上&#xff0c;根据Codeplatoon的数据&#xff0c;Java在1年的招聘信息中排名#2022。考虑到它的普遍存在&#xff0c;对精通Java的专业人员的需求仍然很高也就不足…

【vlan高级特性——super vlan概述】

今天给大家分享Windows常用cmd网络命令&#xff0c;希望对大家能有所帮助&#xff01; 1、arp [option] [address] 显示/修改ARP缓存 执行命令&#xff1a;arp -a 参数说明&#xff1a; 显示和修改地址解析协议(ARP)使用的“IP 到物理”地址转换表。 ARP -s inet_addr eth…

那些30多岁的测试工程师都是怎么走过来的?

最近工作真的不好找了&#xff0c;感觉身边的朋友明显变得焦虑了&#xff0c;一个个都在抱怨生活的迷茫和疑惑。 30岁测试员该何去何从&#xff1f; 如今我们往往能够看到网上的各种新闻&#xff0c;什么“30岁是程序员的一道坎“ “非诚勿扰:32岁 程序员登台&#xff0c;遭美…

【Java-Crawler】爬取动态页面(WebMagic、Selenium、ChromeDriver)

WebMagicSeleniumChromeDriverMaven 爬取动态页面 一、需要下载的资源和引入的依赖资源依赖 二、实战代码测试效果 在上一篇说WebMagic框架的时候&#xff08; 一文学会WebMagic爬虫框架&#xff09;&#xff0c;提到了WebMagic仅能解析静态页面&#xff0c;满足不了小编的爬虫…

chatgpt赋能Python-python_numpy转置

Python中的Numpy转置&#xff1a;使用transpose()函数 在Python中&#xff0c;Numpy是非常常用的一个科学计算库&#xff0c;它提供了大量的数学函数、矩阵计算等功能。其中&#xff0c;矩阵的转置是一个非常基本的运算&#xff0c;在Numpy中&#xff0c;我们可以使用transpos…

SSRS rdlc报表 六 报表分组和总计

报表分组和总计在报表中是一个很常用的功能&#xff0c;比如我们需要按部门进行分组&#xff0c;统计每个部门的费用支出&#xff0c;或者在进一步分组&#xff0c;每个部门每个月的费用支出&#xff0c;通过rdlc报表&#xff0c;很容易实现这个需求。 我们下面要讲解的案例&a…

Thinkphp漏洞详解合集

文章目录 Thinkphp6.0.12LTS反序列化漏洞环境漏洞分析 thinkphp lang命令执行环境影响版本漏洞分析漏洞复现 CNVD-2018-24942(t5RCE)环境影响版本漏洞分析漏洞复现 Thinkphp3.2.x命令执行环境漏洞分析漏洞复现 thinkphp-2x-rce漏洞环境影响版本漏洞分析 Thinkphp5.0.23变量覆盖…

人机交互软件工程视角 第3-11章部分课后习题答案

4. 对于用于帮助儿童之间进行交流和合作的移动设备&#xff0c; 核心可用性目标&#xff1a; 简单易用性&#xff1a;移动设备应该具备简单直观的界面和操作方式&#xff0c;以便儿童能够轻松理解和使用。 可靠性&#xff1a;设备应该稳定运行&#xff0c;并且提供可靠的通…

什么是智能制造?制造企业该如何发展?

智能制造是落实我国制造强国战略的重要举措&#xff0c;加快推进智能制造&#xff0c;是加速我国工业化和信息化深度融合、推动制造业供给侧结构性改革的重要着力点&#xff0c;对重塑我国制造业竞争新优势具有重要意义。 ——摘自《中国制造 2025》 概念的提出 德勤公司(Delo…

使用 PAI-Blade 优化 Stable Diffusion 推理流程(二)

背景 上一篇中&#xff0c;我们使用了 PAI-Blade 优化了 diffusers 中 Stable Diffusion 模型。本篇&#xff0c;我们继续介绍使用 PAI-Blade 优化 LoRA 和 Controlnet 的推理流程。相关优化已经同样在 registry.cn-beijing.aliyuncs.com/blade_demo/blade_diffusion镜像中可以…

Linkage Mapper 连通性模型的构建方法详解(含实际案例分析)

✅创作者:陈书予 🎉个人主页:陈书予的个人主页 🍁陈书予的个人社区,欢迎你的加入: 陈书予的社区 🌟专栏地址: Linkage Mapper解密数字世界链接 文章目录 一、 简介1.1 连通性模型概述二、 Linkage Mapper工具箱2.1 工具箱概述2.2 安装和加载工具箱

【Android定制】BUILD_AGO_GMS = no 和 BUILD_GMS=no属性

文章目录 概要名词解释细节小结 概要 在安卓底层源码中&#xff0c;有这样的两个属性&#xff0c;这两个第一眼看上去都像是带不带谷歌&#xff0c;BUILD_AGO_GMS no和BUILD_GMSno有什么区别&#xff1f;&#xff1f; 如果带了谷歌&#xff0c;那么这个设备就差不多是国外定…

低代码平台盘点:这5款平台备受欢迎!

随着数字化转型需求的持续增长&#xff0c;企业正在寻求更高效的方式来构建定制软件。低代码平台因其能够以最少的编码需求促进更快的应用程序开发而广受欢迎。这些平台提供拖放界面、预置模板和可视化设计工具&#xff0c;使用户无需具备编程语言专业知识即可构建自定义应用程…