From 24a8d17e007545f7426c48352109aa1a9c6587ee Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期三, 06 五月 2020 12:02:09 +0800 Subject: [PATCH] IOS上线隐藏我的界面的banner与超级会员升级信息 --- fanli/src/main/java/com/yeshi/fanli/service/impl/push/PushGoodsServiceImpl.java | 138 +++++++++++++++++++++++++++++++++------------ 1 files changed, 101 insertions(+), 37 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/push/PushGoodsServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/push/PushGoodsServiceImpl.java index 4dc166d..936229c 100644 --- a/fanli/src/main/java/com/yeshi/fanli/service/impl/push/PushGoodsServiceImpl.java +++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/push/PushGoodsServiceImpl.java @@ -1,5 +1,6 @@ package com.yeshi.fanli.service.impl.push; +import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Arrays; import java.util.Date; @@ -14,8 +15,9 @@ import com.yeshi.fanli.entity.goods.CommonGoods; import com.yeshi.fanli.entity.push.PushGoods; import com.yeshi.fanli.entity.push.PushGoodsGroup; +import com.yeshi.fanli.entity.system.ConfigKeyEnum; import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief; -import com.yeshi.fanli.exception.PushException; +import com.yeshi.fanli.exception.push.PushException; import com.yeshi.fanli.exception.push.PushGoodsException; import com.yeshi.fanli.service.inter.config.ConfigService; import com.yeshi.fanli.service.inter.goods.CommonGoodsService; @@ -77,9 +79,26 @@ } @Override - @Transactional - public void save(PushGoods record, List<Long> goodsIds) throws Exception { + @Transactional(rollbackFor=Exception.class) + public void save(PushGoods record, List<Long> goodsIds) throws PushGoodsException, Exception { + // 瀹氭椂鏃堕棿 + Boolean timeTask = record.isTimeTask(); + if (timeTask != null && timeTask) { + String controlTime_str = record.getControlTime_str(); + if (controlTime_str == null || controlTime_str.trim().length() == 0) { + throw new PushGoodsException(1, "棰勮鏃堕棿涓嶈兘涓虹┖"); + } + + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm"); + controlTime_str = controlTime_str.replaceAll("T", " "); + record.setControlTime(format.parse(controlTime_str)); + } else { + record.setControlTime(null); + } + + record.setIsPush(PushGoods.STATE_INIT); + boolean isAdd = false; // 鎺ㄩ�乮d Long pushId = record.getId(); @@ -89,21 +108,27 @@ record.setCreateTime(new Date()); record.setUpdateTime(new Date()); - pushGoodsMapper.insertSelective(record); + pushGoodsMapper.insert(record); pushId = record.getId(); } else { // 淇敼 + PushGoods current = pushGoodsMapper.selectByPrimaryKey(pushId); + if (current == null) { + throw new PushGoodsException(1, "璇ヨ褰曞凡涓嶅瓨鍦�"); + } + + record.setCreateTime(current.getCreateTime()); record.setUpdateTime(new Date()); - pushGoodsMapper.updateByPrimaryKeySelective(record); + pushGoodsMapper.updateByPrimaryKey(record); } // 澶勭悊鍟嗗搧淇℃伅 saveGoodsInfo(isAdd, pushId, goodsIds); } - @Transactional + @Transactional(rollbackFor=Exception.class) public void saveGoodsInfo(boolean isAdd, Long pushId, List<Long> goodsIds) throws Exception { if (goodsIds == null || goodsIds.size() == 0) { @@ -117,17 +142,21 @@ List<Long> listCommonId = new ArrayList<Long>(); for (Long auctionId : goodsIds) { // 鑾峰彇鍟嗗搧璇︽儏 - TaoBaoGoodsBrief goodsBrief = TaoKeApiUtil.searchGoodsDetail(auctionId); - - // 杞崲绠�鐗堝晢鍝佷俊鎭� - CommonGoods commonGoods = CommonGoodsFactory.create(goodsBrief); - if (commonGoods != null) { - commonGoodsService.addOrUpdateCommonGoods(commonGoods); - Long cid = commonGoods.getId(); - if (cid != null) { - listCommonId.add(cid); + try { + TaoBaoGoodsBrief goodsBrief = TaoKeApiUtil.searchGoodsDetail(auctionId); + // 杞崲绠�鐗堝晢鍝佷俊鎭� + CommonGoods commonGoods = CommonGoodsFactory.create(goodsBrief); + if (commonGoods != null) { + commonGoodsService.addOrUpdateCommonGoods(commonGoods); + Long cid = commonGoods.getId(); + if (cid != null) { + listCommonId.add(cid); + } } + } catch (Exception e) { + e.printStackTrace(); } + } /* 淇敼鏃跺垹闄� 閮ㄥ垎 */ @@ -177,7 +206,7 @@ } @Override - @Transactional + @Transactional(rollbackFor=Exception.class) public int deleteBatchByPrimaryKey(List<Long> list) throws Exception { /*List<PushGoods> lisState = pushGoodsMapper.listByPushState(list); @@ -214,28 +243,72 @@ return pushGoodsMapper.countHistoryByPushTime(uid, pushTime); } + @Override - public void executePush(Long id) throws Exception, PushGoodsException, PushException { - - PushGoods pushGoods = selectByPrimaryKey(id); - if (pushGoods == null) { - throw new PushException(1, "鎺ㄩ�佷俊鎭凡涓嶅瓨鍦�"); + public List<PushGoods> listTask() { + return pushGoodsMapper.listTask(); + } + + + @Override + public void taskPush(PushGoods record) { + String msg = null; + int state = PushGoods.STATE_FAIL; + try { + // 鎵ц鎺ㄩ�� + executePush(record); + state = PushGoods.STATE_SUCCESS; + } catch (PushGoodsException e) { + msg = e.getMsg(); + } catch (PushException e) { + msg = e.getMsg(); + } catch (Exception e) { + msg = "绯荤粺鎺ㄩ�佸け璐�"; } + record.setIsPush(state); + record.setPushTime(new Date()); + record.setRemark(msg); + record.setUpdateTime(new Date()); + pushGoodsMapper.updateByPrimaryKey(record); + } + + + @Override + public void handPush(Long id) throws Exception, PushGoodsException, PushException { + PushGoods record = selectByPrimaryKey(id); + if (record == null) { + throw new PushGoodsException(1, "鎺ㄩ�佷俊鎭凡涓嶅瓨鍦�"); + } + // 鎵ц鎺ㄩ�� + executePush(record); + + record.setIsPush(PushGoods.STATE_SUCCESS); + record.setPushTime(new Date()); + record.setUpdateTime(new Date()); + pushGoodsMapper.updateByPrimaryKey(record); + } + + + + @Override + public void executePush(PushGoods pushGoods) throws Exception, PushGoodsException, PushException { + + Long id = pushGoods.getId(); String alertTitle = pushGoods.getAlertTitle(); String alertContent = pushGoods.getAlertContent(); if (StringUtil.isNullOrEmpty(alertTitle) || StringUtil.isNullOrEmpty(alertContent)) { - throw new PushException(1, "鎺ㄩ�佹爣棰樺強鍐呭涓嶈兘涓虹┖"); + throw new PushGoodsException(1, "鎺ㄩ�佹爣棰樺強鍐呭涓嶈兘涓虹┖"); } List<PushGoodsGroup> goodsList = pushGoodsGroupService.getAllInfoByPushId(id); if (goodsList == null || goodsList.size() == 0) { - throw new PushException(1, "鎺ㄩ�佹棤鍟嗗搧,璇峰畬鍠勬暟鎹�"); + throw new PushGoodsException(1, "鎺ㄩ�佹棤鍟嗗搧,璇峰畬鍠勬暟鎹�"); } String versions = pushGoods.getVersions(); if (versions == null || versions.trim().length() == 0) { - throw new PushException(1, "鎺ㄩ�佺増鏈笉鑳戒负绌�"); + throw new PushGoodsException(1, "鎺ㄩ�佺増鏈笉鑳戒负绌�"); } List<String> listIOS = new ArrayList<String>(); @@ -264,7 +337,7 @@ PushGoodsGroup pushGoodsGroup = goodsList.get(0); CommonGoods commonGoods = pushGoodsGroup.getCommonGoods(); if (commonGoods == null) { - throw new PushException(1, "鍟嗗搧璇︾粏淇℃伅宸蹭笉瀛樺湪"); + throw new PushGoodsException(1, "鍟嗗搧璇︾粏淇℃伅宸蹭笉瀛樺湪"); } Long goodsId = commonGoods.getGoodsId(); @@ -274,24 +347,15 @@ } else { /* 澶氫釜鍟嗗搧鎺ㄩ�� */ - String url = configService.get("push_goods_details"); + String url = configService.get(ConfigKeyEnum.pushGoodsDetails.getKey()); if (StringUtil.isNullOrEmpty(url)) { - throw new PushException(1, "鎺ㄩ�侀〉闈㈤摼鎺ヤ笉瀛樺湪"); + throw new PushGoodsException(1, "鎺ㄩ�侀〉闈㈤摼鎺ヤ笉瀛樺湪"); } // 鐢熸垚閾炬帴 url = url + "?id=" + id; pushService.pushUrl(pushGoods.getUid(), alertTitle, alertContent, url, listIOS, listAndroid); } - - // 宸叉帹閫� - pushGoods.setPush(true); - // 鎺ㄩ�佹椂闂� - pushGoods.setPushTime(new Date()); - // 鏇存柊鏃堕棿 - pushGoods.setUpdateTime(new Date()); - - updateByPrimaryKeySelective(pushGoods); } - + } -- Gitblit v1.8.0