wallet
This commit is contained in:
58
app/Models/Wallet/Platform/WalletPlatformModel.php
Normal file
58
app/Models/Wallet/Platform/WalletPlatformModel.php
Normal file
@ -0,0 +1,58 @@
|
||||
<?php
|
||||
namespace App\Models\Wallet\Platform;
|
||||
|
||||
use App\Exceptions\ModelException;
|
||||
use App\Models\Wallet\Base\WalletBaseModel;
|
||||
use App\Tools\Times;
|
||||
use App\Tools\Tools;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class WalletPlatformModel extends WalletBaseModel
|
||||
{
|
||||
protected $table = 'wallet_platform';
|
||||
protected $primaryKey = 'id';
|
||||
protected $fillable = [
|
||||
'id',
|
||||
'name',
|
||||
'code',
|
||||
'appid',
|
||||
'secret',
|
||||
'notify_ip',
|
||||
'created_at',
|
||||
];
|
||||
|
||||
const CODE_CYCLE = 'CYCLE';
|
||||
|
||||
function addPlatform(string $name, string $code): \Illuminate\Database\Eloquent\Model|\Illuminate\Database\Eloquent\Builder|bool
|
||||
{
|
||||
$insert = [
|
||||
'name' => $name,
|
||||
'code' => $code,
|
||||
'created_at' => Times::getNowDateTime(),
|
||||
];
|
||||
try {
|
||||
Db::beginTransaction();
|
||||
$resModel = $this->addItem($insert);
|
||||
if(!$resModel) throw new ModelException('添加失败');
|
||||
|
||||
$appid_key = $resModel->id . $resModel->name . $resModel->code;
|
||||
$resModel->appid = Tools::getMd5($appid_key);
|
||||
$resModel->secret = Tools::generateRandStr(32);
|
||||
$res = $resModel->save();
|
||||
if(!$res) throw new ModelException('添加appid失败');
|
||||
|
||||
Db::commit();
|
||||
}catch (\Exception $e) {
|
||||
Db::rollBack();
|
||||
throw $e;
|
||||
}
|
||||
return $resModel;
|
||||
}
|
||||
|
||||
//@@给平台下发用户信息
|
||||
static function userTransactionNotifyToPlatform($user_transaction_id)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user