feat : finish order

This commit is contained in:
2025-04-02 16:05:24 +08:00
parent 4620a0f1ba
commit ea374d578f
8 changed files with 498 additions and 7 deletions

View File

@@ -0,0 +1,42 @@
<?php
declare(strict_types=1);
namespace App\Model;
use Hyperf\DbConnection\Model\Model;
/**
* @property int $id
* @property int $user_id
* @property int $account_type
* @property int $business_code
* @property string $before_num
* @property string $change_num
* @property string $after_num
* @property int $track_user_id
* @property string $track_param
* @property string $remark
* @property string $create_time
*/
class AccountDetail extends Model
{
/**
* The table associated with the model.
*/
protected ?string $table = 'account_detail';
/**
* The attributes that are mass assignable.
*/
protected array $fillable = [];
protected array $guarded = [];
/**
* The attributes that should be cast to native types.
*/
protected array $casts = ['id' => 'integer', 'user_id' => 'integer', 'account_type' => 'integer', 'business_code' => 'integer', 'track_user_id' => 'integer'];
const string CREATED_AT = 'create_time';
const null UPDATED_AT = null;
}

View File

@@ -32,4 +32,58 @@ class UserAccount extends Model
const CREATED_AT = null;
const UPDATED_AT = null;
/**
* @param int $userId
* @return \Hyperf\Database\Model\Model|UserAccount|null
*/
public function getAccountByUserId(int $userId): \Hyperf\Database\Model\Model|UserAccount|null
{
return $this->where('user_id',$userId)->first();
}
/**
* 增加积分
* @param $userId
* @param $num
* @return int
*/
public function incPointByUserId($userId, $num): int
{
return $this->where('id', $userId)->increment('integral', $num);
}
/**
* 减少积分
* @param $userId
* @param $num
* @return int
*/
public function decIntegralByUserId($userId, $num): int
{
return $this->where('id', $userId)->decrement('integral', $num);
}
/**
* 增加余额
* @param $userId
* @param $num
* @return int
*/
public function incBalanceByUserId($userId, $num): int
{
return $this->where('id', $userId)->increment('balance', $num);
}
/**
* 减少余额
* @param $userId
* @param $num
* @return int
*/
public function decBalanceByUserId($userId, $num): int
{
return $this->where('id', $userId)->decrement('balance', $num);
}
}