12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- <?php
- namespace app\common\model;
- use app\service\pay_user\PayUserWechat;
- use think\Model;
- /**
- *@property
- */
- class TakeCash extends Model
- {
- // 自动写入时间戳字段
- protected $autoWriteTimestamp = true;
- // 定义时间戳字段名
- protected $createTime = 'created_at';
- protected $updateTime = 'updated_at';
- // 追加属性
- protected $append = [
- ];
-
- const STATUS_APPLY=0;
- const STATUS_PASS=1;
- const STATUS_REJECT=2;
- public static $statusList=[
- self::STATUS_APPLY=>'审核中',
- self::STATUS_PASS=>'已通过',
- self::STATUS_REJECT=>'已拒绝',
- ];
- public function audit($status){
- empty(self::$statusList[$status]) && throw_user('状态有误');
- $this['status']=$status;
- $user=$this->user;
- if($status==self::STATUS_REJECT){
- $user::money($this['amount'],$user['id'],MoneyLog::TYPE_TAKECASH_REJECT,'提现不通过');
- }elseif ($status==self::STATUS_PASS){
- (new PayUserWechat())->payment($this['amount'],$user,MoneyLog::TYPE_TAKECASH,'提现',[],false);
- }
- if(!$this->save()){
- throw_user('保存失败');
- }
- }
- public function user()
- {
- return $this->belongsTo(User::class)->removeOption('soft_delete');
- }
- }
|