fanli/src/main/java/com/yeshi/fanli/controller/client/v1/UserAccountController.java
@@ -24,6 +24,7 @@ import com.yeshi.fanli.entity.bus.user.UserInfo; import com.yeshi.fanli.entity.bus.user.UserInfoModifyRecord.ModifyTypeEnum; import com.yeshi.fanli.entity.bus.user.WeiXinUser; import com.yeshi.fanli.entity.push.DeviceActive; import com.yeshi.fanli.entity.system.BusinessSystem; import com.yeshi.fanli.entity.taobao.ClientTBPid; import com.yeshi.fanli.entity.taobao.PidUser; @@ -43,7 +44,9 @@ import com.yeshi.fanli.service.inter.order.LostOrderService; import com.yeshi.fanli.service.inter.order.OrderService; import com.yeshi.fanli.service.inter.order.config.HongBaoManageService; import com.yeshi.fanli.service.inter.push.DeviceActiveService; import com.yeshi.fanli.service.inter.push.DeviceTokenHWService; import com.yeshi.fanli.service.inter.push.DeviceTokenOPPOService; import com.yeshi.fanli.service.inter.taobao.TaoBaoUnionConfigService; import com.yeshi.fanli.service.inter.tlj.UserTaoLiJinOriginService; import com.yeshi.fanli.service.inter.user.ForbiddenUserIdentifyCodeService; @@ -125,6 +128,9 @@ private DeviceTokenHWService deviceTokenHWService; @Resource private DeviceTokenOPPOService deviceTokenOPPOService; @Resource private TaoBaoUnionConfigService taoBaoUnionConfigService; @Resource @@ -156,6 +162,9 @@ @Resource private UserInfoModifyRecordService userInfoModifyRecordService; @Resource private DeviceActiveService deviceActiveService; private static final String PASSWORD_MAX_ERROR = "password_max_error"; private static final String EXTRACT_MIN_MONEY = "extract_min_money"; @@ -1128,9 +1137,15 @@ public void logOut(AcceptData acceptData, Long uid, PrintWriter out) { if (uid == null || uid == 0) return; // 需要解绑HW推送的用户绑定 if ("android".equalsIgnoreCase(acceptData.getPlatform())) if ("android".equalsIgnoreCase(acceptData.getPlatform())) { DeviceActive deviceActive = deviceActiveService.getFirstActiveInfo(acceptData.getDevice()); // 需要解绑HW推送的用户绑定 deviceTokenHWService.unBindDeviceToken(acceptData.getDevice()); if (deviceActive != null) { // 解绑OPPO推送的用户绑定 deviceTokenOPPOService.unBindUid(uid, deviceActive.getId()); } } out.print(JsonUtil.loadTrueResult("")); } @@ -1322,7 +1337,7 @@ } try { userAccountService.bindWeiXin(acceptData,uid, code); userAccountService.bindWeiXin(acceptData, uid, code); UserInfo user = userInfoService.getUserByIdWithMybatis(uid); // 判断taoBaoUid是否已经封禁 fanli/src/main/java/com/yeshi/fanli/dao/mybatis/push/DeviceTokenOPPOMapper.java
@@ -1,5 +1,9 @@ package com.yeshi.fanli.dao.mybatis.push; import java.util.List; import org.apache.ibatis.annotations.Param; import com.yeshi.fanli.dao.BaseMapper; import com.yeshi.fanli.entity.push.DeviceTokenOPPO; @@ -13,4 +17,28 @@ */ DeviceTokenOPPO selectByDeviceActiveId(Long deviceActiveId); /** * 设备数量 * * @return */ long countDeviceToken(@Param("versionList")List<Integer> versionList); /** * 设备列表 * * @param start * @param count * @return */ List<DeviceTokenOPPO> listDeviceToken(@Param("start") long start, @Param("count") int count, @Param("versionList") List<Integer> versionList); /** * 根据用户ID查询 * * @param uid * @return */ List<DeviceTokenOPPO> listByUid(@Param("uid")Long uid,@Param("versionList") List<Integer> verisonList); } fanli/src/main/java/com/yeshi/fanli/log/PushLogHelper.java
@@ -77,6 +77,21 @@ } catch (IOException e1) { } } public static void oppoError(Throwable e) { String date = TimeUtil.getGernalTime(System.currentTimeMillis(), "yyyy_MM_dd"); String os = System.getProperty("os.name"); String filePath = String.format("/usr/local/tomcat8/logs/push/oppo_error_detail_%s.txt", date); if (os.toLowerCase().startsWith("win")) { filePath = String.format("C:/logs/push/oppo_error_detail_%s.txt", date); } try { saveErrorLog(e, filePath); } catch (IOException e1) { } } public static void saveErrorLog(Throwable e, String filePath) throws IOException { // 创建文件夹 fanli/src/main/java/com/yeshi/fanli/mapping/push/DeviceTokenOPPOMapper.xml
@@ -4,7 +4,8 @@ <mapper namespace="com.yeshi.fanli.dao.mybatis.push.DeviceTokenOPPOMapper"> <resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.push.DeviceTokenOPPO"> <id column="do_id" property="id" jdbcType="BIGINT" /> <result column="do_device_id" property="deviceActiveId" jdbcType="BIGINT" /> <result column="do_device_id" property="deviceActiveId" jdbcType="BIGINT" /> <result column="do_register_id" property="registerId" jdbcType="VARCHAR" /> <result column="do_uid" property="uid" jdbcType="BIGINT" /> <result column="do_create_time" property="createTime" jdbcType="TIMESTAMP" /> @@ -18,16 +19,66 @@ <include refid="Base_Column_List" /> from yeshi_ec_uid_devicetoken_oppo where do_id = #{id,jdbcType=BIGINT} </select> <select id="selectByDeviceActiveId" resultMap="BaseResultMap" parameterType="java.lang.Long"> select <include refid="Base_Column_List" /> from yeshi_ec_uid_devicetoken_oppo where do_device_id = #{0} </select> <select id="countDeviceToken" resultType="java.lang.Long" parameterType="java.lang.Long"> select count(do_id) from yeshi_ec_uid_devicetoken_oppo op left join yeshi_ec_device_active a on a.da_id=op.do_device_id <if test="versionList!=null"> <foreach collection="versionList" open="where (" separator=" or " item="ver" close=")"> da_version_code=#{ver} </foreach> </if> </select> <select id="listDeviceToken" resultMap="BaseResultMap"> select <include refid="Base_Column_List" /> from yeshi_ec_uid_devicetoken_oppo left join yeshi_ec_device_active a on a.da_id=do_device_id <if test="versionList!=null"> <foreach collection="versionList" open="where (" separator=" or " item="ver" close=")"> da_version_code=#{ver} </foreach> </if> limit #{start},#{count} </select> <select id="listByUid" resultMap="BaseResultMap" parameterType="java.lang.Long"> select <include refid="Base_Column_List" /> from yeshi_ec_uid_devicetoken_oppo left join yeshi_ec_device_active a on a.da_id=do_device_id where do_uid=#{uid} <if test="versionList!=null"> <foreach collection="versionList" open="and (" separator=" or " item="ver" close=")"> da_version_code=#{ver} </foreach> </if> </select> List<Integer> verisonList <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from yeshi_ec_uid_devicetoken_oppo where do_id = #{id,jdbcType=BIGINT} </delete> fanli/src/main/java/com/yeshi/fanli/service/impl/money/extract/ExtractServiceImpl.java
@@ -382,10 +382,9 @@ AlipayClient alipayClient = new DefaultAlipayClient("https://openapi.alipay.com/gateway.do", Constant.alipayConfig.getAppId(), privateKey, "json", "gbk", null, "RSA2"); AlipayFundTransToaccountTransferRequest request = new AlipayFundTransToaccountTransferRequest(); String uuid = UUID.randomUUID().toString().replace("-", ""); String appName = Constant.systemCommonConfig.getProjectChineseName(); JSONObject json = new JSONObject(); json.put("out_biz_no", uuid);//最长长度64位,支持英文,下划线,数字 json.put("out_biz_no", "widthdraw_"+extract.getId());//最长长度64位,支持英文,下划线,数字 json.put("payee_type", "ALIPAY_LOGONID"); json.put("payee_account", extract.getAccount()); json.put("amount", extract.getMoney()); fanli/src/main/java/com/yeshi/fanli/service/impl/push/DeviceTokenOPPOServiceImpl.java
@@ -1,6 +1,7 @@ package com.yeshi.fanli.service.impl.push; import java.util.Date; import java.util.List; import javax.annotation.Resource; @@ -46,4 +47,19 @@ } } @Override public long countDeviceToken(List<Integer> versionList) { return deviceTokenOPPOMapper.countDeviceToken(versionList); } @Override public List<DeviceTokenOPPO> listDeviceToken(int page, int pageSize, List<Integer> versionList) { return deviceTokenOPPOMapper.listDeviceToken((page - 1) * pageSize, pageSize, versionList); } @Override public List<DeviceTokenOPPO> listByUid(Long uid, List<Integer> verisonList) { return deviceTokenOPPOMapper.listByUid(uid, verisonList); } } fanli/src/main/java/com/yeshi/fanli/service/impl/push/OPPOPushServiceImpl.java
@@ -16,20 +16,22 @@ import com.yeshi.fanli.entity.bus.user.UserCustomSettings; import com.yeshi.fanli.entity.bus.user.UserCustomSettings.UserSettingTypeEnum; import com.yeshi.fanli.entity.push.DeviceTokenHW; import com.yeshi.fanli.entity.push.DeviceTokenOPPO; import com.yeshi.fanli.exception.push.PushException; import com.yeshi.fanli.log.PushLogHelper; import com.yeshi.fanli.service.inter.config.AppVersionService; import com.yeshi.fanli.service.inter.push.DeviceTokenHWService; import com.yeshi.fanli.service.inter.push.DeviceTokenOPPOService; import com.yeshi.fanli.service.inter.push.OPPOPushService; import com.yeshi.fanli.service.inter.user.UserCustomSettingsService; import com.yeshi.fanli.util.StringUtil; import com.yeshi.fanli.util.push.HWPushUtil; import com.yeshi.fanli.util.push.OPPOPushUtil; @Service public class OPPOPushServiceImpl implements OPPOPushService { @Resource private DeviceTokenHWService deviceTokenHWService; private DeviceTokenOPPOService deviceTokenOPPOService; @Resource private AppVersionService appVersionService; @@ -104,13 +106,13 @@ push(PushTypeEnum.signin, uid, title, content, null, null, null, versionCodeList); } private List<DeviceTokenHW> filterDeviceToken(List<DeviceTokenHW> hwDeviceList, int hour) { private List<DeviceTokenOPPO> filterDeviceToken(List<DeviceTokenOPPO> deviceList, int hour) { // 处理消息免打扰 if (hour >= 20 || hour < 8) { Set<Long> uidSets = new HashSet<>(); for (DeviceTokenHW dt : hwDeviceList) if (dt.getUser() != null) uidSets.add(dt.getUser().getId()); for (DeviceTokenOPPO dt : deviceList) if (dt.getUid() != null) uidSets.add(dt.getUid()); List<Long> uidList = new ArrayList<>(); uidList.addAll(uidSets); List<UserCustomSettings> settingList = userCustomSettingsService.listByUidListAndTypeAndState(uidList, @@ -121,14 +123,13 @@ uidSets.add(seeting.getUserInfo().getId()); } if (uidSets.size() > 0) for (int i = 0; i < hwDeviceList.size(); i++) { if (hwDeviceList.get(i).getUser() != null && uidSets.contains(hwDeviceList.get(i).getUser().getId())) { hwDeviceList.remove(i--); for (int i = 0; i < deviceList.size(); i++) { if (deviceList.get(i).getUid() != null && uidSets.contains(deviceList.get(i).getUid())) { deviceList.remove(i--); } } } return hwDeviceList; return deviceList; } /** @@ -153,38 +154,39 @@ } if (uid == null || uid == 0) { long deviceCount = deviceTokenHWService.countDeviceToken(newVersionList); int page = (int) (deviceCount % 100 == 0 ? deviceCount / 100 : deviceCount / 100 + 1); int pageSize = 200; long deviceCount = deviceTokenOPPOService.countDeviceToken(newVersionList); int page = (int) (deviceCount % pageSize == 0 ? deviceCount / pageSize : deviceCount / pageSize + 1); for (int p = 1; p <= page; p++) { List<DeviceTokenHW> hwDeviceList = deviceTokenHWService.getDeviceTokenList(p, 100, newVersionList); hwDeviceList = filterDeviceToken(hwDeviceList, hour); List<DeviceTokenOPPO> deviceList = deviceTokenOPPOService.listDeviceToken(p, pageSize, newVersionList); deviceList = filterDeviceToken(deviceList, hour); List<String> tokenList = new ArrayList<>(); for (DeviceTokenHW token : hwDeviceList) tokenList.add(token.getDeviceToken()); for (DeviceTokenOPPO token : deviceList) tokenList.add(token.getRegisterId()); try { if (type == PushTypeEnum.goodsdetail) {// 商品详情 if (goodsId == null) throw new PushException(2, "参数不完整"); HWPushUtil.pushGoods(tokenList, title, content, 1, goodsId); OPPOPushUtil.pushGoods(tokenList, title, content, 1, goodsId); } else if (type == PushTypeEnum.url) {// 链接 if (StringUtil.isNullOrEmpty(webUrl)) throw new PushException(2, "参数不完整"); HWPushUtil.pushUrl(tokenList, title, content, webUrl); OPPOPushUtil.pushUrl(tokenList, title, content, webUrl); } else if (type == PushTypeEnum.ZNX) {// 站内信 HWPushUtil.pushZNX(tokenList, title, content); OPPOPushUtil.pushZNX(tokenList, title, content); } else if (type == PushTypeEnum.weex) {// weex if (StringUtil.isNullOrEmpty(url)) throw new PushException(2, "参数不完整"); HWPushUtil.pushWEEX(tokenList, title, content, url); OPPOPushUtil.pushWEEX(tokenList, title, content, url); } else if (type == PushTypeEnum.baichuan) {// 百川链接 if (StringUtil.isNullOrEmpty(webUrl)) throw new PushException(2, "参数不完整"); HWPushUtil.pushBaiChuanUrl(tokenList, title, content, webUrl); OPPOPushUtil.pushBaiChuanUrl(tokenList, title, content, webUrl); } else if (type == PushTypeEnum.welfare) {// 福利中心 HWPushUtil.pushWelfareCenter(tokenList, title, content); OPPOPushUtil.pushWelfareCenter(tokenList, title, content); } else if (type == PushTypeEnum.signin) {// 签到 HWPushUtil.pushUserSignInNotification(tokenList, title, content); OPPOPushUtil.pushUserSignInNotification(tokenList, title, content); } } catch (Exception e) { PushLogHelper.hwError(e); @@ -193,12 +195,12 @@ } } else { // 华为单推 List<DeviceTokenHW> hwDeviceList = deviceTokenHWService.getDeviceTokenByUid(uid, newVersionList); List<DeviceTokenOPPO> deviceList = deviceTokenOPPOService.listByUid(uid, newVersionList); List<String> tokenList = new ArrayList<>(); if (hwDeviceList != null) { hwDeviceList = filterDeviceToken(hwDeviceList, hour); for (DeviceTokenHW token : hwDeviceList) tokenList.add(token.getDeviceToken()); if (deviceList != null) { deviceList = filterDeviceToken(deviceList, hour); for (DeviceTokenOPPO token : deviceList) tokenList.add(token.getRegisterId()); } if (tokenList.size() == 0) return; @@ -207,28 +209,28 @@ if (type == PushTypeEnum.goodsdetail) {// 商品详情 if (goodsId == null) throw new PushException(2, "参数不完整"); HWPushUtil.pushGoods(tokenList, title, content, 1, goodsId); OPPOPushUtil.pushGoods(tokenList, title, content, 1, goodsId); } else if (type == PushTypeEnum.url) {// 链接 if (StringUtil.isNullOrEmpty(webUrl)) throw new PushException(2, "参数不完整"); HWPushUtil.pushUrl(tokenList, title, content, webUrl); OPPOPushUtil.pushUrl(tokenList, title, content, webUrl); } else if (type == PushTypeEnum.ZNX) {// 站内信 HWPushUtil.pushZNX(tokenList, title, content); OPPOPushUtil.pushZNX(tokenList, title, content); } else if (type == PushTypeEnum.weex) {// weex if (StringUtil.isNullOrEmpty(url)) throw new PushException(2, "参数不完整"); HWPushUtil.pushWEEX(tokenList, title, content, url); OPPOPushUtil.pushWEEX(tokenList, title, content, url); } else if (type == PushTypeEnum.baichuan) {// 百川链接 if (StringUtil.isNullOrEmpty(webUrl)) throw new PushException(2, "参数不完整"); HWPushUtil.pushBaiChuanUrl(tokenList, title, content, webUrl); OPPOPushUtil.pushBaiChuanUrl(tokenList, title, content, webUrl); } else if (type == PushTypeEnum.welfare) {// 福利中心 HWPushUtil.pushWelfareCenter(tokenList, title, content); OPPOPushUtil.pushWelfareCenter(tokenList, title, content); } else if (type == PushTypeEnum.signin) {// 签到 HWPushUtil.pushUserSignInNotification(tokenList, title, content); OPPOPushUtil.pushUserSignInNotification(tokenList, title, content); } } catch (Exception e) { PushLogHelper.hwError(e); PushLogHelper.oppoError(e); } } fanli/src/main/java/com/yeshi/fanli/service/inter/push/DeviceTokenOPPOService.java
@@ -1,5 +1,7 @@ package com.yeshi.fanli.service.inter.push; import java.util.List; import com.yeshi.fanli.entity.push.DeviceTokenOPPO; /** @@ -25,4 +27,28 @@ */ public void unBindUid(Long uid, Long deviceActiveId); /** * 计算所有的设备 * * @return */ public long countDeviceToken(List<Integer> verisonList); /** * 设备列表 * * @param page * @param pageSize * @return */ public List<DeviceTokenOPPO> listDeviceToken(int page, int pageSize, List<Integer> verisonList); /** * 根据用户ID检索 * * @param uid * @return */ public List<DeviceTokenOPPO> listByUid(Long uid, List<Integer> verisonList); }