增加备货单

This commit is contained in:
mzl
2025-09-02 17:22:56 +08:00
parent 9c0bb434c9
commit 6a1ab1f5c3
22 changed files with 715 additions and 45 deletions
+49
View File
@@ -0,0 +1,49 @@
<?php
namespace app\common\model;
use support\Model;
class StockOrderAccounts extends Model
{
/**
* The connection name for the model.
*
* @var string|null
*/
protected $connection = 'mysql';
/**
* The table associated with the model.
*
* @var string
*/
protected $table = 'stock_order_accounts';
/**
* 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', 'order_id', 'seq_no', 'remit_country_id', 'remit_country_name_snapshot', 'remit_date', 'currency_code', 'currency_name_snapshot', 'account_id', 'account_name_snapshot', 'remitter_name', 'amount', 'created_at', 'updated_at'];
/**
* 不允许自动填充模型字段
*/
protected $guarded = [];
}
@@ -0,0 +1,49 @@
<?php
namespace app\common\model;
use support\Model;
class StockOrderItemOptions extends Model
{
/**
* The connection name for the model.
*
* @var string|null
*/
protected $connection = 'mysql';
/**
* The table associated with the model.
*
* @var string
*/
protected $table = 'stock_order_item_options';
/**
* 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', 'order_item_id', 'option_id', 'option_name_snapshot', 'option_price', 'created_at', 'updated_at'];
/**
* 不允许自动填充模型字段
*/
protected $guarded = [];
}
+83
View File
@@ -0,0 +1,83 @@
<?php
namespace app\common\model;
use support\Model;
class StockOrderItems extends Model
{
/**
* The connection name for the model.
*
* @var string|null
*/
protected $connection = 'mysql';
/**
* The table associated with the model.
*
* @var string
*/
protected $table = 'stock_order_items';
/**
* 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', '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 $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
{
$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;
}
}
+1 -1
View File
@@ -40,7 +40,7 @@ class StockOrders extends Model
/**
* 允许自动填充模型字段
*/
protected $fillable = ['id', 'order_no', 'pi_no', 'biz_date', 'salesperson_id', 'salesperson_name_snapshot', 'clearance_country_id', 'clearance_country_name_snapshot', 'ali_order_no', 'customer_source_id', 'customer_source_name_snapshot', 'customer_id', 'customer_name_snapshot', 'customer_country_id', 'customer_country_name_snapshot', 'declarant_name', 'eta_ship_date', 'shipping_method', 'cif_total_amount', 'domestic_port_id', 'domestic_port_name_snapshot', 'trade_term_id', 'trade_term_name_snapshot', 'clearance_port_id', 'clearance_port_name_snapshot', 'latest_arrival_date', 'contract_exchange_rate', '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', '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'];
/**
* 不允许自动填充模型字段
+49
View File
@@ -0,0 +1,49 @@
<?php
namespace app\common\model;
use support\Model;
class VehMoneyValue 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 = [];
}