|
@@ -18,18 +18,17 @@ class SystemStoreStock extends BaseModel
|
|
|
$model = new self;
|
|
|
$model = $model->alias("a")->join("store_product b", "a.product_id=b.id", "right");
|
|
|
if ($where['store_id'] > 0) $model = $model->where('a.store_id', $where['store_id']);
|
|
|
- if (isset($where['cate_id']) && $where['cate_id'] > 0)
|
|
|
- {
|
|
|
-
|
|
|
+ if (isset($where['cate_id']) && $where['cate_id'] > 0) {
|
|
|
+
|
|
|
$model = $model->whereIn('product_id', function ($query) use ($where) {
|
|
|
$query->name('store_product_cate')->where('cate_id', $where['cate_id'])->field('product_id')->select();
|
|
|
});
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
if ($where['key']) $model = $model->wherelike('b.store_name', "%" . $where['key'] . "%");
|
|
|
if (isset($where['is_warn']) && $where['is_warn'] == 1) $model = $model->where('a.in_stock', '<=', sys_config('warn_stock'));
|
|
|
$model = $model->where('a.id', '>', 0);
|
|
|
- $model = $model->field('a.product_id,b.store_name,b.image,b.is_show,b.is_del,a.store_id,a.in_stock,a.store_sales,a.repair_sales,a.in_last_time,a.bar_code,a.price,a.is_consumer');
|
|
|
+ $model = $model->field('a.product_id,b.store_name,b.image,b.is_show,b.is_del,a.store_id,a.in_stock,a.store_sales,a.repair_sales,a.in_last_time,a.bar_code,a.price,a.is_consumer,a.unique');
|
|
|
$count = $model->count();
|
|
|
if ($where['excel']) {
|
|
|
$data = $model->order("product_id desc")->select()->toarray();
|
|
@@ -42,9 +41,9 @@ class SystemStoreStock extends BaseModel
|
|
|
$value['in_stock'],
|
|
|
$value['repair_sales'],
|
|
|
$value['store_sales'],
|
|
|
- ];
|
|
|
+ StoreProductAttrValue::where('unique', $value['unique'])->value('cost')];
|
|
|
}
|
|
|
- PHPExcelService::setExcelHeader(['门店', '商品名称', '价格', '库存', '待补货', '销量'])
|
|
|
+ PHPExcelService::setExcelHeader(['门店', '商品名称', '价格', '库存', '待补货', '销量', '成本价'])
|
|
|
->setExcelTile('门店库存', '门店库存' . time(), ' 生成时间:' . date('Y-m-d H:i:s', time()))
|
|
|
->setExcelContent($export)
|
|
|
->ExcelSave();
|