fanli/src/main/java/com/yeshi/fanli/controller/client/PushController.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
fanli/src/main/java/com/yeshi/fanli/controller/client/SystemClientController.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/push/DeviceActiveMapper.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
fanli/src/main/java/com/yeshi/fanli/entity/bus/user/LostOrder.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
fanli/src/main/java/com/yeshi/fanli/entity/push/DeviceActive.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
fanli/src/main/java/com/yeshi/fanli/mapping/push/DeviceActiveMapper.xml | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
fanli/src/main/java/com/yeshi/fanli/service/impl/order/LostOrderServiceImpl.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
fanli/src/main/java/com/yeshi/fanli/service/impl/push/DeviceActiveServiceImpl.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
fanli/src/main/java/com/yeshi/fanli/service/inter/push/DeviceActiveService.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
fanli/src/main/java/com/yeshi/fanli/controller/client/PushController.java
@@ -7,16 +7,18 @@ 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.push.DeviceActive; import com.yeshi.fanli.entity.push.DeviceTokenIOS; import com.yeshi.fanli.entity.system.System; 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.PushRecordService; import com.yeshi.fanli.util.StringUtil; import org.yeshi.utils.JsonUtil; @Controller @RequestMapping(value = "api/v1/push") @@ -33,6 +35,9 @@ @Resource private DeviceTokenHWService deviceTokenHWService; @Resource private DeviceActiveService deviceActiveService; @RequestMapping(value = "callback", method = RequestMethod.POST) public void callback(AcceptData acceptData, String pushId, PrintWriter out) { @@ -60,6 +65,13 @@ @RequestMapping(value = "/insertDeviceToken", method = RequestMethod.POST) public void insertIOSDeviceToken(AcceptData acceptData, String deviceToken, PrintWriter out) { if (!StringUtil.isNullOrEmpty(acceptData.getDevice()) && !StringUtil.isNullOrEmpty(deviceToken)) { // 添加设备活跃记录 DeviceActive da = new DeviceActive(); da.setDeviceToken(deviceToken); da.setPlatform(DeviceActive.PLATFORM_IOS); da.setVersionCode(Integer.parseInt(acceptData.getVersion())); deviceActiveService.addDeviceActive(da); DeviceTokenIOS deviceTokenIOS = iosPushService.getDeviceTokenByDeviceToken(deviceToken); if (deviceTokenIOS == null) iosPushService.addDeviceToken(null, Integer.parseInt(acceptData.getVersion()), deviceToken, @@ -83,6 +95,13 @@ @RequestMapping(value = "/uidBindDeviceToken", method = RequestMethod.POST) public void uidBindIOSDeviceToken(AcceptData acceptData, Long uid, String deviceToken, PrintWriter out) { if (uid != null && uid != 0 && !StringUtil.isNullOrEmpty(deviceToken)) { // 添加设备活跃记录 DeviceActive da = new DeviceActive(); da.setDeviceToken(deviceToken); da.setPlatform(DeviceActive.PLATFORM_IOS); da.setVersionCode(Integer.parseInt(acceptData.getVersion())); deviceActiveService.addDeviceActive(da); // 添加token DeviceTokenIOS deviceTokenIOS = iosPushService.getDeviceTokenByDeviceToken(acceptData.getDevice()); if (deviceTokenIOS != null) { deviceTokenIOS.setUid(uid); fanli/src/main/java/com/yeshi/fanli/controller/client/SystemClientController.java
@@ -13,12 +13,14 @@ 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.system.CustomerContent; import com.yeshi.fanli.entity.system.System; import com.yeshi.fanli.entity.system.SystemClientParams; import com.yeshi.fanli.service.inter.config.ConfigService; import com.yeshi.fanli.service.inter.config.SystemClientParamsService; import com.yeshi.fanli.service.inter.config.SystemService; import com.yeshi.fanli.service.inter.push.DeviceActiveService; import com.yeshi.fanli.service.inter.push.IOSPushService; import com.yeshi.fanli.util.ThreadUtil; @@ -39,6 +41,9 @@ @Resource private ConfigService configService; @Resource private DeviceActiveService deviceActiveService; @RequestMapping("getsystemclientparams") public void getSystemClientParams(AcceptData acceptData, PrintWriter out) { @@ -71,17 +76,23 @@ data.put("count", list.size()); data.put("systemClientParamsList", gson.toJson(list)); out.print(JsonUtil.loadTrueResult(data)); // ThreadUtil.run(new Runnable() { // @Override // public void run() { // try { // if ("ios".equalsIgnoreCase(acceptData.getPlatform())) // iosPushService.addDeviceToken(null, Integer.parseInt(acceptData.getVersion()), null, // acceptData.getDevice()); // } catch (Exception e) { // } // } // }); ThreadUtil.run(new Runnable() { @Override public void run() { try { // 安卓平台添加设备活跃记录 if ("android".equalsIgnoreCase(acceptData.getPlatform())) { DeviceActive da = new DeviceActive(); da.setDevice(acceptData.getDevice()); da.setPlatform(DeviceActive.PLATFORM_ANDROID); da.setVersionCode(Integer.parseInt(acceptData.getVersion())); deviceActiveService.addDeviceActive(da); } } catch (Exception e) { } } }); return; } fanli/src/main/java/com/yeshi/fanli/dao/mybatis/push/DeviceActiveMapper.java
New file @@ -0,0 +1,25 @@ package com.yeshi.fanli.dao.mybatis.push; import org.apache.ibatis.annotations.Param; import com.yeshi.fanli.entity.push.DeviceActive; public interface DeviceActiveMapper { int deleteByPrimaryKey(Long id); int insert(DeviceActive record); int insertSelective(DeviceActive record); DeviceActive selectByPrimaryKey(Long id); int updateByPrimaryKeySelective(DeviceActive record); int updateByPrimaryKey(DeviceActive record); DeviceActive selectByDeviceAndPlatform(@Param("device") String device, @Param("platform") int platform); DeviceActive selectByDeviceToeknMd5AndPlatform(@Param("deviceTokenMd5") String deviceTokenMd5, @Param("platform") int platform); } fanli/src/main/java/com/yeshi/fanli/entity/bus/user/LostOrder.java
@@ -29,6 +29,10 @@ public final static int RESULT_CODE_SUCCESS = 2;// 成功 public final static int RESULT_CODE_FAIL = 3;// 失败(通过后3日未处理成功则判断为失败) public final static int STATE_VERFING = 0; public final static int STATE_PASS = 1; public final static int STATE_REJECT = 2; @Id @GeneratedValue(strategy = GenerationType.AUTO) @Expose @@ -79,7 +83,6 @@ private Integer totalPass; @Transient private Integer totalReject; public Integer getResultCode() { return resultCode; fanli/src/main/java/com/yeshi/fanli/entity/push/DeviceActive.java
New file @@ -0,0 +1,95 @@ 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_device_active") public class DeviceActive { public static final int PLATFORM_ANDROID = 1; public static final int PLATFORM_IOS = 2; @Column(name = "da_id") private Long id; @Column(name = "da_platform") private Integer platform; @Column(name = "da_device") private String device; @Column(name = "da_device_token_md5") private String deviceTokenMd5; @Column(name = "da_device_token") private String deviceToken; @Column(name = "da_version_code") private Integer versionCode; @Column(name = "da_createtime") private Date createTime; @Column(name = "da_updatetime") private Date updateTime; public Long getId() { return id; } public void setId(Long id) { this.id = id; } public Integer getPlatform() { return platform; } public void setPlatform(Integer platform) { this.platform = platform; } public String getDevice() { return device; } public void setDevice(String device) { this.device = device; } public String getDeviceTokenMd5() { return deviceTokenMd5; } public void setDeviceTokenMd5(String deviceTokenMd5) { this.deviceTokenMd5 = deviceTokenMd5; } public String getDeviceToken() { return deviceToken; } public void setDeviceToken(String deviceToken) { this.deviceToken = deviceToken; } public Integer getVersionCode() { return versionCode; } public void setVersionCode(Integer versionCode) { this.versionCode = versionCode; } 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; } } fanli/src/main/java/com/yeshi/fanli/mapping/push/DeviceActiveMapper.xml
New file @@ -0,0 +1,100 @@ <?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.DeviceActiveMapper"> <resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.push.DeviceActive"> <id column="da_id" property="id" jdbcType="BIGINT" /> <result column="da_platform" property="platform" jdbcType="INTEGER" /> <result column="da_device" property="device" jdbcType="VARCHAR" /> <result column="da_device_token_md5" property="deviceTokenMd5" jdbcType="VARCHAR" /> <result column="da_device_token" property="deviceToken" jdbcType="VARCHAR" /> <result column="da_version_code" property="versionCode" jdbcType="INTEGER" /> <result column="da_createtime" property="createTime" jdbcType="TIMESTAMP" /> <result column="da_updatetime" property="updateTime" jdbcType="TIMESTAMP" /> </resultMap> <sql id="Base_Column_List">da_id,da_platform,da_device,da_device_token_md5,da_device_token,da_version_code,da_createtime,da_updatetime </sql> <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long"> select <include refid="Base_Column_List" /> from yeshi_ec_device_active where da_id = #{id,jdbcType=BIGINT} </select> <select id="selectByDeviceAndPlatform" resultMap="BaseResultMap"> select <include refid="Base_Column_List" /> from yeshi_ec_device_active where da_device = #{device} and da_platform=#{platform} </select> <select id="selectByDeviceToeknMd5AndPlatform" resultMap="BaseResultMap"> select <include refid="Base_Column_List" /> from yeshi_ec_device_active where da_device_token_md5 = #{deviceTokenMd5} and da_platform=#{platform} </select> <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from yeshi_ec_device_active where da_id = #{id,jdbcType=BIGINT} </delete> <insert id="insert" parameterType="com.yeshi.fanli.entity.push.DeviceActive" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_device_active (da_id,da_platform,da_device,da_device_token_md5,da_device_token,da_version_code,da_createtime,da_updatetime) values (#{id,jdbcType=BIGINT},#{platform,jdbcType=INTEGER},#{device,jdbcType=VARCHAR},#{deviceTokenMd5,jdbcType=VARCHAR},#{deviceToken,jdbcType=VARCHAR},#{versionCode,jdbcType=INTEGER},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP}) </insert> <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.push.DeviceActive" useGeneratedKeys="true" keyProperty="id"> insert into yeshi_ec_device_active <trim prefix="(" suffix=")" suffixOverrides=","> <if test="id != null">da_id,</if> <if test="platform != null">da_platform,</if> <if test="device != null">da_device,</if> <if test="deviceTokenMd5 != null">da_device_token_md5,</if> <if test="deviceToken != null">da_device_token,</if> <if test="versionCode != null">da_version_code,</if> <if test="createTime != null">da_createtime,</if> <if test="updateTime != null">da_updatetime,</if> </trim> values <trim prefix="(" suffix=")" suffixOverrides=","> <if test="id != null">#{id,jdbcType=BIGINT},</if> <if test="platform != null">#{platform,jdbcType=INTEGER},</if> <if test="device != null">#{device,jdbcType=VARCHAR},</if> <if test="deviceTokenMd5 != null">#{deviceTokenMd5,jdbcType=VARCHAR},</if> <if test="deviceToken != null">#{deviceToken,jdbcType=VARCHAR},</if> <if test="versionCode != null">#{versionCode,jdbcType=INTEGER},</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.DeviceActive">update yeshi_ec_device_active set da_platform = #{platform,jdbcType=INTEGER},da_device = #{device,jdbcType=VARCHAR},da_device_token_md5 = #{deviceTokenMd5,jdbcType=VARCHAR},da_device_token = #{deviceToken,jdbcType=VARCHAR},da_version_code = #{versionCode,jdbcType=INTEGER},da_createtime = #{createTime,jdbcType=TIMESTAMP},da_updatetime = #{updateTime,jdbcType=TIMESTAMP} where da_id = #{id,jdbcType=BIGINT} </update> <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.push.DeviceActive"> update yeshi_ec_device_active <set> <if test="platform != null">da_platform=#{platform,jdbcType=INTEGER},</if> <if test="device != null">da_device=#{device,jdbcType=VARCHAR},</if> <if test="deviceTokenMd5 != null">da_device_token_md5=#{deviceTokenMd5,jdbcType=VARCHAR}, </if> <if test="deviceToken != null">da_device_token=#{deviceToken,jdbcType=VARCHAR},</if> <if test="versionCode != null">da_version_code=#{versionCode,jdbcType=INTEGER},</if> <if test="createTime != null">da_createtime=#{createTime,jdbcType=TIMESTAMP},</if> <if test="updateTime != null">da_updatetime=#{updateTime,jdbcType=TIMESTAMP},</if> </set> where da_id = #{id,jdbcType=BIGINT} </update> </mapper> fanli/src/main/java/com/yeshi/fanli/service/impl/order/LostOrderServiceImpl.java
@@ -54,8 +54,7 @@ } else if (orderList.get(0).getState() == 1 && orderList.get(0).getResultCode() == LostOrder.RESULT_CODE_SUCCESS) { return -1; } else if (orderList.get(0).getState() == 1 && orderList.get(0).getResultCode() == LostOrder.RESULT_CODE_FAIL) { } else { return -6; } } @@ -240,7 +239,7 @@ // 订单申诉人工通过后,但是隔了3天还未处理成功就视为该订单申诉失败 lostOrderDao.update( "update LostOrder lo set lo.resultCode=? where lo.state=1 and lo.resultCode=? and lo.handleTime<?", new Serializable[] { LostOrder.RESULT_CODE_FAIL, LostOrder.RESULT_CODE_VERFING, new Serializable[] { LostOrder.RESULT_CODE_FAIL, LostOrder.RESULT_CODE_FAIL, System.currentTimeMillis() - 1000 * 60 * 60 * 24 * 3L }); } fanli/src/main/java/com/yeshi/fanli/service/impl/push/DeviceActiveServiceImpl.java
New file @@ -0,0 +1,85 @@ package com.yeshi.fanli.service.impl.push; import java.util.Date; import javax.annotation.Resource; import org.springframework.stereotype.Service; import com.yeshi.fanli.dao.mybatis.push.DeviceActiveMapper; import com.yeshi.fanli.entity.push.DeviceActive; import com.yeshi.fanli.service.inter.push.DeviceActiveService; import com.yeshi.fanli.util.StringUtil; @Service public class DeviceActiveServiceImpl implements DeviceActiveService { @Resource private DeviceActiveMapper deviceActiveMapper; @Override public void addDeviceActive(DeviceActive deviceActive) { // 添加记录 if (deviceActive == null) return; if (deviceActive.getPlatform() == null) return; if (deviceActive.getVersionCode() == null) return; if (deviceActive.getPlatform() == DeviceActive.PLATFORM_ANDROID && StringUtil.isNullOrEmpty(deviceActive.getDevice())) return; if (deviceActive.getPlatform() == DeviceActive.PLATFORM_IOS && StringUtil.isNullOrEmpty(deviceActive.getDeviceToken())) return; switch (deviceActive.getPlatform()) { case DeviceActive.PLATFORM_ANDROID: // Android的唯一标识为device if (StringUtil.isNullOrEmpty(deviceActive.getDevice())) return; DeviceActive da = deviceActiveMapper.selectByDeviceAndPlatform(deviceActive.getDevice(), deviceActive.getPlatform()); if (da == null) { deviceActive.setId(null); deviceActive.setUpdateTime(new Date()); deviceActive.setCreateTime(new Date()); deviceActiveMapper.insertSelective(deviceActive); } else { DeviceActive updateDeviceActive = new DeviceActive(); updateDeviceActive.setId(da.getId()); updateDeviceActive.setUpdateTime(new Date()); updateDeviceActive.setVersionCode(deviceActive.getVersionCode()); deviceActiveMapper.updateByPrimaryKeySelective(updateDeviceActive); } break; case DeviceActive.PLATFORM_IOS: // IOS的设备标识为deviceToken if (StringUtil.isNullOrEmpty(deviceActive.getDeviceToken())) return; deviceActive.setDeviceTokenMd5(StringUtil.Md5(deviceActive.getDeviceToken())); DeviceActive da1 = deviceActiveMapper.selectByDeviceToeknMd5AndPlatform(deviceActive.getDeviceTokenMd5(), deviceActive.getPlatform()); if (da1 == null) { deviceActive.setId(null); deviceActive.setUpdateTime(new Date()); deviceActive.setCreateTime(new Date()); deviceActiveMapper.insertSelective(deviceActive); } else { DeviceActive updateDeviceActive = new DeviceActive(); updateDeviceActive.setId(da1.getId()); updateDeviceActive.setUpdateTime(new Date()); updateDeviceActive.setVersionCode(deviceActive.getVersionCode()); deviceActiveMapper.updateByPrimaryKeySelective(updateDeviceActive); } break; default: return; } } } fanli/src/main/java/com/yeshi/fanli/service/inter/push/DeviceActiveService.java
New file @@ -0,0 +1,14 @@ package com.yeshi.fanli.service.inter.push; import com.yeshi.fanli.entity.push.DeviceActive; public interface DeviceActiveService { /** * 添加用户活跃记录 * * @param deviceActive */ public void addDeviceActive(DeviceActive deviceActive); }