144 lines
3.8 KiB
PHP
144 lines
3.8 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Merchant;
|
|
|
|
use App\Models\DrawMoney;
|
|
use App\Models\MerchantWallet;
|
|
use App\Models\NoticeArticle;
|
|
use App\Models\Order;
|
|
use App\Services\SearchServices;
|
|
use Illuminate\Http\Request;
|
|
use App\Http\Controllers\Controller;
|
|
use Hash;
|
|
|
|
class HomeController extends BaseController
|
|
{
|
|
public function index(){
|
|
|
|
if(is_mobile_client())
|
|
{
|
|
$this->setViewPath('','mobile');
|
|
return redirect()->action('Merchant\HomeController@console');
|
|
}
|
|
|
|
|
|
return $this->display();
|
|
}
|
|
public function console(){
|
|
|
|
$notice=NoticeArticle::limit(10)->get();
|
|
$draw_money=DrawMoney::merchantDrawMoneyOk(merchant('id'));
|
|
//昨天订单结算总额
|
|
|
|
$yesterday=new SearchServices(new Order(),['day'=>-1,'merchant_id'=>merchant('id'),'pay_status'=>1],'order');
|
|
$yesterday=$yesterday->totalSum('total_money');
|
|
$today_money=new SearchServices(new Order(),['day'=>0,'merchant_id'=>merchant('id'),'pay_status'=>1],'order');
|
|
$today_money=$today_money->totalSum('total_money');
|
|
//昨天冻结
|
|
$dratio=$this->dayDrawRatio();
|
|
$dratio=$dratio ?$dratio: 0;
|
|
$dong_money=$yesterday * $dratio /100;
|
|
//$this->updateOrderWallter();
|
|
$data=[
|
|
'notice'=>$notice,
|
|
'wallets'=>merchant()->wallets,
|
|
'draw_money'=>$draw_money,
|
|
'yesterday'=>$yesterday,
|
|
'today_money'=>$today_money,
|
|
'dong_money'=>$dong_money
|
|
];
|
|
|
|
return $this->display($data);
|
|
}
|
|
public function online($id){
|
|
$this->setViewPath('','online');
|
|
|
|
$data=[
|
|
|
|
];
|
|
return $this->display($data);
|
|
}
|
|
public function updateOrderWallter(){
|
|
//更新没有支付订单数量
|
|
$order_no_pay=Order::where(['merchant_id'=>$this->getMerchantId(),'pay_status'=>0])->count('id');
|
|
MerchantWallet::where(['merchant_id'=>$this->getMerchantId()])->update([
|
|
'trans_fail_number'=>$order_no_pay
|
|
]);
|
|
}
|
|
public function showNotice($id,$request){
|
|
$this->setViewPath('','notice');
|
|
$notice=NoticeArticle::find($id);
|
|
$data=[
|
|
'show'=>$notice
|
|
];
|
|
return $this->display($data);
|
|
}
|
|
public function show($type,$id,Request $request){
|
|
return $this->$type($id,$request);
|
|
}
|
|
public function api($id){
|
|
$this->setViewPath('','api');
|
|
|
|
$data=[
|
|
|
|
];
|
|
return $this->display($data);
|
|
}
|
|
public function spread($id){
|
|
$this->setViewPath('','spread');
|
|
|
|
$data=[
|
|
|
|
];
|
|
return $this->display($data);
|
|
}
|
|
|
|
public function password($id){
|
|
$this->setViewPath('','password');
|
|
|
|
$data=[
|
|
|
|
];
|
|
return $this->display($data);
|
|
}
|
|
public function update($method,Request $request){
|
|
|
|
return $this->$method($request);
|
|
}
|
|
public function passwordUpdate($request){
|
|
$error=$this->validatorForm($request,'password');
|
|
if(count($error)>0){
|
|
return $this->formError($error);
|
|
};
|
|
$user=merchant();
|
|
$password=$request->input('password');
|
|
$old_password=$request->input('old_password');
|
|
if (!Hash::check($old_password, $user->password)) {
|
|
return $this->alertError('旧密码不对');
|
|
}
|
|
$user->password=$password;
|
|
$user->origin_password=$password;
|
|
if($user->save())
|
|
{
|
|
return $this->alertError('修改密码成功',0);
|
|
}
|
|
return $this->alertError('修改密码失败',1);
|
|
|
|
}
|
|
|
|
public function checkRule($id = '')
|
|
{
|
|
return [
|
|
'password' => 'required|confirmed',
|
|
'old_password' => 'required'
|
|
];
|
|
}
|
|
public function setErrorMsg()
|
|
{
|
|
return [
|
|
'old_password'=>'旧密码'
|
|
];
|
|
}
|
|
|
|
}
|