From aa74028ca2fda462fb8646256c4a9867e2dc79e0 Mon Sep 17 00:00:00 2001 From: vine_liutk <961510893@qq.com> Date: Tue, 22 Feb 2022 18:09:00 +0800 Subject: [PATCH 01/39] =?UTF-8?q?=E5=B0=8F=E7=A8=8B=E5=BA=8F=E6=8E=88?= =?UTF-8?q?=E6=9D=83=E7=99=BB=E5=BD=951.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.example | 3 + .../Auth/SocialiteAuthController.php | 334 ++++++++++++++++++ .../Http/Controllers/WechatMiniController.php | 12 + app/Endpoint/Api/routes.php | 9 + app/Models/SocialiteUser.php | 22 ++ app/Providers/AppServiceProvider.php | 1 + app/Providers/Socialite/WechatMini.php | 76 ++++ composer.json | 1 + composer.lock | 2 +- config/socialite.php | 12 + config/wechat.php | 48 +++ ...22_142257_create_socialite_users_table.php | 37 ++ 12 files changed, 556 insertions(+), 1 deletion(-) create mode 100644 app/Endpoint/Api/Http/Controllers/Auth/SocialiteAuthController.php create mode 100644 app/Endpoint/Api/Http/Controllers/WechatMiniController.php create mode 100644 app/Models/SocialiteUser.php create mode 100644 app/Providers/Socialite/WechatMini.php create mode 100644 config/socialite.php create mode 100644 database/migrations/2022_02_22_142257_create_socialite_users_table.php diff --git a/.env.example b/.env.example index 85f7a425..e1f3dcad 100644 --- a/.env.example +++ b/.env.example @@ -67,3 +67,6 @@ ALIYUN_OSS_STS_HOST = ALIYUN_SMS_ACCESS_ID= ALIYUN_SMS_ACCESS_KEY= ALIYUN_SMS_SIGN_NAME= + +WECHAT_MINI_PROGRAM_APPID= +WECHAT_MINI_PROGRAM_SECRET= diff --git a/app/Endpoint/Api/Http/Controllers/Auth/SocialiteAuthController.php b/app/Endpoint/Api/Http/Controllers/Auth/SocialiteAuthController.php new file mode 100644 index 00000000..b63dad84 --- /dev/null +++ b/app/Endpoint/Api/Http/Controllers/Auth/SocialiteAuthController.php @@ -0,0 +1,334 @@ +validate([ + 'code' => ['bail', 'required', 'string'], + ]); + $code = $input['code']; + + //获取第三方用户信息 + $socialiteUser = $this->getSocialiteUserByCode($provider, $code); + + //通过第三方用户信息登录已绑定账号 + $token = $this->loginUser([ + 'socialite_type'=>$provider, + 'socialite_id'=>$socialiteUser?->id, + ], $request); + + return response()->json([ + 'token' => $token?->plainTextToken, + ]); + } + + public function codeBindUser($provider, Request $request) + { + $type = $request->input('type', 'default'); + + $rules = [ + 'code' => ['bail', 'required', 'string'], + 'inviter_code' => ['bail', 'nullable', 'string'], + ]; + switch ($type) { + case 'default'://手机号+密码 + $rules = array_merge($rules, [ + 'phone' => ['bail', 'required', 'string'], + 'password' => ['bail', 'required', 'string'], + ]); + break; + case 'sms_code'://手机号+验证码 + $rules = array_merge($rules, [ + 'phone' => ['bail', 'required', new PhoneNumberRule()], + 'verify_code' => ['bail', 'required', 'string'], + ]); + break; + case 'wechat_mini'://微信小程序解密手机号 + $rules = array_merge($rules, [ + 'data' => ['bail', 'required', 'string'], + 'iv' => ['bail', 'required', 'string'], + ]); + break; + default://默认手机号+密码 + $rules = array_merge($rules, [ + 'phone' => ['bail', 'required', 'string'], + 'password' => ['bail', 'required', 'string'], + ]); + break; + } + + $input = $request->validate($rules); + $code = $input['code']; + + //获取第三方用户信息 + $socialiteUser = $this->getSocialiteUserByCode($provider, $code); + + //绑定用户,并返回token + $token = $this->bindUser([ + 'socialite_type'=>$provider, + 'socialite_id'=>$socialiteUser?->id, + ], $type ?? 'default', $request); + + return response()->json([ + 'token' => $token?->plainTextToken, + ]); + } + + /** + * [目前支持:微信小程序] + */ + protected function getSocialiteUserByCode($provider, $code) + { + //获取第三方用户信息 + $user = null; + $config = config('socialite', []); + $socialite = new SocialiteManager($config); + switch ($provider) { + case 'wechat-mini'://微信小程序 + $user = $socialite->create('wehcat-mini')->userFromCode($code); + break; + default: + throw new BizException(404); + } + return $user; + } + + /** + * 第三方登录现有绑定的用户 + * + * @param [array] $socialite + * @param [Request] $request + */ + protected function loginUser(array $socialite, Request $request) + { + $token = null; + $socialiteUser = SocialiteUser::firstOrCreate($socialite); + $user = $socialiteUser->user; + if ($user) { + $user->last_login_at = now(); + $user->last_login_ip = $request->realIp(); + $user->save(); + // 获取登录设备 + $device = $request->header('client-app', Device::UNIAPP); + + switch ($device) { + case Device::MERCHANT: + if ($user->userInfo?->agent_level < UserInfo::AGENT_LEVEL_VIP) { + throw new BizException('账户没有权限'); + } + + // 清理此用户的商户端令牌 + $user->tokens()->where('name', $device)->delete(); + // 颁发新的商户端令牌 + $token = $user->createToken($device); + break; + case Device::DEALER: + if (!$user->isDealer()) { + throw new BizException('账户没有权限'); + } + + // 清理此用户的商户端令牌 + $user->tokens()->where('name', $device)->delete(); + // 颁发新的商户端令牌 + $token = $user->createToken($device); + break; + default: + $device = Device::UNIAPP; + // 清理此用户的商城端令牌 + $user->tokens()->where('name', $device)->delete(); + // 颁发新的商城端令牌 + $token = $user->createToken($device, ['mall']); + break; + } + } + return $token; + } + + protected function bindUser(array $socialite, string $type, Request $request) + { + $token = null; + $socialiteUser = SocialiteUser::firstOrCreate($socialite); + $user = null; + $input = $request->input(); + switch ($type) { + case 'default'://手机号+密码 + $user = User::where('phone', $input['phone'])->first(); + //手机号不存在,或者密码错误 + if (! $user?->verifyPassword($input['password'])) { + throw new BizException(__('Incorrect account or password')); + } + break; + case 'sms_code'://手机号+验证码 + app(SmsCodeService::class)->validate( + $input['phone'], + SmsCode::TYPE_REGISTER, + $input['verify_code'] + ); + $user = User::where('phone', $input['phone'])->first(); + break; + case 'wechat_mini'://微信小程序解密手机号 + //解密失败 + $app = EasyWeChatFactory::miniProgram([ + 'app_id' => config('wechat.mini_program.default.app_id', ''), + 'secret' => config('wechat.mini_program.default.secret', ''), + + // 下面为可选项 + // 指定 API 调用返回结果的类型:array(default)/collection/object/raw/自定义类名 + 'response_type' => 'array', + + 'log' => [ + 'level' => 'debug', + 'file' => storage_path('logs/wechat-mini.log'), + ], + ]); + $session = Cache::get($socialite['socialite_id']); + try { + $decryptedData = $app->encryptor->decryptData($session, $input['iv'], $input['data']); + } catch (\EasyWeChat\Kernel\Exceptions\DecryptException $e) { + return $this->error('系统错误, 请重新进入小程序'); + } + $phone = data_get($decryptedData, 'phoneNumber'); + //解密成功,$user + $user = User::where('phone', $phone)->first(); + break; + } + + //走登录逻辑 + if ($user) { + $user->last_login_at = now(); + $user->last_login_ip = $request->realIp(); + $user->save(); + + // 获取登录设备 + $device = $request->header('client-app', Device::UNIAPP); + + switch ($device) { + case Device::MERCHANT: + if ($user->userInfo?->agent_level < UserInfo::AGENT_LEVEL_VIP) { + throw new BizException('账户没有权限'); + } + + // 清理此用户的商户端令牌 + $user->tokens()->where('name', $device)->delete(); + // 颁发新的商户端令牌 + $token = $user->createToken($device); + break; + case Device::DEALER: + if (!$user->isDealer()) { + throw new BizException('账户没有权限'); + } + + // 清理此用户的商户端令牌 + $user->tokens()->where('name', $device)->delete(); + // 颁发新的商户端令牌 + $token = $user->createToken($device); + break; + default: + $device = Device::UNIAPP; + // 清理此用户的商城端令牌 + $user->tokens()->where('name', $device)->delete(); + // 颁发新的商城端令牌 + $token = $user->createToken($device, ['mall']); + break; + } + } else {//走注册逻辑 + $time = now(); + $ip = $request->realIp(); + $inviter = $this->findUserByCode((string) Arr::get($input, 'code')); + try { + DB::beginTransaction(); + + $user = User::create( + array_merge($input, [ + 'phone_verified_at' => $time, + 'register_ip' => $ip, + 'last_login_at' => $time, + 'last_login_ip' => $ip, + ]), + $inviter + ); + + DB::commit(); + } catch (Throwable $e) { + DB::rollBack(); + + report($e); + + throw new BizException(__('Registration failed, please try again')); + } + + // 获取登录设备 + $device = $request->header('client-app', Device::UNIAPP); + + switch ($device) { + case Device::DEALER: + $token = $user->createToken(Device::DEALER); + break; + default: + $token = $user->createToken(Device::UNIAPP, ['mall']); + break; + } + } + //解绑以前的关系 + SocialiteUser::where('user_id', $user->id)->update([ + 'user_id' => null, + ]); + //绑定用户和三方信息关系 + $socialiteUser->update([ + 'user_id' => $user->id, + ]); + + return $token; + } + + /** + * 通过邀请码搜索用户 + * + * @param string $code + * @return \App\Models\User|null + * + * @throws \App\Exceptions\BizException + */ + protected function findUserByCode(string $code): ?User + { + if ($code === '') { + return null; + } + + $user = User::when(PhoneNumber::validate($code), function ($query) use ($code) { + $query->where('phone', $code); + }, function ($query) use ($code) { + $query->whereRelation('userInfo', 'code', $code); + })->first(); + + if ($user === null) { + throw new BizException(__('Inviter does not exist')); + } + + return $user; + } +} diff --git a/app/Endpoint/Api/Http/Controllers/WechatMiniController.php b/app/Endpoint/Api/Http/Controllers/WechatMiniController.php new file mode 100644 index 00000000..ef2c0364 --- /dev/null +++ b/app/Endpoint/Api/Http/Controllers/WechatMiniController.php @@ -0,0 +1,12 @@ +'socialite', + ], function () { + Route::post('code-auth/{provider}', [Auth\SocialiteAuthController::class, 'codeAuth']); + Route::post('code-bind-user/{provider}', [Auth\SocialiteAuthController::class, 'codeBindUser']); + }); + Route::middleware(['auth:api'])->group(function () { // 我的信息 Route::get('me', [UserController::class, 'show']); diff --git a/app/Models/SocialiteUser.php b/app/Models/SocialiteUser.php new file mode 100644 index 00000000..3c030195 --- /dev/null +++ b/app/Models/SocialiteUser.php @@ -0,0 +1,22 @@ +belongsTo(User::class); + } +} diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 3bf420c6..a29f94ec 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -9,6 +9,7 @@ use EasyWeChat\Payment\Application as EasyWeChatPaymentApplication; use Illuminate\Database\Eloquent\Relations\Relation; use Illuminate\Http\Request; use Illuminate\Http\Resources\Json\JsonResource; +use Illuminate\Support\Facades\Schema; use Illuminate\Support\ServiceProvider; use Overtrue\EasySms\EasySms; use Symfony\Component\HttpFoundation\HeaderUtils; diff --git a/app/Providers/Socialite/WechatMini.php b/app/Providers/Socialite/WechatMini.php new file mode 100644 index 00000000..16da36cd --- /dev/null +++ b/app/Providers/Socialite/WechatMini.php @@ -0,0 +1,76 @@ + $this->config->get('client_id'), + 'secret' => $this->config->get('client_secret'), + + // 下面为可选项 + // 指定 API 调用返回结果的类型:array(default)/collection/object/raw/自定义类名 + 'response_type' => 'array', + + 'log' => [ + 'level' => 'debug', + 'file' => storage_path('logs/wechat-mini.log'), + ], + ]); + $result = $app->auth->session($code); + if ($result) { + if (data_get($result, 'errcode')) { + throw new BizException(data_get($result, 'errmsg')); + } + //缓存微信小程序会话密钥(48小时) + Cache::put($result['openid'], $result['session_key'], 48 * 60 * 60); + + return $this->mapUserToObject([ + 'openid'=>$result['openid'], + // 'unionid'=>$result['unionid'], + ]); + } else { + throw new BizException('解析失败'); + } + } + + protected function getAuthUrl(): string + { + return ''; + } + + protected function getTokenUrl(): string + { + return ''; + } + + protected function getUserByToken(string $token): array + { + return []; + } + + protected function mapUserToObject(array $user): User + { + return new User([ + 'id' => $user['openid'] ?? null, + 'name' => $user['nickname'] ?? null, + 'nickname' => $user['nickname'] ?? null, + 'avatar' => $user['headimgurl'] ?? null, + 'email' => null, + ]); + } +} diff --git a/composer.json b/composer.json index e0a990dd..d831fe6c 100644 --- a/composer.json +++ b/composer.json @@ -26,6 +26,7 @@ "laravel/sanctum": "^2.12", "laravel/tinker": "^2.5", "overtrue/easy-sms": "^2.0", + "overtrue/socialite": "*", "simplesoftwareio/simple-qrcode": "^4.2", "tucker-eric/eloquentfilter": "^3.0", "w7corp/easywechat": "^5.10" diff --git a/composer.lock b/composer.lock index 0a534fbe..ef988496 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "f53d3bea81e27c131da9f29019c886a1", + "content-hash": "5ea856539b7c9cb2093859052437846e", "packages": [ { "name": "adbario/php-dot-notation", diff --git a/config/socialite.php b/config/socialite.php new file mode 100644 index 00000000..7e528f19 --- /dev/null +++ b/config/socialite.php @@ -0,0 +1,12 @@ +[ + 'provider' => WechatMini::class, + 'client_id' => env('WECHAT_MINI_PROGRAM_APPID', ''), + 'client_secret' => env('WECHAT_MINI_PROGRAM_SECRET', ''), + 'redirect' =>'', + ], +]; diff --git a/config/wechat.php b/config/wechat.php index ea02f988..6dd2a912 100644 --- a/config/wechat.php +++ b/config/wechat.php @@ -1,6 +1,54 @@ [ + 'default' => [ + 'app_id' => env('WECHAT_OFFICIAL_ACCOUNT_APPID', 'your-app-id'), // AppID + 'secret' => env('WECHAT_OFFICIAL_ACCOUNT_SECRET', 'your-app-secret'), // AppSecret + 'token' => env('WECHAT_OFFICIAL_ACCOUNT_TOKEN', 'your-token'), // Token + 'aes_key' => env('WECHAT_OFFICIAL_ACCOUNT_AES_KEY', ''), // EncodingAESKey + + /* + * OAuth 配置 + * + * scopes:公众平台(snsapi_userinfo / snsapi_base),开放平台:snsapi_login + * callback:OAuth授权完成后的回调页地址(如果使用中间件,则随便填写。。。) + * enforce_https:是否强制使用 HTTPS 跳转 + */ + 'oauth' => [ + 'scopes' => array_map('trim', explode(',', env('WECHAT_OFFICIAL_ACCOUNT_OAUTH_SCOPES', 'snsapi_userinfo'))), + 'callback' => env('WECHAT_OFFICIAL_ACCOUNT_OAUTH_CALLBACK', '/examples/oauth_callback.php'), + 'enforce_https' => true, + ], + ], + ], + + /* + * 开放平台第三方平台 + */ + // 'open_platform' => [ + // 'default' => [ + // 'app_id' => env('WECHAT_OPEN_PLATFORM_APPID', ''), + // 'secret' => env('WECHAT_OPEN_PLATFORM_SECRET', ''), + // 'token' => env('WECHAT_OPEN_PLATFORM_TOKEN', ''), + // 'aes_key' => env('WECHAT_OPEN_PLATFORM_AES_KEY', ''), + // ], + // ], + + /* + * 小程序 + */ + 'mini_program' => [ + 'default' => [ + 'app_id' => env('WECHAT_MINI_PROGRAM_APPID', ''), + 'secret' => env('WECHAT_MINI_PROGRAM_SECRET', ''), + 'token' => env('WECHAT_MINI_PROGRAM_TOKEN', ''), + 'aes_key' => env('WECHAT_MINI_PROGRAM_AES_KEY', ''), + ], + ], 'payment' => [ 'default' => [ 'sandbox' => env('WECHAT_PAYMENT_SANDBOX', false), diff --git a/database/migrations/2022_02_22_142257_create_socialite_users_table.php b/database/migrations/2022_02_22_142257_create_socialite_users_table.php new file mode 100644 index 00000000..d28a02fc --- /dev/null +++ b/database/migrations/2022_02_22_142257_create_socialite_users_table.php @@ -0,0 +1,37 @@ +id(); + $table->string('socialite_type')->comment('平台'); + $table->string('socialite_id')->comment('三方唯一ID'); + $table->unsignedBigInteger('user_id')->nullable()->comment('绑定的用户ID'); + $table->timestamps(); + + $table->index(['socialite_type', 'socialite_id']); + $table->index('user_id'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('socialite_users'); + } +} From 764efe86ada408403b16e9e8f4e10d048be14273 Mon Sep 17 00:00:00 2001 From: vine_liutk <961510893@qq.com> Date: Wed, 23 Feb 2022 09:54:20 +0800 Subject: [PATCH 02/39] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=B0=8F=E7=A8=8B?= =?UTF-8?q?=E5=BA=8F=E7=99=BB=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Auth/SocialiteAuthController.php | 156 +++++++----------- 1 file changed, 64 insertions(+), 92 deletions(-) diff --git a/app/Endpoint/Api/Http/Controllers/Auth/SocialiteAuthController.php b/app/Endpoint/Api/Http/Controllers/Auth/SocialiteAuthController.php index b63dad84..4ec9ca48 100644 --- a/app/Endpoint/Api/Http/Controllers/Auth/SocialiteAuthController.php +++ b/app/Endpoint/Api/Http/Controllers/Auth/SocialiteAuthController.php @@ -33,13 +33,18 @@ class SocialiteAuthController extends Controller $code = $input['code']; //获取第三方用户信息 - $socialiteUser = $this->getSocialiteUserByCode($provider, $code); + $socialite = $this->getSocialiteUserByCode($provider, $code); //通过第三方用户信息登录已绑定账号 - $token = $this->loginUser([ - 'socialite_type'=>$provider, - 'socialite_id'=>$socialiteUser?->id, - ], $request); + $token = null; + $socialiteUser = SocialiteUser::firstOrCreate([ + 'socialite_type' => $provider, + 'socialite_id' => $socialite?->id, + ]); + $user = $socialiteUser->user; + if ($user) { + $token = $this->loginUser($user, $request); + } return response()->json([ 'token' => $token?->plainTextToken, @@ -61,13 +66,13 @@ class SocialiteAuthController extends Controller 'password' => ['bail', 'required', 'string'], ]); break; - case 'sms_code'://手机号+验证码 + case 'sms-code'://手机号+验证码 $rules = array_merge($rules, [ 'phone' => ['bail', 'required', new PhoneNumberRule()], 'verify_code' => ['bail', 'required', 'string'], ]); break; - case 'wechat_mini'://微信小程序解密手机号 + case 'wechat-mini'://微信小程序解密手机号 $rules = array_merge($rules, [ 'data' => ['bail', 'required', 'string'], 'iv' => ['bail', 'required', 'string'], @@ -85,12 +90,12 @@ class SocialiteAuthController extends Controller $code = $input['code']; //获取第三方用户信息 - $socialiteUser = $this->getSocialiteUserByCode($provider, $code); + $socialite = $this->getSocialiteUserByCode($provider, $code); //绑定用户,并返回token $token = $this->bindUser([ 'socialite_type'=>$provider, - 'socialite_id'=>$socialiteUser?->id, + 'socialite_id'=>$socialite?->id, ], $type ?? 'default', $request); return response()->json([ @@ -118,56 +123,11 @@ class SocialiteAuthController extends Controller } /** - * 第三方登录现有绑定的用户 + * 第三方绑定用户 * * @param [array] $socialite * @param [Request] $request */ - protected function loginUser(array $socialite, Request $request) - { - $token = null; - $socialiteUser = SocialiteUser::firstOrCreate($socialite); - $user = $socialiteUser->user; - if ($user) { - $user->last_login_at = now(); - $user->last_login_ip = $request->realIp(); - $user->save(); - // 获取登录设备 - $device = $request->header('client-app', Device::UNIAPP); - - switch ($device) { - case Device::MERCHANT: - if ($user->userInfo?->agent_level < UserInfo::AGENT_LEVEL_VIP) { - throw new BizException('账户没有权限'); - } - - // 清理此用户的商户端令牌 - $user->tokens()->where('name', $device)->delete(); - // 颁发新的商户端令牌 - $token = $user->createToken($device); - break; - case Device::DEALER: - if (!$user->isDealer()) { - throw new BizException('账户没有权限'); - } - - // 清理此用户的商户端令牌 - $user->tokens()->where('name', $device)->delete(); - // 颁发新的商户端令牌 - $token = $user->createToken($device); - break; - default: - $device = Device::UNIAPP; - // 清理此用户的商城端令牌 - $user->tokens()->where('name', $device)->delete(); - // 颁发新的商城端令牌 - $token = $user->createToken($device, ['mall']); - break; - } - } - return $token; - } - protected function bindUser(array $socialite, string $type, Request $request) { $token = null; @@ -219,46 +179,11 @@ class SocialiteAuthController extends Controller //走登录逻辑 if ($user) { - $user->last_login_at = now(); - $user->last_login_ip = $request->realIp(); - $user->save(); - - // 获取登录设备 - $device = $request->header('client-app', Device::UNIAPP); - - switch ($device) { - case Device::MERCHANT: - if ($user->userInfo?->agent_level < UserInfo::AGENT_LEVEL_VIP) { - throw new BizException('账户没有权限'); - } - - // 清理此用户的商户端令牌 - $user->tokens()->where('name', $device)->delete(); - // 颁发新的商户端令牌 - $token = $user->createToken($device); - break; - case Device::DEALER: - if (!$user->isDealer()) { - throw new BizException('账户没有权限'); - } - - // 清理此用户的商户端令牌 - $user->tokens()->where('name', $device)->delete(); - // 颁发新的商户端令牌 - $token = $user->createToken($device); - break; - default: - $device = Device::UNIAPP; - // 清理此用户的商城端令牌 - $user->tokens()->where('name', $device)->delete(); - // 颁发新的商城端令牌 - $token = $user->createToken($device, ['mall']); - break; - } + $token = $this->loginUser($user, $request); } else {//走注册逻辑 $time = now(); $ip = $request->realIp(); - $inviter = $this->findUserByCode((string) Arr::get($input, 'code')); + $inviter = $this->findUserByCode((string) Arr::get($input, 'inviter_code')); try { DB::beginTransaction(); @@ -305,6 +230,53 @@ class SocialiteAuthController extends Controller return $token; } + /** + * 第三方登录现有绑定的用户 + * + * @param [User] $user + * @param [Request] $request + */ + protected function loginUser(User $user, Request $request) + { + $token = null; + $user->last_login_at = now(); + $user->last_login_ip = $request->realIp(); + $user->save(); + // 获取登录设备 + $device = $request->header('client-app', Device::UNIAPP); + + switch ($device) { + case Device::MERCHANT: + if ($user->userInfo?->agent_level < UserInfo::AGENT_LEVEL_VIP) { + throw new BizException('账户没有权限'); + } + + // 清理此用户的商户端令牌 + $user->tokens()->where('name', $device)->delete(); + // 颁发新的商户端令牌 + $token = $user->createToken($device); + break; + case Device::DEALER: + if (!$user->isDealer()) { + throw new BizException('账户没有权限'); + } + + // 清理此用户的商户端令牌 + $user->tokens()->where('name', $device)->delete(); + // 颁发新的商户端令牌 + $token = $user->createToken($device); + break; + default: + $device = Device::UNIAPP; + // 清理此用户的商城端令牌 + $user->tokens()->where('name', $device)->delete(); + // 颁发新的商城端令牌 + $token = $user->createToken($device, ['mall']); + break; + } + return $token; + } + /** * 通过邀请码搜索用户 * From 292f3e82eb6c010c0108130fcec72422f3b94bc5 Mon Sep 17 00:00:00 2001 From: vine_liutk <961510893@qq.com> Date: Wed, 23 Feb 2022 13:41:58 +0800 Subject: [PATCH 03/39] =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=90=8E=E5=8F=B0?= =?UTF-8?q?=E6=8B=92=E7=BB=9D=E6=94=B6=E6=AC=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Admin/Forms/DealerOrderRefuse.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/Admin/Forms/DealerOrderRefuse.php b/app/Admin/Forms/DealerOrderRefuse.php index c7e0ec34..0525e799 100644 --- a/app/Admin/Forms/DealerOrderRefuse.php +++ b/app/Admin/Forms/DealerOrderRefuse.php @@ -40,6 +40,10 @@ class DealerOrderRefuse extends Form $order->update([ 'status' => DealerOrderStatus::Paying, + //置空已支付的信息 + 'pay_way'=> null, + 'pay_image'=> null, + 'pay_info' => null, 'pay_time' => null, ]); From 04d339c5526117bc35b125f7f61f58ce21364d6a Mon Sep 17 00:00:00 2001 From: vine_liutk <961510893@qq.com> Date: Wed, 23 Feb 2022 13:43:43 +0800 Subject: [PATCH 04/39] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=8B=92=E7=BB=9D?= =?UTF-8?q?=E6=94=B6=E6=AC=BE=E7=9A=84=E8=A1=A8=E5=8D=95=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Admin/Forms/DealerOrderRefuse.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Admin/Forms/DealerOrderRefuse.php b/app/Admin/Forms/DealerOrderRefuse.php index 0525e799..e852922c 100644 --- a/app/Admin/Forms/DealerOrderRefuse.php +++ b/app/Admin/Forms/DealerOrderRefuse.php @@ -71,7 +71,7 @@ class DealerOrderRefuse extends Form */ public function form() { - $this->textarea('reason', '原因')->rules('required|max:255'); + $this->textarea('reason', '原因')->required()->rules('required|max:255'); } /** From 2a72d9153cc49507f0609c52448dbadb0188b17e Mon Sep 17 00:00:00 2001 From: vine_liutk <961510893@qq.com> Date: Wed, 23 Feb 2022 16:08:02 +0800 Subject: [PATCH 05/39] =?UTF-8?q?=E5=B0=8F=E7=A8=8B=E5=BA=8F=E6=B3=A8?= =?UTF-8?q?=E5=86=8C=E7=94=A8=E6=88=B7=E9=9A=8F=E6=9C=BA=E5=AF=86=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Api/Http/Controllers/Auth/SocialiteAuthController.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/Endpoint/Api/Http/Controllers/Auth/SocialiteAuthController.php b/app/Endpoint/Api/Http/Controllers/Auth/SocialiteAuthController.php index 4ec9ca48..8cf5ebb6 100644 --- a/app/Endpoint/Api/Http/Controllers/Auth/SocialiteAuthController.php +++ b/app/Endpoint/Api/Http/Controllers/Auth/SocialiteAuthController.php @@ -17,6 +17,7 @@ use Illuminate\Http\Request; use Illuminate\Support\Arr; use Illuminate\Support\Facades\Cache; use Illuminate\Support\Facades\DB; +use Illuminate\Support\Str; use Overtrue\Socialite\SocialiteManager; use Throwable; @@ -189,6 +190,7 @@ class SocialiteAuthController extends Controller $user = User::create( array_merge($input, [ + 'password' => Str::random(6), //先随机一个密码 'phone_verified_at' => $time, 'register_ip' => $ip, 'last_login_at' => $time, From 8150e53a5b56741076f87debe74e8be670e6ff32 Mon Sep 17 00:00:00 2001 From: vine_liutk <961510893@qq.com> Date: Wed, 23 Feb 2022 16:24:26 +0800 Subject: [PATCH 06/39] =?UTF-8?q?=E8=B0=83=E6=95=B4=E6=88=91=E4=B8=89?= =?UTF-8?q?=E6=96=B9=E6=8E=88=E6=9D=83=E7=99=BB=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Auth/SocialiteAuthController.php | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/app/Endpoint/Api/Http/Controllers/Auth/SocialiteAuthController.php b/app/Endpoint/Api/Http/Controllers/Auth/SocialiteAuthController.php index 8cf5ebb6..54ca6579 100644 --- a/app/Endpoint/Api/Http/Controllers/Auth/SocialiteAuthController.php +++ b/app/Endpoint/Api/Http/Controllers/Auth/SocialiteAuthController.php @@ -135,23 +135,24 @@ class SocialiteAuthController extends Controller $socialiteUser = SocialiteUser::firstOrCreate($socialite); $user = null; $input = $request->input(); + $phone = $input['phone']; switch ($type) { case 'default'://手机号+密码 - $user = User::where('phone', $input['phone'])->first(); + $user = User::where('phone', $phone)->first(); //手机号不存在,或者密码错误 if (! $user?->verifyPassword($input['password'])) { throw new BizException(__('Incorrect account or password')); } break; - case 'sms_code'://手机号+验证码 + case 'sms-code'://手机号+验证码 app(SmsCodeService::class)->validate( $input['phone'], SmsCode::TYPE_REGISTER, $input['verify_code'] ); - $user = User::where('phone', $input['phone'])->first(); + $user = User::where('phone', $phone)->first(); break; - case 'wechat_mini'://微信小程序解密手机号 + case 'wechat-mini'://微信小程序解密手机号 //解密失败 $app = EasyWeChatFactory::miniProgram([ 'app_id' => config('wechat.mini_program.default.app_id', ''), @@ -177,7 +178,9 @@ class SocialiteAuthController extends Controller $user = User::where('phone', $phone)->first(); break; } - + if (empty($phone)) { + throw new BizException('系统错误,未找到手机号'); + } //走登录逻辑 if ($user) { $token = $this->loginUser($user, $request); @@ -187,15 +190,14 @@ class SocialiteAuthController extends Controller $inviter = $this->findUserByCode((string) Arr::get($input, 'inviter_code')); try { DB::beginTransaction(); - - $user = User::create( - array_merge($input, [ + $user = User::create([ + 'phone' => $phone, 'password' => Str::random(6), //先随机一个密码 'phone_verified_at' => $time, 'register_ip' => $ip, 'last_login_at' => $time, 'last_login_ip' => $ip, - ]), + ], $inviter ); From 6b603e725dfc11fe0a4496be799ac49921013023 Mon Sep 17 00:00:00 2001 From: vine_liutk <961510893@qq.com> Date: Wed, 23 Feb 2022 16:38:16 +0800 Subject: [PATCH 07/39] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=BE=AE=E4=BF=A1?= =?UTF-8?q?=E6=8E=88=E6=9D=83=E7=99=BB=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Api/Http/Controllers/Auth/SocialiteAuthController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Endpoint/Api/Http/Controllers/Auth/SocialiteAuthController.php b/app/Endpoint/Api/Http/Controllers/Auth/SocialiteAuthController.php index 54ca6579..c4b11b97 100644 --- a/app/Endpoint/Api/Http/Controllers/Auth/SocialiteAuthController.php +++ b/app/Endpoint/Api/Http/Controllers/Auth/SocialiteAuthController.php @@ -135,7 +135,7 @@ class SocialiteAuthController extends Controller $socialiteUser = SocialiteUser::firstOrCreate($socialite); $user = null; $input = $request->input(); - $phone = $input['phone']; + $phone = $input['phone'] ?? ''; switch ($type) { case 'default'://手机号+密码 $user = User::where('phone', $phone)->first(); From 292f540879ce80d33e6ed6891d0139e609d45296 Mon Sep 17 00:00:00 2001 From: vine_liutk <961510893@qq.com> Date: Thu, 24 Feb 2022 10:44:29 +0800 Subject: [PATCH 08/39] =?UTF-8?q?=E8=B0=83=E6=95=B4=E4=B8=89=E6=96=B9?= =?UTF-8?q?=E7=99=BB=E5=BD=95=E8=A7=A3=E7=BB=91=E6=97=B6=E7=9A=84=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Api/Http/Controllers/Auth/SocialiteAuthController.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/Endpoint/Api/Http/Controllers/Auth/SocialiteAuthController.php b/app/Endpoint/Api/Http/Controllers/Auth/SocialiteAuthController.php index c4b11b97..114370ec 100644 --- a/app/Endpoint/Api/Http/Controllers/Auth/SocialiteAuthController.php +++ b/app/Endpoint/Api/Http/Controllers/Auth/SocialiteAuthController.php @@ -222,8 +222,11 @@ class SocialiteAuthController extends Controller break; } } - //解绑以前的关系 - SocialiteUser::where('user_id', $user->id)->update([ + //解绑对应三方以前的关系 + SocialiteUser::where([ + 'user_id' => $user->id, + 'socialite_type' => $socialite['socialite_type'], + ])->update([ 'user_id' => null, ]); //绑定用户和三方信息关系 From 251aab920526241f9281cb598b40ae4397d34c0f Mon Sep 17 00:00:00 2001 From: vine_liutk <961510893@qq.com> Date: Thu, 24 Feb 2022 11:16:28 +0800 Subject: [PATCH 09/39] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=B8=89=E6=96=B9?= =?UTF-8?q?=E8=A7=A3=E7=BB=91=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Auth/SocialiteAuthController.php | 21 +++++++++++++++++++ app/Endpoint/Api/routes.php | 1 + 2 files changed, 22 insertions(+) diff --git a/app/Endpoint/Api/Http/Controllers/Auth/SocialiteAuthController.php b/app/Endpoint/Api/Http/Controllers/Auth/SocialiteAuthController.php index 114370ec..e1caa91f 100644 --- a/app/Endpoint/Api/Http/Controllers/Auth/SocialiteAuthController.php +++ b/app/Endpoint/Api/Http/Controllers/Auth/SocialiteAuthController.php @@ -104,6 +104,27 @@ class SocialiteAuthController extends Controller ]); } + /** + * 第三方登录的解绑 + * + * @param [type] $provider + * @param Request $request + */ + public function unbindUser($provider, Request $request) + { + if ($user = $request->user()) { + //解绑三方的关系 + SocialiteUser::where([ + 'user_id' => $user->id, + 'socialite_type' => $provider, + ])->update([ + 'user_id' => null, + ]); + } + + return response()->noContent(); + } + /** * [目前支持:微信小程序] */ diff --git a/app/Endpoint/Api/routes.php b/app/Endpoint/Api/routes.php index 0aa1b0dd..ee6afac7 100644 --- a/app/Endpoint/Api/routes.php +++ b/app/Endpoint/Api/routes.php @@ -92,6 +92,7 @@ Route::group([ ], function () { Route::post('code-auth/{provider}', [Auth\SocialiteAuthController::class, 'codeAuth']); Route::post('code-bind-user/{provider}', [Auth\SocialiteAuthController::class, 'codeBindUser']); + Route::post('unbind-user/{provider}', [Auth\SocialiteAuthController::class, 'unbindUser']); }); Route::middleware(['auth:api'])->group(function () { From 1c5ad9517b5af5ce758cc459343281005dce5d78 Mon Sep 17 00:00:00 2001 From: vine_liutk <961510893@qq.com> Date: Fri, 25 Feb 2022 10:57:29 +0800 Subject: [PATCH 10/39] =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=90=8E=E5=8F=B0?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E6=8E=92=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Admin/Controllers/DealerEarningController.php | 1 + app/Admin/Controllers/DealerManageSubsidyLogController.php | 1 + app/Admin/Controllers/DealerManagerSalesLogController.php | 1 + app/Admin/Controllers/DealerPurchaseLogController.php | 1 + 4 files changed, 4 insertions(+) diff --git a/app/Admin/Controllers/DealerEarningController.php b/app/Admin/Controllers/DealerEarningController.php index 63756e31..ab4dac17 100644 --- a/app/Admin/Controllers/DealerEarningController.php +++ b/app/Admin/Controllers/DealerEarningController.php @@ -35,6 +35,7 @@ class DealerEarningController extends AdminController $earning = DealerEarning::with(['user', 'payer']); return Grid::make($earning, function (Grid $grid) { $grid->setResource('dealer-earnings'); + $grid->model()->orderBy('id', 'desc');//默认ID倒叙 $grid->column('id')->sortable(); $grid->column('user.phone'); $grid->column('type_name')->display(function () { diff --git a/app/Admin/Controllers/DealerManageSubsidyLogController.php b/app/Admin/Controllers/DealerManageSubsidyLogController.php index 82930af2..5cdd4646 100644 --- a/app/Admin/Controllers/DealerManageSubsidyLogController.php +++ b/app/Admin/Controllers/DealerManageSubsidyLogController.php @@ -20,6 +20,7 @@ class DealerManageSubsidyLogController extends AdminController { $builder = DealerManageSubsidyLog::with(['user', 'order', 'product']); return Grid::make($builder, function (Grid $grid) { + $grid->model()->orderBy('id', 'desc');//默认ID倒叙 $grid->column('id')->sortable(); $grid->column('user.phone', '手机号')->copyable(); $grid->column('lvl', '等级')->display(function () { diff --git a/app/Admin/Controllers/DealerManagerSalesLogController.php b/app/Admin/Controllers/DealerManagerSalesLogController.php index c6b477e2..8adad075 100644 --- a/app/Admin/Controllers/DealerManagerSalesLogController.php +++ b/app/Admin/Controllers/DealerManagerSalesLogController.php @@ -21,6 +21,7 @@ class DealerManagerSalesLogController extends AdminController { $builder = DealerManagerSalesLog::with(['user', 'order', 'product']); return Grid::make($builder, function (Grid $grid) { + $grid->model()->orderBy('id', 'desc');//默认ID倒叙 $grid->column('id')->sortable(); $grid->column('user.phone', '手机号')->copyable(); $grid->column('lvl', '等级')->display(function () { diff --git a/app/Admin/Controllers/DealerPurchaseLogController.php b/app/Admin/Controllers/DealerPurchaseLogController.php index bf060cd1..e083b976 100644 --- a/app/Admin/Controllers/DealerPurchaseLogController.php +++ b/app/Admin/Controllers/DealerPurchaseLogController.php @@ -28,6 +28,7 @@ class DealerPurchaseLogController extends AdminController $user = User::where('phone', $phone)->first(); $grid->model()->where('path', 'like', '%-'.$user->id.'-%'); } + $grid->model()->orderBy('id', 'desc');//默认ID倒叙 $grid->column('id')->sortable(); $grid->column('user.phone', '手机号')->copyable(); $grid->column('lvl', '等级')->display(function () { From 1cd6aa665636fa310c6a28f72f58de377786db9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=9D=99?= Date: Fri, 25 Feb 2022 11:30:51 +0800 Subject: [PATCH 11/39] =?UTF-8?q?=E5=BE=AE=E4=BF=A1=E6=94=AF=E4=BB=98?= =?UTF-8?q?=E8=B0=83=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Http/Controllers/WxpayController.php | 111 ++++++++++++++++++ app/Endpoint/Callback/routes.php | 3 +- app/Enums/PayWay.php | 2 +- app/Services/OrderService.php | 37 ++++-- app/Services/Payment/WxpayService.php | 108 +++++++++++++++++ 5 files changed, 246 insertions(+), 15 deletions(-) create mode 100644 app/Endpoint/Callback/Http/Controllers/WxpayController.php create mode 100644 app/Services/Payment/WxpayService.php diff --git a/app/Endpoint/Callback/Http/Controllers/WxpayController.php b/app/Endpoint/Callback/Http/Controllers/WxpayController.php new file mode 100644 index 00000000..50e582e1 --- /dev/null +++ b/app/Endpoint/Callback/Http/Controllers/WxpayController.php @@ -0,0 +1,111 @@ +payment()->handlePaidNotify(function ($message, $fail) use ($request) { + $this->log('paid notify--------'.$request->url(), $message); + + // 通信失败 + if (data_get($message, 'return_code') !== 'SUCCESS') { + return $fail('通信失败'); + } + + try { + $payLog = DB::transaction(function () use ($message) { + $payService = new PayService(); + + if (data_get($message, 'result_code') === 'SUCCESS') { + return $payService->handleSuccessByPaySerialNumber($message['out_trade_no'], [ + 'out_trade_no' => $message['transaction_id'], + 'pay_at' => Carbon::parse($message['time_end']), + ]); + } elseif (data_get($message, 'result_code') === 'FAIL') { + return $payService->handleFailedByPaySerialNumber($message['out_trade_no'], [ + 'out_trade_no' => $message['transaction_id'] ?? null, + 'failed_reason' => '['.$message['err_code'].']'.$message['err_code_des'], + ]); + } + }); + + $payable = $payLog?->payable; + + if ($payable instanceof Order) { + OrderPaid::dispatchIf($payable->isPaid(), $payable); + } + } catch (ModelNotFoundException | BizException $e) { + } catch (Throwable $e) { + throw $e; + } + + return true; + }); + } + + /** + * 订单退款结果通知 + * + * @param \App\Services\Payment\WxpayService $wxpayService + * @return \Illuminate\Http\Response + */ + public function orderRefundedNotify(WxpayService $wxpayService) + { + return $wxpayService->payment()->handleRefundedNotify(function ($message, $reqInfo, $fail) { + $this->log('refund notify', $reqInfo); + + // 通信失败 + if (data_get($message, 'return_code') !== 'SUCCESS') { + return $fail('通信失败'); + } + + // 退款失败 + if ($reqInfo['refund_status'] !== 'SUCCESS') { + $log = OrderRefundLog::where('sn', $reqInfo['out_refund_no'])->first(); + + $log?->update([ + 'status' => OrderRefundLog::STATUS_FAILED, + 'failed_reason' => $reqInfo['refund_status'] === 'CHANGE' ? '退款异常' : '退款关闭', + ]); + } + + return true; + }); + } + + /** + * 微信回调日志 + * + * @param string $message + * @param array $context + * @return void + */ + protected function log(string $message, array $context = []) + { + return Log::build([ + 'driver' => 'daily', + 'path' => storage_path('logs/wxpay-notify.log'), + ])->info($message, $context); + } +} diff --git a/app/Endpoint/Callback/routes.php b/app/Endpoint/Callback/routes.php index 871c05c5..d7958851 100644 --- a/app/Endpoint/Callback/routes.php +++ b/app/Endpoint/Callback/routes.php @@ -3,13 +3,14 @@ use App\Endpoint\Callback\Http\Controllers\AlipayController; use App\Endpoint\Callback\Http\Controllers\Kuaidi100Controller; use App\Endpoint\Callback\Http\Controllers\WeChatPayController; +use App\Endpoint\Callback\Http\Controllers\WxpayController; use App\Endpoint\Callback\Http\Controllers\YzkWeChatPayController; use Illuminate\Support\Facades\Route; //快递100物流推送 Route::post('kuaidi100', [Kuaidi100Controller::class, 'notify']); // 微信支付通知 -Route::post('wxpay/paid-notify', [WeChatPayController::class, 'paidNotify'])->name('wxpay.paid_notify'); +Route::post('wxpay/paid-notify', [WxpayController::class, 'paidNotify'])->name('wxpay.paid_notify'); Route::post('wxpay/order-refund-notify', [WeChatPayController::class, 'orderRefundedNotify'])->name('wxpay.order_refund_notify'); Route::post('alipay', AlipayController::class)->name('alipay.notify'); diff --git a/app/Enums/PayWay.php b/app/Enums/PayWay.php index 27eab37b..ed1f60cf 100644 --- a/app/Enums/PayWay.php +++ b/app/Enums/PayWay.php @@ -10,7 +10,7 @@ enum PayWay: string { case WxpayApp = 'wxpay_app'; case WxpayH5 = 'wxpay_h5'; case WxpayJs = 'wxpay_jsapi'; - case WxpayMp = 'wxpay_mini_program'; + case WxpayMp = 'wxpay_mp'; // 阿里支付 case AlipayApp = 'alipay_app'; diff --git a/app/Services/OrderService.php b/app/Services/OrderService.php index 58bcb29c..c5544955 100644 --- a/app/Services/OrderService.php +++ b/app/Services/OrderService.php @@ -17,6 +17,7 @@ use App\Models\ProductSku; use App\Models\ShippingAddress; use App\Models\User; use App\Models\UserCoupon; +use App\Services\Payment\WxpayService; use Illuminate\Database\QueryException; use Illuminate\Support\Facades\DB; @@ -780,40 +781,50 @@ class OrderService } } while ($payLog === null); - $data = [ - 'pay_sn' => $payLog->pay_sn, - ]; - // 如果支付方式为线下支付,或支付金额为 0,则按支付完成处理 if ($order->total_amount === 0 || $payLog->isOffline()) { (new PayService())->handleSuccess($payLog, [ 'pay_at' => now(), ]); - $data = null; + return [ + 'pay_sn' => $payLog->pay_sn, + 'data' => null, + ]; } elseif ($payLog->isWxpay()) { if (is_null($tradeType = WxpayTradeType::tryFromPayWay($payLog->pay_way))) { throw new BizException('支付方式 非法'); } - $data = (new WeChatPayService())->pay([ + $params = [ 'body' => app_settings('app.app_name').'-商城订单', 'out_trade_no' => $payLog->pay_sn, 'total_fee' => $order->total_amount, 'trade_type' => $tradeType->value, - ]); + ]; + + if ($tradeType === WxpayTradeType::JSAPI) { + $params['openid'] = 'o-BdO46p2hRnk-SQIXa1TEdBFtfs'; + } + + return [ + 'pay_sn' => $payLog->pay_sn, + 'data' => (new WxpayService())->pay($params), + ]; } elseif ($payLog->isAlipay()) { - $data = app(AlipayService::class)->pay([ + $params = [ 'subject' => app_settings('app.app_name').'-商城订单', 'out_trade_no' => $payLog->pay_sn, 'total_amount' => bcdiv($order->total_amount, 100, 2), - ]); + ]; + + return [ + 'pay_sn' => $payLog->pay_sn, + 'data' => app(AlipayService::class)->pay($params), + ]; } - return [ - 'pay_way' => $payLog->pay_way, - 'data' => $data, - ]; + throw new BizException('【-1】支付方式 非法'); } /** diff --git a/app/Services/Payment/WxpayService.php b/app/Services/Payment/WxpayService.php new file mode 100644 index 00000000..b9639e12 --- /dev/null +++ b/app/Services/Payment/WxpayService.php @@ -0,0 +1,108 @@ + + */ + protected $payments = []; + + /** + * 支付 + * + * @param array $params + * @return array + */ + public function pay(array $params, string $paymentName = null): array + { + if (! isset($params['notify_url'])) { + $params['notify_url'] = url(route('wxpay.paid_notify', ['payment' => $paymentName], false), [], true); + } + + if (! isset($params['trade_type'])) { + $params['trade_type'] = WxpayTradeType::App->value; + } + + $app = $this->payment($paymentName); + + $result = $app->order->unify($params); + + $this->validateResult($result, $params); + + return match ($params['trade_type']) { + PayWay::WxpayApp => $app->jssdk->appConfig($result['prepay_id']), + PayWay::WxpayH5 => Arr::only($result, ['mweb_url']), + default => $app->jssdk->bridgeConfig($result['prepay_id'], false), + }; + } + + /** + * @param string|null $name + * @return \EasyWeChat\Payment\Application + */ + public function payment(?string $name = null): Application + { + $name = $name ?: 'default'; + + return $this->payments[$name] = $this->get($name); + } + + /** + * @param string $name + * @return \EasyWeChat\Payment\Application + */ + protected function get(string $name): Application + { + return $this->payments[$name] ?? $this->resolve($name); + } + + /** + * @param string $name + * @return \EasyWeChat\Payment\Application + * + * @throws \App\Exceptions\WeChatPayException + */ + protected function resolve(string $name): Application + { + $config = config("wechat.payment.{$name}"); + + if (empty($config)) { + throw new WeChatPayException("支付 [{$name}] 配置未找到"); + } + + return Factory::payment($config); + } + + /** + * 校验响应结果 + * + * @param array $result + * @param array $raw + * @return void + * + * @throws \App\Exceptions\WeChatPayException + */ + protected function validateResult(array $result, array $raw = []) + { + if (Arr::get($result, 'return_code') !== 'SUCCESS') { + throw new WeChatPayException(Arr::get($result, 'return_msg', '请求失败'), $raw); + } + + if (Arr::get($result, 'result_code') !== 'SUCCESS') { + throw new WeChatPayException(sprintf( + '[%s] %s', + Arr::get($result, 'err_code', '-1'), + Arr::get($result, 'err_code_des', '结果异常') + ), $raw); + } + } +} From fbc83e39befccb807c1e2091badc68037074846c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=9D=99?= Date: Fri, 25 Feb 2022 11:31:20 +0800 Subject: [PATCH 12/39] Update --- deploy/config/deploy/staging.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deploy/config/deploy/staging.rb b/deploy/config/deploy/staging.rb index fcb531bf..59323fec 100644 --- a/deploy/config/deploy/staging.rb +++ b/deploy/config/deploy/staging.rb @@ -32,7 +32,7 @@ server "47.108.227.246", user: "deployer", roles: %w{admin supervisor} # http://capistranorb.com/documentation/getting-started/configuration/ # Feel free to add new variables to customise your setup. -set :branch, "develop" +set :branch, "1.x" set :deploy_to, "/www/wwwroot/test.zichunsheng.cn" From c23be217f4372ef91993f0d65b72076cbfd70f6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=9D=99?= Date: Fri, 25 Feb 2022 11:39:44 +0800 Subject: [PATCH 13/39] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=BE=AE=E4=BF=A1?= =?UTF-8?q?=E6=94=AF=E4=BB=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Services/Payment/WxpayService.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/Services/Payment/WxpayService.php b/app/Services/Payment/WxpayService.php index b9639e12..3ea9f928 100644 --- a/app/Services/Payment/WxpayService.php +++ b/app/Services/Payment/WxpayService.php @@ -2,7 +2,6 @@ namespace App\Services\Payment; -use App\Enums\PayWay; use App\Enums\WxpayTradeType; use App\Exceptions\WeChatPayException; use EasyWeChat\Factory; @@ -39,8 +38,8 @@ class WxpayService $this->validateResult($result, $params); return match ($params['trade_type']) { - PayWay::WxpayApp => $app->jssdk->appConfig($result['prepay_id']), - PayWay::WxpayH5 => Arr::only($result, ['mweb_url']), + WxpayTradeType::App->value => $app->jssdk->appConfig($result['prepay_id']), + WxpayTradeType::H5->value => Arr::only($result, ['mweb_url']), default => $app->jssdk->bridgeConfig($result['prepay_id'], false), }; } From f5cbf6a6387522361d11c1304e4001dfedab36fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=9D=99?= Date: Fri, 25 Feb 2022 13:45:12 +0800 Subject: [PATCH 14/39] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=94=AF=E4=BB=98?= =?UTF-8?q?=E6=96=B9=E5=BC=8F=E6=9E=9A=E4=B8=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Enums/PayWay.php | 10 +++++----- app/Enums/WxpayTradeType.php | 2 +- app/Models/PayLog.php | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/Enums/PayWay.php b/app/Enums/PayWay.php index ed1f60cf..51ed79c9 100644 --- a/app/Enums/PayWay.php +++ b/app/Enums/PayWay.php @@ -9,8 +9,8 @@ enum PayWay: string { // 微信支付 case WxpayApp = 'wxpay_app'; case WxpayH5 = 'wxpay_h5'; - case WxpayJs = 'wxpay_jsapi'; - case WxpayMp = 'wxpay_mp'; + case WxpayJsApi = 'wxpay_jsapi'; + case WxpayMiniProgram = 'wxpay_mp'; // 阿里支付 case AlipayApp = 'alipay_app'; @@ -20,7 +20,7 @@ enum PayWay: string { static::Offline => '#5b69bc', static::Balance => '#dda451', static::Wallet => '#ff8acc', - static::WxpayApp, static::WxpayH5, static::WxpayJs, static::WxpayMp => '#21b978', + static::WxpayApp, static::WxpayH5, static::WxpayJsApi, static::WxpayMiniProgram => '#21b978', static::AlipayApp => '#3085d6', default => '#ea5455', }; @@ -32,7 +32,7 @@ enum PayWay: string { static::Offline => 'offline', static::Balance => 'balance', static::Wallet => 'wallet', - static::WxpayApp, static::WxpayH5, static::WxpayJs, static::WxpayMp => 'wxpay', + static::WxpayApp, static::WxpayH5, static::WxpayJsApi, static::WxpayMiniProgram => 'wxpay', static::AlipayApp => 'alipay', }; } @@ -43,7 +43,7 @@ enum PayWay: string { static::Offline => '线下', static::Balance => '余额', static::Wallet => '可提', - static::WxpayApp, static::WxpayH5, static::WxpayJs, static::WxpayMp => '微信支付', + static::WxpayApp, static::WxpayH5, static::WxpayJsApi, static::WxpayMiniProgram => '微信支付', static::AlipayApp => '支付宝', default => 'Unknown', }; diff --git a/app/Enums/WxpayTradeType.php b/app/Enums/WxpayTradeType.php index 78c6a8c8..22da0570 100644 --- a/app/Enums/WxpayTradeType.php +++ b/app/Enums/WxpayTradeType.php @@ -18,7 +18,7 @@ enum WxpayTradeType: string { return match ($payWay) { PayWay::WxpayApp => static::App, PayWay::WxpayH5 => static::H5, - PayWay::WxpayJs, PayWay::WxpayMp => static::JSAPI, + PayWay::WxpayJsApi, PayWay::WxpayMiniProgram => static::JSAPI, default => null, }; } diff --git a/app/Models/PayLog.php b/app/Models/PayLog.php index 3f0b269e..8d4bda76 100644 --- a/app/Models/PayLog.php +++ b/app/Models/PayLog.php @@ -66,9 +66,9 @@ class PayLog extends Model { return in_array($this->pay_way, [ PayWay::WxpayApp, - PayWay::WxpayJs, + PayWay::WxpayJsApi, PayWay::WxpayH5, - PayWay::WxpayMp, + PayWay::WxpayMiniProgram, ]); } From 50233736c6439384d69a31c09498f5702d12894a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=9D=99?= Date: Fri, 25 Feb 2022 15:05:31 +0800 Subject: [PATCH 15/39] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=BE=AE=E4=BF=A1?= =?UTF-8?q?=E6=94=AF=E4=BB=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Console/Commands/OrderRefundCommand.php | 33 ++-- .../Auth/SocialiteAuthController.php | 3 +- .../Http/Controllers/WeChatPayController.php | 110 ----------- .../Http/Controllers/WxpayController.php | 29 +-- .../Controllers/YzkWeChatPayController.php | 73 -------- app/Endpoint/Callback/routes.php | 9 +- app/Enums/SocialiteType.php | 7 + app/Models/User.php | 5 + app/Services/Dealer/OrderService.php | 13 +- app/Services/OrderService.php | 42 +++-- app/Services/Payment/WxpayService.php | 50 ++++- app/Services/WeChatPayService.php | 172 ------------------ config/wechat.php | 25 ++- 13 files changed, 148 insertions(+), 423 deletions(-) delete mode 100644 app/Endpoint/Callback/Http/Controllers/WeChatPayController.php delete mode 100644 app/Endpoint/Callback/Http/Controllers/YzkWeChatPayController.php create mode 100644 app/Enums/SocialiteType.php delete mode 100644 app/Services/WeChatPayService.php diff --git a/app/Console/Commands/OrderRefundCommand.php b/app/Console/Commands/OrderRefundCommand.php index 14457001..92614003 100644 --- a/app/Console/Commands/OrderRefundCommand.php +++ b/app/Console/Commands/OrderRefundCommand.php @@ -2,14 +2,15 @@ namespace App\Console\Commands; +use App\Enums\PayWay; use App\Exceptions\BizException; use App\Models\BalanceLog; use App\Models\OrderRefundLog; use App\Models\WalletLog; use App\Services\AlipayService; use App\Services\BalanceService; +use App\Services\Payment\WxpayService; use App\Services\WalletService; -use App\Services\WeChatPayService; use Illuminate\Console\Command; use Illuminate\Support\Str; use Throwable; @@ -43,7 +44,11 @@ class OrderRefundCommand extends Command OrderRefundLog::pending()->chunkById(200, function ($logs) use (&$page) { foreach ($logs as $log) { try { - $method = 'refundBy'.Str::studly($log->order->pay_way->value); + $method = match ($log->order->pay_way) { + PayWay::WxpayApp, PayWay::WxpayH5, PayWay::WxpayJsApi, PayWay::WxpayMiniProgram => 'refundByWxpay', + PayWay::AlipayApp => 'refundByAlipay', + default => 'refundBy'.Str::studly($log->order->pay_way->value), + }; if (! method_exists($this, $method)) { throw new BizException('退款方式暂不支持'); @@ -79,20 +84,22 @@ class OrderRefundCommand extends Command * @param \App\Models\OrderRefundLog $log * @return void */ - protected function refundByWxpayApp(OrderRefundLog $log) + protected function refundByWxpay(OrderRefundLog $log) { $order = $log->order; - (new WeChatPayService())->refundByOutTradeNumber( - $order->pay_sn, - $log->sn, - $order->total_amount, - $log->amount, - [ + (new WxpayService())->refundByOutTradeNumber([ + 'number' => $order->pay_sn, + 'refund_number' => $log->sn, + 'total_fee' => $order->total_amount, + 'refund_fee' => $log->amount, + 'optional' => [ 'refund_desc' => $log->reason, - 'notify_url' => url(route('wxpay.order_refund_notify', [], false), [], true), - ] - ); + ], + ], match ($order->pay_way) { + PayWay::WxpayMiniProgram => 'mini_program', + default => 'default', + }); $log->update([ 'status' => OrderRefundLog::STATUS_SUCCESS, @@ -106,7 +113,7 @@ class OrderRefundCommand extends Command * @param \App\Models\OrderRefundLog $log * @return void */ - protected function refundByAlipayApp(OrderRefundLog $log) + protected function refundByAlipay(OrderRefundLog $log) { $order = $log->order; diff --git a/app/Endpoint/Api/Http/Controllers/Auth/SocialiteAuthController.php b/app/Endpoint/Api/Http/Controllers/Auth/SocialiteAuthController.php index e1caa91f..19d6a5c7 100644 --- a/app/Endpoint/Api/Http/Controllers/Auth/SocialiteAuthController.php +++ b/app/Endpoint/Api/Http/Controllers/Auth/SocialiteAuthController.php @@ -4,6 +4,7 @@ namespace App\Endpoint\Api\Http\Controllers\Auth; use App\Constants\Device; use App\Endpoint\Api\Http\Controllers\Controller; +use App\Enums\SocialiteType; use App\Exceptions\BizException; use App\Helpers\PhoneNumber; use App\Models\SmsCode; @@ -135,7 +136,7 @@ class SocialiteAuthController extends Controller $config = config('socialite', []); $socialite = new SocialiteManager($config); switch ($provider) { - case 'wechat-mini'://微信小程序 + case SocialiteType::WechatMiniProgram://微信小程序 $user = $socialite->create('wehcat-mini')->userFromCode($code); break; default: diff --git a/app/Endpoint/Callback/Http/Controllers/WeChatPayController.php b/app/Endpoint/Callback/Http/Controllers/WeChatPayController.php deleted file mode 100644 index 336806cf..00000000 --- a/app/Endpoint/Callback/Http/Controllers/WeChatPayController.php +++ /dev/null @@ -1,110 +0,0 @@ -handlePaidNotify(function ($message, $fail) { - $this->log('paid notify', $message); - - // 通信失败 - if (data_get($message, 'return_code') !== 'SUCCESS') { - return $fail('通信失败'); - } - - try { - $payLog = DB::transaction(function () use ($message) { - $payService = new PayService(); - - if (data_get($message, 'result_code') === 'SUCCESS') { - return $payService->handleSuccessByPaySerialNumber($message['out_trade_no'], [ - 'out_trade_no' => $message['transaction_id'], - 'pay_at' => Carbon::parse($message['time_end']), - ]); - } elseif (data_get($message, 'result_code') === 'FAIL') { - return $payService->handleFailedByPaySerialNumber($message['out_trade_no'], [ - 'out_trade_no' => $message['transaction_id'] ?? null, - 'failed_reason' => '['.$message['err_code'].']'.$message['err_code_des'], - ]); - } - }); - - $payable = $payLog?->payable; - - if ($payable instanceof Order) { - OrderPaid::dispatchIf($payable->isPaid(), $payable); - } - } catch (ModelNotFoundException | BizException $e) { - } catch (Throwable $e) { - throw $e; - } - - return true; - }); - } - - /** - * 订单退款结果通知 - * - * @param \App\Services\WeChatPayService $weChatPayService - * @return \Illuminate\Http\Response - */ - public function orderRefundedNotify(WeChatPayService $weChatPayService) - { - return $weChatPayService->handleRefundedNotify(function ($message, $reqInfo, $fail) { - $this->log('refund notify', $reqInfo); - - // 通信失败 - if (data_get($message, 'return_code') !== 'SUCCESS') { - return $fail('通信失败'); - } - - // 退款失败 - if ($reqInfo['refund_status'] !== 'SUCCESS') { - $log = OrderRefundLog::where('sn', $reqInfo['out_refund_no'])->first(); - - $log?->update([ - 'status' => OrderRefundLog::STATUS_FAILED, - 'failed_reason' => $reqInfo['refund_status'] === 'CHANGE' ? '退款异常' : '退款关闭', - ]); - } - - return true; - }); - } - - /** - * 微信回调日志 - * - * @param string $message - * @param array $context - * @return void - */ - protected function log(string $message, array $context = []) - { - return Log::build([ - 'driver' => 'daily', - 'path' => storage_path('logs/wxpay-notify.log'), - ])->info($message, $context); - } -} diff --git a/app/Endpoint/Callback/Http/Controllers/WxpayController.php b/app/Endpoint/Callback/Http/Controllers/WxpayController.php index 50e582e1..62e610da 100644 --- a/app/Endpoint/Callback/Http/Controllers/WxpayController.php +++ b/app/Endpoint/Callback/Http/Controllers/WxpayController.php @@ -9,10 +9,8 @@ use App\Models\OrderRefundLog; use App\Services\Payment\WxpayService; use App\Services\PayService; use Illuminate\Database\Eloquent\ModelNotFoundException; -use Illuminate\Http\Request; use Illuminate\Support\Carbon; use Illuminate\Support\Facades\DB; -use Illuminate\Support\Facades\Log; use Throwable; class WxpayController extends Controller @@ -20,13 +18,14 @@ class WxpayController extends Controller /** * 支付结果通知 * + * @param string $payment * @param \App\Services\Payment\WxpayService $wxpayService * @return \Illuminate\Http\Response */ - public function paidNotify(WxpayService $wxpayService, Request $request) + public function paidNotify($payment, WxpayService $wxpayService) { - return $wxpayService->payment()->handlePaidNotify(function ($message, $fail) use ($request) { - $this->log('paid notify--------'.$request->url(), $message); + return $wxpayService->payment($payment)->handlePaidNotify(function ($message, $fail) { + $this->log('paid notify', $message); // 通信失败 if (data_get($message, 'return_code') !== 'SUCCESS') { @@ -67,12 +66,13 @@ class WxpayController extends Controller /** * 订单退款结果通知 * + * @param string $payment * @param \App\Services\Payment\WxpayService $wxpayService * @return \Illuminate\Http\Response */ - public function orderRefundedNotify(WxpayService $wxpayService) + public function orderRefundedNotify($payment, WxpayService $wxpayService) { - return $wxpayService->payment()->handleRefundedNotify(function ($message, $reqInfo, $fail) { + return $wxpayService->payment($payment)->handleRefundedNotify(function ($message, $reqInfo, $fail) { $this->log('refund notify', $reqInfo); // 通信失败 @@ -93,19 +93,4 @@ class WxpayController extends Controller return true; }); } - - /** - * 微信回调日志 - * - * @param string $message - * @param array $context - * @return void - */ - protected function log(string $message, array $context = []) - { - return Log::build([ - 'driver' => 'daily', - 'path' => storage_path('logs/wxpay-notify.log'), - ])->info($message, $context); - } } diff --git a/app/Endpoint/Callback/Http/Controllers/YzkWeChatPayController.php b/app/Endpoint/Callback/Http/Controllers/YzkWeChatPayController.php deleted file mode 100644 index ca5387d4..00000000 --- a/app/Endpoint/Callback/Http/Controllers/YzkWeChatPayController.php +++ /dev/null @@ -1,73 +0,0 @@ -handlePaidNotify(function ($message, $fail) { - $this->log('paid notify', $message); - - // 通信失败 - if (data_get($message, 'return_code') !== 'SUCCESS') { - return $fail('通信失败'); - } - - try { - DB::transaction(function () use ($message) { - $payService = new PayService(); - - if (data_get($message, 'result_code') === 'SUCCESS') { - return $payService->handleSuccessByPaySerialNumber($message['out_trade_no'], [ - 'out_trade_no' => $message['transaction_id'], - 'pay_at' => Carbon::parse($message['time_end']), - ]); - } elseif (data_get($message, 'result_code') === 'FAIL') { - return $payService->handleFailedByPaySerialNumber($message['out_trade_no'], [ - 'out_trade_no' => $message['transaction_id'] ?? null, - 'failed_reason' => '['.$message['err_code'].']'.$message['err_code_des'], - ]); - } - }); - } catch (ModelNotFoundException | BizException $e) { - } catch (Throwable $e) { - throw $e; - } - - return true; - }); - } - - /** - * 微信回调日志 - * - * @param string $message - * @param array $context - * @return void - */ - protected function log(string $message, array $context = []) - { - return Log::build([ - 'driver' => 'daily', - 'path' => storage_path('logs/yzk-wxpay-notify.log'), - ])->info($message, $context); - } -} diff --git a/app/Endpoint/Callback/routes.php b/app/Endpoint/Callback/routes.php index d7958851..26c68d31 100644 --- a/app/Endpoint/Callback/routes.php +++ b/app/Endpoint/Callback/routes.php @@ -2,17 +2,14 @@ use App\Endpoint\Callback\Http\Controllers\AlipayController; use App\Endpoint\Callback\Http\Controllers\Kuaidi100Controller; -use App\Endpoint\Callback\Http\Controllers\WeChatPayController; use App\Endpoint\Callback\Http\Controllers\WxpayController; -use App\Endpoint\Callback\Http\Controllers\YzkWeChatPayController; use Illuminate\Support\Facades\Route; //快递100物流推送 Route::post('kuaidi100', [Kuaidi100Controller::class, 'notify']); + // 微信支付通知 -Route::post('wxpay/paid-notify', [WxpayController::class, 'paidNotify'])->name('wxpay.paid_notify'); -Route::post('wxpay/order-refund-notify', [WeChatPayController::class, 'orderRefundedNotify'])->name('wxpay.order_refund_notify'); +Route::post('wxpay/{payment}/paid-notify', [WxpayController::class, 'paidNotify'])->name('wxpay.paid_notify'); +Route::post('wxpay/order-refund-notify', [WxpayController::class, 'orderRefundedNotify'])->name('wxpay.order_refund_notify'); Route::post('alipay', AlipayController::class)->name('alipay.notify'); - -Route::post('yzk-wxpay/paid-notify', [YzkWeChatPayController::class, 'paidNotify'])->name('yzk_wxpay.paid_notify'); diff --git a/app/Enums/SocialiteType.php b/app/Enums/SocialiteType.php new file mode 100644 index 00000000..e404f5f2 --- /dev/null +++ b/app/Enums/SocialiteType.php @@ -0,0 +1,7 @@ +hasMany(DealerUserProductLog::class, 'user_id'); } + public function socialites() + { + return $this->hasMany(SocialiteUser::class, 'user_id'); + } + /** * 确认此用户是否是 VIP * diff --git a/app/Services/Dealer/OrderService.php b/app/Services/Dealer/OrderService.php index 4ddbba4c..558b586e 100644 --- a/app/Services/Dealer/OrderService.php +++ b/app/Services/Dealer/OrderService.php @@ -15,9 +15,8 @@ use App\Models\DealerProduct; use App\Models\DealerUserProductLog; use App\Models\ShippingAddress; use App\Models\User; +use App\Services\Payment\WxpayService; use App\Services\PayService; -use App\Services\WeChatPayService; -use EasyWeChat\Factory as EasyWeChatFactory; use Illuminate\Database\QueryException; class OrderService @@ -351,15 +350,15 @@ class OrderService throw new BizException('支付方式 非法'); } - $app = EasyWeChatFactory::payment(config('wechat.payment.yzk')); - - $data = (new WeChatPayService($app))->pay([ + $params = [ 'body' => app_settings('app.app_name').'-批零订单', 'out_trade_no' => $payLog->pay_sn, 'total_fee' => bcmul($order->total_amount, '100'), 'trade_type' => $tradeType->value, - 'notify_url' => url(route('yzk_wxpay.paid_notify', [], false), [], true), - ]); + ]; + + $data = (new WxpayService())->pay($params, 'yzk_h5'); + break; default: diff --git a/app/Services/OrderService.php b/app/Services/OrderService.php index c5544955..99fa04cf 100644 --- a/app/Services/OrderService.php +++ b/app/Services/OrderService.php @@ -6,6 +6,7 @@ use App\Endpoint\Api\Http\Resources\ProductSkuSimpleResource; use App\Endpoint\Api\Http\Resources\ShippingAddressResource; use App\Endpoint\Api\Http\Resources\UserCouponResource; use App\Enums\PayWay; +use App\Enums\SocialiteType; use App\Enums\WxpayTradeType; use App\Exceptions\BizException; use App\Exceptions\ShippingNotSupportedException; @@ -15,6 +16,7 @@ use App\Models\OrderProduct; use App\Models\ProductGift; use App\Models\ProductSku; use App\Models\ShippingAddress; +use App\Models\SocialiteUser; use App\Models\User; use App\Models\UserCoupon; use App\Services\Payment\WxpayService; @@ -781,16 +783,17 @@ class OrderService } } while ($payLog === null); + $data = [ + 'pay_sn' => $payLog->pay_sn, + ]; + // 如果支付方式为线下支付,或支付金额为 0,则按支付完成处理 if ($order->total_amount === 0 || $payLog->isOffline()) { (new PayService())->handleSuccess($payLog, [ 'pay_at' => now(), ]); - return [ - 'pay_sn' => $payLog->pay_sn, - 'data' => null, - ]; + $data = null; } elseif ($payLog->isWxpay()) { if (is_null($tradeType = WxpayTradeType::tryFromPayWay($payLog->pay_way))) { throw new BizException('支付方式 非法'); @@ -804,13 +807,24 @@ class OrderService ]; if ($tradeType === WxpayTradeType::JSAPI) { - $params['openid'] = 'o-BdO46p2hRnk-SQIXa1TEdBFtfs'; + $socialite = match ($payLog->pay_way) { + PayWay::WxpayMiniProgram => SocialiteUser::where([ + 'user_id' => $order->user_id, + 'socialite_type' => SocialiteType::WechatMiniProgram, + ])->first(), + }; + + if ($socialite === null) { + throw new BizException('未绑定微信小程序'); + } + + $params['openid'] = $socialite->socialite_id; } - return [ - 'pay_sn' => $payLog->pay_sn, - 'data' => (new WxpayService())->pay($params), - ]; + $data = (new WxpayService())->pay($params, match ($payLog->pay_way) { + PayWay::WxpayMiniProgram => 'mini_program', + default => 'default', + }); } elseif ($payLog->isAlipay()) { $params = [ 'subject' => app_settings('app.app_name').'-商城订单', @@ -818,13 +832,13 @@ class OrderService 'total_amount' => bcdiv($order->total_amount, 100, 2), ]; - return [ - 'pay_sn' => $payLog->pay_sn, - 'data' => app(AlipayService::class)->pay($params), - ]; + $data = app(AlipayService::class)->pay($params); } - throw new BizException('【-1】支付方式 非法'); + return [ + 'pay_way' => $payLog->pay_way, + 'data' => $data, + ]; } /** diff --git a/app/Services/Payment/WxpayService.php b/app/Services/Payment/WxpayService.php index 3ea9f928..7b6de61f 100644 --- a/app/Services/Payment/WxpayService.php +++ b/app/Services/Payment/WxpayService.php @@ -19,19 +19,22 @@ class WxpayService * 支付 * * @param array $params + * @param string|null $payment * @return array */ - public function pay(array $params, string $paymentName = null): array + public function pay(array $params, ?string $payment = null): array { if (! isset($params['notify_url'])) { - $params['notify_url'] = url(route('wxpay.paid_notify', ['payment' => $paymentName], false), [], true); + $path = route('wxpay.paid_notify', ['payment' => $payment ?: 'default'], false); + + $params['notify_url'] = url($path, [], true); } if (! isset($params['trade_type'])) { $params['trade_type'] = WxpayTradeType::App->value; } - $app = $this->payment($paymentName); + $app = $this->payment($payment); $result = $app->order->unify($params); @@ -44,6 +47,45 @@ class WxpayService }; } + /** + * 根据商户订单号退款 + * + * @param string $number + * @param string $refundNumber + * @param int $totalFee + * @param int $refundFee + * @param array $optional + * @return array + */ + public function refundByOutTradeNumber(array $params, ?string $payment = null) + { + $optional = Arr::get($params, 'optional', []); + + if (! is_array($optional)) { + $optional = []; + } + + if (! isset($optional['notify_url'])) { + $path = route('wxpay.order_refund_notify', [ + 'payment' => $payment ?: 'default', + ], false); + + $optional['notify_url'] = url($path, [], true); + } + + $result = $this->payment($payment)->refund->byOutTradeNumber( + $params['number'], + $params['refund_number'], + $params['total_fee'], + $params['refund_fee'], + $optional, + ); + + $this->validateResult($result, $params); + + return $result; + } + /** * @param string|null $name * @return \EasyWeChat\Payment\Application @@ -100,7 +142,7 @@ class WxpayService throw new WeChatPayException(sprintf( '[%s] %s', Arr::get($result, 'err_code', '-1'), - Arr::get($result, 'err_code_des', '结果异常') + Arr::get($result, 'err_code_des', '交易失败') ), $raw); } } diff --git a/app/Services/WeChatPayService.php b/app/Services/WeChatPayService.php deleted file mode 100644 index 978432d1..00000000 --- a/app/Services/WeChatPayService.php +++ /dev/null @@ -1,172 +0,0 @@ -app = $app; - } - - /** - * 支付 - * - * @param array $params - * @return array - * - * @throws \App\Exceptions\WeChatPayException - */ - public function pay(array $params) - { - if (! isset($params['notify_url'])) { - $params['notify_url'] = url(route('wxpay.paid_notify', [], false), [], true); - } - - // 如果交易类型不存在,则使用 App 支付 - if (! isset($params['trade_type'])) { - $params['trade_type'] = static::TRADE_TYPE_APP; - } - - $result = $this->app->order->unify($params); - - if (data_get($result, 'return_code') !== 'SUCCESS') { - throw new WeChatPayException( - data_get($result, 'return_msg', '请求失败'), - $params - ); - } - - if (data_get($result, 'result_code') !== 'SUCCESS') { - throw new WeChatPayException( - sprintf( - '[%s] %s', - data_get($result, 'err_code', '-1'), - data_get($result, 'err_code_des', '交易失败') - ), - $params - ); - } - - return match ($params['trade_type']) { - static::TRADE_TYPE_APP => $this->app->jssdk->appConfig($result['prepay_id']), - static::TRADE_TYPE_H5 => Arr::only($result, ['mweb_url']), - default => $this->app->jssdk->bridgeConfig($result['prepay_id'], false), - }; - } - - /** - * 支付结果通知 - * - * @param \Closure $closure - * @return \Symfony\Component\HttpFoundation\Response - */ - public function handlePaidNotify(Closure $closure) - { - return $this->app->handlePaidNotify($closure); - } - - /** - * 根据微信订单号退款 - * - * @param string $transactionId - * @param string $refundNumber - * @param int $totalFee - * @param int $refundFee - * @param array $optional - * @return array - */ - public function refundByTransactionId(string $transactionId, string $refundNumber, int $totalFee, int $refundFee, array $optional = []) - { - $result = $this->app->refund->byTransactionId($transactionId, $refundNumber, $totalFee, $refundFee, $optional); - - if (data_get($result, 'return_code') !== 'SUCCESS') { - throw new WeChatPayException( - data_get($result, 'return_msg', '请求失败') - ); - } - - if (data_get($result, 'result_code') !== 'SUCCESS') { - throw new WeChatPayException( - sprintf( - '[%s] %s', - data_get($result, 'err_code', '-1'), - data_get($result, 'err_code_des', '退款失败') - ) - ); - } - - return $result; - } - - /** - * 根据商户订单号退款 - * - * @param string $number - * @param string $refundNumber - * @param int $totalFee - * @param int $refundFee - * @param array $optional - * @return array - */ - public function refundByOutTradeNumber(string $number, string $refundNumber, int $totalFee, int $refundFee, array $optional = []) - { - $result = $this->app->refund->byOutTradeNumber($number, $refundNumber, $totalFee, $refundFee, $optional); - - if (data_get($result, 'return_code') !== 'SUCCESS') { - throw new WeChatPayException( - data_get($result, 'return_msg', '请求失败') - ); - } - - if (data_get($result, 'result_code') !== 'SUCCESS') { - throw new WeChatPayException( - sprintf( - '[%s] %s', - data_get($result, 'err_code', '-1'), - data_get($result, 'err_code_des', '退款失败') - ) - ); - } - - return $result; - } - - /** - * 退款结果通知 - * - * @param \Closure $closure - * @return \Symfony\Component\HttpFoundation\Response - */ - public function handleRefundedNotify(Closure $closure) - { - return $this->app->handleRefundedNotify($closure); - } -} diff --git a/config/wechat.php b/config/wechat.php index a9d85446..60af8281 100644 --- a/config/wechat.php +++ b/config/wechat.php @@ -50,6 +50,7 @@ return [ ], ], 'payment' => [ + // 商城 - 微信 App支付 'default' => [ 'sandbox' => env('WECHAT_PAYMENT_SANDBOX', false), 'app_id' => env('WECHAT_PAYMENT_APPID'), @@ -71,7 +72,29 @@ return [ ], ], ], - 'yzk' => [ + // 商城 - 微信小程序支付 + 'mini_program' => [ + 'sandbox' => env('WECHAT_PAYMENT_SANDBOX', false), + 'app_id' => env('WECHAT_MINI_PROGRAM_APPID'), + 'mch_id' => env('WECHAT_PAYMENT_MCH_ID'), + 'key' => env('WECHAT_PAYMENT_KEY'), + 'cert_path' => env('WECHAT_PAYMENT_CERT_PATH'), // 绝对地址 + 'key_path' => env('WECHAT_PAYMENT_KEY_PATH'), // 绝对地址 + 'notify_url' => env('WECHAT_PAYMENT_NOTIFY_URL'), + + // 日志 + 'log' => [ + 'default' => 'daily', + 'channels' => [ + 'daily' => [ + 'driver' => 'daily', + 'path' => storage_path('logs/wxpay-mini-program.log'), + 'level' => 'info', + ], + ], + ], + ], + 'yzk_h5' => [ 'sandbox' => env('WECHAT_PAYMENT_SANDBOX_YZK', false), 'app_id' => env('WECHAT_PAYMENT_APPID_YZK'), 'mch_id' => env('WECHAT_PAYMENT_MCH_ID_YZK'), From 6f748f65a458fd9a5773f55d1b5897d28f2635de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=9D=99?= Date: Fri, 25 Feb 2022 15:15:55 +0800 Subject: [PATCH 16/39] Fxi --- .../Api/Http/Controllers/Auth/SocialiteAuthController.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/Endpoint/Api/Http/Controllers/Auth/SocialiteAuthController.php b/app/Endpoint/Api/Http/Controllers/Auth/SocialiteAuthController.php index 19d6a5c7..0eba4040 100644 --- a/app/Endpoint/Api/Http/Controllers/Auth/SocialiteAuthController.php +++ b/app/Endpoint/Api/Http/Controllers/Auth/SocialiteAuthController.php @@ -135,13 +135,16 @@ class SocialiteAuthController extends Controller $user = null; $config = config('socialite', []); $socialite = new SocialiteManager($config); + switch ($provider) { - case SocialiteType::WechatMiniProgram://微信小程序 - $user = $socialite->create('wehcat-mini')->userFromCode($code); + case SocialiteType::WechatMiniProgram->value: //微信小程序 + $user = $socialite->create(SocialiteType::WechatMiniProgram->value)->userFromCode($code); break; + default: throw new BizException(404); } + return $user; } From 991a0ad281e9b4b4fa5e9f433271483db872468d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=9D=99?= Date: Fri, 25 Feb 2022 15:17:53 +0800 Subject: [PATCH 17/39] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=BE=AE=E4=BF=A1?= =?UTF-8?q?=E6=8E=88=E6=9D=83=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/socialite.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/socialite.php b/config/socialite.php index 7e528f19..5f5739f0 100644 --- a/config/socialite.php +++ b/config/socialite.php @@ -3,7 +3,7 @@ use App\Providers\Socialite\WechatMini; return [ - 'wehcat-mini'=>[ + 'wechat-mini'=>[ 'provider' => WechatMini::class, 'client_id' => env('WECHAT_MINI_PROGRAM_APPID', ''), 'client_secret' => env('WECHAT_MINI_PROGRAM_SECRET', ''), From cecbe3970b26333ac300050e490f6339872d195c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=9D=99?= Date: Fri, 25 Feb 2022 15:23:34 +0800 Subject: [PATCH 18/39] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=BE=AE=E4=BF=A1?= =?UTF-8?q?=E6=94=AF=E4=BB=98=E5=9B=9E=E8=B0=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Http/Controllers/WxpayController.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/app/Endpoint/Callback/Http/Controllers/WxpayController.php b/app/Endpoint/Callback/Http/Controllers/WxpayController.php index 62e610da..e22cff92 100644 --- a/app/Endpoint/Callback/Http/Controllers/WxpayController.php +++ b/app/Endpoint/Callback/Http/Controllers/WxpayController.php @@ -11,6 +11,7 @@ use App\Services\PayService; use Illuminate\Database\Eloquent\ModelNotFoundException; use Illuminate\Support\Carbon; use Illuminate\Support\Facades\DB; +use Illuminate\Support\Facades\Log; use Throwable; class WxpayController extends Controller @@ -93,4 +94,19 @@ class WxpayController extends Controller return true; }); } + + /** + * 微信回调日志 + * + * @param string $message + * @param array $context + * @return void + */ + protected function log(string $message, array $context = []) + { + return Log::build([ + 'driver' => 'daily', + 'path' => storage_path('logs/wxpay-notify.log'), + ])->info($message, $context); + } } From 7185c7941984fdd4e510b2e9ecbb23efd091f8ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=9D=99?= Date: Fri, 25 Feb 2022 15:32:21 +0800 Subject: [PATCH 19/39] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=BE=AE=E4=BF=A1?= =?UTF-8?q?=E9=80=80=E6=AC=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Endpoint/Callback/routes.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Endpoint/Callback/routes.php b/app/Endpoint/Callback/routes.php index 26c68d31..50d2f0f3 100644 --- a/app/Endpoint/Callback/routes.php +++ b/app/Endpoint/Callback/routes.php @@ -10,6 +10,6 @@ Route::post('kuaidi100', [Kuaidi100Controller::class, 'notify']); // 微信支付通知 Route::post('wxpay/{payment}/paid-notify', [WxpayController::class, 'paidNotify'])->name('wxpay.paid_notify'); -Route::post('wxpay/order-refund-notify', [WxpayController::class, 'orderRefundedNotify'])->name('wxpay.order_refund_notify'); +Route::post('wxpay/{payment}/order-refund-notify', [WxpayController::class, 'orderRefundedNotify'])->name('wxpay.order_refund_notify'); Route::post('alipay', AlipayController::class)->name('alipay.notify'); From d706b144560cb60094f52a45cbf3ab4874b9cd26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=9D=99?= Date: Fri, 25 Feb 2022 16:28:32 +0800 Subject: [PATCH 20/39] Update --- .../Distribution/PreIncomeJobCommand.php | 28 ++++++++-------- .../Distribution/PreIncomeSettleCommand.php | 32 +++++++++---------- 2 files changed, 31 insertions(+), 29 deletions(-) diff --git a/app/Console/Commands/Distribution/PreIncomeJobCommand.php b/app/Console/Commands/Distribution/PreIncomeJobCommand.php index d65d01db..9cabe193 100644 --- a/app/Console/Commands/Distribution/PreIncomeJobCommand.php +++ b/app/Console/Commands/Distribution/PreIncomeJobCommand.php @@ -55,20 +55,22 @@ class PreIncomeJobCommand extends Command //发送商家端预收益进帐消息 try { DB::beginTransaction(); + switch (get_class($job->jobable)) { - case Order::class://如果是订单类型,则发送预收益消息 - $order = $job->jobable; - $incomesLogs = DistributionPreIncome::where('order_id', $order->id)->get(); - foreach ($incomesLogs as $log) { - MerchantMessage::createDistributionMessage($log->user_id, [ - 'title'=>'恭喜收入'.$log->total_revenue.'元', - 'content'=>'您有新的预收益产生,共'.$log->total_revenue.'元。', - ]); - } - break; - default: - break; - } + case Order::class://如果是订单类型,则发送预收益消息 + $order = $job->jobable; + $incomesLogs = DistributionPreIncome::where('order_id', $order->id)->get(); + foreach ($incomesLogs as $log) { + MerchantMessage::createDistributionMessage($log->user_id, [ + 'title'=>'恭喜收入'.$log->total_revenue.'元', + 'content'=>'您有新的预收益产生,共'.$log->total_revenue.'元。', + ]); + } + break; + default: + break; + } + DB::commit(); } catch (Throwable $e) { DB::rollBack(); diff --git a/app/Console/Commands/Distribution/PreIncomeSettleCommand.php b/app/Console/Commands/Distribution/PreIncomeSettleCommand.php index e456ad83..c8166a91 100644 --- a/app/Console/Commands/Distribution/PreIncomeSettleCommand.php +++ b/app/Console/Commands/Distribution/PreIncomeSettleCommand.php @@ -44,33 +44,33 @@ class PreIncomeSettleCommand extends Command DB::beginTransaction(); $walletService->changeBalance( - $preIncome->user, - bcmul($preIncome->total_revenue, 100), - WalletLog::ACTION_DISTRIBUTION_PRE_INCOME, - $preIncome->remarks, - $preIncome - ); + $preIncome->user, + bcmul($preIncome->total_revenue, 100), + WalletLog::ACTION_DISTRIBUTION_PRE_INCOME, + $preIncome->remarks, + $preIncome + ); // 计算配额 $changeQuota = bcmul($preIncome->total_revenue, app_settings('distribution.quota_v2_rate', 0), 4); $changeQuota = round($changeQuota, 3); $preIncome->user->userInfo()->update([ - 'quota_v2' => DB::raw("quota_v2+{$changeQuota}"), - ]); + 'quota_v2' => DB::raw("quota_v2+{$changeQuota}"), + ]); $preIncome->user->quotaLogs()->create([ - 'loggable_id' => $preIncome->id, - 'loggable_type' => $preIncome->getMorphClass(), - 'change_quota' => $changeQuota, - 'remarks' => $preIncome->type_text.'得配额', - ]); + 'loggable_id' => $preIncome->id, + 'loggable_type' => $preIncome->getMorphClass(), + 'change_quota' => $changeQuota, + 'remarks' => $preIncome->type_text.'得配额', + ]); // 将预收益标记为已结算 $preIncome->update([ - 'completed_at' => now(), - 'status' => DistributionPreIncome::STATUS_PROCESSED, - ]); + 'completed_at' => now(), + 'status' => DistributionPreIncome::STATUS_PROCESSED, + ]); DB::commit(); } catch (Throwable $e) { From b8fdcde922b503fb1d555f07481fc6e401fbbc49 Mon Sep 17 00:00:00 2001 From: vine_liutk <961510893@qq.com> Date: Fri, 25 Feb 2022 16:33:06 +0800 Subject: [PATCH 21/39] =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=95=86=E5=9F=8E?= =?UTF-8?q?=E7=AD=89=E7=BA=A7=E6=96=87=E5=AD=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Admin/Controllers/AfterSaleController.php | 104 ++++++------ app/Admin/Controllers/OrderController.php | 151 +++++++++--------- app/Admin/Controllers/UserController.php | 67 ++++---- app/Admin/Metrics/Users.php | 14 +- .../Controllers/Merchant/AgentController.php | 10 +- app/Models/UserInfo.php | 14 +- 6 files changed, 184 insertions(+), 176 deletions(-) diff --git a/app/Admin/Controllers/AfterSaleController.php b/app/Admin/Controllers/AfterSaleController.php index 3ca7ef3b..c4c66e9c 100644 --- a/app/Admin/Controllers/AfterSaleController.php +++ b/app/Admin/Controllers/AfterSaleController.php @@ -52,7 +52,7 @@ class AfterSaleController extends AdminController $grid->column('tags', '标签')->display(function ($tags) { $array = []; foreach ($this->tags as $key => $tag) { - $array[] = $tag->name; + $array[] = $tag->name; } return $array; })->label(); @@ -136,56 +136,66 @@ class AfterSaleController extends AdminController protected function detail($id) { return function (Row $row) use ($id) { - $row->column(4, function ($column) use ($id) { + $row->column(5, function ($column) use ($id) { $builder = AfterSale::with(['user', 'user.userInfo', 'order', 'orderProduct', 'tags']); $column->row(Show::make($id, $builder, function (Show $show) { - $show->field('id'); - $show->field('sn'); - $show->field('order.sn', '售后订单')->unescape()->as(function ($value) { - if (Admin::user()->can('dcat.admin.orders.show')) { - return ''.$value.''; - } - return $value; - }); - $show->field('order_product.name', '售后商品')->as(function ($value) { - return $value.'*'. $this->num; - }); - // $show->field('num'); - if (in_array($show->model()->type, [AfterSaleModel::TYPE_REFUND_AND_RETURN, AfterSaleModel::TYPE_REFUND])) { - $show->field('amount', '售后金额')->as(function ($amount) { - return '¥'.bcdiv($amount, 100, 2); + // $show->field('id'); + $type = $show->model()->type; + $show->row(function (Show\Row $show) use ($type) { + $show->width(6)->field('sn'); + $show->field('order.sn', '关联订单编号')->unescape()->as(function ($value) { + if (Admin::user()->can('dcat.admin.orders.show')) { + return ''.$value.''; + } + return $value; }); - } - $show->field('type')->using([ - AfterSaleModel::TYPE_REFUND_AND_RETURN => '退款退货', - AfterSaleModel::TYPE_REFUND => '退款', - AfterSaleModel::TYPE_CHANGE => '换货', - AfterSaleModel::TYPE_FILL => '漏发', - ])->label(); - $show->field('state')->using(AfterSaleModel::$stateText)->dot([ - AfterSaleModel::STATE_APPLY=>'warning', - AfterSaleModel::STATE_VERIFY=>'danger', - AfterSaleModel::STATE_AGREE=>'warning', - AfterSaleModel::STATE_SHIPPING=>'primary', - AfterSaleModel::STATE_FINANCE=>'primary', - AfterSaleModel::STATE_FINISH=>'success', - AfterSaleModel::STATE_CANCEL=>'#b3b9bf', - ]); - $show->field('user.user_info.nickname', '下单用户'); - $show->field('user.phone'); - if (in_array($show->model()->type, [AfterSaleModel::TYPE_REFUND_AND_RETURN, AfterSaleModel::TYPE_CHANGE])) { - $show->field('tracking_number'); - } + $show->field('order_product.name', '售后商品')->as(function ($value) { + return $value.'*'. $this->num; + }); + // $show->field('num'); + if (in_array($type, [AfterSaleModel::TYPE_REFUND_AND_RETURN, AfterSaleModel::TYPE_REFUND])) { + $show->field('amount', '售后金额')->as(function ($amount) { + return '¥'.bcdiv($amount, 100, 2); + }); + } + $show->width(6)->field('user.user_info.nickname', '下单用户'); + $show->field('user.phone'); + $show->field('type')->using([ + AfterSaleModel::TYPE_REFUND_AND_RETURN => '退款退货', + AfterSaleModel::TYPE_REFUND => '退款', + AfterSaleModel::TYPE_CHANGE => '换货', + AfterSaleModel::TYPE_FILL => '漏发', + ])->label(); + if (in_array($type, [AfterSaleModel::TYPE_REFUND_AND_RETURN, AfterSaleModel::TYPE_REFUND, AfterSaleModel::TYPE_CHANGE])) { + $show->field('sales_value', '销售值'); + } + }); + $status = $stae = $show->model()->state; + $show->row(function (Show\Row $show) use ($type, $status) { + $show->width(6)->field('state')->using(AfterSaleModel::$stateText)->dot([ + AfterSaleModel::STATE_APPLY=>'warning', + AfterSaleModel::STATE_VERIFY=>'danger', + AfterSaleModel::STATE_AGREE=>'warning', + AfterSaleModel::STATE_SHIPPING=>'primary', + AfterSaleModel::STATE_FINANCE=>'primary', + AfterSaleModel::STATE_FINISH=>'success', + AfterSaleModel::STATE_CANCEL=>'#b3b9bf', + ]); + if (in_array($type, [AfterSaleModel::TYPE_REFUND_AND_RETURN, AfterSaleModel::TYPE_CHANGE]) && in_array($status, [ + AfterSaleModel::STATE_SHIPPING, AfterSaleModel::STATE_FINANCE, AfterSaleModel::STATE_FINISH, + ])) { + $show->field('tracking_number'); + } + }); + $show->row(function (Show\Row $show) use ($type, $status) { + $show->width(12)->field('tags')->width(10, 1)->as(function () { + return $this->tags->pluck('name'); + })->label(); + $show->width(6)->field('created_at'); + $show->field('updated_at'); + }); - $show->field('tags')->as(function () { - return $this->tags->pluck('name'); - })->label(); - if (in_array($show->model()->type, [AfterSaleModel::TYPE_REFUND_AND_RETURN, AfterSaleModel::TYPE_REFUND, AfterSaleModel::TYPE_CHANGE])) { - $show->field('sales_value', '销售值'); - } // $show->field('order_product.cover')->image(); - $show->field('created_at'); - $show->field('updated_at'); $show->panel() ->tools(function (Show\Tools $tools) use ($show) { $tools->disableEdit(); @@ -214,7 +224,7 @@ class AfterSaleController extends AdminController }); })); }); - $row->column(8, function ($column) use ($id) { + $row->column(7, function ($column) use ($id) { $afterSale = AfterSaleModel::findOrFail($id); $builder = AfterSaleModel::with('orderProduct')->where('order_product_id', $afterSale?->order_product_id)->where('id', '<>', $id); $column->row(Box::make('相关售后', Grid::make($builder, function (Grid $grid) { diff --git a/app/Admin/Controllers/OrderController.php b/app/Admin/Controllers/OrderController.php index 4b11cc3c..4c89c4ed 100644 --- a/app/Admin/Controllers/OrderController.php +++ b/app/Admin/Controllers/OrderController.php @@ -154,92 +154,85 @@ class OrderController extends AdminController $builder = OrderModel::with(['user', 'userCoupon', 'tags'])->withCount('afterSales'); $column->row(Show::make($id, $builder, function (Show $show) { // $show->field('id'); - $show->field('sn'); - $show->field('order_status')->as(function ($v) { - return $this->order_status; - })->using([ - 0=>'待付款', - 1=>'待发货', - 2=>'发货中', - 3=>'已发货', - 9=>'已完成', - 10=>'已取消', - ])->dot([ - 0=>'primary', - 1=>'warning', - 2=>'danger', - 3=>'success', - 9=>'success', - 10=>'#b3b9bf', - ]); - $show->field('total_amount')->as(function ($v) { - return bcdiv($v, 100, 2); - })->prepend('¥'); - $show->field('created_at'); - $show->html(function () { - $content = ''; + $show->row(function (Show\Row $show) { + $show->width(6)->field('sn'); + $show->field('order_status')->as(function ($v) { + return $this->order_status; + })->using([ + 0=>'待付款', + 1=>'待发货', + 2=>'发货中', + 3=>'已发货', + 9=>'已完成', + 10=>'已取消', + ])->dot([ + 0=>'primary', + 1=>'warning', + 2=>'danger', + 3=>'success', + 9=>'success', + 10=>'#b3b9bf', + ]); - if ($this->pay_way) { - $content = '  '.$this->pay_way->getMallOrderText(); - } + $show->field('created_at'); + $show->width(6)->field('tags')->as(function () { + return $this->tags->pluck('name'); + })->label(); + $show->field('pay_at'); + $show->field('pay_way')->unescape()->as(function () { + $content = ''; - return << -
- 支付方式 -
+ if ($this->pay_way) { + $content = '  '.$this->pay_way->getMallOrderText(); + } -
-
-
{$content} 
-
-
- -HTML; + return $content; + }); }); - $show->field('pay_at'); - $show->field('tags')->as(function () { - return $this->tags->pluck('name'); - })->label(); - $show->divider(); - $show->field('consignee_name'); - $show->field('consignee_telephone'); - $show->field('consignee')->as(function () { - return $this->consignee_zone . ' '. $this->consignee_address; + $show->row(function (Show\Row $show) { + $show->width(6)->field('consignee_name'); + $show->field('consignee_telephone'); + $show->width(12)->field('consignee')->width(10, 1)->as(function () { + return $this->consignee_zone . ' '. $this->consignee_address; + }); }); - // $show->field('user.phone'); - $show->divider(); - $show->field('products_total_amount')->as(function ($v) { - return bcdiv($v, 100, 2); - })->prepend('¥'); - $show->field('vip_discount_amount')->as(function ($v) { - return bcdiv($v, 100, 2); - })->prepend('- ¥'); - if ($show->model()->user_coupon_id) { - $show->field('user_coupon.coupon_name', '优惠券')->label(); - $show->field('coupon_discount_amount')->as(function ($v) { + $userCouponId = $show->model()->user_coupon_id; + $show->row(function (Show\Row $show) use ($userCouponId) { + $show->width(6)->field('products_total_amount')->as(function ($v) { + return bcdiv($v, 100, 2); + })->prepend('¥'); + $show->field('vip_discount_amount')->as(function ($v) { return bcdiv($v, 100, 2); })->prepend('- ¥'); - } - $show->field('shipping_fee')->as(function ($v) { - return bcdiv($v, 100, 2); - })->prepend('+ ¥'); - $show->field('reduced_amount')->as(function ($v) { - return bcdiv($v, 100, 2); - })->prepend('- ¥'); - $show->divider(); - $show->field('sales_value', '总销售值'); - $show->field('is_settle', '是否结算')->using([ - 0=>'未结算', - 1=>'已结算', - ])->dot([ - 0=>'danger', - 1=>'success', - ]); - $show->field('completed_at', '完成时间'); - $show->divider(); - $show->field('note'); - $show->field('remark'); + if ($userCouponId) { + $show->field('user_coupon.coupon_name', '优惠券')->label(); + $show->field('coupon_discount_amount')->as(function ($v) { + return bcdiv($v, 100, 2); + })->prepend('- ¥'); + } + $show->field('shipping_fee')->as(function ($v) { + return bcdiv($v, 100, 2); + })->prepend('+ ¥'); + $show->field('reduced_amount')->as(function ($v) { + return bcdiv($v, 100, 2); + })->prepend('- ¥'); + $show->field('total_amount')->as(function ($v) { + return bcdiv($v, 100, 2); + })->prepend('¥'); + }); + $show->row(function (Show\Row $show) use ($userCouponId) { + $show->width(6)->field('sales_value', '总销售值'); + $show->field('is_settle', '是否结算')->using([ + 0=>'未结算', + 1=>'已结算', + ])->dot([ + 0=>'danger', + 1=>'success', + ]); + $show->field('completed_at', '完成时间'); + $show->width(12)->field('note')->width(10, 1); + $show->width(12)->field('remark')->width(10, 1); + }); $show->panel() ->tools(function (Show\Tools $tools) use ($show) { diff --git a/app/Admin/Controllers/UserController.php b/app/Admin/Controllers/UserController.php index 9ceb7907..f1e22353 100644 --- a/app/Admin/Controllers/UserController.php +++ b/app/Admin/Controllers/UserController.php @@ -60,7 +60,7 @@ class UserController extends AdminController $grid->column('userInfo.code')->copyable(); $grid->column('userInfo.agent_level')->display(function ($value) { - return $this->userInfo?->agent_level_name??'未知'; + return $this->userInfo?->agent_level_name ?? '未知'; })->label(); $grid->column('userInfo.inviterInfo.user.phone')->copyable(); @@ -71,18 +71,18 @@ class UserController extends AdminController Grid\Column\Filter\Between::make() ); $grid->column('wallet.balance')->display(function ($value) { - $value = bcdiv($value, 100, 2); + $value = bcdiv($value, 100, 2); if ($this->wallet?->is_frozen) { - $value.= "  冻结"; + $value .= "  冻结"; } return $value; })->prepend('¥')->filter( PriceBetween::make() ); $grid->column('balance.balance')->display(function ($value) { - $value = bcdiv($value, 100, 2); + $value = bcdiv($value, 100, 2); if ($this->balance?->is_frozen) { - $value.= "  冻结"; + $value .= "  冻结"; } return $value; })->prepend('¥')->filter( @@ -170,34 +170,39 @@ class UserController extends AdminController $row->column(5, function ($column) use ($id) { $builder = User::with(['userInfo', 'wallet', 'balance', 'userInfo.inviterInfo.user']); $column->row(Show::make($id, $builder, function (Show $show) { - $show->field('id'); - $show->field('phone'); - $show->field('user_info.nickname'); - $show->field('user_info.gender')->using(UserInfo::$genderTexts)->label(); - $show->field('user_info.birthday'); - $show->field('user_info.agent_level')->as(function ($value) { - return $this->userInfo?->agent_level_name??'未知'; - })->label(); - $show->field('user_info.inviter_info.user.phone'); - $show->field('user_info.growth_value'); - $show->field('user_info.group_sales_value'); + $show->row(function (Show\Row $show) { + $show->width(12)->field('id')->width(10, 1); + $show->width(6)->field('phone'); + $show->field('user_info.inviter_info.user.phone'); + $show->field('user_info.nickname'); + $show->field('user_info.gender')->using(UserInfo::$genderTexts)->label(); + $show->field('user_info.birthday'); + $show->field('user_info.agent_level')->as(function ($value) { + return $this->userInfo?->agent_level_name ?? '未知'; + })->label(); - $show->field('wallet.balance')->as(function ($value) { - $value = bcdiv($value, 100, 2); - return $value; - })->prepend('¥'); - $show->field('balance.balance')->as(function ($value) { - $value = bcdiv($value, 100, 2); - return $value; - })->prepend('¥'); - $show->field('user_info.quota_v2'); - $show->field('user_info.quota_v1'); - $show->field('user_info.points'); + $show->field('user_info.growth_value'); + $show->field('user_info.group_sales_value'); + + $show->field('wallet.balance')->as(function ($value) { + $value = bcdiv($value, 100, 2); + return $value; + })->prepend('¥'); + $show->field('balance.balance')->as(function ($value) { + $value = bcdiv($value, 100, 2); + return $value; + })->prepend('¥'); + $show->field('user_info.quota_v2'); + $show->field('user_info.quota_v1'); + $show->field('user_info.points'); + }); + $show->row(function (Show\Row $show) { + $show->width(6)->field('last_login_ip'); + $show->field('last_login_at'); + $show->field('register_ip'); + $show->field('created_at'); + }); - $show->field('last_login_ip'); - $show->field('last_login_at'); - $show->field('register_ip'); - $show->field('created_at'); $show->panel() ->tools(function ($tools) use ($show) { $tools->disableEdit(); diff --git a/app/Admin/Metrics/Users.php b/app/Admin/Metrics/Users.php index f832d023..bc2f38d0 100644 --- a/app/Admin/Metrics/Users.php +++ b/app/Admin/Metrics/Users.php @@ -140,7 +140,7 @@ class Users extends Donut
- 店铺 + 会员
{$vip} @@ -149,7 +149,7 @@ class Users extends Donut
- 社区 + 铁牌会员
{$community} @@ -158,7 +158,7 @@ class Users extends Donut
- 区级 + 铜牌会员
{$district} @@ -168,7 +168,7 @@ class Users extends Donut
- 市级 + 银牌会员
{$city} @@ -178,7 +178,7 @@ class Users extends Donut
- 省级 + 金牌会员
{$province} @@ -187,7 +187,7 @@ class Users extends Donut
- 分公司 + 钻石会员
{$branch} @@ -196,7 +196,7 @@ class Users extends Donut
- 董事 + 默认用户
{$director} diff --git a/app/Endpoint/Api/Http/Controllers/Merchant/AgentController.php b/app/Endpoint/Api/Http/Controllers/Merchant/AgentController.php index 767b7eac..2133aaaf 100644 --- a/app/Endpoint/Api/Http/Controllers/Merchant/AgentController.php +++ b/app/Endpoint/Api/Http/Controllers/Merchant/AgentController.php @@ -34,7 +34,7 @@ class AgentController extends Controller ], // 代理 'agents_count' => [ - 'label' => '店铺', + 'label' => '会员', 'current_agents_count' => $userInfo->getVipAgentsCount(), 'upgrade_agents_count' => $rules['community']['vips_agents_count'], ], @@ -50,7 +50,7 @@ class AgentController extends Controller 'upgrade_team_sales_value' => (string) $rules['district']['team_sales_value'], ], 'agents_count' => [ - 'label' => '店铺', + 'label' => '会员', 'current_agents_count' => $userInfo->getVipAgentsCount(), 'upgrade_agents_count' => $rules['district']['vips_agents_count'], ], @@ -66,7 +66,7 @@ class AgentController extends Controller 'upgrade_team_sales_value' => (string) $rules['city']['team_sales_value'], ], 'agents_count' => [ - 'label' => '区代', + 'label' => '铜牌会员', 'current_agents_count' => $userInfo->getDistrictAgentsCountOnDifferentLines(), 'upgrade_agents_count' => $rules['city']['district_agents_count'], ], @@ -82,7 +82,7 @@ class AgentController extends Controller 'upgrade_team_sales_value' => (string) $rules['province']['team_sales_value'], ], 'agents_count' => [ - 'label' => '市代', + 'label' => '银牌会员', 'current_agents_count' => $userInfo->getCityAgentsCountOnDifferentLines(), 'upgrade_agents_count' => $rules['province']['city_agents_count'], ], @@ -98,7 +98,7 @@ class AgentController extends Controller 'upgrade_team_sales_value' => (string) $rules['branch']['team_sales_value'], ], 'agents_count' => [ - 'label' => '省代', + 'label' => '金牌会员', 'current_agents_count' => $userInfo->getProvinceAgentsCountOnDifferentLines(), 'upgrade_agents_count' => $rules['branch']['province_agents_count'], ], diff --git a/app/Models/UserInfo.php b/app/Models/UserInfo.php index 425f166e..059f1ae5 100644 --- a/app/Models/UserInfo.php +++ b/app/Models/UserInfo.php @@ -116,13 +116,13 @@ class UserInfo extends Model */ public static $agentLevelTexts = [ self::AGENT_LEVEL_CIVILIAN => '粉丝', - self::AGENT_LEVEL_VIP => '店铺', - self::AGENT_LEVEL_COMMUNITY => '社区', - self::AGENT_LEVEL_DISTRICT => '区级', - self::AGENT_LEVEL_CITY => '市级', - self::AGENT_LEVEL_PROVINCE => '省级', - self::AGENT_LEVEL_BRANCH => '分公司', - self::AGENT_LEVEL_DIRECTOR => '董事', + self::AGENT_LEVEL_VIP => '会员', + self::AGENT_LEVEL_COMMUNITY => '铁牌会员', + self::AGENT_LEVEL_DISTRICT => '铜牌会员', + self::AGENT_LEVEL_CITY => '银牌会员', + self::AGENT_LEVEL_PROVINCE => '金牌会员', + self::AGENT_LEVEL_BRANCH => '钻石会员', + self::AGENT_LEVEL_DIRECTOR => '默认用户', ]; /** From 8dbcb4f5fe03bbd80be13f352503687dbab72863 Mon Sep 17 00:00:00 2001 From: vine_liutk <961510893@qq.com> Date: Fri, 25 Feb 2022 16:39:25 +0800 Subject: [PATCH 22/39] =?UTF-8?q?=E8=B0=83=E6=95=B4=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E7=BA=A7=E5=88=AB=E6=96=87=E5=AD=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Admin/Forms/UserEditAgent.php | 2 +- app/Admin/Renderable/UserFansSimpleTable.php | 2 +- app/Admin/Renderable/UserInviterSimpleTable.php | 2 +- resources/lang/zh_CN/dealer.php | 2 +- resources/lang/zh_CN/user.php | 4 ++-- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/Admin/Forms/UserEditAgent.php b/app/Admin/Forms/UserEditAgent.php index 3e15d539..b3cf6e0a 100644 --- a/app/Admin/Forms/UserEditAgent.php +++ b/app/Admin/Forms/UserEditAgent.php @@ -73,7 +73,7 @@ class UserEditAgent extends Form implements LazyRenderable public function form() { // dd(UserInfo::$agentLevelTexts); - $this->select('agent_level', '管理级别')->options(UserInfo::$agentLevelTexts)->required(); + $this->select('agent_level', '身份')->options(UserInfo::$agentLevelTexts)->required(); } public function default() diff --git a/app/Admin/Renderable/UserFansSimpleTable.php b/app/Admin/Renderable/UserFansSimpleTable.php index 7657508f..013d209a 100644 --- a/app/Admin/Renderable/UserFansSimpleTable.php +++ b/app/Admin/Renderable/UserFansSimpleTable.php @@ -17,7 +17,7 @@ class UserFansSimpleTable extends LazyRenderable $grid->column('user.phone', '手机号')->link(function ($value) { return admin_url('users/'.$this->user_id); }); - $grid->column('agent_level', '管理级别')->display(function ($value) { + $grid->column('agent_level', '身份')->display(function ($value) { return $this->agent_level_name??'未知'; })->label(); diff --git a/app/Admin/Renderable/UserInviterSimpleTable.php b/app/Admin/Renderable/UserInviterSimpleTable.php index f9d7f703..5c861926 100644 --- a/app/Admin/Renderable/UserInviterSimpleTable.php +++ b/app/Admin/Renderable/UserInviterSimpleTable.php @@ -18,7 +18,7 @@ class UserInviterSimpleTable extends LazyRenderable $grid->column('user.phone', '手机号')->link(function ($value) { return admin_url('users/'.$this->user_id); }); - $grid->column('agent_level', '管理级别')->display(function ($value) { + $grid->column('agent_level', '身份')->display(function ($value) { return $this->agent_level_name??'未知'; })->label(); diff --git a/resources/lang/zh_CN/dealer.php b/resources/lang/zh_CN/dealer.php index 9d1802df..74f4c61d 100644 --- a/resources/lang/zh_CN/dealer.php +++ b/resources/lang/zh_CN/dealer.php @@ -14,7 +14,7 @@ return [ 'userInfo'=>[ 'avatar' => '头像', 'nickname' => '昵称', - 'agent_level'=>'管理级别', + 'agent_level'=>'身份', 'growth_value'=>'消费值', 'group_sales_value'=>'业绩', 'inviterInfo'=>[ diff --git a/resources/lang/zh_CN/user.php b/resources/lang/zh_CN/user.php index 6c38ca8e..a182054d 100644 --- a/resources/lang/zh_CN/user.php +++ b/resources/lang/zh_CN/user.php @@ -25,7 +25,7 @@ return [ 'avatar' => '头像', 'nickname' => '昵称', 'code' => '邀请码', - 'agent_level'=>'管理级别', + 'agent_level'=>'身份', 'growth_value'=>'消费值', 'group_sales_value'=>'业绩', 'inviterInfo'=>[ @@ -37,7 +37,7 @@ return [ 'user_info'=>[ 'avatar' => '头像', 'nickname' => '昵称', - 'agent_level'=>'管理级别', + 'agent_level'=>'身份', 'growth_value'=>'消费值', 'group_sales_value'=>'业绩', 'points'=>'积分', From 78b56393f9c95ffc97283de967cd7dc91302026f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=9D=99?= Date: Fri, 25 Feb 2022 16:40:41 +0800 Subject: [PATCH 23/39] =?UTF-8?q?=E9=9A=90=E8=97=8F=E4=BC=9A=E5=91=98?= =?UTF-8?q?=E5=A5=96=E5=8A=B1=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Admin/Controllers/SettingController.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/app/Admin/Controllers/SettingController.php b/app/Admin/Controllers/SettingController.php index a8f15773..58b3237c 100644 --- a/app/Admin/Controllers/SettingController.php +++ b/app/Admin/Controllers/SettingController.php @@ -111,7 +111,7 @@ class SettingController extends AdminController switch ($type) { case 'app': $tab->add('系统配置', new App(), true); - $tab->addLink('会员奖励配置', admin_route('settings.index', ['type'=>'distribution'])); + // $tab->addLink('会员奖励配置', admin_route('settings.index', ['type'=>'distribution'])); $tab->addLink('经销商配置', admin_route('settings.index', ['type'=>'dealer'])); $tab->addLink('提现配置', admin_route('settings.index', ['type'=>'withdraw'])); $tab->addLink('Ios配置', admin_route('settings.index', ['type'=>'ios'])); @@ -131,7 +131,7 @@ class SettingController extends AdminController break; case 'dealer': $tab->addLink('系统配置', admin_route('settings.index', ['type'=>'app'])); - $tab->addLink('会员奖励配置', admin_route('settings.index', ['type'=>'distribution'])); + // $tab->addLink('会员奖励配置', admin_route('settings.index', ['type'=>'distribution'])); $tab->add('经销商配置', new Dealer(), true); $tab->addLink('提现配置', admin_route('settings.index', ['type'=>'withdraw'])); $tab->addLink('Ios配置', admin_route('settings.index', ['type'=>'ios'])); @@ -141,7 +141,7 @@ class SettingController extends AdminController break; case 'withdraw': $tab->addLink('系统配置', admin_route('settings.index', ['type'=>'app'])); - $tab->addLink('会员奖励配置', admin_route('settings.index', ['type'=>'distribution'])); + // $tab->addLink('会员奖励配置', admin_route('settings.index', ['type'=>'distribution'])); $tab->addLink('经销商配置', admin_route('settings.index', ['type'=>'dealer'])); $tab->add('提现配置', new Withdraw(), true); $tab->addLink('Ios配置', admin_route('settings.index', ['type'=>'ios'])); @@ -151,7 +151,7 @@ class SettingController extends AdminController break; case 'ios': $tab->addLink('系统配置', admin_route('settings.index', ['type'=>'app'])); - $tab->addLink('会员奖励配置', admin_route('settings.index', ['type'=>'distribution'])); + // $tab->addLink('会员奖励配置', admin_route('settings.index', ['type'=>'distribution'])); $tab->addLink('经销商配置', admin_route('settings.index', ['type'=>'dealer'])); $tab->addLink('提现配置', admin_route('settings.index', ['type'=>'withdraw'])); $tab->add('Ios配置', new Ios(), true); @@ -161,7 +161,7 @@ class SettingController extends AdminController break; case 'android': $tab->addLink('系统配置', admin_route('settings.index', ['type'=>'app'])); - $tab->addLink('会员奖励配置', admin_route('settings.index', ['type'=>'distribution'])); + // $tab->addLink('会员奖励配置', admin_route('settings.index', ['type'=>'distribution'])); $tab->addLink('经销商配置', admin_route('settings.index', ['type'=>'dealer'])); $tab->addLink('提现配置', admin_route('settings.index', ['type'=>'withdraw'])); $tab->addLink('Ios配置', admin_route('settings.index', ['type'=>'ios'])); @@ -171,7 +171,7 @@ class SettingController extends AdminController break; case 'kuaidi100': $tab->addLink('系统配置', admin_route('settings.index', ['type'=>'app'])); - $tab->addLink('会员奖励配置', admin_route('settings.index', ['type'=>'distribution'])); + // $tab->addLink('会员奖励配置', admin_route('settings.index', ['type'=>'distribution'])); $tab->addLink('经销商配置', admin_route('settings.index', ['type'=>'dealer'])); $tab->addLink('提现配置', admin_route('settings.index', ['type'=>'withdraw'])); $tab->addLink('Ios配置', admin_route('settings.index', ['type'=>'ios'])); @@ -181,7 +181,7 @@ class SettingController extends AdminController break; case 'unipush': $tab->addLink('系统配置', admin_route('settings.index', ['type'=>'app'])); - $tab->addLink('会员奖励配置', admin_route('settings.index', ['type'=>'distribution'])); + // $tab->addLink('会员奖励配置', admin_route('settings.index', ['type'=>'distribution'])); $tab->addLink('经销商配置', admin_route('settings.index', ['type'=>'dealer'])); $tab->addLink('提现配置', admin_route('settings.index', ['type'=>'withdraw'])); $tab->addLink('Ios配置', admin_route('settings.index', ['type'=>'ios'])); From abcebe0c15d0b436824fb91d8e1939e3e4cf35ac Mon Sep 17 00:00:00 2001 From: vine_liutk <961510893@qq.com> Date: Fri, 25 Feb 2022 16:55:06 +0800 Subject: [PATCH 24/39] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=90=8E=E5=8F=B0?= =?UTF-8?q?=E8=AE=A2=E5=8D=95=E8=AF=A6=E6=83=85=E7=9A=84=E7=89=A9=E6=B5=81?= =?UTF-8?q?=E6=9F=A5=E7=9C=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Admin/Controllers/OrderController.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/Admin/Controllers/OrderController.php b/app/Admin/Controllers/OrderController.php index 4c89c4ed..86a857ce 100644 --- a/app/Admin/Controllers/OrderController.php +++ b/app/Admin/Controllers/OrderController.php @@ -4,6 +4,7 @@ namespace App\Admin\Controllers; use App\Admin\Actions\Grid\CreateOrderPackage; use App\Admin\Actions\Grid\Exports\ShippingOrder as ExportShippingOrder; +use App\Admin\Actions\Grid\KuaidiInfo; use App\Admin\Actions\Grid\OrderSetTag; use App\Admin\Actions\Show\OrderConsigneeInfo; use App\Admin\Actions\Show\OrderCreatePackage; @@ -331,6 +332,10 @@ class OrderController extends AdminController OrderPackage::STATUS_DISTRIBUTE=>'primary', OrderPackage::STATUS_QUESTION =>'warning', ]); + $grid->column('kuaidi_info', '物流详情')->display('详情')->modal(function ($modal) { + $modal->title('物流详情'); + return KuaidiInfo::make(); + }); $grid->column('is_failed', '正常')->bool([ 0=>true, 1=>false, From 7d6b80f80529c3332ca3a24a5a0302df771fd9ff Mon Sep 17 00:00:00 2001 From: vine_liutk <961510893@qq.com> Date: Fri, 25 Feb 2022 17:13:49 +0800 Subject: [PATCH 25/39] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=89=B9=E9=9B=B6?= =?UTF-8?q?=E8=AE=A2=E5=8D=95=E6=94=AF=E4=BB=98=E6=96=B9=E5=BC=8F=E7=AD=9B?= =?UTF-8?q?=E9=80=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/DealerOrderController.php | 4 +- .../Grid/Filter/DealerOrderPayWayIn.php | 77 +++++++++++++++++++ app/Enums/PayWay.php | 13 ++++ 3 files changed, 93 insertions(+), 1 deletion(-) create mode 100644 app/Admin/Renderable/Grid/Filter/DealerOrderPayWayIn.php diff --git a/app/Admin/Controllers/DealerOrderController.php b/app/Admin/Controllers/DealerOrderController.php index 7226f669..19f123e9 100644 --- a/app/Admin/Controllers/DealerOrderController.php +++ b/app/Admin/Controllers/DealerOrderController.php @@ -8,8 +8,10 @@ use App\Admin\Actions\Grid\DealerOrderPaid; use App\Admin\Actions\Grid\DealerOrderRefuse; use App\Admin\Actions\Grid\DealerOrderShipping; use App\Admin\Actions\Show\DealerOrderRemark; +use App\Admin\Renderable\Grid\Filter\DealerOrderPayWayIn; use App\Admin\Repositories\DealerOrder; use App\Enums\DealerOrderStatus; +use App\Enums\PayWay; use App\Models\DealerChannelSubsidyLog; use App\Models\DealerOrderProduct; use Dcat\Admin\Admin; @@ -54,7 +56,7 @@ class DealerOrderController extends AdminController return '  '.$v->getDealerOrderText(); } return ''; - }); + })->filter(DealerOrderPayWayIn::make(PayWay::dealerOrderTexts())); $grid->column('order_status')->display(function ($v) { return $this->order_status; diff --git a/app/Admin/Renderable/Grid/Filter/DealerOrderPayWayIn.php b/app/Admin/Renderable/Grid/Filter/DealerOrderPayWayIn.php new file mode 100644 index 00000000..f8e87f17 --- /dev/null +++ b/app/Admin/Renderable/Grid/Filter/DealerOrderPayWayIn.php @@ -0,0 +1,77 @@ +options = $options; + + $this->class = [ + 'all' => uniqid('column-filter-all-'), + 'item' => uniqid('column-filter-item-'), + ]; + } + + /** + * Add a binding to the query. + * + * @param array $value + * @param Model $model + */ + public function addBinding($value, Model $model) + { + if (empty($value)) { + return; + } + $all = [ + PayWay::Offline->value => '线下打款', + PayWay::Wallet->value => '余额支付', + PayWay::WxpayH5->value => '微信支付', + ''=>'Unknown', + ]; + + if (array_diff($all, $value)) {//无差别则直接跳过 + //判断查询的状态有哪些; + $model->where(function ($query) use ($value) { + foreach ($value as $payWay) { + switch ($payWay) { + case '': + $query->orWhereNull('pay_way'); + break; + default: + $query->orWhere('pay_way', $payWay); + } + } + }); + } + } + + /** + * Render this filter. + * + * @return string + */ + public function render() + { + return $this->renderCheckbox(); + } +} diff --git a/app/Enums/PayWay.php b/app/Enums/PayWay.php index 51ed79c9..538d0fe1 100644 --- a/app/Enums/PayWay.php +++ b/app/Enums/PayWay.php @@ -58,4 +58,17 @@ enum PayWay: string { default => 'Unknown', }; } + + /** + * @return string + */ + public static function dealerOrderTexts(): array + { + return [ + static::Offline->value => '线下打款', + static::Wallet->value => '余额支付', + static::WxpayH5->value => '微信支付', + ''=>'Unknown', + ]; + } } From 75abc0bd35ec96c3a26195b715428fa9c352ea8a Mon Sep 17 00:00:00 2001 From: vine_liutk <961510893@qq.com> Date: Fri, 25 Feb 2022 17:15:29 +0800 Subject: [PATCH 26/39] =?UTF-8?q?=E8=B0=83=E6=95=B4=E4=BC=9A=E5=91=98?= =?UTF-8?q?=E8=BA=AB=E4=BB=BD=E7=AD=9B=E9=80=89=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Admin/Controllers/UserController.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Admin/Controllers/UserController.php b/app/Admin/Controllers/UserController.php index f1e22353..c7604607 100644 --- a/app/Admin/Controllers/UserController.php +++ b/app/Admin/Controllers/UserController.php @@ -61,7 +61,7 @@ class UserController extends AdminController $grid->column('userInfo.agent_level')->display(function ($value) { return $this->userInfo?->agent_level_name ?? '未知'; - })->label(); + })->label()->filter(Grid\Column\Filter\In::make(UserInfo::$agentLevelTexts)); $grid->column('userInfo.inviterInfo.user.phone')->copyable(); $grid->column('userInfo.growth_value')->filter( @@ -145,7 +145,7 @@ class UserController extends AdminController $filter->panel(); $filter->like('phone')->width(3); $filter->like('userInfo.nickname')->width(3); - $filter->equal('userInfo.agent_level')->select(UserInfo::$agentLevelTexts)->width(3); + // $filter->equal('userInfo.agent_level')->select(UserInfo::$agentLevelTexts)->width(3); $filter->between('created_at')->dateTime()->width(7); // $filter->between('userInfo.growth_value')->width(6); // $filter->between('userInfo.group_sales_value')->width(6); From eef271078fc0658bdcbb68e2a569754c43e78c9a Mon Sep 17 00:00:00 2001 From: vine_liutk <961510893@qq.com> Date: Fri, 25 Feb 2022 17:52:32 +0800 Subject: [PATCH 27/39] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E6=B6=88=E8=B4=B9=E5=80=BC=E7=BB=9F=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/SalesValueLogController.php | 86 +++++++++ app/Admin/Controllers/UserController.php | 7 +- .../UserSalesValueLogSimpleTable.php | 56 ++++++ app/Admin/Repositories/SalesValueLog.php | 16 ++ app/Admin/routes.php | 4 + app/Models/SalesValueLog.php | 8 + dcat_admin_ide_helper.php | 172 ++++++++++-------- resources/lang/zh_CN/sales-value-log.php | 17 ++ 8 files changed, 289 insertions(+), 77 deletions(-) create mode 100644 app/Admin/Controllers/SalesValueLogController.php create mode 100644 app/Admin/Renderable/UserSalesValueLogSimpleTable.php create mode 100644 app/Admin/Repositories/SalesValueLog.php create mode 100644 resources/lang/zh_CN/sales-value-log.php diff --git a/app/Admin/Controllers/SalesValueLogController.php b/app/Admin/Controllers/SalesValueLogController.php new file mode 100644 index 00000000..7ad55fec --- /dev/null +++ b/app/Admin/Controllers/SalesValueLogController.php @@ -0,0 +1,86 @@ +column('id')->sortable(); + $grid->column('user.phone'); + $grid->column('user.userInfo.nickname'); + // $grid->column('order_id'); + // $grid->column('order_user_id'); + $grid->column('type')->using([ + 1=>'个人', + 2=>'团队', + ]); + $grid->column('change_sales_value'); + $grid->column('remarks'); + $grid->column('created_at'); + $grid->column('updated_at')->sortable(); + + $grid->filter(function (Grid\Filter $filter) { + $filter->panel(false); + $filter->equal('user.phone')->width(3); + $filter->between('created_at')->dateTime()->width(7); + }); + }); + } + + /** + * Make a show builder. + * + * @param mixed $id + * + * @return Show + */ + protected function detail($id) + { + return Show::make($id, new SalesValueLog(), function (Show $show) { + $show->field('id'); + $show->field('user_id'); + $show->field('order_id'); + $show->field('order_user_id'); + $show->field('type'); + $show->field('change_sales_value'); + $show->field('remarks'); + $show->field('created_at'); + $show->field('updated_at'); + }); + } + + /** + * Make a form builder. + * + * @return Form + */ + protected function form() + { + return Form::make(new SalesValueLog(), function (Form $form) { + $form->display('id'); + $form->text('user_id'); + $form->text('order_id'); + $form->text('order_user_id'); + $form->text('type'); + $form->text('change_sales_value'); + $form->text('remarks'); + + $form->display('created_at'); + $form->display('updated_at'); + }); + } +} diff --git a/app/Admin/Controllers/UserController.php b/app/Admin/Controllers/UserController.php index c7604607..888db266 100644 --- a/app/Admin/Controllers/UserController.php +++ b/app/Admin/Controllers/UserController.php @@ -17,6 +17,7 @@ use App\Admin\Renderable\Grid\Filter\PriceBetween; use App\Admin\Renderable\UserBalanceLogSimpleTable; use App\Admin\Renderable\UserFansSimpleTable; use App\Admin\Renderable\UserInviterSimpleTable; +use App\Admin\Renderable\UserSalesValueLogSimpleTable; use App\Admin\Renderable\UserWalletLogSimpleTable; use App\Admin\Repositories\User; use App\Exceptions\BizException; @@ -66,7 +67,11 @@ class UserController extends AdminController $grid->column('userInfo.inviterInfo.user.phone')->copyable(); $grid->column('userInfo.growth_value')->filter( Grid\Column\Filter\Between::make() - ); + )->modal(function ($modal) { + $modal->title('消费值'); + return UserSalesValueLogSimpleTable::make(['id'=>$this->id]); + })->setHeaderAttributes(['style' => 'color:#5b69bc']); + ; $grid->column('userInfo.group_sales_value')->filter( Grid\Column\Filter\Between::make() ); diff --git a/app/Admin/Renderable/UserSalesValueLogSimpleTable.php b/app/Admin/Renderable/UserSalesValueLogSimpleTable.php new file mode 100644 index 00000000..5d44c41e --- /dev/null +++ b/app/Admin/Renderable/UserSalesValueLogSimpleTable.php @@ -0,0 +1,56 @@ +payload['id'] ?? 0; + $builder = SalesValueLog::query(); + return Grid::make($builder, function (Grid $grid) use ($userId) { + $grid->model()->where('user_id', $userId); + $grid->column('type')->using([ + 1=>'个人', + 2=>'团队', + ]); + $grid->column('change_sales_value', '变动'); + $grid->column('remarks', '备注'); + $grid->column('created_at', '创建时间')->sortable(); + // $grid->column('updated_at') + // $grid->withBorder(); + $grid->model()->orderBy('created_at', 'desc'); + // $grid->disableRefreshButton(); + $grid->disableActions(); + $grid->disableCreateButton(); + $grid->header(function ($collection) use ($grid) { + $query = SalesValueLog::query(); + + // 拿到表格筛选 where 条件数组进行遍历 + $grid->model()->getQueries()->unique()->each(function ($value) use (&$query) { + // dd($value); + if (in_array($value['method'], ['paginate', 'get', 'orderBy', 'orderByDesc'], true)) { + return; + } + + $query = call_user_func_array([$query, $value['method']], $value['arguments'] ?? []); + }); + // 查出统计数据 + $salesValue1 = (clone $query)->where('type', '1')->sum('change_sales_value'); + $salesValue2 = (clone $query)->where('type', '2')->sum('change_sales_value'); + // 自定义组件 + return "
个人消费值:".$salesValue1.'
团队消费值:'.$salesValue2.'
'; + }); + $grid->filter(function (Grid\Filter $filter) { + $filter->between('created_at', '时间')->date()->default([ + 'start'=>now()->subDays(30)->toDateString(), + 'end'=>now()->toDateString(), + ]); + }); + }); + } +} diff --git a/app/Admin/Repositories/SalesValueLog.php b/app/Admin/Repositories/SalesValueLog.php new file mode 100644 index 00000000..85a10305 --- /dev/null +++ b/app/Admin/Repositories/SalesValueLog.php @@ -0,0 +1,16 @@ +get('import-job-logs', 'ImportJobLogController@index')->name('import_job_logs.index'); + $router->resource('sales-value-logs', 'SalesValueLogController')->only( + ['index'] + )->names('sales_value_logs'); + //经销商 $router->resource('dealer-products', 'DealerProductController')->names('dealer_products'); diff --git a/app/Models/SalesValueLog.php b/app/Models/SalesValueLog.php index 630a7ade..681bd474 100644 --- a/app/Models/SalesValueLog.php +++ b/app/Models/SalesValueLog.php @@ -2,10 +2,13 @@ namespace App\Models; +use Dcat\Admin\Traits\HasDateTimeFormatter; use Illuminate\Database\Eloquent\Model; class SalesValueLog extends Model { + use HasDateTimeFormatter; + public const TYPE_INDIVIDUAL = 1; public const TYPE_TEAM = 2; @@ -27,4 +30,9 @@ class SalesValueLog extends Model 'change_sales_value', 'remarks', ]; + + public function user() + { + return $this->belongsTo(User::class); + } } diff --git a/dcat_admin_ide_helper.php b/dcat_admin_ide_helper.php index 6bc8486a..a2d41b6c 100644 --- a/dcat_admin_ide_helper.php +++ b/dcat_admin_ide_helper.php @@ -11,6 +11,7 @@ namespace Dcat\Admin { use Illuminate\Support\Collection; /** + * @property Grid\Column|Collection width * @property Grid\Column|Collection created_at * @property Grid\Column|Collection dimensions * @property Grid\Column|Collection id @@ -18,13 +19,6 @@ namespace Dcat\Admin { * @property Grid\Column|Collection key * @property Grid\Column|Collection name * @property Grid\Column|Collection updated_at - * @property Grid\Column|Collection address - * @property Grid\Column|Collection consignee - * @property Grid\Column|Collection is_default - * @property Grid\Column|Collection telephone - * @property Grid\Column|Collection user_id - * @property Grid\Column|Collection zone - * @property Grid\Column|Collection zone_id * @property Grid\Column|Collection detail * @property Grid\Column|Collection type * @property Grid\Column|Collection version @@ -40,6 +34,7 @@ namespace Dcat\Admin { * @property Grid\Column|Collection http_path * @property Grid\Column|Collection slug * @property Grid\Column|Collection role_id + * @property Grid\Column|Collection user_id * @property Grid\Column|Collection value * @property Grid\Column|Collection avatar * @property Grid\Column|Collection password @@ -64,6 +59,7 @@ namespace Dcat\Admin { * @property Grid\Column|Collection tracking_number * @property Grid\Column|Collection before_agent_level * @property Grid\Column|Collection change_agent_level + * @property Grid\Column|Collection remark * @property Grid\Column|Collection apk_link * @property Grid\Column|Collection cate * @property Grid\Column|Collection context @@ -96,9 +92,10 @@ namespace Dcat\Admin { * @property Grid\Column|Collection continue_click_times * @property Grid\Column|Collection last_click_at * @property Grid\Column|Collection coupon_id + * @property Grid\Column|Collection is_enable * @property Grid\Column|Collection ranges - * @property Grid\Column|Collection status * @property Grid\Column|Collection administrator_id + * @property Grid\Column|Collection status * @property Grid\Column|Collection task_id * @property Grid\Column|Collection limit * @property Grid\Column|Collection sent @@ -109,20 +106,20 @@ namespace Dcat\Admin { * @property Grid\Column|Collection use_start_at * @property Grid\Column|Collection lvl * @property Grid\Column|Collection order_completed_at - * @property Grid\Column|Collection remark * @property Grid\Column|Collection total_amount * @property Grid\Column|Collection earningable_id * @property Grid\Column|Collection earningable_type * @property Grid\Column|Collection fee * @property Grid\Column|Collection fee_rate - * @property Grid\Column|Collection is_manager * @property Grid\Column|Collection pay_at * @property Grid\Column|Collection pay_image * @property Grid\Column|Collection pay_info + * @property Grid\Column|Collection pay_way * @property Grid\Column|Collection payer_id * @property Grid\Column|Collection settle_at * @property Grid\Column|Collection total_earnings * @property Grid\Column|Collection end_at + * @property Grid\Column|Collection is_manager * @property Grid\Column|Collection is_settle * @property Grid\Column|Collection real_amount * @property Grid\Column|Collection start_at @@ -133,13 +130,16 @@ namespace Dcat\Admin { * @property Grid\Column|Collection price * @property Grid\Column|Collection qty * @property Grid\Column|Collection sale_price + * @property Grid\Column|Collection reason * @property Grid\Column|Collection allocated_at * @property Grid\Column|Collection consignee_address * @property Grid\Column|Collection consignee_name * @property Grid\Column|Collection consignee_telephone * @property Grid\Column|Collection consignee_zone * @property Grid\Column|Collection consignor_id + * @property Grid\Column|Collection out_trade_no * @property Grid\Column|Collection paied_time + * @property Grid\Column|Collection pay_sn * @property Grid\Column|Collection pay_time * @property Grid\Column|Collection settle_state * @property Grid\Column|Collection shipping_time @@ -160,8 +160,12 @@ namespace Dcat\Admin { * @property Grid\Column|Collection change_from_purchase_subsidy_id * @property Grid\Column|Collection purchase_subsidy_id * @property Grid\Column|Collection change_sales_value + * @property Grid\Column|Collection dealer_price + * @property Grid\Column|Collection quantity + * @property Grid\Column|Collection sell_price * @property Grid\Column|Collection before_lvl * @property Grid\Column|Collection change_lvl + * @property Grid\Column|Collection revoke_id * @property Grid\Column|Collection account_amount * @property Grid\Column|Collection rate * @property Grid\Column|Collection service_amount @@ -187,7 +191,6 @@ namespace Dcat\Admin { * @property Grid\Column|Collection queue * @property Grid\Column|Collection uuid * @property Grid\Column|Collection job_id - * @property Grid\Column|Collection reason * @property Grid\Column|Collection fails * @property Grid\Column|Collection file * @property Grid\Column|Collection success @@ -197,7 +200,6 @@ namespace Dcat\Admin { * @property Grid\Column|Collection is_push * @property Grid\Column|Collection message_id * @property Grid\Column|Collection order_package_id - * @property Grid\Column|Collection quantity * @property Grid\Column|Collection checked_at * @property Grid\Column|Collection is_failed * @property Grid\Column|Collection last_news @@ -210,7 +212,6 @@ namespace Dcat\Admin { * @property Grid\Column|Collection gift_for_sku_id * @property Grid\Column|Collection reduced_amount * @property Grid\Column|Collection remain_quantity - * @property Grid\Column|Collection sell_price * @property Grid\Column|Collection sku_id * @property Grid\Column|Collection specs * @property Grid\Column|Collection spu_id @@ -220,10 +221,8 @@ namespace Dcat\Admin { * @property Grid\Column|Collection max * @property Grid\Column|Collection auto_complete_at * @property Grid\Column|Collection is_change + * @property Grid\Column|Collection is_settlable * @property Grid\Column|Collection note - * @property Grid\Column|Collection out_trade_no - * @property Grid\Column|Collection pay_sn - * @property Grid\Column|Collection pay_way * @property Grid\Column|Collection products_total_amount * @property Grid\Column|Collection shipping_fee * @property Grid\Column|Collection shipping_state @@ -244,7 +243,6 @@ namespace Dcat\Admin { * @property Grid\Column|Collection reviewer_id * @property Grid\Column|Collection buynote_id * @property Grid\Column|Collection cost_price - * @property Grid\Column|Collection growth_value * @property Grid\Column|Collection market_price * @property Grid\Column|Collection media * @property Grid\Column|Collection release_at @@ -262,14 +260,20 @@ namespace Dcat\Admin { * @property Grid\Column|Collection size * @property Grid\Column|Collection x * @property Grid\Column|Collection y + * @property Grid\Column|Collection address + * @property Grid\Column|Collection consignee + * @property Grid\Column|Collection is_default + * @property Grid\Column|Collection telephone + * @property Grid\Column|Collection zone + * @property Grid\Column|Collection zone_id * @property Grid\Column|Collection rule_id * @property Grid\Column|Collection template_id * @property Grid\Column|Collection zones * @property Grid\Column|Collection expires_at * @property Grid\Column|Collection phone + * @property Grid\Column|Collection socialite_id + * @property Grid\Column|Collection socialite_type * @property Grid\Column|Collection tag_id - * @property Grid\Column|Collection tag_log_id - * @property Grid\Column|Collection tag_log_type * @property Grid\Column|Collection taggable_id * @property Grid\Column|Collection taggable_type * @property Grid\Column|Collection bank_description @@ -289,6 +293,7 @@ namespace Dcat\Admin { * @property Grid\Column|Collection depth * @property Grid\Column|Collection gender * @property Grid\Column|Collection group_sales_value + * @property Grid\Column|Collection growth_value * @property Grid\Column|Collection inviter_id * @property Grid\Column|Collection nickname * @property Grid\Column|Collection pre_growth_value @@ -305,6 +310,7 @@ namespace Dcat\Admin { * @property Grid\Column|Collection register_ip * @property Grid\Column|Collection status_remark * + * @method Grid\Column|Collection width(string $label = null) * @method Grid\Column|Collection created_at(string $label = null) * @method Grid\Column|Collection dimensions(string $label = null) * @method Grid\Column|Collection id(string $label = null) @@ -312,13 +318,6 @@ namespace Dcat\Admin { * @method Grid\Column|Collection key(string $label = null) * @method Grid\Column|Collection name(string $label = null) * @method Grid\Column|Collection updated_at(string $label = null) - * @method Grid\Column|Collection address(string $label = null) - * @method Grid\Column|Collection consignee(string $label = null) - * @method Grid\Column|Collection is_default(string $label = null) - * @method Grid\Column|Collection telephone(string $label = null) - * @method Grid\Column|Collection user_id(string $label = null) - * @method Grid\Column|Collection zone(string $label = null) - * @method Grid\Column|Collection zone_id(string $label = null) * @method Grid\Column|Collection detail(string $label = null) * @method Grid\Column|Collection type(string $label = null) * @method Grid\Column|Collection version(string $label = null) @@ -334,6 +333,7 @@ namespace Dcat\Admin { * @method Grid\Column|Collection http_path(string $label = null) * @method Grid\Column|Collection slug(string $label = null) * @method Grid\Column|Collection role_id(string $label = null) + * @method Grid\Column|Collection user_id(string $label = null) * @method Grid\Column|Collection value(string $label = null) * @method Grid\Column|Collection avatar(string $label = null) * @method Grid\Column|Collection password(string $label = null) @@ -358,6 +358,7 @@ namespace Dcat\Admin { * @method Grid\Column|Collection tracking_number(string $label = null) * @method Grid\Column|Collection before_agent_level(string $label = null) * @method Grid\Column|Collection change_agent_level(string $label = null) + * @method Grid\Column|Collection remark(string $label = null) * @method Grid\Column|Collection apk_link(string $label = null) * @method Grid\Column|Collection cate(string $label = null) * @method Grid\Column|Collection context(string $label = null) @@ -390,9 +391,10 @@ namespace Dcat\Admin { * @method Grid\Column|Collection continue_click_times(string $label = null) * @method Grid\Column|Collection last_click_at(string $label = null) * @method Grid\Column|Collection coupon_id(string $label = null) + * @method Grid\Column|Collection is_enable(string $label = null) * @method Grid\Column|Collection ranges(string $label = null) - * @method Grid\Column|Collection status(string $label = null) * @method Grid\Column|Collection administrator_id(string $label = null) + * @method Grid\Column|Collection status(string $label = null) * @method Grid\Column|Collection task_id(string $label = null) * @method Grid\Column|Collection limit(string $label = null) * @method Grid\Column|Collection sent(string $label = null) @@ -403,20 +405,20 @@ namespace Dcat\Admin { * @method Grid\Column|Collection use_start_at(string $label = null) * @method Grid\Column|Collection lvl(string $label = null) * @method Grid\Column|Collection order_completed_at(string $label = null) - * @method Grid\Column|Collection remark(string $label = null) * @method Grid\Column|Collection total_amount(string $label = null) * @method Grid\Column|Collection earningable_id(string $label = null) * @method Grid\Column|Collection earningable_type(string $label = null) * @method Grid\Column|Collection fee(string $label = null) * @method Grid\Column|Collection fee_rate(string $label = null) - * @method Grid\Column|Collection is_manager(string $label = null) * @method Grid\Column|Collection pay_at(string $label = null) * @method Grid\Column|Collection pay_image(string $label = null) * @method Grid\Column|Collection pay_info(string $label = null) + * @method Grid\Column|Collection pay_way(string $label = null) * @method Grid\Column|Collection payer_id(string $label = null) * @method Grid\Column|Collection settle_at(string $label = null) * @method Grid\Column|Collection total_earnings(string $label = null) * @method Grid\Column|Collection end_at(string $label = null) + * @method Grid\Column|Collection is_manager(string $label = null) * @method Grid\Column|Collection is_settle(string $label = null) * @method Grid\Column|Collection real_amount(string $label = null) * @method Grid\Column|Collection start_at(string $label = null) @@ -427,13 +429,16 @@ namespace Dcat\Admin { * @method Grid\Column|Collection price(string $label = null) * @method Grid\Column|Collection qty(string $label = null) * @method Grid\Column|Collection sale_price(string $label = null) + * @method Grid\Column|Collection reason(string $label = null) * @method Grid\Column|Collection allocated_at(string $label = null) * @method Grid\Column|Collection consignee_address(string $label = null) * @method Grid\Column|Collection consignee_name(string $label = null) * @method Grid\Column|Collection consignee_telephone(string $label = null) * @method Grid\Column|Collection consignee_zone(string $label = null) * @method Grid\Column|Collection consignor_id(string $label = null) + * @method Grid\Column|Collection out_trade_no(string $label = null) * @method Grid\Column|Collection paied_time(string $label = null) + * @method Grid\Column|Collection pay_sn(string $label = null) * @method Grid\Column|Collection pay_time(string $label = null) * @method Grid\Column|Collection settle_state(string $label = null) * @method Grid\Column|Collection shipping_time(string $label = null) @@ -454,8 +459,12 @@ namespace Dcat\Admin { * @method Grid\Column|Collection change_from_purchase_subsidy_id(string $label = null) * @method Grid\Column|Collection purchase_subsidy_id(string $label = null) * @method Grid\Column|Collection change_sales_value(string $label = null) + * @method Grid\Column|Collection dealer_price(string $label = null) + * @method Grid\Column|Collection quantity(string $label = null) + * @method Grid\Column|Collection sell_price(string $label = null) * @method Grid\Column|Collection before_lvl(string $label = null) * @method Grid\Column|Collection change_lvl(string $label = null) + * @method Grid\Column|Collection revoke_id(string $label = null) * @method Grid\Column|Collection account_amount(string $label = null) * @method Grid\Column|Collection rate(string $label = null) * @method Grid\Column|Collection service_amount(string $label = null) @@ -481,7 +490,6 @@ namespace Dcat\Admin { * @method Grid\Column|Collection queue(string $label = null) * @method Grid\Column|Collection uuid(string $label = null) * @method Grid\Column|Collection job_id(string $label = null) - * @method Grid\Column|Collection reason(string $label = null) * @method Grid\Column|Collection fails(string $label = null) * @method Grid\Column|Collection file(string $label = null) * @method Grid\Column|Collection success(string $label = null) @@ -491,7 +499,6 @@ namespace Dcat\Admin { * @method Grid\Column|Collection is_push(string $label = null) * @method Grid\Column|Collection message_id(string $label = null) * @method Grid\Column|Collection order_package_id(string $label = null) - * @method Grid\Column|Collection quantity(string $label = null) * @method Grid\Column|Collection checked_at(string $label = null) * @method Grid\Column|Collection is_failed(string $label = null) * @method Grid\Column|Collection last_news(string $label = null) @@ -504,7 +511,6 @@ namespace Dcat\Admin { * @method Grid\Column|Collection gift_for_sku_id(string $label = null) * @method Grid\Column|Collection reduced_amount(string $label = null) * @method Grid\Column|Collection remain_quantity(string $label = null) - * @method Grid\Column|Collection sell_price(string $label = null) * @method Grid\Column|Collection sku_id(string $label = null) * @method Grid\Column|Collection specs(string $label = null) * @method Grid\Column|Collection spu_id(string $label = null) @@ -514,10 +520,8 @@ namespace Dcat\Admin { * @method Grid\Column|Collection max(string $label = null) * @method Grid\Column|Collection auto_complete_at(string $label = null) * @method Grid\Column|Collection is_change(string $label = null) + * @method Grid\Column|Collection is_settlable(string $label = null) * @method Grid\Column|Collection note(string $label = null) - * @method Grid\Column|Collection out_trade_no(string $label = null) - * @method Grid\Column|Collection pay_sn(string $label = null) - * @method Grid\Column|Collection pay_way(string $label = null) * @method Grid\Column|Collection products_total_amount(string $label = null) * @method Grid\Column|Collection shipping_fee(string $label = null) * @method Grid\Column|Collection shipping_state(string $label = null) @@ -538,7 +542,6 @@ namespace Dcat\Admin { * @method Grid\Column|Collection reviewer_id(string $label = null) * @method Grid\Column|Collection buynote_id(string $label = null) * @method Grid\Column|Collection cost_price(string $label = null) - * @method Grid\Column|Collection growth_value(string $label = null) * @method Grid\Column|Collection market_price(string $label = null) * @method Grid\Column|Collection media(string $label = null) * @method Grid\Column|Collection release_at(string $label = null) @@ -556,14 +559,20 @@ namespace Dcat\Admin { * @method Grid\Column|Collection size(string $label = null) * @method Grid\Column|Collection x(string $label = null) * @method Grid\Column|Collection y(string $label = null) + * @method Grid\Column|Collection address(string $label = null) + * @method Grid\Column|Collection consignee(string $label = null) + * @method Grid\Column|Collection is_default(string $label = null) + * @method Grid\Column|Collection telephone(string $label = null) + * @method Grid\Column|Collection zone(string $label = null) + * @method Grid\Column|Collection zone_id(string $label = null) * @method Grid\Column|Collection rule_id(string $label = null) * @method Grid\Column|Collection template_id(string $label = null) * @method Grid\Column|Collection zones(string $label = null) * @method Grid\Column|Collection expires_at(string $label = null) * @method Grid\Column|Collection phone(string $label = null) + * @method Grid\Column|Collection socialite_id(string $label = null) + * @method Grid\Column|Collection socialite_type(string $label = null) * @method Grid\Column|Collection tag_id(string $label = null) - * @method Grid\Column|Collection tag_log_id(string $label = null) - * @method Grid\Column|Collection tag_log_type(string $label = null) * @method Grid\Column|Collection taggable_id(string $label = null) * @method Grid\Column|Collection taggable_type(string $label = null) * @method Grid\Column|Collection bank_description(string $label = null) @@ -583,6 +592,7 @@ namespace Dcat\Admin { * @method Grid\Column|Collection depth(string $label = null) * @method Grid\Column|Collection gender(string $label = null) * @method Grid\Column|Collection group_sales_value(string $label = null) + * @method Grid\Column|Collection growth_value(string $label = null) * @method Grid\Column|Collection inviter_id(string $label = null) * @method Grid\Column|Collection nickname(string $label = null) * @method Grid\Column|Collection pre_growth_value(string $label = null) @@ -604,6 +614,7 @@ namespace Dcat\Admin { class MiniGrid extends Grid {} /** + * @property Show\Field|Collection width * @property Show\Field|Collection created_at * @property Show\Field|Collection dimensions * @property Show\Field|Collection id @@ -611,13 +622,6 @@ namespace Dcat\Admin { * @property Show\Field|Collection key * @property Show\Field|Collection name * @property Show\Field|Collection updated_at - * @property Show\Field|Collection address - * @property Show\Field|Collection consignee - * @property Show\Field|Collection is_default - * @property Show\Field|Collection telephone - * @property Show\Field|Collection user_id - * @property Show\Field|Collection zone - * @property Show\Field|Collection zone_id * @property Show\Field|Collection detail * @property Show\Field|Collection type * @property Show\Field|Collection version @@ -633,6 +637,7 @@ namespace Dcat\Admin { * @property Show\Field|Collection http_path * @property Show\Field|Collection slug * @property Show\Field|Collection role_id + * @property Show\Field|Collection user_id * @property Show\Field|Collection value * @property Show\Field|Collection avatar * @property Show\Field|Collection password @@ -657,6 +662,7 @@ namespace Dcat\Admin { * @property Show\Field|Collection tracking_number * @property Show\Field|Collection before_agent_level * @property Show\Field|Collection change_agent_level + * @property Show\Field|Collection remark * @property Show\Field|Collection apk_link * @property Show\Field|Collection cate * @property Show\Field|Collection context @@ -689,9 +695,10 @@ namespace Dcat\Admin { * @property Show\Field|Collection continue_click_times * @property Show\Field|Collection last_click_at * @property Show\Field|Collection coupon_id + * @property Show\Field|Collection is_enable * @property Show\Field|Collection ranges - * @property Show\Field|Collection status * @property Show\Field|Collection administrator_id + * @property Show\Field|Collection status * @property Show\Field|Collection task_id * @property Show\Field|Collection limit * @property Show\Field|Collection sent @@ -702,20 +709,20 @@ namespace Dcat\Admin { * @property Show\Field|Collection use_start_at * @property Show\Field|Collection lvl * @property Show\Field|Collection order_completed_at - * @property Show\Field|Collection remark * @property Show\Field|Collection total_amount * @property Show\Field|Collection earningable_id * @property Show\Field|Collection earningable_type * @property Show\Field|Collection fee * @property Show\Field|Collection fee_rate - * @property Show\Field|Collection is_manager * @property Show\Field|Collection pay_at * @property Show\Field|Collection pay_image * @property Show\Field|Collection pay_info + * @property Show\Field|Collection pay_way * @property Show\Field|Collection payer_id * @property Show\Field|Collection settle_at * @property Show\Field|Collection total_earnings * @property Show\Field|Collection end_at + * @property Show\Field|Collection is_manager * @property Show\Field|Collection is_settle * @property Show\Field|Collection real_amount * @property Show\Field|Collection start_at @@ -726,13 +733,16 @@ namespace Dcat\Admin { * @property Show\Field|Collection price * @property Show\Field|Collection qty * @property Show\Field|Collection sale_price + * @property Show\Field|Collection reason * @property Show\Field|Collection allocated_at * @property Show\Field|Collection consignee_address * @property Show\Field|Collection consignee_name * @property Show\Field|Collection consignee_telephone * @property Show\Field|Collection consignee_zone * @property Show\Field|Collection consignor_id + * @property Show\Field|Collection out_trade_no * @property Show\Field|Collection paied_time + * @property Show\Field|Collection pay_sn * @property Show\Field|Collection pay_time * @property Show\Field|Collection settle_state * @property Show\Field|Collection shipping_time @@ -753,8 +763,12 @@ namespace Dcat\Admin { * @property Show\Field|Collection change_from_purchase_subsidy_id * @property Show\Field|Collection purchase_subsidy_id * @property Show\Field|Collection change_sales_value + * @property Show\Field|Collection dealer_price + * @property Show\Field|Collection quantity + * @property Show\Field|Collection sell_price * @property Show\Field|Collection before_lvl * @property Show\Field|Collection change_lvl + * @property Show\Field|Collection revoke_id * @property Show\Field|Collection account_amount * @property Show\Field|Collection rate * @property Show\Field|Collection service_amount @@ -780,7 +794,6 @@ namespace Dcat\Admin { * @property Show\Field|Collection queue * @property Show\Field|Collection uuid * @property Show\Field|Collection job_id - * @property Show\Field|Collection reason * @property Show\Field|Collection fails * @property Show\Field|Collection file * @property Show\Field|Collection success @@ -790,7 +803,6 @@ namespace Dcat\Admin { * @property Show\Field|Collection is_push * @property Show\Field|Collection message_id * @property Show\Field|Collection order_package_id - * @property Show\Field|Collection quantity * @property Show\Field|Collection checked_at * @property Show\Field|Collection is_failed * @property Show\Field|Collection last_news @@ -803,7 +815,6 @@ namespace Dcat\Admin { * @property Show\Field|Collection gift_for_sku_id * @property Show\Field|Collection reduced_amount * @property Show\Field|Collection remain_quantity - * @property Show\Field|Collection sell_price * @property Show\Field|Collection sku_id * @property Show\Field|Collection specs * @property Show\Field|Collection spu_id @@ -813,10 +824,8 @@ namespace Dcat\Admin { * @property Show\Field|Collection max * @property Show\Field|Collection auto_complete_at * @property Show\Field|Collection is_change + * @property Show\Field|Collection is_settlable * @property Show\Field|Collection note - * @property Show\Field|Collection out_trade_no - * @property Show\Field|Collection pay_sn - * @property Show\Field|Collection pay_way * @property Show\Field|Collection products_total_amount * @property Show\Field|Collection shipping_fee * @property Show\Field|Collection shipping_state @@ -837,7 +846,6 @@ namespace Dcat\Admin { * @property Show\Field|Collection reviewer_id * @property Show\Field|Collection buynote_id * @property Show\Field|Collection cost_price - * @property Show\Field|Collection growth_value * @property Show\Field|Collection market_price * @property Show\Field|Collection media * @property Show\Field|Collection release_at @@ -855,14 +863,20 @@ namespace Dcat\Admin { * @property Show\Field|Collection size * @property Show\Field|Collection x * @property Show\Field|Collection y + * @property Show\Field|Collection address + * @property Show\Field|Collection consignee + * @property Show\Field|Collection is_default + * @property Show\Field|Collection telephone + * @property Show\Field|Collection zone + * @property Show\Field|Collection zone_id * @property Show\Field|Collection rule_id * @property Show\Field|Collection template_id * @property Show\Field|Collection zones * @property Show\Field|Collection expires_at * @property Show\Field|Collection phone + * @property Show\Field|Collection socialite_id + * @property Show\Field|Collection socialite_type * @property Show\Field|Collection tag_id - * @property Show\Field|Collection tag_log_id - * @property Show\Field|Collection tag_log_type * @property Show\Field|Collection taggable_id * @property Show\Field|Collection taggable_type * @property Show\Field|Collection bank_description @@ -882,6 +896,7 @@ namespace Dcat\Admin { * @property Show\Field|Collection depth * @property Show\Field|Collection gender * @property Show\Field|Collection group_sales_value + * @property Show\Field|Collection growth_value * @property Show\Field|Collection inviter_id * @property Show\Field|Collection nickname * @property Show\Field|Collection pre_growth_value @@ -898,6 +913,7 @@ namespace Dcat\Admin { * @property Show\Field|Collection register_ip * @property Show\Field|Collection status_remark * + * @method Show\Field|Collection width(string $label = null) * @method Show\Field|Collection created_at(string $label = null) * @method Show\Field|Collection dimensions(string $label = null) * @method Show\Field|Collection id(string $label = null) @@ -905,13 +921,6 @@ namespace Dcat\Admin { * @method Show\Field|Collection key(string $label = null) * @method Show\Field|Collection name(string $label = null) * @method Show\Field|Collection updated_at(string $label = null) - * @method Show\Field|Collection address(string $label = null) - * @method Show\Field|Collection consignee(string $label = null) - * @method Show\Field|Collection is_default(string $label = null) - * @method Show\Field|Collection telephone(string $label = null) - * @method Show\Field|Collection user_id(string $label = null) - * @method Show\Field|Collection zone(string $label = null) - * @method Show\Field|Collection zone_id(string $label = null) * @method Show\Field|Collection detail(string $label = null) * @method Show\Field|Collection type(string $label = null) * @method Show\Field|Collection version(string $label = null) @@ -927,6 +936,7 @@ namespace Dcat\Admin { * @method Show\Field|Collection http_path(string $label = null) * @method Show\Field|Collection slug(string $label = null) * @method Show\Field|Collection role_id(string $label = null) + * @method Show\Field|Collection user_id(string $label = null) * @method Show\Field|Collection value(string $label = null) * @method Show\Field|Collection avatar(string $label = null) * @method Show\Field|Collection password(string $label = null) @@ -951,6 +961,7 @@ namespace Dcat\Admin { * @method Show\Field|Collection tracking_number(string $label = null) * @method Show\Field|Collection before_agent_level(string $label = null) * @method Show\Field|Collection change_agent_level(string $label = null) + * @method Show\Field|Collection remark(string $label = null) * @method Show\Field|Collection apk_link(string $label = null) * @method Show\Field|Collection cate(string $label = null) * @method Show\Field|Collection context(string $label = null) @@ -983,9 +994,10 @@ namespace Dcat\Admin { * @method Show\Field|Collection continue_click_times(string $label = null) * @method Show\Field|Collection last_click_at(string $label = null) * @method Show\Field|Collection coupon_id(string $label = null) + * @method Show\Field|Collection is_enable(string $label = null) * @method Show\Field|Collection ranges(string $label = null) - * @method Show\Field|Collection status(string $label = null) * @method Show\Field|Collection administrator_id(string $label = null) + * @method Show\Field|Collection status(string $label = null) * @method Show\Field|Collection task_id(string $label = null) * @method Show\Field|Collection limit(string $label = null) * @method Show\Field|Collection sent(string $label = null) @@ -996,20 +1008,20 @@ namespace Dcat\Admin { * @method Show\Field|Collection use_start_at(string $label = null) * @method Show\Field|Collection lvl(string $label = null) * @method Show\Field|Collection order_completed_at(string $label = null) - * @method Show\Field|Collection remark(string $label = null) * @method Show\Field|Collection total_amount(string $label = null) * @method Show\Field|Collection earningable_id(string $label = null) * @method Show\Field|Collection earningable_type(string $label = null) * @method Show\Field|Collection fee(string $label = null) * @method Show\Field|Collection fee_rate(string $label = null) - * @method Show\Field|Collection is_manager(string $label = null) * @method Show\Field|Collection pay_at(string $label = null) * @method Show\Field|Collection pay_image(string $label = null) * @method Show\Field|Collection pay_info(string $label = null) + * @method Show\Field|Collection pay_way(string $label = null) * @method Show\Field|Collection payer_id(string $label = null) * @method Show\Field|Collection settle_at(string $label = null) * @method Show\Field|Collection total_earnings(string $label = null) * @method Show\Field|Collection end_at(string $label = null) + * @method Show\Field|Collection is_manager(string $label = null) * @method Show\Field|Collection is_settle(string $label = null) * @method Show\Field|Collection real_amount(string $label = null) * @method Show\Field|Collection start_at(string $label = null) @@ -1020,13 +1032,16 @@ namespace Dcat\Admin { * @method Show\Field|Collection price(string $label = null) * @method Show\Field|Collection qty(string $label = null) * @method Show\Field|Collection sale_price(string $label = null) + * @method Show\Field|Collection reason(string $label = null) * @method Show\Field|Collection allocated_at(string $label = null) * @method Show\Field|Collection consignee_address(string $label = null) * @method Show\Field|Collection consignee_name(string $label = null) * @method Show\Field|Collection consignee_telephone(string $label = null) * @method Show\Field|Collection consignee_zone(string $label = null) * @method Show\Field|Collection consignor_id(string $label = null) + * @method Show\Field|Collection out_trade_no(string $label = null) * @method Show\Field|Collection paied_time(string $label = null) + * @method Show\Field|Collection pay_sn(string $label = null) * @method Show\Field|Collection pay_time(string $label = null) * @method Show\Field|Collection settle_state(string $label = null) * @method Show\Field|Collection shipping_time(string $label = null) @@ -1047,8 +1062,12 @@ namespace Dcat\Admin { * @method Show\Field|Collection change_from_purchase_subsidy_id(string $label = null) * @method Show\Field|Collection purchase_subsidy_id(string $label = null) * @method Show\Field|Collection change_sales_value(string $label = null) + * @method Show\Field|Collection dealer_price(string $label = null) + * @method Show\Field|Collection quantity(string $label = null) + * @method Show\Field|Collection sell_price(string $label = null) * @method Show\Field|Collection before_lvl(string $label = null) * @method Show\Field|Collection change_lvl(string $label = null) + * @method Show\Field|Collection revoke_id(string $label = null) * @method Show\Field|Collection account_amount(string $label = null) * @method Show\Field|Collection rate(string $label = null) * @method Show\Field|Collection service_amount(string $label = null) @@ -1074,7 +1093,6 @@ namespace Dcat\Admin { * @method Show\Field|Collection queue(string $label = null) * @method Show\Field|Collection uuid(string $label = null) * @method Show\Field|Collection job_id(string $label = null) - * @method Show\Field|Collection reason(string $label = null) * @method Show\Field|Collection fails(string $label = null) * @method Show\Field|Collection file(string $label = null) * @method Show\Field|Collection success(string $label = null) @@ -1084,7 +1102,6 @@ namespace Dcat\Admin { * @method Show\Field|Collection is_push(string $label = null) * @method Show\Field|Collection message_id(string $label = null) * @method Show\Field|Collection order_package_id(string $label = null) - * @method Show\Field|Collection quantity(string $label = null) * @method Show\Field|Collection checked_at(string $label = null) * @method Show\Field|Collection is_failed(string $label = null) * @method Show\Field|Collection last_news(string $label = null) @@ -1097,7 +1114,6 @@ namespace Dcat\Admin { * @method Show\Field|Collection gift_for_sku_id(string $label = null) * @method Show\Field|Collection reduced_amount(string $label = null) * @method Show\Field|Collection remain_quantity(string $label = null) - * @method Show\Field|Collection sell_price(string $label = null) * @method Show\Field|Collection sku_id(string $label = null) * @method Show\Field|Collection specs(string $label = null) * @method Show\Field|Collection spu_id(string $label = null) @@ -1107,10 +1123,8 @@ namespace Dcat\Admin { * @method Show\Field|Collection max(string $label = null) * @method Show\Field|Collection auto_complete_at(string $label = null) * @method Show\Field|Collection is_change(string $label = null) + * @method Show\Field|Collection is_settlable(string $label = null) * @method Show\Field|Collection note(string $label = null) - * @method Show\Field|Collection out_trade_no(string $label = null) - * @method Show\Field|Collection pay_sn(string $label = null) - * @method Show\Field|Collection pay_way(string $label = null) * @method Show\Field|Collection products_total_amount(string $label = null) * @method Show\Field|Collection shipping_fee(string $label = null) * @method Show\Field|Collection shipping_state(string $label = null) @@ -1131,7 +1145,6 @@ namespace Dcat\Admin { * @method Show\Field|Collection reviewer_id(string $label = null) * @method Show\Field|Collection buynote_id(string $label = null) * @method Show\Field|Collection cost_price(string $label = null) - * @method Show\Field|Collection growth_value(string $label = null) * @method Show\Field|Collection market_price(string $label = null) * @method Show\Field|Collection media(string $label = null) * @method Show\Field|Collection release_at(string $label = null) @@ -1149,14 +1162,20 @@ namespace Dcat\Admin { * @method Show\Field|Collection size(string $label = null) * @method Show\Field|Collection x(string $label = null) * @method Show\Field|Collection y(string $label = null) + * @method Show\Field|Collection address(string $label = null) + * @method Show\Field|Collection consignee(string $label = null) + * @method Show\Field|Collection is_default(string $label = null) + * @method Show\Field|Collection telephone(string $label = null) + * @method Show\Field|Collection zone(string $label = null) + * @method Show\Field|Collection zone_id(string $label = null) * @method Show\Field|Collection rule_id(string $label = null) * @method Show\Field|Collection template_id(string $label = null) * @method Show\Field|Collection zones(string $label = null) * @method Show\Field|Collection expires_at(string $label = null) * @method Show\Field|Collection phone(string $label = null) + * @method Show\Field|Collection socialite_id(string $label = null) + * @method Show\Field|Collection socialite_type(string $label = null) * @method Show\Field|Collection tag_id(string $label = null) - * @method Show\Field|Collection tag_log_id(string $label = null) - * @method Show\Field|Collection tag_log_type(string $label = null) * @method Show\Field|Collection taggable_id(string $label = null) * @method Show\Field|Collection taggable_type(string $label = null) * @method Show\Field|Collection bank_description(string $label = null) @@ -1176,6 +1195,7 @@ namespace Dcat\Admin { * @method Show\Field|Collection depth(string $label = null) * @method Show\Field|Collection gender(string $label = null) * @method Show\Field|Collection group_sales_value(string $label = null) + * @method Show\Field|Collection growth_value(string $label = null) * @method Show\Field|Collection inviter_id(string $label = null) * @method Show\Field|Collection nickname(string $label = null) * @method Show\Field|Collection pre_growth_value(string $label = null) diff --git a/resources/lang/zh_CN/sales-value-log.php b/resources/lang/zh_CN/sales-value-log.php new file mode 100644 index 00000000..11fe9654 --- /dev/null +++ b/resources/lang/zh_CN/sales-value-log.php @@ -0,0 +1,17 @@ + [ + 'SalesValueLog' => 'SalesValueLog', + 'sales-value-log' => 'SalesValueLog', + ], + 'fields' => [ + 'user_id' => '用户', + 'order_id' => '订单', + 'order_user_id' => '下单用户', + 'type' => '类型', + 'change_sales_value' => '变更销售值', + 'remarks' => '备注', + ], + 'options' => [ + ], +]; From ccafcc58016947fc9ca267e484657a2d119b54d5 Mon Sep 17 00:00:00 2001 From: vine_liutk <961510893@qq.com> Date: Mon, 28 Feb 2022 09:46:45 +0800 Subject: [PATCH 28/39] =?UTF-8?q?=E8=B0=83=E6=95=B4=E8=BF=9B=E8=B4=A7?= =?UTF-8?q?=E8=A1=A5=E8=B4=B4=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Admin/Controllers/DealerPurchaseLogController.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/Admin/Controllers/DealerPurchaseLogController.php b/app/Admin/Controllers/DealerPurchaseLogController.php index e083b976..ad8357eb 100644 --- a/app/Admin/Controllers/DealerPurchaseLogController.php +++ b/app/Admin/Controllers/DealerPurchaseLogController.php @@ -26,7 +26,9 @@ class DealerPurchaseLogController extends AdminController // dd($phone); if ($phone) { $user = User::where('phone', $phone)->first(); - $grid->model()->where('path', 'like', '%-'.$user->id.'-%'); + if ($user) { + $grid->model()->where('path', 'like', '%-'.$user->id.'-%'); + } } $grid->model()->orderBy('id', 'desc');//默认ID倒叙 $grid->column('id')->sortable(); From 8dada477a4dd4d4a6fbdaba0549ff7d61feab965 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=9D=99?= Date: Mon, 28 Feb 2022 10:49:59 +0800 Subject: [PATCH 29/39] =?UTF-8?q?=E7=AD=89=E7=BA=A7=E5=9B=BE=E6=A0=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Admin/Controllers/DealerController.php | 4 ++-- .../Controllers/DealerEarningController.php | 1 - .../Controllers/DealerOrderController.php | 1 - .../Resources/Dealer/DealerFansResource.php | 2 +- .../Http/Resources/Dealer/DealerResource.php | 3 ++- .../Resources/Merchant/UserInfoResource.php | 1 + app/Enums/DealerLvl.php | 20 +++++++++++++++---- app/Models/UserInfo.php | 18 +++++++++++++++++ 8 files changed, 40 insertions(+), 10 deletions(-) diff --git a/app/Admin/Controllers/DealerController.php b/app/Admin/Controllers/DealerController.php index 3bc35c43..3b46a5c1 100644 --- a/app/Admin/Controllers/DealerController.php +++ b/app/Admin/Controllers/DealerController.php @@ -42,7 +42,7 @@ class DealerController extends AdminController $lvlTexts = DealerLvl::texts(); $grid->column('lvl')->display(function () { - return $this->lvl_text; + return $this->lvl->text(); })->filter(Grid\Column\Filter\In::make($lvlTexts)); $grid->column('wallet.balance')->display(function ($value) { return $value ?? 0; @@ -111,7 +111,7 @@ class DealerController extends AdminController // $show->field('id'); $show->field('user.phone'); $show->field('lvl')->as(function () { - return $this->lvl_text; + return $this->lvl->text(); }); $show->field('is_sale')->as(function ($val) { return $val ? '是' : '否'; diff --git a/app/Admin/Controllers/DealerEarningController.php b/app/Admin/Controllers/DealerEarningController.php index ab4dac17..c7a32e39 100644 --- a/app/Admin/Controllers/DealerEarningController.php +++ b/app/Admin/Controllers/DealerEarningController.php @@ -57,7 +57,6 @@ class DealerEarningController extends AdminController // $grid->column('earningable_id'); $grid->column('lvl')->display(function () { return $this->lvl->text(); - // return $this->lvl_text; }); $grid->column('is_manager')->bool(); $grid->column('total_amount')->prepend('¥'); diff --git a/app/Admin/Controllers/DealerOrderController.php b/app/Admin/Controllers/DealerOrderController.php index 19f123e9..5c004b67 100644 --- a/app/Admin/Controllers/DealerOrderController.php +++ b/app/Admin/Controllers/DealerOrderController.php @@ -275,7 +275,6 @@ HTML; $grid->column('user.phone', '手机号'); $grid->column('lvl', '等级')->display(function () { return $this->lvl->text(); - // return $this->lvl_text; }); $grid->column('total_amount', '补贴金额'); $grid->column('remark', '备注'); diff --git a/app/Endpoint/Api/Http/Resources/Dealer/DealerFansResource.php b/app/Endpoint/Api/Http/Resources/Dealer/DealerFansResource.php index 09450b61..3c8b9ab7 100644 --- a/app/Endpoint/Api/Http/Resources/Dealer/DealerFansResource.php +++ b/app/Endpoint/Api/Http/Resources/Dealer/DealerFansResource.php @@ -27,7 +27,7 @@ class DealerFansResource extends JsonResource return $this->dealer->team_sales_value; }, 0), 'lvl_name' => (string) $this->whenLoaded('dealer', function () { - return $this->dealer->lvl_text; + return $this->dealer->lvl->text(); }, '未知'), ]; } diff --git a/app/Endpoint/Api/Http/Resources/Dealer/DealerResource.php b/app/Endpoint/Api/Http/Resources/Dealer/DealerResource.php index f6c3b74e..b1bce8f2 100644 --- a/app/Endpoint/Api/Http/Resources/Dealer/DealerResource.php +++ b/app/Endpoint/Api/Http/Resources/Dealer/DealerResource.php @@ -16,7 +16,8 @@ class DealerResource extends JsonResource { return [ 'lvl' => $this->lvl, - 'lvl_name'=> $this->lvl_text, + 'lvl_icon' => $this->lvl->icon(), + 'lvl_name'=> $this->lvl->text(), 'is_sale' => $this->is_sale, 'guanli_values'=> bcdiv($this->calculate_total_amount, '1', 2), //预计管理津贴 'team_sales_value' => $this->team_sales_value, // 团队业绩 diff --git a/app/Endpoint/Api/Http/Resources/Merchant/UserInfoResource.php b/app/Endpoint/Api/Http/Resources/Merchant/UserInfoResource.php index 8eff3b9d..300e20f5 100644 --- a/app/Endpoint/Api/Http/Resources/Merchant/UserInfoResource.php +++ b/app/Endpoint/Api/Http/Resources/Merchant/UserInfoResource.php @@ -23,6 +23,7 @@ class UserInfoResource extends JsonResource 'points' => (int) $this->points, 'quota_v2' => $this->quota_v2, 'quota_v1' => $this->quota_v1, + 'agent_level_icon' => $this->agent_level_icon, 'agent_level_name' => $this->agent_level_name, ]; } diff --git a/app/Enums/DealerLvl.php b/app/Enums/DealerLvl.php index 9570ce7f..69f8424d 100644 --- a/app/Enums/DealerLvl.php +++ b/app/Enums/DealerLvl.php @@ -25,6 +25,18 @@ enum DealerLvl: int { }; } + /** + * @return string + */ + public function icon() + { + return match ($this) { + static::Secondary => 'https://cdn.zichunsheng.cn/statics/icons/dealer_lvl_5.png', + static::Top => 'https://cdn.zichunsheng.cn/statics/icons/dealer_lvl_6.png', + default => '', + }; + } + /** * @return string */ @@ -35,8 +47,8 @@ enum DealerLvl: int { static::Gold => '金牌经销商', static::Special => '特邀经销商', static::Contracted => '签约经销商', - static::Secondary => '二级经销商', - static::Top => '一级经销商', + static::Secondary => '签约经销商II', + static::Top => '签约经销商I', }; } @@ -50,8 +62,8 @@ enum DealerLvl: int { static::Gold->value => '金牌经销商', static::Special->value => '特邀经销商', static::Contracted->value => '签约经销商', - static::Secondary->value => '二级经销商', - static::Top->value => '一级经销商', + static::Secondary->value => '签约经销商II', + static::Top->value => '签约经销商I', ]; } } diff --git a/app/Models/UserInfo.php b/app/Models/UserInfo.php index 059f1ae5..7e443486 100644 --- a/app/Models/UserInfo.php +++ b/app/Models/UserInfo.php @@ -125,6 +125,19 @@ class UserInfo extends Model self::AGENT_LEVEL_DIRECTOR => '默认用户', ]; + /** + * 代理等级图标 + * + * @var array + */ + public static $agentLevelIcons = [ + self::AGENT_LEVEL_COMMUNITY => 'https://cdn.zichunsheng.cn/statics/icons/lvl_2.png', + self::AGENT_LEVEL_DISTRICT => 'https://cdn.zichunsheng.cn/statics/icons/lvl_3.png', + self::AGENT_LEVEL_CITY => 'https://cdn.zichunsheng.cn/statics/icons/lvl_4.png', + self::AGENT_LEVEL_PROVINCE => 'https://cdn.zichunsheng.cn/statics/icons/lvl_5.png', + self::AGENT_LEVEL_BRANCH => 'https://cdn.zichunsheng.cn/statics/icons/lvl_6.png', + ]; + /** * {@inheritdoc} */ @@ -458,6 +471,11 @@ class UserInfo extends Model return static::$agentLevelTexts[$this->agent_level] ?? '未知'; } + public function getAgentLevelIconAttribute(): string + { + return static::$agentLevelIcons[$this->agent_level] ?? ''; + } + /** * 获取完整的邀请路径 * From 25b12506d66336ca85ac27ed0800485503e1622c Mon Sep 17 00:00:00 2001 From: vine_liutk <961510893@qq.com> Date: Mon, 28 Feb 2022 10:55:14 +0800 Subject: [PATCH 30/39] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E5=86=B2=E7=AA=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Admin/Controllers/UserController.php | 1 - .../Renderable/DealerSubordinateCard.php | 59 +++++++++++++++++++ 2 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 app/Admin/Renderable/DealerSubordinateCard.php diff --git a/app/Admin/Controllers/UserController.php b/app/Admin/Controllers/UserController.php index 888db266..bcd96658 100644 --- a/app/Admin/Controllers/UserController.php +++ b/app/Admin/Controllers/UserController.php @@ -71,7 +71,6 @@ class UserController extends AdminController $modal->title('消费值'); return UserSalesValueLogSimpleTable::make(['id'=>$this->id]); })->setHeaderAttributes(['style' => 'color:#5b69bc']); - ; $grid->column('userInfo.group_sales_value')->filter( Grid\Column\Filter\Between::make() ); diff --git a/app/Admin/Renderable/DealerSubordinateCard.php b/app/Admin/Renderable/DealerSubordinateCard.php new file mode 100644 index 00000000..6f35767f --- /dev/null +++ b/app/Admin/Renderable/DealerSubordinateCard.php @@ -0,0 +1,59 @@ +id; + // dd($id); + $query = DB::table('users') + ->join('user_infos', 'users.id', '=', 'user_infos.user_id') + ->join('dealers', 'users.id', '=', 'dealers.user_id'); + $userInfo = UserInfo::where('user_id', $id)->first(); + // 查询数据逻辑 + $data = [ + 'top'=> (clone $query)->whereNotNull('users.phone')->where('dealers.lvl', 6)->where('user_infos.path', 'like', $userInfo->full_path.'%')->count(), + 'secondary'=> (clone $query)->whereNotNull('users.phone')->where('dealers.lvl', 5)->where('user_infos.path', 'like', $userInfo->full_path.'%')->count(), + 'contracted'=> (clone $query)->whereNotNull('users.phone')->where('dealers.lvl', 4)->where('user_infos.path', 'like', $userInfo->full_path.'%')->count(), + 'special'=> (clone $query)->whereNotNull('users.phone')->where('dealers.lvl', 3)->where('user_infos.path', 'like', $userInfo->full_path.'%')->count(), + 'gold'=> (clone $query)->whereNotNull('users.phone')->where('dealers.lvl', 2)->where('user_infos.path', 'like', $userInfo->full_path.'%')->count(), + ]; + + // 这里可以返回内置组件,也可以返回视图文件或HTML字符串 + return + << + +
+

{$data['top']}

+ 一级经销商 +
+
+

{$data['secondary']}

+ 二级经销商 +
+
+

{$data['contracted']}

+ 签约经销商 +
+
+
+
+

{$data['special']}

+ 特邀经销商 +
+
+

{$data['gold']}

+ 金牌经销商 +
+
+HTML; + } +} From b3959d133b8e8ba8fdc4070dea63c688a85f2f7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=9D=99?= Date: Mon, 28 Feb 2022 11:01:19 +0800 Subject: [PATCH 31/39] =?UTF-8?q?=E4=BC=9A=E5=91=98=E7=AD=89=E7=BA=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Endpoint/Api/Http/Resources/Merchant/UserInfoResource.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/Endpoint/Api/Http/Resources/Merchant/UserInfoResource.php b/app/Endpoint/Api/Http/Resources/Merchant/UserInfoResource.php index 300e20f5..f59ff200 100644 --- a/app/Endpoint/Api/Http/Resources/Merchant/UserInfoResource.php +++ b/app/Endpoint/Api/Http/Resources/Merchant/UserInfoResource.php @@ -23,6 +23,7 @@ class UserInfoResource extends JsonResource 'points' => (int) $this->points, 'quota_v2' => $this->quota_v2, 'quota_v1' => $this->quota_v1, + 'agent_level' => $this->agent_level, 'agent_level_icon' => $this->agent_level_icon, 'agent_level_name' => $this->agent_level_name, ]; From 47526c74dc2539a72d6c4cbf68aef20e25a26cc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=9D=99?= Date: Mon, 28 Feb 2022 13:33:36 +0800 Subject: [PATCH 32/39] =?UTF-8?q?53=E5=AE=A2=E6=9C=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Endpoint/Wap/routes.php | 3 ++ resources/views/endpoint/kf/index.blade.php | 49 +++++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 resources/views/endpoint/kf/index.blade.php diff --git a/app/Endpoint/Wap/routes.php b/app/Endpoint/Wap/routes.php index 79c6d40b..f4d3fb93 100644 --- a/app/Endpoint/Wap/routes.php +++ b/app/Endpoint/Wap/routes.php @@ -5,3 +5,6 @@ use Illuminate\Support\Facades\Route; //快递100物流推送 Route::get('articles/{id}', [ArticleController::class, 'show']); + +// 53 客服 +Route::view('53kf', 'endpoint.kf.index'); diff --git a/resources/views/endpoint/kf/index.blade.php b/resources/views/endpoint/kf/index.blade.php new file mode 100644 index 00000000..2327584f --- /dev/null +++ b/resources/views/endpoint/kf/index.blade.php @@ -0,0 +1,49 @@ + + + + + + + + + + + + + <body> + </body> + + From 09ea54bd188a7c6004eef3fab7bb9c7b674208ea Mon Sep 17 00:00:00 2001 From: vine_liutk <961510893@qq.com> Date: Mon, 28 Feb 2022 15:27:48 +0800 Subject: [PATCH 33/39] =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=B9=BF=E5=91=8A?= =?UTF-8?q?=E4=BD=8D=E5=88=9D=E5=A7=8B=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- database/seeders/AdAddressSeeder.php | 140 ++++++++++++++++++++++----- 1 file changed, 115 insertions(+), 25 deletions(-) diff --git a/database/seeders/AdAddressSeeder.php b/database/seeders/AdAddressSeeder.php index 9e01f826..fc5ce97e 100644 --- a/database/seeders/AdAddressSeeder.php +++ b/database/seeders/AdAddressSeeder.php @@ -60,11 +60,6 @@ class AdAddressSeeder extends Seeder 'dimensions'=> '', 'is_show' => true, ], - 'app_start_page_banner'=>[ - 'name' => 'APP启动页广告位', - 'dimensions'=> '', - 'is_show' => true, - ], 'vip_will_cheap_banner'=> [ 'name' => '会员就是省', 'dimensions'=> '710*382', @@ -90,11 +85,6 @@ class AdAddressSeeder extends Seeder 'dimensions'=> '600*700', 'is_show' => true, ], - 'merchant_notice'=>[ - 'name' =>'商户公告弹窗', - 'dimensions'=> '600*700', - 'is_show'=> true, - ], 'article_banner'=>[ 'name' =>'文章广告位', 'dimensions'=> '', @@ -105,36 +95,136 @@ class AdAddressSeeder extends Seeder 'dimensions'=> '750*524', 'is_show'=> true, ], - 'mall_notice'=>[ - 'name' =>'商城公告广告位', - 'dimensions'=> '600*700', - 'is_show'=> true, - ], - 'merchant_notice'=>[ - 'name' =>'商户公告广告位', - 'dimensions'=> '600*700', - 'is_show'=> true, - ], 'homepage_popup'=>[ 'name' =>'首页弹窗广告位', 'dimensions'=> '608*735', 'is_show'=> true, ], - 'wholesale_homepage_banner'=>[ - 'name' =>'批零首页广告位', - 'dimensions'=> '750*550', - 'is_show'=> true, - ], 'vip_coupon_bottom_banner'=>[ 'name' =>'VIP优惠券底部广告位', 'dimensions'=> '213*246', 'is_show'=> true, ], + + /** 商城小程序广告位 start **/ + 'wechat_mini_top_navigation_banner' => [ + 'name' => '【小程序】首页顶部导航', + 'dimensions'=> '50*50', + 'is_show' => true, + ], + 'wechat_mini_floor_banner' => [ + 'name' => '【小程序】首页楼层广告位', + 'dimensions'=> '710*220', + 'is_show' => true, + ], + 'wechat_mini_recommend_banner' => [ + 'name' => '【小程序】首页精品推荐广告位', + 'dimensions'=> '670*260', + 'is_show' => true, + ], + 'wechat_mini_top_banner' => [ + 'name' => '【小程序】首页顶部广告位', + 'dimensions'=> '750*450', + 'is_show' => true, + ], + 'wechat_mini_vip_banner' => [ + 'name' => '【小程序】VIP会员积分权益', + 'dimensions'=> '710*196', + 'is_show' => true, + ], + 'wechat_mini_vip_award_banner' => [ + 'name' => '【小程序】VIP会员推广奖励', + 'dimensions'=> '226*289', + 'is_show' => true, + ], + 'wechat_mini_vip_car_banner' => [ + 'name' => '【小程序】VIP直通车广告位', + 'dimensions'=> '375*200', + 'is_show' => true, + ], + 'wechat_mini_share_register_banner' => [ + 'name' => '【小程序】分享注册位', + 'dimensions'=> '', + 'is_show' => true, + ], + 'wechat_mini_share_download_banner' => [ + 'name' => '【小程序】分享下载位', + 'dimensions'=> '', + 'is_show' => true, + ], + 'wechat_mini_vip_will_cheap_banner'=> [ + 'name' => '【小程序】会员就是省', + 'dimensions'=> '710*382', + 'is_show' => true, + ], + 'wechat_mini_vip_award_bottom_banner'=> [ + 'name' => '【小程序】会员推广奖励底部广告位', + 'dimensions'=> '470*202', + 'is_show' => true, + ], + 'wechat_mini_show_vip_banner'=> [ + 'name' => '【小程序】查看会员权益广告位', + 'dimensions'=> '710*382', + 'is_show' => true, + ], + 'wechat_mini_become_vip_banner'=> [ + 'name' => '【小程序】成为会员广告位', + 'dimensions'=> '710*382', + 'is_show' => true, + ], + 'wechat_mini_mall_notice'=>[ + 'name' => '【小程序】商城公告弹窗', + 'dimensions'=> '600*700', + 'is_show' => true, + ], + 'wechat_mini_article_banner'=>[ + 'name' =>'【小程序】文章广告位', + 'dimensions'=> '', + 'is_show'=> true, + ], + 'wechat_mini_vip_coupon_banner'=>[ + 'name' =>'【小程序】会员优惠券广告位', + 'dimensions'=> '750*524', + 'is_show'=> true, + ], + 'wechat_mini_homepage_popup'=>[ + 'name' =>'【小程序】首页弹窗广告位', + 'dimensions'=> '608*735', + 'is_show'=> true, + ], + 'wechat_mini_vip_coupon_bottom_banner'=>[ + 'name' =>'【小程序】VIP优惠券底部广告位', + 'dimensions'=> '213*246', + 'is_show'=> true, + ], + /** 商城小程序广告位 end **/ + + //商城APP端广告位 + 'app_start_page_banner'=>[ + 'name' => 'APP启动页广告位', + 'dimensions'=> '', + 'is_show' => true, + ], + /** 商户特殊广告位 start **/ + 'merchant_notice'=>[ + 'name' =>'商户公告广告位', + 'dimensions'=> '600*700', + 'is_show'=> true, + ], 'merchant_top_navigation_banner'=>[ 'name' =>'商户端首页顶部导航', 'dimensions'=> '58*58', 'is_show' =>true, ], + /** 商户特殊广告位 end **/ + + /** 批零特殊广告位 start **/ + 'wholesale_homepage_banner'=>[ + 'name' =>'批零首页广告位', + 'dimensions'=> '750*550', + 'is_show'=> true, + ], + /** 批零特殊广告位 end **/ ] as $key => $values) { AdAddress::firstOrCreate(['key' => $key], $values); } From 610080c0920ba65aac4c346851b28d5e72503229 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=9D=99?= Date: Mon, 28 Feb 2022 17:27:01 +0800 Subject: [PATCH 34/39] WIP --- app/Enums/PayWay.php | 1 - 1 file changed, 1 deletion(-) diff --git a/app/Enums/PayWay.php b/app/Enums/PayWay.php index 538d0fe1..d296c6e9 100644 --- a/app/Enums/PayWay.php +++ b/app/Enums/PayWay.php @@ -68,7 +68,6 @@ enum PayWay: string { static::Offline->value => '线下打款', static::Wallet->value => '余额支付', static::WxpayH5->value => '微信支付', - ''=>'Unknown', ]; } } From 62427335fdd3a6c728760f1411f99a7a5c5309e4 Mon Sep 17 00:00:00 2001 From: vine_liutk <961510893@qq.com> Date: Tue, 1 Mar 2022 09:56:53 +0800 Subject: [PATCH 35/39] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=80=81=E9=85=8D?= =?UTF-8?q?=E9=A2=9D=E5=A2=9E=E5=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/QuotaV1SendJobController.php | 10 +++ .../Grid/Tools/QuotaV1/Deduction.php | 54 +++++++++++++++ .../Grid/Tools/QuotaV1/Recharge.php | 54 +++++++++++++++ app/Admin/Forms/QuotaV1Deduction.php | 69 +++++++++++++++++++ app/Admin/Forms/QuotaV1Recharge.php | 69 +++++++++++++++++++ app/Models/QuotaV1Log.php | 14 ++++ app/Services/QuotaV1Service.php | 57 +++++++++++++++ ...2_28_161649_create_quota_v1_logs_table.php | 39 +++++++++++ 8 files changed, 366 insertions(+) create mode 100644 app/Admin/Extensions/Grid/Tools/QuotaV1/Deduction.php create mode 100644 app/Admin/Extensions/Grid/Tools/QuotaV1/Recharge.php create mode 100644 app/Admin/Forms/QuotaV1Deduction.php create mode 100644 app/Admin/Forms/QuotaV1Recharge.php create mode 100644 app/Models/QuotaV1Log.php create mode 100644 app/Services/QuotaV1Service.php create mode 100644 database/migrations/2022_02_28_161649_create_quota_v1_logs_table.php diff --git a/app/Admin/Controllers/QuotaV1SendJobController.php b/app/Admin/Controllers/QuotaV1SendJobController.php index 672b45e5..1f10a622 100644 --- a/app/Admin/Controllers/QuotaV1SendJobController.php +++ b/app/Admin/Controllers/QuotaV1SendJobController.php @@ -3,6 +3,8 @@ namespace App\Admin\Controllers; use App\Admin\Actions\Grid\QuotaV1SendJobStart; +use App\Admin\Extensions\Grid\Tools\QuotaV1\Deduction; +use App\Admin\Extensions\Grid\Tools\QuotaV1\Recharge; use App\Admin\Renderable\QuotaV1SendLogTable; use App\Admin\Repositories\QuotaV1SendJob; use App\Models\QuotaV1SendJob as QuotaV1SendJobModel; @@ -25,6 +27,14 @@ class QuotaV1SendJobController extends AdminController $builder = QuotaV1SendJob::with('administrator'); return Grid::make($builder, function (Grid $grid) { $grid->column('id')->sortable(); + $grid->tools(function (Grid\Tools $tools) { + if (Admin::user()->can('dcat.admin.quota_v1_send_jobs.recharge')) { + $tools->append(new Recharge()); + } + if (Admin::user()->can('dcat.admin.quota_v1_send_jobs.deduction')) { + $tools->append(new Deduction()); + } + }); $grid->column('amount')->display(function ($value) { return bcdiv($value, 100, 2); })->prepend('¥'); diff --git a/app/Admin/Extensions/Grid/Tools/QuotaV1/Deduction.php b/app/Admin/Extensions/Grid/Tools/QuotaV1/Deduction.php new file mode 100644 index 00000000..ffdcaa58 --- /dev/null +++ b/app/Admin/Extensions/Grid/Tools/QuotaV1/Deduction.php @@ -0,0 +1,54 @@ +can('dcat.admin.quota_v1_send_jobs.deduction'); + } + + /** + * 按钮样式定义,默认 btn btn-white waves-effect + * + * @var string + */ + protected $style = 'btn btn btn-danger'; + + /** + * 按钮文本 + * + * @return string|void + */ + public function title() + { + return '扣减'; + } + + public function render() + { + $form = QuotaV1Deduction::make(); + return Modal::make() + ->lg() + ->title($this->title()) + ->body($form) + ->button($this->html()); + } + + /** + * 设置请求参数 + * + * @return array|void + */ + public function parameters() + { + return [ + + ]; + } +} diff --git a/app/Admin/Extensions/Grid/Tools/QuotaV1/Recharge.php b/app/Admin/Extensions/Grid/Tools/QuotaV1/Recharge.php new file mode 100644 index 00000000..0b1b71a7 --- /dev/null +++ b/app/Admin/Extensions/Grid/Tools/QuotaV1/Recharge.php @@ -0,0 +1,54 @@ +can('dcat.admin.quota_v1_send_jobs.recharge'); + } + + /** + * 按钮样式定义,默认 btn btn-white waves-effect + * + * @var string + */ + protected $style = 'btn btn btn-warning'; + + /** + * 按钮文本 + * + * @return string|void + */ + public function title() + { + return '增加'; + } + + public function render() + { + $form = QuotaV1Recharge::make(); + return Modal::make() + ->lg() + ->title($this->title()) + ->body($form) + ->button($this->html()); + } + + /** + * 设置请求参数 + * + * @return array|void + */ + public function parameters() + { + return [ + + ]; + } +} diff --git a/app/Admin/Forms/QuotaV1Deduction.php b/app/Admin/Forms/QuotaV1Deduction.php new file mode 100644 index 00000000..d3cf0096 --- /dev/null +++ b/app/Admin/Forms/QuotaV1Deduction.php @@ -0,0 +1,69 @@ +can('dcat.admin.quota_v1_send_jobs.deduction'); + } + + /** + * Handle the form request. + * + * @param array $input + * + * @return mixed + */ + public function handle(array $input) + { + if (($input['change_balance'] ?? 0) <= 0) { + return $this->response()->error('扣减配额必须大于0'); + } + try { + DB::beginTransaction(); + //获取当前操作人; + $adminUser = Admin::user(); + $user = User::findOrFail($input['user_id'] ?? 0); + $quotaV1Service = new QuotaV1Service(); + $quotaV1Service->changeBalance($user, -($input['change_balance'] ?? 0), QuotaV1Log::ACTION_ADMIN_DEDUCTION, '后台扣减', $adminUser); + DB::commit(); + } catch (Throwable $th) { + DB::rollBack(); + report($th); + return $this->response()->error('操作失败:'.$th->getMessage()); + } + + return $this->response() + ->success(__('admin.update_succeeded')) + ->refresh(); + } + + /** + * Build a form here. + */ + public function form() + { + $this->select('user_id', '用户手机号')->ajax(admin_route('api.users'))->required(); + $this->currency('change_balance', '扣减配额')->symbol('¥')->required(); + $this->confirm('是否确认扣减?', '提交后该动作无法逆转'); + } +} diff --git a/app/Admin/Forms/QuotaV1Recharge.php b/app/Admin/Forms/QuotaV1Recharge.php new file mode 100644 index 00000000..ecd0f1c8 --- /dev/null +++ b/app/Admin/Forms/QuotaV1Recharge.php @@ -0,0 +1,69 @@ +can('dcat.admin.quota_v1_send_jobs.recharge'); + } + + /** + * Handle the form request. + * + * @param array $input + * + * @return mixed + */ + public function handle(array $input) + { + if (($input['change_balance'] ?? 0) <= 0) { + return $this->response()->error('增加配额必须大于0'); + } + try { + DB::beginTransaction(); + //获取当前操作人; + $adminUser = Admin::user(); + $user = User::findOrFail($input['user_id'] ?? 0); + $quotaV1Service = new QuotaV1Service(); + $quotaV1Service->changeBalance($user, $input['change_balance'] ?? 0, QuotaV1Log::ACTION_ADMIN_RECHARGE, '后台增加', $adminUser); + DB::commit(); + } catch (Throwable $th) { + DB::rollBack(); + report($th); + return $this->response()->error('操作失败:'.$th->getMessage()); + } + + return $this->response() + ->success(__('admin.update_succeeded')) + ->refresh(); + } + + /** + * Build a form here. + */ + public function form() + { + $this->select('user_id', '用户手机号')->ajax(admin_route('api.users'))->required(); + $this->currency('change_balance', '增加配额')->symbol('¥')->required(); + $this->confirm('是否确认增加老配额?', '提交后该动作无法逆转'); + } +} diff --git a/app/Models/QuotaV1Log.php b/app/Models/QuotaV1Log.php new file mode 100644 index 00000000..6271df3d --- /dev/null +++ b/app/Models/QuotaV1Log.php @@ -0,0 +1,14 @@ +userInfo()->lockForUpdate()->first(); + + if ($userInfo === null) { + throw new BizException('系统错误'); + } + + // 变更前余额 + $beforeBalance = $userInfo->quota_v1; + $_changeBalance = abs($changeBalance); + + if ($changeBalance > 0) { + // 收入 + $user->userInfo()->increment('quota_v1', $_changeBalance); + } else { + // 支出 + if ($userInfo->quota_v1 < $_changeBalance) { + throw new BizException('老配额不足'); + } + + $user->userInfo()->decrement('quota_v1', $_changeBalance); + } + + $user->walletLogs()->create([ + 'loggable_id' => $loggable?->id, + 'loggable_type' => $loggable?->getMorphClass(), + 'before_balance' => $beforeBalance, + 'change_balance' => $changeBalance, + 'action' => $action, + 'remarks' => $remarks, + ]); + } +} diff --git a/database/migrations/2022_02_28_161649_create_quota_v1_logs_table.php b/database/migrations/2022_02_28_161649_create_quota_v1_logs_table.php new file mode 100644 index 00000000..2f14c0f9 --- /dev/null +++ b/database/migrations/2022_02_28_161649_create_quota_v1_logs_table.php @@ -0,0 +1,39 @@ +id(); + $table->unsignedBigInteger('user_id')->comment('用户ID'); + $table->nullableMorphs('loggable'); + $table->tinyInteger('action')->comment('操作类型'); + $table->unsignedDecimal('before_balance')->default(0)->comment('变更前的余额'); + $table->unsignedDecimal('change_balance', 12, 3)->default(0)->comment('变动余额'); + $table->string('remarks')->nullable()->comment('备注'); + $table->timestamps(); + + $table->index('user_id'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('quota_v1_logs'); + } +} From fa95f81ab0860922a870a2ecfcfbadef647695c7 Mon Sep 17 00:00:00 2001 From: vine_liutk <961510893@qq.com> Date: Tue, 1 Mar 2022 10:02:01 +0800 Subject: [PATCH 36/39] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=80=81=E9=85=8D?= =?UTF-8?q?=E9=A2=9D=E5=A2=9E=E5=87=8F=E6=9D=83=E9=99=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- database/seeders/AdminPermissionSeeder.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/database/seeders/AdminPermissionSeeder.php b/database/seeders/AdminPermissionSeeder.php index 54fdfa66..8e6103e6 100644 --- a/database/seeders/AdminPermissionSeeder.php +++ b/database/seeders/AdminPermissionSeeder.php @@ -305,6 +305,8 @@ class AdminPermissionSeeder extends Seeder 'curd' => ['index', 'create', 'store', 'edit', 'update', 'destroy'], 'children' => [ 'log_list'=>['name' =>'分红记录'], + 'recharge'=>['name' =>'增加配额'], + 'deduction'=>['name' =>'扣减配额'], ], ], 'dealers' =>[ From 3c666e42cd47540c18c1bac6307ee8cadc873d58 Mon Sep 17 00:00:00 2001 From: vine_liutk <961510893@qq.com> Date: Tue, 1 Mar 2022 11:16:29 +0800 Subject: [PATCH 37/39] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=89=B9=E9=9B=B6?= =?UTF-8?q?=E6=98=8E=E7=BB=86=E8=A1=A8=E7=BB=93=E7=AE=97=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E6=8E=92=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Admin/Controllers/DealerManageSubsidyLogController.php | 2 +- app/Admin/Controllers/DealerManagerSalesLogController.php | 2 +- app/Admin/Controllers/DealerPurchaseLogController.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/Admin/Controllers/DealerManageSubsidyLogController.php b/app/Admin/Controllers/DealerManageSubsidyLogController.php index 5cdd4646..c08155fc 100644 --- a/app/Admin/Controllers/DealerManageSubsidyLogController.php +++ b/app/Admin/Controllers/DealerManageSubsidyLogController.php @@ -30,7 +30,7 @@ class DealerManageSubsidyLogController extends AdminController $grid->column('product.name', '商品名称'); $grid->column('sales_volume', '销量'); $grid->column('total_amount', '金额'); - $grid->column('order_completed_at', '结算时间'); + $grid->column('order_completed_at', '结算时间')->sortable(); $grid->column('created_at')->sortable(); $grid->disableCreateButton(); diff --git a/app/Admin/Controllers/DealerManagerSalesLogController.php b/app/Admin/Controllers/DealerManagerSalesLogController.php index 8adad075..a8450428 100644 --- a/app/Admin/Controllers/DealerManagerSalesLogController.php +++ b/app/Admin/Controllers/DealerManagerSalesLogController.php @@ -30,7 +30,7 @@ class DealerManagerSalesLogController extends AdminController $grid->column('order.sn', '订单编号'); $grid->column('product.name', '商品名称'); $grid->column('sales_volume', '销量'); - $grid->column('order_completed_at', '结算时间'); + $grid->column('order_completed_at', '结算时间')->sortable(); $grid->column('created_at')->sortable(); $grid->disableCreateButton(); diff --git a/app/Admin/Controllers/DealerPurchaseLogController.php b/app/Admin/Controllers/DealerPurchaseLogController.php index ad8357eb..8a3349ec 100644 --- a/app/Admin/Controllers/DealerPurchaseLogController.php +++ b/app/Admin/Controllers/DealerPurchaseLogController.php @@ -39,7 +39,7 @@ class DealerPurchaseLogController extends AdminController $grid->column('order.sn', '订单编号'); $grid->column('total_amount'); $grid->column('remark'); - $grid->column('order_completed_at'); + $grid->column('order_completed_at', '结算时间')->sortable(); $grid->column('created_at')->sortable(); $grid->header(function ($collection) use ($grid) { From 44db8dbf5d9954e9c17564d7f6cd89ff7d0438a8 Mon Sep 17 00:00:00 2001 From: vine_liutk <961510893@qq.com> Date: Tue, 1 Mar 2022 15:15:52 +0800 Subject: [PATCH 38/39] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=BB=8F=E9=94=80?= =?UTF-8?q?=E5=95=86=E7=BB=9F=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Admin/Controllers/DealerController.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/Admin/Controllers/DealerController.php b/app/Admin/Controllers/DealerController.php index 3b46a5c1..48eabee1 100644 --- a/app/Admin/Controllers/DealerController.php +++ b/app/Admin/Controllers/DealerController.php @@ -6,6 +6,7 @@ use App\Admin\Actions\Grid\DealerBonds; use App\Admin\Actions\Grid\DealerEditLvl; use App\Admin\Actions\Grid\DealerEditProduct; use App\Admin\Renderable\DealerEarningSimpleTable; +use App\Admin\Renderable\DealerSubordinateCard; use App\Admin\Renderable\DealerUserProductLogSimpleTable; use App\Admin\Renderable\DealerWalletLogSimpleTable; use App\Admin\Repositories\Dealer; @@ -43,7 +44,10 @@ class DealerController extends AdminController $lvlTexts = DealerLvl::texts(); $grid->column('lvl')->display(function () { return $this->lvl->text(); - })->filter(Grid\Column\Filter\In::make($lvlTexts)); + })->filter(Grid\Column\Filter\In::make($lvlTexts))->modal(function ($modal) { + // $modal->title('消费值'); + return DealerSubordinateCard::make(['id'=>$this->user_id]); + })->setHeaderAttributes(['style' => 'color:#5b69bc']); $grid->column('wallet.balance')->display(function ($value) { return $value ?? 0; })->prepend('¥'); From 996a7211d7f070a6c662aa9f73fb63a3fb5eb335 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=9D=99?= Date: Thu, 3 Mar 2022 05:41:40 +0000 Subject: [PATCH 39/39] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=96=87=E4=BB=B6=20ap?= =?UTF-8?q?p/Endpoint/Api/Http/Controllers/WechatMiniController.php?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Api/Http/Controllers/WechatMiniController.php | 12 ------------ 1 file changed, 12 deletions(-) delete mode 100644 app/Endpoint/Api/Http/Controllers/WechatMiniController.php diff --git a/app/Endpoint/Api/Http/Controllers/WechatMiniController.php b/app/Endpoint/Api/Http/Controllers/WechatMiniController.php deleted file mode 100644 index ef2c0364..00000000 --- a/app/Endpoint/Api/Http/Controllers/WechatMiniController.php +++ /dev/null @@ -1,12 +0,0 @@ -