Store.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. namespace app\shop\controller\setting;
  3. use app\shop\controller\Controller;
  4. use app\shop\model\settings\Setting as SettingModel;
  5. use app\common\enum\settings\DeliveryTypeEnum;
  6. /**
  7. * 商城设置控制器
  8. */
  9. class Store extends Controller
  10. {
  11. /**
  12. * 商城设置
  13. */
  14. public function index()
  15. {
  16. if($this->request->isGet()){
  17. return $this->fetchData();
  18. }
  19. $model = new SettingModel;
  20. $data = $this->request->param();
  21. $arr = [
  22. 'name' => $data['name'],
  23. 'delivery_type' => $data['checkedCities'],
  24. 'kuaidi100' => ['customer' => $data['customer'], 'key' => $data['key']],
  25. 'supplier_cash' => $data['supplier_cash'],
  26. 'commission_rate' => $data['commission_rate'],
  27. 'add_audit' => $data['add_audit'],
  28. 'edit_audit' => $data['edit_audit'],
  29. 'supplier_image' => $data['supplier_image'],
  30. 'sms_open' => $data['sms_open'],
  31. 'supplier_logo' => $data['supplier_logo'],
  32. 'is_get_log' => $data['is_get_log'],
  33. ];
  34. if ($model->edit('store', $arr)) {
  35. return $this->renderSuccess('操作成功');
  36. }
  37. return $this->renderError($model->getError() ?: '操作失败');
  38. }
  39. /**
  40. * 获取商城配置
  41. */
  42. public function fetchData()
  43. {
  44. $vars['values'] = SettingModel::getItem('store');
  45. $all_type = DeliveryTypeEnum::data();
  46. return $this->renderSuccess('', compact('vars', 'all_type'));
  47. }
  48. }