master
e 2018-10-29 00:22:20 +08:00
parent 8dc8a9be88
commit 856e6ff149
3 changed files with 156 additions and 10 deletions

View File

@ -3,9 +3,7 @@ package com.zzjee.wmutil;
import com.alibaba.fastjson.JSONObject;
import com.xiaoleilu.hutool.http.HttpUtil;
import com.zzjee.yongyoubase.openapi4j.exception.OpenAPIException;
import com.zzjee.yongyoubase.openapi4j.service.ConsignmentService;
import com.zzjee.yongyoubase.openapi4j.service.InventoryService;
import com.zzjee.yongyoubase.openapi4j.service.PurchaseOrderService;
import com.zzjee.yongyoubase.openapi4j.service.*;
import com.alibaba.fastjson.JSONArray;
import org.jeecgframework.core.util.DateUtils;
import org.jeecgframework.core.util.JSONHelper;
@ -157,7 +155,27 @@ public class yyUtil {
}
}
public static void addOtherOut(Map<String, Object> params){
String to_account = params.get("to_account").toString(); //提供方id String page_index = args[1];// 页号
String jsonBody = params.get("jsonBody").toString();
OtherOutService otherOutService = new OtherOutService();
try {
JSONObject record = otherOutService.add(jsonBody, to_account);
} catch (OpenAPIException e) {
e.printStackTrace();
}
}
public static void addOtherIn(Map<String, Object> params){
String to_account = params.get("to_account").toString(); //提供方id String page_index = args[1];// 页号
String jsonBody = params.get("jsonBody").toString();
OtherInService otherInService = new OtherInService();
try {
JSONObject record = otherInService.add(jsonBody, to_account);
} catch (OpenAPIException e) {
e.printStackTrace();
}
}
}

View File

@ -26,14 +26,7 @@ public class PurchaseOrderGet {
PurchaseOrderService purchaseOrderService = new PurchaseOrderService();
try {
JSONObject record = purchaseOrderService.get(id, to_account);
logger.info(record.toString());
} catch (OpenAPIException e) {
e.printStackTrace();
}

View File

@ -0,0 +1,135 @@
package com.zzjee.yongyoubase.openapi4j.service;
import com.alibaba.fastjson.JSONObject;
import com.zzjee.yongyoubase.openapi4j.commons.TokenManager;
import com.zzjee.yongyoubase.openapi4j.exception.OpenAPIException;
import com.zzjee.yongyoubase.openapi4j.model.Record;
import com.zzjee.yongyoubase.openapi4j.platform.TradeService;
import com.zzjee.yongyoubase.openapi4j.util.HttpUtil;
import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import java.util.HashMap;
import java.util.Map;
/**
* Copyright(c) 2015-2015 by yonyouup. All Rights Reserved
*
* @author yanwuyang
* @version <> , 2015128
* @see </>
* @since </>
*/
@SuppressWarnings("all")
public class OtherInService extends BaseService {
private static final long serialVersionUID = 8697005112465513332L;
final static Logger logger = LogManager.getLogger(OtherInService.class);
public OtherInService() {
this.access_token = TokenManager.getToKenId();
}
public OtherInService(String token) {
this.access_token = token;
}
/**
*
*
* @param id
* @param to_account id
* @return
* @throws OpenAPIException
*/
public JSONObject get(String id, String to_account) throws OpenAPIException {
JSONObject record;
try {
Map<String, String> paramMap = new HashMap();
paramMap.put("to_account", to_account);
paramMap.put("id", id);
String url = this.createURL("otherin/get", paramMap);
logger.debug(url);
record = JSONObject.parseObject(HttpUtil.get(url));
} catch (Exception e) {
throw new OpenAPIException(e.getMessage(), e);
}
return record;
}
/**
*
*
* @param paramMap
* @return
* @throws OpenAPIException
*/
public JSONObject batchGet(Map<String, String> paramMap) throws OpenAPIException {
JSONObject record;
try {
String url = this.createURL("otherinlist/batch_get", paramMap);
logger.debug(url);
record = JSONObject.parseObject(HttpUtil.get(url));
} catch (Exception e) {
throw new OpenAPIException(e.getMessage(), e);
}
return record;
}
/**
*
*
* @param jsonBody
* @param to_account id
* @return
* @throws OpenAPIException
*/
public JSONObject add(String jsonBody, String to_account) throws OpenAPIException {
JSONObject record;
try {
String tradeId = TradeService.getTradeId();
Map<String, String> paramMap = new HashMap();
paramMap.put("to_account", to_account);
paramMap.put("tradeid", tradeId);
String url = this.createURL("otherin/add", paramMap);
logger.debug(url);
String resultStr = HttpUtil.post(url, jsonBody);
logger.debug(resultStr);
JSONObject resultRecord = Record.parseObject(resultStr);
Thread.sleep(3000);
record = Record.parseObject(HttpUtil.get(resultRecord.getString("url")));
} catch (Exception e) {
throw new OpenAPIException(e.getMessage(), e);
}
return record;
}
/**
*
*
* @param bizId id
* @param jsonBody
* @param to_account id
* @return
* @throws OpenAPIException
*/
public JSONObject addByBizId(String bizId, String jsonBody, String to_account) throws OpenAPIException {
JSONObject record;
try {
Map<String, String> paramMap = new HashMap();
paramMap.put("to_account", to_account);
paramMap.put("biz_id", bizId);
String url = this.createURL("otherin/add", paramMap);
logger.debug(url);
String resultStr = HttpUtil.post(url, jsonBody);
logger.debug(resultStr);
JSONObject resultRecord = Record.parseObject(resultStr);
Thread.sleep(3000);
record = Record.parseObject(HttpUtil.get(resultRecord.getString("url")));
} catch (Exception e) {
throw new OpenAPIException(e.getMessage(), e);
}
return record;
}
}