|  | @@ -7,10 +7,7 @@ import com.ym.mec.biz.dal.dao.MusicGroupDao;
 | 
	
		
			
				|  |  |  import com.ym.mec.biz.dal.dao.SellOrderDao;
 | 
	
		
			
				|  |  |  import com.ym.mec.biz.dal.dao.StudentPaymentOrderDao;
 | 
	
		
			
				|  |  |  import com.ym.mec.biz.dal.entity.*;
 | 
	
		
			
				|  |  | -import com.ym.mec.biz.dal.enums.GoodsType;
 | 
	
		
			
				|  |  | -import com.ym.mec.biz.dal.enums.KitGroupPurchaseTypeEnum;
 | 
	
		
			
				|  |  | -import com.ym.mec.biz.dal.enums.OrderDetailTypeEnum;
 | 
	
		
			
				|  |  | -import com.ym.mec.biz.dal.enums.SellTypeEnum;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.dal.enums.*;
 | 
	
		
			
				|  |  |  import com.ym.mec.biz.service.*;
 | 
	
		
			
				|  |  |  import com.ym.mec.common.dal.BaseDAO;
 | 
	
		
			
				|  |  |  import com.ym.mec.common.service.impl.BaseServiceImpl;
 | 
	
	
		
			
				|  | @@ -31,6 +28,8 @@ public class SellOrderServiceImpl extends BaseServiceImpl<Integer, SellOrder> im
 | 
	
		
			
				|  |  |      private StudentPaymentOrderDao studentPaymentOrderDao;
 | 
	
		
			
				|  |  |      @Autowired
 | 
	
		
			
				|  |  |      private MusicGroupDao musicGroupDao;
 | 
	
		
			
				|  |  | +    @Autowired
 | 
	
		
			
				|  |  | +    private SysPaymentConfigService sysPaymentConfigService;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      @Override
 | 
	
		
			
				|  |  |      public BaseDAO<Integer, SellOrder> getDAO() {
 | 
	
	
		
			
				|  | @@ -67,6 +66,9 @@ public class SellOrderServiceImpl extends BaseServiceImpl<Integer, SellOrder> im
 | 
	
		
			
				|  |  |          BigDecimal hasRouteBalance = BigDecimal.ZERO;
 | 
	
		
			
				|  |  |          BigDecimal goodsTotalBalance = goodsTotalPrice.multiply(balance).divide(totalAmount, 2, BigDecimal.ROUND_HALF_UP);
 | 
	
		
			
				|  |  |          List<SellOrder> sellOrders = new ArrayList<>();
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        AccountType accountType = sysPaymentConfigService.checkAccountType(PaymentChannelEnum.valueOf(order.getPaymentChannel()), order.getMerNos());
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |          for (Integer goodsId : goodsIds) {
 | 
	
		
			
				|  |  |              SellOrder sellOrder = new SellOrder();
 | 
	
		
			
				|  |  |              BigDecimal goodsPrice = BigDecimal.ZERO;
 | 
	
	
		
			
				|  | @@ -106,6 +108,7 @@ public class SellOrderServiceImpl extends BaseServiceImpl<Integer, SellOrder> im
 | 
	
		
			
				|  |  |              sellOrder.setUserId(order.getUserId());
 | 
	
		
			
				|  |  |              sellOrder.setPaymentChannel(order.getPaymentChannel());
 | 
	
		
			
				|  |  |              sellOrder.setMerNo(order.getMerNos());
 | 
	
		
			
				|  |  | +            sellOrder.setAccountType(accountType);
 | 
	
		
			
				|  |  |              sellOrder.setSellTime(order.getCreateTime());
 | 
	
		
			
				|  |  |              sellOrder.setCreateIme(new Date());
 | 
	
		
			
				|  |  |              sellOrder.setUpdateTime(new Date());
 | 
	
	
		
			
				|  | @@ -116,6 +119,24 @@ public class SellOrderServiceImpl extends BaseServiceImpl<Integer, SellOrder> im
 | 
	
		
			
				|  |  |              } else {
 | 
	
		
			
				|  |  |                  sellOrder.setType(SellTypeEnum.OTHER);
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            StockType goodsStockType = StockType.INTERNAL;
 | 
	
		
			
				|  |  | +            for (Goods goods : goodies) {
 | 
	
		
			
				|  |  | +                if (goods.getId().equals(goodsId)) {
 | 
	
		
			
				|  |  | +                    goodsStockType = goods.getStockType();
 | 
	
		
			
				|  |  | +                    break;
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            //库存类型
 | 
	
		
			
				|  |  | +            if(goodsStockType.equals(StockType.ALL) && accountType.equals(AccountType.INTERNAL)){
 | 
	
		
			
				|  |  | +                sellOrder.setStockType(StockType.INTERNAL);
 | 
	
		
			
				|  |  | +            }else if(goodsStockType.equals(StockType.ALL) && accountType.equals(AccountType.EXTERNAL)){
 | 
	
		
			
				|  |  | +                sellOrder.setStockType(StockType.EXTERNAL);
 | 
	
		
			
				|  |  | +            }else {
 | 
	
		
			
				|  |  | +                sellOrder.setStockType(goodsStockType);
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            //批次号 TODO
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |              sellOrders.add(sellOrder);
 | 
	
		
			
				|  |  |              i++;
 | 
	
		
			
				|  |  |          }
 | 
	
	
		
			
				|  | @@ -138,8 +159,10 @@ public class SellOrderServiceImpl extends BaseServiceImpl<Integer, SellOrder> im
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          int i = 1;
 | 
	
		
			
				|  |  |          BigDecimal detailRouteBalance = BigDecimal.ZERO;
 | 
	
		
			
				|  |  | -        for (StudentPaymentOrderDetail orderDetail : orderDetails) {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +        AccountType accountType = sysPaymentConfigService.checkAccountType(PaymentChannelEnum.valueOf(studentPaymentOrder.getPaymentChannel()), studentPaymentOrder.getMerNos());
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        for (StudentPaymentOrderDetail orderDetail : orderDetails) {
 | 
	
		
			
				|  |  |              BigDecimal detailBalance = orderDetail.getPrice().compareTo(BigDecimal.ZERO) <= 0 ? BigDecimal.ZERO :
 | 
	
		
			
				|  |  |                      orderDetail.getPrice().multiply(detailTotalBalance).divide(detailTotalPrice, 2, BigDecimal.ROUND_HALF_UP);
 | 
	
		
			
				|  |  |              if (i == orderDetails.size()) {
 | 
	
	
		
			
				|  | @@ -192,6 +215,7 @@ public class SellOrderServiceImpl extends BaseServiceImpl<Integer, SellOrder> im
 | 
	
		
			
				|  |  |                  sellOrder.setUserId(studentPaymentOrder.getUserId());
 | 
	
		
			
				|  |  |                  sellOrder.setPaymentChannel(studentPaymentOrder.getPaymentChannel());
 | 
	
		
			
				|  |  |                  sellOrder.setMerNo(studentPaymentOrder.getMerNos());
 | 
	
		
			
				|  |  | +                sellOrder.setAccountType(accountType);
 | 
	
		
			
				|  |  |                  sellOrder.setSellTime(studentPaymentOrder.getCreateTime());
 | 
	
		
			
				|  |  |                  sellOrder.setCreateIme(new Date());
 | 
	
		
			
				|  |  |                  sellOrder.setUpdateTime(new Date());
 | 
	
	
		
			
				|  | @@ -211,6 +235,16 @@ public class SellOrderServiceImpl extends BaseServiceImpl<Integer, SellOrder> im
 | 
	
		
			
				|  |  |                      sellOrder.setBalanceAmount(BigDecimal.ZERO);
 | 
	
		
			
				|  |  |                      sellOrder.setExpectAmount(BigDecimal.ZERO);
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  | +                //库存类型
 | 
	
		
			
				|  |  | +                if(goods.getStockType().equals(StockType.ALL) && accountType.equals(AccountType.INTERNAL)){
 | 
	
		
			
				|  |  | +                    sellOrder.setStockType(StockType.INTERNAL);
 | 
	
		
			
				|  |  | +                }else if(goods.getStockType().equals(StockType.ALL) && accountType.equals(AccountType.EXTERNAL)){
 | 
	
		
			
				|  |  | +                    sellOrder.setStockType(StockType.EXTERNAL);
 | 
	
		
			
				|  |  | +                }else {
 | 
	
		
			
				|  |  | +                    sellOrder.setStockType(goods.getStockType());
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +                //批次号 TODO
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |                  sellOrders.add(sellOrder);
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |          }
 |