From e358583d644fa39fc1e93b14b3cafff3644980e4 Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期五, 22 二月 2019 09:29:54 +0800 Subject: [PATCH] 用户服务修改 --- fanli-facade-user/src/main/java/org/fanli/facade/user/exception/account/UserCustomSettingsException.java | 32 fanli-facade-user/src/main/java/org/fanli/facade/user/service/account/user/UserRankingsService.java | 180 ++++ fanli-service-user/src/main/java/org/fanli/service/user/service/impl/account/user/UserActiveLogServiceImpl.java | 42 fanli-service-user/src/main/java/org/fanli/service/user/dao/account/user/UserActiveLogMapper.java | 20 fanli-service-user/src/main/java/org/fanli/service/user/mapper/account/user/UserRankMapper.xml | 94 ++ fanli-facade-user/src/main/java/org/fanli/facade/user/entity/account/user/UserCustomSettings.java | 105 ++ fanli-service-system/src/main/java/com/yeshi/fanli/system/mapping/common/SMSHistoryMapper.xml | 62 + fanli-service-system/src/main/java/com/yeshi/fanli/system/utils/SMSRedisManager.java | 180 ++++ fanli-service-user/src/main/java/org/fanli/service/user/service/impl/account/user/UserRankingsServiceImpl.java | 475 ++++++++++ fanli-service-user/src/main/java/org/fanli/service/user/mapper/account/user/UserRankingsMapper.xml | 330 +++++++ fanli-service-user/src/main/java/org/fanli/service/user/dao/account/user/UserCustomSettingsMapper.java | 31 fanli-facade-system/src/main/java/org/fanli/facade/system/util/TencentSMSUtil.java | 46 + fanli-service-system/src/main/java/com/yeshi/fanli/system/dao/common/SMSHistoryMapper.java | 18 fanli-facade-user/src/main/java/org/fanli/facade/user/service/account/user/UserActiveLogService.java | 27 fanli-service-user/src/main/java/org/fanli/service/user/mapper/account/user/UserCustomSettingsMapper.xml | 102 ++ fanli-service-user/src/main/java/org/fanli/service/user/service/impl/account/UserAccountServiceImpl.java | 2 fanli-service-user/src/main/java/org/fanli/service/user/dao/account/user/UserRankMapper.java | 15 fanli-facade-user/src/main/java/org/fanli/facade/user/entity/account/user/UserRankings.java | 4 fanli-service-user/src/main/java/org/fanli/service/user/mapper/account/user/UserActiveLogMapper.xml | 103 ++ fanli-facade-system/src/main/java/org/fanli/facade/system/exception/SMSException.java | 32 fanli-facade-user/src/main/java/org/fanli/facade/user/service/account/user/UserRankService.java | 15 fanli-service-user/src/main/java/org/fanli/service/user/service/impl/account/user/UserCustomSettingsServiceImpl.java | 144 +++ fanli-facade-system/src/main/java/org/fanli/facade/system/entity/common/SMSHistory.java | 73 + fanli-facade-user/src/main/java/org/fanli/facade/user/entity/account/user/UserActiveLog.java | 2 fanli-service-user/src/main/java/org/fanli/service/user/service/impl/account/user/UserRankServiceImpl.java | 22 fanli-service-user/src/main/java/org/fanli/service/user/dao/account/user/UserRankingsMapper.java | 62 + fanli-facade-user/src/main/java/org/fanli/facade/user/entity/account/user/UserRank.java | 2 fanli-service-user/src/main/java/org/fanli/service/user/dao/account/user/UserRankRecordMapper.java | 10 fanli-facade-user/src/main/java/org/fanli/facade/user/entity/UserInfoExtra.java | 1 fanli-facade-user/src/main/java/org/fanli/facade/user/util/typehandler/UserSettingTypeEnumHandler.java | 52 + fanli-facade-user/src/main/java/org/fanli/facade/user/vo/UserSettingsVO.java | 60 + fanli-facade-user/src/main/java/org/fanli/facade/user/service/account/user/UserCustomSettingsService.java | 60 + fanli-service-user/src/main/java/org/fanli/service/user/mapper/account/user/UserRankRecordMapper.xml | 60 + fanli-service-system/src/main/java/com/yeshi/fanli/system/service/impl/common/SMSServiceImpl.java | 108 ++ fanli-facade-system/src/main/java/org/fanli/facade/system/service/common/SMSService.java | 54 + 35 files changed, 2,620 insertions(+), 5 deletions(-) diff --git a/fanli-facade-system/src/main/java/org/fanli/facade/system/entity/common/SMSHistory.java b/fanli-facade-system/src/main/java/org/fanli/facade/system/entity/common/SMSHistory.java new file mode 100644 index 0000000..1229b16 --- /dev/null +++ b/fanli-facade-system/src/main/java/org/fanli/facade/system/entity/common/SMSHistory.java @@ -0,0 +1,73 @@ +package org.fanli.facade.system.entity.common; + + +import java.util.Date; + +import org.yeshi.utils.mybatis.Column; +import org.yeshi.utils.mybatis.Table; + +/** + * 鐭俊楠岃瘉鐮佸彂閫佸巻鍙茶褰� + * + * @author Administrator + * + */ +@Table("yeshi_ec_sms_history") +public class SMSHistory { + + public final static int TYPE_LOGIN = 1;// 鐧诲綍 + public final static int TYPE_BIND = 2;// 缁戝畾 + public final static int TYPE_EXTRACT = 3;// 鎻愮幇 + + @Column(name = "sh_id") + private Long id; + @Column(name = "sh_type") + private Integer type; + @Column(name = "sh_phone") + private String phone; + @Column(name = "sh_content") + private String content; + @Column(name = "sh_createtime") + private Date createTime; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public Integer getType() { + return type; + } + + public void setType(Integer type) { + this.type = type; + } + + public String getPhone() { + return phone; + } + + public void setPhone(String phone) { + this.phone = phone; + } + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } + + public Date getCreateTime() { + return createTime; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + +} diff --git a/fanli-facade-system/src/main/java/org/fanli/facade/system/exception/SMSException.java b/fanli-facade-system/src/main/java/org/fanli/facade/system/exception/SMSException.java new file mode 100644 index 0000000..80410a8 --- /dev/null +++ b/fanli-facade-system/src/main/java/org/fanli/facade/system/exception/SMSException.java @@ -0,0 +1,32 @@ +package org.fanli.facade.system.exception; + +public class SMSException 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 SMSException(int code, String msg) { + this.code = code; + this.msg = msg; + } + + public SMSException() { + } + + @Override + public String getMessage() { + return this.msg; + } + +} diff --git a/fanli-facade-system/src/main/java/org/fanli/facade/system/service/common/SMSService.java b/fanli-facade-system/src/main/java/org/fanli/facade/system/service/common/SMSService.java new file mode 100644 index 0000000..51fd592 --- /dev/null +++ b/fanli-facade-system/src/main/java/org/fanli/facade/system/service/common/SMSService.java @@ -0,0 +1,54 @@ +package org.fanli.facade.system.service.common; + +import java.math.BigDecimal; + +import org.fanli.facade.system.exception.SMSException; + +/** + * 鐭俊鏈嶅姟 + * + * @author Administrator + * + */ +public interface SMSService { + + /** + * 鍙戦�佺櫥褰曢獙璇佺爜 + * + * @param phone + * @throws SMSException + */ + public String sendLoginVCode(String phone) throws SMSException; + + /** + * 鍙戦�佺粦瀹氶獙璇佺爜 + * + * @param phone + * @throws SMSException + */ + public void sendBindVCode(String phone) throws SMSException; + + /** + * 鍙戦�佹彁鐜伴獙璇佺爜 + * + * @param phone + * @throws SMSException + */ + public void sendExtractVCode(String phone) throws SMSException; + + /** + * 鎻愮幇鎴愬姛鐭俊 + * + * @param phone + * @param money + */ + public void sendExtractSuccessMsg(String phone, BigDecimal money) throws SMSException; + + /** + * 鍙戦�佹彁鐜板け璐ラ獙璇佺爜 + * + * @param phone + * @param money + */ + public void sendExtractFailMsg(String phone, BigDecimal money) throws SMSException; +} diff --git a/fanli-facade-system/src/main/java/org/fanli/facade/system/util/TencentSMSUtil.java b/fanli-facade-system/src/main/java/org/fanli/facade/system/util/TencentSMSUtil.java new file mode 100644 index 0000000..406f39d --- /dev/null +++ b/fanli-facade-system/src/main/java/org/fanli/facade/system/util/TencentSMSUtil.java @@ -0,0 +1,46 @@ +package org.fanli.facade.system.util; + +import java.io.IOException; + +import org.fanli.facade.system.exception.SMSException; +import org.json.JSONException; + +import com.github.qcloudsms.SmsSingleSender; +import com.github.qcloudsms.SmsSingleSenderResult; +import com.github.qcloudsms.httpclient.HTTPException; +import com.yeshi.fanli.base.Constant; + +//鑵捐鐭俊鍙戦�� +public class TencentSMSUtil { + + /** + * 鍙戦�佸崟涓�鐭俊 + * + * @param phone + * @param msg + */ + public static void sendSingleMsg(String phone, String msg) throws SMSException { + SmsSingleSender ssender = new SmsSingleSender(Integer.parseInt(Constant.smsConfig.getSmsAppId()), + Constant.smsConfig.getSmsAppKey()); + SmsSingleSenderResult result = null; + try { + result = ssender.send(0, "86", phone, msg, "", ""); + } catch (JSONException e) { + e.printStackTrace(); + } catch (HTTPException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + + if (result == null) + throw new SMSException(2, "鐭俊鍙戦�佸け璐�"); + if (result.result == 1025) { + throw new SMSException(result.result, "浠婃棩楠岃瘉鐮佸彂閫佽秴闄愶紝璇锋槑鏃ュ啀璇�"); + } else if (result.result != 0) {// 鍙戦�佸け璐� + throw new SMSException(result.result, "鐭俊鍙戦�佸け璐�"); + } + + } + +} diff --git a/fanli-facade-user/src/main/java/org/fanli/facade/user/entity/UserInfoExtra.java b/fanli-facade-user/src/main/java/org/fanli/facade/user/entity/UserInfoExtra.java index 7848779..6ccc064 100644 --- a/fanli-facade-user/src/main/java/org/fanli/facade/user/entity/UserInfoExtra.java +++ b/fanli-facade-user/src/main/java/org/fanli/facade/user/entity/UserInfoExtra.java @@ -2,6 +2,7 @@ import java.util.Date; +import org.fanli.facade.user.entity.account.user.UserRank; import org.yeshi.utils.mybatis.Column; import org.yeshi.utils.mybatis.Table; diff --git a/fanli-facade-user/src/main/java/org/fanli/facade/user/entity/UserActiveLog.java b/fanli-facade-user/src/main/java/org/fanli/facade/user/entity/account/user/UserActiveLog.java similarity index 97% rename from fanli-facade-user/src/main/java/org/fanli/facade/user/entity/UserActiveLog.java rename to fanli-facade-user/src/main/java/org/fanli/facade/user/entity/account/user/UserActiveLog.java index f0309f7..7bfbecc 100644 --- a/fanli-facade-user/src/main/java/org/fanli/facade/user/entity/UserActiveLog.java +++ b/fanli-facade-user/src/main/java/org/fanli/facade/user/entity/account/user/UserActiveLog.java @@ -1,4 +1,4 @@ -package org.fanli.facade.user.entity; +package org.fanli.facade.user.entity.account.user; import java.util.Date; diff --git a/fanli-facade-user/src/main/java/org/fanli/facade/user/entity/account/user/UserCustomSettings.java b/fanli-facade-user/src/main/java/org/fanli/facade/user/entity/account/user/UserCustomSettings.java new file mode 100644 index 0000000..3771c6d --- /dev/null +++ b/fanli-facade-user/src/main/java/org/fanli/facade/user/entity/account/user/UserCustomSettings.java @@ -0,0 +1,105 @@ +package org.fanli.facade.user.entity.account.user; + +import java.util.Date; + +import org.yeshi.utils.mybatis.Column; +import org.yeshi.utils.mybatis.Table; + +import com.yeshi.fanli.base.entity.user.UserInfo; + +/** + * 鐢ㄦ埛app鐣岄潰涓�у寲璁剧疆 + * @author Administrator + * + */ +@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; + } + +} diff --git a/fanli-facade-user/src/main/java/org/fanli/facade/user/entity/UserRank.java b/fanli-facade-user/src/main/java/org/fanli/facade/user/entity/account/user/UserRank.java similarity index 97% rename from fanli-facade-user/src/main/java/org/fanli/facade/user/entity/UserRank.java rename to fanli-facade-user/src/main/java/org/fanli/facade/user/entity/account/user/UserRank.java index cb45fc5..73a7408 100644 --- a/fanli-facade-user/src/main/java/org/fanli/facade/user/entity/UserRank.java +++ b/fanli-facade-user/src/main/java/org/fanli/facade/user/entity/account/user/UserRank.java @@ -1,4 +1,4 @@ -package org.fanli.facade.user.entity; +package org.fanli.facade.user.entity.account.user; import java.util.Date; diff --git a/fanli-facade-user/src/main/java/org/fanli/facade/user/entity/UserRankings.java b/fanli-facade-user/src/main/java/org/fanli/facade/user/entity/account/user/UserRankings.java similarity index 98% rename from fanli-facade-user/src/main/java/org/fanli/facade/user/entity/UserRankings.java rename to fanli-facade-user/src/main/java/org/fanli/facade/user/entity/account/user/UserRankings.java index c41f809..5a9a58a 100644 --- a/fanli-facade-user/src/main/java/org/fanli/facade/user/entity/UserRankings.java +++ b/fanli-facade-user/src/main/java/org/fanli/facade/user/entity/account/user/UserRankings.java @@ -1,4 +1,4 @@ -package org.fanli.facade.user.entity; +package org.fanli.facade.user.entity.account.user; import java.math.BigDecimal; import java.util.Date; @@ -22,7 +22,7 @@ @Table(name = "yeshi_ec_rankings_record") @org.yeshi.utils.mybatis.Table("yeshi_ec_rankings_record") public class UserRankings { - + @Id @Column(name = "r_id") diff --git a/fanli-facade-user/src/main/java/org/fanli/facade/user/exception/account/UserCustomSettingsException.java b/fanli-facade-user/src/main/java/org/fanli/facade/user/exception/account/UserCustomSettingsException.java new file mode 100644 index 0000000..af7f826 --- /dev/null +++ b/fanli-facade-user/src/main/java/org/fanli/facade/user/exception/account/UserCustomSettingsException.java @@ -0,0 +1,32 @@ +package org.fanli.facade.user.exception.account; + +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; + } + +} diff --git a/fanli-facade-user/src/main/java/org/fanli/facade/user/service/account/user/UserActiveLogService.java b/fanli-facade-user/src/main/java/org/fanli/facade/user/service/account/user/UserActiveLogService.java new file mode 100644 index 0000000..b75896f --- /dev/null +++ b/fanli-facade-user/src/main/java/org/fanli/facade/user/service/account/user/UserActiveLogService.java @@ -0,0 +1,27 @@ +package org.fanli.facade.user.service.account.user; + +import org.fanli.facade.user.entity.account.user.UserActiveLog; + +/** + * 鐢ㄦ埛娲昏穬鏃ュ織鏈嶅姟 + * + * @author Administrator + * + */ +public interface UserActiveLogService { + /** + * 鐢ㄦ埛娲昏穬鏃ュ織 + * + * @param userActiveLog + */ + public void addUserActiveLog(UserActiveLog userActiveLog); + + /** + * 鑾峰彇鏌愪釜鐢ㄦ埛鐨勬渶杩戜竴娆$殑娲昏穬淇℃伅 + * + * @param uid + * @return + */ + public UserActiveLog getUserLatestActiveInfo(Long uid); + +} diff --git a/fanli-facade-user/src/main/java/org/fanli/facade/user/service/account/user/UserCustomSettingsService.java b/fanli-facade-user/src/main/java/org/fanli/facade/user/service/account/user/UserCustomSettingsService.java new file mode 100644 index 0000000..08566be --- /dev/null +++ b/fanli-facade-user/src/main/java/org/fanli/facade/user/service/account/user/UserCustomSettingsService.java @@ -0,0 +1,60 @@ +package org.fanli.facade.user.service.account.user; + +import java.util.List; + +import org.fanli.facade.user.entity.account.user.UserCustomSettings; +import org.fanli.facade.user.exception.account.UserCustomSettingsException; +import org.fanli.facade.user.vo.UserSettingsVO; + +public interface UserCustomSettingsService { + + /** + * 鏇存柊鍚勯」璁剧疆鐘舵�� + * @param uid + * @param typeNum + * @param state + * @throws UserCustomSettingsException + */ + public void saveModuleState(Long uid, String type, 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(); + + +} diff --git a/fanli-facade-user/src/main/java/org/fanli/facade/user/service/account/user/UserRankService.java b/fanli-facade-user/src/main/java/org/fanli/facade/user/service/account/user/UserRankService.java new file mode 100644 index 0000000..8f6d2d4 --- /dev/null +++ b/fanli-facade-user/src/main/java/org/fanli/facade/user/service/account/user/UserRankService.java @@ -0,0 +1,15 @@ +package org.fanli.facade.user.service.account.user; + +import java.util.List; + +import org.fanli.facade.user.entity.account.user.UserRank; + +public interface UserRankService { + + /** + * 鑾峰彇鎵�鏈夌瓑绾� + * @return + */ + public List<UserRank> getAllRank(); + +} diff --git a/fanli-facade-user/src/main/java/org/fanli/facade/user/service/account/user/UserRankingsService.java b/fanli-facade-user/src/main/java/org/fanli/facade/user/service/account/user/UserRankingsService.java new file mode 100644 index 0000000..1171197 --- /dev/null +++ b/fanli-facade-user/src/main/java/org/fanli/facade/user/service/account/user/UserRankingsService.java @@ -0,0 +1,180 @@ +package org.fanli.facade.user.service.account.user; + +import java.io.File; +import java.util.List; + +import org.fanli.facade.user.entity.account.user.UserRankings; +import org.fanli.facade.user.entity.invite.InviteGetMoney; +import org.fanli.facade.user.exception.UserRankingsException; +import org.springframework.web.multipart.MultipartFile; + +public interface UserRankingsService { + + /** + * 鎻掑叆瀵硅薄 + * + * @param record + * @return + * @throws UserRankingsException + */ + public int insertSelective(UserRankings record) throws UserRankingsException; + + /** + * 鏇存柊褰撳墠瀵硅薄鎵�鏈夋暟鎹� + * + * @param record + * @return + * @throws UserRankingsException + */ + public int updateByPrimaryKey(UserRankings record) throws UserRankingsException; + + /** + * 閫夋嫨鎬ф洿鏂板唴瀹光�斺�斾笉涓虹┖鍒欐洿鏂拌瀛楁 + * + * @param record + * @return + * @throws UserRankingsException + */ + public int updateByPrimaryKeySelective(UserRankings record) throws UserRankingsException; + + /** + * 鏍规嵁id鏌ユ壘褰撳墠瀵硅薄 + * + * @param id + * @return + * @throws UserRankingsException + */ + public UserRankings selectByPrimaryKey(Long id) throws UserRankingsException; + + /** + * 鏍规嵁id鍒犻櫎 + * + * @param ids + */ + public int deleteBatchById(Long id) throws UserRankingsException; + + /** + * 鏍规嵁id鎵归噺鍒犻櫎 + * @param arrayID + * @return + * @throws UserRankingsException + */ + public int deleteBatchByPrimaryKey(List<Long> arrayID) throws UserRankingsException; + + + /** + * 涓婁紶鍥剧墖 + * + * @param file + * @param admin + * @return + * @throws UserRankingsException + */ + public void uploadPicture(MultipartFile file, UserRankings UserRankings) throws Exception; + + + /** + * 淇濆瓨淇℃伅骞朵笂浼犲浘鐗囨枃浠� + * @param record + * @return + * @throws UserRankingsException + */ + public void insertAndUploadFile(UserRankings record, MultipartFile file) throws Exception; + + /** + * 鏍规嵁鏄电О鏌ヨ + * @param nickName + * @return + * @throws UserRankingsException + */ + public List<UserRankings> selectByNickName(String nickName) throws UserRankingsException; + + /** + * 鏍规嵁鏄剧ずID鏌ヨ + * @param nickName + * @return + * @throws UserRankingsException + */ + public List<UserRankings> selectByShowId(String showId) throws UserRankingsException; + + + + /** + * 鏌ヨ鎵�鏈夊垪琛� + * @param pageIndex + * @param pageSize + * @param key + * @param sort + * @return + * @throws UserRankingsException + */ + public List<UserRankings> query(long start, int count, String key, Integer tradeState, Integer shareState, Integer sort) throws UserRankingsException; + + public long queryCount(String key, Integer tradeState, Integer shareState) throws UserRankingsException; + + /** + * 鍒犻櫎鍥剧墖 + * @param userRankings + * @throws Exception + */ + public void removePicture(UserRankings userRankings) throws Exception; + + /** + * 鎵归噺璁剧疆濂栭噾 + * @param idList + * @param type 1鑷喘濂栭噾 2 鍒嗕韩濂栭噾 + * @param reward + * @param startReward + * @param endReward + * @throws Exception + */ + public void setRewardtBatch(List<Long> idList, Integer type, Double reward, Double startReward, Double endReward) throws Exception; + + /** + * 鎵归噺淇敼鐘舵�� + * @param idList + * @param type + * @param state + * @throws Exception + */ + public void setStateBatch(List<Long> idList, Integer type, Integer state) throws Exception; + + public void uploadFile(File file) throws Exception; + + public void updateShowID(File file) throws Exception; + + public void batchUpNickName(File file) throws Exception; + + /** + * 鏍规嵁id闆嗗悎鏌ヨ瀵瑰簲鏁版嵁 + * @param ids + * @return + * @throws UserRankingsException + */ + public List<UserRankings> listQueryByIds(List<Long> ids) throws UserRankingsException; + + + /** + * 鎵归噺閫夋嫨鏇存柊 + * @param list + * @return + * @throws UserRankingsException + */ + public int updateBatchSelective(List<UserRankings> list) throws UserRankingsException; + + /** + * 鍓嶇鎺掕姒� + * @param start + * @param count + * @return + */ + public List<InviteGetMoney> getRank(long start, int count); + + /** + * + * @throws UserRankingsException + */ + public void updateClearTradeState() throws UserRankingsException; + + +} diff --git a/fanli-facade-user/src/main/java/org/fanli/facade/user/util/typehandler/UserSettingTypeEnumHandler.java b/fanli-facade-user/src/main/java/org/fanli/facade/user/util/typehandler/UserSettingTypeEnumHandler.java new file mode 100644 index 0000000..ee83ce5 --- /dev/null +++ b/fanli-facade-user/src/main/java/org/fanli/facade/user/util/typehandler/UserSettingTypeEnumHandler.java @@ -0,0 +1,52 @@ +package org.fanli.facade.user.util.typehandler; + +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 org.fanli.facade.user.entity.account.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 { + // 鏍规嵁鏁版嵁搴撲腑鐨刱ey鍊硷紝瀹氫綅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 { + // 鏍规嵁鏁版嵁搴撲腑鐨刱ey鍊硷紝瀹氫綅SexEnum瀛愮被 + return UserSettingTypeEnum.valueOf(key); + } + } + + @Override + public void setNonNullParameter(PreparedStatement arg0, int arg1, UserSettingTypeEnum arg2, JdbcType arg3) + throws SQLException { + arg0.setString(arg1, arg2.name()); + } + +} diff --git a/fanli-facade-user/src/main/java/org/fanli/facade/user/vo/UserSettingsVO.java b/fanli-facade-user/src/main/java/org/fanli/facade/user/vo/UserSettingsVO.java new file mode 100644 index 0000000..cf38ffc --- /dev/null +++ b/fanli-facade-user/src/main/java/org/fanli/facade/user/vo/UserSettingsVO.java @@ -0,0 +1,60 @@ +package org.fanli.facade.user.vo; + +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; + } + +} diff --git a/fanli-service-system/src/main/java/com/yeshi/fanli/system/dao/common/SMSHistoryMapper.java b/fanli-service-system/src/main/java/com/yeshi/fanli/system/dao/common/SMSHistoryMapper.java new file mode 100644 index 0000000..942adc5 --- /dev/null +++ b/fanli-service-system/src/main/java/com/yeshi/fanli/system/dao/common/SMSHistoryMapper.java @@ -0,0 +1,18 @@ +package com.yeshi.fanli.system.dao.common; + +import org.fanli.facade.system.entity.common.SMSHistory; + +public interface SMSHistoryMapper { + + int deleteByPrimaryKey(Long id); + + int insert(SMSHistory record); + + int insertSelective(SMSHistory record); + + SMSHistory selectByPrimaryKey(Long id); + + int updateByPrimaryKeySelective(SMSHistory record); + + int updateByPrimaryKey(SMSHistory record); +} \ No newline at end of file diff --git a/fanli-service-system/src/main/java/com/yeshi/fanli/system/mapping/common/SMSHistoryMapper.xml b/fanli-service-system/src/main/java/com/yeshi/fanli/system/mapping/common/SMSHistoryMapper.xml new file mode 100644 index 0000000..3492ab2 --- /dev/null +++ b/fanli-service-system/src/main/java/com/yeshi/fanli/system/mapping/common/SMSHistoryMapper.xml @@ -0,0 +1,62 @@ +<?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.system.dao.common.SMSHistoryMapper"> + <resultMap id="BaseResultMap" type="org.fanli.facade.system.entity.common.SMSHistory"> + <id column="sh_id" property="id" jdbcType="BIGINT" /> + <result column="sh_type" property="type" jdbcType="INTEGER" /> + <result column="sh_phone" property="phone" jdbcType="VARCHAR" /> + <result column="sh_content" property="content" jdbcType="VARCHAR" /> + <result column="sh_createtime" property="createTime" jdbcType="TIMESTAMP" /> + </resultMap> + <sql id="Base_Column_List">sh_id,sh_type,sh_phone,sh_content,sh_createtime</sql> + <select id="selectByPrimaryKey" resultMap="BaseResultMap" + parameterType="java.lang.Long"> + select + <include refid="Base_Column_List" /> + from yeshi_ec_sms_history where sh_id = #{id,jdbcType=BIGINT} + </select> + <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from + yeshi_ec_sms_history where sh_id = #{id,jdbcType=BIGINT} + </delete> + <insert id="insert" parameterType="org.fanli.facade.system.entity.common.SMSHistory" + useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_sms_history + (sh_id,sh_type,sh_phone,sh_content,sh_createtime) values + (#{id,jdbcType=BIGINT},#{type,jdbcType=INTEGER},#{phone,jdbcType=VARCHAR},#{content,jdbcType=VARCHAR},#{createTime,jdbcType=TIMESTAMP}) + </insert> + <insert id="insertSelective" parameterType="org.fanli.facade.system.entity.common.SMSHistory" + useGeneratedKeys="true" keyProperty="id"> + insert into yeshi_ec_sms_history + <trim prefix="(" suffix=")" suffixOverrides=","> + <if test="id != null">sh_id,</if> + <if test="type != null">sh_type,</if> + <if test="phone != null">sh_phone,</if> + <if test="content != null">sh_content,</if> + <if test="createTime != null">sh_createtime,</if> + </trim> + values + <trim prefix="(" suffix=")" suffixOverrides=","> + <if test="id != null">#{id,jdbcType=BIGINT},</if> + <if test="type != null">#{type,jdbcType=INTEGER},</if> + <if test="phone != null">#{phone,jdbcType=VARCHAR},</if> + <if test="content != null">#{content,jdbcType=VARCHAR},</if> + <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if> + </trim> + </insert> + <update id="updateByPrimaryKey" parameterType="org.fanli.facade.system.entity.common.SMSHistory">update + yeshi_ec_sms_history set sh_type = #{type,jdbcType=INTEGER},sh_phone = + #{phone,jdbcType=VARCHAR},sh_content = + #{content,jdbcType=VARCHAR},sh_createtime = + #{createTime,jdbcType=TIMESTAMP} where sh_id = #{id,jdbcType=BIGINT} + </update> + <update id="updateByPrimaryKeySelective" parameterType="org.fanli.facade.system.entity.common.SMSHistory"> + update yeshi_ec_sms_history + <set> + <if test="type != null">sh_type=#{type,jdbcType=INTEGER},</if> + <if test="phone != null">sh_phone=#{phone,jdbcType=VARCHAR},</if> + <if test="content != null">sh_content=#{content,jdbcType=VARCHAR},</if> + <if test="createTime != null">sh_createtime=#{createTime,jdbcType=TIMESTAMP},</if> + </set> + where sh_id = #{id,jdbcType=BIGINT} + </update> +</mapper> diff --git a/fanli-service-system/src/main/java/com/yeshi/fanli/system/service/impl/common/SMSServiceImpl.java b/fanli-service-system/src/main/java/com/yeshi/fanli/system/service/impl/common/SMSServiceImpl.java new file mode 100644 index 0000000..1874512 --- /dev/null +++ b/fanli-service-system/src/main/java/com/yeshi/fanli/system/service/impl/common/SMSServiceImpl.java @@ -0,0 +1,108 @@ +package com.yeshi.fanli.system.service.impl.common; + +import java.math.BigDecimal; +import java.util.Date; + +import javax.annotation.Resource; + +import org.fanli.facade.system.entity.common.SMSHistory; +import org.fanli.facade.system.exception.SMSException; +import org.fanli.facade.system.service.common.SMSService; +import org.fanli.facade.system.util.TencentSMSUtil; +import org.springframework.stereotype.Service; +import org.yeshi.utils.StringUtil; + +import com.yeshi.fanli.base.Constant; +import com.yeshi.fanli.system.dao.common.SMSHistoryMapper; +import com.yeshi.fanli.system.utils.SMSRedisManager; + +@Service +public class SMSServiceImpl implements SMSService { + + @Resource + private SMSHistoryMapper smsHistoryMapper; + + @Resource + private SMSRedisManager redisManager; + + private String getVerifyCode(int count) { + String sts = "0123456789"; + String code = ""; + for (int i = 0; i < count; i++) { + int p = (int) (Math.random() * 10); + code += sts.charAt(p); + } + return code; + } + + @Override + public String sendLoginVCode(String phone) throws SMSException { + boolean limit = redisManager.isSmsFrequencyLimit(phone, SMSHistory.TYPE_LOGIN); + if (limit) + throw new SMSException(1001, "璇疯繃60绉掑啀璇�"); + String msgCode = getVerifyCode(6); + System.out.println(msgCode); + // 楠岃瘉鐮佹ā鏉� + String msg = Constant.smsConfig.getSmsLogin().replace("[绛惧悕]", Constant.smsConfig.getSmsSign()).replace("[楠岃瘉鐮乚", + msgCode); + // 鍙戦�佺煭淇� + TencentSMSUtil.sendSingleMsg(phone, msg); + // 缂撳瓨 + redisManager.sendSms(phone, SMSHistory.TYPE_LOGIN); + redisManager.saveSMSVCode(phone, SMSHistory.TYPE_LOGIN, msgCode); + SMSHistory smsHistory = new SMSHistory(); + smsHistory.setContent(msg); + smsHistory.setCreateTime(new Date()); + smsHistory.setPhone(phone); + smsHistory.setType(SMSHistory.TYPE_LOGIN); + smsHistoryMapper.insertSelective(smsHistory); + return msgCode; + } + + @Override + public void sendBindVCode(String phone) throws SMSException { + boolean limit = redisManager.isSmsFrequencyLimit(phone, SMSHistory.TYPE_BIND); + if (limit) + throw new SMSException(1001, "璇疯繃60绉掑啀璇�"); + String msgCode = StringUtil.getRandomCode(6); + String msg = Constant.smsConfig.getSmsBind().replace("[绛惧悕]", Constant.smsConfig.getSmsSign()).replace("[楠岃瘉鐮乚", + msgCode); + // 鍙戦�佺煭淇� + TencentSMSUtil.sendSingleMsg(phone, msg); + // 缂撳瓨 + redisManager.sendSms(phone, SMSHistory.TYPE_BIND); + redisManager.saveSMSVCode(phone, SMSHistory.TYPE_BIND, msgCode); + } + + @Override + public void sendExtractVCode(String phone) throws SMSException { + boolean limit = redisManager.isSmsFrequencyLimit(phone, SMSHistory.TYPE_EXTRACT); + if (limit) + throw new SMSException(1001, "璇疯繃60绉掑啀璇�"); + String msgCode = StringUtil.getRandomCode(6); + String msg = Constant.smsConfig.getSmsExtract().replace("[绛惧悕]", Constant.smsConfig.getSmsSign()) + .replace("[楠岃瘉鐮乚", msgCode); + // 鍙戦�佺煭淇� + TencentSMSUtil.sendSingleMsg(phone, msg); + // 缂撳瓨 + redisManager.sendSms(phone, SMSHistory.TYPE_EXTRACT); + redisManager.saveSMSVCode(phone, SMSHistory.TYPE_EXTRACT, msgCode); + } + + @Override + public void sendExtractSuccessMsg(String phone, BigDecimal money) throws SMSException { + String msg = Constant.smsConfig.getSmsExtractSuccess().replace("[绛惧悕]", Constant.smsConfig.getSmsSign()) + .replace("[閲戦]", money.toString()); + // 鍙戦�佺煭淇� + TencentSMSUtil.sendSingleMsg(phone, msg); + } + + @Override + public void sendExtractFailMsg(String phone, BigDecimal money) throws SMSException { + String msg = Constant.smsConfig.getSmsExtractFail().replace("[绛惧悕]", Constant.smsConfig.getSmsSign()) + .replace("[閲戦]", money.toString()); + // 鍙戦�佺煭淇� + TencentSMSUtil.sendSingleMsg(phone, msg); + } + +} diff --git a/fanli-service-system/src/main/java/com/yeshi/fanli/system/utils/SMSRedisManager.java b/fanli-service-system/src/main/java/com/yeshi/fanli/system/utils/SMSRedisManager.java new file mode 100644 index 0000000..71cc6ae --- /dev/null +++ b/fanli-service-system/src/main/java/com/yeshi/fanli/system/utils/SMSRedisManager.java @@ -0,0 +1,180 @@ +package com.yeshi.fanli.system.utils; + +import javax.annotation.Resource; + +import org.fanli.facade.system.service.common.ConfigService; +import org.springframework.stereotype.Component; +import org.yeshi.utils.StringUtil; + +import com.yeshi.fanli.base.Constant; + +import redis.clients.jedis.Jedis; +import redis.clients.jedis.JedisPool; + +//鎶㈢孩鍖呴噰鐢ㄧ殑redis +@Component +public class SMSRedisManager { + + @Resource + private JedisPool jedisPool; + + @Resource + private ConfigService configService; + + /** + * 缂撳瓨瀛楃涓� + * + * @param key + * @param value + */ + private void setString(String key, String value) { + Jedis jedis = jedisPool.getResource(); + try { + jedis.set(key, value); + } finally { + jedisPool.returnResource(jedis); + } + + } + + /** + * 鍒犻櫎鏌愪釜閿�� + * + * @param key + * @param value + */ + private void removeKey(String key) { + Jedis jedis = jedisPool.getResource(); + try { + jedis.del(key); + } finally { + jedisPool.returnResource(jedis); + } + + } + + /** + * 缂撳瓨瀛楃涓� + * + * @param key + * @param value + * @param seconds + * -缂撳瓨鏃堕棿锛坰锛� + */ + private void setString(String key, String value, int seconds) { + Jedis jedis = jedisPool.getResource(); + try { + jedis.setex(key, seconds, value); + } finally { + jedisPool.returnResource(jedis); + } + } + + private String getString(String key) { + Jedis jedis = jedisPool.getResource(); + try { + return jedis.get(key); + } finally { + jedisPool.returnResource(jedis); + } + } + + public void cacheCommonString(String key, String value, int seconds) { + setString(key, value, seconds); + } + + public void cacheCommonString(String key, String value) { + setString(key, value); + } + + public String getCommonString(String key) { + return getString(key); + } + + public void removeCommonString(String key) { + removeKey(key); + } + + /** + * 鏄惁闄愬埗鍙戦�佺煭淇� + * + * @param phone + * @param type + * @return + */ + public boolean isSmsFrequencyLimit(String phone, int type) { + if (!Constant.IS_OUTNET) + return false; + String key = "sms-" + phone + "-" + type; + String value = getCommonString(key); + if (StringUtil.isNullOrEmpty(value)) + return false; + else + return true; + } + + /** + * 璁剧疆鐭俊60s鍊掕鏃� + * + * @param phone + * @param type + */ + public void sendSms(String phone, int type) { + if (!Constant.IS_OUTNET) + return; + String key = "sms-" + phone + "-" + type; + setString(key, "1", 10); + } + + public void clearSMSFrequencyLimit(String phone, int type) { + if (!Constant.IS_OUTNET) + return; + String key = "sms-" + phone + "-" + type; + removeKey(key); + } + + /** + * 淇濆瓨楠岃瘉鐮� + * + * @param phone + * @param type + * @param code + */ + + public void saveSMSVCode(String phone, int type, String code) { + if (!Constant.IS_OUTNET) + return; + String key = "smscode-" + phone + "-" + type; + // 淇濆瓨2鍒嗛挓 + setString(key, code, 120); + } + + /** + * + * @param phone + * @param type + * @return + */ + public String getSMSVCode(String phone, int type) { + if (!Constant.IS_OUTNET) + return ""; + String key = "smscode-" + phone + "-" + type; + // 淇濆瓨2鍒嗛挓 + return getString(key); + } + + /** + * 娓呴櫎鎺夐獙璇佺爜 + * + * @param phone + * @param type + * @param code + */ + public void clearSMSVCode(String phone, int type) { + if (!Constant.IS_OUTNET) + return; + String key = "smscode-" + phone + "-" + type; + removeKey(key); + } + +} diff --git a/fanli-service-user/src/main/java/org/fanli/service/user/dao/account/user/UserActiveLogMapper.java b/fanli-service-user/src/main/java/org/fanli/service/user/dao/account/user/UserActiveLogMapper.java new file mode 100644 index 0000000..ec8e4fd --- /dev/null +++ b/fanli-service-user/src/main/java/org/fanli/service/user/dao/account/user/UserActiveLogMapper.java @@ -0,0 +1,20 @@ +package org.fanli.service.user.dao.account.user; + +import org.fanli.facade.user.entity.account.user.UserActiveLog; + +public interface UserActiveLogMapper { + + int deleteByPrimaryKey(Long id); + + int insert(UserActiveLog record); + + int insertSelective(UserActiveLog record); + + UserActiveLog selectByPrimaryKey(Long id); + + UserActiveLog selectLatestByUid(Long uid); + + int updateByPrimaryKeySelective(UserActiveLog record); + + int updateByPrimaryKey(UserActiveLog record); +} \ No newline at end of file diff --git a/fanli-service-user/src/main/java/org/fanli/service/user/dao/account/user/UserCustomSettingsMapper.java b/fanli-service-user/src/main/java/org/fanli/service/user/dao/account/user/UserCustomSettingsMapper.java new file mode 100644 index 0000000..437afb4 --- /dev/null +++ b/fanli-service-user/src/main/java/org/fanli/service/user/dao/account/user/UserCustomSettingsMapper.java @@ -0,0 +1,31 @@ +package org.fanli.service.user.dao.account.user; + + +import java.util.List; + +import org.apache.ibatis.annotations.Param; +import org.fanli.facade.user.entity.account.user.UserCustomSettings; + +import com.yeshi.fanli.base.BaseMapper; + +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); + +} \ No newline at end of file diff --git a/fanli-service-user/src/main/java/org/fanli/service/user/dao/account/user/UserRankMapper.java b/fanli-service-user/src/main/java/org/fanli/service/user/dao/account/user/UserRankMapper.java new file mode 100644 index 0000000..cfa87a6 --- /dev/null +++ b/fanli-service-user/src/main/java/org/fanli/service/user/dao/account/user/UserRankMapper.java @@ -0,0 +1,15 @@ +package org.fanli.service.user.dao.account.user; + + +import java.util.List; + +import org.fanli.facade.user.entity.account.user.UserRank; + +import com.yeshi.fanli.base.BaseMapper; + +public interface UserRankMapper extends BaseMapper<UserRank> { + + List<UserRank> getAllRank(); + + +} \ No newline at end of file diff --git a/fanli-service-user/src/main/java/org/fanli/service/user/dao/account/user/UserRankRecordMapper.java b/fanli-service-user/src/main/java/org/fanli/service/user/dao/account/user/UserRankRecordMapper.java new file mode 100644 index 0000000..d77b32d --- /dev/null +++ b/fanli-service-user/src/main/java/org/fanli/service/user/dao/account/user/UserRankRecordMapper.java @@ -0,0 +1,10 @@ +package org.fanli.service.user.dao.account.user; + + +import org.fanli.facade.user.entity.UserRankRecord; + +import com.yeshi.fanli.base.BaseMapper; + +public interface UserRankRecordMapper extends BaseMapper<UserRankRecord> { + +} \ No newline at end of file diff --git a/fanli-service-user/src/main/java/org/fanli/service/user/dao/account/user/UserRankingsMapper.java b/fanli-service-user/src/main/java/org/fanli/service/user/dao/account/user/UserRankingsMapper.java new file mode 100644 index 0000000..d5258a6 --- /dev/null +++ b/fanli-service-user/src/main/java/org/fanli/service/user/dao/account/user/UserRankingsMapper.java @@ -0,0 +1,62 @@ +package org.fanli.service.user.dao.account.user; + +import java.util.List; + +import org.apache.ibatis.annotations.Param; +import org.fanli.facade.user.entity.account.user.UserRankings; + +public interface UserRankingsMapper { + + int deleteByPrimaryKey(Long id); + + int insert(UserRankings record); + + int insertSelective(UserRankings record); + + UserRankings selectByPrimaryKey(Long id); + + int updateByPrimaryKeySelective(UserRankings record); + + int updateByPrimaryKey(UserRankings record); + + + /** + * 鎵归噺鎻掑叆 + * @param list + * @return + */ + int insertBatch(List<UserRankings> list); + + + /** + * 鎵归噺閫夋嫨鏇存柊 + * @param list + * @return + */ + int updateBatchSelective(List<UserRankings> list); + + + List<UserRankings> queryAll(); + + /** + * 娓呯┖鑷喘姒滅姸鎬佷互鍙婇噾棰� + */ + void updateClearTradeState(); + + // 鏍规嵁鍚嶇О鏌ヨ + List<UserRankings> selectByNickName(String nickName); + + // 鏍规嵁灞曠ずID鏌ヨ + List<UserRankings> selectByShowId(String showId); + + + // 鏌ヨ鍒楄〃 + List<UserRankings> query(@Param("start") long start, @Param("count") int count, @Param("key") String key, + @Param("tradeState") Integer tradeState, @Param("shareState") Integer shareState, @Param("sort") Integer sort); + + // 鏌ヨ鍒楄〃缁熻 + long queryCount(@Param("key") String key, @Param("tradeState") Integer tradeState, @Param("shareState") Integer shareState); + + // 濂栭噾姒� 闅忔満id鏌ヨ + public List<UserRankings> listQueryByIds(List<Long> list); +} \ No newline at end of file diff --git a/fanli-service-user/src/main/java/org/fanli/service/user/mapper/account/user/UserActiveLogMapper.xml b/fanli-service-user/src/main/java/org/fanli/service/user/mapper/account/user/UserActiveLogMapper.xml new file mode 100644 index 0000000..320b8b6 --- /dev/null +++ b/fanli-service-user/src/main/java/org/fanli/service/user/mapper/account/user/UserActiveLogMapper.xml @@ -0,0 +1,103 @@ +<?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="org.fanli.service.user.dao.account.user.UserActiveLogMapper"> + <resultMap id="BaseResultMap" + type="org.fanli.facade.user.entity.account.user.UserActiveLog"> + <id column="lua_id" property="id" jdbcType="BIGINT" /> + <result column="lua_uid" property="uid" jdbcType="BIGINT" /> + <result column="lua_ip" property="ip" jdbcType="VARCHAR" /> + <result column="lua_channel" property="channel" jdbcType="VARCHAR" /> + <result column="lua_version_code" property="versionCode" + jdbcType="VARCHAR" /> + <result column="lua_createtime" property="createTime" jdbcType="TIMESTAMP" /> + <result column="lua_updatetime" property="updateTime" jdbcType="TIMESTAMP" /> + <result column="lua_device_type" property="deviceType" + jdbcType="VARCHAR" /> + <result column="lua_os_version" property="osVersion" jdbcType="VARCHAR" /> + </resultMap> + <sql id="Base_Column_List">lua_id,lua_uid,lua_ip,lua_channel,lua_version_code,lua_createtime,lua_updatetime,lua_device_type,lua_os_version + </sql> + <select id="selectByPrimaryKey" resultMap="BaseResultMap" + parameterType="java.lang.Long"> + select + <include refid="Base_Column_List" /> + from yeshi_ec_log_user_active where lua_id = #{id,jdbcType=BIGINT} + </select> + + <select id="selectLatestByUid" resultMap="BaseResultMap" + parameterType="java.lang.Long"> + select + <include refid="Base_Column_List" /> + from yeshi_ec_log_user_active where lua_uid = #{0} order by lua_id + desc limit 1 + </select> + + <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from + yeshi_ec_log_user_active where lua_id = #{id,jdbcType=BIGINT} + </delete> + <insert id="insert" + parameterType="org.fanli.facade.user.entity.account.user.UserActiveLog" + useGeneratedKeys="true" keyProperty="id">insert into + yeshi_ec_log_user_active + (lua_id,lua_uid,lua_ip,lua_channel,lua_version_code,lua_createtime,lua_updatetime,lua_device_type,lua_os_version) + values + (#{id,jdbcType=BIGINT},#{uid,jdbcType=BIGINT},#{ip,jdbcType=VARCHAR},#{channel,jdbcType=VARCHAR},#{versionCode,jdbcType=VARCHAR},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP},#{deviceType,jdbcType=VARCHAR},#{osVersion,jdbcType=VARCHAR}) + </insert> + <insert id="insertSelective" + parameterType="org.fanli.facade.user.entity.account.user.UserActiveLog" + useGeneratedKeys="true" keyProperty="id"> + insert into yeshi_ec_log_user_active + <trim prefix="(" suffix=")" suffixOverrides=","> + <if test="id != null">lua_id,</if> + <if test="uid != null">lua_uid,</if> + <if test="ip != null">lua_ip,</if> + <if test="channel != null">lua_channel,</if> + <if test="versionCode != null">lua_version_code,</if> + <if test="createTime != null">lua_createtime,</if> + <if test="updateTime != null">lua_updatetime,</if> + <if test="deviceType != null">lua_device_type,</if> + <if test="osVersion != null">lua_os_version,</if> + </trim> + values + <trim prefix="(" suffix=")" suffixOverrides=","> + <if test="id != null">#{id,jdbcType=BIGINT},</if> + <if test="uid != null">#{uid,jdbcType=BIGINT},</if> + <if test="ip != null">#{ip,jdbcType=VARCHAR},</if> + <if test="channel != null">#{channel,jdbcType=VARCHAR},</if> + <if test="versionCode != null">#{versionCode,jdbcType=VARCHAR},</if> + <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if> + <if test="updateTime != null">#{updateTime,jdbcType=TIMESTAMP},</if> + <if test="deviceType != null">#{deviceType,jdbcType=VARCHAR},</if> + <if test="osVersion != null">#{osVersion,jdbcType=VARCHAR}</if> + </trim> + </insert> + <update id="updateByPrimaryKey" + parameterType="org.fanli.facade.user.entity.account.user.UserActiveLog">update + yeshi_ec_log_user_active set lua_uid = + #{uid,jdbcType=BIGINT},lua_ip = + #{ip,jdbcType=VARCHAR},lua_channel = + #{channel,jdbcType=VARCHAR},lua_version_code = + #{versionCode,jdbcType=VARCHAR},lua_createtime = + #{createTime,jdbcType=TIMESTAMP},lua_updatetime = + #{updateTime,jdbcType=TIMESTAMP} ,lua_device_type + =#{deviceType,jdbcType=VARCHAR} ,lua_os_version + =#{osVersion,jdbcType=VARCHAR} where lua_id = #{id,jdbcType=BIGINT} + </update> + <update id="updateByPrimaryKeySelective" + parameterType="org.fanli.facade.user.entity.account.user.UserActiveLog"> + update yeshi_ec_log_user_active + <set> + <if test="uid != null">lua_uid=#{uid,jdbcType=BIGINT},</if> + <if test="ip != null">lua_ip=#{ip,jdbcType=VARCHAR},</if> + <if test="channel != null">lua_channel=#{channel,jdbcType=VARCHAR},</if> + <if test="versionCode != null">lua_version_code=#{versionCode,jdbcType=VARCHAR},</if> + <if test="createTime != null">lua_createtime=#{createTime,jdbcType=TIMESTAMP},</if> + <if test="updateTime != null">lua_updatetime=#{updateTime,jdbcType=TIMESTAMP},</if> + <if test="id !=null">lua_id =#{id,jdbcType=BIGINT},</if> + <if test="deviceType !=null">lua_device_type =#{deviceType,jdbcType=VARCHAR},</if> + <if test="osVersion !=null">lua_os_version =#{osVersion,jdbcType=VARCHAR},</if> + </set> + where lua_id = #{id,jdbcType=BIGINT} + </update> +</mapper> diff --git a/fanli-service-user/src/main/java/org/fanli/service/user/mapper/account/user/UserCustomSettingsMapper.xml b/fanli-service-user/src/main/java/org/fanli/service/user/mapper/account/user/UserCustomSettingsMapper.xml new file mode 100644 index 0000000..838e373 --- /dev/null +++ b/fanli-service-user/src/main/java/org/fanli/service/user/mapper/account/user/UserCustomSettingsMapper.xml @@ -0,0 +1,102 @@ +<?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="org.fanli.service.user.dao.account.user.UserCustomSettingsMapper"> + <resultMap id="BaseResultMap" + type="org.fanli.facade.user.entity.account.user.UserCustomSettings"> + <id column="ucs_id" property="id" jdbcType="BIGINT" /> + <result column="ucs_type" property="type" + typeHandler="org.fanli.facade.user.util.typehandler.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.base.entity.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="org.fanli.facade.user.entity.account.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="org.fanli.facade.user.entity.account.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="org.fanli.facade.user.entity.account.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="org.fanli.facade.user.entity.account.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_uid = #{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> diff --git a/fanli-service-user/src/main/java/org/fanli/service/user/mapper/account/user/UserRankMapper.xml b/fanli-service-user/src/main/java/org/fanli/service/user/mapper/account/user/UserRankMapper.xml new file mode 100644 index 0000000..84322b3 --- /dev/null +++ b/fanli-service-user/src/main/java/org/fanli/service/user/mapper/account/user/UserRankMapper.xml @@ -0,0 +1,94 @@ +<?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="org.fanli.service.user.dao.account.user.UserRankMapper"> + <resultMap id="BaseResultMap" + type="org.fanli.facade.user.entity.account.user.UserRank"> + <id column="ur_id" property="id" jdbcType="BIGINT" /> + <result column="ur_name" property="name" jdbcType="VARCHAR" /> + <result column="ur_picture" property="picture" jdbcType="VARCHAR" /> + <result column="ur_icon" property="icon" jdbcType="VARCHAR" /> + <result column="ur_rebate_num" property="rebateNum" jdbcType="INTEGER" /> + <result column="ur_share_num" property="shareNum" jdbcType="INTEGER" /> + <result column="ur_invite_num" property="inviteNum" jdbcType="INTEGER" /> + <result column="ur_orderby" property="orderby" jdbcType="INTEGER" /> + <result column="ur_create_time" property="createTime" jdbcType="TIMESTAMP" /> + <result column="ur_update_time" property="updateTime" jdbcType="TIMESTAMP" /> + </resultMap> + <sql id="Base_Column_List">ur_id,ur_name,ur_picture,ur_icon,ur_rebate_num,ur_share_num,ur_invite_num,ur_orderby,ur_create_time,ur_update_time + </sql> + <select id="selectByPrimaryKey" resultMap="BaseResultMap" + parameterType="java.lang.Long"> + select + <include refid="Base_Column_List" /> + from yeshi_ec_user_rank where ur_id = #{id,jdbcType=BIGINT} + </select> + <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from + yeshi_ec_user_rank where ur_id = #{id,jdbcType=BIGINT}</delete> + <insert id="insert" parameterType="org.fanli.facade.user.entity.account.user.UserRank" + useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_user_rank + (ur_id,ur_name,ur_picture,ur_icon,ur_rebate_num,ur_share_num,ur_invite_num,ur_orderby,ur_create_time,ur_update_time) + values + (#{id,jdbcType=BIGINT},#{name,jdbcType=VARCHAR},#{picture,jdbcType=VARCHAR},#{icon,jdbcType=VARCHAR},#{rebateNum,jdbcType=INTEGER},#{shareNum,jdbcType=INTEGER},#{inviteNum,jdbcType=INTEGER},#{orderby,jdbcType=INTEGER},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP}) + </insert> + <insert id="insertSelective" parameterType="org.fanli.facade.user.entity.account.user.UserRank" + useGeneratedKeys="true" keyProperty="id"> + insert into yeshi_ec_user_rank + <trim prefix="(" suffix=")" suffixOverrides=","> + <if test="id != null">ur_id,</if> + <if test="name != null">ur_name,</if> + <if test="picture != null">ur_picture,</if> + <if test="icon != null">ur_icon,</if> + <if test="rebateNum != null">ur_rebate_num,</if> + <if test="shareNum != null">ur_share_num,</if> + <if test="inviteNum != null">ur_invite_num,</if> + <if test="orderby != null">ur_orderby,</if> + <if test="createTime != null">ur_create_time,</if> + <if test="updateTime != null">ur_update_time,</if> + </trim> + values + <trim prefix="(" suffix=")" suffixOverrides=","> + <if test="id != null">#{id,jdbcType=BIGINT},</if> + <if test="name != null">#{name,jdbcType=VARCHAR},</if> + <if test="picture != null">#{picture,jdbcType=VARCHAR},</if> + <if test="icon != null">#{icon,jdbcType=VARCHAR},</if> + <if test="rebateNum != null">#{rebateNum,jdbcType=INTEGER},</if> + <if test="shareNum != null">#{shareNum,jdbcType=INTEGER},</if> + <if test="inviteNum != null">#{inviteNum,jdbcType=INTEGER},</if> + <if test="orderby != null">#{orderby,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="org.fanli.facade.user.entity.account.user.UserRank">update + yeshi_ec_user_rank set ur_name = #{name,jdbcType=VARCHAR},ur_picture = + #{picture,jdbcType=VARCHAR},ur_icon = + #{icon,jdbcType=VARCHAR},ur_rebate_num = + #{rebateNum,jdbcType=INTEGER},ur_share_num = + #{shareNum,jdbcType=INTEGER},ur_invite_num = + #{inviteNum,jdbcType=INTEGER},ur_orderby = + #{orderby,jdbcType=INTEGER},ur_create_time = + #{createTime,jdbcType=TIMESTAMP},ur_update_time = + #{updateTime,jdbcType=TIMESTAMP} where ur_id = #{id,jdbcType=BIGINT} + </update> + <update id="updateByPrimaryKeySelective" parameterType="org.fanli.facade.user.entity.account.user.UserRank"> + update yeshi_ec_user_rank + <set> + <if test="name != null">ur_name=#{name,jdbcType=VARCHAR},</if> + <if test="picture != null">ur_picture=#{picture,jdbcType=VARCHAR},</if> + <if test="icon != null">ur_icon=#{icon,jdbcType=VARCHAR},</if> + <if test="rebateNum != null">ur_rebate_num=#{rebateNum,jdbcType=INTEGER},</if> + <if test="shareNum != null">ur_share_num=#{shareNum,jdbcType=INTEGER},</if> + <if test="inviteNum != null">ur_invite_num=#{inviteNum,jdbcType=INTEGER},</if> + <if test="orderby != null">ur_orderby=#{orderby,jdbcType=INTEGER},</if> + <if test="createTime != null">ur_create_time=#{createTime,jdbcType=TIMESTAMP},</if> + <if test="updateTime != null">ur_update_time=#{updateTime,jdbcType=TIMESTAMP},</if> + </set> + where ur_id = #{id,jdbcType=BIGINT} + </update> + <select id="getAllRank" resultMap="BaseResultMap"> + select + <include refid="Base_Column_List" /> + from yeshi_ec_user_rank ORDER BY ur_orderby + </select> +</mapper> diff --git a/fanli-service-user/src/main/java/org/fanli/service/user/mapper/account/user/UserRankRecordMapper.xml b/fanli-service-user/src/main/java/org/fanli/service/user/mapper/account/user/UserRankRecordMapper.xml new file mode 100644 index 0000000..6a0b985 --- /dev/null +++ b/fanli-service-user/src/main/java/org/fanli/service/user/mapper/account/user/UserRankRecordMapper.xml @@ -0,0 +1,60 @@ +<?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="org.fanli.service.user.dao.account.user.UserRankRecordMapper"> + <resultMap id="BaseResultMap" type="org.fanli.facade.user.entity.UserRankRecord"> + <id column="urd_id" property="id" jdbcType="BIGINT" /> + <result column="urd_uid" property="uid" jdbcType="BIGINT" /> + <result column="urd_rank_id" property="rankId" jdbcType="BIGINT" /> + <result column="urd_create_time" property="createTime" + jdbcType="TIMESTAMP" /> + </resultMap> + <sql id="Base_Column_List">urd_id,urd_uid,urd_rank_id,urd_create_time</sql> + <select id="selectByPrimaryKey" resultMap="BaseResultMap" + parameterType="java.lang.Long"> + select + <include refid="Base_Column_List" /> + from yeshi_ec_user_rank_record where urd_id = #{id,jdbcType=BIGINT} + </select> + <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from + yeshi_ec_user_rank_record where urd_id = #{id,jdbcType=BIGINT} + </delete> + <insert id="insert" parameterType="com.yeshi.fanli.entity.bus.user.UserRankRecord" + useGeneratedKeys="true" keyProperty="id">insert into + yeshi_ec_user_rank_record (urd_id,urd_uid,urd_rank_id,urd_create_time) + values + (#{id,jdbcType=BIGINT},#{uid,jdbcType=BIGINT},#{rankId,jdbcType=BIGINT},#{createTime,jdbcType=TIMESTAMP}) + </insert> + <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.bus.user.UserRankRecord" + useGeneratedKeys="true" keyProperty="id"> + insert into yeshi_ec_user_rank_record + <trim prefix="(" suffix=")" suffixOverrides=","> + <if test="id != null">urd_id,</if> + <if test="uid != null">urd_uid,</if> + <if test="rankId != null">urd_rank_id,</if> + <if test="createTime != null">urd_create_time,</if> + </trim> + values + <trim prefix="(" suffix=")" suffixOverrides=","> + <if test="id != null">#{id,jdbcType=BIGINT},</if> + <if test="uid != null">#{uid,jdbcType=BIGINT},</if> + <if test="rankId != null">#{rankId,jdbcType=BIGINT},</if> + <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if> + </trim> + </insert> + <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.bus.user.UserRankRecord">update + yeshi_ec_user_rank_record set urd_uid = + #{uid,jdbcType=BIGINT},urd_rank_id = + #{rankId,jdbcType=BIGINT},urd_create_time = + #{createTime,jdbcType=TIMESTAMP} where urd_id = #{id,jdbcType=BIGINT} + </update> + <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.bus.user.UserRankRecord"> + update yeshi_ec_user_rank_record + <set> + <if test="uid != null">urd_uid=#{uid,jdbcType=BIGINT},</if> + <if test="rankId != null">urd_rank_id=#{rankId,jdbcType=BIGINT},</if> + <if test="createTime != null">urd_create_time=#{createTime,jdbcType=TIMESTAMP},</if> + </set> + where urd_id = #{id,jdbcType=BIGINT} + </update> +</mapper> diff --git a/fanli-service-user/src/main/java/org/fanli/service/user/mapper/account/user/UserRankingsMapper.xml b/fanli-service-user/src/main/java/org/fanli/service/user/mapper/account/user/UserRankingsMapper.xml new file mode 100644 index 0000000..6375c13 --- /dev/null +++ b/fanli-service-user/src/main/java/org/fanli/service/user/mapper/account/user/UserRankingsMapper.xml @@ -0,0 +1,330 @@ +<?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="org.fanli.service.user.dao.account.user.UserRankingsMapper"> + <resultMap id="BaseResultMap" type="org.fanli.facade.user.entity.account.user.UserRankings"> + <id column="r_id" property="id" jdbcType="BIGINT" /> + <result column="r_show_id" property="showId" jdbcType="VARCHAR" /> + <result column="r_nick_name" property="nickName" jdbcType="VARCHAR" /> + <result column="r_portrait" property="portrait" jdbcType="VARCHAR" /> + <result column="r_trade_reward" property="tradeReward" + jdbcType="DECIMAL" /> + <result column="r_share_reward" property="shareReward" + jdbcType="DECIMAL" /> + <result column="r_trade_state" property="tradeState" jdbcType="INTEGER" /> + <result column="r_share_state" property="shareState" jdbcType="INTEGER" /> + <result column="r_trade_time" property="tradeTime" jdbcType="TIMESTAMP" /> + <result column="r_share_time" property="shareTime" jdbcType="TIMESTAMP" /> + <result column="r_createtime" property="createtime" jdbcType="TIMESTAMP" /> + </resultMap> + <sql id="Base_Column_List">r_id,r_show_id,r_nick_name,r_portrait,r_trade_reward,r_share_reward,r_trade_state,r_share_state,r_trade_time,r_share_time,r_createtime + </sql> + <select id="selectByPrimaryKey" resultMap="BaseResultMap" + parameterType="java.lang.Long"> + select + <include refid="Base_Column_List" /> + from yeshi_ec_rankings_record where r_id = #{id,jdbcType=BIGINT} + </select> + <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from + yeshi_ec_rankings_record where r_id = #{id,jdbcType=BIGINT}</delete> + <insert id="insert" parameterType="com.yeshi.fanli.entity.bus.user.UserRankings" + useGeneratedKeys="true" keyProperty="id">insert into + yeshi_ec_rankings_record + (r_id,r_show_id,r_nick_name,r_portrait,r_trade_reward,r_share_reward,r_trade_state,r_share_state,r_trade_time,r_share_time,r_createtime) + values + (#{id,jdbcType=BIGINT},#{showId,jdbcType=VARCHAR},#{nickName,jdbcType=VARCHAR},#{portrait,jdbcType=VARCHAR},#{tradeReward,jdbcType=DECIMAL},#{shareReward,jdbcType=DECIMAL},#{tradeState,jdbcType=INTEGER},#{shareState,jdbcType=INTEGER},#{tradeTime,jdbcType=TIMESTAMP},#{shareTime,jdbcType=TIMESTAMP},#{createtime,jdbcType=TIMESTAMP}) + </insert> + <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.bus.user.UserRankings" + useGeneratedKeys="true" keyProperty="id"> + insert into yeshi_ec_rankings_record + <trim prefix="(" suffix=")" suffixOverrides=","> + <if test="id != null">r_id,</if> + <if test="showId != null">r_show_id,</if> + <if test="nickName != null">r_nick_name,</if> + <if test="portrait != null">r_portrait,</if> + <if test="tradeReward != null">r_trade_reward,</if> + <if test="shareReward != null">r_share_reward,</if> + <if test="tradeState != null">r_trade_state,</if> + <if test="shareState != null">r_share_state,</if> + <if test="tradeTime != null">r_trade_time,</if> + <if test="shareTime != null">r_share_time,</if> + <if test="createtime != null">r_createtime,</if> + </trim> + values + <trim prefix="(" suffix=")" suffixOverrides=","> + <if test="id != null">#{id,jdbcType=BIGINT},</if> + <if test="showId != null">#{showId,jdbcType=VARCHAR},</if> + <if test="nickName != null">#{nickName,jdbcType=VARCHAR},</if> + <if test="portrait != null">#{portrait,jdbcType=VARCHAR},</if> + <if test="tradeReward != null">#{tradeReward,jdbcType=DECIMAL},</if> + <if test="shareReward != null">#{shareReward,jdbcType=DECIMAL},</if> + <if test="tradeState != null">#{tradeState,jdbcType=INTEGER},</if> + <if test="shareState != null">#{shareState,jdbcType=INTEGER},</if> + <if test="tradeTime != null">#{tradeTime,jdbcType=TIMESTAMP},</if> + <if test="shareTime != null">#{shareTime,jdbcType=TIMESTAMP},</if> + <if test="createtime != null">#{createtime,jdbcType=TIMESTAMP},</if> + </trim> + </insert> + <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.bus.user.UserRankings">update + yeshi_ec_rankings_record set r_show_id = + #{showId,jdbcType=VARCHAR},r_nick_name = + #{nickName,jdbcType=VARCHAR},r_portrait = + #{portrait,jdbcType=VARCHAR},r_trade_reward = + #{tradeReward,jdbcType=DECIMAL},r_share_reward = + #{shareReward,jdbcType=DECIMAL},r_trade_state = + #{tradeState,jdbcType=INTEGER},r_share_state = + #{shareState,jdbcType=INTEGER},r_trade_time = + #{tradeTime,jdbcType=TIMESTAMP},r_share_time = + #{shareTime,jdbcType=TIMESTAMP},r_createtime = + #{createtime,jdbcType=TIMESTAMP} where r_id = #{id,jdbcType=BIGINT} + </update> + <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.bus.user.UserRankings"> + update yeshi_ec_rankings_record + <set> + <if test="showId != null">r_show_id=#{showId,jdbcType=VARCHAR},</if> + <if test="nickName != null">r_nick_name=#{nickName,jdbcType=VARCHAR},</if> + <if test="portrait != null">r_portrait=#{portrait,jdbcType=VARCHAR},</if> + <if test="tradeReward != null">r_trade_reward=#{tradeReward,jdbcType=DECIMAL},</if> + <if test="shareReward != null">r_share_reward=#{shareReward,jdbcType=DECIMAL},</if> + <if test="tradeState != null">r_trade_state=#{tradeState,jdbcType=INTEGER},</if> + <if test="shareState != null">r_share_state=#{shareState,jdbcType=INTEGER},</if> + <if test="tradeTime != null">r_trade_time=#{tradeTime,jdbcType=TIMESTAMP},</if> + <if test="shareTime != null">r_share_time=#{shareTime,jdbcType=TIMESTAMP},</if> + <if test="createtime != null">r_createtime=#{createtime,jdbcType=TIMESTAMP},</if> + </set> + where r_id = #{id,jdbcType=BIGINT} + </update> + + <select id="selectByNickName" resultMap="BaseResultMap"> + select + <include refid="Base_Column_List" /> + from yeshi_ec_rankings_record where r_nick_name = + #{nickName,jdbcType=VARCHAR} + </select> + + <select id="selectByShowId" resultMap="BaseResultMap"> + select + <include refid="Base_Column_List" /> + from yeshi_ec_rankings_record where r_show_id = + #{showId,jdbcType=VARCHAR} + </select> + + <update id="updateClearTradeState"> + update yeshi_ec_rankings_record + <set> + r_trade_reward = 0, + r_trade_state = 0 + </set> + WHERE r_trade_state = 1 + </update> + + <select id="query" resultMap="BaseResultMap"> + <!-- 鏍规嵁鏉′欢鏌ヨ鎵�鏈夋爣绛� --> + SELECT + <include refid="Base_Column_List" /> + FROM yeshi_ec_rankings_record + WHERE <![CDATA[1>0]]> + <if test='key != null and key != ""'> + AND (r_show_id like '%#{key}%' OR r_nick_name like '%#{key}%') + </if> + + <if test='tradeState != null and tradeState == 1'> + AND r_trade_state = #{tradeState} + </if> + + <if test='shareState != null and shareState == 1'> + AND r_share_state = #{shareState} + </if> + + <if test='tradeState != null and tradeState == 0'> + AND (r_trade_state = #{tradeState} or r_trade_state is null) + </if> + + <if test='shareState != null and shareState == 0'> + AND (r_share_state = #{shareState} or r_share_state is null) + </if> + + ORDER BY + + <if test='sort==1'> + r_trade_reward, + </if> + <if test='sort==2'> + r_trade_reward desc, + </if> + <if test='sort==3'> + r_share_reward, + </if> + <if test='sort==4'> + r_share_reward desc, + </if> + <if test='sort==5'> + r_trade_time, + </if> + <if test='sort==6'> + r_trade_time desc, + </if> + <if test='sort==7'> + r_share_time, + </if> + <if test='sort==8'> + r_share_time desc, + </if> + r_createtime LIMIT ${start},${count} + </select> + + <select id="queryCount" resultType="java.lang.Long"> + <!-- 鏍规嵁鏉′欢鏌ヨ鎵�鏈夋爣绛� --> + SELECT count(r_id) FROM yeshi_ec_rankings_record + WHERE <![CDATA[1>0]]> + <if test='key != null and key != ""'> + AND (r_show_id like '%#{key}%' OR r_nick_name like '%#{key}%') + </if> + <if test='tradeState != null and tradeState == 1'> + AND r_trade_state = #{tradeState} + </if> + + <if test='shareState != null and shareState == 1'> + AND r_share_state = #{shareState} + </if> + + <if test='tradeState != null and tradeState == 0'> + AND (r_trade_state = #{tradeState} or r_trade_state is null) + </if> + + <if test='shareState != null and shareState == 0'> + AND (r_share_state = #{shareState} or r_share_state is null) + </if> + </select> + + <insert id="insertBatch" useGeneratedKeys="true" keyProperty="id" + parameterType="java.util.List"> + insert into yeshi_ec_rankings_record + ( + <include refid="Base_Column_List" /> + ) + values + + <foreach collection="list" item="item" separator=","> + ( + #{item.id,jdbcType=BIGINT}, + #{item.showId,jdbcType=VARCHAR}, + #{item.nickName,jdbcType=VARCHAR}, + #{item.portrait,jdbcType=VARCHAR}, + #{item.tradeReward,jdbcType=DECIMAL}, + #{item.shareReward,jdbcType=DECIMAL}, + #{item.tradeState,jdbcType=INTEGER}, + #{item.shareState,jdbcType=INTEGER}, + #{item.tradeTime,jdbcType=TIMESTAMP}, + #{item.shareTime,jdbcType=TIMESTAMP}, + #{item.createtime,jdbcType=TIMESTAMP} + ) + + </foreach> + </insert> + + <update id="updateBatchSelective" parameterType="java.util.List"> + + update yeshi_ec_rankings_record + <trim prefix="set" suffixOverrides=","> + <trim prefix="r_show_id =case" suffix="end,"> + <foreach collection="list" item="item" index="index"> + <if test="item.showId !=null"> + when r_id=#{item.id} then #{item.showId} + </if> + </foreach> + </trim> + + <trim prefix="r_nick_name =case" suffix="end,"> + <foreach collection="list" item="item" index="index"> + <if test="item.nickName !=null"> + when r_id=#{item.id} then #{item.nickName} + </if> + </foreach> + </trim> + + <trim prefix="r_portrait =case" suffix="end,"> + <foreach collection="list" item="item" index="index"> + <if test="item.portrait !=null"> + when r_id=#{item.id} then #{item.portrait} + </if> + </foreach> + </trim> + + <trim prefix="r_trade_reward =case" suffix="end,"> + <foreach collection="list" item="item" index="index"> + <if test="item.tradeReward !=null"> + when r_id=#{item.id} then #{item.tradeReward} + </if> + </foreach> + </trim> + + <trim prefix="r_share_reward =case" suffix="end,"> + <foreach collection="list" item="item" index="index"> + <if test="item.shareReward !=null"> + when r_id=#{item.id} then #{item.shareReward} + </if> + </foreach> + </trim> + + + <trim prefix="r_trade_state =case" suffix="end,"> + <foreach collection="list" item="item" index="index"> + <if test="item.tradeState !=null"> + when r_id=#{item.id} then #{item.tradeState} + </if> + </foreach> + </trim> + + <trim prefix="r_share_state =case" suffix="end,"> + <foreach collection="list" item="item" index="index"> + <if test="item.shareState !=null"> + when r_id=#{item.id} then #{item.shareState} + </if> + </foreach> + </trim> + <trim prefix="r_trade_time =case" suffix="end,"> + <foreach collection="list" item="item" index="index"> + <if test="item.tradeTime !=null"> + when r_id=#{item.id} then #{item.tradeTime} + </if> + </foreach> + </trim> + <trim prefix="r_share_time =case" suffix="end,"> + <foreach collection="list" item="item" index="index"> + <if test="item.shareTime !=null"> + when r_id=#{item.id} then #{item.shareTime} + </if> + </foreach> + </trim> + + </trim> + where r_id in + <foreach collection="list" index="index" item="item" + separator="," open="(" close=")"> + #{item.id,jdbcType=BIGINT} + </foreach> + </update> + + + <select id="queryAll" resultMap="BaseResultMap"> + <!-- 鏍规嵁鏉′欢鏌ヨ鎵�鏈夋爣绛� --> + SELECT + <include refid="Base_Column_List" /> + FROM yeshi_ec_rankings_record + </select> + + <select id="listQueryByIds" resultMap="BaseResultMap" + parameterType="java.util.List"> + SELECT + <include refid="Base_Column_List" /> + FROM yeshi_ec_rankings_record + where r_id in + <foreach collection="list" index="index" item="item" + separator="," open="(" close=")"> + #{item,jdbcType=BIGINT} + </foreach> + </select> + + +</mapper> diff --git a/fanli-service-user/src/main/java/org/fanli/service/user/service/impl/account/UserAccountServiceImpl.java b/fanli-service-user/src/main/java/org/fanli/service/user/service/impl/account/UserAccountServiceImpl.java index e362956..1b5d2c0 100644 --- a/fanli-service-user/src/main/java/org/fanli/service/user/service/impl/account/UserAccountServiceImpl.java +++ b/fanli-service-user/src/main/java/org/fanli/service/user/service/impl/account/UserAccountServiceImpl.java @@ -93,7 +93,7 @@ @Resource private UserExtraTaoBaoInfoService userExtraTaoBaoInfoService; - + @Resource private ForbiddenUserIdentifyCodeService forbiddenUserIdentifyCodeService; diff --git a/fanli-service-user/src/main/java/org/fanli/service/user/service/impl/account/user/UserActiveLogServiceImpl.java b/fanli-service-user/src/main/java/org/fanli/service/user/service/impl/account/user/UserActiveLogServiceImpl.java new file mode 100644 index 0000000..a27e683 --- /dev/null +++ b/fanli-service-user/src/main/java/org/fanli/service/user/service/impl/account/user/UserActiveLogServiceImpl.java @@ -0,0 +1,42 @@ +package org.fanli.service.user.service.impl.account.user; + +import java.util.Date; + +import javax.annotation.Resource; + +import org.fanli.facade.user.entity.account.user.UserActiveLog; +import org.fanli.facade.user.service.account.user.UserActiveLogService; +import org.fanli.service.user.dao.account.user.UserActiveLogMapper; +import org.springframework.stereotype.Service; + +@Service +public class UserActiveLogServiceImpl implements UserActiveLogService { + + @Resource + private UserActiveLogMapper userActiveLogMapper; + + @Override + public void addUserActiveLog(UserActiveLog userActiveLog) { + if (userActiveLog == null) + return; + if (userActiveLog.getUid() == null || userActiveLog.getUid() == 0) + return; + UserActiveLog latestLog = getUserLatestActiveInfo(userActiveLog.getUid()); + // 闂撮殧5鍒嗛挓浠ヤ笂鍐嶈褰� + if (latestLog == null || System.currentTimeMillis() - latestLog.getCreateTime().getTime() > 1000 * 60 * 5L) { + userActiveLog.setCreateTime(new Date()); + userActiveLog.setUpdateTime(new Date()); + userActiveLogMapper.insertSelective(userActiveLog); + } + } + + @Override + public UserActiveLog getUserLatestActiveInfo(Long uid) { + return userActiveLogMapper.selectLatestByUid(uid); + } + + + + + +} diff --git a/fanli-service-user/src/main/java/org/fanli/service/user/service/impl/account/user/UserCustomSettingsServiceImpl.java b/fanli-service-user/src/main/java/org/fanli/service/user/service/impl/account/user/UserCustomSettingsServiceImpl.java new file mode 100644 index 0000000..e1203c1 --- /dev/null +++ b/fanli-service-user/src/main/java/org/fanli/service/user/service/impl/account/user/UserCustomSettingsServiceImpl.java @@ -0,0 +1,144 @@ +package org.fanli.service.user.service.impl.account.user; + +import java.util.Date; +import java.util.List; + +import javax.annotation.Resource; + +import org.fanli.facade.user.entity.account.user.UserCustomSettings; +import org.fanli.facade.user.entity.account.user.UserCustomSettings.UserSettingTypeEnum; +import org.fanli.facade.user.exception.account.UserCustomSettingsException; +import org.fanli.facade.user.service.account.user.UserCustomSettingsService; +import org.fanli.facade.user.vo.UserSettingsVO; +import org.fanli.service.user.dao.account.user.UserCustomSettingsMapper; +import org.springframework.stereotype.Service; + +import com.yeshi.fanli.base.entity.user.UserInfo; + +@Service +public class UserCustomSettingsServiceImpl implements UserCustomSettingsService { + + @Resource + private UserCustomSettingsMapper userCustomSettingsMapper; + + @Override + public void saveModuleState(Long uid, String type, Integer state) throws UserCustomSettingsException{ + if (uid == null || type == null || state == null || state > 1 || state < 0) { + throw new UserCustomSettingsException(1, "浼犻�掑弬鏁颁笉姝g‘"); + } + + + UserSettingTypeEnum mineTypeNum = null; + if (type.equals(UserSettingTypeEnum.cancelNotice.name())) { + mineTypeNum = UserSettingTypeEnum.cancelNotice; + } else if (type.equals(UserSettingTypeEnum.noNewsRedDot.name())) { + mineTypeNum = UserSettingTypeEnum.noNewsRedDot; + } else if (type.equals(UserSettingTypeEnum.noBonusCount.name())) { + mineTypeNum = UserSettingTypeEnum.noBonusCount; + } else if (type.equals(UserSettingTypeEnum.noShareRecordAndStorage.name())) { + mineTypeNum = UserSettingTypeEnum.noShareRecordAndStorage; + } else if (type.equals(UserSettingTypeEnum.noInvitationBonus.name())) { + mineTypeNum = UserSettingTypeEnum.noInvitationBonus; + } else { + throw new UserCustomSettingsException(1, "鍙傛暟绫诲瀷涓嶅尮閰�"); + } + + + UserCustomSettings settings = userCustomSettingsMapper.getSettingsByUidAndType(uid, type); + if (settings != null) { + // 鏇存柊 + UserCustomSettings record = new UserCustomSettings(); + record.setId(settings.getId()); + record.setState(state); + record.setUpdateTime(new Date()); + userCustomSettingsMapper.updateByPrimaryKeySelective(record); + } else { + // 鎻掑叆 + 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); + } + + } + + @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; + } +} diff --git a/fanli-service-user/src/main/java/org/fanli/service/user/service/impl/account/user/UserRankServiceImpl.java b/fanli-service-user/src/main/java/org/fanli/service/user/service/impl/account/user/UserRankServiceImpl.java new file mode 100644 index 0000000..c2fb486 --- /dev/null +++ b/fanli-service-user/src/main/java/org/fanli/service/user/service/impl/account/user/UserRankServiceImpl.java @@ -0,0 +1,22 @@ +package org.fanli.service.user.service.impl.account.user; + +import java.util.List; + +import javax.annotation.Resource; + +import org.fanli.facade.user.entity.account.user.UserRank; +import org.fanli.facade.user.service.account.user.UserRankService; +import org.fanli.service.user.dao.account.user.UserRankMapper; +import org.springframework.stereotype.Service; + +@Service +public class UserRankServiceImpl implements UserRankService { + + @Resource + private UserRankMapper userRankMapper; + + @Override + public List<UserRank> getAllRank(){ + return userRankMapper.getAllRank(); + } +} diff --git a/fanli-service-user/src/main/java/org/fanli/service/user/service/impl/account/user/UserRankingsServiceImpl.java b/fanli-service-user/src/main/java/org/fanli/service/user/service/impl/account/user/UserRankingsServiceImpl.java new file mode 100644 index 0000000..05720d1 --- /dev/null +++ b/fanli-service-user/src/main/java/org/fanli/service/user/service/impl/account/user/UserRankingsServiceImpl.java @@ -0,0 +1,475 @@ +package org.fanli.service.user.service.impl.account.user; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileReader; +import java.io.InputStream; +import java.math.BigDecimal; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Collections; +import java.util.Comparator; +import java.util.Date; +import java.util.List; +import java.util.UUID; + +import javax.annotation.Resource; +import javax.transaction.Transactional; + +import org.fanli.facade.user.dto.HongBao; +import org.fanli.facade.user.entity.account.user.UserRankings; +import org.fanli.facade.user.entity.invite.InviteGetMoney; +import org.fanli.facade.user.exception.UserRankingsException; +import org.fanli.facade.user.service.account.user.UserRankingsService; +import org.fanli.service.user.dao.account.user.UserRankingsMapper; +import org.springframework.stereotype.Service; +import org.springframework.web.multipart.MultipartFile; +import org.yeshi.utils.StringUtil; +import org.yeshi.utils.tencentcloud.COSManager; + +import com.yeshi.fanli.base.entity.user.UserInfo; + +@Service +public class UserRankingsServiceImpl implements UserRankingsService { + + @Resource + private UserRankingsMapper userRankingsMapper; + @Resource + private HongBaoService hongBaoService; + + @Override + public int insertSelective(UserRankings record) throws UserRankingsException { + // TODO Auto-generated method stub + return userRankingsMapper.insertSelective(record); + } + + @Override + public int updateByPrimaryKey(UserRankings record) throws UserRankingsException { + return userRankingsMapper.updateByPrimaryKey(record); + } + + @Override + public int updateByPrimaryKeySelective(UserRankings record) throws UserRankingsException { + return userRankingsMapper.updateByPrimaryKeySelective(record); + } + + @Override + public int updateBatchSelective(List<UserRankings> list) throws UserRankingsException { + return userRankingsMapper.updateBatchSelective(list); + } + + @Override + @Transactional + public int deleteBatchById(Long id) throws UserRankingsException { + return userRankingsMapper.deleteByPrimaryKey(id); + } + + + @Override + public void updateClearTradeState() throws UserRankingsException { + userRankingsMapper.updateClearTradeState(); + } + + + @Override + @Transactional + public int deleteBatchByPrimaryKey(List<Long> arrayID) throws UserRankingsException { + for (Long id : arrayID) { + + UserRankings userRankings = userRankingsMapper.selectByPrimaryKey(id); + String portrait = userRankings.getPortrait(); + if (!StringUtil.isNullOrEmpty(portrait)) { + COSManager.getInstance().deleteFile(portrait); + } + userRankingsMapper.deleteByPrimaryKey(id); + } + + return arrayID.size(); + } + + @Override + public UserRankings selectByPrimaryKey(Long id) throws UserRankingsException { + // TODO Auto-generated method stub + return userRankingsMapper.selectByPrimaryKey(id); + } + + @Override + public List<UserRankings> selectByNickName(String nickName) throws UserRankingsException { + // TODO Auto-generated method stub + return userRankingsMapper.selectByNickName(nickName); + } + + @Override + public List<UserRankings> selectByShowId(String id) throws UserRankingsException { + // TODO Auto-generated method stub + return userRankingsMapper.selectByShowId(id); + } + + @Override + public void insertAndUploadFile(UserRankings record, MultipartFile file) throws Exception { + // TODO Auto-generated method stub + record.setCreatetime(new Date()); + userRankingsMapper.insertSelective(record); + + // 涓婁紶鍥剧墖 + if (file != null) { + uploadPicture(file, record); + } + + } + + @Override + public void uploadPicture(MultipartFile file, UserRankings userRankings) throws Exception { + + /* 淇敼鍥剧墖鏃讹紝鍏堝垹闄ゅ凡瀛樺湪鍥剧墖 */ + String portrait = userRankings.getPortrait(); + if (!StringUtil.isNullOrEmpty(portrait)) { + COSManager.getInstance().deleteFile(portrait); + } + + String contentType = file.getContentType(); + String type = contentType.substring(contentType.indexOf("/") + 1); + + // 涓婁紶鏂囦欢鐩稿浣嶇疆 + String fileUrl = "userRankings/" + UUID.randomUUID().toString().replace("-", "") + "." + type; + + InputStream inputStream = file.getInputStream(); + String uploadFilePath = COSManager.getInstance().uploadFile(inputStream, fileUrl).getUrl(); + + /* 鏇存柊鏁版嵁搴撲俊鎭� */ + if (!StringUtil.isNullOrEmpty(uploadFilePath)) { + userRankings.setPortrait(uploadFilePath); + userRankingsMapper.updateByPrimaryKeySelective(userRankings); + } + } + + @Override + public void removePicture(UserRankings userRankings) throws Exception { + + /* 淇敼鍥剧墖鏃讹紝鍏堝垹闄ゅ凡瀛樺湪鍥剧墖 */ + String portrait = userRankings.getPortrait(); + if (!StringUtil.isNullOrEmpty(portrait)) { + boolean deleteFile = COSManager.getInstance().deleteFile(portrait); + if (deleteFile) { + userRankings.setPortrait(null); + userRankingsMapper.updateByPrimaryKey(userRankings); + } + } + + } + + @Override + public List<UserRankings> query(long start, int count, String key, Integer tradeState, Integer shareState, Integer sort) + throws UserRankingsException { + return userRankingsMapper.query(start, count, key, tradeState, shareState, sort); + } + + @Override + public long queryCount(String key, Integer tradeState, Integer shareState) throws UserRankingsException { + return userRankingsMapper.queryCount(key, tradeState, shareState); + } + + @Override + @Transactional + public void setRewardtBatch(List<Long> idList, Integer type, Double reward, Double startReward, Double endReward) throws Exception { + + for (Long id : idList) { + + UserRankings userRankings = userRankingsMapper.selectByPrimaryKey(id); + + if (userRankings == null) { + continue; + } + + Double result = 0.00; + + if (reward != null && reward >= 0) { + result = reward; + } else { + if (startReward != null && endReward != null) { + // 闅忔満鏉冮噸 + result = startReward + (Math.random() * ((endReward - startReward) + 1)); + } else { + break; + } + } + + if (type == 1 || type.equals(1)) { + userRankings.setTradeReward(new BigDecimal(result)); + } else { + userRankings.setShareReward(new BigDecimal(result)); + } + + userRankingsMapper.updateByPrimaryKeySelective(userRankings); + + } + + } + + @Override + @Transactional + public void setStateBatch(List<Long> idList, Integer type, Integer state) throws Exception { + + for (Long id : idList) { + + UserRankings userRankings = userRankingsMapper.selectByPrimaryKey(id); + + if (userRankings == null) { + continue; + } + + if (type == 1 || type.equals(1)) { + userRankings.setTradeState(state); + + if (state != null && state.equals(1)) { + userRankings.setTradeTime(new Date()); + } + } else { + userRankings.setShareState(state); + + if (state != null && state.equals(1)) { + userRankings.setShareTime(new Date()); + } + } + + userRankingsMapper.updateByPrimaryKey(userRankings); + + } + + } + + @Override + @Transactional + public void uploadFile(File file) throws Exception { + + List<UserRankings> list = new ArrayList<UserRankings>(); + + File[] files = file.listFiles(); + + for (File filePic : files) {// 閬嶅巻杩欎釜鏁扮粍 + String name = filePic.getName(); + System.out.println("name" + name); + String prefix = name.substring(name.lastIndexOf(".") + 1); + // 涓婁紶鏂囦欢鐩稿浣嶇疆 + String fileUrl = "userRankings/" + UUID.randomUUID().toString().replace("-", "") + "." + prefix; + System.out.println(fileUrl); + + FileInputStream is = new FileInputStream(filePic); + + String uploadFilePath = COSManager.getInstance().uploadFile(is, fileUrl).getUrl(); + + /* 鏇存柊鏁版嵁搴撲俊鎭� */ + if (!StringUtil.isNullOrEmpty(uploadFilePath)) { + UserRankings userRankings = new UserRankings(); + userRankings.setPortrait(uploadFilePath); + userRankings.setCreatetime(new Date()); + list.add(userRankings); + } + + is.close(); + } + + if (list.size() > 0) { + userRankingsMapper.insertBatch(list); + } + } + + @Override + @Transactional + public void updateShowID(File file) throws Exception { + List<String> listID = new ArrayList<String>(); + + BufferedReader br = new BufferedReader(new FileReader(file));// 鏋勯�犱竴涓狟ufferedReader绫绘潵璇诲彇鏂囦欢 + String s = ""; + while ((s = br.readLine()) != null) {// 浣跨敤readLine鏂规硶锛屼竴娆¤涓�琛� + listID.add(s); + } + br.close(); + + int i = 0; + List<UserRankings> list = userRankingsMapper.queryAll(); + for (UserRankings userRankings : list) { + + String showId = listID.get(i); + i++; + + userRankings.setShowId(showId); + } + + userRankingsMapper.updateBatchSelective(list); + + } + + @Override + @Transactional + public void batchUpNickName(File file) throws Exception { + List<String> listID = new ArrayList<String>(); + + BufferedReader br = new BufferedReader(new FileReader(file));// 鏋勯�犱竴涓狟ufferedReader绫绘潵璇诲彇鏂囦欢 + String s = ""; + while ((s = br.readLine()) != null) {// 浣跨敤readLine鏂规硶锛屼竴娆¤涓�琛� + listID.add(s); + } + br.close(); + + int i = 0; + List<UserRankings> list = userRankingsMapper.queryAll(); + for (UserRankings userRankings : list) { + + String nickName = listID.get(i); + i++; + + userRankings.setNickName(nickName); + } + + userRankingsMapper.updateBatchSelective(list); + + } + + @Override + public List<UserRankings> listQueryByIds(List<Long> ids) throws UserRankingsException { + return userRankingsMapper.listQueryByIds(ids); + } + + @Override + public List<InviteGetMoney> getRank(long start, int count) { + + List<InviteGetMoney> resultList = new ArrayList<InviteGetMoney>(); + + List<InviteGetMoney> rankingsList = new ArrayList<InviteGetMoney>(); + + try { + + List<UserRankings> userRankingsList = query(0, count, null, 1, null, 2); + + for (UserRankings userRankings : userRankingsList) { + + InviteGetMoney invite = new InviteGetMoney(); + String showId = userRankings.getShowId(); + if (StringUtil.isNullOrEmpty(showId)) { + showId = "2***5"; + } + invite.setUid(showId); + invite.setName(userRankings.getNickName()); + // invite.setIcon(userRankings.getPortrait()); + invite.setPortrait(userRankings.getPortrait()); + invite.setMoney(userRankings.getTradeReward()); + invite.setCreateTime(userRankings.getCreatetime()); + rankingsList.add(invite); + } + + Calendar calendar = Calendar.getInstance(); + calendar.add(Calendar.DATE, -1); + + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); // 璁剧疆鏃堕棿鏍煎紡 + String defaultDate = sdf.format(calendar.getTime()); // 鏍煎紡鍖栧墠涓�澶� + + // 鐪熷疄鐢ㄦ埛 + List<HongBao> listHongBao = hongBaoService.listShareAndInviteMoney(0, count, defaultDate); + if (listHongBao != null && listHongBao.size() > 0) { + HongBao hongBao = listHongBao.get(0); + BigDecimal maxMoney = hongBao.getShareAndInviteMoney(); + + UserRankings userRankings = userRankingsList.get(userRankingsList.size() - 1); + BigDecimal mminMoney = userRankings.getTradeReward(); + + // 鐪熷疄鏁版嵁澶т簬鏈�浣庨噾棰� + if (maxMoney.compareTo(mminMoney) > 0) { + for (HongBao hb : listHongBao) { + BigDecimal rewardMoney = hb.getShareAndInviteMoney(); + + // 濂栭噾楂樺埌浣庢帓搴忥紝涓嶆弧瓒崇粨鏉熷惊鐜� + if (rewardMoney.compareTo(mminMoney) <= 0) { + break; + } + + UserInfo userInfo = hb.getUserInfo(); + if (userInfo != null) { + + InviteGetMoney invite = new InviteGetMoney(); + + invite.setName(userInfo.getNickName()); + // invite.setIcon(userRankings.getPortrait()); + invite.setPortrait(userInfo.getPortrait()); + invite.setMoney(rewardMoney); + invite.setCreateTime(new Date()); + + // 澶勭悊id + Long id = userInfo.getId(); + String uid = id + ""; + String index = uid.substring(0, 1); + String end = uid.substring(uid.length() - 1, uid.length()); + invite.setUid(index + "***" + end); + rankingsList.add(invite); + + } + + } + } + } + + List<InviteGetMoney> list = listSort(rankingsList); + + if (list.size() > count) { + resultList = list.subList(0, count-1); + } else { + resultList = list; + } + + for (int i = 0 ;i<resultList.size() ; i++) { + long n = i+1; + String icon = ""; + if (n == 1) { + icon ="http://buxinimg.oss-cn-qingdao.aliyuncs.com/5e75b65b6eca4c74850a7306d7584663.png"; + } + if (n == 2) { + icon ="http://buxinimg.oss-cn-qingdao.aliyuncs.com/442c950dd14a41a8849c0597f643ddd2.png"; + } + if (n == 3) { + icon ="http://buxinimg.oss-cn-qingdao.aliyuncs.com/5c9559905f034541888e674b30dbbeb3.png"; + } + if (n == 4) { + icon ="http://buxinimg.oss-cn-qingdao.aliyuncs.com/531b640cf73042ac929750e5ff610a20.png"; + } + if (n == 5) { + icon ="http://buxinimg.oss-cn-qingdao.aliyuncs.com/2a229650a22c4ce09e3c60e8cddafdd6.png"; + } + resultList.get(i).setIcon(icon); + + + resultList.get(i).setRankIcon("http://ec-1255749512.file.myqcloud.com/resource/rank/rank_icon_3.png"); + resultList.get(i).setId(n); + } + + + } catch (UserRankingsException e) { + e.printStackTrace(); + } + + return resultList; + + + } + + public List<InviteGetMoney> listSort(List<InviteGetMoney> list) { + + Collections.sort(list, new Comparator<InviteGetMoney>() { + public int compare(InviteGetMoney p1, InviteGetMoney p2) { + + // 鎸夌収Person鐨勫勾榫勮繘琛屽崌搴忔帓鍒� + if (p1.getMoney().compareTo(p2.getMoney()) < 0) { + return 1; + } + + if (p1.getMoney().compareTo(p2.getMoney()) == 0) { + return 0; + } + return -1; + } + }); + + return list; + } +} -- Gitblit v1.8.0