New file |
| | |
| | | package com.ks.lucky.pojo.DO; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | public class BaseUser implements Serializable { |
| | | private Long appId; |
| | | private String uid; |
| | | |
| | | public BaseUser() { |
| | | } |
| | | |
| | | public BaseUser(Long appId, String uid) { |
| | | this.appId = appId; |
| | | this.uid = uid; |
| | | } |
| | | |
| | | public Long getAppId() { |
| | | return appId; |
| | | } |
| | | |
| | | public void setAppId(Long appId) { |
| | | this.appId = appId; |
| | | } |
| | | |
| | | public String getUid() { |
| | | return uid; |
| | | } |
| | | |
| | | public void setUid(String uid) { |
| | | this.uid = uid; |
| | | } |
| | | } |
| | |
| | | |
| | | import org.springframework.data.annotation.Transient; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.Date; |
| | | |
| | | public class LuckyActivityAwardResult implements Serializable { |
| | | public class LuckyActivityAwardResult extends BaseUser { |
| | | public final static int STATE_NOT_SHOW = -1;//未外显 |
| | | public final static int STATE_NOT_RECIEVE = 0;//未领取 |
| | | public final static int STATE_RECIEVED = 1;//已领取 |
| | |
| | | private Long id; |
| | | |
| | | private Long activityId; |
| | | |
| | | private Long appId; |
| | | |
| | | private String uid; |
| | | |
| | | private Long awardId; |
| | | |
| | |
| | | |
| | | public void setActivityId(Long activityId) { |
| | | this.activityId = activityId; |
| | | } |
| | | |
| | | public Long getAppId() { |
| | | return appId; |
| | | } |
| | | |
| | | public void setAppId(Long appId) { |
| | | this.appId = appId; |
| | | } |
| | | |
| | | public String getUid() { |
| | | return uid; |
| | | } |
| | | |
| | | public void setUid(String uid) { |
| | | this.uid = uid == null ? null : uid.trim(); |
| | | } |
| | | |
| | | public Long getAwardId() { |
| | |
| | | import java.util.Date; |
| | | |
| | | public class LuckyActivityJoinAssist implements Serializable { |
| | | |
| | | public enum ActivityJoinAssistEvent { |
| | | assist("助力"), assistJoin("助力者参加活动"); |
| | | |
| | | private String name; |
| | | |
| | | private ActivityJoinAssistEvent(String name) { |
| | | this.name = name; |
| | | } |
| | | |
| | | public String getName() { |
| | | return this.name; |
| | | } |
| | | |
| | | } |
| | | |
| | | private Long id; |
| | | |
| | | private Long joinId; |
| | |
| | | |
| | | private Integer weight; |
| | | |
| | | private ActivityJoinAssistEvent eventKey; |
| | | |
| | | private Date createTime; |
| | | |
| | | private Date updateTime; |
| | | |
| | | public ActivityJoinAssistEvent getEventKey() { |
| | | return eventKey; |
| | | } |
| | | |
| | | public void setEventKey(ActivityJoinAssistEvent eventKey) { |
| | | this.eventKey = eventKey; |
| | | } |
| | | |
| | | public Long getId() { |
| | | return id; |
| | | } |
| | |
| | | package com.ks.lucky.pojo.DO; |
| | | |
| | | import org.yeshi.utils.mybatis.Column; |
| | | import org.yeshi.utils.mybatis.Table; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.Date; |
| | | |
| | | public class LuckyActivityJoinRecord implements Serializable { |
| | | @Table("lucky_activity_join_record") |
| | | public class LuckyActivityJoinRecord extends BaseUser { |
| | | |
| | | //未开 |
| | | public final static int DRAW_STATE_UNOPEN = 0; |
| | | |
| | | //中奖 |
| | | public final static int DRAW_STATE_DRAWN = 1; |
| | | |
| | | //未中奖 |
| | | public final static int DRAW_STATE_NOT_DRAWN = 2; |
| | | |
| | | //真实用户 |
| | | public final static int USER_TYPE_REAL = 1; |
| | |
| | | //虚拟用户 |
| | | public final static int USER_TYPE_VIRTUAL = 0; |
| | | |
| | | @Column(name = "id") |
| | | private Long id; |
| | | |
| | | @Column(name = "activity_id") |
| | | private Long activityId; |
| | | |
| | | private Long appId; |
| | | |
| | | private String uid; |
| | | |
| | | @Column(name = "join_info") |
| | | private String joinInfo; |
| | | |
| | | @Column(name = "user_type") |
| | | private Integer userType; |
| | | |
| | | @Column(name = "weight") |
| | | private Integer weight; |
| | | |
| | | @Column(name = "create_time") |
| | | private Date createTime; |
| | | |
| | | @Column(name = "update_time") |
| | | private Date updateTime; |
| | | |
| | | //是否中奖 |
| | | @Column(name = "draw_state") |
| | | private Integer drawState; |
| | | |
| | | public Integer getDrawState() { |
| | | return drawState; |
| | | } |
| | | |
| | | public void setDrawState(Integer drawState) { |
| | | this.drawState = drawState; |
| | | } |
| | | |
| | | public Long getId() { |
| | | return id; |
| | |
| | | |
| | | public void setActivityId(Long activityId) { |
| | | this.activityId = activityId; |
| | | } |
| | | |
| | | public Long getAppId() { |
| | | return appId; |
| | | } |
| | | |
| | | public void setAppId(Long appId) { |
| | | this.appId = appId; |
| | | } |
| | | |
| | | public String getUid() { |
| | | return uid; |
| | | } |
| | | |
| | | public void setUid(String uid) { |
| | | this.uid = uid == null ? null : uid.trim(); |
| | | } |
| | | |
| | | public String getJoinInfo() { |
| | |
| | | public void setCreateTime(Date createTime) { |
| | | this.createTime = createTime; |
| | | } |
| | | |
| | | public Date getUpdateTime() { |
| | | return updateTime; |
| | | } |
| | | |
| | | public void setUpdateTime(Date updateTime) { |
| | | this.updateTime = updateTime; |
| | | } |
| | | } |
New file |
| | |
| | | package com.ks.lucky.pojo.DO; |
| | | |
| | | import javax.validation.constraints.NotEmpty; |
| | | import javax.validation.constraints.NotNull; |
| | | import java.io.Serializable; |
| | | import java.util.Date; |
| | | |
| | | public class LuckyActivityUserWeightRecord implements Serializable { |
| | | private Long id; |
| | | |
| | | @NotNull(message = "活动ID不能为空") |
| | | private Long activityId; |
| | | |
| | | @NotNull(message = "应用ID不能为空") |
| | | private Long appId; |
| | | @NotEmpty(message = "用户ID不能为空") |
| | | private String uid; |
| | | @NotNull(message = "权重不能为空") |
| | | private Integer weight; |
| | | @NotEmpty(message = "标题不能为空") |
| | | private String title; |
| | | |
| | | private String desc; |
| | | |
| | | private Date createTime; |
| | | |
| | | private Date updateTime; |
| | | |
| | | public Long getId() { |
| | | return id; |
| | | } |
| | | |
| | | public void setId(Long id) { |
| | | this.id = id; |
| | | } |
| | | |
| | | public Long getActivityId() { |
| | | return activityId; |
| | | } |
| | | |
| | | public void setActivityId(Long activityId) { |
| | | this.activityId = activityId; |
| | | } |
| | | |
| | | public Long getAppId() { |
| | | return appId; |
| | | } |
| | | |
| | | public void setAppId(Long appId) { |
| | | this.appId = appId; |
| | | } |
| | | |
| | | public String getUid() { |
| | | return uid; |
| | | } |
| | | |
| | | public void setUid(String uid) { |
| | | this.uid = uid == null ? null : uid.trim(); |
| | | } |
| | | |
| | | public Integer getWeight() { |
| | | return weight; |
| | | } |
| | | |
| | | public void setWeight(Integer weight) { |
| | | this.weight = weight; |
| | | } |
| | | |
| | | public String getTitle() { |
| | | return title; |
| | | } |
| | | |
| | | public void setTitle(String title) { |
| | | this.title = title == null ? null : title.trim(); |
| | | } |
| | | |
| | | public String getDesc() { |
| | | return desc; |
| | | } |
| | | |
| | | public void setDesc(String desc) { |
| | | this.desc = desc == null ? null : desc.trim(); |
| | | } |
| | | |
| | | public Date getCreateTime() { |
| | | return createTime; |
| | | } |
| | | |
| | | public void setCreateTime(Date createTime) { |
| | | this.createTime = createTime; |
| | | } |
| | | |
| | | public Date getUpdateTime() { |
| | | return updateTime; |
| | | } |
| | | |
| | | public void setUpdateTime(Date updateTime) { |
| | | this.updateTime = updateTime; |
| | | } |
| | | } |
New file |
| | |
| | | package com.ks.lucky.pojo.DTO; |
| | | |
| | | import com.ks.lucky.pojo.DO.BaseUser; |
| | | |
| | | public class ActivityAssistFriend extends BaseUser { |
| | | |
| | | private int assistCount; |
| | | |
| | | public int getAssistCount() { |
| | | return assistCount; |
| | | } |
| | | |
| | | public void setAssistCount(int assistCount) { |
| | | this.assistCount = assistCount; |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.ks.lucky.pojo.DTO; |
| | | |
| | | import java.io.Serializable; |
| | | import java.math.BigDecimal; |
| | | |
| | | /** |
| | | * 活动中奖率统计 |
| | | */ |
| | | public class ActivityDrawnProbabilityStatistic implements Serializable { |
| | | |
| | | private Long activityId; |
| | | |
| | | //平均的中奖概率 |
| | | private BigDecimal averageDrawnProbability; |
| | | |
| | | |
| | | //我的中奖概率 |
| | | private BigDecimal myDrawnProbability; |
| | | |
| | | public Long getActivityId() { |
| | | return activityId; |
| | | } |
| | | |
| | | public void setActivityId(Long activityId) { |
| | | this.activityId = activityId; |
| | | } |
| | | |
| | | public BigDecimal getAverageDrawnProbability() { |
| | | return averageDrawnProbability; |
| | | } |
| | | |
| | | public void setAverageDrawnProbability(BigDecimal averageDrawnProbability) { |
| | | this.averageDrawnProbability = averageDrawnProbability; |
| | | } |
| | | |
| | | public BigDecimal getMyDrawnProbability() { |
| | | return myDrawnProbability; |
| | | } |
| | | |
| | | public void setMyDrawnProbability(BigDecimal myDrawnProbability) { |
| | | this.myDrawnProbability = myDrawnProbability; |
| | | } |
| | | } |
New file |
| | |
| | | package com.ks.lucky.pojo.DTO; |
| | | |
| | | import com.ks.lucky.pojo.DO.BaseUser; |
| | | import com.ks.lucky.pojo.DO.LuckyActivityJoinAssist; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 活动好友的助力信息 |
| | | */ |
| | | public class ActivityFriendAssistInfo extends BaseUser { |
| | | |
| | | private Long joinerId; |
| | | private int weight; |
| | | private List<LuckyActivityJoinAssist.ActivityJoinAssistEvent> eventList; |
| | | |
| | | |
| | | public Long getJoinerId() { |
| | | return joinerId; |
| | | } |
| | | |
| | | public void setJoinerId(Long joinerId) { |
| | | this.joinerId = joinerId; |
| | | } |
| | | |
| | | public int getWeight() { |
| | | return weight; |
| | | } |
| | | |
| | | public void setWeight(int weight) { |
| | | this.weight = weight; |
| | | } |
| | | |
| | | public List<LuckyActivityJoinAssist.ActivityJoinAssistEvent> getEventList() { |
| | | return eventList; |
| | | } |
| | | |
| | | public void setEventList(List<LuckyActivityJoinAssist.ActivityJoinAssistEvent> eventList) { |
| | | this.eventList = eventList; |
| | | } |
| | | } |
New file |
| | |
| | | package com.ks.lucky.pojo.DTO; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | /** |
| | | * 活动参与统计信息 |
| | | */ |
| | | public class ActivityJoinStatisticInfo implements Serializable { |
| | | |
| | | private Long activityId; |
| | | private Integer myPosition; |
| | | private Integer totalJoiner; |
| | | |
| | | |
| | | |
| | | |
| | | public Long getActivityId() { |
| | | return activityId; |
| | | } |
| | | |
| | | public void setActivityId(Long activityId) { |
| | | this.activityId = activityId; |
| | | } |
| | | |
| | | public Integer getMyPosition() { |
| | | return myPosition; |
| | | } |
| | | |
| | | public void setMyPosition(Integer myPosition) { |
| | | this.myPosition = myPosition; |
| | | } |
| | | |
| | | public Integer getTotalJoiner() { |
| | | return totalJoiner; |
| | | } |
| | | |
| | | public void setTotalJoiner(Integer totalJoiner) { |
| | | this.totalJoiner = totalJoiner; |
| | | } |
| | | } |
New file |
| | |
| | | package com.ks.lucky.pojo.DTO; |
| | | |
| | | import com.ks.lucky.pojo.DO.BaseUser; |
| | | |
| | | public class ActivityJoinerRankInfo extends BaseUser { |
| | | //排名顺序 |
| | | private int rank; |
| | | //权重 |
| | | private int weight; |
| | | |
| | | public int getRank() { |
| | | return rank; |
| | | } |
| | | |
| | | public void setRank(int rank) { |
| | | this.rank = rank; |
| | | } |
| | | |
| | | public int getWeight() { |
| | | return weight; |
| | | } |
| | | |
| | | public void setWeight(int weight) { |
| | | this.weight = weight; |
| | | } |
| | | } |
New file |
| | |
| | | package com.ks.lucky.pojo.DTO; |
| | | |
| | | import com.ks.lucky.pojo.DO.BaseUser; |
| | | |
| | | public class ActivitySimpleUser extends BaseUser { |
| | | |
| | | private Long activityId; |
| | | |
| | | public ActivitySimpleUser(Long activityId, String uid, Long appId) { |
| | | super(appId, uid); |
| | | this.activityId = activityId; |
| | | } |
| | | |
| | | public Long getActivityId() { |
| | | return activityId; |
| | | } |
| | | |
| | | public void setActivityId(Long activityId) { |
| | | this.activityId = activityId; |
| | | } |
| | | } |
| | |
| | | import com.ks.lucky.exception.LuckyActivityException; |
| | | import com.ks.lucky.pojo.DO.LuckyActivityAwardResult; |
| | | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 抽奖结果 |
| | | */ |
| | |
| | | /** |
| | | * 获取结果 |
| | | * |
| | | * @param appKey |
| | | * @param appId |
| | | * @param uid |
| | | * @param activityId |
| | | * @param awardId |
| | | * @return |
| | | */ |
| | | public LuckyActivityAwardResult getResult(String appKey, String uid, Long activityId, Long awardId); |
| | | public LuckyActivityAwardResult getResult(Long appId, String uid, Long activityId, Long awardId); |
| | | |
| | | /** |
| | | * 领奖 |
| | | * |
| | | * @param appKey |
| | | * @param appId |
| | | * @param uid |
| | | * @param activityId |
| | | */ |
| | | public void recieveAward(String appKey, String uid, Long activityId) throws LuckyActivityException, LuckyActivityAwardException, LuckyActivityAwardResultException; |
| | | public void recieveAward(Long appId, String uid, Long activityId) throws LuckyActivityException, LuckyActivityAwardException, LuckyActivityAwardResultException; |
| | | |
| | | |
| | | /** |
| | | * 获取已经中奖的活动ID |
| | | * |
| | | * @param uid |
| | | * @param page |
| | | * @param pageSize |
| | | * @return |
| | | */ |
| | | public List<Long> getDrawnActivityIdList(Long appId, Long uid, int page, int pageSize); |
| | | |
| | | public long countDrawnActivityIdList(Long appId, Long uid); |
| | | |
| | | |
| | | /** |
| | | * 根据奖项信息获取开奖结果 |
| | | * |
| | | * @param activityId |
| | | * @param awardId |
| | | * @param page |
| | | * @param pageSize |
| | | * @return |
| | | */ |
| | | public List<LuckyActivityAwardResult> getResultListWithAwardInfo(Long activityId, Long awardId, int page, int pageSize); |
| | | |
| | | |
| | | /** |
| | | * 根据奖项信息获取开奖结果数量 |
| | | * |
| | | * @param activityId |
| | | * @param awardId |
| | | * @return |
| | | */ |
| | | public long countResultWithAwardInfo(Long activityId, Long awardId); |
| | | |
| | | |
| | | /** |
| | | * 最近更新时间 |
| | | * |
| | | * @param activityId |
| | | * @return |
| | | */ |
| | | public Date getLatestUpdateTime(Long activityId); |
| | | |
| | | |
| | | } |
| | |
| | | import com.ks.lucky.exception.LuckyActivityException; |
| | | import com.ks.lucky.exception.LuckyActivityJoinAssistException; |
| | | import com.ks.lucky.pojo.DO.LuckyActivityJoinAssist; |
| | | import com.ks.lucky.pojo.DTO.ActivityAssistFriend; |
| | | import com.ks.lucky.pojo.DTO.ActivityFriendAssistInfo; |
| | | import io.lettuce.core.dynamic.annotation.Param; |
| | | |
| | | import javax.validation.constraints.NotEmpty; |
| | | import javax.validation.constraints.NotNull; |
| | |
| | | * 活动助力 |
| | | * |
| | | * @param activityId |
| | | * @param appKey |
| | | * @param appId |
| | | * @param uid |
| | | * @param targetUid |
| | | * @throws LuckyActivityJoinAssistException |
| | | */ |
| | | public void assist(@NotNull Long activityId, @NotEmpty String appKey, @NotEmpty String uid, @NotEmpty String targetUid) throws LuckyActivityException, LuckyActivityJoinAssistException; |
| | | public void assist(@NotNull Long activityId, @NotEmpty Long appId, @NotEmpty String uid, @NotEmpty String targetUid, @NotNull LuckyActivityJoinAssist.ActivityJoinAssistEvent eventKey, int weight) throws LuckyActivityException, LuckyActivityJoinAssistException; |
| | | |
| | | |
| | | /** |
| | | * 获取助力列表 |
| | | * |
| | | * @param activityId |
| | | * @param appKey |
| | | * @param appId |
| | | * @param uid |
| | | * @param page |
| | | * @param pageSize |
| | | * @return |
| | | */ |
| | | public List<LuckyActivityJoinAssist> getAssistRecordList(Long activityId, String appKey, String uid, int page, int pageSize); |
| | | public List<LuckyActivityJoinAssist> getAssistRecordList(Long activityId, Long appId, String uid, int page, int pageSize); |
| | | |
| | | |
| | | /** |
| | | * 助力列表计数 |
| | | * |
| | | * @param activityId |
| | | * @param appKey |
| | | * @param appId |
| | | * @param uid |
| | | * @return |
| | | */ |
| | | public long countAssistRecord(Long activityId, String appKey, String uid); |
| | | public long countAssistRecord(Long activityId, Long appId, String uid); |
| | | |
| | | |
| | | /** |
| | | * 获取助力好友 |
| | | * |
| | | * @param appId |
| | | * @param targetUid |
| | | * @param page |
| | | * @param pageSize |
| | | */ |
| | | public List<ActivityAssistFriend> getAssistFriendsList(Long appId, String targetUid, int page, int pageSize); |
| | | |
| | | /** |
| | | * 获取助力好友数量 |
| | | * |
| | | * @param appId |
| | | * @param targetUid |
| | | */ |
| | | public long countAssistFriends(Long appId, String targetUid); |
| | | |
| | | |
| | | /** |
| | | * 获取活动的助力信息 |
| | | * |
| | | * @param activityId |
| | | * @param appId |
| | | * @param uid |
| | | * @param page |
| | | * @param pageSize |
| | | * @return |
| | | */ |
| | | public List<ActivityFriendAssistInfo> getActivityFriendAssistInfoList(Long activityId, Long appId, String uid, int page, int pageSize); |
| | | |
| | | long countyActivityFriendAssistInfo(Long activityId, Long appId, String uid); |
| | | |
| | | |
| | | } |
| | |
| | | import com.ks.lucky.exception.LuckyActivityException; |
| | | import com.ks.lucky.exception.LuckyActivityJoinException; |
| | | import com.ks.lucky.pojo.DO.LuckyActivityJoinRecord; |
| | | import com.ks.lucky.pojo.DTO.JoinInfo; |
| | | import com.ks.lucky.pojo.DTO.*; |
| | | |
| | | import javax.validation.constraints.NotEmpty; |
| | | import javax.validation.constraints.NotNull; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 活动参与记录服务 |
| | |
| | | * 参与活动 |
| | | * |
| | | * @param activityId |
| | | * @param appKey |
| | | * @param appId |
| | | * @param uid |
| | | * @param weight |
| | | * @param joinInfo |
| | | * @throws LuckyActivityException |
| | | * @throws LuckyActivityJoinException |
| | | */ |
| | | public void join(@NotNull Long activityId, @NotEmpty String appKey, @NotEmpty String uid, Integer weight, JoinInfo joinInfo) throws LuckyActivityException, LuckyActivityJoinException; |
| | | public void join(@NotNull Long activityId, @NotEmpty Long appId, @NotEmpty String uid, Integer weight, JoinInfo joinInfo) throws LuckyActivityException, LuckyActivityJoinException; |
| | | |
| | | |
| | | /** |
| | | * 获取参与信息 |
| | | * |
| | | * @param activityId |
| | | * @param appKey |
| | | * @param appId |
| | | * @param uid |
| | | * @return |
| | | */ |
| | | public LuckyActivityJoinRecord getJoinInfo(Long activityId, String appKey, String uid); |
| | | public LuckyActivityJoinRecord getJoinInfo(Long activityId, Long appId, String uid); |
| | | |
| | | |
| | | /** |
| | | * 获取还未开奖的活动列表 |
| | | * |
| | | * @param uid |
| | | * @param page |
| | | * @param pageSize |
| | | * @return |
| | | */ |
| | | public List<Long> getUnOpenActivityIdList(Long appId, String uid, int page, int pageSize); |
| | | |
| | | public long countUnOpenActivityIdList(Long appId, String uid); |
| | | |
| | | |
| | | /** |
| | | * 获取未中奖的活动ID |
| | | * |
| | | * @param uid |
| | | * @param page |
| | | * @param pageSize |
| | | * @return |
| | | */ |
| | | public List<Long> getUnDrawnActivityIdList(Long appId, String uid, int page, int pageSize); |
| | | |
| | | public long countUnDrawnActivityIdList(Long appId, String uid); |
| | | |
| | | /** |
| | | * 获取最近的参与人信息 |
| | | * |
| | | * @param activityId |
| | | * @param count |
| | | * @return |
| | | */ |
| | | public List<ActivitySimpleUser> getRecentJoinerList(Long activityId, int count); |
| | | |
| | | /** |
| | | * 批量获取活动最近的参与人信息 |
| | | * |
| | | * @param activityIdList |
| | | * @param count |
| | | * @return |
| | | */ |
| | | public List<ActivitySimpleUser> getRecentJoinerList(List<Long> activityIdList, int count); |
| | | |
| | | |
| | | /** |
| | | * 获取活动的参与者列表(根据参与时间先后排序) |
| | | * |
| | | * @param activityId |
| | | * @param page |
| | | * @param count |
| | | * @return |
| | | */ |
| | | public List<ActivitySimpleUser> getJoinerList(Long activityId, int page, int count); |
| | | |
| | | /** |
| | | * 活动参与者统计信息 |
| | | * |
| | | * @param activityId |
| | | * @param appId |
| | | * @param uid |
| | | * @return |
| | | */ |
| | | public ActivityJoinStatisticInfo getActivityJoinerStatisticInfo(Long activityId, Long appId, String uid); |
| | | |
| | | |
| | | /** |
| | | * 获取活动中奖概率统计信息 |
| | | * |
| | | * @param activityId |
| | | * @param appId |
| | | * @param uid |
| | | * @return |
| | | */ |
| | | public ActivityDrawnProbabilityStatistic getActivityDrawnProbabilityStatistic(Long activityId, Long appId, String uid); |
| | | |
| | | |
| | | /** |
| | | * 获取排行榜 |
| | | * |
| | | * @param activityId |
| | | * @param page |
| | | * @param pageSize |
| | | * @return |
| | | */ |
| | | public List<ActivityJoinerRankInfo> getWeightRankList(Long activityId, int page, int pageSize); |
| | | |
| | | |
| | | /** |
| | | * 排行榜数量 |
| | | * |
| | | * @param activityId |
| | | * @return |
| | | */ |
| | | public long countWeightRank(Long activityId); |
| | | |
| | | |
| | | /** |
| | | * 获取我的排行 |
| | | * |
| | | * @param activityId |
| | | * @param appId |
| | | * @param uid |
| | | * @return |
| | | */ |
| | | public ActivityJoinerRankInfo getMyWeightRank(Long activityId, Long appId, String uid); |
| | | |
| | | } |
| | |
| | | /** |
| | | * 获取有效的活动列表 |
| | | * |
| | | * @param appKey |
| | | * @param appId |
| | | * @param sponsorId |
| | | * @param key |
| | | * @param page |
| | | * @param pageSize |
| | | * @return |
| | | */ |
| | | public List<LuckyActivity> getActivityList(String appKey, Long sponsorId, List<Integer> stateList, String key, int page, int pageSize); |
| | | public List<LuckyActivity> getActivityList(Long appId, Long sponsorId, List<Integer> stateList, String key, int page, int pageSize); |
| | | |
| | | |
| | | /** |
| | | * 有效的活动计数 |
| | | * |
| | | * @param appKey |
| | | * @param appId |
| | | * @param sponsorId |
| | | * @param key |
| | | * @return |
| | | */ |
| | | public long countActivity(String appKey, Long sponsorId, List<Integer> stateList, String key); |
| | | public long countActivity(Long appId, Long sponsorId, List<Integer> stateList, String key); |
| | | |
| | | |
| | | /** |
| | |
| | | |
| | | |
| | | /** |
| | | * 获取活动详情 |
| | | * |
| | | * @param ids |
| | | * @return |
| | | */ |
| | | public List<LuckyActivity> getActivityDetail(List<Long> ids); |
| | | |
| | | |
| | | /** |
| | | * 修改活动 |
| | | * |
| | | * @param activity |
New file |
| | |
| | | package com.ks.lucky.remote.service; |
| | | |
| | | import com.ks.lucky.pojo.DO.LuckyActivityUserWeightRecord; |
| | | |
| | | import java.util.List; |
| | | |
| | | public interface LuckyActivityUserWeightRecordService { |
| | | |
| | | /** |
| | | * 获取权重记录 |
| | | * |
| | | * @param activityid |
| | | * @param appId |
| | | * @param uid |
| | | * @param page |
| | | * @param pageSize |
| | | * @return |
| | | */ |
| | | public List<LuckyActivityUserWeightRecord> getWeightRecordList(Long activityid, Long appId, String uid, int page, int pageSize); |
| | | |
| | | /** |
| | | * @param activityid |
| | | * @param appId |
| | | * @param uid |
| | | * @return |
| | | */ |
| | | public long countWeightRecord(Long activityid, Long appId, String uid); |
| | | |
| | | |
| | | } |
| | |
| | | <artifactId>spring-boot-maven-plugin</artifactId> |
| | | </plugin> |
| | | <!-- MyBatis插件 --> |
| | | <plugin> |
| | | <groupId>org.mybatis.generator</groupId> |
| | | <artifactId>mybatis-generator-maven-plugin</artifactId> |
| | | <version>1.3.2</version> |
| | | <configuration> |
| | | <!--配置文件的位置--> |
| | | <configurationFile>src/main/resources/generatorConfig.xml</configurationFile> |
| | | <verbose>true</verbose> |
| | | <overwrite>true</overwrite> |
| | | </configuration> |
| | | <executions> |
| | | <execution> |
| | | <id>Generate MyBatis Artifacts</id> |
| | | <goals> |
| | | <goal>generate</goal> |
| | | </goals> |
| | | </execution> |
| | | </executions> |
| | | <dependencies> |
| | | <dependency> |
| | | <groupId>org.mybatis.generator</groupId> |
| | | <artifactId>mybatis-generator-core</artifactId> |
| | | <version>1.3.2</version> |
| | | </dependency> |
| | | </dependencies> |
| | | </plugin> |
| | | <!--<plugin>--> |
| | | <!--<groupId>org.mybatis.generator</groupId>--> |
| | | <!--<artifactId>mybatis-generator-maven-plugin</artifactId>--> |
| | | <!--<version>1.3.2</version>--> |
| | | <!--<configuration>--> |
| | | <!--<!–配置文件的位置–>--> |
| | | <!--<configurationFile>src/main/resources/generatorConfig.xml</configurationFile>--> |
| | | <!--<verbose>true</verbose>--> |
| | | <!--<overwrite>true</overwrite>--> |
| | | <!--</configuration>--> |
| | | <!--<executions>--> |
| | | <!--<execution>--> |
| | | <!--<id>Generate MyBatis Artifacts</id>--> |
| | | <!--<goals>--> |
| | | <!--<goal>generate</goal>--> |
| | | <!--</goals>--> |
| | | <!--</execution>--> |
| | | <!--</executions>--> |
| | | <!--<dependencies>--> |
| | | <!--<dependency>--> |
| | | <!--<groupId>org.mybatis.generator</groupId>--> |
| | | <!--<artifactId>mybatis-generator-core</artifactId>--> |
| | | <!--<version>1.3.2</version>--> |
| | | <!--</dependency>--> |
| | | <!--</dependencies>--> |
| | | <!--</plugin>--> |
| | | </plugins> |
| | | </build> |
| | | |
New file |
| | |
| | | package com.ks.daylucky.aspect; |
| | | |
| | | import org.aspectj.lang.ProceedingJoinPoint; |
| | | import org.aspectj.lang.annotation.Around; |
| | | import org.aspectj.lang.annotation.Aspect; |
| | | import org.springframework.core.annotation.Order; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.web.context.request.RequestContextHolder; |
| | | import org.springframework.web.context.request.ServletRequestAttributes; |
| | | import org.yeshi.utils.JsonUtil; |
| | | import org.yeshi.utils.StringUtil; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.validation.Validator; |
| | | import java.io.PrintWriter; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * 参数检查AOP |
| | | */ |
| | | @Aspect |
| | | @Order(1) |
| | | @Component |
| | | public class ApiClientSignAspect { |
| | | |
| | | public static final String EDP = "execution(* com.ks.daylucky.controller.api.client.**.*(..))"; |
| | | private final static String SECRET = "123123123"; |
| | | |
| | | @Around(EDP) |
| | | public Object validSign(ProceedingJoinPoint joinPoint) throws Throwable { |
| | | ServletRequestAttributes servletContainer = (ServletRequestAttributes) RequestContextHolder |
| | | .getRequestAttributes(); |
| | | PrintWriter out = servletContainer.getResponse().getWriter(); |
| | | HttpServletRequest request = servletContainer.getRequest(); |
| | | Map<String, String[]> paramsMap = request.getParameterMap(); |
| | | List<String> dataSource = new ArrayList<>(); |
| | | for (Iterator<String> its = paramsMap.keySet().iterator(); its.hasNext(); ) { |
| | | String key = its.next(); |
| | | if (!key.equalsIgnoreCase("sign")) { |
| | | dataSource.add(key + "=" + paramsMap.get(key).toString()); |
| | | } |
| | | } |
| | | Collections.sort(dataSource); |
| | | |
| | | String sign = StringUtil.Md5(StringUtil.concat(dataSource, "") + SECRET); |
| | | |
| | | if (!sign.equalsIgnoreCase(paramsMap.get("sign") + "")) { |
| | | //签名出错 |
| | | out.print(JsonUtil.loadFalseResult(-1, "签名出错")); |
| | | out.close(); |
| | | } |
| | | return joinPoint.proceed(joinPoint.getArgs()); |
| | | } |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.ks.daylucky.aspect; |
| | | |
| | | import com.ks.app.entity.AppInfo; |
| | | import com.ks.daylucky.pojo.VO.AcceptData; |
| | | import com.ks.daylucky.service.impl.AppManager; |
| | | import com.ks.daylucky.util.ApiCodeConstant; |
| | | import org.aspectj.lang.ProceedingJoinPoint; |
| | | import org.aspectj.lang.annotation.Around; |
| | | import org.aspectj.lang.annotation.Aspect; |
| | | import org.springframework.core.annotation.Order; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.web.context.request.RequestContextHolder; |
| | | import org.springframework.web.context.request.ServletRequestAttributes; |
| | | import org.yeshi.utils.JsonUtil; |
| | | import org.yeshi.utils.StringUtil; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.io.PrintWriter; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * 参数检查AOP |
| | | */ |
| | | @Aspect |
| | | @Order(2) |
| | | @Component |
| | | public class VerifyAppAspect { |
| | | |
| | | @Resource |
| | | private AppManager appManager; |
| | | |
| | | |
| | | public static final String EDP = "execution(* com.ks.daylucky.controller.api.client.**.*(..))"; |
| | | |
| | | @Around(EDP) |
| | | public Object verifyApp(ProceedingJoinPoint joinPoint) throws Throwable { |
| | | ServletRequestAttributes servletContainer = (ServletRequestAttributes) RequestContextHolder |
| | | .getRequestAttributes(); |
| | | PrintWriter out = servletContainer.getResponse().getWriter(); |
| | | HttpServletRequest request = servletContainer.getRequest(); |
| | | Map<String, String[]> paramsMap = request.getParameterMap(); |
| | | String appKey = paramsMap.get("appKey") + ""; |
| | | |
| | | AppInfo app = null; |
| | | if (!StringUtil.isNullOrEmpty(appKey)) { |
| | | app = appManager.getAppDetail(appKey); |
| | | } |
| | | if (StringUtil.isNullOrEmpty(appKey) || app == null) { |
| | | out.print(JsonUtil.loadFalseResult(ApiCodeConstant.CODE_APP_NOT_EXIST, "应用不存在")); |
| | | out.close(); |
| | | return null; |
| | | } |
| | | |
| | | for (Object obj : joinPoint.getArgs()) { |
| | | if (obj instanceof AcceptData) { |
| | | //注入应用详情 |
| | | ((AcceptData) obj).setApp(app); |
| | | break; |
| | | } |
| | | } |
| | | return joinPoint.proceed(joinPoint.getArgs()); |
| | | } |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.ks.daylucky.controller.api.client; |
| | | |
| | | import com.ks.daylucky.pojo.DO.UserInfo; |
| | | import com.ks.daylucky.pojo.VO.AcceptData; |
| | | import com.ks.daylucky.pojo.VO.ActivityFriendAssistInfoVO; |
| | | import com.ks.daylucky.pojo.VO.AssistFriendVO; |
| | | import com.ks.daylucky.pojo.VO.SimpleUser; |
| | | import com.ks.daylucky.service.UserInfoService; |
| | | import com.ks.daylucky.util.Constant; |
| | | import com.ks.daylucky.util.UserInfoUtil; |
| | | import com.ks.lucky.pojo.DO.LuckyActivityJoinAssist; |
| | | import com.ks.lucky.pojo.DTO.ActivityAssistFriend; |
| | | import com.ks.lucky.pojo.DTO.ActivityFriendAssistInfo; |
| | | import com.ks.lucky.remote.service.LuckyActivityJoinAssistService; |
| | | import net.sf.json.JSONObject; |
| | | import org.apache.dubbo.config.annotation.Reference; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.ResponseBody; |
| | | import org.yeshi.utils.JsonUtil; |
| | | import org.yeshi.utils.StringUtil; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | @Controller |
| | | @RequestMapping("api/client/activity/assist") |
| | | public class ActivityAssistController { |
| | | |
| | | @Reference |
| | | private LuckyActivityJoinAssistService luckyActivityJoinAssistService; |
| | | |
| | | @Resource |
| | | private UserInfoService userInfoService; |
| | | |
| | | |
| | | @ResponseBody |
| | | @RequestMapping("getAssistFriendsList") |
| | | public String getAssistFriendsList(AcceptData acceptData, int page) { |
| | | List<AssistFriendVO> list = new ArrayList<>(); |
| | | List<ActivityAssistFriend> recordList = luckyActivityJoinAssistService.getAssistFriendsList(acceptData.getApp().getId(), acceptData.getUid() + "", page, Constant.PAGE_SIZE); |
| | | long count = luckyActivityJoinAssistService.countAssistFriends(acceptData.getApp().getId(), acceptData.getUid() + ""); |
| | | List<Long> uidList = new ArrayList<>(); |
| | | if (recordList != null) { |
| | | for (ActivityAssistFriend assist : recordList) { |
| | | uidList.add(Long.parseLong(assist.getUid())); |
| | | } |
| | | //填充用户信息 |
| | | if (uidList.size() > 0) { |
| | | Map<Long, UserInfo> userInfoMap = userInfoService.listUserInfoAsMap(UserInfoUtil.getBaseUserList(recordList)); |
| | | for (ActivityAssistFriend assistFriend : recordList) { |
| | | list.add(new AssistFriendVO(userInfoMap.get(Long.parseLong(assistFriend.getUid())), assistFriend.getAssistCount())); |
| | | } |
| | | } |
| | | } |
| | | JSONObject data = new JSONObject(); |
| | | data.put("data", JsonUtil.getApiCommonGson().toJson(list)); |
| | | data.put("count", count); |
| | | return JsonUtil.loadTrueResult(data); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 活动助力列表 |
| | | * |
| | | * @param acceptData |
| | | * @param page |
| | | * @return |
| | | */ |
| | | @ResponseBody |
| | | @RequestMapping("getActivityAssistCouponList") |
| | | public String getActivityAssistCouponList(AcceptData acceptData, Long activityId, int page) { |
| | | List<ActivityFriendAssistInfo> list = luckyActivityJoinAssistService.getActivityFriendAssistInfoList(activityId, acceptData.getApp().getId(), acceptData.getUid() + "", page, Constant.PAGE_SIZE); |
| | | List<ActivityFriendAssistInfoVO> voList = new ArrayList<>(); |
| | | if (list != null) { |
| | | Map<Long, UserInfo> userMap = userInfoService.listUserInfoAsMap(UserInfoUtil.getBaseUserList(list)); |
| | | for (ActivityFriendAssistInfo info : list) { |
| | | UserInfo user = userMap.get(Long.parseLong(info.getUid())); |
| | | if (user != null) { |
| | | List<String> eventList = new ArrayList<>(); |
| | | if (info.getEventList() != null) { |
| | | for (LuckyActivityJoinAssist.ActivityJoinAssistEvent event : info.getEventList()) { |
| | | eventList.add(event.getName()); |
| | | } |
| | | } |
| | | voList.add(new ActivityFriendAssistInfoVO(new SimpleUser(user.getId(), user.getNickName(), user.getPortrait()), StringUtil.concat(eventList, "\n且"), info.getWeight())); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | long count = luckyActivityJoinAssistService.countyActivityFriendAssistInfo(activityId, acceptData.getApp().getId(), acceptData.getUid() + ""); |
| | | |
| | | JSONObject data = new JSONObject(); |
| | | data.put("data", voList); |
| | | data.put("count", count); |
| | | return JsonUtil.loadTrueResult(data); |
| | | } |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.ks.daylucky.controller.api.client; |
| | | |
| | | import com.ks.daylucky.pojo.DO.UserInfo; |
| | | import com.ks.daylucky.pojo.VO.AcceptData; |
| | | import com.ks.daylucky.pojo.VO.SimpleUser; |
| | | import com.ks.daylucky.service.UserInfoService; |
| | | import com.ks.daylucky.util.Constant; |
| | | import com.ks.daylucky.util.UserInfoUtil; |
| | | import com.ks.lucky.pojo.DO.LuckyActivityAwardResult; |
| | | import com.ks.lucky.pojo.DO.LuckyActivityAwards; |
| | | import com.ks.lucky.remote.service.LuckyActivityAwardResultService; |
| | | import com.ks.lucky.remote.service.LuckyActivityAwardService; |
| | | import net.sf.json.JSONArray; |
| | | import net.sf.json.JSONObject; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.ResponseBody; |
| | | import org.yeshi.utils.JsonUtil; |
| | | import org.yeshi.utils.TimeUtil; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | @Controller |
| | | @RequestMapping("api/client/activity/awards") |
| | | public class ActivityAwardsController { |
| | | |
| | | @Resource |
| | | private LuckyActivityAwardResultService luckyActivityAwardResultService; |
| | | |
| | | @Resource |
| | | private LuckyActivityAwardService luckyActivityAwardService; |
| | | |
| | | @Resource |
| | | private UserInfoService userInfoService; |
| | | |
| | | |
| | | /** |
| | | * 获取中奖信息 |
| | | * |
| | | * @param acceptData |
| | | * @return |
| | | */ |
| | | @ResponseBody |
| | | @RequestMapping("getDrawnInfo") |
| | | public String getDrawnInfo(AcceptData acceptData, Long activityId, int count) { |
| | | List<LuckyActivityAwards> list = luckyActivityAwardService.getAwardList(activityId); |
| | | JSONArray array = new JSONArray(); |
| | | for (LuckyActivityAwards award : list) { |
| | | JSONObject item = new JSONObject(); |
| | | List<LuckyActivityAwardResult> awardResults = luckyActivityAwardResultService.getResultListWithAwardInfo(activityId, award.getId(), 1, count); |
| | | List<SimpleUser> userList = new ArrayList<>(); |
| | | Map<Long, UserInfo> userMap = userInfoService.listUserInfoAsMap(UserInfoUtil.getBaseUserList(awardResults)); |
| | | for (LuckyActivityAwardResult info : awardResults) { |
| | | UserInfo user = userMap.get(info.getUid()); |
| | | if (user != null) { |
| | | userList.add(new SimpleUser(user.getId(), user.getNickName(), user.getPortrait())); |
| | | } |
| | | } |
| | | item.put("userList", userList); |
| | | item.put("award", JsonUtil.getApiCommonGson().toJson(award)); |
| | | array.add(item); |
| | | } |
| | | |
| | | JSONObject data = new JSONObject(); |
| | | data.put("data", array); |
| | | Date updateTime = luckyActivityAwardResultService.getLatestUpdateTime(activityId); |
| | | if (updateTime != null) { |
| | | data.put("updateTime", TimeUtil.getGernalTime(updateTime.getTime(), "yyyy.MMM.dd HH:mm")); |
| | | } |
| | | return JsonUtil.loadTrueResult(data); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取活动的某个奖项的中奖列表 |
| | | * |
| | | * @param acceptData |
| | | * @param activityId |
| | | * @param awardId |
| | | * @param page |
| | | * @return |
| | | */ |
| | | |
| | | @ResponseBody |
| | | @RequestMapping("getDrawnList") |
| | | public String getDrawnList(AcceptData acceptData, Long activityId, Long awardId, int page) { |
| | | |
| | | List<LuckyActivityAwardResult> awardResults = luckyActivityAwardResultService.getResultListWithAwardInfo(activityId, awardId, page, Constant.PAGE_SIZE); |
| | | long count = luckyActivityAwardResultService.countResultWithAwardInfo(activityId, awardId); |
| | | List<SimpleUser> userList = new ArrayList<>(); |
| | | Map<Long, UserInfo> userMap =userInfoService.listUserInfoAsMap(UserInfoUtil.getBaseUserList(awardResults)); |
| | | for (LuckyActivityAwardResult info : awardResults) { |
| | | UserInfo user = userMap.get(info.getUid()); |
| | | if (user != null) { |
| | | userList.add(new SimpleUser(user.getId(), user.getNickName(), user.getPortrait())); |
| | | } |
| | | } |
| | | |
| | | |
| | | JSONObject data = new JSONObject(); |
| | | data.put("data", userList); |
| | | data.put("count", count); |
| | | return JsonUtil.loadTrueResult(data); |
| | | } |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.ks.daylucky.controller.api.client; |
| | | |
| | | import com.ks.daylucky.pojo.DO.ActivityTag; |
| | | import com.ks.daylucky.pojo.DO.UserInfo; |
| | | import com.ks.daylucky.pojo.VO.AcceptData; |
| | | import com.ks.daylucky.pojo.VO.ActivityDetailInfoVO; |
| | | import com.ks.daylucky.pojo.VO.SimpleUser; |
| | | import com.ks.daylucky.service.ActivityTagService; |
| | | import com.ks.daylucky.service.UserInfoService; |
| | | import com.ks.daylucky.util.Constant; |
| | | import com.ks.daylucky.util.UserInfoUtil; |
| | | import com.ks.lucky.pojo.DO.LuckyActivity; |
| | | import com.ks.lucky.pojo.DO.LuckyActivityJoinRecord; |
| | | import com.ks.lucky.pojo.DTO.ActivitySimpleUser; |
| | | import com.ks.lucky.remote.service.LuckyActivityJoinService; |
| | | import com.ks.lucky.remote.service.LuckyActivityService; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.ResponseBody; |
| | | import org.yeshi.utils.JsonUtil; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | @Controller |
| | | @RequestMapping("api/client/activity") |
| | | public class ActivityController { |
| | | |
| | | @Resource |
| | | private LuckyActivityService luckyActivityService; |
| | | |
| | | @Resource |
| | | private ActivityTagService activityTagService; |
| | | |
| | | @Resource |
| | | private LuckyActivityJoinService luckyActivityJoinService; |
| | | |
| | | @Resource |
| | | private UserInfoService userInfoService; |
| | | |
| | | |
| | | @ResponseBody |
| | | @RequestMapping("getActivityDetail") |
| | | public String getActivityDetail(AcceptData acceptData, Long activityId) { |
| | | |
| | | ActivityDetailInfoVO vo = new ActivityDetailInfoVO(); |
| | | |
| | | LuckyActivity actiivty = luckyActivityService.getActivityDetail(activityId); |
| | | //获取tag |
| | | List<ActivityTag> tagList = activityTagService.getTagList(activityId); |
| | | |
| | | //获取参与者数量 |
| | | long count = luckyActivityJoinService.countWeightRank(activityId); |
| | | |
| | | //获取最近的参与者列表 |
| | | List<SimpleUser> userList = new ArrayList<>(); |
| | | luckyActivityJoinService.getJoinerList(activityId, 1, 20); |
| | | List<ActivitySimpleUser> list = luckyActivityJoinService.getJoinerList(activityId, 1, Constant.PAGE_SIZE); |
| | | if (list != null && list.size() > 0) { |
| | | Map<Long, UserInfo> userInfoMap = userInfoService.listUserInfoAsMap(UserInfoUtil.getBaseUserList(list)); |
| | | for (ActivitySimpleUser info : list) { |
| | | UserInfo user = userInfoMap.get(info.getUid()); |
| | | if (user != null) { |
| | | userList.add(new SimpleUser(user.getId(), user.getNickName(), user.getPortrait())); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //获取是否参加 |
| | | LuckyActivityJoinRecord record = luckyActivityJoinService.getJoinInfo(activityId, acceptData.getApp().getId(), acceptData.getUid() + ""); |
| | | |
| | | boolean join = false; |
| | | if (record != null) { |
| | | join = true; |
| | | } |
| | | |
| | | vo.setActivity(actiivty); |
| | | vo.setJoin(join); |
| | | vo.setJoinerList(userList); |
| | | vo.setTagList(tagList); |
| | | |
| | | return JsonUtil.loadTrueResult(vo); |
| | | } |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.ks.daylucky.controller.api.client; |
| | | |
| | | import com.ks.daylucky.pojo.DO.UserInfo; |
| | | import com.ks.daylucky.pojo.VO.AcceptData; |
| | | import com.ks.daylucky.pojo.VO.ActivityJoinerRankInfoVO; |
| | | import com.ks.daylucky.pojo.VO.DrawnProbabilityVO; |
| | | import com.ks.daylucky.pojo.VO.SimpleUser; |
| | | import com.ks.daylucky.service.UserInfoService; |
| | | import com.ks.daylucky.util.Constant; |
| | | import com.ks.daylucky.util.UserInfoUtil; |
| | | import com.ks.lucky.pojo.DTO.ActivityDrawnProbabilityStatistic; |
| | | import com.ks.lucky.pojo.DTO.ActivityJoinStatisticInfo; |
| | | import com.ks.lucky.pojo.DTO.ActivityJoinerRankInfo; |
| | | import com.ks.lucky.pojo.DTO.ActivitySimpleUser; |
| | | import com.ks.lucky.remote.service.LuckyActivityJoinService; |
| | | import net.sf.json.JSONObject; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.ResponseBody; |
| | | import org.yeshi.utils.JsonUtil; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.math.BigDecimal; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | @Controller |
| | | @RequestMapping("api/client/activity/join") |
| | | public class ActivityJoinController { |
| | | |
| | | @Resource |
| | | private LuckyActivityJoinService luckyActivityJoinService; |
| | | |
| | | @Resource |
| | | private UserInfoService userInfoService; |
| | | |
| | | |
| | | /** |
| | | * 获取排行 |
| | | * |
| | | * @param acceptData |
| | | * @param activityId |
| | | * @param page |
| | | * @return |
| | | */ |
| | | @ResponseBody |
| | | @RequestMapping("getRankList") |
| | | public String getRankList(AcceptData acceptData, Long activityId, int page) { |
| | | List<ActivityJoinerRankInfoVO> voList = new ArrayList<>(); |
| | | |
| | | List<ActivityJoinerRankInfo> list = luckyActivityJoinService.getWeightRankList(activityId, page, Constant.PAGE_SIZE); |
| | | if (list != null && list.size() > 0) { |
| | | Map<Long, UserInfo> userInfoMap = userInfoService.listUserInfoAsMap(UserInfoUtil.getBaseUserList(list)); |
| | | for (ActivityJoinerRankInfo info : list) { |
| | | UserInfo user = userInfoMap.get(info.getUid()); |
| | | if (user != null) { |
| | | voList.add(new ActivityJoinerRankInfoVO(new SimpleUser(user.getId(), user.getNickName(), user.getPortrait()), info.getRank(), info.getWeight())); |
| | | } |
| | | } |
| | | } |
| | | |
| | | ActivityJoinerRankInfoVO myRank = null; |
| | | if (page == 1 && acceptData.getUid() != null) { |
| | | ActivityJoinerRankInfo rank = luckyActivityJoinService.getMyWeightRank(activityId, acceptData.getApp().getId(), acceptData.getUid() + ""); |
| | | if (rank != null) { |
| | | UserInfo user = userInfoService.getUserDetail(Long.parseLong(rank.getUid())); |
| | | myRank = new ActivityJoinerRankInfoVO(new SimpleUser(user.getId(), user.getNickName(), user.getPortrait()), rank.getRank(), rank.getWeight()); |
| | | } |
| | | } |
| | | |
| | | |
| | | long count = luckyActivityJoinService.countWeightRank(activityId); |
| | | |
| | | JSONObject data = new JSONObject(); |
| | | data.put("data", voList); |
| | | data.put("count", count); |
| | | if (myRank != null) { |
| | | data.put("myRank", myRank); |
| | | } |
| | | return JsonUtil.loadTrueResult(data); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取参与者的中奖概率 |
| | | * |
| | | * @param acceptData |
| | | * @param activityId |
| | | * @param targetUid |
| | | * @return |
| | | */ |
| | | @ResponseBody |
| | | @RequestMapping("getProbability") |
| | | public String getProbability(AcceptData acceptData, Long activityId, Long targetUid) { |
| | | ActivityDrawnProbabilityStatistic probability = luckyActivityJoinService.getActivityDrawnProbabilityStatistic(activityId, acceptData.getApp().getId(), targetUid + ""); |
| | | BigDecimal average = probability.getAverageDrawnProbability(); |
| | | BigDecimal my = probability.getMyDrawnProbability(); |
| | | |
| | | DrawnProbabilityVO vo = new DrawnProbabilityVO(); |
| | | vo.setAverage(average.multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP) + ""); |
| | | vo.setMy(my.multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP) + ""); |
| | | |
| | | |
| | | //-------计算百分比-------- |
| | | //获取我的排行 |
| | | ActivityJoinerRankInfo rank = luckyActivityJoinService.getMyWeightRank(activityId, acceptData.getApp().getId(), targetUid + ""); |
| | | //获取总人数 |
| | | long count = luckyActivityJoinService.countWeightRank(activityId); |
| | | BigDecimal percent = new BigDecimal(rank.getRank()).divide(new BigDecimal(count), 2, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100)); |
| | | vo.setPercent(percent.intValue()); |
| | | |
| | | BigDecimal offset = null; |
| | | if (average.compareTo(my) > 0) { |
| | | offset = new BigDecimal(0).subtract(average.divide(my, 2, BigDecimal.ROUND_HALF_UP)); |
| | | } else { |
| | | offset = my.divide(average, 2, BigDecimal.ROUND_HALF_UP); |
| | | } |
| | | |
| | | vo.setOffset(offset); |
| | | |
| | | return JsonUtil.loadTrueResult(vo); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取参与者列表 |
| | | * |
| | | * @param acceptData |
| | | * @param activityId |
| | | * @param page |
| | | * @return |
| | | */ |
| | | @ResponseBody |
| | | @RequestMapping("getJoinerList") |
| | | public String getJoinerList(AcceptData acceptData, Long activityId, int page) { |
| | | List<SimpleUser> voList = new ArrayList<>(); |
| | | |
| | | List<ActivitySimpleUser> list = luckyActivityJoinService.getJoinerList(activityId, page, Constant.PAGE_SIZE); |
| | | if (list != null && list.size() > 0) { |
| | | Map<Long, UserInfo> userInfoMap = userInfoService.listUserInfoAsMap(UserInfoUtil.getBaseUserList(list)); |
| | | for (ActivitySimpleUser info : list) { |
| | | UserInfo user = userInfoMap.get(info.getUid()); |
| | | if (user != null) { |
| | | voList.add(new SimpleUser(user.getId(), user.getNickName(), user.getPortrait())); |
| | | } |
| | | } |
| | | } |
| | | |
| | | JSONObject data = new JSONObject(); |
| | | if (page == 1) { |
| | | //统计信息 |
| | | ActivityJoinStatisticInfo joinerStatisticInfo = luckyActivityJoinService.getActivityJoinerStatisticInfo(activityId, acceptData.getApp().getId(), acceptData.getUid() + ""); |
| | | if (joinerStatisticInfo != null) { |
| | | data.put("statistic", joinerStatisticInfo); |
| | | } |
| | | } |
| | | |
| | | |
| | | long count = luckyActivityJoinService.countWeightRank(activityId); |
| | | |
| | | |
| | | data.put("data", voList); |
| | | data.put("count", count); |
| | | return JsonUtil.loadTrueResult(data); |
| | | } |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.ks.daylucky.controller.api.client; |
| | | |
| | | import com.ks.daylucky.pojo.VO.AcceptData; |
| | | import com.ks.daylucky.pojo.VO.ActivityLuckyCouponVO; |
| | | import com.ks.daylucky.util.Constant; |
| | | import com.ks.lucky.pojo.DO.LuckyActivityUserWeightRecord; |
| | | import com.ks.lucky.remote.service.LuckyActivityUserWeightRecordService; |
| | | import net.sf.json.JSONObject; |
| | | import org.apache.dubbo.config.annotation.Reference; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.ResponseBody; |
| | | import org.yeshi.utils.JsonUtil; |
| | | import org.yeshi.utils.TimeUtil; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 幸运券 |
| | | */ |
| | | @Controller |
| | | @RequestMapping("api/client/activity/coupon") |
| | | public class ActivityLuckyCouponController { |
| | | |
| | | @Reference |
| | | private LuckyActivityUserWeightRecordService luckyActivityUserWeightRecordService; |
| | | |
| | | |
| | | @ResponseBody |
| | | @RequestMapping("getCouponList") |
| | | public String getCouponList(AcceptData acceptData, Long activityId, int page) { |
| | | long count = luckyActivityUserWeightRecordService.countWeightRecord(activityId, acceptData.getApp().getId(), acceptData.getUid() + ""); |
| | | List<LuckyActivityUserWeightRecord> list = luckyActivityUserWeightRecordService.getWeightRecordList(activityId, acceptData.getApp().getId(), acceptData.getUid() + "", page, Constant.PAGE_SIZE); |
| | | |
| | | List<ActivityLuckyCouponVO> voList = new ArrayList<>(); |
| | | if (list != null) { |
| | | for (LuckyActivityUserWeightRecord record : list) { |
| | | voList.add(new ActivityLuckyCouponVO(record.getTitle(), record.getWeight(), TimeUtil.getGernalTime(record.getCreateTime().getTime(), "yyyy.MM.dd HH:mm"))); |
| | | } |
| | | } |
| | | JSONObject data = new JSONObject(); |
| | | data.put("data", voList); |
| | | data.put("count", count); |
| | | return JsonUtil.loadTrueResult(data); |
| | | } |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.ks.daylucky.controller.api.client; |
| | | |
| | | import com.ks.daylucky.pojo.DO.AppConfig; |
| | | import com.ks.daylucky.pojo.DTO.ConfigKeyEnum; |
| | | import com.ks.daylucky.pojo.VO.AcceptData; |
| | | import com.ks.daylucky.service.AppConfigService; |
| | | import net.sf.json.JSONObject; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.ResponseBody; |
| | | import org.yeshi.utils.JsonUtil; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | @Controller |
| | | @RequestMapping("api/client/config") |
| | | public class ConfigController { |
| | | |
| | | @Resource |
| | | private AppConfigService appConfigService; |
| | | |
| | | |
| | | @ResponseBody |
| | | @RequestMapping("getConfig") |
| | | public String getConfig(AcceptData acceptData) { |
| | | ConfigKeyEnum[] configKeyEnums = new ConfigKeyEnum[]{ |
| | | ConfigKeyEnum.newerCourse, |
| | | ConfigKeyEnum.commonQuestion |
| | | }; |
| | | JSONObject data = new JSONObject(); |
| | | for (ConfigKeyEnum key : configKeyEnums) { |
| | | AppConfig config = appConfigService.getConfigCache(acceptData.getApp().getId(), key, acceptData.getVersion()); |
| | | data.put(key.name(), config.getValue()); |
| | | } |
| | | return JsonUtil.loadTrueResult(data); |
| | | } |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.ks.daylucky.controller.api.client; |
| | | |
| | | import com.alipay.api.AlipayApiException; |
| | | import com.google.gson.Gson; |
| | | import com.google.gson.GsonBuilder; |
| | | import com.ks.app.entity.AppAlipayInfoWithBLOBs; |
| | | import com.ks.app.entity.AppInfo; |
| | | import com.ks.daylucky.exception.UserInfoException; |
| | | import com.ks.daylucky.exception.UserInfoExtraException; |
| | | import com.ks.daylucky.pojo.DO.UserInfo; |
| | | import com.ks.daylucky.pojo.DO.UserMsg; |
| | | import com.ks.daylucky.pojo.DTO.TokenDTO; |
| | | import com.ks.daylucky.pojo.DTO.UserMsgSettings; |
| | | import com.ks.daylucky.pojo.VO.AcceptData; |
| | | import com.ks.daylucky.service.UserInfoExtraService; |
| | | import com.ks.daylucky.service.UserInfoService; |
| | | import com.ks.daylucky.service.UserMsgService; |
| | | import com.ks.daylucky.util.Constant; |
| | | import com.ks.daylucky.util.UserInfoUtil; |
| | | import net.sf.json.JSONObject; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.ResponseBody; |
| | | import org.yeshi.utils.JsonUtil; |
| | | import org.yeshi.utils.StringUtil; |
| | | import org.yeshi.utils.alipay.AlipayXcxUtil; |
| | | import org.yeshi.utils.entity.alipay.AlipayAppInfo; |
| | | import org.yeshi.utils.entity.alipay.AlipayCertInfo; |
| | | import org.yeshi.utils.exception.AlipayXcxException; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.io.ByteArrayInputStream; |
| | | import java.util.List; |
| | | |
| | | @Controller |
| | | @RequestMapping("api/client/user") |
| | | public class UserController { |
| | | @Resource |
| | | private UserInfoService userInfoService; |
| | | |
| | | @Resource |
| | | private UserInfoExtraService userInfoExtraService; |
| | | |
| | | @Resource |
| | | private UserMsgService userMsgService; |
| | | |
| | | private AlipayAppInfo getAlipayAppInfo(AppInfo app) { |
| | | AppAlipayInfoWithBLOBs alipay = app.getAlipayInfo(); |
| | | AlipayAppInfo info = new AlipayAppInfo(alipay.getAlipayAppId(), alipay.getAlipayPrivateKey(), new AlipayCertInfo(new ByteArrayInputStream(alipay.getAlipayAppCertPublicKey()), new ByteArrayInputStream(alipay.getAlipayPublicCert()), new ByteArrayInputStream(alipay.getAlipayRootCert()))); |
| | | return info; |
| | | } |
| | | |
| | | @ResponseBody |
| | | @RequestMapping("getToken") |
| | | public String getToken(AcceptData acceptData, String alipayCode, String wxCode) { |
| | | //支付宝应用 |
| | | if (!StringUtil.isNullOrEmpty(alipayCode)) { |
| | | String userId = null; |
| | | try { |
| | | userId = AlipayXcxUtil.getUserId(getAlipayAppInfo(acceptData.getApp()), alipayCode); |
| | | } catch (AlipayApiException e) { |
| | | e.printStackTrace(); |
| | | } catch (AlipayXcxException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | if (userId == null) { |
| | | return JsonUtil.loadFalseResult("token获取失败"); |
| | | } |
| | | |
| | | String identifyCode = userId; |
| | | UserInfo user = userInfoService.getUserInfo(acceptData.getApp().getId(), identifyCode); |
| | | //注册 |
| | | if (user == null) { |
| | | user = new UserInfo(); |
| | | user.setAppId(acceptData.getApp().getId()); |
| | | user.setIdentifyCode(identifyCode); |
| | | try { |
| | | Long uid = userInfoService.addUserInfo(user); |
| | | user.setId(uid); |
| | | } catch (UserInfoException e) { |
| | | return JsonUtil.loadFalseResult("token获取失败"); |
| | | } |
| | | } |
| | | |
| | | TokenDTO tokenDTO = UserInfoUtil.getToken(user.getId()); |
| | | return JsonUtil.loadTrueResult(tokenDTO); |
| | | } |
| | | return JsonUtil.loadFalseResult("不为支付宝应用"); |
| | | } |
| | | |
| | | |
| | | @ResponseBody |
| | | @RequestMapping("getUserInfo") |
| | | public String getUserInfo(AcceptData acceptData) { |
| | | long uid = acceptData.getUid(); |
| | | UserInfo user = userInfoService.getUserDetail(uid); |
| | | if (user == null) { |
| | | return JsonUtil.loadFalseResult("用户不存在"); |
| | | } |
| | | return JsonUtil.loadTrueResult(JsonUtil.getApiCommonGson().toJson(user)); |
| | | } |
| | | |
| | | |
| | | @ResponseBody |
| | | @RequestMapping("setAlipayUserInfo") |
| | | public String setAlipayUserInfo(AcceptData acceptData, String portrait, String nickName) { |
| | | long uid = acceptData.getUid(); |
| | | UserInfo user = userInfoService.getUserDetail(uid); |
| | | if (user == null) { |
| | | return JsonUtil.loadFalseResult("用户不存在"); |
| | | } |
| | | UserInfo update = new UserInfo(); |
| | | update.setId(uid); |
| | | update.setPortrait(portrait); |
| | | update.setNickName(nickName); |
| | | update.setAlipayPortrait(portrait); |
| | | update.setAlipayNickName(nickName); |
| | | |
| | | userInfoService.updateUserInfo(update); |
| | | |
| | | return JsonUtil.loadTrueResult(JsonUtil.getApiCommonGson().toJson(user)); |
| | | } |
| | | |
| | | @ResponseBody |
| | | @RequestMapping("getMsgSettings") |
| | | public String getMsgSettings(AcceptData acceptData) { |
| | | UserMsgSettings msgSettings = userInfoExtraService.getUserMsgSettings(acceptData.getUid()); |
| | | return JsonUtil.loadTrueResult(JsonUtil.getApiCommonGson().toJson(msgSettings)); |
| | | } |
| | | |
| | | |
| | | @ResponseBody |
| | | @RequestMapping("setMsgSettings") |
| | | public String setMsgSettings(AcceptData acceptData, UserMsgSettings settings) { |
| | | userInfoExtraService.setUserMsgSetting(acceptData.getUid(), settings); |
| | | UserMsgSettings msgSettings = userInfoExtraService.getUserMsgSettings(acceptData.getUid()); |
| | | return JsonUtil.loadTrueResult(JsonUtil.getApiCommonGson().toJson(msgSettings)); |
| | | } |
| | | |
| | | @ResponseBody |
| | | @RequestMapping("setMsgRead") |
| | | public String setMsgRead(AcceptData acceptData) { |
| | | try { |
| | | userInfoExtraService.setMsgRead(acceptData.getUid()); |
| | | return JsonUtil.loadTrueResult(""); |
| | | } catch (UserInfoExtraException e) { |
| | | e.printStackTrace(); |
| | | return JsonUtil.loadFalseResult("设置出错"); |
| | | } |
| | | } |
| | | |
| | | |
| | | @ResponseBody |
| | | @RequestMapping("getUserMsgList") |
| | | public String getUserMsgList(AcceptData acceptData, int page) { |
| | | List<UserMsg> msgList = userMsgService.getUserMsgList(acceptData.getUid(), page, Constant.PAGE_SIZE); |
| | | long count = userMsgService.countUserMsg(acceptData.getUid()); |
| | | Gson gson = JsonUtil.getConvertDateToShortNameBuilder(new GsonBuilder().excludeFieldsWithoutExposeAnnotation()).create(); |
| | | |
| | | JSONObject data = new JSONObject(); |
| | | data.put("data", gson.toJson(msgList)); |
| | | data.put("count", count); |
| | | return JsonUtil.loadTrueResult(data); |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | import com.ks.daylucky.pojo.DO.UserInfo; |
| | | import com.ks.daylucky.query.UserInfoQuery; |
| | | import com.ks.lib.common.dao.BaseMapper; |
| | | import com.ks.lucky.pojo.DO.BaseUser; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import java.util.List; |
| | |
| | | |
| | | long count(@Param("query") UserInfoQuery query); |
| | | |
| | | |
| | | /** |
| | | * 批量获取用户详情 |
| | | * |
| | | * @param userList |
| | | * @return |
| | | */ |
| | | List<UserInfo> listUserInfo(List<BaseUser> userList); |
| | | |
| | | |
| | | } |
| | |
| | | package com.ks.daylucky.pojo.DO; |
| | | |
| | | import com.google.gson.annotations.Expose; |
| | | |
| | | import javax.validation.constraints.NotNull; |
| | | import java.util.Date; |
| | | |
| | | public class UserInfo { |
| | | @Expose |
| | | private Long id; |
| | | @Expose |
| | | @NotNull(message = "应用ID不能为空") |
| | | private Long appId; |
| | | |
| | | @Expose |
| | | @NotNull(message = "应用唯一标识不能为空") |
| | | private String identifyCode; |
| | | |
| | |
| | | |
| | | private String alipayPortrait; |
| | | |
| | | private String alipayNickName; |
| | | |
| | | private String wxOpenId; |
| | | |
| | | private String wxUnionId; |
| | |
| | | private UserInfoExtra userInfoExtra; |
| | | |
| | | |
| | | public String getAlipayNickName() { |
| | | return alipayNickName; |
| | | } |
| | | |
| | | public void setAlipayNickName(String alipayNickName) { |
| | | this.alipayNickName = alipayNickName; |
| | | } |
| | | |
| | | public UserInfoExtra getUserInfoExtra() { |
| | | return userInfoExtra; |
| | | } |
New file |
| | |
| | | package com.ks.daylucky.pojo.DTO; |
| | | |
| | | public enum ConfigKeyEnum { |
| | | |
| | | newerCourse("newer_course_url", "新手教程"), |
| | | commonQuestion("common_question_url", "常见问题"); |
| | | |
| | | private String key; |
| | | |
| | | |
| | | private ConfigKeyEnum(String key, String name) { |
| | | this.key = key; |
| | | } |
| | | |
| | | public String getKey() { |
| | | return key; |
| | | } |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.ks.daylucky.pojo.DTO; |
| | | |
| | | public class TokenDTO { |
| | | private String token; |
| | | private long expireTime; |
| | | |
| | | |
| | | public TokenDTO(String token, long expireTime) { |
| | | this.token = token; |
| | | this.expireTime = expireTime; |
| | | } |
| | | |
| | | public String getToken() { |
| | | return token; |
| | | } |
| | | |
| | | public void setToken(String token) { |
| | | this.token = token; |
| | | } |
| | | |
| | | public long getExpireTime() { |
| | | return expireTime; |
| | | } |
| | | |
| | | public void setExpireTime(long expireTime) { |
| | | this.expireTime = expireTime; |
| | | } |
| | | } |
New file |
| | |
| | | package com.ks.daylucky.pojo.DTO; |
| | | |
| | | public class TokenParseResultDTO { |
| | | |
| | | //token有效 |
| | | public final static int TOKEN_STATE_VALID = 0; |
| | | |
| | | //token错误 |
| | | public final static int TOKEN_STATE_ERROR = 1; |
| | | |
| | | //token过期 |
| | | public final static int TOKEN_STATE_OUT_DATE = 2; |
| | | private int state; |
| | | private Long uid; |
| | | |
| | | public TokenParseResultDTO(int state, Long uid) { |
| | | this.state = state; |
| | | this.uid = uid; |
| | | } |
| | | |
| | | public int getState() { |
| | | return state; |
| | | } |
| | | |
| | | public void setState(int state) { |
| | | this.state = state; |
| | | } |
| | | |
| | | public Long getUid() { |
| | | return uid; |
| | | } |
| | | |
| | | public void setUid(Long uid) { |
| | | this.uid = uid; |
| | | } |
| | | } |
| | |
| | | |
| | | public class UserMsgSettings { |
| | | |
| | | //参加抽奖 |
| | | private Boolean joinActivityMsg; |
| | | //开奖 |
| | | private Boolean openActivityMsg; |
| | | //中奖 |
| | | private Boolean drawnMsg; |
| | | //未中奖 |
| | | private Boolean notDrawnMsg; |
| | | //未开奖 |
| | | private Boolean notOpenActivityMsg; |
| | | //成功助力 |
| | | private Boolean assistSuccessMsg; |
| | | |
| | | public Boolean getJoinActivityMsg() { |
| | | return joinActivityMsg; |
| | | } |
| | | |
| | | public void setJoinActivityMsg(Boolean joinActivityMsg) { |
| | | this.joinActivityMsg = joinActivityMsg; |
| | | } |
| | | |
| | | public Boolean getOpenActivityMsg() { |
| | | return openActivityMsg; |
| | | } |
| | | |
| | | public void setOpenActivityMsg(Boolean openActivityMsg) { |
| | | this.openActivityMsg = openActivityMsg; |
| | | } |
| | | |
| | | public Boolean getDrawnMsg() { |
| | | return drawnMsg; |
| | | } |
| | | |
| | | public void setDrawnMsg(Boolean drawnMsg) { |
| | | this.drawnMsg = drawnMsg; |
| | | } |
| | | |
| | | public Boolean getNotDrawnMsg() { |
| | | return notDrawnMsg; |
| | | } |
| | | |
| | | public void setNotDrawnMsg(Boolean notDrawnMsg) { |
| | | this.notDrawnMsg = notDrawnMsg; |
| | | } |
| | | |
| | | public Boolean getNotOpenActivityMsg() { |
| | | return notOpenActivityMsg; |
| | | } |
| | | |
| | | public void setNotOpenActivityMsg(Boolean notOpenActivityMsg) { |
| | | this.notOpenActivityMsg = notOpenActivityMsg; |
| | | } |
| | | |
| | | public Boolean getAssistSuccessMsg() { |
| | | return assistSuccessMsg; |
| | | } |
| | | |
| | | public void setAssistSuccessMsg(Boolean assistSuccessMsg) { |
| | | this.assistSuccessMsg = assistSuccessMsg; |
| | | } |
| | | |
| | | @Override |
| | | public String toString() { |
| | | return new Gson().toJson(this); |
New file |
| | |
| | | package com.ks.daylucky.pojo.VO; |
| | | |
| | | import com.ks.app.entity.AppInfo; |
| | | |
| | | public class AcceptData { |
| | | private String sign; |
| | | private String appKey; |
| | | private Long timeStamp; |
| | | private Integer version; |
| | | |
| | | |
| | | /** |
| | | * 需要注入的字段 |
| | | */ |
| | | private Long uid; |
| | | private AppInfo app; |
| | | |
| | | public Long getUid() { |
| | | return uid; |
| | | } |
| | | |
| | | public void setUid(Long uid) { |
| | | this.uid = uid; |
| | | } |
| | | |
| | | public AppInfo getApp() { |
| | | return app; |
| | | } |
| | | |
| | | public void setApp(AppInfo app) { |
| | | this.app = app; |
| | | } |
| | | |
| | | public Long getTimeStamp() { |
| | | return timeStamp; |
| | | } |
| | | |
| | | public void setTimeStamp(Long timeStamp) { |
| | | this.timeStamp = timeStamp; |
| | | } |
| | | |
| | | public String getSign() { |
| | | return sign; |
| | | } |
| | | |
| | | public void setSign(String sign) { |
| | | this.sign = sign; |
| | | } |
| | | |
| | | public String getAppKey() { |
| | | return appKey; |
| | | } |
| | | |
| | | public void setAppKey(String appKey) { |
| | | this.appKey = appKey; |
| | | } |
| | | |
| | | public Integer getVersion() { |
| | | return version; |
| | | } |
| | | |
| | | public void setVersion(Integer version) { |
| | | this.version = version; |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.ks.daylucky.pojo.VO; |
| | | |
| | | import com.google.gson.annotations.Expose; |
| | | import com.ks.daylucky.pojo.DO.ActivityTag; |
| | | import com.ks.lucky.pojo.DO.LuckyActivity; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 活动详情 |
| | | */ |
| | | public class ActivityDetailInfoVO { |
| | | |
| | | @Expose |
| | | //活动信息 |
| | | private LuckyActivity activity; |
| | | |
| | | @Expose |
| | | //是否参加 |
| | | private Boolean join; |
| | | |
| | | @Expose |
| | | //参与人列表 |
| | | private List<SimpleUser> joinerList; |
| | | |
| | | @Expose |
| | | //标签列表 |
| | | private List<ActivityTag> tagList; |
| | | |
| | | public List<ActivityTag> getTagList() { |
| | | return tagList; |
| | | } |
| | | |
| | | public void setTagList(List<ActivityTag> tagList) { |
| | | this.tagList = tagList; |
| | | } |
| | | |
| | | public LuckyActivity getActivity() { |
| | | return activity; |
| | | } |
| | | |
| | | public void setActivity(LuckyActivity activity) { |
| | | this.activity = activity; |
| | | } |
| | | |
| | | public Boolean getJoin() { |
| | | return join; |
| | | } |
| | | |
| | | public void setJoin(Boolean join) { |
| | | this.join = join; |
| | | } |
| | | |
| | | public List<SimpleUser> getJoinerList() { |
| | | return joinerList; |
| | | } |
| | | |
| | | public void setJoinerList(List<SimpleUser> joinerList) { |
| | | this.joinerList = joinerList; |
| | | } |
| | | } |
New file |
| | |
| | | package com.ks.daylucky.pojo.VO; |
| | | |
| | | import com.ks.daylucky.pojo.DO.UserInfo; |
| | | |
| | | public class ActivityFriendAssistInfoVO { |
| | | |
| | | private SimpleUser user; |
| | | |
| | | private String state; |
| | | |
| | | private int count; |
| | | |
| | | public ActivityFriendAssistInfoVO(SimpleUser user, String state, int count) { |
| | | this.user = user; |
| | | this.state = state; |
| | | this.count = count; |
| | | } |
| | | |
| | | public SimpleUser getUser() { |
| | | return user; |
| | | } |
| | | |
| | | public void setUser(SimpleUser user) { |
| | | this.user = user; |
| | | } |
| | | |
| | | public String getState() { |
| | | return state; |
| | | } |
| | | |
| | | public void setState(String state) { |
| | | this.state = state; |
| | | } |
| | | |
| | | public int getCount() { |
| | | return count; |
| | | } |
| | | |
| | | public void setCount(int count) { |
| | | this.count = count; |
| | | } |
| | | } |
New file |
| | |
| | | package com.ks.daylucky.pojo.VO; |
| | | |
| | | public class ActivityJoinerRankInfoVO { |
| | | |
| | | private SimpleUser user; |
| | | //排名顺序 |
| | | private int rank; |
| | | //权重 |
| | | private int count; |
| | | |
| | | |
| | | public ActivityJoinerRankInfoVO(SimpleUser user, int rank, int count) { |
| | | this.user = user; |
| | | this.rank = rank; |
| | | this.count = count; |
| | | } |
| | | |
| | | public SimpleUser getUser() { |
| | | return user; |
| | | } |
| | | |
| | | public void setUser(SimpleUser user) { |
| | | this.user = user; |
| | | } |
| | | |
| | | public int getRank() { |
| | | return rank; |
| | | } |
| | | |
| | | public void setRank(int rank) { |
| | | this.rank = rank; |
| | | } |
| | | |
| | | public int getCount() { |
| | | return count; |
| | | } |
| | | |
| | | public void setCount(int count) { |
| | | this.count = count; |
| | | } |
| | | } |
New file |
| | |
| | | package com.ks.daylucky.pojo.VO; |
| | | |
| | | public class ActivityLuckyCouponVO { |
| | | private String title; |
| | | private int count; |
| | | private String time; |
| | | |
| | | |
| | | public ActivityLuckyCouponVO(String title, int count, String time) { |
| | | this.title = title; |
| | | this.count = count; |
| | | this.time = time; |
| | | } |
| | | |
| | | public String getTitle() { |
| | | return title; |
| | | } |
| | | |
| | | public void setTitle(String title) { |
| | | this.title = title; |
| | | } |
| | | |
| | | public int getCount() { |
| | | return count; |
| | | } |
| | | |
| | | public void setCount(int count) { |
| | | this.count = count; |
| | | } |
| | | |
| | | public String getTime() { |
| | | return time; |
| | | } |
| | | |
| | | public void setTime(String time) { |
| | | this.time = time; |
| | | } |
| | | } |
New file |
| | |
| | | package com.ks.daylucky.pojo.VO; |
| | | |
| | | import com.ks.daylucky.pojo.DO.UserInfo; |
| | | |
| | | public class AssistFriendVO { |
| | | private UserInfo user; |
| | | private int count; |
| | | |
| | | public AssistFriendVO(UserInfo user, int count) { |
| | | this.user = user; |
| | | this.count = count; |
| | | } |
| | | |
| | | public UserInfo getUser() { |
| | | return user; |
| | | } |
| | | |
| | | public void setUser(UserInfo user) { |
| | | this.user = user; |
| | | } |
| | | |
| | | public int getCount() { |
| | | return count; |
| | | } |
| | | |
| | | public void setCount(int count) { |
| | | this.count = count; |
| | | } |
| | | } |
New file |
| | |
| | | package com.ks.daylucky.pojo.VO; |
| | | |
| | | import java.math.BigDecimal; |
| | | |
| | | public class DrawnProbabilityVO { |
| | | private String average;//平均中奖概率 |
| | | private String my;//我的中奖概率 |
| | | private int percent;//百分比 |
| | | private BigDecimal offset;//与平均值相差倍数 |
| | | |
| | | |
| | | public String getAverage() { |
| | | return average; |
| | | } |
| | | |
| | | public void setAverage(String average) { |
| | | this.average = average; |
| | | } |
| | | |
| | | public String getMy() { |
| | | return my; |
| | | } |
| | | |
| | | public void setMy(String my) { |
| | | this.my = my; |
| | | } |
| | | |
| | | public int getPercent() { |
| | | return percent; |
| | | } |
| | | |
| | | public void setPercent(int percent) { |
| | | this.percent = percent; |
| | | } |
| | | |
| | | public BigDecimal getOffset() { |
| | | return offset; |
| | | } |
| | | |
| | | public void setOffset(BigDecimal offset) { |
| | | this.offset = offset; |
| | | } |
| | | } |
New file |
| | |
| | | package com.ks.daylucky.pojo.VO; |
| | | |
| | | import com.google.gson.annotations.Expose; |
| | | |
| | | public class SimpleUser { |
| | | @Expose |
| | | private Long uid; |
| | | @Expose |
| | | private String nickName; |
| | | @Expose |
| | | private String portrait; |
| | | |
| | | public SimpleUser(Long uid, String nickName, String portrait) { |
| | | this.uid = uid; |
| | | this.nickName = nickName; |
| | | this.portrait = portrait; |
| | | } |
| | | |
| | | public String getNickName() { |
| | | return nickName; |
| | | } |
| | | |
| | | public void setNickName(String nickName) { |
| | | this.nickName = nickName; |
| | | } |
| | | |
| | | public String getPortrait() { |
| | | return portrait; |
| | | } |
| | | |
| | | public void setPortrait(String portrait) { |
| | | this.portrait = portrait; |
| | | } |
| | | |
| | | public Long getUid() { |
| | | return uid; |
| | | } |
| | | |
| | | public void setUid(Long uid) { |
| | | this.uid = uid; |
| | | } |
| | | } |
New file |
| | |
| | | package com.ks.daylucky.service; |
| | | |
| | | public interface ActivityService { |
| | | |
| | | |
| | | |
| | | } |
| | |
| | | import com.beust.jcommander.ParameterException; |
| | | import com.ks.daylucky.exception.AppConfigException; |
| | | import com.ks.daylucky.pojo.DO.AppConfig; |
| | | import com.ks.daylucky.pojo.DTO.ConfigKeyEnum; |
| | | import com.ks.daylucky.query.AppConfigQuery; |
| | | |
| | | import javax.validation.Valid; |
| | |
| | | * @param version |
| | | * @return |
| | | */ |
| | | public AppConfig getConfig(Long appId, String key, Integer version); |
| | | public AppConfig getConfig(Long appId, ConfigKeyEnum key, Integer version); |
| | | |
| | | |
| | | /** |
| | |
| | | * @param version |
| | | * @return |
| | | */ |
| | | public AppConfig getConfigCache(Long appId, String key, Integer version); |
| | | public AppConfig getConfigCache(Long appId, ConfigKeyEnum key, Integer version); |
| | | |
| | | |
| | | /** |
| | |
| | | import com.ks.daylucky.exception.UserInfoException; |
| | | import com.ks.daylucky.pojo.DO.UserInfo; |
| | | import com.ks.daylucky.query.UserInfoQuery; |
| | | import com.ks.lucky.pojo.DO.BaseUser; |
| | | |
| | | import javax.validation.Valid; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | public interface UserInfoService { |
| | | |
| | |
| | | * @throws UserInfoException |
| | | */ |
| | | public Long addUserInfo(@Valid UserInfo userInfo) throws ParameterException, UserInfoException; |
| | | |
| | | public Map<Long,UserInfo> listUserInfoAsMap(BaseUser... users); |
| | | |
| | | |
| | | /** |
| | |
| | | public void updateUserInfo(UserInfo userInfo); |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | |
| | | AppInfo info = appService.getAppDetail(appId); |
| | | return info; |
| | | } |
| | | |
| | | public AppInfo getAppDetail(String appKey) { |
| | | AppInfo info = appService.getAppDetail(appKey); |
| | | return info; |
| | | } |
| | | |
| | | } |
| | |
| | | import com.ks.daylucky.exception.AppConfigException; |
| | | import com.ks.daylucky.mapper.AppConfigMapper; |
| | | import com.ks.daylucky.pojo.DO.AppConfig; |
| | | import com.ks.daylucky.pojo.DTO.ConfigKeyEnum; |
| | | import com.ks.daylucky.query.AppConfigQuery; |
| | | import com.ks.daylucky.service.AppConfigService; |
| | | import org.apache.dubbo.config.annotation.Service; |
| | |
| | | } |
| | | |
| | | @Override |
| | | public AppConfig getConfig(Long appId, String key, Integer version) { |
| | | public AppConfig getConfig(Long appId, ConfigKeyEnum key, Integer version) { |
| | | AppConfigQuery query = new AppConfigQuery(); |
| | | query.appId = appId; |
| | | query.key = key; |
| | | query.key = key.getKey(); |
| | | query.version = version; |
| | | |
| | | List<AppConfig> list = appConfigMapper.list(query); |
| | |
| | | } |
| | | |
| | | @Override |
| | | public AppConfig getConfigCache(Long appId, String key, Integer version) { |
| | | public AppConfig getConfigCache(Long appId, ConfigKeyEnum key, Integer version) { |
| | | return getConfig(appId, key, version); |
| | | } |
| | | |
| | |
| | | |
| | | @Override |
| | | public void setUserMsgSetting(Long uid, UserMsgSettings setting) { |
| | | UserMsgSettings old = getUserMsgSettings(uid); |
| | | //设置已经设置的 |
| | | if (setting.getAssistSuccessMsg() != null) { |
| | | old.setAssistSuccessMsg(setting.getAssistSuccessMsg()); |
| | | } |
| | | |
| | | if (setting.getDrawnMsg() != null) { |
| | | old.setDrawnMsg(setting.getDrawnMsg()); |
| | | } |
| | | |
| | | if (setting.getJoinActivityMsg() != null) { |
| | | old.setJoinActivityMsg(setting.getJoinActivityMsg()); |
| | | } |
| | | |
| | | if (setting.getNotDrawnMsg() != null) { |
| | | old.setNotDrawnMsg(setting.getNotDrawnMsg()); |
| | | } |
| | | |
| | | if (setting.getNotOpenActivityMsg() != null) { |
| | | old.setNotOpenActivityMsg(setting.getNotOpenActivityMsg()); |
| | | } |
| | | |
| | | if (setting.getOpenActivityMsg() != null) { |
| | | old.setOpenActivityMsg(setting.getOpenActivityMsg()); |
| | | } |
| | | |
| | | |
| | | UserInfoExtra extra = new UserInfoExtra(); |
| | | extra.setUid(uid); |
| | | extra.setMsgSetting(setting.toString()); |
| | | extra.setMsgSetting(old.toString()); |
| | | extra.setUpdateTime(new Date()); |
| | | userInfoExtraMapper.updateByPrimaryKeySelective(extra); |
| | | } |
| | |
| | | import com.ks.daylucky.query.UserInfoQuery; |
| | | import com.ks.daylucky.service.UserInfoExtraService; |
| | | import com.ks.daylucky.service.UserInfoService; |
| | | import com.ks.lucky.pojo.DO.BaseUser; |
| | | import org.apache.dubbo.config.annotation.Service; |
| | | import org.springframework.validation.annotation.Validated; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.validation.Valid; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.*; |
| | | |
| | | @Service(version = "1.0.0") |
| | | public class UserInfoServiceImpl implements UserInfoService { |
| | |
| | | return userInfo.getId(); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public Map<Long, UserInfo> listUserInfoAsMap(BaseUser... users) { |
| | | List<UserInfo> list = userInfoMapper.listUserInfo(Arrays.asList(users)); |
| | | Map<Long, UserInfo> map = new HashMap<>(); |
| | | if (list != null) { |
| | | for (UserInfo userInfo : list) { |
| | | map.put(userInfo.getId(), userInfo); |
| | | } |
| | | } |
| | | return map; |
| | | } |
| | | |
| | | @Override |
| | | public List<UserInfo> getUserList(UserInfoQuery query, int page, int pageSize) { |
| | | query.start = (page - 1) * pageSize; |
New file |
| | |
| | | package com.ks.daylucky.util; |
| | | |
| | | public class ApiCodeConstant { |
| | | |
| | | //签名错误 |
| | | public final static int CODE_SIGN_ERROR = 101; |
| | | |
| | | //应用不存在 |
| | | public final static int CODE_APP_NOT_EXIST = 201; |
| | | |
| | | } |
New file |
| | |
| | | package com.ks.daylucky.util; |
| | | |
| | | public class Constant { |
| | | public final static int PAGE_SIZE = 20; |
| | | } |
| | |
| | | package com.ks.daylucky.util; |
| | | |
| | | import com.ks.daylucky.pojo.DO.UserInfo; |
| | | import com.ks.daylucky.pojo.DTO.TokenDTO; |
| | | import com.ks.daylucky.pojo.DTO.TokenParseResultDTO; |
| | | import com.ks.lucky.pojo.DO.BaseUser; |
| | | import org.yeshi.utils.StringUtil; |
| | | import org.yeshi.utils.encrypt.AESUtil; |
| | | |
| | | import java.util.List; |
| | | |
| | | public class UserInfoUtil { |
| | | |
| | | private final static String TOKEN_KEY = "@2020_Ks@8#8"; |
| | | |
| | | |
| | | /** |
| | | * 获取用户唯一标识 |
| | |
| | | return null; |
| | | } |
| | | |
| | | public static TokenDTO getToken(Long uid) { |
| | | //用户ID#到期时间戳 |
| | | //有效期为12小时 |
| | | long expireTime = System.currentTimeMillis() + 1000 * 60 * 60L * 12; |
| | | String tokenSource = String.format("%s#%s", uid + "", expireTime); |
| | | return new TokenDTO(AESUtil.encrypt(tokenSource, TOKEN_KEY), expireTime); |
| | | } |
| | | |
| | | /** |
| | | * 获取token的状态 |
| | | * |
| | | * @param token |
| | | * @return |
| | | */ |
| | | public static TokenParseResultDTO parseToken(String token) { |
| | | String result = AESUtil.decrypt(token, TOKEN_KEY); |
| | | if (StringUtil.isNullOrEmpty(result)) { |
| | | return new TokenParseResultDTO(TokenParseResultDTO.TOKEN_STATE_ERROR, null); |
| | | } |
| | | long time = Long.parseLong(result.split("#")[1]); |
| | | long uid = Long.parseLong(result.split("#")[0]); |
| | | |
| | | if (time < System.currentTimeMillis()) { |
| | | return new TokenParseResultDTO(TokenParseResultDTO.TOKEN_STATE_OUT_DATE, null); |
| | | } |
| | | |
| | | return new TokenParseResultDTO(TokenParseResultDTO.TOKEN_STATE_VALID, uid); |
| | | } |
| | | |
| | | public static BaseUser[] getBaseUserList(List<? extends BaseUser> list) { |
| | | BaseUser[] users = new BaseUser[list.size()]; |
| | | list.toArray(users); |
| | | return users; |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | <!--enableDeleteByExample="false" enableSelectByExample="false"--> |
| | | <!--selectByExampleQueryId="false"></table>--> |
| | | |
| | | <table schema="" domainObjectName="" tableName=""></table> |
| | | |
| | | |
| | | </context> |
| | | |
| | |
| | | limit #{query.start},#{query.count} |
| | | </select> |
| | | |
| | | |
| | | <select id="listUserInfo" resultMap="BaseResultMap"> |
| | | select |
| | | <include refid="Base_Column_List"/> |
| | | from user_info |
| | | where 1=1 |
| | | <foreach collection="userList" item="user" open=" and (" close=")" separator=" or "> |
| | | #{user.uid}=id and app_id=#{user.appId} |
| | | </foreach> |
| | | </select> |
| | | |
| | | |
| | | <select id="count" resultType="java.lang.Long"> |
| | | select |
| | | count(*) |
| | |
| | | <name>service-lucky</name> |
| | | <description>抽奖服务</description> |
| | | |
| | | <packaging>war</packaging> |
| | | <packaging>jar</packaging> |
| | | |
| | | <properties> |
| | | <java.version>1.8</java.version> |
| | |
| | | int setStateByActivityId(@Param("activityId") Long activityId, @Param("state") Integer state, @Param("stateDesc") String stateDesc, @Param("updateTime") Date updateTime); |
| | | |
| | | |
| | | List<LuckyActivityAwardResult> listUserAwardResult(@Param("appId") Long appId, @Param("uid") Long uid, @Param("stateList") List<Integer> stateList, @Param("activityStateList") List<Integer> activityStateList, long start, int count); |
| | | |
| | | long countUserAwardResult(@Param("appId") Long appId, @Param("uid") Long uid, @Param("stateList") List<Integer> stateList, @Param("activityStateList") List<Integer> activityStateList); |
| | | |
| | | } |
| | |
| | | |
| | | import com.ks.lib.common.dao.BaseMapper; |
| | | import com.ks.lucky.pojo.DO.LuckyActivityJoinAssist; |
| | | import com.ks.lucky.pojo.DTO.ActivityAssistFriend; |
| | | import com.ks.lucky.pojo.DTO.ActivityFriendAssistInfo; |
| | | import com.ks.lucky.query.ActivityJoinAssistQuery; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | |
| | | List<LuckyActivityJoinAssist> list(@Param("query")ActivityJoinAssistQuery query); |
| | | |
| | | long count(@Param("query")ActivityJoinAssistQuery query); |
| | | |
| | | |
| | | /** |
| | | * 获取助力过你的好友 |
| | | * |
| | | * @param appId |
| | | * @param targetUid |
| | | * @param start |
| | | * @param count |
| | | * @return |
| | | */ |
| | | List<ActivityAssistFriend> listAssistFriends(@Param("appId") Long appId, @Param("targetUid") String targetUid, @Param("start") long start, @Param("count") int count); |
| | | |
| | | long countAssistFriends(@Param("appId") Long appId, @Param("targetUid") String targetUid); |
| | | |
| | | |
| | | /** |
| | | * 获取好友助力信息 |
| | | * |
| | | * @param joinId |
| | | * @param start |
| | | * @param count |
| | | * @return |
| | | */ |
| | | List<ActivityFriendAssistInfo> listActivityFriendAssistInfo(@Param("joinId") Long joinId, @Param("start") long start, @Param("count") int count); |
| | | |
| | | long countActivityFriendAssistInfo(@Param("joinId") Long joinId); |
| | | |
| | | } |
| | |
| | | |
| | | import com.ks.lib.common.dao.BaseMapper; |
| | | import com.ks.lucky.pojo.DO.LuckyActivityJoinRecord; |
| | | import com.ks.lucky.pojo.DTO.ActivityJoinerRankInfo; |
| | | import com.ks.lucky.query.ActivityJoinRecordQuery; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | |
| | | void addWeight(@Param("id") Long id,@Param("weight") int weight); |
| | | |
| | | |
| | | int updateSelectiveWithQuery(LuckyActivityJoinRecord record, ActivityJoinRecordQuery query); |
| | | |
| | | |
| | | List<LuckyActivityJoinRecord> listWithActivityState(@Param("query") ActivityJoinRecordQuery query, @Param("activityStateList") List<Integer> activityStateList); |
| | | |
| | | long countWithActivityState(@Param("query") ActivityJoinRecordQuery query, @Param("activityStateList") List<Integer> activityStateList); |
| | | |
| | | |
| | | /** |
| | | * 获取参与者的位置 |
| | | * |
| | | * @param activityId |
| | | * @param appId |
| | | * @param uid |
| | | * @return |
| | | */ |
| | | int getJoinerPosition(@Param("activityId") Long activityId, @Param("appId") Long appId, @Param("uid") String uid); |
| | | |
| | | |
| | | /** |
| | | * 统计权重 |
| | | * |
| | | * @param activityId |
| | | * @return |
| | | */ |
| | | Long sumWeight(@Param("activityId") Long activityId); |
| | | |
| | | |
| | | /** |
| | | * 排序列表 |
| | | * @param activityId |
| | | * @param start |
| | | * @param count |
| | | * @return |
| | | */ |
| | | List<ActivityJoinerRankInfo> listWeightRank(@Param("activityId") Long activityId, @Param("start") long start, @Param("count") int count); |
| | | |
| | | long countWeightRank(@Param("activityId") Long activityId); |
| | | |
| | | /** |
| | | * 获取某个记录的排序 |
| | | * |
| | | * @param record |
| | | * @return |
| | | */ |
| | | int getWeightRankWithRecord(LuckyActivityJoinRecord record); |
| | | } |
New file |
| | |
| | | package com.ks.lucky.mapper; |
| | | |
| | | import com.ks.lib.common.dao.BaseMapper; |
| | | import com.ks.lucky.pojo.DO.LuckyActivityUserWeightRecord; |
| | | import com.ks.lucky.query.ActivityUserWeightRecordQuery; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import java.util.List; |
| | | |
| | | public interface LuckyActivityUserWeightRecordMapper extends BaseMapper<LuckyActivityUserWeightRecord> { |
| | | |
| | | List<LuckyActivityUserWeightRecord> list(@Param("query") ActivityUserWeightRecordQuery query); |
| | | |
| | | long count(@Param("query") ActivityUserWeightRecordQuery query); |
| | | |
| | | } |
| | |
| | | package com.ks.lucky.query; |
| | | |
| | | import com.ks.lucky.pojo.DO.LuckyActivityJoinAssist; |
| | | |
| | | public class ActivityJoinAssistQuery extends BaseDaoQuery { |
| | | public Long joinId; |
| | | public Long appId; |
| | | public String uid; |
| | | public LuckyActivityJoinAssist.ActivityJoinAssistEvent eventKey; |
| | | } |
| | |
| | | package com.ks.lucky.query; |
| | | |
| | | import java.util.List; |
| | | |
| | | public class ActivityJoinRecordQuery extends BaseDaoQuery { |
| | | public Long activityId; |
| | | public Long appId; |
| | | public String uid; |
| | | //中奖状态 |
| | | public List<Integer> drawStateList; |
| | | } |
New file |
| | |
| | | package com.ks.lucky.query; |
| | | |
| | | public class ActivityUserWeightRecordQuery extends BaseDaoQuery { |
| | | public Long activityId; |
| | | public Long appId; |
| | | public String uid; |
| | | } |
| | |
| | | private LuckyActivityAwardResultExtraMapper luckyActivityAwardResultExtraMapper; |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * 添加记录 |
| | | * |
| | |
| | | package com.ks.lucky.service.impl; |
| | | |
| | | import com.ks.lucky.exception.LuckyActivityAwardException; |
| | | import com.ks.lucky.mapper.LuckyActivityAwardResultMapper; |
| | | import com.ks.lucky.mapper.LuckyActivityAwardsMapper; |
| | | import com.ks.lucky.mapper.LuckyActivityJoinRecordMapper; |
| | | import com.ks.lucky.pojo.DO.LuckyActivityAwardMaterial; |
| | | import com.ks.lucky.pojo.DO.LuckyActivityAwardResult; |
| | | import com.ks.lucky.pojo.DO.LuckyActivityAwards; |
| | | import com.ks.lucky.pojo.DO.LuckyActivityJoinRecord; |
| | | import com.ks.lucky.query.ActivityAwardQuery; |
| | | import com.ks.lucky.query.ActivityAwardResultQuery; |
| | | import com.ks.lucky.query.ActivityJoinRecordQuery; |
| | | import com.ks.lucky.remote.service.LuckyActivityAwardService; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.yeshi.utils.StringUtil; |
| | |
| | | @Resource |
| | | private LuckyActivityJoinRecordMapper luckyActivityJoinRecordMapper; |
| | | |
| | | @Resource |
| | | private LuckyActivityAwardResultMapper luckyActivityAwardResultMapper; |
| | | |
| | | |
| | | public LuckyActivityJoinRecord getRecord(Long activityId, Long appId, String uid) { |
| | | ActivityJoinRecordQuery query = new ActivityJoinRecordQuery(); |
| | |
| | | |
| | | /** |
| | | * 获取参与数据 |
| | | * |
| | | * @param activityId |
| | | * @return |
| | | */ |
| | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 设置所有的参与者未中奖 |
| | | * |
| | | * @param activityId |
| | | */ |
| | | public void setActivityAllJoinerUnDraw(Long activityId) { |
| | | ActivityJoinRecordQuery query = new ActivityJoinRecordQuery(); |
| | | query.activityId = activityId; |
| | | LuckyActivityJoinRecord record = new LuckyActivityJoinRecord(); |
| | | record.setUpdateTime(new Date()); |
| | | record.setDrawState(LuckyActivityJoinRecord.DRAW_STATE_NOT_DRAWN); |
| | | luckyActivityJoinRecordMapper.updateSelectiveWithQuery(record, query); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 设置已经中奖的参与记录为中奖 |
| | | * |
| | | * @param activityId |
| | | */ |
| | | public void setActivityDrawnJoinerState(Long activityId) { |
| | | //查询中奖记录 |
| | | ActivityAwardResultQuery query = new ActivityAwardResultQuery(); |
| | | query.activityId = activityId; |
| | | long count = luckyActivityAwardResultMapper.count(query); |
| | | //分页查询 |
| | | int pageSize = 200; |
| | | int totalPage = (int) (count % pageSize == 0 ? count / pageSize : count / pageSize + 1); |
| | | |
| | | for (int page = 0; page < totalPage; page++) { |
| | | query.start = page * pageSize; |
| | | query.count = pageSize; |
| | | //查询出中奖记录 |
| | | List<LuckyActivityAwardResult> list = luckyActivityAwardResultMapper.list(query); |
| | | for (LuckyActivityAwardResult result : list) { |
| | | ActivityJoinRecordQuery recordQuery = new ActivityJoinRecordQuery(); |
| | | recordQuery.activityId = activityId; |
| | | recordQuery.appId = result.getAppId(); |
| | | recordQuery.uid = result.getUid(); |
| | | recordQuery.count = 1; |
| | | //查询中奖记录对应的参与记录 |
| | | List<LuckyActivityJoinRecord> recordList = luckyActivityJoinRecordMapper.list(recordQuery); |
| | | if (recordList != null && recordList.size() > 0) { |
| | | LuckyActivityJoinRecord record = new LuckyActivityJoinRecord(); |
| | | record.setId(recordList.get(0).getId()); |
| | | record.setDrawState(LuckyActivityJoinRecord.DRAW_STATE_DRAWN); |
| | | record.setUpdateTime(new Date()); |
| | | //修改参与记录的状态的已中奖 |
| | | luckyActivityJoinRecordMapper.updateByPrimaryKeySelective(record); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.ks.lucky.service.impl; |
| | | |
| | | import com.ks.lib.common.exception.ParamsException; |
| | | import com.ks.lucky.mapper.LuckyActivityUserWeightRecordMapper; |
| | | import com.ks.lucky.pojo.DO.LuckyActivityUserWeightRecord; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.validation.annotation.Validated; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.validation.Valid; |
| | | import java.util.Date; |
| | | |
| | | @Component |
| | | public class LuckyActivityUserWeightRecordManager { |
| | | |
| | | @Resource |
| | | private LuckyActivityUserWeightRecordMapper luckyActivityUserWeightRecordMapper; |
| | | |
| | | |
| | | @Validated |
| | | public void addRecord(@Valid LuckyActivityUserWeightRecord record) throws ParamsException { |
| | | |
| | | if (record.getCreateTime() != null) { |
| | | record.setCreateTime(new Date()); |
| | | } |
| | | luckyActivityUserWeightRecordMapper.insertSelective(record); |
| | | } |
| | | |
| | | } |
| | |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | @Service(version = "1.0") |
| | |
| | | private LuckyActivityAwardResultManager luckyActivityAwardResultManager; |
| | | |
| | | @Resource |
| | | private AppManager appManager; |
| | | |
| | | @Resource |
| | | private LuckyActivityManager luckyActivityManager; |
| | | |
| | | |
| | | @Override |
| | | public LuckyActivityAwardResult getResult(String appKey, String uid, Long activityId, Long awardId) { |
| | | Long appId = appManager.getAppId(appKey); |
| | | public LuckyActivityAwardResult getResult(Long appId, String uid, Long activityId, Long awardId) { |
| | | if (appId == null) { |
| | | return null; |
| | | } |
| | |
| | | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @Override |
| | | public void recieveAward(String appKey, String uid, Long activityId) throws LuckyActivityException, LuckyActivityAwardException, LuckyActivityAwardResultException { |
| | | public void recieveAward(Long appId, String uid, Long activityId) throws LuckyActivityException, LuckyActivityAwardException, LuckyActivityAwardResultException { |
| | | //----------验证开始----------- |
| | | Long appId = appManager.getAppId(appKey); |
| | | LuckyActivity activity = luckyActivityManager.selectByPrimaryKey(activityId); |
| | | if (activity == null) { |
| | | //不存在 |
| | |
| | | //发奖 |
| | | luckyActivityAwardResultManager.sendAward(result, extra); |
| | | } |
| | | |
| | | @Override |
| | | public List<Long> getDrawnActivityIdList(Long appId, Long uid, int page, int pageSize) { |
| | | List<LuckyActivityAwardResult> list = luckyActivityAwardResultMapper.listUserAwardResult(appId, uid, Arrays.asList(new Integer[]{LuckyActivityAwardResult.STATE_NOT_RECIEVE, LuckyActivityAwardResult.STATE_RECIEVED, LuckyActivityAwardResult.STATE_OUT_OF_DATE, LuckyActivityAwardResult.STATE_RECIEVE_FAILED}), Arrays.asList(new Integer[]{LuckyActivity.STATE_OPENED}), (page - 1) * pageSize, pageSize); |
| | | List<Long> activityIdList = new ArrayList<>(); |
| | | if (list != null) { |
| | | for (LuckyActivityAwardResult result : list) { |
| | | activityIdList.add(result.getActivityId()); |
| | | } |
| | | } |
| | | return activityIdList; |
| | | } |
| | | |
| | | @Override |
| | | public long countDrawnActivityIdList(Long appId, Long uid) { |
| | | return luckyActivityAwardResultMapper.countUserAwardResult(appId, uid, Arrays.asList(new Integer[]{LuckyActivityAwardResult.STATE_NOT_RECIEVE, LuckyActivityAwardResult.STATE_RECIEVED, LuckyActivityAwardResult.STATE_OUT_OF_DATE, LuckyActivityAwardResult.STATE_RECIEVE_FAILED}), Arrays.asList(new Integer[]{LuckyActivity.STATE_OPENED})); |
| | | } |
| | | |
| | | @Override |
| | | public List<LuckyActivityAwardResult> getResultListWithAwardInfo(Long activityId, Long awardId, int page, int pageSize) { |
| | | ActivityAwardResultQuery query = new ActivityAwardResultQuery(); |
| | | query.activityId = activityId; |
| | | query.awardId = awardId; |
| | | query.start = (page - 1) * pageSize; |
| | | query.count = pageSize; |
| | | return luckyActivityAwardResultMapper.list(query); |
| | | } |
| | | |
| | | @Override |
| | | public long countResultWithAwardInfo(Long activityId, Long awardId) { |
| | | ActivityAwardResultQuery query = new ActivityAwardResultQuery(); |
| | | query.activityId = activityId; |
| | | query.awardId = awardId; |
| | | |
| | | return luckyActivityAwardResultMapper.count(query); |
| | | } |
| | | |
| | | @Override |
| | | public Date getLatestUpdateTime(Long activityId) { |
| | | ActivityAwardResultQuery query = new ActivityAwardResultQuery(); |
| | | query.activityId = activityId; |
| | | query.count = 1; |
| | | query.sortList = Arrays.asList(new String[]{"update_time desc"}); |
| | | |
| | | List<LuckyActivityAwardResult> list = luckyActivityAwardResultMapper.list(query); |
| | | if (list == null || list.size() == 0) { |
| | | return null; |
| | | } |
| | | return list.get(0).getUpdateTime() == null ? list.get(0).getCreateTime() : list.get(0).getUpdateTime(); |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | package com.ks.lucky.service.impl.remote; |
| | | |
| | | import com.ks.lib.common.exception.ParamsException; |
| | | import com.ks.lucky.exception.LuckyActivityException; |
| | | import com.ks.lucky.exception.LuckyActivityJoinAssistException; |
| | | import com.ks.lucky.mapper.LuckyActivityJoinAssistMapper; |
| | |
| | | import com.ks.lucky.pojo.DO.LuckyActivity; |
| | | import com.ks.lucky.pojo.DO.LuckyActivityJoinAssist; |
| | | import com.ks.lucky.pojo.DO.LuckyActivityJoinRecord; |
| | | import com.ks.lucky.pojo.DO.LuckyActivityUserWeightRecord; |
| | | import com.ks.lucky.pojo.DTO.ActivityAssistFriend; |
| | | import com.ks.lucky.pojo.DTO.ActivityFriendAssistInfo; |
| | | import com.ks.lucky.query.ActivityJoinAssistQuery; |
| | | import com.ks.lucky.remote.service.LuckyActivityJoinAssistService; |
| | | import com.ks.lucky.service.impl.AppManager; |
| | | import com.ks.lucky.service.impl.LuckyActivityJoinManager; |
| | | import com.ks.lucky.service.impl.LuckyActivityUserWeightRecordManager; |
| | | import com.ks.lucky.util.factory.LuckyActivityUserWeightRecordFactory; |
| | | import org.apache.dubbo.config.annotation.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.validation.annotation.Validated; |
| | |
| | | private LuckyActivityJoinAssistMapper luckyActivityJoinAssistMapper; |
| | | |
| | | @Resource |
| | | private AppManager appManager; |
| | | private LuckyActivityUserWeightRecordManager luckyActivityUserWeightRecordManager; |
| | | |
| | | @Resource |
| | | private LuckyActivityJoinRecordMapper luckyActivityJoinRecordMapper; |
| | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @Validated |
| | | @Override |
| | | public void assist(Long activityId, String appKey, String uid, String targetUid) throws LuckyActivityException, LuckyActivityJoinAssistException { |
| | | public void assist(Long activityId, Long appId, String uid, String targetUid, LuckyActivityJoinAssist.ActivityJoinAssistEvent eventKey, int weight) throws LuckyActivityException, LuckyActivityJoinAssistException { |
| | | |
| | | if (uid.equalsIgnoreCase(targetUid)) { |
| | | throw new LuckyActivityJoinAssistException(1, "不能为自己助力"); |
| | |
| | | } |
| | | |
| | | |
| | | Long appId = appManager.getAppId(appKey); |
| | | |
| | | LuckyActivityJoinRecord record = luckyActivityJoinManager.getRecord(activityId, appId, targetUid); |
| | | |
| | | if (record == null) { |
| | |
| | | query.joinId = record.getId(); |
| | | query.appId = appId; |
| | | query.uid = uid; |
| | | query.eventKey = eventKey; |
| | | query.start = 0; |
| | | query.count = 1; |
| | | List<LuckyActivityJoinAssist> list = luckyActivityJoinAssistMapper.list(query); |
| | |
| | | assist.setCreateTime(new Date()); |
| | | assist.setJoinId(record.getId()); |
| | | assist.setUid(uid); |
| | | assist.setWeight(1); |
| | | assist.setWeight(weight); |
| | | assist.setEventKey(eventKey); |
| | | luckyActivityJoinRecordMapper.addWeight(record.getId(), assist.getWeight()); |
| | | luckyActivityJoinAssistMapper.insertSelective(assist); |
| | | |
| | | |
| | | LuckyActivityUserWeightRecord weightRecord = LuckyActivityUserWeightRecordFactory.createAssist(activityId, appId, uid, eventKey, weight); |
| | | try { |
| | | luckyActivityUserWeightRecordManager.addRecord(weightRecord); |
| | | } catch (ParamsException e) { |
| | | throw new LuckyActivityJoinAssistException(1, "添加记录出错"); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public List<LuckyActivityJoinAssist> getAssistRecordList(Long activityId, String appKey, String uid, int page, int pageSize) { |
| | | Long appId = appManager.getAppId(appKey); |
| | | public List<LuckyActivityJoinAssist> getAssistRecordList(Long activityId, Long appId, String uid, int page, int pageSize) { |
| | | LuckyActivityJoinRecord record = luckyActivityJoinManager.getRecord(activityId, appId, uid); |
| | | if (record == null) { |
| | | return null; |
| | |
| | | } |
| | | |
| | | @Override |
| | | public long countAssistRecord(Long activityId, String appKey, String uid) { |
| | | Long appId = appManager.getAppId(appKey); |
| | | public long countAssistRecord(Long activityId, Long appId, String uid) { |
| | | LuckyActivityJoinRecord record = luckyActivityJoinManager.getRecord(activityId, appId, uid); |
| | | if (record == null) { |
| | | return 0L; |
| | |
| | | |
| | | return luckyActivityJoinAssistMapper.count(query); |
| | | } |
| | | |
| | | @Override |
| | | public List<ActivityAssistFriend> getAssistFriendsList(Long appId, String targetUid, int page, int pageSize) { |
| | | return luckyActivityJoinAssistMapper.listAssistFriends(appId, targetUid, (page - 1) * pageSize, pageSize); |
| | | } |
| | | |
| | | @Override |
| | | public long countAssistFriends(Long appId, String targetUid) { |
| | | return luckyActivityJoinAssistMapper.countAssistFriends(appId, targetUid); |
| | | } |
| | | |
| | | @Override |
| | | public List<ActivityFriendAssistInfo> getActivityFriendAssistInfoList(Long activityId, Long appId, String uid, int page, int pageSize) { |
| | | LuckyActivityJoinRecord record = luckyActivityJoinManager.getRecord(activityId, appId, uid); |
| | | if (record == null) { |
| | | return null; |
| | | } |
| | | return luckyActivityJoinAssistMapper.listActivityFriendAssistInfo(record.getId(), (page - 1) * pageSize, pageSize); |
| | | } |
| | | |
| | | @Override |
| | | public long countyActivityFriendAssistInfo(Long activityId, Long appId, String uid) { |
| | | LuckyActivityJoinRecord record = luckyActivityJoinManager.getRecord(activityId, appId, uid); |
| | | if (record == null) { |
| | | return 0L; |
| | | } |
| | | return luckyActivityJoinAssistMapper.countActivityFriendAssistInfo(record.getId()); |
| | | } |
| | | } |
| | |
| | | package com.ks.lucky.service.impl.remote; |
| | | |
| | | import com.ks.lib.common.exception.ParamsException; |
| | | import com.ks.lucky.exception.LuckyActivityException; |
| | | import com.ks.lucky.exception.LuckyActivityJoinException; |
| | | import com.ks.lucky.mapper.LuckyActivityAwardsMapper; |
| | | import com.ks.lucky.mapper.LuckyActivityJoinRecordMapper; |
| | | import com.ks.lucky.pojo.DO.LuckyActivity; |
| | | import com.ks.lucky.pojo.DO.LuckyActivityAwards; |
| | | import com.ks.lucky.pojo.DO.LuckyActivityJoinRecord; |
| | | import com.ks.lucky.pojo.DTO.JoinInfo; |
| | | import com.ks.lucky.pojo.DO.LuckyActivityUserWeightRecord; |
| | | import com.ks.lucky.pojo.DTO.*; |
| | | import com.ks.lucky.query.ActivityAwardQuery; |
| | | import com.ks.lucky.query.ActivityJoinRecordQuery; |
| | | import com.ks.lucky.remote.service.LuckyActivityJoinService; |
| | | import com.ks.lucky.service.impl.AppManager; |
| | | import com.ks.lucky.service.impl.LuckyActivityJoinManager; |
| | | import com.ks.lucky.service.impl.LuckyActivityManager; |
| | | import com.ks.lucky.service.impl.LuckyActivityUserWeightRecordManager; |
| | | import com.ks.lucky.util.factory.LuckyActivityUserWeightRecordFactory; |
| | | import org.apache.dubbo.config.annotation.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.yeshi.utils.StringUtil; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.math.BigDecimal; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | @Service(version = "1.0") |
| | | public class LuckyActivityJoinServiceImpl implements LuckyActivityJoinService { |
| | |
| | | private LuckyActivityManager luckyActivityManager; |
| | | |
| | | @Resource |
| | | private AppManager appManager; |
| | | private LuckyActivityUserWeightRecordManager luckyActivityUserWeightRecordManager; |
| | | |
| | | @Resource |
| | | private LuckyActivityJoinRecordMapper luckyActivityJoinRecordMapper; |
| | | |
| | | @Resource |
| | | private LuckyActivityAwardsMapper luckyActivityAwardsMapper; |
| | | |
| | | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @Validated |
| | | @Override |
| | | public void join(Long activityId, String appKey, String uid, Integer weight, JoinInfo joinInfo) throws LuckyActivityException, LuckyActivityJoinException { |
| | | public void join(Long activityId, Long appId, String uid, Integer weight, JoinInfo joinInfo) throws LuckyActivityException, LuckyActivityJoinException { |
| | | luckyActivityManager.canJoin(activityId); |
| | | Long appId = appManager.getAppId(appKey); |
| | | LuckyActivityJoinRecord record = luckyActivityJoinManager.getRecord(activityId, appId, uid); |
| | | if (record != null) { |
| | | throw new LuckyActivityJoinException(1, "已经参加"); |
| | |
| | | record.setCreateTime(new Date()); |
| | | luckyActivityJoinRecordMapper.insertSelective(record); |
| | | luckyActivityManager.addJoinCount(activityId, 1); |
| | | |
| | | |
| | | LuckyActivityUserWeightRecord weightRecord = LuckyActivityUserWeightRecordFactory.createJoin(activityId, appId, uid, weight); |
| | | try { |
| | | luckyActivityUserWeightRecordManager.addRecord(weightRecord); |
| | | } catch (ParamsException e) { |
| | | throw new LuckyActivityJoinException(1, "添加记录出错"); |
| | | } |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public LuckyActivityJoinRecord getJoinInfo(Long activityId, String appKey, String uid) { |
| | | Long appId = appManager.getAppId(appKey); |
| | | public LuckyActivityJoinRecord getJoinInfo(Long activityId, Long appId, String uid) { |
| | | LuckyActivityJoinRecord record = luckyActivityJoinManager.getRecord(activityId, appId, uid); |
| | | return record; |
| | | } |
| | | |
| | | @Override |
| | | public List<Long> getUnOpenActivityIdList(Long appId, String uid, int page, int pageSize) { |
| | | ActivityJoinRecordQuery query = new ActivityJoinRecordQuery(); |
| | | query.appId = appId; |
| | | query.uid = uid; |
| | | query.drawStateList = Arrays.asList(new Integer[]{LuckyActivityJoinRecord.DRAW_STATE_UNOPEN}); |
| | | query.start = (page - 1) * pageSize; |
| | | query.count = pageSize; |
| | | return drawActivityId(luckyActivityJoinRecordMapper.listWithActivityState(query, null)); |
| | | } |
| | | |
| | | @Override |
| | | public long countUnOpenActivityIdList(Long appId, String uid) { |
| | | ActivityJoinRecordQuery query = new ActivityJoinRecordQuery(); |
| | | query.appId = appId; |
| | | query.uid = uid; |
| | | query.drawStateList = Arrays.asList(new Integer[]{LuckyActivityJoinRecord.DRAW_STATE_UNOPEN}); |
| | | return luckyActivityJoinRecordMapper.countWithActivityState(query, null); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 提取活动ID |
| | | * |
| | | * @param list |
| | | * @return |
| | | */ |
| | | private List<Long> drawActivityId(List<LuckyActivityJoinRecord> list) { |
| | | List<Long> activityList = new ArrayList<>(); |
| | | if (list != null) { |
| | | for (LuckyActivityJoinRecord record : list) { |
| | | activityList.add(record.getActivityId()); |
| | | } |
| | | } |
| | | return activityList; |
| | | } |
| | | |
| | | @Override |
| | | public List<Long> getUnDrawnActivityIdList(Long appId, String uid, int page, int pageSize) { |
| | | ActivityJoinRecordQuery query = new ActivityJoinRecordQuery(); |
| | | query.appId = appId; |
| | | query.uid = uid; |
| | | query.drawStateList = Arrays.asList(new Integer[]{LuckyActivityJoinRecord.DRAW_STATE_NOT_DRAWN}); |
| | | query.start = (page - 1) * pageSize; |
| | | query.count = pageSize; |
| | | List<LuckyActivityJoinRecord> list = luckyActivityJoinRecordMapper.listWithActivityState(query, Arrays.asList(new Integer[]{LuckyActivity.STATE_OPENED})); |
| | | return drawActivityId(list); |
| | | } |
| | | |
| | | @Override |
| | | public long countUnDrawnActivityIdList(Long appId, String uid) { |
| | | ActivityJoinRecordQuery query = new ActivityJoinRecordQuery(); |
| | | query.appId = appId; |
| | | query.uid = uid; |
| | | query.drawStateList = Arrays.asList(new Integer[]{LuckyActivityJoinRecord.DRAW_STATE_NOT_DRAWN}); |
| | | return luckyActivityJoinRecordMapper.countWithActivityState(query, Arrays.asList(new Integer[]{LuckyActivity.STATE_OPENED})); |
| | | } |
| | | |
| | | @Override |
| | | public List<ActivitySimpleUser> getRecentJoinerList(Long activityId, int count) { |
| | | ActivityJoinRecordQuery query = new ActivityJoinRecordQuery(); |
| | | query.activityId = activityId; |
| | | query.sortList = Arrays.asList(new String[]{"id desc"}); |
| | | query.count = count; |
| | | List<LuckyActivityJoinRecord> recordList = luckyActivityJoinRecordMapper.list(query); |
| | | |
| | | List<ActivitySimpleUser> list = new ArrayList<>(); |
| | | if (recordList != null) { |
| | | for (LuckyActivityJoinRecord record : recordList) { |
| | | list.add(new ActivitySimpleUser(activityId, record.getUid(), record.getAppId())); |
| | | } |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | @Override |
| | | public List<ActivitySimpleUser> getRecentJoinerList(List<Long> activityIdList, int count) { |
| | | List<ActivitySimpleUser> list = new ArrayList<>(); |
| | | if (activityIdList != null) { |
| | | for (Long activityId : activityIdList) { |
| | | list.addAll(getRecentJoinerList(activityId, count)); |
| | | } |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | @Override |
| | | public List<ActivitySimpleUser> getJoinerList(Long activityId, int page, int count) { |
| | | ActivityJoinRecordQuery query = new ActivityJoinRecordQuery(); |
| | | query.activityId = activityId; |
| | | query.sortList = Arrays.asList(new String[]{"id asc"}); |
| | | query.count = count; |
| | | query.start = (page - 1) * count; |
| | | |
| | | List<LuckyActivityJoinRecord> recordList = luckyActivityJoinRecordMapper.list(query); |
| | | List<ActivitySimpleUser> list = new ArrayList<>(); |
| | | if (recordList != null) { |
| | | for (LuckyActivityJoinRecord record : recordList) { |
| | | list.add(new ActivitySimpleUser(activityId, record.getUid(), record.getAppId())); |
| | | } |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | @Override |
| | | public ActivityJoinStatisticInfo getActivityJoinerStatisticInfo(Long activityId, Long appId, String uid) { |
| | | ActivityJoinStatisticInfo info = new ActivityJoinStatisticInfo(); |
| | | ActivityJoinRecordQuery query = new ActivityJoinRecordQuery(); |
| | | query.activityId = activityId; |
| | | long count = luckyActivityJoinRecordMapper.count(query); |
| | | info.setTotalJoiner((int) count); |
| | | info.setActivityId(activityId); |
| | | |
| | | if (!StringUtil.isNullOrEmpty(uid)) { |
| | | int position = luckyActivityJoinRecordMapper.getJoinerPosition(activityId, appId, uid); |
| | | info.setMyPosition(position + 1); |
| | | } |
| | | return info; |
| | | } |
| | | |
| | | @Override |
| | | public ActivityDrawnProbabilityStatistic getActivityDrawnProbabilityStatistic(Long activityId, Long appId, String uid) { |
| | | Long weight = luckyActivityJoinRecordMapper.sumWeight(activityId); |
| | | if (weight == null) { |
| | | weight = 1L; |
| | | } |
| | | ActivityJoinRecordQuery query = new ActivityJoinRecordQuery(); |
| | | query.activityId = activityId; |
| | | long joinerCount = luckyActivityJoinRecordMapper.count(query); |
| | | ActivityDrawnProbabilityStatistic statistic = new ActivityDrawnProbabilityStatistic(); |
| | | ActivityAwardQuery awardQuery = new ActivityAwardQuery(); |
| | | awardQuery.activityId = activityId; |
| | | //奖项数量 |
| | | int awardCount = 0; |
| | | List<LuckyActivityAwards> awards = luckyActivityAwardsMapper.list(awardQuery); |
| | | if (awards != null && awards.size() > 0) { |
| | | for (LuckyActivityAwards award : awards) { |
| | | awardCount += award.getCount(); |
| | | } |
| | | |
| | | } |
| | | //平均中奖概率 |
| | | BigDecimal averageProbability = new BigDecimal(awardCount).divide(new BigDecimal(joinerCount), 8, BigDecimal.ROUND_DOWN); |
| | | statistic.setAverageDrawnProbability(averageProbability); |
| | | if (!StringUtil.isNullOrEmpty(uid)) { |
| | | query.appId = appId; |
| | | query.uid = uid; |
| | | LuckyActivityJoinRecord record = luckyActivityJoinManager.getRecord(activityId, appId, uid); |
| | | if (record != null) { |
| | | //我的中奖概率 |
| | | BigDecimal myProbability = new BigDecimal(awardCount * record.getWeight()).divide(new BigDecimal(weight), 8, BigDecimal.ROUND_DOWN); |
| | | statistic.setMyDrawnProbability(myProbability); |
| | | } |
| | | } |
| | | statistic.setActivityId(activityId); |
| | | return statistic; |
| | | } |
| | | |
| | | @Override |
| | | public List<ActivityJoinerRankInfo> getWeightRankList(Long activityId, int page, int pageSize) { |
| | | return luckyActivityJoinRecordMapper.listWeightRank(activityId, (page - 1) * pageSize, pageSize); |
| | | } |
| | | |
| | | @Override |
| | | public long countWeightRank(Long activityId) { |
| | | return luckyActivityJoinRecordMapper.countWeightRank(activityId); |
| | | } |
| | | |
| | | @Override |
| | | public ActivityJoinerRankInfo getMyWeightRank(Long activityId, Long appId, String uid) { |
| | | LuckyActivityJoinRecord record = luckyActivityJoinManager.getRecord(activityId, appId, uid); |
| | | if (record == null) { |
| | | return null; |
| | | } |
| | | |
| | | int rank = luckyActivityJoinRecordMapper.getWeightRankWithRecord(record); |
| | | |
| | | ActivityJoinerRankInfo rankInfo = new ActivityJoinerRankInfo(); |
| | | rankInfo.setAppId(record.getAppId()); |
| | | rankInfo.setRank(rank); |
| | | rankInfo.setUid(record.getUid()); |
| | | rankInfo.setWeight(record.getWeight()); |
| | | |
| | | return rankInfo; |
| | | } |
| | | |
| | | } |
| | |
| | | update.setState(LuckyActivity.STATE_OPENED); |
| | | update.setStateRemarks("已开奖"); |
| | | luckyActivityMapper.updateByPrimaryKeySelective(update); |
| | | |
| | | //先设置所有记录未中奖 |
| | | luckyActivityJoinManager.setActivityAllJoinerUnDraw(activityId); |
| | | //设置中奖用户状态为中奖 |
| | | luckyActivityJoinManager.setActivityDrawnJoinerState(activityId); |
| | | |
| | | luckyActivityAwardResultManager.setResultShow(activityId); |
| | | } |
| | | |
| | |
| | | import org.springframework.validation.annotation.Validated; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | |
| | | @Resource |
| | | private LuckyMQService luckyMQService; |
| | | |
| | | private Long getAppId(String appKey) throws AppException { |
| | | return appManager.getAppId(appKey); |
| | | } |
| | | |
| | | private void notNull(LuckyActivity activity) throws LuckyActivityException { |
| | | if (activity == null) { |
| | |
| | | } |
| | | |
| | | @Override |
| | | public List<LuckyActivity> getActivityList(String appKey, Long sponsorId, List<Integer> stateList, String key, int page, int pageSize) { |
| | | public List<LuckyActivity> getActivityList(Long appId, Long sponsorId, List<Integer> stateList, String key, int page, int pageSize) { |
| | | ActivityDaoQuery query = new ActivityDaoQuery(); |
| | | query.stateList = stateList; |
| | | query.key = key; |
| | | query.sponsorId = sponsorId; |
| | | |
| | | try { |
| | | query.appId = getAppId(appKey); |
| | | } catch (AppException e) { |
| | | return null; |
| | | } |
| | | query.appId = appId; |
| | | query.start = (page - 1) * pageSize; |
| | | query.count = pageSize; |
| | | query.sort = "start_time desc"; |
| | |
| | | } |
| | | |
| | | @Override |
| | | public long countActivity(String appKey, Long sponsorId, List<Integer> stateList, String key) { |
| | | public long countActivity(Long appId, Long sponsorId, List<Integer> stateList, String key) { |
| | | ActivityDaoQuery query = new ActivityDaoQuery(); |
| | | query.stateList = stateList; |
| | | query.key = key; |
| | | query.sponsorId = sponsorId; |
| | | try { |
| | | query.appId = getAppId(appKey); |
| | | } catch (AppException e) { |
| | | return 0L; |
| | | } |
| | | query.appId = appId; |
| | | |
| | | return luckyActivityMapper.count(query); |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | @Override |
| | | public List<LuckyActivity> getActivityDetail(List<Long> ids) { |
| | | List<LuckyActivity> activityList = new ArrayList<>(); |
| | | for (Long id : ids) { |
| | | LuckyActivity luckyActivity = getActivityDetail(id); |
| | | activityList.add(luckyActivity); |
| | | } |
| | | return activityList; |
| | | } |
| | | |
| | | @Override |
| | | public void updateActivity(LuckyActivity activity) throws LuckyActivityException { |
| | | if (activity.getState() != null) { |
| | | throw new LuckyActivityException(1, "不能更改活动状态"); |
New file |
| | |
| | | package com.ks.lucky.service.impl.remote; |
| | | |
| | | import com.ks.lucky.mapper.LuckyActivityUserWeightRecordMapper; |
| | | import com.ks.lucky.pojo.DO.LuckyActivityUserWeightRecord; |
| | | import com.ks.lucky.query.ActivityUserWeightRecordQuery; |
| | | import com.ks.lucky.remote.service.LuckyActivityUserWeightRecordService; |
| | | import org.apache.dubbo.config.annotation.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.List; |
| | | |
| | | @Service(version = "1.0.0") |
| | | public class LuckyActivityUserWeightRecordServiceImpl implements LuckyActivityUserWeightRecordService { |
| | | |
| | | @Resource |
| | | private LuckyActivityUserWeightRecordMapper luckyActivityUserWeightRecordMapper; |
| | | |
| | | @Override |
| | | public List<LuckyActivityUserWeightRecord> getWeightRecordList(Long activityid, Long appId, String uid, int page, int pageSize) { |
| | | ActivityUserWeightRecordQuery query = new ActivityUserWeightRecordQuery(); |
| | | query.activityId = activityid; |
| | | query.appId = appId; |
| | | query.uid = uid; |
| | | query.start = (page - 1) * pageSize; |
| | | query.count = pageSize; |
| | | return luckyActivityUserWeightRecordMapper.list(query); |
| | | } |
| | | |
| | | @Override |
| | | public long countWeightRecord(Long activityid, Long appId, String uid) { |
| | | ActivityUserWeightRecordQuery query = new ActivityUserWeightRecordQuery(); |
| | | query.activityId = activityid; |
| | | query.appId = appId; |
| | | query.uid = uid; |
| | | return luckyActivityUserWeightRecordMapper.count(query); |
| | | } |
| | | } |
New file |
| | |
| | | package com.ks.lucky.util.factory; |
| | | |
| | | import com.ks.lucky.pojo.DO.LuckyActivityJoinAssist; |
| | | import com.ks.lucky.pojo.DO.LuckyActivityUserWeightRecord; |
| | | |
| | | public class LuckyActivityUserWeightRecordFactory { |
| | | |
| | | private static LuckyActivityUserWeightRecord getCommon(Long activityId, Long appId, String uid, int weight) { |
| | | LuckyActivityUserWeightRecord weightRecord = new LuckyActivityUserWeightRecord(); |
| | | weightRecord.setActivityId(activityId); |
| | | weightRecord.setAppId(appId); |
| | | weightRecord.setUid(uid); |
| | | weightRecord.setWeight(weight); |
| | | return weightRecord; |
| | | } |
| | | |
| | | public static LuckyActivityUserWeightRecord createJoin(Long activityId, Long appId, String uid, int weight) { |
| | | LuckyActivityUserWeightRecord weightRecord = getCommon(activityId, appId, uid, weight); |
| | | weightRecord.setTitle("自己参与"); |
| | | return weightRecord; |
| | | } |
| | | |
| | | public static LuckyActivityUserWeightRecord createAssist(Long activityId, Long appId, String uid, LuckyActivityJoinAssist.ActivityJoinAssistEvent event, int weight) { |
| | | LuckyActivityUserWeightRecord weightRecord = getCommon(activityId, appId, uid, weight); |
| | | weightRecord.setTitle(event.getName()); |
| | | return weightRecord; |
| | | } |
| | | |
| | | } |
| | | |
| | |
| | | server: |
| | | port: 8083 |
| | | port: 8084 |
| | | tomcat: |
| | | uri-encoding: UTF-8 |
| | | |
| | |
| | | database: 3 |
| | | |
| | | datasource: |
| | | url: jdbc:mysql://gz-cdb-r13d0yi9.sql.tencentcdb.com:62929/ks_lucky |
| | | url: jdbc:mysql://172.16.16.17:3306/ks_lucky |
| | | username: root |
| | | password: Yeshi2016@ |
| | | driver-class-name: com.mysql.jdbc.Driver |
| | |
| | | <!--enableDeleteByExample="false" enableSelectByExample="false"--> |
| | | <!--selectByExampleQueryId="false"></table>--> |
| | | |
| | | <!--<table schema="" domainObjectName="LuckyMQ" tableName="lucky_mq" enableCountByExample="false" enableUpdateByExample="false"--> |
| | | <!--enableDeleteByExample="false" enableSelectByExample="false"--> |
| | | <!--selectByExampleQueryId="false"></table>--> |
| | | <table schema="" domainObjectName="LuckyActivityUserWeightRecord" tableName="lucky_activity_weight_record" enableCountByExample="false" enableUpdateByExample="false" |
| | | enableDeleteByExample="false" enableSelectByExample="false" |
| | | selectByExampleQueryId="false"></table> |
| | | |
| | | <table schema="" domainObjectName="" tableName=""></table> |
| | | <!--<table schema="" domainObjectName="" tableName=""></table>--> |
| | | |
| | | |
| | | </context> |
| | |
| | | </select> |
| | | |
| | | |
| | | <select id="listUserAwardResult" parameterType="java.lang.Long" resultMap="BaseResultMap"> |
| | | SELECT r.* FROM `lucky_activity_award_result` r LEFT JOIN `lucky_activity` a ON r.`activity_id`=a.`id` |
| | | where uid=#{uid} and app_id=#{appId} |
| | | |
| | | <if test="stateList!=null"> |
| | | <foreach collection="stateList" item="state" open=" and (" close=")" separator=" or "> |
| | | r.state=#{state} |
| | | </foreach> |
| | | </if> |
| | | |
| | | <if test="activityStateList!=null"> |
| | | <foreach collection="activityStateList" item="state" open=" and (" close=")" separator=" or "> |
| | | a.state=#{state} |
| | | </foreach> |
| | | </if> |
| | | order by r.create_time desc |
| | | limit #{start},#{count} |
| | | </select> |
| | | |
| | | <select id="countUserAwardResult" resultType="java.lang.Long"> |
| | | SELECT count(*) FROM `lucky_activity_award_result` r LEFT JOIN `lucky_activity` a ON r.`activity_id`=a.`id` |
| | | where uid=#{uid} and app_id=#{appId} |
| | | |
| | | <if test="stateList!=null"> |
| | | <foreach collection="stateList" item="state" open=" and (" close=")" separator=" or "> |
| | | r.state=#{state} |
| | | </foreach> |
| | | </if> |
| | | |
| | | <if test="activityStateList!=null"> |
| | | <foreach collection="activityStateList" item="state" open=" and (" close=")" separator=" or "> |
| | | a.state=#{state} |
| | | </foreach> |
| | | </if> |
| | | </select> |
| | | |
| | | |
| | | <update id="setStateByActivityId"> |
| | | update lucky_activity_award_result |
| | | <set> |
| | |
| | | <?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.ks.lucky.mapper.LuckyActivityJoinAssistMapper"> |
| | | <resultMap id="BaseResultMap" type="com.ks.lucky.pojo.DO.LuckyActivityJoinAssist"> |
| | | <id column="id" jdbcType="BIGINT" property="id"/> |
| | |
| | | <result column="weight" jdbcType="INTEGER" property="weight"/> |
| | | <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/> |
| | | <result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/> |
| | | <result column="event_key" property="eventKey" jdbcType="VARCHAR"/> |
| | | </resultMap> |
| | | <sql id="Base_Column_List"> |
| | | id, join_id, app_id, uid, weight, create_time, update_time |
| | | </sql> |
| | | <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap"> |
| | | select |
| | | <include refid="Base_Column_List"/> |
| | | from lucky_activity_join_assist |
| | | where id = #{id,jdbcType=BIGINT} |
| | | <resultMap id="AssistFriendResultMap" type="com.ks.lucky.pojo.DTO.ActivityAssistFriend"> |
| | | <result column="uid" jdbcType="VARCHAR" property="uid"/> |
| | | <result column="app_id" jdbcType="BIGINT" property="appId"/> |
| | | <result column="count" jdbcType="INTEGER" property="assistCount"/> |
| | | </resultMap> |
| | | |
| | | |
| | | <resultMap id="ActivityAssistInfoResultMap" type="com.ks.lucky.pojo.DTO.ActivityAssistFriend"> |
| | | <result column="uid" jdbcType="VARCHAR" property="uid"/> |
| | | <result column="app_id" jdbcType="BIGINT" property="appId"/> |
| | | <result column="weight" jdbcType="INTEGER" property="weight"/> |
| | | <result column="join_id" jdbcType="BIGINT" property="joinId"/> |
| | | <association property="eventList" |
| | | javaType="com.ks.lucky.pojo.DO.LuckyActivityJoinAssist.ActivityJoinAssistEvent" |
| | | select="selectEventkeyWithJoinId"></association> |
| | | </resultMap> |
| | | |
| | | <select id="selectEventkeyWithJoinId" parameterType="java.lang.Long" |
| | | resultType="com.ks.lucky.pojo.DO.LuckyActivityJoinAssist.ActivityJoinAssistEvent"> |
| | | |
| | | SELECT a.`event_key` FROM `lucky_activity_join_assist` a WHERE a.`join_id`=#{joinId} AND app_id=#{appId} AND uid=#{uid} |
| | | |
| | | </select> |
| | | |
| | | |
| | | <sql id="Base_Column_List">id, join_id, app_id, uid, weight, create_time, update_time,event_key</sql> |
| | | <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">select |
| | | <include refid="Base_Column_List"/> |
| | | from lucky_activity_join_assist where id = #{id,jdbcType=BIGINT} |
| | | </select> |
| | | <!-- 非模板 --> |
| | | <sql id="listWhere"> |
| | | <if test="query.joinId!=null"> |
| | | and join_id=#{query.joinId} |
| | | </if> |
| | | <if test="query.appId!=null"> |
| | | and app_id=#{query.appId} |
| | | </if> |
| | | <if test="query.uid!=null"> |
| | | and uid=#{query.uid} |
| | | </if> |
| | | |
| | | <if test="query.minCreateTime!=null"> |
| | | and create_time>=#{query.minCreateTime} |
| | | </if> |
| | | |
| | | <if test="query.maxCreateTime!=null"> |
| | | and #{query.maxCreateTime}>create_time |
| | | </if> |
| | | |
| | | <if test="query.joinId!=null">and join_id=#{query.joinId}</if> |
| | | <if test="query.appId!=null">and app_id=#{query.appId}</if> |
| | | <if test="query.uid!=null">and uid=#{query.uid}</if> |
| | | <if test="query.eventKey!=null">and event_key=#{query.eventKey}</if> |
| | | <if test="query.minCreateTime!=null">and create_time>=#{query.minCreateTime}</if> |
| | | <if test="query.maxCreateTime!=null">and #{query.maxCreateTime}>create_time</if> |
| | | </sql> |
| | | |
| | | |
| | | <select id="list" resultMap="BaseResultMap"> |
| | | select |
| | | <select id="list" resultMap="BaseResultMap">select |
| | | <include refid="Base_Column_List"/> |
| | | from lucky_activity_join_assist |
| | | where 1=1 |
| | | <include refid="listWhere"> |
| | | |
| | | </include> |
| | | |
| | | |
| | | from lucky_activity_join_assist where 1=1 |
| | | <include refid="listWhere"/> |
| | | <if test="query.sortList!=null"> |
| | | <foreach collection="query.sortList" item="item" separator="," open=" order by "> |
| | | #{item} |
| | | </foreach> |
| | | <foreach collection="query.sortList" item="item" separator="," open=" order by ">#{item}</foreach> |
| | | </if> |
| | | limit #{query.start},#{query.count} |
| | | </select> |
| | | <select id="count" resultType="java.lang.Long">select count(*) from lucky_activity_join_assist where 1=1 |
| | | <include refid="listWhere"/> |
| | | </select> |
| | | <select id="listAssistFriends" |
| | | resultMap="AssistFriendResultMap">SELECT a.`uid`,a.`app_id`,count(a.id) as `count` FROM `lucky_activity_join_assist` a LEFT JOIN `lucky_activity_join_record` r ON r.`id`=a.`join_id` WHERE r.`uid`=#{targetUid} AND r.`app_id`=#{appId} AND a.`app_id`=#{appId} GROUP BY a.uid order by a.create_time desc limit #{start},#{count}</select> |
| | | <select id="countAssistFriends" |
| | | resultType="java.lang.Long">SELECT count(DISTINCT(a.`uid`)) FROM `lucky_activity_join_assist` a LEFT JOIN `lucky_activity_join_record` r ON r.`id`=a.`join_id` WHERE r.`uid`=#{targetUid} AND r.`app_id`=#{appId} AND a.`app_id`=#{appId}</select> |
| | | |
| | | <select id="count" resultType="java.lang.Long"> |
| | | select |
| | | count(*) |
| | | from lucky_activity_join_assist |
| | | where 1=1 |
| | | <include refid="listWhere"> |
| | | |
| | | </include> |
| | | <select id="listActivityFriendAssistInfo" |
| | | resultMap="ActivityAssistInfoResultMap"> |
| | | SELECT a.`join_id`,a.`app_id`,a.`uid`,SUM(a.`weight`) AS weight FROM `lucky_activity_join_assist` a WHERE a.`join_id`=#{joinId} GROUP BY app_id,uid limit #{start},#{count} |
| | | |
| | | </select> |
| | | <select id="countActivityFriendAssistInfo" |
| | | resultType="java.lang.Long"> |
| | | SELECT COUNT( DISTINCT(CONCAT(a.`app_id`,a.`uid`))) FROM `lucky_activity_join_assist` a WHERE a.`join_id`=#{joinId} |
| | | </select> |
| | | |
| | | |
| | | <delete id="deleteByPrimaryKey" parameterType="java.lang.Long"> |
| | | delete from lucky_activity_join_assist |
| | | where id = #{id,jdbcType=BIGINT} |
| | | </delete> |
| | | <insert id="insert" useGeneratedKeys="true" keyProperty="id" parameterType="com.ks.lucky.pojo.DO.LuckyActivityJoinAssist"> |
| | | insert into lucky_activity_join_assist (id, join_id, app_id, |
| | | uid, weight, create_time, |
| | | update_time) |
| | | values (#{id,jdbcType=BIGINT}, #{joinId,jdbcType=BIGINT}, #{appId,jdbcType=BIGINT}, |
| | | #{uid,jdbcType=VARCHAR}, #{weight,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, |
| | | #{updateTime,jdbcType=TIMESTAMP}) |
| | | </insert> |
| | | <insert id="insertSelective" useGeneratedKeys="true" keyProperty="id" parameterType="com.ks.lucky.pojo.DO.LuckyActivityJoinAssist"> |
| | | insert into lucky_activity_join_assist |
| | | <delete id="deleteByPrimaryKey" |
| | | parameterType="java.lang.Long">delete from lucky_activity_join_assist where id = #{id,jdbcType=BIGINT}</delete> |
| | | <insert id="insert" useGeneratedKeys="true" keyProperty="id" |
| | | parameterType="com.ks.lucky.pojo.DO.LuckyActivityJoinAssist">insert into lucky_activity_join_assist (id, join_id, app_id, uid, weight, create_time, update_time,id,event_key) values (#{id,jdbcType=BIGINT}, #{joinId,jdbcType=BIGINT}, #{appId,jdbcType=BIGINT}, #{uid,jdbcType=VARCHAR}, #{weight,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP},#{id,jdbcType=BIGINT},#{eventKey,jdbcType=VARCHAR})</insert> |
| | | <insert id="insertSelective" useGeneratedKeys="true" keyProperty="id" |
| | | parameterType="com.ks.lucky.pojo.DO.LuckyActivityJoinAssist">insert into lucky_activity_join_assist |
| | | <trim prefix="(" suffix=")" suffixOverrides=","> |
| | | <if test="id != null"> |
| | | id, |
| | | </if> |
| | | <if test="joinId != null"> |
| | | join_id, |
| | | </if> |
| | | <if test="appId != null"> |
| | | app_id, |
| | | </if> |
| | | <if test="uid != null"> |
| | | uid, |
| | | </if> |
| | | <if test="weight != null"> |
| | | weight, |
| | | </if> |
| | | <if test="createTime != null"> |
| | | create_time, |
| | | </if> |
| | | <if test="updateTime != null"> |
| | | update_time, |
| | | </if> |
| | | <if test="id != null">id,</if> |
| | | <if test="joinId != null">join_id,</if> |
| | | <if test="appId != null">app_id,</if> |
| | | <if test="uid != null">uid,</if> |
| | | <if test="weight != null">weight,</if> |
| | | <if test="createTime != null">create_time,</if> |
| | | <if test="updateTime != null">update_time,</if> |
| | | <if test="eventKey != null">event_key,</if> |
| | | </trim> |
| | | <trim prefix="values (" suffix=")" suffixOverrides=","> |
| | | <if test="id != null"> |
| | | #{id,jdbcType=BIGINT}, |
| | | </if> |
| | | <if test="joinId != null"> |
| | | #{joinId,jdbcType=BIGINT}, |
| | | </if> |
| | | <if test="appId != null"> |
| | | #{appId,jdbcType=BIGINT}, |
| | | </if> |
| | | <if test="uid != null"> |
| | | #{uid,jdbcType=VARCHAR}, |
| | | </if> |
| | | <if test="weight != null"> |
| | | #{weight,jdbcType=INTEGER}, |
| | | </if> |
| | | <if test="createTime != null"> |
| | | #{createTime,jdbcType=TIMESTAMP}, |
| | | </if> |
| | | <if test="updateTime != null"> |
| | | #{updateTime,jdbcType=TIMESTAMP}, |
| | | </if> |
| | | <if test="id != null">#{id,jdbcType=BIGINT},</if> |
| | | <if test="joinId != null">#{joinId,jdbcType=BIGINT},</if> |
| | | <if test="appId != null">#{appId,jdbcType=BIGINT},</if> |
| | | <if test="uid != null">#{uid,jdbcType=VARCHAR},</if> |
| | | <if test="weight != null">#{weight,jdbcType=INTEGER},</if> |
| | | <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="updateTime != null">#{updateTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="eventKey != null">#{eventKey,jdbcType=VARCHAR}</if> |
| | | </trim> |
| | | </insert> |
| | | <update id="updateByPrimaryKeySelective" parameterType="com.ks.lucky.pojo.DO.LuckyActivityJoinAssist"> |
| | | update lucky_activity_join_assist |
| | | <update id="updateByPrimaryKeySelective" parameterType="com.ks.lucky.pojo.DO.LuckyActivityJoinAssist">update |
| | | lucky_activity_join_assist |
| | | <set> |
| | | <if test="joinId != null"> |
| | | join_id = #{joinId,jdbcType=BIGINT}, |
| | | </if> |
| | | <if test="appId != null"> |
| | | app_id = #{appId,jdbcType=BIGINT}, |
| | | </if> |
| | | <if test="uid != null"> |
| | | uid = #{uid,jdbcType=VARCHAR}, |
| | | </if> |
| | | <if test="weight != null"> |
| | | weight = #{weight,jdbcType=INTEGER}, |
| | | </if> |
| | | <if test="createTime != null"> |
| | | create_time = #{createTime,jdbcType=TIMESTAMP}, |
| | | </if> |
| | | <if test="updateTime != null"> |
| | | update_time = #{updateTime,jdbcType=TIMESTAMP}, |
| | | </if> |
| | | <if test="joinId != null">join_id = #{joinId,jdbcType=BIGINT},</if> |
| | | <if test="appId != null">app_id = #{appId,jdbcType=BIGINT},</if> |
| | | <if test="uid != null">uid = #{uid,jdbcType=VARCHAR},</if> |
| | | <if test="weight != null">weight = #{weight,jdbcType=INTEGER},</if> |
| | | <if test="createTime != null">create_time = #{createTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="updateTime != null">update_time = #{updateTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="eventKey !=null">event_key =#{eventKey,jdbcType=VARCHAR},</if> |
| | | </set> |
| | | where id = #{id,jdbcType=BIGINT} |
| | | </update> |
| | | <update id="updateByPrimaryKey" parameterType="com.ks.lucky.pojo.DO.LuckyActivityJoinAssist"> |
| | | update lucky_activity_join_assist |
| | | set join_id = #{joinId,jdbcType=BIGINT}, |
| | | app_id = #{appId,jdbcType=BIGINT}, |
| | | uid = #{uid,jdbcType=VARCHAR}, |
| | | weight = #{weight,jdbcType=INTEGER}, |
| | | create_time = #{createTime,jdbcType=TIMESTAMP}, |
| | | update_time = #{updateTime,jdbcType=TIMESTAMP} |
| | | where id = #{id,jdbcType=BIGINT} |
| | | </update> |
| | | <update id="updateByPrimaryKey" |
| | | parameterType="com.ks.lucky.pojo.DO.LuckyActivityJoinAssist">update lucky_activity_join_assist set join_id = #{joinId,jdbcType=BIGINT}, app_id = #{appId,jdbcType=BIGINT}, uid = #{uid,jdbcType=VARCHAR}, weight = #{weight,jdbcType=INTEGER}, create_time = #{createTime,jdbcType=TIMESTAMP}, update_time = #{updateTime,jdbcType=TIMESTAMP} ,event_key =#{eventKey,jdbcType=VARCHAR} where id = #{id,jdbcType=BIGINT}</update> |
| | | </mapper> |
| | |
| | | <?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.ks.lucky.mapper.LuckyActivityJoinRecordMapper"> |
| | | <resultMap id="BaseResultMap" type="com.ks.lucky.pojo.DO.LuckyActivityJoinRecord"> |
| | | <id column="id" jdbcType="BIGINT" property="id"/> |
| | |
| | | <result column="user_type" jdbcType="INTEGER" property="userType"/> |
| | | <result column="weight" jdbcType="INTEGER" property="weight"/> |
| | | <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/> |
| | | <result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/> |
| | | <result column="draw_state" property="drawState" jdbcType="INTEGER"/> |
| | | </resultMap> |
| | | <sql id="Base_Column_List"> |
| | | id, activity_id, app_id, uid, join_info, user_type, weight, create_time |
| | | </sql> |
| | | <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap"> |
| | | select |
| | | <include refid="Base_Column_List"/> |
| | | from lucky_activity_join_record |
| | | where id = #{id,jdbcType=BIGINT} |
| | | </select> |
| | | |
| | | <select id="selectByPrimaryKeyForUpdate" parameterType="java.lang.Long" resultMap="BaseResultMap"> |
| | | select |
| | | <include refid="Base_Column_List"/> |
| | | from lucky_activity_join_record |
| | | where id = #{0} for update |
| | | </select> |
| | | |
| | | <resultMap id="RankResultMap" type="com.ks.lucky.pojo.DTO.ActivityJoinerRankInfo"> |
| | | <result column="rank" jdbcType="INTEGER" property="rank"/> |
| | | <result column="app_id" jdbcType="BIGINT" property="appId"/> |
| | | <result column="uid" jdbcType="VARCHAR" property="uid"/> |
| | | <result column="weight" jdbcType="INTEGER" property="weight"/> |
| | | </resultMap> |
| | | |
| | | <sql id="Base_Column_List">id, activity_id, app_id, uid, join_info, user_type, weight, create_time,update_time,draw_state</sql> |
| | | <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">select |
| | | <include refid="Base_Column_List"/> |
| | | from lucky_activity_join_record where id = #{id,jdbcType=BIGINT} |
| | | </select> |
| | | <select id="selectByPrimaryKeyForUpdate" parameterType="java.lang.Long" resultMap="BaseResultMap">select |
| | | <include refid="Base_Column_List"/> |
| | | from lucky_activity_join_record where id = #{0} for update |
| | | </select> |
| | | <!-- 非模板 --> |
| | | |
| | | <sql id="listWhere"> |
| | | <if test="query.activityId!=null"> |
| | | and activity_id=#{query.activityId} |
| | | <if test="query.activityId!=null">and activity_id=#{query.activityId}</if> |
| | | <if test="query.appId!=null">and app_id=#{query.appId}</if> |
| | | <if test="query.uid!=null">and uid=#{query.uid}</if> |
| | | <if test="query.drawStateList!=null"> |
| | | <foreach collection="query.drawStateList" item="state" open=" and (" close=")" separator=" or "> |
| | | and draw_state=#{state} |
| | | </foreach> |
| | | </if> |
| | | <if test="query.appId!=null"> |
| | | and app_id=#{query.appId} |
| | | </if> |
| | | <if test="query.uid!=null"> |
| | | and uid=#{query.uid} |
| | | </if> |
| | | |
| | | <if test="query.minCreateTime!=null"> |
| | | and create_time>=#{query.minCreateTime} |
| | | </if> |
| | | |
| | | <if test="query.maxCreateTime!=null"> |
| | | and #{query.maxCreateTime}>create_time |
| | | </if> |
| | | |
| | | <if test="query.minCreateTime!=null">and create_time>=#{query.minCreateTime}</if> |
| | | <if test="query.maxCreateTime!=null">and #{query.maxCreateTime}>create_time</if> |
| | | </sql> |
| | | |
| | | |
| | | <select id="list" resultMap="BaseResultMap"> |
| | | select |
| | | <select id="list" resultMap="BaseResultMap">select |
| | | <include refid="Base_Column_List"/> |
| | | from lucky_activity_join_record |
| | | where 1=1 |
| | | <include refid="listWhere"> |
| | | |
| | | </include> |
| | | |
| | | |
| | | from lucky_activity_join_record where 1=1 |
| | | <include refid="listWhere"/> |
| | | <if test="query.sortList!=null"> |
| | | <foreach collection="query.sortList" item="item" separator="," open=" order by "> |
| | | #{item} |
| | | </foreach> |
| | | <foreach collection="query.sortList" item="item" separator="," open=" order by ">#{item}</foreach> |
| | | </if> |
| | | limit #{query.start},#{query.count} |
| | | </select> |
| | | |
| | | <select id="count" resultType="java.lang.Long"> |
| | | select |
| | | count(*) |
| | | from lucky_activity_join_record |
| | | where 1=1 |
| | | <include refid="listWhere"> |
| | | |
| | | </include> |
| | | <select id="count" resultType="java.lang.Long">select count(*) from lucky_activity_join_record where 1=1 |
| | | <include refid="listWhere"/> |
| | | </select> |
| | | |
| | | <update id="addWeight"> |
| | | |
| | | update lucky_activity_join_record set weight=weight+#{weight} where id=#{id} |
| | | <sql id="listWithActivityWhere"> |
| | | <if test="query.activityId!=null">and r.activity_id=#{query.activityId}</if> |
| | | <if test="query.appId!=null">and r.app_id=#{query.appId}</if> |
| | | <if test="query.uid!=null">and r.uid=#{query.uid}</if> |
| | | <if test="query.drawStateList!=null"> |
| | | <foreach collection="query.drawStateList" item="state" open=" and (" close=")" separator=" or "> |
| | | and draw_state=#{state} |
| | | </foreach> |
| | | </if> |
| | | <if test="query.minCreateTime!=null">and r.create_time>=#{query.minCreateTime}</if> |
| | | <if test="query.maxCreateTime!=null">and #{query.maxCreateTime}>r.create_time</if> |
| | | </sql> |
| | | |
| | | </update> |
| | | <select id="listWithActivityState" resultMap="BaseResultMap"> |
| | | select |
| | | r.* |
| | | from lucky_activity_join_record r LEFT JOIN `lucky_activity` a ON r.`activity_id`=a.`id` where 1=1 |
| | | <include refid="listWithActivityWhere"/> |
| | | |
| | | <delete id="deleteByPrimaryKey" parameterType="java.lang.Long"> |
| | | delete from lucky_activity_join_record |
| | | where id = #{id,jdbcType=BIGINT} |
| | | </delete> |
| | | <insert id="insert" useGeneratedKeys="true" keyProperty="id" parameterType="com.ks.lucky.pojo.DO.LuckyActivityJoinRecord"> |
| | | insert into lucky_activity_join_record (id, activity_id, app_id, |
| | | uid, join_info, user_type, |
| | | weight, create_time) |
| | | values (#{id,jdbcType=BIGINT}, #{activityId,jdbcType=BIGINT}, #{appId,jdbcType=BIGINT}, |
| | | #{uid,jdbcType=VARCHAR}, #{joinInfo,jdbcType=VARCHAR}, #{userType,jdbcType=INTEGER}, |
| | | #{weight,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}) |
| | | </insert> |
| | | <insert id="insertSelective" useGeneratedKeys="true" keyProperty="id" parameterType="com.ks.lucky.pojo.DO.LuckyActivityJoinRecord"> |
| | | insert into lucky_activity_join_record |
| | | <if test="activityStateList!=null"> |
| | | <foreach collection="activityStateList" item="state" open=" and (" close=")" separator="or"> |
| | | #{state}=a.state |
| | | </foreach> |
| | | </if> |
| | | order by r.create_time desc |
| | | limit #{query.start},#{query.count} |
| | | </select> |
| | | <select id="countWithActivityState" resultType="java.lang.Long"> |
| | | select |
| | | count(*) |
| | | from lucky_activity_join_record r LEFT JOIN `lucky_activity` a ON r.`activity_id`=a.`id` where 1=1 |
| | | <include refid="listWithActivityWhere"/> |
| | | |
| | | <if test="activityStateList!=null"> |
| | | <foreach collection="activityStateList" item="state" open=" and (" close=")" separator="or"> |
| | | #{state}=a.state |
| | | </foreach> |
| | | </if> |
| | | </select> |
| | | |
| | | |
| | | <select id="getJoinerPosition" resultType="java.lang.Integer"> |
| | | select count(*) from `lucky_activity_join_record` r where r.`activity_id`=#{activityId} and r.`id` <![CDATA[<]]> (SELECT r.`id` FROM `lucky_activity_join_record` r where r.`activity_id`=#{activityId} and r.`app_id`=#{appId} and r.`uid`=#{uid}) |
| | | </select> |
| | | |
| | | |
| | | <select id="sumWeight" resultType="java.lang.Long"> |
| | | select sum(r.weight) from `lucky_activity_join_record` r where r.`activity_id`=#{activityId} |
| | | </select> |
| | | |
| | | |
| | | <select id="listWeightRank" resultMap="RankResultMap"> |
| | | SELECT (@i:=@i+1) rank,r.* FROM lucky_activity_join_record r,(SELECT @i:=#{start}) t where r.`activity_id`=#{activityId} order by r.`weight` desc,r.`id` LIMIT #{start},#{count}; |
| | | </select> |
| | | |
| | | |
| | | <select id="countWeightRank" resultType="java.lang.Long"> |
| | | SELECT count(*) FROM lucky_activity_join_record r where r.`activity_id`=#{activityId} |
| | | </select> |
| | | |
| | | |
| | | <!-- 参与者的排行 = 大于自己权重的参与者数量 + 等于自己的权重数量且id小于等于自己ID的参与者数量 --> |
| | | |
| | | <select id="getWeightRankWithRecord" resultType="java.lang.Integer"> |
| | | select |
| | | ( |
| | | (select COUNT(*) from lucky_activity_join_record r where r.`activity_id`=#{activityId} and r.`weight`>#{weight}) |
| | | + |
| | | (SELECT COUNT(*) FROM lucky_activity_join_record r WHERE r.`activity_id`=#{activityId} AND r.`weight`=#{weight} and r.`id` <![CDATA[<=]]> #{id})) as rank |
| | | </select> |
| | | |
| | | |
| | | <update id="addWeight">update lucky_activity_join_record set weight=weight+#{weight} where id=#{id}</update> |
| | | <delete id="deleteByPrimaryKey" |
| | | parameterType="java.lang.Long">delete from lucky_activity_join_record where id = #{id,jdbcType=BIGINT}</delete> |
| | | <insert id="insert" useGeneratedKeys="true" keyProperty="id" |
| | | parameterType="com.ks.lucky.pojo.DO.LuckyActivityJoinRecord">insert into lucky_activity_join_record (id, activity_id, app_id, uid, join_info, user_type, weight, create_time,id,update_time,draw_state) values (#{id,jdbcType=BIGINT}, #{activityId,jdbcType=BIGINT}, #{appId,jdbcType=BIGINT}, #{uid,jdbcType=VARCHAR}, #{joinInfo,jdbcType=VARCHAR}, #{userType,jdbcType=INTEGER}, #{weight,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP},#{id,jdbcType=BIGINT},#{updateTime,jdbcType=TIMESTAMP},#{drawState,jdbcType=INTEGER})</insert> |
| | | <insert id="insertSelective" useGeneratedKeys="true" keyProperty="id" |
| | | parameterType="com.ks.lucky.pojo.DO.LuckyActivityJoinRecord">insert into lucky_activity_join_record |
| | | <trim prefix="(" suffix=")" suffixOverrides=","> |
| | | <if test="id != null"> |
| | | id, |
| | | </if> |
| | | <if test="activityId != null"> |
| | | activity_id, |
| | | </if> |
| | | <if test="appId != null"> |
| | | app_id, |
| | | </if> |
| | | <if test="uid != null"> |
| | | uid, |
| | | </if> |
| | | <if test="joinInfo != null"> |
| | | join_info, |
| | | </if> |
| | | <if test="userType != null"> |
| | | user_type, |
| | | </if> |
| | | <if test="weight != null"> |
| | | weight, |
| | | </if> |
| | | <if test="createTime != null"> |
| | | create_time, |
| | | </if> |
| | | <if test="id != null">id,</if> |
| | | <if test="activityId != null">activity_id,</if> |
| | | <if test="appId != null">app_id,</if> |
| | | <if test="uid != null">uid,</if> |
| | | <if test="joinInfo != null">join_info,</if> |
| | | <if test="userType != null">user_type,</if> |
| | | <if test="weight != null">weight,</if> |
| | | <if test="createTime != null">create_time,</if> |
| | | <if test="updateTime != null">update_time,</if> |
| | | <if test="drawState != null">draw_state,</if> |
| | | </trim> |
| | | <trim prefix="values (" suffix=")" suffixOverrides=","> |
| | | <if test="id != null"> |
| | | #{id,jdbcType=BIGINT}, |
| | | </if> |
| | | <if test="activityId != null"> |
| | | #{activityId,jdbcType=BIGINT}, |
| | | </if> |
| | | <if test="appId != null"> |
| | | #{appId,jdbcType=BIGINT}, |
| | | </if> |
| | | <if test="uid != null"> |
| | | #{uid,jdbcType=VARCHAR}, |
| | | </if> |
| | | <if test="joinInfo != null"> |
| | | #{joinInfo,jdbcType=VARCHAR}, |
| | | </if> |
| | | <if test="userType != null"> |
| | | #{userType,jdbcType=INTEGER}, |
| | | </if> |
| | | <if test="weight != null"> |
| | | #{weight,jdbcType=INTEGER}, |
| | | </if> |
| | | <if test="createTime != null"> |
| | | #{createTime,jdbcType=TIMESTAMP}, |
| | | </if> |
| | | <if test="id != null">#{id,jdbcType=BIGINT},</if> |
| | | <if test="activityId != null">#{activityId,jdbcType=BIGINT},</if> |
| | | <if test="appId != null">#{appId,jdbcType=BIGINT},</if> |
| | | <if test="uid != null">#{uid,jdbcType=VARCHAR},</if> |
| | | <if test="joinInfo != null">#{joinInfo,jdbcType=VARCHAR},</if> |
| | | <if test="userType != null">#{userType,jdbcType=INTEGER},</if> |
| | | <if test="weight != null">#{weight,jdbcType=INTEGER},</if> |
| | | <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="updateTime != null">#{updateTime,jdbcType=TIMESTAMP}</if> |
| | | <if test="drawState != null">#{drawState,jdbcType=INTEGER}</if> |
| | | </trim> |
| | | </insert> |
| | | <update id="updateByPrimaryKeySelective" parameterType="com.ks.lucky.pojo.DO.LuckyActivityJoinRecord"> |
| | | update lucky_activity_join_record |
| | | <update id="updateByPrimaryKeySelective" parameterType="com.ks.lucky.pojo.DO.LuckyActivityJoinRecord">update |
| | | lucky_activity_join_record |
| | | <set> |
| | | <if test="activityId != null"> |
| | | activity_id = #{activityId,jdbcType=BIGINT}, |
| | | </if> |
| | | <if test="appId != null"> |
| | | app_id = #{appId,jdbcType=BIGINT}, |
| | | </if> |
| | | <if test="uid != null"> |
| | | uid = #{uid,jdbcType=VARCHAR}, |
| | | </if> |
| | | <if test="joinInfo != null"> |
| | | join_info = #{joinInfo,jdbcType=VARCHAR}, |
| | | </if> |
| | | <if test="userType != null"> |
| | | user_type = #{userType,jdbcType=INTEGER}, |
| | | </if> |
| | | <if test="weight != null"> |
| | | weight = #{weight,jdbcType=INTEGER}, |
| | | </if> |
| | | <if test="createTime != null"> |
| | | create_time = #{createTime,jdbcType=TIMESTAMP}, |
| | | </if> |
| | | <if test="activityId != null">activity_id = #{activityId,jdbcType=BIGINT},</if> |
| | | <if test="appId != null">app_id = #{appId,jdbcType=BIGINT},</if> |
| | | <if test="uid != null">uid = #{uid,jdbcType=VARCHAR},</if> |
| | | <if test="joinInfo != null">join_info = #{joinInfo,jdbcType=VARCHAR},</if> |
| | | <if test="userType != null">user_type = #{userType,jdbcType=INTEGER},</if> |
| | | <if test="weight != null">weight = #{weight,jdbcType=INTEGER},</if> |
| | | <if test="createTime != null">create_time = #{createTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="updateTime !=null">update_time =#{updateTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="drawState != null">draw_state =#{drawState,jdbcType=INTEGER},</if> |
| | | </set> |
| | | where id = #{id,jdbcType=BIGINT} |
| | | </update> |
| | | <update id="updateByPrimaryKey" parameterType="com.ks.lucky.pojo.DO.LuckyActivityJoinRecord"> |
| | | update lucky_activity_join_record |
| | | set activity_id = #{activityId,jdbcType=BIGINT}, |
| | | app_id = #{appId,jdbcType=BIGINT}, |
| | | uid = #{uid,jdbcType=VARCHAR}, |
| | | join_info = #{joinInfo,jdbcType=VARCHAR}, |
| | | user_type = #{userType,jdbcType=INTEGER}, |
| | | weight = #{weight,jdbcType=INTEGER}, |
| | | create_time = #{createTime,jdbcType=TIMESTAMP} |
| | | where id = #{id,jdbcType=BIGINT} |
| | | |
| | | |
| | | <update id="updateSelectiveWithQuery" parameterType="com.ks.lucky.pojo.DO.LuckyActivityJoinRecord">update |
| | | lucky_activity_join_record |
| | | <set> |
| | | <if test="record.activityId != null">activity_id = #{record.activityId,jdbcType=BIGINT},</if> |
| | | <if test="record.appId != null">app_id = #{record.appId,jdbcType=BIGINT},</if> |
| | | <if test="record.uid != null">uid = #{record.uid,jdbcType=VARCHAR},</if> |
| | | <if test="record.joinInfo != null">join_info = #{record.joinInfo,jdbcType=VARCHAR},</if> |
| | | <if test="record.userType != null">user_type = #{record.userType,jdbcType=INTEGER},</if> |
| | | <if test="record.weight != null">weight = #{record.weight,jdbcType=INTEGER},</if> |
| | | <if test="record.createTime != null">create_time = #{record.createTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="record.updateTime !=null">update_time =#{record.updateTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="record.drawState != null">draw_state =#{record.drawState,jdbcType=INTEGER},</if> |
| | | </set> |
| | | where 1=1 |
| | | <include refid="listWhere"></include> |
| | | </update> |
| | | |
| | | <update id="updateByPrimaryKey" |
| | | parameterType="com.ks.lucky.pojo.DO.LuckyActivityJoinRecord">update lucky_activity_join_record set activity_id = #{activityId,jdbcType=BIGINT}, app_id = #{appId,jdbcType=BIGINT}, uid = #{uid,jdbcType=VARCHAR}, join_info = #{joinInfo,jdbcType=VARCHAR}, user_type = #{userType,jdbcType=INTEGER}, weight = #{weight,jdbcType=INTEGER}, create_time = #{createTime,jdbcType=TIMESTAMP} ,update_time =#{updateTime,jdbcType=TIMESTAMP} ,draw_state =#{drawState,jdbcType=INTEGER} where id = #{id,jdbcType=BIGINT}</update> |
| | | |
| | | |
| | | </mapper> |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8" ?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > |
| | | <mapper namespace="com.ks.lucky.mapper.LuckyActivityUserWeightRecordMapper" > |
| | | <resultMap id="BaseResultMap" type="com.ks.lucky.pojo.DO.LuckyActivityUserWeightRecord" > |
| | | <id column="id" property="id" jdbcType="BIGINT" /> |
| | | <result column="activity_id" property="activityId" jdbcType="BIGINT" /> |
| | | <result column="app_id" property="appId" jdbcType="BIGINT" /> |
| | | <result column="uid" property="uid" jdbcType="VARCHAR" /> |
| | | <result column="weight" property="weight" jdbcType="INTEGER" /> |
| | | <result column="title" property="title" jdbcType="VARCHAR" /> |
| | | <result column="`desc`" property="desc" jdbcType="VARCHAR" /> |
| | | <result column="create_time" property="createTime" jdbcType="TIMESTAMP" /> |
| | | <result column="update_time" property="updateTime" jdbcType="TIMESTAMP" /> |
| | | </resultMap> |
| | | <sql id="Base_Column_List" > |
| | | id, activity_id, app_id, uid, weight, title, `desc`, create_time, update_time |
| | | </sql> |
| | | <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long" > |
| | | select |
| | | <include refid="Base_Column_List" /> |
| | | from lucky_activity_weight_record |
| | | where id = #{id,jdbcType=BIGINT} |
| | | </select> |
| | | <delete id="deleteByPrimaryKey" parameterType="java.lang.Long" > |
| | | delete from lucky_activity_weight_record |
| | | where id = #{id,jdbcType=BIGINT} |
| | | </delete> |
| | | <insert id="insert" keyProperty="id" useGeneratedKeys="true" parameterType="com.ks.lucky.pojo.DO.LuckyActivityUserWeightRecord" > |
| | | insert into lucky_activity_weight_record (id, activity_id, app_id, |
| | | uid, weight, title, |
| | | `desc`, create_time, update_time |
| | | ) |
| | | values (#{id,jdbcType=BIGINT}, #{activityId,jdbcType=BIGINT}, #{appId,jdbcType=BIGINT}, |
| | | #{uid,jdbcType=VARCHAR}, #{weight,jdbcType=INTEGER}, #{title,jdbcType=VARCHAR}, |
| | | #{desc,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP} |
| | | ) |
| | | </insert> |
| | | <insert id="insertSelective" keyProperty="id" useGeneratedKeys="true" parameterType="com.ks.lucky.pojo.DO.LuckyActivityUserWeightRecord" > |
| | | insert into lucky_activity_weight_record |
| | | <trim prefix="(" suffix=")" suffixOverrides="," > |
| | | <if test="id != null" > |
| | | id, |
| | | </if> |
| | | <if test="activityId != null" > |
| | | activity_id, |
| | | </if> |
| | | <if test="appId != null" > |
| | | app_id, |
| | | </if> |
| | | <if test="uid != null" > |
| | | uid, |
| | | </if> |
| | | <if test="weight != null" > |
| | | weight, |
| | | </if> |
| | | <if test="title != null" > |
| | | title, |
| | | </if> |
| | | <if test="desc != null" > |
| | | desc, |
| | | </if> |
| | | <if test="createTime != null" > |
| | | create_time, |
| | | </if> |
| | | <if test="updateTime != null" > |
| | | update_time, |
| | | </if> |
| | | </trim> |
| | | <trim prefix="values (" suffix=")" suffixOverrides="," > |
| | | <if test="id != null" > |
| | | #{id,jdbcType=BIGINT}, |
| | | </if> |
| | | <if test="activityId != null" > |
| | | #{activityId,jdbcType=BIGINT}, |
| | | </if> |
| | | <if test="appId != null" > |
| | | #{appId,jdbcType=BIGINT}, |
| | | </if> |
| | | <if test="uid != null" > |
| | | #{uid,jdbcType=VARCHAR}, |
| | | </if> |
| | | <if test="weight != null" > |
| | | #{weight,jdbcType=INTEGER}, |
| | | </if> |
| | | <if test="title != null" > |
| | | #{title,jdbcType=VARCHAR}, |
| | | </if> |
| | | <if test="desc != null" > |
| | | #{desc,jdbcType=VARCHAR}, |
| | | </if> |
| | | <if test="createTime != null" > |
| | | #{createTime,jdbcType=TIMESTAMP}, |
| | | </if> |
| | | <if test="updateTime != null" > |
| | | #{updateTime,jdbcType=TIMESTAMP}, |
| | | </if> |
| | | </trim> |
| | | </insert> |
| | | <update id="updateByPrimaryKeySelective" parameterType="com.ks.lucky.pojo.DO.LuckyActivityUserWeightRecord" > |
| | | update lucky_activity_weight_record |
| | | <set > |
| | | <if test="activityId != null" > |
| | | activity_id = #{activityId,jdbcType=BIGINT}, |
| | | </if> |
| | | <if test="appId != null" > |
| | | app_id = #{appId,jdbcType=BIGINT}, |
| | | </if> |
| | | <if test="uid != null" > |
| | | uid = #{uid,jdbcType=VARCHAR}, |
| | | </if> |
| | | <if test="weight != null" > |
| | | weight = #{weight,jdbcType=INTEGER}, |
| | | </if> |
| | | <if test="title != null" > |
| | | title = #{title,jdbcType=VARCHAR}, |
| | | </if> |
| | | <if test="desc != null" > |
| | | `desc` = #{desc,jdbcType=VARCHAR}, |
| | | </if> |
| | | <if test="createTime != null" > |
| | | create_time = #{createTime,jdbcType=TIMESTAMP}, |
| | | </if> |
| | | <if test="updateTime != null" > |
| | | update_time = #{updateTime,jdbcType=TIMESTAMP}, |
| | | </if> |
| | | </set> |
| | | where id = #{id,jdbcType=BIGINT} |
| | | </update> |
| | | <update id="updateByPrimaryKey" parameterType="com.ks.lucky.pojo.DO.LuckyActivityUserWeightRecord" > |
| | | update lucky_activity_weight_record |
| | | set activity_id = #{activityId,jdbcType=BIGINT}, |
| | | app_id = #{appId,jdbcType=BIGINT}, |
| | | uid = #{uid,jdbcType=VARCHAR}, |
| | | weight = #{weight,jdbcType=INTEGER}, |
| | | title = #{title,jdbcType=VARCHAR}, |
| | | `desc` = #{desc,jdbcType=VARCHAR}, |
| | | create_time = #{createTime,jdbcType=TIMESTAMP}, |
| | | update_time = #{updateTime,jdbcType=TIMESTAMP} |
| | | where id = #{id,jdbcType=BIGINT} |
| | | </update> |
| | | </mapper> |
| | |
| | | |
| | | import com.ks.lucky.pojo.DO.LuckyActivity; |
| | | import com.ks.lucky.pojo.DO.LuckyActivityAwardResultExtra; |
| | | import com.ks.lucky.pojo.DO.LuckyActivityJoinAssist; |
| | | import com.ks.lucky.pojo.DO.LuckyActivityJoinRecord; |
| | | import org.junit.jupiter.api.Test; |
| | | import org.yeshi.utils.mybatis.ColumnParseUtil; |
| | | |
| | |
| | | |
| | | @Test |
| | | public void test(){ |
| | | ColumnParseUtil.parseColumn(LuckyActivity.class,"D:\\workspace\\DayBuy\\service-lucky\\src\\main\\resources\\mapper\\LuckyActivityAwardResultExtraMapper.xml"); |
| | | ColumnParseUtil.parseColumn(LuckyActivityJoinAssist.class,"D:\\workspace\\DayLucky\\service-lucky\\src\\main\\resources\\mapper\\LuckyActivityJoinAssistMapper.xml"); |
| | | } |
| | | } |
| | |
| | | import com.ks.lucky.exception.LuckyActivityException; |
| | | import com.ks.lucky.exception.LuckyActivityJoinAssistException; |
| | | import com.ks.lucky.exception.LuckyActivityJoinException; |
| | | import com.ks.lucky.pojo.DO.LuckyActivityJoinAssist; |
| | | import com.ks.lucky.pojo.DTO.JoinInfo; |
| | | import com.ks.lucky.remote.service.LuckyActivityJoinAssistService; |
| | | import com.ks.lucky.remote.service.LuckyActivityJoinService; |
| | |
| | | @Test |
| | | public void join() { |
| | | Long activityId = 7L; |
| | | String appKey = "1000001"; |
| | | Long appId = 10001L; |
| | | String uid = "123"; |
| | | JoinInfo joinInfo = JoinInfo.JoinInfoFactory.createAlipay("123123123123"); |
| | | try { |
| | | luckyActivityJoinService.join(activityId, appKey, uid, null, joinInfo); |
| | | luckyActivityJoinService.join(activityId, appId, uid, null, joinInfo); |
| | | } catch (LuckyActivityException e) { |
| | | e.printStackTrace(); |
| | | } catch (LuckyActivityJoinException e) { |
| | |
| | | @Test |
| | | public void assist() { |
| | | Long activityId = 7L; |
| | | String appKey = "1000001"; |
| | | Long appId = 10001L; |
| | | String uid = "12345"; |
| | | String targetUid = "123"; |
| | | |
| | | |
| | | try { |
| | | luckyActivityJoinAssistService.assist(activityId, appKey, uid, targetUid); |
| | | luckyActivityJoinAssistService.assist(activityId, appId, uid, targetUid, LuckyActivityJoinAssist.ActivityJoinAssistEvent.assist, 1); |
| | | } catch (LuckyActivityJoinAssistException e) { |
| | | e.printStackTrace(); |
| | | } catch (LuckyActivityException e) { |