|
|
|
@ -25,7 +25,12 @@ import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.PlatformTransactionManager; |
|
|
|
|
|
|
|
import java.sql.Time; |
|
|
|
import java.sql.Timestamp; |
|
|
|
import java.text.DateFormat; |
|
|
|
import java.text.SimpleDateFormat; |
|
|
|
import java.time.LocalDateTime; |
|
|
|
import java.time.format.DateTimeFormatter; |
|
|
|
import java.util.*; |
|
|
|
|
|
|
|
@Service |
|
|
|
@ -66,15 +71,15 @@ public class GoodsServiceImpl implements GoodsService { |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public int getApiGoods() { |
|
|
|
int count = 0; //统计更新数量
|
|
|
|
// 日期时间格式
|
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
|
|
|
|
|
|
|
int count = 0; //统计更新数量
|
|
|
|
String host = ProperUtils.getSzwhProp("ENTRUST_URL"); |
|
|
|
String apiurl = host + "/consign/exchange/v1/selectEntrustSource/exchange"; |
|
|
|
log.info("get apigoods :" + apiurl); |
|
|
|
|
|
|
|
//创建签名
|
|
|
|
String sign = SignUtils.createSign("entrust"); |
|
|
|
log.info("请求token:"+sign); |
|
|
|
// 请求头
|
|
|
|
Map<String, Object> hmap = new HashMap(); |
|
|
|
hmap.put("entrust_token", sign); |
|
|
|
@ -95,8 +100,6 @@ public class GoodsServiceImpl implements GoodsService { |
|
|
|
String goodsId= nsdjson.getString("identifier"); |
|
|
|
// 以identifier为主键查询详情
|
|
|
|
String gdetailUrl = gdurl+"/"+goodsId; |
|
|
|
// 增加日志信息
|
|
|
|
|
|
|
|
// 执行get请求
|
|
|
|
JSONObject gdJson = RequestUtils.GetData(gdetailUrl, hmap); |
|
|
|
//处理返回的结果
|
|
|
|
@ -114,8 +117,11 @@ public class GoodsServiceImpl implements GoodsService { |
|
|
|
} |
|
|
|
// insertGoodsDetail
|
|
|
|
GoodsDetail goodsDetail = ApiGoodsUtils.jsonToGoodsDetail(nsdjson,sdjson); |
|
|
|
goodsDetailMapper.add(goodsDetail); |
|
|
|
// 返回商品详情
|
|
|
|
int gdid = goodsDetailMapper.add(goodsDetail); |
|
|
|
|
|
|
|
//抽取target 字段中的json,转为jsonobject
|
|
|
|
JSONObject targetJson=nsdjson.getJSONObject("targetData"); |
|
|
|
//处理状态
|
|
|
|
int istatus =0; |
|
|
|
if(sdjson.getInteger("status")==1 || sdjson.getInteger("status")==4 || |
|
|
|
@ -126,7 +132,41 @@ public class GoodsServiceImpl implements GoodsService { |
|
|
|
}else{ |
|
|
|
istatus=4; |
|
|
|
} |
|
|
|
|
|
|
|
//商品起止时间
|
|
|
|
String cstart = sdjson.getString("contractualPeriodStart"); |
|
|
|
String curTime = new SimpleDateFormat("HH:mm:ss").format(new Date()); |
|
|
|
String ncstart= cstart+" "+curTime; |
|
|
|
//
|
|
|
|
String cend=nsdjson.getString("contractualPeriodEnd"); |
|
|
|
String ncend = cend+" 23:59:59"; |
|
|
|
Goods goods =new Goods(); |
|
|
|
//起止时间转为timestamp
|
|
|
|
goods.setContractualStartTime(Timestamp.valueOf(ncstart)); |
|
|
|
goods.setContractualtimeEndTime(Timestamp.valueOf(ncend)); |
|
|
|
goods.setGoodsDetailId(gdid); |
|
|
|
goods.setContractStatus(nsdjson.getInteger("contractStatus")); |
|
|
|
goods.setGoodsStatus(istatus); |
|
|
|
goods.setOldStatus(0); // 默认为0
|
|
|
|
goods.setEntrustStatus(sdjson.getInteger("status")); |
|
|
|
//
|
|
|
|
goods.setUserIslicode(targetJson.getString("identifier")); |
|
|
|
goods.setUsername(targetJson.getString("titleName")); |
|
|
|
goods.setIsLicode(sdjson.getString("isliCode")); |
|
|
|
goods.setGoodsIslicode(nsdjson.getString("identifier")); |
|
|
|
goods.setRecommendSort(1); // 默认排序1
|
|
|
|
// 添加,返回当前的编号
|
|
|
|
int ret_gid = goodsMapper.addGoods(goods); |
|
|
|
//添加操作日志
|
|
|
|
OperationLog oplog = new OperationLog(); |
|
|
|
oplog.setLogid(goods.getId()); |
|
|
|
String nowStr= sdf.format(new Date()); |
|
|
|
String message= nowStr+" 发布标的成功"; |
|
|
|
oplog.setMessage(message); |
|
|
|
oplog.setType("goods"); |
|
|
|
// 日志入库
|
|
|
|
operationLogMapper.addLog(oplog); |
|
|
|
// 计算器增加1
|
|
|
|
count++; |
|
|
|
} |
|
|
|
|
|
|
|
return count; |
|
|
|
|