| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- <?php
- namespace App\Models;
- /**
- * 充值缴费订单模型
- */
- class PayOrdersModel extends BaseModel
- {
- protected $table = 'pay_orders';
- protected $fillable = [
- 'order_no',
- 'user_id',
- 'total',
- 'type',
- 'discount',
- 'pay_total',
- 'charge_amount',
- 'pay_at',
- 'account',
- 'transaction_id',
- 'meal_id',
- 'product_id',
- 'out_trade_no',
- 'charge_kami',
- 'area',
- 'ytype',
- 'id_card_no',
- 'city',
- 'remark',
- 'result',
- 'failed_remark',
- 'create_time',
- 'update_time',
- 'refund_status',
- 'refund_money',
- 'refund_remark',
- 'status',
- 'mark'
- ];
- /**
- * 关联用户
- */
- public function user()
- {
- return $this->belongsTo(MemberModel::class, 'user_id', 'id');
- }
- /**
- * 推荐收益用户
- * @return \Illuminate\Database\Eloquent\Relations\HasOne
- */
- public function recUser()
- {
- return $this->hasOne(MemberModel::class, 'id', 'rec_bonus_id')
- ->select(['id', 'mobile', 'nickname', 'realname', 'status']);
- }
- /**
- * 关联套餐
- */
- public function meal()
- {
- return $this->belongsTo(PayMealsModel::class, 'meal_id', 'id');
- }
- /**
- * 获取类型文本
- */
- public function getTypeTextAttribute()
- {
- $typeMap = [
- 1 => '话费',
- 2 => '电费',
- 3 => '燃气'
- ];
- return $typeMap[$this->type] ?? '未知';
- }
- /**
- * 获取状态文本
- */
- public function getStatusTextAttribute()
- {
- $statusMap = [
- 1 => '待付款',
- 2 => '已付款',
- 3 => '充值中',
- 4 => '充值成功',
- 5 => '充值失败',
- 6 => '部分成功'
- ];
- return $statusMap[$this->status] ?? '未知';
- }
- /**
- * 获取退款状态文本
- */
- public function getRefundStatusTextAttribute()
- {
- $refundStatusMap = [
- 0 => '无',
- 1 => '已成功',
- 2 => '待退款',
- 3 => '退款失败'
- ];
- return $refundStatusMap[$this->refund_status] ?? '未知';
- }
- }
|