Merge remote-tracking branch 'origin/master'
| | |
| | | package com.yeshi.fanli.controller.admin;
|
| | |
|
| | | import java.io.PrintWriter;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Arrays;
|
| | | import java.util.List;
|
| | |
|
| | |
| | |
|
| | | import org.springframework.stereotype.Controller;
|
| | | import org.springframework.web.bind.annotation.RequestMapping;
|
| | | import org.springframework.web.bind.annotation.RequestMethod;
|
| | | import org.yeshi.utils.HttpUtil;
|
| | | import org.yeshi.utils.JsonUtil;
|
| | |
|
| | | import com.yeshi.fanli.entity.bus.msg.UserSystemMsg;
|
| | | import com.yeshi.fanli.entity.bus.msg.UserSystemMsgTypeEnum;
|
| | | import com.yeshi.fanli.exception.PushException;
|
| | | import com.yeshi.fanli.service.inter.config.ConfigService;
|
| | | import com.yeshi.fanli.service.inter.msg.UserSystemMsgService;
|
| | | import com.yeshi.fanli.service.inter.push.PushRecordService;
|
| | | import com.yeshi.fanli.service.inter.push.PushService;
|
| | | import com.yeshi.fanli.service.inter.user.AccountMessageService;
|
| | | import com.yeshi.fanli.service.inter.user.SystemZnxService;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.factory.IOSPushFactory;
|
| | |
|
| | |
| | | public final static int BAICHUAN = 6; // 站内推送
|
| | | public final static int WELFARE_CENTER = 7; // 福利中心
|
| | |
|
| | | @Resource
|
| | | private PushRecordService pushRecordService;
|
| | |
|
| | | @Resource
|
| | | private ConfigService configService;
|
| | |
|
| | | @Resource
|
| | | private SystemZnxService systemZnxService;
|
| | |
|
| | | @Resource
|
| | | private AccountMessageService accountMessageService;
|
| | |
|
| | | @Resource
|
| | | private PushService pushService;
|
| | |
| | | @Resource
|
| | | private UserSystemMsgService userSystemMsgService;
|
| | |
|
| | | /**
|
| | | * 商品推送
|
| | | * |
| | | * @param uId
|
| | | * -用户ID 可为空
|
| | | * @param url
|
| | | * -商品链接
|
| | | * @param title
|
| | | * -推送标题
|
| | | * @param content
|
| | | * -推送内容
|
| | | * @param out
|
| | | * @throws Exception
|
| | | */
|
| | | @RequestMapping(value = "pushGoodsAll_f", method = RequestMethod.POST)
|
| | | public void pushGoods(Long uId, String url, String title, String content, String versions, PrintWriter out) throws Exception {
|
| | | try {
|
| | | String auctionId = null;
|
| | | if (!StringUtil.isNullOrEmpty(url) && url.contains("id=")) {
|
| | | String[] sts = url.split("\\?")[1].split("&");
|
| | | for (String st : sts)
|
| | | if (st.contains("id=")) {
|
| | | auctionId = st.replace("id=", "");
|
| | | }
|
| | | }
|
| | |
|
| | | if (StringUtil.isNullOrEmpty(auctionId)) {
|
| | | out.print(JsonUtil.loadFalseResult("提取商品ID失败"));
|
| | | return;
|
| | | }
|
| | |
|
| | | JSONObject json = IOSPushFactory.createGoodsPush(Long.parseLong(auctionId), title, content);
|
| | | if (json.toString().getBytes().length > 256) {
|
| | | out.print(JsonUtil.loadFalseResult("标题或内容过长,请删减后再试"));
|
| | | return;
|
| | | }
|
| | |
|
| | | List<String> listVersion = null;
|
| | | if (versions != null && versions.trim().length() > 0) {
|
| | | listVersion = Arrays.asList(versions.split(","));
|
| | | }
|
| | | |
| | | pushService.pushGoods(uId, url, title, content, listVersion);
|
| | | out.print(JsonUtil.loadTrueResult("推送成功"));
|
| | | } catch (PushException e) {
|
| | | out.print(JsonUtil.loadFalseResult(e.getMsg()));
|
| | | } catch (Exception e) {
|
| | | out.print(JsonUtil.loadFalseResult("推送失败"));
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 网页推送
|
| | | * |
| | | * @param url
|
| | | * @param title
|
| | | * @param content
|
| | | * @param out
|
| | | * @throws Exception
|
| | | */
|
| | | @RequestMapping(value = "pushUrlAll_f", method = RequestMethod.POST)
|
| | | public void pushUrl(String url, String title, String content, String versions, PrintWriter out) throws Exception {
|
| | | if (StringUtil.isNullOrEmpty(url) || StringUtil.isNullOrEmpty(title) || StringUtil.isNullOrEmpty(content)) {
|
| | | out.print(JsonUtil.loadFalseResult("请填写链接,标题与内容"));
|
| | | return;
|
| | | }
|
| | |
|
| | | JSONObject json = IOSPushFactory.createURLPush(HttpUtil.getShortLink(url), title, content);
|
| | | if (json.toString().getBytes().length > 256) {
|
| | | out.print(JsonUtil.loadFalseResult("标题或内容过长,请删减后再试"));
|
| | | return;
|
| | | }
|
| | | |
| | | try {
|
| | | List<String> listVersion = null;
|
| | | if (versions != null && versions.trim().length() > 0) {
|
| | | listVersion = Arrays.asList(versions.split(","));
|
| | | }
|
| | | |
| | | pushService.pushUrl(null, url, title, content, listVersion);
|
| | | out.print(JsonUtil.loadTrueResult("推送成功"));
|
| | | } catch (PushException e) {
|
| | | out.print(JsonUtil.loadFalseResult(e.getMsg()));
|
| | | } catch (Exception e) {
|
| | | out.print(JsonUtil.loadFalseResult("推送失败"));
|
| | | e.printStackTrace();
|
| | | }
|
| | | |
| | | }
|
| | |
|
| | | /**
|
| | | * |
| | | * 方法说明: 站内信推送
|
| | | * |
| | | * @author mawurui createTime 2018年3月12日 下午5:45:00
|
| | | * @param uId
|
| | | * @param title
|
| | | * @param content
|
| | | * @throws Exception
|
| | | */
|
| | | @RequestMapping(value = "pushFanZNX_f", method = RequestMethod.POST)
|
| | | public void pushSystemZnx(Long uId, String title, String content, String versions, PrintWriter out) throws Exception {
|
| | | try {
|
| | | List<String> listVersion = null;
|
| | | if (versions != null && versions.trim().length() > 0) {
|
| | | listVersion = Arrays.asList(versions.split(","));
|
| | | }
|
| | | |
| | | pushService.pushZNX(uId, title, content, listVersion);
|
| | | |
| | | out.print(JsonUtil.loadTrueResult("推送成功"));
|
| | | } catch (PushException e) {
|
| | | out.print(JsonUtil.loadFalseResult(e.getMsg()));
|
| | | } catch (Exception e) {
|
| | | out.print(JsonUtil.loadFalseResult("推送失败"));
|
| | | e.printStackTrace();
|
| | | }
|
| | | |
| | | }
|
| | |
|
| | | /**
|
| | | * 短链接转换
|
| | |
| | | * @throws Exception
|
| | | */
|
| | | @RequestMapping(value = "newPushGoodsAll")
|
| | | public void newPushGoodsAll(String callback, Long uid, String url, String title, String content, String versions, PrintWriter out)
|
| | | public void newPushGoodsAll(String callback, String url, String title, String content, String uids, String versions, PrintWriter out)
|
| | | throws Exception {
|
| | |
|
| | | String auctionId = null;
|
| | |
| | | }
|
| | |
|
| | | try {
|
| | | List<String> listVersion = null;
|
| | | if (versions != null && versions.trim().length() > 0) {
|
| | | listVersion = Arrays.asList(versions.split(","));
|
| | | |
| | | List<String> listuid = null;
|
| | | if (uids != null && uids.trim().length() > 0) {
|
| | | listuid = Arrays.asList(uids.split(","));
|
| | | if (listuid == null || listuid.size() == 0) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("用户id格式不正确"));
|
| | | return;
|
| | | }
|
| | | }
|
| | |
|
| | | pushService.pushGoods(uid, url, title, content, listVersion);
|
| | | |
| | | List<String> listVersion = null;
|
| | | if (versions != null && versions.trim().length() > 0) {
|
| | | List<String> list = Arrays.asList(versions.split(","));
|
| | | |
| | | if (list != null && list.size() > 0) {
|
| | | listVersion = new ArrayList<String>();
|
| | | for (String version: list) {
|
| | | if (version != null && version.trim().length() > 0) {
|
| | | listVersion.add(version.trim());
|
| | | }
|
| | | }
|
| | | }
|
| | | |
| | | if (listVersion == null || listVersion.size() == 0) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("版本号格式不正确"));
|
| | | return;
|
| | | }
|
| | | }
|
| | | |
| | | if (listuid == null) {
|
| | | // 全推
|
| | | pushService.pushGoods(null, title, content, url, listVersion);
|
| | | } else {
|
| | | // 部分用户推送
|
| | | for (String str_uid: listuid) {
|
| | | if (str_uid != null && str_uid.trim().length() > 0) {
|
| | | pushService.pushGoods(Long.parseLong(str_uid), url, title, content, listVersion);
|
| | | }
|
| | | }
|
| | | }
|
| | | |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("推送成功"));
|
| | | } catch (PushException e) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg()));
|
| | |
| | | * @throws Exception
|
| | | */
|
| | | @RequestMapping(value = "newPushUrlAll")
|
| | | public void newPushUrlAll(String callback, String url, String title, String content, String versions, PrintWriter out) {
|
| | | public void newPushUrlAll(String callback, String url, String title, String content, String uids, |
| | | String versions, PrintWriter out) {
|
| | |
|
| | | if (StringUtil.isNullOrEmpty(url) || StringUtil.isNullOrEmpty(title) || StringUtil.isNullOrEmpty(content)) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("请填写链接,标题与内容"));
|
| | |
| | | }
|
| | |
|
| | | try {
|
| | | List<String> listVersion = null;
|
| | | if (versions != null && versions.trim().length() > 0) {
|
| | | listVersion = Arrays.asList(versions.split(","));
|
| | |
|
| | | List<String> listuid = null;
|
| | | if (uids != null && uids.trim().length() > 0) {
|
| | | listuid = Arrays.asList(uids.split(","));
|
| | | if (listuid == null || listuid.size() == 0) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("用户id格式不正确"));
|
| | | return;
|
| | | }
|
| | | }
|
| | |
|
| | | pushService.pushUrl(null, url, title, content, listVersion);
|
| | | List<String> listVersion = null;
|
| | | if (versions != null && versions.trim().length() > 0) {
|
| | | List<String> list = Arrays.asList(versions.split(","));
|
| | | |
| | | if (list != null && list.size() > 0) {
|
| | | listVersion = new ArrayList<String>();
|
| | | for (String version: list) {
|
| | | if (version != null && version.trim().length() > 0) {
|
| | | listVersion.add(version.trim());
|
| | | }
|
| | | }
|
| | | }
|
| | | |
| | | if (listVersion == null || listVersion.size() == 0) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("版本号格式不正确"));
|
| | | return;
|
| | | }
|
| | | }
|
| | | |
| | | if (listuid == null) {
|
| | | // 全推
|
| | | pushService.pushUrl(null, title, content, url, listVersion);
|
| | | } else {
|
| | | // 部分推送
|
| | | for (String str_uid: listuid) {
|
| | | if (str_uid != null && str_uid.trim().length() > 0) {
|
| | | pushService.pushUrl(Long.parseLong(str_uid), url, title, content, listVersion);
|
| | | }
|
| | | }
|
| | | }
|
| | | |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("推送成功"));
|
| | | } catch (PushException e) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg()));
|
| | |
| | |
|
| | | try {
|
| | |
|
| | | String[] uidArray = null;
|
| | | if (uids != null) {
|
| | | uidArray = uids.split(",");
|
| | | List<String> listuid = null;
|
| | | if (uids != null && uids.trim().length() > 0) {
|
| | | listuid = Arrays.asList(uids.split(","));
|
| | | if (listuid == null || listuid.size() == 0) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("用户id格式不正确"));
|
| | | return;
|
| | | }
|
| | | }
|
| | |
|
| | | List<String> listVersion = null;
|
| | | if (versions != null && versions.trim().length() > 0) {
|
| | | listVersion = Arrays.asList(versions.split(","));
|
| | | List<String> list = Arrays.asList(versions.split(","));
|
| | | |
| | | if (list != null && list.size() > 0) {
|
| | | listVersion = new ArrayList<String>();
|
| | | for (String version: list) {
|
| | | if (version != null && version.trim().length() > 0) {
|
| | | listVersion.add(version.trim());
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | if (uidArray == null) {
|
| | | if (listVersion == null || listVersion.size() == 0) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("版本号格式不正确"));
|
| | | return;
|
| | | }
|
| | | }
|
| | | |
| | | if (listuid == null) {
|
| | | // 全推
|
| | | pushService.pushZNX(null, title, content, listVersion);
|
| | | } else {
|
| | | for (int i = 0; i < uidArray.length; i++) {
|
| | | String str_uid = uidArray[i];
|
| | | // 部分推送
|
| | | for (String str_uid: listuid) {
|
| | | if (str_uid != null && str_uid.trim().length() > 0) {
|
| | | pushService.pushZNX(Long.parseLong(str_uid), title, content, listVersion);
|
| | |
|
| | |
| | |
|
| | | try {
|
| | |
|
| | | String[] uidArray = null;
|
| | | if (uids != null) {
|
| | | uidArray = uids.split(",");
|
| | | List<String> listuid = null;
|
| | | if (uids != null && uids.trim().length() > 0) {
|
| | | listuid = Arrays.asList(uids.split(","));
|
| | | if (listuid == null || listuid.size() == 0) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("用户id格式不正确"));
|
| | | return;
|
| | | }
|
| | | }
|
| | |
|
| | | List<String> listVersion = null;
|
| | | if (versions != null && versions.trim().length() > 0) {
|
| | | listVersion = Arrays.asList(versions.split(","));
|
| | | List<String> list = Arrays.asList(versions.split(","));
|
| | | |
| | | if (list != null && list.size() > 0) {
|
| | | listVersion = new ArrayList<String>();
|
| | | for (String version: list) {
|
| | | if (version != null && version.trim().length() > 0) {
|
| | | listVersion.add(version.trim());
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | if (uidArray == null) {
|
| | | if (listVersion == null || listVersion.size() == 0) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("版本号格式不正确"));
|
| | | return;
|
| | | }
|
| | | }
|
| | | |
| | | if (listuid == null) {
|
| | | // 全推
|
| | | pushService.pushBaiChuanUrl(null, title, content, url, listVersion);
|
| | | } else {
|
| | | for (int i = 0; i < uidArray.length; i++) {
|
| | | String str_uid = uidArray[i];
|
| | | // 部分推送
|
| | | for (String str_uid: listuid) {
|
| | | if (str_uid != null && str_uid.trim().length() > 0) {
|
| | | pushService.pushBaiChuanUrl(Long.parseLong(str_uid), title, content, url, listVersion);
|
| | | }
|
| | |
| | | import org.springframework.stereotype.Controller;
|
| | | import org.springframework.web.bind.annotation.RequestMapping;
|
| | | import org.springframework.web.bind.annotation.RequestMethod;
|
| | | import org.springframework.web.multipart.commons.CommonsMultipartFile;
|
| | | import org.yeshi.utils.JsonUtil;
|
| | |
|
| | | import com.google.gson.Gson;
|
| | | import com.yeshi.fanli.entity.AppInfo;
|
| | |
| | | import com.yeshi.fanli.service.inter.customerservice.CustomerServiceCommonQuestionService;
|
| | | import com.yeshi.fanli.service.inter.customerservice.CustomerServiceHistoryService;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import org.yeshi.utils.JsonUtil;
|
| | |
|
| | | import net.sf.json.JSONObject;
|
| | |
|
| | |
| | | out.print(JsonUtil.loadTrueResult(JsonUtil.getApiCommonGson().toJson(answer)));
|
| | | }
|
| | |
|
| | | |
| | | /**
|
| | | * 用户吐槽
|
| | | * @param fileList
|
| | | * @param uid
|
| | | * @param content
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "complaint")
|
| | | public void complaint(List<CommonsMultipartFile> fileList, Long uid, String content, PrintWriter out) {
|
| | | |
| | | // 图片最多五张、可以为空
|
| | | if (fileList != null && fileList.size() > 5 ) {
|
| | | out.print(JsonUtil.loadFalseResult("图片最多可上传五张"));
|
| | | return;
|
| | | }
|
| | | |
| | | if (content == null || content.trim().length() == 0) {
|
| | | out.print(JsonUtil.loadFalseResult("吐槽内容为空"));
|
| | | return;
|
| | | }
|
| | | |
| | | try {
|
| | | |
| | | |
| | | out.print(JsonUtil.loadTrueResult("吐槽"));
|
| | | } catch (Exception e) {
|
| | | out.print(JsonUtil.loadFalseResult("操作失败"));
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | }
|
| | |
| | | |
| | | List<DeviceTokenIOS> selectByUid( @Param("uid")Long uid, @Param("list")List<Integer> list); |
| | | |
| | | List<DeviceTokenIOS> selectList(@Param("start")Long start,@Param("count")int count, @Param("array")String[] arrayVersion); |
| | | List<DeviceTokenIOS> selectList(@Param("start")Long start,@Param("count")int count, @Param("list")List<Integer> list); |
| | | |
| | | long selectCount(); |
| | | |
| | |
| | | package com.yeshi.fanli.dao.mybatis.push; |
| | | |
| | | import com.yeshi.fanli.dao.BaseMapper; |
| | | import com.yeshi.fanli.entity.xinge.PushRecord; |
| | | |
| | | public interface PushRecordMapper { |
| | | public interface PushRecordMapper extends BaseMapper<PushRecord>{ |
| | | |
| | | int deleteByPrimaryKey(Long id); |
| | | |
| | | int insert(PushRecord record); |
| | | |
| | | int insertSelective(PushRecord record); |
| | | |
| | | PushRecord selectByPrimaryKey(Long id); |
| | | |
| | | int updateByPrimaryKeySelective(PushRecord record); |
| | | |
| | | int updateByPrimaryKey(PushRecord record); |
| | | } |
| | |
| | | select |
| | | <include refid="Base_Column_List" /> |
| | | from yeshi_ec_uid_devicetoken_ios |
| | | <if test="array != null"> |
| | | <if test="list != null and list.size() > 0"> |
| | | WHERE version in |
| | | <foreach collection="array" item="item" open="(" separator="," close=")"> |
| | | <foreach collection="list" item="item" open="(" separator="," close=")"> |
| | | #{item} |
| | | </foreach> |
| | | </if> |
| | |
| | | <!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.PushRecordMapper"> |
| | | <resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.push.PushQueueRecord"> |
| | | <id column="qe_id" property="id" jdbcType="BIGINT"/> |
| | | <result column="qe_type" property="type" jdbcType="INTEGER"/> |
| | | <result column="qe_content" property="jsonContent" jdbcType="VARCHAR"/> |
| | | <result column="qe_start_cursor" property="startCursor" jdbcType="BIGINT"/> |
| | | <result column="qe_end_cursor" property="endCursor" jdbcType="BIGINT"/> |
| | | <result column="qe_record_cursor" property="recordCursor" jdbcType="BIGINT"/> |
| | | <result column="qe_push_num" property="pushNum" jdbcType="INTEGER"/> |
| | | <result column="qe_versions" property="versions" jdbcType="VARCHAR"/> |
| | | <result column="qe_state" property="state" jdbcType="INTEGER"/> |
| | | <result column="qe_createtime" property="createtime" jdbcType="TIMESTAMP"/> |
| | | <result column="qe_endtime" property="endtime" jdbcType="TIMESTAMP"/> |
| | | <resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.xinge.PushRecord"> |
| | | <id column="id" property="id" jdbcType="BIGINT"/> |
| | | <result column="url" property="url" jdbcType="VARCHAR"/> |
| | | <result column="type" property="type" jdbcType="INTEGER"/> |
| | | <result column="title" property="title" jdbcType="VARCHAR"/> |
| | | <result column="state" property="state" jdbcType="INTEGER"/> |
| | | <result column="createtime" property="createtime" jdbcType="BIGINT"/> |
| | | <result column="count" property="count" jdbcType="BIGINT"/> |
| | | <result column="iosPushId" property="iosPushId" jdbcType="VARCHAR"/> |
| | | <result column="androidPushId" property="androidPushId" jdbcType="VARCHAR"/> |
| | | <result column="account" property="account" jdbcType="INTEGER"/> |
| | | <result column="appName" property="appName" jdbcType="VARCHAR"/> |
| | | <result column="uid" property="uid" jdbcType="BIGINT"/> |
| | | </resultMap> |
| | | <sql id="Base_Column_List">qe_id,qe_type,qe_content,qe_start_cursor,qe_end_cursor,qe_record_cursor,qe_push_num,qe_versions,qe_state,qe_createtime,qe_endtime</sql> |
| | | <sql id="Base_Column_List">id,url,type,title,state,createtime,count,iosPushId,androidPushId,account,appName,uid</sql> |
| | | <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">select |
| | | <include refid="Base_Column_List"/>from yeshi_ec_push_queue where qe_id = #{id,jdbcType=BIGINT} |
| | | <include refid="Base_Column_List"/>from yeshi_ec_push_record where id = #{id,jdbcType=BIGINT} |
| | | </select> |
| | | <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from yeshi_ec_push_queue where qe_id = #{id,jdbcType=BIGINT}</delete> |
| | | <insert id="insert" parameterType="com.yeshi.fanli.entity.push.PushQueueRecord" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_push_queue (qe_id,qe_type,qe_content,qe_start_cursor,qe_end_cursor,qe_record_cursor,qe_push_num,qe_versions,qe_state,qe_createtime,qe_endtime) values (#{id,jdbcType=BIGINT},#{type,jdbcType=INTEGER},#{jsonContent,jdbcType=VARCHAR},#{startCursor,jdbcType=BIGINT},#{endCursor,jdbcType=BIGINT},#{recordCursor,jdbcType=BIGINT},#{pushNum,jdbcType=INTEGER},#{versions,jdbcType=VARCHAR},#{state,jdbcType=INTEGER},#{createtime,jdbcType=TIMESTAMP},#{endtime,jdbcType=TIMESTAMP})</insert> |
| | | <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.push.PushQueueRecord" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_push_queue |
| | | <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from yeshi_ec_push_record where id = #{id,jdbcType=BIGINT}</delete> |
| | | <insert id="insert" parameterType="com.yeshi.fanli.entity.xinge.PushRecord" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_push_record (id,url,type,title,state,createtime,count,iosPushId,androidPushId,account,appName,uid) values (#{id,jdbcType=BIGINT},#{url,jdbcType=VARCHAR},#{type,jdbcType=INTEGER},#{title,jdbcType=VARCHAR},#{state,jdbcType=INTEGER},#{createtime,jdbcType=BIGINT},#{count,jdbcType=BIGINT},#{iosPushId,jdbcType=VARCHAR},#{androidPushId,jdbcType=VARCHAR},#{account,jdbcType=INTEGER},#{appName,jdbcType=VARCHAR},#{uid,jdbcType=BIGINT})</insert> |
| | | <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.xinge.PushRecord" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_push_record |
| | | <trim prefix="(" suffix=")" suffixOverrides=","> |
| | | <if test="id != null">qe_id,</if> |
| | | <if test="type != null">qe_type,</if> |
| | | <if test="jsonContent != null">qe_content,</if> |
| | | <if test="startCursor != null">qe_start_cursor,</if> |
| | | <if test="endCursor != null">qe_end_cursor,</if> |
| | | <if test="recordCursor != null">qe_record_cursor,</if> |
| | | <if test="pushNum != null">qe_push_num,</if> |
| | | <if test="versions != null">qe_versions,</if> |
| | | <if test="state != null">qe_state,</if> |
| | | <if test="createtime != null">qe_createtime,</if> |
| | | <if test="endtime != null">qe_endtime,</if> |
| | | <if test="id != null">id,</if> |
| | | <if test="url != null">url,</if> |
| | | <if test="type != null">type,</if> |
| | | <if test="title != null">title,</if> |
| | | <if test="state != null">state,</if> |
| | | <if test="createtime != null">createtime,</if> |
| | | <if test="count != null">count,</if> |
| | | <if test="iosPushId != null">iosPushId,</if> |
| | | <if test="androidPushId != null">androidPushId,</if> |
| | | <if test="account != null">account,</if> |
| | | <if test="appName != null">appName,</if> |
| | | <if test="uid != null">uid,</if> |
| | | </trim>values |
| | | <trim prefix="(" suffix=")" suffixOverrides=","> |
| | | <if test="id != null">#{id,jdbcType=BIGINT},</if> |
| | | <if test="url != null">#{url,jdbcType=VARCHAR},</if> |
| | | <if test="type != null">#{type,jdbcType=INTEGER},</if> |
| | | <if test="jsonContent != null">#{jsonContent,jdbcType=VARCHAR},</if> |
| | | <if test="startCursor != null">#{startCursor,jdbcType=BIGINT},</if> |
| | | <if test="endCursor != null">#{endCursor,jdbcType=BIGINT},</if> |
| | | <if test="recordCursor != null">#{recordCursor,jdbcType=BIGINT},</if> |
| | | <if test="pushNum != null">#{pushNum,jdbcType=INTEGER},</if> |
| | | <if test="versions != null">#{versions,jdbcType=VARCHAR},</if> |
| | | <if test="title != null">#{title,jdbcType=VARCHAR},</if> |
| | | <if test="state != null">#{state,jdbcType=INTEGER},</if> |
| | | <if test="createtime != null">#{createtime,jdbcType=TIMESTAMP},</if> |
| | | <if test="endtime != null">#{endtime,jdbcType=TIMESTAMP},</if> |
| | | <if test="createtime != null">#{createtime,jdbcType=BIGINT},</if> |
| | | <if test="count != null">#{count,jdbcType=BIGINT},</if> |
| | | <if test="iosPushId != null">#{iosPushId,jdbcType=VARCHAR},</if> |
| | | <if test="androidPushId != null">#{androidPushId,jdbcType=VARCHAR},</if> |
| | | <if test="account != null">#{account,jdbcType=INTEGER},</if> |
| | | <if test="appName != null">#{appName,jdbcType=VARCHAR},</if> |
| | | <if test="uid != null">#{uid,jdbcType=BIGINT},</if> |
| | | </trim> |
| | | </insert> |
| | | <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.push.PushQueueRecord">update yeshi_ec_push_queue set qe_type = #{type,jdbcType=INTEGER},qe_content = #{jsonContent,jdbcType=VARCHAR},qe_start_cursor = #{startCursor,jdbcType=BIGINT},qe_end_cursor = #{endCursor,jdbcType=BIGINT},qe_record_cursor = #{recordCursor,jdbcType=BIGINT},qe_push_num = #{pushNum,jdbcType=INTEGER},qe_versions = #{versions,jdbcType=VARCHAR},qe_state = #{state,jdbcType=INTEGER},qe_createtime = #{createtime,jdbcType=TIMESTAMP},qe_endtime = #{endtime,jdbcType=TIMESTAMP} where qe_id = #{id,jdbcType=BIGINT}</update> |
| | | <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.push.PushQueueRecord">update yeshi_ec_push_queue |
| | | <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.xinge.PushRecord">update yeshi_ec_push_record set url = #{url,jdbcType=VARCHAR},type = #{type,jdbcType=INTEGER},title = #{title,jdbcType=VARCHAR},state = #{state,jdbcType=INTEGER},createtime = #{createtime,jdbcType=BIGINT},count = #{count,jdbcType=BIGINT},iosPushId = #{iosPushId,jdbcType=VARCHAR},androidPushId = #{androidPushId,jdbcType=VARCHAR},account = #{account,jdbcType=INTEGER},appName = #{appName,jdbcType=VARCHAR},uid = #{uid,jdbcType=BIGINT} where id = #{id,jdbcType=BIGINT}</update> |
| | | <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.xinge.PushRecord">update yeshi_ec_push_record |
| | | <set> |
| | | <if test="type != null">qe_type=#{type,jdbcType=INTEGER},</if> |
| | | <if test="jsonContent != null">qe_content=#{jsonContent,jdbcType=VARCHAR},</if> |
| | | <if test="startCursor != null">qe_start_cursor=#{startCursor,jdbcType=BIGINT},</if> |
| | | <if test="endCursor != null">qe_end_cursor=#{endCursor,jdbcType=BIGINT},</if> |
| | | <if test="recordCursor != null">qe_record_cursor=#{recordCursor,jdbcType=BIGINT},</if> |
| | | <if test="pushNum != null">qe_push_num=#{pushNum,jdbcType=INTEGER},</if> |
| | | <if test="versions != null">qe_versions=#{versions,jdbcType=VARCHAR},</if> |
| | | <if test="state != null">qe_state=#{state,jdbcType=INTEGER},</if> |
| | | <if test="createtime != null">qe_createtime=#{createtime,jdbcType=TIMESTAMP},</if> |
| | | <if test="endtime != null">qe_endtime=#{endtime,jdbcType=TIMESTAMP},</if> |
| | | </set> where qe_id = #{id,jdbcType=BIGINT} |
| | | <if test="url != null">url=#{url,jdbcType=VARCHAR},</if> |
| | | <if test="type != null">type=#{type,jdbcType=INTEGER},</if> |
| | | <if test="title != null">title=#{title,jdbcType=VARCHAR},</if> |
| | | <if test="state != null">state=#{state,jdbcType=INTEGER},</if> |
| | | <if test="createtime != null">createtime=#{createtime,jdbcType=BIGINT},</if> |
| | | <if test="count != null">count=#{count,jdbcType=BIGINT},</if> |
| | | <if test="iosPushId != null">iosPushId=#{iosPushId,jdbcType=VARCHAR},</if> |
| | | <if test="androidPushId != null">androidPushId=#{androidPushId,jdbcType=VARCHAR},</if> |
| | | <if test="account != null">account=#{account,jdbcType=INTEGER},</if> |
| | | <if test="appName != null">appName=#{appName,jdbcType=VARCHAR},</if> |
| | | <if test="uid != null">uid=#{uid,jdbcType=BIGINT},</if> |
| | | </set> where id = #{id,jdbcType=BIGINT} |
| | | </update> |
| | | </mapper> |
| | |
| | | package com.yeshi.fanli.service.impl.push;
|
| | |
|
| | | import java.util.ArrayList;
|
| | | import java.util.Arrays;
|
| | | import java.util.Calendar;
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | |
| | | }
|
| | |
|
| | | @Override
|
| | | public List<DeviceTokenIOS> getDeviceTokenListByUid(Long uid, List<String> listVersion) {
|
| | | // 版本号
|
| | | List<Integer> listCode = appVersionService.listVersionCodeByVersions(AppVersionInfo.PLATFORM_IOS,listVersion);
|
| | | public List<DeviceTokenIOS> getDeviceTokenListByUid(Long uid, List<String> listVersion) throws PushException {
|
| | | List<Integer> listCode = null;
|
| | | if (listVersion != null && listVersion.size() > 0) {
|
| | | // 版本号推送限制 |
| | | listCode = appVersionService.listVersionCodeByVersions(AppVersionInfo.PLATFORM_IOS,listVersion);
|
| | | if (listCode == null || listCode.size() == 0) {
|
| | | throw new PushException(1, "IOS推送失败,推送版本不存在!");
|
| | | }
|
| | | }
|
| | |
|
| | | return deviceTokenIOSMapper.selectByUid(uid, listCode);
|
| | | }
|
| | |
| | | * @param json
|
| | | */
|
| | | @Transactional
|
| | | public void addPushIOSQueue(MessageInfo info, String url, int type, List<String> listVersion) {
|
| | | public void addPushIOSQueue(MessageInfo info, String url, int type, List<String> listVersion) throws PushException {
|
| | |
|
| | | try {
|
| | |
|
| | |
| | | int pushNum = 50;
|
| | |
|
| | | String versionCodes = "";
|
| | | |
| | | if (listVersion != null && listVersion.size() > 0) {
|
| | | // 加入版本推送限制
|
| | | List<Integer> listCode = appVersionService.listVersionCodeByVersions(AppVersionInfo.PLATFORM_IOS,listVersion);
|
| | |
|
| | | if (listCode != null && listCode.size() > 0) {
|
| | |
| | | versionCodes = versionCodes.substring(0, versionCodes.length() - 1);
|
| | | }
|
| | | }
|
| | | |
| | | if (versionCodes == null || versionCodes.trim().length() == 0) {
|
| | | throw new PushException(1, "IOS推送失败,推送版本不存在!");
|
| | | }
|
| | | |
| | | }
|
| | | |
| | |
|
| | | for (long i = 0; i < tokenCount + totalCount;) {
|
| | |
|
| | |
| | | Long startCursor = pushQueueRecord.getStartCursor();
|
| | | // 结束位置
|
| | | Long endCursor = pushQueueRecord.getEndCursor();
|
| | | // 版本号
|
| | | String[] versionArray = null;
|
| | | String versions = pushQueueRecord.getVersions();
|
| | | if (versions != null && versions.trim().length() == 0) {
|
| | | versionArray = versions.split(",");
|
| | | }
|
| | |
|
| | | if (startCursor == null && endCursor == null) {
|
| | | return;
|
| | | }
|
| | |
|
| | | |
| | | // 推送的版本号
|
| | | String versions = pushQueueRecord.getVersions();
|
| | | List<Integer> listVersionCode = null;
|
| | | if (versions != null && versions.trim().length() > 0) {
|
| | | |
| | | List<String> listVersion = Arrays.asList(versions.split(","));
|
| | | if (listVersion != null && listVersion.size() > 0) {
|
| | | listVersionCode = new ArrayList<Integer>();
|
| | | for (String version: listVersion) {
|
| | | if (version != null && version.trim().length() > 0) {
|
| | | listVersionCode.add(Integer.parseInt(version));
|
| | | }
|
| | | }
|
| | | }
|
| | | |
| | | if (listVersionCode == null || listVersionCode.size() == 0) {
|
| | | return; //版本号存在异常
|
| | | }
|
| | | }
|
| | | |
| | |
|
| | | int total = (int) (endCursor - startCursor);
|
| | |
|
| | |
| | | // 不足50个数据
|
| | | if (moveNum > total) {
|
| | | moveNum = (int) (endCursor - startCursor);
|
| | | List<DeviceTokenIOS> list = deviceTokenIOSMapper.selectList(startCursor, moveNum, versionArray);
|
| | | List<DeviceTokenIOS> list = deviceTokenIOSMapper.selectList(startCursor, moveNum, listVersionCode);
|
| | | recordCursor = endCursor;
|
| | |
|
| | | if (list != null) {
|
| | |
| | | // System.out.println("recordCursorend:" +recordCursor);
|
| | | moveNum = (int) (endCursor - recordCursor);
|
| | | // System.out.println(moveNum);
|
| | | List<DeviceTokenIOS> list = deviceTokenIOSMapper.selectList(recordCursor, moveNum, versionArray);
|
| | | List<DeviceTokenIOS> list = deviceTokenIOSMapper.selectList(recordCursor, moveNum, listVersionCode);
|
| | | if (list != null) {
|
| | | executePushIOS(list, pushQueueRecord, endCursor);
|
| | | PushLogHelper.iosInfo("推送游标:" + recordCursor + "," + moveNum);
|
| | |
| | | recordCursor = endCursor;
|
| | |
|
| | | } else {
|
| | | List<DeviceTokenIOS> list = deviceTokenIOSMapper.selectList(recordCursor, moveNum, versionArray);
|
| | | List<DeviceTokenIOS> list = deviceTokenIOSMapper.selectList(recordCursor, moveNum, listVersionCode);
|
| | | recordCursor = recordCursor + 50;
|
| | |
|
| | | if (list != null) {
|
| | |
| | | PushLogHelper.iosInfo("推送游标:" + recordCursor + "," + moveNum);
|
| | | }
|
| | | }
|
| | |
|
| | | // System.out.println("recordCursor:" +recordCursor);
|
| | | }
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | public void executePushIOS(List<DeviceTokenIOS> list, PushQueueRecord pushQueueRecord, long recordCursor) {
|
| | |
| | | throw new PushCouponException(1, "标题或内容不能为空");
|
| | | }
|
| | |
|
| | | |
| | | List<String> listuid = null;
|
| | | String uids = pushCoupon.getUids();
|
| | | if (uids != null && uids.trim().length() > 0) {
|
| | | listuid = Arrays.asList(uids.split(","));
|
| | | if (listuid == null || listuid.size() == 0) {
|
| | | throw new PushCouponException(1, "用户id格式不正确");
|
| | | }
|
| | | }
|
| | | |
| | | List<String> listVersion = null;
|
| | | String versions = pushCoupon.getVersions();
|
| | | if (versions != null && versions.trim().length() > 0) {
|
| | | listVersion = Arrays.asList(versions.split(","));
|
| | | if (listVersion == null || listVersion.size() == 0) {
|
| | | throw new PushCouponException(1, "版本号格式不正确\"");
|
| | | }
|
| | | String uids = pushCoupon.getUids();
|
| | | if (uids == null || uids.trim().length() == 0) {
|
| | | }
|
| | | |
| | | if (listuid == null) {
|
| | | // 全推
|
| | | pushService.pushWelfareCenter(null, title, content, listVersion);
|
| | |
|
| | | } else {
|
| | | // 指定用户推送
|
| | | String[] uidArray = uids.split(",");
|
| | | |
| | | if (uidArray != null) {
|
| | | for (int i = 0; i < uidArray.length; i++) {
|
| | | String str_uid = uidArray[i];
|
| | | for (String str_uid: listuid) {
|
| | | if (str_uid != null && str_uid.trim().length() > 0) {
|
| | | pushService.pushWelfareCenter(Long.parseLong(str_uid), title, content, listVersion);
|
| | | }
|
| | | }
|
| | | }
|
| | | |
| | | }
|
| | |
|
| | | // 已推送
|
| | |
| | | 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.PushCouponException;
|
| | | import com.yeshi.fanli.exception.push.PushGoodsException;
|
| | | import com.yeshi.fanli.service.inter.config.ConfigService;
|
| | | import com.yeshi.fanli.service.inter.goods.CommonGoodsService;
|
| | |
| | | String versions = pushGoods.getVersions();
|
| | | if (versions != null && versions.trim().length() > 0) {
|
| | | listVersion = Arrays.asList(versions.split(","));
|
| | | if (listVersion == null || listVersion.size() == 0) {
|
| | | throw new PushCouponException(1, "版本号格式不正确\"");
|
| | | }
|
| | | }
|
| | |
|
| | | if (goodsList.size() == 1) {
|
| | |
| | | public void pushBaiChuanUrl(Long uid, String title, String content, String url, List<String> listVersion) throws PushException {
|
| | | iosPushService.pushBaiChuanUrl(uid, title, content, url, listVersion);
|
| | | xmPushService.pushBaiChuanUrl(uid, title, content, url, listVersion);
|
| | | |
| | | // 插入推送记录
|
| | | PushRecord pushRecord = new PushRecord();
|
| | | pushRecord.setTitle(title);
|
| | | pushRecord.setUid(uid);
|
| | | pushRecord.setState(1); // 成功
|
| | | pushRecord.setType(PushController.BAICHUAN); // 类型:百川
|
| | | pushRecord.setAppName(Constant.systemCommonConfig.getProjectChineseName());
|
| | | pushRecord.setCreatetime(java.lang.System.currentTimeMillis());
|
| | | |
| | | pushRecordMapper.insertSelective(pushRecord);
|
| | | }
|
| | |
|
| | | @Override
|
| | |
| | | String appVersion = null;
|
| | | if (listVersion != null && listVersion.size() > 0) {
|
| | | appVersion = getCanPushVersions(minVersionCode, listVersion);
|
| | | if (appVersion == null || appVersion.trim().length() ==0) {
|
| | | throw new PushException(1, "小米推送失败,推送的版本过低!");
|
| | | }
|
| | | } else if (minVersionCode > 0) {
|
| | | appVersion = getVersionByMinVersionCode(minVersionCode);
|
| | | }
|
| | |
| | | String appVersion = null;
|
| | | if (listVersion != null && listVersion.size() > 0) {
|
| | | appVersion = getCanPushVersions(minVersionCode, listVersion);
|
| | | if (appVersion == null || appVersion.trim().length() ==0) {
|
| | | throw new PushException(1, "小米推送失败,推送的版本过低!");
|
| | | }
|
| | | } else if (minVersionCode > 0) {
|
| | | appVersion = getVersionByMinVersionCode(minVersionCode);
|
| | | }
|
| | |
| | | String appVersion = null;
|
| | | if (listVersion != null && listVersion.size() > 0) {
|
| | | appVersion = getCanPushVersions(minVersionCode, listVersion);
|
| | | if (appVersion == null || appVersion.trim().length() == 0) {
|
| | | throw new PushException(1, "小米推送失败,推送的版本过低!");
|
| | | }
|
| | | } else if (minVersionCode > 0) {
|
| | | appVersion = getVersionByMinVersionCode(minVersionCode);
|
| | | }
|
| | |
| | | String appVersion = null;
|
| | | if (listVersion != null && listVersion.size() > 0) {
|
| | | appVersion = getCanPushVersions(minVersionCode, listVersion);
|
| | | if (appVersion == null || appVersion.trim().length() == 0) {
|
| | | throw new PushException(1, "小米推送失败,推送的版本不能低于1.4.8");
|
| | | }
|
| | | } else if (minVersionCode > 0) {
|
| | | appVersion = getVersionByMinVersionCode(minVersionCode);
|
| | | }
|
| | |
| | | * @param listVersion
|
| | | * @return
|
| | | */
|
| | | private String getCanPushVersions(int versionCode, List<String> listVersion) {
|
| | | private String getCanPushVersions(int versionCode, List<String> listVersion) throws PushException{
|
| | | List<AppVersionInfo> list = appVersionService.listByVersions(AppVersionInfo.PLATFORM_ANDROID, listVersion);
|
| | | String versions = "";
|
| | |
|
| | |
| | | versions += appVersion.getVersion() + ",";
|
| | | }
|
| | | }
|
| | | } else {
|
| | | throw new PushException(1, "推送的版本不存在,请核实版本信息");
|
| | | }
|
| | |
|
| | | if (versions.endsWith(",")) {
|
| | |
| | | String appVersion = null;
|
| | | if (listVersion != null && listVersion.size() > 0) {
|
| | | appVersion = getCanPushVersions(minVersionCode, listVersion);
|
| | | if (appVersion == null || appVersion.trim().length() ==0) {
|
| | | throw new PushException(1, "小米推送失败,推送的版本不能低于1.4.8");
|
| | | }
|
| | | |
| | | } else if (minVersionCode > 0){
|
| | | appVersion = getVersionByMinVersionCode(minVersionCode);
|
| | | }
|
| | |
| | | String appVersion = null;
|
| | | if (listVersion != null && listVersion.size() > 0) {
|
| | | appVersion = getCanPushVersions(minVersionCode, listVersion);
|
| | | if (appVersion == null || appVersion.trim().length() ==0) {
|
| | | throw new PushException(1, "小米推送失败,推送的版本不能低于1.5.1");
|
| | | }
|
| | | } else if (minVersionCode > 0){
|
| | | appVersion = getVersionByMinVersionCode(minVersionCode);
|
| | | }
|
| | |
| | |
|
| | | import com.yeshi.fanli.entity.push.DeviceTokenIOS;
|
| | | import com.yeshi.fanli.entity.push.PushQueueRecord;
|
| | | import com.yeshi.fanli.exception.PushException;
|
| | |
|
| | | /**
|
| | | * IOS推送服务
|
| | |
| | | * @param uid
|
| | | * @return
|
| | | */
|
| | | public List<DeviceTokenIOS> getDeviceTokenListByUid(Long uid, List<String> listVersion);
|
| | | public List<DeviceTokenIOS> getDeviceTokenListByUid(Long uid, List<String> listVersion) throws PushException;
|
| | |
|
| | | /**
|
| | | * 获取DeviceToken不为空的列表
|