瀏覽代碼

Merge branch 'zx_saas_vip_activity' of http://git.dayaedu.com/yonge/mec into master_saas

zouxuan 1 年之前
父節點
當前提交
34d1b14f10

+ 6 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/VipGroupActivity.java

@@ -129,6 +129,9 @@ public class VipGroupActivity{
 	@ApiModelProperty(value = "线下课是否参与梯度奖励")
 	private Integer offlineClassJoinGradientRewards = 0;
 
+	@ApiModelProperty(value = "是否固定课程数量")
+	private Boolean fixedCourseNumFlag = false;
+
 	@ApiModelProperty(value = "最少课程数量")
 	private Integer minCourseNum = -1;
 
@@ -180,5 +183,8 @@ public class VipGroupActivity{
 	@ApiModelProperty(value = "单价")
 	private BigDecimal singlePrice;
 
+	@ApiModelProperty(value = "活动价用于前端展示")
+	private BigDecimal displayPrice;
+
 	private Integer tenantId = TenantContextHolder.getTenantId();
 }

+ 8 - 3
mec-biz/src/main/java/com/ym/mec/biz/service/impl/VipGroupActivityServiceImpl.java

@@ -608,9 +608,14 @@ public class VipGroupActivityServiceImpl extends BaseServiceImpl<Integer, VipGro
 			}
 		}
 		//计算支付金额
-		BigDecimal actualAmount = this.getActivityPrice(vipGroupActivity,payParam.getOrganId(),new BigDecimal(1));
-		actualAmount = actualAmount.multiply(vipGroupActivity.getDiscount()).divide(new BigDecimal(100), 0, ROUND_UP);
-		actualAmount = actualAmount.multiply(new BigDecimal(payParam.getBuyNum()));
+		BigDecimal actualAmount;
+		if(vipGroupActivity.getFixedCourseNumFlag()){
+			actualAmount = vipGroupActivity.getMarketPrice();
+		}else {
+			actualAmount = this.getActivityPrice(vipGroupActivity,payParam.getOrganId(),new BigDecimal(1));
+			actualAmount = actualAmount.multiply(vipGroupActivity.getDiscount()).divide(new BigDecimal(100), 0, ROUND_UP);
+			actualAmount = actualAmount.multiply(new BigDecimal(payParam.getBuyNum()));
+		}
 		// 判断是否存在支付中的记录
 		List<StudentPaymentOrder> list = studentPaymentOrderService
 				.queryByCondition(GroupType.ACTIVITY,

+ 21 - 18
mec-biz/src/main/java/com/ym/mec/biz/service/impl/VipGroupServiceImpl.java

@@ -2,8 +2,7 @@ package com.ym.mec.biz.service.impl;
 
 import static com.ym.mec.biz.dal.enums.GroupType.VIP;
 import static com.ym.mec.biz.dal.enums.SysUserRoleEnum.ORGAN_MANAGER;
-import static java.math.BigDecimal.ROUND_DOWN;
-import static java.math.BigDecimal.ZERO;
+import static java.math.BigDecimal.*;
 
 import java.math.BigDecimal;
 import java.time.LocalDate;
@@ -1966,6 +1965,14 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 
         VipGroupSalarySettlementTypeDto vipOfflineSalarySettlement = null;
         VipGroupSalarySettlementTypeDto giveVipOfflineSalarySettlement = null;
+        BigDecimal onlineClassesUnitPrice = vipGroup.getOnlineClassesUnitPrice();
+        if (Objects.isNull(onlineClassesUnitPrice)) {
+            throw new BizException("课程单价异常");
+        }
+        BigDecimal offlineClassesUnitPrice = vipGroup.getOfflineClassesUnitPrice();
+        if (Objects.isNull(offlineClassesUnitPrice)) {
+            throw new BizException("课程单价异常");
+        }
         BigDecimal discount = new BigDecimal(100);
         if (vipGroup.getVipGroupActivityId() != null) {
             VipGroupActivity vipGroupActivity = vipGroupActivityDao.get(vipGroup.getVipGroupActivityId());
@@ -1976,6 +1983,8 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
             }
             vipOfflineSalarySettlement = vipGroupSalarySettlementDto.getOfflineSalarySettlement();
             giveVipOfflineSalarySettlement = vipGroupSalarySettlementDto.getGiveVipOfflineSalarySettlement();
+            onlineClassesUnitPrice = onlineClassesUnitPrice.multiply(discount).divide(new BigDecimal(100), 0, ROUND_UP);
+            offlineClassesUnitPrice = offlineClassesUnitPrice.multiply(discount).divide(new BigDecimal(100), 0, ROUND_UP);
 
             //是否是赠送课程
             ActivityUserMapper activityUserMapper = activityUserMapperService.findVipUserMapper(vipGroup.getId(), "VIP", null);
@@ -1991,16 +2000,8 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 
         BigDecimal offlineClassNum = new BigDecimal(vipGroup.getOfflineClassesNum());
         BigDecimal onlineClassNum = new BigDecimal(vipGroup.getOnlineClassesNum());
-        BigDecimal onlineClassesUnitPrice = vipGroup.getOnlineClassesUnitPrice();
-        if (Objects.isNull(onlineClassesUnitPrice)) {
-            throw new BizException("课程单价异常");
-        }
         BigDecimal onlineVipGroupCharge = onlineClassesUnitPrice.multiply(onlineClassNum);
 
-        BigDecimal offlineClassesUnitPrice = vipGroup.getOfflineClassesUnitPrice();
-        if (Objects.isNull(offlineClassesUnitPrice)) {
-            throw new BizException("课程单价异常");
-        }
         BigDecimal offlineVipGroupCharge = offlineClassesUnitPrice.multiply(offlineClassNum);
         BigDecimal teacherOfflineSalary = BigDecimal.ZERO;
         BigDecimal giveTeacherOfflineSalary = BigDecimal.ZERO;
@@ -2094,6 +2095,14 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 
         VipGroupSalarySettlementTypeDto vipOfflineSalarySettlement = null;
         VipGroupSalarySettlementTypeDto giveVipOfflineSalarySettlement = null;
+        BigDecimal onlineClassesUnitPrice = vipGroup.getOnlineClassesUnitPrice();
+        if (Objects.isNull(onlineClassesUnitPrice)) {
+            throw new BizException("课程单价异常");
+        }
+        BigDecimal offlineClassesUnitPrice = vipGroup.getOfflineClassesUnitPrice();
+        if (Objects.isNull(offlineClassesUnitPrice)) {
+            throw new BizException("课程单价异常");
+        }
         BigDecimal discount = new BigDecimal(100);
         if (vipGroup.getVipGroupActivityId() != null) {
             VipGroupActivity vipGroupActivity = vipGroupActivityDao.get(vipGroup.getVipGroupActivityId());
@@ -2104,20 +2113,14 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
             }
             vipOfflineSalarySettlement = vipGroupSalarySettlementDto.getOfflineSalarySettlement();
             giveVipOfflineSalarySettlement = vipGroupSalarySettlementDto.getGiveVipOfflineSalarySettlement();
+            onlineClassesUnitPrice = onlineClassesUnitPrice.multiply(discount).divide(new BigDecimal(100), 0, ROUND_UP);
+            offlineClassesUnitPrice = offlineClassesUnitPrice.multiply(discount).divide(new BigDecimal(100), 0, ROUND_UP);
         }
 
         BigDecimal offlineClassNum = new BigDecimal(vipGroup.getOfflineClassesNum());
         BigDecimal onlineClassNum = new BigDecimal(vipGroup.getOnlineClassesNum());
-        BigDecimal onlineClassesUnitPrice = vipGroup.getOnlineClassesUnitPrice();
-        if (Objects.isNull(onlineClassesUnitPrice)) {
-            throw new BizException("课程单价异常");
-        }
         BigDecimal onlineVipGroupCharge = onlineClassesUnitPrice.multiply(onlineClassNum);
 
-        BigDecimal offlineClassesUnitPrice = vipGroup.getOfflineClassesUnitPrice();
-        if (Objects.isNull(offlineClassesUnitPrice)) {
-            throw new BizException("课程单价异常");
-        }
         BigDecimal offlineVipGroupCharge = offlineClassesUnitPrice.multiply(offlineClassNum);
         BigDecimal teacherOfflineSalary = BigDecimal.ZERO;
         BigDecimal giveTeacherOfflineSalary = BigDecimal.ZERO;

+ 4 - 3
mec-biz/src/main/resources/config/mybatis/VipGroupActivityMapper.xml

@@ -56,6 +56,7 @@
 		<result property="code" column="code_"/>
 		<result property="activityChannel" column="activity_channel_"/>
 		<result property="originalPrice" column="original_price_"/>
+		<result property="fixedCourseNumFlag" column="fixed_course_num_flag_"/>
         <result column="tenant_id_" property="tenantId"/>
 	</resultMap>
 	
@@ -79,14 +80,14 @@
 										,member_rank_id_,member_time_,give_member_rank_id_,give_member_time_,course_type_,
 		                                activity_type_,give_sign_course_time_,is_pay_to_balance_,teach_mode_,give_teach_mode_,
 		                                period_,give_period_,status_,market_price_,give_allow_online_to_offline_,give_prize_num_,
-		                                activity_channel_,original_price_,tenant_id_,give_coupon_id_,give_coupon_num_)
+		                                activity_channel_,original_price_,tenant_id_,give_coupon_id_,give_coupon_num_,fixed_course_num_flag_)
 		VALUES(#{name},#{description},#{vipGroupCategoryIdList},#{startTime},#{endTime},#{organId},#{coursesStartTime},#{coursesEndTime},
 		       now(),now(),#{salarySettlementJson},#{delFlag},#{onlineClassJoinGradientRewards},
 		       #{offlineClassJoinGradientRewards},#{minCourseNum},#{maxCourseNum},#{studentMaxUsedTimes},#{applyToStudentType},#{allowOnlineToOffline},
 			   #{singleCourseTime},#{discount},#{fullMinusCourseTimes},#{giveCourseType},#{giveCategoryId},#{giveCourseNum}
 				  ,#{memberRankId},#{memberTime},#{giveMemberRankId},#{giveMemberTime},#{courseType},#{activityType},#{giveSingleCourseTime},
 		       #{isPayToBalance},#{teachMode},#{giveTeachMode},#{periodEnum,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{givePeriodEnum,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{status},
-		       #{marketPrice},#{giveAllowOnlineToOffline},#{givePrizeNum},#{activityChannel},#{originalPrice},#{tenantId},#{giveCouponId},#{giveCouponNum})
+		       #{marketPrice},#{giveAllowOnlineToOffline},#{givePrizeNum},#{activityChannel},#{originalPrice},#{tenantId},#{giveCouponId},#{giveCouponNum},#{fixedCourseNumFlag})
 	</insert>
 	
 	<!-- 根据主键查询一条记录 -->
@@ -108,7 +109,7 @@
 		allow_online_to_offline_=#{allowOnlineToOffline},end_time_ = #{endTime},market_price_ = #{marketPrice},update_time_ = NOW(),
 		give_allow_online_to_offline_ = #{giveAllowOnlineToOffline},
 		give_prize_num_ = #{givePrizeNum},activity_channel_ = #{activityChannel},original_price_ = #{originalPrice} ,
-									  give_coupon_id_ = #{giveCouponId} ,give_coupon_num_ = #{giveCouponNum}
+									  give_coupon_id_ = #{giveCouponId} ,give_coupon_num_ = #{giveCouponNum},fixed_course_num_flag_ = #{fixedCourseNumFlag}
 		WHERE id_ = #{id} and tenant_id_ = #{tenantId}
 	</update>
 

+ 14 - 0
mec-student/src/main/java/com/ym/mec/student/controller/ActivityController.java

@@ -27,6 +27,8 @@ import java.math.BigDecimal;
 import java.util.*;
 import java.util.stream.Collectors;
 
+import static java.math.BigDecimal.ROUND_UP;
+
 @RequestMapping("activity")
 @Api(tags = "活动")
 @RestController
@@ -154,6 +156,12 @@ public class ActivityController extends BaseController {
         Map<String, String> categoryMap = vipGroupCategoryDao.findConditionCategorys().stream().collect(Collectors.toMap(e-> e.getId().toString(), ConditionDto::getName));
         vipGroupActivity.setVipGroupCategoryNames(categoryMap.get(vipGroupActivity.getVipGroupCategoryIdList()));
         vipGroupActivity.setGiveCategoryName(categoryMap.get(vipGroupActivity.getGiveCategoryId()));
+        //如果是固定金额
+        if(vipGroupActivity.getFixedCourseNumFlag()){
+            vipGroupActivity.setDisplayPrice(vipGroupActivity.getMarketPrice());
+        }else {
+            vipGroupActivity.setDisplayPrice(vipGroupActivity.getSinglePrice().multiply(vipGroupActivity.getDiscount()).divide(new BigDecimal(100), 0, ROUND_UP));
+        }
         vipGroupActivityService.setActivityType(vipGroupActivity);
         return succeed(vipGroupActivity);
     }
@@ -186,6 +194,12 @@ public class ActivityController extends BaseController {
             for (VipGroupActivity activity : vipGroupActivities) {
                 activity.setVipGroupCategoryNames(categoryMap.get(activity.getVipGroupCategoryIdList()));
                 activity.setGiveCategoryName(categoryMap.get(activity.getGiveCategoryId()));
+                //如果是固定金额
+                if(activity.getFixedCourseNumFlag()){
+                    activity.setDisplayPrice(activity.getMarketPrice());
+                }else {
+                    activity.setDisplayPrice(activity.getSinglePrice().multiply(activity.getDiscount()).divide(new BigDecimal(100), 0, ROUND_UP));
+                }
                 vipGroupActivityService.setActivityType(activity);
             }
         }