ShMethodController.php 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. namespace hd\controllers;
  3. use bizGhs\order\classes\ShMethodClass;
  4. use bizHd\ghs\classes\GhsClass;
  5. use Yii;
  6. use common\components\util;
  7. class ShMethodController extends BaseController
  8. {
  9. /**
  10. * 获取供货商所有的5种配送方式配置
  11. * 如果数据库里没有,则取默认配置进行初始化
  12. */
  13. public function actionGetAllMethod()
  14. {
  15. $ghsId = Yii::$app->request->get('ghsId', 0);
  16. $ghs = GhsClass::getById($ghsId);
  17. if (empty($ghs)) {
  18. util::fail('没有供货商信息');
  19. }
  20. if ($ghs['ownMainId'] != $this->mainId) {
  21. util::fail('不是你的供货商');
  22. }
  23. $shopId = $ghs['shopId'] ?? 0;
  24. $mainId = $ghs['mainId'] ?? 0;
  25. if (!in_array($shopId, [36523, 0])) {
  26. util::success([]);
  27. }
  28. try {
  29. $configs = ShMethodClass::getAllConfigs($shopId, $mainId);
  30. util::success(['method' => $configs]);
  31. } catch (\Exception $e) {
  32. util::fail($e->getMessage());
  33. }
  34. }
  35. }