From 76cce51cdfe18c035be46b8d33da81a4250fc131 Mon Sep 17 00:00:00 2001 From: liapples Date: Tue, 24 Aug 2021 10:52:10 +0800 Subject: [PATCH 01/42] =?UTF-8?q?=E4=BB=A3=E7=90=86=E5=95=86=E8=B5=84?= =?UTF-8?q?=E6=96=99=EF=BC=8C=E5=85=B3=E4=BA=8E=E6=88=91=E4=BB=AC=E3=80=81?= =?UTF-8?q?=E6=B3=A8=E5=86=8C=E5=8D=8F=E8=AE=AE=E3=80=81=E8=B4=AD=E4=B9=B0?= =?UTF-8?q?=E5=8D=8F=E8=AE=AE=E7=BC=96=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/AgentInfoController.php | 18 + app/AdminAgent/Forms/AgentInfo.php | 49 +++ app/AdminAgent/routes.php | 1 + dcat_admin_ide_helper.php | 320 +++++++++--------- resources/lang/zh_CN/agent-info.php | 15 + 5 files changed, 243 insertions(+), 160 deletions(-) create mode 100644 app/AdminAgent/Controllers/AgentInfoController.php create mode 100644 app/AdminAgent/Forms/AgentInfo.php create mode 100644 resources/lang/zh_CN/agent-info.php diff --git a/app/AdminAgent/Controllers/AgentInfoController.php b/app/AdminAgent/Controllers/AgentInfoController.php new file mode 100644 index 0000000..63600ba --- /dev/null +++ b/app/AdminAgent/Controllers/AgentInfoController.php @@ -0,0 +1,18 @@ +title('代理商信息') + ->body(new Card(' ', new AgentInfo())); + } +} diff --git a/app/AdminAgent/Forms/AgentInfo.php b/app/AdminAgent/Forms/AgentInfo.php new file mode 100644 index 0000000..342cfc9 --- /dev/null +++ b/app/AdminAgent/Forms/AgentInfo.php @@ -0,0 +1,49 @@ +find(Admin::user()->id); + $model->about = $input['about']; + $model->reg_protocol = $input['reg_protocol']; + $model->buy_protocol = $input['buy_protocol']; + $model->save(); + + return $this->response()->success('保存成功')->refresh(); + } + + /** + * Build a form here. + */ + public function form() + { + $this->editor('about')->required(); + $this->editor('reg_protocol')->required(); + $this->editor('buy_protocol')->required(); + } + + /** + * The data of the form. + * + * @return array + */ + public function default() + { + return Model::query()->find(Admin::user()->id)->toArray(); + } +} diff --git a/app/AdminAgent/routes.php b/app/AdminAgent/routes.php index 5e345a1..770fea5 100644 --- a/app/AdminAgent/routes.php +++ b/app/AdminAgent/routes.php @@ -22,4 +22,5 @@ Route::group([ $router->resource('slide/list', 'SlideController'); $router->resource('special/list', 'SpecialController'); $router->resource('waterfall_ad/list', 'WaterfallAdController'); + $router->resource('agent_info', 'AgentInfoController'); }); diff --git a/dcat_admin_ide_helper.php b/dcat_admin_ide_helper.php index 9bdf614..371bf3d 100644 --- a/dcat_admin_ide_helper.php +++ b/dcat_admin_ide_helper.php @@ -11,87 +11,87 @@ namespace Dcat\Admin { use Illuminate\Support\Collection; /** - * @property Grid\Column|Collection product_id - * @property Grid\Column|Collection know - * @property Grid\Column|Collection content + * @property Grid\Column|Collection agent_id + * @property Grid\Column|Collection created_at + * @property Grid\Column|Collection desc * @property Grid\Column|Collection id * @property Grid\Column|Collection name + * @property Grid\Column|Collection picture + * @property Grid\Column|Collection tag + * @property Grid\Column|Collection updated_at + * @property Grid\Column|Collection content + * @property Grid\Column|Collection know + * @property Grid\Column|Collection product_id + * @property Grid\Column|Collection detail * @property Grid\Column|Collection type * @property Grid\Column|Collection version - * @property Grid\Column|Collection detail - * @property Grid\Column|Collection created_at - * @property Grid\Column|Collection updated_at * @property Grid\Column|Collection is_enabled - * @property Grid\Column|Collection parent_id - * @property Grid\Column|Collection order + * @property Grid\Column|Collection extension * @property Grid\Column|Collection icon + * @property Grid\Column|Collection order + * @property Grid\Column|Collection parent_id * @property Grid\Column|Collection uri - * @property Grid\Column|Collection extension - * @property Grid\Column|Collection permission_id * @property Grid\Column|Collection menu_id - * @property Grid\Column|Collection slug + * @property Grid\Column|Collection permission_id * @property Grid\Column|Collection http_method * @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 username - * @property Grid\Column|Collection password * @property Grid\Column|Collection avatar + * @property Grid\Column|Collection password * @property Grid\Column|Collection remember_token - * @property Grid\Column|Collection agent_id - * @property Grid\Column|Collection picture - * @property Grid\Column|Collection tag - * @property Grid\Column|Collection desc + * @property Grid\Column|Collection username * @property Grid\Column|Collection about - * @property Grid\Column|Collection reg_protocol * @property Grid\Column|Collection buy_protocol + * @property Grid\Column|Collection reg_protocol * @property Grid\Column|Collection agent_product_id * @property Grid\Column|Collection supplier_id - * @property Grid\Column|Collection product_ids - * @property Grid\Column|Collection price - * @property Grid\Column|Collection original_price - * @property Grid\Column|Collection sale - * @property Grid\Column|Collection stock - * @property Grid\Column|Collection channel_id * @property Grid\Column|Collection category_id + * @property Grid\Column|Collection channel_id + * @property Grid\Column|Collection deleted_at * @property Grid\Column|Collection guide_id + * @property Grid\Column|Collection original_price + * @property Grid\Column|Collection price + * @property Grid\Column|Collection product_ids + * @property Grid\Column|Collection sale * @property Grid\Column|Collection status + * @property Grid\Column|Collection stock * @property Grid\Column|Collection verifier - * @property Grid\Column|Collection deleted_at + * @property Grid\Column|Collection address * @property Grid\Column|Collection appid * @property Grid\Column|Collection appsecret - * @property Grid\Column|Collection mchid - * @property Grid\Column|Collection mchkey * @property Grid\Column|Collection company_name - * @property Grid\Column|Collection logo - * @property Grid\Column|Collection address - * @property Grid\Column|Collection license_pic - * @property Grid\Column|Collection director * @property Grid\Column|Collection contact_phone + * @property Grid\Column|Collection director + * @property Grid\Column|Collection license_pic + * @property Grid\Column|Collection logo + * @property Grid\Column|Collection mchid + * @property Grid\Column|Collection mchkey * @property Grid\Column|Collection rate * @property Grid\Column|Collection author * @property Grid\Column|Collection image * @property Grid\Column|Collection pid * @property Grid\Column|Collection sort * @property Grid\Column|Collection template - * @property Grid\Column|Collection start_at * @property Grid\Column|Collection end_at - * @property Grid\Column|Collection uuid + * @property Grid\Column|Collection start_at * @property Grid\Column|Collection connection - * @property Grid\Column|Collection queue - * @property Grid\Column|Collection payload * @property Grid\Column|Collection exception * @property Grid\Column|Collection failed_at + * @property Grid\Column|Collection payload + * @property Grid\Column|Collection queue + * @property Grid\Column|Collection uuid * @property Grid\Column|Collection photo * @property Grid\Column|Collection is_read - * @property Grid\Column|Collection order_no - * @property Grid\Column|Collection num - * @property Grid\Column|Collection mobile - * @property Grid\Column|Collection pay_type * @property Grid\Column|Collection coupon_id - * @property Grid\Column|Collection paid_money + * @property Grid\Column|Collection mobile + * @property Grid\Column|Collection num + * @property Grid\Column|Collection order_no * @property Grid\Column|Collection paid_at + * @property Grid\Column|Collection paid_money + * @property Grid\Column|Collection pay_type * @property Grid\Column|Collection refund_info * @property Grid\Column|Collection verify_code * @property Grid\Column|Collection email @@ -107,87 +107,87 @@ namespace Dcat\Admin { * @property Grid\Column|Collection openid * @property Grid\Column|Collection unionid * - * @method Grid\Column|Collection product_id(string $label = null) - * @method Grid\Column|Collection know(string $label = null) - * @method Grid\Column|Collection content(string $label = null) + * @method Grid\Column|Collection agent_id(string $label = null) + * @method Grid\Column|Collection created_at(string $label = null) + * @method Grid\Column|Collection desc(string $label = null) * @method Grid\Column|Collection id(string $label = null) * @method Grid\Column|Collection name(string $label = null) + * @method Grid\Column|Collection picture(string $label = null) + * @method Grid\Column|Collection tag(string $label = null) + * @method Grid\Column|Collection updated_at(string $label = null) + * @method Grid\Column|Collection content(string $label = null) + * @method Grid\Column|Collection know(string $label = null) + * @method Grid\Column|Collection product_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) - * @method Grid\Column|Collection detail(string $label = null) - * @method Grid\Column|Collection created_at(string $label = null) - * @method Grid\Column|Collection updated_at(string $label = null) * @method Grid\Column|Collection is_enabled(string $label = null) - * @method Grid\Column|Collection parent_id(string $label = null) - * @method Grid\Column|Collection order(string $label = null) + * @method Grid\Column|Collection extension(string $label = null) * @method Grid\Column|Collection icon(string $label = null) + * @method Grid\Column|Collection order(string $label = null) + * @method Grid\Column|Collection parent_id(string $label = null) * @method Grid\Column|Collection uri(string $label = null) - * @method Grid\Column|Collection extension(string $label = null) - * @method Grid\Column|Collection permission_id(string $label = null) * @method Grid\Column|Collection menu_id(string $label = null) - * @method Grid\Column|Collection slug(string $label = null) + * @method Grid\Column|Collection permission_id(string $label = null) * @method Grid\Column|Collection http_method(string $label = null) * @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 username(string $label = null) - * @method Grid\Column|Collection password(string $label = null) * @method Grid\Column|Collection avatar(string $label = null) + * @method Grid\Column|Collection password(string $label = null) * @method Grid\Column|Collection remember_token(string $label = null) - * @method Grid\Column|Collection agent_id(string $label = null) - * @method Grid\Column|Collection picture(string $label = null) - * @method Grid\Column|Collection tag(string $label = null) - * @method Grid\Column|Collection desc(string $label = null) + * @method Grid\Column|Collection username(string $label = null) * @method Grid\Column|Collection about(string $label = null) - * @method Grid\Column|Collection reg_protocol(string $label = null) * @method Grid\Column|Collection buy_protocol(string $label = null) + * @method Grid\Column|Collection reg_protocol(string $label = null) * @method Grid\Column|Collection agent_product_id(string $label = null) * @method Grid\Column|Collection supplier_id(string $label = null) - * @method Grid\Column|Collection product_ids(string $label = null) - * @method Grid\Column|Collection price(string $label = null) - * @method Grid\Column|Collection original_price(string $label = null) - * @method Grid\Column|Collection sale(string $label = null) - * @method Grid\Column|Collection stock(string $label = null) - * @method Grid\Column|Collection channel_id(string $label = null) * @method Grid\Column|Collection category_id(string $label = null) + * @method Grid\Column|Collection channel_id(string $label = null) + * @method Grid\Column|Collection deleted_at(string $label = null) * @method Grid\Column|Collection guide_id(string $label = null) + * @method Grid\Column|Collection original_price(string $label = null) + * @method Grid\Column|Collection price(string $label = null) + * @method Grid\Column|Collection product_ids(string $label = null) + * @method Grid\Column|Collection sale(string $label = null) * @method Grid\Column|Collection status(string $label = null) + * @method Grid\Column|Collection stock(string $label = null) * @method Grid\Column|Collection verifier(string $label = null) - * @method Grid\Column|Collection deleted_at(string $label = null) + * @method Grid\Column|Collection address(string $label = null) * @method Grid\Column|Collection appid(string $label = null) * @method Grid\Column|Collection appsecret(string $label = null) - * @method Grid\Column|Collection mchid(string $label = null) - * @method Grid\Column|Collection mchkey(string $label = null) * @method Grid\Column|Collection company_name(string $label = null) - * @method Grid\Column|Collection logo(string $label = null) - * @method Grid\Column|Collection address(string $label = null) - * @method Grid\Column|Collection license_pic(string $label = null) - * @method Grid\Column|Collection director(string $label = null) * @method Grid\Column|Collection contact_phone(string $label = null) + * @method Grid\Column|Collection director(string $label = null) + * @method Grid\Column|Collection license_pic(string $label = null) + * @method Grid\Column|Collection logo(string $label = null) + * @method Grid\Column|Collection mchid(string $label = null) + * @method Grid\Column|Collection mchkey(string $label = null) * @method Grid\Column|Collection rate(string $label = null) * @method Grid\Column|Collection author(string $label = null) * @method Grid\Column|Collection image(string $label = null) * @method Grid\Column|Collection pid(string $label = null) * @method Grid\Column|Collection sort(string $label = null) * @method Grid\Column|Collection template(string $label = null) - * @method Grid\Column|Collection start_at(string $label = null) * @method Grid\Column|Collection end_at(string $label = null) - * @method Grid\Column|Collection uuid(string $label = null) + * @method Grid\Column|Collection start_at(string $label = null) * @method Grid\Column|Collection connection(string $label = null) - * @method Grid\Column|Collection queue(string $label = null) - * @method Grid\Column|Collection payload(string $label = null) * @method Grid\Column|Collection exception(string $label = null) * @method Grid\Column|Collection failed_at(string $label = null) + * @method Grid\Column|Collection payload(string $label = null) + * @method Grid\Column|Collection queue(string $label = null) + * @method Grid\Column|Collection uuid(string $label = null) * @method Grid\Column|Collection photo(string $label = null) * @method Grid\Column|Collection is_read(string $label = null) - * @method Grid\Column|Collection order_no(string $label = null) - * @method Grid\Column|Collection num(string $label = null) - * @method Grid\Column|Collection mobile(string $label = null) - * @method Grid\Column|Collection pay_type(string $label = null) * @method Grid\Column|Collection coupon_id(string $label = null) - * @method Grid\Column|Collection paid_money(string $label = null) + * @method Grid\Column|Collection mobile(string $label = null) + * @method Grid\Column|Collection num(string $label = null) + * @method Grid\Column|Collection order_no(string $label = null) * @method Grid\Column|Collection paid_at(string $label = null) + * @method Grid\Column|Collection paid_money(string $label = null) + * @method Grid\Column|Collection pay_type(string $label = null) * @method Grid\Column|Collection refund_info(string $label = null) * @method Grid\Column|Collection verify_code(string $label = null) * @method Grid\Column|Collection email(string $label = null) @@ -208,87 +208,87 @@ namespace Dcat\Admin { class MiniGrid extends Grid {} /** - * @property Show\Field|Collection product_id - * @property Show\Field|Collection know - * @property Show\Field|Collection content + * @property Show\Field|Collection agent_id + * @property Show\Field|Collection created_at + * @property Show\Field|Collection desc * @property Show\Field|Collection id * @property Show\Field|Collection name + * @property Show\Field|Collection picture + * @property Show\Field|Collection tag + * @property Show\Field|Collection updated_at + * @property Show\Field|Collection content + * @property Show\Field|Collection know + * @property Show\Field|Collection product_id + * @property Show\Field|Collection detail * @property Show\Field|Collection type * @property Show\Field|Collection version - * @property Show\Field|Collection detail - * @property Show\Field|Collection created_at - * @property Show\Field|Collection updated_at * @property Show\Field|Collection is_enabled - * @property Show\Field|Collection parent_id - * @property Show\Field|Collection order + * @property Show\Field|Collection extension * @property Show\Field|Collection icon + * @property Show\Field|Collection order + * @property Show\Field|Collection parent_id * @property Show\Field|Collection uri - * @property Show\Field|Collection extension - * @property Show\Field|Collection permission_id * @property Show\Field|Collection menu_id - * @property Show\Field|Collection slug + * @property Show\Field|Collection permission_id * @property Show\Field|Collection http_method * @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 username - * @property Show\Field|Collection password * @property Show\Field|Collection avatar + * @property Show\Field|Collection password * @property Show\Field|Collection remember_token - * @property Show\Field|Collection agent_id - * @property Show\Field|Collection picture - * @property Show\Field|Collection tag - * @property Show\Field|Collection desc + * @property Show\Field|Collection username * @property Show\Field|Collection about - * @property Show\Field|Collection reg_protocol * @property Show\Field|Collection buy_protocol + * @property Show\Field|Collection reg_protocol * @property Show\Field|Collection agent_product_id * @property Show\Field|Collection supplier_id - * @property Show\Field|Collection product_ids - * @property Show\Field|Collection price - * @property Show\Field|Collection original_price - * @property Show\Field|Collection sale - * @property Show\Field|Collection stock - * @property Show\Field|Collection channel_id * @property Show\Field|Collection category_id + * @property Show\Field|Collection channel_id + * @property Show\Field|Collection deleted_at * @property Show\Field|Collection guide_id + * @property Show\Field|Collection original_price + * @property Show\Field|Collection price + * @property Show\Field|Collection product_ids + * @property Show\Field|Collection sale * @property Show\Field|Collection status + * @property Show\Field|Collection stock * @property Show\Field|Collection verifier - * @property Show\Field|Collection deleted_at + * @property Show\Field|Collection address * @property Show\Field|Collection appid * @property Show\Field|Collection appsecret - * @property Show\Field|Collection mchid - * @property Show\Field|Collection mchkey * @property Show\Field|Collection company_name - * @property Show\Field|Collection logo - * @property Show\Field|Collection address - * @property Show\Field|Collection license_pic - * @property Show\Field|Collection director * @property Show\Field|Collection contact_phone + * @property Show\Field|Collection director + * @property Show\Field|Collection license_pic + * @property Show\Field|Collection logo + * @property Show\Field|Collection mchid + * @property Show\Field|Collection mchkey * @property Show\Field|Collection rate * @property Show\Field|Collection author * @property Show\Field|Collection image * @property Show\Field|Collection pid * @property Show\Field|Collection sort * @property Show\Field|Collection template - * @property Show\Field|Collection start_at * @property Show\Field|Collection end_at - * @property Show\Field|Collection uuid + * @property Show\Field|Collection start_at * @property Show\Field|Collection connection - * @property Show\Field|Collection queue - * @property Show\Field|Collection payload * @property Show\Field|Collection exception * @property Show\Field|Collection failed_at + * @property Show\Field|Collection payload + * @property Show\Field|Collection queue + * @property Show\Field|Collection uuid * @property Show\Field|Collection photo * @property Show\Field|Collection is_read - * @property Show\Field|Collection order_no - * @property Show\Field|Collection num - * @property Show\Field|Collection mobile - * @property Show\Field|Collection pay_type * @property Show\Field|Collection coupon_id - * @property Show\Field|Collection paid_money + * @property Show\Field|Collection mobile + * @property Show\Field|Collection num + * @property Show\Field|Collection order_no * @property Show\Field|Collection paid_at + * @property Show\Field|Collection paid_money + * @property Show\Field|Collection pay_type * @property Show\Field|Collection refund_info * @property Show\Field|Collection verify_code * @property Show\Field|Collection email @@ -304,87 +304,87 @@ namespace Dcat\Admin { * @property Show\Field|Collection openid * @property Show\Field|Collection unionid * - * @method Show\Field|Collection product_id(string $label = null) - * @method Show\Field|Collection know(string $label = null) - * @method Show\Field|Collection content(string $label = null) + * @method Show\Field|Collection agent_id(string $label = null) + * @method Show\Field|Collection created_at(string $label = null) + * @method Show\Field|Collection desc(string $label = null) * @method Show\Field|Collection id(string $label = null) * @method Show\Field|Collection name(string $label = null) + * @method Show\Field|Collection picture(string $label = null) + * @method Show\Field|Collection tag(string $label = null) + * @method Show\Field|Collection updated_at(string $label = null) + * @method Show\Field|Collection content(string $label = null) + * @method Show\Field|Collection know(string $label = null) + * @method Show\Field|Collection product_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) - * @method Show\Field|Collection detail(string $label = null) - * @method Show\Field|Collection created_at(string $label = null) - * @method Show\Field|Collection updated_at(string $label = null) * @method Show\Field|Collection is_enabled(string $label = null) - * @method Show\Field|Collection parent_id(string $label = null) - * @method Show\Field|Collection order(string $label = null) + * @method Show\Field|Collection extension(string $label = null) * @method Show\Field|Collection icon(string $label = null) + * @method Show\Field|Collection order(string $label = null) + * @method Show\Field|Collection parent_id(string $label = null) * @method Show\Field|Collection uri(string $label = null) - * @method Show\Field|Collection extension(string $label = null) - * @method Show\Field|Collection permission_id(string $label = null) * @method Show\Field|Collection menu_id(string $label = null) - * @method Show\Field|Collection slug(string $label = null) + * @method Show\Field|Collection permission_id(string $label = null) * @method Show\Field|Collection http_method(string $label = null) * @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 username(string $label = null) - * @method Show\Field|Collection password(string $label = null) * @method Show\Field|Collection avatar(string $label = null) + * @method Show\Field|Collection password(string $label = null) * @method Show\Field|Collection remember_token(string $label = null) - * @method Show\Field|Collection agent_id(string $label = null) - * @method Show\Field|Collection picture(string $label = null) - * @method Show\Field|Collection tag(string $label = null) - * @method Show\Field|Collection desc(string $label = null) + * @method Show\Field|Collection username(string $label = null) * @method Show\Field|Collection about(string $label = null) - * @method Show\Field|Collection reg_protocol(string $label = null) * @method Show\Field|Collection buy_protocol(string $label = null) + * @method Show\Field|Collection reg_protocol(string $label = null) * @method Show\Field|Collection agent_product_id(string $label = null) * @method Show\Field|Collection supplier_id(string $label = null) - * @method Show\Field|Collection product_ids(string $label = null) - * @method Show\Field|Collection price(string $label = null) - * @method Show\Field|Collection original_price(string $label = null) - * @method Show\Field|Collection sale(string $label = null) - * @method Show\Field|Collection stock(string $label = null) - * @method Show\Field|Collection channel_id(string $label = null) * @method Show\Field|Collection category_id(string $label = null) + * @method Show\Field|Collection channel_id(string $label = null) + * @method Show\Field|Collection deleted_at(string $label = null) * @method Show\Field|Collection guide_id(string $label = null) + * @method Show\Field|Collection original_price(string $label = null) + * @method Show\Field|Collection price(string $label = null) + * @method Show\Field|Collection product_ids(string $label = null) + * @method Show\Field|Collection sale(string $label = null) * @method Show\Field|Collection status(string $label = null) + * @method Show\Field|Collection stock(string $label = null) * @method Show\Field|Collection verifier(string $label = null) - * @method Show\Field|Collection deleted_at(string $label = null) + * @method Show\Field|Collection address(string $label = null) * @method Show\Field|Collection appid(string $label = null) * @method Show\Field|Collection appsecret(string $label = null) - * @method Show\Field|Collection mchid(string $label = null) - * @method Show\Field|Collection mchkey(string $label = null) * @method Show\Field|Collection company_name(string $label = null) - * @method Show\Field|Collection logo(string $label = null) - * @method Show\Field|Collection address(string $label = null) - * @method Show\Field|Collection license_pic(string $label = null) - * @method Show\Field|Collection director(string $label = null) * @method Show\Field|Collection contact_phone(string $label = null) + * @method Show\Field|Collection director(string $label = null) + * @method Show\Field|Collection license_pic(string $label = null) + * @method Show\Field|Collection logo(string $label = null) + * @method Show\Field|Collection mchid(string $label = null) + * @method Show\Field|Collection mchkey(string $label = null) * @method Show\Field|Collection rate(string $label = null) * @method Show\Field|Collection author(string $label = null) * @method Show\Field|Collection image(string $label = null) * @method Show\Field|Collection pid(string $label = null) * @method Show\Field|Collection sort(string $label = null) * @method Show\Field|Collection template(string $label = null) - * @method Show\Field|Collection start_at(string $label = null) * @method Show\Field|Collection end_at(string $label = null) - * @method Show\Field|Collection uuid(string $label = null) + * @method Show\Field|Collection start_at(string $label = null) * @method Show\Field|Collection connection(string $label = null) - * @method Show\Field|Collection queue(string $label = null) - * @method Show\Field|Collection payload(string $label = null) * @method Show\Field|Collection exception(string $label = null) * @method Show\Field|Collection failed_at(string $label = null) + * @method Show\Field|Collection payload(string $label = null) + * @method Show\Field|Collection queue(string $label = null) + * @method Show\Field|Collection uuid(string $label = null) * @method Show\Field|Collection photo(string $label = null) * @method Show\Field|Collection is_read(string $label = null) - * @method Show\Field|Collection order_no(string $label = null) - * @method Show\Field|Collection num(string $label = null) - * @method Show\Field|Collection mobile(string $label = null) - * @method Show\Field|Collection pay_type(string $label = null) * @method Show\Field|Collection coupon_id(string $label = null) - * @method Show\Field|Collection paid_money(string $label = null) + * @method Show\Field|Collection mobile(string $label = null) + * @method Show\Field|Collection num(string $label = null) + * @method Show\Field|Collection order_no(string $label = null) * @method Show\Field|Collection paid_at(string $label = null) + * @method Show\Field|Collection paid_money(string $label = null) + * @method Show\Field|Collection pay_type(string $label = null) * @method Show\Field|Collection refund_info(string $label = null) * @method Show\Field|Collection verify_code(string $label = null) * @method Show\Field|Collection email(string $label = null) diff --git a/resources/lang/zh_CN/agent-info.php b/resources/lang/zh_CN/agent-info.php new file mode 100644 index 0000000..9a4f497 --- /dev/null +++ b/resources/lang/zh_CN/agent-info.php @@ -0,0 +1,15 @@ + [ + 'AgentInfo' => '代理商信息', + 'agent-info' => '代理商信息', + ], + 'fields' => [ + 'about' => '关于我们', + 'agent_id' => '代理商ID', + 'buy_protocol' => '购买协议', + 'reg_protocol' => '注册协议', + ], + 'options' => [ + ], +]; From f71ce4cefccb2ca085823f89331350d849edf883 Mon Sep 17 00:00:00 2001 From: liapples Date: Tue, 24 Aug 2021 11:47:34 +0800 Subject: [PATCH 02/42] =?UTF-8?q?=E6=B6=88=E6=81=AF=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/MessageController.php | 127 ++++++++++++++++++ app/AdminAgent/Repositories/Message.php | 16 +++ app/AdminAgent/routes.php | 1 + resources/lang/zh_CN/message.php | 16 +++ 4 files changed, 160 insertions(+) create mode 100644 app/AdminAgent/Controllers/MessageController.php create mode 100644 app/AdminAgent/Repositories/Message.php create mode 100644 resources/lang/zh_CN/message.php diff --git a/app/AdminAgent/Controllers/MessageController.php b/app/AdminAgent/Controllers/MessageController.php new file mode 100644 index 0000000..ef12801 --- /dev/null +++ b/app/AdminAgent/Controllers/MessageController.php @@ -0,0 +1,127 @@ +model()->where('agent_id', Admin::user()->id); + + $grid->column('id')->sortable(); + $grid->column('user_id'); + $grid->column('title'); + $grid->column('is_read')->if(fn($v) => $this->user_id != 0)->bool()->else()->display('所有人接收'); + $grid->column('created_at'); + + $grid->filter(function (Grid\Filter $filter) { + $filter->panel(); + $filter->model()->where('agent_id', Admin::user()->id); + + $filter->equal('id'); + $filter->like('title'); + }); + }); + } + + /** + * Make a show builder. + * + * @param mixed $id + * + * @return Show + */ + protected function detail($id) + { + return Show::make($id, new Message(), function (Show $show) { + //不允许查看非自己的数据 + if ($show->model()->agent_id != Admin::user()->id) { + Admin::exit('数据不存在'); + } + + $show->field('id'); + $show->field('user_id'); + $show->field('title'); + $show->field('content')->unescape(); + $show->field('is_read') + ->as(function () { + if ($this->user_id) { + return $this->is_read ? '已读' : '未读'; + } + return '所有人接收'; + }); + $show->field('created_at'); + }); + } + + /** + * Make a form builder. + * + * @return Form + */ + protected function form() + { + return Form::make(new Message(), function (Form $form) { + //不允许查看非自己的数据 + if ($form->isEditing() && $form->model()->agent_id != Admin::user()->id) { + return $form->response()->error('数据不存在'); + } + + $form->display('id'); + $form->selectTable('user_id') + ->from(new SelectUser()) + ->model(User::class, 'id', 'nickname') + ->default(0) + ->help('不选择则表示所有人都收到消息'); + $form->text('title')->required(); + $form->editor('content'); + + if ($form->isCreating()) { + $form->confirm('发布确认', '为了保证消费者利益,所有人接收的消息发布后禁止编辑,确定发布?'); + } + })->saving(function (Form $form) { + //不允许修改非自己的数据 + if ($form->isEditing() && $form->model()->agent_id != Admin::user()->id) { + return $form->response()->error('数据不存在'); + } + + //消息已读后禁止编辑 + if ($form->isEditing()) { + if ($form->model()->user_id == 0) { + return $form->response()->error('为了保证消费者利益,所有人接收的消息禁止编辑'); + } + if ($form->model()->is_read) { + return $form->response()->error('消息已读,禁止修改'); + } + } + + //特殊字段处理 + $form->hidden(['agent_id']); + $form->agent_id = Admin::user()->id; + $form->user_id = $form->user_id ?? 0; + + //不允许编辑的字段 + $form->ignore(['id', 'status', 'created_at', 'updated_at', 'deleted_at']); + })->deleting(function (Form $form) { + //不允许删除非自己的数据 + if ($form->model()[0]['agent_id'] != Admin::user()->id) { + return $form->response()->error('数据不存在'); + } + }); + } +} diff --git a/app/AdminAgent/Repositories/Message.php b/app/AdminAgent/Repositories/Message.php new file mode 100644 index 0000000..b506edb --- /dev/null +++ b/app/AdminAgent/Repositories/Message.php @@ -0,0 +1,16 @@ +resource('slide/list', 'SlideController'); $router->resource('special/list', 'SpecialController'); $router->resource('waterfall_ad/list', 'WaterfallAdController'); + $router->resource('message/list', 'MessageController'); $router->resource('agent_info', 'AgentInfoController'); }); diff --git a/resources/lang/zh_CN/message.php b/resources/lang/zh_CN/message.php new file mode 100644 index 0000000..25cdde3 --- /dev/null +++ b/resources/lang/zh_CN/message.php @@ -0,0 +1,16 @@ + [ + 'Message' => '系统消息', + 'message' => '系统消息', + ], + 'fields' => [ + 'agent_id' => '代理商ID', + 'user_id' => '接收者ID', + 'title' => '消息标题', + 'content' => '消息内容', + 'is_read' => '是否已读', + ], + 'options' => [ + ], +]; From e3610577b5ba3a1cf2ca990e5272308117176a70 Mon Sep 17 00:00:00 2001 From: liapples Date: Tue, 24 Aug 2021 11:53:21 +0800 Subject: [PATCH 03/42] =?UTF-8?q?filter=E5=A2=9E=E5=8A=A0width?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/AdminAgent/Controllers/MessageController.php | 4 ++-- app/AdminAgent/Controllers/SlideController.php | 4 ++-- app/AdminAgent/Controllers/SpecialController.php | 2 +- app/AdminAgent/Controllers/WaterfallAdController.php | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/AdminAgent/Controllers/MessageController.php b/app/AdminAgent/Controllers/MessageController.php index ef12801..3512a60 100644 --- a/app/AdminAgent/Controllers/MessageController.php +++ b/app/AdminAgent/Controllers/MessageController.php @@ -33,8 +33,8 @@ class MessageController extends AdminController $filter->panel(); $filter->model()->where('agent_id', Admin::user()->id); - $filter->equal('id'); - $filter->like('title'); + $filter->equal('id')->width(2); + $filter->like('title')->width(3); }); }); } diff --git a/app/AdminAgent/Controllers/SlideController.php b/app/AdminAgent/Controllers/SlideController.php index 35ec18e..2457efd 100644 --- a/app/AdminAgent/Controllers/SlideController.php +++ b/app/AdminAgent/Controllers/SlideController.php @@ -32,8 +32,8 @@ class SlideController extends AdminController $grid->filter(function (Grid\Filter $filter) { $filter->panel(); - $filter->equal('id'); - $filter->like('title'); + $filter->equal('id')->width(2); + $filter->like('title')->width(3); }); }); } diff --git a/app/AdminAgent/Controllers/SpecialController.php b/app/AdminAgent/Controllers/SpecialController.php index ccd01f7..5688d1c 100644 --- a/app/AdminAgent/Controllers/SpecialController.php +++ b/app/AdminAgent/Controllers/SpecialController.php @@ -55,7 +55,7 @@ class SpecialController extends AdminController $grid->filter(function (Grid\Filter $filter) { $filter->panel(); - $filter->equal('id'); + $filter->equal('id')->width(2); }); }); } diff --git a/app/AdminAgent/Controllers/WaterfallAdController.php b/app/AdminAgent/Controllers/WaterfallAdController.php index 98b13bc..230fbe1 100644 --- a/app/AdminAgent/Controllers/WaterfallAdController.php +++ b/app/AdminAgent/Controllers/WaterfallAdController.php @@ -32,8 +32,8 @@ class WaterfallAdController extends AdminController $grid->filter(function (Grid\Filter $filter) { $filter->panel(); - $filter->equal('id'); - $filter->like('title'); + $filter->equal('id')->width(2); + $filter->like('title')->width(3); }); }); } From 4d838816d8c07bf3d2e28d49d18f1e5d2febd91b Mon Sep 17 00:00:00 2001 From: liapples Date: Tue, 24 Aug 2021 12:35:49 +0800 Subject: [PATCH 04/42] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=B7=A6=E9=A1=B6?= =?UTF-8?q?=E9=83=A8LOGO=E6=97=81=E7=9A=84=E6=A0=87=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/admin-agent.php | 2 +- config/admin-guide.php | 2 +- config/admin-supplier.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/config/admin-agent.php b/config/admin-agent.php index 0cd359a..c248ec3 100644 --- a/config/admin-agent.php +++ b/config/admin-agent.php @@ -22,7 +22,7 @@ return [ | `img` tag, eg 'Admin logo'. | */ - 'logo' => '  Dcat Admin', + 'logo' => '  代理商管理后台', /* |-------------------------------------------------------------------------- diff --git a/config/admin-guide.php b/config/admin-guide.php index e35d424..95d77be 100644 --- a/config/admin-guide.php +++ b/config/admin-guide.php @@ -22,7 +22,7 @@ return [ | `img` tag, eg 'Admin logo'. | */ - 'logo' => '  Dcat Admin', + 'logo' => '  地接管理后台', /* |-------------------------------------------------------------------------- diff --git a/config/admin-supplier.php b/config/admin-supplier.php index 2bdc4be..da01013 100644 --- a/config/admin-supplier.php +++ b/config/admin-supplier.php @@ -22,7 +22,7 @@ return [ | `img` tag, eg 'Admin logo'. | */ - 'logo' => '  Dcat Admin', + 'logo' => '  供应商管理后台', /* |-------------------------------------------------------------------------- From 9266c6632dc9d18dd0e848e463e77e31dd0b0799 Mon Sep 17 00:00:00 2001 From: liapples Date: Tue, 24 Aug 2021 13:00:49 +0800 Subject: [PATCH 05/42] =?UTF-8?q?=E5=85=AC=E5=91=8A=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- MySQL_change.sql | 6 +- .../Controllers/NoticeController.php | 101 ++++++++++++++++++ app/AdminAgent/Repositories/Notice.php | 16 +++ app/AdminAgent/routes.php | 1 + app/Http/Controllers/Api/IndexController.php | 3 +- resources/lang/zh_CN/notice.php | 15 +++ 6 files changed, 140 insertions(+), 2 deletions(-) create mode 100644 app/AdminAgent/Controllers/NoticeController.php create mode 100644 app/AdminAgent/Repositories/Notice.php create mode 100644 resources/lang/zh_CN/notice.php diff --git a/MySQL_change.sql b/MySQL_change.sql index c4775f8..f1f0d49 100644 --- a/MySQL_change.sql +++ b/MySQL_change.sql @@ -98,7 +98,6 @@ ALTER TABLE `slides` 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, @@ -117,3 +116,8 @@ CREATE TABLE `waterfall_ads` ( 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`; diff --git a/app/AdminAgent/Controllers/NoticeController.php b/app/AdminAgent/Controllers/NoticeController.php new file mode 100644 index 0000000..e2616b5 --- /dev/null +++ b/app/AdminAgent/Controllers/NoticeController.php @@ -0,0 +1,101 @@ +model()->where('agent_id', Admin::user()->id) + ->orderBy('sort')->orderBy('id', 'DESC'); + + $grid->column('id')->sortable(); + $grid->column('title'); + $grid->column('sort')->editable()->width(120); + $grid->column('created_at'); + $grid->column('updated_at'); + + $grid->filter(function (Grid\Filter $filter) { + $filter->panel(); + + $filter->equal('id')->width(2); + $filter->like('title')->width(3); + }); + }); + } + + /** + * Make a show builder. + * + * @param mixed $id + * + * @return Show + */ + protected function detail($id) + { + return Show::make($id, new Notice(), function (Show $show) { + //不允许查看非自己的数据 + if ($show->model()->agent_id != Admin::user()->id) { + Admin::exit('数据不存在'); + } + + $show->field('id'); + $show->field('title'); + $show->field('content')->unescape(); + $show->field('sort'); + $show->field('created_at'); + $show->field('updated_at'); + }); + } + + /** + * Make a form builder. + * + * @return Form + */ + protected function form() + { + return Form::make(new Notice(), function (Form $form) { + //不允许查看非自己的数据 + if ($form->isEditing() && $form->model()->agent_id != Admin::user()->id) { + return $form->response()->error('数据不存在'); + } + + $form->display('id'); + $form->text('title'); + $form->editor('content'); + $form->text('sort')->default(255); + })->saving(function (Form $form) { + //不允许修改非自己的数据 + if ($form->isEditing() && $form->model()->agent_id != Admin::user()->id) { + return $form->response()->error('数据不存在'); + } + + //特殊字段处理 + $form->hidden(['agent_id']); + $form->agent_id = Admin::user()->id; + $form->sort = $form->sort ?? 255; + + //不允许编辑的字段 + $form->ignore(['id', 'created_at', 'updated_at']); + })->deleting(function (Form $form) { + //不允许删除非自己的数据 + if ($form->model()[0]['agent_id'] != Admin::user()->id) { + return $form->response()->error('数据不存在'); + } + }); + } +} diff --git a/app/AdminAgent/Repositories/Notice.php b/app/AdminAgent/Repositories/Notice.php new file mode 100644 index 0000000..2013af8 --- /dev/null +++ b/app/AdminAgent/Repositories/Notice.php @@ -0,0 +1,16 @@ +resource('special/list', 'SpecialController'); $router->resource('waterfall_ad/list', 'WaterfallAdController'); $router->resource('message/list', 'MessageController'); + $router->resource('notice/list', 'NoticeController'); $router->resource('agent_info', 'AgentInfoController'); }); diff --git a/app/Http/Controllers/Api/IndexController.php b/app/Http/Controllers/Api/IndexController.php index 8e9034e..6e162d7 100644 --- a/app/Http/Controllers/Api/IndexController.php +++ b/app/Http/Controllers/Api/IndexController.php @@ -31,7 +31,8 @@ class IndexController extends Controller } # 公告 - $notice = Notice::where('agent_id', $this->agent_id)->limit(10)->get(['id', 'title', 'updated_at']); + $notice = Notice::where('agent_id', $this->agent_id)->limit(10) + ->orderBy('sort')->orderBy('id', 'desc')->get(['id', 'title']); # 我的频道 if ($this->user_id) { diff --git a/resources/lang/zh_CN/notice.php b/resources/lang/zh_CN/notice.php new file mode 100644 index 0000000..7e5cd26 --- /dev/null +++ b/resources/lang/zh_CN/notice.php @@ -0,0 +1,15 @@ + [ + 'Notice' => '系统公告', + 'notice' => '系统公告', + ], + 'fields' => [ + 'agent_id' => '发布者ID', + 'title' => '公告标题', + 'sort' => '排序', + 'content' => '公告内容', + ], + 'options' => [ + ], +]; From c42ad9bb0a0b3a688b976d35225c4f8b39bbd968 Mon Sep 17 00:00:00 2001 From: liapples Date: Tue, 24 Aug 2021 13:37:18 +0800 Subject: [PATCH 06/42] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=A0=B8=E9=94=80?= =?UTF-8?q?=E4=BA=BA=E5=91=98=E5=88=97=E8=A1=A8=E5=8F=8Auser=E8=A1=A8?= =?UTF-8?q?=E4=B8=ADverifier=E5=AD=97=E6=AE=B5=E6=94=B9=E5=90=8D=E4=B8=BAi?= =?UTF-8?q?s=5Fverify?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- MySQL_change.sql | 3 +++ .../Controllers/AgentProductController.php | 3 ++- app/AdminAgent/Controllers/UserController.php | 21 +++++++++++++++---- app/AdminAgent/Renderable/SelectUser.php | 8 ++++++- app/AdminAgent/routes.php | 1 + .../Api/VerificationController.php | 2 +- resources/lang/zh_CN/user.php | 2 +- 7 files changed, 32 insertions(+), 8 deletions(-) diff --git a/MySQL_change.sql b/MySQL_change.sql index f1f0d49..34a9eb6 100644 --- a/MySQL_change.sql +++ b/MySQL_change.sql @@ -121,3 +121,6 @@ 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`; diff --git a/app/AdminAgent/Controllers/AgentProductController.php b/app/AdminAgent/Controllers/AgentProductController.php index fa7ac89..1fbe0a3 100644 --- a/app/AdminAgent/Controllers/AgentProductController.php +++ b/app/AdminAgent/Controllers/AgentProductController.php @@ -197,7 +197,7 @@ class AgentProductController extends AdminController $form->selectTable('verifier') ->title('选择核销人员') ->dialogWidth('50%;min-width:600px;') //不起作用 - ->from(SelectUser::make()) + ->from(SelectUser::make(['is_verify' => 1])) ->model(User::class, 'id', 'nickname') ->customFormat(fn($v) => !$v ? '' : $v) ->required(); @@ -240,6 +240,7 @@ class AgentProductController extends AdminController $form->hidden(['agent_id', 'status']); //表单没有的字段,必须加这句才能够重写 $form->agent_id = $agent_id; $form->status = $form->status == ProductStatus::ON_SALE ? ProductStatus::ON_SALE : ProductStatus::SOLD_OUT; + $form->guide_id = $form->guide_id ?? 0; //不允许编辑的字段 $form->ignore(['id', 'agent_id', 'status', 'created_at', 'updated_at', 'deleted_at']); diff --git a/app/AdminAgent/Controllers/UserController.php b/app/AdminAgent/Controllers/UserController.php index cd56193..a0fb750 100644 --- a/app/AdminAgent/Controllers/UserController.php +++ b/app/AdminAgent/Controllers/UserController.php @@ -8,6 +8,7 @@ use Dcat\Admin\Form; use Dcat\Admin\Grid; use Dcat\Admin\Show; use Dcat\Admin\Http\Controllers\AdminController; +use Illuminate\Support\Facades\Route; class UserController extends AdminController { @@ -25,6 +26,11 @@ class UserController extends AdminController $grid->disableBatchDelete(); $grid->disableDeleteButton(); + //如果是核销人员页面,多加where条件判断 + if (strpos(Route::current()->uri, 'verifier')) { + $grid->model()->where('is_verify', 1); + } + $grid->model()->where('agent_id', Admin::user()->id); $grid->column('id')->sortable(); @@ -32,6 +38,7 @@ class UserController extends AdminController $grid->column('mobile'); $grid->column('nickname'); $grid->column('status')->switch(); + $grid->column('is_verify')->switch(); $grid->column('created_at'); $grid->filter(function (Grid\Filter $filter) { @@ -88,18 +95,24 @@ class UserController extends AdminController $form->display('nickname'); $form->text('mobile'); $form->switch('status'); + $form->switch('is_verify'); })->saving(function (Form $form) { //不允许修改非自己的数据 if ($form->isEditing() && $form->model()->agent_id != Admin::user()->id) { return $form->response()->error('数据不存在'); } - //不允许编辑的字段 - $form->ignore(['id', 'agent_id', 'nickname', 'deleted_at']); - //处理特殊字段 $form->agent_id = Admin::user()->id; - $form->status = $form->status ? 1 : 0; + if (isset($form->status)) { //为防止行内编辑出错,此处需要加判断 + $form->status = $form->status ? 1 : 0; + } + if (isset($form->is_verify)) { //为防止行内编辑出错,此处需要加判断 + $form->is_verify = $form->is_verify ? 1 : 0; + } + + //不允许编辑的字段 + $form->ignore(['id', 'agent_id', 'nickname', 'deleted_at']); })->deleting(function (Form $form) { return $form->response()->error('禁止删除'); }); diff --git a/app/AdminAgent/Renderable/SelectUser.php b/app/AdminAgent/Renderable/SelectUser.php index 4d5e2e4..10d2353 100644 --- a/app/AdminAgent/Renderable/SelectUser.php +++ b/app/AdminAgent/Renderable/SelectUser.php @@ -24,7 +24,13 @@ class SelectUser extends LazyRenderable $grid->disableBatchDelete(); $grid->disableBatchActions(); - $grid->model()->where(['status' => UserStatus::NORMAL, 'agent_id' => Admin::user()->id]); + $where = ['status' => UserStatus::NORMAL, 'agent_id' => Admin::user()->id]; + //核销人员选择 + if ($this->is_verify !== null) { + $where['is_verify'] = $this->is_verify; + } + + $grid->model()->where($where); $grid->quickSearch(['mobile', 'nickname'])->placeholder('搜索手机号、用户昵称'); $grid->column('id'); diff --git a/app/AdminAgent/routes.php b/app/AdminAgent/routes.php index 7c4dd66..c5a0b79 100644 --- a/app/AdminAgent/routes.php +++ b/app/AdminAgent/routes.php @@ -18,6 +18,7 @@ Route::group([ $router->resource('product/list', 'AgentProductController'); $router->resource('category/list', 'CategoryController'); $router->resource('user/list', 'UserController'); + $router->resource('user/verifier', 'UserController'); $router->resource('order/list', 'OrderController'); $router->resource('slide/list', 'SlideController'); $router->resource('special/list', 'SpecialController'); diff --git a/app/Http/Controllers/Api/VerificationController.php b/app/Http/Controllers/Api/VerificationController.php index 007355a..677516b 100644 --- a/app/Http/Controllers/Api/VerificationController.php +++ b/app/Http/Controllers/Api/VerificationController.php @@ -28,7 +28,7 @@ class VerificationController extends Controller } $user = User::firstWhere(['id' => $this->user_id, 'status' => 1]); - if (!$user || $user->id != $order->agentProduct->verifier) { + if (!$user || $user->is_verify !=1 || $user->id != $order->agentProduct->verifier) { return $this->error('对不起,你没有核销权限,请联系管理员'); } diff --git a/resources/lang/zh_CN/user.php b/resources/lang/zh_CN/user.php index 66079ca..2ef8fb4 100644 --- a/resources/lang/zh_CN/user.php +++ b/resources/lang/zh_CN/user.php @@ -13,7 +13,7 @@ return [ 'openid' => '微信openid', 'status' => '用户状态', 'unionid' => '微信unionid', - 'verifier' => '是否核销人员', + 'is_verify' => '是否核销人员', 'created_at' => '注册时间', ], 'options' => [ From 533e7b1e511a4e90c7e698c39465fc1d1ea7be7d Mon Sep 17 00:00:00 2001 From: liapples Date: Tue, 24 Aug 2021 14:43:02 +0800 Subject: [PATCH 07/42] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=A8=A1=E5=9E=8B?= =?UTF-8?q?=E5=85=B3=E8=81=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Models/Order.php | 5 +++++ app/Models/Supplier.php | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/app/Models/Order.php b/app/Models/Order.php index 1d247d2..6d62275 100644 --- a/app/Models/Order.php +++ b/app/Models/Order.php @@ -84,4 +84,9 @@ class Order extends BaseModel { return $this->belongsTo(User::class); } + + public function agentProductItem() + { + return $this->hasMany(AgentProductItem::class, 'agent_product_id', 'agent_product_id'); + } } diff --git a/app/Models/Supplier.php b/app/Models/Supplier.php index 0fc9f08..863b4c5 100644 --- a/app/Models/Supplier.php +++ b/app/Models/Supplier.php @@ -16,4 +16,9 @@ class Supplier extends BaseModel $this->attributes['password'] = password_hash($value, PASSWORD_BCRYPT); } } + + public function agentProductItem() + { + return $this->hasMany(AgentProductItem::class); + } } From bb9bfeb8bc1a8b01bc5679336bc5ab06fc49030d Mon Sep 17 00:00:00 2001 From: liapples Date: Tue, 24 Aug 2021 14:53:24 +0800 Subject: [PATCH 08/42] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E6=9D=A1=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/OrderController.php | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/app/AdminSupplier/Controllers/OrderController.php b/app/AdminSupplier/Controllers/OrderController.php index 0d0aa8b..b7a1e58 100644 --- a/app/AdminSupplier/Controllers/OrderController.php +++ b/app/AdminSupplier/Controllers/OrderController.php @@ -33,7 +33,9 @@ class OrderController extends AdminController $grid->disableEditButton(); $grid->model()->where(function ($query) { - return $query->whereHas('product', fn($q) => $q->where('supplier_id', Admin::user()->id)); + return $query->whereHas('agentProductItem', function($query) { + return $query->where('supplier_id', Admin::user()->id); + }); }); $grid->column('id')->sortable(); @@ -88,13 +90,14 @@ class OrderController extends AdminController */ protected function detail($id) { - return Show::make($id, new Order(['agent:id,name']), function (Show $show) { + return Show::make($id, new Order(['agent:id,name', 'agentProductItem']), function (Show $show) { $show->disableDeleteButton(); $show->disableQuickEdit(); $show->disableEditButton(); //不允许查看非自己的数据 - if ($show->model()->supplier_id != Admin::user()->id) { + $item_supplier_id = $show->model()->agentProductItem[0]->supplier_id ?? 0; + if ($item_supplier_id != Admin::user()->id) { Admin::exit('数据不存在'); } @@ -126,9 +129,10 @@ class OrderController extends AdminController */ protected function form() { - return Form::make(new Order(), function (Form $form) { + return Form::make(new Order('agentProductItem'), function (Form $form) { //不允许查看非自己的数据 - if ($form->isEditing() && $form->model()->supplier_id != Admin::user()->id) { + $item_supplier_id = $form->model()->agentProductItem[0]->supplier_id ?? 0; + if ($form->isEditing() && $item_supplier_id != Admin::user()->id) { return $form->response()->error('数据不存在'); } @@ -140,7 +144,7 @@ class OrderController extends AdminController })->saving(function (Form $form) { return $form->response()->error('操作禁止'); })->deleting(function (Form $form) { - return $form->response()->error('禁止删除'); + return $form->response()->error('操作禁止'); }); } } From bb7d56c68c3823f3b18ecb1c92938878cd046e46 Mon Sep 17 00:00:00 2001 From: liapples Date: Tue, 24 Aug 2021 14:53:48 +0800 Subject: [PATCH 09/42] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BB=A3=E7=90=86?= =?UTF-8?q?=E5=95=86=E7=9A=84=E5=90=88=E4=BD=9C=E4=BE=9B=E5=BA=94=E5=95=86?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/SupplierController.php | 92 +++++++++++++++++++ app/AdminAgent/Repositories/Supplier.php | 16 ++++ app/AdminAgent/routes.php | 1 + dcat_admin_ide_helper.php | 4 + 4 files changed, 113 insertions(+) create mode 100644 app/AdminAgent/Controllers/SupplierController.php create mode 100644 app/AdminAgent/Repositories/Supplier.php diff --git a/app/AdminAgent/Controllers/SupplierController.php b/app/AdminAgent/Controllers/SupplierController.php new file mode 100644 index 0000000..c1a4e87 --- /dev/null +++ b/app/AdminAgent/Controllers/SupplierController.php @@ -0,0 +1,92 @@ +disableActions(); + $grid->disableCreateButton(); + $grid->disableRowSelector(); + $grid->disableFilterButton(); + + $grid->model()->where(function ($query) { + return $query->whereHas('AgentProductItem', function ($query) { + return $query->where('agent_id', Admin::user()->id); + }); + }); + + $grid->column('id')->sortable(); + $grid->column('name'); + $grid->column('company_name'); + $grid->column('address'); + $grid->column('director'); + $grid->column('contact_phone'); + $grid->column('logo')->image('', 60, 60); + $grid->column('avatar')->image('', 60, 60); + $grid->column('license_pic')->image('', 60, 60); + $grid->column('created_at', '入驻时间'); + + $grid->filter(function (Grid\Filter $filter) { + $filter->panel(); + + $filter->equal('id'); + }); + }); + } + + /** + * Make a show builder. + * + * @param mixed $id + * + * @return Show + */ + protected function detail($id) + { + return Show::make($id, new Supplier(), function (Show $show) { + $show->field('id'); + /*$show->field('name'); + $show->field('company_name'); + $show->field('address'); + $show->field('director'); + $show->field('contact_phone'); + $show->field('logo'); + $show->field('avatar'); + $show->field('license_pic'); + $show->field('created_at'); + $show->field('updated_at');*/ + }); + } + + /** + * Make a form builder. + * + * @return Form + */ + protected function form() + { + return Form::make(new Supplier(), function (Form $form) { + $form->display('id'); + })->saving(function (Form $form) { + $form->response()->error('操作禁止'); + })->deleting(function (Form $form) { + $form->response()->error('操作禁止'); + }); + } +} diff --git a/app/AdminAgent/Repositories/Supplier.php b/app/AdminAgent/Repositories/Supplier.php new file mode 100644 index 0000000..067a134 --- /dev/null +++ b/app/AdminAgent/Repositories/Supplier.php @@ -0,0 +1,16 @@ +resource('message/list', 'MessageController'); $router->resource('notice/list', 'NoticeController'); $router->resource('agent_info', 'AgentInfoController'); + $router->resource('supplier/list', 'SupplierController'); }); diff --git a/dcat_admin_ide_helper.php b/dcat_admin_ide_helper.php index 371bf3d..473a1fa 100644 --- a/dcat_admin_ide_helper.php +++ b/dcat_admin_ide_helper.php @@ -103,6 +103,7 @@ namespace Dcat\Admin { * @property Grid\Column|Collection money * @property Grid\Column|Collection order_id * @property Grid\Column|Collection transaction_id + * @property Grid\Column|Collection is_verify * @property Grid\Column|Collection nickname * @property Grid\Column|Collection openid * @property Grid\Column|Collection unionid @@ -199,6 +200,7 @@ namespace Dcat\Admin { * @method Grid\Column|Collection money(string $label = null) * @method Grid\Column|Collection order_id(string $label = null) * @method Grid\Column|Collection transaction_id(string $label = null) + * @method Grid\Column|Collection is_verify(string $label = null) * @method Grid\Column|Collection nickname(string $label = null) * @method Grid\Column|Collection openid(string $label = null) * @method Grid\Column|Collection unionid(string $label = null) @@ -300,6 +302,7 @@ namespace Dcat\Admin { * @property Show\Field|Collection money * @property Show\Field|Collection order_id * @property Show\Field|Collection transaction_id + * @property Show\Field|Collection is_verify * @property Show\Field|Collection nickname * @property Show\Field|Collection openid * @property Show\Field|Collection unionid @@ -396,6 +399,7 @@ namespace Dcat\Admin { * @method Show\Field|Collection money(string $label = null) * @method Show\Field|Collection order_id(string $label = null) * @method Show\Field|Collection transaction_id(string $label = null) + * @method Show\Field|Collection is_verify(string $label = null) * @method Show\Field|Collection nickname(string $label = null) * @method Show\Field|Collection openid(string $label = null) * @method Show\Field|Collection unionid(string $label = null) From 1d66ddcf904ea0fc74dbb85e05fffb6333ed6263 Mon Sep 17 00:00:00 2001 From: liapples Date: Tue, 24 Aug 2021 15:28:49 +0800 Subject: [PATCH 10/42] =?UTF-8?q?=E4=BE=9B=E5=BA=94=E5=95=86=E4=B8=AA?= =?UTF-8?q?=E4=BA=BA=E4=BF=A1=E6=81=AF=E7=BC=96=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/SupplierInfoController.php | 18 ++++++ app/AdminSupplier/Forms/SupplierInfo.php | 63 +++++++++++++++++++ app/AdminSupplier/routes.php | 1 + 3 files changed, 82 insertions(+) create mode 100644 app/AdminSupplier/Controllers/SupplierInfoController.php create mode 100644 app/AdminSupplier/Forms/SupplierInfo.php diff --git a/app/AdminSupplier/Controllers/SupplierInfoController.php b/app/AdminSupplier/Controllers/SupplierInfoController.php new file mode 100644 index 0000000..dd54974 --- /dev/null +++ b/app/AdminSupplier/Controllers/SupplierInfoController.php @@ -0,0 +1,18 @@ +title('供应商信息') + ->body(new Card(' ', new SupplierInfo())); + } +} diff --git a/app/AdminSupplier/Forms/SupplierInfo.php b/app/AdminSupplier/Forms/SupplierInfo.php new file mode 100644 index 0000000..31c271b --- /dev/null +++ b/app/AdminSupplier/Forms/SupplierInfo.php @@ -0,0 +1,63 @@ +id); + + $model->name = $input['name']; + $model->company_name = $input['company_name']; + $model->address = $input['address']; + $model->director = $input['director']; + $model->contact_phone = $input['contact_phone']; + $model->avatar = $input['avatar']; + $model->logo = $input['logo']; + $model->license_pic = $input['license_pic']; + $model->save(); + + return $this->response()->success('保存成功')->refresh(); + } + + /** + * Build a form here. + */ + public function form() + { + Admin::translation('supplier'); + + $this->text('name')->required(); + $this->text('company_name')->required(); + $this->text('address')->required(); + $this->text('director')->required(); + $this->text('contact_phone')->required(); + $this->image('avatar'); + $this->image('logo')->required(); + $this->image('license_pic')->required(); + } + + /** + * The data of the form. + * + * @return array + */ + public function default() + { + return Supplier::find(Admin::user()->id)->toArray(); + } +} diff --git a/app/AdminSupplier/routes.php b/app/AdminSupplier/routes.php index 40df52a..d6cec73 100644 --- a/app/AdminSupplier/routes.php +++ b/app/AdminSupplier/routes.php @@ -18,4 +18,5 @@ Route::group([ $router->resource('product/list', 'ProductController'); $router->resource('order/list', 'OrderController'); $router->resource('agent/list', 'AgentController'); + $router->resource('supplier_info', 'SupplierInfoController'); }); From da7161cc0cd85e00d2817601146f8f8c79e0b8e3 Mon Sep 17 00:00:00 2001 From: liapples Date: Tue, 24 Aug 2021 15:29:19 +0800 Subject: [PATCH 11/42] =?UTF-8?q?=E4=BB=A3=E7=90=86=E5=95=86=E4=B8=AA?= =?UTF-8?q?=E4=BA=BA=E4=BF=A1=E6=81=AF=E7=BC=96=E8=BE=91=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E6=9B=B4=E5=A4=9A=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/AdminAgent/Forms/AgentInfo.php | 40 +++++++++++++++++++++++------- resources/lang/zh_CN/agent.php | 1 + 2 files changed, 32 insertions(+), 9 deletions(-) diff --git a/app/AdminAgent/Forms/AgentInfo.php b/app/AdminAgent/Forms/AgentInfo.php index 342cfc9..023e166 100644 --- a/app/AdminAgent/Forms/AgentInfo.php +++ b/app/AdminAgent/Forms/AgentInfo.php @@ -1,7 +1,7 @@ find(Admin::user()->id); - $model->about = $input['about']; - $model->reg_protocol = $input['reg_protocol']; - $model->buy_protocol = $input['buy_protocol']; + $model = Agent::query()->find(Admin::user()->id); + + $model->name = $input['name']; + $model->company_name = $input['company_name']; + $model->address = $input['address']; + $model->director = $input['director']; + $model->contact_phone = $input['contact_phone']; + $model->logo = $input['logo']; + $model->avatar = $input['avatar']; + $model->license_pic = $input['license_pic']; + + $model->agentInfo->about = $input['agentInfo']['about']; + $model->agentInfo->reg_protocol = $input['agentInfo']['reg_protocol']; + $model->agentInfo->buy_protocol = $input['agentInfo']['buy_protocol']; $model->save(); + $model->agentInfo()->save($model->agentInfo); return $this->response()->success('保存成功')->refresh(); } @@ -32,9 +43,20 @@ class AgentInfo extends Form */ public function form() { - $this->editor('about')->required(); - $this->editor('reg_protocol')->required(); - $this->editor('buy_protocol')->required(); + Admin::translation('agent'); + + $this->text('name')->required(); + $this->text('company_name')->required(); + $this->text('address')->required(); + $this->text('director')->required(); + $this->text('contact_phone')->required(); + $this->image('logo')->required(); + $this->image('avatar'); + $this->image('license_pic')->required(); + + $this->editor('agentInfo.about')->required(); + $this->editor('agentInfo.reg_protocol')->required(); + $this->editor('agentInfo.buy_protocol')->required(); } /** @@ -44,6 +66,6 @@ class AgentInfo extends Form */ public function default() { - return Model::query()->find(Admin::user()->id)->toArray(); + return Agent::with('agentInfo')->find(Admin::user()->id)->toArray(); } } diff --git a/resources/lang/zh_CN/agent.php b/resources/lang/zh_CN/agent.php index 079ba7b..c7e3765 100644 --- a/resources/lang/zh_CN/agent.php +++ b/resources/lang/zh_CN/agent.php @@ -21,6 +21,7 @@ return [ 'license_pic' => '营业执照', 'director' => '负责人', 'contact_phone' => '联系电话', + 'agentInfo' => trans('agent-info.fields'), ], 'options' => [ ], From 8949ddc5f42a07d757df06f65e932c2510567b59 Mon Sep 17 00:00:00 2001 From: liapples Date: Tue, 24 Aug 2021 15:49:09 +0800 Subject: [PATCH 12/42] =?UTF-8?q?=E4=BA=BA=E6=B0=94=E7=88=86=E6=AC=BE?= =?UTF-8?q?=E6=A0=B9=E6=8D=AE=E9=94=80=E9=87=8F=E6=8E=92=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/Api/IndexController.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/Api/IndexController.php b/app/Http/Controllers/Api/IndexController.php index 6e162d7..20b740c 100644 --- a/app/Http/Controllers/Api/IndexController.php +++ b/app/Http/Controllers/Api/IndexController.php @@ -82,10 +82,10 @@ class IndexController extends Controller } # 人气爆款 - $hots = AgentProduct::query() + $hots = AgentProduct::with('product:id,title,pictures') //必须查询ID才能正常查询 ->where('agent_id', $this->agent_id) ->select('id', 'sale', 'product_id', 'price', 'original_price') //必须查询product_id才能with - ->with('product:id,title,pictures') //必须查询ID才能正常查询 + ->orderBy('sale', 'desc')->orderBy('id', 'desc') ->limit(6)->get(); if (!$hots->isEmpty()) { foreach ($hots as &$v) { From b5e9554bda54dfda51c527f8f5078ccbd6e7d355 Mon Sep 17 00:00:00 2001 From: liapples Date: Tue, 24 Aug 2021 16:23:44 +0800 Subject: [PATCH 13/42] =?UTF-8?q?=E4=BF=AE=E6=94=B9=20=E4=B8=8D=E5=85=81?= =?UTF-8?q?=E8=AE=B8=E5=88=A0=E9=99=A4=E9=9D=9E=E8=87=AA=E5=B7=B1=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=20=E7=9A=84=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Admin/Controllers/OrderController.php | 2 +- app/AdminAgent/Controllers/AgentProductController.php | 2 +- app/AdminAgent/Controllers/CategoryController.php | 2 +- app/AdminAgent/Controllers/MessageController.php | 2 +- app/AdminAgent/Controllers/NoticeController.php | 2 +- app/AdminAgent/Controllers/OrderController.php | 2 +- app/AdminAgent/Controllers/SlideController.php | 2 +- app/AdminAgent/Controllers/SpecialController.php | 2 +- app/AdminAgent/Controllers/UserController.php | 2 +- app/AdminAgent/Controllers/WaterfallAdController.php | 2 +- app/AdminSupplier/Controllers/AgentController.php | 4 ++-- app/AdminSupplier/Controllers/ProductController.php | 6 +++--- 12 files changed, 15 insertions(+), 15 deletions(-) diff --git a/app/Admin/Controllers/OrderController.php b/app/Admin/Controllers/OrderController.php index 0ae2502..23243db 100644 --- a/app/Admin/Controllers/OrderController.php +++ b/app/Admin/Controllers/OrderController.php @@ -126,7 +126,7 @@ class OrderController extends AdminController })->saving(function (Form $form) { return $form->response()->error('操作禁止'); })->deleting(function (Form $form) { - return $form->response()->error('禁止删除'); + return $form->response()->error('操作禁止'); }); } } diff --git a/app/AdminAgent/Controllers/AgentProductController.php b/app/AdminAgent/Controllers/AgentProductController.php index 1fbe0a3..a835f50 100644 --- a/app/AdminAgent/Controllers/AgentProductController.php +++ b/app/AdminAgent/Controllers/AgentProductController.php @@ -298,7 +298,7 @@ class AgentProductController extends AdminController } })->deleting(function (Form $form) { //不允许删除非自己的数据 - if ($form->model()[0]['agent_id'] != Admin::user()->id) { + if (array_filter($form->model()->toArray(), fn($v) => $v['agent_id'] != Admin::user()->id)) { return $form->response()->error('数据不存在'); } }); diff --git a/app/AdminAgent/Controllers/CategoryController.php b/app/AdminAgent/Controllers/CategoryController.php index 7de0f71..1870ed6 100644 --- a/app/AdminAgent/Controllers/CategoryController.php +++ b/app/AdminAgent/Controllers/CategoryController.php @@ -104,7 +104,7 @@ class CategoryController extends AdminController $form->sort = $form->sort ?? 255; })->deleting(function (Form $form) { //不允许修改非自己的数据 - if ($form->model()[0]['agent_id'] != Admin::user()->id) { + if (array_filter($form->model()->toArray(), fn($v) => $v['agent_id'] != Admin::user()->id)) { return $form->response()->error('数据不存在'); } diff --git a/app/AdminAgent/Controllers/MessageController.php b/app/AdminAgent/Controllers/MessageController.php index 3512a60..3813198 100644 --- a/app/AdminAgent/Controllers/MessageController.php +++ b/app/AdminAgent/Controllers/MessageController.php @@ -119,7 +119,7 @@ class MessageController extends AdminController $form->ignore(['id', 'status', 'created_at', 'updated_at', 'deleted_at']); })->deleting(function (Form $form) { //不允许删除非自己的数据 - if ($form->model()[0]['agent_id'] != Admin::user()->id) { + if (array_filter($form->model()->toArray(), fn($v) => $v['agent_id'] != Admin::user()->id)) { return $form->response()->error('数据不存在'); } }); diff --git a/app/AdminAgent/Controllers/NoticeController.php b/app/AdminAgent/Controllers/NoticeController.php index e2616b5..aa7eb0c 100644 --- a/app/AdminAgent/Controllers/NoticeController.php +++ b/app/AdminAgent/Controllers/NoticeController.php @@ -93,7 +93,7 @@ class NoticeController extends AdminController $form->ignore(['id', 'created_at', 'updated_at']); })->deleting(function (Form $form) { //不允许删除非自己的数据 - if ($form->model()[0]['agent_id'] != Admin::user()->id) { + if (array_filter($form->model()->toArray(), fn($v) => $v['agent_id'] != Admin::user()->id)) { return $form->response()->error('数据不存在'); } }); diff --git a/app/AdminAgent/Controllers/OrderController.php b/app/AdminAgent/Controllers/OrderController.php index a9e9699..453d519 100644 --- a/app/AdminAgent/Controllers/OrderController.php +++ b/app/AdminAgent/Controllers/OrderController.php @@ -184,7 +184,7 @@ class OrderController extends AdminController return $form->response()->error('请通过订单列表的”通过“和”拒绝“按钮来审核退款'); } })->deleting(function (Form $form) { - return $form->response()->error('禁止删除'); + return $form->response()->error('操作禁止'); }); } } diff --git a/app/AdminAgent/Controllers/SlideController.php b/app/AdminAgent/Controllers/SlideController.php index 2457efd..33e7f80 100644 --- a/app/AdminAgent/Controllers/SlideController.php +++ b/app/AdminAgent/Controllers/SlideController.php @@ -126,7 +126,7 @@ class SlideController extends AdminController $form->ignore(['id', 'created_at', 'updated_at']); })->deleting(function (Form $form) { //不允许删除非自己的数据 - if ($form->model()[0]['agent_id'] != Admin::user()->id) { + if (array_filter($form->model()->toArray(), fn($v) => $v['agent_id'] != Admin::user()->id)) { return $form->response()->error('数据不存在'); } }); diff --git a/app/AdminAgent/Controllers/SpecialController.php b/app/AdminAgent/Controllers/SpecialController.php index 5688d1c..8781c25 100644 --- a/app/AdminAgent/Controllers/SpecialController.php +++ b/app/AdminAgent/Controllers/SpecialController.php @@ -145,7 +145,7 @@ class SpecialController extends AdminController $form->ignore(['id', 'agent_id', 'created_at', 'updated_at']); })->deleting(function (Form $form) { //不允许删除非自己的数据 - if ($form->model()[0]['agent_id'] != Admin::user()->id) { + if (array_filter($form->model()->toArray(), fn($v) => $v['agent_id'] != Admin::user()->id)) { return $form->response()->error('数据不存在'); } }); diff --git a/app/AdminAgent/Controllers/UserController.php b/app/AdminAgent/Controllers/UserController.php index a0fb750..ac410f0 100644 --- a/app/AdminAgent/Controllers/UserController.php +++ b/app/AdminAgent/Controllers/UserController.php @@ -114,7 +114,7 @@ class UserController extends AdminController //不允许编辑的字段 $form->ignore(['id', 'agent_id', 'nickname', 'deleted_at']); })->deleting(function (Form $form) { - return $form->response()->error('禁止删除'); + return $form->response()->error('操作禁止'); }); } } diff --git a/app/AdminAgent/Controllers/WaterfallAdController.php b/app/AdminAgent/Controllers/WaterfallAdController.php index 230fbe1..fffd0cb 100644 --- a/app/AdminAgent/Controllers/WaterfallAdController.php +++ b/app/AdminAgent/Controllers/WaterfallAdController.php @@ -122,7 +122,7 @@ class WaterfallAdController extends AdminController $form->ignore(['id', 'created_at', 'updated_at']); })->deleting(function (Form $form) { //不允许删除非自己的数据 - if ($form->model()[0]['agent_id'] != Admin::user()->id) { + if (array_filter($form->model()->toArray(), fn($v) => $v['agent_id'] != Admin::user()->id)) { return $form->response()->error('数据不存在'); } }); diff --git a/app/AdminSupplier/Controllers/AgentController.php b/app/AdminSupplier/Controllers/AgentController.php index 9f15d85..00aebe3 100644 --- a/app/AdminSupplier/Controllers/AgentController.php +++ b/app/AdminSupplier/Controllers/AgentController.php @@ -103,9 +103,9 @@ class AgentController extends AdminController $form->display('id'); })->saving(function (Form $form) { - return $form->response()->error('禁止操作'); + return $form->response()->error('操作禁止'); })->deleting(function (Form $form) { - return $form->response()->error('禁止删除'); + return $form->response()->error('操作禁止'); }); } } diff --git a/app/AdminSupplier/Controllers/ProductController.php b/app/AdminSupplier/Controllers/ProductController.php index afb3316..42e97e8 100644 --- a/app/AdminSupplier/Controllers/ProductController.php +++ b/app/AdminSupplier/Controllers/ProductController.php @@ -129,9 +129,9 @@ class ProductController extends AdminController ->update(['status' => ProductStatus::SOLD_OUT]); } })->deleting(function (Form $form) { - //这里获取字段值和saving不同 - if ($form->model()[0]['supplier_id'] != Admin::user()->id) { - return $form->response()->error('删除失败'); + //不允许删除非自己的数据 + if (array_filter($form->model()->toArray(), fn($v) => $v['supplier_id'] != Admin::user()->id)) { + return $form->response()->error('数据不存在'); } }); } From 4fc412ce3d998b51dabc121e8eb7a63f3fc94b37 Mon Sep 17 00:00:00 2001 From: liapples Date: Tue, 24 Aug 2021 16:32:33 +0800 Subject: [PATCH 14/42] =?UTF-8?q?=E9=9A=90=E8=97=8F=E5=88=9B=E5=BB=BA?= =?UTF-8?q?=E6=8C=89=E9=92=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Admin/Controllers/ProductController.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/Admin/Controllers/ProductController.php b/app/Admin/Controllers/ProductController.php index 0323d8e..65e8785 100644 --- a/app/Admin/Controllers/ProductController.php +++ b/app/Admin/Controllers/ProductController.php @@ -24,6 +24,7 @@ class ProductController extends AdminController protected function grid() { return Grid::make(new Product(['supplier:id,name', 'category:id,name']), function (Grid $grid) { + $grid->disableCreateButton(); //如果是审核页面,多加where条件判断 if (strpos(Route::current()->uri, 'audit')) { $grid->model()->where('status', ProductStatus::UNAUDITED); From 46ad8c10e313e58e371d834abfeee4895c08fee5 Mon Sep 17 00:00:00 2001 From: liapples Date: Tue, 24 Aug 2021 18:01:52 +0800 Subject: [PATCH 15/42] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=BD=AF=E5=88=A0?= =?UTF-8?q?=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Models/Article.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/Models/Article.php b/app/Models/Article.php index 66152a6..b078fd3 100644 --- a/app/Models/Article.php +++ b/app/Models/Article.php @@ -3,8 +3,9 @@ namespace App\Models; use Illuminate\Database\Eloquent\Factories\HasFactory; +use Illuminate\Database\Eloquent\SoftDeletes; class Article extends BaseModel { - use HasFactory; + use HasFactory, SoftDeletes; } From b31eac08fa195e3416e82329296f0ee17118eb1f Mon Sep 17 00:00:00 2001 From: liapples Date: Tue, 24 Aug 2021 18:02:25 +0800 Subject: [PATCH 16/42] =?UTF-8?q?=E4=BB=A3=E7=90=86=E5=95=86=E6=96=87?= =?UTF-8?q?=E7=AB=A0=E7=AE=A1=E7=90=86=EF=BC=8C=E5=B9=B6=E6=A0=B9=E6=8D=AE?= =?UTF-8?q?=E5=90=8E=E5=8F=B0=E8=AE=BE=E7=BD=AE=E6=98=BE=E7=A4=BA=E5=A4=A7?= =?UTF-8?q?=E5=9B=BE=E6=88=96=E5=B0=8F=E5=9B=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- MySQL_change.sql | 5 + .../Controllers/ArticleController.php | 111 ++++++++++++++++++ app/AdminAgent/Repositories/Article.php | 16 +++ app/AdminAgent/routes.php | 1 + .../Controllers/Api/ArticleController.php | 26 ++-- dcat_admin_ide_helper.php | 8 +- resources/lang/zh_CN/article.php | 22 ++++ resources/lang/zh_CN/product.php | 2 +- 8 files changed, 174 insertions(+), 17 deletions(-) create mode 100644 app/AdminAgent/Controllers/ArticleController.php create mode 100644 app/AdminAgent/Repositories/Article.php create mode 100644 resources/lang/zh_CN/article.php diff --git a/MySQL_change.sql b/MySQL_change.sql index 34a9eb6..df1c207 100644 --- a/MySQL_change.sql +++ b/MySQL_change.sql @@ -124,3 +124,8 @@ ALTER TABLE `notices` 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`; diff --git a/app/AdminAgent/Controllers/ArticleController.php b/app/AdminAgent/Controllers/ArticleController.php new file mode 100644 index 0000000..4fdc45f --- /dev/null +++ b/app/AdminAgent/Controllers/ArticleController.php @@ -0,0 +1,111 @@ +model()->where('agent_id', Admin::user()->id) + ->orderBy('sort')->orderBy('id', 'desc'); + + $grid->column('id')->sortable(); + $grid->column('author'); + $grid->column('title'); + $grid->column('image')->image('', 60, 60); + $grid->column('sort')->editable()->width(120)->help('数字超小越靠前'); + $grid->column('type')->using(['普通列表', '大图显示']); + $grid->column('created_at'); + $grid->column('updated_at')->sortable(); + + $grid->filter(function (Grid\Filter $filter) { + $filter->panel(); + + $filter->equal('id')->width(2); + $filter->like('title')->width(3); + }); + }); + } + + /** + * Make a show builder. + * + * @param mixed $id + * + * @return Show + */ + protected function detail($id) + { + return Show::make($id, new Article(), function (Show $show) { + //不允许查看非自己的数据 + if ($show->model()->agent_id != Admin::user()->id) { + Admin::exit('数据不存在'); + } + + $show->field('id'); + $show->field('author'); + $show->field('title'); + $show->field('image')->image('', 80, 80); + $show->field('content')->unescape(); + $show->field('sort'); + $show->field('type')->using(['普通列表', '大图显示']); + $show->field('created_at'); + $show->field('updated_at'); + }); + } + + /** + * Make a form builder. + * + * @return Form + */ + protected function form() + { + return Form::make(new Article(), function (Form $form) { + //不允许查看非自己的数据 + if ($form->isEditing() && $form->model()->agent_id != Admin::user()->id) { + return $form->response()->error('数据不存在'); + } + + $form->display('id'); + $form->text('author')->default(Admin::user()->name); + $form->text('title')->required(); + $form->image('image')->required(); + $form->editor('content')->required(); + $form->text('sort')->default(255); + $form->select('type')->options(['普通列表', '大图显示'])->default(0)->required(); + })->saving(function (Form $form) { + //不允许修改非自己的数据 + if ($form->isEditing() && $form->model()->agent_id != Admin::user()->id) { + return $form->response()->error('数据不存在'); + } + + //特殊字段处理 + $form->hidden(['agent_id']); + $form->agent_id = Admin::user()->id; + $form->sort = $form->sort ?? 255; + $form->type = $form->type ? 1 : 0; + + //不允许编辑的字段 + $form->ignore(['id', 'created_at', 'updated_at']); + })->deleting(function (Form $form) { + //不允许删除非自己的数据 + if (array_filter($form->model()->toArray(), fn($v) => $v['agent_id'] != Admin::user()->id)) { + return $form->response()->error('数据不存在'); + } + }); + } +} diff --git a/app/AdminAgent/Repositories/Article.php b/app/AdminAgent/Repositories/Article.php new file mode 100644 index 0000000..c46b1d6 --- /dev/null +++ b/app/AdminAgent/Repositories/Article.php @@ -0,0 +1,16 @@ +resource('notice/list', 'NoticeController'); $router->resource('agent_info', 'AgentInfoController'); $router->resource('supplier/list', 'SupplierController'); + $router->resource('article/list', 'ArticleController'); }); diff --git a/app/Http/Controllers/Api/ArticleController.php b/app/Http/Controllers/Api/ArticleController.php index 2843243..0b171de 100644 --- a/app/Http/Controllers/Api/ArticleController.php +++ b/app/Http/Controllers/Api/ArticleController.php @@ -16,25 +16,27 @@ class ArticleController extends Controller //文章列表 public function index() { - //TODO 此处仅为演示数据,调用数据需要再修改 - $list = Article::query() - ->where('agent_id', $this->agent_id) - ->select('id', 'image', 'title', 'updated_at') - ->orderBy('id', 'DESC') + $list = Article::where('agent_id', $this->agent_id) + ->select('id', 'image', 'title', 'type', 'updated_at') + ->orderBy('sort')->orderBy('id', 'DESC') ->simplePaginate()->toArray(); $new_data = []; $prefix = Storage::disk('public')->url(''); foreach ($list['data'] as $k => &$item) { $item['image'] = $prefix . $item['image']; - $new_key = floor($k / 4); - if ($k % 4 == 0) { - $new_data[$new_key] = [ - 'big' => $item, - 'children' => [] - ]; + + //type=1是大图 + if ($item['type'] == 1) { + $new_data[] = ['big' => $item]; + continue; + } + //普通列表 + $count = count($new_data); + if ($count) { + $new_data[$count - 1]['children'][] = $item; } else { - $new_data[$new_key]['children'][] = $item; + $new_data[] = ['children' => [$item]]; } } $list['data'] = $new_data; diff --git a/dcat_admin_ide_helper.php b/dcat_admin_ide_helper.php index 473a1fa..102c0a1 100644 --- a/dcat_admin_ide_helper.php +++ b/dcat_admin_ide_helper.php @@ -72,8 +72,8 @@ namespace Dcat\Admin { * @property Grid\Column|Collection rate * @property Grid\Column|Collection author * @property Grid\Column|Collection image - * @property Grid\Column|Collection pid * @property Grid\Column|Collection sort + * @property Grid\Column|Collection pid * @property Grid\Column|Collection template * @property Grid\Column|Collection end_at * @property Grid\Column|Collection start_at @@ -169,8 +169,8 @@ namespace Dcat\Admin { * @method Grid\Column|Collection rate(string $label = null) * @method Grid\Column|Collection author(string $label = null) * @method Grid\Column|Collection image(string $label = null) - * @method Grid\Column|Collection pid(string $label = null) * @method Grid\Column|Collection sort(string $label = null) + * @method Grid\Column|Collection pid(string $label = null) * @method Grid\Column|Collection template(string $label = null) * @method Grid\Column|Collection end_at(string $label = null) * @method Grid\Column|Collection start_at(string $label = null) @@ -271,8 +271,8 @@ namespace Dcat\Admin { * @property Show\Field|Collection rate * @property Show\Field|Collection author * @property Show\Field|Collection image - * @property Show\Field|Collection pid * @property Show\Field|Collection sort + * @property Show\Field|Collection pid * @property Show\Field|Collection template * @property Show\Field|Collection end_at * @property Show\Field|Collection start_at @@ -368,8 +368,8 @@ namespace Dcat\Admin { * @method Show\Field|Collection rate(string $label = null) * @method Show\Field|Collection author(string $label = null) * @method Show\Field|Collection image(string $label = null) - * @method Show\Field|Collection pid(string $label = null) * @method Show\Field|Collection sort(string $label = null) + * @method Show\Field|Collection pid(string $label = null) * @method Show\Field|Collection template(string $label = null) * @method Show\Field|Collection end_at(string $label = null) * @method Show\Field|Collection start_at(string $label = null) diff --git a/resources/lang/zh_CN/article.php b/resources/lang/zh_CN/article.php new file mode 100644 index 0000000..af5235b --- /dev/null +++ b/resources/lang/zh_CN/article.php @@ -0,0 +1,22 @@ + [ + 'Article' => '文章', + 'article' => '文章', + ], + 'fields' => [ + 'agent_id' => '代理商ID', + 'author' => '作者', + 'title' => '文章标题', + 'image' => '文章缩略图', + 'content' => '文章内容', + 'sort' => '排序', + 'type' => '显示方式', + ], + 'options' => [ + 'type' => [ + 0 => '普通列表', + 1 => '大图显示', + ], + ], +]; diff --git a/resources/lang/zh_CN/product.php b/resources/lang/zh_CN/product.php index 151e444..8d706cd 100644 --- a/resources/lang/zh_CN/product.php +++ b/resources/lang/zh_CN/product.php @@ -7,7 +7,7 @@ return [ 'fields' => [ 'category_id' => '产品分类ID', 'content' => '产品详情', - 'know' => '旅客须知', + 'know' => '旅游须知', 'original_price' => '原价', 'pictures' => '产品图片', 'picture' => '产品图片', From 7c1f42d0cc05da8290db88fbf9a4b9ebfe2ba495 Mon Sep 17 00:00:00 2001 From: liapples Date: Tue, 24 Aug 2021 18:17:23 +0800 Subject: [PATCH 17/42] =?UTF-8?q?=E9=87=8D=E5=91=BD=E5=90=8D=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E8=A1=A8`slides`=20TO=20`advertisings`=E5=92=8C?= =?UTF-8?q?=E9=87=8D=E5=91=BD=E5=90=8D=E6=A8=A1=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- MySQL_change.sql | 8 ++++++++ app/Admin/Extensions/Grid/AuditAgent.php | 8 ++++---- .../{SlideController.php => AdvertisingController.php} | 10 +++++----- .../Repositories/{Slide.php => Advertising.php} | 4 ++-- app/AdminAgent/routes.php | 2 +- app/Http/Controllers/Api/IndexController.php | 4 ++-- app/Models/{Slide.php => Advertising.php} | 4 ++-- 7 files changed, 24 insertions(+), 16 deletions(-) rename app/AdminAgent/Controllers/{SlideController.php => AdvertisingController.php} (92%) rename app/AdminAgent/Repositories/{Slide.php => Advertising.php} (71%) rename app/Models/{Slide.php => Advertising.php} (81%) diff --git a/MySQL_change.sql b/MySQL_change.sql index df1c207..24f35ce 100644 --- a/MySQL_change.sql +++ b/MySQL_change.sql @@ -129,3 +129,11 @@ ALTER TABLE `users` 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`; + + + diff --git a/app/Admin/Extensions/Grid/AuditAgent.php b/app/Admin/Extensions/Grid/AuditAgent.php index 6a893ad..dc639cd 100644 --- a/app/Admin/Extensions/Grid/AuditAgent.php +++ b/app/Admin/Extensions/Grid/AuditAgent.php @@ -5,7 +5,7 @@ use App\Common\UserStatus; use App\Models\Agent; use App\Models\Category; use App\Models\Channel; -use App\Models\Slide; +use App\Models\Advertising; use Dcat\Admin\Grid\RowAction; use Illuminate\Http\Request; use Illuminate\Support\Facades\DB; @@ -94,8 +94,8 @@ class AuditAgent extends RowAction } //首页轮播图 - if (!Slide::where('agent_id', $id)->first()) { - $default_slide = Slide::where('agent_id', 0)->orderBy('id')->get()->toArray(); + if (!Advertising::where('agent_id', $id)->first()) { + $default_slide = Advertising::where('agent_id', 0)->orderBy('id')->get()->toArray(); $default_slide = array_map(function ($v) use ($id, $host) { unset($v['id']); @@ -104,7 +104,7 @@ class AuditAgent extends RowAction $v['url'] = str_replace($host, '', $v['url']); return $v; }, $default_slide); - Slide::insert($default_slide); + Advertising::insert($default_slide); } //TODO 还需要插入 演示产品、公告、专题等 diff --git a/app/AdminAgent/Controllers/SlideController.php b/app/AdminAgent/Controllers/AdvertisingController.php similarity index 92% rename from app/AdminAgent/Controllers/SlideController.php rename to app/AdminAgent/Controllers/AdvertisingController.php index 33e7f80..3563779 100644 --- a/app/AdminAgent/Controllers/SlideController.php +++ b/app/AdminAgent/Controllers/AdvertisingController.php @@ -2,14 +2,14 @@ namespace App\AdminAgent\Controllers; -use App\AdminAgent\Repositories\Slide; +use App\AdminAgent\Repositories\Advertising; use Dcat\Admin\Admin; use Dcat\Admin\Form; use Dcat\Admin\Grid; use Dcat\Admin\Show; use Dcat\Admin\Http\Controllers\AdminController; -class SlideController extends AdminController +class AdvertisingController extends AdminController { /** * Make a grid builder. @@ -18,7 +18,7 @@ class SlideController extends AdminController */ protected function grid() { - return Grid::make(new Slide(), function (Grid $grid) { + return Grid::make(new Advertising(), function (Grid $grid) { $grid->model()->where('agent_id', Admin::user()->id)->orderBy('sort')->orderBy('id', 'DESC'); $grid->column('id')->sortable(); @@ -47,7 +47,7 @@ class SlideController extends AdminController */ protected function detail($id) { - return Show::make($id, new Slide(), function (Show $show) { + return Show::make($id, new Advertising(), function (Show $show) { //不允许查看非自己的数据 if ($show->model()->agent_id != Admin::user()->id) { Admin::exit('数据不存在'); @@ -72,7 +72,7 @@ class SlideController extends AdminController */ protected function form() { - return Form::make(new Slide(), function (Form $form) { + return Form::make(new Advertising(), function (Form $form) { //不允许查看非自己的数据 if ($form->isEditing() && $form->model()->agent_id != Admin::user()->id) { return $form->response()->error('数据不存在'); diff --git a/app/AdminAgent/Repositories/Slide.php b/app/AdminAgent/Repositories/Advertising.php similarity index 71% rename from app/AdminAgent/Repositories/Slide.php rename to app/AdminAgent/Repositories/Advertising.php index a7eef5c..bdc6a0d 100644 --- a/app/AdminAgent/Repositories/Slide.php +++ b/app/AdminAgent/Repositories/Advertising.php @@ -2,10 +2,10 @@ namespace App\AdminAgent\Repositories; -use App\Models\Slide as Model; +use App\Models\Advertising as Model; use Dcat\Admin\Repositories\EloquentRepository; -class Slide extends EloquentRepository +class Advertising extends EloquentRepository { /** * Model. diff --git a/app/AdminAgent/routes.php b/app/AdminAgent/routes.php index 3b28c5b..8f26883 100644 --- a/app/AdminAgent/routes.php +++ b/app/AdminAgent/routes.php @@ -20,7 +20,7 @@ Route::group([ $router->resource('user/list', 'UserController'); $router->resource('user/verifier', 'UserController'); $router->resource('order/list', 'OrderController'); - $router->resource('slide/list', 'SlideController'); + $router->resource('advertising/list', 'AdvertisingController'); $router->resource('special/list', 'SpecialController'); $router->resource('waterfall_ad/list', 'WaterfallAdController'); $router->resource('message/list', 'MessageController'); diff --git a/app/Http/Controllers/Api/IndexController.php b/app/Http/Controllers/Api/IndexController.php index 20b740c..9f6aef1 100644 --- a/app/Http/Controllers/Api/IndexController.php +++ b/app/Http/Controllers/Api/IndexController.php @@ -5,7 +5,7 @@ use App\Http\Controllers\Controller; use App\Models\Channel; use App\Models\Notice; use App\Models\AgentProduct; -use App\Models\Slide; +use App\Models\Advertising; use App\Models\Special; use App\Models\UserChannel; use Illuminate\Support\Facades\Storage; @@ -23,7 +23,7 @@ class IndexController extends Controller $img_prefix = Storage::disk('public')->url(''); # 轮播图 - $slide = Slide::where(['agent_id' => $this->agent_id, 'status' => 1]) + $slide = Advertising::where(['agent_id' => $this->agent_id, 'status' => 1]) ->orderBy('sort')->orderBy('id', 'DESC')->limit(10) ->get(['title', 'picture', 'type', 'url']); foreach ($slide as &$v) { diff --git a/app/Models/Slide.php b/app/Models/Advertising.php similarity index 81% rename from app/Models/Slide.php rename to app/Models/Advertising.php index 22c2c4e..ab58f1d 100644 --- a/app/Models/Slide.php +++ b/app/Models/Advertising.php @@ -6,10 +6,10 @@ use Illuminate\Database\Eloquent\Factories\HasFactory; /** * 轮播图 - * Class Slide + * Class Advertising * @package App\Models */ -class Slide extends BaseModel +class Advertising extends BaseModel { use HasFactory; From 57f79c31d96309167899f94d5c976e5033d69f90 Mon Sep 17 00:00:00 2001 From: liapples Date: Wed, 25 Aug 2021 00:25:06 +0800 Subject: [PATCH 18/42] =?UTF-8?q?=E7=80=91=E5=B8=83=E6=B5=81=E3=80=81?= =?UTF-8?q?=E8=BD=AE=E6=92=AD=E5=9B=BE=E3=80=81=E9=A6=96=E9=A1=B5=E6=A8=AA?= =?UTF-8?q?=E5=B1=8F=E5=B9=BF=E5=91=8A=E7=BB=9F=E4=B8=80=E4=BF=9D=E5=AD=98?= =?UTF-8?q?=E5=9C=A8Advertisings=E8=A1=A8=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- MySQL_change.sql | 11 ++ .../Controllers/AdvertisingController.php | 25 +++- .../Controllers/SpecialController.php | 8 -- .../Controllers/WaterfallAdController.php | 130 ------------------ app/AdminAgent/Repositories/WaterfallAd.php | 16 --- .../Api/AgentProductController.php | 38 +++-- app/Http/Controllers/Api/IndexController.php | 18 +-- .../Controllers/Api/SpecialController.php | 2 +- app/Models/WaterfallAd.php | 18 --- resources/lang/zh_CN/advertising.php | 28 ++++ resources/lang/zh_CN/slide.php | 18 --- 11 files changed, 91 insertions(+), 221 deletions(-) delete mode 100644 app/AdminAgent/Controllers/WaterfallAdController.php delete mode 100644 app/AdminAgent/Repositories/WaterfallAd.php delete mode 100644 app/Models/WaterfallAd.php create mode 100644 resources/lang/zh_CN/advertising.php delete mode 100644 resources/lang/zh_CN/slide.php diff --git a/MySQL_change.sql b/MySQL_change.sql index 24f35ce..ab1d0bb 100644 --- a/MySQL_change.sql +++ b/MySQL_change.sql @@ -135,5 +135,16 @@ 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`; diff --git a/app/AdminAgent/Controllers/AdvertisingController.php b/app/AdminAgent/Controllers/AdvertisingController.php index 3563779..4286d12 100644 --- a/app/AdminAgent/Controllers/AdvertisingController.php +++ b/app/AdminAgent/Controllers/AdvertisingController.php @@ -22,9 +22,10 @@ class AdvertisingController extends AdminController $grid->model()->where('agent_id', Admin::user()->id)->orderBy('sort')->orderBy('id', 'DESC'); $grid->column('id')->sortable(); + $grid->column('display')->using(admin_trans('advertising.options.display')); $grid->column('title'); $grid->column('picture')->image('', 60, 60); - $grid->column('type')->using(['链接内部页面', '链接网址']); + $grid->column('type')->using(admin_trans('advertising.options.type')); $grid->column('url'); $grid->column('status')->switch(); $grid->column('sort')->editable()->sortable()->width(120); @@ -33,6 +34,7 @@ class AdvertisingController extends AdminController $filter->panel(); $filter->equal('id')->width(2); + $filter->equal('display')->select(admin_trans('advertising.options.display'))->width(2); $filter->like('title')->width(3); }); }); @@ -54,9 +56,10 @@ class AdvertisingController extends AdminController } $show->field('id'); + $show->field('display')->using(admin_trans('advertising.options.display')); $show->field('title'); $show->field('picture')->image('', 80, 80); - $show->field('type')->using(['链接内部页面', '链接网址']); + $show->field('type')->using(admin_trans('advertising.options.type')); $show->field('url'); $show->field('status')->using(['禁用', '启用']); $show->field('sort'); @@ -79,15 +82,22 @@ class AdvertisingController extends AdminController } $form->display('id'); + $form->select('display') + ->options(admin_trans('advertising.options.display')) + ->default(0) + ->required(); $form->text('title') ->help('主要用于后台显示,方便管理') ->required(); $form->image('picture') ->required()->removable(false)->uniqueName() - ->help('图片大小:750*360'); - $form->select('status')->options(['禁用', '启用'])->default(1)->required(); - $form->radio('type', '链接类型') - ->options(['链接到内部页面', '链接到网址']) + ->help('轮播图大小:750*360;横屏广告大小:750*230;产品列表内嵌广告建议跟产品图片大小一致'); + $form->select('status') + ->options(['禁用', '启用']) + ->default(1) + ->required(); + $form->radio('type', '链接类型') + ->options(admin_trans('advertising.options.type')) ->value(0)->default(0) ->when(0, function (Form $form) { $form->text('url-0', '内部页面地址') @@ -100,7 +110,8 @@ class AdvertisingController extends AdminController $form->url('url-1', '链接到网址') ->placeholder('如:https://www.baidu.com/') ->customFormat(fn() => $this->type == 1 ? $this->url : ''); - }); + }) + ->required(); $form->text('sort')->default(255)->required(); })->saving(function (Form $form) { //不允许修改非自己的数据 diff --git a/app/AdminAgent/Controllers/SpecialController.php b/app/AdminAgent/Controllers/SpecialController.php index 8781c25..68978ec 100644 --- a/app/AdminAgent/Controllers/SpecialController.php +++ b/app/AdminAgent/Controllers/SpecialController.php @@ -28,7 +28,6 @@ class SpecialController extends AdminController $grid->model()->where('agent_id', Admin::user()->id); $grid->column('id')->sortable(); - $grid->column('picture_ad')->image('', 60, 60); $grid->column('agent_product_id', '专题产品') ->display('查看') ->modal(function ($modal) use ($grid) { @@ -48,7 +47,6 @@ class SpecialController extends AdminController } return Table::make(['产品ID', '标题', '图片', '销量', '库存'], $result); }); - $grid->column('sort'); $grid->column('created_at'); $grid->column('updated_at')->sortable(); @@ -76,7 +74,6 @@ class SpecialController extends AdminController } $show->field('id'); - $show->field('picture_ad')->image('', 80, 80); $show->field('picture')->image('', 80, 80); $show->field('agent_product_id', '产品') ->unescape() @@ -86,7 +83,6 @@ class SpecialController extends AdminController ->orderBy('id')->get(['id', 'product_id']); return join("
", $data->map(fn($v) => $v->product->title)->toArray()); }); - $show->field('sort'); $show->field('created_at'); $show->field('updated_at'); }); @@ -106,9 +102,6 @@ class SpecialController extends AdminController } $form->display('id'); - $form->image('picture_ad') - ->required()->removable(false)->uniqueName() - ->help('图片大小:750*230'); $form->multipleImage('picture') ->required()->removable(false)->uniqueName() ->help('图片大小:750*490'); @@ -130,7 +123,6 @@ class SpecialController extends AdminController }) ->pluck('product.title') ->value(join(',', $form->model()->agent_product_id ?? [])); - $form->text('sort')->default(255); })->saving(function (Form $form) { //不允许修改非自己的数据 if ($form->isEditing() && $form->model()->agent_id != Admin::user()->id) { diff --git a/app/AdminAgent/Controllers/WaterfallAdController.php b/app/AdminAgent/Controllers/WaterfallAdController.php deleted file mode 100644 index fffd0cb..0000000 --- a/app/AdminAgent/Controllers/WaterfallAdController.php +++ /dev/null @@ -1,130 +0,0 @@ -model()->where('agent_id', Admin::user()->id)->orderBy('sort')->orderBy('id', 'DESC'); - - $grid->column('id')->sortable(); - $grid->column('title'); - $grid->column('picture')->image('', 60, 60); - $grid->column('type')->using(['链接内部页面', '链接网址']); - $grid->column('url'); - $grid->column('status')->switch(); - $grid->column('sort')->editable()->sortable()->width(120); - - $grid->filter(function (Grid\Filter $filter) { - $filter->panel(); - - $filter->equal('id')->width(2); - $filter->like('title')->width(3); - }); - }); - } - - /** - * Make a show builder. - * - * @param mixed $id - * - * @return Show - */ - protected function detail($id) - { - return Show::make($id, new WaterfallAd('agentProduct.product:id,title'), function (Show $show) { - //不允许查看非自己的数据 - if ($show->model()->agent_id != Admin::user()->id) { - Admin::exit('数据不存在'); - } - - $show->field('id'); - $show->field('title'); - $show->field('picture')->image('', 80, 80); - $show->field('type')->using(['链接内部页面', '链接网址']); - $show->field('url'); - $show->field('status')->using(['禁用', '启用']); - $show->field('sort'); - $show->field('created_at'); - $show->field('updated_at'); - }); - } - - /** - * Make a form builder. - * - * @return Form - */ - protected function form() - { - return Form::make(new WaterfallAd(), function (Form $form) { - //不允许查看非自己的数据 - if ($form->isEditing() && $form->model()->agent_id != Admin::user()->id) { - return $form->response()->error('数据不存在'); - } - - $form->display('id'); - $form->text('title')->required(); - $form->image('picture') - ->required()->removable(false)->uniqueName(); - $form->radio('type', '链接类型') - ->options(['链接到内部页面', '链接到网址']) - ->value(0)->default(0) - ->when(0, function (Form $form) { - $form->text('url-0', '内部页面地址') - ->customFormat(fn() => $this->type == 0 ? $this->url : '') - ->help('格式如下:
产品详情页:/pages/goodsDetail/index?goods_id=产品ID -
文章详情页:/pages/notice/article?article_id=文章ID -
公告详情页:/pages/notice/notice?notice_id=公告ID'); - }) - ->when(1, function (Form $form) { - $form->url('url-1', '链接到网址') - ->placeholder('如:https://www.baidu.com/') - ->customFormat(fn() => $this->type == 1 ? $this->url : ''); - }); - $form->text('sort')->default(255)->required(); - })->saving(function (Form $form) { - //不允许修改非自己的数据 - if ($form->isEditing() && $form->model()->agent_id != Admin::user()->id) { - return $form->response()->error('数据不存在'); - } - - //将null字段设置为空值,防止插入数据库出错 - foreach ($form->input() as $k => $v) { - if (is_null($v)) { - $form->$k = ''; - } - } - - //处理特殊字段 - $form->hidden(['agent_id', 'url']); - $form->agent_id = Admin::user()->id; - $form->status = $form->status ? 1 : 0; - $form->url = $form->{'url-' . $form->type}; - $form->deleteInput(['url-0', 'url-1']); - - //不允许编辑的字段 - $form->ignore(['id', 'created_at', 'updated_at']); - })->deleting(function (Form $form) { - //不允许删除非自己的数据 - if (array_filter($form->model()->toArray(), fn($v) => $v['agent_id'] != Admin::user()->id)) { - return $form->response()->error('数据不存在'); - } - }); - } -} diff --git a/app/AdminAgent/Repositories/WaterfallAd.php b/app/AdminAgent/Repositories/WaterfallAd.php deleted file mode 100644 index 20e0745..0000000 --- a/app/AdminAgent/Repositories/WaterfallAd.php +++ /dev/null @@ -1,16 +0,0 @@ -index(); + $list = AgentProduct::list()->where('agent_id', $this->agent_id)->simplePaginate(); + $list = $this->paginatePicAddHost($list); + $list = $list->toArray(); + if (!empty($list['data']) && is_array($list['data'])) { + shuffle($list['data']); //随机乱序 + } + $list = $this->insertAd($list); + + return $this->success($list); } //【我的】页面下方推荐 @@ -81,11 +88,14 @@ class AgentProductController extends Controller return $this->index(); } - //人气爆款列表 + //人气爆款列表,销量排序 public function hotList() { - //TODO 具体排序规则,后期再做修改 - return $this->index(); + $list = AgentProduct::list()->where('agent_id', $this->agent_id)->simplePaginate(); + $list = $this->paginatePicAddHost($list); + $list = $this->insertAd($list); + + return $this->success($list); } //分页列表产品图片加域名 @@ -106,27 +116,27 @@ class AgentProductController extends Controller private function insertAd($list) { //插入瀑布流广告,分别在第8个和第16个插入,同时需要考虑到分页。当所有瀑布流广告插入完之后,再次循环插入 - $list = $list->toArray(); - if ($list['data']) { - $ad_total = WaterfallAd::where(['agent_id' => $this->agent_id, 'status' => 1])->count(); + if (is_object($list) && method_exists($list, 'toArray')) { + $list = $list->toArray(); + } + $ad_total = Advertising::where(['agent_id' => $this->agent_id, 'status' => 1, 'display' => 2])->count(); + if ($list['data'] && $ad_total > 0) { $page = (int)request()->input('page'); $start = ($page ? $page - 1 : 0) * 2 % $ad_total; - $ad = WaterfallAd::where(['agent_id' => $this->agent_id, 'status' => 1]) + $ad = Advertising::where(['agent_id' => $this->agent_id, 'status' => 1, 'display' => 2]) ->orderBy('sort')->orderBy('id', 'DESC') ->offset($start)->limit(2)->get(['title', 'picture', 'type', 'url'])->toArray(); $prefix = Storage::disk('public')->url(''); - //每隔8个插入广告 - $gap = 4; foreach ($ad as $k => &$v) { $v['is_ad'] = true; $v['picture'] = $prefix . $v['picture']; - //插入广告 - $temp = $gap * ($k+1); + //每隔8个插入广告 + $temp = 8 * ($k+1); if (!empty($list['data'][$temp - 1]) && !empty($ad[$k])) { array_splice($list['data'], $temp + $k, 0, [$ad[$k]]); } diff --git a/app/Http/Controllers/Api/IndexController.php b/app/Http/Controllers/Api/IndexController.php index 9f6aef1..f7e5212 100644 --- a/app/Http/Controllers/Api/IndexController.php +++ b/app/Http/Controllers/Api/IndexController.php @@ -6,7 +6,6 @@ use App\Models\Channel; use App\Models\Notice; use App\Models\AgentProduct; use App\Models\Advertising; -use App\Models\Special; use App\Models\UserChannel; use Illuminate\Support\Facades\Storage; @@ -23,11 +22,13 @@ class IndexController extends Controller $img_prefix = Storage::disk('public')->url(''); # 轮播图 - $slide = Advertising::where(['agent_id' => $this->agent_id, 'status' => 1]) + $slide = Advertising::where(['agent_id' => $this->agent_id, 'status' => 1, 'display' => 0]) ->orderBy('sort')->orderBy('id', 'DESC')->limit(10) ->get(['title', 'picture', 'type', 'url']); - foreach ($slide as &$v) { - $v->picture = $img_prefix . $v->picture; + if (!$slide->isEmpty()) { + foreach ($slide as &$v) { + $v->picture = $img_prefix . $v->picture; + } } # 公告 @@ -71,13 +72,12 @@ class IndexController extends Controller } # 专题列表 - $special = Special::query() - ->where('agent_id', $this->agent_id) - ->orderBy('sort')->orderBy('id') - ->limit(6)->get(['id', 'picture_ad']); + $special = Advertising::where('agent_id', $this->agent_id) + ->orderBy('sort')->orderBy('id', 'desc')->limit(6) + ->get(['title', 'picture', 'type', 'url']); if (!$special->isEmpty()) { foreach ($special as $k=>&$v) { - $v->picture_ad = $img_prefix . $v->picture_ad; + $v->picture = $img_prefix . $v->picture; } } diff --git a/app/Http/Controllers/Api/SpecialController.php b/app/Http/Controllers/Api/SpecialController.php index 681f4b2..73e0def 100644 --- a/app/Http/Controllers/Api/SpecialController.php +++ b/app/Http/Controllers/Api/SpecialController.php @@ -12,7 +12,7 @@ class SpecialController extends Controller { $id = (int)request()->input('id'); $detail = Special::query() - ->select(['id', 'picture', 'picture_ad', 'updated_at', 'agent_product_id']) + ->select(['id', 'picture', 'updated_at', 'agent_product_id']) ->find($id); $detail->product = AgentProduct::list() diff --git a/app/Models/WaterfallAd.php b/app/Models/WaterfallAd.php deleted file mode 100644 index 7299f03..0000000 --- a/app/Models/WaterfallAd.php +++ /dev/null @@ -1,18 +0,0 @@ -belongsTo(AgentProduct::class); - } -} diff --git a/resources/lang/zh_CN/advertising.php b/resources/lang/zh_CN/advertising.php new file mode 100644 index 0000000..9508def --- /dev/null +++ b/resources/lang/zh_CN/advertising.php @@ -0,0 +1,28 @@ + [ + 'Advertising' => '广告图', + 'advertising' => '广告图', + ], + 'fields' => [ + 'title' => '标题', + 'picture' => '图片地址', + 'status' => '状态', + 'agent_id' => '代理商ID', + 'sort' => '排序', + 'type' => '链接类型', + 'url' => '链接到', + 'display' => '显示位置', + ], + 'options' => [ + 'type' => [ + 0 => '内部页面', + 1 => '网址', + ], + 'display' => [ + 0 => '轮播图', + 1 => '首页横屏广告', + 2 => '产品列表内嵌广告', + ], + ], +]; diff --git a/resources/lang/zh_CN/slide.php b/resources/lang/zh_CN/slide.php deleted file mode 100644 index 46d7ed2..0000000 --- a/resources/lang/zh_CN/slide.php +++ /dev/null @@ -1,18 +0,0 @@ - [ - 'Slide' => '轮播图', - 'slide' => '轮播图', - ], - 'fields' => [ - 'title' => '图片说明', - 'picture' => '图片地址', - 'status' => '状态', - 'agent_id' => '代理商ID', - 'sort' => '排序', - 'type' => '链接类型', - 'url' => '链接到', - ], - 'options' => [ - ], -]; From fa0d42c2dc3a5be78f295f2a2a29ce0e1d3da45c Mon Sep 17 00:00:00 2001 From: liapples Date: Wed, 25 Aug 2021 09:41:49 +0800 Subject: [PATCH 19/42] =?UTF-8?q?=E7=BC=96=E8=BE=91=E8=B5=84=E6=96=99?= =?UTF-8?q?=E9=9C=80=E8=A6=81=E5=AE=A1=E6=A0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/AdminAgent/Forms/AgentInfo.php | 4 ++++ app/AdminSupplier/Forms/SupplierInfo.php | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/app/AdminAgent/Forms/AgentInfo.php b/app/AdminAgent/Forms/AgentInfo.php index 023e166..8668887 100644 --- a/app/AdminAgent/Forms/AgentInfo.php +++ b/app/AdminAgent/Forms/AgentInfo.php @@ -1,6 +1,7 @@ logo = $input['logo']; $model->avatar = $input['avatar']; $model->license_pic = $input['license_pic']; + $model->status = UserStatus::UNAUDITED; $model->agentInfo->about = $input['agentInfo']['about']; $model->agentInfo->reg_protocol = $input['agentInfo']['reg_protocol']; @@ -57,6 +59,8 @@ class AgentInfo extends Form $this->editor('agentInfo.about')->required(); $this->editor('agentInfo.reg_protocol')->required(); $this->editor('agentInfo.buy_protocol')->required(); + + $this->confirm('编辑确认', '编辑内容需要管理员重新审核,确定要提交吗?'); } /** diff --git a/app/AdminSupplier/Forms/SupplierInfo.php b/app/AdminSupplier/Forms/SupplierInfo.php index 31c271b..9203051 100644 --- a/app/AdminSupplier/Forms/SupplierInfo.php +++ b/app/AdminSupplier/Forms/SupplierInfo.php @@ -2,6 +2,7 @@ namespace App\AdminSupplier\Forms; +use App\Common\UserStatus; use App\Models\Supplier; use Dcat\Admin\Admin; use Dcat\Admin\Widgets\Form; @@ -29,6 +30,7 @@ class SupplierInfo extends Form $model->avatar = $input['avatar']; $model->logo = $input['logo']; $model->license_pic = $input['license_pic']; + $model->status = UserStatus::UNAUDITED; $model->save(); return $this->response()->success('保存成功')->refresh(); @@ -49,6 +51,8 @@ class SupplierInfo extends Form $this->image('avatar'); $this->image('logo')->required(); $this->image('license_pic')->required(); + + $this->confirm('编辑确认', '编辑内容需要管理员重新审核,确定要提交吗?'); } /** From 88807e6e97fac224e866c9f50095cdfe40b03ef5 Mon Sep 17 00:00:00 2001 From: liapples Date: Wed, 25 Aug 2021 09:59:18 +0800 Subject: [PATCH 20/42] =?UTF-8?q?help=E5=A2=9E=E5=8A=A0=E4=B8=93=E9=A2=98?= =?UTF-8?q?=E6=B4=BB=E5=8A=A8=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/AdminAgent/Controllers/AdvertisingController.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/AdminAgent/Controllers/AdvertisingController.php b/app/AdminAgent/Controllers/AdvertisingController.php index 4286d12..b6b504a 100644 --- a/app/AdminAgent/Controllers/AdvertisingController.php +++ b/app/AdminAgent/Controllers/AdvertisingController.php @@ -104,7 +104,8 @@ class AdvertisingController extends AdminController ->customFormat(fn() => $this->type == 0 ? $this->url : '') ->help('格式如下:
产品详情页:/pages/goodsDetail/index?goods_id=产品ID
文章详情页:/pages/notice/article?article_id=文章ID -
公告详情页:/pages/notice/notice?notice_id=公告ID'); +
公告详情页:/pages/notice/notice?notice_id=公告ID +
专题活动页:/pages/activityList/index?special_id=专题ID'); }) ->when(1, function (Form $form) { $form->url('url-1', '链接到网址') From 6519883d241ab1709dc07ff56218449119ad7240 Mon Sep 17 00:00:00 2001 From: liapples Date: Wed, 25 Aug 2021 14:14:52 +0800 Subject: [PATCH 21/42] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=B6=88=E6=81=AF?= =?UTF-8?q?=E5=B7=B2=E8=AF=BB=E7=9A=84=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/MessageController.php | 14 +++++++------- .../Controllers/Api/MessageController.php | 19 +++++++++++++------ app/Models/MessageRead.php | 14 ++++++++++++++ 3 files changed, 34 insertions(+), 13 deletions(-) create mode 100644 app/Models/MessageRead.php diff --git a/app/AdminAgent/Controllers/MessageController.php b/app/AdminAgent/Controllers/MessageController.php index 3813198..df3136b 100644 --- a/app/AdminAgent/Controllers/MessageController.php +++ b/app/AdminAgent/Controllers/MessageController.php @@ -26,7 +26,7 @@ class MessageController extends AdminController $grid->column('id')->sortable(); $grid->column('user_id'); $grid->column('title'); - $grid->column('is_read')->if(fn($v) => $this->user_id != 0)->bool()->else()->display('所有人接收'); +// $grid->column('is_read')->if(fn($v) => $this->user_id != 0)->bool()->else()->display('所有人接收'); $grid->column('created_at'); $grid->filter(function (Grid\Filter $filter) { @@ -58,13 +58,13 @@ class MessageController extends AdminController $show->field('user_id'); $show->field('title'); $show->field('content')->unescape(); - $show->field('is_read') + /*$show->field('is_read') ->as(function () { if ($this->user_id) { return $this->is_read ? '已读' : '未读'; } return '所有人接收'; - }); + });*/ $show->field('created_at'); }); } @@ -91,9 +91,9 @@ class MessageController extends AdminController $form->text('title')->required(); $form->editor('content'); - if ($form->isCreating()) { + /*if ($form->isCreating()) { $form->confirm('发布确认', '为了保证消费者利益,所有人接收的消息发布后禁止编辑,确定发布?'); - } + }*/ })->saving(function (Form $form) { //不允许修改非自己的数据 if ($form->isEditing() && $form->model()->agent_id != Admin::user()->id) { @@ -101,14 +101,14 @@ class MessageController extends AdminController } //消息已读后禁止编辑 - if ($form->isEditing()) { + /*if ($form->isEditing()) { if ($form->model()->user_id == 0) { return $form->response()->error('为了保证消费者利益,所有人接收的消息禁止编辑'); } if ($form->model()->is_read) { return $form->response()->error('消息已读,禁止修改'); } - } + }*/ //特殊字段处理 $form->hidden(['agent_id']); diff --git a/app/Http/Controllers/Api/MessageController.php b/app/Http/Controllers/Api/MessageController.php index 70e6b39..6030cf7 100644 --- a/app/Http/Controllers/Api/MessageController.php +++ b/app/Http/Controllers/Api/MessageController.php @@ -4,6 +4,7 @@ namespace App\Http\Controllers\Api; use App\Http\Controllers\Controller; use App\Models\Message; +use App\Models\MessageRead; use Illuminate\Http\Request; /** @@ -15,10 +16,16 @@ class MessageController extends Controller { public function index() { - $list = Message::where(['agent_id' => $this->agent_id, 'user_id' => $this->user_id]) - ->select('id', 'title', 'is_read', 'created_at') + $list = Message::where('agent_id', $this->agent_id) + ->whereIn('user_id', [$this->user_id, 0]) //0是所有人都接收的系统消息 + ->select('id', 'user_id', 'title', 'created_at') ->orderBy('id', 'DESC') ->simplePaginate(15); + if (!empty($list->items())) { + foreach ($list->items() as &$v) { + $v->is_read = (int)MessageRead::where(['id' => $v->id, 'user_id' => $v->user_id])->exists(); + } + } return $this->success($list); } @@ -26,8 +33,9 @@ class MessageController extends Controller { $id = (int)request()->input('id'); - $message = Message::query() - ->where(['agent_id' => $this->agent_id, 'user_id' => $this->user_id]) + //增加where条件是为了防止偷看别人的消息 + $message = Message::where(['agent_id' => $this->agent_id]) + ->whereIn('user_id', [$this->user_id, 0]) //0是所有人都接收的系统消息 ->find($id); if (!$message) { @@ -35,8 +43,7 @@ class MessageController extends Controller } //标记短消息为已读 - $message->is_read = 1; - $message->save(); + MessageRead::insertOrIgnore(['id' => $id, 'user_id' => $this->user_id]); return $this->success($message); } diff --git a/app/Models/MessageRead.php b/app/Models/MessageRead.php new file mode 100644 index 0000000..843bd76 --- /dev/null +++ b/app/Models/MessageRead.php @@ -0,0 +1,14 @@ + Date: Wed, 25 Aug 2021 14:14:52 +0800 Subject: [PATCH 22/42] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=B6=88=E6=81=AF?= =?UTF-8?q?=E5=B7=B2=E8=AF=BB=E7=9A=84=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- MySQL_change.sql | 4 ++++ .../Controllers/MessageController.php | 14 +++++++------- .../Controllers/Api/MessageController.php | 19 +++++++++++++------ app/Models/MessageRead.php | 14 ++++++++++++++ 4 files changed, 38 insertions(+), 13 deletions(-) create mode 100644 app/Models/MessageRead.php diff --git a/MySQL_change.sql b/MySQL_change.sql index ab1d0bb..0a3a808 100644 --- a/MySQL_change.sql +++ b/MySQL_change.sql @@ -148,3 +148,7 @@ ALTER TABLE `agent_products` # 0:24 ‎2021/‎08/‎25 ALTER TABLE `specials` DROP COLUMN `picture_ad`; + +# 14:15 2021/8/25 +ALTER TABLE `messages` + DROP COLUMN `is_read`; diff --git a/app/AdminAgent/Controllers/MessageController.php b/app/AdminAgent/Controllers/MessageController.php index 3813198..df3136b 100644 --- a/app/AdminAgent/Controllers/MessageController.php +++ b/app/AdminAgent/Controllers/MessageController.php @@ -26,7 +26,7 @@ class MessageController extends AdminController $grid->column('id')->sortable(); $grid->column('user_id'); $grid->column('title'); - $grid->column('is_read')->if(fn($v) => $this->user_id != 0)->bool()->else()->display('所有人接收'); +// $grid->column('is_read')->if(fn($v) => $this->user_id != 0)->bool()->else()->display('所有人接收'); $grid->column('created_at'); $grid->filter(function (Grid\Filter $filter) { @@ -58,13 +58,13 @@ class MessageController extends AdminController $show->field('user_id'); $show->field('title'); $show->field('content')->unescape(); - $show->field('is_read') + /*$show->field('is_read') ->as(function () { if ($this->user_id) { return $this->is_read ? '已读' : '未读'; } return '所有人接收'; - }); + });*/ $show->field('created_at'); }); } @@ -91,9 +91,9 @@ class MessageController extends AdminController $form->text('title')->required(); $form->editor('content'); - if ($form->isCreating()) { + /*if ($form->isCreating()) { $form->confirm('发布确认', '为了保证消费者利益,所有人接收的消息发布后禁止编辑,确定发布?'); - } + }*/ })->saving(function (Form $form) { //不允许修改非自己的数据 if ($form->isEditing() && $form->model()->agent_id != Admin::user()->id) { @@ -101,14 +101,14 @@ class MessageController extends AdminController } //消息已读后禁止编辑 - if ($form->isEditing()) { + /*if ($form->isEditing()) { if ($form->model()->user_id == 0) { return $form->response()->error('为了保证消费者利益,所有人接收的消息禁止编辑'); } if ($form->model()->is_read) { return $form->response()->error('消息已读,禁止修改'); } - } + }*/ //特殊字段处理 $form->hidden(['agent_id']); diff --git a/app/Http/Controllers/Api/MessageController.php b/app/Http/Controllers/Api/MessageController.php index 70e6b39..6030cf7 100644 --- a/app/Http/Controllers/Api/MessageController.php +++ b/app/Http/Controllers/Api/MessageController.php @@ -4,6 +4,7 @@ namespace App\Http\Controllers\Api; use App\Http\Controllers\Controller; use App\Models\Message; +use App\Models\MessageRead; use Illuminate\Http\Request; /** @@ -15,10 +16,16 @@ class MessageController extends Controller { public function index() { - $list = Message::where(['agent_id' => $this->agent_id, 'user_id' => $this->user_id]) - ->select('id', 'title', 'is_read', 'created_at') + $list = Message::where('agent_id', $this->agent_id) + ->whereIn('user_id', [$this->user_id, 0]) //0是所有人都接收的系统消息 + ->select('id', 'user_id', 'title', 'created_at') ->orderBy('id', 'DESC') ->simplePaginate(15); + if (!empty($list->items())) { + foreach ($list->items() as &$v) { + $v->is_read = (int)MessageRead::where(['id' => $v->id, 'user_id' => $v->user_id])->exists(); + } + } return $this->success($list); } @@ -26,8 +33,9 @@ class MessageController extends Controller { $id = (int)request()->input('id'); - $message = Message::query() - ->where(['agent_id' => $this->agent_id, 'user_id' => $this->user_id]) + //增加where条件是为了防止偷看别人的消息 + $message = Message::where(['agent_id' => $this->agent_id]) + ->whereIn('user_id', [$this->user_id, 0]) //0是所有人都接收的系统消息 ->find($id); if (!$message) { @@ -35,8 +43,7 @@ class MessageController extends Controller } //标记短消息为已读 - $message->is_read = 1; - $message->save(); + MessageRead::insertOrIgnore(['id' => $id, 'user_id' => $this->user_id]); return $this->success($message); } diff --git a/app/Models/MessageRead.php b/app/Models/MessageRead.php new file mode 100644 index 0000000..843bd76 --- /dev/null +++ b/app/Models/MessageRead.php @@ -0,0 +1,14 @@ + Date: Wed, 25 Aug 2021 14:31:43 +0800 Subject: [PATCH 23/42] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=8F=98=E9=87=8F?= =?UTF-8?q?=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/AdminAgent/Controllers/AgentProductController.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/AdminAgent/Controllers/AgentProductController.php b/app/AdminAgent/Controllers/AgentProductController.php index a835f50..0341e4e 100644 --- a/app/AdminAgent/Controllers/AgentProductController.php +++ b/app/AdminAgent/Controllers/AgentProductController.php @@ -39,9 +39,9 @@ class AgentProductController extends AdminController $grid->column('id')->sortable(); $grid->column('product.picture', '产品图片')->image('', 60, 60); $grid->column('product.title', '产品名称')->limit(15); - $grid->column('product_id', '产品详情') + $grid->column('product_ids', '产品详情') ->display('查看') - ->modal(function ($v) { + ->modal(function ($modal) { $titles = ['供应商', '产品标题', '产品图片', '原价', '现价', '销量', '库存']; $pic = isset($this->product->picture) ? "product->picture}\" style=\"max-width:80px;max-height:200px;cursor:pointer\" class=\"img img-thumbnail\">" @@ -69,7 +69,7 @@ class AgentProductController extends AdminController return join(',',array_intersect_key($channels, $data)); }) ->limit(10); - $grid->column('category.name', '分类')->label(); + $grid->column('category.name', '分类'); $grid->column('status') ->using(ProductStatus::array()) ->dot([ From e4bf808abc2a69d6545c7ba1d7f3db5e5e26276d Mon Sep 17 00:00:00 2001 From: liapples Date: Thu, 26 Aug 2021 11:17:47 +0800 Subject: [PATCH 24/42] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BB=A3=E7=90=86?= =?UTF-8?q?=E5=95=86=E4=BA=A7=E5=93=81=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- MySQL_change.sql | 25 +++ app/Admin/Controllers/SupplierController.php | 10 ++ .../Controllers/AdvertisingController.php | 3 +- .../Controllers/AgentProductController.php | 160 ++++++++++++------ .../Controllers/SpecialController.php | 21 +-- app/AdminAgent/Controllers/UserController.php | 2 +- .../Renderable/SelectAgentProduct.php | 16 +- app/AdminAgent/routes.php | 1 + .../Api/AgentProductController.php | 22 ++- .../Controllers/Api/ChannelController.php | 5 +- app/Http/Controllers/Api/IndexController.php | 10 +- app/Http/Controllers/Api/LoginController.php | 3 +- app/Http/Controllers/Api/OrderController.php | 27 ++- .../Controllers/Api/SpecialController.php | 9 +- .../Controllers/Api/UserFavController.php | 17 +- app/Models/AgentProduct.php | 29 +++- app/Models/Product.php | 9 +- ready.md | 64 +++++++ resources/lang/zh_CN/agent-product.php | 6 + 19 files changed, 315 insertions(+), 124 deletions(-) diff --git a/MySQL_change.sql b/MySQL_change.sql index 0a3a808..85f0d54 100644 --- a/MySQL_change.sql +++ b/MySQL_change.sql @@ -152,3 +152,28 @@ ALTER TABLE `specials` # 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`; diff --git a/app/Admin/Controllers/SupplierController.php b/app/Admin/Controllers/SupplierController.php index ae3e08f..a0cb945 100644 --- a/app/Admin/Controllers/SupplierController.php +++ b/app/Admin/Controllers/SupplierController.php @@ -4,7 +4,9 @@ namespace App\Admin\Controllers; use App\Admin\Extensions\Grid\AuditSupplier; use App\Admin\Repositories\Supplier; +use App\Common\ProductStatus; use App\Common\UserStatus; +use App\Models\Product; use Dcat\Admin\Form; use Dcat\Admin\Grid; use Dcat\Admin\Show; @@ -116,6 +118,7 @@ class SupplierController extends AdminController $form->select('status', '状态') ->options(UserStatus::array()) ->default(UserStatus::NORMAL) + ->help('如果禁用供应商将同时下架供应商的所有产品,需要供应商手动上架后才能销售,请谨慎!') ->required(); $form->text('company_name'); $form->image('logo'); @@ -123,6 +126,8 @@ class SupplierController extends AdminController $form->image('license_pic'); $form->text('director'); $form->mobile('contact_phone'); + })->editing(function (Form $form) { + $form->responseValidationMessages('111111111111111111111', 'title格式错误'); })->saving(function (Form $form) { //判断账号是否唯一 if ($form->isCreating()) { @@ -142,6 +147,11 @@ class SupplierController extends AdminController $form->$k = ''; } } + })->saved(function (Form $form) { + //禁用供应商将下架所有供应商的产品 + if ($form->status == UserStatus::DISABLED) { + Product::where('supplier_id', $form->getKey())->update(['status' => ProductStatus::SOLD_OUT]); + } }); } } diff --git a/app/AdminAgent/Controllers/AdvertisingController.php b/app/AdminAgent/Controllers/AdvertisingController.php index b6b504a..b5286d9 100644 --- a/app/AdminAgent/Controllers/AdvertisingController.php +++ b/app/AdminAgent/Controllers/AdvertisingController.php @@ -19,7 +19,8 @@ class AdvertisingController extends AdminController protected function grid() { return Grid::make(new Advertising(), function (Grid $grid) { - $grid->model()->where('agent_id', Admin::user()->id)->orderBy('sort')->orderBy('id', 'DESC'); + $grid->model()->where('agent_id', Admin::user()->id) + ->orderBy('display', 'desc')->orderBy('sort')->orderBy('id', 'DESC'); $grid->column('id')->sortable(); $grid->column('display')->using(admin_trans('advertising.options.display')); diff --git a/app/AdminAgent/Controllers/AgentProductController.php b/app/AdminAgent/Controllers/AgentProductController.php index 0341e4e..854a69a 100644 --- a/app/AdminAgent/Controllers/AgentProductController.php +++ b/app/AdminAgent/Controllers/AgentProductController.php @@ -21,7 +21,6 @@ use Dcat\Admin\Grid; use Dcat\Admin\Show; use Dcat\Admin\Http\Controllers\AdminController; use Dcat\Admin\Widgets\Alert; -use Dcat\Admin\Widgets\Table; class AgentProductController extends AdminController { @@ -37,9 +36,22 @@ class AgentProductController extends AdminController $grid->model()->where('agent_id', $agent_id); $grid->column('id')->sortable(); - $grid->column('product.picture', '产品图片')->image('', 60, 60); - $grid->column('product.title', '产品名称')->limit(15); - $grid->column('product_ids', '产品详情') + $grid->column('picture', '产品图片')->image('', 60, 60); + $grid->column('title', '产品名称')->limit(15); + $grid->column('price'); + $grid->column('original_price'); + $grid->column('sale'); + $grid->column('stock'); + + $channels = Channel::where('agent_id', $agent_id)->pluck('name', 'id')->toArray(); + $grid->column('channel_id', '频道') + ->display(function ($modal) use ($channels) { + $data = array_flip(explode(',', $this->channel_id)); + return join(',',array_intersect_key($channels, $data)); + }) + ->limit(10); + $grid->column('category.name', '分类'); + /*$grid->column('product_ids', '产品详情') ->display('查看') ->modal(function ($modal) { $titles = ['供应商', '产品标题', '产品图片', '原价', '现价', '销量', '库存']; @@ -56,20 +68,8 @@ class AgentProductController extends AdminController $this->product->stock ?? '', ]]; return Table::make($titles, $data); - }); - $grid->column('price'); - $grid->column('original_price'); - $grid->column('sale'); - $grid->column('stock'); + });*/ - $channels = Channel::where('agent_id', $agent_id)->pluck('name', 'id')->toArray(); - $grid->column('channel_id', '频道') - ->display(function ($modal) use ($channels) { - $data = array_flip(explode(',', $this->channel_id)); - return join(',',array_intersect_key($channels, $data)); - }) - ->limit(10); - $grid->column('category.name', '分类'); $grid->column('status') ->using(ProductStatus::array()) ->dot([ @@ -78,7 +78,7 @@ class AgentProductController extends AdminController ProductStatus::REFUSE => 'danger', ProductStatus::SOLD_OUT => 'warning', ], 'primary'); - $grid->column('created_at'); + $grid->column('is_rec')->switch()->help('推荐后将在“我的”页面下方显示'); $grid->column('updated_at'); $grid->filter(function (Grid\Filter $filter) { @@ -125,6 +125,11 @@ class AgentProductController extends AdminController if (Admin::user()->type == AgentType::CLUSTER) { $show->field('guide.name', '地接'); } + $show->field('is_rec')->using(['未推荐', '已推荐']); + $show->field('title'); + $show->field('pictures')->image('', 80, 80); + $show->field('know')->unescape(); + $show->field('content')->unescape(); $show->field('created_at'); $show->field('updated_at'); @@ -150,7 +155,7 @@ class AgentProductController extends AdminController */ protected function form() { - return Form::make(new AgentProduct(['product:id,title']), function (Form $form) { + return Form::make(new AgentProduct(), function (Form $form) { $agent_id = Admin::user()->id; //不允许查看非自己的数据 @@ -159,25 +164,36 @@ class AgentProductController extends AdminController } $form->display('id'); - $form->hidden('product_id'); - $form->selectTable('product_id', '封面产品') - ->help('产品列表显示的是该产品的标题和图片') - ->title('选择产品') - ->dialogWidth('80%;min-width:825px;') - ->from(SelectProduct::make()) - ->model(Product::class) - ->required(); - $form->multipleSelectTable('product_ids', '选择产品') - ->help('可单选或多选组合销售') - ->title('选择产品') - ->dialogWidth('80%;min-width:825px;') - ->from(SelectProduct::make()) - ->model(Product::class) - ->required(); + $form->radio('type') + ->options(['单品销售', '组合销售']) + ->default(0) + ->when(0, function (Form $form) { + /** 单品销售 **/ + $form->selectTable('product_id', '选择产品') + ->help('产品列表显示的是该产品的标题和图片') + ->title('选择产品') + ->dialogWidth('80%;min-width:825px;') + ->from(SelectProduct::make()) + ->model(Product::class); + })->when(1, function (Form $form) { + /** 组合销售 **/ + $form->multipleSelectTable('product_ids', '选择产品') + ->help('可单选或多选组合销售') + ->title('选择产品') + ->dialogWidth('80%;min-width:825px;') + ->from(SelectProduct::make()) + ->model(Product::class); + + /** 自定义内容 **/ + $form->text('title'); + $form->multipleImage('pictures'); + $form->editor('know'); + $form->editor('content'); + }); $form->text('price')->required(); $form->text('original_price')->required(); $form->text('sale')->default(0); - $form->text('stock')->default(9999); + $form->text('stock')->default(8888); $options = Channel::selectOptions(fn($query) => $query->where('agent_id', $agent_id)); $form->multipleSelect('channel_id')->options(array_slice($options, 1)); @@ -194,6 +210,7 @@ class AgentProductController extends AdminController ProductStatus::SOLD_OUT => '下架', ]) ->required(); + $form->switch('is_rec')->help('推荐后将在“我的”页面下方显示'); $form->selectTable('verifier') ->title('选择核销人员') ->dialogWidth('50%;min-width:600px;') //不起作用 @@ -216,26 +233,69 @@ class AgentProductController extends AdminController return $form->response()->error('数据不存在'); } - $agent_id = Admin::user()->id; + //推荐按钮开关 + if ($form->product_id === null && $form->product_ids === null && $form->is_rec !== null) { + $form->model()->is_rec = $form->is_rec ? 1 : 0; + $form->model()->save(); + return $form->response()->success('更新成功'); + } - $product_ids = explode(',', $form->product_ids); - if (empty($product_ids)) { - return $form->response()->error('请选择产品'); + //单品销售 + if ($form->type == 0) { + $form->product_id = (int)$form->product_id; + if (!$form->product_id) { + return $form->response()->error('请选择产品'); + } + $form->product_ids = $form->product_id; + + //将供应商产品写入title,pictures,know,content + $product = Product::find($form->product_id); + if ($product->status != ProductStatus::ON_SALE) { + return $form->response()->error('产品ID '. $form->product_id .' 已下架'); + } else if ($product->stock < $form->stock) { + return $form->response()->error('库存不足,你设置的库存应小于等于' . $form->stock); + } + $form->title = $product->title; + $form->pictures = $product->pictures; + $form->know = $product->know; + $form->content = $product->content; } + //组合销售 + else if ($form->type == 1) { + if (!$form->product_ids) { + return $form->response()->error('请选择产品'); + } + $product_ids = explode(',', $form->product_ids); - //判断供应商产品是否存在或下架 - $not_in_id = Product::query() - ->whereIn('id', $product_ids) - ->where(function ($query) use ($form) { - $query->where('status', '<>', ProductStatus::ON_SALE) - ->orWhere('stock', '<', $form->stock); - }) - ->pluck('id') - ->toArray(); - if ($not_in_id) { - return $form->response()->error('产品ID '. join(',', $not_in_id) .' 库存小于你设置的库存' . $form->stock . ',或不存在、已下架'); + if (count($product_ids) < 2) { + return $form->response()->error('组合销售必须选择两个以上产品,否则请选择单品销售'); + } + $form->product_id = $product_ids[0]; + + $required_fields = ['title', 'pictures', 'know', 'content']; + foreach ($required_fields as $field) { + if (!$form->$field) { + return $form->response()->error('内容输入不完整,标题、产品图片、旅游须知、产品详情必填'); + } + } + + //判断供应商产品是否存在或下架 + $not_in_id = Product::query() + ->whereIn('id', $product_ids) + ->where(function ($query) use ($form) { + $query->where('status', '<>', ProductStatus::ON_SALE) + ->orWhere('stock', '<', $form->stock); + }) + ->pluck('id') + ->toArray(); + if ($not_in_id) { + return $form->response()->error('产品ID ' . join(',', $not_in_id) . ' 库存小于你设置的库存' . $form->stock . ',或不存在、已下架'); + } + } else { + return $form->response()->error('不存在此销售方式'); } + $agent_id = Admin::user()->id; //处理特殊字段 $form->hidden(['agent_id', 'status']); //表单没有的字段,必须加这句才能够重写 $form->agent_id = $agent_id; diff --git a/app/AdminAgent/Controllers/SpecialController.php b/app/AdminAgent/Controllers/SpecialController.php index 68978ec..8894a9c 100644 --- a/app/AdminAgent/Controllers/SpecialController.php +++ b/app/AdminAgent/Controllers/SpecialController.php @@ -31,16 +31,15 @@ class SpecialController extends AdminController $grid->column('agent_product_id', '专题产品') ->display('查看') ->modal(function ($modal) use ($grid) { - $data = AgentProduct::with('product:id,title,pictures') - ->whereIn('id', $this->agent_product_id) - ->get(['id', 'product_id', 'sale', 'stock']); + $data = AgentProduct::whereIn('id', $this->agent_product_id) + ->get(['id', 'product_id', 'sale', 'stock', 'title', 'pictures']); $result = []; $prefix = Storage::disk('public')->url(''); foreach ($data as $k => $v) { $result[] = [ $v->id, - $v->product->title, - '', + $v->title, + '', $v->sale, $v->stock, ]; @@ -78,10 +77,9 @@ class SpecialController extends AdminController $show->field('agent_product_id', '产品') ->unescape() ->as(function ($v) { - $data = AgentProduct::with('product:id,title') - ->whereIn('id', $v) + $data = AgentProduct::whereIn('id', $v) ->orderBy('id')->get(['id', 'product_id']); - return join("
", $data->map(fn($v) => $v->product->title)->toArray()); + return join("
", $data->map(fn($v) => $v->title)->toArray()); }); $show->field('created_at'); $show->field('updated_at'); @@ -111,17 +109,16 @@ class SpecialController extends AdminController ->from(SelectAgentProduct::make()) ->options(function ($v) { if (!$v) return []; - $agent_product = AgentProduct::with('product:id,title') - ->select(['id', 'product_id']) + $agent_product = AgentProduct::select(['id', 'product_id', 'title']) ->whereIn('id', $v) ->orderBy('id')->get(); $result = []; foreach ($agent_product as $v) { - $result[$v->id] = $v->product->title ?? ''; + $result[$v->id] = $v->title ?? ''; } return $result; }) - ->pluck('product.title') + ->pluck('title', 'id') ->value(join(',', $form->model()->agent_product_id ?? [])); })->saving(function (Form $form) { //不允许修改非自己的数据 diff --git a/app/AdminAgent/Controllers/UserController.php b/app/AdminAgent/Controllers/UserController.php index ac410f0..e77faa9 100644 --- a/app/AdminAgent/Controllers/UserController.php +++ b/app/AdminAgent/Controllers/UserController.php @@ -37,7 +37,7 @@ class UserController extends AdminController $grid->column('avatar')->image(60, 60); $grid->column('mobile'); $grid->column('nickname'); - $grid->column('status')->switch(); + $grid->column('status')->switch()->help('禁用后用户将无法登录'); $grid->column('is_verify')->switch(); $grid->column('created_at'); diff --git a/app/AdminAgent/Renderable/SelectAgentProduct.php b/app/AdminAgent/Renderable/SelectAgentProduct.php index b4d480d..527910c 100644 --- a/app/AdminAgent/Renderable/SelectAgentProduct.php +++ b/app/AdminAgent/Renderable/SelectAgentProduct.php @@ -8,7 +8,7 @@ use Dcat\Admin\Grid; use Dcat\Admin\Grid\LazyRenderable; /** - * 选择产品 + * 选择代理商在售产品 * Class SelectProduct * @package App\AdminAgent\Renderable */ @@ -19,19 +19,18 @@ class SelectAgentProduct extends LazyRenderable // 获取外部传递的参数 // $id = $this->id; Admin::translation('agent-product'); - return Grid::make(new AgentProduct(['product.supplier:id,name']), function (Grid $grid) { + return Grid::make(new AgentProduct(), function (Grid $grid) { $grid->disableActions(); $grid->disableBatchDelete(); $grid->disableBatchActions(); $grid->model()->where('stock', '>', 0) ->where(['agent_id' => Admin::user()->id, 'status' => ProductStatus::ON_SALE]); - $grid->quickSearch(['product.title', 'product.supplier.name'])->placeholder('搜索产品名称、供应商'); + $grid->quickSearch(['title'])->placeholder('搜索产品名称'); $grid->column('id'); - $grid->column('product.supplier.name'); - $grid->column('product.title'); - $grid->column('product.picture')->image(60, 60); + $grid->column('title'); + $grid->column('picture')->image(60, 60); $grid->column('sale'); $grid->column('stock'); $grid->column('updated_at'); @@ -39,8 +38,9 @@ class SelectAgentProduct extends LazyRenderable $grid->paginate(15); $grid->filter(function (Grid\Filter $filter) { - $filter->like('product.title')->width(4); - $filter->like('product.supplier.name', '供应商名称')->width(4); + $filter->panel(); + + $filter->like('title')->width(4); }); }); } diff --git a/app/AdminAgent/routes.php b/app/AdminAgent/routes.php index 8f26883..34318d8 100644 --- a/app/AdminAgent/routes.php +++ b/app/AdminAgent/routes.php @@ -28,4 +28,5 @@ Route::group([ $router->resource('agent_info', 'AgentInfoController'); $router->resource('supplier/list', 'SupplierController'); $router->resource('article/list', 'ArticleController'); + $router->resource('setting', 'SettingController'); }); diff --git a/app/Http/Controllers/Api/AgentProductController.php b/app/Http/Controllers/Api/AgentProductController.php index 662f341..40fdc4a 100644 --- a/app/Http/Controllers/Api/AgentProductController.php +++ b/app/Http/Controllers/Api/AgentProductController.php @@ -25,7 +25,7 @@ class AgentProductController extends Controller $where['agent_id'] = $this->agent_id; - $list = AgentProduct::list()->where($where)->simplePaginate(); + $list = AgentProduct::list()->where($where)->orderBy('id', 'DESC')->simplePaginate(); $list = $this->paginatePicAddHost($list); $list = $this->insertAd($list); @@ -39,7 +39,6 @@ class AgentProductController extends Controller // TODO 优惠券查询待优化 $agent_product = AgentProduct::query() - ->with('product:id,title,pictures,know,stock,content') ->with('coupon:tag,agent_product_id') ->with('fav:agent_product_id') ->whereHas('product', function ($query) { @@ -53,9 +52,10 @@ class AgentProductController extends Controller } $prefix = Storage::disk('public')->url(''); - $agent_product->product->pictures = array_map(fn($item) => ($prefix . $item), $agent_product->product->pictures); + $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 ($agent_product->price < $agent_product->original_price) { $agent_product->cost = round($agent_product->price / $agent_product->original_price * 10, 1); @@ -70,7 +70,7 @@ class AgentProductController extends Controller // 猜你喜欢 public function guessLike() { - $list = AgentProduct::list()->where('agent_id', $this->agent_id)->simplePaginate(); + $list = AgentProduct::list()->where('agent_id', $this->agent_id)->orderBy('id', 'DESC')->simplePaginate(); $list = $this->paginatePicAddHost($list); $list = $list->toArray(); if (!empty($list['data']) && is_array($list['data'])) { @@ -84,14 +84,18 @@ class AgentProductController extends Controller //【我的】页面下方推荐 public function recommendList() { - //TODO 推荐数据暂时使用产品列表,后期需要通过后台设置获取或根据用户购买过的关键词获取 - return $this->index(); + $list = AgentProduct::list()->where(['agent_id' => $this->agent_id, 'is_rec' => 1]) + ->orderBy('id', 'DESC')->simplePaginate(); + $list = $this->paginatePicAddHost($list); + $list = $this->insertAd($list); + + return $this->success($list); } //人气爆款列表,销量排序 public function hotList() { - $list = AgentProduct::list()->where('agent_id', $this->agent_id)->simplePaginate(); + $list = AgentProduct::list()->where('agent_id', $this->agent_id)->orderBy('id', 'DESC')->simplePaginate(); $list = $this->paginatePicAddHost($list); $list = $this->insertAd($list); @@ -104,9 +108,9 @@ class AgentProductController extends Controller if (!$list->isEmpty()) { $prefix = Storage::disk('public')->url(''); foreach ($list->items() as $k=>&$v) { - $v->product->pictures = array_map(function($item) use ($prefix) { + $v->pictures = array_map(function($item) use ($prefix) { return strpos($item, $prefix) === false ? $prefix . $item : $item; - }, $v->product->pictures); + }, $v->pictures); } } return $list; diff --git a/app/Http/Controllers/Api/ChannelController.php b/app/Http/Controllers/Api/ChannelController.php index f653a67..0a36a2d 100644 --- a/app/Http/Controllers/Api/ChannelController.php +++ b/app/Http/Controllers/Api/ChannelController.php @@ -5,7 +5,6 @@ use App\Http\Controllers\Controller; use App\Models\AgentProduct; use App\Models\Channel; use App\Models\UserChannel; -use Illuminate\Support\Facades\DB; /** * 频道列表 @@ -38,10 +37,8 @@ class ChannelController extends Controller { $channel_id = (int)request()->input('channel_id'); - $list = AgentProduct::where('agent_id', $this->agent_id) + $list = AgentProduct::list()->where('agent_id', $this->agent_id) ->whereRaw("FIND_IN_SET($channel_id, `channel_id`)") - ->with('product:id,title,pictures') - ->select('id', 'sale', 'product_id', 'price', 'original_price') ->orderBy('id', 'DESC') ->simplePaginate(); return $this->success($list); diff --git a/app/Http/Controllers/Api/IndexController.php b/app/Http/Controllers/Api/IndexController.php index f7e5212..567bd90 100644 --- a/app/Http/Controllers/Api/IndexController.php +++ b/app/Http/Controllers/Api/IndexController.php @@ -82,17 +82,15 @@ class IndexController extends Controller } # 人气爆款 - $hots = AgentProduct::with('product:id,title,pictures') //必须查询ID才能正常查询 - ->where('agent_id', $this->agent_id) - ->select('id', 'sale', 'product_id', 'price', 'original_price') //必须查询product_id才能with + $hots = AgentProduct::list()->where('agent_id', $this->agent_id) ->orderBy('sale', 'desc')->orderBy('id', 'desc') ->limit(6)->get(); if (!$hots->isEmpty()) { foreach ($hots as &$v) { - if (!empty($v->product->pictures) && is_array($v->product->pictures)) { - $v->product->pictures = array_map(function($item) use ($img_prefix) { + if (!empty($v->pictures) && is_array($v->pictures)) { + $v->pictures = array_map(function($item) use ($img_prefix) { return strpos($item, $img_prefix) === false ? $img_prefix . $item : $item; - }, $v->product->pictures); + }, $v->pictures); } } } diff --git a/app/Http/Controllers/Api/LoginController.php b/app/Http/Controllers/Api/LoginController.php index f31892b..dd98651 100644 --- a/app/Http/Controllers/Api/LoginController.php +++ b/app/Http/Controllers/Api/LoginController.php @@ -67,8 +67,7 @@ class LoginController extends Controller //TODO 存入初始化数据 user_channel - // TODO 用于测试 - $token_key = md5($userModel->id); + $token_key = md5($userModel->id . env('APP_KEY')); Cache::put($token_key, $userModel->id); // 测试代码结束 $userModel->token = $token_key; diff --git a/app/Http/Controllers/Api/OrderController.php b/app/Http/Controllers/Api/OrderController.php index 6aa66c5..fb00b89 100644 --- a/app/Http/Controllers/Api/OrderController.php +++ b/app/Http/Controllers/Api/OrderController.php @@ -46,8 +46,7 @@ class OrderController extends Controller $where['user_id'] = $this->user_id; $order_list = Order::where($where) - ->with('product:id,title,pictures') - ->select('id', 'agent_product_id', 'product_id', 'picture', 'price', 'num', 'status', 'created_at') + ->select('id', 'agent_product_id', 'product_id', 'title', 'picture', 'price', 'num', 'status', 'created_at') ->orderBy('id', 'DESC') ->simplePaginate(15) ->toArray(); @@ -61,14 +60,14 @@ class OrderController extends Controller $v['picture'] = $prefix . $v['picture']; } - if (strpos($v['product']['picture'], $prefix) === false) { - $v['product']['picture'] = $prefix . $v['product']['picture']; + if (strpos($v['picture'], $prefix) === false) { + $v['picture'] = $prefix . $v['picture']; } - if (!empty($v['product']['pictures']) && is_array($v['product']['pictures'])) { - $v['product']['pictures'] = array_map(function($item) use ($prefix) { + if (!empty($v['pictures']) && is_array($v['pictures'])) { + $v['pictures'] = array_map(function($item) use ($prefix) { return strpos($item, $prefix) === false ? $prefix . $item : $item; - }, $v['product']['pictures']); + }, $v['pictures']); } //10分钟内未付款订单提示付款 @@ -124,9 +123,10 @@ class OrderController extends Controller ->where('id', $formData['id']) ->with('coupon') ->with('product') + ->has('product') ->first(); if (!$ap || !$ap->product) { - $this->error('产品不存在'); + $this->error('产品不存在或已下架'); } if ($ap->stock < $formData['num'] || $ap->product->stock < $formData['num']) { $this->error('对不起,库存不足'); @@ -142,12 +142,9 @@ class OrderController extends Controller DB::beginTransaction(); try { $price = $this->calc($ap->price, $ap->coupon, $formData['num'], $formData['pay_type']); - $title = $ap->product->title; //产品标题 - //代理商产品表增加销量 - // $ap->increment('sale', $formData['num']); TODO 支付成功之后再增加销量 + $title = $ap->title; //产品标题 - //供应商产品表加销量、减库存 - // $ap->product->sale += $formData['num']; TODO 支付成功之后再增加销量 + //供应商产品表减库存 $ap->product->decrement('stock', $formData['num']); //代理商产品表减库存 @@ -163,7 +160,7 @@ class OrderController extends Controller 'name' => $formData['name'], 'mobile' => $formData['mobile'], 'title' => $title, - 'picture' => $ap->product->picture, + 'picture' => $ap->picture, 'agent_product_id' => $ap->id, 'product_id' => $ap->product_id, 'product_ids' => $ap->product->product_ids ?? $ap->product_id, @@ -250,7 +247,7 @@ class OrderController extends Controller } $ap = AgentProduct::query() - ->with('product:id,title,pictures') + ->has('product') ->with('coupon:agent_product_id,type,detail,agent_id,tag,start_at,end_at') ->find($formData['id'], ['id', 'price', 'original_price', 'product_id']); diff --git a/app/Http/Controllers/Api/SpecialController.php b/app/Http/Controllers/Api/SpecialController.php index 73e0def..638e828 100644 --- a/app/Http/Controllers/Api/SpecialController.php +++ b/app/Http/Controllers/Api/SpecialController.php @@ -4,6 +4,7 @@ namespace App\Http\Controllers\Api; use App\Http\Controllers\Controller; use App\Models\AgentProduct; use App\Models\Special; +use Illuminate\Support\Facades\Storage; class SpecialController extends Controller { @@ -11,14 +12,20 @@ class SpecialController extends Controller public function show() { $id = (int)request()->input('id'); + $prefix = Storage::disk('public')->url(''); + $detail = Special::query() ->select(['id', 'picture', 'updated_at', 'agent_product_id']) ->find($id); + $detail->picture = array_map(fn($v) => $prefix . $v, $detail->picture); $detail->product = AgentProduct::list() ->where('agent_id', $this->agent_id) ->whereIn('id', $detail->agent_product_id) - ->limit(6)->get(); + ->orderBy('id', 'DESC')->limit(6)->get(); + foreach ($detail->product as $k => &$v) { + $v->pictures = array_map(fn($item) => $prefix . $item, $v->pictures); + } unset($detail->agent_product_id); return $this->success($detail); diff --git a/app/Http/Controllers/Api/UserFavController.php b/app/Http/Controllers/Api/UserFavController.php index b900971..c83f33f 100644 --- a/app/Http/Controllers/Api/UserFavController.php +++ b/app/Http/Controllers/Api/UserFavController.php @@ -18,8 +18,7 @@ class UserFavController extends Controller { $list = UserFav::query() ->with([ - 'agentProduct:id,price,original_price', - 'product:id,title,pictures', + 'agentProduct:id,price,original_price,title,pictures', ]) ->where('user_id', $this->user_id) ->select('id', 'agent_product_id', 'product_id', 'created_at') @@ -30,16 +29,14 @@ class UserFavController extends Controller $prefix = Storage::disk('public')->url(''); if ($list['data']) { foreach ($list['data'] as &$v) { - if (!empty($v['product']['pictures'])) { - //单图 - if (strpos($v['product']['picture'], $prefix) === false) { - $v['product']['picture'] = $prefix . $v['product']['picture']; - } - + if (!empty($v['agent_product']['pictures'])) { //多图 - $v['product']['pictures'] = array_map(function ($v) use ($prefix) { + $v['agent_product']['pictures'] = array_map(function ($v) use ($prefix) { return strpos($v, $prefix) === false ? $prefix . $v : $v; - }, $v['product']['pictures']); + }, $v['agent_product']['pictures']); + + //单图 + $v['agent_product']['picture'] = $prefix . $v['agent_product']['picture']; } } } diff --git a/app/Models/AgentProduct.php b/app/Models/AgentProduct.php index 6138030..5957e13 100644 --- a/app/Models/AgentProduct.php +++ b/app/Models/AgentProduct.php @@ -59,6 +59,13 @@ class AgentProduct extends BaseModel } } + public function setPicturesAttribute($value) + { + if (is_array($value)) { + $this->attributes['pictures'] = json_encode(array_filter($value)); + } + } + public function setProductIdsAttribute($value) { if (is_array($value)) { @@ -66,15 +73,29 @@ class AgentProduct extends BaseModel } } + // 获取所有产品图片 + public function getPicturesAttribute($value): array + { + if (is_string($value)) { + $value = $value ? json_decode($value, true) : []; + } + $this->append('picture'); + return $value ?? []; + } + + // 获取第一张产品图片 + public function getPictureAttribute($value): string + { + return $this->pictures[0] ?? ''; + } + //列表查询统一查询条件 public function scopeList($query) { - return $query->with('product:id,title,pictures') - ->whereHas('product', function ($query) { + return $query->whereHas('product', function ($query) { return $query->where('status', ProductStatus::ON_SALE)->where('stock', '>', 0); }) ->where('status', ProductStatus::ON_SALE)->where('stock', '>', 0) - ->select('id', 'sale', 'product_id', 'price', 'original_price') - ->orderBy('id', 'DESC'); + ->select('id', 'sale', 'product_id', 'price', 'original_price', 'title', 'pictures'); } } diff --git a/app/Models/Product.php b/app/Models/Product.php index b4e6a8d..9210efe 100644 --- a/app/Models/Product.php +++ b/app/Models/Product.php @@ -32,7 +32,14 @@ class Product extends BaseModel return $this->pictures[0] ?? ''; } - public function supplier() + public function setPicturesAttribute($value) + { + if (is_array($value)) { + $this->attributes['pictures'] = json_encode(array_filter($value)); + } + } + + public function supplier() { return $this->belongsTo(Supplier::class); } diff --git a/ready.md b/ready.md index d32c95f..a6887e5 100644 --- a/ready.md +++ b/ready.md @@ -6,8 +6,72 @@ 5、关于我们、注册协议、购买协议等信息; ```sql +# 11:12 2021/8/26 +TRUNCATE `advertisings`; +TRUNCATE `agent_products`; +TRUNCATE `agent_product_items`; +TRUNCATE `articles`; +TRUNCATE `coupons`; +TRUNCATE `messages`; +TRUNCATE `message_reads`; +TRUNCATE `notices`; TRUNCATE `orders`; +TRUNCATE `products`; +TRUNCATE `specials`; TRUNCATE `users`; +TRUNCATE `user_channels`; TRUNCATE `user_favs`; TRUNCATE `user_money_logs`; +TRUNCATE `agents`; +TRUNCATE `suppliers`; +TRUNCATE `guides`; + +INSERT INTO `categories` (`id`, `agent_id`, `pid`, `name`, `sort`, `template`, `deleted_at`) VALUES (1, 0, 0, '酒店', 255, '', NULL); +INSERT INTO `categories` (`id`, `agent_id`, `pid`, `name`, `sort`, `template`, `deleted_at`) VALUES (2, 0, 0, '景点', 255, '', NULL); +INSERT INTO `categories` (`id`, `agent_id`, `pid`, `name`, `sort`, `template`, `deleted_at`) VALUES (3, 0, 0, '国内游', 255, '', NULL); +INSERT INTO `categories` (`id`, `agent_id`, `pid`, `name`, `sort`, `template`, `deleted_at`) VALUES (4, 0, 0, '国际游', 255, '', NULL); +INSERT INTO `categories` (`id`, `agent_id`, `pid`, `name`, `sort`, `template`, `deleted_at`) VALUES (5, 0, 0, '跟团游', 255, '', NULL); + +INSERT INTO `channels` (`id`, `agent_id`, `pid`, `name`, `icon`, `sort`, `deleted_at`) VALUES (1, 0, 0, '机票酒店', '/static/images/icon.jpg', 255, NULL); +INSERT INTO `channels` (`id`, `agent_id`, `pid`, `name`, `icon`, `sort`, `deleted_at`) VALUES (2, 0, 0, '旅游度假', '/static/images/icon.jpg', 255, NULL); +INSERT INTO `channels` (`id`, `agent_id`, `pid`, `name`, `icon`, `sort`, `deleted_at`) VALUES (3, 0, 0, '接送服务', '/static/images/icon.jpg', 255, NULL); +INSERT INTO `channels` (`id`, `agent_id`, `pid`, `name`, `icon`, `sort`, `deleted_at`) VALUES (4, 0, 0, '其它精选', '/static/images/icon.jpg', 255, NULL); +INSERT INTO `channels` (`id`, `agent_id`, `pid`, `name`, `icon`, `sort`, `deleted_at`) VALUES (5, 0, 0, '攻略社区', '/static/images/icon.jpg', 255, NULL); +INSERT INTO `channels` (`id`, `agent_id`, `pid`, `name`, `icon`, `sort`, `deleted_at`) VALUES (6, 0, 1, '多地比价', '/static/images/icon.jpg', 255, NULL); +INSERT INTO `channels` (`id`, `agent_id`, `pid`, `name`, `icon`, `sort`, `deleted_at`) VALUES (7, 0, 1, '降价提醒', '/static/images/icon.jpg', 255, NULL); +INSERT INTO `channels` (`id`, `agent_id`, `pid`, `name`, `icon`, `sort`, `deleted_at`) VALUES (8, 0, 1, '团体机票', '/static/images/icon.jpg', 255, NULL); +INSERT INTO `channels` (`id`, `agent_id`, `pid`, `name`, `icon`, `sort`, `deleted_at`) VALUES (9, 0, 2, '冲浪', '/static/images/icon.jpg', 255, NULL); +INSERT INTO `channels` (`id`, `agent_id`, `pid`, `name`, `icon`, `sort`, `deleted_at`) VALUES (10, 0, 2, '热气球', '/static/images/icon.jpg', 255, NULL); +INSERT INTO `channels` (`id`, `agent_id`, `pid`, `name`, `icon`, `sort`, `deleted_at`) VALUES (11, 0, 2, '蹦极', '/static/images/icon.jpg', 255, NULL); +INSERT INTO `channels` (`id`, `agent_id`, `pid`, `name`, `icon`, `sort`, `deleted_at`) VALUES (12, 0, 2, '滑翔伞', '/static/images/icon.jpg', 255, NULL); +INSERT INTO `channels` (`id`, `agent_id`, `pid`, `name`, `icon`, `sort`, `deleted_at`) VALUES (13, 0, 2, '主题玩法', '/static/images/icon.jpg', 255, NULL); +INSERT INTO `channels` (`id`, `agent_id`, `pid`, `name`, `icon`, `sort`, `deleted_at`) VALUES (14, 0, 2, '取景地', '/static/images/icon.jpg', 255, NULL); +INSERT INTO `channels` (`id`, `agent_id`, `pid`, `name`, `icon`, `sort`, `deleted_at`) VALUES (15, 0, 2, '周边游', '/static/images/icon.jpg', 255, NULL); +INSERT INTO `channels` (`id`, `agent_id`, `pid`, `name`, `icon`, `sort`, `deleted_at`) VALUES (16, 0, 2, '国内游', '/static/images/icon.jpg', 255, NULL); +INSERT INTO `channels` (`id`, `agent_id`, `pid`, `name`, `icon`, `sort`, `deleted_at`) VALUES (17, 0, 2, '尾单特卖', '/static/images/icon.jpg', 255, NULL); +INSERT INTO `channels` (`id`, `agent_id`, `pid`, `name`, `icon`, `sort`, `deleted_at`) VALUES (18, 0, 2, '邮轮', '/static/images/icon.jpg', 255, NULL); +INSERT INTO `channels` (`id`, `agent_id`, `pid`, `name`, `icon`, `sort`, `deleted_at`) VALUES (19, 0, 2, '汽车·船票', '/static/images/icon.jpg', 255, NULL); +INSERT INTO `channels` (`id`, `agent_id`, `pid`, `name`, `icon`, `sort`, `deleted_at`) VALUES (20, 0, 2, '定制游', '/static/images/icon.jpg', 255, NULL); +INSERT INTO `channels` (`id`, `agent_id`, `pid`, `name`, `icon`, `sort`, `deleted_at`) VALUES (21, 0, 2, '家庭游', '/static/images/icon.jpg', 255, NULL); +INSERT INTO `channels` (`id`, `agent_id`, `pid`, `name`, `icon`, `sort`, `deleted_at`) VALUES (22, 0, 2, '签证·上网', '/static/images/icon.jpg', 255, NULL); +INSERT INTO `channels` (`id`, `agent_id`, `pid`, `name`, `icon`, `sort`, `deleted_at`) VALUES (23, 0, 2, '自驾·租车', '/static/images/icon.jpg', 255, NULL); +INSERT INTO `channels` (`id`, `agent_id`, `pid`, `name`, `icon`, `sort`, `deleted_at`) VALUES (24, 0, 2, '旅游·团购', '/static/images/icon.jpg', 255, NULL); +INSERT INTO `channels` (`id`, `agent_id`, `pid`, `name`, `icon`, `sort`, `deleted_at`) VALUES (25, 0, 3, '接送机', '/static/images/icon.jpg', 255, NULL); +INSERT INTO `channels` (`id`, `agent_id`, `pid`, `name`, `icon`, `sort`, `deleted_at`) VALUES (26, 0, 3, '接送火车', '/static/images/icon.jpg', 255, NULL); +INSERT INTO `channels` (`id`, `agent_id`, `pid`, `name`, `icon`, `sort`, `deleted_at`) VALUES (27, 0, 3, '打车', '/static/images/icon.jpg', 255, NULL); +INSERT INTO `channels` (`id`, `agent_id`, `pid`, `name`, `icon`, `sort`, `deleted_at`) VALUES (28, 0, 3, '按天包车', '/static/images/icon.jpg', 255, NULL); +INSERT INTO `channels` (`id`, `agent_id`, `pid`, `name`, `icon`, `sort`, `deleted_at`) VALUES (29, 0, 3, '定制包车', '/static/images/icon.jpg', 255, NULL); +INSERT INTO `channels` (`id`, `agent_id`, `pid`, `name`, `icon`, `sort`, `deleted_at`) VALUES (30, 0, 3, '国内租车', '/static/images/icon.jpg', 255, NULL); +INSERT INTO `channels` (`id`, `agent_id`, `pid`, `name`, `icon`, `sort`, `deleted_at`) VALUES (31, 0, 3, '境外租车', '/static/images/icon.jpg', 255, NULL); +INSERT INTO `channels` (`id`, `agent_id`, `pid`, `name`, `icon`, `sort`, `deleted_at`) VALUES (32, 0, 4, '每日签到', '/static/images/icon.jpg', 255, NULL); +INSERT INTO `channels` (`id`, `agent_id`, `pid`, `name`, `icon`, `sort`, `deleted_at`) VALUES (33, 0, 4, '会员中心', '/static/images/icon.jpg', 255, NULL); +INSERT INTO `channels` (`id`, `agent_id`, `pid`, `name`, `icon`, `sort`, `deleted_at`) VALUES (34, 0, 4, '任务中心', '/static/images/icon.jpg', 255, NULL); +INSERT INTO `channels` (`id`, `agent_id`, `pid`, `name`, `icon`, `sort`, `deleted_at`) VALUES (35, 0, 4, '智慧旅游', '/static/images/icon.jpg', 255, NULL); +INSERT INTO `channels` (`id`, `agent_id`, `pid`, `name`, `icon`, `sort`, `deleted_at`) VALUES (36, 0, 4, '兑换会员', '/static/images/icon.jpg', 255, NULL); +INSERT INTO `channels` (`id`, `agent_id`, `pid`, `name`, `icon`, `sort`, `deleted_at`) VALUES (37, 0, 4, '旅盟', '/static/images/icon.jpg', 255, NULL); +INSERT INTO `channels` (`id`, `agent_id`, `pid`, `name`, `icon`, `sort`, `deleted_at`) VALUES (38, 0, 5, '旅游攻略', '/static/images/icon.jpg', 255, NULL); +INSERT INTO `channels` (`id`, `agent_id`, `pid`, `name`, `icon`, `sort`, `deleted_at`) VALUES (39, 0, 5, '玩法指南', '/static/images/icon.jpg', 255, NULL); +INSERT INTO `channels` (`id`, `agent_id`, `pid`, `name`, `icon`, `sort`, `deleted_at`) VALUES (40, 0, 5, '有问必答', '/static/images/icon.jpg', 255, NULL); +INSERT INTO `channels` (`id`, `agent_id`, `pid`, `name`, `icon`, `sort`, `deleted_at`) VALUES (41, 0, 5, '热门笔记', '/static/images/icon.jpg', 255, NULL); + ``` \ No newline at end of file diff --git a/resources/lang/zh_CN/agent-product.php b/resources/lang/zh_CN/agent-product.php index c5b61c3..2d914c6 100644 --- a/resources/lang/zh_CN/agent-product.php +++ b/resources/lang/zh_CN/agent-product.php @@ -15,6 +15,12 @@ return [ 'category_id' => '分类', 'status' => '状态', 'verifier' => '核销人员', + 'is_rec' => '是否推荐', + 'title' => '标题', + 'content' => '产品详情', + 'know' => '旅游须知', + 'pictures' => '产品图片', + 'picture' => '产品图片', 'product' => trans('product.fields'), ], 'options' => [ From 7bf99d6e3bf10c6c9c1e5a5577622b86c53d7ce6 Mon Sep 17 00:00:00 2001 From: liapples Date: Thu, 26 Aug 2021 11:54:59 +0800 Subject: [PATCH 25/42] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=9B=BE=E7=89=87?= =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E5=8F=8A=E6=98=BE=E7=A4=BA=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Admin/Controllers/AgentController.php | 12 ++++++------ app/Admin/Controllers/GuideController.php | 12 ++++++------ app/Admin/Controllers/OrderController.php | 2 +- app/Admin/Controllers/ProductController.php | 4 ++-- app/Admin/Controllers/SupplierController.php | 12 ++++++------ app/Admin/Controllers/UserController.php | 4 ++-- app/AdminAgent/Controllers/ArticleController.php | 2 +- app/AdminAgent/Controllers/OrderController.php | 2 +- app/AdminAgent/Controllers/UserController.php | 4 ++-- app/AdminSettled/Controllers/AgentController.php | 4 ++-- app/AdminSettled/Controllers/GuideController.php | 4 ++-- app/AdminSettled/Controllers/SupplierController.php | 4 ++-- app/AdminSupplier/Controllers/AgentController.php | 4 ++-- app/AdminSupplier/Controllers/OrderController.php | 4 ++-- app/AdminSupplier/Controllers/ProductController.php | 2 +- app/Http/Controllers/Api/ChannelController.php | 5 +++++ 16 files changed, 43 insertions(+), 38 deletions(-) diff --git a/app/Admin/Controllers/AgentController.php b/app/Admin/Controllers/AgentController.php index 3f4da37..daa3d1e 100644 --- a/app/Admin/Controllers/AgentController.php +++ b/app/Admin/Controllers/AgentController.php @@ -34,9 +34,9 @@ class AgentController extends AdminController $grid->column('name'); $grid->column('type')->using(AgentType::array()); $grid->column('company_name'); - $grid->column('logo')->image(60, 60); + $grid->column('logo')->image('', 60, 60); $grid->column('address'); - $grid->column('license_pic')->image(60, 60); + $grid->column('license_pic')->image('', 60, 60); $grid->column('director'); $grid->column('contact_phone'); $grid->column('created_at'); @@ -90,9 +90,9 @@ class AgentController extends AdminController $show->field('status')->using(UserStatus::array()); $show->field('type')->using(AgentType::array()); $show->field('company_name'); - $show->field('logo')->image(120, 120); + $show->field('logo')->image('', 80, 80); $show->field('address'); - $show->field('license_pic')->image(120, 120); + $show->field('license_pic')->image('', 80, 80); $show->field('director'); $show->field('contact_phone'); $show->field('agentInfo.about', '关于我们') @@ -149,9 +149,9 @@ class AgentController extends AdminController ->default(AgentType::OPERATOR) ->required(); $form->text('company_name'); - $form->image('logo'); + $form->image('logo')->removable(false)->uniqueName(); $form->text('address'); - $form->image('license_pic'); + $form->image('license_pic')->removable(false)->uniqueName(); $form->text('director'); $form->text('contact_phone'); $form->editor('agentInfo.about', '关于我们');// 隐藏菜单用:->options(['menubar' => false]); diff --git a/app/Admin/Controllers/GuideController.php b/app/Admin/Controllers/GuideController.php index 08880a1..3236a3a 100644 --- a/app/Admin/Controllers/GuideController.php +++ b/app/Admin/Controllers/GuideController.php @@ -30,8 +30,8 @@ class GuideController extends AdminController $grid->column('id')->sortable(); $grid->column('username'); $grid->column('name'); - $grid->column('photo')->image(60, 60); - $grid->column('license_pic')->image(60, 60); + $grid->column('photo')->image('', 60, 60); + $grid->column('license_pic')->image('', 60, 60); $grid->column('contact_phone'); $grid->column('created_at'); $grid->column('updated_at'); @@ -78,8 +78,8 @@ class GuideController extends AdminController $show->field('username'); $show->field('name'); $show->field('status')->using(UserStatus::array()); - $show->field('photo')->image(); - $show->field('license_pic')->image(); + $show->field('photo')->image('', 80, 80); + $show->field('license_pic')->image('', 80, 80); $show->field('contact_phone'); $show->field('created_at'); $show->field('updated_at'); @@ -109,8 +109,8 @@ class GuideController extends AdminController } $form->select('status')->options(UserStatus::array())->default(UserStatus::NORMAL); $form->text('name'); - $form->image('photo'); - $form->image('license_pic'); + $form->image('photo')->removable(false)->uniqueName(); + $form->image('license_pic')->removable(false)->uniqueName(); $form->text('contact_phone'); })->saving(function (Form $form) { //判断账号是否唯一 diff --git a/app/Admin/Controllers/OrderController.php b/app/Admin/Controllers/OrderController.php index 23243db..5935cd5 100644 --- a/app/Admin/Controllers/OrderController.php +++ b/app/Admin/Controllers/OrderController.php @@ -99,7 +99,7 @@ class OrderController extends AdminController $show->field('paid_money'); $show->field('pay_type')->using(PayType::array()); $show->field('title'); - $show->field('picture')->image(80, 80); + $show->field('picture')->image('', 80, 80); $show->field('price'); $show->field('product_id'); $show->field('status')->using(OrderStatus::array()); diff --git a/app/Admin/Controllers/ProductController.php b/app/Admin/Controllers/ProductController.php index 65e8785..bb2f741 100644 --- a/app/Admin/Controllers/ProductController.php +++ b/app/Admin/Controllers/ProductController.php @@ -32,7 +32,7 @@ class ProductController extends AdminController $grid->column('id')->sortable(); $grid->column('category.name', '分类'); - $grid->column('picture')->image(60, 60); + $grid->column('picture')->image('', 60, 60); $grid->column('title'); $grid->column('original_price'); $grid->column('price'); @@ -80,7 +80,7 @@ class ProductController extends AdminController $show->field('id'); $show->field('category.name', '所属分类'); $show->field('title'); - $show->field('pictures')->image(80, 80); + $show->field('pictures')->image('', 80, 80); $show->field('original_price'); $show->field('price'); $show->field('sale'); diff --git a/app/Admin/Controllers/SupplierController.php b/app/Admin/Controllers/SupplierController.php index a0cb945..8ad9bec 100644 --- a/app/Admin/Controllers/SupplierController.php +++ b/app/Admin/Controllers/SupplierController.php @@ -34,9 +34,9 @@ class SupplierController extends AdminController $grid->column('username'); $grid->column('name'); $grid->column('company_name'); - $grid->column('logo')->image(60, 60); + $grid->column('logo')->image('', 60, 60); $grid->column('address'); - $grid->column('license_pic')->image(60,60); + $grid->column('license_pic')->image('', 60,60); $grid->column('director'); $grid->column('contact_phone'); $grid->column('created_at'); @@ -84,9 +84,9 @@ class SupplierController extends AdminController $show->field('username'); $show->field('name'); $show->field('company_name'); - $show->field('logo')->image(60, 60); + $show->field('logo')->image('', 60, 60); $show->field('address'); - $show->field('license_pic')->image(60, 60); + $show->field('license_pic')->image('', 60, 60); $show->field('director'); $show->field('contact_phone'); $show->field('created_at'); @@ -121,9 +121,9 @@ class SupplierController extends AdminController ->help('如果禁用供应商将同时下架供应商的所有产品,需要供应商手动上架后才能销售,请谨慎!') ->required(); $form->text('company_name'); - $form->image('logo'); + $form->image('logo')->removable(false)->uniqueName(); $form->text('address'); - $form->image('license_pic'); + $form->image('license_pic')->removable(false)->uniqueName(); $form->text('director'); $form->mobile('contact_phone'); })->editing(function (Form $form) { diff --git a/app/Admin/Controllers/UserController.php b/app/Admin/Controllers/UserController.php index 36a3dbd..fda6afc 100644 --- a/app/Admin/Controllers/UserController.php +++ b/app/Admin/Controllers/UserController.php @@ -25,7 +25,7 @@ class UserController extends AdminController $grid->column('id')->sortable(); $grid->column('agent.name', '所属代理商'); - $grid->column('avatar')->image(60, 60); + $grid->column('avatar')->image('', 60, 60); $grid->column('mobile'); $grid->column('nickname'); $grid->column('status')->bool(); @@ -55,7 +55,7 @@ class UserController extends AdminController $show->field('id'); $show->field('agent.name', '代理商'); - $show->field('avatar')->image(80, 80); + $show->field('avatar')->image('', 80, 80); $show->field('mobile'); $show->field('nickname'); $show->field('status')->bool(); diff --git a/app/AdminAgent/Controllers/ArticleController.php b/app/AdminAgent/Controllers/ArticleController.php index 4fdc45f..a436491 100644 --- a/app/AdminAgent/Controllers/ArticleController.php +++ b/app/AdminAgent/Controllers/ArticleController.php @@ -83,7 +83,7 @@ class ArticleController extends AdminController $form->display('id'); $form->text('author')->default(Admin::user()->name); $form->text('title')->required(); - $form->image('image')->required(); + $form->image('image')->required()->removable(false)->uniqueName(); $form->editor('content')->required(); $form->text('sort')->default(255); $form->select('type')->options(['普通列表', '大图显示'])->default(0)->required(); diff --git a/app/AdminAgent/Controllers/OrderController.php b/app/AdminAgent/Controllers/OrderController.php index 453d519..28da7c5 100644 --- a/app/AdminAgent/Controllers/OrderController.php +++ b/app/AdminAgent/Controllers/OrderController.php @@ -139,7 +139,7 @@ class OrderController extends AdminController $show->field('name'); $show->field('mobile'); $show->field('title'); - $show->field('picture')->image(80, 80); + $show->field('picture')->image('', 80, 80); $show->field('status')->using(OrderStatus::array()); $show->field('pay_type')->using(PayType::array()); $show->field('created_at'); diff --git a/app/AdminAgent/Controllers/UserController.php b/app/AdminAgent/Controllers/UserController.php index e77faa9..5a4a681 100644 --- a/app/AdminAgent/Controllers/UserController.php +++ b/app/AdminAgent/Controllers/UserController.php @@ -34,7 +34,7 @@ class UserController extends AdminController $grid->model()->where('agent_id', Admin::user()->id); $grid->column('id')->sortable(); - $grid->column('avatar')->image(60, 60); + $grid->column('avatar')->image('', 60, 60); $grid->column('mobile'); $grid->column('nickname'); $grid->column('status')->switch()->help('禁用后用户将无法登录'); @@ -68,7 +68,7 @@ class UserController extends AdminController } $show->field('id'); - $show->field('avatar')->image(80, 80); + $show->field('avatar')->image('', 80, 80); $show->field('mobile'); $show->field('nickname'); $show->field('status')->bool(); diff --git a/app/AdminSettled/Controllers/AgentController.php b/app/AdminSettled/Controllers/AgentController.php index 59a9637..1be865c 100644 --- a/app/AdminSettled/Controllers/AgentController.php +++ b/app/AdminSettled/Controllers/AgentController.php @@ -68,9 +68,9 @@ class AgentController extends AdminController ->default(AgentType::OPERATOR) ->required(); $form->text('company_name')->required(); - $form->image('logo')->required(); + $form->image('logo')->required()->removable(false)->uniqueName(); $form->text('address')->required(); - $form->image('license_pic')->required(); + $form->image('license_pic')->required()->removable(false)->uniqueName(); $form->text('director')->required(); $form->text('contact_phone')->required(); })->saving(function (Form $form) { diff --git a/app/AdminSettled/Controllers/GuideController.php b/app/AdminSettled/Controllers/GuideController.php index a1be17b..832456f 100644 --- a/app/AdminSettled/Controllers/GuideController.php +++ b/app/AdminSettled/Controllers/GuideController.php @@ -58,8 +58,8 @@ class GuideController extends AdminController $form->text('username')->required(); $form->text('password')->required(); $form->text('name')->required(); - $form->image('photo')->required(); - $form->image('license_pic')->required(); + $form->image('photo')->required()->removable(false)->uniqueName(); + $form->image('license_pic')->required()->removable(false)->uniqueName(); $form->text('contact_phone')->required(); })->saving(function (Form $form) { //判断账号是否唯一 diff --git a/app/AdminSettled/Controllers/SupplierController.php b/app/AdminSettled/Controllers/SupplierController.php index 3c8e145..62ba1bb 100644 --- a/app/AdminSettled/Controllers/SupplierController.php +++ b/app/AdminSettled/Controllers/SupplierController.php @@ -59,9 +59,9 @@ class SupplierController extends AdminController $form->text('password')->required(); $form->text('name')->required(); $form->text('company_name')->required(); - $form->image('logo'); + $form->image('logo')->removable(false)->uniqueName(); $form->text('address')->required(); - $form->image('license_pic')->required(); + $form->image('license_pic')->required()->removable(false)->uniqueName(); $form->text('director')->required(); $form->text('contact_phone')->required(); })->saving(function (Form $form) { diff --git a/app/AdminSupplier/Controllers/AgentController.php b/app/AdminSupplier/Controllers/AgentController.php index 00aebe3..21639ed 100644 --- a/app/AdminSupplier/Controllers/AgentController.php +++ b/app/AdminSupplier/Controllers/AgentController.php @@ -42,8 +42,8 @@ class AgentController extends AdminController $grid->column('address'); $grid->column('director'); $grid->column('contact_phone'); - $grid->column('logo')->image(60, 60); - $grid->column('license_pic')->image(60, 60); + $grid->column('logo')->image('', 60, 60); + $grid->column('license_pic')->image('', 60, 60); $grid->column('status')->using(UserStatus::array()); $grid->column('created_at', '注册时间'); diff --git a/app/AdminSupplier/Controllers/OrderController.php b/app/AdminSupplier/Controllers/OrderController.php index b7a1e58..46d607a 100644 --- a/app/AdminSupplier/Controllers/OrderController.php +++ b/app/AdminSupplier/Controllers/OrderController.php @@ -41,7 +41,7 @@ class OrderController extends AdminController $grid->column('id')->sortable(); $grid->column('agent.name', '代理商'); $grid->column('title'); - $grid->column('picture')->image(60, 60); + $grid->column('picture')->image('', 60, 60); $grid->column('product', '订单信息') ->display('查看') ->modal('订单信息', function ($modal) { @@ -111,7 +111,7 @@ class OrderController extends AdminController $show->field('paid_money'); $show->field('pay_type')->using(PayType::array()); $show->field('title'); - $show->field('picture')->image(80, 80); + $show->field('picture')->image('', 80, 80); $show->field('price'); $show->field('product_id'); $show->field('status')->using(OrderStatus::array()); diff --git a/app/AdminSupplier/Controllers/ProductController.php b/app/AdminSupplier/Controllers/ProductController.php index 42e97e8..f410e0f 100644 --- a/app/AdminSupplier/Controllers/ProductController.php +++ b/app/AdminSupplier/Controllers/ProductController.php @@ -61,7 +61,7 @@ class ProductController extends AdminController $show->field('title'); $show->field('price'); $show->field('original_price'); - $show->field('pictures')->image(80, 80); + $show->field('pictures')->image('', 80, 80); $show->field('stock'); $show->field('sale'); $show->field('status'); diff --git a/app/Http/Controllers/Api/ChannelController.php b/app/Http/Controllers/Api/ChannelController.php index 0a36a2d..2e4ee2d 100644 --- a/app/Http/Controllers/Api/ChannelController.php +++ b/app/Http/Controllers/Api/ChannelController.php @@ -5,6 +5,7 @@ use App\Http\Controllers\Controller; use App\Models\AgentProduct; use App\Models\Channel; use App\Models\UserChannel; +use Illuminate\Support\Facades\Storage; /** * 频道列表 @@ -21,6 +22,10 @@ class ChannelController extends Controller ->orderBy('sort') ->orderBy('id') ->get(['id', 'pid', 'name', 'icon']); + $prefix = Storage::disk('public')->url(''); + foreach ($list as $k => &$v) { + $v->icon = $prefix . $v->icon; + } return $this->success($list); } From de21915d9eb2091114eaf70798602b448d795a47 Mon Sep 17 00:00:00 2001 From: liapples Date: Thu, 26 Aug 2021 11:55:14 +0800 Subject: [PATCH 26/42] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=BA=93=E5=88=9D?= =?UTF-8?q?=E5=A7=8B=E5=8C=96=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ready.md | 82 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 41 insertions(+), 41 deletions(-) diff --git a/ready.md b/ready.md index a6887e5..4a3938f 100644 --- a/ready.md +++ b/ready.md @@ -32,46 +32,46 @@ INSERT INTO `categories` (`id`, `agent_id`, `pid`, `name`, `sort`, `template`, ` INSERT INTO `categories` (`id`, `agent_id`, `pid`, `name`, `sort`, `template`, `deleted_at`) VALUES (4, 0, 0, '国际游', 255, '', NULL); INSERT INTO `categories` (`id`, `agent_id`, `pid`, `name`, `sort`, `template`, `deleted_at`) VALUES (5, 0, 0, '跟团游', 255, '', NULL); -INSERT INTO `channels` (`id`, `agent_id`, `pid`, `name`, `icon`, `sort`, `deleted_at`) VALUES (1, 0, 0, '机票酒店', '/static/images/icon.jpg', 255, NULL); -INSERT INTO `channels` (`id`, `agent_id`, `pid`, `name`, `icon`, `sort`, `deleted_at`) VALUES (2, 0, 0, '旅游度假', '/static/images/icon.jpg', 255, NULL); -INSERT INTO `channels` (`id`, `agent_id`, `pid`, `name`, `icon`, `sort`, `deleted_at`) VALUES (3, 0, 0, '接送服务', '/static/images/icon.jpg', 255, NULL); -INSERT INTO `channels` (`id`, `agent_id`, `pid`, `name`, `icon`, `sort`, `deleted_at`) VALUES (4, 0, 0, '其它精选', '/static/images/icon.jpg', 255, NULL); -INSERT INTO `channels` (`id`, `agent_id`, `pid`, `name`, `icon`, `sort`, `deleted_at`) VALUES (5, 0, 0, '攻略社区', '/static/images/icon.jpg', 255, NULL); -INSERT INTO `channels` (`id`, `agent_id`, `pid`, `name`, `icon`, `sort`, `deleted_at`) VALUES (6, 0, 1, '多地比价', '/static/images/icon.jpg', 255, NULL); -INSERT INTO `channels` (`id`, `agent_id`, `pid`, `name`, `icon`, `sort`, `deleted_at`) VALUES (7, 0, 1, '降价提醒', '/static/images/icon.jpg', 255, NULL); -INSERT INTO `channels` (`id`, `agent_id`, `pid`, `name`, `icon`, `sort`, `deleted_at`) VALUES (8, 0, 1, '团体机票', '/static/images/icon.jpg', 255, NULL); -INSERT INTO `channels` (`id`, `agent_id`, `pid`, `name`, `icon`, `sort`, `deleted_at`) VALUES (9, 0, 2, '冲浪', '/static/images/icon.jpg', 255, NULL); -INSERT INTO `channels` (`id`, `agent_id`, `pid`, `name`, `icon`, `sort`, `deleted_at`) VALUES (10, 0, 2, '热气球', '/static/images/icon.jpg', 255, NULL); -INSERT INTO `channels` (`id`, `agent_id`, `pid`, `name`, `icon`, `sort`, `deleted_at`) VALUES (11, 0, 2, '蹦极', '/static/images/icon.jpg', 255, NULL); -INSERT INTO `channels` (`id`, `agent_id`, `pid`, `name`, `icon`, `sort`, `deleted_at`) VALUES (12, 0, 2, '滑翔伞', '/static/images/icon.jpg', 255, NULL); -INSERT INTO `channels` (`id`, `agent_id`, `pid`, `name`, `icon`, `sort`, `deleted_at`) VALUES (13, 0, 2, '主题玩法', '/static/images/icon.jpg', 255, NULL); -INSERT INTO `channels` (`id`, `agent_id`, `pid`, `name`, `icon`, `sort`, `deleted_at`) VALUES (14, 0, 2, '取景地', '/static/images/icon.jpg', 255, NULL); -INSERT INTO `channels` (`id`, `agent_id`, `pid`, `name`, `icon`, `sort`, `deleted_at`) VALUES (15, 0, 2, '周边游', '/static/images/icon.jpg', 255, NULL); -INSERT INTO `channels` (`id`, `agent_id`, `pid`, `name`, `icon`, `sort`, `deleted_at`) VALUES (16, 0, 2, '国内游', '/static/images/icon.jpg', 255, NULL); -INSERT INTO `channels` (`id`, `agent_id`, `pid`, `name`, `icon`, `sort`, `deleted_at`) VALUES (17, 0, 2, '尾单特卖', '/static/images/icon.jpg', 255, NULL); -INSERT INTO `channels` (`id`, `agent_id`, `pid`, `name`, `icon`, `sort`, `deleted_at`) VALUES (18, 0, 2, '邮轮', '/static/images/icon.jpg', 255, NULL); -INSERT INTO `channels` (`id`, `agent_id`, `pid`, `name`, `icon`, `sort`, `deleted_at`) VALUES (19, 0, 2, '汽车·船票', '/static/images/icon.jpg', 255, NULL); -INSERT INTO `channels` (`id`, `agent_id`, `pid`, `name`, `icon`, `sort`, `deleted_at`) VALUES (20, 0, 2, '定制游', '/static/images/icon.jpg', 255, NULL); -INSERT INTO `channels` (`id`, `agent_id`, `pid`, `name`, `icon`, `sort`, `deleted_at`) VALUES (21, 0, 2, '家庭游', '/static/images/icon.jpg', 255, NULL); -INSERT INTO `channels` (`id`, `agent_id`, `pid`, `name`, `icon`, `sort`, `deleted_at`) VALUES (22, 0, 2, '签证·上网', '/static/images/icon.jpg', 255, NULL); -INSERT INTO `channels` (`id`, `agent_id`, `pid`, `name`, `icon`, `sort`, `deleted_at`) VALUES (23, 0, 2, '自驾·租车', '/static/images/icon.jpg', 255, NULL); -INSERT INTO `channels` (`id`, `agent_id`, `pid`, `name`, `icon`, `sort`, `deleted_at`) VALUES (24, 0, 2, '旅游·团购', '/static/images/icon.jpg', 255, NULL); -INSERT INTO `channels` (`id`, `agent_id`, `pid`, `name`, `icon`, `sort`, `deleted_at`) VALUES (25, 0, 3, '接送机', '/static/images/icon.jpg', 255, NULL); -INSERT INTO `channels` (`id`, `agent_id`, `pid`, `name`, `icon`, `sort`, `deleted_at`) VALUES (26, 0, 3, '接送火车', '/static/images/icon.jpg', 255, NULL); -INSERT INTO `channels` (`id`, `agent_id`, `pid`, `name`, `icon`, `sort`, `deleted_at`) VALUES (27, 0, 3, '打车', '/static/images/icon.jpg', 255, NULL); -INSERT INTO `channels` (`id`, `agent_id`, `pid`, `name`, `icon`, `sort`, `deleted_at`) VALUES (28, 0, 3, '按天包车', '/static/images/icon.jpg', 255, NULL); -INSERT INTO `channels` (`id`, `agent_id`, `pid`, `name`, `icon`, `sort`, `deleted_at`) VALUES (29, 0, 3, '定制包车', '/static/images/icon.jpg', 255, NULL); -INSERT INTO `channels` (`id`, `agent_id`, `pid`, `name`, `icon`, `sort`, `deleted_at`) VALUES (30, 0, 3, '国内租车', '/static/images/icon.jpg', 255, NULL); -INSERT INTO `channels` (`id`, `agent_id`, `pid`, `name`, `icon`, `sort`, `deleted_at`) VALUES (31, 0, 3, '境外租车', '/static/images/icon.jpg', 255, NULL); -INSERT INTO `channels` (`id`, `agent_id`, `pid`, `name`, `icon`, `sort`, `deleted_at`) VALUES (32, 0, 4, '每日签到', '/static/images/icon.jpg', 255, NULL); -INSERT INTO `channels` (`id`, `agent_id`, `pid`, `name`, `icon`, `sort`, `deleted_at`) VALUES (33, 0, 4, '会员中心', '/static/images/icon.jpg', 255, NULL); -INSERT INTO `channels` (`id`, `agent_id`, `pid`, `name`, `icon`, `sort`, `deleted_at`) VALUES (34, 0, 4, '任务中心', '/static/images/icon.jpg', 255, NULL); -INSERT INTO `channels` (`id`, `agent_id`, `pid`, `name`, `icon`, `sort`, `deleted_at`) VALUES (35, 0, 4, '智慧旅游', '/static/images/icon.jpg', 255, NULL); -INSERT INTO `channels` (`id`, `agent_id`, `pid`, `name`, `icon`, `sort`, `deleted_at`) VALUES (36, 0, 4, '兑换会员', '/static/images/icon.jpg', 255, NULL); -INSERT INTO `channels` (`id`, `agent_id`, `pid`, `name`, `icon`, `sort`, `deleted_at`) VALUES (37, 0, 4, '旅盟', '/static/images/icon.jpg', 255, NULL); -INSERT INTO `channels` (`id`, `agent_id`, `pid`, `name`, `icon`, `sort`, `deleted_at`) VALUES (38, 0, 5, '旅游攻略', '/static/images/icon.jpg', 255, NULL); -INSERT INTO `channels` (`id`, `agent_id`, `pid`, `name`, `icon`, `sort`, `deleted_at`) VALUES (39, 0, 5, '玩法指南', '/static/images/icon.jpg', 255, NULL); -INSERT INTO `channels` (`id`, `agent_id`, `pid`, `name`, `icon`, `sort`, `deleted_at`) VALUES (40, 0, 5, '有问必答', '/static/images/icon.jpg', 255, NULL); -INSERT INTO `channels` (`id`, `agent_id`, `pid`, `name`, `icon`, `sort`, `deleted_at`) VALUES (41, 0, 5, '热门笔记', '/static/images/icon.jpg', 255, NULL); +INSERT INTO `channels` (`id`, `agent_id`, `pid`, `name`, `icon`, `sort`, `deleted_at`) VALUES (1, 0, 0, '机票酒店', 'images/icon.jpg', 255, NULL); +INSERT INTO `channels` (`id`, `agent_id`, `pid`, `name`, `icon`, `sort`, `deleted_at`) VALUES (2, 0, 0, '旅游度假', 'images/icon.jpg', 255, NULL); +INSERT INTO `channels` (`id`, `agent_id`, `pid`, `name`, `icon`, `sort`, `deleted_at`) VALUES (3, 0, 0, '接送服务', 'images/icon.jpg', 255, NULL); +INSERT INTO `channels` (`id`, `agent_id`, `pid`, `name`, `icon`, `sort`, `deleted_at`) VALUES (4, 0, 0, '其它精选', 'images/icon.jpg', 255, NULL); +INSERT INTO `channels` (`id`, `agent_id`, `pid`, `name`, `icon`, `sort`, `deleted_at`) VALUES (5, 0, 0, '攻略社区', 'images/icon.jpg', 255, NULL); +INSERT INTO `channels` (`id`, `agent_id`, `pid`, `name`, `icon`, `sort`, `deleted_at`) VALUES (6, 0, 1, '多地比价', 'images/icon.jpg', 255, NULL); +INSERT INTO `channels` (`id`, `agent_id`, `pid`, `name`, `icon`, `sort`, `deleted_at`) VALUES (7, 0, 1, '降价提醒', 'images/icon.jpg', 255, NULL); +INSERT INTO `channels` (`id`, `agent_id`, `pid`, `name`, `icon`, `sort`, `deleted_at`) VALUES (8, 0, 1, '团体机票', 'images/icon.jpg', 255, NULL); +INSERT INTO `channels` (`id`, `agent_id`, `pid`, `name`, `icon`, `sort`, `deleted_at`) VALUES (9, 0, 2, '冲浪', 'images/icon.jpg', 255, NULL); +INSERT INTO `channels` (`id`, `agent_id`, `pid`, `name`, `icon`, `sort`, `deleted_at`) VALUES (10, 0, 2, '热气球', 'images/icon.jpg', 255, NULL); +INSERT INTO `channels` (`id`, `agent_id`, `pid`, `name`, `icon`, `sort`, `deleted_at`) VALUES (11, 0, 2, '蹦极', 'images/icon.jpg', 255, NULL); +INSERT INTO `channels` (`id`, `agent_id`, `pid`, `name`, `icon`, `sort`, `deleted_at`) VALUES (12, 0, 2, '滑翔伞', 'images/icon.jpg', 255, NULL); +INSERT INTO `channels` (`id`, `agent_id`, `pid`, `name`, `icon`, `sort`, `deleted_at`) VALUES (13, 0, 2, '主题玩法', 'images/icon.jpg', 255, NULL); +INSERT INTO `channels` (`id`, `agent_id`, `pid`, `name`, `icon`, `sort`, `deleted_at`) VALUES (14, 0, 2, '取景地', 'images/icon.jpg', 255, NULL); +INSERT INTO `channels` (`id`, `agent_id`, `pid`, `name`, `icon`, `sort`, `deleted_at`) VALUES (15, 0, 2, '周边游', 'images/icon.jpg', 255, NULL); +INSERT INTO `channels` (`id`, `agent_id`, `pid`, `name`, `icon`, `sort`, `deleted_at`) VALUES (16, 0, 2, '国内游', 'images/icon.jpg', 255, NULL); +INSERT INTO `channels` (`id`, `agent_id`, `pid`, `name`, `icon`, `sort`, `deleted_at`) VALUES (17, 0, 2, '尾单特卖', 'images/icon.jpg', 255, NULL); +INSERT INTO `channels` (`id`, `agent_id`, `pid`, `name`, `icon`, `sort`, `deleted_at`) VALUES (18, 0, 2, '邮轮', 'images/icon.jpg', 255, NULL); +INSERT INTO `channels` (`id`, `agent_id`, `pid`, `name`, `icon`, `sort`, `deleted_at`) VALUES (19, 0, 2, '汽车·船票', 'images/icon.jpg', 255, NULL); +INSERT INTO `channels` (`id`, `agent_id`, `pid`, `name`, `icon`, `sort`, `deleted_at`) VALUES (20, 0, 2, '定制游', 'images/icon.jpg', 255, NULL); +INSERT INTO `channels` (`id`, `agent_id`, `pid`, `name`, `icon`, `sort`, `deleted_at`) VALUES (21, 0, 2, '家庭游', 'images/icon.jpg', 255, NULL); +INSERT INTO `channels` (`id`, `agent_id`, `pid`, `name`, `icon`, `sort`, `deleted_at`) VALUES (22, 0, 2, '签证·上网', 'images/icon.jpg', 255, NULL); +INSERT INTO `channels` (`id`, `agent_id`, `pid`, `name`, `icon`, `sort`, `deleted_at`) VALUES (23, 0, 2, '自驾·租车', 'images/icon.jpg', 255, NULL); +INSERT INTO `channels` (`id`, `agent_id`, `pid`, `name`, `icon`, `sort`, `deleted_at`) VALUES (24, 0, 2, '旅游·团购', 'images/icon.jpg', 255, NULL); +INSERT INTO `channels` (`id`, `agent_id`, `pid`, `name`, `icon`, `sort`, `deleted_at`) VALUES (25, 0, 3, '接送机', 'images/icon.jpg', 255, NULL); +INSERT INTO `channels` (`id`, `agent_id`, `pid`, `name`, `icon`, `sort`, `deleted_at`) VALUES (26, 0, 3, '接送火车', 'images/icon.jpg', 255, NULL); +INSERT INTO `channels` (`id`, `agent_id`, `pid`, `name`, `icon`, `sort`, `deleted_at`) VALUES (27, 0, 3, '打车', 'images/icon.jpg', 255, NULL); +INSERT INTO `channels` (`id`, `agent_id`, `pid`, `name`, `icon`, `sort`, `deleted_at`) VALUES (28, 0, 3, '按天包车', 'images/icon.jpg', 255, NULL); +INSERT INTO `channels` (`id`, `agent_id`, `pid`, `name`, `icon`, `sort`, `deleted_at`) VALUES (29, 0, 3, '定制包车', 'images/icon.jpg', 255, NULL); +INSERT INTO `channels` (`id`, `agent_id`, `pid`, `name`, `icon`, `sort`, `deleted_at`) VALUES (30, 0, 3, '国内租车', 'images/icon.jpg', 255, NULL); +INSERT INTO `channels` (`id`, `agent_id`, `pid`, `name`, `icon`, `sort`, `deleted_at`) VALUES (31, 0, 3, '境外租车', 'images/icon.jpg', 255, NULL); +INSERT INTO `channels` (`id`, `agent_id`, `pid`, `name`, `icon`, `sort`, `deleted_at`) VALUES (32, 0, 4, '每日签到', 'images/icon.jpg', 255, NULL); +INSERT INTO `channels` (`id`, `agent_id`, `pid`, `name`, `icon`, `sort`, `deleted_at`) VALUES (33, 0, 4, '会员中心', 'images/icon.jpg', 255, NULL); +INSERT INTO `channels` (`id`, `agent_id`, `pid`, `name`, `icon`, `sort`, `deleted_at`) VALUES (34, 0, 4, '任务中心', 'images/icon.jpg', 255, NULL); +INSERT INTO `channels` (`id`, `agent_id`, `pid`, `name`, `icon`, `sort`, `deleted_at`) VALUES (35, 0, 4, '智慧旅游', 'images/icon.jpg', 255, NULL); +INSERT INTO `channels` (`id`, `agent_id`, `pid`, `name`, `icon`, `sort`, `deleted_at`) VALUES (36, 0, 4, '兑换会员', 'images/icon.jpg', 255, NULL); +INSERT INTO `channels` (`id`, `agent_id`, `pid`, `name`, `icon`, `sort`, `deleted_at`) VALUES (37, 0, 4, '旅盟', 'images/icon.jpg', 255, NULL); +INSERT INTO `channels` (`id`, `agent_id`, `pid`, `name`, `icon`, `sort`, `deleted_at`) VALUES (38, 0, 5, '旅游攻略', 'images/icon.jpg', 255, NULL); +INSERT INTO `channels` (`id`, `agent_id`, `pid`, `name`, `icon`, `sort`, `deleted_at`) VALUES (39, 0, 5, '玩法指南', 'images/icon.jpg', 255, NULL); +INSERT INTO `channels` (`id`, `agent_id`, `pid`, `name`, `icon`, `sort`, `deleted_at`) VALUES (40, 0, 5, '有问必答', 'images/icon.jpg', 255, NULL); +INSERT INTO `channels` (`id`, `agent_id`, `pid`, `name`, `icon`, `sort`, `deleted_at`) VALUES (41, 0, 5, '热门笔记', 'images/icon.jpg', 255, NULL); ``` \ No newline at end of file From d26aeeef92fc650ebcb9972af6ab2d7665d426d0 Mon Sep 17 00:00:00 2001 From: liapples Date: Thu, 26 Aug 2021 13:25:52 +0800 Subject: [PATCH 27/42] =?UTF-8?q?=E6=B5=8B=E8=AF=95=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=EF=BC=8C=E6=94=AF=E4=BB=98=E9=87=91=E9=A2=9D0.01?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/Api/OrderController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Controllers/Api/OrderController.php b/app/Http/Controllers/Api/OrderController.php index fb00b89..3e59e3e 100644 --- a/app/Http/Controllers/Api/OrderController.php +++ b/app/Http/Controllers/Api/OrderController.php @@ -318,7 +318,7 @@ class OrderController extends Controller $result = $app->order->unify([ 'body' => $order->title, 'out_trade_no' => $order->order_no . '-' . $order->status, //后面加status,主要是为了方便微信支付回调时区分定金(首付款)和尾款支付 - 'total_fee' => round($price * 100), //支付金额单位为分 + 'total_fee' => 0.01, //TODO 测试暂时注释 round($price * 100), //支付金额单位为分 'notify_url' => route('wxpay_notify', ['agent_id' => $this->agent_id]), // 支付结果通知网址,如果不设置则会使用配置里的默认地址 'trade_type' => 'JSAPI', 'openid' => $openid, From b48e8c1ffb2b31bd4a994316a9d9be0ebe3e969c Mon Sep 17 00:00:00 2001 From: liapples Date: Thu, 26 Aug 2021 13:28:49 +0800 Subject: [PATCH 28/42] =?UTF-8?q?=E4=B8=93=E9=A2=98=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0display?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/Api/IndexController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Controllers/Api/IndexController.php b/app/Http/Controllers/Api/IndexController.php index 567bd90..0f32d30 100644 --- a/app/Http/Controllers/Api/IndexController.php +++ b/app/Http/Controllers/Api/IndexController.php @@ -72,7 +72,7 @@ class IndexController extends Controller } # 专题列表 - $special = Advertising::where('agent_id', $this->agent_id) + $special = Advertising::where(['agent_id' => $this->agent_id, 'display' => 1]) ->orderBy('sort')->orderBy('id', 'desc')->limit(6) ->get(['title', 'picture', 'type', 'url']); if (!$special->isEmpty()) { From d28e3c9c2633fd10cb46cd06ba0fe1627f8b119d Mon Sep 17 00:00:00 2001 From: liapples Date: Thu, 26 Aug 2021 13:31:04 +0800 Subject: [PATCH 29/42] =?UTF-8?q?=E6=94=AF=E4=BB=98=E9=87=91=E9=A2=9D1?= =?UTF-8?q?=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/Api/OrderController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Controllers/Api/OrderController.php b/app/Http/Controllers/Api/OrderController.php index 3e59e3e..67d71e1 100644 --- a/app/Http/Controllers/Api/OrderController.php +++ b/app/Http/Controllers/Api/OrderController.php @@ -318,7 +318,7 @@ class OrderController extends Controller $result = $app->order->unify([ 'body' => $order->title, 'out_trade_no' => $order->order_no . '-' . $order->status, //后面加status,主要是为了方便微信支付回调时区分定金(首付款)和尾款支付 - 'total_fee' => 0.01, //TODO 测试暂时注释 round($price * 100), //支付金额单位为分 + 'total_fee' => 1, //TODO 测试暂时注释 round($price * 100), //支付金额单位为分 'notify_url' => route('wxpay_notify', ['agent_id' => $this->agent_id]), // 支付结果通知网址,如果不设置则会使用配置里的默认地址 'trade_type' => 'JSAPI', 'openid' => $openid, From 8aa2628e6a68025fb3661aa7d6bec3471a94203c Mon Sep 17 00:00:00 2001 From: liapples Date: Thu, 26 Aug 2021 13:38:38 +0800 Subject: [PATCH 30/42] =?UTF-8?q?=E6=8F=92=E5=85=A5=E6=9D=83=E9=99=90?= =?UTF-8?q?=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Admin/Extensions/Grid/AuditAgent.php | 7 +++++++ app/Admin/Extensions/Grid/AuditGuide.php | 8 ++++++++ app/Admin/Extensions/Grid/AuditSupplier.php | 8 ++++++++ 3 files changed, 23 insertions(+) diff --git a/app/Admin/Extensions/Grid/AuditAgent.php b/app/Admin/Extensions/Grid/AuditAgent.php index dc639cd..aaf66b9 100644 --- a/app/Admin/Extensions/Grid/AuditAgent.php +++ b/app/Admin/Extensions/Grid/AuditAgent.php @@ -6,6 +6,7 @@ use App\Models\Agent; use App\Models\Category; use App\Models\Channel; use App\Models\Advertising; +use Dcat\Admin\Admin; use Dcat\Admin\Grid\RowAction; use Illuminate\Http\Request; use Illuminate\Support\Facades\DB; @@ -107,6 +108,12 @@ class AuditAgent extends RowAction Advertising::insert($default_slide); } + //插入权限表 + if ($user->status == UserStatus::NORMAL) { + DB::table(config('admin-agent.database.role_users_table')) + ->insertOrIgnore(['role_id' => 1, 'user_id' => Admin::user()->id]); + } + //TODO 还需要插入 演示产品、公告、专题等 DB::commit(); diff --git a/app/Admin/Extensions/Grid/AuditGuide.php b/app/Admin/Extensions/Grid/AuditGuide.php index 8e9d19e..abc610c 100644 --- a/app/Admin/Extensions/Grid/AuditGuide.php +++ b/app/Admin/Extensions/Grid/AuditGuide.php @@ -3,8 +3,10 @@ namespace App\Admin\Extensions\Grid; use App\Models\Guide; use App\Common\UserStatus; +use Dcat\Admin\Admin; use Dcat\Admin\Grid\RowAction; use Illuminate\Http\Request; +use Illuminate\Support\Facades\DB; /** * 供应商审核 @@ -38,6 +40,12 @@ class AuditGuide extends RowAction $user->status = $request->action == 1 ? UserStatus::NORMAL : UserStatus::REFUSE; $user->save(); + //插入权限表 + if ($user->status == UserStatus::NORMAL) { + DB::table(config('admin-guide.database.role_users_table')) + ->insertOrIgnore(['role_id' => 1, 'user_id' => Admin::user()->id]); + } + return $this->response()->success("审核成功")->refresh(); } catch (\Exception $e) { return $this->response()->error($e->getMessage()); diff --git a/app/Admin/Extensions/Grid/AuditSupplier.php b/app/Admin/Extensions/Grid/AuditSupplier.php index d188a2d..86c5642 100644 --- a/app/Admin/Extensions/Grid/AuditSupplier.php +++ b/app/Admin/Extensions/Grid/AuditSupplier.php @@ -3,8 +3,10 @@ namespace App\Admin\Extensions\Grid; use App\Common\UserStatus; use App\Models\Supplier; +use Dcat\Admin\Admin; use Dcat\Admin\Grid\RowAction; use Illuminate\Http\Request; +use Illuminate\Support\Facades\DB; /** * 供应商审核 @@ -38,6 +40,12 @@ class AuditSupplier extends RowAction $user->status = $request->action == 1 ? UserStatus::NORMAL : UserStatus::REFUSE; $user->save(); + //插入权限表 + if ($user->status == UserStatus::NORMAL) { + DB::table(config('admin-supplier.database.role_users_table')) + ->insertOrIgnore(['role_id' => 1, 'user_id' => Admin::user()->id]); + } + return $this->response()->success("审核成功")->refresh(); } catch (\Exception $e) { return $this->response()->error($e->getMessage()); From 40b7206b7b9bf331ceb3bae51b84e521cb7573dc Mon Sep 17 00:00:00 2001 From: liapples Date: Thu, 26 Aug 2021 14:27:54 +0800 Subject: [PATCH 31/42] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=88=86=E7=B1=BBarray?= =?UTF-8?q?=5Fslice?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Admin/Controllers/ProductController.php | 2 +- app/AdminAgent/Controllers/AgentProductController.php | 4 ++-- app/AdminSupplier/Controllers/ProductController.php | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/Admin/Controllers/ProductController.php b/app/Admin/Controllers/ProductController.php index bb2f741..e1fb588 100644 --- a/app/Admin/Controllers/ProductController.php +++ b/app/Admin/Controllers/ProductController.php @@ -106,7 +106,7 @@ class ProductController extends AdminController $options = Category::selectOptions(fn($query) => $query->where('agent_id', 0)); $form->select('category_id', '所属分类') - ->options(array_slice($options, 1)) + ->options(array_slice($options, 1, null, true)) ->required(); $form->text('title')->required(); $form->multipleImage('pictures')->required(); diff --git a/app/AdminAgent/Controllers/AgentProductController.php b/app/AdminAgent/Controllers/AgentProductController.php index 854a69a..e7aac28 100644 --- a/app/AdminAgent/Controllers/AgentProductController.php +++ b/app/AdminAgent/Controllers/AgentProductController.php @@ -196,11 +196,11 @@ class AgentProductController extends AdminController $form->text('stock')->default(8888); $options = Channel::selectOptions(fn($query) => $query->where('agent_id', $agent_id)); - $form->multipleSelect('channel_id')->options(array_slice($options, 1)); + $form->multipleSelect('channel_id')->options(array_slice($options, 1, null, true)); $options = Category::selectOptions(fn($query) => $query->where('agent_id', $agent_id)); $form->select('category_id') - ->options(array_slice($options, 1)) + ->options(array_slice($options, 1, null, true)) ->required(); $form->radio('status') diff --git a/app/AdminSupplier/Controllers/ProductController.php b/app/AdminSupplier/Controllers/ProductController.php index f410e0f..e898591 100644 --- a/app/AdminSupplier/Controllers/ProductController.php +++ b/app/AdminSupplier/Controllers/ProductController.php @@ -88,7 +88,7 @@ class ProductController extends AdminController $form->display('id'); $options = Category::selectOptions(fn($query) => $query->where('agent_id', 0)); - $form->select('category_id')->options(array_slice($options, 1))->required(); + $form->select('category_id')->options(array_slice($options, 1, null, true))->required(); $form->text('title')->required(); $form->text('price')->required(); $form->text('original_price')->required(); From 3b4dfa62b70e8996f76c2028b5427624620537a4 Mon Sep 17 00:00:00 2001 From: liapples Date: Thu, 26 Aug 2021 14:36:49 +0800 Subject: [PATCH 32/42] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/Api/OrderController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Controllers/Api/OrderController.php b/app/Http/Controllers/Api/OrderController.php index 67d71e1..7e0e5e3 100644 --- a/app/Http/Controllers/Api/OrderController.php +++ b/app/Http/Controllers/Api/OrderController.php @@ -249,7 +249,7 @@ class OrderController extends Controller $ap = AgentProduct::query() ->has('product') ->with('coupon:agent_product_id,type,detail,agent_id,tag,start_at,end_at') - ->find($formData['id'], ['id', 'price', 'original_price', 'product_id']); + ->find($formData['id'], ['id', 'price', 'original_price', 'product_id', 'title', 'pictures']); if (!$ap) { return $this->error('产品信息不存在'); From 769677ea0b1ca56a28b587e9e1e0949dc96646cc Mon Sep 17 00:00:00 2001 From: liapples Date: Thu, 26 Aug 2021 14:41:37 +0800 Subject: [PATCH 33/42] =?UTF-8?q?=E8=AE=A2=E5=8D=95=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E5=AD=97=E6=AE=B5=E6=8B=BC=E6=8E=A5=E5=9F=9F=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/Api/OrderController.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/Http/Controllers/Api/OrderController.php b/app/Http/Controllers/Api/OrderController.php index 7e0e5e3..e7065d4 100644 --- a/app/Http/Controllers/Api/OrderController.php +++ b/app/Http/Controllers/Api/OrderController.php @@ -255,6 +255,9 @@ class OrderController extends Controller return $this->error('产品信息不存在'); } + $prefix = Storage::disk('public')->url(''); + $ap->pictures = array_map(fn($v) => $prefix . $v, $ap->pictures); + //如果是线下支付,显示的价格跟在线全款支付价格一样 if ($formData['pay_type'] == PayType::OFFLINE) { $formData['pay_type'] = PayType::ONLINE; From 1bc3ade5b6f8a8362d9f0a1d389d45e8b6dcf3f4 Mon Sep 17 00:00:00 2001 From: liapples Date: Thu, 26 Aug 2021 14:54:29 +0800 Subject: [PATCH 34/42] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=B5=8B=E8=AF=95pay?= =?UTF-8?q?=5Fdebugs=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/Api/WxpayController.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/Http/Controllers/Api/WxpayController.php b/app/Http/Controllers/Api/WxpayController.php index 427172a..59af014 100644 --- a/app/Http/Controllers/Api/WxpayController.php +++ b/app/Http/Controllers/Api/WxpayController.php @@ -33,6 +33,9 @@ class WxpayController $this->log($message); // 请求成功 if ($message['return_code'] === 'SUCCESS') { + //TODO 仅测试用 + DB::table('pay_debugs')->insert(['content' => json_encode($message)]); + //主要是为了区分定金支付和尾款支付,订单号带有-status后缀,分割后前面才是真正的订单号 list($order_no, $status) = explode('-', $message['out_trade_no']); $order = Order::query() From d19898d60c5d37d6437c761f113c2c9fdec402c5 Mon Sep 17 00:00:00 2001 From: liapples Date: Thu, 26 Aug 2021 15:09:20 +0800 Subject: [PATCH 35/42] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=B5=8B=E8=AF=95pay?= =?UTF-8?q?=5Fdebugs=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/Api/WxpayController.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/Http/Controllers/Api/WxpayController.php b/app/Http/Controllers/Api/WxpayController.php index 59af014..92f404f 100644 --- a/app/Http/Controllers/Api/WxpayController.php +++ b/app/Http/Controllers/Api/WxpayController.php @@ -30,12 +30,12 @@ class WxpayController $app = Factory::payment($config); try { $response = $app->handlePaidNotify(function ($message, $fail) { + //TODO 仅测试用 + DB::table('pay_debugs')->insert(['content' => json_encode($message)]); + $this->log($message); // 请求成功 if ($message['return_code'] === 'SUCCESS') { - //TODO 仅测试用 - DB::table('pay_debugs')->insert(['content' => json_encode($message)]); - //主要是为了区分定金支付和尾款支付,订单号带有-status后缀,分割后前面才是真正的订单号 list($order_no, $status) = explode('-', $message['out_trade_no']); $order = Order::query() From a1df8152a3c71316e1eab399a7a7097d0e8f9a79 Mon Sep 17 00:00:00 2001 From: liapples Date: Thu, 26 Aug 2021 15:31:01 +0800 Subject: [PATCH 36/42] =?UTF-8?q?=E5=8E=BB=E6=8E=89=E5=BE=AE=E4=BF=A1?= =?UTF-8?q?=E6=94=AF=E4=BB=98=E8=B7=AF=E7=94=B1=E4=B8=AD=E9=97=B4=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- routes/api.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/routes/api.php b/routes/api.php index dd6a970..c9993ad 100644 --- a/routes/api.php +++ b/routes/api.php @@ -21,6 +21,13 @@ use Illuminate\Support\Facades\Route; # 登录 Route::post('login', 'App\Http\Controllers\Api\LoginController@login'); +# 微信支付 +Route::namespace('App\Http\Controllers\Api') + ->prefix('wxpay')->group(function () { + Route::post('notify/{agent_id}', 'WxpayController@notify')->name('wxpay_notify'); //异步通知,aid为代理商ID + Route::post('refund/{agent_id}', 'WxpayController@refund')->name('wxpay_refund'); //退款通知,aid为代理商ID +}); + # 仅用于测试 Route::get('t/index', \App\Http\Controllers\Api\TestController::class . '@index'); @@ -71,11 +78,6 @@ Route::namespace('App\Http\Controllers\Api') Route::post('show', 'SpecialController@show'); //专题详情 }); - # 微信支付 - Route::prefix('wxpay')->group(function () { - Route::post('notify/{agent_id}', 'WxpayController@notify')->name('wxpay_notify'); //异步通知,aid为代理商ID - Route::post('refund/{agent_id}', 'WxpayController@refund')->name('wxpay_refund'); //退款通知,aid为代理商ID - }); }); # 需要登录才能请求 From f9afd5fe2006412d801b502e4c16335a642ea632 Mon Sep 17 00:00:00 2001 From: liapples Date: Thu, 26 Aug 2021 16:07:22 +0800 Subject: [PATCH 37/42] =?UTF-8?q?=E5=9B=BE=E7=89=87=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/AdminAgent/Renderable/SelectAgentProduct.php | 2 +- app/AdminAgent/Renderable/SelectProduct.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/AdminAgent/Renderable/SelectAgentProduct.php b/app/AdminAgent/Renderable/SelectAgentProduct.php index 527910c..90fb507 100644 --- a/app/AdminAgent/Renderable/SelectAgentProduct.php +++ b/app/AdminAgent/Renderable/SelectAgentProduct.php @@ -30,7 +30,7 @@ class SelectAgentProduct extends LazyRenderable $grid->column('id'); $grid->column('title'); - $grid->column('picture')->image(60, 60); + $grid->column('picture')->image('', 60, 60); $grid->column('sale'); $grid->column('stock'); $grid->column('updated_at'); diff --git a/app/AdminAgent/Renderable/SelectProduct.php b/app/AdminAgent/Renderable/SelectProduct.php index 4601b54..f162add 100644 --- a/app/AdminAgent/Renderable/SelectProduct.php +++ b/app/AdminAgent/Renderable/SelectProduct.php @@ -30,7 +30,7 @@ class SelectProduct extends LazyRenderable $grid->column('id'); $grid->column('supplier.name', '供应商'); $grid->column('title'); - $grid->column('picture')->image(60, 60); + $grid->column('picture')->image('',60, 60); $grid->column('sale'); $grid->column('stock'); $grid->column('updated_at'); From 9870eb12900656a7c5b7dcd037ccf2ed012dfbb8 Mon Sep 17 00:00:00 2001 From: liapples Date: Thu, 26 Aug 2021 16:22:31 +0800 Subject: [PATCH 38/42] =?UTF-8?q?=E7=89=B9=E6=AE=8A=E5=AD=97=E6=AE=B5?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0is=5Fnull=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/AdminAgent/Controllers/ArticleController.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/AdminAgent/Controllers/ArticleController.php b/app/AdminAgent/Controllers/ArticleController.php index a436491..422a09e 100644 --- a/app/AdminAgent/Controllers/ArticleController.php +++ b/app/AdminAgent/Controllers/ArticleController.php @@ -96,8 +96,12 @@ class ArticleController extends AdminController //特殊字段处理 $form->hidden(['agent_id']); $form->agent_id = Admin::user()->id; - $form->sort = $form->sort ?? 255; - $form->type = $form->type ? 1 : 0; + if (!is_null($form->sort)) { + $form->sort = $form->sort ?? 255; + } + if (!is_null($form->type)) { + $form->type = $form->type ? 1 : 0; + } //不允许编辑的字段 $form->ignore(['id', 'created_at', 'updated_at']); From 9223c9156cc0e529898d70bd6e5028b97d4e0926 Mon Sep 17 00:00:00 2001 From: liapples Date: Thu, 26 Aug 2021 16:22:31 +0800 Subject: [PATCH 39/42] =?UTF-8?q?=E7=89=B9=E6=AE=8A=E5=AD=97=E6=AE=B5?= =?UTF-8?q?=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/AdminAgent/Controllers/ArticleController.php | 1 - app/AdminAgent/Controllers/UserController.php | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/app/AdminAgent/Controllers/ArticleController.php b/app/AdminAgent/Controllers/ArticleController.php index a436491..14e7631 100644 --- a/app/AdminAgent/Controllers/ArticleController.php +++ b/app/AdminAgent/Controllers/ArticleController.php @@ -97,7 +97,6 @@ class ArticleController extends AdminController $form->hidden(['agent_id']); $form->agent_id = Admin::user()->id; $form->sort = $form->sort ?? 255; - $form->type = $form->type ? 1 : 0; //不允许编辑的字段 $form->ignore(['id', 'created_at', 'updated_at']); diff --git a/app/AdminAgent/Controllers/UserController.php b/app/AdminAgent/Controllers/UserController.php index 5a4a681..cdde359 100644 --- a/app/AdminAgent/Controllers/UserController.php +++ b/app/AdminAgent/Controllers/UserController.php @@ -104,10 +104,10 @@ class UserController extends AdminController //处理特殊字段 $form->agent_id = Admin::user()->id; - if (isset($form->status)) { //为防止行内编辑出错,此处需要加判断 + if (!is_null($form->status)) { //为防止行内编辑出错,此处需要加判断 $form->status = $form->status ? 1 : 0; } - if (isset($form->is_verify)) { //为防止行内编辑出错,此处需要加判断 + if (!is_null($form->is_verify)) { //为防止行内编辑出错,此处需要加判断 $form->is_verify = $form->is_verify ? 1 : 0; } From e82bc7e3fd7a0a9b9b7b8f7ad7f2e3df5acb1276 Mon Sep 17 00:00:00 2001 From: liapples Date: Thu, 26 Aug 2021 17:04:19 +0800 Subject: [PATCH 40/42] =?UTF-8?q?=E5=A2=9E=E5=8A=A0is=5Fnull=E5=88=A4?= =?UTF-8?q?=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/AdvertisingController.php | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/app/AdminAgent/Controllers/AdvertisingController.php b/app/AdminAgent/Controllers/AdvertisingController.php index b5286d9..51ef9e1 100644 --- a/app/AdminAgent/Controllers/AdvertisingController.php +++ b/app/AdminAgent/Controllers/AdvertisingController.php @@ -121,6 +121,17 @@ class AdvertisingController extends AdminController return $form->response()->error('数据不存在'); } + //处理特殊字段 + $form->hidden(['agent_id', 'url']); + $form->agent_id = Admin::user()->id; + if (!is_null($form->status)) { + $form->status = $form->status ? 1 : 0; + } + if (!is_null($form->type)) { + $form->url = $form->{'url-' . $form->type}; + $form->deleteInput(['url-0', 'url-1']); + } + //将null字段设置为空值,防止插入数据库出错 foreach ($form->input() as $k => $v) { if (is_null($v)) { @@ -128,13 +139,6 @@ class AdvertisingController extends AdminController } } - //处理特殊字段 - $form->hidden(['agent_id', 'url']); - $form->agent_id = Admin::user()->id; - $form->status = $form->status ? 1 : 0; - $form->url = $form->{'url-' . $form->type}; - $form->deleteInput(['url-0', 'url-1']); - //不允许编辑的字段 $form->ignore(['id', 'created_at', 'updated_at']); })->deleting(function (Form $form) { From a7ebe5a15e1b7dbca3c5de5731d40aa6d097b84b Mon Sep 17 00:00:00 2001 From: liapples Date: Thu, 26 Aug 2021 17:04:32 +0800 Subject: [PATCH 41/42] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=B7=AF=E7=94=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- routes/api.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/routes/api.php b/routes/api.php index c9993ad..7d49567 100644 --- a/routes/api.php +++ b/routes/api.php @@ -102,7 +102,10 @@ Route::namespace('App\Http\Controllers\Api') }); # 核销订单 - Route::post('verification/verify', 'VerificationController@verify'); + Route::prefix('verification')->group(function () { + Route::post('verify', 'VerificationController@verify'); + Route::post('qrcode', 'VerificationController@qrcode'); + }); # 短信息 Route::prefix('message')->group(function () { From a59757c0bed8a8ef30571a30b17159c7fb2ec03f Mon Sep 17 00:00:00 2001 From: liapples Date: Thu, 26 Aug 2021 17:10:18 +0800 Subject: [PATCH 42/42] =?UTF-8?q?=E5=9B=BE=E7=89=87=E5=A2=9E=E5=8A=A0uniqu?= =?UTF-8?q?eName?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Admin/Controllers/ProductController.php | 2 +- app/AdminAgent/Controllers/AgentProductController.php | 2 +- app/AdminAgent/Controllers/SpecialController.php | 3 +-- app/AdminSupplier/Controllers/ProductController.php | 2 +- 4 files changed, 4 insertions(+), 5 deletions(-) diff --git a/app/Admin/Controllers/ProductController.php b/app/Admin/Controllers/ProductController.php index e1fb588..2d43892 100644 --- a/app/Admin/Controllers/ProductController.php +++ b/app/Admin/Controllers/ProductController.php @@ -109,7 +109,7 @@ class ProductController extends AdminController ->options(array_slice($options, 1, null, true)) ->required(); $form->text('title')->required(); - $form->multipleImage('pictures')->required(); + $form->multipleImage('pictures')->required()->removable(false)->uniqueName(); $form->text('original_price')->required(); $form->text('price')->required(); $form->text('sale')->default(0); diff --git a/app/AdminAgent/Controllers/AgentProductController.php b/app/AdminAgent/Controllers/AgentProductController.php index e7aac28..ee27d4f 100644 --- a/app/AdminAgent/Controllers/AgentProductController.php +++ b/app/AdminAgent/Controllers/AgentProductController.php @@ -186,7 +186,7 @@ class AgentProductController extends AdminController /** 自定义内容 **/ $form->text('title'); - $form->multipleImage('pictures'); + $form->multipleImage('pictures')->removable(false)->uniqueName(); $form->editor('know'); $form->editor('content'); }); diff --git a/app/AdminAgent/Controllers/SpecialController.php b/app/AdminAgent/Controllers/SpecialController.php index 8894a9c..335b21b 100644 --- a/app/AdminAgent/Controllers/SpecialController.php +++ b/app/AdminAgent/Controllers/SpecialController.php @@ -100,8 +100,7 @@ class SpecialController extends AdminController } $form->display('id'); - $form->multipleImage('picture') - ->required()->removable(false)->uniqueName() + $form->multipleImage('picture')->required()->removable(false)->uniqueName() ->help('图片大小:750*490'); $form->multipleSelectTable('agent_product_id') ->title('选择在售产品')->required() diff --git a/app/AdminSupplier/Controllers/ProductController.php b/app/AdminSupplier/Controllers/ProductController.php index e898591..1834803 100644 --- a/app/AdminSupplier/Controllers/ProductController.php +++ b/app/AdminSupplier/Controllers/ProductController.php @@ -92,7 +92,7 @@ class ProductController extends AdminController $form->text('title')->required(); $form->text('price')->required(); $form->text('original_price')->required(); - $form->multipleImage('pictures')->required()->removable()->retainable(); + $form->multipleImage('pictures')->required()->removable(false)->retainable()->uniqueName(); $form->text('stock')->default(9999)->required(); $form->editor('know'); $form->editor('content')->required();