From 58ca424e545ee7968685ece20e00743febb7855d Mon Sep 17 00:00:00 2001 From: liapples Date: Sun, 26 Sep 2021 10:49:57 +0800 Subject: [PATCH 01/19] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/AdminAgent/Controllers/AgentProductController.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/AdminAgent/Controllers/AgentProductController.php b/app/AdminAgent/Controllers/AgentProductController.php index 286571b..baead92 100644 --- a/app/AdminAgent/Controllers/AgentProductController.php +++ b/app/AdminAgent/Controllers/AgentProductController.php @@ -212,8 +212,8 @@ class AgentProductController extends AdminController $form->hasMany('spec', function (Form\NestedForm $form) { $form->hidden('id'); $form->hidden('product_spec_id'); - $form->text('supplier_name', '规格')->disable()->customFormat(fn() => $this->product_spec['name'] ?? '已删除规格'); - $form->date('supplier_date', '日期')->disable()->customFormat(fn() => $this->product_spec['date'] ?? '已删除规格'); + $form->text('supplier_name', '规格')->disable()->customFormat(fn() => $this->product_spec['name'] ?? '供应商已删除规格'); + $form->date('supplier_date', '日期')->disable()->customFormat(fn() => $this->product_spec['date'] ?? '供应商已删除规格'); $form->text('supplier_stock', '供应商库存')->disable()->customFormat(fn() => $this->product_spec['stock'] ?? 0); $form->text('supplier_price', '供应商价')->disable()->customFormat(fn() => $this->product_spec['price'] ?? 0); $form->text('stock', '您的库存')->customFormat(fn() => isset($this->product_spec['stock'], $this->stock) && $this->stock > $this->product_spec['stock'] ? $this->product_spec['stock'] : $this->stock); From df5034d76f8712d0d5976870e64a1bdb192b931e Mon Sep 17 00:00:00 2001 From: liapples Date: Sun, 26 Sep 2021 10:54:37 +0800 Subject: [PATCH 02/19] =?UTF-8?q?=E8=BD=AF=E5=88=A0=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- MySQL_change.sql | 3 +++ app/Models/ProductSpec.php | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/MySQL_change.sql b/MySQL_change.sql index 263f655..32a85de 100644 --- a/MySQL_change.sql +++ b/MySQL_change.sql @@ -130,3 +130,6 @@ ALTER TABLE `product_specs` ALTER TABLE `agent_product_specs` DROP COLUMN `name`, DROP COLUMN `date`; +ALTER TABLE `product_specs` + ADD COLUMN `deleted_at` TIMESTAMP NULL DEFAULT NULL AFTER `price`; + diff --git a/app/Models/ProductSpec.php b/app/Models/ProductSpec.php index f6bb574..6ceabc6 100644 --- a/app/Models/ProductSpec.php +++ b/app/Models/ProductSpec.php @@ -4,10 +4,11 @@ namespace App\Models; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; +use Illuminate\Database\Eloquent\SoftDeletes; class ProductSpec extends Model { - use HasFactory; + use HasFactory, SoftDeletes; protected $guarded = ['id']; From ac04b717e1ca412fff6a0f0560df191d3ce91d47 Mon Sep 17 00:00:00 2001 From: liapples Date: Sun, 26 Sep 2021 11:06:22 +0800 Subject: [PATCH 03/19] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- resources/js/select-supplier-product-change.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/resources/js/select-supplier-product-change.js b/resources/js/select-supplier-product-change.js index 0a903d9..be1ee06 100644 --- a/resources/js/select-supplier-product-change.js +++ b/resources/js/select-supplier-product-change.js @@ -7,8 +7,8 @@ $(function () { data: {id: $(this).val(), _form_: '{{class}}'}, success: function (res) { var fields = { - name: 'name', - date: 'date', + supplier_name: 'name', + supplier_date: 'date', supplier_price: 'price', supplier_stock: 'stock', price: 'price', From 3bf5018f476577ad5286a33e264078a59a4170b8 Mon Sep 17 00:00:00 2001 From: liapples Date: Sun, 26 Sep 2021 11:11:51 +0800 Subject: [PATCH 04/19] =?UTF-8?q?=E5=A2=9E=E5=8A=A0has?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/Api/AgentProductController.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/Api/AgentProductController.php b/app/Http/Controllers/Api/AgentProductController.php index c43ad15..e7fcdd0 100644 --- a/app/Http/Controllers/Api/AgentProductController.php +++ b/app/Http/Controllers/Api/AgentProductController.php @@ -64,7 +64,13 @@ class AgentProductController extends Controller } else { $where = ['id' => $id, 'agent_id' => $this->agent_id, 'status' => ProductStatus::ON_SALE]; } - $agent_product = AgentProduct::with(['coupon:tag,agent_product_id', 'product:id,type,extends', 'spec.productSpec:id,name,date']) + $agent_product = AgentProduct::with([ + 'coupon:tag,agent_product_id', + 'product:id,type,extends', + 'spec' => function($query) { + return $query->has('productSpec')->with('productSpec:id,name,date'); + } + ]) ->whereDoesntHave('agentProductItem', function ($query) { return $query->whereHas('product', function ($query) { return $query->where('stock', '<=', 0)->orWhere('status', '<>', ProductStatus::ON_SALE); From 1f1c38d9f361be28f1cfc81a393ad830f08d5cfc Mon Sep 17 00:00:00 2001 From: liapples Date: Sun, 26 Sep 2021 11:19:59 +0800 Subject: [PATCH 05/19] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=BC=96=E8=BE=91?= =?UTF-8?q?=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Admin/Controllers/ProductController.php | 74 +++++++++++++++++++++ 1 file changed, 74 insertions(+) diff --git a/app/Admin/Controllers/ProductController.php b/app/Admin/Controllers/ProductController.php index 2fd83d6..ca57abd 100644 --- a/app/Admin/Controllers/ProductController.php +++ b/app/Admin/Controllers/ProductController.php @@ -10,7 +10,9 @@ use App\Models\AgentProduct; use App\Models\AgentProductItem; use App\Models\Category; use App\Models\Supplier; +use Dcat\Admin\Admin; use Dcat\Admin\Form; +use Dcat\Admin\Form\NestedForm; use Dcat\Admin\Grid; use Dcat\Admin\Show; use Dcat\Admin\Http\Controllers\AdminController; @@ -122,6 +124,78 @@ class ProductController extends AdminController ->required(); $form->editor('know'); $form->editor('content'); + $form->mobile('verify_mobile')->required(); + + $form->radio('type', '产品类型') + ->options(admin_trans('product.options.publish_type'))->disable($form->isEditing()) + ->default(current(admin_trans('product.options.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) { //不允许编辑的字段 if ($form->isEditing()) { From 8048d6146bfab4daa51b8bda87a10041aa923801 Mon Sep 17 00:00:00 2001 From: liapples Date: Sun, 26 Sep 2021 11:37:15 +0800 Subject: [PATCH 06/19] =?UTF-8?q?=E6=98=BE=E7=A4=BA=E4=BB=A3=E7=90=86?= =?UTF-8?q?=E5=95=86=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/AdminAgent/Forms/AgentInfo.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/AdminAgent/Forms/AgentInfo.php b/app/AdminAgent/Forms/AgentInfo.php index a29ea0f..defb909 100644 --- a/app/AdminAgent/Forms/AgentInfo.php +++ b/app/AdminAgent/Forms/AgentInfo.php @@ -1,6 +1,7 @@ select('type')->options(AgentType::array())->disable(); $this->text('name')->required(); $this->text('company_name')->required(); $this->text('credit_codes')->required(); From 327faf6edff0de1c9cf486abcb409db6e3bad037 Mon Sep 17 00:00:00 2001 From: liapples Date: Sun, 26 Sep 2021 11:40:12 +0800 Subject: [PATCH 07/19] type --- app/Admin/Controllers/AgentController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Admin/Controllers/AgentController.php b/app/Admin/Controllers/AgentController.php index 6aa2020..8b3bd5a 100644 --- a/app/Admin/Controllers/AgentController.php +++ b/app/Admin/Controllers/AgentController.php @@ -66,7 +66,7 @@ class AgentController extends AdminController $column->append((new AuditAgent(null, 1))->setKey($this->id))->append(' '); $column->append((new AuditAgent(null, 2))->setKey($this->id)); }) - ->if(fn() => $this->status == UserStatus::NORMAL) + ->if(fn() => $this->status == UserStatus::NORMAL && in_array($this->type, [AgentType::OPERATOR, AgentType::SUPPLIER])) ->display('') ->then(function ($column) use ($last_template_id) { $is_success = $this->miniUpload->is_success ?? null; From d8ab522c9911b7323b66ad573dbc8d5813dbb1f1 Mon Sep 17 00:00:00 2001 From: liapples Date: Sun, 26 Sep 2021 11:48:11 +0800 Subject: [PATCH 08/19] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Admin/Controllers/AgentController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Admin/Controllers/AgentController.php b/app/Admin/Controllers/AgentController.php index 8b3bd5a..b09abfa 100644 --- a/app/Admin/Controllers/AgentController.php +++ b/app/Admin/Controllers/AgentController.php @@ -83,7 +83,7 @@ class AgentController extends AdminController $column->append((new MiniProgramUpload(null, 1))->setKey($this->id)); $statusArr = [0 => '审核成功', 1 => '审核被拒绝', 2 => '审核中', 3 => '已撤回', 4 => '审核延后']; if (isset($is_success, $statusArr[$is_success])) { - $column->append('
(' . $statusArr[$is_success] . ')'); + $column->append('
(模板' . $template_id . $statusArr[$is_success] . ')'); } } }); From 995848e0d828cd5e908bc4b8050e2909550c3e49 Mon Sep 17 00:00:00 2001 From: liapples Date: Sun, 26 Sep 2021 14:03:37 +0800 Subject: [PATCH 09/19] =?UTF-8?q?=E8=A7=84=E6=A0=BC=E6=95=B0=E7=BB=84?= =?UTF-8?q?=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Api/AgentProductController.php | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/app/Http/Controllers/Api/AgentProductController.php b/app/Http/Controllers/Api/AgentProductController.php index e7fcdd0..a6062de 100644 --- a/app/Http/Controllers/Api/AgentProductController.php +++ b/app/Http/Controllers/Api/AgentProductController.php @@ -106,6 +106,35 @@ class AgentProductController extends Controller $agent_product->product = null; } + //处理规格 + if (!$agent_product->spec->isEmpty()) { + $specs = $agent_product->spec->toArray(); + + //二维数组转一维 + $specs = array_map(function ($v) { + if (is_array($v['product_spec'])) { + unset($v['product_spec']['id']); + $v = array_merge($v, $v['product_spec']); + } + unset($v['agent_product_id'], $v['product_spec_id'], $v['product_spec']); + return $v; + }, $specs); + + //去年name和date为空的数组 + $specs = array_filter($specs, fn($v) => isset($v['name'], $v['date'])); + + $names = array_column($specs, 'name'); + $names = array_values(array_unique($names)); + + $result = []; + foreach ($names as $name) { + $list = array_filter($specs, fn($v) => $v['name'] == $name); + $result[] = ['name' => $name, 'list' => array_column($list, null, 'date')]; + } + unset($agent_product->spec); + $agent_product->spec = $result; + } + unset($agent_product->agent_id, $agent_product->status, $agent_product->deleted_at); return $this->success($agent_product); } From 7eb68f9de15801313fc1d7af61098f9233b29ce5 Mon Sep 17 00:00:00 2001 From: liapples Date: Sun, 26 Sep 2021 14:10:01 +0800 Subject: [PATCH 10/19] =?UTF-8?q?=E8=A7=84=E6=A0=BC=E6=95=B0=E7=BB=84?= =?UTF-8?q?=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/Api/AgentProductController.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/Api/AgentProductController.php b/app/Http/Controllers/Api/AgentProductController.php index a6062de..bf9e29b 100644 --- a/app/Http/Controllers/Api/AgentProductController.php +++ b/app/Http/Controllers/Api/AgentProductController.php @@ -129,7 +129,12 @@ class AgentProductController extends Controller $result = []; foreach ($names as $name) { $list = array_filter($specs, fn($v) => $v['name'] == $name); - $result[] = ['name' => $name, 'list' => array_column($list, null, 'date')]; + $result[] = [ + 'name' => $name, + 'original_price' => min(array_column($list, 'original_price')), + 'price' => min(array_column($list, 'price')), + 'list' => array_column($list, null, 'date'), + ]; } unset($agent_product->spec); $agent_product->spec = $result; From 11a55441e52d33a8d3184124a2de49ffa67703d7 Mon Sep 17 00:00:00 2001 From: liapples Date: Sun, 26 Sep 2021 14:34:21 +0800 Subject: [PATCH 11/19] =?UTF-8?q?=E8=BD=AF=E5=88=A0=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Models/AgentProductSpec.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/Models/AgentProductSpec.php b/app/Models/AgentProductSpec.php index 3f11256..67abe72 100644 --- a/app/Models/AgentProductSpec.php +++ b/app/Models/AgentProductSpec.php @@ -4,10 +4,11 @@ namespace App\Models; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; +use Illuminate\Database\Eloquent\SoftDeletes; class AgentProductSpec extends Model { - use HasFactory; + use HasFactory, SoftDeletes; protected $guarded = ['id']; From cdb83993e64d1fa67d48ae935b15fd624a177b67 Mon Sep 17 00:00:00 2001 From: liapples Date: Sun, 26 Sep 2021 14:47:51 +0800 Subject: [PATCH 12/19] =?UTF-8?q?hidden=20id=EF=BC=8C=E5=8E=BB=E6=8E=89?= =?UTF-8?q?=E5=BA=93=E5=AD=98=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/AdminAgent/Controllers/AgentProductController.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/AdminAgent/Controllers/AgentProductController.php b/app/AdminAgent/Controllers/AgentProductController.php index baead92..1d7b059 100644 --- a/app/AdminAgent/Controllers/AgentProductController.php +++ b/app/AdminAgent/Controllers/AgentProductController.php @@ -210,7 +210,7 @@ class AgentProductController extends AdminController ->script($js); $form->hasMany('spec', function (Form\NestedForm $form) { - $form->hidden('id'); +// $form->hidden('id'); hasMany时,ID会自动生成 $form->hidden('product_spec_id'); $form->text('supplier_name', '规格')->disable()->customFormat(fn() => $this->product_spec['name'] ?? '供应商已删除规格'); $form->date('supplier_date', '日期')->disable()->customFormat(fn() => $this->product_spec['date'] ?? '供应商已删除规格'); @@ -419,8 +419,8 @@ class AgentProductController extends AdminController $product = Product::find($form->product_id); if ($product->status != ProductStatus::ON_SALE) { return $form->response()->error('产品ID '. $form->product_id .' 已下架'); - } else if ($product->stock < $form->stock) { - return $form->response()->error("供应商当前库存为{$product->stock},你设置的库存不能超过该数值"); + /*} else if ($product->stock < $form->stock) { + return $form->response()->error("供应商当前库存为{$product->stock},你设置的库存不能超过该数值");*/ } else if ($form->price < $product->price) { return $form->response()->error("产品售价不能小于供应商售价{$product->price}"); } From 353b4f92ed354ad3102d519ac76dfae51e85aa4b Mon Sep 17 00:00:00 2001 From: liapples Date: Sun, 26 Sep 2021 14:54:36 +0800 Subject: [PATCH 13/19] =?UTF-8?q?=E4=BF=AE=E6=94=B9list=E7=BB=93=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/Api/AgentProductController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Controllers/Api/AgentProductController.php b/app/Http/Controllers/Api/AgentProductController.php index bf9e29b..577e604 100644 --- a/app/Http/Controllers/Api/AgentProductController.php +++ b/app/Http/Controllers/Api/AgentProductController.php @@ -133,7 +133,7 @@ class AgentProductController extends Controller 'name' => $name, 'original_price' => min(array_column($list, 'original_price')), 'price' => min(array_column($list, 'price')), - 'list' => array_column($list, null, 'date'), + 'list' => $list, ]; } unset($agent_product->spec); From 3031869ea086f8340150ad0160aafd0bdfbb6c65 Mon Sep 17 00:00:00 2001 From: liapples Date: Sun, 26 Sep 2021 14:55:17 +0800 Subject: [PATCH 14/19] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- resources/js/select-supplier-product-change.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/resources/js/select-supplier-product-change.js b/resources/js/select-supplier-product-change.js index be1ee06..c787d03 100644 --- a/resources/js/select-supplier-product-change.js +++ b/resources/js/select-supplier-product-change.js @@ -18,7 +18,16 @@ $(function () { }; var data = res.data; var forms = $('.has-many-spec-forms'); - forms.html(''); + + //如果是原来数据库已经保存有id,调用click,提交的时候会同时删除数据库,否则直接remove掉,减小HTML体积 + forms.children().each(function () { + if ($(this).find('.field_id').val()) { + $(this).find('.remove.btn').click(); + } else { + $(this).remove(); + } + }); + for (var key in data) { var row = $(template.replace(/new___LA_KEY__/g, key)); for(var key2 in fields) { From efd62dda6c9b65920ac765f8346b66e8d1b85ad5 Mon Sep 17 00:00:00 2001 From: liapples Date: Sun, 26 Sep 2021 14:55:27 +0800 Subject: [PATCH 15/19] =?UTF-8?q?=E8=BD=AF=E5=88=A0=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- MySQL_change.sql | 3 +++ 1 file changed, 3 insertions(+) diff --git a/MySQL_change.sql b/MySQL_change.sql index 32a85de..452567a 100644 --- a/MySQL_change.sql +++ b/MySQL_change.sql @@ -132,4 +132,7 @@ ALTER TABLE `agent_product_specs` DROP COLUMN `date`; ALTER TABLE `product_specs` ADD COLUMN `deleted_at` TIMESTAMP NULL DEFAULT NULL AFTER `price`; +ALTER TABLE `agent_product_specs` + ADD COLUMN `deleted_at` TIMESTAMP NULL DEFAULT NULL AFTER `price`; + From 30b6caf130c2bf2fb723f571864fb71832c2fb40 Mon Sep 17 00:00:00 2001 From: liapples Date: Sun, 26 Sep 2021 15:07:27 +0800 Subject: [PATCH 16/19] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=BB=93=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/Api/AgentProductController.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/Api/AgentProductController.php b/app/Http/Controllers/Api/AgentProductController.php index 577e604..32bc48d 100644 --- a/app/Http/Controllers/Api/AgentProductController.php +++ b/app/Http/Controllers/Api/AgentProductController.php @@ -116,7 +116,7 @@ class AgentProductController extends Controller unset($v['product_spec']['id']); $v = array_merge($v, $v['product_spec']); } - unset($v['agent_product_id'], $v['product_spec_id'], $v['product_spec']); + unset($v['agent_product_id'], $v['product_spec_id'], $v['product_spec'], $v['deleted_at']); return $v; }, $specs); @@ -133,7 +133,7 @@ class AgentProductController extends Controller 'name' => $name, 'original_price' => min(array_column($list, 'original_price')), 'price' => min(array_column($list, 'price')), - 'list' => $list, + 'list' => array_values($list), ]; } unset($agent_product->spec); From 1917c15302933c7175368c39c303bd7c1d6698e6 Mon Sep 17 00:00:00 2001 From: liapples Date: Sun, 26 Sep 2021 15:33:46 +0800 Subject: [PATCH 17/19] =?UTF-8?q?=E5=8D=95=E5=BA=93=E5=AD=98=E6=9C=8D?= =?UTF-8?q?=E5=8A=A1=E7=94=A8=E6=88=B7=E6=95=B0=E4=B8=8D=E8=83=BD=E5=B0=8F?= =?UTF-8?q?=E4=BA=8E1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/AdminSupplier/Controllers/ProductController.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/AdminSupplier/Controllers/ProductController.php b/app/AdminSupplier/Controllers/ProductController.php index cc0670b..cf9c140 100644 --- a/app/AdminSupplier/Controllers/ProductController.php +++ b/app/AdminSupplier/Controllers/ProductController.php @@ -107,7 +107,7 @@ class ProductController extends AdminController $form->text('title')->required(); // $form->currency('price')->symbol('¥')->required(); // $form->currency('original_price')->symbol('¥')->required(); - $form->number('service_persons')->required(); + $form->number('service_persons')->min(1)->required(); // $form->number('stock')->required(); $form->hasMany('spec', function (NestedForm $form) { $form->hidden('id'); @@ -249,6 +249,11 @@ class ProductController extends AdminController $form->original_price = min(array_column($spec, 'original_price')); $form->price = min(array_column($spec, 'price')); + //单库存服务用户数必须大于1 + if ($form->service_persons < 1) { + return $form->response()->error('单库存服务用户数不能小于1'); + } + //特殊字段处理 if ($form->isCreating()) { $form->hidden(['status', 'supplier_id']); //表单没有的字段,必须加上这句才能重置值 From e4b032bbbbf5f40ed84ee63012b9eebd83035b8d Mon Sep 17 00:00:00 2001 From: liapples Date: Sun, 26 Sep 2021 15:37:29 +0800 Subject: [PATCH 18/19] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=B5=B7=E5=A7=8B?= =?UTF-8?q?=E6=97=A5=E6=9C=9F=E5=92=8C=E7=BB=93=E6=9D=9F=E6=97=A5=E6=9C=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/Api/AgentProductController.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/Http/Controllers/Api/AgentProductController.php b/app/Http/Controllers/Api/AgentProductController.php index 32bc48d..1e23c43 100644 --- a/app/Http/Controllers/Api/AgentProductController.php +++ b/app/Http/Controllers/Api/AgentProductController.php @@ -131,6 +131,8 @@ class AgentProductController extends Controller $list = array_filter($specs, fn($v) => $v['name'] == $name); $result[] = [ 'name' => $name, + 'date_start' => min(array_column($list, 'date')), + 'date_end' => max(array_column($list, 'date')), 'original_price' => min(array_column($list, 'original_price')), 'price' => min(array_column($list, 'price')), 'list' => array_values($list), From 3b6ff3a1814fbc2d9a625d82b525e3668ec21b5b Mon Sep 17 00:00:00 2001 From: liapples Date: Sun, 26 Sep 2021 15:43:11 +0800 Subject: [PATCH 19/19] =?UTF-8?q?order=5Fitems=E5=A2=9E=E5=8A=A0=E5=AD=97?= =?UTF-8?q?=E6=AE=B5=EF=BC=8C=E8=AE=A2=E5=8D=95=E8=AF=A6=E6=83=85=E8=B0=83?= =?UTF-8?q?=E7=94=A8info=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- MySQL_change.sql | 4 ++ app/Http/Controllers/Api/OrderController.php | 41 +++++++++----------- 2 files changed, 23 insertions(+), 22 deletions(-) diff --git a/MySQL_change.sql b/MySQL_change.sql index 452567a..6375bcc 100644 --- a/MySQL_change.sql +++ b/MySQL_change.sql @@ -135,4 +135,8 @@ ALTER TABLE `product_specs` ALTER TABLE `agent_product_specs` ADD COLUMN `deleted_at` TIMESTAMP NULL DEFAULT NULL AFTER `price`; +ALTER TABLE `order_product_items` + ADD COLUMN `agent_product_spec_id` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '代理商产品规格ID' AFTER `price`, + ADD COLUMN `product_type` TINYINT NOT NULL DEFAULT 0 COMMENT '供应商产品的type' AFTER `agent_product_spec_id`, + CHANGE COLUMN `product_spec_id` `product_spec_id` BIGINT NOT NULL DEFAULT 0 COMMENT '供应商产品规格ID' AFTER `product_type`; diff --git a/app/Http/Controllers/Api/OrderController.php b/app/Http/Controllers/Api/OrderController.php index 2e6a29d..9c229d9 100644 --- a/app/Http/Controllers/Api/OrderController.php +++ b/app/Http/Controllers/Api/OrderController.php @@ -156,7 +156,9 @@ class OrderController extends Controller //0:单品销售;1:组合销售 if ($ap->type == 0) { - $spec = AgentProductSpec::where('agent_product_id', $formData['id'])->find($formData['spec_id']); + $spec = AgentProductSpec::with('productSpec') + ->where('agent_product_id', $formData['id']) + ->find($formData['spec_id']); if (!$spec) { return $this->error('你选择的产品规格不存在'); } @@ -314,25 +316,20 @@ class OrderController extends Controller 'info' => $order_info, ]); - //存入订单产品表 - $supplier_product_info = Product::whereIn('id', $product_ids) - ->orderBy('id')->get(['type', 'id AS product_id', 'supplier_id', 'price', 'service_persons'])->toArray(); - - $order_id = $order->id; - $agent_id = $this->agent_id; - $agent_product_id = $ap->id; - - foreach ($supplier_product_info as &$v) { - $v['order_id'] = $order_id; - $v['agent_id'] = $agent_id; - $v['agent_product_id'] = $agent_product_id; - $v['num'] = $formData['num']; - if ($v['type'] == 0) { //TODO 此处未处理组合产品 - $v['product_spec_id'] = $formData['spec_id']; - } - unset($v['type']); - } - OrderProductItem::insert($supplier_product_info); + //存入订单产品表,TODO 此处不考虑组合产品 + OrderProductItem::insert([ + 'order_id' => $order->id, + 'agent_id' => $this->agent_id, + 'agent_product_id' => $ap->id, + 'supplier_id' => $ap->product->supplier_id, + 'product_id' => $ap->product->id, + 'num' => $formData['num'], + 'price' => $ap->product->price, + 'agent_product_spec_id' => $formData['spec_id'], + 'product_type' => $ap->product->type, + 'product_spec_id' => $spec->productSpec->id, + 'service_persons' => $ap->product->service_persons, + ]); DB::commit(); } catch (\Exception $e) { @@ -341,7 +338,7 @@ class OrderController extends Controller } if ($formData['pay_type'] == PayType::OFFLINE) { //线下支付 - return $this->success(['id' => $order_id], '操作成功,请及时联系客服付款'); + return $this->success(['id' => $order->id], '操作成功,请及时联系客服付款'); } else { //在线支付或定金支付 /*$config = $this->payConfig($order, $price); if (!empty($config['paySign'])) { @@ -526,7 +523,7 @@ class OrderController extends Controller $id = (int)request()->input('id'); $fields = ['id', 'agent_id', 'order_no', 'agent_product_id', 'num', 'price', 'name', 'mobile', 'title', 'picture', 'status', - 'pay_type', 'coupon_id', 'paid_money', 'paid_at', 'refund_info', 'verify_code', 'created_at']; + 'pay_type', 'coupon_id', 'paid_money', 'paid_at', 'refund_info', 'verify_code', 'info', 'created_at']; $order = Order::with('agent:id,appid,appsecret') ->where('user_id', $this->user_id) ->find($id, $fields);