123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- <?php
- namespace app\common\model;
- use app\admin\model\Admin;
- use think\Model;
- /**
- * 配置模型
- */
- class MobileOrderRefundLog extends Model
- {
- protected $autoWriteTimestamp=true;
- protected $updateTime=null;
- protected $append=[
- 'create_time_format',
- ];
- public function refunduser(){
- return $this->morphTo('refunduser',[
- 'admin'=>Admin::class,
- 'user' =>User::class,
- ]);
- }
- public function mobileOrder(){
- return $this->belongsTo(MobileOrder::class,'mobile_id','id')->setEagerlyType(0);
- }
- public static function withRefundUser(User $user,$data){
- return new self([
- 'refunduser_type'=>'user',
- 'refunduser_id'=>$user['id'],
- 'amount'=>$data['amount'],
- ]);
- }
- public static function withRefundAdmin(Admin $user,$data){
- return new self([
- 'refunduser_type'=>'admin',
- 'refunduser_id'=>$user['id'],
- 'amount'=>$data['amount'],
- ]);
- }
- public static function withRefund($type,$user,$data){
- return new self([
- 'refunduser_type'=>$type,
- 'refunduser_id'=>$user['id'],
- 'amount_user'=>$data['amount_user']??0,
- 'amount_backend'=>$data['amount'],
- 'reason'=>$data['refund_reason'],
- 'pass'=>$data['pass'],
- ]);
- }
- public function getCreateTimeFormatAttr($a,$b){
- return date('m/d H:i',$b['create_time']);
- }
- }
|