admin
2018-12-10 01d627f3c67e2bc5c28b2dd5e23983ddcf7a08f3
IOS唯一设备标识修改
7个文件已修改
132 ■■■■■ 已修改文件
fanli/src/main/java/com/yeshi/fanli/controller/client/PushController.java 33 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/UserInfoController.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/hongbao/HongBaoServiceImpl.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/order/PidOrderServiceImpl.java 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/push/DeviceActiveServiceImpl.java 49 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/push/IOSPushServiceImpl.java 28 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/push/IOSPushService.java 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/PushController.java
@@ -16,7 +16,6 @@
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;
@@ -111,16 +110,10 @@
            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);
            }
            out.print(JsonUtil.loadTrue(0, null, "成功"));
        }
    }
@@ -141,19 +134,11 @@
            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(""));
        }
    }
@@ -165,12 +150,8 @@
     */
    @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, "解绑成功"));
        }
    }
@@ -202,7 +183,6 @@
        deviceTokenHWService.unBindDeviceToken(acceptData.getDevice());
        out.print(JsonUtil.loadTrueResult("成功"));
    }
    
    /**
     * 解绑推送
@@ -273,7 +253,6 @@
                    String fontColor2 = "#E5005C";
                    JSONArray array = new JSONArray();
                    
                    JSONObject contentJson1 = new JSONObject();
                    contentJson1.put("color", fontColor1);
                    contentJson1.put("content", "本次推荐共");
@@ -339,8 +318,8 @@
                        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; // 已被记录
                            }
fanli/src/main/java/com/yeshi/fanli/controller/client/UserInfoController.java
@@ -9,7 +9,6 @@
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import javax.annotation.Resource;
fanli/src/main/java/com/yeshi/fanli/service/impl/hongbao/HongBaoServiceImpl.java
@@ -10,7 +10,6 @@
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import org.apache.ibatis.annotations.Param;
import org.hibernate.HibernateException;
import org.hibernate.Query;
import org.hibernate.SQLQuery;
@@ -59,7 +58,6 @@
import com.yeshi.fanli.service.inter.hongbao.ThreeSaleSerivce;
import com.yeshi.fanli.service.inter.order.OrderItemServcie;
import com.yeshi.fanli.service.inter.order.OrderService;
import com.yeshi.fanli.service.inter.push.PushService;
import com.yeshi.fanli.service.inter.user.AccountDetailsService;
import com.yeshi.fanli.service.inter.user.AccountMessageService;
import com.yeshi.fanli.service.inter.user.MoneyRecordService;
fanli/src/main/java/com/yeshi/fanli/service/impl/order/PidOrderServiceImpl.java
@@ -252,15 +252,17 @@
    @Override
    @Transactional
    public void doPidOrder(String orderId) {
        BigDecimal  rate = hongBaoManageService.getFanLiRate();
        List<PidOrder> orders = pidOrderMapper.getPidOrderListByOrderId(orderId);
        // 只看有用户Id的情况
        if (orders.get(0).getUserInfo() != null) {
            // 根据第一个的订单创建时间来确定返利比例
            BigDecimal rate = hongBaoManageService.getShareRate(orders.get(0).getOrderCreateTime().getTime());
            List<HongBao> hbList = hongBaoMapper.selectByOrderId(orderId);
            if (hbList.size() <= 0) {// 还没有加入红包
                // 加入红包
                for (PidOrder order : orders) {
                    // 防止同一订单号来源于不同的PID
                    if (order.getUserInfo() == null)
                        continue;
fanli/src/main/java/com/yeshi/fanli/service/impl/push/DeviceActiveServiceImpl.java
@@ -27,16 +27,9 @@
        if (deviceActive.getVersionCode() == null)
            return;
        if (deviceActive.getPlatform() == DeviceActive.PLATFORM_ANDROID
                && StringUtil.isNullOrEmpty(deviceActive.getDevice()))
        if (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;
@@ -46,47 +39,31 @@
                deviceActive.setId(null);
                deviceActive.setUpdateTime(new Date());
                deviceActive.setCreateTime(new Date());
            if (!StringUtil.isNullOrEmpty(deviceActive.getDeviceToken())) {
                deviceActive.setDeviceTokenMd5(StringUtil.Md5(deviceActive.getDeviceToken()));
            }
                deviceActiveMapper.insertSelective(deviceActive);
            } else {
                DeviceActive updateDeviceActive = new DeviceActive();
                updateDeviceActive.setId(da.getId());
                updateDeviceActive.setUpdateTime(new Date());
                updateDeviceActive.setVersionCode(deviceActive.getVersionCode());
            if (!StringUtil.isNullOrEmpty(deviceActive.getDeviceToken())) {
                updateDeviceActive.setDeviceToken(deviceActive.getDeviceToken());
                updateDeviceActive.setDeviceTokenMd5(StringUtil.Md5(deviceActive.getDeviceToken()));
            }
                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;
        }
    }
    
    /**
     * 
     * @param device 设备号
     * @param platform 平台类型
     * @param device
     *            设备号
     * @param platform
     *            平台类型
     * @return
     */
    @Override
fanli/src/main/java/com/yeshi/fanli/service/impl/push/IOSPushServiceImpl.java
@@ -6,8 +6,6 @@
import javax.annotation.Resource;
import net.sf.json.JSONObject;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -21,14 +19,14 @@
import com.yeshi.fanli.entity.xinge.MessageInfo;
import com.yeshi.fanli.entity.xinge.PushRecord;
import com.yeshi.fanli.exception.PushException;
import com.yeshi.fanli.log.LogHelper;
import com.yeshi.fanli.log.PushLogHelper;
import com.yeshi.fanli.service.inter.push.IOSPushService;
import com.yeshi.fanli.util.CMQManager;
import com.yeshi.fanli.util.Constant;
import com.yeshi.fanli.util.StringUtil;
import com.yeshi.fanli.util.ThreadUtil;
import com.yeshi.fanli.util.push.IOSPushUtil;
import net.sf.json.JSONObject;
@Service
public class IOSPushServiceImpl implements IOSPushService {
@@ -245,7 +243,7 @@
            return;
        // 判断device是否存在
        DeviceTokenIOS deviceTokenIos = deviceTokenIOSMapper.selectByDeviceToken(deviceToken);
        DeviceTokenIOS deviceTokenIos = deviceTokenIOSMapper.selectByDevice(device);
        if (deviceTokenIos == null) {
            deviceTokenIos = new DeviceTokenIOS();
            deviceTokenIos.setCreateTime(new Date());
@@ -256,6 +254,14 @@
            deviceTokenIos.setUid(uid);
            deviceTokenIos.setVersion(version);
            deviceTokenIOSMapper.insertSelective(deviceTokenIos);
        } else {// 更新devicetoken
            DeviceTokenIOS updateDeviceTokenIOS = new DeviceTokenIOS();
            updateDeviceTokenIOS.setId(deviceTokenIos.getId());
            updateDeviceTokenIOS.setDeviceToken(deviceToken);
            updateDeviceTokenIOS.setDeviceTokenMd5(StringUtil.Md5(deviceToken));
            updateDeviceTokenIOS.setUid(uid);
            updateDeviceTokenIOS.setUpdateTime(new Date());
            deviceTokenIOSMapper.updateByPrimaryKeySelective(updateDeviceTokenIOS);
        }
    }
@@ -469,4 +475,16 @@
        pushQueueRecordMapper.updateByPrimaryKeySelective(pushQueueRecord);
    }
    @Override
    public void unBindUidAndDevice(String device) {
        if (StringUtil.isNullOrEmpty(device))
            return;
        DeviceTokenIOS deviceTokenIOS = deviceTokenIOSMapper.selectByDevice(device);
        if (device != null) {
            deviceTokenIOS.setUpdateTime(new Date());
            deviceTokenIOS.setUid(null);
            deviceTokenIOSMapper.updateByPrimaryKey(deviceTokenIOS);
        }
    }
}
fanli/src/main/java/com/yeshi/fanli/service/inter/push/IOSPushService.java
@@ -4,6 +4,7 @@
import com.yeshi.fanli.entity.push.DeviceTokenIOS;
import com.yeshi.fanli.entity.push.PushQueueRecord;
import com.yeshi.fanli.exception.PushException;
/**
 * IOS推送服务
@@ -24,12 +25,14 @@
    /**
     * 更新设备的deviceToken
     *
     * @param deviceTokenIos
     */
    public void updateDeviceToken(DeviceTokenIOS deviceTokenIos);
    /**
     * 通过设备号获取DeviceToken
     *
     * @param device
     * @return
     */
@@ -60,14 +63,24 @@
    public long getDeviceTokenCount();
    /**
     * 解绑用户与设备的关系
     *
     * @param device
     */
    public void unBindUidAndDevice(String device);
    /**
     * 执行推送-队列
     *
     * @param pushQueueRecord
     * @throws Exception
     */
    public void executePushIOS(List<DeviceTokenIOS> list ,PushQueueRecord pushQueueRecord, long recordCursor) throws Exception;
    public void executePushIOS(List<DeviceTokenIOS> list, PushQueueRecord pushQueueRecord, long recordCursor)
            throws Exception;
    /**
     * 循环处理
     *
     * @param pushQueueRecord
     * @throws Exception
     */