1.简介
微盟商家 微盟
2.微盟接口
微盟商品、订单涉及到的接口有
查询类目 /category/queryChildrenCategory
查询规格值 ec/category/queryCategoryAttrInfo
获取配送方式 /goods/findDeliveryTypeList
获取运费模板 /goods/findFreightTemplateList
添加规格值 ec/category/addAttrValue
添加商品 ec/goods/addGoods
上传图片 ec/goodsImage/uploadImg
获取分组 ec/goodsClassify/queryClassifyInfoList
添加分组 ec/goodsClassify/addClassify
批量上下架 ec/goods/updateGoodsShelfStatus
查询订单列表 ec/order/queryOrderList
查询订单详情 ec/order/queryOrderDetail
微盟http请求方法
- public JSONObject httpPostRaw(String url, JSONObject bodyJson, JSONObject headerMap)
- {
- // post请求返回结果
- CloseableHttpClient httpClient = HttpClientBuilder.create().build(); // 获取DefaultHttpClient请求
- HttpPost httpPost = new HttpPost(url);
- try {
- // 设置http头
- httpPost.setHeader("Content-Type", "application/json"); // 默认json
- if (null != headerMap && headerMap.size() > 0){
- for (String name : headerMap.keySet())
- {
- httpPost.setHeader(name, headerMap.getString(name));
- }
- }
-
- // 设置body
- if(bodyJson != null){
- StringEntity entity = new StringEntity(bodyJson.toJSONString(),"UTF-8");
- entity.setContentEncoding("UTF-8");
- entity.setContentType("application/json");
- httpPost.setEntity(entity);
- }
-
- HttpResponse result = httpClient.execute(httpPost);
- url = URLDecoder.decode(url, "UTF-8");
- // 请求发送成功,并得到响应
- try {
- String str = EntityUtils.toString(result.getEntity());
- return JSON.parseObject(str);
- } catch (Exception e) {
- logger.error("post请求提交失败:" + url, e);
- }
- } catch (IOException e) {
- logger.error("post请求提交失败:" + url, e);
- }
- finally {
- try {
- httpClient.close();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
-
- return null;
- }
-
- public static void main(String[] args) {
- HttpRequestUtils httpRequestUtil = new HttpRequestUtils();
- String weiMengBaseUrl = "https://dopen.weimob.com";
- String addAttrValue = "/api/1_0/ec/category/addAttrValue";
- JSONObject bodyJson = new JSONObject();
- bodyJson.put("categoryId", 44);
- bodyJson.put("attrId", 53000);
- JSONArray noExistJson = new JSONArray();
- JSONObject tmp = new JSONObject();
- tmp.put("value", "01白色");
- noExistJson.add(tmp);
- bodyJson.put("attrValueList", noExistJson);
- JSONObject retJson = httpRequestUtil.httpPostRaw(weiMengBaseUrl + addAttrValue + "?accesstoken=87186ee0-b557-47f8-89d9-230cb3a1669f", bodyJson, null);
- System.out.println(retJson.toJSONString());
- }
添加商品
https://dopen.weimob.com/api/1_0/ec/goods/addGoods?accesstoken=a9dc920d-c488-4354-9c09-1c0d0463ceb5
传参:
{"goods":{"b2cGoods":{"b2cGoodsType":0,"deliveryTypeIdList":[3920196],"freightTemplateId":229050849},"categoryId":44,"deductStockType":1,"goodsDesc":"仙女裙","goodsImageUrl":["https://image-c.weimobwmc.com/openruntime/3ea7f5949c50488a8c436fa3073eea20.jpg"],"isMultiSku":1,"isPutAway":1,"selectedSaleAttrList":[{"attrValueList":[{"key":"148252623149"}],"attributeId":"53000"},{"attrValueList":[{"key":"148250430149"},{"key":"148250431149"}],"attributeId":"52000"}],"sellModelType":1,"skuList":[{"b2cSku":{"volume":"0.1","weight":"0.4"},"editStockNum":"0","outerSkuCode":"6018#","salePrice":"154.00","skuAttrMap":{"53000":{"name":"颜色","value":"40杏色","key":"148252623149"},"52000":{"name":"尺寸","value":"S","key":"148250430149"}}},{"b2cSku":{"volume":"0.1","weight":"0.4"},"editStockNum":"0","outerSkuCode":"6018#","salePrice":"154.00","skuAttrMap":{"53000":{"name":"颜色","value":"40杏色","key":"148252623149"},"52000":{"name":"尺寸","value":"M","key":"148250431149"}}}],"title":"6018#秋装新款可盐可甜亮片连衣裙网纱仙女裙性感晚礼服超仙"}}
返回数据:
{"globalTicket":"907260111855793408","code":{"errcode":"0","errmsg":"处理成功"},"data":{"result":true,"applyId":null,"skuList":[{"goodsId":null,"validateId":null,"imageUrl":null,"outerSkuCode":"6018#","storeId":null,"title":null,"skuId":2082944090149},{"goodsId":null,"validateId":null,"imageUrl":null,"outerSkuCode":"6018#","storeId":null,"title":null,"skuId":2082944100149}],"distributorId":null,"goodsId":1370590010149,"notDelDeliveryGoodsIds":null,"outerGoodsIdList":null,"deletedGoodsIds":null,"distributorResponse":null}}
3.获取微盟订单列表
获取微盟订单列表结构如下,pageList为订单数组。
itemList为商品列表,
商品中goodsCode为商品中的SPU编码,groupList为分组信息列表(可以在商品中进行设置,订单商品的这里也可以获取到,可用于区分不同平台商品)。