diff --git a/src/main/java/cn/chjyj/szwh/controller/api/GoodsController.java b/src/main/java/cn/chjyj/szwh/controller/api/GoodsController.java index a615c72..83ff33a 100644 --- a/src/main/java/cn/chjyj/szwh/controller/api/GoodsController.java +++ b/src/main/java/cn/chjyj/szwh/controller/api/GoodsController.java @@ -1,5 +1,6 @@ package cn.chjyj.szwh.controller.api; +import cn.chjyj.szwh.bean.Goods; import cn.chjyj.szwh.controller.BaseController; import cn.chjyj.szwh.service.GoodsService; import com.alibaba.fastjson2.JSONObject; @@ -8,6 +9,8 @@ import org.apache.commons.logging.LogFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; +import java.util.List; + /** * API端产品信息 */ @@ -53,4 +56,30 @@ public class GoodsController extends BaseController { jsonObject.put("msg","成功"); return jsonObject; } + + /** + * 根据类型获取委托信息 + * @param type + * @param createtime + * @param goods_type + * @return + */ + @PostMapping("/getTypeGoods") + public JSONObject getTypeGoods(String type,String createtime,String goods_type){ + //10长的时间戳 + long startTime = System.currentTimeMillis(); + List goodsList = goodsService.getTypeGoods(type,createtime,goods_type); + long endtime = System.currentTimeMillis(); + JSONObject outjson = new JSONObject(); + if(goodsList!=null){ + outjson.put("code","success"); + outjson.put("msg","成功"); + outjson.put("userTime",(endtime-startTime)/1000l+"ms"); + outjson.put("data",goodsList); + }else{ + outjson.put("code","failure"); + outjson.put("msg","请求失败"); + } + return outjson; + } } diff --git a/src/main/java/cn/chjyj/szwh/job/SzwhRevocationGoodsJob.java b/src/main/java/cn/chjyj/szwh/job/SzwhRevocationGoodsJob.java index 6215cd3..2a4f67b 100644 --- a/src/main/java/cn/chjyj/szwh/job/SzwhRevocationGoodsJob.java +++ b/src/main/java/cn/chjyj/szwh/job/SzwhRevocationGoodsJob.java @@ -28,6 +28,6 @@ public class SzwhRevocationGoodsJob extends QuartzJobBean { String nowstr = localDateTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); log.info("获取撤销委托信息:"+nowstr); // - goodsTaskService.getRevocationGoods(); + goodsTaskService.fetchRevocationGoods(); } } diff --git a/src/main/java/cn/chjyj/szwh/service/GoodsService.java b/src/main/java/cn/chjyj/szwh/service/GoodsService.java index 0748301..cc27696 100644 --- a/src/main/java/cn/chjyj/szwh/service/GoodsService.java +++ b/src/main/java/cn/chjyj/szwh/service/GoodsService.java @@ -95,4 +95,13 @@ public interface GoodsService { * @return */ int manuImportGoods(JSONObject json); + + /** + * 根据类型获取委托数据 + * @param type + * @param createtime + * @param goods_type + * @return + */ + List getTypeGoods(String type,String createtime,String goods_type); } diff --git a/src/main/java/cn/chjyj/szwh/service/GoodsTaskService.java b/src/main/java/cn/chjyj/szwh/service/GoodsTaskService.java index 3d37b90..7034592 100644 --- a/src/main/java/cn/chjyj/szwh/service/GoodsTaskService.java +++ b/src/main/java/cn/chjyj/szwh/service/GoodsTaskService.java @@ -7,7 +7,7 @@ public interface GoodsTaskService { /** * 获取撤销委托信息 */ - public void getRevocationGoods(); + public void fetchRevocationGoods(); /** * 查询撤销结果 diff --git a/src/main/java/cn/chjyj/szwh/service/impl/GoodsServiceImpl.java b/src/main/java/cn/chjyj/szwh/service/impl/GoodsServiceImpl.java index a4cb1b4..3534e38 100644 --- a/src/main/java/cn/chjyj/szwh/service/impl/GoodsServiceImpl.java +++ b/src/main/java/cn/chjyj/szwh/service/impl/GoodsServiceImpl.java @@ -507,6 +507,24 @@ public class GoodsServiceImpl implements GoodsService { return opGoodsInfo(jsonObject); } + @Override + public List getTypeGoods(String type, String createtime, String goods_type) { + List glist = new ArrayList<>(); + String where="";//查询条件 + if("1".equals(type)){ + glist = goodsMapper.getGoodsByCondition("1=1",10,"click_count","DESC"); + } + if("2".equals(type)){ + glist = goodsMapper.getGoodsByCondition("1=1",10,"sale_count","DESC"); + } + if("3".equals(type)){ + where="is_recommend=1 and goods_status=1"; + glist = goodsMapper.getGoodsByCondition(where,8,"recommend_sort","DESC"); + } + + return glist; + } + /** * query rank list * @return diff --git a/src/main/java/cn/chjyj/szwh/service/impl/GoodsTaskServiceImpl.java b/src/main/java/cn/chjyj/szwh/service/impl/GoodsTaskServiceImpl.java index b606e04..f72a4c4 100644 --- a/src/main/java/cn/chjyj/szwh/service/impl/GoodsTaskServiceImpl.java +++ b/src/main/java/cn/chjyj/szwh/service/impl/GoodsTaskServiceImpl.java @@ -33,7 +33,7 @@ public class GoodsTaskServiceImpl implements GoodsTaskService { * 获取撤销的商品列表 */ @Override - public void getRevocationGoods() { + public void fetchRevocationGoods() { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); //获取接口数据 JSONObject recvjson = SzwhApiUtils.revocationGoods(); @@ -48,14 +48,21 @@ public class GoodsTaskServiceImpl implements GoodsTaskService { Goods dbgoods = goodsMapper.getGoodsByIsliCode(islicode); // 如果商品存在,执行撤销操作 if (dbgoods != null && dbgoods.getApplyOut() == 0) { + // 已经撤销了 + if(dbgoods.getApplyOut()==1 && dbgoods.getGoodsStatus()==2){ + continue; + } //更新状态 - goodsMapper.updateRevocationGoods(dbgoods.getId().toString()); - //构建操作日志 - OperationLog oplog = new OperationLog(); - oplog.setType("goods"); - oplog.setLogid(dbgoods.getId()); - oplog.setMessage(sdf.format(new Date()) + " 发布投送系统撤销委托"); - operationLogMapper.addLog(oplog); + int ret =goodsMapper.updateRevocationGoods(dbgoods.getId().toString()); + // 更新成功后执行 + if(ret==1) { + //构建操作日志 + OperationLog oplog = new OperationLog(); + oplog.setType("goods"); + oplog.setLogid(dbgoods.getId()); + oplog.setMessage(sdf.format(new Date()) + " 发布投送系统撤销委托"); + operationLogMapper.addLog(oplog); + } } } } diff --git a/src/test/java/cn/chjyj/szwh/NewTest.java b/src/test/java/cn/chjyj/szwh/NewTest.java index 99f1311..b17432c 100644 --- a/src/test/java/cn/chjyj/szwh/NewTest.java +++ b/src/test/java/cn/chjyj/szwh/NewTest.java @@ -108,7 +108,7 @@ public class NewTest { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); try { Date startd = sdf.parse("2022-10-17"); - Date afdate =WorkDayUtil.getWorkDay(startd,40); + Date afdate =WorkDayUtil.getWorkDay(startd,15); //Date afdate = DateUtils.daysAgoOrAfter(startd,40); System.out.println("40工作日后的日期:"+sdf.format(afdate)); }catch (Exception ex){ diff --git a/src/test/java/cn/chjyj/szwh/service/impl/GoodsTaskServiceImplTest.java b/src/test/java/cn/chjyj/szwh/service/impl/GoodsTaskServiceImplTest.java index 08cb0ad..e3edb79 100644 --- a/src/test/java/cn/chjyj/szwh/service/impl/GoodsTaskServiceImplTest.java +++ b/src/test/java/cn/chjyj/szwh/service/impl/GoodsTaskServiceImplTest.java @@ -23,7 +23,7 @@ public class GoodsTaskServiceImplTest { */ @Test public void getRevocationGoods() { - goodsTaskService.getRevocationGoods(); + goodsTaskService.fetchRevocationGoods(); } /**