|
|
@@ -4,6 +4,7 @@ namespace ghs\controllers;
|
|
|
|
|
|
use biz\shop\classes\ShopExtClass;
|
|
|
use biz\stat\classes\StatBookClass;
|
|
|
+use bizGhs\product\classes\ProductClass;
|
|
|
use common\components\dateUtil;
|
|
|
use common\components\printUtil;
|
|
|
use Yii;
|
|
|
@@ -24,8 +25,19 @@ class StatBookController extends BaseController
|
|
|
$period = dateUtil::formatTime($searchTime, $startTime, $endTime, true);
|
|
|
$where['time'] = ['between', [$period['startTime'], $period['endTime']]];
|
|
|
}
|
|
|
-
|
|
|
+ $itemList = ProductClass::getAllByCondition(['mainId' => $this->mainId], null, 'id,stock', 'id', true);
|
|
|
$list = StatBookClass::getAllByCondition($where, 'time DESC', '*');
|
|
|
+ if (!empty($list)) {
|
|
|
+ foreach ($list as $key => $val) {
|
|
|
+ $productId = $val['itemId'] ?? 0;
|
|
|
+ $stock = 0;
|
|
|
+ if (isset($itemList[$productId])) {
|
|
|
+ $product = $itemList[$productId];
|
|
|
+ $stock = $product->stock;
|
|
|
+ }
|
|
|
+ $list[$key]['stock'] = $stock;
|
|
|
+ }
|
|
|
+ }
|
|
|
util::success(['list' => $list]);
|
|
|
}
|
|
|
|
|
|
@@ -42,9 +54,20 @@ class StatBookController extends BaseController
|
|
|
$period = dateUtil::formatTime($searchTime, $startTime, $endTime, true);
|
|
|
$where['time'] = ['between', [$period['startTime'], $period['endTime']]];
|
|
|
}
|
|
|
-
|
|
|
+ $itemList = ProductClass::getAllByCondition(['mainId' => $this->mainId], null, 'id,stock', 'id', true);
|
|
|
$list = StatBookClass::getAllByCondition($where, 'time DESC', '*');
|
|
|
- util::success(['list' => $list, 'moreData' => 0, 'totalPage' => 1, 'totalNum' => 1]);
|
|
|
+ if (!empty($list)) {
|
|
|
+ foreach ($list as $key => $val) {
|
|
|
+ $productId = $val['itemId'] ?? 0;
|
|
|
+ $stock = 0;
|
|
|
+ if (isset($itemList[$productId])) {
|
|
|
+ $product = $itemList[$productId];
|
|
|
+ $stock = $product->stock;
|
|
|
+ }
|
|
|
+ $list[$key]['stock'] = $stock;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ util::success(['list' => $list]);
|
|
|
}
|
|
|
|
|
|
public function actionPrintOrder()
|