StorageController.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. namespace addons\StarChain\backend\controllers;
  3. use addons\StarChain\common\services\SpuService;
  4. use addons\StarChain\common\services\StorageService;
  5. /**
  6. * 选品库
  7. */
  8. class StorageController extends BaseController
  9. {
  10. /**
  11. * 商品库
  12. *
  13. * @return string
  14. */
  15. public function actionIndex()
  16. {
  17. if ($this->request->isAjax) {
  18. $params = $this->request->get();
  19. $service = new StorageService(['mall_id' => $this->mall_id]);
  20. return $this->success('ok', $service->getStorageList($params));
  21. }
  22. return $this->render($this->action->id);
  23. }
  24. /**
  25. * 重新导入
  26. *
  27. * @return string
  28. */
  29. public function actionAgainImport()
  30. {
  31. if ($this->request->isAjax) {
  32. $ids = $this->request->getBodyParam('ids');
  33. $service = new SpuService(['mall_id' => $this->mall_id]);
  34. $count = $service->addTaskDoImport($ids, false);
  35. $count > 0
  36. ? $this->success("成功重新加载{$count}个商品")
  37. : $this->error($service->error);
  38. }
  39. }
  40. /**
  41. * 移除导入商品
  42. *
  43. * @return string
  44. */
  45. public function actionRemoveImport()
  46. {
  47. if ($this->request->isAjax) {
  48. $ids = $this->request->getBodyParam('ids');
  49. $service = new SpuService(['mall_id' => $this->mall_id]);
  50. $count = $service->removeImport($ids);
  51. $count > 0
  52. ? $this->success("成功移除{$count}个商品")
  53. : $this->error($service->error);
  54. }
  55. }
  56. }