瀏覽代碼

收支统计

刘俊驰 3 天之前
父節點
當前提交
27bae343cd

+ 1 - 1
cooleshow-app/src/main/java/com/yonge/cooleshow/student/controller/UserOrderController.java

@@ -318,7 +318,7 @@ public class UserOrderController extends BaseController {
         // 新增数据
         UserPaymentOrderWrapper.PaymentConfig paymentConfig = userPaymentCoreService.executeOrderCreate(order);
         if (Objects.isNull(paymentConfig)) {
-            throw com.microsvc.toolkit.common.webportal.exception.BizException.from("下单失败");
+            throw new BizException("下单失败");
         }
 
         return R.from(paymentConfig);

+ 1 - 0
cooleshow-common/src/main/java/com/yonge/cooleshow/common/enums/payment/EPaymentType.java

@@ -13,6 +13,7 @@ public enum EPaymentType {
     SVIP("开通会员 SVIP"),
     PRACTICE("趣纠课购买"),
     LIVE("直播课购买"),
+    GROUP("小组课购买"),
     VIDEO("视频课购买"),
     MUSIC("单曲点播"),
     PIANO_ROOM("琴房时长"),

+ 2 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/dao/CourseGroupDao.java

@@ -274,5 +274,7 @@ public interface CourseGroupDao extends BaseMapper<CourseGroup> {
     void updateCompleteCourseNum(@Param("groupIds") List<Long> groupIds);
 
     void updateExposureNum(@Param("groupId") Long groupId, @Param("exposureNum") Integer exposureNum);
+
+    int updateLockNum(@Param("groupId") Long groupId, @Param("num") int num);
 }
 

+ 6 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/entity/CourseGroup.java

@@ -127,5 +127,11 @@ public class CourseGroup implements Serializable {
     @ApiModelProperty(value = "更新时间")
     private Date updatedTime;
 
+
+    @TableField("lock_num_")
+    @ApiModelProperty(value = "小组课订单锁定数")
+    private Integer lockNum;
+
+
 }
 

+ 25 - 7
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/CourseGroupServiceImpl.java

@@ -110,6 +110,9 @@ public class CourseGroupServiceImpl extends ServiceImpl<CourseGroupDao, CourseGr
     private CouponInfoService couponInfoService;
 
     @Autowired
+    private CourseGroupDao courseGroupDao;
+
+    @Autowired
     private PlatformCashAccountRecordService platformCashAccountRecordService;
 
     @Autowired
@@ -380,12 +383,8 @@ public class CourseGroupServiceImpl extends ServiceImpl<CourseGroupDao, CourseGr
         batchCheckStudentCourseTime(studentId, courseList, CourseSchedule::getStartTime, CourseSchedule::getEndTime);
 
         // 小组课判断购买人数
-        if (orderGoodsInfo.getGoodType() == GoodTypeEnum.GROUP) {
-            String configValue = sysConfigService.findConfigValue(SysConfigConstant.GROUP_MAX_STUDENT_NUM);
-            if (StringUtils.isNotBlank(configValue)) {
-                int maxStudentNum = Integer.parseInt(configValue);
-
-            }
+        if (orderGoodsInfo.getGoodType() == GoodTypeEnum.GROUP && courseGroup.getLockNum()>=courseGroup.getMaxStudentNum()) {
+            throw new BizException("小组课已满员!");
         }
 
 
@@ -598,6 +597,19 @@ public class CourseGroupServiceImpl extends ServiceImpl<CourseGroupDao, CourseGr
         if (CollectionUtils.isEmpty(courseList)) {
             throw new BizException("课程组课程不存在!");
         }
+
+        // 小组课判断购买人数
+        if (orderGoodsInfo.getGoodType() == GoodTypeEnum.GROUP ) {
+            if (courseGroup.getLockNum() >= courseGroup.getMaxStudentNum()) {
+                throw new BizException("小组课已满员!");
+            }
+            // 更新小组课锁定人数
+            int i = courseGroupDao.updateLockNum(groupId, 1);
+            if (i == 0) {
+                throw new BizException("小组课已满员!");
+            }
+        }
+
         // 写入学生购买课程记录 换到订单写入成功后写入
         buyLiveCourseAfter(orderGoodsInfo.getOrderNo(), orderGoodsInfo.getUserId(), courseList,
                 courseGroup,orderGoodsInfo.getUserOrderDetail().getActualPrice());
@@ -1262,6 +1274,12 @@ public class CourseGroupServiceImpl extends ServiceImpl<CourseGroupDao, CourseGr
     public void buyLiveCourseCancel(UserOrderDetailVo orderParam) {
         courseScheduleStudentPaymentService.remove(Wrappers.<CourseScheduleStudentPayment>lambdaQuery()
                 .eq(CourseScheduleStudentPayment::getOrderNo, orderParam.getOrderNo()));
+
+
+        if (orderParam.getGoodType() == GoodTypeEnum.GROUP ) {
+            // 减少订单锁定
+            courseGroupDao.updateLockNum(orderParam.getBizId(), -1);
+        }
     }
 
     /**
@@ -1752,7 +1770,7 @@ public class CourseGroupServiceImpl extends ServiceImpl<CourseGroupDao, CourseGr
             throw new BizException("只能下架销售中的课程组");
         } else if (dto.getStatus() == 1  && !CourseGroupEnum.OUT_SALE.getCode().equals(liveCourseGroupVo.getStatus())) {
             throw new BizException("只能上架被下架的课程组");
-        } else if ( LocalDate.now().compareTo(liveCourseGroupVo.getSalesEndDate().toInstant().atZone(ZoneId.systemDefault()).toLocalDate()) > 0) {
+        } else if (LocalDate.now().isAfter(liveCourseGroupVo.getSalesEndDate().toInstant().atZone(ZoneId.systemDefault()).toLocalDate())) {
             throw new BizException("课程组售卖时间已结束,不能操作");
         }
 

+ 12 - 1
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/UserAccountServiceImpl.java

@@ -300,6 +300,7 @@ public class UserAccountServiceImpl extends ServiceImpl<UserAccountDao, UserAcco
         BigDecimal practiceAmount = BigDecimal.ZERO;
         BigDecimal vipCourseAmount = BigDecimal.ZERO;
         BigDecimal liveAmount = BigDecimal.ZERO;
+        BigDecimal groupAmount = BigDecimal.ZERO;
         BigDecimal videoAmount = BigDecimal.ZERO;
         BigDecimal musicAmount = BigDecimal.ZERO;
 
@@ -317,6 +318,7 @@ public class UserAccountServiceImpl extends ServiceImpl<UserAccountDao, UserAcco
             practiceAmount = practiceAmount.add(info.getPracticeAmount());
             vipCourseAmount = vipCourseAmount.add(info.getVipCourseAmount());
             liveAmount = liveAmount.add(info.getLiveAmount());
+            groupAmount = groupAmount.add(info.getGroupAmount());
             videoAmount = videoAmount.add(info.getVideoAmount());
             musicAmount = musicAmount.add(info.getMusicAmount());
 
@@ -331,7 +333,7 @@ public class UserAccountServiceImpl extends ServiceImpl<UserAccountDao, UserAcco
         AccountTotal total = new AccountTotal();
 
         total.setTotalInAmount(
-                practiceAmount.add(liveAmount).add(videoAmount).add(musicAmount)
+                practiceAmount.add(liveAmount).add(groupAmount).add(videoAmount).add(musicAmount)
                         .add(liveShareAmount).add(videoShareAmount).add(musicShareAmount)
                         .add(vipShareAmount).add(mallShareAmount).add(actiRegistShareAmount).add(albumShareAmount)
                         .add(vipCourseAmount)
@@ -352,6 +354,12 @@ public class UserAccountServiceImpl extends ServiceImpl<UserAccountDao, UserAcco
                     .divide(total.getTotalInAmount(), 4, RoundingMode.HALF_UP)
                     .multiply(new BigDecimal("100")));
 
+
+            total.setGroupAmount(groupAmount);
+            total.setGroupRate(total.getGroupAmount()
+                    .divide(total.getTotalInAmount(), 4, RoundingMode.HALF_UP)
+                    .multiply(new BigDecimal("100")));
+
             total.setVideoAmount(videoAmount);
             total.setVideoRate(total.getVideoAmount()
                     .divide(total.getTotalInAmount(), 4, RoundingMode.HALF_UP)
@@ -398,6 +406,7 @@ public class UserAccountServiceImpl extends ServiceImpl<UserAccountDao, UserAcco
                             .subtract(total.getPracticeRate())
                             .subtract(total.getVipCourseRate())
                             .subtract(total.getLiveRate())
+                            .subtract(total.getGroupRate())
                             .subtract(total.getVideoRate())
                             .subtract(total.getMusicRate())
                             .subtract(total.getMusicShareRate())
@@ -550,6 +559,8 @@ public class UserAccountServiceImpl extends ServiceImpl<UserAccountDao, UserAcco
                 null == info.getVipCourseAmount() ? BigDecimal.ZERO.setScale(2, RoundingMode.HALF_UP) : info.getVipCourseAmount().setScale(2, RoundingMode.HALF_UP));
         info.setLiveAmount(
                 null == info.getLiveAmount() ? BigDecimal.ZERO.setScale(2, RoundingMode.HALF_UP) : info.getLiveAmount().setScale(2, RoundingMode.HALF_UP));
+        info.setGroupAmount(
+                null == info.getLiveAmount() ? BigDecimal.ZERO.setScale(2, RoundingMode.HALF_UP) : info.getGroupAmount().setScale(2, RoundingMode.HALF_UP));
         info.setVideoAmount(
                 null == info.getVideoAmount() ? BigDecimal.ZERO.setScale(2, RoundingMode.HALF_UP) : info.getVideoAmount().setScale(2, RoundingMode.HALF_UP));
         info.setMusicAmount(

+ 1 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/UserOrderServiceImpl.java

@@ -219,6 +219,7 @@ public class UserOrderServiceImpl extends ServiceImpl<UserOrderDao, UserOrder> i
         orderCancel.put(GoodTypeEnum.VIDEO, recordService::buyVideoCourseFailed);
         //直播课购买
         orderCancel.put(GoodTypeEnum.LIVE, courseGroupService::buyLiveCourseCancel);
+        orderCancel.put(GoodTypeEnum.GROUP, courseGroupService::buyLiveCourseCancel);
         // 曲目购买
         orderCancel.put(GoodTypeEnum.MUSIC, musicSheetService::buyMusicSheetCancel);
         // 专辑购买

+ 6 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/vo/res/AccountTotal.java

@@ -2,6 +2,7 @@ package com.yonge.cooleshow.biz.dal.vo.res;
 
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
 
 import java.math.BigDecimal;
 import java.util.List;
@@ -10,6 +11,7 @@ import java.util.List;
  * @Author: liweifan
  * @Data: 2022/4/21 11:29
  */
+@Data
 @ApiModel(value = "AccountTotal", description = "用户账户统计对象")
 public class AccountTotal {
     @ApiModelProperty("总收入")
@@ -26,6 +28,10 @@ public class AccountTotal {
     private BigDecimal liveAmount = BigDecimal.ZERO;
     @ApiModelProperty("直播课-百分比")
     private BigDecimal liveRate = BigDecimal.ZERO;
+    @ApiModelProperty("小组课")
+    private BigDecimal groupAmount = BigDecimal.ZERO;
+    @ApiModelProperty("小组课-百分比")
+    private BigDecimal groupRate = BigDecimal.ZERO;
     @ApiModelProperty("视频课")
     private BigDecimal videoAmount = BigDecimal.ZERO;
     @ApiModelProperty("视频课-百分比")

+ 6 - 0
cooleshow-user/user-biz/src/main/resources/config/mybatis/CourseGroupMapper.xml

@@ -1116,4 +1116,10 @@
         </where>
         GROUP BY cg.id_
     </select>
+
+    <update id="updateLockNum">
+        update course_group
+        set lock_num_ = lock_num_ + #{num}
+        where id_ = #{groupId} and lock_num_ + #{num} &lt;= max_student_num_ and lock_num_ + #{num} &gt;= 0
+    </update>
 </mapper>

+ 3 - 1
cooleshow-user/user-biz/src/main/resources/config/mybatis/UserAccountMapper.xml

@@ -84,7 +84,7 @@
                 and a.post_status_ = 'RECORDED' and a.in_or_out_ = 'IN') as amountRecorded,
             (select sum(a.trans_amount_) from user_cash_account_record a where a.account_id_ = t.user_id_
                 and a.post_status_ in ('RECORDED','WAIT') and a.in_or_out_ = 'IN'
-                and a.biz_type_ in ('LIVE_SHARE','VIDEO_SHARE','MUSIC_SHARE','ALBUM_SHARE','VIP_SHARE','MALL_SHARE','ACTI_REGIST_SHARE')) as amountShare
+                and a.biz_type_ in ('LIVE_SHARE','GROUP_SHARE','VIDEO_SHARE','MUSIC_SHARE','ALBUM_SHARE','VIP_SHARE','MALL_SHARE','ACTI_REGIST_SHARE')) as amountShare
         FROM user_cash_account t
         where t.user_id_ = #{id}
     </select>
@@ -106,6 +106,7 @@
             sum(a.practiceAmount) as practiceAmount,
             sum(a.vipCourseAmount) as vipCourseAmount,
             sum(a.liveAmount) as liveAmount,
+            sum(a.groupAmount) as groupAmount,
             sum(a.videoAmount) as videoAmount,
             sum(a.musicAmount) as musicAmount,
             sum(a.liveShareAmount) as liveShareAmount,
@@ -122,6 +123,7 @@
                 sum(if(t.biz_type_ = 'PRACTICE',t.trans_amount_,0)) as practiceAmount,
                 sum(if(t.biz_type_ = 'VIP_COURSE',t.trans_amount_,0)) as vipCourseAmount,
                 sum(if(t.biz_type_ = 'LIVE',t.trans_amount_,0)) as liveAmount,
+                sum(if(t.biz_type_ = 'GROUP',t.trans_amount_,0)) as groupAmount,
                 sum(if(t.biz_type_ = 'VIDEO',t.trans_amount_,0)) as videoAmount,
                 sum(if(t.biz_type_ = 'MUSIC',t.trans_amount_,0)) as musicAmount,
                 sum(if(t.biz_type_ = 'LIVE_SHARE',t.trans_amount_,0)) as liveShareAmount,

+ 3 - 3
cooleshow-user/user-biz/src/main/resources/config/mybatis/UserAccountRecordMapper.xml

@@ -239,7 +239,7 @@
                 max(t.update_time_) as create_time_,
                 max(t.update_time_) as update_time_
             from user_cash_account_record t
-            where t.biz_type_ = 'LIVE'
+            where t.biz_type_ in ('LIVE','GROUP')
             <include refid="selectCondition"/>
             group by t.account_id_,t.in_or_out_,t.post_status_,t.biz_type_,biz_id_,biz_name_
             union all
@@ -256,10 +256,10 @@
                 t.update_time_ as create_time_,
                 t.update_time_ as update_time_
             from user_cash_account_record t
-            where t.biz_type_ != 'LIVE'
+            where t.biz_type_ not in ('LIVE','GROUP')
             <include refid="selectCondition"/>
         ) t
-        left join course_schedule a on t.biz_id_ = a.id_ and t.biz_type_ in ('PRACTICE','LIVE','VIP_COURSE')
+        left join course_schedule a on t.biz_id_ = a.id_ and t.biz_type_ in ('PRACTICE','LIVE','GROUP','VIP_COURSE')
         order by t.update_time_ desc,t.id_ desc
     </select>