| | |
| | | import javax.annotation.Resource;
|
| | | import javax.transaction.Transactional;
|
| | |
|
| | | import net.sf.json.JSONObject;
|
| | |
|
| | | import org.springframework.stereotype.Service;
|
| | | import org.yeshi.utils.HttpUtil;
|
| | |
|
| | | import com.yeshi.fanli.dao.mybatis.push.PushGoodsMapper;
|
| | | 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.taobao.TaoBaoGoodsBrief;
|
| | | import com.yeshi.fanli.exception.PushException;
|
| | | import com.yeshi.fanli.exception.push.PushGoodsException;
|
| | | import com.yeshi.fanli.goods.CommonGoods;
|
| | | import com.yeshi.fanli.service.inter.config.ConfigService;
|
| | | import com.yeshi.fanli.service.inter.goods.CommonGoodsService;
|
| | | import com.yeshi.fanli.service.inter.push.PushGoodsGroupService;
|
| | |
| | | import com.yeshi.fanli.service.inter.push.PushService;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.factory.CommonGoodsFactory;
|
| | | import com.yeshi.fanli.util.factory.IOSPushFactory;
|
| | | import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
|
| | |
|
| | | @Service
|
| | |
| | | } else {
|
| | | // 修改
|
| | | record.setUpdateTime(new Date());
|
| | | pushGoodsMapper.insertSelective(record);
|
| | | pushGoodsMapper.updateByPrimaryKeySelective(record);
|
| | | }
|
| | |
|
| | | // 处理商品信息
|
| | |
| | | @Transactional
|
| | | public int deleteBatchByPrimaryKey(List<Long> list) throws Exception {
|
| | |
|
| | | List<PushGoods> lisState = pushGoodsMapper.listByPushState(list);
|
| | | /*List<PushGoods> lisState = pushGoodsMapper.listByPushState(list);
|
| | | if (lisState != null && lisState.size() > 0) {
|
| | | for (PushGoods pushGoods : lisState) {
|
| | | // 已推送的消息不能删除
|
| | | list.remove(pushGoods.getId());
|
| | | }
|
| | | }
|
| | | }*/
|
| | |
|
| | | // 删除对应商品
|
| | | pushGoodsGroupService.deleteBatchByPushId(list);
|
| | |
| | | }
|
| | |
|
| | | @Override
|
| | | public List<PushGoods> listHistoryByPushTime(long start, int count, Date pushTime) {
|
| | | return pushGoodsMapper.listHistoryByPushTime(start, count, pushTime);
|
| | | public List<PushGoods> listHistoryByPushTime(long start, int count, Long uid, Date pushTime) {
|
| | | return pushGoodsMapper.listHistoryByPushTime(start, count, uid, pushTime);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public long countHistoryByPushTime(Date pushTime) {
|
| | | return pushGoodsMapper.countHistoryByPushTime(pushTime);
|
| | | public long countHistoryByPushTime(Long uid, Date pushTime) {
|
| | | return pushGoodsMapper.countHistoryByPushTime(uid, pushTime);
|
| | | }
|
| | |
|
| | | @Override
|
| | |
| | | }
|
| | |
|
| | | Long goodsId = commonGoods.getGoodsId();
|
| | | JSONObject json = IOSPushFactory.createGoodsPush(goodsId, alertTitle, alertContent);
|
| | | if (json.toString().getBytes().length > 256) {
|
| | | throw new PushException(1, "标题或内容过长,请删减后再试");
|
| | | }
|
| | |
|
| | | String url = "https://item.taobao.com/item.htm?id=" + goodsId;
|
| | |
|
| | | pushService.pushGoods(pushGoods.getUid(), url, alertTitle, alertContent);
|
| | |
| | | }
|
| | | // 生成链接
|
| | | url = url + "?id=" + id;
|
| | |
|
| | | JSONObject json = IOSPushFactory.createURLPush(HttpUtil.getShortLink(url), alertTitle, alertContent);
|
| | | if (json.toString().getBytes().length > 256) {
|
| | | throw new PushException(1, "标题或内容过长,请删减后再试");
|
| | | }
|
| | |
|
| | | pushService.pushUrl(pushGoods.getUid(), url, alertTitle, alertContent);
|
| | | }
|