146 lines
5.3 KiB
PHP
146 lines
5.3 KiB
PHP
<?php
|
|
|
|
namespace common\models;
|
|
|
|
use common\enums\UserRoleEnum;
|
|
use yii\behaviors\TimestampBehavior;
|
|
use yii\db\ActiveRecord;
|
|
|
|
class CashApply extends \common\modelsgii\CashApply
|
|
{
|
|
|
|
public function behaviors()
|
|
{
|
|
return [
|
|
[
|
|
'class' => TimestampBehavior::class,
|
|
'attributes' => [
|
|
ActiveRecord::EVENT_BEFORE_INSERT => ['created_at','updated_at'],
|
|
ActiveRecord::EVENT_BEFORE_UPDATE => ['updated_at'],
|
|
],
|
|
],
|
|
];
|
|
}
|
|
public function getAdmin()
|
|
{
|
|
return $this->hasOne(Admin::class,['uid'=>'user_id']);
|
|
}
|
|
|
|
//导出提现申请
|
|
public static function inventory($params)
|
|
{
|
|
$where = $andWhere = [];
|
|
|
|
switch ($params['status']) {
|
|
case 1:
|
|
$where['check_status'] = [0, 1];
|
|
break;
|
|
case 2:
|
|
$where['check_status'] = 2;
|
|
break;
|
|
case 3:
|
|
$where['check_status'] = 3;
|
|
break;
|
|
}
|
|
//统计时间范围
|
|
if (!empty($params['start_time']) && !empty($params['end_time'])) {
|
|
$start_time=strtotime($params['start_time']);
|
|
$end_time=strtotime($params['end_time'] ." 23:59:59");
|
|
}else{
|
|
$start_time = strtotime(date('Y-m-01'));
|
|
$end_time = strtotime(date('Y-m-01',strtotime("+1 month")));
|
|
}
|
|
$andWhere = ['between', 'created_at', $start_time, $end_time];
|
|
|
|
if(!empty($params['name'])){
|
|
if($params['name'] == '平台'){
|
|
$where['user_id'] = 0;
|
|
}else{
|
|
$store = Store::find()->where(['name'=>$params['name']])->asArray()->one();
|
|
if($store){
|
|
$where['user_id'] = intval($store['id']);
|
|
}else{
|
|
$where['user_id'] = -1;
|
|
}
|
|
}
|
|
}
|
|
//查询数据
|
|
$list=CashApply::find()->where($where)->andWhere($andWhere)->asArray()->all();
|
|
|
|
//把结果按照显示顺序存到返回的数组中
|
|
if(!empty($list)){
|
|
foreach ($list as $key => $value){
|
|
$inventory[$key]['order_no'] = $value['order_no'];
|
|
if($value['user_id']){
|
|
|
|
$payee = Store::find()->where(['id' => $value['user_id']])->one();
|
|
$inventory[$key]['store'] = $payee['name'];
|
|
}else{
|
|
$inventory[$key]['store'] = "平台";
|
|
$payee = Admin::find()->where(['role' => UserRoleEnum::SUPER_ADMIN])->one();
|
|
}
|
|
|
|
$inventory[$key]['payee'] = $payee['bank_user_name'];
|
|
$inventory[$key]['apply_cash'] = $value['apply_cash'];//
|
|
|
|
$inventory[$key]['created_at'] = date('Y-m-d H:i:s',$value['created_at']);//下单时间
|
|
}
|
|
|
|
}else{
|
|
$inventory[0]['prescription_no']= '无数据导出';
|
|
}
|
|
return $inventory;
|
|
}
|
|
|
|
//导出提现申请
|
|
public static function inventory1($params)
|
|
{
|
|
$where = $andWhere = [];
|
|
//统计时间范围
|
|
if (!empty($params['start_time']) && !empty($params['end_time'])) {
|
|
$start_time=strtotime($params['start_time']);
|
|
$end_time=strtotime($params['end_time'] ." 23:59:59");
|
|
}else{
|
|
$start_time = strtotime(date('Y-m-01'));
|
|
$end_time = strtotime(date('Y-m-01',strtotime("+1 month")));
|
|
}
|
|
$andWhere = ['between', 'created_at', $start_time, $end_time];
|
|
|
|
//查询数据
|
|
$list=CashApply::find()->where($where)->andWhere($andWhere)->asArray()->all();
|
|
|
|
//把结果按照显示顺序存到返回的数组中
|
|
if(!empty($list)){
|
|
foreach ($list as $key => $value){
|
|
$inventory[$key]['order_no'] = $value['order_no'];
|
|
if($value['user_id']){
|
|
$payee = Store::find()->where(['id' => $value['user_id']])->one();
|
|
$inventory[$key]['payee'] = $payee['contact'];
|
|
}else{
|
|
$payee = Admin::find()->where(['role' => UserRoleEnum::SUPER_ADMIN])->one();
|
|
$inventory[$key]['payee'] = $payee['username'];
|
|
}
|
|
|
|
$inventory[$key]['apply_cash'] = $value['apply_cash'];//
|
|
$inventory[$key]['true_cash'] = $value['true_cash'];//
|
|
$inventory[$key]['charge_cash'] = $value['charge_cash'];//
|
|
if ($value['check_status'] == 1) {
|
|
$inventory[$key]['status'] = '审核中';
|
|
} elseif ($value['check_status'] == 2) {
|
|
$inventory[$key]['status'] = '审核通过,提现成功';
|
|
} elseif ($value['check_status'] == 3) {
|
|
$inventory[$key]['status'] = '申请已拒绝,手续费未扣';
|
|
} elseif ($value['check_status'] == 4) {
|
|
$inventory[$key]['status'] = '审核通过,提现失败';
|
|
} else {
|
|
$inventory[$key]['status'] = '未知';
|
|
}
|
|
$inventory[$key]['created_at'] = date('Y-m-d H:i:s',$value['created_at']);//下单时间
|
|
}
|
|
|
|
}else{
|
|
$inventory[0]['id']= '无数据导出';
|
|
}
|
|
return $inventory;
|
|
}
|
|
} |