| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- <?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','type_name'];
- // 时间
- public function getTimeTextAttribute()
- {
- return $this->create_time? datetime($this->create_time,'Y-m-d H:i:s') : '';
- }
- // 时间
- public function getRealMoneyAttribute()
- {
- return moneyFormat(abs($this->money),2);
- }
- // 类型
- public function getTypeNameAttribute()
- {
- $types = [1=>'订单付款',2=>'余额充值',3=>'订单退款',4=>'余额转出',5=>'余额转出驳回',6=>'平台转入',7=>'企业结算',8=>'收益',9=>'其他',10=>'余额转账'];
- return isset($types[$this->type])?$types[$this->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_status','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','meeting_id','pay_total','pay_at','transaction_id','bonus','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']);
- }
- }
|