System.php 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\merchant\controller;
  12. use service\JsonService;
  13. use service\SystemConfigService;
  14. use app\merchant\model\merchant\Merchant;
  15. use app\merchant\model\special\Lecturer;
  16. use service\GroupDataService;
  17. use app\merchant\model\special\Special;
  18. use app\merchant\model\download\DataDownload as DownloadModel;
  19. use app\merchant\model\store\StoreProduct as ProductModel;
  20. use app\merchant\model\ump\EventRegistration as EventRegistrationModel;
  21. class System extends AuthController
  22. {
  23. public function index()
  24. {
  25. $merchant = Merchant::where('id', $this->merchantId)->find();
  26. $lecturer = Lecturer::where('id', $this->merchantInfo['lecturer_id'])->field('label,explain,introduction')->find();
  27. $lecturer['introduction'] = htmlspecialchars_decode($lecturer['introduction']);
  28. $this->assign(['merchat' => json_encode($merchant), 'lecturer' => json_encode($lecturer)]);
  29. return $this->fetch();
  30. }
  31. /**
  32. * 保存商户资料
  33. */
  34. public function edit_merchant()
  35. {
  36. $post = parent::postMore([
  37. ['mer_name', ''],
  38. ['mer_email', ''],
  39. ['mer_phone', ''],
  40. ['mer_address', ''],
  41. ['mer_avatar', ''],
  42. ['mer_info', ''],
  43. ['estate', 0],
  44. ['card_id', ''],
  45. ['bank', ''],
  46. ['bank_number', ''],
  47. ['bank_name', ''],
  48. ['bank_address', ''],
  49. ['label', []],
  50. ['explain', '']
  51. ]);
  52. $data['label'] = json_encode($post['label']);
  53. $data['explain'] = $post['explain'];
  54. $data['introduction'] = htmlspecialchars($post['mer_info']);
  55. $data['lecturer_name'] = $post['mer_name'];
  56. $data['lecturer_head'] = $post['mer_avatar'];
  57. $data['phone'] = $post['mer_phone'];
  58. Merchant::beginTrans();
  59. try {
  60. unset($post['label'], $post['explain']);
  61. Merchant::edit($post, $this->merchantId, 'id');
  62. if (!$post['estate']) {
  63. Special::where(['is_del' => 0, 'mer_id' => $this->merchantId])->update(['is_show' => 0]);
  64. DownloadModel::where(['is_del' => 0, 'mer_id' => $this->merchantId])->update(['is_show' => 0]);
  65. ProductModel::where(['is_del' => 0, 'mer_id' => $this->merchantId])->update(['is_show' => 0]);
  66. EventRegistrationModel::where(['is_del' => 0, 'mer_id' => $this->merchantId])->update(['is_show' => 0]);
  67. $data['is_show'] = 0;
  68. Lecturer::edit($data, $this->merchantInfo['lecturer_id'], 'id');
  69. } else {
  70. $data['is_show'] = 1;
  71. Lecturer::edit($data, $this->merchantInfo['lecturer_id'], 'id');
  72. }
  73. Merchant::commitTrans();
  74. return JsonService::successful('保存成功');
  75. } catch (\Exception $e) {
  76. Merchant::rollbackTrans();
  77. return JsonService::fail($e->getMessage());
  78. }
  79. }
  80. }