From eece8679ca7dbafa5039ea33358fbc12f79ced1a Mon Sep 17 00:00:00 2001 From: panliang <1163816051@qq.com> Date: Wed, 18 May 2022 11:19:11 +0800 Subject: [PATCH] user --- app/Models/UserVip.php | 5 +++++ app/Services/VipService.php | 2 +- .../migrations/2021_12_03_135905_create_vips_table.php | 2 +- database/seeders/AppSettingSeeder.php | 8 -------- 4 files changed, 7 insertions(+), 10 deletions(-) diff --git a/app/Models/UserVip.php b/app/Models/UserVip.php index f2b883cf..a9a5919f 100644 --- a/app/Models/UserVip.php +++ b/app/Models/UserVip.php @@ -25,4 +25,9 @@ class UserVip extends Model { return $this->belongsTo(Vip::class, 'vip_id'); } + + public function pay() + { + return $this->morphOne(PayLog::class, 'payable'); + } } diff --git a/app/Services/VipService.php b/app/Services/VipService.php index 4d5e0434..682a112b 100644 --- a/app/Services/VipService.php +++ b/app/Services/VipService.php @@ -65,7 +65,7 @@ class VipService 'trade_type' => WxpayTradeType::JSAPI->value, 'openid' => $openid, ]; - return (new WxpayService())->pay($params); + return ['pay_way' => $pay_way, 'data' => (new WxpayService())->pay($params)]; } throw new BizException('未知的支付方式'); } diff --git a/database/migrations/2021_12_03_135905_create_vips_table.php b/database/migrations/2021_12_03_135905_create_vips_table.php index 76012ae2..6a9b1fe9 100644 --- a/database/migrations/2021_12_03_135905_create_vips_table.php +++ b/database/migrations/2021_12_03_135905_create_vips_table.php @@ -26,7 +26,7 @@ class CreateVipsTable extends Migration }); Schema::create('user_vips', function (Blueprint $table) { $table->id(); - $table->unsignedBigInteger('user_id')->unique()->comment('用户ID'); + $table->unsignedBigInteger('user_id')->comment('用户ID'); $table->unsignedBigInteger('vip_id')->comment('会员ID'); $table->string('name')->comment('名称'); $table->decimal('price', 12, 2)->default(0)->comment('价格'); diff --git a/database/seeders/AppSettingSeeder.php b/database/seeders/AppSettingSeeder.php index 41ad7758..70864dec 100644 --- a/database/seeders/AppSettingSeeder.php +++ b/database/seeders/AppSettingSeeder.php @@ -100,14 +100,6 @@ class AppSettingSeeder extends Seeder 'merchant_master_secret' => 'HCB87uFoF18iWsKHf7VY57', ], 'remarks' => '个推配置', - ], - 'custom' => [ - 'value' => [ - 'key_value' => [ - 'wechat_mini_show_vip_banner' => 'https://zcs-test.oss-cn-chengdu.aliyuncs.com/ac/is_vip.png', - 'wechat_mini_become_vip_banner' => 'https://zcs-test.oss-cn-chengdu.aliyuncs.com/ac/not_vip.png', - ] - ] ] ] as $key => $values) { Setting::firstOrCreate(['key' => $key], $values);