From 8c5a87a337682250f2b1b6aea2d957f1383e7aa6 Mon Sep 17 00:00:00 2001 From: luofei <604446095@qq.com> Date: Tue, 27 Feb 2024 14:54:44 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=95=86=E6=88=B7=E5=95=86?= =?UTF-8?q?=E5=93=81=E5=88=86=E7=B1=BB=E5=88=97=E8=A1=A8=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../system/merchant/MerchantRepository.php | 12 +++++++++--- app/common/repositories/user/UserRepository.php | 10 ++++++++++ app/controller/api/Common.php | 10 ++++++++++ app/controller/api/store/merchant/Merchant.php | 3 ++- route/api.php | 1 + 5 files changed, 32 insertions(+), 4 deletions(-) diff --git a/app/common/repositories/system/merchant/MerchantRepository.php b/app/common/repositories/system/merchant/MerchantRepository.php index 4c812f3e..7979e59f 100644 --- a/app/common/repositories/system/merchant/MerchantRepository.php +++ b/app/common/repositories/system/merchant/MerchantRepository.php @@ -14,6 +14,7 @@ namespace app\common\repositories\system\merchant; +use app\common\dao\store\StoreCategoryDao; use app\common\dao\system\merchant\MerchantDao; use app\common\model\store\order\StoreOrder; use app\common\model\store\product\ProductReply; @@ -381,12 +382,17 @@ class MerchantRepository extends BaseRepository /** * @Author:Qinii * @Date: 2020/5/30 - * @param int $id + * @param int $merId + * @param int $pid * @return mixed */ - public function categoryList(int $id) + public function categoryList(int $merId, int $pid = 0) { - return app()->make(StoreCategoryRepository::class)->getApiFormatList($id, 1); + if ($pid == 0) { + return app()->make(StoreCategoryRepository::class)->getApiFormatList($merId, 1); + } else { + return app()->make(StoreCategoryDao::class)->children($pid, $merId); + } } public function wxQrcode($merId) diff --git a/app/common/repositories/user/UserRepository.php b/app/common/repositories/user/UserRepository.php index 537100a5..c00ac160 100644 --- a/app/common/repositories/user/UserRepository.php +++ b/app/common/repositories/user/UserRepository.php @@ -698,6 +698,8 @@ class UserRepository extends BaseRepository public function registr(string $phone, ?string $pwd, $user_type = 'h5') { $pwd = $pwd ? $this->encodePassword($pwd) : $this->encodePassword($this->dao->defaultPwd()); + $ip = app('request')->ip(); + $code = Cache::get('promote_'.$ip); $data = [ 'account' => $phone, 'pwd' => $pwd, @@ -706,6 +708,14 @@ class UserRepository extends BaseRepository 'phone' => $phone, 'last_ip' => app('request')->ip() ]; + if ($code) { + $data['promotion_code'] = $code; + $shop = explode('shop_', $code); + if (count($shop) == 2) { + $data['spread_uid'] = $shop[1]; + } + Cache::delete('promote_' . $ip); + } return $this->create($user_type, $data); } diff --git a/app/controller/api/Common.php b/app/controller/api/Common.php index 4a198f97..17f29e07 100644 --- a/app/controller/api/Common.php +++ b/app/controller/api/Common.php @@ -663,4 +663,14 @@ class Common extends BaseController return app('json')->success($select); } + /** + * 推广写入 + */ + public function promoteWriting() + { + $code = $this->request->param('code'); + Cache::set('promote_' . app('request')->ip(), $code, 86400); + return app('json')->success(); + } + } diff --git a/app/controller/api/store/merchant/Merchant.php b/app/controller/api/store/merchant/Merchant.php index e413b8e6..71d91528 100644 --- a/app/controller/api/store/merchant/Merchant.php +++ b/app/controller/api/store/merchant/Merchant.php @@ -101,9 +101,10 @@ class Merchant extends BaseController */ public function categoryList($id) { + $pid = $this->request->get('pid', 0); if(!$this->repository->merExists((int)$id)) return app('json')->fail('店铺已打烊'); - return app('json')->success($this->repository->categoryList($id)); + return app('json')->success($this->repository->categoryList($id, $pid)); } public function qrcode($id) diff --git a/route/api.php b/route/api.php index 3f2c8767..b3b16f52 100644 --- a/route/api.php +++ b/route/api.php @@ -22,6 +22,7 @@ use think\facade\Route; Route::group('api/', function () { Route::any('test', 'api.Auth/test'); Route::any('applet', 'api.Common/applet'); + Route::any('promote_writing', 'api.Common/promoteWriting'); //强制登录 Route::group(function () { Route::group('v2', function () {