| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- <?php
- // +----------------------------------------------------------------------
- // | LARAVEL8.0 框架 [ LARAVEL ][ RXThinkCMF ]
- // +----------------------------------------------------------------------
- // | 版权所有 2017~2021 LARAVEL研发中心
- // +----------------------------------------------------------------------
- // | 官方网站: http://www.laravel.cn
- // +----------------------------------------------------------------------
- // | Author: laravel开发员 <laravel.qq.com>
- // +----------------------------------------------------------------------
- namespace App\Models;
- /**
- * 账户明细-模型
- * @author laravel开发员
- * @since 2020/11/11
- * @package App\Models
- */
- class AccountLogModel extends BaseModel
- {
- // 设置数据表
- protected $table = 'account_logs';
- protected $appends = ['bill','real_money','time_text','status_text','account_name','type_name'];
- // 时间
- public function getTimeTextAttribute()
- {
- return $this->create_time? datetime($this->create_time,'Y-m-d H:i:s') : '';
- }
- // 金额
- public function getMoneyAttribute($value)
- {
- return $this->account_type==1? moneyFormat($value,2): floatval($value);
- }
- public function getAfterMoneyAttribute($value)
- {
- return $this->account_type==1? moneyFormat($value,2): floatval($value);
- }
- // 金额
- public function getRealMoneyAttribute()
- {
- return moneyFormat(abs($this->money),2);
- }
- // 类型
- public function getTypeNameAttribute()
- {
- $types = [1=>'订单付款',2=>'账户充值',3=>'订单退款',4=>'账户提现',5=>'账户提现驳回',6=>'平台调整',7=>'商家结算',8=>'收益奖励',9=>'积分互转',99=>'其他'];
- return isset($types[$this->type])?$types[$this->type]:'账户交易';
- }
- // 账户类型
- public function getAccountNameAttribute()
- {
- $types = [1=>'收益余额',2=>'数字资产',3=>'报单积分',4=>'绿色积分'];
- return isset($types[$this->account_type])?$types[$this->account_type]:'账户余额';
- }
- // 状态
- public function getStatusTextAttribute()
- {
- $statusArr = [1=>'交易成功',2=>'待处理',3=>'失败'];
- return isset($statusArr[$this->status])?$statusArr[$this->status]:'交易成功';
- }
- // 账单
- public function getBillAttribute()
- {
- if($this->type==4){
- return BalanceLogModel::where(['order_no'=>$this->source_order_no,'mark'=>1])
- ->select(['id','user_id','order_no','money','pay_at','pay_type','receive_status','total','fee','actual_money','pool_money','pt_money','type','pay_status','package_info','mch_id','batch_id','account_name','account','confirm_remark','transaction_id','confirm_at','create_time','status'])
- ->first();
- }else if($this->store_id>0 && $this->type == 7){
- return OrderModel::with(['user'])->where(['order_no'=>$this->source_order_no,'mark'=>1])
- ->select(['id','user_id','order_no','total','type','pay_total','pay_status','pay_at','transaction_id','create_time','status'])
- ->first();
- }else{
- return '';
- }
- }
- /**
- * 用户
- * @return \Illuminate\Database\Eloquent\Relations\HasOne
- */
- public function member()
- {
- return $this->hasOne(MemberModel::class, 'id','user_id')
- ->select(['id','mobile','realname','nickname','status']);
- }
- }
|