173 lines
6.6 KiB
PHP
173 lines
6.6 KiB
PHP
<?php
|
|
|
|
/**
|
|
* @author Any
|
|
* @description KISS
|
|
* @date 2021年6月9日
|
|
* @version 1.0.0
|
|
*
|
|
* _____LOG_____
|
|
*
|
|
*/
|
|
namespace app\models\common;
|
|
|
|
use app\models\Model;
|
|
use app\models\User;
|
|
use app\models\Cash;
|
|
use app\models\CashSetting;
|
|
use app\components\SysConst;
|
|
use app\components\SiteHelper;
|
|
use yii\data\Pagination;
|
|
|
|
class CommonCashListForm extends Model
|
|
{
|
|
public $keywords;
|
|
public $limit;
|
|
public $page;
|
|
|
|
public $user_id;
|
|
public $cx_mch_id;
|
|
public $scene;
|
|
public $transfer_status;
|
|
public $status;
|
|
public $cash_id;
|
|
|
|
public $start_time;
|
|
public $end_time;
|
|
|
|
|
|
|
|
public function rules()
|
|
{
|
|
return [
|
|
[['keywords'], 'trim'],
|
|
[['keywords'], 'string'],
|
|
[['limit', 'page', 'user_id', 'cx_mch_id', 'scene', 'transfer_status', 'status', 'cash_id'], 'integer'],
|
|
[['page'], 'default', 'value' => 1],
|
|
[['limit'], 'default', 'value' => 20],
|
|
[['start_time', 'end_time', ], 'safe'],
|
|
[['cx_mch_id'], 'required'],
|
|
[['user_id',], 'required', 'on' => 'user']
|
|
];
|
|
}
|
|
|
|
public function search()
|
|
{
|
|
if(!$this->validate()){
|
|
return $this->getModelError();
|
|
}
|
|
$query = Cash::find()->alias('c')
|
|
->leftJoin(['u' => User::tableName()], 'u.id=c.user_id')
|
|
->where([
|
|
'c.cx_mch_id' => $this->cx_mch_id,
|
|
'c.is_delete' => 0,
|
|
])
|
|
->andWhere([
|
|
'OR',
|
|
['LIKE', 'c.remark', $this->keywords],
|
|
['LIKE', 'c.wechat_account', $this->keywords],
|
|
['LIKE', 'c.wechat_account_name', $this->keywords],
|
|
['LIKE', 'c.alipay_account', $this->keywords],
|
|
['LIKE', 'c.alipay_account_name', $this->keywords],
|
|
['LIKE', 'c.bank_card_no', $this->keywords],
|
|
['LIKE', 'c.bank_card_name', $this->keywords],
|
|
['LIKE', 'c.order_no', $this->keywords],
|
|
['LIKE', 'u.username', $this->keywords],
|
|
['LIKE', 'u.nickname', $this->keywords],
|
|
['LIKE', 'u.real_name', $this->keywords],
|
|
])
|
|
->andFilterWhere([
|
|
'c.user_id' => $this->user_id,
|
|
'c.status' => $this->status,
|
|
'c.transfer_status' => $this->transfer_status,
|
|
'c.scene' => $this->scene,
|
|
'c.id' => $this->cash_id,
|
|
]);
|
|
$query = $this->switchTime($query);
|
|
$query = $query->select('u.nickname,u.avatar_url,u.real_name,c.id,c.cx_mch_id,c.user_id,c.scene,c.money,c.service_charge,c.order_no,c.status,c.transfer_status,c.wechat_account,c.wechat_account_name,c.alipay_account,c.alipay_account_name,c.bank_name,c.bank_card_no,c.bank_card_name,c.cash_type,c.pay_type,c.pay_time,c.created_at,c.review_time,c.review_comment,c.remark');
|
|
$count_query = clone $query;
|
|
$count = $count_query->count();
|
|
$pagination = new Pagination(['pageSize' => $this->limit, 'totalCount' => $count, 'page' => $this->page - 1]);
|
|
$list = $query->offset($pagination->offset)->limit($pagination->limit)->orderBy(['c.created_at' => SORT_DESC])->asArray()->all();
|
|
foreach ($list as $index => $item){
|
|
$item['created_at_cn'] = date('Y-m-d H:i:s',$item['created_at']);
|
|
$item['pay_time_cn'] = date('Y-m-d H:i:s',$item['pay_time']);
|
|
$item['review_time_cn'] = date('Y-m-d H:i:s',$item['review_time']);
|
|
$item['avatar_url'] = SiteHelper::getFullUrl($item['avatar_url']);
|
|
$item['status_cn'] = Cash::getStatus($item['status']);
|
|
$item['transfer_status_cn'] = Cash::getTransferStatus($item['transfer_status']);
|
|
$item['cash_type_cn'] = Cash::getCashType($item['cash_type']);
|
|
$item['pay_type_cn'] = Cash::getPayType($item['pay_type']);
|
|
$item['scene_cn'] = Cash::getScene($item['scene']);
|
|
$item['actual_money'] = $item['money'] - $item['service_charge'];//实际到账金额
|
|
$item['actual_money'] = sprintf("%.2f",$item['actual_money']);
|
|
$item['cash_type_info'] = $this->getCashTypeInfo($item);
|
|
$item['cash_money_info'] = $this->getCashMoneyInfo($item);
|
|
$list[$index] = $item;
|
|
}
|
|
//是否已经全部加载
|
|
$end_flag = $this->page > $pagination->pageCount ? true : false;
|
|
return [
|
|
'code' => 0,
|
|
'msg' => 'ok',
|
|
'data' => $list,
|
|
'count' => $count,
|
|
'page_size' => $this->limit,
|
|
'page_count' => $pagination->pageCount,
|
|
'page_no' => $this->page,
|
|
'end_flag' => $end_flag
|
|
];
|
|
}
|
|
|
|
public function switchTime($query)
|
|
{
|
|
if(!empty($this->start_time)){
|
|
$query = $query->andWhere([
|
|
'>',
|
|
'c.created_at',
|
|
strtotime($this->start_time)
|
|
]);
|
|
}
|
|
if(!empty($this->end_time)){
|
|
$query = $query->andWhere([
|
|
'<',
|
|
'c.created_at',
|
|
strtotime($this->end_time)
|
|
]);
|
|
}
|
|
return $query;
|
|
}
|
|
|
|
//提现方式
|
|
private function getCashTypeInfo($cash)
|
|
{
|
|
$cash_type_info = [];
|
|
$cash_type_info[] = $cash['cash_type_cn'];
|
|
if($cash['cash_type'] == Cash::$cxCashTypeAuto){
|
|
$cash_type_info[] = "--";
|
|
} else if($cash['cash_type'] == Cash::$cxCashTypeWx){
|
|
$cash_type_info[] = "微信账户:{$cash['wechat_account']}";
|
|
$cash_type_info[] = "微信账户持有者:{$cash['wechat_account_name']}";
|
|
} else if($cash['cash_type'] == Cash::$cxCashTypeAli){
|
|
$cash_type_info[] = "支付宝账户:{$cash['alipay_account']}";
|
|
$cash_type_info[] = "支付宝账户持有者:{$cash['alipay_account_name']}";
|
|
} else if($cash['cash_type'] == Cash::$cxCashTypeBank){
|
|
$cash_type_info[] = "银行名称:{$cash['bank_name']}";
|
|
$cash_type_info[] = "银行卡号:{$cash['bank_card_no']}";
|
|
$cash_type_info[] = "银行卡持有人姓名:{$cash['bank_card_name']}";
|
|
}
|
|
return implode(" / ", $cash_type_info);
|
|
}
|
|
|
|
//提现信息
|
|
private function getCashMoneyInfo($cash)
|
|
{
|
|
$cash_money_info = [];
|
|
$cash_money_info[] = "提现金额:¥{$cash['money']}";
|
|
$cash_money_info[] = "服务费:¥{$cash['service_charge']}";
|
|
$cash_money_info[] = "实际到账:¥{$cash['actual_money']}";
|
|
return implode(" / ", $cash_money_info);
|
|
}
|
|
}
|
|
|