1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- <?php
- namespace app\admin\controller;
- use app\data\model\DataMerchants;
- use app\data\model\DataUser;
- use Carbon\Carbon;
- use think\admin\Controller;
- use think\admin\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='商家审核管理';
- DataMerchants::mQuery()
- ->like('name')
- ->dateBetween('create_at')
- ->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]);
- }
- $row->commit();
- $this->success('审核成功');
- }
- /**
- * 商家设置
- * @auth true
- * @menu true
- */
- public function config(){
- $this->title='系统设置';
- if($this->request->isGet()){
- $this->assign('config',sysconf('merchant_config.')?:new \stdClass);
- $this->fetch();
- }else{
- $data=$this->request->post();
- sysconf('merchant_config',$data);
- $this->success('保存成功');
- }
- }
- }
|