备货单&审批流程
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
namespace app\common\model;
|
||||
|
||||
use support\Model;
|
||||
use app\common\traits\HasMoneyJournal;
|
||||
|
||||
class StockOrderItems extends Model
|
||||
{
|
||||
@@ -40,44 +41,44 @@ class StockOrderItems extends Model
|
||||
/**
|
||||
* 允许自动填充模型字段
|
||||
*/
|
||||
protected $fillable = ['id', 'order_id', 'product_code', 'sku_id', 'sku_snapshot', 'model_snapshot', 'quantity', 'color_interior_id', 'color_interior_snapshot', 'color_exterior_id', 'color_exterior_snapshot', 'remark', 'unit_price', 'handling_fee', 'fob_transport_fee', 'port_misc_fee', 'retrofit_fee', 'total_price', 'created_at', 'updated_at', 'unit_price_value_id', 'handling_fee_value_id', 'fob_transport_fee_value_id', 'port_misc_fee_value_id', 'retrofit_fee_value_id', 'total_price_value_id'];
|
||||
protected $fillable = [
|
||||
'id', 'order_id', 'product_code', 'sku_id', 'sku_snapshot',
|
||||
'model_snapshot', 'quantity', 'color_interior_coide', 'color_interior_snapshot',
|
||||
'color_exterior_coide', 'color_exterior_snapshot', 'remark',
|
||||
// 'unit_price',
|
||||
// 'handling_fee',
|
||||
// 'fob_transport_fee',
|
||||
// 'port_misc_fee',
|
||||
// 'retrofit_fee',
|
||||
// 'total_price',
|
||||
'created_at', 'updated_at',
|
||||
// 'unit_price_value_id',
|
||||
// 'handling_fee_value_id',
|
||||
// 'fob_transport_fee_value_id',
|
||||
// 'port_misc_fee_value_id',
|
||||
// 'retrofit_fee_value_id',
|
||||
// 'total_price_value_id'
|
||||
];
|
||||
|
||||
/**
|
||||
* 不允许自动填充模型字段
|
||||
*/
|
||||
protected $guarded = [];
|
||||
|
||||
/* ========= 关系 ========= */
|
||||
|
||||
public function unitPrice() { return $this->belongsTo(VehMoneyValue::class, 'unit_price_value_id'); }
|
||||
public function handlingFee() { return $this->belongsTo(VehMoneyValue::class, 'handling_fee_value_id'); }
|
||||
public function fobTransportFee() { return $this->belongsTo(VehMoneyValue::class, 'fob_transport_fee_value_id'); }
|
||||
public function portMiscFee() { return $this->belongsTo(VehMoneyValue::class, 'port_misc_fee_value_id'); }
|
||||
public function retrofitFee() { return $this->belongsTo(VehMoneyValue::class, 'retrofit_fee_value_id'); }
|
||||
public function totalPrice() { return $this->belongsTo(VehMoneyValue::class, 'total_price_value_id'); }
|
||||
|
||||
// 便捷访问器(原币种的金额)
|
||||
public function getUnitPriceAmountAttribute() { return $this->unitPrice?->amount; }
|
||||
public function getHandlingFeeAmountAttribute() { return $this->handlingFee?->amount; }
|
||||
public function getFobTransportFeeAmountAttribute() { return $this->fobTransportFee?->amount; }
|
||||
public function getPortMiscFeeAmountAttribute() { return $this->portMiscFee?->amount; }
|
||||
public function getRetrofitFeeAmountAttribute() { return $this->retrofitFee?->amount; }
|
||||
public function getTotalPriceAmountAttribute() { return $this->totalPrice?->amount; }
|
||||
|
||||
// 便捷:按“各自 exchange_rate”换到结算币后相加(无 rate 的跳过)
|
||||
public function sumToSettlement(): string
|
||||
use HasMoneyJournal;
|
||||
// 实现抽象方法
|
||||
protected static function moneyObjectScene(): string
|
||||
{
|
||||
$list = array_filter([
|
||||
$this->unitPrice?->amountInSettlement(),
|
||||
$this->handlingFee?->amountInSettlement(),
|
||||
$this->fobTransportFee?->amountInSettlement(),
|
||||
$this->portMiscFee?->amountInSettlement(),
|
||||
$this->retrofitFee?->amountInSettlement(),
|
||||
], fn($v) => $v !== null);
|
||||
|
||||
$sum = '0.00';
|
||||
foreach ($list as $v) {
|
||||
$sum = bcadd($sum, (string)$v, 2);
|
||||
}
|
||||
return $sum;
|
||||
return 'stock_order_items';
|
||||
}
|
||||
|
||||
// 便捷访问器(最新一条的原币金额)
|
||||
public function getUnitPriceAmountAttribute() { return $this->moneyLatest('unit_price')?->amount; }
|
||||
public function getHandlingFeeAmountAttribute() { return $this->moneyLatest('handling_fee')?->amount; }
|
||||
public function getFobTransportFeeAmountAttribute() { return $this->moneyLatest('fob_transport_fee')?->amount; }
|
||||
public function getPortMiscFeeAmountAttribute() { return $this->moneyLatest('port_misc_fee')?->amount; }
|
||||
public function getRetrofitFeeAmountAttribute() { return $this->moneyLatest('retrofit_fee')?->amount; }
|
||||
public function getTotalPriceAmountAttribute() { return $this->moneyLatest('total_price')?->amount; }
|
||||
}
|
||||
@@ -40,7 +40,17 @@ class StockOrders extends Model
|
||||
/**
|
||||
* 允许自动填充模型字段
|
||||
*/
|
||||
protected $fillable = ['id', 'order_no', 'pi_no', 'biz_date', 'salesperson_id', 'salesperson_snapshot', 'clearance_country_id', 'clearance_country_snapshot', 'ali_order_no', 'customer_source_id', 'customer_source_snapshot', 'customer_id', 'customer_snapshot', 'customer_country_id', 'customer_country_snapshot', 'declarant_name', 'eta_ship_date', 'shipping_method', 'cif_total_amount', 'domestic_port_id', 'domestic_port_snapshot', 'trade_term_id', 'trade_term_snapshot', 'clearance_port_id', 'clearance_port_snapshot', 'latest_arrival_date', 'contract_exchange_rate', 'settlement_currency', 'status', 'remark', 'created_at', 'updated_at', 'deleted_at'];
|
||||
protected $fillable = [
|
||||
'id', 'order_no', 'pi_no', 'biz_date', 'salesperson_id', 'salesperson_snapshot',
|
||||
'clearance_country_id', 'clearance_country_snapshot', 'ali_order_no',
|
||||
'customer_source_id', 'customer_source_snapshot', 'customer_id', 'customer_snapshot',
|
||||
'customer_country_id', 'customer_country_snapshot', 'declarant_name', 'eta_ship_date',
|
||||
'shipping_method_id', 'shipping_method_snapshot', 'cif_total_amount', 'domestic_port_id', 'domestic_port_snapshot',
|
||||
'trade_term_id', 'trade_term_snapshot', 'clearance_port_id', 'clearance_port_snapshot',
|
||||
'latest_arrival_date', 'contract_exchange_rate', 'settlement_currency', 'status',
|
||||
'remark', 'created_at', 'updated_at', 'deleted_at',
|
||||
'object_id', 'contract', 'is_use', 'is_final', 'approval_status'
|
||||
];
|
||||
|
||||
/**
|
||||
* 不允许自动填充模型字段
|
||||
|
||||
@@ -37,13 +37,26 @@ class VehMoneyValue extends Model
|
||||
|
||||
protected $dateFormat = 'U';
|
||||
|
||||
/**
|
||||
* 允许自动填充模型字段
|
||||
*/
|
||||
protected $fillable = ['id', 'currency', 'amount', 'exchange_rate', 'remark', 'created_at', 'updated_at'];
|
||||
|
||||
/**
|
||||
* 不允许自动填充模型字段
|
||||
*/
|
||||
protected $guarded = [];
|
||||
|
||||
|
||||
protected $fillable = [
|
||||
'object_scene','object_id','field','currency','amount','exchange_rate',
|
||||
'remark','created_at','updated_at'
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'amount' => 'string',
|
||||
'exchange_rate' => 'string',
|
||||
];
|
||||
|
||||
/** 按本行汇率换到结算币;无汇率返回 null */
|
||||
public function amountInSettlement(int $scale = 2): ?string
|
||||
{
|
||||
if ($this->exchange_rate === null) return null;
|
||||
return (string) bcmul((string)$this->amount, (string)$this->exchange_rate, $scale);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\model;
|
||||
|
||||
use support\Model;
|
||||
|
||||
class VehMoneyValue_bak extends Model
|
||||
{
|
||||
/**
|
||||
* The connection name for the model.
|
||||
*
|
||||
* @var string|null
|
||||
*/
|
||||
protected $connection = 'mysql';
|
||||
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'veh_money_value';
|
||||
|
||||
/**
|
||||
* The primary key associated with the table.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $primaryKey = 'id';
|
||||
|
||||
/**
|
||||
* Indicates if the model should be timestamped.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $timestamps = true;
|
||||
|
||||
|
||||
protected $dateFormat = 'U';
|
||||
|
||||
/**
|
||||
* 允许自动填充模型字段
|
||||
*/
|
||||
protected $fillable = ['id', 'currency', 'amount', 'exchange_rate', 'remark', 'created_at', 'updated_at'];
|
||||
|
||||
/**
|
||||
* 不允许自动填充模型字段
|
||||
*/
|
||||
protected $guarded = [];
|
||||
}
|
||||
Reference in New Issue
Block a user