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 () {