OnStockController.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. namespace ghs\controllers;
  3. use bizGhs\product\classes\ProductClass;
  4. use bizGhs\stock\classes\OnStockRecordClass;
  5. use common\components\dateUtil;
  6. use common\components\util;
  7. use Yii;
  8. //库存管理与预警 lqh 2021.1.26
  9. class OnStockController extends BaseController
  10. {
  11. //库存明细 lqh 2021.1.26
  12. public function actionDetail()
  13. {
  14. $get = Yii::$app->request->get();
  15. $id = $get['id'] ?? 0;
  16. $product = ProductClass::getById($id, true);
  17. if (isset($product->mainId) == false || $product->mainId != $this->mainId) {
  18. util::fail('没有权限');
  19. }
  20. $where = ['productId' => $id];
  21. $searchTime = $get['searchTime'] ?? '';
  22. if (!empty($searchTime)) {
  23. $startTime = $get['startTime'] ?? '';
  24. $endTime = $get['endTime'] ?? '';
  25. $period = dateUtil::formatTime($searchTime, $startTime, $endTime);
  26. $where['addTime'] = ['between', [$period['startTime'], $period['endTime']]];
  27. }
  28. $list = OnStockRecordClass::getRecordList($where);
  29. util::success($list);
  30. }
  31. }