35 lines
1.1 KiB
PHP
Executable File
35 lines
1.1 KiB
PHP
Executable File
<?php
|
|
|
|
namespace App\Model;
|
|
|
|
|
|
use App\Enums\OrderType;
|
|
use App\Model\Customer\Customer;
|
|
|
|
class AgentSale extends BaseModel
|
|
{
|
|
public static function log(Customer $agentor, Order $order, $brokerage)
|
|
{
|
|
$money = $order->money;
|
|
$orderId = $order->id;
|
|
$unionOrderId = 0;
|
|
if ($order->type == OrderType::UNION) {
|
|
$money = $order->union_money;
|
|
$unionOrderId = $order->id;
|
|
$orderId = $order->pid;
|
|
}
|
|
$agentSale = new AgentSale();
|
|
$agentSale->shop_id = $agentor->shop_id;
|
|
$agentSale->agent_id = $agentor->id;
|
|
$agentSale->agent_brokerage = $agentor->agent_brokerage;
|
|
$agentSale->agent_at = $agentor->agent_at;
|
|
$agentSale->customer_id = $order->customer_id;
|
|
$agentSale->order_id = $orderId;
|
|
$agentSale->union_order_id = $unionOrderId;
|
|
$agentSale->money = $money;
|
|
$agentSale->brokerage_money = $brokerage;
|
|
$agentSale->created_date = date('Ymd', strtotime($order->created_at));
|
|
$agentSale->save();
|
|
}
|
|
}
|