|  | @@ -170,11 +170,11 @@ public class ShopSettlementServiceImpl implements ShopSettlementService {
 | 
	
		
			
				|  |  |          Map<Long, List<Long>> shopOrderItemIds = new HashMap<>();
 | 
	
		
			
				|  |  |          List<ShopSettlementDO> shopSettlementDOS = new ArrayList<>();
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +        // pt结算成本价
 | 
	
		
			
				|  |  | +        Long ptSettlementAmount = 0L;
 | 
	
		
			
				|  |  |          Integer ptPlatformCollectionAmount = 0;
 | 
	
		
			
				|  |  |          // 代收积分
 | 
	
		
			
				|  |  |          Long ptPayIntegral = 0L;
 | 
	
		
			
				|  |  | -        // 代收消费分
 | 
	
		
			
				|  |  | -        Long ptPayConsumptionPoints = 0L;
 | 
	
		
			
				|  |  |          // 店铺应得金额(成本 * 数量)
 | 
	
		
			
				|  |  |          int ptShopAmount = 0;
 | 
	
		
			
				|  |  |          BigDecimal ptShopHighAmount = BigDecimal.ZERO;
 | 
	
	
		
			
				|  | @@ -196,13 +196,14 @@ public class ShopSettlementServiceImpl implements ShopSettlementService {
 | 
	
		
			
				|  |  |                  Integer platformCollectionAmount = 0;
 | 
	
		
			
				|  |  |                  // 代收积分
 | 
	
		
			
				|  |  |                  Long payIntegral = 0L;
 | 
	
		
			
				|  |  | -                // 代收消费分
 | 
	
		
			
				|  |  | -                Long payConsumptionPoints = 0L;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |                  // 店铺应得金额(成本 * 数量)
 | 
	
		
			
				|  |  |                  int shopAmount = 0;
 | 
	
		
			
				|  |  |                  BigDecimal shopHighAmount = BigDecimal.ZERO;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +                // 结算成本价
 | 
	
		
			
				|  |  | +                Long settlementAmount = 0L;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |                  //获取该店铺下的订单
 | 
	
		
			
				|  |  |                  for (OrderDTO order : orders) {
 | 
	
		
			
				|  |  |                      // 获取所有的订单id
 | 
	
	
		
			
				|  | @@ -214,32 +215,26 @@ public class ShopSettlementServiceImpl implements ShopSettlementService {
 | 
	
		
			
				|  |  |                      for (OrderItemDTO item : order.getItems()) {
 | 
	
		
			
				|  |  |                          //拿到该店铺下的所有订单项id
 | 
	
		
			
				|  |  |                          orderItemIds.add(item.getId());
 | 
	
		
			
				|  |  | -                        //计算订单的收入金额(pt)
 | 
	
		
			
				|  |  | -                        platformCollectionAmount += item.getPayRmb();
 | 
	
		
			
				|  |  | -                        ptPlatformCollectionAmount += item.getPayRmb();
 | 
	
		
			
				|  |  |                          //计算订单的收入积分(pt)
 | 
	
		
			
				|  |  |                          payIntegral += item.getPayIntegral();
 | 
	
		
			
				|  |  | -                        payConsumptionPoints += item.getPayConsumptionPoints();     //消费分
 | 
	
		
			
				|  |  |                          ptPayIntegral += item.getPayIntegral();
 | 
	
		
			
				|  |  | -                        ptPayConsumptionPoints += item.getPayConsumptionPoints();   //消费分
 | 
	
		
			
				|  |  |                          // 商品的成本价(成本 * 数量)
 | 
	
		
			
				|  |  |                          shopAmount += item.getSettlementPrice() * item.getCount();
 | 
	
		
			
				|  |  |                          ptShopAmount += item.getSettlementPrice() * item.getCount();
 | 
	
		
			
				|  |  | -                        // 商品的高精度成本价(成本 * 数量)
 | 
	
		
			
				|  |  | -                        shopHighAmount = shopHighAmount.add(BigDecimal.valueOf(item.getHighPrecisionSettlementPrice().doubleValue() * item.getCount()));
 | 
	
		
			
				|  |  | -                        ptShopHighAmount = ptShopHighAmount.add(BigDecimal.valueOf(item.getHighPrecisionSettlementPrice().doubleValue() * item.getCount()));
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |                          // 如果商品成本不为0,则计算利润
 | 
	
		
			
				|  |  | -                        if(!item.getSettlementPrice().equals(0)){
 | 
	
		
			
				|  |  | +                        if (!item.getSettlementPrice().equals(0)) {
 | 
	
		
			
				|  |  |                              profit = profit.add(BigDecimal.valueOf(item.getCostPrice() - item.getSettlementPrice()));
 | 
	
		
			
				|  |  | -                        } else if(item.getHighPrecisionSettlementPrice().compareTo(new BigDecimal("0")) == 0){
 | 
	
		
			
				|  |  | -                            // 商品的高精度成本价
 | 
	
		
			
				|  |  | -                            profit = profit.add(item.getHighPrecisionPrice().subtract(item.getHighPrecisionSettlementPrice()));
 | 
	
		
			
				|  |  | +                        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                        if (item.getSettlementTime() != null) {
 | 
	
		
			
				|  |  | +                            settlementAmount += item.getSettlementPrice();
 | 
	
		
			
				|  |  | +                            ptSettlementAmount += item.getSettlementPrice();
 | 
	
		
			
				|  |  |                          }
 | 
	
		
			
				|  |  |                      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |                      // 订单利润大于0的时候才操作
 | 
	
		
			
				|  |  | -                    if(profit.compareTo(BigDecimal.ZERO) > 0){
 | 
	
		
			
				|  |  | +                    if (profit.compareTo(BigDecimal.ZERO) > 0) {
 | 
	
		
			
				|  |  |                          PtProfitDO ptProfit = ptProfitService.getPtProfit();
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |                          // 金额转积分 放大一万倍
 | 
	
	
		
			
				|  | @@ -269,7 +264,6 @@ public class ShopSettlementServiceImpl implements ShopSettlementService {
 | 
	
		
			
				|  |  |                    积分要转换才能变为钱
 | 
	
		
			
				|  |  |                   */
 | 
	
		
			
				|  |  |                  platformCollectionAmount += integral2Money(payIntegral);
 | 
	
		
			
				|  |  | -                platformCollectionAmount += integral2Money(payConsumptionPoints);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |                  // 店铺共计成本金额
 | 
	
	
		
			
				|  | @@ -281,17 +275,16 @@ public class ShopSettlementServiceImpl implements ShopSettlementService {
 | 
	
		
			
				|  |  |                          .merchantId(merchant.getMerchantId())
 | 
	
		
			
				|  |  |                          .platformCollectionAmount(platformCollectionAmount)
 | 
	
		
			
				|  |  |                          .shopAmount(payIntegral)
 | 
	
		
			
				|  |  | -                        .shopConsumptionPoints(payConsumptionPoints)
 | 
	
		
			
				|  |  |                          .shopTotalHighAmount(totalHighAmount.setScale(6, RoundingMode.HALF_UP))
 | 
	
		
			
				|  |  |                          .accountName(shop.getAccountName())
 | 
	
		
			
				|  |  |                          .accountNumber(shop.getAccountNumber())
 | 
	
		
			
				|  |  | +                        .settlementAmount(settlementAmount)
 | 
	
		
			
				|  |  |                          .build();
 | 
	
		
			
				|  |  |                  shopSettlementDOS.add(shopSett);
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          ptPlatformCollectionAmount += integral2Money(ptPayIntegral);
 | 
	
		
			
				|  |  | -        ptPlatformCollectionAmount += integral2Money(ptPayConsumptionPoints);
 | 
	
		
			
				|  |  |          // 平台共计成本金额
 | 
	
		
			
				|  |  |          BigDecimal totalHighAmount = ptShopHighAmount.add(BigDecimal.valueOf(ptShopAmount));
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -299,8 +292,8 @@ public class ShopSettlementServiceImpl implements ShopSettlementService {
 | 
	
		
			
				|  |  |          PtSettlementDO ptSettlementDO = PtSettlementDO.builder()
 | 
	
		
			
				|  |  |                  .platformCollectionAmount(ptPlatformCollectionAmount)
 | 
	
		
			
				|  |  |                  .shopAmount(ptPayIntegral)
 | 
	
		
			
				|  |  | -                .consumptionPoints(ptPayConsumptionPoints)
 | 
	
		
			
				|  |  |                  .shopTotalHighAmount(totalHighAmount.setScale(6, RoundingMode.HALF_UP))
 | 
	
		
			
				|  |  | +                .settlementAmount(ptSettlementAmount)
 | 
	
		
			
				|  |  |                  .build();
 | 
	
		
			
				|  |  |          ptSettlementMapper.insert(ptSettlementDO);
 | 
	
		
			
				|  |  |  
 |