| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- <?php
- namespace addons\QiJuhe\backend\controllers;
- use addons\QiJuhe\common\enums\QiJuheEnum;
- use addons\QiJuhe\common\service\QiGoodsService;
- use addons\QiJuhe\common\service\StorageService;
- use yii\helpers\Json;
- class StorageController extends BaseController
- {
- public $enableCsrfValidation = false;
- /**
- * @var StorageService
- */
- public $service;
- public function __construct($id, $module, $config = [], StorageService $service)
- {
- parent::__construct($id, $module, $config);
- $this->service = $service;
- }
- public function actionIndex()
- {
- if (!$this->request->isAjax) {
- return $this->render('index', [
- 'chain_map' => Json::encode(QiJuheEnum::SUPPLY_CHAIN_MAP)
- ]);
- }
- $param = $this->request->getQueryParams();
- $param['mall_id'] = $this->mall_id;
- $list = $this->service->lists($param);
- return $this->success('ok', $list);
- }
- public function actionImport()
- {
- $ids = $this->request->post('ids');
- $again = $this->request->post('again');
- $this->service->mall_id = $this->mall_id;
- $res = $this->service->imports($ids, $again);
- return $res ? $this->success('后台导入中...请稍后刷新查看') : $this->error($this->service->error);
- }
- public function actionRemove()
- {
- $ids = $this->request->post('ids');
- $this->service->mall_id = $this->mall_id;
- $res = $this->service->removes($ids);
- return $res ? $this->success('移除成功') : $this->error($this->service->error);
- }
- /**
- * 获取供应链端商品详情
- *
- * @return void
- */
- public function actionGoodsDetail()
- {
- $id = $this->request->post('id');
- $this->service->mall_id = $this->mall_id;
-
- $detail = $this->service->getGoodsDetail($id);
-
- return $detail ? $this->success('ok', $detail) : $this->error($this->service->error);
- }
- /**
- * 商品下级检测
- *
- * @return void
- */
- public function actionCheckPull()
- {
- $supply_id = $this->request->post('supply_id');
- $this->service->setMallId($this->mall_id);
- $this->service->checkPull($supply_id);
- return $this->success('后台检测中...');
- }
- /**
- * @return mixed
- */
- public function actionTest()
- {
- // $service = new QiGoodsService(['mall_id' => $this->mall_id]);
- QiGoodsService::handleSync([
- 'mall_id' => $this->mall_id,
- 'ids' => 291,
- ]);
- }
- }
|