123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- <?php
- namespace app\admin\controller;
- use app\data\model\DataMerchants;
- use app\data\model\DataUser;
- use Carbon\Carbon;
- use think\admin\Controller;
- use app\data\model\SystemUser;
- use think\facade\Db;
- /**
- * 商家管理
- * Class Xw
- * @package app\admin\controller\Xw
- */
- class Merchant extends Controller
- {
- /**
- * 商家审核管理
- * @auth true
- * @menu true
- */
- public function index(){
- $this->title='商家审核管理';
- // 列表选项卡状态
- // if (is_numeric($this->type = trim(input('type', '0'), 't'))) {
- // $where = [];
- // $this->type==0?$where[]=['audit','in',[1,3]]:$where[]=['audit','in',[2]];
- $this->assign('audit',DataMerchants::getAudit());
- // $this->type = trim(input('type', '0'), 't');
- // print_r($this->type);
- // }
- // print_r($where);
- DataMerchants::mQuery()
- ->like('name')
- ->dateBetween('create_at')
- ->equal('audit')
- ->layTable();
- }
- /**
- * 商家审核详情
- * @auth true
- * @menu true
- */
- public function audit_detail($id){
- $row=DataMerchants::with(['user'])->find($id );
- $this->assign('row',$row);
- $this->fetch('form');
- }
- /**
- * 商家审核
- * @auth true
- * @menu true
- */
- public function audit($id){
- $data=$this->_vali([
- 'audit.require'=>'结果必须',
- 'audit.in:2,3'=>'审核结果有误',
- 'why.requireIf:audit,3'=>'原因必须',
- ]);
- $row=DataMerchants::with(['user'])->find($id);
- $row->startTrans();
- if($row['audit']!=1){
- $this->error('该信息已审核');
- }
- $row['audit']=$data['audit'];
- $row['why']=$data['why'];
- $row['audit_at']=Carbon::now()->toDateTimeString();
- $row->save();
- if($row['audit']==2){
- #创建商家账号
- \app\data\model\SystemUser::createMerchant($row);
- DataUser::mk()->where('id',$row['uuid'])->update(['is_merchants'=>1,'update_at'=>date('Y-m-d H:i:s')]);
- //极光推送
- $content = '您申请加入商家信息已通过申请,请及时查看';
- }elseif ($data['audit']==3){
- //极光推送
- $content = '您申请加入商家信息未通过申请,请及时查看';
- }
- $alias = DataUser::mk()->where('id',$row['uuid'])->value('jgalias');
- if(!empty(getAliasDevices($alias)['body']['registration_ids'])){
- $alias ? jgpush($content,$alias) : '';
- }
- setusermessage($row['uuid'],'审核通知',$content);
- $row->commit();
- $this->success('审核成功');
- }
- /**
- * 商家设置
- * @auth true
- * @menu true
- */
- public function config(){
- $this->title='系统设置';
- if($this->request->isGet()){
- $config=systemConfig('merchant_config');
- $this->assign('config',$config);
- $this->fetch();
- }else{
- $data=$this->request->post();
- systemConfig('merchant_config',$data);
- $this->success('保存成功');
- }
- }
- }
|