|
@@ -4169,15 +4169,35 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
|
|
|
List<VipGroupActivity> vipGroupActivities = vipGroupActivityDao.queryByIds(order.getActivityId());
|
|
|
List<ActivityUserMapper> activityUserMappers = new ArrayList<>();
|
|
|
Integer times = 0;
|
|
|
- for (VipGroupActivity e : vipGroupActivities) {
|
|
|
+
|
|
|
+ BigDecimal couponRemitFee = order.getCouponRemitFee();
|
|
|
+ BigDecimal subCouponRemitFee = couponRemitFee;
|
|
|
+ BigDecimal totalMarketPrice = vipGroupActivities.stream().map(e -> e.getMarketPrice()).reduce(ZERO, BigDecimal::add);
|
|
|
+
|
|
|
+ for (int i = 0; i < vipGroupActivities.size(); i++) {
|
|
|
+ VipGroupActivity activity = vipGroupActivities.get(i);
|
|
|
ActivityUserMapper activityUserMapper = new ActivityUserMapper();
|
|
|
- activityUserMapper.setActivityId(e.getId());
|
|
|
+ activityUserMapper.setActivityId(activity.getId());
|
|
|
activityUserMapper.setUserId(order.getUserId());
|
|
|
activityUserMapper.setPaymentOrderId(order.getId());
|
|
|
activityUserMapper.setTeacherId(student.getTeacherId());
|
|
|
activityUserMapper.setVipFlag(1);
|
|
|
activityUserMappers.add(activityUserMapper);
|
|
|
- times = times + e.getGivePrizeNum();
|
|
|
+ if(couponRemitFee.compareTo(ZERO) > 0){
|
|
|
+ if(i == vipGroupActivities.size() - 1){
|
|
|
+ activityUserMapper.setActualPrice(activity.getMarketPrice().subtract(subCouponRemitFee));
|
|
|
+ }else {
|
|
|
+ //获取比例
|
|
|
+ BigDecimal ratioAmount = activity.getMarketPrice().divide(totalMarketPrice, 6, BigDecimal.ROUND_HALF_UP);
|
|
|
+ //获取分配的减免金额
|
|
|
+ BigDecimal multiply = ratioAmount.multiply(couponRemitFee).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ subCouponRemitFee = subCouponRemitFee.subtract(multiply);
|
|
|
+ activityUserMapper.setActualPrice(activity.getMarketPrice().subtract(multiply));
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ activityUserMapper.setActualPrice(activity.getMarketPrice());
|
|
|
+ }
|
|
|
+ times = times + activity.getGivePrizeNum();
|
|
|
}
|
|
|
//赠送抽奖机会
|
|
|
if(times > 0){
|