StockController.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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. $recordType = $get['recordType']??'';
  29. if(is_numeric($recordType)){
  30. $where['recordType'] = $recordType;
  31. }
  32. $list = StockRecordClass::getRecordList($where);
  33. $typeList = StockRecordClass::getAllType();
  34. $list['typeList'] = $typeList;
  35. util::success($list);
  36. }
  37. //库存明细 lqh 2021.1.26 和上面个方法一样,有多处要处理 stock_detail_list_2
  38. public function actionList()
  39. {
  40. $get = Yii::$app->request->get();
  41. $id = $get['id'] ?? 0;
  42. $product = ProductClass::getById($id, true);
  43. if (isset($product->mainId) == false || $product->mainId != $this->mainId) {
  44. util::fail('没有权限');
  45. }
  46. $where = ['productId' => $id];
  47. $searchTime = $get['searchTime'] ?? '';
  48. if (!empty($searchTime)) {
  49. $startTime = $get['startTime'] ?? '';
  50. $endTime = $get['endTime'] ?? '';
  51. $period = dateUtil::formatTime($searchTime, $startTime, $endTime);
  52. $where['addTime'] = ['between', [$period['startTime'], $period['endTime']]];
  53. }
  54. $recordType = $get['recordType']??'';
  55. if(is_numeric($recordType)){
  56. $where['recordType'] = $recordType;
  57. }
  58. $list = StockRecordClass::getRecordList($where);
  59. $typeList = StockRecordClass::getAllType();
  60. $list['typeList'] = $typeList;
  61. util::success($list);
  62. }
  63. }