فهرست منبع

管乐迷商城改造

zouxuan 1 سال پیش
والد
کامیت
48caed3254

+ 24 - 11
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupPaymentCalenderGoodsServiceImpl.java

@@ -1,12 +1,12 @@
 package com.ym.mec.biz.service.impl;
 
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ym.mec.biz.dal.dao.GoodsDao;
 import com.ym.mec.biz.dal.dao.MusicGroupPaymentCalenderGoodsDao;
 import com.ym.mec.biz.dal.dto.MusicGroupPaymentBaseCalender;
-import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender;
-import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderActivity;
-import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderGoods;
-import com.ym.mec.biz.dal.entity.VipGroupActivity;
+import com.ym.mec.biz.dal.entity.*;
+import com.ym.mec.biz.service.GoodsService;
 import com.ym.mec.biz.service.MusicGroupPaymentCalenderBaseService;
 import com.ym.mec.biz.service.MusicGroupPaymentCalenderGoodsService;
 import org.apache.commons.collections.CollectionUtils;
@@ -17,6 +17,7 @@ import org.springframework.stereotype.Service;
 
 import java.math.BigDecimal;
 import java.util.List;
+import java.util.Map;
 import java.util.stream.Collectors;
 
 @Service("musicGroupPaymentCalenderGoodsService")
@@ -30,6 +31,8 @@ public class MusicGroupPaymentCalenderGoodsServiceImpl extends ServiceImpl<Music
         return this.baseMapper;
     }
 
+    private GoodsDao goodsDao;
+
     @Override
     public MusicGroupPaymentCalender.PaymentCalenderStatusEnum checkComponentAmount(MusicGroupPaymentBaseCalender baseCalender) {
         return null;
@@ -37,23 +40,33 @@ public class MusicGroupPaymentCalenderGoodsServiceImpl extends ServiceImpl<Music
 
     @Override
     public BigDecimal getActualAmount(MusicGroupPaymentBaseCalender baseCalender) {
-        return null;
+        List<MusicGroupPaymentCalenderGoods> goodsList = baseCalender.getCalenderGoodsList();
+        if(CollectionUtils.isNotEmpty(goodsList)){
+            //计算现价
+            return JSONObject.parseObject(baseCalender.getCalenderFeeJson()).getBigDecimal("allTotal");
+        }
+        return BigDecimal.ZERO;
     }
 
     @Override
     public BigDecimal getOriginalAmount(MusicGroupPaymentBaseCalender musicGroupPaymentBaseCalender) {
         List<MusicGroupPaymentCalenderGoods> goodsList = musicGroupPaymentBaseCalender.getCalenderGoodsList();
-//        if(CollectionUtils.isNotEmpty(goodsList)){
-//            List<Integer> collect = calenderActivityList.stream().map(e -> e.getActivityId()).collect(Collectors.toList());
-//            List<VipGroupActivity> vipGroupActivities = vipGroupActivityDao.queryByIds(StringUtils.join(collect, ","));
-//            return vipGroupActivities.stream().map(e->fun.apply(e)).reduce(BigDecimal.ZERO,BigDecimal::add);
-//        }
+        if(CollectionUtils.isNotEmpty(goodsList)){
+            List<Integer> goodsIds = goodsList.stream().map(e -> e.getGoodsId()).collect(Collectors.toList());
+            List<Goods> goodies = goodsDao.getGoodies(goodsIds);
+            Map<Integer,Goods> goodsMap = goodies.stream().collect(Collectors.toMap(Goods::getId, e -> e));
+            //计算原价
+            return goodsList.stream().map(e -> {
+                Goods goods = goodsMap.get(e.getGoodsId());
+                return goods.getGroupPurchasePrice().multiply(new BigDecimal(e.getNum()));
+            }).reduce(BigDecimal.ZERO,BigDecimal::add);
+        }
         return BigDecimal.ZERO;
     }
 
     @Override
     public BigDecimal getCurrentAmount(MusicGroupPaymentBaseCalender baseCalender) {
-        return null;
+        return getOriginalAmount(baseCalender);
     }
 
     @Override

+ 17 - 8
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupPaymentCalenderServiceImpl.java

@@ -2,7 +2,6 @@ package com.ym.mec.biz.service.impl;
 
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
-import com.ym.mec.auth.api.client.SysUserFeignService;
 import com.ym.mec.auth.api.entity.SysUser;
 import com.ym.mec.biz.dal.dao.*;
 import com.ym.mec.biz.dal.dto.*;
@@ -25,24 +24,17 @@ import com.ym.mec.common.exception.BizException;
 import com.ym.mec.common.page.PageInfo;
 import com.ym.mec.common.service.IdGeneratorService;
 import com.ym.mec.common.service.impl.BaseServiceImpl;
-import com.ym.mec.common.tenant.TenantContextHolder;
 import com.ym.mec.thirdparty.message.MessageSenderPluginContext;
 import com.ym.mec.util.collection.MapUtil;
-import com.ym.mec.util.excel.POIUtil;
-import com.ym.mec.util.ini.IniFileUtil;
 import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.core.io.ClassPathResource;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Isolation;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.ui.ModelMap;
-import org.springframework.web.multipart.MultipartFile;
 
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
 import java.math.BigDecimal;
 import java.util.*;
 import java.util.concurrent.CompletableFuture;
@@ -112,6 +104,8 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
     @Autowired
     private CloudTeacherOrderService cloudTeacherOrderService;
     @Autowired
+    private MusicGroupPaymentCalenderAddressService musicGroupPaymentCalenderAddressService;
+    @Autowired
     private MusicGroupPaymentCalenderGoodsServiceImpl musicGroupPaymentCalenderGoodsService;
     @Autowired
     private MusicGroupPaymentCalenderActivityServiceImpl musicGroupPaymentCalenderActivityService;
@@ -298,6 +292,7 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 
         BigDecimal originalTotalAmount = courseOriginalAmount.add(memberOriginalAmount)
                 .add(activityOriginalAmount)
+                .add(goodsOriginalAmount)
                 .add(repairOriginalAmount).setScale(0, BigDecimal.ROUND_HALF_UP);
 
         //计算缴费项目总金额(前端录入)
@@ -309,6 +304,7 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 
         BigDecimal actualTotalAmount = courseActualAmount.add(memberActualAmount)
                 .add(repairActualAmount)
+                .add(goodsActualAmount)
                 .add(activityActualAmount).setScale(0, BigDecimal.ROUND_HALF_UP);
         //标记是否云教练缴费
         if(musicGroupPaymentCalender.getPayUserType() == STUDENT && musicGroup.getCourseViewType() == CourseViewTypeEnum.MEMBER_FEE){
@@ -350,7 +346,9 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
                 BigDecimal memberCurrentAmount = musicGroupPaymentCalenderMemberService.getCurrentAmount(musicGroupPaymentBaseCalender);
                 BigDecimal repairCurrentAmount = musicGroupPaymentCalenderRepairService.getCurrentAmount(musicGroupPaymentBaseCalender);
                 BigDecimal activityCurrentAmount = musicGroupPaymentCalenderActivityService.getCurrentAmount(musicGroupPaymentBaseCalender);
+                BigDecimal goodsCurrentAmount = musicGroupPaymentCalenderGoodsService.getCurrentAmount(musicGroupPaymentBaseCalender);
                 BigDecimal currentTotalAmount = courseCurrentAmount.add(memberCurrentAmount)
+                        .add(goodsCurrentAmount)
                         .add(repairCurrentAmount)
                         .add(activityCurrentAmount).setScale(0, BigDecimal.ROUND_HALF_UP);
                 status = actualTotalAmount.compareTo(currentTotalAmount) == 0 ? NO : AUDITING;
@@ -434,6 +432,15 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
             musicGroupPaymentCalender.setMusicGroupPaymentCalenderCourseSettingsList(courseSettingsList);
             musicGroupPaymentCalenderCourseSettingsService.batchInsert(musicGroupPaymentCalender);
         }
+        //保存商品缴费信息
+        if (musicGroupPaymentCalender.getPaymentType() == GOODS_PURCHASE) {
+            if(CollectionUtils.isNotEmpty(musicGroupPaymentBaseCalender.getCalenderGoodsList())){
+                musicGroupPaymentCalenderGoodsService.saveBatch(musicGroupPaymentBaseCalender.getCalenderGoodsList());
+            }
+            if(musicGroupPaymentBaseCalender.getCalenderAddress() != null){
+                musicGroupPaymentCalenderAddressService.save(musicGroupPaymentBaseCalender.getCalenderAddress());
+            }
+        }
 
         // 如果是报名,需要修改乐团状态
         if (musicGroupPaymentCalender.getPaymentType() == MUSIC_APPLY) {
@@ -538,6 +545,8 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
         if (calenderMember != null) {
             result.put("memberPrivilegesItemList", memberRankPrivilegesService.queryByMemberRankId(calenderMember.getMemberRankSettingId()));
         }
+        //获取商品采购信息
+        result.put("goods",musicGroupPaymentCalenderGoodsService.lambdaQuery().eq(MusicGroupPaymentCalenderGoods::getCalenderId,calenderId).list());
         return result;
     }