diff --git a/app/admin/lists/product_source_link/ProductSourceLinkLists.php b/app/admin/lists/product_source_link/ProductSourceLinkLists.php index e99c8170..9162f793 100644 --- a/app/admin/lists/product_source_link/ProductSourceLinkLists.php +++ b/app/admin/lists/product_source_link/ProductSourceLinkLists.php @@ -6,7 +6,8 @@ namespace app\admin\lists\product_source_link; use app\admin\lists\BaseAdminDataLists; use app\common\model\product_source_link\ProductSourceLink; use app\common\lists\ListsSearchInterface; - +use app\common\model\product_source_link_info\ProductSourceLinkInfo; +use app\common\model\warehouse_product\WarehouseProduct; /** * 商品溯源管理列表 @@ -44,11 +45,14 @@ class ProductSourceLinkLists extends BaseAdminDataLists implements ListsSearchIn { return ProductSourceLink::where($this->searchWhere) ->with(['product','warehouse','purchase']) - // ->join('') - ->field(['id', 'purchase_uid', 'product_id', 'total_nums', 'nums', 'warehouse_id', 'warehouse_total_nums', 'warehouse_nums']) + ->field(['id', 'purchase_uid', 'product_id','warehouse_id',]) ->limit($this->limitOffset, $this->limitLength) ->order(['id' => 'desc']) ->select() + ->each(function ($item) { + $item->total_nums = ProductSourceLinkInfo::where('product_id', $item->product_id)->where('oid',$item->id)->where('types',1)->sum('nums'); + $item->warehouse_nums = ProductSourceLinkInfo::where('product_id', $item->product_id)->where('oid',$item->id)->where('types',2)->sum('nums'); + }) ->toArray(); }