From 221d27318efcface8c6b3add9d4115fe413861ff Mon Sep 17 00:00:00 2001 From: liapples Date: Wed, 15 Sep 2021 16:34:16 +0800 Subject: [PATCH 01/14] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Admin/Extensions/Grid/MiniProgramUpload.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Admin/Extensions/Grid/MiniProgramUpload.php b/app/Admin/Extensions/Grid/MiniProgramUpload.php index c6161cd..f92ed94 100644 --- a/app/Admin/Extensions/Grid/MiniProgramUpload.php +++ b/app/Admin/Extensions/Grid/MiniProgramUpload.php @@ -23,7 +23,7 @@ class MiniProgramUpload extends RowAction public function __construct($title = null, $action = 1) { parent::__construct($title); - $this->action = $action; //$action:1=为指定代理商上传小程序;2=批量上传小程序(一键分发小程序给所有代理商) + $this->action = $action; //$action:1=为指定代理商上传小程序;2=暂未确定 $this->title = $action == 1 ? '上传小程序' : '为所有代理商上传'; } From 7da46724a45f79fbb4a3ec81d2cfa30519cf4d54 Mon Sep 17 00:00:00 2001 From: liapples Date: Wed, 15 Sep 2021 19:10:34 +0800 Subject: [PATCH 02/14] =?UTF-8?q?=E6=9F=A5=E7=9C=8B=E5=AE=A1=E6=A0=B8?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Grid/MiniProgramAuditStatus.php | 31 +++++++------------ 1 file changed, 11 insertions(+), 20 deletions(-) diff --git a/app/Admin/Extensions/Grid/MiniProgramAuditStatus.php b/app/Admin/Extensions/Grid/MiniProgramAuditStatus.php index 54b88b9..b6ff7b9 100644 --- a/app/Admin/Extensions/Grid/MiniProgramAuditStatus.php +++ b/app/Admin/Extensions/Grid/MiniProgramAuditStatus.php @@ -1,12 +1,11 @@ response()->error('该代理商未注册过小程序,请先注册'); } - $template_id = MiniProgramTemplate::max('template_id'); - $log = MiniProgramUploadLog::where(['agent_id' => $agent->id, 'template_id' => $template_id])->orderBy('id', 'desc')->first(); +// $template_id = MiniProgramTemplate::max('template_id'); + $log = MiniProgramUploadLog::where(['agent_id' => $agent->id])->orderBy('id', 'desc')->first(); if (!$log) { return $this->response()->error('该代理商未上传及发布过最新版本的小程序'); - } else if (!$log->audit_id){ + } else if (!$log->audit_id) { return $this->response()->error('未找到审核记录audit_id'); } try { - $setting = AdminSetting::val(['service_appid', 'service_appsecret', 'service_token', 'service_aeskey']); - $config = [ - 'app_id' => $setting['service_appid'], - 'secret' => $setting['service_appsecret'], - 'token' => $setting['service_token'], - 'aes_key' => $setting['service_aeskey'], - ]; - - $openPlatform = Factory::openPlatform($config); - $refreshToken = $openPlatform->getAuthorizer($agent->appid)['authorization_info']['authorizer_refresh_token'] ?? null; + $openPlatform = new OpenPlatform(); + $refreshToken = $openPlatform->refreshToken($agent->appid); if (!$refreshToken) { return $this->response()->error('获取refresh_token失败'); } /** @var Client $code */ - $code = $openPlatform->miniProgram($agent->appid, $refreshToken)['code'] ?? null; + $code = $openPlatform->code($agent->appid, $refreshToken); if (!$code) { return $this->response()->error('获取code失败'); } @@ -85,14 +76,14 @@ class MiniProgramAuditStatus extends RowAction //发布结果处理 $releaseArr = [-1 => '系统繁忙', 85019 => '没有审核版本', 85020 => '审核状态未满足发布']; if (isset($res_release['errcode'], $res_release['errmsg']) && $res_release['errcode'] == 0 && $res_release['errmsg'] == 'ok') { - return $this->response()->success('审核成功且已发布')->refresh(); + return $this->response()->success("模板ID {$log->template_id} 的小程序已审核成功且发布")->refresh(); } else if (isset($releaseArr[$res_release['errcode']])) { - return $this->response()->success('审核成功,发布结果为:' . $releaseArr[$res_release['errcode']])->refresh(); + return $this->response()->warning('审核成功,发布结果为:' . $releaseArr[$res_release['errcode']])->refresh(); } else { - return $this->response()->success('审核成功,失败出错:' . join(',', $res_release))->refresh(); + return $this->response()->warning('审核成功,但发布出错:' . join(',', $res_release))->refresh(); } } else if (isset($statusArr[$res['status']])) { - return $this->response()->success($statusArr[$res['status']])->refresh(); + return $this->response()->warning($statusArr[$res['status']])->refresh(); } else { return $this->response()->error($res['reason'] ?? join(',', $res)); } From 99a76f4c46478cc3df22c0ef0e17764391b6e4c7 Mon Sep 17 00:00:00 2001 From: liapples Date: Wed, 15 Sep 2021 19:25:25 +0800 Subject: [PATCH 03/14] =?UTF-8?q?=E6=94=B6=E8=97=8F=E5=88=A4=E6=96=AD?= =?UTF-8?q?=E9=80=BB=E8=BE=91=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/Api/AgentProductController.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/app/Http/Controllers/Api/AgentProductController.php b/app/Http/Controllers/Api/AgentProductController.php index ab5e599..72eeaf4 100644 --- a/app/Http/Controllers/Api/AgentProductController.php +++ b/app/Http/Controllers/Api/AgentProductController.php @@ -60,7 +60,7 @@ class AgentProductController extends Controller // TODO 优惠券查询待优化 $agent_product = AgentProduct::query() - ->with(['coupon:tag,agent_product_id', 'fav:agent_product_id']) + ->with(['coupon:tag,agent_product_id']) ->whereDoesntHave('agentProductItem', function ($query) { return $query->whereHas('product', function ($query) { return $query->where('stock', '<=', 0)->orWhere('status', '<>', ProductStatus::ON_SALE); @@ -76,8 +76,12 @@ class AgentProductController extends Controller $prefix = Storage::disk('public')->url(''); $agent_product->pictures = array_map(fn($item) => ($prefix . $item), $agent_product->pictures); - $agent_product->is_collect = !is_null($agent_product->fav); //判断是否收藏 - unset($agent_product->fav); + if ($this->user_id) { + $agent_product->is_collect = UserFav::query()->where(['user_id' => $this->user_id, 'agent_product_id' => $id])->exists() ? 1 : 0; //判断是否收藏 + } else { + $agent_product->is_collect = 0; + } + //计算折扣 if ($agent_product->price < $agent_product->original_price) { $agent_product->cost = round($agent_product->price / $agent_product->original_price * 10, 1); From 1b8224ba5fd180f7ed75bbd999bec05cc151fd80 Mon Sep 17 00:00:00 2001 From: liapples Date: Wed, 15 Sep 2021 19:29:10 +0800 Subject: [PATCH 04/14] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Service/OpenPlatform.php | 73 ++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 app/Service/OpenPlatform.php diff --git a/app/Service/OpenPlatform.php b/app/Service/OpenPlatform.php new file mode 100644 index 0000000..017f1a7 --- /dev/null +++ b/app/Service/OpenPlatform.php @@ -0,0 +1,73 @@ +config = [ + 'app_id' => $setting['service_appid'], + 'secret' => $setting['service_appsecret'], + 'token' => $setting['service_token'], + 'aes_key' => $setting['service_aeskey'], + ]; + + $this->openPlatform = Factory::openPlatform($this->config); + return $this->openPlatform; + } + + /*public static function getInstance(): self + { + if (!self::$instance instanceof self) { + self::$instance = new self(); + } + return self::$instance; + }*/ + + public function refreshToken($appid) + { + return $this->openPlatform->getAuthorizer($appid)['authorization_info']['authorizer_refresh_token'] ?? null; + } + + public function miniProgram($appid, $refreshToken = null) + { + if (is_null($refreshToken)) { + $refreshToken = $this->refreshToken($appid); + } + return $this->openPlatform->miniProgram($appid, $refreshToken)['code'] ?? null; + } + + public function codeTemplate() + { + return $this->openPlatform['code_template'] ?? null; + } + + public function code($appid, $refreshToken = null) + { + if (is_null($refreshToken)) { + $refreshToken = $this->refreshToken($appid); + } + return $this->openPlatform->miniProgram($appid, $refreshToken)['code'] ?? null; + } + + public function component() + { + return $this->openPlatform['component'] ?? null; + } +} From b479a5e6fe17820478a316b334a02ac44edc3c43 Mon Sep 17 00:00:00 2001 From: liapples Date: Wed, 15 Sep 2021 19:32:03 +0800 Subject: [PATCH 05/14] OpenPlatform --- app/Admin/Extensions/Grid/MiniProgramReg.php | 35 ++++++------------- .../Extensions/Grid/MiniProgramUpload.php | 22 +++++------- 2 files changed, 18 insertions(+), 39 deletions(-) diff --git a/app/Admin/Extensions/Grid/MiniProgramReg.php b/app/Admin/Extensions/Grid/MiniProgramReg.php index 43da4c4..969c91b 100644 --- a/app/Admin/Extensions/Grid/MiniProgramReg.php +++ b/app/Admin/Extensions/Grid/MiniProgramReg.php @@ -5,6 +5,7 @@ use App\Models\AdminSetting; use App\Models\Agent; use App\Models\MiniProgramTemplate; use App\Models\MiniProgramUploadLog; +use App\Service\OpenPlatform; use Dcat\Admin\Grid\RowAction; use EasyWeChat\Factory; use EasyWeChat\OpenPlatform\Component\Client; @@ -44,19 +45,11 @@ class MiniProgramReg extends RowAction { $agent = Agent::find($this->getKey()); - $setting = AdminSetting::val(['service_appid', 'service_appsecret', 'service_token', 'service_aeskey', 'service_component_phone']); - $config = [ - 'app_id' => $setting['service_appid'], - 'secret' => $setting['service_appsecret'], - 'token' => $setting['service_token'], - 'aes_key' => $setting['service_aeskey'], - ]; - - $openPlatform = Factory::openPlatform($config); - if (empty($openPlatform['component'])) { - return $this->response()->error('获取component失败,请检查配置信息是否正确'); + $openPlatform = new OpenPlatform(); + $component = $openPlatform->component(); + if (empty($component)) { + return $this->response()->error('获取component失败'); } - $component = $openPlatform['component']; $res = $component->registerMiniProgram([ 'name' => $agent->company_name, // 企业名 @@ -64,7 +57,7 @@ class MiniProgramReg extends RowAction 'code_type' => 1, // 企业代码类型(1:统一社会信用代码, 2:组织机构代码,3:营业执照注册号) 'legal_persona_wechat' => $agent->legal_persona_wechat, // 法人微信 'legal_persona_name' => $agent->legal_persona_name, // 法人姓名 - 'component_phone' => $setting['service_component_phone'], //第三方联系电话 + 'component_phone' => AdminSetting::val('service_component_phone'), //第三方联系电话 ]); $errorArr = $this->regErrorCode(); @@ -88,20 +81,12 @@ class MiniProgramReg extends RowAction } try { - $setting = AdminSetting::val(['service_appid', 'service_appsecret', 'service_token', 'service_aeskey']); - $config = [ - 'app_id' => $setting['service_appid'], - 'secret' => $setting['service_appsecret'], - 'token' => $setting['service_token'], - 'aes_key' => $setting['service_aeskey'], - ]; - - $openPlatform = Factory::openPlatform($config); - if (empty($openPlatform['component'])) { + $openPlatform = new OpenPlatform(); + /** @var Client $component */ + $component = $openPlatform->component(); + if (empty($component)) { return $this->response()->error('获取component失败,请检查配置信息是否正确'); } - /** @var Client $component */ - $component = $openPlatform['component']; $res = $component->getRegistrationStatus($agent->company_name, $agent->legal_persona_wechat, $agent->legal_persona_name); $errorArr = $this->searchErrorCode(); diff --git a/app/Admin/Extensions/Grid/MiniProgramUpload.php b/app/Admin/Extensions/Grid/MiniProgramUpload.php index f92ed94..5151813 100644 --- a/app/Admin/Extensions/Grid/MiniProgramUpload.php +++ b/app/Admin/Extensions/Grid/MiniProgramUpload.php @@ -5,6 +5,7 @@ use App\Models\AdminSetting; use App\Models\Agent; use App\Models\MiniProgramTemplate; use App\Models\MiniProgramUploadLog; +use App\Service\OpenPlatform; use Dcat\Admin\Grid\RowAction; use EasyWeChat\Factory; use EasyWeChat\OpenPlatform\Authorizer\MiniProgram\Code\Client; @@ -55,16 +56,8 @@ class MiniProgramUpload extends RowAction } try { - $setting = AdminSetting::val(['service_appid', 'service_appsecret', 'service_token', 'service_aeskey']); - $config = [ - 'app_id' => $setting['service_appid'], - 'secret' => $setting['service_appsecret'], - 'token' => $setting['service_token'], - 'aes_key' => $setting['service_aeskey'], - ]; - - $openPlatform = Factory::openPlatform($config); - $refreshToken = $openPlatform->getAuthorizer($agent->appid)['authorization_info']['authorizer_refresh_token'] ?? null; + $openPlatform = new OpenPlatform(); + $refreshToken = $openPlatform->refreshToken($agent->appid); if (!$refreshToken) { return $this->response()->error('获取refresh_token失败'); } @@ -102,10 +95,6 @@ class MiniProgramUpload extends RowAction //提交上传 $commit = $code->commit($templateId, $extJson, $version, $description); - //获取体验二维码并保存 - $qrcode = $code->getQrCode(storage_path("app/public/{$agent->id}-{$agent->appid}.jpg")); - Storage::put("public/mini_program_qrcode/{$agent->id}-{$agent->appid}.jpg", $qrcode); - if (!isset($commit['errcode'], $commit['errmsg']) || $commit['errcode'] != 0 || $commit['errmsg'] != 'ok') { throw new \Exception(isset($commit['errmsg']) ? $commit['errmsg'] : join(',', $commit)); } @@ -125,6 +114,11 @@ class MiniProgramUpload extends RowAction 'audit_id' => $res['auditid'], 'created_at' => now(), ]); + + //获取体验二维码并保存 + $qrcode = $code->getQrCode(storage_path("app/public/{$agent->id}-{$agent->appid}.jpg")); + Storage::put("public/mini_program_qrcode/{$agent->id}-{$agent->appid}.jpg", $qrcode); + return $this->response()->success("上传成功,并已提交审核")->refresh(); } else if (isset($audit_err_code[$res['errcode']])) { throw new \Exception($audit_err_code[$res['errcode']]); From c521dcc7149892cd5f2d444535237db7bdb0538e Mon Sep 17 00:00:00 2001 From: liapples Date: Wed, 15 Sep 2021 19:32:12 +0800 Subject: [PATCH 06/14] =?UTF-8?q?=E6=98=BE=E7=A4=BA=E6=A8=A1=E6=9D=BF?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Admin/Controllers/MiniProgramTemplateController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Admin/Controllers/MiniProgramTemplateController.php b/app/Admin/Controllers/MiniProgramTemplateController.php index 1d13201..58f450b 100644 --- a/app/Admin/Controllers/MiniProgramTemplateController.php +++ b/app/Admin/Controllers/MiniProgramTemplateController.php @@ -29,7 +29,7 @@ class MiniProgramTemplateController extends AdminController $grid->tools(new MiniProgramPull); $grid->column('template_id'); -// $grid->column('template_type')->using([0 => '普通模板', 1 => '标准模板']); + $grid->column('template_type')->using([0 => '普通模板', 1 => '标准模板']); $grid->column('user_version'); $grid->column('user_desc'); $grid->column('source_miniprogram'); From e0160b63fb9d433fb4039eaf8d9c779f6fab63e8 Mon Sep 17 00:00:00 2001 From: liapples Date: Wed, 15 Sep 2021 23:24:28 +0800 Subject: [PATCH 07/14] =?UTF-8?q?=E4=BF=AE=E6=94=B9BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Service/OpenPlatform.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Service/OpenPlatform.php b/app/Service/OpenPlatform.php index 017f1a7..020242e 100644 --- a/app/Service/OpenPlatform.php +++ b/app/Service/OpenPlatform.php @@ -50,7 +50,7 @@ class OpenPlatform if (is_null($refreshToken)) { $refreshToken = $this->refreshToken($appid); } - return $this->openPlatform->miniProgram($appid, $refreshToken)['code'] ?? null; + return $this->openPlatform->miniProgram($appid, $refreshToken); } public function codeTemplate() From 3db88a22ab87360502b7a5670a582d19828e7eba Mon Sep 17 00:00:00 2001 From: liapples Date: Thu, 16 Sep 2021 08:30:05 +0800 Subject: [PATCH 08/14] =?UTF-8?q?=E6=B6=88=E6=81=AF=E6=8E=A5=E6=94=B6?= =?UTF-8?q?=E9=80=BB=E8=BE=91=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/Api/MiniProgramController.php | 35 ++++++++----------- app/Service/OpenPlatform.php | 20 +++++++++++ 2 files changed, 34 insertions(+), 21 deletions(-) diff --git a/app/Http/Controllers/Api/MiniProgramController.php b/app/Http/Controllers/Api/MiniProgramController.php index b8712e4..5855bb1 100644 --- a/app/Http/Controllers/Api/MiniProgramController.php +++ b/app/Http/Controllers/Api/MiniProgramController.php @@ -5,6 +5,7 @@ use App\Http\Controllers\Controller; use App\Models\AdminSetting; use App\Models\Agent; use App\Models\MiniProgramUploadLog; +use App\Service\OpenPlatform; use EasyWeChat\Factory; use Illuminate\Http\Request; use Illuminate\Support\Facades\DB; @@ -27,16 +28,8 @@ class MiniProgramController extends Controller 'created_at' => now(), ]); - $setting = AdminSetting::val(['service_appid', 'service_appsecret', 'service_token', 'service_aeskey']); - $config = [ // 第三方平台信息 - 'app_id' => $setting['service_appid'], - 'secret' => $setting['service_appsecret'], - 'token' => $setting['service_token'], - 'aes_key' => $setting['service_aeskey'], - ]; - - $openPlatform = Factory::openPlatform($config); - $server = $openPlatform->server; + $openPlatform = new OpenPlatform(); + $server = $openPlatform->server(); // 处理授权成功事件:Guard::EVENT_AUTHORIZED // 处理授权更新事件:Guard::EVENT_UPDATE_AUTHORIZED @@ -75,23 +68,15 @@ class MiniProgramController extends Controller 'created_at' => now(), ]); - $setting = AdminSetting::val(['service_appid', 'service_appsecret', 'service_token', 'service_aeskey']); - $config = [ - 'app_id' => $setting['service_appid'], - 'secret' => $setting['service_appsecret'], - 'token' => $setting['service_token'], - 'aes_key' => $setting['service_aeskey'], - ]; - - $openPlatform = Factory::openPlatform($config); - $refreshToken = $openPlatform->getAuthorizer($appid)['authorization_info']['authorizer_refresh_token'] ?? null; + $openPlatform = new OpenPlatform(); + $refreshToken = $openPlatform->refreshToken($appid); if (!$refreshToken) { return $this->error('获取refresh_token失败'); } $server = $openPlatform->miniProgram($appid, $refreshToken)->server; //接收事件 https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/code/audit_event.html - $server->push(function ($message) use ($appid) { + $server->push(function ($message) use ($appid, $openPlatform, $refreshToken) { DB::table('mini_program_events') ->insert([ 'type' => 1, @@ -107,6 +92,14 @@ class MiniProgramController extends Controller 'weapp_audit_fail' => 1, //拒绝 'weapp_audit_delay' => 4, //审核延后 ]; + + //如果审核成功则发布 + if ($message['Event'] == 'weapp_audit_success') { + $code = $openPlatform->code($appid, $refreshToken); + $code->release(); + } + + //保存到日志 $log = MiniProgramUploadLog::query() ->where('appid', $appid) ->orderBy('id', 'desc') diff --git a/app/Service/OpenPlatform.php b/app/Service/OpenPlatform.php index 020242e..c83237d 100644 --- a/app/Service/OpenPlatform.php +++ b/app/Service/OpenPlatform.php @@ -5,6 +5,7 @@ namespace App\Service; use App\Models\AdminSetting; use EasyWeChat\Factory; use EasyWeChat\OpenPlatform\Application; +use EasyWeChat\OpenPlatform\Server\Guard; /** * 微信第三方开放平台 @@ -29,6 +30,10 @@ class OpenPlatform ]; $this->openPlatform = Factory::openPlatform($this->config); + } + + public function openPlatform(): Application + { return $this->openPlatform; } @@ -70,4 +75,19 @@ class OpenPlatform { return $this->openPlatform['component'] ?? null; } + + public function server(): Guard + { + return $this->openPlatform->server; + } + + public function __call($method, $args) + { + return $this->openPlatform->$method(...$args); + } + + public function __get(string $name) + { + return $this->openPlatform->$name; + } } From 4f82c80748e6963c9e9b48a989978fd7e1bc52ce Mon Sep 17 00:00:00 2001 From: liapples Date: Thu, 16 Sep 2021 09:46:15 +0800 Subject: [PATCH 09/14] =?UTF-8?q?=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/Api/TestController.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/app/Http/Controllers/Api/TestController.php b/app/Http/Controllers/Api/TestController.php index 58a42aa..5e490d2 100644 --- a/app/Http/Controllers/Api/TestController.php +++ b/app/Http/Controllers/Api/TestController.php @@ -5,6 +5,7 @@ namespace App\Http\Controllers\Api; use App\Models\AdminSetting; use App\Models\AgentProduct; use App\Models\MiniProgramUploadLog; +use App\Service\OpenPlatform; use EasyWeChat\Factory; use Illuminate\Support\Facades\Cache; use Illuminate\Support\Facades\DB; @@ -28,6 +29,9 @@ class TestController 'created_at' => now() ]); + $openPlatform = new OpenPlatform(); + $refreshToken = $openPlatform->refreshToken($appid); + //审核结果通知 if (isset($message['MsgType'], $message['Event']) && $message['MsgType'] == 'event') { $auditArr = [ @@ -35,6 +39,14 @@ class TestController 'weapp_audit_fail' => 1, //拒绝 'weapp_audit_delay' => 4, //审核延后 ]; + + //如果审核成功则发布 + if ($message['Event'] == 'weapp_audit_success') { + $code = $openPlatform->code($appid, $refreshToken); + $res = $code->release(); + dump($res); + } + $log = MiniProgramUploadLog::query() ->where('appid', $appid) ->orderBy('id', 'desc') From 4041eff8974978cf32d66a03c87433327aed17ef Mon Sep 17 00:00:00 2001 From: liapples Date: Thu, 16 Sep 2021 09:47:09 +0800 Subject: [PATCH 10/14] =?UTF-8?q?=E6=B8=85=E7=A9=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- MySQL_change.sql | 363 ----------------------------------------------- 1 file changed, 363 deletions(-) diff --git a/MySQL_change.sql b/MySQL_change.sql index 9b4fc15..e69de29 100644 --- a/MySQL_change.sql +++ b/MySQL_change.sql @@ -1,363 +0,0 @@ -# 10:47 2021/8/17 -ALTER TABLE `categories` - CHANGE COLUMN `template` `template` VARCHAR(50) NOT NULL DEFAULT '' COMMENT '产品模板' COLLATE 'utf8_general_ci' AFTER `sort`; - -# 12:47 2021/8/17 -ALTER TABLE `users` - CHANGE COLUMN `mobile` `mobile` VARCHAR(15) NOT NULL DEFAULT '' COMMENT '手机号' COLLATE 'utf8mb4_unicode_ci' AFTER `id`; - -# 18:09 2021/8/17 -ALTER TABLE `agents` - ADD COLUMN `type` TINYINT NOT NULL DEFAULT '0' COMMENT '1、计调版旅行社;2、供应商旅行社;3、组团版旅行社' AFTER `remember_token`; - -# 23:25 2021/08/17 -ALTER TABLE `agent_products` - ADD COLUMN `guide_id` INT NOT NULL DEFAULT 0 COMMENT '绑定地接(组团版旅行社才能绑定)' AFTER `category_id`; - -ALTER TABLE `agents` - CHANGE COLUMN `type` `type` TINYINT(4) NOT NULL DEFAULT '0' COMMENT '1、计调版旅行社;2、供应商旅行社;3、组团版旅行社' AFTER `status`; - -ALTER TABLE `agent_products` - ADD COLUMN `verifier` INT NOT NULL DEFAULT '0' COMMENT '核销人员的user_id' AFTER `status`, - CHANGE COLUMN `product_id` `product_id` INT(11) NOT NULL COMMENT '供应商产品ID,组合产品时为第一个ID' AFTER `agent_id`, - ADD COLUMN `product_ids` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '供应商产品ID,主要用于组合产品,可能会有多个ID' COLLATE 'utf8_general_ci' AFTER `product_id`; - -ALTER TABLE `orders` - CHANGE COLUMN `product_id` `product_id` INT(11) NOT NULL COMMENT '供应商产品ID,组合产品时为第一个ID' AFTER `agent_product_id`, - ADD COLUMN `product_ids` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '供应商产品ID,主要用于组合产品,可能会有多个ID' COLLATE 'utf8_general_ci' AFTER `product_id`; - -# 9:37 2021/8/18 -ALTER TABLE `orders` - CHANGE COLUMN `paid_at` `paid_at` TIMESTAMP NULL DEFAULT NULL COMMENT '付款时间' AFTER `paid_money`, - CHANGE COLUMN `status` `status` TINYINT(3) NOT NULL DEFAULT '0' COMMENT '订单状态,-1:已取消;0:待付款;1:已付订金/定金/首付款;2:已付全款;3:已付尾款;4:线下未支付;5:线下已支付;6:退款中;7:已退款;16:已完成;' AFTER `picture`, - CHANGE COLUMN `pay_type` `pay_type` TINYINT(3) NOT NULL DEFAULT '0' COMMENT '支付方式,0:在线支付,1:线下支付,2:订金支付,3:定金支付,4:首款支付;5:追加/尾款支付;【注:订单生成后不应该再修改此项的值】' AFTER `status`; - -# 11:27 2021/8/18 -ALTER TABLE `agents` - ADD COLUMN `rate` FLOAT(10,2) NOT NULL DEFAULT 0 COMMENT '平台分成比率' AFTER `contact_phone`; - -ALTER TABLE `suppliers` - ADD COLUMN `rate` FLOAT(10,2) NOT NULL DEFAULT '0.00' COMMENT '平台分成比率' AFTER `contact_phone`; - -ALTER TABLE `guides` - ADD COLUMN `rate` FLOAT(10,2) NOT NULL DEFAULT '0.00' COMMENT '平台分成比率' AFTER `status`; - -# 17:54 2021/8/18 -ALTER TABLE `agent_products` - DROP INDEX `agent_id_product_id`, - ADD INDEX `agent_id_product_id` (`agent_id`, `product_id`); - -# 18:03 2021/8/19 -ALTER TABLE `advertisings` - CHANGE COLUMN `agent_id` `agent_id` INT(10) NOT NULL COMMENT '发布者ID' AFTER `id`, - ADD INDEX `agent_id` (`agent_id`); - -# 0:01 ‎2021/‎08/‎20 -ALTER TABLE `orders` - ADD COLUMN `guide_id` INT NOT NULL DEFAULT '0' COMMENT '地接ID' AFTER `refund_info`, - ADD INDEX `guide_id` (`guide_id`); - -# 14:27 2021/8/20 -ALTER TABLE `orders` - CHANGE COLUMN `status` `status` TINYINT(3) NOT NULL DEFAULT '0' COMMENT '订单状态,-1:已取消;0:待付款;1:已付订金/定金/首付款;2:已付全款;3:已付尾款;4:线下未支付;5:线下已支付;6:退款中;7:已退款;8:拒绝退款;16:已完成;' AFTER `picture`, - CHANGE COLUMN `refund_info` `refund_info` TEXT NULL DEFAULT NULL COMMENT '退款信息["desc":"退款说明","refund_no":"退款号,用于微信申请退款","pictures":"退款图片凭据","old_status":"申请退款前的订单状态"]' COLLATE 'utf8_general_ci' AFTER `paid_at`; - -ALTER TABLE `user_money_logs` - ADD INDEX `agent_id` (`agent_id`); - -CREATE TABLE `agent_product_items` ( - `id` INT(10) NOT NULL AUTO_INCREMENT, - `agent_product_id` INT(10) NOT NULL, - `agent_id` INT(10) NOT NULL, - `supplier_id` INT(10) NOT NULL, - `product_id` INT(10) NOT NULL, - PRIMARY KEY (`id`) USING BTREE, - INDEX `agent_product_id` (`agent_product_id`) USING BTREE, - INDEX `agent_id` (`agent_id`) USING BTREE, - INDEX `supplier_id` (`supplier_id`) USING BTREE, - INDEX `product_id` (`product_id`) USING BTREE -) -COMMENT='代理商产品-组合产品明细' -COLLATE='utf8_general_ci' -ENGINE=InnoDB -; - -ALTER TABLE `agent_products` - ADD COLUMN `stock` INT(10) NOT NULL DEFAULT '0' COMMENT '库存' AFTER `sale`; - -# 10:42 ‎2021/‎08/‎21 -ALTER TABLE `orders` - CHANGE COLUMN `order_no` `order_no` CHAR(22) NOT NULL COMMENT '订单号' COLLATE 'utf8_general_ci' AFTER `agent_id`; - -ALTER TABLE `orders` - ADD COLUMN verify_code CHAR(13) NOT NULL DEFAULT '' COMMENT '核销码' AFTER `guide_id`; - -# 10:35 ‎2021/‎08/‎22 -ALTER TABLE `slides` - CHANGE COLUMN `url` `picture` VARCHAR(255) NOT NULL COMMENT '轮播图地址' COLLATE 'utf8_general_ci' AFTER `title`, - ADD COLUMN `type` TINYINT NOT NULL DEFAULT '0' COMMENT '链接类型,0:链接到内部页面;1:链接到webview url' AFTER `sort`, - ADD COLUMN `url` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '链接地址' AFTER `type`; - -# 23:43 ‎2021/‎08/‎22 -CREATE TABLE `waterfall_ads` ( - `id` INT(10) NOT NULL AUTO_INCREMENT, - `agent_id` INT(10) NOT NULL COMMENT '代理商ID', - `title` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '广告名称' COLLATE 'utf8_general_ci', - `picture` VARCHAR(255) NOT NULL COMMENT '广告图片' COLLATE 'utf8_general_ci', - `type` TINYINT(3) NOT NULL DEFAULT '0' COMMENT '链接类型,0:链接到内部页面;1:链接到外部url', - `url` VARCHAR(50) NOT NULL COMMENT '链接' COLLATE 'utf8_general_ci', - `status` TINYINT(3) NOT NULL DEFAULT '1' COMMENT '0:未启用,1:启用', - `sort` SMALLINT(5) NOT NULL DEFAULT '255' COMMENT '排序,越小越靠前', - `created_at` TIMESTAMP NULL DEFAULT NULL, - `updated_at` TIMESTAMP NULL DEFAULT NULL, - PRIMARY KEY (`id`) USING BTREE, - INDEX `agent_id` (`agent_id`) USING BTREE -) -COMMENT='瀑布流内嵌广告' -COLLATE='utf8_general_ci' -ENGINE=InnoDB; - -# 12:39 2021/8/24 -ALTER TABLE `notices` - ADD COLUMN `sort` SMALLINT NOT NULL DEFAULT '255' COMMENT '排序,越小越靠前' AFTER `content`; - -ALTER TABLE `users` - CHANGE COLUMN `verifier` `is_verify` TINYINT(3) NOT NULL DEFAULT '0' COMMENT '是否是核销人员,1:是;0:否' AFTER `status`; - -# 15:51 2021/8/24 -ALTER TABLE `articles` - ADD COLUMN `type` TINYINT NOT NULL DEFAULT 0 COMMENT '0:普通列表显示;1:大图显示;' AFTER `content`, - ADD COLUMN `sort` SMALLINT NOT NULL DEFAULT 255 COMMENT '排序,越小越靠前' AFTER `type`; - -# 18:16 2021/8/24 -ALTER TABLE `slides` - COMMENT='广告图、轮播图等'; -RENAME TABLE `slides` TO `advertisings`; - -# 23:05 ‎2021/‎08/‎24 -ALTER TABLE `advertisings` - CHANGE COLUMN `agent_id` `agent_id` INT(11) NOT NULL COMMENT '发布者ID' AFTER `id`, - ADD COLUMN `display` TINYINT NOT NULL DEFAULT 0 COMMENT '显示位置,0:轮播图;1:首页横屏广告;2:瀑布流内嵌广告;' AFTER `url`; - -# 23:56 ‎2021/‎08/‎24 -ALTER TABLE `agent_products` - ADD INDEX `sale` (`sale`), - ADD INDEX `category_id` (`category_id`); - -# 0:24 ‎2021/‎08/‎25 -ALTER TABLE `specials` - DROP COLUMN `picture_ad`; - -# 14:15 2021/8/25 -ALTER TABLE `messages` - DROP COLUMN `is_read`; - -CREATE TABLE `message_reads` ( - `id` INT(10) NOT NULL COMMENT '消息ID,message_id', - `user_id` INT(10) NOT NULL COMMENT '用户ID,user_id', - PRIMARY KEY (`id`, `user_id`) USING BTREE -) -COMMENT='消息已读状态记录,如果含有记录,说明已读,否则未读' -COLLATE='utf8_general_ci' -ENGINE=InnoDB -; - -# 14:34 2021/8/25 -ALTER TABLE `agent_products` - ADD COLUMN `is_rec` TINYINT NOT NULL DEFAULT 0 COMMENT '是否推荐,推荐后在我的下文显示,0:未推荐;1:推荐;' AFTER `verifier`; - -# 16:35 2021/8/25 -ALTER TABLE `agent_products` - ADD COLUMN `type` TINYINT(3) NOT NULL DEFAULT '0' COMMENT '0:单品销售;1:组合销售;' AFTER `is_rec`, - ADD COLUMN `title` VARCHAR(255) NOT NULL COMMENT '标题' COLLATE 'utf8_general_ci' AFTER `type`, - ADD COLUMN `pictures` TEXT NOT NULL COMMENT '产品图片,可能有多张,JSON格式' COLLATE 'utf8_general_ci' AFTER `title`, - ADD COLUMN `know` TEXT NULL DEFAULT NULL COMMENT '旅客须知' COLLATE 'utf8_general_ci' AFTER `pictures`, - ADD COLUMN `content` MEDIUMTEXT NULL DEFAULT NULL COMMENT '产品详情' COLLATE 'utf8_general_ci' AFTER `know`; - -# 11:07 2021/8/26 -DROP TABLE `waterfall_ads`; - -# 19:25 2021/8/26 -CREATE TABLE `pay_debugs` ( - `id` INT(10) NOT NULL AUTO_INCREMENT, - `agent_id` INT(10) NOT NULL DEFAULT '0' COMMENT '代理商ID', - `type` TINYINT(3) NOT NULL DEFAULT '0' COMMENT '1:支付;2:退款;', - `content` TEXT NULL DEFAULT NULL COMMENT '回调内容' COLLATE 'utf8_general_ci', - `created_at` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP, - PRIMARY KEY (`id`) USING BTREE, - INDEX `agent_id` (`agent_id`) USING BTREE -) -COMMENT='微信支付回调记录' -COLLATE='utf8_general_ci' -ENGINE=InnoDB; - -CREATE TABLE `agent_settings` ( - `id` INT(10) NOT NULL AUTO_INCREMENT, - `agent_id` INT(10) NOT NULL COMMENT '代理商ID', - `setting` JSON NOT NULL COMMENT '设置值,JSON格式', - PRIMARY KEY (`id`) USING BTREE, - UNIQUE INDEX `agent_id` (`agent_id`) USING BTREE -) -COMMENT='代理商设置配置' -COLLATE='utf8_general_ci' -ENGINE=InnoDB; - -# 15:19 2021/8/27 -ALTER TABLE `messages` - ADD COLUMN `author` VARCHAR(20) NOT NULL DEFAULT '' COMMENT '作者' COLLATE 'utf8_general_ci' AFTER `content`; -ALTER TABLE `notices` - ADD COLUMN `author` VARCHAR(20) NOT NULL DEFAULT '' COMMENT '作者' COLLATE 'utf8_general_ci' AFTER `sort`; -ALTER TABLE `articles` - ADD COLUMN `agent_product_ids` TEXT NULL DEFAULT NULL COMMENT '绑定产品' AFTER `sort`; - -# 9:28 2021/8/30 -ALTER TABLE `agent_products` - ADD COLUMN `deposit` DECIMAL(20,2) NOT NULL DEFAULT 0 COMMENT '订金' AFTER `content`, - ADD COLUMN `deposit_timeout` INT NOT NULL DEFAULT 0 COMMENT '订金支付超时时间,单位:分钟' AFTER `deposit`, - ADD COLUMN `earnest` DECIMAL(20,2) NOT NULL DEFAULT '0' COMMENT '定金' AFTER `deposit_timeout`, - ADD COLUMN `earnest_timeout` INT NOT NULL DEFAULT 0 COMMENT '定金支付超时时间,单位:分钟' AFTER `earnest`; - -# 10:58 2021/8/30 -ALTER TABLE `orders` - ADD COLUMN `timeout` TIMESTAMP NULL DEFAULT NULL COMMENT '订单超时时间,超过这个时间,订单将变为“已取消”' AFTER `verify_code`; - -################################################################# -# 23:53 ‎2021/‎08/‎31 -CREATE TABLE `order_product_items` ( - `id` INT(11) NOT NULL AUTO_INCREMENT, - `order_id` INT(11) NOT NULL COMMENT '订单ID', - `agent_id` INT(11) NOT NULL COMMENT '代理商ID', - `agent_product_id` INT(11) NOT NULL COMMENT '代理商产品ID', - `supplier_id` INT(11) NOT NULL COMMENT '供应商ID', - `product_id` INT(11) NOT NULL COMMENT '供应商产品ID', - PRIMARY KEY (`id`) USING BTREE, - INDEX `order_id_supplier_id` (`order_id`, `supplier_id`) USING BTREE -) -COMMENT='订单对应产品表' -COLLATE='utf8_general_ci' -ENGINE=InnoDB; - -# 15:44 2021/9/2 -ALTER TABLE `order_product_items` - ADD COLUMN `num` INT(10) NOT NULL COMMENT '购买数量' AFTER `product_id`, - ADD COLUMN `price` DECIMAL(20,2) NOT NULL COMMENT '销售价格' AFTER `num`; - -# 16:42 2021/9/2 -ALTER TABLE `agent_products` - CHANGE COLUMN `type` `type` TINYINT(3) NOT NULL DEFAULT '0' COMMENT '0:单品销售;1:组合销售;2:组团旅行社的云产品;' AFTER `is_rec`, - ADD COLUMN `is_cloud` TINYINT NOT NULL DEFAULT 0 COMMENT '是否是(组团旅行社特有)云产品,。0:否;1:是;' AFTER `earnest_timeout`, - ADD COLUMN `agent_cloud_pid` INT(10) NOT NULL DEFAULT '0' COMMENT '组团版旅行社的云产品ID' AFTER `is_cloud`, - ADD INDEX `agent_cloud_pid` (`agent_cloud_pid`); -UPDATE `agent_products` ap SET `is_cloud`=1 WHERE EXISTS(SELECT 1 FROM `agents` WHERE `id`=ap.`agent_id` AND `type`=3); - -# 18:15 2021/9/3 -ALTER TABLE `orders` - ADD COLUMN `agent_cloud_pid` INT NOT NULL DEFAULT 0 COMMENT '组团云产品ID' AFTER `verify_code`, - ADD COLUMN `agent_cloud_price` DECIMAL(20,2) NOT NULL DEFAULT '0' COMMENT '组团云产品销售价格' AFTER `agent_cloud_pid`, - ADD INDEX `agent_cloud_pid` (`agent_cloud_pid`); - -# 9:26 2021/9/6 -ALTER TABLE `user_money_logs` - ADD COLUMN `out_trade_no` CHAR(24) NOT NULL DEFAULT '' COMMENT '发起支付时传给微信的订单号(格式:order_no-status)' AFTER `transaction_id`; - -# 11:40 2021/9/6 -ALTER TABLE `products` - CHANGE COLUMN `status` `status` TINYINT(3) NOT NULL DEFAULT '1' COMMENT '-2:下架,-1:审核拒绝,0:未审核,1:上架' AFTER `sale`; -ALTER TABLE `agent_products` - CHANGE COLUMN `status` `status` TINYINT(3) NOT NULL DEFAULT '1' COMMENT '-2:下架,-1:审核拒绝,0:未审核,1:上架' AFTER `guide_id`; - -# 10:40 2021/9/7 -ALTER TABLE `products` - ADD COLUMN `type` TINYINT NOT NULL DEFAULT 0 COMMENT '0:旅游线路、1:洒店、2:景区、3:餐厅、4:车队、5:单项' AFTER `category_id`, - ADD COLUMN `extends` JSON NULL DEFAULT NULL COMMENT '扩展字段,根据type不同,字段名不同' AFTER `verify_mobile`; - -ALTER TABLE `suppliers` - ADD COLUMN `public_type` VARCHAR(255) NOT NULL DEFAULT '[]' COMMENT '允许发布产品的模板' AFTER `rate`; - -# 9:39 2021/9/8 -ALTER TABLE `suppliers` - CHANGE COLUMN `public_type` `publish_type` VARCHAR(255) NOT NULL DEFAULT '[]' COMMENT '允许发布产品的模板' COLLATE 'utf8_general_ci' AFTER `rate`; - -# 15:19 2021/9/9 -ALTER TABLE `orders` - ADD COLUMN `pay_user_id` INT NOT NULL DEFAULT 0 COMMENT '支付用户的user_id(跳转到外部小程序支付时用到)' AFTER `agent_cloud_price`; - - - -# 18:47 2021/9/11 -ALTER TABLE `agents` - CHANGE COLUMN `appid` `appid` VARCHAR(30) NULL COMMENT '微信AppID' COLLATE 'utf8_general_ci' AFTER `remember_token`, - CHANGE COLUMN `appsecret` `appsecret` CHAR(32) NULL COMMENT '微信AppSecret' COLLATE 'utf8_general_ci' AFTER `appid`, - CHANGE COLUMN `mchid` `mchid` VARCHAR(32) NULL COMMENT '微信支付mch_id' COLLATE 'utf8_general_ci' AFTER `appsecret`, - CHANGE COLUMN `mchkey` `mchkey` CHAR(32) NULL COMMENT '微信支付key' COLLATE 'utf8_general_ci' AFTER `mchid`; - -CREATE TABLE `mini_program_drafts` ( - `draft_id` INT(10) NOT NULL COMMENT '腾讯开放平台的草稿ID', - `user_version` VARCHAR(20) NOT NULL DEFAULT '' COMMENT '版本号' COLLATE 'utf8_general_ci', - `user_desc` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '描述' COLLATE 'utf8_general_ci', - `source_miniprogram_appid` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '模板小程序APPID' COLLATE 'utf8_general_ci', - `source_miniprogram` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '来源小程序' COLLATE 'utf8_general_ci', - `developer` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '开发者' COLLATE 'utf8_general_ci', - `create_time` INT(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '草稿创建时间', - `is_create_template` TINYINT(3) NOT NULL DEFAULT '0' COMMENT '是否已创建模板,0:否,1:是', - PRIMARY KEY (`draft_id`) USING BTREE -) -COMMENT='第三方平台草稿列表' -COLLATE='utf8_general_ci' -ENGINE=InnoDB; - -CREATE TABLE `mini_program_events` ( - `id` BIGINT(19) NOT NULL AUTO_INCREMENT, - `type` TINYINT(3) NOT NULL DEFAULT '0' COMMENT '0:授权事件接收;1:消息与事件接收', - `response` TEXT NULL DEFAULT NULL COMMENT '所有请求信息' COLLATE 'utf8mb4_bin', - `event` VARCHAR(255) NULL DEFAULT NULL COLLATE 'utf8mb4_bin', - `appid` VARCHAR(50) NULL DEFAULT NULL COMMENT 'msg_event时才会记录' COLLATE 'utf8mb4_bin', - `created_at` TIMESTAMP NULL DEFAULT NULL, - PRIMARY KEY (`id`) USING BTREE -) -COMMENT='第三方平台事件接收记录' -COLLATE='utf8mb4_bin' -ENGINE=InnoDB; - -CREATE TABLE `mini_program_templates` ( - `template_id` INT(10) NOT NULL, - `user_version` VARCHAR(20) NOT NULL DEFAULT '' COMMENT '版本号' COLLATE 'utf8_general_ci', - `user_desc` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '描述' COLLATE 'utf8_general_ci', - `source_miniprogram_appid` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '来源小程序' COLLATE 'utf8_general_ci', - `source_miniprogram` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '模板小程序APPID' COLLATE 'utf8_general_ci', - `developer` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '上传者微信昵称' COLLATE 'utf8_general_ci', - `template_type` INT(10) NOT NULL DEFAULT '0' COMMENT '模板ID', - `create_time` INT(10) UNSIGNED NOT NULL DEFAULT '0', - PRIMARY KEY (`template_id`) USING BTREE -) -COMMENT='第三方平台模板列表' -COLLATE='utf8_general_ci' -ENGINE=InnoDB; - -CREATE TABLE `mini_program_upload_logs` ( - `id` INT(10) NOT NULL AUTO_INCREMENT, - `agent_id` INT(10) NOT NULL COMMENT '代理商ID', - `appid` VARCHAR(50) NOT NULL COMMENT '代理商APPID' COLLATE 'utf8_general_ci', - `user_version` VARCHAR(20) NOT NULL COMMENT '版本号' COLLATE 'utf8_general_ci', - `template_id` INT(10) NOT NULL COMMENT '小程序template_id', - `qrcode` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '小程序上传后获取到的二维码' COLLATE 'utf8_general_ci', - `audit_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0' COMMENT '审核ID', - `is_success` TINYINT(3) NOT NULL DEFAULT '-1' COMMENT '0:审核成功; 1:审核被拒绝; 2:审核中; 3:已撤回; 4:审核延后', - `created_at` TIMESTAMP NULL DEFAULT NULL, - `updated_at` TIMESTAMP NULL DEFAULT NULL, - PRIMARY KEY (`id`) USING BTREE, - INDEX `agent_id` (`agent_id`) USING BTREE -) -COMMENT='注册小程序日志' -COLLATE='utf8_general_ci' -ENGINE=InnoDB; - -# 9:29 2021/9/13 -ALTER TABLE `agents` - ADD COLUMN `credit_codes` VARCHAR(50) NOT NULL DEFAULT '' COMMENT '统一社会信用代码' AFTER `company_name`, - ADD COLUMN `legal_persona_name` VARCHAR(20) NOT NULL DEFAULT '' COMMENT '法人姓名' AFTER `contact_phone`, - ADD COLUMN `legal_persona_wechat` VARCHAR(100) NOT NULL DEFAULT '' COMMENT '法人微信号' AFTER `legal_persona_name`; - -# 17:02 2021/9/13 -ALTER TABLE `user_money_logs` - CHANGE COLUMN `money` `money` DECIMAL(20,2) NOT NULL COMMENT '变动金额,正数=平台收入,负数=平台支出' AFTER `agent_id`; From f38a24f83237676157ce2b6046bb6650f5077a2c Mon Sep 17 00:00:00 2001 From: liapples Date: Thu, 16 Sep 2021 09:55:23 +0800 Subject: [PATCH 11/14] =?UTF-8?q?=E5=8E=BB=E6=8E=89=E6=97=A0=E7=94=A8?= =?UTF-8?q?=E7=9A=84=E5=85=B3=E8=81=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Models/AgentProduct.php | 5 ----- 1 file changed, 5 deletions(-) diff --git a/app/Models/AgentProduct.php b/app/Models/AgentProduct.php index 04c9464..0d6fb99 100644 --- a/app/Models/AgentProduct.php +++ b/app/Models/AgentProduct.php @@ -22,11 +22,6 @@ class AgentProduct extends BaseModel return $this->hasMany(Coupon::class); } - public function fav() - { - return $this->hasOne(UserFav::class); - } - public function agent() { return $this->belongsTo(Agent::class); From 31eb86ee296f70a93326ad4f622ab745012a4ce9 Mon Sep 17 00:00:00 2001 From: liapples Date: Thu, 16 Sep 2021 11:58:07 +0800 Subject: [PATCH 12/14] =?UTF-8?q?=E8=AE=A2=E5=8D=95=E8=B6=85=E6=97=B6?= =?UTF-8?q?=E7=94=B1=E4=BE=9B=E5=BA=94=E5=95=86=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/OrderController.php | 10 ---- .../Controllers/OrderController.php | 8 ++- .../Extensions/Grid/ChangeOrderStatus.php | 50 +++++++++++++++++++ 3 files changed, 57 insertions(+), 11 deletions(-) create mode 100644 app/AdminSupplier/Extensions/Grid/ChangeOrderStatus.php diff --git a/app/AdminAgent/Controllers/OrderController.php b/app/AdminAgent/Controllers/OrderController.php index 3d000a2..01632e2 100644 --- a/app/AdminAgent/Controllers/OrderController.php +++ b/app/AdminAgent/Controllers/OrderController.php @@ -3,19 +3,16 @@ namespace App\AdminAgent\Controllers; use App\AdminAgent\Extensions\Grid\AuditRefund; -use App\AdminAgent\Extensions\Grid\ChangeOrderStatus; use App\AdminAgent\Repositories\Order; use App\Common\OrderStatus; use App\Common\PayType; use App\Models\OrderProductItem; -use App\Models\Supplier; use Dcat\Admin\Admin; use Dcat\Admin\Form; use Dcat\Admin\Grid; use Dcat\Admin\Grid\Filter\AbstractFilter; use Dcat\Admin\Show; use Dcat\Admin\Http\Controllers\AdminController; -use Dcat\Admin\Widgets\Dropdown; use Dcat\Admin\Widgets\Table; use Illuminate\Support\Arr; use Illuminate\Support\Facades\Storage; @@ -101,10 +98,6 @@ class OrderController extends AdminController } else if ($this->status == OrderStatus::REFUSED_REFUND) { $column->append('已拒绝退款'); } - }) - ->if(fn() => $this->status == OrderStatus::OFFLINE_UNPAID) - ->then(function (Grid\Column $column) { - return $column->action(new ChangeOrderStatus); }); $grid->column('pay_type')->using(PayType::array()); @@ -221,9 +214,6 @@ class OrderController extends AdminController if ($form->status !== null) { if (in_array($form->status, [OrderStatus::REFUNDED, OrderStatus::REFUSED_REFUND])) { return $form->response()->error('请通过订单列表的”通过“和”拒绝“按钮来审核退款'); - } else if ($form->status == OrderStatus::OFFLINE_PAID) { - $form->hidden('timeout'); - $form->timeout = null; //清空超时时间 } else { return $form->response()->error('操作禁止'); } diff --git a/app/AdminSupplier/Controllers/OrderController.php b/app/AdminSupplier/Controllers/OrderController.php index 88e7c8d..7d01749 100644 --- a/app/AdminSupplier/Controllers/OrderController.php +++ b/app/AdminSupplier/Controllers/OrderController.php @@ -2,6 +2,7 @@ namespace App\AdminSupplier\Controllers; +use App\AdminSupplier\Extensions\Grid\ChangeOrderStatus; use App\AdminSupplier\Repositories\Order; use App\Common\OrderStatus; use App\Common\PayType; @@ -59,7 +60,12 @@ class OrderController extends AdminController $grid->column('price'); // $grid->column('refund_info'); $grid->column('pay_type')->using(PayType::array()); - $grid->column('status', '订单状态')->using(OrderStatus::array()); + $grid->column('status', '订单状态') + ->using(OrderStatus::array()) + ->if(fn() => $this->status == OrderStatus::OFFLINE_UNPAID) + ->then(function (Grid\Column $column) { + return $column->action(new ChangeOrderStatus); + }); $grid->column('paid_at'); $grid->column('created_at'); diff --git a/app/AdminSupplier/Extensions/Grid/ChangeOrderStatus.php b/app/AdminSupplier/Extensions/Grid/ChangeOrderStatus.php new file mode 100644 index 0000000..fd63cb8 --- /dev/null +++ b/app/AdminSupplier/Extensions/Grid/ChangeOrderStatus.php @@ -0,0 +1,50 @@ +appendHtmlAttribute('class', 'btn btn-sm btn-success'); + $this->defaultHtmlAttribute('href', 'javascript:;'); + + return "formatHtmlAttributes()}>{$this->title}"; + } + + public function handle() + { + try { + $order = Order::query()->whereHas('orderProductItem', function ($query) { + $query->where(['supplier_id' => Admin::user()->id, 'order_id' => $this->getKey()]); + })->firstWhere(['id' => $this->getKey(), 'status' => OrderStatus::OFFLINE_UNPAID]); + if (!$order) { + return $this->response()->error("订单不存在或已处理过了")->refresh(); + } + $order->status = OrderStatus::OFFLINE_PAID; + $order->verify_code = uniqid(); //生成核销码 + $order->save(); + + return $this->response()->success("操作成功,已设置为“线下已付款”")->refresh(); + } catch (\Exception $e) { + return $this->response()->error($e->getMessage()); + } + } + + public function confirm() + { + return ['确定要设置为已付款吗?', '']; + } +} From 1b12c899dcdfe83d98fc51976af4ac41a3284c52 Mon Sep 17 00:00:00 2001 From: shuixiang Date: Thu, 16 Sep 2021 12:15:49 +0800 Subject: [PATCH 13/14] =?UTF-8?q?=E5=BC=82=E5=B8=B8=E6=8A=A5=E5=91=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Exceptions/Handler.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index e2a4569..d59b8d9 100644 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -36,11 +36,7 @@ class Handler extends ExceptionHandler */ public function register() { - $this->reportable(function (Throwable $e) { - if ($this->shouldReport($e) && app()->bound('sentry')) { - app('sentry')->captureException($e); - } - }); + // } /** @@ -49,6 +45,9 @@ class Handler extends ExceptionHandler */ public function report(Throwable $e): bool { + if ($this->shouldReport($e) && app()->bound('sentry')) { + app('sentry')->captureException($e); + } // 判断异常是否需要自定义报告... return false; } From 882ac7fb24d11d07a986016f9b998972c4501cf9 Mon Sep 17 00:00:00 2001 From: liapples Date: Thu, 16 Sep 2021 13:04:58 +0800 Subject: [PATCH 14/14] =?UTF-8?q?=E5=9B=9E=E6=BB=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/OrderController.php | 8 ++++ .../Extensions/Grid/ChangeOrderStatus.php | 47 ------------------- .../Controllers/OrderController.php | 17 ++----- 3 files changed, 13 insertions(+), 59 deletions(-) delete mode 100644 app/AdminAgent/Extensions/Grid/ChangeOrderStatus.php diff --git a/app/AdminAgent/Controllers/OrderController.php b/app/AdminAgent/Controllers/OrderController.php index 01632e2..86a360a 100644 --- a/app/AdminAgent/Controllers/OrderController.php +++ b/app/AdminAgent/Controllers/OrderController.php @@ -3,6 +3,7 @@ namespace App\AdminAgent\Controllers; use App\AdminAgent\Extensions\Grid\AuditRefund; +use App\AdminAgent\Extensions\Grid\ChangeOrderStatus; use App\AdminAgent\Repositories\Order; use App\Common\OrderStatus; use App\Common\PayType; @@ -98,6 +99,10 @@ class OrderController extends AdminController } else if ($this->status == OrderStatus::REFUSED_REFUND) { $column->append('已拒绝退款'); } + }) + ->if(fn() => $this->status == OrderStatus::OFFLINE_UNPAID) + ->then(function (Grid\Column $column) { + return $column->action(new ChangeOrderStatus); }); $grid->column('pay_type')->using(PayType::array()); @@ -214,6 +219,9 @@ class OrderController extends AdminController if ($form->status !== null) { if (in_array($form->status, [OrderStatus::REFUNDED, OrderStatus::REFUSED_REFUND])) { return $form->response()->error('请通过订单列表的”通过“和”拒绝“按钮来审核退款'); + } else if ($form->status == OrderStatus::OFFLINE_PAID) { + $form->hidden('timeout'); + $form->timeout = null; //清空超时时间 } else { return $form->response()->error('操作禁止'); } diff --git a/app/AdminAgent/Extensions/Grid/ChangeOrderStatus.php b/app/AdminAgent/Extensions/Grid/ChangeOrderStatus.php deleted file mode 100644 index a26bd9c..0000000 --- a/app/AdminAgent/Extensions/Grid/ChangeOrderStatus.php +++ /dev/null @@ -1,47 +0,0 @@ -appendHtmlAttribute('class', 'btn btn-sm btn-success'); - $this->defaultHtmlAttribute('href', 'javascript:;'); - - return "formatHtmlAttributes()}>{$this->title}"; - } - - public function handle() - { - try { - $order = Order::firstWhere(['id' => $this->getKey(), 'agent_id' => Admin::user()->id, 'status' => OrderStatus::OFFLINE_UNPAID]); - if (!$order) { - return $this->response()->error("订单不存在或已处理过了")->refresh(); - } - $order->status = OrderStatus::OFFLINE_PAID; - $order->verify_code = uniqid(); //生成核销码 - $order->save(); - - return $this->response()->success("操作成功,已设置为“线下已付款”")->refresh(); - } catch (\Exception $e) { - return $this->response()->error($e->getMessage()); - } - } - - public function confirm() - { - return ['确定要设置为已付款吗?', '']; - } -} diff --git a/app/AdminSupplier/Controllers/OrderController.php b/app/AdminSupplier/Controllers/OrderController.php index 7d01749..611a1b6 100644 --- a/app/AdminSupplier/Controllers/OrderController.php +++ b/app/AdminSupplier/Controllers/OrderController.php @@ -2,12 +2,10 @@ namespace App\AdminSupplier\Controllers; -use App\AdminSupplier\Extensions\Grid\ChangeOrderStatus; use App\AdminSupplier\Repositories\Order; use App\Common\OrderStatus; use App\Common\PayType; use App\Models\Agent; -use App\Models\OrderProductItem; use App\Models\Supplier; use Dcat\Admin\Admin; use Dcat\Admin\Form; @@ -60,12 +58,7 @@ class OrderController extends AdminController $grid->column('price'); // $grid->column('refund_info'); $grid->column('pay_type')->using(PayType::array()); - $grid->column('status', '订单状态') - ->using(OrderStatus::array()) - ->if(fn() => $this->status == OrderStatus::OFFLINE_UNPAID) - ->then(function (Grid\Column $column) { - return $column->action(new ChangeOrderStatus); - }); + $grid->column('status', '订单状态')->using(OrderStatus::array()); $grid->column('paid_at'); $grid->column('created_at'); @@ -102,10 +95,10 @@ class OrderController extends AdminController $show->disableQuickEdit(); $show->disableEditButton(); - //不允许查看非自己的数据,$show->model()->whereHas()不起作用? - if (!OrderProductItem::where(['order_id' => $show->model()->id, 'supplier_id' => Admin::user()->id])->exists()) { - Admin::exit('数据不存在'); - } + //不允许查看非自己的数据 TODO 待筛选 + $show->model()->whereHas('orderProductItem', function ($query) { + return $query->where('supplier_id', Admin::user()->id); + }); $show->field('id'); $show->field('agent.name');