New file |
| | |
| | | package com.yeshi.fanli.controller.admin;
|
| | |
|
| | | import java.io.PrintWriter;
|
| | | import java.util.ArrayList;
|
| | | import java.util.List;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | | import javax.servlet.http.HttpServletResponse;
|
| | |
|
| | | import net.sf.json.JSONObject;
|
| | |
|
| | | import org.springframework.stereotype.Controller;
|
| | | import org.springframework.web.bind.annotation.RequestMapping;
|
| | | import org.yeshi.utils.JsonUtil;
|
| | |
|
| | | import com.google.gson.Gson;
|
| | | import com.google.gson.GsonBuilder;
|
| | | import com.google.gson.reflect.TypeToken;
|
| | | 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.exception.PushException;
|
| | | import com.yeshi.fanli.exception.push.PushGoodsException;
|
| | | 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.tag.PageEntity;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.annotation.RequestNoLogin;
|
| | |
|
| | | @Controller
|
| | | @RequestMapping("admin/new/api/v1/pushgoods")
|
| | | public class PushGoodsController {
|
| | |
|
| | | @Resource
|
| | | private AdminUserService adminUserService;
|
| | |
|
| | | @Resource
|
| | | private PushGoodsService pushGoodsService;
|
| | |
|
| | | @Resource
|
| | | private PushGoodsGroupService pushGoodsGroupService;
|
| | |
|
| | | /**
|
| | | * 新增/修改
|
| | | * |
| | | * @param callback
|
| | | * @param special
|
| | | * @param out
|
| | | */
|
| | | @RequestNoLogin()
|
| | | @RequestMapping(value = "save")
|
| | | public void save(String callback, PushGoods pushGoods, Long uid, String idArray, HttpServletResponse response,
|
| | | PrintWriter out) {
|
| | |
|
| | | response.setHeader("Access-Control-Allow-Origin", "*");
|
| | | response.setHeader("Access-Control-Allow-Methods", "*");
|
| | |
|
| | | AdminUser admin = adminUserService.selectByPrimaryKey(uid);
|
| | | if (admin == null) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("操作用户验证失败"));
|
| | | return;
|
| | | }
|
| | |
|
| | | try {
|
| | |
|
| | | String alertTitle = pushGoods.getAlertTitle();
|
| | | if (StringUtil.isNullOrEmpty(alertTitle)) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("显示标题不能为空"));
|
| | | return;
|
| | | }
|
| | |
|
| | | // 页面内容标题为空时 显示通知栏上的标题
|
| | | String title = pushGoods.getTitle();
|
| | | if (StringUtil.isNullOrEmpty(title)) {
|
| | | pushGoods.setTitle(pushGoods.getAlertTitle());
|
| | | }
|
| | |
|
| | | Gson gson = new Gson();
|
| | | List<Long> list = gson.fromJson(idArray, new TypeToken<ArrayList<Long>>() {
|
| | | }.getType());
|
| | |
|
| | | pushGoodsService.save(pushGoods, list);
|
| | |
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("添加成功"));
|
| | |
|
| | | } catch (Exception e) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("操作异常"));
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 删除
|
| | | * |
| | | * @param callback
|
| | | * @param idArray
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "delete")
|
| | | public void delete(String callback, String idArray, PrintWriter out) {
|
| | |
|
| | | try {
|
| | | if (StringUtil.isNullOrEmpty(idArray)) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("请选择操作的数据"));
|
| | | return;
|
| | | }
|
| | |
|
| | | Gson gson = new Gson();
|
| | | List<Long> list = gson.fromJson(idArray, new TypeToken<ArrayList<Long>>() {
|
| | | }.getType());
|
| | |
|
| | | if (list == null || list.size() == 0) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("未检测到删除的数据"));
|
| | | return;
|
| | | }
|
| | |
|
| | | int count = pushGoodsService.deleteBatchByPrimaryKey(list);
|
| | |
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("成功删除[" + count + "]条数据"));
|
| | |
|
| | | } catch (Exception e) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("删除失败"));
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 查询
|
| | | * |
| | | * @param callback
|
| | | * @param pageIndex
|
| | | * @param pageSize
|
| | | * @param key
|
| | | * 模糊查询:说明、标识
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "getPushInfo")
|
| | | public void getPushInfo(String callback, Long id, PrintWriter out) {
|
| | |
|
| | | if (id == null) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("参数不能为空"));
|
| | | return;
|
| | | }
|
| | |
|
| | | try {
|
| | |
|
| | | PushGoods pushGoods = pushGoodsService.selectByPrimaryKey(id);
|
| | | if (pushGoods == null) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("数据信息已不存在"));
|
| | | return;
|
| | | }
|
| | |
|
| | | List<PushGoodsGroup> listGroup = pushGoodsGroupService.getAllInfoByPushId(pushGoods.getId());
|
| | | |
| | | JSONObject data = new JSONObject();
|
| | | data.put("pushGoods", pushGoods);
|
| | | data.put("listGroup", listGroup);
|
| | |
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
|
| | |
|
| | | } catch (Exception e) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("操作异常"));
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 查询
|
| | | * |
| | | * @param callback
|
| | | * @param pageIndex
|
| | | * @param pageSize
|
| | | * @param key
|
| | | * 模糊查询:说明、标识
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "query")
|
| | | public void query(String callback, Integer pageIndex, Integer pageSize, String key, Integer state, PrintWriter out) {
|
| | |
|
| | | if (pageIndex == null || pageIndex < 1) {
|
| | | pageIndex = 1;
|
| | | }
|
| | |
|
| | | if (pageSize == null || pageSize < 1) {
|
| | | pageSize = Constant.PAGE_SIZE;
|
| | | }
|
| | |
|
| | | try {
|
| | |
|
| | | List<PushGoods> list = pushGoodsService.listQuery((pageIndex - 1) * pageSize, pageSize, key, state);
|
| | |
|
| | | if (list == null || list.size() == 0) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("暂无数据"));
|
| | | return;
|
| | | }
|
| | |
|
| | | for (PushGoods pushGoods : list) {
|
| | | long countGoods = pushGoodsGroupService.countByPushId(pushGoods.getId());
|
| | | pushGoods.setCountGoods(countGoods);
|
| | | }
|
| | |
|
| | | long count = pushGoodsService.countQuery(key, state);
|
| | |
|
| | | int totalPage = (int) (count % pageSize == 0 ? count / pageSize : count / pageSize + 1);
|
| | | PageEntity pe = new PageEntity(pageIndex, pageSize, count, totalPage);
|
| | |
|
| | | GsonBuilder gsonBuilder = new GsonBuilder();
|
| | | gsonBuilder.serializeNulls();
|
| | | Gson gson = gsonBuilder.setDateFormat("yyyy/MM/dd HH:mm:ss").create();
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("pe", pe);
|
| | | data.put("result_list", gson.toJson(list));
|
| | |
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
|
| | |
|
| | | } catch (Exception e) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("操作异常"));
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | |
| | | |
| | | /**
|
| | | * 网页推送
|
| | | * |
| | | * @param id 推送id
|
| | | * @param out
|
| | | * @throws Exception
|
| | | */
|
| | | @RequestMapping(value = "push")
|
| | | public void push(String callback, Long id, PrintWriter out) throws Exception {
|
| | |
|
| | | if (id == null) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("传递参数不能为空"));
|
| | | return;
|
| | | }
|
| | | |
| | | try {
|
| | | pushGoodsService.executePush(id);
|
| | | |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("推送成功"));
|
| | | |
| | | } catch (PushException e) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg()));
|
| | | } catch (PushGoodsException e) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg()));
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("推送失败"));
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | |
|
| | |
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.controller.apph5;
|
| | |
|
| | | import java.io.PrintWriter;
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import net.sf.json.JSONArray;
|
| | | import net.sf.json.JSONObject;
|
| | |
|
| | | import org.springframework.core.task.TaskExecutor;
|
| | | import org.springframework.stereotype.Controller;
|
| | | import org.springframework.web.bind.annotation.RequestMapping;
|
| | | import org.yeshi.utils.JsonUtil;
|
| | | import org.yeshi.utils.taobao.TbImgUtil;
|
| | |
|
| | | import com.google.gson.Gson;
|
| | | import com.google.gson.GsonBuilder;
|
| | | import com.yeshi.fanli.entity.accept.AcceptData;
|
| | | import com.yeshi.fanli.entity.push.DeviceActive;
|
| | | import com.yeshi.fanli.entity.push.PushGoods;
|
| | | import com.yeshi.fanli.entity.push.PushGoodsGroup;
|
| | | import com.yeshi.fanli.entity.push.PushGoodsRecord;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
|
| | | import com.yeshi.fanli.goods.CommonGoods;
|
| | | import com.yeshi.fanli.service.inter.hongbao.HongBaoManageService;
|
| | | import com.yeshi.fanli.service.inter.push.DeviceActiveService;
|
| | | import com.yeshi.fanli.service.inter.push.PushGoodsGroupService;
|
| | | import com.yeshi.fanli.service.inter.push.PushGoodsRecordService;
|
| | | import com.yeshi.fanli.service.inter.push.PushGoodsService;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.taobao.TaoBaoUtil;
|
| | |
|
| | | /**
|
| | | * 今日推送
|
| | | * |
| | | * @author Administrator
|
| | | *
|
| | | */
|
| | | @Controller
|
| | | @RequestMapping("api/apph5/v1/push")
|
| | | public class AppH5PushController {
|
| | |
|
| | | @Resource(name = "taskExecutor")
|
| | | private TaskExecutor executor;
|
| | |
|
| | | @Resource
|
| | | private HongBaoManageService manageService;
|
| | |
|
| | | @Resource
|
| | | private PushGoodsService pushGoodsService;
|
| | |
|
| | | @Resource
|
| | | private PushGoodsGroupService pushGoodsGroupService;
|
| | |
|
| | | @Resource
|
| | | private DeviceActiveService deviceActiveService;
|
| | |
|
| | | @Resource
|
| | | private PushGoodsRecordService pushGoodsRecordService;
|
| | |
|
| | | /**
|
| | | * 推送商品详情页
|
| | | * |
| | | * @param callback
|
| | | * @param id
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "getpushgoods")
|
| | | public void getPushGoodsDetail(String callback, AcceptData acceptData, String deviceToken, Long id, PrintWriter out) {
|
| | |
|
| | | if (id == null) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("参数不正确"));
|
| | | return;
|
| | | }
|
| | |
|
| | | try {
|
| | | PushGoods pushGoods = pushGoodsService.selectByPrimaryKey(id);
|
| | | if (pushGoods == null) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("此推送记录已不存在"));
|
| | | return;
|
| | | }
|
| | |
|
| | | JSONArray array = new JSONArray();
|
| | | Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
|
| | | .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
|
| | |
|
| | | List<PushGoodsGroup> list = pushGoodsGroupService.getAllInfoByPushId(id);
|
| | |
|
| | | if (list != null && list.size() > 0) {
|
| | |
|
| | | Map<String, String> map = manageService.convertMap();
|
| | | String proportion = map.get("hongbao_goods_proportion");
|
| | | String fcRate = map.get("hongbao_fc_ratio");
|
| | |
|
| | | for (PushGoodsGroup pushGoodsGroup : list) {
|
| | | CommonGoods commonGoods = pushGoodsGroup.getCommonGoods();
|
| | | if (commonGoods == null) {
|
| | | continue;
|
| | | }
|
| | |
|
| | | TaoBaoGoodsBrief goodsBrief = TaoBaoUtil.convert(commonGoods);
|
| | | int biz30day = goodsBrief.getBiz30day();
|
| | | if (biz30day >= 10000) {
|
| | | double sales = biz30day;
|
| | | String salesCountMidea = String.format("%.1f", sales / 10000);
|
| | | goodsBrief.setSalesCount(salesCountMidea + "万");
|
| | | } else {
|
| | | goodsBrief.setSalesCount(biz30day + "");
|
| | | }
|
| | |
|
| | | // 改变图片尺寸
|
| | | String pictUrl = commonGoods.getPicture();
|
| | | if (!StringUtil.isNullOrEmpty(pictUrl) && !pictUrl.contains("320x320")) {
|
| | | commonGoods.setPicture(TbImgUtil.getTBSize320Img(pictUrl));
|
| | | }
|
| | |
|
| | | array.add(gson.toJson(TaoBaoUtil.getTaoBaoGoodsBriefExtra(goodsBrief, proportion, fcRate, null)));
|
| | | }
|
| | | }
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("title", pushGoods.getTitle());
|
| | | data.put("content", pushGoods.getContent());
|
| | | data.put("result_list", array);
|
| | |
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
|
| | |
|
| | | DeviceActive deviceActive = deviceActiveService.getDeviceByDeviceAndPlatform(acceptData.getDevice(),
|
| | | deviceToken, acceptData.getPlatform());
|
| | |
|
| | | // 列表参数、设备参数信息不为空
|
| | | if (deviceActive != null) {
|
| | | // 记录访问信息
|
| | | executor.execute(new Runnable() {
|
| | | @Override
|
| | | public void run() {
|
| | | try {
|
| | |
|
| | | List<PushGoodsRecord> listRecord = pushGoodsRecordService.listByPushIdAndDeviceId(
|
| | | pushGoods.getId(), deviceActive.getId());
|
| | | if (listRecord == null || listRecord.size() == 0) {
|
| | | PushGoodsRecord pushGoodsRecord = new PushGoodsRecord();
|
| | |
|
| | | pushGoodsRecord.setCreateTime(new Date());
|
| | | pushGoodsRecord.setPushGoods(pushGoods);
|
| | | pushGoodsRecord.setDeviceActive(deviceActive);
|
| | | pushGoodsRecordService.insert(pushGoodsRecord);
|
| | | }
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | });
|
| | | }
|
| | |
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | package com.yeshi.fanli.controller.client;
|
| | |
|
| | | import java.io.PrintWriter;
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import net.sf.json.JSONArray;
|
| | | import net.sf.json.JSONObject;
|
| | |
|
| | | import org.springframework.core.task.TaskExecutor;
|
| | | import org.springframework.stereotype.Controller;
|
| | | import org.springframework.web.bind.annotation.RequestMapping;
|
| | | import org.springframework.web.bind.annotation.RequestMethod;
|
| | | import org.yeshi.utils.JsonUtil;
|
| | |
|
| | | import com.yeshi.fanli.entity.accept.AcceptData;
|
| | | import com.yeshi.fanli.entity.common.JumpDetailV2;
|
| | | import com.yeshi.fanli.entity.push.DeviceActive;
|
| | | import com.yeshi.fanli.entity.push.DeviceTokenIOS;
|
| | | import com.yeshi.fanli.entity.push.PushGoods;
|
| | | import com.yeshi.fanli.entity.push.PushGoodsGroup;
|
| | | import com.yeshi.fanli.entity.push.PushGoodsRecord;
|
| | | import com.yeshi.fanli.entity.system.System;
|
| | | import com.yeshi.fanli.exception.push.PushGoodsGroupException;
|
| | | import com.yeshi.fanli.goods.CommonGoods;
|
| | | import com.yeshi.fanli.service.inter.common.JumpDetailV2Service;
|
| | | import com.yeshi.fanli.service.inter.config.ConfigService;
|
| | | import com.yeshi.fanli.service.inter.config.SystemService;
|
| | | import com.yeshi.fanli.service.inter.push.DeviceActiveService;
|
| | | import com.yeshi.fanli.service.inter.push.DeviceTokenHWService;
|
| | | import com.yeshi.fanli.service.inter.push.IOSPushService;
|
| | | import com.yeshi.fanli.service.inter.push.PushGoodsGroupService;
|
| | | import com.yeshi.fanli.service.inter.push.PushGoodsRecordService;
|
| | | import com.yeshi.fanli.service.inter.push.PushGoodsService;
|
| | | import com.yeshi.fanli.service.inter.push.PushRecordService;
|
| | | import com.yeshi.fanli.service.inter.push.PushService;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.factory.JumpDetailParamsFactory;
|
| | |
|
| | | @Controller
|
| | | @RequestMapping(value = "api/v1/push")
|
| | |
| | |
|
| | | @Resource
|
| | | private DeviceActiveService deviceActiveService;
|
| | | |
| | | @Resource
|
| | | private PushService pushService;
|
| | | |
| | | @Resource
|
| | | private PushGoodsService PushGoodsService;
|
| | | |
| | | @Resource
|
| | | private PushGoodsGroupService pushGoodsGroupService;
|
| | | |
| | | @Resource
|
| | | private PushGoodsRecordService pushGoodsRecordService;
|
| | | |
| | | @Resource
|
| | | private JumpDetailV2Service jumpDetailV2Service;
|
| | | |
| | | @Resource
|
| | | private ConfigService configService;
|
| | | |
| | | @Resource(name = "taskExecutor")
|
| | | private TaskExecutor executor;
|
| | |
|
| | | @RequestMapping(value = "callback", method = RequestMethod.POST)
|
| | | public void callback(AcceptData acceptData, String pushId, PrintWriter out) {
|
| | |
| | | da.setVersionCode(Integer.parseInt(acceptData.getVersion()));
|
| | | deviceActiveService.addDeviceActive(da);
|
| | | // 添加token
|
| | | DeviceTokenIOS deviceTokenIOS = iosPushService.getDeviceTokenByDeviceToken(acceptData.getDevice());
|
| | | DeviceTokenIOS deviceTokenIOS = iosPushService.getDeviceTokenByDeviceToken(deviceToken);
|
| | | if (deviceTokenIOS != null) {
|
| | | deviceTokenIOS.setUid(uid);
|
| | | deviceTokenIOS.setDevice(acceptData.getDevice());
|
| | |
| | | deviceTokenHWService.unBindDeviceToken(acceptData.getDevice());
|
| | | out.print(JsonUtil.loadTrueResult("成功"));
|
| | | }
|
| | | |
| | | |
| | | /**
|
| | | * 解绑推送
|
| | | * |
| | | * @param acceptData
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "/gethistory", method = RequestMethod.POST)
|
| | | public void getHistory(AcceptData acceptData, String deviceToken, int page, PrintWriter out) {
|
| | |
|
| | | long count = 0;
|
| | | List<PushGoods> list = null;
|
| | | JSONArray resultList = new JSONArray();
|
| | |
|
| | | DeviceActive deviceActive = deviceActiveService.getDeviceByDeviceAndPlatform(acceptData.getDevice(),
|
| | | deviceToken, acceptData.getPlatform());
|
| | |
|
| | | if (deviceActive != null) {
|
| | |
|
| | | // 设备注册时间
|
| | | Date createTime = deviceActive.getCreateTime();
|
| | | count = PushGoodsService.countHistoryByPushTime(createTime);
|
| | |
|
| | | int pageSize = Constant.PAGE_SIZE;
|
| | |
|
| | | list = PushGoodsService.listHistoryByPushTime((page - 1) * pageSize, pageSize, createTime);
|
| | | if (list != null && list.size() > 0) {
|
| | | for (PushGoods pushGoods : list) {
|
| | | JSONObject result = new JSONObject();
|
| | |
|
| | | Long pushId = pushGoods.getId();
|
| | | String picture = pushGoods.getPicture();
|
| | | String alertContent = pushGoods.getAlertContent();
|
| | | Date pushTime = pushGoods.getPushTime();
|
| | |
|
| | | result.put("content", alertContent);
|
| | | result.put("pushtime", pushTime.getTime());
|
| | |
|
| | | // 统计商品数量
|
| | | long totalgoods = 0;
|
| | | // 商品id
|
| | | Long auctionId = null;
|
| | | if (StringUtil.isNullOrEmpty(picture)) {
|
| | | try {
|
| | | List<PushGoodsGroup> listGroup = pushGoodsGroupService.getAllInfoByPushId(pushId);
|
| | |
|
| | | if (listGroup != null && listGroup.size() > 0) {
|
| | |
|
| | | totalgoods = listGroup.size();
|
| | |
|
| | | PushGoodsGroup pushGoodsGroup = listGroup.get(0);
|
| | | if (pushGoodsGroup != null) {
|
| | | CommonGoods commonGoods = pushGoodsGroup.getCommonGoods();
|
| | | if (commonGoods != null) {
|
| | | picture = commonGoods.getPicture();
|
| | | auctionId = commonGoods.getGoodsId();
|
| | | }
|
| | | }
|
| | | }
|
| | | } catch (PushGoodsGroupException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | result.put("picture", picture);
|
| | |
|
| | | String fontColor1 = "#888888";
|
| | | String fontColor2 = "#F14242";
|
| | | JSONArray array = new JSONArray();
|
| | |
|
| | | JSONArray array1 = new JSONArray();
|
| | | array1.add(fontColor1);
|
| | | array1.add("本次推送共");
|
| | |
|
| | | JSONArray array2 = new JSONArray();
|
| | | array2.add(fontColor2);
|
| | | array2.add(totalgoods);
|
| | |
|
| | | JSONArray array3 = new JSONArray();
|
| | | array3.add(fontColor1);
|
| | | array3.add("个商品");
|
| | |
|
| | | array.add(array1);
|
| | | array.add(array2);
|
| | | array.add(array3);
|
| | |
|
| | | result.put("totalwords", array);
|
| | |
|
| | | String params = "";
|
| | |
|
| | | JumpDetailV2 jumpDetail = null;
|
| | | if (totalgoods == 1) {
|
| | |
|
| | | params = JumpDetailParamsFactory.createGoodsParams(auctionId);
|
| | | // 单个商品跳转商品详情
|
| | | jumpDetail = jumpDetailV2Service.getByTypeCache("goodsdetail");
|
| | |
|
| | | } else {
|
| | | String url = configService.get("push_goods_details");
|
| | | if (url == null) {
|
| | | url = "";
|
| | | }
|
| | | url = url + "?id=" + pushId;
|
| | |
|
| | | params = JumpDetailParamsFactory.createWEBParams(url);
|
| | |
|
| | | // 跳转推荐详情
|
| | | jumpDetail = jumpDetailV2Service.getByTypeCache("web");
|
| | | }
|
| | | result.put("params", params);
|
| | | result.put("jumpDetail", jumpDetail);
|
| | |
|
| | | resultList.add(result);
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | JSONObject resultJson = new JSONObject();
|
| | | resultJson.put("count", count);
|
| | | resultJson.put("result_list", resultList);
|
| | |
|
| | | out.print(JsonUtil.loadTrueResult(resultJson));
|
| | |
|
| | | // 列表参数、设备参数信息不为空
|
| | | if (list != null && list.size() > 0 && deviceActive != null) {
|
| | |
|
| | | final List<PushGoods> listPush = list;
|
| | | // 记录访问信息
|
| | | executor.execute(new Runnable() {
|
| | | @Override
|
| | | public void run() {
|
| | | try {
|
| | | Long deviceId = deviceActive.getId();
|
| | |
|
| | | for (PushGoods pushGoods : listPush) {
|
| | | List<PushGoodsRecord> listRecord = pushGoodsRecordService.listByPushIdAndDeviceId(
|
| | | pushGoods.getId(), deviceId);
|
| | | if (listRecord != null && listRecord.size() > 0) {
|
| | | continue; // 已被记录
|
| | | }
|
| | |
|
| | | PushGoodsRecord pushGoodsRecord = new PushGoodsRecord();
|
| | |
|
| | | pushGoodsRecord.setCreateTime(new Date());
|
| | | pushGoodsRecord.setPushGoods(pushGoods);
|
| | | pushGoodsRecord.setDeviceActive(deviceActive);
|
| | | pushGoodsRecordService.insert(pushGoodsRecord);
|
| | | }
|
| | |
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | }
|
| | | });
|
| | | }
|
| | | }
|
| | | |
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.dao.mybatis.push; |
| | | |
| | | import java.util.List; |
| | | |
| | | import com.yeshi.fanli.entity.push.PushGoodsGroup; |
| | | |
| | | public interface PushGoodsGroupMapper { |
| | | |
| | | int deleteByPrimaryKey(Long id); |
| | | |
| | | int insert(PushGoodsGroup record); |
| | | |
| | | int insertSelective(PushGoodsGroup record); |
| | | |
| | | PushGoodsGroup selectByPrimaryKey(Long id); |
| | | |
| | | int updateByPrimaryKeySelective(PushGoodsGroup record); |
| | | |
| | | int updateByPrimaryKey(PushGoodsGroup record); |
| | | |
| | | /** |
| | | * 根据推送id统计 |
| | | * @param pushId |
| | | * @return |
| | | */ |
| | | long countByPushId(Long pushId); |
| | | |
| | | /** |
| | | * 根据推送id删除商品 |
| | | * @param pushId |
| | | * @return |
| | | */ |
| | | int deleteByPushId(Long pushId); |
| | | |
| | | |
| | | /** |
| | | * 根据推送id查询商品 |
| | | * @param pushId |
| | | * @return |
| | | */ |
| | | List<PushGoodsGroup> selectByPushId(Long pushId); |
| | | |
| | | /** |
| | | * 根据推送id查询商品所有信息 |
| | | * @param pushId |
| | | * @return |
| | | */ |
| | | List<PushGoodsGroup> getAllInfoByPushId(Long pushId); |
| | | |
| | | /** |
| | | * 批量插入 |
| | | * @param list |
| | | * @return |
| | | */ |
| | | int insertBatch(List<PushGoodsGroup> list); |
| | | |
| | | /** |
| | | * 批量删除 |
| | | * @param list |
| | | * @return |
| | | */ |
| | | int deleteBatchByPrimaryKey(List<Long> list); |
| | | |
| | | /** |
| | | * 批量删除 根据推送id |
| | | * @param list |
| | | * @return |
| | | */ |
| | | int deleteBatchByPushId(List<Long> list); |
| | | |
| | | } |
New file |
| | |
| | | package com.yeshi.fanli.dao.mybatis.push; |
| | | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import com.yeshi.fanli.entity.push.PushGoods; |
| | | |
| | | public interface PushGoodsMapper { |
| | | |
| | | int deleteByPrimaryKey(Long id); |
| | | |
| | | int insert(PushGoods record); |
| | | |
| | | int insertSelective(PushGoods record); |
| | | |
| | | PushGoods selectByPrimaryKey(Long id); |
| | | |
| | | int updateByPrimaryKeySelective(PushGoods record); |
| | | |
| | | int updateByPrimaryKey(PushGoods record); |
| | | |
| | | /** |
| | | * 批量删除 |
| | | * @param list |
| | | * @return |
| | | */ |
| | | int deleteBatchByPrimaryKey(List<Long> list); |
| | | |
| | | /** |
| | | * 后端列表查询 |
| | | * @param start |
| | | * @param count |
| | | * @param key |
| | | * @return |
| | | */ |
| | | List<PushGoods> listQuery(@Param("start") long start, @Param("count") int count, |
| | | @Param("key") String key, @Param("state") Integer state); |
| | | |
| | | long countQuery(@Param("key") String key, @Param("state") Integer state); |
| | | |
| | | |
| | | /** |
| | | * 获取历史推送商品信息 |
| | | * @param start |
| | | * @param count |
| | | * @param pushTime |
| | | * @return |
| | | */ |
| | | List<PushGoods> listHistoryByPushTime(@Param("start") long start, @Param("count") int count, |
| | | @Param("pushTime") Date pushTime); |
| | | |
| | | /** |
| | | * 统计历史推送商品信息 |
| | | * @param start |
| | | * @param count |
| | | * @param pushTime |
| | | * @return |
| | | */ |
| | | long countHistoryByPushTime(@Param("pushTime") Date pushTime); |
| | | |
| | | /** |
| | | * 查询已推送记录 |
| | | * @param list |
| | | * @return |
| | | */ |
| | | List<PushGoods> listByPushState(List<Long> list); |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.yeshi.fanli.dao.mybatis.push; |
| | | |
| | | import java.util.List; |
| | | |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import com.yeshi.fanli.entity.push.PushGoodsRecord; |
| | | |
| | | public interface PushGoodsRecordMapper { |
| | | |
| | | int deleteByPrimaryKey(Long id); |
| | | |
| | | int insert(PushGoodsRecord record); |
| | | |
| | | int insertSelective(PushGoodsRecord record); |
| | | |
| | | PushGoodsRecord selectByPrimaryKey(Long id); |
| | | |
| | | int updateByPrimaryKeySelective(PushGoodsRecord record); |
| | | |
| | | int updateByPrimaryKey(PushGoodsRecord record); |
| | | |
| | | /** |
| | | * 根据推送id 设备id 查询 |
| | | * @param pushId |
| | | * @param deviceId |
| | | * @return |
| | | */ |
| | | List<PushGoodsRecord> listByPushIdAndDeviceId( @Param("pushId")Long pushId, @Param("deviceId") Long deviceId); |
| | | } |
New file |
| | |
| | | package com.yeshi.fanli.entity.push;
|
| | |
|
| | | import java.util.Date;
|
| | |
|
| | | import org.yeshi.utils.mybatis.Column;
|
| | | import org.yeshi.utils.mybatis.Table;
|
| | |
|
| | | @Table("yeshi_ec_push_goods")
|
| | | public class PushGoods {
|
| | |
|
| | | @Column(name = "pg_id")
|
| | | private Long id;
|
| | |
|
| | | // 显示标题
|
| | | @Column(name = "pg_alert_title")
|
| | | private String alertTitle;
|
| | |
|
| | | // 显示内容
|
| | | @Column(name = "pg_alert_content")
|
| | | private String alertContent;
|
| | | |
| | | // 页面标题
|
| | | @Column(name = "pg_title")
|
| | | private String title;
|
| | | |
| | | // 页面内容(html)
|
| | | @Column(name = "pg_content")
|
| | | private String content;
|
| | | |
| | | // 封面图片
|
| | | @Column(name = "pg_picture")
|
| | | private String picture;
|
| | | |
| | | // 推送用户id 使用于单推
|
| | | @Column(name = "pg_uid")
|
| | | private Long uid;
|
| | | |
| | | // 是否已推送
|
| | | @Column(name = "pg_is_push")
|
| | | private boolean isPush;
|
| | | |
| | | // 推送时间
|
| | | @Column(name = "pg_push_time")
|
| | | private Date pushTime;
|
| | | |
| | | @Column(name = "pg_createtime")
|
| | | private Date createTime;
|
| | | |
| | | @Column(name = "pg_updatetime")
|
| | | private Date updateTime;
|
| | |
|
| | | |
| | | // 统计商品数量
|
| | | private Long countGoods; |
| | | |
| | | |
| | | public PushGoods(){}
|
| | | |
| | | public PushGoods(Long id){
|
| | | this.id = id;
|
| | | }
|
| | | |
| | | |
| | | |
| | | public Long getId() {
|
| | | return id;
|
| | | }
|
| | |
|
| | | public void setId(Long id) {
|
| | | this.id = id;
|
| | | }
|
| | |
|
| | | public String getAlertTitle() {
|
| | | return alertTitle;
|
| | | }
|
| | |
|
| | | public void setAlertTitle(String alertTitle) {
|
| | | this.alertTitle = alertTitle;
|
| | | }
|
| | |
|
| | | public String getAlertContent() {
|
| | | return alertContent;
|
| | | }
|
| | |
|
| | | public void setAlertContent(String alertContent) {
|
| | | this.alertContent = alertContent;
|
| | | }
|
| | |
|
| | | public String getTitle() {
|
| | | return title;
|
| | | }
|
| | |
|
| | | public void setTitle(String title) {
|
| | | this.title = title;
|
| | | }
|
| | |
|
| | | public String getContent() {
|
| | | return content;
|
| | | }
|
| | |
|
| | | public void setContent(String content) {
|
| | | this.content = content;
|
| | | }
|
| | |
|
| | | public boolean isPush() {
|
| | | return isPush;
|
| | | }
|
| | |
|
| | | public void setPush(boolean isPush) {
|
| | | this.isPush = isPush;
|
| | | }
|
| | |
|
| | | public Date getPushTime() {
|
| | | return pushTime;
|
| | | }
|
| | |
|
| | | public void setPushTime(Date pushTime) {
|
| | | this.pushTime = pushTime;
|
| | | }
|
| | |
|
| | | public Date getCreateTime() {
|
| | | return createTime;
|
| | | }
|
| | |
|
| | | public void setCreateTime(Date createTime) {
|
| | | this.createTime = createTime;
|
| | | }
|
| | |
|
| | | public Date getUpdateTime() {
|
| | | return updateTime;
|
| | | }
|
| | |
|
| | | public void setUpdateTime(Date updateTime) {
|
| | | this.updateTime = updateTime;
|
| | | }
|
| | |
|
| | | public Long getUid() {
|
| | | return uid;
|
| | | }
|
| | |
|
| | | public void setUid(Long uid) {
|
| | | this.uid = uid;
|
| | | }
|
| | |
|
| | | public Long getCountGoods() {
|
| | | return countGoods;
|
| | | }
|
| | |
|
| | | public void setCountGoods(Long countGoods) {
|
| | | this.countGoods = countGoods;
|
| | | }
|
| | |
|
| | | public String getPicture() {
|
| | | return picture;
|
| | | }
|
| | |
|
| | | public void setPicture(String picture) {
|
| | | this.picture = picture;
|
| | | }
|
| | | |
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.entity.push;
|
| | |
|
| | | import org.yeshi.utils.mybatis.Column;
|
| | | import org.yeshi.utils.mybatis.Table;
|
| | |
|
| | | import com.yeshi.fanli.goods.CommonGoods;
|
| | |
|
| | | @Table("yeshi_ec_push_goods_group")
|
| | | public class PushGoodsGroup {
|
| | |
|
| | | @Column(name = "gro_id")
|
| | | private Long id;
|
| | |
|
| | | // 推送id
|
| | | @Column(name = "gro_push_id")
|
| | | private Long pushId;
|
| | |
|
| | | // 商品
|
| | | @Column(name = "gro_goods_id")
|
| | | private CommonGoods commonGoods;
|
| | |
|
| | | public Long getId() {
|
| | | return id;
|
| | | }
|
| | |
|
| | | public void setId(Long id) {
|
| | | this.id = id;
|
| | | }
|
| | |
|
| | | public Long getPushId() {
|
| | | return pushId;
|
| | | }
|
| | |
|
| | | public void setPushId(Long pushId) {
|
| | | this.pushId = pushId;
|
| | | }
|
| | |
|
| | | public CommonGoods getCommonGoods() {
|
| | | return commonGoods;
|
| | | }
|
| | |
|
| | | public void setCommonGoods(CommonGoods commonGoods) {
|
| | | this.commonGoods = commonGoods;
|
| | | }
|
| | | |
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.entity.push;
|
| | |
|
| | | import java.util.Date;
|
| | |
|
| | | import org.yeshi.utils.mybatis.Column;
|
| | | import org.yeshi.utils.mybatis.Table;
|
| | |
|
| | | /**
|
| | | * 推送商品记录
|
| | | * |
| | | * @author yj
|
| | | *
|
| | | */
|
| | | @Table("yeshi_ec_push_goods_record")
|
| | | public class PushGoodsRecord {
|
| | |
|
| | | @Column(name = "rod_id")
|
| | | private Long id;
|
| | |
|
| | | // 推送id
|
| | | @Column(name = "rod_push_id")
|
| | | private PushGoods pushGoods;
|
| | |
|
| | | // 设备id
|
| | | @Column(name = "rod_device_id")
|
| | | private DeviceActive deviceActive;
|
| | |
|
| | | @Column(name = "rod_createtime")
|
| | | private Date createTime;
|
| | |
|
| | | public Long getId() {
|
| | | return id;
|
| | | }
|
| | |
|
| | | public void setId(Long id) {
|
| | | this.id = id;
|
| | | }
|
| | |
|
| | | public PushGoods getPushGoods() {
|
| | | return pushGoods;
|
| | | }
|
| | |
|
| | | public void setPushGoods(PushGoods pushGoods) {
|
| | | this.pushGoods = pushGoods;
|
| | | }
|
| | |
|
| | | public DeviceActive getDeviceActive() {
|
| | | return deviceActive;
|
| | | }
|
| | |
|
| | | public void setDeviceActive(DeviceActive deviceActive) {
|
| | | this.deviceActive = deviceActive;
|
| | | }
|
| | |
|
| | | public Date getCreateTime() {
|
| | | return createTime;
|
| | | }
|
| | |
|
| | | public void setCreateTime(Date createTime) {
|
| | | this.createTime = createTime;
|
| | | }
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.exception.push;
|
| | |
|
| | | public class PushGoodsException extends Exception {
|
| | | |
| | | private static final long serialVersionUID = 1L;
|
| | | |
| | | private int code;
|
| | | private String msg;
|
| | |
|
| | | public PushGoodsException() {}
|
| | | |
| | | public PushGoodsException(int code, String msg) {
|
| | | this.code = code;
|
| | | this.msg = msg;
|
| | | }
|
| | |
|
| | | public int getCode() {
|
| | | return code;
|
| | | }
|
| | |
|
| | | public String getMsg() {
|
| | | return msg;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public String getMessage() {
|
| | | return this.msg;
|
| | | }
|
| | |
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.exception.push;
|
| | |
|
| | | public class PushGoodsGroupException extends Exception {
|
| | | |
| | | private static final long serialVersionUID = 1L;
|
| | | |
| | | private int code;
|
| | | private String msg;
|
| | |
|
| | | public PushGoodsGroupException() {}
|
| | | |
| | | public PushGoodsGroupException(int code, String msg) {
|
| | | this.code = code;
|
| | | this.msg = msg;
|
| | | }
|
| | |
|
| | | public int getCode() {
|
| | | return code;
|
| | | }
|
| | |
|
| | | public String getMsg() {
|
| | | return msg;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public String getMessage() {
|
| | | return this.msg;
|
| | | }
|
| | |
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.exception.push;
|
| | |
|
| | | public class PushGoodsRecordException extends Exception {
|
| | | |
| | | private static final long serialVersionUID = 1L;
|
| | | |
| | | private int code;
|
| | | private String msg;
|
| | |
|
| | | public PushGoodsRecordException() {}
|
| | | |
| | | public PushGoodsRecordException(int code, String msg) {
|
| | | this.code = code;
|
| | | this.msg = msg;
|
| | | }
|
| | |
|
| | | public int getCode() {
|
| | | return code;
|
| | | }
|
| | |
|
| | | public String getMsg() {
|
| | | return msg;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public String getMessage() {
|
| | | return this.msg;
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | @Column(name = "cg_updatetime")
|
| | | private Date updateTime;
|
| | |
|
| | | public CommonGoods() {}
|
| | | |
| | | public CommonGoods(Long id) {
|
| | | this.id = id;
|
| | | }
|
| | | |
| | | public Long getId() {
|
| | | return id;
|
| | | }
|
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | |
| | | <mapper namespace="com.yeshi.fanli.dao.mybatis.push.PushGoodsGroupMapper"> |
| | | <resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.push.PushGoodsGroup"> |
| | | <id column="gro_id" property="id" jdbcType="BIGINT"/> |
| | | <result column="gro_push_id" property="pushId" jdbcType="BIGINT"/> |
| | | |
| | | <association property="commonGoods" column="gro_goods_id" |
| | | resultMap="com.yeshi.fanli.dao.mybatis.goods.CommonGoodsMapper.BaseResultMap" /> |
| | | |
| | | </resultMap> |
| | | <sql id="Base_Column_List">gro_id,gro_push_id,gro_goods_id</sql> |
| | | <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">select |
| | | <include refid="Base_Column_List"/>from yeshi_ec_push_goods_group where gro_id = #{id,jdbcType=BIGINT} |
| | | </select> |
| | | <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from yeshi_ec_push_goods_group where gro_id = #{id,jdbcType=BIGINT}</delete> |
| | | <insert id="insert" parameterType="com.yeshi.fanli.entity.push.PushGoodsGroup" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_push_goods_group (gro_id,gro_push_id,gro_goods_id) values (#{id,jdbcType=BIGINT},#{pushId,jdbcType=BIGINT},#{commonGoods.id,jdbcType=BIGINT})</insert> |
| | | <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.push.PushGoodsGroup" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_push_goods_group |
| | | <trim prefix="(" suffix=")" suffixOverrides=","> |
| | | <if test="id != null">gro_id,</if> |
| | | <if test="pushId != null">gro_push_id,</if> |
| | | <if test="commonGoods != null">gro_goods_id,</if> |
| | | </trim>values |
| | | <trim prefix="(" suffix=")" suffixOverrides=","> |
| | | <if test="id != null">#{id,jdbcType=BIGINT},</if> |
| | | <if test="pushId != null">#{pushId,jdbcType=BIGINT},</if> |
| | | <if test="commonGoods != null">#{commonGoods.id,jdbcType=BIGINT},</if> |
| | | </trim> |
| | | </insert> |
| | | <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.push.PushGoodsGroup">update yeshi_ec_push_goods_group set gro_push_id = #{pushId,jdbcType=BIGINT},gro_goods_id = #{commonGoods.id,jdbcType=BIGINT} where gro_id = #{id,jdbcType=BIGINT}</update> |
| | | <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.push.PushGoodsGroup">update yeshi_ec_push_goods_group |
| | | <set> |
| | | <if test="pushId != null">gro_push_id=#{pushId,jdbcType=BIGINT},</if> |
| | | <if test="commonGoods != null">gro_goods_id=#{commonGoods.id,jdbcType=BIGINT},</if> |
| | | </set> where gro_id = #{id,jdbcType=BIGINT} |
| | | </update> |
| | | |
| | | <delete id="deleteBatchByPrimaryKey" parameterType="java.util.List"> |
| | | delete from yeshi_ec_push_goods_group where gro_id in |
| | | <foreach item="item" collection="list" open="(" separator="," |
| | | close=")">#{item}</foreach> |
| | | </delete> |
| | | |
| | | <delete id="deleteByPushId" parameterType="java.lang.Long"> |
| | | delete from yeshi_ec_push_goods_group |
| | | where gro_push_id = #{pushId,jdbcType=BIGINT} |
| | | </delete> |
| | | |
| | | |
| | | <delete id="deleteBatchByPushId" parameterType="java.util.List"> |
| | | delete from yeshi_ec_push_goods_group where gro_push_id in |
| | | <foreach item="item" collection="list" open="(" separator="," |
| | | close=")">#{item}</foreach> |
| | | </delete> |
| | | |
| | | <select id="selectByPushId" resultMap="BaseResultMap" parameterType="java.lang.Long"> |
| | | select <include refid="Base_Column_List"/> from yeshi_ec_push_goods_group |
| | | where gro_push_id = #{pushId,jdbcType=BIGINT} |
| | | </select> |
| | | |
| | | <insert id="insertBatch" parameterType="java.util.List"> |
| | | insert into yeshi_ec_push_goods_group |
| | | (<include refid="Base_Column_List" />) |
| | | values |
| | | <foreach collection="list" item="item" separator=","> |
| | | ( |
| | | #{item.id,jdbcType=BIGINT}, |
| | | #{item.pushId,jdbcType=BIGINT}, |
| | | #{item.commonGoods.id,jdbcType=BIGINT}, |
| | | ) |
| | | </foreach> |
| | | </insert> |
| | | |
| | | <select id="countByPushId" resultType="java.lang.Long" parameterType="java.lang.Long"> |
| | | SELECT IFNULL(count(gro_id),0) from yeshi_ec_push_goods_group |
| | | where gro_push_id = #{pushId,jdbcType=BIGINT} |
| | | </select> |
| | | |
| | | <select id="getAllInfoByPushId" resultMap="BaseResultMap" parameterType="java.lang.Long"> |
| | | SELECT * FROM yeshi_ec_push_goods_group ph |
| | | LEFT JOIN `yeshi_ec_common_goods` gg ON ph.`gro_goods_id` = gg.`cg_id` |
| | | WHERE gro_push_id = #{pushId,jdbcType=BIGINT} |
| | | </select> |
| | | |
| | | </mapper> |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | |
| | | <mapper namespace="com.yeshi.fanli.dao.mybatis.push.PushGoodsMapper"> |
| | | <resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.push.PushGoods"> |
| | | <id column="pg_id" property="id" jdbcType="BIGINT"/> |
| | | <result column="pg_alert_title" property="alertTitle" jdbcType="VARCHAR"/> |
| | | <result column="pg_alert_content" property="alertContent" jdbcType="VARCHAR"/> |
| | | <result column="pg_title" property="title" jdbcType="VARCHAR"/> |
| | | <result column="pg_content" property="content" jdbcType="VARCHAR"/> |
| | | <result column="pg_picture" property="picture" jdbcType="VARCHAR"/> |
| | | <result column="pg_uid" property="uid" jdbcType="BIGINT"/> |
| | | <result column="pg_is_push" property="isPush" jdbcType="VARCHAR"/> |
| | | <result column="pg_push_time" property="pushTime" jdbcType="TIMESTAMP"/> |
| | | <result column="pg_createtime" property="createTime" jdbcType="TIMESTAMP"/> |
| | | <result column="pg_updatetime" property="updateTime" jdbcType="TIMESTAMP"/> |
| | | </resultMap> |
| | | <sql id="Base_Column_List">pg_id,pg_alert_title,pg_alert_content,pg_title,pg_content,pg_picture,pg_uid,pg_is_push,pg_push_time,pg_createtime,pg_updatetime</sql> |
| | | <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">select |
| | | <include refid="Base_Column_List"/>from yeshi_ec_push_goods where pg_id = #{id,jdbcType=BIGINT} |
| | | </select> |
| | | <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from yeshi_ec_push_goods where pg_id = #{id,jdbcType=BIGINT}</delete> |
| | | <insert id="insert" parameterType="com.yeshi.fanli.entity.push.PushGoods" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_push_goods (pg_id,pg_alert_title,pg_alert_content,pg_title,pg_content,pg_picture,pg_uid,pg_is_push,pg_push_time,pg_createtime,pg_updatetime) values (#{id,jdbcType=BIGINT},#{alertTitle,jdbcType=VARCHAR},#{alertContent,jdbcType=VARCHAR},#{title,jdbcType=VARCHAR},#{content,jdbcType=VARCHAR},#{picture,jdbcType=VARCHAR},#{uid,jdbcType=BIGINT},#{isPush,jdbcType=VARCHAR},#{pushTime,jdbcType=TIMESTAMP},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP})</insert> |
| | | <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.push.PushGoods" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_push_goods |
| | | <trim prefix="(" suffix=")" suffixOverrides=","> |
| | | <if test="id != null">pg_id,</if> |
| | | <if test="alertTitle != null">pg_alert_title,</if> |
| | | <if test="alertContent != null">pg_alert_content,</if> |
| | | <if test="title != null">pg_title,</if> |
| | | <if test="content != null">pg_content,</if> |
| | | <if test="picture != null">pg_picture,</if> |
| | | <if test="uid != null">pg_uid,</if> |
| | | <if test="isPush != null">pg_is_push,</if> |
| | | <if test="pushTime != null">pg_push_time,</if> |
| | | <if test="createTime != null">pg_createtime,</if> |
| | | <if test="updateTime != null">pg_updatetime,</if> |
| | | </trim>values |
| | | <trim prefix="(" suffix=")" suffixOverrides=","> |
| | | <if test="id != null">#{id,jdbcType=BIGINT},</if> |
| | | <if test="alertTitle != null">#{alertTitle,jdbcType=VARCHAR},</if> |
| | | <if test="alertContent != null">#{alertContent,jdbcType=VARCHAR},</if> |
| | | <if test="title != null">#{title,jdbcType=VARCHAR},</if> |
| | | <if test="content != null">#{content,jdbcType=VARCHAR},</if> |
| | | <if test="picture != null">#{picture,jdbcType=VARCHAR},</if> |
| | | <if test="uid != null">#{uid,jdbcType=BIGINT},</if> |
| | | <if test="isPush != null">#{isPush,jdbcType=VARCHAR},</if> |
| | | <if test="pushTime != null">#{pushTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="updateTime != null">#{updateTime,jdbcType=TIMESTAMP},</if> |
| | | </trim> |
| | | </insert> |
| | | <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.push.PushGoods">update yeshi_ec_push_goods set pg_alert_title = #{alertTitle,jdbcType=VARCHAR},pg_alert_content = #{alertContent,jdbcType=VARCHAR},pg_title = #{title,jdbcType=VARCHAR},pg_content = #{content,jdbcType=VARCHAR},pg_picture = #{picture,jdbcType=VARCHAR},pg_uid = #{uid,jdbcType=BIGINT},pg_is_push = #{isPush,jdbcType=VARCHAR},pg_push_time = #{pushTime,jdbcType=TIMESTAMP},pg_createtime = #{createTime,jdbcType=TIMESTAMP},pg_updatetime = #{updateTime,jdbcType=TIMESTAMP} where pg_id = #{id,jdbcType=BIGINT}</update> |
| | | <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.push.PushGoods">update yeshi_ec_push_goods |
| | | <set> |
| | | <if test="alertTitle != null">pg_alert_title=#{alertTitle,jdbcType=VARCHAR},</if> |
| | | <if test="alertContent != null">pg_alert_content=#{alertContent,jdbcType=VARCHAR},</if> |
| | | <if test="title != null">pg_title=#{title,jdbcType=VARCHAR},</if> |
| | | <if test="content != null">pg_content=#{content,jdbcType=VARCHAR},</if> |
| | | <if test="picture != null">pg_picture=#{picture,jdbcType=VARCHAR},</if> |
| | | <if test="uid != null">pg_uid=#{uid,jdbcType=BIGINT},</if> |
| | | <if test="isPush != null">pg_is_push=#{isPush,jdbcType=VARCHAR},</if> |
| | | <if test="pushTime != null">pg_push_time=#{pushTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="createTime != null">pg_createtime=#{createTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="updateTime != null">pg_updatetime=#{updateTime,jdbcType=TIMESTAMP},</if> |
| | | </set> where pg_id = #{id,jdbcType=BIGINT} |
| | | </update> |
| | | |
| | | |
| | | <delete id="deleteBatchByPrimaryKey" parameterType="java.util.List"> |
| | | delete from yeshi_ec_push_goods where gro_id in |
| | | <foreach item="item" collection="list" open="(" separator="," |
| | | close=")">#{item}</foreach> |
| | | </delete> |
| | | |
| | | <select id="listQuery" resultMap="BaseResultMap"> |
| | | SELECT <include refid="Base_Column_List" /> FROM yeshi_ec_push_goods |
| | | WHERE 1=1 |
| | | <if test='key != null and key != ""'> |
| | | AND (pg_alert_title like '%${key}%' or pg_alert_content like '%${key}%') |
| | | </if> |
| | | <if test='state != null'> |
| | | AND pg_is_push = #{state} |
| | | </if> |
| | | ORDER BY pg_createtime desc |
| | | LIMIT ${start},${count} |
| | | </select> |
| | | |
| | | <select id="countQuery" resultType="java.lang.Long"> |
| | | SELECT IFNULL(count(pg_id),0) FROM yeshi_ec_push_goods |
| | | WHERE 1=1 |
| | | <if test='key != null and key != ""'> |
| | | AND (pg_alert_title like '%${key}%' or pg_alert_content like '%${key}%') |
| | | </if> |
| | | <if test='state != null'> |
| | | AND pg_is_push = #{state} |
| | | </if> |
| | | </select> |
| | | |
| | | <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}]]> |
| | | 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}]]> |
| | | </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 |
| | | <foreach item="item" collection="list" open="(" separator="," |
| | | close=")">#{item}</foreach> |
| | | </select> |
| | | </mapper> |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | |
| | | <mapper namespace="com.yeshi.fanli.dao.mybatis.push.PushGoodsRecordMapper"> |
| | | <resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.push.PushGoodsRecord"> |
| | | <id column="rod_id" property="id" jdbcType="BIGINT"/> |
| | | <result column="rod_createtime" property="createTime" jdbcType="TIMESTAMP"/> |
| | | |
| | | <association property="deviceActive" column="rod_device_id" |
| | | javaType="com.yeshi.fanli.entity.push.DeviceActive"> |
| | | <id column="rod_device_id" property="id" jdbcType="BIGINT" /> |
| | | </association> |
| | | |
| | | <association property="pushGoods" column="rod_push_id" |
| | | javaType="com.yeshi.fanli.entity.push.PushGoods"> |
| | | <id column="rod_device_id" property="id" jdbcType="BIGINT" /> |
| | | </association> |
| | | |
| | | </resultMap> |
| | | |
| | | <resultMap id="AllResultMap" type="com.yeshi.fanli.entity.push.PushGoodsRecord"> |
| | | <id column="rod_id" property="id" jdbcType="BIGINT"/> |
| | | <result column="rod_createtime" property="createTime" jdbcType="TIMESTAMP"/> |
| | | |
| | | <association property="deviceActive" column="rod_device_id" |
| | | resultMap="com.yeshi.fanli.dao.mybatis.push.DeviceActiveMapper.BaseResultMap"/> |
| | | |
| | | <association property="pushGoods" column="rod_push_id" |
| | | resultMap="com.yeshi.fanli.dao.mybatis.push.PushGoodsMapper.BaseResultMap"/> |
| | | </resultMap> |
| | | |
| | | |
| | | |
| | | <sql id="Base_Column_List">rod_id,rod_push_id,rod_device_id,rod_createtime</sql> |
| | | <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">select |
| | | <include refid="Base_Column_List"/>from yeshi_ec_push_goods_record where rod_id = #{id,jdbcType=BIGINT} |
| | | </select> |
| | | <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from yeshi_ec_push_goods_record where rod_id = #{id,jdbcType=BIGINT}</delete> |
| | | <insert id="insert" parameterType="com.yeshi.fanli.entity.push.PushGoodsRecord" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_push_goods_record (rod_id,rod_push_id,rod_device_id,rod_createtime) values (#{id,jdbcType=BIGINT},#{pushGoods.id,jdbcType=VARCHAR},#{deviceActive.id,jdbcType=VARCHAR},#{createTime,jdbcType=TIMESTAMP})</insert> |
| | | <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.push.PushGoodsRecord" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_push_goods_record |
| | | <trim prefix="(" suffix=")" suffixOverrides=","> |
| | | <if test="id != null">rod_id,</if> |
| | | <if test="pushGoods != null">rod_push_id,</if> |
| | | <if test="deviceActive != null">rod_device_id,</if> |
| | | <if test="createTime != null">rod_createtime,</if> |
| | | </trim>values |
| | | <trim prefix="(" suffix=")" suffixOverrides=","> |
| | | <if test="id != null">#{id,jdbcType=BIGINT},</if> |
| | | <if test="pushGoods != null">#{pushGoods.id,jdbcType=VARCHAR},</if> |
| | | <if test="deviceActive != null">#{deviceActive.id,jdbcType=VARCHAR},</if> |
| | | <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if> |
| | | </trim> |
| | | </insert> |
| | | <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.push.PushGoodsRecord">update yeshi_ec_push_goods_record set rod_push_id = #{pushGoods.id,jdbcType=VARCHAR},rod_device_id = #{deviceActive.id,jdbcType=VARCHAR},rod_createtime = #{createTime,jdbcType=TIMESTAMP} where rod_id = #{id,jdbcType=BIGINT}</update> |
| | | <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.push.PushGoodsRecord">update yeshi_ec_push_goods_record |
| | | <set> |
| | | <if test="pushGoods != null">rod_push_id=#{pushGoods.id,jdbcType=VARCHAR},</if> |
| | | <if test="deviceActive != null">rod_device_id=#{deviceActive.id,jdbcType=VARCHAR},</if> |
| | | <if test="createTime != null">rod_createtime=#{createTime,jdbcType=TIMESTAMP},</if> |
| | | </set> where rod_id = #{id,jdbcType=BIGINT} |
| | | </update> |
| | | |
| | | <select id="listByPushIdAndDeviceId" resultMap="BaseResultMap"> |
| | | select <include refid="Base_Column_List"/> from yeshi_ec_push_goods_record |
| | | where rod_push_id = #{pushId} and rod_device_id = #{deviceId} |
| | | </select> |
| | | |
| | | </mapper> |
| | |
| | | return;
|
| | | }
|
| | | }
|
| | | |
| | | |
| | | /**
|
| | | * |
| | | * @param device 设备号
|
| | | * @param platform 平台类型
|
| | | * @return
|
| | | */
|
| | | @Override
|
| | | public DeviceActive getDeviceByDeviceAndPlatform(String device, String deviceToken, String platform) {
|
| | | |
| | | DeviceActive deviceActive = null;
|
| | | if ("android".equalsIgnoreCase(platform)) {
|
| | | |
| | | deviceActive = deviceActiveMapper.selectByDeviceAndPlatform(device, DeviceActive.PLATFORM_ANDROID);
|
| | | |
| | | } else if ("ios".equalsIgnoreCase(platform)) {
|
| | | |
| | | deviceActive = deviceActiveMapper.selectByDeviceToeknMd5AndPlatform(StringUtil.Md5(deviceToken),
|
| | | DeviceActive.PLATFORM_IOS);
|
| | | |
| | | }
|
| | | |
| | | return deviceActive;
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | return;
|
| | |
|
| | | // 判断device是否存在
|
| | | DeviceTokenIOS deviceTokenIos = deviceTokenIOSMapper.selectByDevice(device);
|
| | | DeviceTokenIOS deviceTokenIos = deviceTokenIOSMapper.selectByDeviceToken(deviceToken);
|
| | | if (deviceTokenIos == null) {
|
| | | deviceTokenIos = new DeviceTokenIOS();
|
| | | deviceTokenIos.setCreateTime(new Date());
|
New file |
| | |
| | | package com.yeshi.fanli.service.impl.push;
|
| | |
|
| | | import java.util.List;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.stereotype.Service;
|
| | |
|
| | | import com.yeshi.fanli.dao.mybatis.push.PushGoodsGroupMapper;
|
| | | import com.yeshi.fanli.entity.push.PushGoodsGroup;
|
| | | import com.yeshi.fanli.exception.push.PushGoodsGroupException;
|
| | | import com.yeshi.fanli.service.inter.push.PushGoodsGroupService;
|
| | |
|
| | | @Service
|
| | | public class PushGoodsGroupServiceImpl implements PushGoodsGroupService {
|
| | | |
| | | @Resource
|
| | | private PushGoodsGroupMapper pushGoodsGroupMapper;
|
| | | |
| | |
|
| | | @Override
|
| | | public int deleteByPrimaryKey(Long id) throws PushGoodsGroupException {
|
| | | return pushGoodsGroupMapper.deleteByPrimaryKey(id);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public int insert(PushGoodsGroup record) throws PushGoodsGroupException {
|
| | | return pushGoodsGroupMapper.insert(record);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public int insertSelective(PushGoodsGroup record) throws PushGoodsGroupException {
|
| | | return pushGoodsGroupMapper.insertSelective(record);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public PushGoodsGroup selectByPrimaryKey(Long id) throws PushGoodsGroupException {
|
| | | return pushGoodsGroupMapper.selectByPrimaryKey(id);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public int updateByPrimaryKeySelective(PushGoodsGroup record) throws PushGoodsGroupException {
|
| | | return pushGoodsGroupMapper.updateByPrimaryKeySelective(record);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public int updateByPrimaryKey(PushGoodsGroup record) throws PushGoodsGroupException {
|
| | | return pushGoodsGroupMapper.updateByPrimaryKey(record);
|
| | | }
|
| | | |
| | | @Override
|
| | | public int deleteByPushId(Long pushId) throws PushGoodsGroupException {
|
| | | return pushGoodsGroupMapper.deleteByPushId(pushId);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public int insertBatch(List<PushGoodsGroup> list) throws PushGoodsGroupException {
|
| | | return pushGoodsGroupMapper.insertBatch(list);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public List<PushGoodsGroup> selectByPushId(Long pushId) throws PushGoodsGroupException {
|
| | | return pushGoodsGroupMapper.selectByPushId(pushId);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public int deleteBatchByPrimaryKey(List<Long> list) throws PushGoodsGroupException {
|
| | | return pushGoodsGroupMapper.deleteBatchByPrimaryKey(list);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public int deleteBatchByPushId(List<Long> list) throws PushGoodsGroupException {
|
| | | return pushGoodsGroupMapper.deleteBatchByPushId(list);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public long countByPushId(Long pushId) {
|
| | | return pushGoodsGroupMapper.countByPushId(pushId);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public List<PushGoodsGroup> getAllInfoByPushId(Long pushId) throws PushGoodsGroupException {
|
| | | return pushGoodsGroupMapper.getAllInfoByPushId(pushId);
|
| | | }
|
| | | |
| | | |
| | |
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.service.impl.push;
|
| | |
|
| | | import java.util.List;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.stereotype.Service;
|
| | |
|
| | | import com.yeshi.fanli.dao.mybatis.push.PushGoodsRecordMapper;
|
| | | import com.yeshi.fanli.entity.push.PushGoodsRecord;
|
| | | import com.yeshi.fanli.exception.push.PushGoodsRecordException;
|
| | | import com.yeshi.fanli.service.inter.push.PushGoodsRecordService;
|
| | |
|
| | | @Service
|
| | | public class PushGoodsRecordServiceImpl implements PushGoodsRecordService {
|
| | | |
| | | @Resource
|
| | | private PushGoodsRecordMapper pushGoodsRecordMapper;
|
| | | |
| | |
|
| | | @Override
|
| | | public int deleteByPrimaryKey(Long id) throws PushGoodsRecordException {
|
| | | return pushGoodsRecordMapper.deleteByPrimaryKey(id);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public int insert(PushGoodsRecord record) throws PushGoodsRecordException {
|
| | | return pushGoodsRecordMapper.insert(record);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public int insertSelective(PushGoodsRecord record) throws PushGoodsRecordException {
|
| | | return pushGoodsRecordMapper.insertSelective(record);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public PushGoodsRecord selectByPrimaryKey(Long id) throws PushGoodsRecordException {
|
| | | return pushGoodsRecordMapper.selectByPrimaryKey(id);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public int updateByPrimaryKeySelective(PushGoodsRecord record) throws PushGoodsRecordException {
|
| | | return pushGoodsRecordMapper.updateByPrimaryKeySelective(record);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public int updateByPrimaryKey(PushGoodsRecord record) throws PushGoodsRecordException {
|
| | | return pushGoodsRecordMapper.updateByPrimaryKey(record);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public List<PushGoodsRecord> listByPushIdAndDeviceId(Long pushId, Long deviceId) throws PushGoodsRecordException {
|
| | | return pushGoodsRecordMapper.listByPushIdAndDeviceId(pushId, deviceId);
|
| | | }
|
| | | |
| | | |
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.service.impl.push;
|
| | |
|
| | | import java.util.ArrayList;
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | |
|
| | | 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.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.PushGoodsService;
|
| | | 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
|
| | | public class PushGoodsServiceImpl implements PushGoodsService {
|
| | |
|
| | | @Resource
|
| | | private PushService pushService;
|
| | |
|
| | | @Resource
|
| | | private ConfigService configService;
|
| | |
|
| | | @Resource
|
| | | private PushGoodsMapper pushGoodsMapper;
|
| | |
|
| | | @Resource
|
| | | private CommonGoodsService commonGoodsService;
|
| | |
|
| | | @Resource
|
| | | private PushGoodsGroupService pushGoodsGroupService;
|
| | |
|
| | | @Override
|
| | | public int deleteByPrimaryKey(Long id) throws PushGoodsException {
|
| | | return pushGoodsMapper.deleteByPrimaryKey(id);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public int insert(PushGoods record) throws PushGoodsException {
|
| | | return pushGoodsMapper.insert(record);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public int insertSelective(PushGoods record) throws PushGoodsException {
|
| | | return pushGoodsMapper.insertSelective(record);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public PushGoods selectByPrimaryKey(Long id) throws PushGoodsException {
|
| | | return pushGoodsMapper.selectByPrimaryKey(id);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public int updateByPrimaryKeySelective(PushGoods record) throws PushGoodsException {
|
| | | return pushGoodsMapper.updateByPrimaryKeySelective(record);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public int updateByPrimaryKey(PushGoods record) throws PushGoodsException {
|
| | | return pushGoodsMapper.updateByPrimaryKey(record);
|
| | | }
|
| | |
|
| | | @Override
|
| | | @Transactional
|
| | | public void save(PushGoods record, List<Long> goodsIds) throws Exception {
|
| | |
|
| | | boolean isAdd = false;
|
| | | // 推送id
|
| | | Long pushId = record.getId();
|
| | | if (pushId == null) {
|
| | | // 新增
|
| | | isAdd = true;
|
| | |
|
| | | record.setCreateTime(new Date());
|
| | | record.setUpdateTime(new Date());
|
| | | pushGoodsMapper.insertSelective(record);
|
| | |
|
| | | pushId = record.getId();
|
| | |
|
| | | } else {
|
| | | // 修改
|
| | | record.setUpdateTime(new Date());
|
| | | pushGoodsMapper.insertSelective(record);
|
| | | }
|
| | |
|
| | | // 处理商品信息
|
| | | saveGoodsInfo(isAdd, pushId, goodsIds);
|
| | | }
|
| | |
|
| | | @Transactional
|
| | | public void saveGoodsInfo(boolean isAdd, Long pushId, List<Long> goodsIds) throws Exception {
|
| | |
|
| | | if (goodsIds == null || goodsIds.size() == 0) {
|
| | | if (!isAdd) {
|
| | | pushGoodsGroupService.deleteByPushId(pushId);
|
| | | }
|
| | | return;
|
| | | }
|
| | |
|
| | | // 商品信息获取与保存
|
| | | 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);
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | /* 修改时删除 部分 */
|
| | | if (!isAdd) {
|
| | |
|
| | | List<Long> listdelete = new ArrayList<Long>();
|
| | |
|
| | | List<PushGoodsGroup> listGroup = pushGoodsGroupService.selectByPushId(pushId);
|
| | |
|
| | | if (listGroup != null && listGroup.size() > 0) {
|
| | | for (PushGoodsGroup group : listGroup) {
|
| | | Long groupId = group.getId();
|
| | |
|
| | | CommonGoods commonGoods = group.getCommonGoods();
|
| | | if (commonGoods != null) {
|
| | | Long commonId = commonGoods.getId();
|
| | | if (commonId != null && listCommonId.contains(groupId)) {
|
| | | // 已经存在
|
| | | listCommonId.remove(commonId);
|
| | | } else {
|
| | | // 已经被删除
|
| | | listdelete.add(groupId);
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | // 删除已被前端清除商品
|
| | | if (listdelete.size() > 0) {
|
| | | pushGoodsGroupService.deleteBatchByPrimaryKey(listdelete);
|
| | | }
|
| | | }
|
| | |
|
| | | // 插入商品列表
|
| | | if (listCommonId.size() > 0 && !listCommonId.isEmpty()) {
|
| | | List<PushGoodsGroup> listAdd = new ArrayList<PushGoodsGroup>();
|
| | | for (Long cid : listCommonId) {
|
| | | PushGoodsGroup pushGoodsGroup = new PushGoodsGroup();
|
| | | pushGoodsGroup.setPushId(pushId);
|
| | | pushGoodsGroup.setCommonGoods(new CommonGoods(cid));
|
| | | listAdd.add(pushGoodsGroup);
|
| | | }
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | @Override
|
| | | @Transactional
|
| | | public int deleteBatchByPrimaryKey(List<Long> list) throws Exception {
|
| | |
|
| | | List<PushGoods> lisState = pushGoodsMapper.listByPushState(list);
|
| | | if (lisState != null && lisState.size() > 0) {
|
| | | for (PushGoods pushGoods : lisState) {
|
| | | // 已推送的消息不能删除
|
| | | list.remove(pushGoods.getId());
|
| | | }
|
| | | }
|
| | |
|
| | | // 删除对应商品
|
| | | pushGoodsGroupService.deleteBatchByPushId(list);
|
| | |
|
| | | return pushGoodsMapper.deleteBatchByPrimaryKey(list);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public List<PushGoods> listQuery(long start, int count, String key, Integer state) {
|
| | | return pushGoodsMapper.listQuery(start, count, key, state);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public long countQuery(String key, Integer state) {
|
| | | return pushGoodsMapper.countQuery(key, state);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public List<PushGoods> listHistoryByPushTime(long start, int count, Date pushTime) {
|
| | | return pushGoodsMapper.listHistoryByPushTime(start, count, pushTime);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public long countHistoryByPushTime(Date pushTime) {
|
| | | return pushGoodsMapper.countHistoryByPushTime(pushTime);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void executePush(Long id) throws Exception, PushGoodsException, PushException {
|
| | |
|
| | | PushGoods pushGoods = selectByPrimaryKey(id);
|
| | | if (pushGoods == null) {
|
| | | throw new PushException(1, "推送信息已不存在");
|
| | | }
|
| | |
|
| | | String alertTitle = pushGoods.getAlertTitle();
|
| | | String alertContent = pushGoods.getAlertContent();
|
| | | if (StringUtil.isNullOrEmpty(alertTitle) || StringUtil.isNullOrEmpty(alertContent)) {
|
| | | throw new PushException(1, "推送标题及内容不能为空");
|
| | | }
|
| | |
|
| | | List<PushGoodsGroup> goodsList = pushGoodsGroupService.getAllInfoByPushId(id);
|
| | | if (goodsList == null || goodsList.size() == 0) {
|
| | | throw new PushException(1, "推送无商品,请完善数据");
|
| | | }
|
| | |
|
| | | if (goodsList.size() == 1) {
|
| | | /* 单个商品推送: 直接处理为商品信息 */
|
| | | PushGoodsGroup pushGoodsGroup = goodsList.get(0);
|
| | | CommonGoods commonGoods = pushGoodsGroup.getCommonGoods();
|
| | | if (commonGoods == null) {
|
| | | throw new PushException(1, "商品详细信息已不存在");
|
| | | }
|
| | |
|
| | | 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);
|
| | |
|
| | | } else {
|
| | | /* 多个商品推送 */
|
| | | String url = configService.get("push_goods_details");
|
| | | if (StringUtil.isNullOrEmpty(url)) {
|
| | | throw new PushException(1, "推送页面链接不存在");
|
| | | }
|
| | | // 生成链接
|
| | | 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);
|
| | | }
|
| | | |
| | | // 已推送
|
| | | pushGoods.setPush(true);
|
| | | // 推送时间
|
| | | pushGoods.setPushTime(new Date());
|
| | | // 更新时间
|
| | | pushGoods.setUpdateTime(new Date());
|
| | | |
| | | updateByPrimaryKeySelective(pushGoods);
|
| | |
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | */
|
| | | public void addDeviceActive(DeviceActive deviceActive);
|
| | |
|
| | | /**
|
| | | * |
| | | * @param device 设备号
|
| | | * @param platform 平台类型
|
| | | * @return
|
| | | */
|
| | | public DeviceActive getDeviceByDeviceAndPlatform(String device, String deviceToken, String platform);
|
| | | |
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.service.inter.push;
|
| | |
|
| | | import java.util.List;
|
| | |
|
| | | import com.yeshi.fanli.entity.push.PushGoodsGroup;
|
| | | import com.yeshi.fanli.exception.push.PushGoodsGroupException;
|
| | |
|
| | | public interface PushGoodsGroupService {
|
| | |
|
| | | public int deleteByPrimaryKey(Long id) throws PushGoodsGroupException;
|
| | |
|
| | | public int insert(PushGoodsGroup record) throws PushGoodsGroupException;
|
| | |
|
| | | public int insertSelective(PushGoodsGroup record) throws PushGoodsGroupException;
|
| | |
|
| | | public PushGoodsGroup selectByPrimaryKey(Long id) throws PushGoodsGroupException;
|
| | |
|
| | | public int updateByPrimaryKeySelective(PushGoodsGroup record) throws PushGoodsGroupException;
|
| | |
|
| | | public int updateByPrimaryKey(PushGoodsGroup record) throws PushGoodsGroupException;
|
| | |
|
| | |
|
| | | /**
|
| | | * 根据推送id统计
|
| | | * @param pushId
|
| | | * @return
|
| | | */
|
| | | public long countByPushId(Long pushId);
|
| | | |
| | | /**
|
| | | * 根据推送id删除商品
|
| | | * @param pushId
|
| | | * @return
|
| | | */
|
| | | public int deleteByPushId(Long pushId) throws PushGoodsGroupException;
|
| | | |
| | | /**
|
| | | * 批量插入
|
| | | * @param list
|
| | | * @return
|
| | | */
|
| | | public int insertBatch(List<PushGoodsGroup> list) throws PushGoodsGroupException;
|
| | | |
| | | /**
|
| | | * 根据推送id查询
|
| | | * @param pushId
|
| | | * @return
|
| | | */
|
| | | public List<PushGoodsGroup> selectByPushId(Long pushId) throws PushGoodsGroupException;
|
| | | |
| | | /**
|
| | | * 批量删除
|
| | | * @param list
|
| | | * @return
|
| | | */
|
| | | public int deleteBatchByPrimaryKey(List<Long> list) throws PushGoodsGroupException;
|
| | | |
| | | /**
|
| | | * 批量删除 根据推送id
|
| | | * @param list
|
| | | * @return
|
| | | */
|
| | | public int deleteBatchByPushId(List<Long> list) throws PushGoodsGroupException;
|
| | | |
| | | |
| | | /**
|
| | | * 根据推送id查询商品所有信息
|
| | | * @param pushId
|
| | | * @return
|
| | | */
|
| | | public List<PushGoodsGroup> getAllInfoByPushId(Long pushId) throws PushGoodsGroupException;
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.service.inter.push;
|
| | |
|
| | | import java.util.List;
|
| | |
|
| | | import com.yeshi.fanli.entity.push.PushGoodsRecord;
|
| | | import com.yeshi.fanli.exception.push.PushGoodsRecordException;
|
| | |
|
| | | public interface PushGoodsRecordService {
|
| | |
|
| | | public int deleteByPrimaryKey(Long id) throws PushGoodsRecordException;
|
| | |
|
| | | public int insert(PushGoodsRecord record) throws PushGoodsRecordException;
|
| | |
|
| | | public int insertSelective(PushGoodsRecord record) throws PushGoodsRecordException;
|
| | |
|
| | | public PushGoodsRecord selectByPrimaryKey(Long id) throws PushGoodsRecordException;
|
| | |
|
| | | public int updateByPrimaryKeySelective(PushGoodsRecord record) throws PushGoodsRecordException;
|
| | |
|
| | | public int updateByPrimaryKey(PushGoodsRecord record) throws PushGoodsRecordException;
|
| | | |
| | | /**
|
| | | * 根据推送id 设备id 查询
|
| | | * @param pushId
|
| | | * @param deviceId
|
| | | * @return
|
| | | */
|
| | | public List<PushGoodsRecord> listByPushIdAndDeviceId(Long pushId, Long deviceId) throws PushGoodsRecordException;
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.service.inter.push;
|
| | |
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | |
|
| | | import com.yeshi.fanli.entity.push.PushGoods;
|
| | | import com.yeshi.fanli.exception.PushException;
|
| | | import com.yeshi.fanli.exception.push.PushGoodsException;
|
| | |
|
| | | public interface PushGoodsService {
|
| | |
|
| | | public int deleteByPrimaryKey(Long id) throws PushGoodsException;
|
| | |
|
| | | public int insert(PushGoods record) throws PushGoodsException;
|
| | |
|
| | | public int insertSelective(PushGoods record) throws PushGoodsException;
|
| | |
|
| | | public PushGoods selectByPrimaryKey(Long id) throws PushGoodsException;
|
| | |
|
| | | public int updateByPrimaryKeySelective(PushGoods record) throws PushGoodsException;
|
| | |
|
| | | public int updateByPrimaryKey(PushGoods record) throws PushGoodsException;
|
| | |
|
| | | public void save(PushGoods record, List<Long> goodsId) throws Exception;
|
| | | |
| | | /**
|
| | | * 批量删除
|
| | | * @param list
|
| | | * @return
|
| | | */
|
| | | public int deleteBatchByPrimaryKey(List<Long> list) throws Exception;
|
| | | |
| | | |
| | | /**
|
| | | * 后端列表查询
|
| | | * @param start
|
| | | * @param count
|
| | | * @param key
|
| | | * @return
|
| | | */
|
| | | public List<PushGoods> listQuery(long start, int count, String key, Integer state);
|
| | | |
| | | public long countQuery(String key, Integer state);
|
| | |
|
| | | /**
|
| | | * 获取历史推送商品信息
|
| | | * @param start
|
| | | * @param count
|
| | | * @param pushTime
|
| | | * @return
|
| | | */
|
| | | public List<PushGoods> listHistoryByPushTime(long start, int count, Date pushTime);
|
| | |
|
| | | public long countHistoryByPushTime(Date pushTime);
|
| | |
|
| | | |
| | | /**
|
| | | * 执行推送
|
| | | * @param id
|
| | | * @throws Exception
|
| | | * @throws PushGoodsException
|
| | | * @throws PushException
|
| | | */
|
| | | public void executePush(Long id) throws Exception, PushGoodsException, PushException;
|
| | | |
| | | }
|
| | |
| | | * @param auctionId
|
| | | * @return
|
| | | */
|
| | | public static String createGoodsParams(ClientTBPid clientTBPid, Long auctionId) {
|
| | | public static String createGoodsParams(Long auctionId) {
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("id", auctionId);
|
| | | return data.toString();
|
| | |
| | |
|
| | | PushNotificationManager pushManager = new PushNotificationManager();
|
| | | // true:表示的是产品线上发布推送服务 false:表示的是产品测试推送服务
|
| | | pushManager.initializeConnection(new AppleNotificationServerBasicImpl(certificate, certificatePassword, true));
|
| | | if(Constant.IS_TEST)
|
| | | pushManager.initializeConnection(new AppleNotificationServerBasicImpl(certificate, certificatePassword, false));
|
| | | else
|
| | | pushManager.initializeConnection(new AppleNotificationServerBasicImpl(certificate, certificatePassword, true));
|
| | |
|
| | | List<Device> deviceList = new ArrayList<Device>();
|
| | | for (String token : tokenList) {
|