PsMethodController.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. namespace hd\controllers;
  3. use bizHd\order\classes\PsMethodClass;
  4. use Yii;
  5. use common\components\util;
  6. /**
  7. * 花店配送方式设置接口(xhPsMethod / xhPsExplain / xhPsReduceRule)
  8. * 用途:hdApp 门店设置-配送方式页,与供货商 xhSh* 配置分离
  9. */
  10. class PsMethodController extends BaseController
  11. {
  12. /**
  13. * 获取指定配送方式的配置
  14. * GET style:0送货 1自取 2跑腿 3物流 4快递
  15. */
  16. public function actionGetConfig()
  17. {
  18. $style = Yii::$app->request->get('style', 0);
  19. try {
  20. $config = PsMethodClass::getConfig($this->shopId, $this->mainId, $style);
  21. util::success($config);
  22. } catch (\Exception $e) {
  23. util::fail($e->getMessage());
  24. }
  25. }
  26. /**
  27. * 获取所有配送方式的排序与别名(底部预览用)
  28. */
  29. public function actionGetSorts()
  30. {
  31. try {
  32. $sorts = PsMethodClass::getSorts($this->mainId);
  33. util::success($sorts);
  34. } catch (\Exception $e) {
  35. util::fail($e->getMessage());
  36. }
  37. }
  38. /**
  39. * 保存指定配送方式配置
  40. */
  41. public function actionSaveConfig()
  42. {
  43. $post = Yii::$app->request->post();
  44. try {
  45. PsMethodClass::saveConfig($this->shopId, $this->mainId, $post);
  46. util::complete('保存成功');
  47. } catch (\Exception $e) {
  48. util::fail($e->getMessage());
  49. }
  50. }
  51. }