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