| | |
| | | import com.yeshi.fanli.entity.common.AdminUser;
|
| | | 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.AdminUserService;
|
| | | import com.yeshi.fanli.service.inter.push.PushGoodsGroupService;
|
| | | import com.yeshi.fanli.service.inter.push.PushGoodsService;
|
| | |
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.annotation.RequestNoLogin;
|
| | | import com.yeshi.fanli.util.taobao.TaoBaoUtil;
|
| | |
|
| | | @Controller
|
| | | @RequestMapping("admin/new/api/v1/pushgoods")
|
| | |
| | | return;
|
| | | }
|
| | |
|
| | | List<TaoBaoGoodsBrief> listgoods = new ArrayList<TaoBaoGoodsBrief>();
|
| | | |
| | | List<PushGoodsGroup> listGroup = pushGoodsGroupService.getAllInfoByPushId(pushGoods.getId());
|
| | | if (listGroup == null) {
|
| | | listGroup = new ArrayList<PushGoodsGroup>();
|
| | | } else {
|
| | | for (PushGoodsGroup pushGoodsGroup: listGroup) {
|
| | | CommonGoods commonGoods = pushGoodsGroup.getCommonGoods();
|
| | | if (commonGoods != null) {
|
| | | TaoBaoGoodsBrief goodsBrief = TaoBaoUtil.convert(commonGoods);
|
| | | listgoods.add(goodsBrief);
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("pushGoods", pushGoods);
|
| | | data.put("listGroup", listGroup);
|
| | | data.put("listGroup", listgoods);
|
| | |
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
|
| | |
|
| | |
| | | * @param acceptData
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "/gethistory"/*, method = RequestMethod.POST*/)
|
| | | public void getHistory(AcceptData acceptData, String deviceToken, int page, PrintWriter out) {
|
| | | @RequestMapping(value = "/gethistory", method = RequestMethod.POST)
|
| | | public void getHistory(AcceptData acceptData, Long uid, String deviceToken, int page, PrintWriter out) {
|
| | |
|
| | | long count = 0;
|
| | | List<PushGoods> list = null;
|
| | |
| | |
|
| | | // 设备注册时间
|
| | | Date createTime = deviceActive.getCreateTime();
|
| | | count = PushGoodsService.countHistoryByPushTime(createTime);
|
| | | count = PushGoodsService.countHistoryByPushTime(uid, createTime);
|
| | |
|
| | | int pageSize = Constant.PAGE_SIZE;
|
| | |
|
| | | list = PushGoodsService.listHistoryByPushTime((page - 1) * pageSize, pageSize, createTime);
|
| | | list = PushGoodsService.listHistoryByPushTime((page - 1) * pageSize, pageSize, uid, createTime);
|
| | | if (list != null && list.size() > 0) {
|
| | | for (PushGoods pushGoods : list) {
|
| | | JSONObject result = new JSONObject();
|
| | |
| | | long secondTeam = threeSaleSerivce.countSecondTeam(uid, 1);
|
| | | long secondTeamTotal = threeSaleSerivce.countSecondTeam(uid, null);
|
| | |
|
| | | JSONObject bossData = new JSONObject();
|
| | | JSONObject bossData = null;
|
| | | ThreeSale threeSale = threeSaleSerivce.getMyBoss(uid);
|
| | | if (threeSale != null) {
|
| | | |
| | | bossData = new JSONObject();
|
| | | UserInfo boss = threeSale.getBoss();
|
| | | if (boss != null) {
|
| | | bossData.put("nickName", boss.getNickName());
|
| | |
| | | long secondTeam = threeSaleSerivce.countSecondTeam(uid, 1);
|
| | | long secondTeamTotal = threeSaleSerivce.countSecondTeam(uid, null);
|
| | |
|
| | | JSONObject bossData = new JSONObject();
|
| | | JSONObject bossData = null;
|
| | | ThreeSale threeSale = threeSaleSerivce.getMyBoss(uid);
|
| | | if (threeSale != null) {
|
| | | |
| | | bossData = new JSONObject();
|
| | | UserInfo boss = threeSale.getBoss();
|
| | | if (boss != null) {
|
| | | bossData.put("nickName", boss.getNickName());
|
| | |
| | | * @return |
| | | */ |
| | | List<PushGoods> listHistoryByPushTime(@Param("start") long start, @Param("count") int count, |
| | | @Param("pushTime") Date pushTime); |
| | | @Param("uid") Long uid, @Param("pushTime") Date pushTime); |
| | | |
| | | /** |
| | | * 统计历史推送商品信息 |
| | |
| | | * @param pushTime |
| | | * @return |
| | | */ |
| | | long countHistoryByPushTime(@Param("pushTime") Date pushTime); |
| | | long countHistoryByPushTime(@Param("uid") Long uid, @Param("pushTime") Date pushTime); |
| | | |
| | | /** |
| | | * 查询已推送记录 |
| | |
| | | |
| | | |
| | | <delete id="deleteBatchByPrimaryKey" parameterType="java.util.List"> |
| | | delete from yeshi_ec_push_goods where gro_id in |
| | | delete from yeshi_ec_push_goods where pg_id in |
| | | <foreach item="item" collection="list" open="(" separator="," |
| | | close=")">#{item}</foreach> |
| | | </delete> |
| | |
| | | |
| | | <select id="listHistoryByPushTime" resultMap="BaseResultMap"> |
| | | SELECT <include refid="Base_Column_List" /> FROM yeshi_ec_push_goods |
| | | WHERE pg_is_push = 1 AND <![CDATA[pg_push_time >= #{pushTime}]]> |
| | | WHERE pg_is_push = 1 AND <![CDATA[pg_push_time >= #{pushTime}]]> |
| | | AND (pg_uid is null <if test='uid != null'>or pg_uid = #{uid} </if>) |
| | | ORDER BY pg_push_time desc |
| | | LIMIT ${start},${count} |
| | | </select> |
| | | |
| | | <select id="countHistoryByPushTime" resultType="java.lang.Long"> |
| | | SELECT IFNULL(count(pg_id),0) FROM yeshi_ec_push_goods |
| | | WHERE pg_is_push = 1 AND <![CDATA[pg_push_time >= #{pushTime}]]> |
| | | WHERE pg_is_push = 1 AND <![CDATA[pg_push_time >= #{pushTime}]]> |
| | | AND (pg_uid is null <if test='uid != null'>or pg_uid = #{uid} </if>) |
| | | </select> |
| | | |
| | | <select id="listByPushState" resultMap="BaseResultMap" parameterType="java.util.List"> |
| | | SELECT <include refid="Base_Column_List" /> FROM yeshi_ec_push_goods |
| | | WHERE pg_is_push = 1 AND gro_id in |
| | | WHERE pg_is_push = 1 AND pg_id in |
| | | <foreach item="item" collection="list" open="(" separator="," |
| | | close=")">#{item}</foreach> |
| | | </select> |
| | |
| | | @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);
|
| | | }
|
| | |
| | | * @param pushTime
|
| | | * @return
|
| | | */
|
| | | public List<PushGoods> listHistoryByPushTime(long start, int count, Date pushTime);
|
| | | public List<PushGoods> listHistoryByPushTime(long start, int count, Long uid, Date pushTime);
|
| | |
|
| | | public long countHistoryByPushTime(Date pushTime);
|
| | | public long countHistoryByPushTime(Long uid, Date pushTime);
|
| | |
|
| | |
|
| | | /**
|