Browse Source

Merge branch 'develop' of ssh://8.134.10.79:222/Leadfyy.co/hainan into develop

develop
lemon 5 years ago
parent
commit
d459a44de2
  1. 4
      app/Admin/Controllers/AgentController.php
  2. 4
      app/Admin/Controllers/GuideController.php
  3. 2
      app/Admin/Controllers/SupplierController.php
  4. 6
      app/AdminAgent/Controllers/AgentProductController.php
  5. 7
      app/AdminAgent/Renderable/SelectAgentCloudProduct.php
  6. 7
      app/AdminAgent/Renderable/SelectAgentProduct.php
  7. 134
      app/AdminSupplier/Controllers/ProductController.php
  8. 11
      app/Http/Controllers/Api/AgentProductController.php
  9. 8
      config/admin-supplier.php
  10. 2
      resources/lang/zh_CN/agent.php
  11. 2
      resources/lang/zh_CN/guide.php
  12. 2
      resources/lang/zh_CN/supplier.php

4
app/Admin/Controllers/AgentController.php

@ -169,9 +169,9 @@ class AgentController extends AdminController
}
}
//成比例
//成比例
if ($form->rate < 0 || $form->rate > 100) {
return $form->response()->error('成比例在 0 ~ 100 之间');
return $form->response()->error('成比例在 0 ~ 100 之间');
}
//不允许编辑的字段

4
app/Admin/Controllers/GuideController.php

@ -123,9 +123,9 @@ class GuideController extends AdminController
}
}
//成比例
//成比例
if ($form->rate < 0 || $form->rate > 100) {
return $form->response()->error('成比例在 0 ~ 100 之间');
return $form->response()->error('成比例在 0 ~ 100 之间');
}
//不允许编辑的字段

2
app/Admin/Controllers/SupplierController.php

@ -130,7 +130,7 @@ class SupplierController extends AdminController
$form->select('status', '状态')
->options(UserStatus::array())
->default(UserStatus::NORMAL)
->help('如果禁用供应商将同时<span style="color:#f00;">下架供应商的所有产品</span>,需要供应商手动上架后才能销售,请谨慎!')
->help('如果禁用供应商,其下的<span style="color:#f00;">所有产品都会跟着下架</span>,包括代理商在售的产品')
->required();
$form->text('company_name');
$form->image('logo')->removable(false)->uniqueName();

6
app/AdminAgent/Controllers/AgentProductController.php

@ -413,7 +413,11 @@ class AgentProductController extends AdminController
['is_cloud', '=', 1],
['type', '=', 1],
['agent_id', '<>', Admin::user()->id],
])->find($form->agent_cloud_pid);
])->whereDoesntHave('agentProductItem', function ($query) {
return $query->whereHas('product', function ($query) {
return $query->where('stock', '<=', 0)->orWhere('status', '<>', ProductStatus::ON_SALE);
});
})->find($form->agent_cloud_pid);
if (!$cloud_product) {
return $form->response()->error('你选择的组团云产品库存不足或已下架,请重新选择');

7
app/AdminAgent/Renderable/SelectAgentCloudProduct.php

@ -30,7 +30,12 @@ class SelectAgentCloudProduct extends LazyRenderable
['is_cloud', '=', 1],
['type', '=', 1],
['agent_id', '<>', Admin::user()->id],
]);
])->whereDoesntHave('agentProductItem', function ($query) {
return $query->whereHas('product', function ($query) {
return $query->where('stock', '<=', 0)->orWhere('status', '<>', ProductStatus::ON_SALE);
});
});
$grid->quickSearch(['title'])->placeholder('搜索产品名称');

7
app/AdminAgent/Renderable/SelectAgentProduct.php

@ -25,7 +25,12 @@ class SelectAgentProduct extends LazyRenderable
$grid->disableBatchActions();
$grid->model()->where('stock', '>', 0)
->where(['agent_id' => Admin::user()->id, 'status' => ProductStatus::ON_SALE]);
->where(['agent_id' => Admin::user()->id, 'status' => ProductStatus::ON_SALE])
->whereDoesntHave('agentProductItem', function ($query) {
return $query->whereHas('product', function ($query) {
return $query->where('stock', '<=', 0)->orWhere('status', '<>', ProductStatus::ON_SALE);
});
});
$grid->quickSearch(['title'])->placeholder('搜索产品名称');
$grid->column('id');

134
app/AdminSupplier/Controllers/ProductController.php

@ -6,7 +6,6 @@ use App\AdminSupplier\Repositories\Product;
use App\Common\ProductStatus;
use App\Models\AgentProduct;
use App\Models\AgentProductItem;
use App\Models\AgentSetting;
use App\Models\Category;
use Dcat\Admin\Admin;
use Dcat\Admin\Form;
@ -14,11 +13,9 @@ use Dcat\Admin\Form\NestedForm;
use Dcat\Admin\Grid;
use Dcat\Admin\Show;
use Dcat\Admin\Http\Controllers\AdminController;
use Dcat\Admin\Widgets\Alert;
use Dcat\Admin\Widgets\Card;
use Dcat\Admin\Widgets\Table;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
class ProductController extends AdminController
{
@ -31,21 +28,10 @@ class ProductController extends AdminController
protected function grid()
{
return Grid::make(new Product(['category:id,name']), function (Grid $grid) {
$type = request()->input('type');
if (isset($type) && isset(admin_trans('product.options.publish_type')[$type])) {
$grid->model()->where(['supplier_id' => Admin::user()->id, 'type' => $type]);
Admin::script('$(function(){
$(".pull-right a").each(function() {
var href = $(this).attr("href");
$(this).attr("href", href + "?type='.$type.'")
});
});');
} else {
$grid->model()->where('supplier_id', Admin::user()->id);
}
$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');
$grid->column('picture')->image('', 60, 60);
@ -62,6 +48,7 @@ class ProductController extends AdminController
$filter->panel();
$filter->equal('id')->width(2);
$filter->equal('type')->select(admin_trans('product.options.publish_type'))->width(2);
});
});
}
@ -76,13 +63,6 @@ class ProductController extends AdminController
protected function detail($id)
{
return Show::make($id, new Product(), function (Show $show) {
Admin::script('$(function(){
$(".pull-right a").each(function() {
var href = $(this).attr("href");
$(this).attr("href", href + "?type='.request()->input('type').'")
});
});');
$show->field('id');
$show->field('supplier_id');
$show->field('category_id');
@ -124,24 +104,15 @@ class ProductController extends AdminController
*/
protected function form()
{
Form\Field\Map::requireAssets(); //地图
Admin::user()->publish_type = json_decode(Admin::user()->publish_type, true);
return Form::make(new Product(), function (Form $form) {
Admin::script('$(function(){
$(".pull-right a").each(function() {
var href = $(this).attr("href");
$(this).attr("href", href + "?type='.request()->input('type').'")
});
});');
//不允许编辑非自己数据
if ($form->isEditing() && $form->model()->supplier_id != Admin::user()->id) {
return $form->response()->error('数据不存在');
}
$type = request()->input('type');
$form->display('id');
$form->hidden('type')->value($type);
$options = Category::selectOptions(fn($query) => $query->where('agent_id', 0));
$form->select('category_id')->options(array_slice($options, 1, null, true))->required();
@ -155,64 +126,67 @@ class ProductController extends AdminController
$form->text('verify_mobile','核销员手机');
//扩展字段
if ($type == 0) { //旅游线路
$form->table('extends.project', '包含项目', function (NestedForm $table) {
$table->text('name', '项目名称');
$table->text('num', '数量');
$table->text('price', '费用');
});
$form->dateRange('extends.date.start', 'extends.date.end', '行程时间');
} else if ($type == 1) { //酒店
$default = ['行李寄存', '24小时前台', '前台保险柜', '唤醒服务', '早餐', '送餐服务', '电梯', '空调',
'新风系统', '24小时热水', '吹风机', '加湿器', '自动售货机', '健身房', '桌球室', '洗衣服务'];
$form->table('extends.tags', '酒店设施', function (NestedForm $table) {
$table->text('tag', '包含项目')->placeholder('如:24小时热水、干洗服务等');
});
} else if ($type == 2) { //景区
$form->table('extends.open_time', '开放时间', function (NestedForm $table) {
$table->text('week', '星期')->placeholder('如:周一至周五');
$table->text('section', '时段')->placeholder('如:上午/下午');
$table->text('time', '时间')->placeholder('如:08:00~18:00');
});
$form->table('extends.project', '包含项目', function (NestedForm $table) {
$table->text('name', '项目名称');
$table->text('num', '数量');
$table->text('price', '费用');
});
} else if ($type == 3) { //餐厅
$form->table('extends.open_time', '开放时间', function (NestedForm $table) {
$table->text('week', '星期')->placeholder('如:周一至周五');
$table->text('section', '时段')->placeholder('如:上午/下午');
$table->text('time', '时间')->placeholder('如:08:00~18:00');
});
$form->table('extends.package', '包含套餐', function (NestedForm $table) {
$table->text('name', '名称')->placeholder('如:清蒸鱿鱼');
$table->text('num', '数量')->placeholder('如:1条');
$table->text('price', '价格')->placeholder('如:99元');
$publish_type = array_intersect_key(
admin_trans('product.options.publish_type'),
array_flip(Admin::user()->publish_type)
);
$form->radio('type', '产品类型')
->options($publish_type)
->default(current(Admin::user()->publish_type))
->when(0, function (Form $form) { //旅游线路
$form->table('extends.field_0.project', '包含项目', function (NestedForm $table) {
$table->text('name', '项目名称');
$table->text('num', '数量');
$table->text('price', '费用');
});
$form->dateRange('extends.field_0.date.start', 'extends.field_0.date.end', '行程时间');
})->when(1, function (Form $form) { //酒店
$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);
$form->map('extends.field_1.latitude', 'extends.field_1.longitude', '位置');
})->when(2, function (Form $form) { //景区
$form->table('extends.field_2.open_time', '开放时间', function (NestedForm $table) {
$table->text('node', '节点')->placeholder('如:周一至周五');
$table->text('summer', '夏季')->placeholder('如:08:00~19:00');
$table->text('winter', '冬季')->placeholder('如:08:00~18:00');
});
$form->table('extends.field_2.project', '包含项目', function (NestedForm $table) {
$table->text('name', '项目名称');
$table->text('num', '数量');
$table->text('price', '费用');
});
$form->map('extends.field_2.latitude', 'extends.field_2.longitude', '位置');
})->when(3, function (Form $form) { //餐厅
$form->table('extends.field_3.open_time', '开放时间', function (NestedForm $table) {
$table->text('week', '星期')->placeholder('如:周一至周五');
$table->text('section', '时段')->placeholder('如:上午/下午');
$table->text('time', '时间')->placeholder('如:08:00~18:00');
});
$form->table('extends.field_3.package', '包含套餐', function (NestedForm $table) {
$table->text('name', '名称')->placeholder('如:清蒸鱿鱼');
$table->text('num', '数量')->placeholder('如:1条');
$table->text('price', '价格')->placeholder('如:99元');
});
$form->map('extends.field_3.latitude', 'extends.field_3.longitude', '位置');
});
}
if ($form->isEditing()) {
$form->confirm('提示', '修改标题、价格、产品图片、旅游须知、产品详情需要重新审核,同时<span class="btn-danger">下架所有</span>关联的代理商产品,是否继续?');
}
})->creating(function (Form $form) {
$type = request()->input('type');
if ($form->isCreating()) {
if ($type == null) {
Admin::exit('请选择要发布的产品类型');
}
if (!Admin::user()->publish_type || !in_array($type, Admin::user()->publish_type)) {
Admin::exit(Alert::make('对不起,你没有此类产品的发布权限', '权限不足')->danger());
}
}
})->saving(function (Form $form) {
//不允许编辑非自己数据
if ($form->isEditing() && $form->model()->supplier_id != Admin::user()->id) {
return $form->response()->error('数据不存在');
}
$type = $form->isCreating() ? $form->type : $form->model()->type;
if (!Admin::user()->publish_type || !in_array($type, Admin::user()->publish_type)) {
if (!Admin::user()->publish_type || !in_array($form->type, Admin::user()->publish_type)) {
return $form->response()->error('对不起,你没有此类产品的发布、编辑权限');
}

11
app/Http/Controllers/Api/AgentProductController.php

@ -5,6 +5,7 @@ use App\Common\ProductStatus;
use App\Http\Controllers\Controller;
use App\Models\Advertising;
use App\Models\AgentProduct;
use App\Models\Product;
use App\Models\UserFav;
use Illuminate\Support\Facades\Storage;
@ -59,8 +60,7 @@ class AgentProductController extends Controller
// TODO 优惠券查询待优化
$agent_product = AgentProduct::query()
->with('coupon:tag,agent_product_id')
->with('fav:agent_product_id')
->with(['coupon:tag,agent_product_id', 'fav:agent_product_id'])
->whereDoesntHave('agentProductItem', function ($query) {
return $query->whereHas('product', function ($query) {
return $query->where('stock', '<=', 0)->orWhere('status', '<>', ProductStatus::ON_SALE);
@ -85,6 +85,13 @@ 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 {
$agent_product->product = null;
}
unset($agent_product->agent_id, $agent_product->status, $agent_product->deleted_at);
return $this->success($agent_product);
}

8
config/admin-supplier.php

@ -343,4 +343,12 @@ return [
| Whether enable default breadcrumb for every page content.
*/
'enable_default_breadcrumb' => true,
//地图配置
'map_provider' => 'tencent',
'map' => [
'keys' => [
'tencent' => env('TENCENT_MAP_KEY','')
]
]
];

2
resources/lang/zh_CN/agent.php

@ -21,7 +21,7 @@ return [
'license_pic' => '营业执照',
'director' => '负责人',
'contact_phone' => '联系电话',
'rate' => '成比例',
'rate' => '成比例',
'agentInfo' => trans('agent-info.fields'),
],
'options' => [

2
resources/lang/zh_CN/guide.php

@ -13,7 +13,7 @@ return [
'license_pic' => '地接资格证件',
'contact_phone' => '联系电话',
'status' => '状态',
'rate' => '成比例',
'rate' => '成比例',
],
'options' => [
],

2
resources/lang/zh_CN/supplier.php

@ -15,7 +15,7 @@ return [
'license_pic' => '营业执照',
'director' => '负责人',
'contact_phone' => '联系电话',
'rate' => '成比例',
'rate' => '成比例',
'publish_type' => '可发布产品类型',
],
'options' => [

Loading…
Cancel
Save