Prechádzať zdrojové kódy

Merge branch 'master' of http://git.dayaedu.com/yonge/mec

zouxuan 4 rokov pred
rodič
commit
dfb160d076

+ 8 - 1
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/LuckDrawPrizeDao.java

@@ -20,11 +20,18 @@ public interface LuckDrawPrizeDao extends BaseDAO<Integer, LuckDrawPrize> {
 	 * @return
 	 */
 	LuckDrawPrize getLock(Integer id);
-	
+
 	/**
 	 * 批量新增
 	 * @param luckDrawPrizeList
 	 * @return
 	 */
 	int batchInsert(List<LuckDrawPrize> luckDrawPrizeList);
+
+	/**
+	 * 查询默认奖品
+	 * @param group
+	 * @return
+	 */
+	List<LuckDrawPrize> queryDefaultPrize(int group);
 }

+ 21 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/LuckStatisDto.java

@@ -1,13 +1,26 @@
 package com.ym.mec.biz.dal.dto;
 
+import io.swagger.annotations.ApiModelProperty;
+
 import java.math.BigDecimal;
 import java.util.List;
 
 public class LuckStatisDto {
     private List<OrderStatisDto> orderStatisDtoList;
+
+    @ApiModelProperty(value = "总预计人数",required = true)
     private Integer totalEstimatedNums = 0;
+
+    @ApiModelProperty(value = "总人数",required = true)
     private Integer totalNum = 0;
+
+    @ApiModelProperty(value = "总人次",required = true)
+    private Integer totalTimes = 0;
+
+    @ApiModelProperty(value = "总金额",required = true)
     private BigDecimal totalMoney = BigDecimal.ZERO;
+
+    @ApiModelProperty(value = "总转化率",required = true)
     private BigDecimal scale = BigDecimal.ZERO;
 
     public List<OrderStatisDto> getOrderStatisDtoList() {
@@ -49,4 +62,12 @@ public class LuckStatisDto {
     public void setScale(BigDecimal scale) {
         this.scale = scale;
     }
+
+    public Integer getTotalTimes() {
+        return totalTimes;
+    }
+
+    public void setTotalTimes(Integer totalTimes) {
+        this.totalTimes = totalTimes;
+    }
 }

+ 9 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/OrderStatisDto.java

@@ -7,6 +7,7 @@ public class OrderStatisDto {
     private String organName;
     private Integer estimatedNums = 0;
     private Integer nums = 0;
+    private Integer times = 0;
     private BigDecimal scale = BigDecimal.ZERO;
     private BigDecimal money = BigDecimal.ZERO;
 
@@ -57,4 +58,12 @@ public class OrderStatisDto {
     public void setScale(BigDecimal scale) {
         this.scale = scale;
     }
+
+    public Integer getTimes() {
+        return times;
+    }
+
+    public void setTimes(Integer times) {
+        this.times = times;
+    }
 }

+ 10 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/LuckDrawPrize.java

@@ -65,6 +65,8 @@ public class LuckDrawPrize {
 	private Date modifyOn;
 
 	private Integer groupId;
+	
+	private Boolean isDefault;
 
 	public Integer getId() {
 		return id;
@@ -145,4 +147,12 @@ public class LuckDrawPrize {
 	public void setGroupId(Integer groupId) {
 		this.groupId = groupId;
 	}
+
+	public Boolean getIsDefault() {
+		return isDefault;
+	}
+
+	public void setIsDefault(Boolean isDefault) {
+		this.isDefault = isDefault;
+	}
 }

+ 17 - 34
mec-biz/src/main/java/com/ym/mec/biz/service/impl/LuckDrawPrizeServiceImpl.java

@@ -2,10 +2,6 @@ package com.ym.mec.biz.service.impl;
 
 import java.util.Date;
 import java.util.List;
-import java.util.concurrent.Callable;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.FutureTask;
 
 import org.apache.commons.lang.StringUtils;
 import org.apache.commons.lang.math.RandomUtils;
@@ -100,15 +96,14 @@ public class LuckDrawPrizeServiceImpl extends BaseServiceImpl<Integer, LuckDrawP
 			int randomNum = RandomUtils.nextInt(DRAW_BASE_NUMBER);
 			double start = 0;
 			double chances = 0;
-			ExecutorService executor = Executors.newCachedThreadPool();
 			for (LuckDrawPrize luckDraw : luckDraws) {
 				chances += luckDraw.getChances();
 				// 抽中了
 				if (start <= randomNum && randomNum < (chances * DRAW_BASE_NUMBER)) {
-					final LuckDrawPrize syncLuckDraw = luckDrawPrizeDao.getLock(luckDraw.getId());
+					LuckDrawPrize syncLuckDraw = luckDrawPrizeDao.getLock(luckDraw.getId());
+					Date date = new Date();
 					// 检查库存
-					if (syncLuckDraw.getStock() > 0) {
-						Date date = new Date();
+					if (syncLuckDraw.getIsDefault() == true || syncLuckDraw.getStock() > 0) {
 						// 减库存
 						syncLuckDraw.setStock(syncLuckDraw.getStock() - 1);
 						syncLuckDraw.setModifyOn(date);
@@ -116,34 +111,22 @@ public class LuckDrawPrizeServiceImpl extends BaseServiceImpl<Integer, LuckDrawP
 						// 抽奖记录
 						luckDrawLogService.add(userId, syncLuckDraw.getId(), group);
 
-						// 给奖励
-						FutureTask<String> task = new FutureTask<String>(new Callable<String>() {
-							@Override
-							public String call() throws Exception {
-
-								switch (syncLuckDraw.getRewardType()) {
-								case COUPON:
-									break;
-
-								case POINTS:
-									break;
-
-								case CASH:
-									break;
-
-								default:
-									break;
-								}
-
-								return null;
-							}
-						});
-						executor.submit(task);
-						executor.shutdown();
-
 						return syncLuckDraw;
 					} else {
-						throw new BizException("系统繁忙,请重试");
+						// 库存不足,抽中默认奖品
+						List<LuckDrawPrize> defaultPrizeList = luckDrawPrizeDao.queryDefaultPrize(group);
+						if (defaultPrizeList != null && defaultPrizeList.size() > 0) {
+							syncLuckDraw = luckDrawPrizeDao.getLock(defaultPrizeList.get(0).getId());
+							// 减库存
+							syncLuckDraw.setStock(syncLuckDraw.getStock() - 1);
+							syncLuckDraw.setModifyOn(date);
+							update(syncLuckDraw);
+							// 抽奖记录
+							luckDrawLogService.add(userId, syncLuckDraw.getId(), group);
+							return syncLuckDraw;
+						} else {
+							throw new BizException("系统繁忙,请重试");
+						}
 					}
 				}
 				start = luckDraw.getChances() * DRAW_BASE_NUMBER;

+ 2 - 2
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentRegistrationServiceImpl.java

@@ -433,7 +433,7 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
 
     @Override
     @Transactional(rollbackFor = Exception.class)
-    public StudentPaymentOrder reAddOrder(Integer userId, BigDecimal amount, String orderNo, String paymentChannel, BigDecimal courseFee, List<MusicGroupSubjectGoodsGroup> goodsGroups, List<Goods> goodsList, List<Goods> otherGoodsList, String musicGroupId, StudentPaymentOrder oldOrder, List<CourseFormDto> courseForms, BigDecimal remitFee, BigDecimal courseRemitFee,List<MusicGroupPaymentCalenderCourseSettings> newCourses) {
+    public StudentPaymentOrder reAddOrder(Integer userId, BigDecimal amount, String orderNo, String paymentChannel, BigDecimal courseFee, List<MusicGroupSubjectGoodsGroup> goodsGroups, List<Goods> goodsList, List<Goods> otherGoodsList, String musicGroupId, StudentPaymentOrder oldOrder, List<CourseFormDto> courseForms, BigDecimal remitFee, BigDecimal courseRemitFee, List<MusicGroupPaymentCalenderCourseSettings> newCourses) {
         //关闭老订单
         oldOrder.setStatus(DealStatusEnum.CLOSE);
         studentPaymentOrderService.update(oldOrder);
@@ -1197,6 +1197,6 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
     @Override
     public BigDecimal getClassGroupCourseExpectPrice(List<Integer> classGroupIds) {
         List<CourseScheduleStudentPayment> classGroupNoStartCourse = courseScheduleStudentPaymentService.getClassGroupNoStartCourse(classGroupIds);
-        return BigDecimal.ZERO;
+        return classGroupNoStartCourse.stream().map(CourseScheduleStudentPayment::getExpectPrice).reduce(BigDecimal.ZERO, BigDecimal::add);
     }
 }

+ 1 - 1
mec-biz/src/main/resources/config/mybatis/CourseScheduleStudentPaymentMapper.xml

@@ -54,7 +54,7 @@
 	</insert>
     <insert id="batchInsert" parameterType="java.util.List" useGeneratedKeys="true" keyProperty="id_">
 		INSERT INTO course_schedule_student_payment (id_,group_type_,music_group_id_,course_schedule_id_,user_id_,expect_price_,
-				original_price_,actual_price_,create_time_,update_time_,settlement_time_,class_group_id_)
+				original_price_,actual_price_,create_time_,update_time_,settlement_time_,class_group_id_,batch_no_)
 		VALUE
 		<foreach collection="list" item="data" separator=",">
 			(#{data.id},#{data.groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{data.musicGroupId},#{data.courseScheduleId},#{data.userId},#{data.expectPrice},

+ 16 - 5
mec-biz/src/main/resources/config/mybatis/LuckDrawPrizeMapper.xml

@@ -10,12 +10,13 @@
 		<result column="reward_type_" property="rewardType" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler" />
 		<result column="memo_" property="memo" jdbcType="VARCHAR" />
 		<result column="group_id_" property="groupId" jdbcType="INTEGER" />
+		<result column="is_default_" property="isDefault" />
 		<result column="create_on_" property="createOn" jdbcType="TIMESTAMP" />
 		<result column="modify_on_" property="modifyOn" jdbcType="TIMESTAMP" />
 	</resultMap>
 
 	<sql id="Base_Column_List">
-		id_, name_, chances_, stock_, enabled_, reward_type_, memo_, group_id_, create_on_, modify_on_
+		id_, name_, chances_, stock_, enabled_, reward_type_, memo_, group_id_, is_default_, create_on_, modify_on_
 	</sql>
 
 	<sql id="queryCondition">
@@ -57,24 +58,24 @@
 	<insert id="insert" parameterType="com.ym.mec.biz.dal.entity.LuckDrawPrize" useGeneratedKeys="true" keyColumn="id"
             keyProperty="id">
 		insert into luck_draw_prize (id_, name_, chances_,
-		stock_, enabled_, reward_type_, memo_, group_id_, create_on_,
+		stock_, enabled_, reward_type_, memo_, group_id_, is_default_, create_on_,
 		modify_on_)
 		values (#{id,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR},
 		#{chances,jdbcType=DOUBLE},
-		#{stock,jdbcType=INTEGER}, #{enabled,jdbcType=BIT},#{rewardType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}, #{memo,jdbcType=VARCHAR}, #{groupId,jdbcType=INTEGER}, #{createOn,jdbcType=TIMESTAMP},
+		#{stock,jdbcType=INTEGER}, #{enabled,jdbcType=BIT},#{rewardType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}, #{memo,jdbcType=VARCHAR}, #{groupId,jdbcType=INTEGER}, #(isDefault), #{createOn,jdbcType=TIMESTAMP},
 		#{modifyOn,jdbcType=TIMESTAMP})
 	</insert>
 
 	<insert id="batchInsert" parameterType="java.util.List" useGeneratedKeys="true" keyColumn="id"
             keyProperty="id">
 		insert into luck_draw_prize (id_, name_, chances_,
-		stock_, enabled_, reward_type_, memo_, group_id_, create_on_,
+		stock_, enabled_, reward_type_, memo_, group_id_, is_default_, create_on_,
 		modify_on_) values 
 		<foreach collection="list" item="item" separator=",">
 		(#{item.id,jdbcType=INTEGER}, #{item.name,jdbcType=VARCHAR},
 		#{item.chances,jdbcType=DOUBLE}, #{item.stock,jdbcType=INTEGER}, 
 		#{item.enabled,jdbcType=BIT},#{item.rewardType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
-		#{item.memo,jdbcType=VARCHAR}, #{item.groupId,jdbcType=INTEGER}, now(), now())
+		#{item.memo,jdbcType=VARCHAR}, #{item.groupId,jdbcType=INTEGER}, #{item.isDefault}, now(), now())
 		</foreach>
 	</insert>
 
@@ -102,6 +103,9 @@
 			<if test="groupId != null">
 				group_id_ = #{groupId,jdbcType=INTEGER},
 			</if>
+			<if test="isDefault != null">
+				is_default_ = #{isDefault},
+			</if>
 			<if test="createOn != null">
 				create_on_ = #{createOn,jdbcType=TIMESTAMP},
 			</if>
@@ -130,4 +134,11 @@
 		from luck_draw_prize
 		where enabled_ = 1 and group_id_ = #{group} order by id_ asc
 	</select>
+
+	<select id="queryDefaultPrize" resultMap="BaseResultMap" parameterType="int">
+		select
+		<include refid="Base_Column_List" />
+		from luck_draw_prize
+		where enabled_ = 1 and group_id_ = #{group} and is_default_ = 1 order by id_ asc
+	</select>
 </mapper>

+ 3 - 2
mec-biz/src/main/resources/config/mybatis/StudentPaymentOrderMapper.xml

@@ -565,6 +565,7 @@
         <result property="organName" column="organName"/>
         <result property="estimatedNums" column="estimatedNums"/>
         <result property="nums" column="nums"/>
+        <result property="times" column="times"/>
         <result property="scale" column="scale"/>
         <result property="money" column="money"/>
     </resultMap>
@@ -729,8 +730,8 @@
     </select>
 
     <select id="doubleEleven2020Statis" resultMap="luckStatis">
-        SELECT o.id_ organId, o.name_ organName, SUM(spo.actual_amount_) money, COUNT(DISTINCT spo.user_id_) nums
-        FROM student_payment_order spo
+        SELECT o.id_ organId, o.name_ organName, SUM(spo.actual_amount_) money, COUNT(DISTINCT spo.user_id_) nums,
+        COUNT(spo.id_) times FROM student_payment_order spo
         LEFT JOIN organization o ON o.id_ = spo.organ_id_
         WHERE spo.type_ = 'DOUBLE_ELEVEN2020'
         AND spo.status_ = 'SUCCESS'

+ 1 - 1
mec-web/src/main/java/com/ym/mec/web/controller/MusicGroupPaymentCalenderController.java

@@ -131,7 +131,7 @@ public class MusicGroupPaymentCalenderController extends BaseController {
     }
 
     @ApiOperation(value = "获取指定学员在指定乐团下本次课排课时长")
-    @PostMapping("/getMusicCourseSettingsWithStudents")
+    @GetMapping("/getMusicCourseSettingsWithStudents")
     @PreAuthorize("@pcs.hasPermissions('musicGroupPaymentCalender/getMusicCourseSettingsWithStudents')")
     public HttpResponseResult<List<MusicGroupPaymentCalenderCourseSettings>> getMusicCourseSettingsWithStudents(String musicGroupId, String studentIds){
         if(StringUtils.isBlank(studentIds)){

+ 3 - 0
mec-web/src/main/java/com/ym/mec/web/controller/education/ActivityController.java

@@ -55,6 +55,7 @@ public class ActivityController extends BaseController {
         BigDecimal totalMoney = BigDecimal.ZERO;
         Integer totalEstimatedNums = 0;
         Integer totalNum = 0;
+        Integer totalTimes = 0;
         for (OrderStatisDto order : orders) {
             for (OrderStatisDto organNormalStudent : organNormalStudents) {
                 if (order.getOrganId().equals(organNormalStudent.getOrganId())) {
@@ -64,6 +65,7 @@ public class ActivityController extends BaseController {
             }
             totalEstimatedNums += order.getEstimatedNums();
             totalNum += order.getNums();
+            totalTimes += order.getTimes();
             totalMoney = totalMoney.add(order.getMoney());
             if (order.getEstimatedNums() <= 0) {
                 order.setScale(new BigDecimal(order.getNums()).multiply(new BigDecimal(100)).divide(new BigDecimal(1), 2, BigDecimal.ROUND_HALF_UP));
@@ -77,6 +79,7 @@ public class ActivityController extends BaseController {
         luckStatisDto.setOrderStatisDtoList(orders);
         luckStatisDto.setTotalEstimatedNums(totalEstimatedNums);
         luckStatisDto.setTotalNum(totalNum);
+        luckStatisDto.setTotalTimes(totalTimes);
         luckStatisDto.setTotalMoney(totalMoney);
         if (luckStatisDto.getTotalEstimatedNums() <= 0) {
             totalEstimatedNums = 1;