ShMethodController.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. /**
  3. * 用途:配送方式配置控制器
  4. * 谁用:供货商系统管理员
  5. * 解决什么问题:提供配送方式(送货、自取、跑腿、快递、物流)配置的获取和保存接口
  6. */
  7. namespace ghs\controllers;
  8. use bizGhs\order\classes\ShMethodClass;
  9. use Yii;
  10. use common\components\util;
  11. class ShMethodController extends BaseController
  12. {
  13. /**
  14. * 获取指定配送方式的配置
  15. * GET 参数:
  16. * - style: 配送类型 (0: 送货, 1: 自取, 2: 跑腿, 3: 快递, 4: 物流)
  17. */
  18. public function actionGetConfig()
  19. {
  20. $style = Yii::$app->request->get('style', 0);
  21. try {
  22. $config = ShMethodClass::getConfig($this->shopId, $this->mainId, $style);
  23. util::success($config);
  24. } catch (\Exception $e) {
  25. util::fail($e->getMessage());
  26. }
  27. }
  28. /**
  29. * 保存指定配送方式的配置
  30. * POST 参数:
  31. * - id: 配置ID(可选)
  32. * - style: 配送类型 (0: 送货, 1: 自取, 2: 跑腿, 3: 快递, 4: 物流)
  33. * - alias: 别名
  34. * - status: 状态 (0: 禁用, 1: 启用)
  35. * - sort: 排序
  36. * - minAmount: 最低消费金额
  37. * - minNum: 最低消费数量
  38. * - unMeet: 不满条件处理方式 (0: 收运费, 1: 不能下单, 2: 收包装费)
  39. * - unMeetFee: 运费/包装费金额
  40. * - startKm: 起步公里数
  41. * - startPrice: 起步价格
  42. * - perKmPrice: 超出起步每公里加价
  43. * - changeRate: 临时涨价比例 (%)
  44. * - explains: 说明项列表 (二维数组,包含 explain, color, fontWeight, sort)
  45. * - reduceRules: 跑腿满减规则列表 (二维数组,包含 meetNum, meetAmount, freeKm, sort)
  46. */
  47. public function actionSaveConfig()
  48. {
  49. $post = Yii::$app->request->post();
  50. try {
  51. ShMethodClass::saveConfig($this->shopId, $this->mainId, $post);
  52. util::complete('保存成功');
  53. } catch (\Exception $e) {
  54. util::fail($e->getMessage());
  55. }
  56. }
  57. }