StockController.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. namespace ghs\controllers;
  3. use bizGhs\product\classes\ProductClass;
  4. use bizGhs\stock\classes\StockRecordClass;
  5. use common\components\dateUtil;
  6. use common\components\util;
  7. use Yii;
  8. //库存管理与预警 lqh 2021.1.26
  9. class StockController extends BaseController
  10. {
  11. //库存明细 lqh 2021.1.26 和下面个方法一样,有多处要处理 stock_detail_list_2
  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 = StockRecordClass::getRecordList($where);
  29. $typeList = StockRecordClass::getTypeName();
  30. $list['typeList'] = $typeList;
  31. util::success($list);
  32. }
  33. //库存明细 lqh 2021.1.26 和上面个方法一样,有多处要处理 stock_detail_list_2
  34. public function actionList()
  35. {
  36. $get = Yii::$app->request->get();
  37. $id = $get['id'] ?? 0;
  38. $product = ProductClass::getById($id, true);
  39. if (isset($product->mainId) == false || $product->mainId != $this->mainId) {
  40. util::fail('没有权限');
  41. }
  42. $where = ['productId' => $id];
  43. $searchTime = $get['searchTime'] ?? '';
  44. if (!empty($searchTime)) {
  45. $startTime = $get['startTime'] ?? '';
  46. $endTime = $get['endTime'] ?? '';
  47. $period = dateUtil::formatTime($searchTime, $startTime, $endTime);
  48. $where['addTime'] = ['between', [$period['startTime'], $period['endTime']]];
  49. }
  50. $list = StockRecordClass::getRecordList($where);
  51. $typeList = StockRecordClass::getTypeName();
  52. $list['typeList'] = $typeList;
  53. util::success($list);
  54. }
  55. }