StockController.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. namespace hd\controllers;
  3. use biz\stock\classes\GoodsStockRecordClass;
  4. use bizGhs\stock\classes\StockRecordClass;
  5. use bizGhs\product\classes\ProductClass;
  6. use common\components\dateUtil;
  7. use common\components\util;
  8. use Yii;
  9. class StockController 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 = StockRecordClass::getRecordList($where);
  29. util::success($list);
  30. }
  31. //商品库存变动明细
  32. public function actionGoodsStockChange()
  33. {
  34. $get = Yii::$app->request->get();
  35. $goodsId = $get['id'] ?? 0;
  36. $where = ['goodsId' => $goodsId];
  37. $searchTime = $get['searchTime'] ?? '';
  38. if (!empty($searchTime)) {
  39. $startTime = $get['startTime'] ?? '';
  40. $endTime = $get['endTime'] ?? '';
  41. $period = dateUtil::formatTime($searchTime, $startTime, $endTime);
  42. $where['addTime'] = ['between', [$period['startTime'], $period['endTime']]];
  43. }
  44. $list = GoodsStockRecordClass::getRecordList($where);
  45. util::success($list);
  46. }
  47. }