Deliverylimit.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2017~2021 https://www.yiovo.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
  8. // +----------------------------------------------------------------------
  9. // | Author: 萤火科技 <admin@yiovo.com>
  10. // +----------------------------------------------------------------------
  11. declare (strict_types = 1);
  12. namespace app\store\controller\setting;
  13. use app\store\controller\Controller;
  14. use app\store\model\DeliveryLimit as DeliveryLimitModel;
  15. /**
  16. * 配送地区限购设置
  17. * Class Deliverylimit
  18. * @package app\store\controller\setting
  19. */
  20. class Deliverylimit extends Controller
  21. {
  22. /**
  23. * 获取详情记录
  24. * @param int $limitId
  25. * @return array
  26. */
  27. public function detail()
  28. {
  29. $detail = DeliveryLimitModel::detail(DeliveryLimitModel::DEFAULT_ID);
  30. $detail['rules'] = [['region'=>$detail['region'],'region_text'=>$detail['region_text']]];
  31. return $this->renderSuccess(compact('detail'));
  32. }
  33. /**
  34. * 添加配送模板
  35. * @return array
  36. */
  37. public function add()
  38. {
  39. // 新增记录
  40. $model = new DeliveryLimitModel;
  41. if ($model->add($this->request->post())) {
  42. return $this->renderSuccess('添加成功');
  43. }
  44. return $this->renderError($model->getError() ?: '添加失败');
  45. }
  46. /**
  47. * 编辑配送模板
  48. * @param int $limitId
  49. * @return array
  50. */
  51. public function edit(int $limitId)
  52. {
  53. // 模板详情
  54. $model = DeliveryLimitModel::detail($limitId);
  55. // 更新记录
  56. if ($model->edit($this->request->post())) {
  57. return $this->renderSuccess('更新成功');
  58. }
  59. return $this->renderError($model->getError() ?: '更新失败');
  60. }
  61. }