2 changed files with 43 additions and 3 deletions
@ -1,13 +1,52 @@ |
|||
package cn.chjyj.szwh.service.impl; |
|||
|
|||
import cn.chjyj.szwh.bean.Goods; |
|||
import cn.chjyj.szwh.bean.OperationLog; |
|||
import cn.chjyj.szwh.mapper.GoodsMapper; |
|||
import cn.chjyj.szwh.mapper.OperationLogMapper; |
|||
import cn.chjyj.szwh.service.GoodsTaskService; |
|||
import cn.chjyj.szwh.utils.RequestUtils; |
|||
import cn.chjyj.szwh.utils.SzwhApiUtils; |
|||
import com.alibaba.fastjson2.JSONArray; |
|||
import com.alibaba.fastjson2.JSONObject; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import java.text.SimpleDateFormat; |
|||
import java.util.Date; |
|||
|
|||
@Service |
|||
public class GoodsTaskServiceImpl implements GoodsTaskService { |
|||
@Autowired |
|||
private GoodsMapper goodsMapper; |
|||
@Autowired |
|||
private OperationLogMapper operationLogMapper; |
|||
|
|||
@Override |
|||
public void getRevocationGoods() { |
|||
String st="同步被撤销商品信息"; |
|||
System.out.println(st); |
|||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); |
|||
|
|||
JSONObject recvjson = SzwhApiUtils.revocationGoods(); |
|||
JSONObject dataJson = recvjson.getJSONObject("data"); |
|||
if(!dataJson.isEmpty()){ |
|||
JSONArray jsonArray = JSONArray.parseArray(dataJson.toJSONString()); |
|||
for(int i=0;i<jsonArray.size();i++){ |
|||
JSONObject jitem = (JSONObject) jsonArray.get(i); |
|||
String islicode = jitem.getString("isliCode"); |
|||
//查询是否存在商品
|
|||
Goods dbgoods =goodsMapper.getGoodsByIsliCode(islicode); |
|||
if(dbgoods!=null){ |
|||
//更新状态
|
|||
goodsMapper.updateRevocationGoods(islicode); |
|||
//构建操作日志
|
|||
OperationLog oplog = new OperationLog(); |
|||
oplog.setType("goods"); |
|||
oplog.setLogid(dbgoods.getId()); |
|||
oplog.setMessage(sdf.format(new Date())+" 发布投送系统撤销委托"); |
|||
operationLogMapper.addLog(oplog); |
|||
} |
|||
|
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
|||
Loading…
Reference in new issue