| | |
| | | |
| | | @NotNull(message = "开始时间不能为空") |
| | | private Date startTime; |
| | | |
| | | private Date preFinishTime; |
| | | |
| | | @NotNull(message = "结束时间不能为空") |
| | | private Date finishTime; |
| | | private Date actualFinishTime; |
| | | |
| | | private Date preOpenTime; |
| | | |
| | |
| | | this.startTime = startTime; |
| | | } |
| | | |
| | | public Date getFinishTime() { |
| | | return finishTime; |
| | | } |
| | | |
| | | public void setFinishTime(Date finishTime) { |
| | | this.finishTime = finishTime; |
| | | } |
| | | |
| | | public Date getPreOpenTime() { |
| | | return preOpenTime; |
| | | } |
| | |
| | | public void setUpdateTime(Date updateTime) { |
| | | this.updateTime = updateTime; |
| | | } |
| | | |
| | | public Date getPreFinishTime() { |
| | | return preFinishTime; |
| | | } |
| | | |
| | | public void setPreFinishTime(Date preFinishTime) { |
| | | this.preFinishTime = preFinishTime; |
| | | } |
| | | |
| | | public Date getActualFinishTime() { |
| | | return actualFinishTime; |
| | | } |
| | | |
| | | public void setActualFinishTime(Date actualFinishTime) { |
| | | this.actualFinishTime = actualFinishTime; |
| | | } |
| | | } |
| | |
| | | import com.ks.lucky.exception.LuckyActivityJoinAssistException; |
| | | import com.ks.lucky.pojo.DO.LuckyActivityJoinAssist; |
| | | |
| | | import javax.validation.constraints.NotEmpty; |
| | | import javax.validation.constraints.NotNull; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | * @param targetUid |
| | | * @throws LuckyActivityJoinAssistException |
| | | */ |
| | | public void assist(Long activityId, String appKey, String uid, String targetUid) throws LuckyActivityException, LuckyActivityJoinAssistException; |
| | | public void assist(@NotNull Long activityId, @NotEmpty String appKey, @NotEmpty String uid, @NotEmpty String targetUid) throws LuckyActivityException, LuckyActivityJoinAssistException; |
| | | |
| | | |
| | | /** |
| | |
| | | import com.ks.lucky.pojo.DO.LuckyActivityJoinRecord; |
| | | import com.ks.lucky.pojo.DTO.JoinInfo; |
| | | |
| | | import javax.validation.constraints.NotEmpty; |
| | | import javax.validation.constraints.NotNull; |
| | | |
| | | /** |
| | | * 活动参与记录服务 |
| | | */ |
| | |
| | | * @param activityId |
| | | * @param appKey |
| | | * @param uid |
| | | * @param weight |
| | | * @param joinInfo |
| | | * @throws LuckyActivityException |
| | | * @throws LuckyActivityJoinException |
| | | */ |
| | | public void join(Long activityId, String appKey, String uid, JoinInfo joinInfo) throws LuckyActivityException, LuckyActivityJoinException; |
| | | public void join(@NotNull Long activityId, @NotEmpty String appKey, @NotEmpty String uid, Integer weight, JoinInfo joinInfo) throws LuckyActivityException, LuckyActivityJoinException; |
| | | |
| | | |
| | | /** |
| | |
| | | import com.ks.lucky.service.impl.LuckyActivityJoinManager; |
| | | import org.apache.dubbo.config.annotation.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.validation.annotation.Validated; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.Date; |
| | |
| | | private LuckyActivityMapper luckyActivityMapper; |
| | | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @Validated |
| | | @Override |
| | | public void assist(Long activityId, String appKey, String uid, String targetUid) throws LuckyActivityException, LuckyActivityJoinAssistException { |
| | | |
| | |
| | | import com.ks.lucky.service.impl.LuckyActivityManager; |
| | | import org.apache.dubbo.config.annotation.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.validation.annotation.Validated; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.Date; |
| | |
| | | |
| | | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @Validated |
| | | @Override |
| | | public void join(Long activityId, String appKey, String uid, JoinInfo joinInfo) throws LuckyActivityException, LuckyActivityJoinException { |
| | | public void join(Long activityId, String appKey, 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, "已经参加"); |
| | | } |
| | | |
| | | if (weight == null) { |
| | | weight = 1; |
| | | } |
| | | |
| | | record = new LuckyActivityJoinRecord(); |
| | | record.setActivityId(activityId); |
| | | record.setAppId(appId); |
| | |
| | | record.setJoinInfo(joinInfo.toString()); |
| | | record.setUid(uid); |
| | | record.setUserType(LuckyActivityJoinRecord.USER_TYPE_REAL); |
| | | record.setWeight(1); |
| | | record.setWeight(weight); |
| | | record.setCreateTime(new Date()); |
| | | luckyActivityJoinRecordMapper.insertSelective(record); |
| | | luckyActivityManager.addJoinCount(activityId, record.getWeight()); |
| | | luckyActivityManager.addJoinCount(activityId, 1); |
| | | } |
| | | |
| | | @Override |
| | |
| | | throw new LuckyActivityException(1, "活动开始时间不能小于当前时间"); |
| | | } |
| | | |
| | | if (activity.getFinishTime() != null && activity.getStartTime().getTime() >= activity.getFinishTime().getTime()) { |
| | | if (activity.getPreFinishTime() != null && activity.getStartTime().getTime() >= activity.getPreFinishTime().getTime()) { |
| | | throw new LuckyActivityException(1, "活动开始结束时间不能小于开始时间"); |
| | | } |
| | | |
| | |
| | | <result column="state" jdbcType="INTEGER" property="state"/> |
| | | <result column="state_remarks" jdbcType="VARCHAR" property="stateRemarks"/> |
| | | <result column="start_time" jdbcType="TIMESTAMP" property="startTime"/> |
| | | <result column="finish_time" jdbcType="TIMESTAMP" property="finishTime"/> |
| | | <result column="pre_finish_time" jdbcType="TIMESTAMP" property="preFinishTime"/> |
| | | <result column="actual_finish_time" jdbcType="TIMESTAMP" property="actualFinishTime"/> |
| | | <result column="pre_open_time" jdbcType="TIMESTAMP" property="preOpenTime"/> |
| | | <result column="actual_open_time" jdbcType="TIMESTAMP" property="actualOpenTime"/> |
| | | <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/> |
| | |
| | | </resultMap> |
| | | <sql id="Base_Column_List"> |
| | | id, app_id, sponsor_id, `name`, material_poster, material_tag_image, material_, `desc`, |
| | | max_person_count,current_person_count, state, state_remarks, start_time, finish_time, pre_open_time,actual_open_time, create_time, |
| | | max_person_count,current_person_count, state, state_remarks, start_time, pre_finish_time,actual_finish_time, pre_open_time,actual_open_time, create_time, |
| | | update_time |
| | | </sql> |
| | | <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap"> |
| | |
| | | `name`, material_poster, material_tag_image, |
| | | material_, `desc`, max_person_count, current_person_count, |
| | | state, state_remarks, start_time, |
| | | finish_time, pre_open_time, actual_open_time,create_time, |
| | | pre_finish_time,actual_finish_time, pre_open_time, actual_open_time,create_time, |
| | | update_time) |
| | | values (#{id,jdbcType=BIGINT}, #{appId,jdbcType=BIGINT}, #{sponsorId,jdbcType=BIGINT}, |
| | | #{name,jdbcType=VARCHAR}, #{materialPoster,jdbcType=VARCHAR}, #{materialTagImage,jdbcType=VARCHAR}, |
| | | #{material,jdbcType=VARCHAR}, #{desc,jdbcType=VARCHAR}, #{maxPersonCount,jdbcType=INTEGER}, #{currentPersonCount,jdbcType=INTEGER}, |
| | | #{state,jdbcType=INTEGER}, #{stateRemarks,jdbcType=VARCHAR}, #{startTime,jdbcType=TIMESTAMP}, |
| | | #{finishTime,jdbcType=TIMESTAMP}, #{preOpenTime,jdbcType=TIMESTAMP}, #{actualOpenTime,jdbcType=TIMESTAMP}, #{createTime,jdbcType=TIMESTAMP}, |
| | | #{preFinishTime,jdbcType=TIMESTAMP}, #{actualFinishTime,jdbcType=TIMESTAMP}, #{preOpenTime,jdbcType=TIMESTAMP}, #{actualOpenTime,jdbcType=TIMESTAMP}, #{createTime,jdbcType=TIMESTAMP}, |
| | | #{updateTime,jdbcType=TIMESTAMP}) |
| | | </insert> |
| | | <insert id="insertSelective" useGeneratedKeys="true" keyProperty="id" parameterType="com.ks.lucky.pojo.DO.LuckyActivity"> |
| | |
| | | <if test="startTime != null"> |
| | | start_time, |
| | | </if> |
| | | <if test="finishTime != null"> |
| | | finish_time, |
| | | <if test="preFinishTime != null"> |
| | | pre_finish_time, |
| | | </if> |
| | | |
| | | <if test="actualFinishTime != null"> |
| | | actual_finish_time, |
| | | </if> |
| | | |
| | | |
| | | <if test="preOpenTime != null"> |
| | | pre_open_time, |
| | | </if> |
| | |
| | | <if test="startTime != null"> |
| | | #{startTime,jdbcType=TIMESTAMP}, |
| | | </if> |
| | | <if test="finishTime != null"> |
| | | #{finishTime,jdbcType=TIMESTAMP}, |
| | | <if test="preFinishTime != null"> |
| | | #{preFinishTime,jdbcType=TIMESTAMP}, |
| | | </if> |
| | | |
| | | <if test="actualFinishTime != null"> |
| | | #{actualFinishTime,jdbcType=TIMESTAMP}, |
| | | </if> |
| | | |
| | | <if test="preOpenTime != null"> |
| | | #{preOpenTime,jdbcType=TIMESTAMP}, |
| | | </if> |
| | |
| | | <if test="startTime != null"> |
| | | start_time = #{startTime,jdbcType=TIMESTAMP}, |
| | | </if> |
| | | <if test="finishTime != null"> |
| | | finish_time = #{finishTime,jdbcType=TIMESTAMP}, |
| | | <if test="preFinishTime != null"> |
| | | pre_finish_time = #{preFinishTime,jdbcType=TIMESTAMP}, |
| | | </if> |
| | | |
| | | <if test="actualFinishTime != null"> |
| | | actual_finish_time = #{actualFinishTime,jdbcType=TIMESTAMP}, |
| | | </if> |
| | | |
| | | <if test="preOpenTime != null"> |
| | | pre_open_time = #{preOpenTime,jdbcType=TIMESTAMP}, |
| | | </if> |
| | |
| | | state = #{state,jdbcType=INTEGER}, |
| | | state_remarks = #{stateRemarks,jdbcType=VARCHAR}, |
| | | start_time = #{startTime,jdbcType=TIMESTAMP}, |
| | | finish_time = #{finishTime,jdbcType=TIMESTAMP}, |
| | | pre_finish_time = #{preFinishTime,jdbcType=TIMESTAMP}, |
| | | actual_finish_time = #{actualFinishTime,jdbcType=TIMESTAMP}, |
| | | pre_open_time = #{preOpenTime,jdbcType=TIMESTAMP}, |
| | | actual_open_time = #{actualOpenTime,jdbcType=TIMESTAMP}, |
| | | create_time = #{createTime,jdbcType=TIMESTAMP}, |
| | |
| | | |
| | | |
| | | <if test="query.minFinishTime!=null"> |
| | | and finish_time>=#{query.minFinishTime} |
| | | and pre_finish_time>=#{query.minFinishTime} |
| | | </if> |
| | | |
| | | <if test="query.maxFinishTime!=null"> |
| | | and #{query.maxFinishTime}>finish_time |
| | | and #{query.maxFinishTime}>pre_finish_time |
| | | </if> |
| | | |
| | | </sql> |
| | |
| | | package com.ks; |
| | | |
| | | import com.ks.lucky.pojo.DO.LuckyActivity; |
| | | import com.ks.lucky.pojo.DO.LuckyActivityAwardResultExtra; |
| | | import org.junit.jupiter.api.Test; |
| | | import org.yeshi.utils.mybatis.ColumnParseUtil; |
| | |
| | | |
| | | @Test |
| | | public void test(){ |
| | | ColumnParseUtil.parseColumn(LuckyActivityAwardResultExtra.class,"D:\\workspace\\DayBuy\\service-lucky\\src\\main\\resources\\mapper\\LuckyActivityAwardResultExtraMapper.xml"); |
| | | ColumnParseUtil.parseColumn(LuckyActivity.class,"D:\\workspace\\DayBuy\\service-lucky\\src\\main\\resources\\mapper\\LuckyActivityAwardResultExtraMapper.xml"); |
| | | } |
| | | } |
| | |
| | | activity.setAppId(4L); |
| | | activity.setMaxPersonCount(100); |
| | | activity.setStartTime(new Date()); |
| | | activity.setFinishTime(new Date()); |
| | | activity.setPreFinishTime(new Date()); |
| | | activity.setMaterialPoster("http://"); |
| | | activity.setSponsorId(1L); |
| | | activity.setName("测试活动1"); |
| | |
| | | String uid = "123"; |
| | | JoinInfo joinInfo = JoinInfo.JoinInfoFactory.createAlipay("123123123123"); |
| | | try { |
| | | luckyActivityJoinService.join(activityId, appKey, uid, joinInfo); |
| | | luckyActivityJoinService.join(activityId, appKey, uid, null, joinInfo); |
| | | } catch (LuckyActivityException e) { |
| | | e.printStackTrace(); |
| | | } catch (LuckyActivityJoinException e) { |