| | |
| | |
|
| | | 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 com.yeshi.fanli.entity.accept.AcceptData;
|
| | | import com.yeshi.fanli.entity.common.JumpDetailV2;
|
| | | import com.yeshi.fanli.entity.goods.CommonGoods;
|
| | | 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.util.Constant;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.factory.JumpDetailParamsFactory;
|
| | |
|
| | | import net.sf.json.JSONArray;
|
| | | import net.sf.json.JSONObject;
|
| | |
|
| | | @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;
|
| | |
|
| | |
| | | da.setDeviceToken(deviceToken);
|
| | | da.setPlatform(DeviceActive.PLATFORM_IOS);
|
| | | da.setVersionCode(Integer.parseInt(acceptData.getVersion()));
|
| | | da.setDevice(acceptData.getDevice());
|
| | | deviceActiveService.addDeviceActive(da);
|
| | |
|
| | | DeviceTokenIOS deviceTokenIOS = iosPushService.getDeviceTokenByDeviceToken(deviceToken);
|
| | | if (deviceTokenIOS == null)
|
| | | iosPushService.addDeviceToken(null, Integer.parseInt(acceptData.getVersion()), deviceToken,
|
| | | acceptData.getDevice());
|
| | | else {
|
| | | deviceTokenIOS.setDevice(acceptData.getDevice());
|
| | | iosPushService.updateDeviceToken(deviceTokenIOS);
|
| | | }
|
| | | iosPushService.addDeviceToken(null, Integer.parseInt(acceptData.getVersion()), deviceToken,
|
| | | acceptData.getDevice());
|
| | | out.print(JsonUtil.loadTrue(0, null, "成功"));
|
| | | }
|
| | | }
|
| | |
| | | da.setDeviceToken(deviceToken);
|
| | | da.setPlatform(DeviceActive.PLATFORM_IOS);
|
| | | da.setVersionCode(Integer.parseInt(acceptData.getVersion()));
|
| | | da.setDevice(acceptData.getDevice());
|
| | | deviceActiveService.addDeviceActive(da);
|
| | | // 添加token
|
| | | DeviceTokenIOS deviceTokenIOS = iosPushService.getDeviceTokenByDeviceToken(deviceToken);
|
| | | if (deviceTokenIOS != null) {
|
| | | deviceTokenIOS.setUid(uid);
|
| | | deviceTokenIOS.setDevice(acceptData.getDevice());
|
| | | deviceTokenIOS.setVersion(Integer.parseInt(acceptData.getVersion()));
|
| | | iosPushService.updateDeviceToken(deviceTokenIOS);
|
| | | } else {
|
| | | iosPushService.addDeviceToken(uid, Integer.parseInt(acceptData.getVersion()), deviceToken,
|
| | | acceptData.getDevice());
|
| | | }
|
| | | out.print(JsonUtil.loadTrueResult(""));
|
| | | iosPushService.addDeviceToken(uid, Integer.parseInt(acceptData.getVersion()), deviceToken,
|
| | | acceptData.getDevice());
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | */
|
| | | @RequestMapping(value = "/unBind", method = RequestMethod.POST)
|
| | | public void unBind(AcceptData acceptData, String deviceToken, PrintWriter out) {
|
| | | if (!StringUtil.isNullOrEmpty(deviceToken)) {
|
| | | DeviceTokenIOS deviceTokenIOS = iosPushService.getDeviceTokenByDeviceToken(deviceToken);
|
| | | if (deviceTokenIOS != null) {
|
| | | deviceTokenIOS.setUid(null);
|
| | | iosPushService.updateDeviceToken(deviceTokenIOS);
|
| | | }
|
| | | if (!StringUtil.isNullOrEmpty(acceptData.getDevice())) {
|
| | | iosPushService.unBindUidAndDevice(acceptData.getDevice());
|
| | | out.print(JsonUtil.loadTrue(0, null, "解绑成功"));
|
| | | }
|
| | | }
|
| | |
| | | deviceTokenHWService.unBindDeviceToken(acceptData.getDevice());
|
| | | out.print(JsonUtil.loadTrueResult("成功"));
|
| | | }
|
| | | |
| | | |
| | |
|
| | | /**
|
| | | * 解绑推送
|
| | | *
|
| | |
| | |
|
| | | result.put("picture", picture);
|
| | |
|
| | | String fontColor1 = "#888888";
|
| | | String fontColor2 = "#F14242";
|
| | | String fontColor1 = "#666666";
|
| | | String fontColor2 = "#E5005C";
|
| | | JSONArray array = new JSONArray();
|
| | |
|
| | | |
| | |
|
| | | JSONObject contentJson1 = new JSONObject();
|
| | | contentJson1.put("color", fontColor1);
|
| | | contentJson1.put("content", "本次推荐共");
|
| | | |
| | |
|
| | | JSONObject contentJson2 = new JSONObject();
|
| | | contentJson2.put("color", fontColor2);
|
| | | contentJson2.put("content", totalgoods);
|
| | | |
| | |
|
| | | JSONObject contentJson3 = new JSONObject();
|
| | | contentJson3.put("color", fontColor1);
|
| | | contentJson3.put("content", "个商品");
|
| | |
| | | Long deviceId = deviceActive.getId();
|
| | |
|
| | | for (PushGoods pushGoods : listPush) {
|
| | | List<PushGoodsRecord> listRecord = pushGoodsRecordService.listByPushIdAndDeviceId(
|
| | | pushGoods.getId(), deviceId);
|
| | | List<PushGoodsRecord> listRecord = pushGoodsRecordService
|
| | | .listByPushIdAndDeviceId(pushGoods.getId(), deviceId);
|
| | | if (listRecord != null && listRecord.size() > 0) {
|
| | | continue; // 已被记录
|
| | | }
|
| | |
| | | });
|
| | | }
|
| | | }
|
| | | |
| | |
|
| | | }
|