增加备货单

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
@@ -0,0 +1,33 @@
<?php
namespace app\common\controller;
use app\common\controller\BaseController;
use app\common\traits\crud\CrudControllerTrait;
use app\common\service\StockOrderAccountsService;
class StockOrderAccountsController extends BaseController
{
use CrudControllerTrait;
protected $service;
public function __construct()
{
$this->service = new StockOrderAccountsService();
}
/**
* 列表页数据格式化
*
* @param array $data
* @return array
*/
// protected function indexFormat($data)
// {
// if (isset($data['created_at']))
// $data['created_at'] = date('Y-m-d H:i:s', $data['created_at']);
// if (isset($data['updated_at']))
// $data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']);
// return $data;
// }
}
@@ -0,0 +1,33 @@
<?php
namespace app\common\controller;
use app\common\controller\BaseController;
use app\common\traits\crud\CrudControllerTrait;
use app\common\service\StockOrderItemOptionsService;
class StockOrderItemOptionsController extends BaseController
{
use CrudControllerTrait;
protected $service;
public function __construct()
{
$this->service = new StockOrderItemOptionsService();
}
/**
* 列表页数据格式化
*
* @param array $data
* @return array
*/
// protected function indexFormat($data)
// {
// if (isset($data['created_at']))
// $data['created_at'] = date('Y-m-d H:i:s', $data['created_at']);
// if (isset($data['updated_at']))
// $data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']);
// return $data;
// }
}
@@ -0,0 +1,33 @@
<?php
namespace app\common\controller;
use app\common\controller\BaseController;
use app\common\traits\crud\CrudControllerTrait;
use app\common\service\StockOrderItemsService;
class StockOrderItemsController extends BaseController
{
use CrudControllerTrait;
protected $service;
public function __construct()
{
$this->service = new StockOrderItemsService();
}
/**
* 列表页数据格式化
*
* @param array $data
* @return array
*/
// protected function indexFormat($data)
// {
// if (isset($data['created_at']))
// $data['created_at'] = date('Y-m-d H:i:s', $data['created_at']);
// if (isset($data['updated_at']))
// $data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']);
// return $data;
// }
}
@@ -0,0 +1,33 @@
<?php
namespace app\common\controller;
use app\common\controller\BaseController;
use app\common\traits\crud\CrudControllerTrait;
use app\common\service\VehMoneyValueService;
class VehMoneyValueController extends BaseController
{
use CrudControllerTrait;
protected $service;
public function __construct()
{
$this->service = new VehMoneyValueService();
}
/**
* 列表页数据格式化
*
* @param array $data
* @return array
*/
// protected function indexFormat($data)
// {
// if (isset($data['created_at']))
// $data['created_at'] = date('Y-m-d H:i:s', $data['created_at']);
// if (isset($data['updated_at']))
// $data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']);
// return $data;
// }
}
@@ -0,0 +1,17 @@
<?php
namespace app\common\logic;
use app\common\traits\crud\CrudLogicTrait;
use app\common\model\StockOrderAccounts;
class StockOrderAccountsLogic
{
use CrudLogicTrait;
/**
* 指定当前要操作的模型
*/
protected string $modelClass = StockOrderAccounts::class;
}
@@ -0,0 +1,17 @@
<?php
namespace app\common\logic;
use app\common\traits\crud\CrudLogicTrait;
use app\common\model\StockOrderItemOptions;
class StockOrderItemOptionsLogic
{
use CrudLogicTrait;
/**
* 指定当前要操作的模型
*/
protected string $modelClass = StockOrderItemOptions::class;
}
+17
View File
@@ -0,0 +1,17 @@
<?php
namespace app\common\logic;
use app\common\traits\crud\CrudLogicTrait;
use app\common\model\StockOrderItems;
class StockOrderItemsLogic
{
use CrudLogicTrait;
/**
* 指定当前要操作的模型
*/
protected string $modelClass = StockOrderItems::class;
}
+17
View File
@@ -0,0 +1,17 @@
<?php
namespace app\common\logic;
use app\common\traits\crud\CrudLogicTrait;
use app\common\model\VehMoneyValue;
class VehMoneyValueLogic
{
use CrudLogicTrait;
/**
* 指定当前要操作的模型
*/
protected string $modelClass = VehMoneyValue::class;
}
+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 = [];
}
@@ -0,0 +1,31 @@
<?php
namespace app\common\service;
use app\common\validate\StockOrderAccountsValidate;
use app\common\traits\crud\CrudServiceTrait;
use app\common\model\StockOrderAccounts;
class StockOrderAccountsService
{
use CrudServiceTrait;
/**
* 指定当前要操作的模型
*/
protected string $modelClass = StockOrderAccounts::class;
/**
* 验证器
*/
protected $validator = StockOrderAccountsValidate::class;
/**
* 获取验证器
*/
public function getValidator()
{
return new $this->validator;
}
}
@@ -0,0 +1,31 @@
<?php
namespace app\common\service;
use app\common\validate\StockOrderItemOptionsValidate;
use app\common\traits\crud\CrudServiceTrait;
use app\common\model\StockOrderItemOptions;
class StockOrderItemOptionsService
{
use CrudServiceTrait;
/**
* 指定当前要操作的模型
*/
protected string $modelClass = StockOrderItemOptions::class;
/**
* 验证器
*/
protected $validator = StockOrderItemOptionsValidate::class;
/**
* 获取验证器
*/
public function getValidator()
{
return new $this->validator;
}
}
@@ -0,0 +1,31 @@
<?php
namespace app\common\service;
use app\common\validate\StockOrderItemsValidate;
use app\common\traits\crud\CrudServiceTrait;
use app\common\model\StockOrderItems;
class StockOrderItemsService
{
use CrudServiceTrait;
/**
* 指定当前要操作的模型
*/
protected string $modelClass = StockOrderItems::class;
/**
* 验证器
*/
protected $validator = StockOrderItemsValidate::class;
/**
* 获取验证器
*/
public function getValidator()
{
return new $this->validator;
}
}
@@ -0,0 +1,31 @@
<?php
namespace app\common\service;
use app\common\validate\VehMoneyValueValidate;
use app\common\traits\crud\CrudServiceTrait;
use app\common\model\VehMoneyValue;
class VehMoneyValueService
{
use CrudServiceTrait;
/**
* 指定当前要操作的模型
*/
protected string $modelClass = VehMoneyValue::class;
/**
* 验证器
*/
protected $validator = VehMoneyValueValidate::class;
/**
* 获取验证器
*/
public function getValidator()
{
return new $this->validator;
}
}
+44 -44
View File
@@ -34,52 +34,52 @@ class VehVehicleSkuService
}
// 枚举
private const MAPS = [
'BODY' => [
'SEDAN' => '三厢轿车', 'SUV'=>'SUV', 'HB'=>'两厢/掀背', 'MPV'=>'MPV', 'PICKUP'=>'皮卡'
],
'DRIVE' => [
'FWD'=>'前驱', 'RWD'=>'后驱', 'AWD'=>'四驱(AWD)', '4WD'=>'四驱(4WD)'
],
'MOTOR_LAYOUT' => [
'FWD'=>'前置单电机', 'RWD'=>'后置单电机', 'AWD'=>'双电机四驱', 'DM-I'=>'DM-i', 'DM-P'=>'DM-p'
],
'FUEL' => [
'GAS'=>'汽油', 'HEV'=>'油电混动', 'PHEV'=>'插电混动', 'EV'=>'纯电', 'EREV'=>'增程'
],
'TRANS' => [
'MT'=>'手动', 'AT'=>'自动', 'CVT'=>'无级', 'DCT'=>'双离合', '1SPEED'=>'单速'
],
'RANGE_STD' => [
'CLTC'=>'CLTC', 'WLTP'=>'WLTP', 'EPA'=>'EPA', 'NEDC'=>'NEDC'
],
'EMISSION' => [
'CHN6'=>'国六', 'EURO6'=>'欧6', 'EPA'=>'美国EPA'
],
];
// // 枚举
// private const MAPS = [
// 'BODY' => [
// 'SEDAN' => '三厢轿车', 'SUV'=>'SUV', 'HB'=>'两厢/掀背', 'MPV'=>'MPV', 'PICKUP'=>'皮卡'
// ],
// 'DRIVE' => [
// 'FWD'=>'前驱', 'RWD'=>'后驱', 'AWD'=>'四驱(AWD)', '4WD'=>'四驱(4WD)'
// ],
// 'MOTOR_LAYOUT' => [
// 'FWD'=>'前置单电机', 'RWD'=>'后置单电机', 'AWD'=>'双电机四驱', 'DM-I'=>'DM-i', 'DM-P'=>'DM-p'
// ],
// 'FUEL' => [
// 'GAS'=>'汽油', 'HEV'=>'油电混动', 'PHEV'=>'插电混动', 'EV'=>'纯电', 'EREV'=>'增程'
// ],
// 'TRANS' => [
// 'MT'=>'手动', 'AT'=>'自动', 'CVT'=>'无级', 'DCT'=>'双离合', '1SPEED'=>'单速'
// ],
// 'RANGE_STD' => [
// 'CLTC'=>'CLTC', 'WLTP'=>'WLTP', 'EPA'=>'EPA', 'NEDC'=>'NEDC'
// ],
// 'EMISSION' => [
// 'CHN6'=>'国六', 'EURO6'=>'欧6', 'EPA'=>'美国EPA'
// ],
// ];
// *_code取中文
public function label(string $dict, ?string $code): ?string
{
if ($code === null || $code === '') return null;
$dict = strtoupper($dict);
$code = strtoupper($code);
return self::MAPS[$dict][$code] ?? $code;
}
// // *_code取中文
// public function label(string $dict, ?string $code): ?string
// {
// if ($code === null || $code === '') return null;
// $dict = strtoupper($dict);
// $code = strtoupper($code);
// return self::MAPS[$dict][$code] ?? $code;
// }
// 静态映射把 *_code → 中文
private function backfill(array $d): array
{
$d['body_type'] = $this->label('BODY', $d['body_type_code']);
$d['drive_type'] = $this->label('DRIVE', $d['drive_type_code']);
$d['motor_layout'] = $this->label('MOTOR_LAYOUT', $d['motor_layout_code']);
$d['fuel_type'] = $this->label('FUEL', $d['fuel_type_code']);
$d['transmission'] = $this->label('TRANS', $d['transmission_code']);
$d['range_std'] = $this->label('RANGE_STD', $d['range_std_code']);
$d['emission_std'] = $this->label('EMISSION', $d['emission_std_code']);
return $d;
}
// // 静态映射把 *_code → 中文
// private function backfill(array $d): array
// {
// $d['body_type'] = $this->label('BODY', $d['body_type_code']);
// $d['drive_type'] = $this->label('DRIVE', $d['drive_type_code']);
// $d['motor_layout'] = $this->label('MOTOR_LAYOUT', $d['motor_layout_code']);
// $d['fuel_type'] = $this->label('FUEL', $d['fuel_type_code']);
// $d['transmission'] = $this->label('TRANS', $d['transmission_code']);
// $d['range_std'] = $this->label('RANGE_STD', $d['range_std_code']);
// $d['emission_std'] = $this->label('EMISSION', $d['emission_std_code']);
// return $d;
// }
protected function buildQueryConfig(Request $request, string $scene = 'default'): array
{
@@ -0,0 +1,29 @@
<?php
namespace app\common\validate;
use think\Validate;
class StockOrderAccountsValidate extends Validate
{
// 规则
protected $rule = [
];
// 提示
protected $message = [
];
// 场景
protected $scene = [
'store' => [
],
'update' => [
]
];
}
@@ -0,0 +1,29 @@
<?php
namespace app\common\validate;
use think\Validate;
class StockOrderItemOptionsValidate extends Validate
{
// 规则
protected $rule = [
];
// 提示
protected $message = [
];
// 场景
protected $scene = [
'store' => [
],
'update' => [
]
];
}
@@ -0,0 +1,29 @@
<?php
namespace app\common\validate;
use think\Validate;
class StockOrderItemsValidate extends Validate
{
// 规则
protected $rule = [
];
// 提示
protected $message = [
];
// 场景
protected $scene = [
'store' => [
],
'update' => [
]
];
}
@@ -0,0 +1,29 @@
<?php
namespace app\common\validate;
use think\Validate;
class VehMoneyValueValidate extends Validate
{
// 规则
protected $rule = [
];
// 提示
protected $message = [
];
// 场景
protected $scene = [
'store' => [
],
'update' => [
]
];
}