|
|
|
@ -81,7 +81,7 @@ public class GoodsServiceImpl implements GoodsService { |
|
|
|
Map<String, Object> hmap = new HashMap(); |
|
|
|
hmap.put("entrust_token", sign); |
|
|
|
// get 方式获取
|
|
|
|
JSONObject jsonObject = RequestUtils.GetData(apiurl, hmap,true); |
|
|
|
JSONObject jsonObject = RequestUtils.GetData(apiurl, hmap, true); |
|
|
|
// 产品详情地址
|
|
|
|
String gdurl = host + "/consign/exchange/v1/selectEntrustDetails"; |
|
|
|
return opGoodsInfo(jsonObject,host,hmap); |
|
|
|
@ -463,35 +463,38 @@ public class GoodsServiceImpl implements GoodsService { |
|
|
|
|
|
|
|
/** |
|
|
|
* 手动导入商品信息 |
|
|
|
* |
|
|
|
* @param jsonObject |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public int manuImportGoods(JSONObject jsonObject) { |
|
|
|
public int manuImportGoods(JSONObject jsonObject) { |
|
|
|
String host = ProperUtils.getSzwhProp("ENTRUST_URL"); |
|
|
|
//创建签名
|
|
|
|
String sign = SignUtils.createSign("entrust"); |
|
|
|
// 请求头
|
|
|
|
Map<String, Object> hmap = new HashMap(); |
|
|
|
hmap.put("entrust_token", sign); |
|
|
|
return opGoodsInfo(jsonObject,host,hmap); |
|
|
|
//处理json数据
|
|
|
|
return opGoodsInfo(jsonObject, host, hmap); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 操作商品信息 |
|
|
|
* |
|
|
|
* @param jsonObject 待处理的json内容 |
|
|
|
* @param host 目标网址 |
|
|
|
* @param hmap 请求主机头集合 |
|
|
|
* @param host 目标网址 |
|
|
|
* @param hmap 请求主机头集合 |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
private int opGoodsInfo(JSONObject jsonObject,String host,Map hmap){ |
|
|
|
private int opGoodsInfo(JSONObject jsonObject, String host, Map hmap) { |
|
|
|
// 日期时间格式
|
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
|
|
|
int count = 0; //统计更新数量
|
|
|
|
// 产品详情地址
|
|
|
|
String gdurl = host + "/consign/exchange/v1/selectEntrustDetails"; |
|
|
|
// 循环查询商品的详情
|
|
|
|
if(jsonObject!=null && jsonObject.containsKey("data") ) { |
|
|
|
if (jsonObject != null && jsonObject.containsKey("data")) { |
|
|
|
// json的data节点
|
|
|
|
JSONArray jsonArray = jsonObject.getJSONArray("data"); |
|
|
|
for (int i = 0; i < jsonArray.size(); i++) { |
|
|
|
@ -507,7 +510,7 @@ public class GoodsServiceImpl implements GoodsService { |
|
|
|
// 以identifier为主键查询详情
|
|
|
|
String gdetailUrl = gdurl + "/" + goodsId; |
|
|
|
// 请求商品的详情
|
|
|
|
JSONObject gdJson = RequestUtils.GetData(gdetailUrl, hmap,true); |
|
|
|
JSONObject gdJson = RequestUtils.GetData(gdetailUrl, hmap, true); |
|
|
|
log.info(goodsId + "详情:" + gdJson); |
|
|
|
//处理返回的结果
|
|
|
|
//JSONArray gdArr = gdJson.getJSONArray("data");
|
|
|
|
@ -521,7 +524,7 @@ public class GoodsServiceImpl implements GoodsService { |
|
|
|
// 从里面取出数据
|
|
|
|
JSONObject gditem = gdJson.getJSONObject("data"); |
|
|
|
// 商品详情json非空时候
|
|
|
|
if(gditem!=null){ |
|
|
|
if (gditem != null) { |
|
|
|
GoodsSource goodsSource = ApiGoodsUtils.jsonToGoodsSource(gditem, goodsId); |
|
|
|
goodsSourceMapper.add(goodsSource); |
|
|
|
} |
|
|
|
@ -544,13 +547,39 @@ public class GoodsServiceImpl implements GoodsService { |
|
|
|
istatus = 4; |
|
|
|
} |
|
|
|
Goods goods = new Goods(); |
|
|
|
String contractualPeriod = nsdjson.getString("contractualPeriod"); |
|
|
|
int iperiod = 0; |
|
|
|
//商品起止时间
|
|
|
|
String cstart = sdjson.getString("contractualPeriodStart"); |
|
|
|
String cstart = nsdjson.getString("contractualPeriodStart"); |
|
|
|
String curTime = new SimpleDateFormat("HH:mm:ss").format(new Date()); |
|
|
|
String ncstart = cstart + " " + curTime; |
|
|
|
// 委托周期
|
|
|
|
int day = nsdjson.getInteger("contractualCycle"); |
|
|
|
//转换为date
|
|
|
|
String cend = nsdjson.getString("contractualPeriodEnd"); |
|
|
|
|
|
|
|
if (StringUtils.isBlank(cend)) { |
|
|
|
|
|
|
|
//如果是一次性授权或单次授权,存在托管结束时间
|
|
|
|
if (iperiod == 2) { |
|
|
|
try { |
|
|
|
// 委托开始时间
|
|
|
|
Date wtStart = sdf.parse(cstart); |
|
|
|
// 委托终止时间
|
|
|
|
Date wtEnd = DateUtils.daysAgoOrAfter(wtStart, day); |
|
|
|
cend = wtEnd.toString(); |
|
|
|
} catch (Exception ex) { |
|
|
|
ex.printStackTrace(); |
|
|
|
} |
|
|
|
} |
|
|
|
//永久性
|
|
|
|
if (iperiod == 1) { |
|
|
|
cend = "2099-12-31"; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
String ncend = cend + " 23:59:59"; |
|
|
|
//
|
|
|
|
try { |
|
|
|
//起止时间转为timestamp
|
|
|
|
SimpleDateFormat tsdf = new SimpleDateFormat("yyyyMMddHHmmss"); |
|
|
|
@ -560,7 +589,7 @@ public class GoodsServiceImpl implements GoodsService { |
|
|
|
Timestamp ncet = new Timestamp(tsdf.parse(ncend).getTime()); |
|
|
|
goods.setContractualStartTime(ncst); |
|
|
|
goods.setContractualtimeEndTime(ncet); |
|
|
|
}catch (Exception ex){ |
|
|
|
} catch (Exception ex) { |
|
|
|
// do nothing
|
|
|
|
} |
|
|
|
// 查询goodsdetail的自编号
|
|
|
|
@ -583,7 +612,7 @@ public class GoodsServiceImpl implements GoodsService { |
|
|
|
goods.setIsDeleted(0); |
|
|
|
goods.setApplyOut(0); |
|
|
|
//当前时间戳
|
|
|
|
Timestamp nowst=new Timestamp(System.currentTimeMillis()); |
|
|
|
Timestamp nowst = new Timestamp(System.currentTimeMillis()); |
|
|
|
goods.setCreateTime(nowst); |
|
|
|
goods.setUpdateTime(nowst); |
|
|
|
// 添加,返回当前的编号
|
|
|
|
|