备货单&审批流程
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; }
|
||||
}
|
||||
Reference in New Issue
Block a user