diff --git a/MySQL_change.sql b/MySQL_change.sql index cd6cbcf..b0ca76e 100644 --- a/MySQL_change.sql +++ b/MySQL_change.sql @@ -1,3 +1,83 @@ # 16:37 2021/9/16 ALTER TABLE `products` ADD COLUMN `service_persons` INT NOT NULL DEFAULT '1' COMMENT '涉及用户数' AFTER `content`; + +# 17:49 2021/9/17 +ALTER TABLE `suppliers` + CHANGE COLUMN `balance` `balance` DECIMAL(20,2) NOT NULL DEFAULT '0.00' COMMENT '余额' AFTER `area_id`, + CHANGE COLUMN `deposit_used` `deposit_used` DECIMAL(20,2) NOT NULL DEFAULT '0.00' COMMENT '交易金已消费' AFTER `balance`, + CHANGE COLUMN `deposit_frozen` `deposit_frozen` DECIMAL(20,2) NOT NULL DEFAULT '0.00' COMMENT '交易金冻结' AFTER `deposit_used`, + CHANGE COLUMN `deposit_normal` `deposit_normal` DECIMAL(20,2) NOT NULL DEFAULT '0.00' COMMENT '交易金正常' AFTER `deposit_frozen`; + +# 10:26 2021/9/18 增加industry_orders、industry_products两个表 +CREATE TABLE `industry_orders` ( + `id` INT(10) NOT NULL AUTO_INCREMENT, + `agent_id` INT(10) NOT NULL COMMENT '代理商ID', + `supplier_id` INT(10) NOT NULL COMMENT '供应商ID', + `order_no` CHAR(22) NOT NULL COMMENT '订单号' COLLATE 'utf8_general_ci', + `industry_product_id` INT(10) NOT NULL COMMENT '行业产品ID', + `num` INT(10) NOT NULL COMMENT '购买数量', + `price` DECIMAL(20,2) NOT NULL COMMENT '订单总价格', + `name` VARCHAR(20) NOT NULL COMMENT '客户姓名' COLLATE 'utf8_general_ci', + `mobile` CHAR(11) NOT NULL COMMENT '手机号' COLLATE 'utf8_general_ci', + `title` VARCHAR(255) NOT NULL COMMENT '产品名称' COLLATE 'utf8_general_ci', + `picture` VARCHAR(255) NOT NULL COMMENT '产品图片' COLLATE 'utf8_general_ci', + `status` TINYINT(3) NOT NULL DEFAULT '0' COMMENT '订单状态,-1:已取消;0:待付款;1:已付订金/定金/首付款;2:已付全款;3:已付尾款;4:线下未支付;5:线下已支付;6:退款中;7:已退款;8:拒绝退款;16:已完成;', + `pay_type` TINYINT(3) NOT NULL DEFAULT '0' COMMENT '支付方式,0:在线支付,1:线下支付,2:订金支付,3:定金支付,4:首款支付;5:追加/尾款支付;【注:订单生成后不应该再修改此项的值】', + `paid_at` TIMESTAMP NULL DEFAULT NULL COMMENT '付款时间', + `verify_code` CHAR(13) NOT NULL DEFAULT '' COMMENT '核销码' COLLATE 'utf8_general_ci', + `timeout` TIMESTAMP NULL DEFAULT NULL COMMENT '订单超时时间,超过这个时间,订单将变为“已取消”', + `created_at` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP, + `updated_at` TIMESTAMP NULL DEFAULT NULL, + `deleted_at` TIMESTAMP NULL DEFAULT NULL, + PRIMARY KEY (`id`) USING BTREE, + UNIQUE INDEX `order_no` (`order_no`) USING BTREE, + INDEX `agent_id` (`agent_id`) USING BTREE, + INDEX `mobile` (`mobile`) USING BTREE, + INDEX `user_id` (`supplier_id`) USING BTREE +) +COMMENT='行业产品订单表' +COLLATE='utf8_general_ci' +ENGINE=InnoDB; + +CREATE TABLE `industry_products` ( + `id` INT(10) NOT NULL AUTO_INCREMENT, + `supplier_id` INT(10) NOT NULL COMMENT '供应商ID', + `category_id` INT(10) NOT NULL COMMENT '分类ID', + `type` TINYINT(3) NOT NULL DEFAULT '0' COMMENT '0:旅游线路、1:洒店、2:景区、3:餐厅、4:车队、5:单项', + `title` VARCHAR(255) NOT NULL COMMENT '标题' COLLATE 'utf8_general_ci', + `price` DECIMAL(20,2) NOT NULL COMMENT '售价', + `original_price` DECIMAL(20,2) NOT NULL DEFAULT '0.00' COMMENT '原价', + `pictures` TEXT NOT NULL COMMENT '产品图片,可能有多张,JSON格式' COLLATE 'utf8_general_ci', + `stock` INT(10) NOT NULL DEFAULT '0' COMMENT '库存量', + `sale` INT(10) NOT NULL DEFAULT '0' COMMENT '销量', + `status` TINYINT(3) NOT NULL DEFAULT '0' COMMENT '-2:下架,-1:审核拒绝,0:未审核,1:上架', + `know` TEXT NULL DEFAULT NULL COMMENT '旅客须知' COLLATE 'utf8_general_ci', + `content` MEDIUMTEXT NULL DEFAULT NULL COMMENT '产品详情' COLLATE 'utf8_general_ci', + `service_persons` INT(10) NOT NULL DEFAULT '1' COMMENT '涉及用户数', + `min_sale` INT(10) NOT NULL DEFAULT '0' COMMENT '起售数', + `verify_mobile` VARCHAR(15) NOT NULL DEFAULT '' COMMENT '核销人员手机号' COLLATE 'utf8mb4_unicode_ci', + `extends` JSON NULL DEFAULT NULL, + `created_at` TIMESTAMP NULL DEFAULT NULL, + `updated_at` TIMESTAMP NULL DEFAULT NULL, + `deleted_at` TIMESTAMP NULL DEFAULT NULL, + PRIMARY KEY (`id`) USING BTREE, + INDEX `supplier_id` (`supplier_id`) USING BTREE +) +COMMENT='行业产品表' +COLLATE='utf8_general_ci' +ENGINE=InnoDB; + +# 13:28 2021/9/18 +ALTER TABLE `industry_orders` + ADD COLUMN `deposit` DECIMAL(20,2) NOT NULL DEFAULT 0 COMMENT '需要扣除的交易金数量' AFTER `verify_code`; + +# 15:59 2021/9/18 +ALTER TABLE `agent_products` + CHANGE COLUMN `guide_id` `guide_id` INT(10) NOT NULL DEFAULT '0' COMMENT '绑定地接(计调版旅行社才能绑定)' AFTER `category_id`, + CHANGE COLUMN `type` `type` TINYINT(3) NOT NULL DEFAULT '0' COMMENT '0:单品销售;1:组合销售;2:计调旅行社的云产品;' AFTER `is_rec`, + CHANGE COLUMN `is_cloud` `is_cloud` TINYINT(3) NOT NULL DEFAULT '0' COMMENT '是否是(计调旅行社特有)云产品,。0:否;1:是;' AFTER `earnest_timeout`, + CHANGE COLUMN `agent_cloud_pid` `agent_cloud_pid` INT(10) NOT NULL DEFAULT '0' COMMENT '计调版旅行社的云产品ID' AFTER `is_cloud`; +ALTER TABLE `orders` + CHANGE COLUMN `agent_cloud_pid` `agent_cloud_pid` INT(10) NOT NULL DEFAULT '0' COMMENT '计调云产品ID' AFTER `verify_code`, + CHANGE COLUMN `agent_cloud_price` `agent_cloud_price` DECIMAL(20,2) NOT NULL DEFAULT '0.00' COMMENT '计调云产品销售价格' AFTER `agent_cloud_pid`; diff --git a/app/Admin/Controllers/AgentController.php b/app/Admin/Controllers/AgentController.php index 94d52f5..6aa2020 100644 --- a/app/Admin/Controllers/AgentController.php +++ b/app/Admin/Controllers/AgentController.php @@ -46,7 +46,7 @@ class AgentController extends AdminController $grid->column('license_pic')->image('', 60, 60); $grid->column('director'); $grid->column('contact_phone'); - $grid->column('rate')->editable()->help('分成百分比,如10%,则输入10'); + //$grid->column('rate')->editable()->help('分成百分比,如10%,则输入10'); $grid->column('created_at'); $last_template_id = MiniProgramTemplate::max('template_id'); @@ -128,7 +128,7 @@ class AgentController extends AdminController $show->field('contact_phone'); $show->field('legal_persona_name'); $show->field('legal_persona_wechat'); - $show->field('rate'); + //$show->field('rate'); $show->field('agentInfo.about', '关于我们') ->unescape() ->as(function ($v) { @@ -192,7 +192,7 @@ class AgentController extends AdminController $form->text('contact_phone'); $form->text('legal_persona_name')->required()->maxLength(20)->help('很重要,注册小程序时需要用到,用于实名认证'); $form->text('legal_persona_wechat')->required()->maxLength(100)->help('很重要,用于接收实名认证信息,不能是手机号或QQ号,微信号请前往微信“我的”页面查看'); - $form->number('rate')->min(0)->max(100)->help('分成百分比,如10%,则输入10'); + //$form->number('rate')->min(0)->max(100)->help('分成百分比,如10%,则输入10'); $form->editor('agentInfo.about', '关于我们');// 隐藏菜单用:->options(['menubar' => false]); $form->editor('agentInfo.reg_protocol', '注册协议'); $form->editor('agentInfo.buy_protocol', '购买协议'); @@ -204,10 +204,10 @@ class AgentController extends AdminController } } - //抽成比例 - if ($form->rate < 0 || $form->rate > 100) { - return $form->response()->error('抽成比例在 0 ~ 100 之间'); - } + ////抽成比例 + //if ($form->rate < 0 || $form->rate > 100) { + // return $form->response()->error('抽成比例在 0 ~ 100 之间'); + //} //不允许编辑的字段 if ($form->isEditing()) { @@ -252,7 +252,7 @@ class AgentController extends AdminController 'license_pic' => $form->model()->license_pic, 'director' => $form->model()->director, 'contact_phone' => $form->model()->contact_phone, - 'rate' => $form->model()->password, + //'rate' => $form->model()->password, ]); //插入权限表 DB::table(config('admin-supplier.database.role_users_table')) diff --git a/app/Admin/Controllers/GuideController.php b/app/Admin/Controllers/GuideController.php index 19469cc..22eadc5 100644 --- a/app/Admin/Controllers/GuideController.php +++ b/app/Admin/Controllers/GuideController.php @@ -36,7 +36,7 @@ class GuideController extends AdminController $grid->column('photo')->image('', 60, 60); $grid->column('license_pic')->image('', 60, 60); $grid->column('contact_phone'); - $grid->column('rate')->editable()->help('分成百分比,如10%,则输入10'); + //$grid->column('rate')->editable()->help('分成百分比,如10%,则输入10'); $grid->column('created_at'); $grid->column('status', '状态') @@ -84,7 +84,7 @@ class GuideController extends AdminController $show->field('photo')->image('', 80, 80); $show->field('license_pic')->image('', 80, 80); $show->field('contact_phone'); - $show->field('rate'); + //$show->field('rate'); $show->field('created_at'); $show->field('updated_at'); }); @@ -117,7 +117,7 @@ class GuideController extends AdminController $form->image('photo')->removable(false)->uniqueName(); $form->image('license_pic')->removable(false)->uniqueName(); $form->text('contact_phone'); - $form->number('rate')->min(0)->max(100)->help('分成百分比,如10%,则输入10'); + //$form->number('rate')->min(0)->max(100)->help('分成百分比,如10%,则输入10'); })->saving(function (Form $form) { //判断账号是否唯一 if ($form->isCreating()) { @@ -127,9 +127,9 @@ class GuideController extends AdminController } //抽成比例 - if ($form->rate < 0 || $form->rate > 100) { - return $form->response()->error('抽成比例在 0 ~ 100 之间'); - } + //if ($form->rate < 0 || $form->rate > 100) { + // return $form->response()->error('抽成比例在 0 ~ 100 之间'); + //} //不允许编辑的字段 if ($form->isEditing()) { diff --git a/app/Admin/Controllers/IndustryProductController.php b/app/Admin/Controllers/IndustryProductController.php new file mode 100644 index 0000000..326b4b6 --- /dev/null +++ b/app/Admin/Controllers/IndustryProductController.php @@ -0,0 +1,122 @@ +disableCreateButton(); + $grid->disableDeleteButton(); + $grid->disableEditButton(); + + //如果是审核页面,多加where条件判断 + if (strpos(Route::current()->uri, 'audit')) { + $grid->model()->where('status', UserStatus::UNAUDITED); + } + + $grid->column('id')->sortable(); + $grid->column('type')->using(admin_trans('product.options.publish_type')); + $grid->column('category.name', '分类'); + $grid->column('title')->limit(15); + $grid->column('picture')->image('', 60,60); + $grid->column('price'); + $grid->column('original_price'); + $grid->column('stock'); + $grid->column('sale'); + $grid->column('status') + ->if(fn() => $this->status == ProductStatus::UNAUDITED) + ->display('') + ->then(function ($column) { + $column->append((new AuditIndustryProduct(null, 1))->setKey($this->id))->append(' '); + $column->append((new AuditIndustryProduct(null, 2))->setKey($this->id)); + }) + ->else() + ->using(ProductStatus::array()) + ->dot([ + ProductStatus::ON_SALE => 'success', + ProductStatus::UNAUDITED => '', + ProductStatus::REFUSE => 'danger', + ProductStatus::SOLD_OUT => 'warning', + ], 'primary'); + $grid->column('service_persons'); + $grid->column('min_sale'); + $grid->column('created_at'); + + $grid->filter(function (Grid\Filter $filter) { + $filter->equal('id')->width(2); + + }); + }); + } + + /** + * Make a show builder. + * + * @param mixed $id + * + * @return Show + */ + protected function detail($id) + { + return Show::make($id, new IndustryProduct(['category:id,name', 'supplier:id,name,contact_phone']), function (Show $show) { + $show->disableDeleteButton(); + $show->disableEditButton(); + + $show->field('id'); + $show->field('supplier.name', '供应商'); + $show->field('supplier.contact_phone', '供应商联系电话'); + $show->field('category.name', '分类'); + $show->field('type')->using(admin_trans('product.options.publish_type')); + $show->field('title'); + $show->field('pictures')->image('', 80, 80); + $show->field('price'); + $show->field('original_price'); + $show->field('stock'); + $show->field('sale'); + $show->field('status')->using(ProductStatus::array()); + $show->field('know')->unescape()->as(fn($v) => preg_replace('/.*?<\/script>/is', '', $v)); + $show->field('content')->unescape()->as(fn($v) => preg_replace('/.*?<\/script>/is', '', $v)); + $show->field('service_persons'); + $show->field('min_sale'); + $show->field('verify_mobile'); + $show->field('created_at'); + $show->field('updated_at'); + }); + } + + /** + * Make a form builder. + * + * @return Form + */ + protected function form() + { + return Form::make(new IndustryProduct(['supplier:id,name', 'category:id,name']), function (Form $form) { + $form->disableDeleteButton(); + + $form->display('id'); + $form->select('status')->options(ProductStatus::array()); + })->saving(function (Form $form) { + return $form->response()->error('操作禁止!')->refresh(); //禁止编辑,如果非要编辑的话,记录冻结和解决交易金 + })->deleting(function (Form $form) { + return $form->response()->error('操作禁止!')->refresh(); + }); + } +} diff --git a/app/Admin/Controllers/OrderController.php b/app/Admin/Controllers/OrderController.php index 5935cd5..fd9d248 100644 --- a/app/Admin/Controllers/OrderController.php +++ b/app/Admin/Controllers/OrderController.php @@ -105,6 +105,7 @@ class OrderController extends AdminController $show->field('status')->using(OrderStatus::array()); $show->field('title'); $show->field('user_id'); + $show->field('timeout'); $show->field('created_at'); $show->field('updated_at'); }); diff --git a/app/Admin/Controllers/ServicePersonsSettingController.php b/app/Admin/Controllers/ServicePersonsSettingController.php new file mode 100755 index 0000000..e2f61e1 --- /dev/null +++ b/app/Admin/Controllers/ServicePersonsSettingController.php @@ -0,0 +1,17 @@ +title('交易设置') + ->body(new Card(new ServicePersonsSetting())); + } +} diff --git a/app/Admin/Controllers/SupplierController.php b/app/Admin/Controllers/SupplierController.php index 3b55a28..fbca881 100644 --- a/app/Admin/Controllers/SupplierController.php +++ b/app/Admin/Controllers/SupplierController.php @@ -42,7 +42,7 @@ class SupplierController extends AdminController $grid->column('license_pic')->image('', 60,60); $grid->column('director'); $grid->column('contact_phone'); - $grid->column('rate')->editable()->help('分成百分比,如10%,则输入10'); + //$grid->column('rate')->editable()->help('分成百分比,如10%,则输入10'); $grid->column('created_at'); $grid->column('status', '状态') @@ -92,7 +92,7 @@ class SupplierController extends AdminController $show->field('license_pic')->image('', 60, 60); $show->field('director'); $show->field('contact_phone'); - $show->field('rate'); + //$show->field('rate'); $show->field('publish_type') ->as(function ($value) { if (!is_array($value)) return ''; @@ -140,7 +140,7 @@ class SupplierController extends AdminController $form->image('license_pic')->removable(false)->uniqueName(); $form->text('director'); $form->mobile('contact_phone'); - $form->number('rate')->min(0)->max(100)->help('分成百分比,如10%,则输入10'); + //$form->number('rate')->min(0)->max(100)->help('分成百分比,如10%,则输入10'); $form->checkbox('publish_type') ->options(admin_trans('product.options.publish_type')) ->default(0) @@ -154,9 +154,9 @@ class SupplierController extends AdminController } //抽成比例 - if ($form->rate < 0 || $form->rate > 100) { - return $form->response()->error('抽成比例在 0 ~ 100 之间'); - } + //if ($form->rate < 0 || $form->rate > 100) { + // return $form->response()->error('抽成比例在 0 ~ 100 之间'); + //} //不允许编辑的字段 if ($form->isEditing()) { diff --git a/app/Admin/Extensions/Grid/AuditAgent.php b/app/Admin/Extensions/Grid/AuditAgent.php index d36055f..4a5e171 100644 --- a/app/Admin/Extensions/Grid/AuditAgent.php +++ b/app/Admin/Extensions/Grid/AuditAgent.php @@ -112,9 +112,9 @@ class AuditAgent extends RowAction //插入权限表 if ($user->status == UserStatus::NORMAL) { $roleArr = [ - AgentType::CLUSTER => 4, //计调旅行社 role_id - AgentType::SUPPLIER => 2, //供应商旅行社 role_id - AgentType::OPERATOR => 3, //组团旅行社 role_id + AgentType::SUPPLIER => 2, //供应商旅行社,对应后台的角色role_id + AgentType::CLUSTER => 3, //计调旅行社,对应后台的角色role_id + AgentType::OPERATOR => 4, //组团旅行社,对应后台的角色role_id ]; DB::table(config('admin-agent.database.role_users_table')) ->insertOrIgnore(['role_id' => $roleArr[$user->type], 'user_id' => $this->getKey()]); diff --git a/app/Admin/Extensions/Grid/AuditIndustryProduct.php b/app/Admin/Extensions/Grid/AuditIndustryProduct.php new file mode 100644 index 0000000..9672738 --- /dev/null +++ b/app/Admin/Extensions/Grid/AuditIndustryProduct.php @@ -0,0 +1,88 @@ +action = $action; //$action:1=通过;2=拒绝 + $this->title = $action == 1 ? '通过' : '拒绝'; + } + + protected function html() + { + $class = $this->action == 1 ? 'btn btn-sm btn-success' : 'btn btn-sm btn-danger'; + $this->appendHtmlAttribute('class', $class); + $this->defaultHtmlAttribute('href', 'javascript:;'); + + return "formatHtmlAttributes()}>{$this->title}"; + } + + public function handle(Request $request) + { + DB::beginTransaction(); + try { + //修改产品状态 + $industry = IndustryProduct::find($this->getKey()); + $industry->status = $request->action == 1 ? ProductStatus::ON_SALE : ProductStatus::REFUSE; + $industry->save(); + + //如果是通过,扣除交易金,如果拒绝返还冻结金额 + $single = SystemSetting::val('single', 'price'); //单人头交易金 + + $supplier = Supplier::find(Admin::user()->id); + + $change_deposit = $single * $industry->stock * $industry->service_persons; + if ($industry->status == ProductStatus::ON_SALE) { + if ($supplier->deposit_normal < $change_deposit) { + throw new \Exception('交易金不足,无法扣除'); + } + + $supplier->deposit_normal = $supplier->deposit_normal - $change_deposit; + $supplier->deposit_frozen = $supplier->deposit_frozen + $change_deposit; + $supplier->save(); + } /*else if ($industry->status == ProductStatus::REFUSE) { //拒绝无需处理 + if ($supplier->deposit_frozen < $change_deposit) { + throw new \Exception('冻结金不足,无法扣除'); + } + + $supplier->deposit_normal = $supplier->deposit_normal + $change_deposit; + $supplier->deposit_frozen = $supplier->deposit_frozen - $change_deposit; + $supplier->save(); + }*/ + + DB::commit(); + return $this->response()->success("审核成功")->refresh(); + } catch (\Exception $e) { + DB::rollBack(); + return $this->response()->error($e->getMessage()); + } + } + + public function confirm() + { + return ['确定要'.$this->title.'该产品吗?', '']; + } + + public function parameters() + { + return ['action' => $this->action]; + } +} diff --git a/app/Admin/Forms/ServicePersonsSetting.php b/app/Admin/Forms/ServicePersonsSetting.php new file mode 100644 index 0000000..00fab2d --- /dev/null +++ b/app/Admin/Forms/ServicePersonsSetting.php @@ -0,0 +1,56 @@ +firstOrCreate([ + 'key' => 'single' + ]); + + $arr = [ + 'price' => $input['price'], + ]; + $system->value = $arr; + $system->save(); + return $this + ->response() + ->success('设置成功') + ->refresh(); + } + + /** + * Build a form here. + */ + public function form() + { + $this->decimal('price','单人头交易费')->rules('required|numeric|min:0|not_in:0',[ + '*' => '金额为必填字段且必须大于0', + ]); + } + + /** + * The data of the form. + * + * @return array + */ + public function default() + { + $system = \App\Models\SystemSetting::query()->where('key','single')->value('value'); + return [ + 'price' => $system['price'] ?? 0, + ]; + } +} diff --git a/app/Admin/Repositories/IndustryProduct.php b/app/Admin/Repositories/IndustryProduct.php new file mode 100644 index 0000000..08e9da2 --- /dev/null +++ b/app/Admin/Repositories/IndustryProduct.php @@ -0,0 +1,16 @@ +resource('agent_product/audit', 'AgentProductController'); $router->resource('demand/product', 'DemandProductController'); + $router->resource('industry_product/list', 'IndustryProductController'); + $router->resource('industry_product/audit', 'IndustryProductController'); + $router->resource('finance_statistics', 'FinanceStatisticsController'); $router->resource('order_statistics', 'OrderStatisticsController'); $router->resource('user_statistics', 'UserStatisticsController'); @@ -46,4 +49,5 @@ Route::group([ $router->resource('withdrawal', 'WithdrawalController'); $router->resource('system', 'SystemSettingController'); $router->resource('deposit', 'DepositController'); + $router->resource('setting_single', 'ServicePersonsSettingController'); }); diff --git a/app/AdminAgent/Controllers/AgentProductController.php b/app/AdminAgent/Controllers/AgentProductController.php index 035321a..9e3ffb0 100644 --- a/app/AdminAgent/Controllers/AgentProductController.php +++ b/app/AdminAgent/Controllers/AgentProductController.php @@ -177,7 +177,7 @@ class AgentProductController extends AdminController $form->display('id'); - //组团版旅行社不允许选择组团云产品 + //计调版旅行社不允许选择计调云产品 if (Admin::user()->type == AgentType::CLUSTER) { $form->hidden('product_id')->value(0)->default(0); $form->hidden('type')->value(1)->default(1); @@ -196,7 +196,7 @@ class AgentProductController extends AdminController $form->editor('content'); } else { $form->radio('type') - ->options(['单品销售', '组合销售', '组团云产品']) + ->options(['单品销售', '组合销售', '计调云产品']) ->default(Admin::user()->type == AgentType::CLUSTER ? 1 : 0)->required() ->help('单品销售无需审核,组合销售需要审核才能上架') ->when(0, function (Form $form) { @@ -222,8 +222,8 @@ class AgentProductController extends AdminController $form->editor('know'); $form->editor('content'); })->when(2, function (Form $form) { - /** 组团云产品 **/ - $form->selectTable('agent_cloud_pid', '组团云产品') + /** 计调云产品 **/ + $form->selectTable('agent_cloud_pid', '计调云产品') ->help('产品列表显示的是该产品的标题和图片') ->title('选择产品') ->dialogWidth('80%;min-width:825px;') @@ -260,7 +260,7 @@ class AgentProductController extends AdminController // ->customFormat(fn($v) => !$v ? '' : $v) // ->required(); - //组团版旅行社可以选择地接 + //计调版旅行社可以选择地接 if (Admin::user()->type == AgentType::CLUSTER) { $form->selectTable('guide_id', '地接人员') ->title('选择地接人员') @@ -328,11 +328,11 @@ class AgentProductController extends AdminController return $form->response()->error('产品待审核或审核拒绝,不允许修改!'); } - //组团云产品处理 + //计调云产品处理 if ($form->type == 2) { $cloud_product = AgentProduct::find($form->agent_cloud_pid); if (!$cloud_product || $cloud_product->status != ProductStatus::ON_SALE) { - return $form->response()->error('你选择的组团云产品状态异常,上架失败!'); + return $form->response()->error('你选择的计调云产品状态异常,上架失败!'); } } @@ -410,13 +410,13 @@ class AgentProductController extends AdminController return $form->response()->error("产品售价不能小于供应商产品总售价{$total_price}"); } - //如果是组团版旅行社,标记为是云产品 + //如果是计调版旅行社,标记为是云产品 if (Admin::user()->type == AgentType::CLUSTER) { $form->hidden('is_cloud'); $form->is_cloud = 1; } } - //组团云产品 + //计调云产品 else if ($form->type == 2) { $form->agent_cloud_pid = (int)$form->agent_cloud_pid; if (!$form->agent_cloud_pid) { @@ -437,11 +437,11 @@ class AgentProductController extends AdminController })->find($form->agent_cloud_pid); if (!$cloud_product) { - return $form->response()->error('你选择的组团云产品库存不足或已下架,请重新选择'); + return $form->response()->error('你选择的计调云产品库存不足或已下架,请重新选择'); } else if ($cloud_product->stock < $form->stock) { - return $form->response()->error("组团云产品当前库存为{$cloud_product->stock},你设置的库存不能超过该数值"); + return $form->response()->error("计调云产品当前库存为{$cloud_product->stock},你设置的库存不能超过该数值"); } else if ($form->price < $cloud_product->price) { - return $form->response()->error("产品售价不能小于组团云产品售价{$cloud_product->price}"); + return $form->response()->error("产品售价不能小于计调云产品售价{$cloud_product->price}"); } //同步关键字段信息 @@ -543,7 +543,7 @@ class AgentProductController extends AdminController } } - //如果是组团云产品,且处于上架状态,同步信息到其它产品,否则下架所有关联的产品 + //如果是计调云产品,且处于上架状态,同步信息到其它产品,否则下架所有关联的产品 if ($form->is_cloud) { if ($form->status == ProductStatus::ON_SALE) { $data = [ diff --git a/app/AdminAgent/Controllers/DemandController.php b/app/AdminAgent/Controllers/DemandController.php index 4c1b0e7..37f664b 100755 --- a/app/AdminAgent/Controllers/DemandController.php +++ b/app/AdminAgent/Controllers/DemandController.php @@ -80,18 +80,32 @@ class DemandController extends AdminController }); }else{ $grid->column('bidding','竞标') - ->if(function (){ + ->display('') + ->if(function () { $isBidding = DemandBidding::query() ->where('demand_id',$this->id) ->where([ 'bidding_user_type' => DemandTraits::$col[0], 'bidding_user_id' => Admin::user()->id ]) - ->doesntExist(); + ->exists(); return $this->state == 1 && $this->bidding_user_type == Arr::first(DemandTraits::$col) && $isBidding; }) ->then(function (Grid\Column $column) { - $column->append('发起竞标'); + $column->display('已竞标'); + }) + ->if(function (){ + $isNotBidding = DemandBidding::query() + ->where('demand_id',$this->id) + ->where([ + 'bidding_user_type' => DemandTraits::$col[0], + 'bidding_user_id' => Admin::user()->id + ]) + ->doesntExist(); + return $this->state == 1 && $this->bidding_user_type == Arr::first(DemandTraits::$col) && $isNotBidding; + }) + ->then(function (Grid\Column $column) { + $column->append('参与竞标'); }); } diff --git a/app/AdminAgent/Controllers/IndustryOrderController.php b/app/AdminAgent/Controllers/IndustryOrderController.php new file mode 100644 index 0000000..72b5f5c --- /dev/null +++ b/app/AdminAgent/Controllers/IndustryOrderController.php @@ -0,0 +1,161 @@ +disableRowSelector(); + $grid->disableCreateButton(); + $grid->disableActions(); + + $grid->column('id')->sortable(); + $grid->column('supplier.name', '供应商'); + $grid->column('supplier.contact_phone', '供应商电话'); + $grid->column('order_no')->limit(10); + $grid->column('num'); + $grid->column('price'); + $grid->column('name', '预留姓名'); + $grid->column('mobile', '预留手机'); + $grid->column('title'); + $grid->column('picture')->image('', 80, 80); + $grid->column('status')->using(OrderStatus::array()); + $grid->column('paid_at', '订单确认时间'); + $grid->column('created_at'); + + $grid->filter(function (Grid\Filter $filter) { + $filter->equal('id')->width(2); + $filter->equal('order_no')->width(3); + }); + }); + } + + /** + * Make a show builder. + * + * @param mixed $id + * + * @return Show + */ + protected function detail($id) + { + /* return Show::make($id, new IndustryOrder(), function (Show $show) { + $show->field('id'); + $show->field('supplier_id'); + $show->field('agent_id'); + $show->field('order_no'); + $show->field('num'); + $show->field('price'); + $show->field('name'); + $show->field('mobile'); + $show->field('title'); + $show->field('picture')->image('', 80, 80); + $show->field('status'); + $show->field('pay_type'); + $show->field('paid_at'); + $show->field('verify_code'); + $show->field('timeout'); + $show->field('created_at'); + $show->field('updated_at'); + });*/ + } + + /** + * Make a form builder. + * + * @return Form + */ + protected function form() + { + $pid = request()->input('pid'); + $industry = IndustryProduct::where([ + ['status', '=', ProductStatus::ON_SALE], + ['stock', '>', 0], + ])->find($pid); + + return Form::make(new IndustryOrder(), function (Form $form) use ($industry) { + if (!$industry) { + Admin::exit('产品已下架或库存不足'); + } + + $form->hidden('pid')->value($industry->id); //pid要跟上面的request中的一样,否则提交出错 + $form->number('num') + ->min($industry->min_sale)->required() + ->default($industry->min_sale); + $form->text('name')->default(Admin::user()->director)->required(); + $form->mobile('mobile')->default(Admin::user()->contact_phone)->required(); + + $form->divider(); + $form->text('', '购买产品')->default($industry->title)->disable(); + $form->text('', '单价')->default($industry->price)->disable(); + $form->text('', '库存')->default($industry->stock)->disable(); + $form->text('', '涉及用户数')->default($industry->service_persons)->disable(); + $form->text('', '起购数量')->default($industry->min_sale)->disable(); + $form->image('picture', '产品图')->default($industry->pictures)->disable(); + })->saving(function (Form $form) use ($industry) { + //禁止编辑 + if ($form->isEditing()) { + return $form->response()->error('操作禁止'); + } + + //判断最小起购数 + if ($form->num < $industry->min_sale) { + return $form->response()->error('购买数量不能小于最低起购数:' . $industry->min_sale); + } + + //判断产品状态和库存 + if (!$industry || $industry->status != ProductStatus::ON_SALE || $industry->stock < $form->num) { + return $form->response()->error('产品已下架或库存不足'); + } + + //生成订单号 + list($micro, $sec) = explode(' ', microtime()); + $micro = str_pad(floor($micro * 1000000), 6, 0, STR_PAD_LEFT); + $order_no = date('ymdHis', $sec) . $micro . mt_rand(1000, 9999); + + $form->deleteInput(['pid', 'picture']); + + $form->hidden(['industry_product_id', 'supplier_id', 'agent_id', 'order_no', 'price', 'title', 'picture', 'status', 'pay_type', 'paid_at', 'verify_code', 'timeout']); + + $form->name = $form->name ?? Admin::user()->director; + $form->mobile = $form->mobile ?? Admin::user()->contact_phone; + + $form->industry_product_id = $industry->id; + $form->supplier_id = $industry->supplier_id; + $form->agent_id = Admin::user()->id; + $form->order_no = $order_no; + $form->price = $form->num * $industry->price; + $form->title = $industry->title; + $form->picture = $industry->pictures[0] ?? '' ; + $form->status = OrderStatus::OFFLINE_UNPAID; + $form->pay_type = PayType::OFFLINE; + $form->paid_at = null; + $form->verify_code = ''; + $form->deposit = SystemSetting::val('single', 'price') * $form->num * $industry->service_persons; + $form->timeout = null; + })->saved(function (Form $form) { + return $form->response()->success('下单成功,请等待供应商审核订单')->script('history.go(-1)'); + })->deleting(function (Form $form) { + return $form->response()->error('操作禁止'); + }); + } +} diff --git a/app/AdminAgent/Controllers/IndustryProductController.php b/app/AdminAgent/Controllers/IndustryProductController.php new file mode 100644 index 0000000..62d6daf --- /dev/null +++ b/app/AdminAgent/Controllers/IndustryProductController.php @@ -0,0 +1,90 @@ +disableDeleteButton(); + $grid->disableRowSelector(); + $grid->disableCreateButton(); + $grid->disableEditButton(); + $grid->disableActions(); + + $grid->model()->where('status', ProductStatus::ON_SALE); + + $grid->column('id')->sortable(); + $grid->column('type')->using(admin_trans('product.options.publish_type')); + $grid->column('category.name', '分类'); + $grid->column('title')->limit(15); + $grid->column('picture')->image('', 60,60); + $grid->column('price'); + $grid->column('original_price'); + $grid->column('stock'); + $grid->column('sale'); + $grid->column('service_persons'); + $grid->column('min_sale'); + $grid->column('created_at'); + $grid->column('op', '操作') + ->if(fn() => true) + ->then(function ($column) { + $column->append('查看  '); + $column->append('购买'); + }); + + $grid->filter(function (Grid\Filter $filter) { + $filter->equal('id')->width(2); + + }); + }); + } + + /** + * Make a show builder. + * + * @param mixed $id + * + * @return Show + */ + protected function detail($id) + { + return Show::make($id, new IndustryProduct(['category:id,name', 'supplier:id,name,contact_phone']), function (Show $show) { + $show->disableEditButton(); + $show->disableDeleteButton(); + + $show->field('id'); + $show->field('supplier.name', '供应商'); + $show->field('supplier.contact_phone', '供应商联系电话'); + $show->field('category.name', '分类'); + $show->field('type')->using(admin_trans('product.options.publish_type')); + $show->field('title'); + $show->field('pictures')->image('', 80, 80); + $show->field('price'); + $show->field('original_price'); + $show->field('stock'); + $show->field('sale'); + $show->field('status')->using(ProductStatus::array()); + $show->field('know')->unescape()->as(fn($v) => preg_replace('/.*?<\/script>/is', '', $v)); + $show->field('content')->unescape()->as(fn($v) => preg_replace('/.*?<\/script>/is', '', $v)); + $show->field('service_persons'); + $show->field('min_sale'); + $show->field('verify_mobile'); + $show->field('created_at'); + $show->field('updated_at'); + }); + } +} diff --git a/app/AdminAgent/Controllers/NoticeController.php b/app/AdminAgent/Controllers/NoticeController.php index 080f5c7..7b1a47c 100644 --- a/app/AdminAgent/Controllers/NoticeController.php +++ b/app/AdminAgent/Controllers/NoticeController.php @@ -25,6 +25,7 @@ class NoticeController extends AdminController $grid->column('id')->sortable(); $grid->column('author'); $grid->column('title'); + $grid->column('status','是否启用')->switch(); $grid->column('sort')->editable()->width(120); $grid->column('created_at'); $grid->column('updated_at'); @@ -57,6 +58,7 @@ class NoticeController extends AdminController $show->field('author'); $show->field('title'); $show->field('content')->unescape(); + $show->field('status','是否启用'); $show->field('sort'); $show->field('created_at'); $show->field('updated_at'); @@ -80,6 +82,7 @@ class NoticeController extends AdminController $form->text('author')->default(Admin::user()->name); $form->text('title')->required(); $form->editor('content'); + $form->switch('status','是否启用'); $form->text('sort')->default(255); })->saving(function (Form $form) { //不允许修改非自己的数据 diff --git a/app/AdminAgent/Controllers/OrderController.php b/app/AdminAgent/Controllers/OrderController.php index 86a360a..9a186d6 100644 --- a/app/AdminAgent/Controllers/OrderController.php +++ b/app/AdminAgent/Controllers/OrderController.php @@ -178,6 +178,7 @@ class OrderController extends AdminController $show->field('picture')->image('', 80, 80); $show->field('status')->using(OrderStatus::array()); $show->field('pay_type')->using(PayType::array()); + $show->field('timeout'); $show->field('created_at'); $show->field('updated_at'); }); diff --git a/app/AdminAgent/Renderable/SelectAgentCloudProduct.php b/app/AdminAgent/Renderable/SelectAgentCloudProduct.php index 67acca4..d128258 100644 --- a/app/AdminAgent/Renderable/SelectAgentCloudProduct.php +++ b/app/AdminAgent/Renderable/SelectAgentCloudProduct.php @@ -8,7 +8,7 @@ use Dcat\Admin\Grid; use Dcat\Admin\Grid\LazyRenderable; /** - * 选择代理商组团云产品 + * 选择代理商计调云产品 * Class SelectProduct * @package App\AdminAgent\Renderable */ diff --git a/app/AdminAgent/Repositories/IndustryOrder.php b/app/AdminAgent/Repositories/IndustryOrder.php new file mode 100644 index 0000000..e536314 --- /dev/null +++ b/app/AdminAgent/Repositories/IndustryOrder.php @@ -0,0 +1,16 @@ +resource('order/list', 'OrderController'); $router->resource('advertising/list', 'AdvertisingController'); $router->resource('special/list', 'SpecialController'); - $router->resource('waterfall_ad/list', 'WaterfallAdController'); + + $router->resource('industry_product/list', 'IndustryProductController'); + $router->resource('industry_order/list', 'IndustryOrderController'); $router->resource('demand', 'DemandController'); $router->resource('demand_bidding', 'DemandBiddingController'); diff --git a/app/AdminGuide/Controllers/DemandBiddingController.php b/app/AdminGuide/Controllers/DemandBiddingController.php index 2b9cad1..18c64f0 100755 --- a/app/AdminGuide/Controllers/DemandBiddingController.php +++ b/app/AdminGuide/Controllers/DemandBiddingController.php @@ -2,7 +2,7 @@ namespace App\AdminGuide\Controllers; -use App\AdminAgent\Repositories\DemandBidding; +use App\AdminGuide\Repositories\DemandBidding; use App\Models\Demand; use App\Traits\DemandTraits; use Dcat\Admin\Admin; diff --git a/app/AdminGuide/Controllers/DemandController.php b/app/AdminGuide/Controllers/DemandController.php index 085f1d4..aa3afda 100755 --- a/app/AdminGuide/Controllers/DemandController.php +++ b/app/AdminGuide/Controllers/DemandController.php @@ -2,12 +2,9 @@ namespace App\AdminGuide\Controllers; -use App\AdminAgent\Actions\Grid\DemandConfirm; -use App\AdminAgent\Lazys\DemandBiddingLazys; -use App\Models\AgentProduct; -use App\Models\Product; +use App\AdminGuide\Lazys\DemandBiddingLazys; use App\Traits\ResponseHelper; -use App\AdminAgent\Repositories\Demand; +use App\AdminGuide\Repositories\Demand; use App\Models\DemandBidding; use Dcat\Admin\Admin; use Dcat\Admin\Form; @@ -79,18 +76,32 @@ class DemandController extends AdminController }); }else{ $grid->column('bidding','竞标') - ->if(function (){ + ->display('') + ->if(function () { $isBidding = DemandBidding::query() ->where('demand_id',$this->id) ->where([ 'bidding_user_type' => DemandTraits::$col[2], 'bidding_user_id' => Admin::user()->id ]) - ->doesntExist(); + ->exists(); return $this->state == 1 && $this->bidding_user_type == DemandTraits::$col[2] && $isBidding; }) ->then(function (Grid\Column $column) { - $column->append('发起竞标'); + $column->display('已竞标'); + }) + ->if(function (){ + $isNotBidding = DemandBidding::query() + ->where('demand_id',$this->id) + ->where([ + 'bidding_user_type' => DemandTraits::$col[2], + 'bidding_user_id' => Admin::user()->id + ]) + ->doesntExist(); + return $this->state == 1 && $this->bidding_user_type == DemandTraits::$col[2] && $isNotBidding; + }) + ->then(function (Grid\Column $column) { + $column->append('参与竞标'); }); } diff --git a/app/AdminGuide/Controllers/MyDemandProductController.php b/app/AdminGuide/Controllers/MyDemandProductController.php index 902aacd..ffeb391 100755 --- a/app/AdminGuide/Controllers/MyDemandProductController.php +++ b/app/AdminGuide/Controllers/MyDemandProductController.php @@ -2,14 +2,12 @@ namespace App\AdminGuide\Controllers; -use App\AdminAgent\Actions\Grid\DemandConfirm; -use App\AdminAgent\Lazys\DemandBiddingLazys; use App\Common\ProductStatus; use App\Models\AgentProduct; use App\Models\Channel; use App\Models\Product; use App\Traits\ResponseHelper; -use App\AdminAgent\Repositories\Demand; +use App\AdminGuide\Repositories\Demand; use App\Models\DemandBidding; use Dcat\Admin\Admin; use Dcat\Admin\Form; diff --git a/app/AdminGuide/Controllers/WorkorderController.php b/app/AdminGuide/Controllers/WorkorderController.php index b36cd0b..c31a0b4 100755 --- a/app/AdminGuide/Controllers/WorkorderController.php +++ b/app/AdminGuide/Controllers/WorkorderController.php @@ -2,7 +2,7 @@ namespace App\AdminGuide\Controllers; -use App\AdminAgent\Repositories\Workorder; +use App\AdminGuide\Repositories\Workorder; use App\Common\AgentType; use App\Http\Controllers\Controller; use App\Models\Agent; diff --git a/app/AdminGuide/Extensions/Grid/ChooseDemand.php b/app/AdminGuide/Extensions/Grid/ChooseDemand.php new file mode 100644 index 0000000..e120b9e --- /dev/null +++ b/app/AdminGuide/Extensions/Grid/ChooseDemand.php @@ -0,0 +1,86 @@ +id = $biddingId; + $this->title = '选中竞标'; + } + + protected function html() + { + $class = 'btn btn-sm btn-success'; + $this->appendHtmlAttribute('class', $class); + $this->defaultHtmlAttribute('href', 'javascript:;'); + + return "formatHtmlAttributes()}>{$this->title}"; + } + + public function handle(Request $request) + { + $demandBiddingId = request('bidding_id',0); + $demandBidding = DemandBidding::find($demandBiddingId); + if (empty($demandBidding)) { + return $this->response()->error('订单异常'); + } + + $demand = \App\Models\Demand::find($demandBidding->demand_id); + + if (empty($demand)) { + return $this->response()->error('订单异常'); + } + + DB::beginTransaction(); + try { + $demandBidding->state = 1; + $demandBidding->save(); + //改变订单状态 + $demand->bidding_id = $demandBidding->id; + $demand->bidding_user_id = $demandBidding->bidding_user_id; + $demand->state = DemandTraits::$stateKey[1]; + $demand->save(); + //如果是地接类型 绑定地接到订单 + if ($demand->bidding_user_type == DemandTraits::$col[2]){ + $agentProduct = AgentProduct::find($demand->agent_product_id); + $agentProduct->guide_id = $demandBidding->bidding_user_id; + $agentProduct->guide_price = $demandBidding->price; + $agentProduct->save(); + } + DB::commit(); + return $this->response()->success("选中竞标成功")->refresh(); + } catch (\Exception $e) { + Log::error('选中竞标失败::'.$e->getTraceAsString()); + DB::rollBack(); + return $this->response()->error($e->getMessage()); + } + } + + public function confirm() + { + return ['确定要选中该竞标吗?', '']; + } + + public function parameters() + { + return ['bidding_id' => $this->id]; + } +} diff --git a/app/AdminGuide/Lazys/DemandBiddingLazys.php b/app/AdminGuide/Lazys/DemandBiddingLazys.php new file mode 100644 index 0000000..cfe0285 --- /dev/null +++ b/app/AdminGuide/Lazys/DemandBiddingLazys.php @@ -0,0 +1,48 @@ +model()->where('demand_id',$demandId); + $grid->column('id'); + $grid->column('price','出价')->sortable(); + $grid->column('comment','内容'); + $grid->column('biddingUser.name','竞拍人'); + $grid->column('bidding','竞标') + ->if(function () use ($demand){ + return $demand->state == 1; + }) + ->then(function (Grid\Column $column) { + $column->append(new ChooseDemand($this->id)); + }) + ->if(function () use ($demand){ + return $demand->state == 2; + }) + ->then(function (Grid\Column $column) use ($demand){ + if ($demand->bidding_id == $this->id) { + $column->append('已中标'); + } else { + $column->append('未中标'); + } + }); + $grid->column('created_at'); + $grid->disableActions(); + $grid->disableRowSelector(); + }); + } +} diff --git a/app/AdminGuide/Repositories/Workorder.php b/app/AdminGuide/Repositories/Workorder.php new file mode 100755 index 0000000..a30407b --- /dev/null +++ b/app/AdminGuide/Repositories/Workorder.php @@ -0,0 +1,16 @@ + $this->id]); }); }else{ - $grid->column('bidding', '竞标') + $grid->column('bidding','竞标') + ->display('') ->if(function () { - // $isBidding 表示参加过竞标后不再显示 $isBidding = DemandBidding::query() ->where('demand_id',$this->id) ->where([ 'bidding_user_type' => DemandTraits::$col[1], 'bidding_user_id' => Admin::user()->id ]) - ->doesntExist(); + ->exists(); return $this->state == 1 && $this->bidding_user_type == DemandTraits::$col[1] && $isBidding; }) ->then(function (Grid\Column $column) { - $column->append('发起竞标'); + $column->display('已竞标'); + }) + ->if(function (){ + $isNotBidding = DemandBidding::query() + ->where('demand_id',$this->id) + ->where([ + 'bidding_user_type' => DemandTraits::$col[1], + 'bidding_user_id' => Admin::user()->id + ]) + ->doesntExist(); + return $this->state == 1 && $this->bidding_user_type == DemandTraits::$col[1] && $isNotBidding; }) - ->else() - ->display(''); + ->then(function (Grid\Column $column) { + $column->append('参与竞标'); + }); } $grid->column('created_at')->sortable(); diff --git a/app/AdminSupplier/Controllers/FinanceStatisticsController.php b/app/AdminSupplier/Controllers/FinanceStatisticsController.php index a7785e0..260a5a3 100755 --- a/app/AdminSupplier/Controllers/FinanceStatisticsController.php +++ b/app/AdminSupplier/Controllers/FinanceStatisticsController.php @@ -3,7 +3,6 @@ namespace App\AdminSupplier\Controllers; use App\AdminSupplier\Metrics\Examples\FinanceStatistics; -use App\AdminAgent\Metrics\Examples\ProductStatistics; use App\Common\OrderStatus; use App\Common\PayType; use App\Models\Order; diff --git a/app/AdminSupplier/Controllers/IndustryOrderController.php b/app/AdminSupplier/Controllers/IndustryOrderController.php new file mode 100644 index 0000000..6db573d --- /dev/null +++ b/app/AdminSupplier/Controllers/IndustryOrderController.php @@ -0,0 +1,144 @@ +disableCreateButton(); + $grid->disableRowSelector(); + $grid->disableActions(); + + $grid->model()->where('supplier_id', Admin::user()->id); + + $grid->column('id')->sortable(); + $grid->column('agent.name', '代理商名称'); + $grid->column('order_no'); + $grid->column('num'); + $grid->column('price'); + $grid->column('name'); + $grid->column('mobile'); + $grid->column('industry_product_id', '产品ID'); + $grid->column('title'); + $grid->column('picture')->image('', 60, 60); + $grid->column('status') + ->using(OrderStatus::array()) + ->if(fn() => $this->status == OrderStatus::OFFLINE_UNPAID) + ->action(new IndustryOrderStatus); + $grid->column('paid_at'); + $grid->column('verify_qrcode', '核销二维码') + ->if(fn() => $this->verify_code) + ->then(function ($column) { + $verify_code = $this->id . '-' . $this->verify_code; + $column->append(admin_url('industry_order/qrcode', $verify_code))->image('', 60, 60); + $column->append('
' . $verify_code); + }) + ->else() + ->display(''); +// $grid->column('timeout'); + $grid->column('created_at'); + + $grid->filter(function (Grid\Filter $filter) { + $filter->equal('id')->width(2); + $filter->equal('order_no')->width(3); + }); + }); + } + + //生成核销二维码,行业产品订单使用支付小程序核销 + public function qrcode() + { + $verify_code = request()->route('verify_code'); + + $qrcode = storage_path("app/public/industry_verify_code/$verify_code.jpg"); + if (file_exists($qrcode)) { + return redirect(Storage::disk('public')->url("industry_verify_code/$verify_code.jpg")); + } + + $setting = AdminSetting::val(['payee_appid', 'payee_appsecret']); + $config = [ + 'app_id' => $setting['payee_appid'], + 'secret' => $setting['payee_appsecret'], + ]; + $app = Factory::miniProgram($config); + + //由于参数最多只能32个字符,故通过下面这种方式传参 + //pt表示使用普通订单,使用api/verification/verify接口核销; + //hy表示行业产品订单,使用api/verification/industry_verify接口核销 + $response = $app->app_code->getUnlimit('hy' . $verify_code, ['page' => 'pages/verification/index']); + + if ($response instanceof StreamResponse) { + $filename = $response->saveAs(storage_path('app/public/industry_verify_code'), $verify_code); //保存二维码 + // $qrcode = Storage::disk('public')->url('industry_verify_code/' . $filename); //获取前端路径 + header("Content-Type: " . $response->getHeaderLine('Content-Type')); + exit($response); //输出图片 + } + } + + /** + * Make a show builder. + * + * @param mixed $id + * + * @return Show + */ + protected function detail($id) + { + /*return Show::make($id, new IndustryOrder(), function (Show $show) { + $show->field('id'); + $show->field('agent_id'); + $show->field('supplier_id'); + $show->field('order_no'); + $show->field('industry_product_id'); + $show->field('num'); + $show->field('price'); + $show->field('name'); + $show->field('mobile'); + $show->field('title'); + $show->field('picture'); + $show->field('status'); + $show->field('paid_at'); + $show->field('verify_code'); + $show->field('timeout'); + $show->field('created_at'); + $show->field('updated_at'); + });*/ + } + + /** + * Make a form builder. + * + * @return Form + */ + protected function form() + { + return Form::make(new IndustryOrder(), function (Form $form) { + $form->display('id'); +// $form->select('status')->options([OrderStatus::OFFLINE_PAID => '已付款']); + })->saving(function(Form $form) { + return $form->response()->error('操作禁止'); + })->deleting(function(Form $form) { + return $form->response()->error('操作禁止'); + }); + } +} diff --git a/app/AdminSupplier/Controllers/IndustryProductController.php b/app/AdminSupplier/Controllers/IndustryProductController.php new file mode 100644 index 0000000..cb53b09 --- /dev/null +++ b/app/AdminSupplier/Controllers/IndustryProductController.php @@ -0,0 +1,284 @@ +disableDeleteButton(); + $grid->disableRowSelector(); + + $grid->model()->where('supplier_id', Admin::user()->id); + + $grid->column('id')->sortable(); + $grid->column('type')->using(admin_trans('product.options.publish_type')); + $grid->column('category.name', '分类'); + $grid->column('title')->limit(15); + $grid->column('picture')->image('', 60,60); + $grid->column('price'); + $grid->column('original_price'); + $grid->column('stock'); + $grid->column('sale'); + $grid->column('status') + /*->if(fn() => in_array($this->status, [ProductStatus::SOLD_OUT, ProductStatus::ON_SALE])) + ->using([ProductStatus::SOLD_OUT => 0, ProductStatus::ON_SALE => 1]) + ->switch() + ->else()*/ + ->using(ProductStatus::array()); + $grid->column('service_persons'); + $grid->column('min_sale'); + $grid->column('created_at'); + + $grid->filter(function (Grid\Filter $filter) { + $filter->equal('id')->width(2); + + }); + }); + } + + /** + * Make a show builder. + * + * @param mixed $id + * + * @return Show + */ + protected function detail($id) + { + return Show::make($id, new IndustryProduct(['category:id,name']), function (Show $show) { + $show->disableDeleteButton(); + + //不允许查看非自己的数据 + if ($show->model()->agent_id != Admin::user()->id) { + Admin::exit('数据不存在'); + } + + $show->field('id'); + $show->field('type')->using(admin_trans('product.options.publish_type')); + $show->field('category.name', '分类'); + $show->field('title'); + $show->field('pictures')->image('', 80, 80); + $show->field('price'); + $show->field('original_price'); + $show->field('stock'); + $show->field('sale'); + $show->field('status')->using(ProductStatus::array()); + $show->field('know')->unescape()->as(fn($v) => preg_replace('/.*?<\/script>/is', '', $v)); + $show->field('content')->unescape()->as(fn($v) => preg_replace('/.*?<\/script>/is', '', $v)); + $show->field('service_persons'); + $show->field('min_sale'); + $show->field('verify_mobile'); + $show->field('created_at'); + $show->field('updated_at'); + }); + } + + /** + * Make a form builder. + * + * @return Form + */ + protected function form() + { + Admin::user()->publish_type = json_decode(Admin::user()->publish_type, true); + $change_deposit = 0; + return Form::make(new IndustryProduct(), function (Form $form) { + $form->disableDeleteButton(); + + $form->display('id'); + + $options = Category::selectOptions(fn($query) => $query->where('agent_id', 0)); + $form->select('category_id')->options(array_slice($options, 1, null, true))->required(); + $form->text('title')->required(); + $form->currency('price')->required(); + $form->currency('original_price')->required(); + $form->number('service_persons')->min(0)->required(); + $form->number('stock')->required(); + $form->number('min_sale')->min(1)->required(); + $form->radio('status')->options([1 => '上架', -2 => '下架'])->default(1); + $form->multipleImage('pictures')->required(); + $form->editor('know'); + $form->editor('content')->required(); + $form->mobile('verify_mobile')->required(); + + //扩展字段 + $publish_type = array_intersect_key( + admin_trans('product.options.publish_type'), + array_flip(Admin::user()->publish_type) + ); + + $form->radio('type', '产品类型') + ->options($publish_type)->disable($form->isEditing()) + ->default(current(Admin::user()->publish_type)) + ->when(0, function (Form $form) { //旅游线路 + if ($form->isEditing() && $form->model()->type != 0) { + return; + } + $form->table('extends.field_0.project', '包含项目', function (NestedForm $table) { + $table->text('name', '字段1'); + $table->text('num', '字段2'); + $table->text('price', '字段3'); + })->help('第一行数据默认是表头,如:项目名称、数量、额外费用'); + + $form->dateRange('extends.field_0.date.start', 'extends.field_0.date.end', '行程时间'); + })->when(1, function (Form $form) { //酒店 + if ($form->isEditing() && $form->model()->type != 1) { + return; + } + $default = [ + ['tag' => '行李寄存'], ['tag' => '24小时前台'], ['tag' => '前台保险柜'], ['tag' => '唤醒服务'], + ['tag' => '早餐'], ['tag' => '送餐服务'], ['tag' => '电梯'], ['tag' => '空调'], + ['tag' => '新风系统'], ['tag' => '24小时热水'], ['tag' => '吹风机'], ['tag' => '加湿器'], + ['tag' => '自动售货机'], ['tag' => '健身房'], ['tag' => '桌球室'], ['tag' => '洗衣服务'] + ]; + $form->table('extends.field_1.tags', '酒店设施', function (NestedForm $table) { + $table->text('tag', '包含项目')->placeholder('如:24小时热水、干洗服务等'); + })->value($default)->help('首次创建时,系统会默认填充基本服务,请根据本酒店情况进行删减或新增'); + + $form->text('extends.field_1.name', '酒店名'); + $form->text('extends.field_1.address', '地址'); + $form->map('extends.field_1.latitude', 'extends.field_1.longitude', '位置'); + })->when(2, function (Form $form) { //景区 + if ($form->isEditing() && $form->model()->type != 2) { + return; + } + $form->table('extends.field_2.open_time', '开放时间', function (NestedForm $table) { + $table->text('node', '字段1')->placeholder('如:周一至周五'); + $table->text('summer', '字段2')->placeholder('如:08:00~19:00'); + $table->text('winter', '字段3')->placeholder('如:08:00~18:00'); + })->help('第一行数据默认是表头,如:项目名称、数量、额外费用'); + + $form->table('extends.field_2.project', '包含项目', function (NestedForm $table) { + $table->text('name', '字段1'); + $table->text('num', '字段2'); + $table->text('price', '字段3'); + })->help('第一行数据默认是表头,如:项目名称、数量、额外费用'); + + $form->text('extends.field_2.name', '景区名'); + $form->text('extends.field_2.address', '地址'); + $form->map('extends.field_2.latitude', 'extends.field_2.longitude', '位置'); + })->when(3, function (Form $form) { //餐厅 + if ($form->isEditing() && $form->model()->type != 3) { + return; + } + $form->table('extends.field_3.open_time', '开放时间', function (NestedForm $table) { + $table->text('week', '字段1')->placeholder('如:周一至周五'); + $table->text('section', '字段2')->placeholder('如:上午/下午'); + $table->text('time', '字段3')->placeholder('如:08:00~18:00'); + })->help('第一行数据默认是表头,如:项目名称、数量、额外费用'); + + $form->table('extends.field_3.package', '包含套餐', function (NestedForm $table) { + $table->text('name', '字段1')->placeholder('如:清蒸鱿鱼'); + $table->text('num', '字段2')->placeholder('如:1条'); + $table->text('price', '字段3')->placeholder('如:99元'); + })->help('第一行数据默认是表头,如:项目名称、数量、额外费用'); + + $form->text('extends.field_3.name', '餐厅名'); + $form->text('extends.field_3.address', '地址'); + $form->map('extends.field_3.latitude', 'extends.field_3.longitude', '位置'); + }); + })->saving(function (Form $form) use (&$change_deposit) { + //不允许编辑非自己数据 + if ($form->isEditing() && $form->model()->supplier_id != Admin::user()->id) { + return $form->response()->error('数据不存在'); + } + + if ($form->isCreating()) { + if (!Admin::user()->publish_type || !in_array($form->type, Admin::user()->publish_type)) { + return $form->response()->error('对不起,你没有此类产品的发布、编辑权限'); + } + } else if ($form->isEditing()) { //type不允许编辑 + $form->deleteInput('type'); + } + + //忽略字段 + $form->ignore(['id', 'sale', 'created_at', 'updated_at', 'deleted_at']); + + $form->hidden(['status', 'supplier_id']); + $form->supplier_id = Admin::user()->id; + if ($form->isCreating()) { + $form->status = ProductStatus::UNAUDITED; + } else if ($form->isEditing() && in_array($form->model()->status, [ProductStatus::SOLD_OUT, ProductStatus::ON_SALE])) { //如果原来是下架或上架状态才允许修改 + $form->status = $form->status == ProductStatus::ON_SALE ? ProductStatus::ON_SALE : ProductStatus::SOLD_OUT; + } + + //处理交易金 + //判断交易金是否充足 + $single = SystemSetting::val('single', 'price'); //单人头交易费 + if (!$single) { + return $form->response()->error('未设置单人头交易费,请联系管理员在后台设置'); + } + + //TODO 还需要计算涉及用户数 + + //目前逻辑不考虑单人头交易费变动的情况 + if ($form->isCreating() || $form->isEditing() && $form->model()->stock != $form->stock) { + + if ($form->isCreating()) { //新增处理 + $change_deposit = $single * $form->service_persons * $form->stock; + } else if ($form->isEditing() && $form->model()->stock != $form->stock) { //库存变动时冻结或解冻相应的保证金 + $new_deposit = $single * $form->service_persons * $form->stock; + $old_deposit = $single * $form->service_persons * $form->model()->stock; + $change_deposit = $new_deposit - $old_deposit; //saved里面获取的$form->model()->stock是不对的 + } + + if (Admin::user()->deposit_normal < $change_deposit) { + return $form->response()->error('交易金不足,请先联系管理员充值'); + } + } + })->saved(function (Form $form, $result) use (&$change_deposit) { + if ($form->isEditing()) { //有extends判断不准 + //待审核 + if ($form->model()->wasChanged(['title', 'price', 'original_price', 'pictures', 'know', 'content'])) { + DB::beginTransaction(); + try { + //将产品状态改为未审核 + $form->model()->update(['status' => ProductStatus::UNAUDITED]); + + //如果产品未审核,重新计算交易金。通过或拒绝之后再扣掉 TODO 改变库存和涉及用户数要考虑。未审核也需要重新全部减掉 + $supplier = Supplier::query()->find(Admin::user()->id); //不能使用Admin::user()修改,必须使用Supplier模型才能正确记录资金变动日志 + + $supplier->deposit_normal = $supplier->deposit_normal - $change_deposit; //正常交易金 + $supplier->deposit_frozen = $supplier->deposit_frozen + $change_deposit; //冻结交易金 + $supplier->save(); + DB::commit(); + } catch (\Exception $e) { + DB::rollBack(); + } + } else { //不是待审核 + + } + } + + /*if ($result && ($form->isCreating() || $form->isEditing() && $form->model()->wasChanged('stock'))) { + + }*/ + })->deleting(function (Form $form) { + //不允许删除非自己的数据 + if (array_filter($form->model()->toArray(), fn($v) => $v['supplier_id'] != Admin::user()->id)) { + return $form->response()->error('数据不存在'); + } + }); + } +} diff --git a/app/AdminSupplier/Controllers/MyBiddingProductController.php b/app/AdminSupplier/Controllers/MyBiddingProductController.php index 383a6da..ab69f64 100755 --- a/app/AdminSupplier/Controllers/MyBiddingProductController.php +++ b/app/AdminSupplier/Controllers/MyBiddingProductController.php @@ -5,12 +5,11 @@ namespace App\AdminSupplier\Controllers; use App\Common\ProductStatus; use App\Traits\ResponseHelper; -use App\AdminAgent\Repositories\Demand; +use App\AdminSupplier\Repositories\Demand; use Dcat\Admin\Admin; use Dcat\Admin\Grid; use Dcat\Admin\Http\Controllers\AdminController; use App\Traits\DemandTraits; -use Dcat\Admin\Repositories\EloquentRepository; class MyBiddingProductController extends AdminController { diff --git a/app/AdminSupplier/Controllers/MyDemandProductController.php b/app/AdminSupplier/Controllers/MyDemandProductController.php index de1024d..8f42998 100755 --- a/app/AdminSupplier/Controllers/MyDemandProductController.php +++ b/app/AdminSupplier/Controllers/MyDemandProductController.php @@ -2,13 +2,11 @@ namespace App\AdminSupplier\Controllers; -use App\AdminAgent\Actions\Grid\DemandConfirm; -use App\AdminAgent\Lazys\DemandBiddingLazys; use App\Common\ProductStatus; use App\Models\AgentProduct; use App\Models\Product; use App\Traits\ResponseHelper; -use App\AdminAgent\Repositories\Demand; +use App\AdminSupplier\Repositories\Demand; use App\Models\DemandBidding; use Dcat\Admin\Admin; use Dcat\Admin\Form; diff --git a/app/AdminSupplier/Controllers/OrderController.php b/app/AdminSupplier/Controllers/OrderController.php index 611a1b6..ba47bf4 100644 --- a/app/AdminSupplier/Controllers/OrderController.php +++ b/app/AdminSupplier/Controllers/OrderController.php @@ -116,6 +116,7 @@ class OrderController extends AdminController $show->field('status')->using(OrderStatus::array()); $show->field('title'); $show->field('user_id'); + $show->field('timeout'); $show->field('created_at'); $show->field('updated_at'); }); diff --git a/app/AdminSupplier/Controllers/ProductController.php b/app/AdminSupplier/Controllers/ProductController.php index 6edecf4..e0404e9 100644 --- a/app/AdminSupplier/Controllers/ProductController.php +++ b/app/AdminSupplier/Controllers/ProductController.php @@ -37,7 +37,12 @@ class ProductController extends AdminController $grid->column('original_price'); $grid->column('stock'); $grid->column('sale'); - $grid->column('status')->using(ProductStatus::array()); + $grid->column('status') + /*->if(fn() => in_array($this->status, [ProductStatus::SOLD_OUT, ProductStatus::ON_SALE])) + ->using([ProductStatus::SOLD_OUT => 0, ProductStatus::ON_SALE => 1]) + ->switch() + ->else()*/ + ->using(ProductStatus::array()); $grid->column('verify_mobile','核销员手机'); $grid->column('created_at'); $grid->column('updated_at'); @@ -104,6 +109,7 @@ class ProductController extends AdminController $form->currency('original_price')->symbol('¥')->required(); $form->number('service_persons')->required(); $form->number('stock')->required(); + $form->radio('status')->options([1 => '上架', -2 => '下架'])->default(1); $form->multipleImage('pictures')->required()->removable(false)->retainable()->uniqueName(); $form->editor('know'); $form->editor('content')->required(); @@ -116,9 +122,12 @@ class ProductController extends AdminController ); $form->radio('type', '产品类型') - ->options($publish_type) + ->options($publish_type)->disable($form->isEditing()) ->default(current(Admin::user()->publish_type)) ->when(0, function (Form $form) { //旅游线路 + if ($form->isEditing() && $form->model()->type != 0) { + return; + } $form->table('extends.field_0.project', '包含项目', function (NestedForm $table) { $table->text('name', '字段1'); $table->text('num', '字段2'); @@ -127,6 +136,9 @@ class ProductController extends AdminController $form->dateRange('extends.field_0.date.start', 'extends.field_0.date.end', '行程时间'); })->when(1, function (Form $form) { //酒店 + if ($form->isEditing() && $form->model()->type != 1) { + return; + } $default = [ ['tag' => '行李寄存'], ['tag' => '24小时前台'], ['tag' => '前台保险柜'], ['tag' => '唤醒服务'], ['tag' => '早餐'], ['tag' => '送餐服务'], ['tag' => '电梯'], ['tag' => '空调'], @@ -141,6 +153,9 @@ class ProductController extends AdminController $form->text('extends.field_1.address', '地址'); $form->map('extends.field_1.latitude', 'extends.field_1.longitude', '位置'); })->when(2, function (Form $form) { //景区 + if ($form->isEditing() && $form->model()->type != 2) { + return; + } $form->table('extends.field_2.open_time', '开放时间', function (NestedForm $table) { $table->text('node', '字段1')->placeholder('如:周一至周五'); $table->text('summer', '字段2')->placeholder('如:08:00~19:00'); @@ -157,6 +172,9 @@ class ProductController extends AdminController $form->text('extends.field_2.address', '地址'); $form->map('extends.field_2.latitude', 'extends.field_2.longitude', '位置'); })->when(3, function (Form $form) { //餐厅 + if ($form->isEditing() && $form->model()->type != 3) { + return; + } $form->table('extends.field_3.open_time', '开放时间', function (NestedForm $table) { $table->text('week', '字段1')->placeholder('如:周一至周五'); $table->text('section', '字段2')->placeholder('如:上午/下午'); @@ -183,12 +201,16 @@ class ProductController extends AdminController return $form->response()->error('数据不存在'); } - if (!Admin::user()->publish_type || !in_array($form->type, Admin::user()->publish_type)) { - return $form->response()->error('对不起,你没有此类产品的发布、编辑权限'); + if ($form->isCreating()) { + if (!Admin::user()->publish_type || !in_array($form->type, Admin::user()->publish_type)) { + return $form->response()->error('对不起,你没有此类产品的发布、编辑权限'); + } + } else if ($form->isEditing()) { //type不允许编辑 + $form->deleteInput('type'); } //不允许编辑的字段,忽略字段不起作用? - $form->ignore(['id', 'supplier_id', 'sale', 'status', 'created_at', 'updated_at', 'deleted_at']); + $form->ignore(['id', 'supplier_id', 'sale', 'created_at', 'updated_at', 'deleted_at']); //null字段转为'' foreach ($form->input() as $k => $v) { @@ -202,6 +224,8 @@ class ProductController extends AdminController $form->hidden(['status', 'supplier_id']); //表单没有的字段,必须加上这句才能重置值 $form->supplier_id = Admin::user()->id; $form->status = ProductStatus::UNAUDITED; + } else if ($form->isEditing() && in_array($form->model()->status, [ProductStatus::SOLD_OUT, ProductStatus::ON_SALE])) { //如果原来是下架或上架状态才允许修改 + $form->status = $form->status == ProductStatus::ON_SALE ? ProductStatus::ON_SALE : ProductStatus::SOLD_OUT; } })->saved(function (Form $form, $result) { if ($form->isEditing() && $result) { diff --git a/app/AdminSupplier/Controllers/ProductStatisticsController.php b/app/AdminSupplier/Controllers/ProductStatisticsController.php index 8ef902e..77d4c8e 100755 --- a/app/AdminSupplier/Controllers/ProductStatisticsController.php +++ b/app/AdminSupplier/Controllers/ProductStatisticsController.php @@ -2,11 +2,7 @@ namespace App\AdminSupplier\Controllers; -use App\AdminAgent\Tools\DataReportDate; -use App\AdminAgent\Metrics\Examples\FinanceStatistics; -use App\AdminAgent\Metrics\Examples\OrderStatistics; use App\AdminSupplier\Metrics\Examples\ProductStatistics; -use App\AdminAgent\Metrics\Examples\UserStatistics; use App\Common\OrderStatus; use App\Common\ProductStatus; use App\Models\AgentProduct; diff --git a/app/AdminSupplier/Controllers/WithdrawalAlipayController.php b/app/AdminSupplier/Controllers/WithdrawalAlipayController.php index bda9fd6..ff194d8 100755 --- a/app/AdminSupplier/Controllers/WithdrawalAlipayController.php +++ b/app/AdminSupplier/Controllers/WithdrawalAlipayController.php @@ -2,7 +2,7 @@ namespace App\AdminSupplier\Controllers; -use App\AdminAgent\Repositories\WithdrawalAlipay; +use App\AdminSupplier\Repositories\WithdrawalAlipay; use App\Common\StatementType; use App\Models\Agent; use App\Models\Supplier; diff --git a/app/AdminSupplier/Controllers/WorkorderController.php b/app/AdminSupplier/Controllers/WorkorderController.php index 2bca5a5..1023808 100755 --- a/app/AdminSupplier/Controllers/WorkorderController.php +++ b/app/AdminSupplier/Controllers/WorkorderController.php @@ -2,7 +2,7 @@ namespace App\AdminSupplier\Controllers; -use App\AdminAgent\Repositories\Workorder; +use App\AdminSupplier\Repositories\Workorder; use App\Http\Controllers\Controller; use App\Models\Agent; use App\Models\AgentProductItem; diff --git a/app/AdminSupplier/Extensions/Grid/ChooseDemand.php b/app/AdminSupplier/Extensions/Grid/ChooseDemand.php index 6834bf5..9620f70 100644 --- a/app/AdminSupplier/Extensions/Grid/ChooseDemand.php +++ b/app/AdminSupplier/Extensions/Grid/ChooseDemand.php @@ -1,6 +1,6 @@ appendHtmlAttribute('class', $class); + $this->defaultHtmlAttribute('href', 'javascript:;'); + + return "formatHtmlAttributes()}>{$this->title}"; + } + + public function handle(Request $request) + { + $id = $this->getKey(); + DB::beginTransaction(); + try { + $order = IndustryOrder::where(['id' => $id, 'status' => OrderStatus::OFFLINE_UNPAID])->find($id); + //操作订单表 + $order->status = OrderStatus::OFFLINE_PAID; + $order->paid_at = now(); + $order->verify_code = uniqid(); + $order->save(); + + //减库存 + $affect_row = IndustryProduct::where([ + ['id', '=', $order->industry_product_id], + ['stock', '>=', $order->num], + ])->decrement('stock', $order->num); + + if (!$affect_row) { + throw new \Exception('库存不足,请先增加库存'); + } + + //扣除交易金 + $supplier = Supplier::find(Admin::user()->id); //不能使用Admin::user()修改,必须使用Supplier模型才能正确记录资金变动日志 + $supplier->deposit_used = $supplier->deposit_used + $order->deposit; + $supplier->deposit_frozen = $supplier->deposit_frozen - $order->deposit; + $supplier->save(); + + DB::commit(); + return $this->response()->success('操作成功'); + } catch (\Exception $e) { + DB::rollBack(); + return $this->response()->error($e->getMessage()); + } + + } + + public function confirm() + { + return ['确定要设置为已付款吗?', '']; + } +} diff --git a/app/AdminSupplier/Lazys/DemandBiddingLazys.php b/app/AdminSupplier/Lazys/DemandBiddingLazys.php index 306efd5..d0876c6 100644 --- a/app/AdminSupplier/Lazys/DemandBiddingLazys.php +++ b/app/AdminSupplier/Lazys/DemandBiddingLazys.php @@ -3,8 +3,8 @@ namespace App\AdminSupplier\Lazys; -use App\AdminAgent\Extensions\Grid\ChooseDemand; -use App\AdminAgent\Repositories\DemandBidding; +use App\AdminSupplier\Extensions\Grid\ChooseDemand; +use App\AdminSupplier\Repositories\DemandBidding; use App\Models\Demand; use App\Traits\DemandTraits; use Dcat\Admin\Grid; diff --git a/app/AdminSupplier/Lazys/ProductForm.php b/app/AdminSupplier/Lazys/ProductForm.php new file mode 100644 index 0000000..37b82cb --- /dev/null +++ b/app/AdminSupplier/Lazys/ProductForm.php @@ -0,0 +1,20 @@ +id; + return Form::make(); + } +} diff --git a/app/AdminSupplier/Renderable/SelectProduct.php b/app/AdminSupplier/Renderable/SelectProduct.php index ad6c093..755f07b 100644 --- a/app/AdminSupplier/Renderable/SelectProduct.php +++ b/app/AdminSupplier/Renderable/SelectProduct.php @@ -2,7 +2,6 @@ namespace App\AdminSupplier\Renderable; use App\Common\ProductStatus; -use App\AdminAgent\Repositories\Product; use App\Models\DemandProduct; use Dcat\Admin\Admin; use Dcat\Admin\Grid; diff --git a/app/AdminSupplier/Repositories/IndustryOrder.php b/app/AdminSupplier/Repositories/IndustryOrder.php new file mode 100644 index 0000000..90ef2e6 --- /dev/null +++ b/app/AdminSupplier/Repositories/IndustryOrder.php @@ -0,0 +1,16 @@ +post('auth/login', 'AuthController@postLogin'); $router->resource('product/list', 'ProductController'); + $router->resource('industry_product/list', 'IndustryProductController'); + $router->resource('industry_order/list', 'IndustryOrderController'); + $router->get('industry_order/qrcode/{verify_code}', 'IndustryOrderController@qrcode'); + $router->resource('order/list', 'OrderController'); $router->resource('agent/list', 'AgentController'); $router->resource('supplier_info', 'SupplierInfoController'); diff --git a/app/Common/StatementType.php b/app/Common/StatementType.php index 496a9ea..8507135 100644 --- a/app/Common/StatementType.php +++ b/app/Common/StatementType.php @@ -23,6 +23,9 @@ class StatementType /** @var int 退款 */ const REFUND = 6; + /** @var int 交易金 */ + const DEPOSIT = 7; + public static function array(): array { return [ @@ -32,6 +35,7 @@ class StatementType self::WITHDRAWAL => '提现', self::WITHDRAWAL_CAT => '提现手续费', self::REFUND => '退款', + self::DEPOSIT => '扣交易金', ]; } } diff --git a/app/Http/Controllers/Api/AgentProductController.php b/app/Http/Controllers/Api/AgentProductController.php index 21ce1b6..b7d2f4b 100644 --- a/app/Http/Controllers/Api/AgentProductController.php +++ b/app/Http/Controllers/Api/AgentProductController.php @@ -94,7 +94,7 @@ class AgentProductController extends Controller $agent_product->cost = ''; } - //如果是单品销售,显示附加信息字段,组合产品和组团产品不显示 + //如果是单品销售,显示附加信息字段,组合产品和计调产品不显示 if ($agent_product->type == 0) { $agent_product->product = Product::query()->where('id', $agent_product->product_id)->first(['type', 'extends']); } else { diff --git a/app/Http/Controllers/Api/IndexController.php b/app/Http/Controllers/Api/IndexController.php index 844d7bb..32f1f1d 100644 --- a/app/Http/Controllers/Api/IndexController.php +++ b/app/Http/Controllers/Api/IndexController.php @@ -32,7 +32,7 @@ class IndexController extends Controller } # 公告 - $notice = Notice::where('agent_id', $this->agent_id)->limit(10) + $notice = Notice::where('agent_id', $this->agent_id)->status()->limit(10) ->orderBy('sort')->orderBy('id', 'desc')->get(['id', 'title']); # 我的频道 diff --git a/app/Http/Controllers/Api/NoticeController.php b/app/Http/Controllers/Api/NoticeController.php index 28bfd75..59cb8bf 100644 --- a/app/Http/Controllers/Api/NoticeController.php +++ b/app/Http/Controllers/Api/NoticeController.php @@ -15,6 +15,7 @@ class NoticeController extends Controller public function index() { $list = Notice::query()->where('agent_id', $this->agent_id) + ->status() ->select(['title', 'updated_at']) ->orderBy('id', 'DESC') ->simplePaginate(15); @@ -25,7 +26,7 @@ class NoticeController extends Controller { $id = (int)request()->input('id'); - $data = Notice::where('agent_id', $this->agent_id)->find($id); + $data = Notice::where('agent_id', $this->agent_id)->status()->find($id); if (!$data) { return $this->error('公告不存在或已删除'); } diff --git a/app/Http/Controllers/Api/OrderController.php b/app/Http/Controllers/Api/OrderController.php index f903bcd..61aaec2 100644 --- a/app/Http/Controllers/Api/OrderController.php +++ b/app/Http/Controllers/Api/OrderController.php @@ -12,13 +12,15 @@ use App\Models\AgentSetting; use App\Models\Coupon; use App\Models\OrderProductItem; use App\Models\Product; +use App\Models\SystemSetting; use App\Models\User; use App\Models\Order; +use App\Service\OpenPlatform; use EasyWeChat\Factory; use EasyWeChat\Kernel\Exceptions\InvalidArgumentException; use EasyWeChat\Kernel\Exceptions\InvalidConfigException; +use EasyWeChat\Kernel\Http\StreamResponse; use GuzzleHttp\Exception\GuzzleException; -use Illuminate\Database\Eloquent\Model; use Illuminate\Http\Request; use Illuminate\Support\Facades\DB; use App\Common\OrderStatus as Status; @@ -145,6 +147,11 @@ class OrderController extends Controller return $this->error('产品已下架或库存不足'); } + //支付小程序的产品不允许购买 + if (AdminSetting::val('payee_appid') == Agent::where('id', $this->agent_id)->value('appid')) { + return $this->error('系统出错了,购买失败~~'); + } + $coupon_ids = []; if ($ap->coupon) { foreach ($ap->coupon as $v) { @@ -213,11 +220,12 @@ class OrderController extends Controller 'agent_cloud_price' => $ap->agentCloudProduct->price ?? 0, 'prepay_price ' => $prepayPrice ?? 0, 'prepay_timeout' => $prepayTimeout ?? 0, + 'service_persons' => SystemSetting::val('single', 'price') ]); //存入订单产品表 $supplier_product_info = Product::whereIn('id', $product_ids) - ->orderBy('id')->get(['id AS product_id', 'supplier_id', 'price'])->toArray(); + ->orderBy('id')->get(['id AS product_id', 'supplier_id', 'price','service_persons'])->toArray(); $order_id = $order->id; $agent_id = $this->agent_id; @@ -427,24 +435,19 @@ class OrderController extends Controller //如果有核销码,生成核销二维码 if ($order->verify_code) { - $setting = AdminSetting::val(['service_appid', 'service_appsecret', 'service_token', 'service_aeskey']); - $config = [ - 'app_id' => $setting['service_appid'], - 'secret' => $setting['service_appsecret'], - 'token' => $setting['service_token'], - 'aes_key' => $setting['service_aeskey'], - ]; - - $app = Factory::openPlatform($config); - $refreshToken = $app->getAuthorizer($order->agent->appid)['authorization_info']['authorizer_refresh_token'] ?? null; + $app = new OpenPlatform(); + $refreshToken = $app->refreshToken($order->agent->appid); if (!$refreshToken) { return $this->error('获取refresh_token失败'); } $app = $app->miniProgram($order->agent->appid, $refreshToken); - $response = $app->app_code->getUnlimit($order->verify_code, ['page' => 'pages/verification/index']); + //由于参数最多只能32个字符,故通过下面这种方式传参 + //pt表示使用普通订单,使用api/verification/verify接口核销; + //hy表示行业产品订单,使用api/verification/industry_verify接口核销 + $response = $app->app_code->getUnlimit('pt' . $order->verify_code, ['page' => 'pages/verification/index']); - if ($response instanceof \EasyWeChat\Kernel\Http\StreamResponse) { + if ($response instanceof StreamResponse) { $filename = $response->saveAs(storage_path('app/public/verify_code'), $order->verify_code); $order->verify_qrcode = Storage::disk('public')->url('verify_code/' . $filename); } diff --git a/app/Http/Controllers/Api/SharePayController.php b/app/Http/Controllers/Api/SharePayController.php index b83c97f..7c345bf 100644 --- a/app/Http/Controllers/Api/SharePayController.php +++ b/app/Http/Controllers/Api/SharePayController.php @@ -76,7 +76,7 @@ class SharePayController extends Controller $result = $app->order->unify([ 'body' => mb_strcut($order->title, 0, 127), 'out_trade_no' => $order->order_no . '-' . $order->status, //后面加status,主要是为了方便微信支付回调时区分定金(首付款)和尾款支付 - 'total_fee' => 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, diff --git a/app/Http/Controllers/Api/VerificationController.php b/app/Http/Controllers/Api/VerificationController.php index 768830c..c9e3e3d 100644 --- a/app/Http/Controllers/Api/VerificationController.php +++ b/app/Http/Controllers/Api/VerificationController.php @@ -7,46 +7,47 @@ use App\Common\StatementType; use App\Http\Controllers\Controller; use App\Models\Agent; use App\Models\Guide; +use App\Models\IndustryOrder; use App\Models\Order; use App\Models\Supplier; use App\Models\Product; use App\Models\OrderProductItem; use App\Models\User; use App\Common\OrderStatus; -use App\Service\SmsService; use App\Service\WithdrawalService; use App\Traits\DemandTraits; -use App\Traits\SmsTraits; use App\Traits\StatementTraits; -use EasyWeChat\Factory; use Illuminate\Support\Facades\DB; -use Illuminate\Support\Facades\Storage; +/** + * 订单核销 + * Class VerificationController + * @package App\Http\Controllers\Api + */ class VerificationController extends Controller { - //核销订单 + //核销小程序订单 public function verify() { - $input_verify_code = request()->input('verify_code'); //订单ID + $input_verify_code = request()->input('verify_code'); //核销码 $code_arr = explode('-', $input_verify_code); if (count($code_arr) != 2) { return $this->error('参数错误'); } list($id, $verify_code) = $code_arr; - $order = Order::with(['agentProduct:id,verifier', 'user', 'agent', 'guide']) - ->where(['verify_code' => $verify_code]) + $order = Order::where(['verify_code' => $verify_code]) ->whereIn('status', [OrderStatus::PAID, OrderStatus::PAID_RETAINAGE, OrderStatus::OFFLINE_PAID, OrderStatus::REFUSED_REFUND]) ->find($id); if (!$order) { - return $this->error('订单不存在或订单状态不允许核销'); + return $this->error('订单不存在或订单状态不允许核销1——' . $input_verify_code); } $mobile = User::where('id', $this->user_id)->value('mobile'); $checkMobile = Product::query()->whereIn('id', explode(',', $order->product_ids))->where('verify_mobile', $mobile)->doesntExist(); if ($checkMobile) { - return $this->error('对不起,你没有核销权限,请联系管理员'); + return $this->error('对不起,你没有核销权限,请联系管理员1——' . $input_verify_code); } $order->status = OrderStatus::SUCCESS; @@ -62,13 +63,57 @@ class VerificationController extends Controller return $this->success(); } + //行业产品订单核销 + public function industry_verify() + { + $input_verify_code = request()->input('verify_code'); //核销码 + + $code_arr = explode('-', $input_verify_code); + if (count($code_arr) != 2) { + return $this->error('参数错误'); + } + list($id, $verify_code) = $code_arr; + + $order = IndustryOrder::with('industryProduct:id,verify_mobile') + ->where(['status' => OrderStatus::OFFLINE_PAID, 'verify_code' => $verify_code])->find($id); + if (!$order) { + return $this->error('订单不存在或订单状态不允许核销2——' . $input_verify_code); + } + + $user = User::find($this->user_id); + if (!$user->mobile) { + return $this->error('手机号与核销手机号不符'); + } else if ($user->mobile != $order->industryProduct->verify_mobile) { + return $this->error('对不起,你没有该订单的核销权限2——' . $input_verify_code); + } + + DB::beginTransaction(); + try { + //改变订单状态为已完成 + $order->status = OrderStatus::SUCCESS; + $order->save(); + + //扣除供应商冻结的交易金 + $supplier = Supplier::find($order->supplier_id); + $supplier->deposit_used = $supplier->deposit_used + $order->deposit; + $supplier->deposit_frozen = $supplier->deposit_frozen - $order->deposit; + $supplier->save(); //需要用save才能执行模型事件记录日志 + + DB::commit(); + return $this->success('核销成功'); + } catch (\Exception $e) { + DB::rollBack(); + return $this->error($e->getMessage()); + } + } + public function fund($order) { $service = new WithdrawalService(); DB::beginTransaction(); try { //最后批量插入 - $adminCreate = $statementCreate = []; + $statementCreate = []; $cost = 0; //如果有地接价格 分帐给地接 if ($order->guide_price > 0) { @@ -84,34 +129,34 @@ class VerificationController extends Controller StatementTraits::$type[0] ); //抽成 - if ($order->guide->rate > 0) { - //计算抽成金额 - $guideCut = bcmul($order->guide_price, $order->guide->rate, 6); - $cutPrice = $guideCut > 0 ? bcdiv($guideCut, 100, 6) : 0; - //总后台抽成流水 - if ($cutPrice > 0) { - $adminCreate[] = $service->createByOrderFormAdmin( - $cutPrice, - StatementType::CUT, - $order->guide->id, - DemandTraits::$col[2], - $order->id, - ); - //地接被抽成流水 - $statementCreate[] = $service->createByOrder( - bcmul($cutPrice, -1, 2), - StatementType::CUT, - $order->guide->id, - DemandTraits::$col[2], - $order->id, - StatementTraits::$type[0] - ); - $guidePrice = bcsub($order->guide_price, $cutPrice, 6); - $guide = Guide::query()->where('id', $order->guide->id)->lockForUpdate()->first(); - $guide->balance = bcadd($guide->balance, $guidePrice, 6); - $guide->save(); - } - } + //if ($order->guide->rate > 0) { + // //计算抽成金额 + // $guideCut = bcmul($order->guide_price, $order->guide->rate, 6); + // $cutPrice = $guideCut > 0 ? bcdiv($guideCut, 100, 6) : 0; + // //总后台抽成流水 + // if ($cutPrice > 0) { + // $adminCreate[] = $service->createByOrderFormAdmin( + // $cutPrice, + // StatementType::CUT, + // $order->guide->id, + // DemandTraits::$col[2], + // $order->id, + // ); + // //地接被抽成流水 + // $statementCreate[] = $service->createByOrder( + // bcmul($cutPrice, -1, 2), + // StatementType::CUT, + // $order->guide->id, + // DemandTraits::$col[2], + // $order->id, + // StatementTraits::$type[0] + // ); + //$guidePrice = bcsub($order->guide_price, $cutPrice, 6); + $guide = Guide::query()->where('id', $order->guide->id)->lockForUpdate()->first(); + $guide->balance = bcadd($guide->balance, $guidePrice, 6); + $guide->save(); + // } + //} } //分账给供应商 @@ -119,7 +164,7 @@ class VerificationController extends Controller ->where('order_id', $order->id) ->with('supplier') ->select('*') - ->selectRaw('sum(price) as sum_price') + ->selectRaw('sum(price) as sum_price,sum(service_persons) as sum_persons') ->groupBy('supplier_id') ->get(); foreach ($orderItem as $v) { @@ -135,33 +180,52 @@ class VerificationController extends Controller StatementTraits::$type[0] ); - if ($v->supplier->rate > 0) { - //计算抽成金额 - $supplierCut = bcmul($v->sum_price, $v->supplier->rate, 6); - $cutPrice = $supplierCut > 0 ? bcdiv($supplierCut, 100, 6) : 0; - if ($cutPrice > 0) { - //总后台抽成流水 - $adminCreate[] = $service->createByOrderFormAdmin( - $cutPrice, - StatementType::CUT, - $v->supplier_id, - DemandTraits::$col[1], - $order->id, - ); - //供应商被抽成流水 - $statementCreate[] = $service->createByOrder( - bcmul($cutPrice, -1, 6), - StatementType::CUT, - $v->supplier_id, - DemandTraits::$col[1], - $order->id, - StatementTraits::$type[0] - ); - $supplierPrice = bcsub($supplierPrice, $cutPrice, 6); - - } - } + //if ($v->supplier->rate > 0) { + // //计算抽成金额 + // $supplierCut = bcmul($v->sum_price, $v->supplier->rate, 6); + // $cutPrice = $supplierCut > 0 ? bcdiv($supplierCut, 100, 6) : 0; + // if ($cutPrice > 0) { + // //总后台抽成流水 + // $adminCreate[] = $service->createByOrderFormAdmin( + // $cutPrice, + // StatementType::CUT, + // $v->supplier_id, + // DemandTraits::$col[1], + // $order->id, + // ); + // //供应商被抽成流水 + // $statementCreate[] = $service->createByOrder( + // bcmul($cutPrice, -1, 6), + // StatementType::CUT, + // $v->supplier_id, + // DemandTraits::$col[1], + // $order->id, + // StatementTraits::$type[0] + // ); + // $supplierPrice = bcsub($supplierPrice, $cutPrice, 6); + // + // } + //} $supplier = Supplier::query()->where('id', $v->supplier_id)->lockForUpdate()->first(); + + //处理交易金 + if ($order->single_price > 0) { + //计算交易金 + $deposit = bcmul($order->single_price,$v->sum_persons,6); + //流水 + $statementCreate[] = $service->createByOrder( + $deposit, + StatementType::DEPOSIT, + $v->supplier_id, + DemandTraits::$col[1], + $order->id, + StatementTraits::$type[0] + ); + //扣 + $supplierPrice = bcsub($supplierPrice,$deposit,6); + $supplier->balance = bcadd($supplier->deposit_used, $supplierPrice, 6); + $supplier->balance = bcsub($supplier->deposit_frozen, $supplierPrice, 6); + } $supplier->balance = bcadd($supplier->balance, $supplierPrice, 6); $supplier->save(); } @@ -170,62 +234,62 @@ class VerificationController extends Controller //成本价 加上地接价格 $agentPrice = bcsub($order->price, $cost, 2); - if ($agentPrice > 0) { - $statementCreate[] = $service->createByOrder( - $agentPrice, - StatementType::ORDER, - $order->agent_id, - DemandTraits::$col[0], - $order->id, - StatementTraits::$type[0] - ); - //抽成 - if ($order->agent->rate > 0) { - //计算抽成金额 - $agentCut = bcmul($agentPrice, $order->agent->rate, 6); - $cutPrice = $agentCut > 0 ? bcdiv($agentCut, 100, 6) : 0; - - //总后台抽成流水 - if ($cutPrice > 0) { - $adminCreate[] = $service->createByOrderFormAdmin( - $cutPrice, - StatementType::CUT, - $order->agent->id, - DemandTraits::$col[0], - $order->id, - ); - //代理商被抽成流水 - $statementCreate[] = $service->createByOrder( - bcmul($cutPrice, -1, 6), - StatementType::CUT, - $order->agent->id, - DemandTraits::$col[0], - $order->id, - StatementTraits::$type[0] - ); - $agentPrice = bcsub($agentPrice, $cutPrice, 6); - } - } + $statementCreate[] = $service->createByOrder( + $agentPrice, + StatementType::ORDER, + $order->agent_id, + DemandTraits::$col[0], + $order->id, + StatementTraits::$type[0] + ); + // + ////抽成 + //if ($order->agent->rate > 0) { + // //计算抽成金额 + // $agentCut = bcmul($agentPrice, $order->agent->rate, 6); + // $cutPrice = $agentCut > 0 ? bcdiv($agentCut, 100, 6) : 0; + // + // //总后台抽成流水 + // if ($cutPrice > 0) { + // $adminCreate[] = $service->createByOrderFormAdmin( + // $cutPrice, + // StatementType::CUT, + // $order->agent->id, + // DemandTraits::$col[0], + // $order->id, + // ); + // //代理商被抽成流水 + // $statementCreate[] = $service->createByOrder( + // bcmul($cutPrice, -1, 6), + // StatementType::CUT, + // $order->agent->id, + // DemandTraits::$col[0], + // $order->id, + // StatementTraits::$type[0] + // ); + // $agentPrice = bcsub($agentPrice, $cutPrice, 6); + // } + //扣除微信支付手续费 - $chargePrice = bcmul($order->price, 0.006, 6); - $statementCreate[] = $service->createByOrder( - bcmul($chargePrice, -1, 6), - StatementType::CHARGE, - $order->agent_id, - DemandTraits::$col[0], - $order->id, - StatementTraits::$type[0] - ); - $agentPrice = bcsub($agentPrice, $chargePrice, 6); + //$chargePrice = bcmul($order->price, 0.006, 6); + //$statementCreate[] = $service->createByOrder( + // bcmul($chargePrice, -1, 6), + // StatementType::CHARGE, + // $order->agent_id, + // DemandTraits::$col[0], + // $order->id, + // StatementTraits::$type[0] + //); + //$agentPrice = bcsub($agentPrice, $chargePrice, 6); $agent = Agent::query()->where('id', $order->agent->id)->lockForUpdate()->first(); $agent->balance = bcadd($agent->balance, $agentPrice, 6); $agent->save(); - } - if (!empty($adminCreate)) { - $order->statementAdmin()->createMany($adminCreate); - } + //} + //if (!empty($adminCreate)) { + // $order->statementAdmin()->createMany($adminCreate); + //} if (!empty($statementCreate)) { $order->statement()->createMany($statementCreate); diff --git a/app/Models/IndustryOrder.php b/app/Models/IndustryOrder.php new file mode 100644 index 0000000..7a5a4ac --- /dev/null +++ b/app/Models/IndustryOrder.php @@ -0,0 +1,27 @@ +belongsTo(Supplier::class); + } + + public function agent() + { + return $this->belongsTo(Agent::class); + } + + public function industryProduct() + { + return $this->belongsTo(IndustryProduct::class); + } +} diff --git a/app/Models/IndustryProduct.php b/app/Models/IndustryProduct.php new file mode 100644 index 0000000..9b9cd8d --- /dev/null +++ b/app/Models/IndustryProduct.php @@ -0,0 +1,31 @@ + 'json', 'extends' => 'json']; + protected $appends = ['picture']; + protected $fillable = ['status']; + + public function getPictureAttribute($value): string + { + return $this->pictures[0] ?? ''; + } + + public function supplier() + { + return $this->belongsTo(Supplier::class); + } + + public function category() + { + return $this->belongsTo(Category::class); + } +} diff --git a/app/Models/Notice.php b/app/Models/Notice.php index 73a66c4..1a58e9b 100644 --- a/app/Models/Notice.php +++ b/app/Models/Notice.php @@ -7,4 +7,9 @@ use Illuminate\Database\Eloquent\Factories\HasFactory; class Notice extends BaseModel { use HasFactory; + + public function scopeStatus($query) + { + return $query->where('status',1); + } } diff --git a/app/Models/Order.php b/app/Models/Order.php index 9d03db2..a72bbed 100644 --- a/app/Models/Order.php +++ b/app/Models/Order.php @@ -123,7 +123,7 @@ class Order extends BaseModel return $this->belongsTo(Guide::class); } - //关联的组团云产品 + //关联的计调云产品 public function agentCloud() { return $this->belongsTo(AgentProduct::class, 'agent_cloud_pid', 'id'); diff --git a/app/Traits/DemandTraits.php b/app/Traits/DemandTraits.php index 781c7e7..bc19e5c 100644 --- a/app/Traits/DemandTraits.php +++ b/app/Traits/DemandTraits.php @@ -25,7 +25,7 @@ trait DemandTraits public static $state = [ 1 => '竞标中' , - 2 => '已竞标' , + 2 => '已结标' , 3 => '流拍' ]; diff --git a/database/migrations/2021_09_18_110418_update_order_table_0917_table.php b/database/migrations/2021_09_18_110418_update_order_table_0917_table.php new file mode 100644 index 0000000..0bf8b1b --- /dev/null +++ b/database/migrations/2021_09_18_110418_update_order_table_0917_table.php @@ -0,0 +1,38 @@ +decimal('single_price') + ->default(0) + ->comment('下单时的单人头交易费'); + }); + + Schema::table('order_product_items', function (Blueprint $table) { + $table->integer('service_persons') + ->default(0) + ->comment('涉及人数'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + // + } +} diff --git a/database/migrations/2021_09_18_153814_update_notice_table_table.php b/database/migrations/2021_09_18_153814_update_notice_table_table.php new file mode 100644 index 0000000..7a6368f --- /dev/null +++ b/database/migrations/2021_09_18_153814_update_notice_table_table.php @@ -0,0 +1,32 @@ +tinyInteger('status') + ->default(0) + ->comment('是否启用 0禁用 1启用'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + // + } +} diff --git a/dcat_admin_ide_helper.php b/dcat_admin_ide_helper.php index 88f1b62..a0d5a39 100644 --- a/dcat_admin_ide_helper.php +++ b/dcat_admin_ide_helper.php @@ -117,6 +117,7 @@ namespace Dcat\Admin { * @property Grid\Column|Collection queue * @property Grid\Column|Collection uuid * @property Grid\Column|Collection photo + * @property Grid\Column|Collection industry_product_id * @property Grid\Column|Collection mobile * @property Grid\Column|Collection num * @property Grid\Column|Collection order_no @@ -296,6 +297,7 @@ namespace Dcat\Admin { * @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 industry_product_id(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) @@ -480,6 +482,7 @@ namespace Dcat\Admin { * @property Show\Field|Collection queue * @property Show\Field|Collection uuid * @property Show\Field|Collection photo + * @property Show\Field|Collection industry_product_id * @property Show\Field|Collection mobile * @property Show\Field|Collection num * @property Show\Field|Collection order_no @@ -659,6 +662,7 @@ namespace Dcat\Admin { * @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 industry_product_id(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) @@ -743,7 +747,7 @@ namespace Dcat\Admin { namespace Dcat\Admin\Grid { /** - + */ class Column {} @@ -755,7 +759,7 @@ namespace Dcat\Admin\Grid { namespace Dcat\Admin\Show { /** - + */ class Field {} } diff --git a/ready.md b/ready.md index be60ceb..98a73e3 100644 --- a/ready.md +++ b/ready.md @@ -23,7 +23,10 @@ TRUNCATE `coupons`; TRUNCATE `demand`; TRUNCATE `demand_bidding`; TRUNCATE `demand_products`; +TRUNCATE `deposit_log`; TRUNCATE `guides`; +TRUNCATE `industry_orders`; +TRUNCATE `industry_products`; TRUNCATE `messages`; TRUNCATE `message_reads`; TRUNCATE `mini_program_drafts`; diff --git a/resources/lang/zh_CN/agent-info.php b/resources/lang/zh_CN/agent-info.php index 9a4f497..ea913d2 100644 --- a/resources/lang/zh_CN/agent-info.php +++ b/resources/lang/zh_CN/agent-info.php @@ -1,8 +1,9 @@ - [ 'AgentInfo' => '代理商信息', 'agent-info' => '代理商信息', + 'agent_info' => '代理商信息', ], 'fields' => [ 'about' => '关于我们', diff --git a/resources/lang/zh_CN/agent-product.php b/resources/lang/zh_CN/agent-product.php index 82cfb69..d2a72ad 100644 --- a/resources/lang/zh_CN/agent-product.php +++ b/resources/lang/zh_CN/agent-product.php @@ -3,6 +3,7 @@ return [ 'labels' => [ 'AgentProduct' => '产品', 'agent-product' => '产品', + 'agent_product' => '产品', ], 'fields' => [ 'agent_id' => '代理商ID', diff --git a/resources/lang/zh_CN/industry-order.php b/resources/lang/zh_CN/industry-order.php new file mode 100644 index 0000000..e0c5a73 --- /dev/null +++ b/resources/lang/zh_CN/industry-order.php @@ -0,0 +1,27 @@ + [ + 'IndustryOrder' => '行业产品订单', + 'industry-order' => '行业产品订单', + 'industry_order' => '行业产品订单', + ], + 'fields' => [ + 'supplier_id' => '供应商ID', + 'agent_id' => '代理商ID', + 'order_no' => '订单号', + 'num' => '购买数量', + 'price' => '订单总价', + 'name' => '客户姓名', + 'mobile' => '手机号', + 'title' => '产品名称', + 'picture' => '产品图片', + 'status' => '订单状态', + 'pay_type' => '支付方式', + 'paid_at' => '付款时间', + 'verify_code' => '核销码', + 'timeout' => '订单超时时间', + 'created_at' => '下单时间', + ], + 'options' => [ + ], +]; diff --git a/resources/lang/zh_CN/industry-product.php b/resources/lang/zh_CN/industry-product.php new file mode 100644 index 0000000..e17148a --- /dev/null +++ b/resources/lang/zh_CN/industry-product.php @@ -0,0 +1,29 @@ + [ + 'IndustryProduct' => '行业产品', + 'industry-product' => '行业产品', + 'industry_product' => '行业产品', + ], + 'fields' => [ + 'supplier_id' => '供应商ID', + 'type' => '产品类型', + 'category_id' => '分类ID', + 'title' => '标题', + 'pictures' => '产品图片', + 'picture' => '产品图片', + 'price' => '售价', + 'original_price' => '原价', + 'stock' => '库存量', + 'sale' => '销量', + 'status' => '状态', + 'know' => '旅客须知', + 'content' => '产品详情', + 'service_persons' => '涉及用户数', + 'min_sale' => '起售数', + 'verify_mobile' => '核销人员手机号', + ], + 'options' => [ + 'publish_type' => admin_trans('product.options.publish_type'), + ], +]; diff --git a/resources/lang/zh_CN/order.php b/resources/lang/zh_CN/order.php index fac16ba..555309d 100644 --- a/resources/lang/zh_CN/order.php +++ b/resources/lang/zh_CN/order.php @@ -23,8 +23,9 @@ return [ 'status' => '订单状态', 'title' => '产品名称', 'user_id' => '用户ID', - 'agent_cloud_pid' => '组团云产品ID', - 'agent_cloud_price' => '组团云产品售价', + 'agent_cloud_pid' => '计调云产品ID', + 'agent_cloud_price' => '计调云产品售价', + 'timeout' => '超时时间', 'created_at' => '下单时间', ], 'options' => [ diff --git a/resources/lang/zh_CN/waterfall-ad.php b/resources/lang/zh_CN/waterfall-ad.php deleted file mode 100644 index 996e9d4..0000000 --- a/resources/lang/zh_CN/waterfall-ad.php +++ /dev/null @@ -1,18 +0,0 @@ - [ - 'WaterfallAd' => '产品列表内嵌广告', - 'waterfall-ad' => '产品列表内嵌广告', - ], - 'fields' => [ - 'title' => '广告名称', - 'agent_id' => '代理商ID', - 'picture' => '广告图片', - 'type' => '链接', - 'url' => '链接地址', - 'sort' => '排序', - 'status' => '状态', - ], - 'options' => [ - ], -]; diff --git a/routes/api.php b/routes/api.php index c6bace0..701e304 100644 --- a/routes/api.php +++ b/routes/api.php @@ -114,7 +114,7 @@ Route::namespace('App\Http\Controllers\Api') # 核销订单 Route::prefix('verification')->group(function () { Route::post('verify', 'VerificationController@verify'); - Route::post('qrcode', 'VerificationController@qrcode'); + Route::post('industry_verify', 'VerificationController@industry_verify'); //行业产品订单核销 }); # 短信息