SupplysController.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. namespace addons\QiJuhe\backend\controllers;
  3. use addons\QiJuhe\common\service\ApiService;
  4. use addons\QiJuhe\common\service\SettingService;
  5. use addons\QiJuhe\common\service\SupplysService;
  6. use Yii;
  7. use common\controllers\AddonsController;
  8. /**
  9. * 中台设置控制器
  10. *
  11. * Class MiddleGroundController
  12. * @package addons\QiJuhe\backend\controllers
  13. */
  14. class SupplysController extends BaseController
  15. {
  16. public $enableCsrfValidation = false;
  17. /**
  18. * 供应链列表
  19. *
  20. * @return void
  21. */
  22. public function actionIndex()
  23. {
  24. if ($this->request->isAjax) {
  25. $params = $this->request->getQueryParams();
  26. $service = new SupplysService(['mall_id' => $this->mall_id]);
  27. return $this->success('ok', $service->getSupplysList($params));
  28. }
  29. return $this->render('index');
  30. }
  31. /**
  32. * 供应链编辑及添加
  33. *
  34. * @return void
  35. */
  36. public function actionEdit()
  37. {
  38. $id = $this->request->getQueryParam('id');
  39. $service = new SupplysService(['mall_id' => $this->mall_id]);
  40. if ($this->request->isPost) {
  41. $data = $this->request->post('setting');
  42. return $service->save($id, $data) ? $this->success('保存成功') : $this->error($service->error);
  43. }
  44. if ($this->request->isAjax) {
  45. return $this->success('ok', $service->getInfo($id));
  46. }
  47. return $this->render('edit');
  48. }
  49. /**
  50. * 供应商列表
  51. *
  52. * @return string
  53. */
  54. public function actionSuppliers()
  55. {
  56. $supply_id = $this->request->get('supply_id') ?? 0;
  57. $api = ApiService::getConnect($this->mall_id, $supply_id);
  58. $list = $api->getSuppliers();
  59. return $this->success('ok', $list);
  60. }
  61. }