## 4. 配置Nginx
1. 网站域名创建(确保域名已经解析到服务器IP地址)
diff --git a/doc/image/deploy/release-page.png b/doc/image/deploy/release-page.png
new file mode 100644
index 0000000000000000000000000000000000000000..8a5f394cb5f377e3afdd238a3017229447bc0060
GIT binary patch
literal 55849
zcmeFYWmH>jyDmzV8qh*16mN0YKyWG)D?t)mixex8;u=~?aVYN4Vj;ncI}~ftBEdDm
z-96-l_WjPczBSJNamM+x_8B{aA9FC1IiKgA*R9tzgH%CsM0cp}5D*X$DagN6Cm9|T%C&m$Sbr~V9
zvRNp@V8}-b(+k0d?}`0lyYr8@Ca9M*Tbr6z4DtXqS09&-)57GzeXX|`o0~X=rk$#S
z*T~oS ZgUXH!`{k=AetPN^QmIB&cjyJ+-Wm3D!+*{PFct`ZCY=aO4_x8)grX;v+jY@
z8PaAjR^!dj-jv)xf$TbA?P=$;G06v!b*+i-=LX;t-su?6wJMZP$N GS
z5HlKl*%92R82TF_*PU864#_^DP3*7rraV9w(A1X$C_Ryo0=)&@;MYDr(4N}6n+xh%
zY9Cld;!z78A$7S$^$(Gc9|Y9hTUcJJ!s+3so1XA1BeBT{3Ps3K$EMDUk*t(T?H2rg
zgBuHG@YsFZ#?-o~n&+@!kT703l|)~*i%4xSIFJB3reP{iX$Hs9xaO&vz!io3hgZV@+!1E
zFfs58y=aG6*=a}hXFcxmxf=UP?5JIVS;s@l{iCA_`bxP?PVO{-Ma6y~Ya1OiGu4kD
zYzlo(;|EgyWUbgUzbdUINXI%o)8SmIF4yJ^x;?hGha-@^;MgFF0S~Dj4eJ4WcJCvg
z#XTz`R>985%^z`Meo98%7P6&J-^T_%iv_VE7&Z*X$l!<_}~LnaM&K0n55Fw@l1^1*?tY(Y3%u-
zV0dO@TGP!B{Ul70UpCt>+3Tz
zGD-(2N*h^wpYahmTrs}BtoT`sx=oyBZ2d{*c~FY~jH*@7#MT{X+SqaHSXTWfo`j#N
zdIJ;nZ1&+D1|Pt4reFv@{-|5%M%nc8eP>3=P>vqw#cuZI_ggEKPW&kv7@+%VD
From 4b0d7698bdfd65951a1ea1f078d403b5433a2281 Mon Sep 17 00:00:00 2001
From: 1nFrastr <960843127@qq.com>
Date: Thu, 2 Jan 2025 13:07:38 +0800
Subject: [PATCH 03/14] readme
---
doc/deploy.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/doc/deploy.md b/doc/deploy.md
index 96bfd3c..f22cfb0 100644
--- a/doc/deploy.md
+++ b/doc/deploy.md
@@ -99,7 +99,7 @@ php artisan app:sync-resource-to-oss
## 7. 配置换脸算法KEY
-请前往《商汤科技-日日新开放平台》注册账号并创建应用,获取应用ID和应用密钥。
+请前往 [《商汤科技-日日新开放平台》](https://signin.sensecore.cn/?login_challenge) 注册账号并创建应用,获取应用ID和应用密钥。
目前不支持自主购买,需在申请AK和SK之后联系他们的商务对接同学开通。详情参考[飞书文档](https://iwqiw8uo3k0.feishu.cn/docx/ElnKdsKH1oQsA5x5X2ocFTcTnLg)
From 040f781f53452891afd92c87d53dd003fa3ff050 Mon Sep 17 00:00:00 2001
From: 1nFrastr <960843127@qq.com>
Date: Thu, 2 Jan 2025 15:51:21 +0800
Subject: [PATCH 04/14] =?UTF-8?q?feat=20=E7=AE=A1=E7=90=86=E5=90=8E?=
=?UTF-8?q?=E5=8F=B0=E5=85=88=E5=8E=BB=E6=8E=89=E6=A3=80=E6=9F=A5IP?=
=?UTF-8?q?=E5=9C=B0=E5=9D=80?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/Adminapi/Middleware/AuthMiddleware.php | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/app/Adminapi/Middleware/AuthMiddleware.php b/app/Adminapi/Middleware/AuthMiddleware.php
index c3d2172..79fb91c 100644
--- a/app/Adminapi/Middleware/AuthMiddleware.php
+++ b/app/Adminapi/Middleware/AuthMiddleware.php
@@ -23,9 +23,9 @@ public function handle(Request $request, Closure $next)
$adminInfo = $request->attributes->get('adminInfo');
// 检查IP地址
- if ($adminInfo['login_ip'] !== $request->ip()) {
- return JsonService::fail('IP 地址发生变化,请重新登录', [], -1);
- }
+// if ($adminInfo['login_ip'] !== $request->ip()) {
+// return JsonService::fail('IP 地址发生变化,请重新登录', [], -1);
+// }
// 系统默认超级管理员,无需权限验证
if ($adminInfo['root'] === 1) {
From a56a77658c6694bcc70416ae7f2b4185af39d7af Mon Sep 17 00:00:00 2001
From: 1nFrastr <960843127@qq.com>
Date: Thu, 2 Jan 2025 22:27:53 +0800
Subject: [PATCH 05/14] =?UTF-8?q?fix=20=E7=B3=BB=E7=BB=9F=E7=89=88?=
=?UTF-8?q?=E6=9C=AC=E5=8F=B7=E4=B8=8D=E8=83=BD=E5=87=BA=E7=8E=B0=E4=B8=AD?=
=?UTF-8?q?=E6=96=87=20+=20=E4=BF=AE=E5=A4=8D=E5=AD=98=E5=82=A8=E5=BC=95?=
=?UTF-8?q?=E6=93=8E=E6=8A=BD=E8=B1=A1=E6=96=B9=E6=B3=95=E5=BF=85=E9=A1=BB?=
=?UTF-8?q?=E5=85=A8=E9=83=A8=E5=AE=9E=E7=8E=B0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/Common/Service/Storage/Engine/Local.php | 4 ++++
app/Common/Service/Storage/Engine/Qcloud.php | 4 ++++
app/Common/Service/Storage/Engine/Qiniu.php | 4 ++++
config/project.php | 4 ++--
4 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/app/Common/Service/Storage/Engine/Local.php b/app/Common/Service/Storage/Engine/Local.php
index 331a209..56483a9 100644
--- a/app/Common/Service/Storage/Engine/Local.php
+++ b/app/Common/Service/Storage/Engine/Local.php
@@ -28,6 +28,10 @@ public function upload($save_dir)
return true;
}
+ public function syncDir($localDir, $targetDir)
+ {
+ }
+
public function fetch($url, $key = null)
{
}
diff --git a/app/Common/Service/Storage/Engine/Qcloud.php b/app/Common/Service/Storage/Engine/Qcloud.php
index 6244829..9c7bb3e 100644
--- a/app/Common/Service/Storage/Engine/Qcloud.php
+++ b/app/Common/Service/Storage/Engine/Qcloud.php
@@ -62,6 +62,10 @@ public function upload($save_dir)
}
}
+ public function syncDir($localDir, $targetDir)
+ {
+ }
+
/**
* notes: 抓取远程资源(最大支持上传5G文件)
* @param $url
diff --git a/app/Common/Service/Storage/Engine/Qiniu.php b/app/Common/Service/Storage/Engine/Qiniu.php
index 44dccec..6b69bb5 100644
--- a/app/Common/Service/Storage/Engine/Qiniu.php
+++ b/app/Common/Service/Storage/Engine/Qiniu.php
@@ -62,6 +62,10 @@ public function upload($save_dir)
}
}
+ public function syncDir($localDir, $targetDir)
+ {
+ }
+
/**
* @notes 抓取远程资源
* @param $url
diff --git a/config/project.php b/config/project.php
index 1107cf3..6bdf657 100644
--- a/config/project.php
+++ b/config/project.php
@@ -1,7 +1,7 @@
'LunaAI换脸 / Lite版本 / v1.0.0',
+ // 系统版本号(不能出现中文)
+ 'version' => 'Lite v1.0.0',
// 官网
'website' => [
From f5f89853b17f878b5d1fd41384d84f66cc68c3e5 Mon Sep 17 00:00:00 2001
From: 1nFrastr <960843127@qq.com>
Date: Thu, 30 Jan 2025 17:11:58 +0800
Subject: [PATCH 06/14] =?UTF-8?q?feat=20=E5=85=85=E5=80=BC=E5=A5=97?=
=?UTF-8?q?=E9=A4=90=E7=AE=A1=E7=90=86?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Controller/RechargePackageController.php | 101 +++++++++++++++
app/Adminapi/Lists/RechargePackageLists.php | 74 +++++++++++
app/Adminapi/Logic/RechargePackageLogic.php | 117 ++++++++++++++++++
app/Adminapi/Route/recharge_package.php | 27 ++++
.../Validate/RechargePackageValidate.php | 74 +++++++++++
app/Common/Model/RechargePackage.php | 37 ++++++
database/change.sql | 19 +++
7 files changed, 449 insertions(+)
create mode 100644 app/Adminapi/Controller/RechargePackageController.php
create mode 100644 app/Adminapi/Lists/RechargePackageLists.php
create mode 100644 app/Adminapi/Logic/RechargePackageLogic.php
create mode 100644 app/Adminapi/Route/recharge_package.php
create mode 100644 app/Adminapi/Validate/RechargePackageValidate.php
create mode 100644 app/Common/Model/RechargePackage.php
create mode 100644 database/change.sql
diff --git a/app/Adminapi/Controller/RechargePackageController.php b/app/Adminapi/Controller/RechargePackageController.php
new file mode 100644
index 0000000..2d2a449
--- /dev/null
+++ b/app/Adminapi/Controller/RechargePackageController.php
@@ -0,0 +1,101 @@
+dataLists(new RechargePackageLists());
+ }
+
+
+ /**
+ * @notes 添加
+ * @author likeadmin
+ * @date 2025/01/30 16:55
+ */
+ public function add()
+ {
+ $params = (new RechargePackageValidate())->post()->goCheck('add');
+ $result = RechargePackageLogic::add($params);
+ if (true === $result) {
+ return $this->success('添加成功', [], 1, 1);
+ }
+ return $this->fail(RechargePackageLogic::getError());
+ }
+
+
+ /**
+ * @notes 编辑
+ * @author likeadmin
+ * @date 2025/01/30 16:55
+ */
+ public function edit()
+ {
+ $params = (new RechargePackageValidate())->post()->goCheck('edit');
+ $result = RechargePackageLogic::edit($params);
+ if (true === $result) {
+ return $this->success('编辑成功', [], 1, 1);
+ }
+ return $this->fail(RechargePackageLogic::getError());
+ }
+
+
+ /**
+ * @notes 删除
+ * @author likeadmin
+ * @date 2025/01/30 16:55
+ */
+ public function delete()
+ {
+ $params = (new RechargePackageValidate())->post()->goCheck('delete');
+ RechargePackageLogic::delete($params);
+ return $this->success('删除成功', [], 1, 1);
+ }
+
+
+ /**
+ * @notes 获取详情
+ * @author likeadmin
+ * @date 2025/01/30 16:55
+ */
+ public function detail()
+ {
+ $params = (new RechargePackageValidate())->goCheck('detail');
+ $result = RechargePackageLogic::detail($params);
+ return $this->data($result);
+ }
+
+
+}
diff --git a/app/Adminapi/Lists/RechargePackageLists.php b/app/Adminapi/Lists/RechargePackageLists.php
new file mode 100644
index 0000000..14cb2ef
--- /dev/null
+++ b/app/Adminapi/Lists/RechargePackageLists.php
@@ -0,0 +1,74 @@
+searchWhere)
+ ->select(['id', 'name', 'describe', 'sell_price', 'draw_number', 'sort', 'status'])
+ ->limit($this->limitLength)
+ ->offset($this->limitOffset)
+ ->orderBy('sort', 'desc')
+ ->orderBy('id', 'desc')
+ ->get()
+ ->toArray();
+ }
+
+
+ /**
+ * @notes 获取数量
+ * @return int
+ * @author likeadmin
+ * @date 2025/01/30 16:55
+ */
+ public function count(): int
+ {
+ return RechargePackage::applySearchWhere($this->searchWhere)->count();
+ }
+
+}
diff --git a/app/Adminapi/Logic/RechargePackageLogic.php b/app/Adminapi/Logic/RechargePackageLogic.php
new file mode 100644
index 0000000..69eef6d
--- /dev/null
+++ b/app/Adminapi/Logic/RechargePackageLogic.php
@@ -0,0 +1,117 @@
+ $params['name'],
+ 'describe' => $params['describe'],
+ 'sell_price' => $params['sell_price'],
+ 'draw_number' => $params['draw_number'],
+ 'sort' => $params['sort'],
+ 'status' => $params['status']
+ ]);
+
+ DB::commit();
+ return true;
+ } catch (\Exception $e) {
+ DB::rollBack();
+ self::setError($e->getMessage());
+ return false;
+ }
+ }
+
+
+ /**
+ * @notes 编辑
+ * @param array $params
+ * @return bool
+ * @author likeadmin
+ * @date 2025/01/30 16:55
+ */
+ public static function edit(array $params): bool
+ {
+ DB::beginTransaction();
+ try {
+
+ $model = RechargePackage::findOrFail($params['id']);
+ $model->fill([
+ 'name' => $params['name'],
+ 'describe' => $params['describe'],
+ 'sell_price' => $params['sell_price'],
+ 'draw_number' => $params['draw_number'],
+ 'sort' => $params['sort'],
+ 'status' => $params['status']
+ ]);
+ $model->save();
+
+ DB::commit();
+ return true;
+ } catch (\Exception $e) {
+ DB::rollBack();
+ self::setError($e->getMessage());
+ return false;
+ }
+ }
+
+
+ /**
+ * @notes 删除
+ * @param array $params
+ * @return bool
+ * @author likeadmin
+ * @date 2025/01/30 16:55
+ */
+ public static function delete(array $params): bool
+ {
+ return RechargePackage::destroy($params['id']);
+ }
+
+
+ /**
+ * @notes 获取详情
+ * @param $params
+ * @return array
+ * @author likeadmin
+ * @date 2025/01/30 16:55
+ */
+ public static function detail($params): array
+ {
+ return RechargePackage::findOrFail($params['id'])->toArray();
+ }
+}
diff --git a/app/Adminapi/Route/recharge_package.php b/app/Adminapi/Route/recharge_package.php
new file mode 100644
index 0000000..d3e9f46
--- /dev/null
+++ b/app/Adminapi/Route/recharge_package.php
@@ -0,0 +1,27 @@
+group(function () {
+ Route::get('/recharge_package/lists', 'lists');
+ Route::post('/recharge_package/add', 'add');
+ Route::post('/recharge_package/edit', 'edit');
+ Route::post('/recharge_package/delete', 'delete');
+ Route::get('/recharge_package/detail', 'detail');
+});
diff --git a/app/Adminapi/Validate/RechargePackageValidate.php b/app/Adminapi/Validate/RechargePackageValidate.php
new file mode 100644
index 0000000..d25b9a4
--- /dev/null
+++ b/app/Adminapi/Validate/RechargePackageValidate.php
@@ -0,0 +1,74 @@
+ 'id不能为空',
+ 'name.required' => '套餐名称不能为空',
+ 'describe.required' => '套餐描述不能为空',
+ 'sell_price.required' => '套餐价格不能为空',
+ 'draw_number.required' => '作图次数不能为空',
+ 'sort.required' => '排序不能为空',
+ 'status.required' => '套餐状态不能为空',
+ ];
+
+ /**
+ * 设置校验规则
+ * @param $scene
+ * @return array
+ */
+ public function rules($scene = '')
+ {
+ $rules = [
+ 'add' => [
+ 'name' => 'required',
+ 'describe' => 'required',
+ 'sell_price' => 'required',
+ 'draw_number' => 'required',
+ 'sort' => 'required',
+ 'status' => 'required',
+ ],
+ 'edit' => [
+ 'id' => 'required',
+ 'name' => 'required',
+ 'describe' => 'required',
+ 'sell_price' => 'required',
+ 'draw_number' => 'required',
+ 'sort' => 'required',
+ 'status' => 'required',
+ ],
+ 'detail' => [
+ 'id' => 'required',
+ ],
+ 'delete' => [
+ 'id' => 'required',
+ ],
+ ];
+
+ return $rules[$scene] ?? [];
+ }
+
+}
diff --git a/app/Common/Model/RechargePackage.php b/app/Common/Model/RechargePackage.php
new file mode 100644
index 0000000..13300bd
--- /dev/null
+++ b/app/Common/Model/RechargePackage.php
@@ -0,0 +1,37 @@
+
Date: Thu, 30 Jan 2025 17:23:39 +0800
Subject: [PATCH 07/14] =?UTF-8?q?feat=20=E5=85=85=E5=80=BC=E5=A5=97?=
=?UTF-8?q?=E9=A4=90=E5=88=97=E8=A1=A8API?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/Api/Controller/RechargeController.php | 8 ++++++++
app/Api/Logic/RechargeLogic.php | 12 +++++++++++-
app/Api/Route/recharge.php | 1 +
3 files changed, 20 insertions(+), 1 deletion(-)
diff --git a/app/Api/Controller/RechargeController.php b/app/Api/Controller/RechargeController.php
index a247cc2..adecd8f 100644
--- a/app/Api/Controller/RechargeController.php
+++ b/app/Api/Controller/RechargeController.php
@@ -45,5 +45,13 @@ public function config()
return $this->data(RechargeLogic::config($this->getUserId()));
}
+ /**
+ * @notes 充值套餐列表
+ */
+ public function package()
+ {
+ $result = RechargeLogic::getAllPackages();
+ return $this->data($result);
+ }
}
diff --git a/app/Api/Logic/RechargeLogic.php b/app/Api/Logic/RechargeLogic.php
index 0e0c04d..e939951 100644
--- a/app/Api/Logic/RechargeLogic.php
+++ b/app/Api/Logic/RechargeLogic.php
@@ -3,8 +3,10 @@
namespace App\Api\Logic;
use App\Common\Enum\PayEnum;
+use App\Common\Enum\YesNoEnum;
use App\Common\Logic\BaseLogic;
use App\Common\Model\Recharge\RechargeOrder;
+use App\Common\Model\RechargePackage;
use App\Common\Model\User\User;
use App\Common\Service\ConfigService;
use Throwable;
@@ -26,7 +28,7 @@ public static function recharge(array $params): array|false
'order_terminal' => $params['terminal'],
'user_id' => $params['user_id'],
'pay_status' => PayEnum::UNPAID,
- 'order_amount' => $params['money'],
+ 'order_amount' => $params['money'], // TODO 从充值计划中获取
];
$order = RechargeOrder::create($data);
@@ -57,5 +59,13 @@ public static function config($userId): array
];
}
+ public static function getAllPackages()
+ {
+ return RechargePackage::where(['status' => YesNoEnum::YES])
+ ->orderBy('sort', 'desc')
+ ->orderBy('id', 'desc')
+ ->get()
+ ->toArray();
+ }
}
diff --git a/app/Api/Route/recharge.php b/app/Api/Route/recharge.php
index 556b619..b3a24de 100644
--- a/app/Api/Route/recharge.php
+++ b/app/Api/Route/recharge.php
@@ -6,4 +6,5 @@
Route::get('/recharge/lists', 'lists');
Route::post('/recharge/recharge', 'recharge');
Route::get('/recharge/config', 'config');
+ Route::get('/recharge/package', 'package');
});
From 3bfc381145c28adb6c314296f1afd92c5723e167 Mon Sep 17 00:00:00 2001
From: 1nFrastr <960843127@qq.com>
Date: Thu, 30 Jan 2025 17:49:33 +0800
Subject: [PATCH 08/14] =?UTF-8?q?feat=20=E6=94=AF=E4=BB=98=E5=9B=9E?=
=?UTF-8?q?=E8=B0=83=E9=80=BB=E8=BE=91=E9=80=82=E9=85=8D=E5=85=85=E5=80=BC?=
=?UTF-8?q?=E5=A5=97=E9=A4=90?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/Api/Logic/RechargeLogic.php | 8 +++-
app/Api/Validate/RechargeValidate.php | 3 ++
app/Common/Logic/PayNotifyLogic.php | 9 ++--
app/Common/Model/Recharge/RechargeOrder.php | 4 ++
app/Console/Commands/AppTest.php | 49 ++-------------------
5 files changed, 21 insertions(+), 52 deletions(-)
diff --git a/app/Api/Logic/RechargeLogic.php b/app/Api/Logic/RechargeLogic.php
index e939951..9ee6e3d 100644
--- a/app/Api/Logic/RechargeLogic.php
+++ b/app/Api/Logic/RechargeLogic.php
@@ -23,14 +23,18 @@ class RechargeLogic extends BaseLogic
public static function recharge(array $params): array|false
{
try {
+ $rechargePackage = RechargePackage::query()->findOrFail($params['package_id']);
+
$data = [
'sn' => generate_sn(RechargeOrder::class, 'sn'),
'order_terminal' => $params['terminal'],
'user_id' => $params['user_id'],
'pay_status' => PayEnum::UNPAID,
- 'order_amount' => $params['money'], // TODO 从充值计划中获取
+ 'order_amount' => $rechargePackage->sell_price,
+ 'recharge_package_snapshot' => $rechargePackage,
];
- $order = RechargeOrder::create($data);
+ $order = new RechargeOrder();
+ $order->fill($data)->save();
return [
'order_id' => (int)$order->id,
diff --git a/app/Api/Validate/RechargeValidate.php b/app/Api/Validate/RechargeValidate.php
index 7a4237c..c42bf62 100644
--- a/app/Api/Validate/RechargeValidate.php
+++ b/app/Api/Validate/RechargeValidate.php
@@ -12,6 +12,7 @@ public function rules($scene = '')
{
$rules = [
'recharge' => [
+ 'package_id' => 'required|exists:recharge_package,id',
'money' => [
'required',
'numeric',
@@ -38,6 +39,8 @@ function ($attribute, $value, Closure $fail) {
protected $messages = [
'money.required' => '请填写充值金额',
'money.gt' => '请填写大于0的充值金额',
+ 'package_id.required' => '请选择充值套餐',
+ 'package_id.exists' => '充值套餐不存在',
];
public function messages()
diff --git a/app/Common/Logic/PayNotifyLogic.php b/app/Common/Logic/PayNotifyLogic.php
index 81abd8b..4dbcab0 100644
--- a/app/Common/Logic/PayNotifyLogic.php
+++ b/app/Common/Logic/PayNotifyLogic.php
@@ -6,6 +6,7 @@
use App\Common\Enum\User\AccountLogEnum;
use App\Common\Model\Recharge\RechargeOrder;
use App\Common\Model\User\User;
+use Illuminate\Support\Arr;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
use Throwable;
@@ -45,13 +46,13 @@ public static function recharge(string $orderSn, array $extra = [])
$user = User::findOrFail($order->user_id);
$user->increment('total_recharge_amount', $order->order_amount);
- $user->increment('user_money', $order->order_amount);
+ $user->increment('balance_draw', Arr::get($order->recharge_package_snapshot, 'draw_number'));
AccountLogLogic::add(
- $order->user_id,
- AccountLogEnum::UM_INC_RECHARGE,
+ $user,
+ AccountLogEnum::DRAW_INC_RECHARGE,
AccountLogEnum::INC,
- $order->order_amount,
+ Arr::get($order->recharge_package_snapshot, 'draw_number'),
$order->sn,
'用户充值'
);
diff --git a/app/Common/Model/Recharge/RechargeOrder.php b/app/Common/Model/Recharge/RechargeOrder.php
index 616298e..0a4c951 100644
--- a/app/Common/Model/Recharge/RechargeOrder.php
+++ b/app/Common/Model/Recharge/RechargeOrder.php
@@ -17,6 +17,10 @@ class RechargeOrder extends BaseModel
protected $appends = ['pay_way_text', 'pay_status_text'];
+ public $casts = [
+ 'recharge_package_snapshot' => 'array'
+ ];
+
protected function getDeletedAtColumn()
{
return 'delete_time';
diff --git a/app/Console/Commands/AppTest.php b/app/Console/Commands/AppTest.php
index 5080881..1c76255 100644
--- a/app/Console/Commands/AppTest.php
+++ b/app/Console/Commands/AppTest.php
@@ -2,12 +2,8 @@
namespace App\Console\Commands;
-use App\Common\Model\SwapTemplate;
-use App\Common\Model\SwapTemplateGroup;
+use App\Common\Model\Recharge\RechargeOrder;
use Illuminate\Console\Command;
-use Illuminate\Support\Facades\File;
-use Overtrue\Pinyin\Pinyin;
-use Symfony\Component\Finder\SplFileInfo;
class AppTest extends Command
{
@@ -30,47 +26,8 @@ class AppTest extends Command
*/
public function handle()
{
- $pinyinNameMapTemplateGroup = SwapTemplateGroup::query()->select([
- 'id',
- 'name',
- ])->get()->map(function (SwapTemplateGroup $group) {
- $group->pinyin = self::getPinyin($group->name);
- return $group;
- })->keyBy('pinyin')->toArray();
-
- $localDir = public_path('resource/image/faceswap');
- // 遍历文件夹
- $files = File::allFiles($localDir);
- collect($files)->each(function (SplFileInfo $file) use ($pinyinNameMapTemplateGroup) {
- $relativePath = str_replace(public_path(), '', $file->getPathname());
- $relativePath = str_replace('\\', '/', $relativePath);
- $relativePath = ltrim($relativePath, '/');
- // 查找出匹配拼音的模板组。拼音正则匹配 luna_之后的一个词
- $pinyin = preg_match('/luna_(\w+)/', $relativePath, $matches) ? $matches[1] : '';
- $group = $pinyinNameMapTemplateGroup[$pinyin] ?? null;
- if ($group) {
- $this->info("Matched: {$relativePath} => {$group['name']}");
-
- if (SwapTemplate::query()->where('group_id', $group['id'])->where('target_image', $relativePath)->exists()) {
- return;
- } else {
- SwapTemplate::query()->create([
- 'group_id' => $group['id'],
- 'name' => $group['name'],
- 'status' => 1,
- 'target_image' => $relativePath,
- ]);
- }
- } else {
- $this->warn("Not Matched: {$relativePath}");
- }
- });
- }
-
- static function getPinyin($chinese)
- {
- $pinyin = Pinyin::sentence($chinese, 'none');
- return $pinyin->join('');
+ $res = RechargeOrder::query()->orderBy('id', 'desc')->first();
+ dd($res->toArray());
}
From e1e748cd4d95b9847270645237e8309a94b7ddbc Mon Sep 17 00:00:00 2001
From: 1nFrastr <960843127@qq.com>
Date: Thu, 30 Jan 2025 20:34:26 +0800
Subject: [PATCH 09/14] =?UTF-8?q?feat=20=E8=AE=A2=E5=8D=95=E5=88=97?=
=?UTF-8?q?=E8=A1=A8=E9=80=82=E9=85=8D=E5=85=85=E5=80=BC=E5=A5=97=E9=A4=90?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/Adminapi/Lists/Recharge/RechargeLists.php | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/app/Adminapi/Lists/Recharge/RechargeLists.php b/app/Adminapi/Lists/Recharge/RechargeLists.php
index f3b2559..b366613 100644
--- a/app/Adminapi/Lists/Recharge/RechargeLists.php
+++ b/app/Adminapi/Lists/Recharge/RechargeLists.php
@@ -20,13 +20,14 @@ class RechargeLists extends BaseAdminDataLists implements ListsSearchInterface,
public function setExcelFields(): array
{
return [
- 'sn' => '充值单号',
'nickname' => '用户昵称',
- 'order_amount' => '充值金额',
+ 'sn' => '订单号',
+ 'order_amount' => '订单金额',
+ 'recharge_package_description' => '充值套餐',
'pay_way_text' => '支付方式',
'pay_status_text' => '支付状态',
- 'pay_time' => '支付时间',
'create_time' => '下单时间',
+ 'pay_time' => '支付时间',
];
}
@@ -82,7 +83,7 @@ public function lists(): array
->select(
'ro.id', 'ro.sn', 'ro.order_amount', 'ro.pay_way', 'ro.pay_time',
'ro.pay_status', 'ro.create_time', 'ro.refund_status',
- 'u.avatar', 'u.nickname', 'u.account'
+ 'u.avatar', 'u.nickname', 'u.account', 'ro.recharge_package_snapshot'
)
->orderBy('ro.id', 'desc')
->limit($this->limitLength)
@@ -95,6 +96,11 @@ public function lists(): array
$item->create_time = date('Y-m-d H:i:s', $item->create_time);
$item->pay_status_text = PayEnum::getPayStatusDesc($item->pay_status);
$item->pay_way_text = PayEnum::getPayDesc($item->pay_way);
+ $item->recharge_package_snapshot = json_decode($item->recharge_package_snapshot, true);
+ $item->recharge_package_description =
+ $item->recharge_package_snapshot
+ ? $item->recharge_package_snapshot['name'] . '(' . $item->recharge_package_snapshot['describe'] . ')'
+ : '';
return (array)$item;
})->toArray();
}
From 8b632422fedaf477db6537e16079ce526f84d375 Mon Sep 17 00:00:00 2001
From: 1nFrastr <960843127@qq.com>
Date: Thu, 30 Jan 2025 20:58:15 +0800
Subject: [PATCH 10/14] =?UTF-8?q?fix=20=E6=A1=86=E6=9E=B6bug-=E5=BE=AE?=
=?UTF-8?q?=E4=BF=A1=E6=94=AF=E4=BB=98=E7=B1=BB=E5=91=BD=E5=90=8D=E7=A9=BA?=
=?UTF-8?q?=E9=97=B4=E5=A4=A7=E5=B0=8F=E5=86=99?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/Console/Commands/QueryRefund.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/app/Console/Commands/QueryRefund.php b/app/Console/Commands/QueryRefund.php
index b512813..8732de5 100644
--- a/app/Console/Commands/QueryRefund.php
+++ b/app/Console/Commands/QueryRefund.php
@@ -7,7 +7,7 @@
use App\Common\Model\Recharge\RechargeOrder;
use App\Common\Model\Refund\RefundLog;
use App\Common\Model\Refund\RefundRecord;
-use App\Common\Service\Pay\WeChatPayService;
+use App\Common\Service\Pay\WechatPayService;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
@@ -96,7 +96,7 @@ private function checkRefundStatus(array $record, RechargeOrder $order)
private function checkWechatRefund($orderTerminal, $refundLogSn)
{
- $result = (new WeChatPayService($orderTerminal))->queryRefund($refundLogSn);
+ $result = (new WechatPayService($orderTerminal))->queryRefund($refundLogSn);
if (isset($result['status']) && $result['status'] === 'SUCCESS') {
return true;
From 8bbaaf702ea088ed94dc0d9a5a0fc3567bd2f959 Mon Sep 17 00:00:00 2001
From: 1nFrastr <960843127@qq.com>
Date: Thu, 30 Jan 2025 20:59:06 +0800
Subject: [PATCH 11/14] =?UTF-8?q?feat=20=E7=94=A8=E6=88=B7=E9=92=B1?=
=?UTF-8?q?=E5=8C=85=E4=BD=99=E9=A2=9D=E9=BB=98=E8=AE=A4=E6=94=B9=E6=88=90?=
=?UTF-8?q?=E6=98=AF=E4=BD=9C=E5=9B=BE=E4=BD=99=E9=A2=9D+=E9=80=80?=
=?UTF-8?q?=E6=AC=BE=E9=80=BB=E8=BE=91=E5=A4=84=E7=90=86?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/Adminapi/Logic/Recharge/RechargeLogic.php | 9 +++++----
.../Validate/Recharge/RechargeRefundValidate.php | 7 +++++--
app/Adminapi/Validate/User/AdjustUserMoney.php | 4 ++--
3 files changed, 12 insertions(+), 8 deletions(-)
diff --git a/app/Adminapi/Logic/Recharge/RechargeLogic.php b/app/Adminapi/Logic/Recharge/RechargeLogic.php
index c1646fd..4f29b46 100644
--- a/app/Adminapi/Logic/Recharge/RechargeLogic.php
+++ b/app/Adminapi/Logic/Recharge/RechargeLogic.php
@@ -12,6 +12,7 @@
use App\Common\Model\Refund\RefundRecord;
use App\Common\Model\User\User;
use App\Common\Service\ConfigService;
+use Illuminate\Support\Arr;
use Illuminate\Support\Facades\DB;
use Throwable;
@@ -74,14 +75,14 @@ public static function refund($params, $adminId)
User::query()->where('id', $order->user_id)
->decrement('total_recharge_amount', $order->order_amount);
User::query()->where('id', $order->user_id)
- ->decrement('user_money', $order->order_amount);
+ ->decrement('balance_draw', Arr::get($order->recharge_package_snapshot, 'draw_number'));
// 记录日志
AccountLogLogic::add(
- $order->user_id,
- AccountLogEnum::UM_DEC_RECHARGE_REFUND,
+ User::findOrFail($order->user_id),
+ AccountLogEnum::DRAW_DEC_RECHARGE_REFUND,
AccountLogEnum::DEC,
- $order->order_amount,
+ Arr::get($order->recharge_package_snapshot, 'draw_number'),
$order->sn,
'充值订单退款'
);
diff --git a/app/Adminapi/Validate/Recharge/RechargeRefundValidate.php b/app/Adminapi/Validate/Recharge/RechargeRefundValidate.php
index 34c2058..de1187b 100644
--- a/app/Adminapi/Validate/Recharge/RechargeRefundValidate.php
+++ b/app/Adminapi/Validate/Recharge/RechargeRefundValidate.php
@@ -10,6 +10,7 @@
use App\Common\Model\User\User;
use App\Common\Validate\BaseValidate;
use Closure;
+use Illuminate\Support\Arr;
class RechargeRefundValidate extends BaseValidate
{
@@ -34,7 +35,8 @@ function ($attribute, $value, Closure $fail) {
}
$user = User::find($order->user_id);
- if ($user && $user->user_money < $order->order_amount) {
+ $orderDrawNumber = Arr::get($order->recharge_package_snapshot, 'draw_number');
+ if ($user && $user->balance_draw < $orderDrawNumber) {
return $fail('退款失败:用户余额已不足退款金额');
}
},
@@ -56,7 +58,8 @@ function ($attribute, $value, Closure $fail) {
$order = RechargeOrder::find($record->order_id);
$user = User::find($record->user_id);
- if ($user && $user->user_money < $order->order_amount) {
+ $orderDrawNumber = Arr::get($order->recharge_package_snapshot, 'draw_number');
+ if ($user && $user->balance_draw < $orderDrawNumber) {
return $fail('退款失败:用户余额已不足退款金额');
}
},
diff --git a/app/Adminapi/Validate/User/AdjustUserMoney.php b/app/Adminapi/Validate/User/AdjustUserMoney.php
index 72e223d..6f63f62 100644
--- a/app/Adminapi/Validate/User/AdjustUserMoney.php
+++ b/app/Adminapi/Validate/User/AdjustUserMoney.php
@@ -28,9 +28,9 @@ function ($attribute, $value, Closure $fail) {
return;
}
- $surplusMoney = $user->user_money - $value;
+ $surplusMoney = $user->balance_draw - $value;
if ($surplusMoney < 0) {
- return $fail('用户可用余额仅剩' . $user->user_money);
+ return $fail('用户可用余额仅剩' . $user->balance_draw);
}
},
],
From d5d58af513c3acbe0dda124c85c6583551edb86a Mon Sep 17 00:00:00 2001
From: 1nFrastr <960843127@qq.com>
Date: Thu, 30 Jan 2025 21:03:47 +0800
Subject: [PATCH 12/14] todo
---
database/change.sql | 2 ++
1 file changed, 2 insertions(+)
diff --git a/database/change.sql b/database/change.sql
index b4ef250..00c9896 100644
--- a/database/change.sql
+++ b/database/change.sql
@@ -17,3 +17,5 @@ CREATE TABLE `lite_recharge_package`
alter table lite_recharge_order
add column `recharge_package_snapshot` json COMMENT '充值套餐快照';
+
+# TODO 充值套餐-菜单SQL
From d923e84030059d40d6e26350ff62f782d456fb0c Mon Sep 17 00:00:00 2001
From: 1nFrastr <960843127@qq.com>
Date: Thu, 30 Jan 2025 21:12:00 +0800
Subject: [PATCH 13/14] =?UTF-8?q?feat=20=E4=BD=BF=E7=94=A8=E5=85=91?=
=?UTF-8?q?=E6=8D=A2=E7=A0=81=E6=8F=90=E9=86=92=E9=9C=80=E8=B4=AD=E4=B9=B0?=
=?UTF-8?q?=E9=AB=98=E7=BA=A7=E7=89=88=E6=8E=88=E6=9D=83?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/Api/Controller/PayController.php | 8 ++++++++
app/Api/Route/pay.php | 1 +
2 files changed, 9 insertions(+)
diff --git a/app/Api/Controller/PayController.php b/app/Api/Controller/PayController.php
index a03d5bd..4991996 100644
--- a/app/Api/Controller/PayController.php
+++ b/app/Api/Controller/PayController.php
@@ -96,4 +96,12 @@ public function aliNotify()
}
}
+ /**
+ * @notes 使用兑换码
+ */
+ public function useCardCode()
+ {
+ return $this->fail("功能未开通!请联系管理员购买高级版授权");
+ }
+
}
diff --git a/app/Api/Route/pay.php b/app/Api/Route/pay.php
index 49cf403..6925cd0 100644
--- a/app/Api/Route/pay.php
+++ b/app/Api/Route/pay.php
@@ -10,4 +10,5 @@
Route::post('/pay/notifyMnp', 'notifyMnp')->name('pay.notifyMnp');
Route::post('/pay/notifyOa', 'notifyOa')->name('pay.notifyOa');
Route::post('/pay/aliNotify', 'aliNotify')->name('pay.aliNotify');
+ Route::post('/pay/useCardCode', 'useCardCode');
});
From 557b88a91043311d4b416627965351105c713009 Mon Sep 17 00:00:00 2001
From: 1nFrastr <960843127@qq.com>
Date: Thu, 30 Jan 2025 21:51:28 +0800
Subject: [PATCH 14/14] =?UTF-8?q?feat=20feat=20=E5=B0=8F=E7=A8=8B=E5=BA=8F?=
=?UTF-8?q?=E5=BC=95=E6=B5=81=E5=AE=A2=E6=9C=8D=E4=BA=8C=E7=BB=B4=E7=A0=81?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/Adminapi/Logic/Channel/MnpSettingsLogic.php | 2 +-
app/Api/Logic/IndexLogic.php | 9 +++++++++
2 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/app/Adminapi/Logic/Channel/MnpSettingsLogic.php b/app/Adminapi/Logic/Channel/MnpSettingsLogic.php
index 0bb074d..58d5538 100644
--- a/app/Adminapi/Logic/Channel/MnpSettingsLogic.php
+++ b/app/Adminapi/Logic/Channel/MnpSettingsLogic.php
@@ -17,7 +17,7 @@ class MnpSettingsLogic extends BaseLogic
public function getConfig()
{
$domainName = $_SERVER['SERVER_NAME'];
- $qrCode = ConfigService::get('mnp_setting', 'qr_code', '');
+ $qrCode = ConfigService::get('mnp_setting', 'qr_code', ConfigService::get('website', 'pc_logo'));
$qrCode = empty($qrCode) ? $qrCode : FileService::getFileUrl($qrCode);
$config = [
'name' => ConfigService::get('mnp_setting', 'name', ''),
diff --git a/app/Api/Logic/IndexLogic.php b/app/Api/Logic/IndexLogic.php
index 5963f40..921d723 100644
--- a/app/Api/Logic/IndexLogic.php
+++ b/app/Api/Logic/IndexLogic.php
@@ -2,12 +2,14 @@
namespace App\Api\Logic;
+use App\Adminapi\Logic\Channel\MnpSettingsLogic;
use App\Common\Logic\BaseLogic;
use App\Common\Model\Article\Article;
use App\Common\Model\Decorate\DecoratePage;
use App\Common\Model\Decorate\DecorateTabbar;
use App\Common\Service\ConfigService;
use App\Common\Service\FileService;
+use Illuminate\Support\Arr;
class IndexLogic extends BaseLogic
{
@@ -112,6 +114,12 @@ public static function getConfigData()
// 备案信息
$copyright = ConfigService::get('copyright', 'config', []);
+ // 小程序相关
+ $mnpSetting = (new MnpSettingsLogic())->getConfig();
+ $mnp = [
+ 'contact_qr_code' => Arr::get($mnpSetting, 'qr_code')
+ ];
+
return [
'domain' => FileService::getFileUrl(),
'style' => $style,
@@ -121,6 +129,7 @@ public static function getConfigData()
'webPage' => $webPage,
'version' => config('project.version'),
'copyright' => $copyright,
+ 'mnp' => $mnp,
];
}