StorageController.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <?php
  2. namespace addons\QiJuhe\backend\controllers;
  3. use addons\QiJuhe\common\enums\QiJuheEnum;
  4. use addons\QiJuhe\common\service\QiGoodsService;
  5. use addons\QiJuhe\common\service\StorageService;
  6. use yii\helpers\Json;
  7. class StorageController extends BaseController
  8. {
  9. public $enableCsrfValidation = false;
  10. /**
  11. * @var StorageService
  12. */
  13. public $service;
  14. public function __construct($id, $module, $config = [], StorageService $service)
  15. {
  16. parent::__construct($id, $module, $config);
  17. $this->service = $service;
  18. }
  19. public function actionIndex()
  20. {
  21. if (!$this->request->isAjax) {
  22. return $this->render('index', [
  23. 'chain_map' => Json::encode(QiJuheEnum::SUPPLY_CHAIN_MAP)
  24. ]);
  25. }
  26. $param = $this->request->getQueryParams();
  27. $param['mall_id'] = $this->mall_id;
  28. $list = $this->service->lists($param);
  29. return $this->success('ok', $list);
  30. }
  31. public function actionImport()
  32. {
  33. $ids = $this->request->post('ids');
  34. $again = $this->request->post('again');
  35. $this->service->mall_id = $this->mall_id;
  36. $res = $this->service->imports($ids, $again);
  37. return $res ? $this->success('后台导入中...请稍后刷新查看') : $this->error($this->service->error);
  38. }
  39. public function actionRemove()
  40. {
  41. $ids = $this->request->post('ids');
  42. $this->service->mall_id = $this->mall_id;
  43. $res = $this->service->removes($ids);
  44. return $res ? $this->success('移除成功') : $this->error($this->service->error);
  45. }
  46. /**
  47. * 获取供应链端商品详情
  48. *
  49. * @return void
  50. */
  51. public function actionGoodsDetail()
  52. {
  53. $id = $this->request->post('id');
  54. $this->service->mall_id = $this->mall_id;
  55. $detail = $this->service->getGoodsDetail($id);
  56. return $detail ? $this->success('ok', $detail) : $this->error($this->service->error);
  57. }
  58. /**
  59. * 商品下级检测
  60. *
  61. * @return void
  62. */
  63. public function actionCheckPull()
  64. {
  65. $supply_id = $this->request->post('supply_id');
  66. $this->service->setMallId($this->mall_id);
  67. $this->service->checkPull($supply_id);
  68. return $this->success('后台检测中...');
  69. }
  70. /**
  71. * @return mixed
  72. */
  73. public function actionTest()
  74. {
  75. // $service = new QiGoodsService(['mall_id' => $this->mall_id]);
  76. QiGoodsService::handleSync([
  77. 'mall_id' => $this->mall_id,
  78. 'ids' => 291,
  79. ]);
  80. }
  81. }