123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212 |
- package net.chenlin.dp.common.openapi4j.service;
- import java.util.HashMap;
- import java.util.Map;
- import org.slf4j.Logger;
- import org.slf4j.LoggerFactory;
- import com.alibaba.fastjson.JSONObject;
- import net.chenlin.dp.common.openapi4j.commons.TokenManager;
- import net.chenlin.dp.common.openapi4j.exception.OpenAPIException;
- import net.chenlin.dp.common.openapi4j.model.Record;
- import net.chenlin.dp.common.openapi4j.platform.TradeService;
- import net.chenlin.dp.common.openapi4j.util.HttpUtil;
- /**
- * Copyright(c) 2015-2015 by yonyouup. All Rights Reserved 销售订单
- *
- * @author yanwuyang
- * @version <类版本> , 2015年12月8日
- * @see <相关类/方法>
- * @since <产品/模块版本>
- */
- @SuppressWarnings("all")
- public class SaleOrderService extends BaseService {
- private static final long serialVersionUID = 8697005112465513332L;
- final static Logger logger = LoggerFactory.getLogger(SaleOrderService.class);
- public SaleOrderService() {
- this.access_token = TokenManager.getToKenId();
- }
- public SaleOrderService(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("saleorder/get", paramMap);
- logger.debug(url);
- record = JSONObject.parseObject(HttpUtil.get(url));
- } catch (Exception e) {
- throw new OpenAPIException(e.getMessage(), e);
- }
- return record;
- }
- public JSONObject shenghe(String jsonboy, String to_account) throws OpenAPIException {
- JSONObject record;
- try {
- // jsonboy="{\n" +
- // "\t\"saleorder\":{\n" +
- // "\t\t\"voucher_code\":\"XSDD210910004\",\n" +
- // "\t\t\"user_id\":\"demo\",\n" +
- // "\t\t\"opinion\":\"同意\",\n" +
- // "\t\t\"agree\":\"1\"\n" +
- // "\t}\n" +
- // "}\n";
- Map<String, String> paramMap = new HashMap();
- paramMap.put("to_account", to_account);
- String url = this.createURL("saleorder/verify", paramMap);
- logger.debug(url);
- System.out.println(jsonboy);
- String resultStr = HttpUtil.post(url, jsonboy);
- 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;
- }
- //放弃审核
- public JSONObject shengheQ(String jsonboy, String to_account) throws OpenAPIException {
- JSONObject record;
- try {
- Map<String, String> paramMap = new HashMap();
- paramMap.put("to_account", to_account);
- String url = this.createURL("saleorder/unverify", paramMap);
- logger.debug(url);
- String resultStr = HttpUtil.post(url, jsonboy);
- 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 paramMap 参数
- * @return
- * @throws OpenAPIException
- */
- public JSONObject batchGet(Map<String, String> paramMap) throws OpenAPIException {
- JSONObject record;
- try {
- String url = this.createURL("saleorderlist/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("saleorder/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 jsonBody 请求体
- * @param to_account 提供方id
- * @return
- * @throws OpenAPIException
- */
- public JSONObject addTH(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("returnorder/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("saleorder/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;
- }
- }
|