|
@@ -16,7 +16,7 @@ class GoodsSalesController
|
|
|
{
|
|
|
$page = $request->get('page', 1);
|
|
|
$pageSize = $request->get('pageSize', 20);
|
|
|
- $days = $request->get('days', []);
|
|
|
+ $days = $request->get('days', [date('Y-m-01 00:00:00'), date('Y-m-t 23:59:59')]);
|
|
|
$classify = $request->get('classify', '');
|
|
|
$categoryId = $request->get('category_id', '');
|
|
|
$goodsName = $request->get('goods_name', '');
|
|
@@ -41,7 +41,7 @@ class GoodsSalesController
|
|
|
}
|
|
|
$searchCategoryIds = SysCategory::where('category_super_path', 'like', $categorySuperPath . '%')->pluck('category_id')->toArray();
|
|
|
$searchCategoryIds[] = $categoryId;
|
|
|
- // 按产品分类筛出来的ID
|
|
|
+ // 按产品类型筛出来的ID
|
|
|
$oldSearchGoodsIds = $searchGoodsIds;
|
|
|
|
|
|
$searchGoodsIds = Goods::whereIn('join_goods_category_id', $searchCategoryIds)->pluck('goods_id')->toArray();
|
|
@@ -49,14 +49,21 @@ class GoodsSalesController
|
|
|
$searchGoodsIds = array_intersect($searchGoodsIds, $oldSearchGoodsIds);
|
|
|
}
|
|
|
}
|
|
|
+ if (!empty($goodsName)) {
|
|
|
+ // 按产品类型和分类筛出来的ID
|
|
|
+ $oldSearchGoodsIds = $searchGoodsIds;
|
|
|
+ $searchGoodsIds = Goods::where('goods_name', 'like', '%' . $goodsName . '%')->pluck("goods_id")->toArray();
|
|
|
+ if (!empty($oldSearchGoodsIds)) {
|
|
|
+ $searchGoodsIds = array_intersect($searchGoodsIds, $oldSearchGoodsIds);
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
$dataInOuts = DataInout::where('data_inout_status', 'VALID')
|
|
|
->where('data_inout_classify', 'IN')
|
|
|
- ->whereBetween('data_inout_addtimes', $days)
|
|
|
- ->when(!empty($payType), function ($query) use ($payType) {
|
|
|
+ ->when(!empty($days), function ($query) use ($days) {
|
|
|
+ $query->whereBetween('data_inout_addtimes', $days);
|
|
|
+ })->when(!empty($payType), function ($query) use ($payType) {
|
|
|
$query->where('data_inout_pay_type', $payType);
|
|
|
- })->when(!empty($goodsName), function ($query) use ($goodsName) {
|
|
|
- $query->where('join_data_inout_object_json', 'like', "%" . $goodsName . "%");
|
|
|
})->select('join_data_inout_object_json')
|
|
|
->get()
|
|
|
->toArray();
|
|
@@ -92,6 +99,9 @@ class GoodsSalesController
|
|
|
continue;
|
|
|
}
|
|
|
foreach ($order['goods'] as $good) {
|
|
|
+ if ((!empty($classify) || !empty($categoryId) || !empty($goodsName)) && !in_array($good['goods_id'], $searchGoodsIds)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
$goodKey = $good['goods_id'];
|
|
|
if (!empty($good['goods_sku_id'])) {
|
|
|
$goodKey .= '_' . $good['goods_sku_id'];
|
|
@@ -219,7 +229,7 @@ class GoodsSalesController
|
|
|
if (!empty($sku['goods_sku_storage_json']) && !in_array($goods['goods_classify'], ['MEALS', 'PACKAGE'])) {
|
|
|
$storageJson = json_decode($sku['goods_sku_storage_json'], true);
|
|
|
$sku['storage'] = $storageJson['storage'];
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
$sku['storage'] = !empty($goods['running']) ? $goods['running']['goods_running_storage'] : 0;
|
|
|
}
|
|
|
}
|