Selaa lähdekoodia

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

# Conflicts:
#	mec-biz/src/main/java/com/ym/mec/biz/service/GoodsService.java
#	mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentRepairServiceImpl.java
zouxuan 5 vuotta sitten
vanhempi
commit
080639fca8
20 muutettua tiedostoa jossa 452 lisäystä ja 129 poistoa
  1. 15 0
      cms/src/main/java/com/ym/mec/cms/controller/NewsController.java
  2. 10 0
      cms/src/main/java/com/ym/mec/cms/controller/queryinfo/NewsInformationQueryInfo.java
  3. 3 2
      cms/src/main/java/com/ym/mec/cms/service/impl/SysNewsInformationServiceImpl.java
  4. 30 16
      cms/src/main/resources/config/mybatis/SysNewsInformationMapper.xml
  5. 22 2
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/SellOrderDao.java
  6. 1 3
      mec-biz/src/main/java/com/ym/mec/biz/dal/enums/SellStatus.java
  7. 1 1
      mec-biz/src/main/java/com/ym/mec/biz/dal/enums/StockType.java
  8. 24 2
      mec-biz/src/main/java/com/ym/mec/biz/dal/page/EndCourseScheduleQueryInfo.java
  9. 4 5
      mec-biz/src/main/java/com/ym/mec/biz/service/GoodsService.java
  10. 10 2
      mec-biz/src/main/java/com/ym/mec/biz/service/SellOrderService.java
  11. 106 35
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/GoodsServiceImpl.java
  12. 21 18
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/SellOrderServiceImpl.java
  13. 18 20
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/SubjectChangeServiceImpl.java
  14. 6 0
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/VipGroupServiceImpl.java
  15. 13 7
      mec-biz/src/main/resources/config/mybatis/CourseScheduleMapper.xml
  16. 22 8
      mec-biz/src/main/resources/config/mybatis/GoodsMapper.xml
  17. 2 2
      mec-biz/src/main/resources/config/mybatis/GoodsProcurementMapper.xml
  18. 95 0
      mec-biz/src/main/resources/config/mybatis/SellOrderMapper.xml
  19. 25 4
      mec-teacher/src/main/java/com/ym/mec/teacher/controller/TeacherController.java
  20. 24 2
      mec-web/src/main/java/com/ym/mec/web/controller/SellOrderController.java

+ 15 - 0
cms/src/main/java/com/ym/mec/cms/controller/NewsController.java

@@ -2,11 +2,14 @@ package com.ym.mec.cms.controller;
 
 import com.ym.mec.auth.api.client.SysUserFeignService;
 import com.ym.mec.auth.api.entity.SysUser;
+
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiImplicitParam;
 import io.swagger.annotations.ApiOperation;
 
 import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
 
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.MediaType;
@@ -17,9 +20,11 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
 import com.ym.mec.cms.controller.queryinfo.NewsInformationQueryInfo;
+import com.ym.mec.cms.dal.dao.SysNewsInformationDao;
 import com.ym.mec.cms.dal.entity.SysNewsInformation;
 import com.ym.mec.cms.service.SysNewsInformationService;
 import com.ym.mec.common.controller.BaseController;
+import com.ym.mec.util.collection.MapUtil;
 
 @RestController
 @RequestMapping("news")
@@ -30,6 +35,9 @@ public class NewsController extends BaseController {
 	private SysNewsInformationService sysNewsInformationService;
 	
 	@Autowired
+	private SysNewsInformationDao sysNewsInformationDao;
+	
+	@Autowired
 	private SysUserFeignService sysUserFeignService;
 
 	@ApiOperation("资讯列表分页查询")
@@ -38,6 +46,13 @@ public class NewsController extends BaseController {
 		if(queryInfo.getTenantId() == null){
 			queryInfo.setTenantId(1);
 		}
+		
+		Map<String, Object> params = new HashMap<String, Object>();
+		MapUtil.populateMap(params, queryInfo);
+		int count = sysNewsInformationDao.queryCount(params);
+		if(count == 0){
+			queryInfo.setMemo(null);
+		}
 		return succeed(sysNewsInformationService.queryPage(queryInfo));
 	}
 

+ 10 - 0
cms/src/main/java/com/ym/mec/cms/controller/queryinfo/NewsInformationQueryInfo.java

@@ -27,6 +27,8 @@ public class NewsInformationQueryInfo extends QueryInfo {
 	@ApiModelProperty(value = "租客编号", required = false)
 	private Integer tenantId;
 	
+	private String clientName;
+	
 	private Date date;
 
 	public Integer getType() {
@@ -84,4 +86,12 @@ public class NewsInformationQueryInfo extends QueryInfo {
 	public void setTenantId(Integer tenantId) {
 		this.tenantId = tenantId;
 	}
+
+	public String getClientName() {
+		return clientName;
+	}
+
+	public void setClientName(String clientName) {
+		this.clientName = clientName;
+	}
 }

+ 3 - 2
cms/src/main/java/com/ym/mec/cms/service/impl/SysNewsInformationServiceImpl.java

@@ -72,9 +72,9 @@ public class SysNewsInformationServiceImpl extends BaseServiceImpl<Long, SysNews
 		String memo = queryInfo.getMemo();
 		
 		Map<String, Object> params = new HashMap<String, Object>();
-		MapUtil.populateMap(params, queryInfo);
 
-		queryInfo.setType(3); 
+		queryInfo.setType(3);
+		MapUtil.populateMap(params, queryInfo);
 		int count = sysNewsInformationDao.queryHomeCount(params);
 		if(count == 0){
 			queryInfo.setMemo(null);
@@ -113,6 +113,7 @@ public class SysNewsInformationServiceImpl extends BaseServiceImpl<Long, SysNews
 		
 		queryInfo.setMemo(memo);
 		queryInfo.setType(6);
+		MapUtil.populateMap(params, queryInfo);
 		count = sysNewsInformationDao.queryHomeCount(params);
 		if(count == 0){
 			queryInfo.setMemo(null);

+ 30 - 16
cms/src/main/resources/config/mybatis/SysNewsInformationMapper.xml

@@ -48,6 +48,16 @@
 			<if test="search != null">
 				and title_ like '%' #{search} '%'
 			</if>
+			<if test="clientName != 'manage'">
+				<choose>
+					<when test="memo != null and memo != ''">
+						and memo_ = #{memo}
+					</when>
+					<otherwise>
+						and (memo_ is null or memo_ = '')
+					</otherwise>
+				</choose>
+			</if>
 		</where>
 	</sql>
 	
@@ -179,14 +189,16 @@
 		<if test="tenantId != null">
 			and tenant_id_ = #{tenantId}
 		</if>
-		<choose>
-			<when test="memo != null and memo != ''">
-				and memo_ = #{memo}
-			</when>
-			<otherwise>
-				and (memo_ is null or memo_ = '')
-			</otherwise>
-		</choose>
+		<if test="clientName != 'manage'">
+			<choose>
+				<when test="memo != null and memo != ''">
+					and memo_ = #{memo}
+				</when>
+				<otherwise>
+					and (memo_ is null or memo_ = '')
+				</otherwise>
+			</choose>
+		</if>
 		order by status_ desc,order_ desc,update_time_ desc
 		<include refid="global.limit" />
 	</select>
@@ -213,13 +225,15 @@
 		<if test="tenantId != null">
 			and tenant_id_ = #{tenantId}
 		</if>
-		<choose>
-			<when test="memo != null and memo != ''">
-				and memo_ = #{memo}
-			</when>
-			<otherwise>
-				and (memo_ is null or memo_ = '')
-			</otherwise>
-		</choose>
+		<if test="clientName != 'manage'">
+			<choose>
+				<when test="memo != null and memo != ''">
+					and memo_ = #{memo}
+				</when>
+				<otherwise>
+					and (memo_ is null or memo_ = '')
+				</otherwise>
+			</choose>
+		</if>
 	</select>
 </mapper>

+ 22 - 2
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/SellOrderDao.java

@@ -13,6 +13,8 @@ public interface SellOrderDao extends BaseDAO<Integer, SellOrder> {
 
     int batchInsert(@Param("sellOrders") List<SellOrder> sellOrders);
 
+    int batchUpdate(@Param("sellOrders") List<SellOrder> sellOrders);
+
     /**
      * 获取订单的销售列表
      *
@@ -122,6 +124,7 @@ public interface SellOrderDao extends BaseDAO<Integer, SellOrder> {
 
     /**
      * 获取声部更换的销售、总收入
+     *
      * @param startTime
      * @param endTime
      * @return
@@ -129,11 +132,28 @@ public interface SellOrderDao extends BaseDAO<Integer, SellOrder> {
     List<OperatingReport> getSubjectChangeMonthReport(@Param("startTime") Date startTime, @Param("endTime") Date endTime);
 
     /**
+     * @param sellOrderIds:
+     * @return java.util.List<com.ym.mec.biz.dal.entity.SellOrder>
      * @describe 获取指定的销售记录
      * @author Joburgess
      * @date 2020.10.13
-     * @param sellOrderIds:
-     * @return java.util.List<com.ym.mec.biz.dal.entity.SellOrder>
      */
     List<SellOrder> getSellOrders(@Param("sellOrderIds") List<Integer> sellOrderIds);
+
+    /**
+     * @describe 获取无批次号商品销售记录
+     * @author Joburgess
+     * @date 2020.10.13
+     * @return java.util.List<com.ym.mec.biz.dal.entity.SellOrder>
+     */
+    List<SellOrder> getNoneBatchNoSellOrders();
+
+
+    /**
+     * 获取订单组合商品的子商品
+     * @param orderId
+     * @param parentGoodsId
+     * @return
+     */
+    List<SellOrder> getSellOrderByParentGoodsId(@Param("orderId") Long orderId, @Param("parentGoodsId") Integer parentGoodsId);
 }

+ 1 - 3
mec-biz/src/main/java/com/ym/mec/biz/dal/enums/SellStatus.java

@@ -5,9 +5,7 @@ import com.ym.mec.common.enums.BaseEnum;
 
 public enum SellStatus implements BaseEnum<Integer, SellStatus> {
     NORMAL(0, "正常"),
-    ONLY_RETURNED(1, "仅退货"),
-    REFUND(2, "退货退费");
-
+    REFUND(1, "已退货");
     private Integer code;
     private String msg;
 

+ 1 - 1
mec-biz/src/main/java/com/ym/mec/biz/dal/enums/StockType.java

@@ -25,6 +25,6 @@ public enum StockType implements BaseEnum<String, StockType> {
 
     @Override
     public String getCode() {
-        return null;
+        return code;
     }
 }

+ 24 - 2
mec-biz/src/main/java/com/ym/mec/biz/dal/page/EndCourseScheduleQueryInfo.java

@@ -43,11 +43,17 @@ public class EndCourseScheduleQueryInfo extends QueryInfo {
     @ApiModelProperty(value = "教师名称")
     private String teacherName;
 
-    @ApiModelProperty(value = "开始时间")
+    @ApiModelProperty(value = "上课开始时间")
     private Date startTime;
 
-    @ApiModelProperty(value = "结束时间")
+    @ApiModelProperty(value = "上课结束时间")
     private Date endTime;
+    
+    @ApiModelProperty(value = "课程创建开始时间")
+    private Date createStartDate;
+    
+    @ApiModelProperty(value = "课程创建结束时间")
+    private Date createEndDate;
 
     @ApiModelProperty(value = "课程状态")
     private CourseStatusEnum courseStatus;
@@ -201,4 +207,20 @@ public class EndCourseScheduleQueryInfo extends QueryInfo {
     public void setClassGroupId(Integer classGroupId) {
         this.classGroupId = classGroupId;
     }
+
+	public Date getCreateStartDate() {
+		return createStartDate;
+	}
+
+	public void setCreateStartDate(Date createStartDate) {
+		this.createStartDate = createStartDate;
+	}
+
+	public Date getCreateEndDate() {
+		return createEndDate;
+	}
+
+	public void setCreateEndDate(Date createEndDate) {
+		this.createEndDate = createEndDate;
+	}
 }

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

@@ -80,13 +80,12 @@ public interface GoodsService extends BaseService<Integer, Goods> {
     void repertoryWarn();
 
     /**
-     * @describe 商品批次号分配
+     * @describe 给超售商品分配批次
      * @author Joburgess
      * @date 2020.10.13
-     * @param goods:
-     * @return java.util.List<com.ym.mec.biz.dal.entity.GoodsProcurement>
+     * @return void
      */
-    List<SellOrder> goodsBatchNoAllot(Goods goods);
+    void sellOrderBatchNoAllot();
 
     /**
      * @describe 扣减商品库存
@@ -105,7 +104,7 @@ public interface GoodsService extends BaseService<Integer, Goods> {
      * @param sellOrderIds: 对应批次商品列表
      * @return void
      */
-    void increaseStock(List<Integer> sellOrderIds, AccountType accountType);
+    void increaseStock(List<SellOrder> sellOrderIds, AccountType accountType);
 
     /**
      * @describe 获取辅件商品列表

+ 10 - 2
mec-biz/src/main/java/com/ym/mec/biz/service/SellOrderService.java

@@ -35,9 +35,17 @@ public interface SellOrderService extends BaseService<Integer, SellOrder> {
 
 
     /**
+     * 获取组合商品的相关商品
+     * @param orderId
+     * @param parentGoodsId
+     * @return
+     */
+    List<SellOrder> getSellOrderByParentGoodsId(Long orderId,Integer parentGoodsId);
+
+    /**
      * 退货
-     * @param id
+     * @param sellOrders
      * @return
      */
-    SellOrder refund(Integer id);
+    List<SellOrder> refund(List<SellOrder> sellOrders);
 }

+ 106 - 35
mec-biz/src/main/java/com/ym/mec/biz/service/impl/GoodsServiceImpl.java

@@ -39,6 +39,7 @@ 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.atomic.AtomicInteger;
 import java.util.stream.Collectors;
@@ -266,6 +267,8 @@ public class GoodsServiceImpl extends BaseServiceImpl<Integer, Goods>  implement
 		}
 		goodsProcurementDao.batchInsert(goodsProcurements);
 
+		sellOrderBatchNoAllot();
+
 		return goodsList;
 	}
 
@@ -304,8 +307,36 @@ public class GoodsServiceImpl extends BaseServiceImpl<Integer, Goods>  implement
 	}
 
 	@Override
-	public List<SellOrder> goodsBatchNoAllot(Goods goods) {
-		return null;
+	public void sellOrderBatchNoAllot() {
+		List<SellOrder> noneBatchNoSellOrders = sellOrderDao.getNoneBatchNoSellOrders();
+		if(CollectionUtils.isEmpty(noneBatchNoSellOrders)){
+			return;
+		}
+		List<SellOrder> updateSellOrders = new ArrayList<>();
+		for (SellOrder noneBatchNoSellOrder : noneBatchNoSellOrders) {
+			GoodsProcurement goodsProcurement = null;
+			if(StockType.INTERNAL.equals(noneBatchNoSellOrder.getStockType())||(StockType.ALL.equals(noneBatchNoSellOrder.getStockType())&&AccountType.INTERNAL.equals(noneBatchNoSellOrder.getAccountType()))){
+				goodsProcurement = goodsProcurementDao.getWithStockSurplusProcurement(noneBatchNoSellOrder.getGoodsId());
+				if(Objects.nonNull(goodsProcurement)){
+					goodsProcurement.setStockSoldNum(new AtomicInteger(goodsProcurement.getStockSoldNum()).incrementAndGet());
+				}
+			}else if(StockType.EXTERNAL.equals(noneBatchNoSellOrder.getStockType())||(StockType.ALL.equals(noneBatchNoSellOrder.getStockType())&&AccountType.EXTERNAL.equals(noneBatchNoSellOrder.getAccountType()))){
+				goodsProcurement = goodsProcurementDao.getWithTaxStockSurplusProcurement(noneBatchNoSellOrder.getGoodsId());
+				if(Objects.nonNull(goodsProcurement)){
+					goodsProcurement.setTaxStockSoldNum(new AtomicInteger(goodsProcurement.getTaxStockSoldNum()).incrementAndGet());
+				}
+			}
+
+			if(Objects.nonNull(goodsProcurement)){
+				goodsProcurementDao.update(goodsProcurement);
+				noneBatchNoSellOrder.setBatchNo(goodsProcurement.getBatchNo());
+				noneBatchNoSellOrder.setSellCost(goodsProcurement.getDiscountPrice());
+				updateSellOrders.add(noneBatchNoSellOrder);
+			}
+		}
+		if(!CollectionUtils.isEmpty(updateSellOrders)){
+			sellOrderDao.batchUpdate(updateSellOrders);
+		}
 	}
 
 	@Override
@@ -319,7 +350,7 @@ public class GoodsServiceImpl extends BaseServiceImpl<Integer, Goods>  implement
 
 		List<Goods> tempGoodsList = goodsDao.lockGoods(new ArrayList<>(goodsIds));
 		Map<Integer, Goods> idTempGoodsMap = tempGoodsList.stream().collect(Collectors.toMap(Goods::getId, g -> g));
-		List<SellOrder> goodsBatchNoDtos = new ArrayList<>();
+		List<GoodsProcurement> goodsProcurements = new ArrayList<>();
 		for (Integer goodsId : goodsIds) {
 			Goods tempGoods = idTempGoodsMap.get(goodsId);
 			List<Goods> childGoods = new ArrayList<>();
@@ -336,14 +367,12 @@ public class GoodsServiceImpl extends BaseServiceImpl<Integer, Goods>  implement
 					goodsProcurement = goodsProcurementDao.getWithStockSurplusProcurement(goods.getId());
 					goods.setStockCount(new AtomicInteger(goods.getStockCount()).decrementAndGet());
 					if(Objects.nonNull(goodsProcurement)){
-						goodsProcurement.setStockCount(new AtomicInteger(goodsProcurement.getStockCount()).decrementAndGet());
 						goodsProcurement.setStockSoldNum(new AtomicInteger(goodsProcurement.getStockSoldNum()).incrementAndGet());
 					}
 				}else if(StockType.EXTERNAL.equals(goods.getStockType())||(StockType.ALL.equals(goods.getStockType())&&AccountType.EXTERNAL.equals(accountType))){
 					goodsProcurement = goodsProcurementDao.getWithTaxStockSurplusProcurement(goods.getId());
 					goods.setTaxStockCount(new AtomicInteger(goods.getTaxStockCount()).decrementAndGet());
 					if(Objects.nonNull(goodsProcurement)){
-						goodsProcurement.setTaxStockCount(new AtomicInteger(goodsProcurement.getTaxStockCount()).decrementAndGet());
 						goodsProcurement.setTaxStockSoldNum(new AtomicInteger(goodsProcurement.getTaxStockSoldNum()).incrementAndGet());
 					}
 				}
@@ -358,22 +387,56 @@ public class GoodsServiceImpl extends BaseServiceImpl<Integer, Goods>  implement
 					goodsProcurement.setParentGoodsId(tempGoods.getId());
 				}
 
-//				goodsBatchNoDtos.add(goodsProcurement);
+				goodsProcurements.add(goodsProcurement);
 			}
 //			goodsDao.update(tempGoods);
 		}
 		goodsDao.batchUpdate(tempGoodsList);
-		return goodsBatchNoDtos;
+
+		List<SellOrder> sellOrders = new ArrayList<>();
+
+		List<GoodsProcurement> singleGoodsList = goodsProcurements.stream().filter(g -> Objects.isNull(g.getParentGoodsId())&&Objects.nonNull(g.getBatchNo())).collect(Collectors.toList());
+		if(!CollectionUtils.isEmpty(singleGoodsList)){
+			Map<String, List<Integer>> batchNoGoodsIdMap = singleGoodsList.stream().collect(Collectors.groupingBy(GoodsProcurement::getBatchNo, Collectors.mapping(GoodsProcurement::getGoodsId, Collectors.toList())));
+			for (Map.Entry<String, List<Integer>> batchNoGoodsIdMapEntry : batchNoGoodsIdMap.entrySet()) {
+				Map<Integer, Long> goodsNumMap = batchNoGoodsIdMapEntry.getValue().stream().collect(Collectors.groupingBy(gid -> gid, Collectors.counting()));
+				for (Map.Entry<Integer, Long> goodsNumMapEntry : goodsNumMap.entrySet()) {
+					SellOrder sellOrder = new SellOrder();
+					sellOrder.setGoodsId(goodsNumMapEntry.getKey());
+					sellOrder.setNum(goodsNumMapEntry.getValue().intValue());
+					sellOrder.setBatchNo(batchNoGoodsIdMapEntry.getKey());
+					GoodsProcurement goodsProcurement = goodsProcurementDao.getWithGoodsAndBatchNo(sellOrder.getGoodsId(), sellOrder.getBatchNo());
+					sellOrder.setSellCost(goodsProcurement.getDiscountPrice().multiply(new BigDecimal(sellOrder.getNum())));
+					sellOrders.add(sellOrder);
+				}
+			}
+		}
+
+		List<GoodsProcurement> groupGoodsList = goodsProcurements.stream().filter(g -> Objects.nonNull(g.getParentGoodsId())||Objects.isNull(g.getBatchNo())).collect(Collectors.toList());
+		if(!CollectionUtils.isEmpty(groupGoodsList)){
+			for (GoodsProcurement goodsProcurement : groupGoodsList) {
+				SellOrder sellOrder = new SellOrder();
+				sellOrder.setParentGoodsId(goodsProcurement.getParentGoodsId());
+				sellOrder.setGoodsId(goodsProcurement.getGoodsId());
+				sellOrder.setNum(1);
+				sellOrder.setBatchNo(goodsProcurement.getBatchNo());
+				if(Objects.nonNull(goodsProcurement.getBatchNo())){
+					sellOrder.setSellCost(goodsProcurement.getDiscountPrice().multiply(new BigDecimal(sellOrder.getNum())));
+				}
+				sellOrders.add(sellOrder);
+			}
+		}
+
+		return sellOrders;
 	}
 
 	@Override
 	@Transactional(rollbackFor = Exception.class, isolation = Isolation.READ_COMMITTED)
-	public void increaseStock(List<Integer> sellOrderIds, AccountType accountType) {
-		if(CollectionUtils.isEmpty(sellOrderIds)){
+	public void increaseStock(List<SellOrder> sellOrders, AccountType accountType) {
+		if(CollectionUtils.isEmpty(sellOrders)){
 			return;
 		}
 
-		List<SellOrder> sellOrders = sellOrderDao.getSellOrders(sellOrderIds);
 		Set<Integer> goodsIdList = new HashSet<>();
 		sellOrders.forEach(so -> {
 			if(Objects.nonNull(so.getParentGoodsId())){
@@ -383,31 +446,39 @@ public class GoodsServiceImpl extends BaseServiceImpl<Integer, Goods>  implement
 			}
 		});
 
-		List<Goods> goods = goodsDao.lockGoods(new ArrayList<>(goodsIdList));
-
-
-//		Set<Integer> goodsIds = goodsBatchNoDtos.stream().map(GoodsBatchNoDto::getGoodsId).collect(Collectors.toSet());
-//		List<Goods> goodsList = goodsDao.lockGoods(new ArrayList<>(goodsIds));
-//		Map<Integer, Goods> idGoodsMap = goodsList.stream().collect(Collectors.toMap(Goods::getId, g -> g));
-//		for (GoodsBatchNoDto goodsBatchNoDto : goodsBatchNoDtos) {
-//			Goods goods = idGoodsMap.get(goodsBatchNoDto.getGoodsId());
-//			GoodsProcurement goodsProcurement = goodsProcurementDao.getWithGoodsAndBatchNo(goods.getId(), goodsBatchNoDto.getBatchNo());
-//			if(StockType.INTERNAL.equals(goods.getStockType())||(StockType.ALL.equals(goods.getStockType())&&AccountType.INTERNAL.equals(accountType))){
-//				goods.setStockCount(new AtomicInteger(goods.getStockCount()).incrementAndGet());
-//				if(Objects.nonNull(goodsProcurement)){
-//					goodsProcurement.setStockCount(new AtomicInteger(goodsProcurement.getStockCount()).incrementAndGet());
-//					goodsProcurement.setStockSoldNum(new AtomicInteger(goodsProcurement.getStockSoldNum()).decrementAndGet());
-//				}
-//			}else if(StockType.EXTERNAL.equals(goods.getStockType())||(StockType.ALL.equals(goods.getStockType())&&AccountType.EXTERNAL.equals(accountType))){
-//				goods.setTaxStockCount(new AtomicInteger(goods.getTaxStockCount()).incrementAndGet());
-//				if(Objects.nonNull(goodsProcurement)){
-//					goodsProcurement.setTaxStockCount(new AtomicInteger(goodsProcurement.getTaxStockCount()).incrementAndGet());
-//					goodsProcurement.setTaxStockSoldNum(new AtomicInteger(goodsProcurement.getTaxStockSoldNum()).decrementAndGet());
-//				}
-//			}
-//			goodsDao.update(goods);
-//			goodsProcurementDao.update(goodsProcurement);
-//		}
+		List<Goods> goodsList = goodsDao.lockGoods(new ArrayList<>(goodsIdList));
+		Map<Integer, Goods> idGoodsMap = goodsList.stream().collect(Collectors.toMap(Goods::getId, g -> g));
+
+		for (SellOrder sellOrder : sellOrders) {
+			Goods goods = goodsDao.get(sellOrder.getGoodsId());
+			GoodsProcurement goodsProcurement = goodsProcurementDao.getWithGoodsAndBatchNo(sellOrder.getGoodsId(), sellOrder.getBatchNo());
+			if(StockType.INTERNAL.equals(goods.getStockType())||(StockType.ALL.equals(goods.getStockType())&&AccountType.INTERNAL.equals(accountType))){
+				goods.setStockCount(new AtomicInteger(goods.getStockCount()).addAndGet(sellOrder.getNum()));
+				if(Objects.nonNull(goodsProcurement)){
+					goodsProcurement.setStockSoldNum(new AtomicInteger(goodsProcurement.getStockSoldNum()).addAndGet(-sellOrder.getNum()));
+				}
+			}else if(StockType.EXTERNAL.equals(goods.getStockType())||(StockType.ALL.equals(goods.getStockType())&&AccountType.EXTERNAL.equals(accountType))){
+				goods.setTaxStockCount(new AtomicInteger(goods.getTaxStockCount()).addAndGet(sellOrder.getNum()));
+				if(Objects.nonNull(goodsProcurement)){
+					goodsProcurement.setTaxStockSoldNum(new AtomicInteger(goodsProcurement.getTaxStockSoldNum()).addAndGet(-sellOrder.getNum()));
+				}
+			}
+			if(Objects.isNull(sellOrder.getParentGoodsId())){
+				goods.setSellCount(new AtomicInteger(goods.getSellCount()).addAndGet(-sellOrder.getNum()));
+			}
+			goodsDao.update(goods);
+			goodsProcurementDao.update(goodsProcurement);
+		}
+
+		//处理组合商品
+		Map<Integer, Long> goodsNumMap = sellOrders.stream().filter(so -> Objects.nonNull(so.getParentGoodsId())).collect(Collectors.groupingBy(SellOrder::getParentGoodsId, Collectors.counting()));
+		for (Map.Entry<Integer, Long> goodsIdNumMapEntry : goodsNumMap.entrySet()) {
+			Goods goods = idGoodsMap.get(goodsIdNumMapEntry.getKey());
+			int goodSize = (int) sellOrders.stream().filter(so -> goodsIdNumMapEntry.getKey().equals(so.getParentGoodsId())).count();
+			int sellNum = (int) (goodSize/goodsIdNumMapEntry.getValue());
+			goods.setSellCount(new AtomicInteger(goods.getSellCount()).addAndGet(-sellNum));
+			goodsDao.update(goods);
+		}
 	}
 
 	@Override

+ 21 - 18
mec-biz/src/main/java/com/ym/mec/biz/service/impl/SellOrderServiceImpl.java

@@ -34,6 +34,8 @@ public class SellOrderServiceImpl extends BaseServiceImpl<Integer, SellOrder> im
     private SysPaymentConfigService sysPaymentConfigService;
     @Autowired
     private SysUserCashAccountService sysUserCashAccountService;
+    @Autowired
+    private GoodsService goodsService;
 
     @Override
     public BaseDAO<Integer, SellOrder> getDAO() {
@@ -264,28 +266,29 @@ public class SellOrderServiceImpl extends BaseServiceImpl<Integer, SellOrder> im
     }
 
     @Override
+    public List<SellOrder> getSellOrderByParentGoodsId(Long orderId, Integer parentGoodsId) {
+        return sellOrderDao.getSellOrderByParentGoodsId(orderId, parentGoodsId);
+    }
+
+    @Override
     @Transactional(rollbackFor = Exception.class)
-    public SellOrder refund(Integer id) {
-        SellOrder sellOrder = sellOrderDao.get(id);
+    public List<SellOrder> refund(List<SellOrder> sellOrders) {
+        for (SellOrder sellOrder : sellOrders) {
+            //1、更改销售列表状态
+            sellOrder.setStatus(SellStatus.REFUND);
+            sellOrder.setUpdateTime(new Date());
+            sellOrderDao.update(sellOrder);
 
-        if (!sellOrder.getStatus().equals(SellStatus.NORMAL)) {
-            throw new BizException("当前状态不能退货,请核查");
-        }
-        if (!sellOrder.getType().equals(SellTypeEnum.SCHOOL_BUY)) {
-            throw new BizException("学校采购不能退货");
+            //2、金额退到余额
+            if (sellOrder.getActualAmount().compareTo(BigDecimal.ZERO) > 0) {
+                sysUserCashAccountService.updateBalance(sellOrder.getUserId(), sellOrder.getActualAmount(), PlatformCashAccountDetailTypeEnum.REFUNDS, "订单:" + sellOrder.getOrderId() + " 商品id:" + sellOrder.getGoodsId() + "退货");
+            }
         }
-        //1、更改销售列表状态
-        sellOrder.setStatus(SellStatus.REFUND);
-        sellOrder.setUpdateTime(new Date());
-        sellOrderDao.update(sellOrder);
-
-        //2、金额退到余额
-        if (sellOrder.getActualAmount().compareTo(BigDecimal.ZERO) > 0) {
-            sysUserCashAccountService.updateBalance(sellOrder.getUserId(), sellOrder.getActualAmount().negate(), PlatformCashAccountDetailTypeEnum.REFUNDS, "退货");
+        //3、退货
+        if (sellOrders.get(0).getAccountType() != null) {
+            goodsService.increaseStock(sellOrders, sellOrders.get(0).getAccountType());
         }
-        //3、商品退回库存 TODO
-
-        return sellOrder;
+        return sellOrders;
     }
 
 }

+ 18 - 20
mec-biz/src/main/java/com/ym/mec/biz/service/impl/SubjectChangeServiceImpl.java

@@ -258,26 +258,24 @@ public class SubjectChangeServiceImpl extends BaseServiceImpl<Integer, SubjectCh
         subjectChange.setVersion(0);
         subjectChangeDao.insert(subjectChange);
 
-        //
-        if (amountMargin.compareTo(BigDecimal.ZERO) <= 0) {
-            String orderNo = idGeneratorService.generatorId("payment") + "";
-            StudentPaymentOrder studentPaymentOrder = new StudentPaymentOrder();
-            studentPaymentOrder.setUserId(subjectChange.getStudentId());
-            studentPaymentOrder.setGroupType(GroupType.SUBJECT_CHANGE);
-            studentPaymentOrder.setOrderNo(orderNo);
-            studentPaymentOrder.setType(OrderTypeEnum.SUBJECT_CHANGE);
-            studentPaymentOrder.setExpectAmount(BigDecimal.ZERO);
-            studentPaymentOrder.setActualAmount(BigDecimal.ZERO);
-            studentPaymentOrder.setBalancePaymentAmount(BigDecimal.ZERO);
-            studentPaymentOrder.setStatus(DealStatusEnum.SUCCESS);
-            studentPaymentOrder.setMusicGroupId(subjectChange.getId().toString());
-            studentPaymentOrder.setPaymentChannel("BALANCE");
-            studentPaymentOrder.setUpdateTime(nowDate);
-            studentPaymentOrder.setOrganId(subjectChange.getOrganId());
-            studentPaymentOrder.setRoutingOrganId(subjectChange.getOrganId());
-            studentPaymentOrderService.insert(studentPaymentOrder);
-
-        }
+//        if (amountMargin.compareTo(BigDecimal.ZERO) <= 0) {
+//            String orderNo = idGeneratorService.generatorId("payment") + "";
+//            StudentPaymentOrder studentPaymentOrder = new StudentPaymentOrder();
+//            studentPaymentOrder.setUserId(subjectChange.getStudentId());
+//            studentPaymentOrder.setGroupType(GroupType.SUBJECT_CHANGE);
+//            studentPaymentOrder.setOrderNo(orderNo);
+//            studentPaymentOrder.setType(OrderTypeEnum.SUBJECT_CHANGE);
+//            studentPaymentOrder.setExpectAmount(BigDecimal.ZERO);
+//            studentPaymentOrder.setActualAmount(BigDecimal.ZERO);
+//            studentPaymentOrder.setBalancePaymentAmount(BigDecimal.ZERO);
+//            studentPaymentOrder.setStatus(DealStatusEnum.SUCCESS);
+//            studentPaymentOrder.setMusicGroupId(subjectChange.getId().toString());
+//            studentPaymentOrder.setPaymentChannel("BALANCE");
+//            studentPaymentOrder.setUpdateTime(nowDate);
+//            studentPaymentOrder.setOrganId(subjectChange.getOrganId());
+//            studentPaymentOrder.setRoutingOrganId(subjectChange.getOrganId());
+//            studentPaymentOrderService.insert(studentPaymentOrder);
+//        }
         return subjectChange;
     }
 

+ 6 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/VipGroupServiceImpl.java

@@ -857,6 +857,12 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 			throw new BizException("请指定vip课程");
 		}
 		VipGroupManageDetailDto vipGroupBaseInfo = vipGroupDao.getVipGroupBaseInfo(vipGroupId);
+		if(Objects.nonNull(vipGroupBaseInfo.getEducationalTeacherId())){
+			SysUser eduUser = sysUserFeignService.queryUserById(vipGroupBaseInfo.getEducationalTeacherId());
+			if(Objects.nonNull(eduUser)){
+				vipGroupBaseInfo.setEducationalTeacherName(eduUser.getRealName());
+			}
+		}
 		vipGroupBaseInfo.setSubjectName(StringUtils.join(subjectDao.findBySubIds(vipGroupBaseInfo.getSubjectIdList()),","));
 		ClassGroupTeacherSalary byVipGoupAndTeacher = classGroupTeacherSalaryDao.findByVipGoupAndTeacher(vipGroupId.intValue(), vipGroupBaseInfo.getUserId());
 		Integer onlineNum = courseScheduleDao.countCourseNum(vipGroupId,"ONLINE");

+ 13 - 7
mec-biz/src/main/resources/config/mybatis/CourseScheduleMapper.xml

@@ -2417,21 +2417,27 @@
         <if test="isCallNames != null and isCallNames == 0">
             AND sa.id_ IS NULL
         </if>
-        <if test="startTime!=null and endTime==null">
-            AND cs.class_date_ &gt; DATE_FORMAT(#{startTime},"%Y-%m-%d")
+        <if test="startTime!=null">
+            AND cs.class_date_ &gt;= DATE_FORMAT(#{startTime},"%Y-%m-%d")
         </if>
-        <if test="startTime==null and endTime!=null">
-            AND cs.class_date_ &lt; DATE_FORMAT(#{endTime},"%Y-%m-%d")
-        </if>
-        <if test="startTime!=null and endTime!=null">
-            AND cs.class_date_ BETWEEN DATE_FORMAT(#{startTime},"%Y-%m-%d") AND DATE_FORMAT(#{endTime},"%Y-%m-%d")
+        <if test="endTime!=null">
+            AND cs.class_date_ &lt;= DATE_FORMAT(#{endTime},"%Y-%m-%d")
         </if>
         <if test="courseStatus!=null">
             AND cs.status_ = #{courseStatus,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
         </if>
+        <if test="createStartDate!=null">
+            AND date(cs.create_time_) &gt;= date(#{createStartDate})
+        </if>
+        <if test="createEndDate!=null">
+            AND date(cs.create_time_) &lt;= date(#{createEndDate})
+        </if>
         <if test="courseType!=null">
             AND cs.type_ = #{courseType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
         </if>
+        <if test="groupType!=null">
+            AND cs.group_type_ = #{groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
+        </if>
         <if test="schoolId!=null">
             AND cs.schoole_id_ = #{schoolId}
         </if>

+ 22 - 8
mec-biz/src/main/resources/config/mybatis/GoodsMapper.xml

@@ -34,6 +34,9 @@
         <result column="complement_goods_id_list_" property="complementGoodsIdList"/>
         <result column="type_" property="type" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
         <result column="supply_channel_" property="supplyChannel" />
+        <result column="stock_type_" property="stockType" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
+        <result column="client_show_" property="clientShow" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
+        <result column="stock_warning_" property="stockWarning" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
     </resultMap>
 
     <!-- 根据主键查询一条记录 -->
@@ -52,23 +55,24 @@
         INSERT INTO goods
         (goods_category_id_,sn_,name_,brand_,specification_,image_,stock_count_,tax_stock_count_,sell_count_,market_price_,
         discount_price_,group_purchase_price_,brief_,desc_,is_new_,is_top_,status_,memo_,publish_time_,
-        complement_goods_id_list_,update_time_,create_time_,type_,agree_cost_price_)
+        complement_goods_id_list_,update_time_,create_time_,type_,agree_cost_price_,client_show_,stock_warning_)
         VALUES(#{goodsCategoryId},#{sn},#{name},#{brand},#{specification},#{image},#{stockCount},#{taxStockCount},#{sellCount},#{marketPrice},
-        #{discountPrice},#{groupPurchasePrice},#{brief},#{desc},
+        #{discountPrice},#{groupPurchasePrice},#{brief},
         #{isNew,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{isTop,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
-        #{memo},#{publishTime},#{complementGoodsIdList},now(),now(),#{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{agreeCostPrice})
+        #{memo},#{publishTime},#{complementGoodsIdList},now(),now(),#{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{agreeCostPrice},
+        #{clientShow,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{stockWarning,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler})
     </insert>
     <insert id="batchInsert">
         INSERT INTO goods
         (goods_category_id_,name_,brand_,specification_,image_,market_price_,
         discount_price_,group_purchase_price_,desc_,update_time_,create_time_,type_,agree_cost_price_,sn_,
-        stock_count_,tax_stock_count_)
+        stock_count_,tax_stock_count_,client_show_,stock_warning_)
         VALUES
         <foreach collection="goodsList" separator="," item="goods">
             (#{goods.goodsCategoryId},#{goods.name},#{goods.brand},#{goods.specification},#{goods.image},#{goods.marketPrice},
             #{goods.discountPrice},#{goods.groupPurchasePrice},#{goods.desc},now(),now(),
             #{goods.type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{goods.agreeCostPrice},#{goods.sn},
-            #{goods.stockCount},#{goods.taxStockCount},)
+            #{goods.stockCount},#{goods.taxStockCount},#{goods.clientShow,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{goods.stockWarning,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler})
         </foreach>
     </insert>
     <!-- 根据主键查询一条记录 -->
@@ -120,9 +124,6 @@
             <if test="brief != null">
                 brief_ = #{brief},
             </if>
-            <if test="updateTime != null">
-                update_time_ = NOW(),
-            </if>
             <if test="discountPrice != null">
                 discount_price_ = #{discountPrice},
             </if>
@@ -144,6 +145,13 @@
             <if test="taxStockCount != null">
                 tax_stock_count_ = #{taxStockCount},
             </if>
+            <if test="clientShow != null">
+                client_show_ = #{clientShow,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
+            </if>
+            <if test="stockWarning != null">
+                stock_warning_ = #{stockWarning,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
+            </if>
+                update_time_ = NOW()
         </set>
         WHERE id_ = #{id}
     </update>
@@ -218,6 +226,12 @@
                 <if test="goods.taxStockCount != null">
                     tax_stock_count_ = #{goods.taxStockCount},
                 </if>
+                <if test="goods.clientShow != null">
+                    client_show_ = #{goods.clientShow,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
+                </if>
+                <if test="goods.stockWarning != null">
+                    stock_warning_ = #{goods.stockWarning,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
+                </if>
                     update_time_ = NOW()
             </set>
             WHERE id_ = #{goods.id}

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

@@ -134,11 +134,11 @@
 	</select>
 
 	<select id="getWithStockSurplusProcurement" resultMap="GoodsProcurement">
-		SELECT * FROM goods_procurement WHERE goods_id_ = #{goodsId} AND stock_count_>stock_sold_num_
+		SELECT * FROM goods_procurement WHERE goods_id_ = #{goodsId} AND stock_count_>stock_sold_num_ ORDER BY create_time_ LIMIT 1
 	</select>
 
 	<select id="getWithTaxStockSurplusProcurement" resultMap="GoodsProcurement">
-		SELECT * FROM goods_procurement WHERE goods_id_ = #{goodsId} AND tax_stock_count_>tax_stock_sold_num_
+		SELECT * FROM goods_procurement WHERE goods_id_ = #{goodsId} AND tax_stock_count_>tax_stock_sold_num_ ORDER BY create_time_ LIMIT 1
 	</select>
 
 	<select id="getWithGoodsAndBatchNo" resultMap="GoodsProcurement">

+ 95 - 0
mec-biz/src/main/resources/config/mybatis/SellOrderMapper.xml

@@ -35,6 +35,8 @@
         <result column="create_ime_" property="createIme"/>
         <result column="update_time_" property="updateTime"/>
         <result column="receive_status_" property="receiveStatus"/>
+        <result column="stock_type_" property="stockType" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler" />
+        <result column="account_type_" property="accountType" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler" />
     </resultMap>
     <sql id="Base_Column_List">
         <!--@mbg.generated-->
@@ -150,6 +152,91 @@
         where id_ = #{id}
     </update>
 
+    <update id="batchUpdate" parameterType="com.ym.mec.biz.dal.entity.SellOrder">
+        <foreach collection="sellOrders" item="sellOrder" separator=";">
+            update sell_order
+            <set>
+                <if test="sellOrder.eduTeacherId != null">
+                    edu_teacher_id_ = #{sellOrder.eduTeacherId},
+                </if>
+                <if test="sellOrder.organId != null">
+                    organ_id_ = #{sellOrder.organId},
+                </if>
+                <if test="sellOrder.cooperationOrganId != null">
+                    cooperation_organ_id_ = #{sellOrder.cooperationOrganId},
+                </if>
+                <if test="sellOrder.transNo != null">
+                    trans_no_ = #{sellOrder.transNo},
+                </if>
+                <if test="sellOrder.orderId != null">
+                    order_id_ = #{sellOrder.orderId},
+                </if>
+                <if test="sellOrder.orderNo != null">
+                    order_no_ = #{sellOrder.orderNo},
+                </if>
+                <if test="sellOrder.expectAmount != null">
+                    expect_amount_ = #{sellOrder.expectAmount},
+                </if>
+                <if test="sellOrder.actualAmount != null">
+                    actual_amount_ = #{sellOrder.actualAmount},
+                </if>
+                <if test="sellOrder.balanceAmount != null">
+                    balance_amount_ = #{sellOrder.balanceAmount},
+                </if>
+                <if test="sellOrder.type != null">
+                    type_ = #{sellOrder.type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
+                </if>
+                <if test="sellOrder.parentGoodsId != null">
+                    parent_goods_id_ = #{sellOrder.parentGoodsId},
+                </if>
+                <if test="sellOrder.goodsId != null">
+                    goods_id_ = #{sellOrder.goodsId},
+                </if>
+                <if test="sellOrder.goodsName != null">
+                    goods_name_ = #{sellOrder.goodsName},
+                </if>
+                <if test="sellOrder.sellCost != null">
+                    sell_cost_ = #{sellOrder.sellCost},
+                </if>
+                <if test="sellOrder.sellCost2 != null">
+                    sell_cost2_ = #{sellOrder.sellCost2},
+                </if>
+                <if test="sellOrder.num != null">
+                    num_ = #{sellOrder.num},
+                </if>
+                <if test="sellOrder.userId != null">
+                    user_id_ = #{sellOrder.userId},
+                </if>
+                <if test="sellOrder.paymentChannel != null">
+                    payment_channel_ = #{sellOrder.paymentChannel},
+                </if>
+                <if test="sellOrder.merNo != null">
+                    mer_no_ = #{sellOrder.merNo},
+                </if>
+                <if test="sellOrder.batchNo != null">
+                    batch_no_ = #{sellOrder.batchNo},
+                </if>
+                <if test="sellOrder.stockType != null">
+                    stock_type_ = #{sellOrder.stockType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
+                </if>
+                <if test="sellOrder.accountType != null">
+                    account_type_ = #{sellOrder.accountType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
+                </if>
+                <if test="sellOrder.status != null">
+                    status_ = #{sellOrder.status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
+                </if>
+                <if test="sellOrder.sellTime != null">
+                    sell_time_ = #{sellOrder.sellTime},
+                </if>
+                <if test="sellOrder.createIme != null">
+                    create_ime_ = #{sellOrder.createIme},
+                </if>
+                    update_time_ = NOW()
+            </set>
+            where id_ = #{sellOrder.id}
+        </foreach>
+    </update>
+
     <insert id="batchInsert" parameterType="java.util.List" useGeneratedKeys="true" keyProperty="id_">
         insert into sell_order (organ_id_, cooperation_organ_id_, trans_no_,order_id_, order_no_, expect_amount_,
         actual_amount_,balance_amount_, type_, parent_goods_id_, goods_id_,goods_name_, sell_cost_, sell_cost2_, num_, user_id_, payment_channel_,
@@ -404,4 +491,12 @@
             #{id}
         </foreach>
     </select>
+
+    <select id="getSellOrderByParentGoodsId" resultMap="SellOrder">
+        SELECT * FROM sell_order WHERE order_id_ = #{orderId} AND parent_goods_id_ = #{parentGoodsId}
+    </select>
+
+    <select id="getNoneBatchNoSellOrders" resultMap="SellOrder">
+        SELECT * FROM sell_order WHERE status_ = 0 AND stock_type_ IS NOT NULL AND batch_no_ IS NULL
+    </select>
 </mapper>

+ 25 - 4
mec-teacher/src/main/java/com/ym/mec/teacher/controller/TeacherController.java

@@ -1,6 +1,8 @@
 package com.ym.mec.teacher.controller;
 
-import com.ym.mec.biz.service.ImGroupNoticeService;
+import com.ym.mec.biz.dal.entity.Employee;
+import com.ym.mec.biz.service.*;
+import com.ym.mec.common.entity.HttpResponseResult;
 import com.ym.mec.common.page.QueryInfo;
 
 import io.swagger.annotations.Api;
@@ -28,9 +30,6 @@ import com.ym.mec.biz.dal.page.TeacherCloseQueryInfo;
 import com.ym.mec.biz.dal.page.TeacherMusicClassQueryInfo;
 import com.ym.mec.biz.dal.page.VipClassQueryInfo;
 import com.ym.mec.biz.dal.page.queryMusicGroupStudentQueryInfo;
-import com.ym.mec.biz.service.ClassGroupService;
-import com.ym.mec.biz.service.SubjectService;
-import com.ym.mec.biz.service.TeacherService;
 import com.ym.mec.common.controller.BaseController;
 
 @RequestMapping("teacher")
@@ -50,6 +49,8 @@ public class TeacherController extends BaseController {
     private SysUserFeignService sysUserFeignService;
 	@Autowired
 	private SubjectDao subjectDao;
+	@Autowired
+    private EmployeeService employeeService;
 
     @ApiOperation(value = "修改教师个人中心信息")
     @PostMapping("/update")
@@ -182,4 +183,24 @@ public class TeacherController extends BaseController {
 		teacherService.realNameAuthentication(user.getId(), realName, idcardNo, idcardFrontImg, idcardBackImg, idcardHandImg);
 		return succeed();
 	}
+
+    @ApiOperation(value = "获取教务人员")
+    @GetMapping("/findEducationUsers")
+    public HttpResponseResult findEducationUsers(Integer userId){
+        SysUser sysUser = sysUserFeignService.queryUserInfo();
+        if (sysUser == null) {
+            return failed(HttpStatus.FORBIDDEN, "请登录");
+        }
+        String organIds = new String();
+        if (!sysUser.getIsSuperAdmin()) {
+            Teacher teacher = teacherService.get(sysUser.getId());
+            if (StringUtils.isEmpty(organIds)) {
+                organIds = teacher.getTeacherOrganId() + "";
+            }
+            if(StringUtils.isNotBlank(teacher.getFlowOrganRange())){
+                organIds = organIds + "," + teacher.getFlowOrganRange();
+            }
+        }
+        return succeed(employeeService.findByRole("4,5",organIds));
+    }
 }

+ 24 - 2
mec-web/src/main/java/com/ym/mec/web/controller/SellOrderController.java

@@ -6,12 +6,15 @@ 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.SellOrder;
+import com.ym.mec.biz.dal.enums.SellStatus;
+import com.ym.mec.biz.dal.enums.SellTypeEnum;
 import com.ym.mec.biz.dal.page.RepairStudentQueryInfo;
 import com.ym.mec.biz.dal.page.SellOrderQueryInfo;
 import com.ym.mec.biz.service.SellOrderService;
 import com.ym.mec.biz.service.StudentRepairService;
 import com.ym.mec.common.controller.BaseController;
 import com.ym.mec.common.entity.HttpResponseResult;
+import com.ym.mec.common.exception.BizException;
 import com.ym.mec.common.page.PageInfo;
 import com.ym.mec.util.date.DateUtil;
 import io.swagger.annotations.Api;
@@ -19,6 +22,7 @@ import io.swagger.annotations.ApiOperation;
 import org.apache.commons.lang3.StringUtils;
 import org.snaker.engine.access.Page;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PostMapping;
@@ -26,6 +30,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
 import java.math.BigDecimal;
+import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Date;
 import java.util.List;
@@ -83,8 +88,25 @@ public class SellOrderController extends BaseController {
     @ApiOperation("退货")
     @PostMapping(value = "/refund")
     @PreAuthorize("@pcs.hasPermissions('sellOrder/refund')")
-    public HttpResponseResult<SellOrder> refund(Integer id) {
-        return succeed(sellOrderService.refund(id));
+    public HttpResponseResult<List<SellOrder>> refund(Integer id, Boolean reTry) {
+        SellOrder sellOrder = sellOrderService.get(id);
+
+        if (!sellOrder.getStatus().equals(SellStatus.NORMAL)) {
+            return failed("当前状态不能退货,请核查");
+        }
+        if (sellOrder.getType().equals(SellTypeEnum.SCHOOL_BUY)) {
+            return failed("学校采购不能退货");
+        }
+        if (sellOrder.getParentGoodsId() != null && (reTry == null || !reTry)) {
+            return failed(HttpStatus.CONTINUE, "组合商品,相关商品将一起退货");
+        }
+        List<SellOrder> sellOrders = new ArrayList<>();
+        if (sellOrder.getParentGoodsId() != null) {
+            sellOrders = sellOrderService.getSellOrderByParentGoodsId(sellOrder.getOrderId(), sellOrder.getParentGoodsId());
+        } else {
+            sellOrders.add(sellOrder);
+        }
+        return succeed(sellOrderService.refund(sellOrders));
     }
 
 }