Merchant.php 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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 app\data\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,'update_at'=>date('Y-m-d H:i:s')]);
  62. //极光推送
  63. $content = '您申请加入商家信息已通过申请,请及时查看';
  64. }elseif ($data['audit']==3){
  65. //极光推送
  66. $content = '您申请加入商家信息未通过申请,请及时查看';
  67. }
  68. $alias = DataUser::mk()->where('id',$row['uuid'])->value('jgalias');
  69. $alias ? jgpush($content,$alias) : '';
  70. setusermessage($row['uuid'],'审核通知',$content);
  71. $row->commit();
  72. $this->success('审核成功');
  73. }
  74. /**
  75. * 商家设置
  76. * @auth true
  77. * @menu true
  78. */
  79. public function config(){
  80. $this->title='系统设置';
  81. if($this->request->isGet()){
  82. $config=systemConfig('merchant_config');
  83. $this->assign('config',$config);
  84. $this->fetch();
  85. }else{
  86. $data=$this->request->post();
  87. systemConfig('merchant_config',$data);
  88. $this->success('保存成功');
  89. }
  90. }
  91. }