Setting.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. /**
  3. *
  4. * @copyright ©2020 点小铺
  5. * @author hanj
  6. * @link: https://dyuit.com
  7. * Created by VSCode
  8. */
  9. namespace app\store\controller\apps\dealer;
  10. use app\store\controller\Controller;
  11. use app\store\model\dealer\Setting as SettingModel;
  12. use app\store\model\Goods as GoodsModel;
  13. /**
  14. * 分销设置
  15. * Class Setting
  16. * @package app\store\controller\apps\dealer
  17. */
  18. class Setting extends Controller
  19. {
  20. /**
  21. * 分销设置
  22. * @return array|bool|mixed
  23. * @throws \think\db\exception\DataNotFoundException
  24. * @throws \think\db\exception\ModelNotFoundException
  25. * @throws \think\exception\DbException
  26. * @throws \think\exception\PDOException
  27. */
  28. public function index()
  29. {
  30. if (!$this->request->isAjax()) {
  31. $data = SettingModel::getAll();
  32. // 购买指定商品成为分销商:商品列表
  33. $goodsList = (new GoodsModel)->getListByIds($data['condition']['values']['become__buy_goods_ids']);
  34. return $this->fetch('index', compact('data', 'goodsList'));
  35. }
  36. $model = new SettingModel;
  37. if ($model->edit($this->postData('setting'))) {
  38. return $this->renderSuccess('更新成功');
  39. }
  40. return $this->renderError($model->getError() ?: '更新失败');
  41. }
  42. /**
  43. * 分销海报
  44. * @return array|mixed
  45. * @throws \think\exception\PDOException
  46. */
  47. public function qrcode()
  48. {
  49. if (!$this->request->isAjax()) {
  50. $data = SettingModel::getItem('qrcode');
  51. return $this->fetch('qrcode', [
  52. 'data' => json_encode($data, JSON_UNESCAPED_UNICODE)
  53. ]);
  54. }
  55. $model = new SettingModel;
  56. if ($model->edit(['qrcode' => $this->postData('qrcode')])) {
  57. return $this->renderSuccess('更新成功');
  58. }
  59. return $this->renderError($model->getError() ?: '更新失败');
  60. }
  61. }