瀏覽代碼

Merge remote-tracking branch 'origin/master'

Joburgess 5 年之前
父節點
當前提交
d485953bfa

+ 13 - 3
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/TenantEntryActivities.java

@@ -25,6 +25,8 @@ public class TenantEntryActivities {
 	/**  */
 	private java.math.BigDecimal discountPrice;
 	
+	private Integer purchaseMinutes;
+	
 	/**  */
 	private Integer giveMinutes;
 	
@@ -38,7 +40,7 @@ public class TenantEntryActivities {
 	private String condition;
 	
 	/**  */
-	private boolean delFlag;
+	private Boolean delFlag;
 	
 	/**  */
 	private java.util.Date createTime;
@@ -94,6 +96,14 @@ public class TenantEntryActivities {
 		return this.discountPrice;
 	}
 			
+	public Integer getPurchaseMinutes() {
+		return purchaseMinutes;
+	}
+
+	public void setPurchaseMinutes(Integer purchaseMinutes) {
+		this.purchaseMinutes = purchaseMinutes;
+	}
+
 	public void setGiveMinutes(Integer giveMinutes){
 		this.giveMinutes = giveMinutes;
 	}
@@ -126,11 +136,11 @@ public class TenantEntryActivities {
 		return this.condition;
 	}
 			
-	public void setDelFlag(boolean delFlag){
+	public void setDelFlag(Boolean delFlag){
 		this.delFlag = delFlag;
 	}
 	
-	public boolean isDelFlag(){
+	public Boolean getDelFlag(){
 		return this.delFlag;
 	}
 			

+ 22 - 6
mec-biz/src/main/java/com/ym/mec/biz/service/impl/TenantEntryActivitiesServiceImpl.java

@@ -4,6 +4,8 @@ import java.util.Date;
 
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Propagation;
+import org.springframework.transaction.annotation.Transactional;
 
 import com.ym.mec.biz.dal.dao.TenantEntryActivitiesDao;
 import com.ym.mec.biz.dal.entity.TenantEntryActivities;
@@ -16,11 +18,11 @@ import com.ym.mec.common.service.impl.BaseServiceImpl;
 public class TenantEntryActivitiesServiceImpl extends BaseServiceImpl<Integer, TenantEntryActivities> implements TenantEntryActivitiesService {
 
 	@Autowired
-	private TenantEntryActivitiesDao tenantEntryActivitesDao;
+	private TenantEntryActivitiesDao tenantEntryActivitiesDao;
 
 	@Override
 	public BaseDAO<Integer, TenantEntryActivities> getDAO() {
-		return tenantEntryActivitesDao;
+		return tenantEntryActivitiesDao;
 	}
 
 	@Override
@@ -32,25 +34,39 @@ public class TenantEntryActivitiesServiceImpl extends BaseServiceImpl<Integer, T
 
 		Date date = new Date();
 		if (tenantEntryActivites.getId() != null) {
-			TenantEntryActivities orginTenantEntryActivites = tenantEntryActivitesDao.get(tenantEntryActivites.getId());
+			TenantEntryActivities orginTenantEntryActivites = tenantEntryActivitiesDao.get(tenantEntryActivites.getId());
 
 			if (orginTenantEntryActivites == null) {
 				throw new BizException("操作失败,请检查输入参数");
 			}
 			tenantEntryActivites.setCreateTime(orginTenantEntryActivites.getCreateTime());
 			tenantEntryActivites.setUpdateTime(date);
-			tenantEntryActivitesDao.update(tenantEntryActivites);
+			tenantEntryActivitiesDao.update(tenantEntryActivites);
 		} else {
 			tenantEntryActivites.setCreateTime(date);
 			tenantEntryActivites.setUpdateTime(date);
-			tenantEntryActivitesDao.insert(tenantEntryActivites);
+			tenantEntryActivitiesDao.insert(tenantEntryActivites);
 		}
 		return true;
 	}
 
 	@Override
+	@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
 	public boolean enter(Integer userId, Integer activitiesId) {
-		return false;
+		TenantEntryActivities tenantEntryActivities = tenantEntryActivitiesDao.get(activitiesId);
+		if (tenantEntryActivities == null) {
+			throw new BizException("活动不存在");
+		}
+
+		Date date = new Date();
+		// 判断活动是否有效
+		if (tenantEntryActivities.getDelFlag() == true || date.before(tenantEntryActivities.getStartDate()) || date.after(tenantEntryActivities.getEndDate())) {
+			throw new BizException("活动已结束或未开始");
+		}
+		
+		//是否满足条件
+
+		return true;
 	}
 
 }

+ 6 - 2
mec-biz/src/main/resources/config/mybatis/TenantEntryActivitiesMapper.xml

@@ -11,6 +11,7 @@
 		<result column="detail_" property="detail" />
 		<result column="total_price_" property="totalPrice" />
 		<result column="discount_price_" property="discountPrice" />
+		<result column="purchase_minutes_" property="purchaseMinutes" />
 		<result column="give_minutes_" property="giveMinutes" />
 		<result column="start_date_" property="startDate" />
 		<result column="end_date_" property="endDate" />
@@ -48,8 +49,8 @@
 		<!-- <selectKey resultClass="int" keyProperty="id" > SELECT SEQ_WSDEFINITION_ID.nextval 
 			AS ID FROM DUAL </selectKey> -->
 		INSERT INTO tenant_entry_activities
-		(id_,name_,cover_img_,detail_,total_price_,discount_price_,give_minutes_,start_date_,end_date_,condition_,del_flag_,create_time_,update_time_)
-		VALUES(#{id},#{name},#{coverImg},#{detail},#{totalPrice},#{discountPrice},#{giveMinutes},#{startDate},#{endDate},#{condition},#{delFlag},#{createTime},#{updateTime})
+		(id_,name_,cover_img_,detail_,total_price_,discount_price_,purchase_minutes_,give_minutes_,start_date_,end_date_,condition_,del_flag_,create_time_,update_time_)
+		VALUES(#{id},#{name},#{coverImg},#{detail},#{totalPrice},#{discountPrice},#{purchaseMinutes},#{giveMinutes},#{startDate},#{endDate},#{condition},#{delFlag},#{createTime},#{updateTime})
 	</insert>
 
 	<!-- 根据主键查询一条记录 -->
@@ -71,6 +72,9 @@
 			<if test="id != null">
 				id_ = #{id},
 			</if>
+			<if test="purchaseMinutes != null">
+				purchase_minutes_ = #{purchaseMinutes},
+			</if>
 			<if test="giveMinutes != null">
 				give_minutes_ = #{giveMinutes},
 			</if>