|
|
@@ -25,20 +25,20 @@ public class GoodsApi extends BaseApi {
|
|
|
* 获取设备可售卖商品列表
|
|
|
*
|
|
|
* @param deviceId 设备ID
|
|
|
+ * @param code 商品code(可选)
|
|
|
* @return 商品列表
|
|
|
* @throws HahaException 调用失败时抛出
|
|
|
*/
|
|
|
- public List<Map<String, Object>> getDeviceGoodsList(String deviceId) throws HahaException {
|
|
|
+ public Map<String, Object> getDeviceGoodsList(String deviceId, String code) throws HahaException {
|
|
|
Map<String, String> params = new HashMap<>();
|
|
|
params.put("access_token", client.getAccessToken());
|
|
|
params.put("device_id", deviceId);
|
|
|
-
|
|
|
- Map<String, Object> result = post("/goods/deviceGoodsList", params);
|
|
|
- Object data = result.get("data");
|
|
|
- if (data instanceof List) {
|
|
|
- return (List<Map<String, Object>>) data;
|
|
|
+ if (code != null && !code.isEmpty()) {
|
|
|
+ params.put("code", code);
|
|
|
}
|
|
|
- return null;
|
|
|
+
|
|
|
+ Map<String, Object> result = post("/product/getProductsListByDeviceId", params);
|
|
|
+ return (Map<String, Object>) result.get("data");
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -46,38 +46,49 @@ public class GoodsApi extends BaseApi {
|
|
|
*
|
|
|
* @param pageNo 页码
|
|
|
* @param pageSize 每页条数
|
|
|
- * @param keyword 搜索关键词(可选)
|
|
|
+ * @param barcode 条形码,多个条形码用逗号隔开(可选)
|
|
|
+ * @param code 商品code,多个商品code用逗号隔开(可选)
|
|
|
+ * @param productName 商品名称(可选)
|
|
|
+ * @param deviceAdapt 适应设备(可选)
|
|
|
* @return 商品总库信息
|
|
|
* @throws HahaException 调用失败时抛出
|
|
|
*/
|
|
|
- public Map<String, Object> getTotalList(int pageNo, int pageSize, String keyword) throws HahaException {
|
|
|
+ public Map<String, Object> getTotalList(int pageNo, int pageSize, String barcode, String code,
|
|
|
+ String productName, String deviceAdapt) throws HahaException {
|
|
|
Map<String, String> params = new HashMap<>();
|
|
|
params.put("access_token", client.getAccessToken());
|
|
|
params.put("page_no", String.valueOf(pageNo));
|
|
|
params.put("page_size", String.valueOf(pageSize));
|
|
|
- if (keyword != null && !keyword.isEmpty()) {
|
|
|
- params.put("keyword", keyword);
|
|
|
+ if (barcode != null && !barcode.isEmpty()) {
|
|
|
+ params.put("barcode", barcode);
|
|
|
+ }
|
|
|
+ if (code != null && !code.isEmpty()) {
|
|
|
+ params.put("code", code);
|
|
|
+ }
|
|
|
+ if (productName != null && !productName.isEmpty()) {
|
|
|
+ params.put("product_name", productName);
|
|
|
+ }
|
|
|
+ if (deviceAdapt != null && !deviceAdapt.isEmpty()) {
|
|
|
+ params.put("device_adapt", deviceAdapt);
|
|
|
}
|
|
|
|
|
|
- Map<String, Object> result = post("/goods/totalList", params);
|
|
|
+ Map<String, Object> result = post("/product/getAssignedProducts", params);
|
|
|
return (Map<String, Object>) result.get("data");
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 添加商品至商家商品库
|
|
|
*
|
|
|
- * @param goodsId 商品ID(来自商品总库)
|
|
|
- * @param price 售价
|
|
|
+ * @param codeList 商品列表(传入哈哈的商品编码,多个中间用逗号隔开)
|
|
|
* @return 是否成功
|
|
|
* @throws HahaException 调用失败时抛出
|
|
|
*/
|
|
|
- public boolean addToMerchant(String goodsId, String price) throws HahaException {
|
|
|
+ public boolean addToMerchant(String codeList) throws HahaException {
|
|
|
Map<String, String> params = new HashMap<>();
|
|
|
params.put("access_token", client.getAccessToken());
|
|
|
- params.put("goods_id", goodsId);
|
|
|
- params.put("price", price);
|
|
|
+ params.put("code_list", codeList);
|
|
|
|
|
|
- post("/goods/addToMerchant", params);
|
|
|
+ post("/Product/addClientProducts", params);
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
@@ -86,37 +97,60 @@ public class GoodsApi extends BaseApi {
|
|
|
*
|
|
|
* @param pageNo 页码
|
|
|
* @param pageSize 每页条数
|
|
|
+ * @param name 商品名称(可选)
|
|
|
+ * @param barCode 商品条码(可选)
|
|
|
+ * @param applyStatus 适用设备:1全部柜,2静态柜,3动态柜(可选)
|
|
|
+ * @param code 商品编码(可选)
|
|
|
* @return 商家商品库信息
|
|
|
* @throws HahaException 调用失败时抛出
|
|
|
*/
|
|
|
- public Map<String, Object> getMerchantList(int pageNo, int pageSize) throws HahaException {
|
|
|
+ public Map<String, Object> getMerchantList(int pageNo, int pageSize, String name,
|
|
|
+ String barCode, String applyStatus, String code) throws HahaException {
|
|
|
Map<String, String> params = new HashMap<>();
|
|
|
params.put("access_token", client.getAccessToken());
|
|
|
params.put("page_no", String.valueOf(pageNo));
|
|
|
params.put("page_size", String.valueOf(pageSize));
|
|
|
+ if (name != null && !name.isEmpty()) {
|
|
|
+ params.put("name", name);
|
|
|
+ }
|
|
|
+ if (barCode != null && !barCode.isEmpty()) {
|
|
|
+ params.put("bar_code", barCode);
|
|
|
+ }
|
|
|
+ if (applyStatus != null && !applyStatus.isEmpty()) {
|
|
|
+ params.put("apply_status", applyStatus);
|
|
|
+ }
|
|
|
+ if (code != null && !code.isEmpty()) {
|
|
|
+ params.put("code", code);
|
|
|
+ }
|
|
|
|
|
|
- Map<String, Object> result = post("/goods/merchantList", params);
|
|
|
+ Map<String, Object> result = post("/product/getClientProducts", params);
|
|
|
return (Map<String, Object>) result.get("data");
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 设置商品上下架状态
|
|
|
+ * 商品上下架
|
|
|
*
|
|
|
- * @param deviceId 设备ID
|
|
|
- * @param goodsId 商品ID
|
|
|
- * @param status 状态:0-下架,1-上架
|
|
|
+ * @param deviceId 设备id,sn号
|
|
|
+ * @param goodsCode 商品code,多个商品code用逗号(,)隔开
|
|
|
+ * @param salesType 上下架类型:IN上架,OUT下架。call_type='CHANGE'时必传。
|
|
|
+ * @param callType 请求更新方式:CHANGE更新模式,COVER覆盖模式,不传默认值是CHANGE。
|
|
|
* @return 是否成功
|
|
|
* @throws HahaException 调用失败时抛出
|
|
|
*/
|
|
|
- public boolean setStatus(String deviceId, String goodsId, int status) throws HahaException {
|
|
|
+ public Map<String, Object> setStatus(String deviceId, String goodsCode, String salesType, String callType) throws HahaException {
|
|
|
Map<String, String> params = new HashMap<>();
|
|
|
params.put("access_token", client.getAccessToken());
|
|
|
params.put("device_id", deviceId);
|
|
|
- params.put("goods_id", goodsId);
|
|
|
- params.put("status", String.valueOf(status));
|
|
|
+ params.put("goods_code", goodsCode);
|
|
|
+ if (salesType != null && !salesType.isEmpty()) {
|
|
|
+ params.put("sales_type", salesType);
|
|
|
+ }
|
|
|
+ if (callType != null && !callType.isEmpty()) {
|
|
|
+ params.put("call_type", callType);
|
|
|
+ }
|
|
|
|
|
|
- post("/goods/setStatus", params);
|
|
|
- return true;
|
|
|
+ Map<String, Object> result = post("/systemtemplate/deviceGoods", params);
|
|
|
+ return (Map<String, Object>) result.get("data");
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -132,7 +166,7 @@ public class GoodsApi extends BaseApi {
|
|
|
params.put("access_token", client.getAccessToken());
|
|
|
params.put("device_id", deviceId);
|
|
|
|
|
|
- Map<String, Object> result = post("/goods/getLayerTemplate", params);
|
|
|
+ Map<String, Object> result = post("/product/getLayerTypeInfo", params);
|
|
|
return (Map<String, Object>) result.get("data");
|
|
|
}
|
|
|
|
|
|
@@ -141,84 +175,88 @@ public class GoodsApi extends BaseApi {
|
|
|
* 创建或更新设备的货架层级模板
|
|
|
*
|
|
|
* @param deviceId 设备ID
|
|
|
- * @param layers 层级配置数组(JSON格式)
|
|
|
+ * @param products 层模板商品数据(json)
|
|
|
* @return 是否成功
|
|
|
* @throws HahaException 调用失败时抛出
|
|
|
*/
|
|
|
- public boolean updateLayerTemplate(String deviceId, String layers) throws HahaException {
|
|
|
+ public Map<String, Object> updateLayerTemplate(String deviceId, String products) throws HahaException {
|
|
|
Map<String, String> params = new HashMap<>();
|
|
|
params.put("access_token", client.getAccessToken());
|
|
|
params.put("device_id", deviceId);
|
|
|
- params.put("layers", layers);
|
|
|
+ params.put("products", products);
|
|
|
|
|
|
- post("/goods/updateLayerTemplate", params);
|
|
|
- return true;
|
|
|
+ Map<String, Object> result = post("/product/postLayerTypeInfo", params);
|
|
|
+ return (Map<String, Object>) result.get("data");
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 新品申请
|
|
|
* 商家申请添加新商品到哈哈平台商品总库
|
|
|
*
|
|
|
- * @param goodsName 商品名称
|
|
|
- * @param barcode 商品条码
|
|
|
- * @param image 商品图片URL
|
|
|
- * @param description 商品描述(可选)
|
|
|
- * @return 是否成功
|
|
|
+ * @param params 新品申请参数,详见API文档
|
|
|
+ * @return 新品申请工单编号
|
|
|
* @throws HahaException 调用失败时抛出
|
|
|
*/
|
|
|
- public boolean applyNew(String goodsName, String barcode, String image, String description) throws HahaException {
|
|
|
- Map<String, String> params = new HashMap<>();
|
|
|
+ public Map<String, Object> applyNew(Map<String, String> params) throws HahaException {
|
|
|
params.put("access_token", client.getAccessToken());
|
|
|
- params.put("goods_name", goodsName);
|
|
|
- params.put("barcode", barcode);
|
|
|
- params.put("image", image);
|
|
|
- if (description != null && !description.isEmpty()) {
|
|
|
- params.put("description", description);
|
|
|
- }
|
|
|
|
|
|
- post("/goods/applyNew", params);
|
|
|
- return true;
|
|
|
+ Map<String, Object> result = post("/goods/addClientNewGoodsInfo", params);
|
|
|
+ return (Map<String, Object>) result.get("data");
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 查询商品编号对应关系
|
|
|
* 查询商家商品ID与哈哈平台商品ID的对应关系
|
|
|
*
|
|
|
- * @param merchantGoodsId 商家商品ID(可选)
|
|
|
- * @param hahaGoodsId 哈哈平台商品ID(可选)
|
|
|
+ * @param codeList 哈哈商品编号列表,多个用逗号隔开(可选)
|
|
|
* @return 对应关系信息
|
|
|
* @throws HahaException 调用失败时抛出
|
|
|
*/
|
|
|
- public Map<String, Object> getIdMapping(String merchantGoodsId, String hahaGoodsId) throws HahaException {
|
|
|
+ public Map<String, Object> getIdMapping(String codeList) throws HahaException {
|
|
|
Map<String, String> params = new HashMap<>();
|
|
|
params.put("access_token", client.getAccessToken());
|
|
|
- if (merchantGoodsId != null && !merchantGoodsId.isEmpty()) {
|
|
|
- params.put("merchant_goods_id", merchantGoodsId);
|
|
|
- }
|
|
|
- if (hahaGoodsId != null && !hahaGoodsId.isEmpty()) {
|
|
|
- params.put("haha_goods_id", hahaGoodsId);
|
|
|
+ if (codeList != null && !codeList.isEmpty()) {
|
|
|
+ params.put("code_list", codeList);
|
|
|
}
|
|
|
|
|
|
- Map<String, Object> result = post("/goods/idMapping", params);
|
|
|
+ Map<String, Object> result = post("/product/getProductsRelation", params);
|
|
|
return (Map<String, Object>) result.get("data");
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 商品合并
|
|
|
- * 将多个相似商品合并为一个商品
|
|
|
+ * 上传图片
|
|
|
+ * 用于新品申请时上传商品图片
|
|
|
*
|
|
|
- * @param targetGoodsId 目标商品ID(保留的商品)
|
|
|
- * @param sourceGoodsIds 源商品ID数组(将被合并的商品),多个ID用逗号分隔
|
|
|
- * @return 是否成功
|
|
|
+ * @param file 图片文件
|
|
|
+ * @return 图片地址
|
|
|
* @throws HahaException 调用失败时抛出
|
|
|
*/
|
|
|
- public boolean mergeGoods(String targetGoodsId, String sourceGoodsIds) throws HahaException {
|
|
|
+ public String uploadImage(java.io.File file) throws HahaException {
|
|
|
+ // 注意:这个接口需要multipart/form-data格式,需要特殊处理
|
|
|
+ // 该方法需要在HttpUtils中添加文件上传支持
|
|
|
+ throw new HahaException("文件上传功能尚未实现,请使用img_type=url方式");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查看新品申请
|
|
|
+ * 获取新品申请商品信息
|
|
|
+ *
|
|
|
+ * @param code 商品code(可选)
|
|
|
+ * @param id 新品申请主键id(可选)
|
|
|
+ * @return 新品申请信息
|
|
|
+ * @throws HahaException 调用失败时抛出
|
|
|
+ */
|
|
|
+ public Map<String, Object> getNewGoodsInfo(String code, String id) throws HahaException {
|
|
|
Map<String, String> params = new HashMap<>();
|
|
|
params.put("access_token", client.getAccessToken());
|
|
|
- params.put("target_goods_id", targetGoodsId);
|
|
|
- params.put("source_goods_ids", sourceGoodsIds);
|
|
|
+ if (code != null && !code.isEmpty()) {
|
|
|
+ params.put("code", code);
|
|
|
+ }
|
|
|
+ if (id != null && !id.isEmpty()) {
|
|
|
+ params.put("id", id);
|
|
|
+ }
|
|
|
|
|
|
- post("/goods/merge", params);
|
|
|
- return true;
|
|
|
+ Map<String, Object> result = post("/goods/getNewClientGoodsInfo", params);
|
|
|
+ return (Map<String, Object>) result.get("data");
|
|
|
}
|
|
|
}
|