소스 검색

查询发货记录

afa 4 달 전
부모
커밋
47501f68b2
2개의 변경된 파일9개의 추가작업 그리고 9개의 파일을 삭제
  1. 1 1
      app/api/controller/Shops.php
  2. 8 8
      app/api/service/SpecService.php

+ 1 - 1
app/api/controller/Shops.php

@@ -44,7 +44,7 @@ class Shops extends Base
                 ->leftjoin('stock_config c', 'a.variety_id = c.id') //品种
                 ->leftjoin('product_config d', 'a.spec_id = d.id') //规格
                 ->leftjoin('customer u', 'a.customer_id = u.id') //客户
-                ->field('a.id,a.plat_id,a.shop_id,a.ship_date,a.settlement_data,a.createtime,a.num, b.name shop_name,c.title variety_name,d.title spec_name,u.name customer_name')
+                ->field('a.id,a.plat_id,a.shop_id,a.box_id,a.fast_mail,a.ship_date,a.settlement_data,a.createtime,a.num, b.name shop_name,c.title variety_name,d.title spec_name,u.name customer_name')
                 ->where($where)
                 ->order('a.ship_date desc')
                 ->paginate($limit);

+ 8 - 8
app/api/service/SpecService.php

@@ -51,7 +51,7 @@ class SpecService{
             //结算周期
             $settlement_data = SpecService::getDeliverySettlement($customer, $data['ship_date']);
             foreach ($data['variety'] as $item) {
-                  if(count($item) != 5 || empty(floatval($item['num'])))  throw new \Exception('参数有误!');
+                  if(count($item) != 9 || empty(floatval($item['num'])))  throw new \Exception('参数有误!');
                   $specsWeight = ProductConfig::where('id', $item['spec_id'])->value('weight');
                   //if(!$specs)  throw new \Exception('参数有误!');
                   $weight = bcmul((string)$specsWeight, $item['num'], 2);
@@ -62,6 +62,8 @@ class SpecService{
                         'plat_id'         => $data['plat_id'],
                         'variety_id'      => $item['variety_id'],
                         'spec_id'         => $item['spec_id'],
+                        'box_id'          => $item['box_id'],
+                        'fast_mail'       => $item['fast_mail'],
                         'num'             => $item['num'],
                         'weigh'           => $weight,
                         'price'           => $item['price'],
@@ -82,14 +84,13 @@ class SpecService{
                         'remark'          => '录入出库'
                   ];
                   //根据规格扣除包装箱
-                  $box_id = CustomerSpec::where('customer_id', $customer->id)->where('type_id', $item['variety_id'])->where('product_id', $item['spec_id'])->value('box_id');
-                  if($box_id){
-                        $boxNum = StockDetail::setStockConfigNum($box_id, (string)-$item['num'], StockConfig::PackingBox);
+                  if($item['box_id']){
+                        $boxNum = StockDetail::setStockConfigNum($item['box_id'], (string)-$item['num'], StockConfig::PackingBox);
                         $stockData[] = [
                               'user_id'         => $uid, 
                               'type_id'         => StockConfig::PackingBox,
                               'type'            => 1,
-                              'variety_id'      => $box_id,
+                              'variety_id'      => $item['box_id'],
                               'change'          => -$item['num'],
                               'after'           => $boxNum,
                               'remark'          => '录入出库'
@@ -120,9 +121,8 @@ class SpecService{
             StockDetail::setStockConfigNum($delivery->variety_id, bcsub($delivery->weigh, $weight, 2), StockConfig::VarietyName);
 
             //根据规格扣除包装箱
-            $box_id = CustomerSpec::where('customer_id', $delivery->customer_id)->where('type_id', $delivery['variety_id'])->where('product_id', $delivery->spec_id)->value('box_id');
-            if($box_id){
-                  StockDetail::setStockConfigNum($box_id, bcsub((string)$delivery->num, $data['num'], 2), StockConfig::PackingBox);
+            if($delivery->box_id){
+                  StockDetail::setStockConfigNum($delivery->box_id, bcsub((string)$delivery->num, $data['num'], 2), StockConfig::PackingBox);
             }
             //修改数量
             $price  = bcdiv($delivery->total_price, (string)$delivery->num, 2); //单价