Browse Source

自动上架

master
Lemon 4 years ago
parent
commit
a4304bf4c8
  1. 2
      app/AdminAgent/Forms/Setting.php
  2. 12
      app/Providers/ProductServiceProvider.php

2
app/AdminAgent/Forms/Setting.php

@ -36,7 +36,7 @@ class Setting extends Form
->help('订单超时时间,单位:分钟。超过该时间未支付,订单将自动关闭');
$this->radio('auto_shelves')->when([1], function (Form $form) {
// 值为1和4时显示文本框
$form->number('profit','利润(%)')->min(0)->max(100)->help('请填写利润百分比 上架商品会自动根据供应商提供的价格 上调设置值的百分比');
//$form->number('profit','利润(%)')->min(0)->max(100)->help('请填写利润百分比 上架商品会自动根据供应商提供的价格 上调设置值的百分比');
$form->radio('auto_category','自动添加分类')->options([
'否',
'是',

12
app/Providers/ProductServiceProvider.php

@ -73,11 +73,11 @@ class ProductServiceProvider extends ServiceProvider
$agentProduct->content = $product->content;
$agentProduct->know = $product->know;
//计算价格
$profit = AgentSetting::val($v, 'profit') ?? 0;
$price = bcmul($product->price, bcdiv($profit + 100, 100, 6), 6);
// $profit = AgentSetting::val($v, 'profit') ?? 0;
// $price = bcmul($product->price, bcdiv($profit + 100, 100, 6), 6);
$agentProduct->price = $price;
$agentProduct->original_price = $price;
$agentProduct->price = $product->price;
$agentProduct->original_price = $product->original_price;
//自动添加分类
$autoCategory = AgentSetting::val($v, 'auto_category') ?? 0;
@ -107,8 +107,8 @@ class ProductServiceProvider extends ServiceProvider
'agent_product_id' => $agentProduct->id,
'product_spec_id' => $spec->id,
'stock' => $spec->stock,
'original_price' => bcmul($spec->price, bcdiv($profit + 100, 100, 6), 6),
'price' => bcmul($spec->price, bcdiv($profit + 100, 100, 6), 6),
'original_price' => $spec->original_price,
'price' => $spec->price,
];
}

Loading…
Cancel
Save