quanwei
2025-12-12 b8961f178740f99ce54cfcbfd88235eaf8b79872
1
<?php namespace app\common\model\plus\regactivity; use app\common\model\BaseModel; use app\common\service\order\OrderService; /**  * 用户模型  */ class User extends BaseModel {     protected $name = 'registration_user';     protected $pk = 'order_id';     /**      * 追加字段      * @var string[]      */     protected $append = [         'pay_status_text',         'pay_type_text',         'status_text',     ];     /**      * 支付状态      */     public function getPayStatusTextAttr($value, $data)     {         if($data["pay_status"] == 20){             $pay_status = "已支付";         }else{             $pay_status = "未支付";         }         return $pay_status;     }     /**      * 支付方式      */     public function getPayTypeTextAttr($value, $data)     {         $pay_type="";         if($data["pay_type"] == 20){             $pay_type = "微信支付";         }elseif($data["pay_type"] == 10){             $pay_type = "余额支付";         }         return $pay_type;     }     /**      * 报名状态      */     public function getStatusTextAttr($value, $data)     {         if($data["status"] == 1){             $status = "报名成功";         }else{             $status = "报名失败";         }         return $status;     }     /**      * 关联会员记录表      * @return \think\model\relation\BelongsTo      */     public function user()     {         return $this->belongsTo('app\\common\\model\\user\\User');     }     /**      * 详情      */     public static function detail($order_id, $with = ['user'])     {         return (new static())->with($with)->find($order_id);     }     /**      * 待支付详情      */     public static function getPayDetail($orderNo)     {         $model = new static();         return $model->where(['order_no' => $orderNo, 'pay_status' => 10])->with(['user'])->find();     }     /**      * 新增用户记录      * @param $user_id      * @param $data      * @return bool      */     public static function add($data)     {         $model = new static;         $model->save(array_merge([             'is_delete' => 0,             'app_id' => $model::$app_id         ], $data));         return $model['order_id'];     }     /**      * 获取报名数量      */     public static function getRegNum($activity_id)     {         return (new static())->where('activity_id', '=', $activity_id)             ->where('status', '=', 1)             ->where('is_delete', '=', 0)             ->count();     }     /**      * 生成订单号      */     public function orderNo()     {         return OrderService::createOrderNo();     } }