Setting.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. <?php
  2. namespace app\shop\controller\plus\agent;
  3. use app\common\model\settings\Setting as SettingModel;
  4. use app\shop\controller\Controller;
  5. use app\shop\model\plus\agent\Setting as AgentSettingModel;
  6. use app\shop\model\product\Product as ProductModel;
  7. /**
  8. * 分销设置控制器
  9. */
  10. class Setting extends Controller
  11. {
  12. public $pay_type = [
  13. ['id' => '10', 'name' => '微信支付'],
  14. ['id' => '20', 'name' => '支付宝'],
  15. ['id' => '30', 'name' => '银行卡']
  16. ];
  17. public $pay_type1 = [
  18. 10 => '微信支付',
  19. 20 => '支付宝',
  20. 30 => '银行卡'
  21. ];
  22. /**
  23. * 分销设置
  24. */
  25. public function index()
  26. {
  27. $pay_type = $this->pay_type;
  28. $data = AgentSettingModel::getAll();
  29. // 购买指定商品成为分销商:商品列表
  30. $product_ids = $data['condition']['values']['become__buy_product_ids'];
  31. $productList = [];
  32. if(count($product_ids) > 0){
  33. $productList = (new ProductModel)->getListByIds($product_ids);
  34. }
  35. //商城设置
  36. $operate_type = SettingModel::getItem('store')['operate_type'];
  37. return $this->renderSuccess('', compact('data', 'productList', 'pay_type', 'operate_type'));
  38. }
  39. /**
  40. * 基础信息设置
  41. */
  42. public function basic()
  43. {
  44. $param = $this->postData();
  45. $data['basic'] = $param;
  46. return $this->edit($data);
  47. }
  48. /**
  49. * 分销商条件设置
  50. */
  51. public function condition()
  52. {
  53. $param = $this->postData();
  54. $data['condition'] = $param;
  55. return $this->edit($data);
  56. }
  57. /**
  58. * 佣金设置
  59. */
  60. public function commission()
  61. {
  62. $param = $this->postData();
  63. $data['commission'] = $param;
  64. return $this->edit($data);
  65. }
  66. /**
  67. * 结算设置
  68. */
  69. public function settlement()
  70. {
  71. $param = $this->postData('form');
  72. $data['settlement'] = [
  73. 'min_money' => $param['min_money'],
  74. 'settle_days' => $param['settle_days'],
  75. 'pay_type' => $param['pay_type'],
  76. ];
  77. return $this->edit($data);
  78. }
  79. /**
  80. * 自定义文字设置
  81. */
  82. public function words()
  83. {
  84. $param = $this->postData();
  85. $data['words'] = $param;
  86. return $this->edit($data);
  87. }
  88. /**
  89. * 申请协议设置
  90. */
  91. public function license()
  92. {
  93. $param = $this->postData();
  94. $data['license'] = $param;
  95. return $this->edit($data);
  96. }
  97. /**
  98. * 页面背景设置
  99. */
  100. public function background()
  101. {
  102. $param = $this->postData();
  103. $data['background'] = $param;
  104. return $this->edit($data);
  105. }
  106. /**
  107. * 修改
  108. */
  109. public function edit($data)
  110. {
  111. $model = new AgentSettingModel;
  112. if ($model->edit($data)) {
  113. return $this->renderSuccess('更新成功');
  114. }
  115. return $this->renderError($model->getError() ?: '更新失败');
  116. }
  117. /**
  118. * 分销海报
  119. */
  120. public function qrcode()
  121. {
  122. if (!$this->request->post()) {
  123. $data = AgentSettingModel::getItem('qrcode');
  124. return $this->renderSuccess('', ['data' => $data]);
  125. }
  126. $model = new AgentSettingModel;
  127. if ($model->edit(['qrcode' => $this->postData('form')])) {
  128. return $this->renderSuccess('更新成功');
  129. }
  130. return $this->renderError($model->getError() ?: '更新失败');
  131. }
  132. }