Merchant.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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. // 列表选项卡状态
  24. // if (is_numeric($this->type = trim(input('type', '0'), 't'))) {
  25. // $where = [];
  26. // $this->type==0?$where[]=['audit','in',[1,3]]:$where[]=['audit','in',[2]];
  27. $this->assign('audit',DataMerchants::getAudit());
  28. // $this->type = trim(input('type', '0'), 't');
  29. // print_r($this->type);
  30. // }
  31. // print_r($where);
  32. DataMerchants::mQuery()
  33. ->like('name')
  34. ->dateBetween('create_at')
  35. ->equal('audit')
  36. ->layTable();
  37. }
  38. /**
  39. * 商家审核详情
  40. * @auth true
  41. * @menu true
  42. */
  43. public function audit_detail($id){
  44. $row=DataMerchants::with(['user'])->find($id );
  45. $this->assign('row',$row);
  46. $this->fetch('form');
  47. }
  48. /**
  49. * 商家审核
  50. * @auth true
  51. * @menu true
  52. */
  53. public function audit($id){
  54. $data=$this->_vali([
  55. 'audit.require'=>'结果必须',
  56. 'audit.in:2,3'=>'审核结果有误',
  57. 'why.requireIf:audit,3'=>'原因必须',
  58. ]);
  59. $row=DataMerchants::with(['user'])->find($id);
  60. $row->startTrans();
  61. if($row['audit']!=1){
  62. $this->error('该信息已审核');
  63. }
  64. $row['audit']=$data['audit'];
  65. $row['why']=$data['why'];
  66. $row['audit_at']=Carbon::now()->toDateTimeString();
  67. $row->save();
  68. if($row['audit']==2){
  69. #创建商家账号
  70. \app\data\model\SystemUser::createMerchant($row);
  71. DataUser::mk()->where('id',$row['uuid'])->update(['is_merchants'=>1,'update_at'=>date('Y-m-d H:i:s')]);
  72. //极光推送
  73. $content = '您申请加入商家信息已通过申请,请及时查看';
  74. }elseif ($data['audit']==3){
  75. //极光推送
  76. $content = '您申请加入商家信息未通过申请,请及时查看';
  77. }
  78. $alias = DataUser::mk()->where('id',$row['uuid'])->value('jgalias');
  79. if(!empty(getAliasDevices($alias)['body']['registration_ids'])){
  80. $alias ? jgpush($content,$alias) : '';
  81. }
  82. setusermessage($row['uuid'],'审核通知',$content);
  83. $row->commit();
  84. $this->success('审核成功');
  85. }
  86. /**
  87. * 商家设置
  88. * @auth true
  89. * @menu true
  90. */
  91. public function config(){
  92. $this->title='系统设置';
  93. if($this->request->isGet()){
  94. $config=systemConfig('merchant_config');
  95. $this->assign('config',$config);
  96. $this->fetch();
  97. }else{
  98. $data=$this->request->post();
  99. systemConfig('merchant_config',$data);
  100. $this->success('保存成功');
  101. }
  102. }
  103. }