Parcourir la source

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

# Conflicts:
#	mec-web/src/main/java/com/ym/mec/web/controller/MusicGroupPaymentCalenderController.java
zouxuan il y a 4 ans
Parent
commit
c7da622b6d

+ 6 - 1
mec-biz/src/main/java/com/ym/mec/biz/service/GoodsCategoryService.java

@@ -2,10 +2,13 @@ package com.ym.mec.biz.service;
 
 import com.ym.mec.biz.dal.dto.SubjectGoodsDto;
 import com.ym.mec.biz.dal.entity.GoodsCategory;
+import com.ym.mec.biz.dal.enums.AccountType;
 import com.ym.mec.biz.dal.page.GoodsCategoryQueryInfo;
 import com.ym.mec.common.page.PageInfo;
 import com.ym.mec.common.service.BaseService;
 
+import java.util.List;
+
 public interface GoodsCategoryService extends BaseService<Integer, GoodsCategory> {
     /**
      * 新增、修改商品类型
@@ -26,4 +29,6 @@ public interface GoodsCategoryService extends BaseService<Integer, GoodsCategory
      * @param goodsIds
      */
     void updateSubjectGoods(Long subjectGoodsMapperId, String goodsIds);
-}
+
+    void goodsTest(List<Integer> goodsIds);
+}

+ 1 - 1
mec-biz/src/main/java/com/ym/mec/biz/service/GoodsService.java

@@ -119,5 +119,5 @@ public interface GoodsService extends BaseService<Integer, Goods> {
      */
     List<GoodsSellDto> queryGoodsSellDtos(String goodsId);
 
-    void getGoodsTest(Integer goodsId);
+    void getGoodsTest(List<Integer> goodsIds);
 }

+ 13 - 1
mec-biz/src/main/java/com/ym/mec/biz/service/MusicGroupPaymentCalenderCourseSettingsService.java

@@ -3,6 +3,18 @@ package com.ym.mec.biz.service;
 import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderCourseSettings;
 import com.ym.mec.common.service.BaseService;
 
+import java.util.List;
+
 public interface MusicGroupPaymentCalenderCourseSettingsService extends BaseService<Integer, MusicGroupPaymentCalenderCourseSettings> {
 
-}
+    /**
+     * @describe 获取指定学员在指定乐团下本次课排课时长
+     * @author Joburgess
+     * @date 2020.11.02
+     * @param musicGroupId:
+     * @param studentIds:
+     * @return java.util.List<com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderCourseSettings>
+     */
+    List<MusicGroupPaymentCalenderCourseSettings> getMusicCourseSettingsWithStudents(String musicGroupId, List<Integer> studentIds);
+
+}

+ 17 - 1
mec-biz/src/main/java/com/ym/mec/biz/service/impl/GoodsCategoryServiceImpl.java

@@ -6,15 +6,18 @@ import com.ym.mec.biz.dal.dto.SubjectGoodsDto;
 import com.ym.mec.biz.dal.entity.Goods;
 import com.ym.mec.biz.dal.entity.GoodsCategory;
 import com.ym.mec.biz.dal.entity.SubjectGoodsMapper;
+import com.ym.mec.biz.dal.enums.AccountType;
 import com.ym.mec.biz.dal.enums.GoodsType;
 import com.ym.mec.biz.dal.page.GoodsCategoryQueryInfo;
 import com.ym.mec.biz.service.GoodsCategoryService;
+import com.ym.mec.biz.service.GoodsService;
 import com.ym.mec.common.dal.BaseDAO;
 import com.ym.mec.common.page.PageInfo;
 import com.ym.mec.common.service.impl.BaseServiceImpl;
 import com.ym.mec.util.collection.MapUtil;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Propagation;
 import org.springframework.transaction.annotation.Transactional;
 
 import java.util.*;
@@ -82,4 +85,17 @@ public class GoodsCategoryServiceImpl extends BaseServiceImpl<Integer, GoodsCate
 		subjectGoodsMapper.setUpdateTime(new Date());
 		subjectGoodsMapperDao.update(subjectGoodsMapper);
 	}
-}
+
+	@Autowired
+	private GoodsService goodsService;
+
+	@Override
+	@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
+	public void goodsTest(List<Integer> goodsIds) {
+		goodsTest1(goodsIds);
+	}
+
+	public void goodsTest1(List<Integer> goodsIds) {
+		goodsService.subtractStock(goodsIds, AccountType.INTERNAL);
+	}
+}

+ 44 - 8
mec-biz/src/main/java/com/ym/mec/biz/service/impl/GoodsServiceImpl.java

@@ -447,14 +447,50 @@ public class GoodsServiceImpl extends BaseServiceImpl<Integer, Goods>  implement
 
 	@Override
 	@Transactional(rollbackFor = Exception.class, isolation = Isolation.READ_COMMITTED)
-	public void getGoodsTest(Integer goodsId) {
-		List<Goods> tempGoodsList = goodsDao.lockGoods(Arrays.asList(goodsId));
-		Goods goods = goodsDao.get(goodsId);
-		if(!tempGoodsList.get(0).getSellCount().equals(goods.getSellCount())){
-			System.out.println("-----------------------------------" + goods);
+	public void getGoodsTest(List<Integer> goodsIds) {
+		List<Goods> tempGoodsList = goodsDao.lockGoods(new ArrayList<>(goodsIds));
+		Map<Integer, Goods> idTempGoodsMap = tempGoodsList.stream().collect(Collectors.toMap(Goods::getId, g -> g));
+		List<GoodsProcurement> goodsProcurements = new ArrayList<>();
+		for (Integer goodsId : goodsIds) {
+			Goods tempGoods = goodsDao.get(goodsId);
+			List<Goods> childGoods = new ArrayList<>();
+			if(StringUtils.isBlank(tempGoods.getComplementGoodsIdList())){
+				childGoods.add(tempGoods);
+			}else{
+				List<Integer> complementGoodsIds = Arrays.stream(tempGoods.getComplementGoodsIdList().split(",")).map(s -> Integer.valueOf(s)).collect(Collectors.toList());
+				childGoods = goodsDao.lockGoods(complementGoodsIds);
+			}
+			for (Goods goods : childGoods) {
+				GoodsProcurement goodsProcurement = null;
+				if(StockType.INTERNAL.equals(goods.getStockType())||(StockType.ALL.equals(goods.getStockType())&&AccountType.INTERNAL.equals(AccountType.INTERNAL))){
+					goodsProcurement = goodsProcurementDao.getWithStockSurplusProcurement(goods.getId());
+					goods.setStockCount(new AtomicInteger(goods.getStockCount()).decrementAndGet());
+					if(Objects.nonNull(goodsProcurement)){
+						goodsProcurement.setStockSoldNum(new AtomicInteger(goodsProcurement.getStockSoldNum()).incrementAndGet());
+					}
+				}else if(StockType.EXTERNAL.equals(goods.getStockType())||(StockType.ALL.equals(goods.getStockType())&&AccountType.EXTERNAL.equals(AccountType.EXTERNAL))){
+					goodsProcurement = goodsProcurementDao.getWithTaxStockSurplusProcurement(goods.getId());
+					goods.setTaxStockCount(new AtomicInteger(goods.getTaxStockCount()).decrementAndGet());
+					if(Objects.nonNull(goodsProcurement)){
+						goodsProcurement.setTaxStockSoldNum(new AtomicInteger(goodsProcurement.getTaxStockSoldNum()).incrementAndGet());
+					}
+				}
+
+				goods.setSellCount(new AtomicInteger(goods.getSellCount()).incrementAndGet());
+
+				goodsDao.update(goods);
+				if(Objects.nonNull(goodsProcurement)){
+					goodsProcurementDao.update(goodsProcurement);
+				}else{
+					goodsProcurement = new GoodsProcurement(goods.getId());
+				}
+				if(StringUtils.isNotBlank(tempGoods.getComplementGoodsIdList())){
+					goodsProcurement.setParentGoodsId(tempGoods.getId());
+				}
+
+				goodsProcurements.add(goodsProcurement);
+			}
 		}
-		goods.setSellCount(new AtomicInteger(goods.getSellCount()).incrementAndGet());
-		goodsDao.update(goods);
 	}
 
 	@Override
@@ -468,7 +504,7 @@ public class GoodsServiceImpl extends BaseServiceImpl<Integer, Goods>  implement
 		Map<Integer, Goods> idTempGoodsMap = tempGoodsList.stream().collect(Collectors.toMap(Goods::getId, g -> g));
 		List<GoodsProcurement> goodsProcurements = new ArrayList<>();
 		for (Integer goodsId : goodsIds) {
-			Goods tempGoods = idTempGoodsMap.get(goodsId);
+			Goods tempGoods = tempGoodsList.get(goodsId);
 			List<Goods> childGoods = new ArrayList<>();
 			if(StringUtils.isBlank(tempGoods.getComplementGoodsIdList())){
 				childGoods.add(tempGoods);

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

@@ -1,5 +1,10 @@
 package com.ym.mec.biz.service.impl;
 
+import com.ym.mec.biz.dal.dao.MusicGroupPaymentCalenderDao;
+import com.ym.mec.biz.dal.dao.MusicGroupPaymentCalenderDetailDao;
+import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender;
+import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderDetail;
+import com.ym.mec.common.exception.BizException;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -8,16 +13,45 @@ import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderCourseSettings;
 import com.ym.mec.biz.service.MusicGroupPaymentCalenderCourseSettingsService;
 import com.ym.mec.common.dal.BaseDAO;
 import com.ym.mec.common.service.impl.BaseServiceImpl;
+import org.springframework.util.CollectionUtils;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.stream.Collectors;
 
 @Service
 public class MusicGroupPaymentCalenderCourseSettingsServiceImpl extends BaseServiceImpl<Integer, MusicGroupPaymentCalenderCourseSettings>  implements MusicGroupPaymentCalenderCourseSettingsService {
 	
 	@Autowired
 	private MusicGroupPaymentCalenderCourseSettingsDao musicGroupPaymentCalenderCourseSettingsDao;
+	@Autowired
+	private MusicGroupPaymentCalenderDao musicGroupPaymentCalenderDao;
+	@Autowired
+	private MusicGroupPaymentCalenderDetailDao musicGroupPaymentCalenderDetailDao;
 
 	@Override
 	public BaseDAO<Integer, MusicGroupPaymentCalenderCourseSettings> getDAO() {
 		return musicGroupPaymentCalenderCourseSettingsDao;
 	}
-	
-}
+
+	@Override
+	public List<MusicGroupPaymentCalenderCourseSettings> getMusicCourseSettingsWithStudents(String musicGroupId, List<Integer> studentIds) {
+		MusicGroupPaymentCalender musicGroupUnusedFirstPaymentCalender = musicGroupPaymentCalenderDao.getMusicGroupUnusedFirstPaymentCalender(musicGroupId, studentIds);
+		if(Objects.isNull(musicGroupUnusedFirstPaymentCalender)){
+			throw new BizException("当前乐团暂无新缴费设置");
+		}
+
+		List<MusicGroupPaymentCalenderDetail> unusedPaymentCalenderDetail = musicGroupPaymentCalenderDetailDao.getCalenderDetailWithCalender(musicGroupUnusedFirstPaymentCalender.getId());
+		if(CollectionUtils.isEmpty(unusedPaymentCalenderDetail)){
+			throw new BizException("当前乐团无学员缴费信息");
+		}
+		Map<Integer, List<MusicGroupPaymentCalenderDetail>> studentPaymentCalenderMap = unusedPaymentCalenderDetail.stream().collect(Collectors.groupingBy(MusicGroupPaymentCalenderDetail::getUserId));
+
+		List<MusicGroupPaymentCalenderCourseSettings> calenderCourseSettings = musicGroupPaymentCalenderCourseSettingsDao.getWithPaymentCalender(musicGroupUnusedFirstPaymentCalender.getId());
+		if(CollectionUtils.isEmpty(calenderCourseSettings)){
+			throw new BizException("课程收费标准设置异常");
+		}
+		return calenderCourseSettings;
+	}
+}

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

@@ -4,6 +4,7 @@ import com.ym.mec.auth.api.client.SysUserFeignService;
 import com.ym.mec.auth.api.entity.SysUser;
 import com.ym.mec.biz.dal.entity.GoodsCategory;
 import com.ym.mec.biz.dal.entity.GoodsProcurement;
+import com.ym.mec.biz.dal.enums.AccountType;
 import com.ym.mec.biz.service.GoodsCategoryService;
 import com.ym.mec.common.entity.HttpResponseResult;
 import io.swagger.annotations.Api;
@@ -12,6 +13,7 @@ import io.swagger.annotations.ApiImplicitParams;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiParam;
 
+import java.util.Arrays;
 import java.util.Date;
 import java.util.Objects;
 
@@ -122,7 +124,9 @@ public class GoodsController extends BaseController {
 
     @GetMapping("getGoodsTest")
     public HttpResponseResult getGoodsTest(Integer goodsId){
-        goodsService.getGoodsTest(goodsId);
+//        goodsService.getGoodsTest(Arrays.asList(goodsId));
+//        goodsService.subtractStock(Arrays.asList(goodsId), AccountType.INTERNAL);
+        goodsCategoryService.goodsTest(Arrays.asList(goodsId));
         return succeed();
     }
 }

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

@@ -5,9 +5,12 @@ import com.ym.mec.auth.api.entity.SysUser;
 import com.ym.mec.biz.dal.dao.EmployeeDao;
 import com.ym.mec.biz.dal.entity.Employee;
 import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender;
+import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderCourseSettings;
 import com.ym.mec.biz.dal.page.MusicGroupPaymentCalenderQueryInfo;
+import com.ym.mec.biz.service.MusicGroupPaymentCalenderCourseSettingsService;
 import com.ym.mec.biz.service.MusicGroupPaymentCalenderService;
 import com.ym.mec.common.controller.BaseController;
+import com.ym.mec.common.entity.HttpResponseResult;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.apache.commons.lang3.StringUtils;
@@ -18,6 +21,7 @@ import org.springframework.web.bind.annotation.*;
 
 import java.util.Arrays;
 import java.util.List;
+import java.util.stream.Collectors;
 
 @RequestMapping("musicGroupPaymentCalender")
 @Api(tags = "乐团缴费日历服务")
@@ -27,6 +31,8 @@ public class MusicGroupPaymentCalenderController extends BaseController {
     @Autowired
     private MusicGroupPaymentCalenderService musicGroupPaymentCalenderService;
     @Autowired
+    private MusicGroupPaymentCalenderCourseSettingsService musicGroupPaymentCalenderCourseSettingsService;
+	@Autowired
     private SysUserFeignService sysUserFeignService;
     @Autowired
     private EmployeeDao employeeDao;
@@ -116,4 +122,14 @@ public class MusicGroupPaymentCalenderController extends BaseController {
         musicGroupPaymentCalenderService.auditRefuse(calenderId,auditMemo);
         return succeed();
     }
+
+    @ApiOperation(value = "获取指定学员在指定乐团下本次课排课时长")
+    @PostMapping("/getMusicCourseSettingsWithStudents")
+    @PreAuthorize("@pcs.hasPermissions('musicGroupPaymentCalender/getMusicCourseSettingsWithStudents')")
+    public HttpResponseResult<List<MusicGroupPaymentCalenderCourseSettings>> getMusicCourseSettingsWithStudents(String musicGroupId, String studentIds){
+        if(StringUtils.isBlank(studentIds)){
+            return failed("请指定学员编号");
+        }
+        return succeed(musicGroupPaymentCalenderCourseSettingsService.getMusicCourseSettingsWithStudents(musicGroupId,Arrays.stream(studentIds.split(",")).map(id -> Integer.valueOf(id)).collect(Collectors.toList())));
+    }
 }