| | |
| | | import com.yeshi.fanli.exception.goods.CollectionGoodsException;
|
| | | import com.yeshi.fanli.exception.taobao.TaoKeApiException;
|
| | | import com.yeshi.fanli.exception.taobao.TaobaoGoodsDownException;
|
| | | import com.yeshi.fanli.exception.user.UserCustomSettingsException;
|
| | | import com.yeshi.fanli.log.LogHelper;
|
| | | import com.yeshi.fanli.service.AdminUserService;
|
| | | import com.yeshi.fanli.service.inter.config.ConfigService;
|
| | |
| | | import com.yeshi.fanli.service.inter.user.SpreadUserImgService;
|
| | | import com.yeshi.fanli.service.inter.user.UserAccountService;
|
| | | import com.yeshi.fanli.service.inter.user.UserActiveLogService;
|
| | | import com.yeshi.fanli.service.inter.user.UserCustomSettingsService;
|
| | | import com.yeshi.fanli.service.inter.user.UserInfoService;
|
| | | import com.yeshi.fanli.service.inter.user.UserMoneyDetailService;
|
| | | import com.yeshi.fanli.service.inter.user.UserShareGoodsRecordService;
|
| | |
| | | import com.yeshi.fanli.util.taobao.TaoBaoUtil;
|
| | | import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
|
| | | import com.yeshi.fanli.util.wx.WXLoginUtil;
|
| | | import com.yeshi.fanli.vo.user.UserSettingsVO;
|
| | |
|
| | | import net.sf.json.JSONArray;
|
| | | import net.sf.json.JSONObject;
|
| | |
| | |
|
| | | @Resource
|
| | | private UserShareGoodsRecordService userShareGoodsRecordService;
|
| | | |
| | | @Resource
|
| | | private UserCustomSettingsService userCustomSettingsService;
|
| | | |
| | |
|
| | | private static final String PASSWORD_MAX_ERROR = "password_max_error";
|
| | | private static final String EXTRACT_MIN_MONEY = "extract_min_money";
|
| | |
| | | data.put("first", 0);
|
| | | int spreadImgCount = spreadUserImgService.countUserSpreadImg(user.getId());
|
| | | long shareCount = userShareGoodsRecordService.countShareRecordByUid(user.getId());
|
| | | |
| | | int showTiCheng = 1; // 不显示
|
| | | if ("ios".equalsIgnoreCase(acceptData.getPlatform())
|
| | | && configService.iosOnLining(Integer.parseInt(acceptData.getVersion())))
|
| | | data.put("showTiCheng", false);
|
| | | else
|
| | | else {
|
| | | data.put("showTiCheng", spreadImgCount + shareCount > 0);
|
| | | if (spreadImgCount + shareCount > 0) {
|
| | | showTiCheng = 0;
|
| | | }
|
| | | }
|
| | |
|
| | | if ("ios".equalsIgnoreCase(acceptData.getPlatform())
|
| | | && configService.iosOnLining(Integer.parseInt(acceptData.getVersion())))
|
| | |
| | | Constant.systemCommonConfig.getProjectHost(), Constant.systemCommonConfig.getProjectName()));
|
| | | else
|
| | | data.put("inviteList", configService.get("team_list"));
|
| | | |
| | | // 界面状态
|
| | | UserSettingsVO mySettings = null; |
| | | try {
|
| | | mySettings = userCustomSettingsService.getMySettings(user.getId());
|
| | | } catch (UserCustomSettingsException e) {
|
| | | mySettings = new UserSettingsVO();
|
| | | e.printStackTrace();
|
| | | }
|
| | | |
| | | if (mySettings.getCancelNotice() == null) {
|
| | | mySettings.setCancelNotice(0);
|
| | | }
|
| | | if (mySettings.getNoBonusCount() == null) {
|
| | | mySettings.setNoBonusCount(showTiCheng); // 根据showTiCheng来判断
|
| | | }
|
| | | if (mySettings.getNoNewsRedDot() == null) {
|
| | | mySettings.setNoNewsRedDot(0);
|
| | | }
|
| | | if (mySettings.getNoShareRecordAndStorage() == null) {
|
| | | mySettings.setNoShareRecordAndStorage(showTiCheng); // 根据showTiCheng来判断
|
| | | }
|
| | | if (mySettings.getNoInvitationBonus() == null) {
|
| | | mySettings.setNoInvitationBonus(0);
|
| | | }
|
| | | |
| | | data.put("moduleState", mySettings);
|
| | | |
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | final UserInfo uuser = user;
|
| | | ThreadUtil.run(new Runnable() {
|
| | |
| | | out.print(JsonUtil.loadFalseResult("删除失败"));
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | }
|
| | | |
| | | |
| | | /**
|
| | | * 设置界面开关状态
|
| | | * @param acceptData
|
| | | * @param uid
|
| | | * @param type 1-通知免打扰(20:00-8:00) 2-不看消息红点提醒 3-不看奖金统计 不看邀请拿奖金 4-不看分享记录和选品库 不看消息红点提醒 |
| | | * @param state 0关闭 1开启
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "setModuleState", method = RequestMethod.POST)
|
| | | public void setModuleState(AcceptData acceptData, Long uid, Integer type, Integer state, PrintWriter out) {
|
| | |
|
| | | if (uid == null) {
|
| | | out.print(JsonUtil.loadFalseResult("用户未登录"));
|
| | | return;
|
| | | }
|
| | | |
| | | try {
|
| | | userCustomSettingsService.saveModuleState(uid, type, state);
|
| | | out.print(JsonUtil.loadTrueResult("设置成功"));
|
| | | } catch (UserCustomSettingsException e) {
|
| | | out.print(JsonUtil.loadFalseResult(e.getMsg()));
|
| | | } catch (Exception e) {
|
| | | out.print(JsonUtil.loadFalseResult("设置失败"));
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | |
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.dao.mybatis.user; |
| | | |
| | | |
| | | import java.util.List; |
| | | |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import com.yeshi.fanli.dao.BaseMapper; |
| | | import com.yeshi.fanli.entity.bus.user.UserCustomSettings; |
| | | |
| | | public interface UserCustomSettingsMapper extends BaseMapper<UserCustomSettings> { |
| | | |
| | | /** |
| | | * 获取我的所有自定义设置 |
| | | * @param uid |
| | | * @return |
| | | */ |
| | | List<UserCustomSettings> getSettingsByUid(Long uid); |
| | | |
| | | /** |
| | | * 获取设置信息 |
| | | * @param uid 用户id |
| | | * @param type 类型 |
| | | * @return |
| | | */ |
| | | UserCustomSettings getSettingsByUidAndType(@Param("uid")Long uid, @Param("type")String type); |
| | | |
| | | |
| | | List<Long> getUserID(@Param("type")String type); |
| | | |
| | | } |
New file |
| | |
| | | package com.yeshi.fanli.entity.bus.user;
|
| | |
|
| | | import java.util.Date;
|
| | |
|
| | | import org.yeshi.utils.mybatis.Column;
|
| | | import org.yeshi.utils.mybatis.Table;
|
| | |
|
| | | /**
|
| | | * 订单-简版
|
| | | * |
| | | * @author yj
|
| | | *
|
| | | * @date 2018年12月23日
|
| | | */
|
| | |
|
| | | @Table("yeshi_ec_user_custom_settings")
|
| | | public class UserCustomSettings {
|
| | |
|
| | | // 消息类型的枚举
|
| | | public enum UserSettingTypeEnum {
|
| | | cancelNotice("通知免打扰(20:00-8:00)"), noNewsRedDot("不看消息红点提醒"), noBonusCount("不看奖金统计"),
|
| | | noShareRecordAndStorage("不看分享记录和选品库"),noInvitationBonus("不看邀请拿奖金");
|
| | | |
| | | private final String desc;
|
| | |
|
| | | private UserSettingTypeEnum(String desc) {
|
| | | this.desc = desc;
|
| | | }
|
| | |
|
| | | public String getDesc() {
|
| | | return desc;
|
| | | }
|
| | | }
|
| | |
|
| | | @Column(name = "ucs_id")
|
| | | private Long id;
|
| | |
|
| | | // 用户id
|
| | | @Column(name = "ucs_uid")
|
| | | private UserInfo userInfo;
|
| | |
|
| | | // 类型
|
| | | @Column(name = "ucs_type")
|
| | | private UserSettingTypeEnum type;
|
| | |
|
| | | // 状态: 默认0 1选中
|
| | | @Column(name = "ucs_state")
|
| | | private Integer state;
|
| | |
|
| | | // 创建时间
|
| | | @Column(name = "ucs_create_time")
|
| | | private Date createTime;
|
| | |
|
| | | // 更新时间
|
| | | @Column(name = "ucs_update_time")
|
| | | private Date updateTime;
|
| | |
|
| | | public Long getId() {
|
| | | return id;
|
| | | }
|
| | |
|
| | | public void setId(Long id) {
|
| | | this.id = id;
|
| | | }
|
| | |
|
| | | public UserInfo getUserInfo() {
|
| | | return userInfo;
|
| | | }
|
| | |
|
| | | public void setUserInfo(UserInfo userInfo) {
|
| | | this.userInfo = userInfo;
|
| | | }
|
| | |
|
| | | public UserSettingTypeEnum getType() {
|
| | | return type;
|
| | | }
|
| | |
|
| | | public void setType(UserSettingTypeEnum type) {
|
| | | this.type = type;
|
| | | }
|
| | |
|
| | | public Integer getState() {
|
| | | return state;
|
| | | }
|
| | |
|
| | | public void setState(Integer state) {
|
| | | this.state = state;
|
| | | }
|
| | |
|
| | | 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;
|
| | | }
|
| | | |
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.exception.user; |
| | | |
| | | public class UserCustomSettingsException extends Exception { |
| | | /** |
| | | * |
| | | */ |
| | | private static final long serialVersionUID = 1L; |
| | | private int code; |
| | | private String msg; |
| | | |
| | | public int getCode() { |
| | | return code; |
| | | } |
| | | |
| | | public String getMsg() { |
| | | return msg; |
| | | } |
| | | |
| | | public UserCustomSettingsException(int code, String msg) { |
| | | this.code = code; |
| | | this.msg = msg; |
| | | } |
| | | |
| | | public UserCustomSettingsException() { |
| | | } |
| | | |
| | | @Override |
| | | public String getMessage() { |
| | | return this.msg; |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | <?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.user.UserCustomSettingsMapper"> |
| | | <resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.bus.user.UserCustomSettings"> |
| | | <id column="ucs_id" property="id" jdbcType="BIGINT"/> |
| | | <result column="ucs_type" property="type" |
| | | typeHandler="com.yeshi.fanli.util.mybatishandler.UserSettingTypeEnumHandler" /> |
| | | <result column="ucs_state" property="state" jdbcType="INTEGER"/> |
| | | <result column="ucs_create_time" property="createTime" jdbcType="TIMESTAMP"/> |
| | | <result column="ucs_update_time" property="updateTime" jdbcType="TIMESTAMP"/> |
| | | |
| | | <association property="userInfo" column="ucs_uid" javaType="com.yeshi.fanli.entity.bus.user.UserInfo"> |
| | | <id column="ucs_uid" property="id" jdbcType="BIGINT" /> |
| | | </association> |
| | | |
| | | </resultMap> |
| | | <sql id="Base_Column_List">ucs_id,ucs_uid,ucs_type,ucs_state,ucs_create_time,ucs_update_time</sql> |
| | | <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">select |
| | | <include refid="Base_Column_List"/>from yeshi_ec_user_custom_settings where ucs_id = #{id,jdbcType=BIGINT} |
| | | </select> |
| | | <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from yeshi_ec_user_custom_settings where ucs_id = #{id,jdbcType=BIGINT}</delete> |
| | | <insert id="insert" parameterType="com.yeshi.fanli.entity.bus.user.UserCustomSettings" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_user_custom_settings (ucs_id,ucs_uid,ucs_type,ucs_state,ucs_create_time,ucs_update_time) values (#{id,jdbcType=BIGINT},#{userInfo.id,jdbcType=BIGINT},#{type,jdbcType=VARCHAR},#{state,jdbcType=INTEGER},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP})</insert> |
| | | <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.bus.user.UserCustomSettings" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_user_custom_settings |
| | | <trim prefix="(" suffix=")" suffixOverrides=","> |
| | | <if test="id != null">ucs_id,</if> |
| | | <if test="userInfo != null">ucs_uid,</if> |
| | | <if test="type != null">ucs_type,</if> |
| | | <if test="state != null">ucs_state,</if> |
| | | <if test="createTime != null">ucs_create_time,</if> |
| | | <if test="updateTime != null">ucs_update_time,</if> |
| | | </trim>values |
| | | <trim prefix="(" suffix=")" suffixOverrides=","> |
| | | <if test="id != null">#{id,jdbcType=BIGINT},</if> |
| | | <if test="userInfo != null">#{userInfo.id,jdbcType=BIGINT},</if> |
| | | <if test="type != null">#{type,jdbcType=VARCHAR},</if> |
| | | <if test="state != null">#{state,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.bus.user.UserCustomSettings">update yeshi_ec_user_custom_settings set ucs_uid = #{userInfo.id,jdbcType=BIGINT},ucs_type = #{type,jdbcType=VARCHAR},ucs_state = #{state,jdbcType=INTEGER},ucs_create_time = #{createTime,jdbcType=TIMESTAMP},ucs_update_time = #{updateTime,jdbcType=TIMESTAMP} where ucs_id = #{id,jdbcType=BIGINT}</update> |
| | | <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.bus.user.UserCustomSettings">update yeshi_ec_user_custom_settings |
| | | <set> |
| | | <if test="userInfo != null">ucs_uid=#{userInfo.id,jdbcType=BIGINT},</if> |
| | | <if test="type != null">ucs_type=#{type,jdbcType=VARCHAR},</if> |
| | | <if test="state != null">ucs_state=#{state,jdbcType=INTEGER},</if> |
| | | <if test="createTime != null">ucs_create_time=#{createTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="updateTime != null">ucs_update_time=#{updateTime,jdbcType=TIMESTAMP},</if> |
| | | </set> where ucs_id = #{id,jdbcType=BIGINT} |
| | | </update> |
| | | |
| | | <select id="getSettingsByUid" resultMap="BaseResultMap" parameterType="java.lang.Long"> |
| | | SELECT * FROM yeshi_ec_user_custom_settings |
| | | WHERE ucs_id = #{uid,jdbcType=BIGINT} |
| | | </select> |
| | | |
| | | <select id="getSettingsByUidAndType" resultMap="BaseResultMap"> |
| | | SELECT * FROM yeshi_ec_user_custom_settings |
| | | WHERE ucs_uid = #{uid} AND ucs_type=#{type} |
| | | </select> |
| | | |
| | | <select id="getUserID" resultType="java.lang.Long" > |
| | | SELECT ucs_uid FROM yeshi_ec_user_custom_settings |
| | | WHERE ucs_state= 1 AND ucs_type=#{type} |
| | | </select> |
| | | |
| | | </mapper> |
| | |
| | | package com.yeshi.fanli.service.impl.push;
|
| | |
|
| | | import java.util.ArrayList;
|
| | | import java.util.Calendar;
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | |
|
| | |
| | | import com.yeshi.fanli.exception.PushException;
|
| | | import com.yeshi.fanli.log.PushLogHelper;
|
| | | import com.yeshi.fanli.service.inter.push.IOSPushService;
|
| | | import com.yeshi.fanli.service.inter.user.UserCustomSettingsService;
|
| | | import com.yeshi.fanli.util.CMQManager;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | |
| | | @Resource
|
| | | private PushQueueRecordMapper pushQueueRecordMapper;
|
| | |
|
| | | @Resource
|
| | | private UserCustomSettingsService userCustomSettingsService;
|
| | | |
| | | @Override
|
| | | public void pushGoods(Long uid, Long auctionId, String title, String content) throws PushException {
|
| | |
|
| | |
| | | * } } });
|
| | | */
|
| | | } else {
|
| | | if (!validateNotDisturbSingle(uid)) {
|
| | | return; //通知免打扰(20:00-24:00 / 00:00 -08:00) |
| | | }
|
| | | |
| | | // IOS 单推
|
| | | List<DeviceTokenIOS> deviceTokenIosList = getDeviceTokenListByUid(uid);
|
| | | List<String> deviceTokenList = new ArrayList<>();
|
| | |
| | | * } catch (Exception e) { PushLogHelper.iosError(e); } } });
|
| | | */
|
| | | } else {
|
| | | if (!validateNotDisturbSingle(uid)) {
|
| | | return; //通知免打扰(20:00-24:00 / 00:00 -08:00) |
| | | }
|
| | | |
| | | List<DeviceTokenIOS> deviceTokenIosList = getDeviceTokenListByUid(uid);
|
| | | List<String> deviceTokenList = new ArrayList<>();
|
| | | if (deviceTokenIosList != null)
|
| | |
| | | * } });
|
| | | */
|
| | | } else if (msg != null) {
|
| | | |
| | | if (uId !=null) {
|
| | | if (!validateNotDisturbSingle(uId)) {
|
| | | return; //通知免打扰(20:00-24:00 / 00:00 -08:00) |
| | | }
|
| | | }
|
| | | |
| | | // 插入推送记录
|
| | | PushRecord pushRecord = new PushRecord();
|
| | | info.setTitle(msg.getTitle());
|
| | |
| | | // 结束游标
|
| | | pushQueueRecord.setEndCursor(endCursor);
|
| | |
|
| | | // TODO 存入数据库
|
| | | // 存入数据库
|
| | | pushQueueRecordMapper.insert(pushQueueRecord);
|
| | | // 加入队列
|
| | | CMQManager.getInstance().addIOSPushMsg(pushQueueRecord);
|
| | |
| | | }
|
| | |
|
| | | } catch (Exception e) {
|
| | | // TODO Auto-generated catch block
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | |
| | |
|
| | | String jsonContent = pushQueueRecord.getJsonContent();
|
| | | JSONObject json = JSONObject.fromObject(jsonContent);
|
| | |
|
| | | |
| | | List<String> tokenList = new ArrayList<>();
|
| | | |
| | | boolean ispush = false;
|
| | | List<Long> listNotPushId = null;
|
| | | |
| | | Calendar now = Calendar.getInstance();
|
| | | int hour = now.get(Calendar.HOUR_OF_DAY);
|
| | | if (hour >= 8 && hour < 20) {
|
| | | ispush = true; // 可推送
|
| | | } else {
|
| | | listNotPushId = validateNotDisturb();
|
| | | }
|
| | | |
| | | for (DeviceTokenIOS ios : list) {
|
| | | |
| | | if (!StringUtil.isNullOrEmpty(ios.getDeviceToken())) {
|
| | | if (!ispush && listNotPushId != null && listNotPushId.size() > 0) {
|
| | | Long uid = ios.getUid();
|
| | | if (uid != null && listNotPushId.contains(uid)) {
|
| | | continue; // 通知免打扰(20:00-24:00 / 00:00 -08:00) |
| | | }
|
| | | }
|
| | | tokenList.add(ios.getDeviceToken());
|
| | | // System.out.println(ios.getDeviceToken());
|
| | | }
|
| | | }
|
| | |
|
| | | if (tokenList.size() > 0) {
|
| | | // System.out.println(tokenList.size());
|
| | | // 执行推送
|
| | | try {
|
| | | IOSPushUtil.executePushIOS(tokenList, json);
|
| | | } catch (Exception e) {
|
| | | // TODO Auto-generated catch block
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | |
| | | pushQueueRecord.setEndtime(new Date());
|
| | | pushQueueRecord.setRecordCursor(recordCursor);
|
| | |
|
| | | // TODO 更新数据库
|
| | | // 更新数据库
|
| | | pushQueueRecordMapper.updateByPrimaryKeySelective(pushQueueRecord);
|
| | | }
|
| | |
|
| | |
| | | }
|
| | | }
|
| | | }
|
| | | |
| | | /**
|
| | | * 通知免打扰(20:00-8:00) |
| | | */
|
| | | public List<Long> validateNotDisturb() {
|
| | | return userCustomSettingsService.getCancelNoticeUsers();
|
| | | }
|
| | | |
| | | /**
|
| | | * 通知免打扰(20:00-8:00) |
| | | */
|
| | | public boolean validateNotDisturbSingle(Long uid) {
|
| | | Calendar now = Calendar.getInstance();
|
| | | int hour = now.get(Calendar.HOUR_OF_DAY);
|
| | | boolean ispush;
|
| | | if (hour >= 8 && hour < 20) {
|
| | | ispush = true; // 可推送
|
| | | } else {
|
| | | // 自定义设置 通知免打扰(20:00-24:00 / 00:00 -08:00) |
| | | ispush = userCustomSettingsService.validateCancelNoticeByUid(uid);
|
| | | }
|
| | | |
| | | return ispush;
|
| | | }
|
| | | |
| | |
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.service.impl.user;
|
| | |
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.stereotype.Service;
|
| | |
|
| | | import com.yeshi.fanli.dao.mybatis.user.UserCustomSettingsMapper;
|
| | | import com.yeshi.fanli.entity.bus.user.UserCustomSettings;
|
| | | import com.yeshi.fanli.entity.bus.user.UserCustomSettings.UserSettingTypeEnum;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInfo;
|
| | | import com.yeshi.fanli.exception.user.UserCustomSettingsException;
|
| | | import com.yeshi.fanli.service.inter.user.UserCustomSettingsService;
|
| | | import com.yeshi.fanli.vo.user.UserSettingsVO;
|
| | |
|
| | | @Service
|
| | | public class UserCustomSettingsServiceImpl implements UserCustomSettingsService {
|
| | |
|
| | | @Resource
|
| | | private UserCustomSettingsMapper userCustomSettingsMapper;
|
| | | |
| | | @Override
|
| | | public void saveModuleState(Long uid, Integer type, Integer state) throws UserCustomSettingsException{
|
| | | if (uid == null || type == null || state == null || state > 1 || state < 0) {
|
| | | throw new UserCustomSettingsException(1, "传递参数不正确");
|
| | | }
|
| | | |
| | | String typeNum = null;
|
| | | UserSettingTypeEnum mineTypeNum = null;
|
| | | |
| | | switch(type) {
|
| | | case 1:
|
| | | typeNum = UserSettingTypeEnum.cancelNotice.name();
|
| | | mineTypeNum = UserSettingTypeEnum.cancelNotice;
|
| | | break;
|
| | | case 2:
|
| | | typeNum = UserSettingTypeEnum.noNewsRedDot.name();
|
| | | mineTypeNum = UserSettingTypeEnum.noNewsRedDot;
|
| | | break;
|
| | | case 3:
|
| | | typeNum = UserSettingTypeEnum.noBonusCount.name();
|
| | | mineTypeNum = UserSettingTypeEnum.noBonusCount;
|
| | | break;
|
| | | case 4:
|
| | | typeNum = UserSettingTypeEnum.noShareRecordAndStorage.name();
|
| | | mineTypeNum = UserSettingTypeEnum.noShareRecordAndStorage;
|
| | | break;
|
| | | case 5:
|
| | | typeNum = UserSettingTypeEnum.noInvitationBonus.name();
|
| | | mineTypeNum = UserSettingTypeEnum.noInvitationBonus;
|
| | | break;
|
| | | default:
|
| | | throw new UserCustomSettingsException(1, "参数类型不匹配"); |
| | | }
|
| | | |
| | | UserCustomSettings settings = userCustomSettingsMapper.getSettingsByUidAndType(uid, typeNum);
|
| | | if (settings == null) { // 插入
|
| | | settings = new UserCustomSettings();
|
| | | settings.setState(state);
|
| | | settings.setType(mineTypeNum);
|
| | | settings.setUserInfo(new UserInfo(uid));
|
| | | settings.setUpdateTime(new Date());
|
| | | settings.setCreateTime(new Date());
|
| | | userCustomSettingsMapper.insertSelective(settings);
|
| | | } else { // 更新
|
| | | UserCustomSettings record = new UserCustomSettings();
|
| | | record.setId(settings.getId());
|
| | | record.setState(state);
|
| | | record.setType(mineTypeNum);
|
| | | record.setUpdateTime(new Date());
|
| | | userCustomSettingsMapper.updateByPrimaryKeySelective(settings);
|
| | | }
|
| | | |
| | | }
|
| | |
|
| | | @Override
|
| | | public List<UserCustomSettings> getSettingsByUid(Long uid) throws UserCustomSettingsException{
|
| | | if (uid == null) {
|
| | | throw new UserCustomSettingsException(1, "uid不能为空");
|
| | | }
|
| | | |
| | | return userCustomSettingsMapper.getSettingsByUid(uid);
|
| | | }
|
| | | |
| | | @Override
|
| | | public UserCustomSettings getSettingsByUidAndType(Long uid, String type) throws UserCustomSettingsException{
|
| | | |
| | | if (uid == null || type == null || type.trim().length() == 0 ) {
|
| | | throw new UserCustomSettingsException(1, "传递的参数不能为空");
|
| | | }
|
| | | |
| | | return userCustomSettingsMapper.getSettingsByUidAndType(uid, type);
|
| | | }
|
| | | |
| | | |
| | | @Override
|
| | | public UserSettingsVO getMySettings(Long uid) throws UserCustomSettingsException{
|
| | | |
| | | UserSettingsVO userSettingsVO = new UserSettingsVO();
|
| | | |
| | | List<UserCustomSettings> list = getSettingsByUid(uid);
|
| | | |
| | | if (list != null && list.size() > 0) {
|
| | | |
| | | for (UserCustomSettings userCustomSettings: list) {
|
| | | |
| | | Integer state = userCustomSettings.getState();
|
| | | if (state == null) {
|
| | | continue;
|
| | | }
|
| | | |
| | | UserSettingTypeEnum typeEnum = userCustomSettings.getType();
|
| | | |
| | | if (typeEnum.equals(UserSettingTypeEnum.cancelNotice) ) {
|
| | | userSettingsVO.setCancelNotice(state);
|
| | | } else if (typeEnum.equals(UserSettingTypeEnum.noNewsRedDot)){
|
| | | userSettingsVO.setNoNewsRedDot(state);
|
| | | } else if (typeEnum.equals(UserSettingTypeEnum.noBonusCount)){
|
| | | userSettingsVO.setNoBonusCount(state);
|
| | | } else if (typeEnum.equals(UserSettingTypeEnum.noShareRecordAndStorage)){
|
| | | userSettingsVO.setNoShareRecordAndStorage(state);
|
| | | } else if (typeEnum.equals(UserSettingTypeEnum.noInvitationBonus)){
|
| | | userSettingsVO.setNoInvitationBonus(state);
|
| | | } |
| | | |
| | | }
|
| | | }
|
| | | |
| | | return userSettingsVO;
|
| | | }
|
| | | |
| | | |
| | | @Override
|
| | | public List<Long> getCancelNoticeUsers(){
|
| | | return userCustomSettingsMapper.getUserID(UserSettingTypeEnum.cancelNotice.name());
|
| | | }
|
| | | |
| | | |
| | | @Override
|
| | | public boolean validateCancelNoticeByUid(Long uid){
|
| | | boolean ispush = true;
|
| | | |
| | | UserCustomSettings settings = userCustomSettingsMapper.getSettingsByUidAndType(uid,
|
| | | UserSettingTypeEnum.cancelNotice.name());
|
| | | |
| | | if (settings != null && settings.getState() != null && settings.getState() == 1) {
|
| | | ispush = false;
|
| | | }
|
| | | |
| | | return ispush;
|
| | | }
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.service.inter.user;
|
| | |
|
| | | import java.util.List;
|
| | |
|
| | | import com.yeshi.fanli.entity.bus.user.UserCustomSettings;
|
| | | import com.yeshi.fanli.exception.user.UserCustomSettingsException;
|
| | | import com.yeshi.fanli.vo.user.UserSettingsVO;
|
| | |
|
| | | public interface UserCustomSettingsService {
|
| | |
|
| | | /**
|
| | | * 更新各项设置状态
|
| | | * @param uid
|
| | | * @param typeNum
|
| | | * @param state
|
| | | * @throws UserCustomSettingsException
|
| | | */
|
| | | public void saveModuleState(Long uid, Integer typeNum, Integer state) throws UserCustomSettingsException;
|
| | |
|
| | | |
| | | /**
|
| | | * 获取我的所有自定义设置
|
| | | * @param uid
|
| | | * @return
|
| | | */
|
| | | public List<UserCustomSettings> getSettingsByUid(Long uid) throws UserCustomSettingsException;
|
| | |
|
| | | |
| | | /**
|
| | | * 获取设置信息
|
| | | * @param uid 用户id
|
| | | * @param type 类型
|
| | | * @return
|
| | | */
|
| | | public UserCustomSettings getSettingsByUidAndType(Long uid, String type) throws UserCustomSettingsException;
|
| | |
|
| | | |
| | | /**
|
| | | * 设置列表
|
| | | * @param uid
|
| | | * @return
|
| | | * @throws UserCustomSettingsException
|
| | | */
|
| | | public UserSettingsVO getMySettings(Long uid) throws UserCustomSettingsException;
|
| | |
|
| | | /**
|
| | | * 推送时判断是否设置免打扰推送
|
| | | * @param uid
|
| | | * @return
|
| | | */
|
| | | public boolean validateCancelNoticeByUid(Long uid);
|
| | |
|
| | | /**
|
| | | * 查询设置免打扰用户
|
| | | * @return
|
| | | */
|
| | | public List<Long> getCancelNoticeUsers();
|
| | |
|
| | |
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.util.mybatishandler;
|
| | |
|
| | | import java.sql.CallableStatement;
|
| | | import java.sql.PreparedStatement;
|
| | | import java.sql.ResultSet;
|
| | | import java.sql.SQLException;
|
| | |
|
| | | import org.apache.ibatis.type.BaseTypeHandler;
|
| | | import org.apache.ibatis.type.JdbcType;
|
| | |
|
| | | import com.yeshi.fanli.entity.bus.user.UserCustomSettings.UserSettingTypeEnum;
|
| | |
|
| | | public class UserSettingTypeEnumHandler extends BaseTypeHandler<UserSettingTypeEnum> {
|
| | |
|
| | | @Override
|
| | | public UserSettingTypeEnum getNullableResult(ResultSet arg0, String arg1) throws SQLException {
|
| | | String key = arg0.getString(arg1);
|
| | | if (arg0.wasNull()) {
|
| | | return null;
|
| | | } else {
|
| | | return UserSettingTypeEnum.valueOf(key);
|
| | | }
|
| | | }
|
| | |
|
| | | @Override
|
| | | public UserSettingTypeEnum getNullableResult(ResultSet arg0, int arg1) throws SQLException {
|
| | | String key = arg0.getString(arg1);
|
| | | if (arg0.wasNull()) {
|
| | | return null;
|
| | | } else {
|
| | | // 根据数据库中的key值,定位SexEnum子类
|
| | | return UserSettingTypeEnum.valueOf(key);
|
| | | }
|
| | | }
|
| | |
|
| | | @Override
|
| | | public UserSettingTypeEnum getNullableResult(CallableStatement arg0, int arg1) throws SQLException {
|
| | | String key = arg0.getString(arg1);
|
| | | if (arg0.wasNull()) {
|
| | | return null;
|
| | | } else {
|
| | | // 根据数据库中的key值,定位SexEnum子类
|
| | | return UserSettingTypeEnum.valueOf(key);
|
| | | }
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void setNonNullParameter(PreparedStatement arg0, int arg1, UserSettingTypeEnum arg2, JdbcType arg3)
|
| | | throws SQLException {
|
| | | arg0.setString(arg1, arg2.name());
|
| | | }
|
| | |
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.vo.user;
|
| | |
|
| | | import java.io.Serializable;
|
| | |
|
| | | public class UserSettingsVO implements Serializable{
|
| | |
|
| | | private static final long serialVersionUID = 1L;
|
| | | |
| | | // 通知免打扰(20:00-8:00)
|
| | | private Integer cancelNotice;
|
| | | // 不看消息红点提醒
|
| | | private Integer noNewsRedDot;
|
| | | // 不看奖金统计
|
| | | private Integer noBonusCount;
|
| | | // 不看分享记录和选品库
|
| | | private Integer noShareRecordAndStorage;
|
| | | // 不看邀请拿奖金
|
| | | private Integer noInvitationBonus;
|
| | |
|
| | | public Integer getCancelNotice() {
|
| | | return cancelNotice;
|
| | | }
|
| | |
|
| | | public void setCancelNotice(Integer cancelNotice) {
|
| | | this.cancelNotice = cancelNotice;
|
| | | }
|
| | |
|
| | | public Integer getNoNewsRedDot() {
|
| | | return noNewsRedDot;
|
| | | }
|
| | |
|
| | | public void setNoNewsRedDot(Integer noNewsRedDot) {
|
| | | this.noNewsRedDot = noNewsRedDot;
|
| | | }
|
| | |
|
| | | public Integer getNoBonusCount() {
|
| | | return noBonusCount;
|
| | | }
|
| | |
|
| | | public void setNoBonusCount(Integer noBonusCount) {
|
| | | this.noBonusCount = noBonusCount;
|
| | | }
|
| | |
|
| | | public Integer getNoShareRecordAndStorage() {
|
| | | return noShareRecordAndStorage;
|
| | | }
|
| | |
|
| | | public void setNoShareRecordAndStorage(Integer noShareRecordAndStorage) {
|
| | | this.noShareRecordAndStorage = noShareRecordAndStorage;
|
| | | }
|
| | |
|
| | | public Integer getNoInvitationBonus() {
|
| | | return noInvitationBonus;
|
| | | }
|
| | |
|
| | | public void setNoInvitationBonus(Integer noInvitationBonus) {
|
| | | this.noInvitationBonus = noInvitationBonus;
|
| | | }
|
| | |
|
| | | }
|