StockLog.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. namespace app\admin\controller\shopro\goods;
  3. use app\admin\controller\shopro\Common;
  4. use think\Db;
  5. use app\admin\model\shopro\goods\SkuPrice as SkuPriceModel;
  6. use app\admin\model\shopro\goods\StockLog as StockLogModel;
  7. use addons\shopro\library\Operator;
  8. /**
  9. * 补库存记录
  10. */
  11. class StockLog extends Common
  12. {
  13. public function _initialize()
  14. {
  15. parent::_initialize();
  16. $this->model = new StockLogModel;
  17. }
  18. /**
  19. * 库存补货列表
  20. *
  21. * @return \think\Response
  22. */
  23. public function index()
  24. {
  25. if (!$this->request->isAjax()) {
  26. return $this->view->fetch();
  27. }
  28. $skuPriceTableName = (new SkuPriceModel())->getQuery()->getTable();
  29. $stockLogs = $this->model->sheepFilter()->alias('g')->with(['goods' => function ($query) {
  30. $query->removeOption('soft_delete');
  31. }, 'oper'])
  32. ->join($skuPriceTableName . ' sp', 'g.goods_sku_price_id = sp.id', 'left')
  33. ->field('g.*,sp.stock as total_stock')
  34. ->paginate($this->request->param('list_rows', 10))->toArray();
  35. // 解析操作人信息
  36. foreach ($stockLogs['data'] as &$log) {
  37. $log['oper'] = Operator::info('admin', $log['oper'] ?? null);
  38. }
  39. $this->success('获取成功', null, $stockLogs);
  40. }
  41. }