Merchant.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <?php
  2. namespace app\admin\controller;
  3. use app\data\model\DataMerchants;
  4. use app\data\model\DataUser;
  5. use Carbon\Carbon;
  6. use think\admin\Controller;
  7. use think\admin\model\SystemUser;
  8. use think\facade\Db;
  9. /**
  10. * 商家管理
  11. * Class Xw
  12. * @package app\admin\controller\Xw
  13. */
  14. class Merchant extends Controller
  15. {
  16. /**
  17. * 商家审核管理
  18. * @auth true
  19. * @menu true
  20. */
  21. public function index(){
  22. $this->title='商家审核管理';
  23. DataMerchants::mQuery()
  24. ->like('name')
  25. ->dateBetween('create_at')
  26. ->layTable();
  27. }
  28. /**
  29. * 商家审核详情
  30. * @auth true
  31. * @menu true
  32. */
  33. public function audit_detail($id){
  34. $row=DataMerchants::with(['user'])->find($id );
  35. $this->assign('row',$row);
  36. $this->fetch('form');
  37. }
  38. /**
  39. * 商家审核
  40. * @auth true
  41. * @menu true
  42. */
  43. public function audit($id){
  44. $data=$this->_vali([
  45. 'audit.require'=>'结果必须',
  46. 'audit.in:2,3'=>'审核结果有误',
  47. 'why.requireIf:audit,3'=>'原因必须',
  48. ]);
  49. $row=DataMerchants::with(['user'])->find($id );
  50. $row->startTrans();
  51. if($row['audit']!=1){
  52. $this->error('该信息已审核');
  53. }
  54. $row['audit']=$data['audit'];
  55. $row['why']=$data['why'];
  56. $row['audit_at']=Carbon::now()->toDateTimeString();
  57. $row->save();
  58. if($row['audit']==2){
  59. #创建商家账号
  60. \app\data\model\SystemUser::createMerchant($row);
  61. DataUser::mk()->where('id',$row['uuid'])->update(['is_merchants'=>1]);
  62. }
  63. $row->commit();
  64. $this->success('审核成功');
  65. }
  66. /**
  67. * 商家设置
  68. * @auth true
  69. * @menu true
  70. */
  71. public function config(){
  72. $this->title='系统设置';
  73. if($this->request->isGet()){
  74. $this->assign('config',sysconf('merchant_config.')?:new \stdClass);
  75. $this->fetch();
  76. }else{
  77. $data=$this->request->post();
  78. sysconf('merchant_config',$data);
  79. $this->success('保存成功');
  80. }
  81. }
  82. }