|  | @@ -2032,8 +2032,8 @@ public class OrderServiceImpl implements OrderService {
 | 
	
		
			
				|  |  |                      for (GoodsEntity goodsEntity : queryGoodsList) {
 | 
	
		
			
				|  |  |                          // 如果当前还有需要购买的
 | 
	
		
			
				|  |  |                          if (sellVolume > 0) {
 | 
	
		
			
				|  |  | -                            // 当前商品剩余的数量
 | 
	
		
			
				|  |  | -                            Integer remainAmount = goodsEntity.getGoodsNumber();
 | 
	
		
			
				|  |  | +                            // 当前商品剩余的数量, 门店库存
 | 
	
		
			
				|  |  | +                            Integer remainAmount = Integer.parseInt(goodsEntity.getStockNum());
 | 
	
		
			
				|  |  |                              if (sellVolume >= remainAmount) {
 | 
	
		
			
				|  |  |                                  // 证明该sku库存不足,需要继续向下个sku消费
 | 
	
		
			
				|  |  |                                  sellVolume -= remainAmount;
 | 
	
	
		
			
				|  | @@ -2092,6 +2092,7 @@ public class OrderServiceImpl implements OrderService {
 | 
	
		
			
				|  |  |  //                                return resultObj;
 | 
	
		
			
				|  |  |  //                            }
 | 
	
		
			
				|  |  |  //                        }
 | 
	
		
			
				|  |  | +                        // 门店库存变化记录
 | 
	
		
			
				|  |  |                          StoreMngChangeEntity storeMngChangeEntity = new StoreMngChangeEntity();
 | 
	
		
			
				|  |  |                          storeMngChangeEntity.setChangeType(Dict.changeType.item_1.getItem());
 | 
	
		
			
				|  |  |                          storeMngChangeEntity.setChangeReason("商品销售扣减");
 | 
	
	
		
			
				|  | @@ -2108,14 +2109,8 @@ public class OrderServiceImpl implements OrderService {
 | 
	
		
			
				|  |  |                          storeMngChangeEntity.setIsValid(0);
 | 
	
		
			
				|  |  |                          storeMngChangeDao.save(storeMngChangeEntity);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -                        productInfo.setStockNum(productInfo.getStockNum() - num);
 | 
	
		
			
				|  |  | -                        productInfo.setStoreId(Long.valueOf(storeId));
 | 
	
		
			
				|  |  | -                        productInfo.setSellVolume(productInfo.getSellVolume() + num);
 | 
	
		
			
				|  |  | -                        productInfo.setLastSaleTime(new Date());
 | 
	
		
			
				|  |  | -                        productStoreRelaDao.updateStockNum(productInfo);//修改普通商品库存
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | +                        int validNum = productInfo.getStockNum() - num;
 | 
	
		
			
				|  |  |                          if (goodsEntity != null) {
 | 
	
		
			
				|  |  | -                            int diff = goodsEntity.getGoodsNumber() - num;
 | 
	
		
			
				|  |  |                              MngChangeEntity mngChangeEntity = new MngChangeEntity();
 | 
	
		
			
				|  |  |                              mngChangeEntity.setThirdPartyMerchCode(goodsEntity.getThirdPartyMerchCode());
 | 
	
		
			
				|  |  |                              mngChangeEntity.setChangeReason("商品销售扣减");
 | 
	
	
		
			
				|  | @@ -2126,19 +2121,25 @@ public class OrderServiceImpl implements OrderService {
 | 
	
		
			
				|  |  |                              mngChangeEntity.setIsValid(0);
 | 
	
		
			
				|  |  |                              mngChangeEntity.setMerchSn(goodsEntity.getMerchSn());
 | 
	
		
			
				|  |  |                              mngChangeEntity.setOriginalNum(goodsEntity.getGoodsNumber());//原库存数
 | 
	
		
			
				|  |  | -                            mngChangeEntity.setValidNum(diff);//可用数
 | 
	
		
			
				|  |  | +                            mngChangeEntity.setValidNum(goodsEntity.getGoodsNumber() - num);//可用数
 | 
	
		
			
				|  |  |                              mngChangeEntity.setChangeNum(num);//变化数
 | 
	
		
			
				|  |  |                              mngChangeEntity.setChangeType(Dict.changeType.item_1.getItem());
 | 
	
		
			
				|  |  |                              mngChangeEntity.setGoodsId(Integer.parseInt(String.valueOf(goodsEntity.getId())));
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |                              mngChangeDao.save(mngChangeEntity);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |                              // 如果园区库存数量小于等于0, 则不更新园区库存, 园区库存只做参考
 | 
	
		
			
				|  |  | -                            if (diff >= 0) {
 | 
	
		
			
				|  |  | -                                goodsEntity.setGoodsNumber(diff);
 | 
	
		
			
				|  |  | -                                goodsEntity.setLastSaleTime(new Date());
 | 
	
		
			
				|  |  | -                                goodsDao.update(goodsEntity);
 | 
	
		
			
				|  |  | -                            }
 | 
	
		
			
				|  |  | +                            int diff = Math.max(goodsEntity.getGoodsNumber() - num, 0);
 | 
	
		
			
				|  |  | +                            goodsEntity.setGoodsNumber(diff);
 | 
	
		
			
				|  |  | +                            goodsEntity.setLastSaleTime(new Date());
 | 
	
		
			
				|  |  | +                            goodsDao.update(goodsEntity);
 | 
	
		
			
				|  |  |                          }
 | 
	
		
			
				|  |  | +                        // 门店库存
 | 
	
		
			
				|  |  | +                        productInfo.setStockNum(validNum);
 | 
	
		
			
				|  |  | +                        productInfo.setStoreId(Long.valueOf(storeId));
 | 
	
		
			
				|  |  | +                        productInfo.setSellVolume(productInfo.getSellVolume() + num);
 | 
	
		
			
				|  |  | +                        productInfo.setLastSaleTime(new Date());
 | 
	
		
			
				|  |  | +                        productStoreRelaDao.updateStockNum(productInfo);//修改普通商品库存
 | 
	
		
			
				|  |  |                      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |                      BigDecimal retailPrice = new BigDecimal(0);
 |