Просмотр исходного кода

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

# Conflicts:
#	mec-biz/src/main/resources/config/mybatis/SellOrderMapper.xml
zouxuan 5 лет назад
Родитель
Сommit
1c5637e7e4

+ 17 - 1
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/GoodsProcurement.java

@@ -10,6 +10,9 @@ public class GoodsProcurement {
 
 	@ApiModelProperty(value = "编号")
 	private Long id;
+
+	@ApiModelProperty(value = "组合商品编号")
+	private Integer parentGoodsId;
 	
 	@ApiModelProperty(value = "商品编号")
 	private Integer goodsId;
@@ -57,6 +60,11 @@ public class GoodsProcurement {
 		this.goodsId = goodsId;
 	}
 
+	public GoodsProcurement(Integer parentGoodsId, Integer goodsId) {
+		this.parentGoodsId = parentGoodsId;
+		this.goodsId = goodsId;
+	}
+
 	public void setId(Long id){
 		this.id = id;
 	}
@@ -64,7 +72,15 @@ public class GoodsProcurement {
 	public Long getId(){
 		return this.id;
 	}
-			
+
+	public Integer getParentGoodsId() {
+		return parentGoodsId;
+	}
+
+	public void setParentGoodsId(Integer parentGoodsId) {
+		this.parentGoodsId = parentGoodsId;
+	}
+
 	public void setGoodsId(Integer goodsId){
 		this.goodsId = goodsId;
 	}

+ 14 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/SellOrder.java

@@ -98,6 +98,12 @@ public class SellOrder {
     private SellTypeEnum type;
 
     /**
+     * 组合商品id
+     */
+    @ApiModelProperty(value="组合商品id")
+    private Integer parentGoodsId;
+
+    /**
     * 商品id
     */
     @ApiModelProperty(value="商品id")
@@ -437,4 +443,12 @@ public class SellOrder {
     public void setStatus(SellStatus status) {
         this.status = status;
     }
+
+    public Integer getParentGoodsId() {
+        return parentGoodsId;
+    }
+
+    public void setParentGoodsId(Integer parentGoodsId) {
+        this.parentGoodsId = parentGoodsId;
+    }
 }

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

@@ -21,6 +21,6 @@ public enum AccountType implements BaseEnum<Integer, AccountType> {
 
     @Override
     public Integer getCode() {
-        return null;
+        return code;
     }
 }

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

@@ -92,9 +92,8 @@ public interface GoodsService extends BaseService<Integer, Goods> {
      * @describe 增加商品库存
      * @author Joburgess
      * @date 2020.10.12
-     * @param goodsBatchNoDtos: 对应批次商品列表
-     * @param goodsIds: 用户购买商品列表
+     * @param sellOrderIds: 对应批次商品列表
      * @return void
      */
-    void increaseStock(List<GoodsBatchNoDto> goodsBatchNoDtos, List<Integer> goodsIds, AccountType accountType);
+    void increaseStock(List<Integer> sellOrderIds, AccountType accountType);
 }

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

@@ -314,77 +314,77 @@ 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<Integer> singleGoodsIds = new ArrayList<>();
+		List<GoodsProcurement> goodsBatchNoDtos = new ArrayList<>();
 		for (Integer goodsId : goodsIds) {
 			Goods tempGoods = idTempGoodsMap.get(goodsId);
+			List<Goods> childGoods = new ArrayList<>();
 			if(StringUtils.isBlank(tempGoods.getComplementGoodsIdList())){
-				singleGoodsIds.add(tempGoods.getId());
+				childGoods.add(tempGoods);
 			}else{
 				List<Integer> complementGoodsIds = Arrays.stream(tempGoods.getComplementGoodsIdList().split(",")).map(s -> Integer.valueOf(s)).collect(Collectors.toList());
-				singleGoodsIds.addAll(complementGoodsIds);
+				childGoods = goodsDao.getGoodies(complementGoodsIds);
 			}
 			tempGoods.setSellCount((int) (tempGoods.getSellCount() + goodsSellNumMap.get(tempGoods.getId())));
-//			goodsDao.update(tempGoods);
-		}
-		goodsDao.batchUpdate(tempGoodsList);
-		List<Goods> singleGoodsList = goodsDao.getGoodies(singleGoodsIds);
-		Map<Integer, Goods> idSingleGoodsMap = singleGoodsList.stream().collect(Collectors.toMap(Goods::getId, g -> g));
-		List<GoodsProcurement> goodsBatchNoDtos = new ArrayList<>();
-		for (Integer singleGoodsId : singleGoodsIds) {
-			Goods goods = idSingleGoodsMap.get(singleGoodsId);
-			GoodsProcurement goodsProcurement = null;
-			if(StockType.INTERNAL.equals(goods.getStockType())||(StockType.ALL.equals(goods.getStockType())&&AccountType.INTERNAL.equals(accountType))){
-				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());
+			for (Goods goods : childGoods) {
+				GoodsProcurement goodsProcurement = null;
+				if(StockType.INTERNAL.equals(goods.getStockType())||(StockType.ALL.equals(goods.getStockType())&&AccountType.INTERNAL.equals(accountType))){
+					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());
+					}
 				}
-			}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());
+
+				goodsDao.update(goods);
 				if(Objects.nonNull(goodsProcurement)){
-					goodsProcurement.setTaxStockCount(new AtomicInteger(goodsProcurement.getTaxStockCount()).decrementAndGet());
-					goodsProcurement.setTaxStockSoldNum(new AtomicInteger(goodsProcurement.getTaxStockSoldNum()).incrementAndGet());
+					goodsProcurementDao.update(goodsProcurement);
+				}else{
+					goodsProcurement = new GoodsProcurement(goods.getId());
+				}
+				if(StringUtils.isNotBlank(tempGoods.getComplementGoodsIdList())){
+					goodsProcurement.setParentGoodsId(tempGoods.getId());
 				}
-			}
 
-			goodsDao.update(goods);
-			if(Objects.nonNull(goodsProcurement)){
 				goodsBatchNoDtos.add(goodsProcurement);
-				goodsProcurementDao.update(goodsProcurement);
-			}else{
-				goodsBatchNoDtos.add(new GoodsProcurement(goods.getId()));
 			}
+//			goodsDao.update(tempGoods);
 		}
-
+		goodsDao.batchUpdate(tempGoodsList);
 		return goodsBatchNoDtos;
 	}
 
 	@Override
 	@Transactional(rollbackFor = Exception.class, isolation = Isolation.READ_COMMITTED)
-	public void increaseStock(List<GoodsBatchNoDto> goodsBatchNoDtos, List<Integer> goodsIdsList, AccountType accountType) {
-		Set<Integer> goodsIds = goodsBatchNoDtos.stream().map(GoodsBatchNoDto::getGoodsId).collect(Collectors.toSet());
-		List<Goods> goodsList = goodsDao.getGoodies(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);
-		}
+	public void increaseStock(List<Integer> sellOrderIds, AccountType accountType) {
+//		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);
+//		}
 	}
 }

+ 22 - 1
mec-biz/src/main/java/com/ym/mec/biz/service/impl/SubjectChangeServiceImpl.java

@@ -213,7 +213,7 @@ public class SubjectChangeServiceImpl extends BaseServiceImpl<Integer, SubjectCh
     @Transactional(rollbackFor = Exception.class)
     public SubjectChange addChange(SubjectChange subjectChange) {
         SubjectChange studentWaitPay = subjectChangeDao.getStudentWaitPay(subjectChange.getStudentId(), subjectChange.getMusicGroupId());
-        if(studentWaitPay != null){
+        if (studentWaitPay != null) {
             throw new BizException("已有未支付的声部更改,请勿重复创建");
         }
         Date nowDate = new Date();
@@ -257,6 +257,27 @@ public class SubjectChangeServiceImpl extends BaseServiceImpl<Integer, SubjectCh
         subjectChange.setUpdateTime(nowDate);
         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);
+
+        }
         return subjectChange;
     }
 

+ 9 - 5
mec-biz/src/main/resources/config/mybatis/SellOrderMapper.xml

@@ -17,6 +17,7 @@
         <result column="actual_amount_" property="actualAmount"/>
         <result column="balance_amount_" property="balanceAmount"/>
         <result column="type_" property="type" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
+        <result column="parent_goods_id_" property="parentGoodsId"/>
         <result column="goods_id_" property="goodsId"/>
         <result column="goods_name_" property="goodsName"/>
         <result column="sell_cost_" property="sellCost"/>
@@ -38,7 +39,7 @@
     <sql id="Base_Column_List">
         <!--@mbg.generated-->
         id_, edu_teacher_id_,organ_id_, cooperation_organ_id_, trans_no_,order_id_, order_no_, expect_amount_,
-        actual_amount_,balance_amount_, sell_cost_, sell_cost2_, type_, goods_id_,goods_name_, num_, user_id_,
+        actual_amount_,balance_amount_, sell_cost_, sell_cost2_, type_,parent_goods_id_, goods_id_,goods_name_, num_, user_id_,
         payment_channel_,mer_no_,batch_no_,stock_type_,account_type_,status_, sell_time_, create_ime_, update_time_
     </sql>
     <select id="get" parameterType="java.lang.Integer" resultMap="SellOrder">
@@ -57,10 +58,10 @@
             useGeneratedKeys="true">
         <!--@mbg.generated-->
         insert into sell_order (edu_teacher_id_,organ_id_, cooperation_organ_id_, trans_no_,order_id_, order_no_,
-        expect_amount_,actual_amount_,balance_amount_, type_, goods_id_,goods_name_, sell_cost_, sell_cost2_, num_, user_id_, payment_channel_,
+        expect_amount_,actual_amount_,balance_amount_, type_,parent_goods_id_, goods_id_,goods_name_, sell_cost_, sell_cost2_, num_, user_id_, payment_channel_,
         mer_no_,batch_no_,stock_type_,account_type_, sell_time_, create_ime_, update_time_)
         values (#{eduTeacherId},#{organId}, #{cooperationOrganId}, #{transNo}, #{orderNo},#{orderId}, #{expectAmount},
-        #{actualAmount}, #{balanceAmount}, #{type}, #{goodsId}, #{goodsName}, #{sellCost}, #{sellCost2}, #{num}, #{userId},
+        #{actualAmount}, #{balanceAmount}, #{type},#{parentGoodsId}, #{goodsId}, #{goodsName}, #{sellCost}, #{sellCost2}, #{num}, #{userId},
         #{paymentChannel}, #{merNo},#{batchNo},#{stockType},#{accountType}, #{sellTime}, #{createIme}, #{updateTime})
     </insert>
     <update id="update" parameterType="com.ym.mec.biz.dal.entity.SellOrder">
@@ -97,6 +98,9 @@
             <if test="type != null">
                 type_ = #{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
             </if>
+            <if test="parentGoodsId != null">
+                parent_goods_id_ = #{parentGoodsId},
+            </if>
             <if test="goodsId != null">
                 goods_id_ = #{goodsId},
             </if>
@@ -148,12 +152,12 @@
 
     <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_, goods_id_,goods_name_, sell_cost_, sell_cost2_, num_, user_id_, payment_channel_,
+        actual_amount_,balance_amount_, type_, parent_goods_id_, goods_id_,goods_name_, sell_cost_, sell_cost2_, num_, user_id_, payment_channel_,
         mer_no_,batch_no_,stock_type_,account_type_, sell_time_,edu_teacher_id_, create_ime_, update_time_)
         VALUE
         <foreach collection="sellOrders" separator="," item="sellOrder">
             (#{sellOrder.organId},#{sellOrder.cooperationOrganId},#{sellOrder.transNo},#{sellOrder.orderId},#{sellOrder.orderNo},
-            #{sellOrder.expectAmount},#{sellOrder.actualAmount},#{sellOrder.balanceAmount},#{sellOrder.type},#{sellOrder.goodsId},
+            #{sellOrder.expectAmount},#{sellOrder.actualAmount},#{sellOrder.balanceAmount},#{sellOrder.type},#{sellOrder.parentGoodsId},#{sellOrder.goodsId},
             #{sellOrder.goodsName},#{sellOrder.sellCost},#{sellOrder.sellCost2},#{sellOrder.num},#{sellOrder.userId},
             #{sellOrder.paymentChannel},#{sellOrder.merNo},#{sellOrder.batchNo},#{sellOrder.stockType},#{sellOrder.accountType},
             #{sellOrder.sellTime},#{sellOrder.eduTeacherId},NOW(),NOW())