|
|
@ -6,10 +6,12 @@ use App\Common\AgentType; |
|
|
use App\Common\ProductStatus; |
|
|
use App\Common\ProductStatus; |
|
|
use App\Models\AgentProduct; |
|
|
use App\Models\AgentProduct; |
|
|
use App\Models\AgentProductItem; |
|
|
use App\Models\AgentProductItem; |
|
|
|
|
|
use App\Models\AgentProductSpec; |
|
|
use App\Models\AgentSetting; |
|
|
use App\Models\AgentSetting; |
|
|
use App\Models\Category; |
|
|
use App\Models\Category; |
|
|
use App\Models\Agent; |
|
|
use App\Models\Agent; |
|
|
use App\Models\Product; |
|
|
use App\Models\Product; |
|
|
|
|
|
use App\Models\ProductSpec; |
|
|
use App\Service\SmsService; |
|
|
use App\Service\SmsService; |
|
|
use App\Traits\SmsTraits; |
|
|
use App\Traits\SmsTraits; |
|
|
use Illuminate\Database\Eloquent\Model; |
|
|
use Illuminate\Database\Eloquent\Model; |
|
|
@ -72,7 +74,7 @@ class ProductServiceProvider extends ServiceProvider |
|
|
$agentProduct->know = $product->know; |
|
|
$agentProduct->know = $product->know; |
|
|
//计算价格
|
|
|
//计算价格
|
|
|
$profit = AgentSetting::val($v, 'profit') ?? 0; |
|
|
$profit = AgentSetting::val($v, 'profit') ?? 0; |
|
|
$price = bcmul($product->price, bcdiv($profit + 100, 100, 6), 2); |
|
|
|
|
|
|
|
|
$price = bcmul($product->price, bcdiv($profit + 100, 100, 6), 6); |
|
|
|
|
|
|
|
|
$agentProduct->price = $price; |
|
|
$agentProduct->price = $price; |
|
|
$agentProduct->original_price = $price; |
|
|
$agentProduct->original_price = $price; |
|
|
@ -95,6 +97,23 @@ class ProductServiceProvider extends ServiceProvider |
|
|
'agent_product_id' => $agentProduct->id, |
|
|
'agent_product_id' => $agentProduct->id, |
|
|
'product_id' => $product->id, |
|
|
'product_id' => $product->id, |
|
|
]); |
|
|
]); |
|
|
|
|
|
|
|
|
|
|
|
//规格
|
|
|
|
|
|
$productSpec = ProductSpec::query()->where('product_id',$product->id)->get(); |
|
|
|
|
|
if (!empty($productSpec)) { |
|
|
|
|
|
$agentSpecArr = []; |
|
|
|
|
|
foreach ($productSpec as $spec) { |
|
|
|
|
|
$agentSpecArr[] = [ |
|
|
|
|
|
'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), |
|
|
|
|
|
]; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$agentProduct->spec()->createMany($agentSpecArr); |
|
|
|
|
|
} |
|
|
DB::commit(); |
|
|
DB::commit(); |
|
|
if(env('SMS_SWITCH','') == true) { |
|
|
if(env('SMS_SWITCH','') == true) { |
|
|
$phone = Agent::query()->where('id',$v)->value('contact_phone'); |
|
|
$phone = Agent::query()->where('id',$v)->value('contact_phone'); |
|
|
|