修改计å¤备货单金额计算&&采购单编写â
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
namespace app\common\controller;
|
||||
|
||||
use app\common\controller\BaseController;
|
||||
use app\common\traits\crud\CrudControllerTrait;
|
||||
use app\common\service\PurchaseOrderItemsService;
|
||||
|
||||
class PurchaseOrderItemsController extends BaseController
|
||||
{
|
||||
use CrudControllerTrait;
|
||||
|
||||
protected $service;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->service = new PurchaseOrderItemsService();
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表页数据格式化
|
||||
*
|
||||
* @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,51 @@
|
||||
<?php
|
||||
namespace app\common\controller;
|
||||
|
||||
use app\common\controller\BaseController;
|
||||
use app\common\traits\crud\CrudControllerTrait;
|
||||
use app\common\service\PurchaseOrdersService;
|
||||
use support\Request;
|
||||
|
||||
class PurchaseOrdersController extends BaseController
|
||||
{
|
||||
use CrudControllerTrait;
|
||||
|
||||
protected $service;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->service = new PurchaseOrdersService();
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表页数据格式化
|
||||
*
|
||||
* @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;
|
||||
// }
|
||||
|
||||
|
||||
/**
|
||||
* 前置查询处理
|
||||
*
|
||||
* @param Request $request
|
||||
* @return array
|
||||
*/
|
||||
public function preQueryData(Request $request)
|
||||
{
|
||||
try {
|
||||
$data = $this->service->preQueryData($request->all());
|
||||
return $this->success($data);
|
||||
} catch (\Throwable $e) {
|
||||
return $this->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\logic;
|
||||
|
||||
use app\common\traits\crud\CrudLogicTrait;
|
||||
use app\common\model\PurchaseOrderItems;
|
||||
|
||||
class PurchaseOrderItemsLogic
|
||||
{
|
||||
use CrudLogicTrait;
|
||||
|
||||
/**
|
||||
* 指定当前要操作的模型
|
||||
*/
|
||||
protected string $modelClass = PurchaseOrderItems::class;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\logic;
|
||||
|
||||
use app\common\traits\crud\CrudLogicTrait;
|
||||
use app\common\model\PurchaseOrders;
|
||||
use app\common\model\StockOrderItems;
|
||||
use app\common\utils\CrudUtil;
|
||||
use app\common\model\StockOrders;
|
||||
|
||||
class PurchaseOrdersLogic
|
||||
{
|
||||
use CrudLogicTrait;
|
||||
|
||||
/**
|
||||
* 指定当前要操作的模型
|
||||
*/
|
||||
protected string $modelClass = PurchaseOrders::class;
|
||||
|
||||
|
||||
/**
|
||||
* 获取备货单PI号
|
||||
*/
|
||||
public function getPiList()
|
||||
{
|
||||
return (new StockOrders())->where('pi_no', '!=', '')
|
||||
->select('pi_no')
|
||||
->distinct()
|
||||
->get();
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据PI号获取备货单
|
||||
*/
|
||||
public function getOrderNoListByPiNo($piNo)
|
||||
{
|
||||
return (new StockOrders())->where('pi_no', $piNo)
|
||||
->select('order_no', 'biz_date', 'salesperson_snapshot', 'id as stock_orders_id')
|
||||
->get();
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据备货单号获取备货单明细
|
||||
*/
|
||||
public function getOrderItemsListByOrderNo($stockOrdersId)
|
||||
{
|
||||
return (new StockOrderItems())->where('order_id', $stockOrdersId)
|
||||
->select('model_snapshot', 'color_interior_snapshot', 'color_exterior_snapshot', 'unique_id', 'id as stock_order_items_id')
|
||||
->get();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\model;
|
||||
|
||||
use support\Model;
|
||||
|
||||
class PurchaseOrderItems extends Model
|
||||
{
|
||||
/**
|
||||
* The connection name for the model.
|
||||
*
|
||||
* @var string|null
|
||||
*/
|
||||
protected $connection = 'mysql';
|
||||
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'purchase_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', 'purchase_order_id', 'stock_id', 'stock_items_id', 'stock_items_uqid', 'quantity', 'unit_price', 'total_price', 'remark'];
|
||||
|
||||
/**
|
||||
* 不允许自动填充模型字段
|
||||
*/
|
||||
protected $guarded = [];
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\model;
|
||||
|
||||
use support\Model;
|
||||
|
||||
class PurchaseOrders extends Model
|
||||
{
|
||||
/**
|
||||
* The connection name for the model.
|
||||
*
|
||||
* @var string|null
|
||||
*/
|
||||
protected $connection = 'mysql';
|
||||
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'purchase_orders';
|
||||
|
||||
/**
|
||||
* 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', 'po_no', 'pi_no', 'buyer_id', 'contract_file', 'status', 'remark', 'created_at', 'updated_at'];
|
||||
|
||||
/**
|
||||
* 不允许自动填充模型字段
|
||||
*/
|
||||
protected $guarded = [];
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\service;
|
||||
|
||||
use app\common\validate\PurchaseOrderItemsValidate;
|
||||
use app\common\traits\crud\CrudServiceTrait;
|
||||
use app\common\model\PurchaseOrderItems;
|
||||
|
||||
class PurchaseOrderItemsService
|
||||
{
|
||||
|
||||
use CrudServiceTrait;
|
||||
|
||||
/**
|
||||
* 指定当前要操作的模型
|
||||
*/
|
||||
protected string $modelClass = PurchaseOrderItems::class;
|
||||
|
||||
/**
|
||||
* 验证器
|
||||
*/
|
||||
protected $validator = PurchaseOrderItemsValidate::class;
|
||||
|
||||
/**
|
||||
* 获取验证器
|
||||
*/
|
||||
public function getValidator()
|
||||
{
|
||||
return new $this->validator;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\service;
|
||||
|
||||
use app\common\validate\PurchaseOrdersValidate;
|
||||
use app\common\traits\crud\CrudServiceTrait;
|
||||
use app\common\model\PurchaseOrders;
|
||||
use support\Request;
|
||||
use app\common\logic\PurchaseOrdersLogic;
|
||||
use app\common\model\PurchaseOrderItems;
|
||||
|
||||
class PurchaseOrdersService
|
||||
{
|
||||
|
||||
use CrudServiceTrait;
|
||||
|
||||
/**
|
||||
* 指定当前要操作的模型
|
||||
*/
|
||||
protected string $modelClass = PurchaseOrders::class;
|
||||
|
||||
/**
|
||||
* 验证器
|
||||
*/
|
||||
protected $validator = PurchaseOrdersValidate::class;
|
||||
|
||||
/**
|
||||
* 获取验证器
|
||||
*/
|
||||
public function getValidator()
|
||||
{
|
||||
return new $this->validator;
|
||||
}
|
||||
|
||||
|
||||
public function getLogic()
|
||||
{
|
||||
return new PurchaseOrdersLogic();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取前置预处理数据
|
||||
*
|
||||
* @param array $data 原始返回值
|
||||
* @return array 处理后的返回值
|
||||
*/
|
||||
public function preQueryData(array $data)
|
||||
{
|
||||
$result = match ($data['scene']) {
|
||||
'pi_no' => $this->getLogic()->getPiList(),
|
||||
'order_no' => $this->getLogic()->getOrderNoListByPiNo($data['pi_no']),
|
||||
'order_items' => $this->getLogic()->getOrderItemsListByOrderNo($data['order_id']),
|
||||
default => $data,
|
||||
};
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function beforeServiceStore(array $data, Request $request)
|
||||
{
|
||||
$data['po_no'] = generateStockNo('CG');
|
||||
$data['buyer_id'] = $request->user->uid;
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function serviceStore(Request $request, array $data = [], string $scene = 'store')
|
||||
{
|
||||
$data = $this->preProcess(ucfirst($scene), $data, $request);
|
||||
$dl = $this->getDataLimitFromRequest($request);
|
||||
// 创建采购单
|
||||
$created = $this->logicCreate($data, $dl);
|
||||
foreach ($data['stock_order'] as $order) {
|
||||
foreach ($order['stock_items'] as $item) {
|
||||
// 创建采购单明细
|
||||
PurchaseOrderItems::create([
|
||||
'purchase_order_id' => $created->id,
|
||||
'stock_id' => $order['stock_orders_id'],
|
||||
'stock_items_id' => $item['stock_order_items_id'],
|
||||
'stock_items_uqid' => $item['unique_id'],
|
||||
]);
|
||||
}
|
||||
}
|
||||
return $this->postProcess(ucfirst($scene), $created);
|
||||
}
|
||||
}
|
||||
@@ -160,7 +160,7 @@ class StockOrdersService
|
||||
$config['with'][] = 'moneyValues';
|
||||
$config['with'][] = 'salesperson';
|
||||
$item = $this->logicShow($config);
|
||||
$pdfData = $this->pdfData($item);
|
||||
$pdfData = $this->formatData($item);
|
||||
|
||||
// 渲染模板为最终HTML
|
||||
$tplPath = app_path('common/utils/pdf/template/stockOrder.stub');
|
||||
@@ -200,7 +200,7 @@ class StockOrdersService
|
||||
return $res;
|
||||
}
|
||||
|
||||
public function pdfData($item)
|
||||
public function pdfData2($item)
|
||||
{
|
||||
$vehList = [];
|
||||
$index = 0;
|
||||
@@ -375,8 +375,8 @@ class StockOrdersService
|
||||
{
|
||||
$config = $this->buildQueryConfig($request, 'detail');
|
||||
$item = $this->logicShow($config);
|
||||
$pdfData = $this->pdfData($item);
|
||||
return $this->postProcess('Detail', $pdfData);
|
||||
$detail = $this->formatData($item);
|
||||
return $this->postProcess('Detail', $detail);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -739,4 +739,238 @@ class StockOrdersService
|
||||
StockOrderAccounts::create($account);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ====== ======= ====== ======= ====== 信息处理 ======= ====== ======= ====== =======
|
||||
|
||||
// PDF数据
|
||||
public function formatData($item)
|
||||
{
|
||||
// 提取车辆列表信息
|
||||
$vehListData = $this->prepareVehicleListData($item);
|
||||
|
||||
// 提取订单金额信息
|
||||
$moneyValues = $this->prepareOrderMoneyValues($item);
|
||||
|
||||
// 提取账户列表信息
|
||||
$accountList = $this->prepareAccountList($item);
|
||||
|
||||
// 构建返回数据
|
||||
$veh = [
|
||||
// 基本信息
|
||||
'order_no' => $item->order_no,
|
||||
'salesperson_snapshot' => $item->salesperson_snapshot,
|
||||
'sign_img_url' => $this->getSignatureImageUrl($item->salesperson->sign_img ?? null),
|
||||
'created_at' => date('Y-m-d', strtotime($item->created_at)),
|
||||
|
||||
'pi_no' => $item->pi_no,
|
||||
'biz_date' => date('Y-m-d', $item->biz_date),
|
||||
'clearance_country_snapshot' => $item->clearance_country_snapshot,
|
||||
'customer_source_snapshot' => $item->customer_source_snapshot,
|
||||
'customer_snapshot' => $item->customer_snapshot,
|
||||
'customer_country_snapshot' => $item->customer_country_snapshot,
|
||||
|
||||
// 订单项
|
||||
'veh_list' => array_values($vehListData['list']),
|
||||
'contract_exchange_rate' => $item->contract_exchange_rate,
|
||||
'cif_total_amount' => $moneyValues['cif_total_amount'] ?? [],
|
||||
'profit_total' => $moneyValues['profit_total'] ?? [],
|
||||
|
||||
// 运输和交付信息
|
||||
'declarant_name' => $item->declarant_name,
|
||||
'eta_ship_date' => date('Y-m-d', $item->eta_ship_date),
|
||||
'shipping_method_snapshot' => $item->shipping_method_snapshot,
|
||||
'domestic_port_snapshot' => $item->domestic_port_snapshot,
|
||||
'trade_term_snapshot' => $item->trade_term_snapshot,
|
||||
'clearance_port_snapshot' => $item->clearance_port_snapshot,
|
||||
'latest_arrival_date' => date('Y-m-d', $item->latest_arrival_date),
|
||||
'pick_up_date' => date('Y-m-d', $item->pick_up_date),
|
||||
'collect_all_date' => date('Y-m-d', $item->collect_all_date),
|
||||
'is_final' => $item->is_final,
|
||||
|
||||
// 账户信息
|
||||
'account_list' => $accountList,
|
||||
'acc_index' => count($accountList) + 1,
|
||||
'currency_symbol' => $item->settlement_currency,
|
||||
'sign_imgs' => $this->queryAppro($item->id),
|
||||
'contract_url' => $this->getContractUrl($item->contract ?? null)
|
||||
];
|
||||
|
||||
return $veh;
|
||||
}
|
||||
|
||||
/**
|
||||
* 准备车辆列表数据
|
||||
*/
|
||||
private function prepareVehicleListData($item): array
|
||||
{
|
||||
$vehList = [];
|
||||
$index = 0;
|
||||
$currencyInfo = $this->getCurrencyInfo($item->settlement_currency);
|
||||
|
||||
foreach ($item->items as $v) {
|
||||
// 如果已存在相同车辆,增加数量
|
||||
if (isset($vehList[$v->unique_id])) {
|
||||
$this->incrementVehicleCount($vehList[$v->unique_id], $currencyInfo);
|
||||
continue;
|
||||
}
|
||||
|
||||
$index++;
|
||||
// 处理金额信息
|
||||
$moneyValues = $this->processItemMoneyValues($v);
|
||||
|
||||
// 处理改装信息
|
||||
$modificationText = $this->getModificationText($v->options);
|
||||
|
||||
// 计算单项利润
|
||||
$itemProfit = $this->calculateProfit($moneyValues, $item);
|
||||
|
||||
// 构建车辆信息
|
||||
$vehList[$v->unique_id] = [
|
||||
'index' => $index,
|
||||
'model_snapshot' => $v->model_snapshot,
|
||||
'color_interior_snapshot' => $v->color_interior_snapshot,
|
||||
'color_exterior_snapshot' => $v->color_exterior_snapshot,
|
||||
'num' => 1,
|
||||
'modify' => $modificationText,
|
||||
'mileage' => $v->mileage
|
||||
] + $moneyValues;
|
||||
|
||||
// 添加利润信息
|
||||
$vehList[$v->unique_id]['profit'] = [
|
||||
'currency' => $item->settlement_currency,
|
||||
'amount' => $itemProfit,
|
||||
'currency_info' => $currencyInfo['currency_symbol'] . number_format($itemProfit, 2, '.', ',')
|
||||
];
|
||||
}
|
||||
|
||||
return ['list' => $vehList];
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理单项金额值
|
||||
*/
|
||||
private function processItemMoneyValues($item): array
|
||||
{
|
||||
$moneyValues = [];
|
||||
foreach ($item->moneyValues as $money) {
|
||||
$moneyValues[$money->field] = [
|
||||
'currency' => $money->currency,
|
||||
'amount' => $money->amount,
|
||||
'rate' => $money->exchange_rate,
|
||||
'currency_info' => $this->formatCurrency($money->amount, $money->currency)
|
||||
];
|
||||
}
|
||||
return $moneyValues;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取改装文本
|
||||
*/
|
||||
private function getModificationText($options): string
|
||||
{
|
||||
$modificationText = '';
|
||||
foreach ($options as $option) {
|
||||
$modificationText .= $option->option_name_snapshot . ' ';
|
||||
}
|
||||
return trim($modificationText);
|
||||
}
|
||||
|
||||
/**
|
||||
* 增加车辆数量并更新相关金额显示
|
||||
*/
|
||||
private function incrementVehicleCount(array &$vehicleData, array $currencyInfo): void
|
||||
{
|
||||
$vehicleData['num'] += 1;
|
||||
|
||||
// 更新总价显示
|
||||
if (isset($vehicleData['total_price']['amount'])) {
|
||||
$totalAmount = $vehicleData['total_price']['amount'] * $vehicleData['num'];
|
||||
$vehicleData['total_price']['currency_info'] = $currencyInfo['currency_symbol'] . number_format($totalAmount, 2, '.', ',');
|
||||
}
|
||||
|
||||
// 更新利润显示
|
||||
if (isset($vehicleData['profit']['amount'])) {
|
||||
$profitAmount = $vehicleData['profit']['amount'] * $vehicleData['num'];
|
||||
$vehicleData['profit']['currency_info'] = $currencyInfo['currency_symbol'] . number_format($profitAmount, 2, '.', ',');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 准备订单金额值
|
||||
*/
|
||||
private function prepareOrderMoneyValues($item): array
|
||||
{
|
||||
$moneyValues = [];
|
||||
foreach ($item->moneyValues as $money) {
|
||||
$moneyValues[$money->field] = [
|
||||
'currency' => $money->currency,
|
||||
'amount' => $money->amount,
|
||||
'rate' => $money->exchange_rate,
|
||||
'currency_info' => $this->formatCurrency($money->amount, $money->currency)
|
||||
];
|
||||
}
|
||||
return $moneyValues;
|
||||
}
|
||||
|
||||
/**
|
||||
* 准备账户列表
|
||||
*/
|
||||
private function prepareAccountList($item): array
|
||||
{
|
||||
$accountList = [];
|
||||
foreach ($item->accounts as $k => $account) {
|
||||
$accountList[] = [
|
||||
'index' => '收款' . ($k + 1),
|
||||
'remit_country_name_snapshot' => $account->remit_country_name_snapshot,
|
||||
'remit_date' => date('Y-m-d', $account->remit_date),
|
||||
'currency_name_snapshot' => $account->currency_name_snapshot,
|
||||
'account_name_snapshot' => $account->account_name_snapshot,
|
||||
'remitter_name' => $account->remitter_name,
|
||||
'amount' => $account->amount,
|
||||
];
|
||||
}
|
||||
return $accountList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取货币信息
|
||||
*/
|
||||
private function getCurrencyInfo(string $currencyCode): array
|
||||
{
|
||||
return SysCurrency::where('currency_code', $currencyCode)
|
||||
->first(['currency_symbol', 'currency_name'])
|
||||
->toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* 格式化货币显示
|
||||
*/
|
||||
private function formatCurrency(float $amount, string $currencyCode): string
|
||||
{
|
||||
$currencySymbol = SysCurrency::where('currency_code', $currencyCode)->value('currency_symbol');
|
||||
return $currencySymbol . number_format($amount, 2, '.', ',');
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取签名图片URL
|
||||
*/
|
||||
private function getSignatureImageUrl(?string $signImg): string
|
||||
{
|
||||
if (empty($signImg)) {
|
||||
return '';
|
||||
}
|
||||
return (new \app\common\service\OssService)->generatePrivateUrl($signImg);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取合同URL
|
||||
*/
|
||||
private function getContractUrl(?string $contract): string
|
||||
{
|
||||
if (empty($contract)) {
|
||||
return '';
|
||||
}
|
||||
return (new \app\common\service\OssService)->generatePrivateUrl($contract);
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@ namespace app\common\service;
|
||||
use app\common\validate\VehMoneyValueValidate;
|
||||
use app\common\traits\crud\CrudServiceTrait;
|
||||
use app\common\model\VehMoneyValue;
|
||||
use support\Db;
|
||||
|
||||
class VehMoneyValueService
|
||||
{
|
||||
@@ -28,4 +29,49 @@ class VehMoneyValueService
|
||||
{
|
||||
return new $this->validator;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 复制金额记录
|
||||
*
|
||||
* @param string $fromScene 源场景
|
||||
* @param int $fromId 源对象ID
|
||||
* @param string $toScene 目标场景
|
||||
* @param int $toId 目标对象ID
|
||||
* @return int 插入条数
|
||||
* @throws BusinessException
|
||||
*/
|
||||
public function copyMoneyValues(string $fromScene, int $fromId, string $toScene, int $toId): int
|
||||
{
|
||||
// 1. 查询源数据
|
||||
$rows = Db::table('veh_money_value')
|
||||
->where('object_scene', $fromScene)
|
||||
->where('object_id', $fromId)
|
||||
->get()
|
||||
->toArray();
|
||||
|
||||
if (empty($rows)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
$now = time();
|
||||
$insertData = [];
|
||||
|
||||
foreach ($rows as $row) {
|
||||
$insertData[] = [
|
||||
'object_scene' => $toScene,
|
||||
'object_id' => $toId,
|
||||
'field' => $row->field,
|
||||
'currency' => $row->currency,
|
||||
'amount' => $row->amount,
|
||||
'exchange_rate' => $row->exchange_rate,
|
||||
'remark' => $row->remark,
|
||||
'created_at' => $now,
|
||||
'updated_at' => $now,
|
||||
];
|
||||
}
|
||||
|
||||
// 2. 插入新数据
|
||||
return Db::table('veh_money_value')->insert($insertData);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\validate;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
class PurchaseOrderItemsValidate extends Validate
|
||||
{
|
||||
// 规则
|
||||
protected $rule = [
|
||||
|
||||
];
|
||||
|
||||
// 提示
|
||||
protected $message = [
|
||||
|
||||
];
|
||||
|
||||
// 场景
|
||||
protected $scene = [
|
||||
'store' => [
|
||||
|
||||
],
|
||||
|
||||
'update' => [
|
||||
|
||||
]
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\validate;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
class PurchaseOrdersValidate extends Validate
|
||||
{
|
||||
// 规则
|
||||
protected $rule = [
|
||||
|
||||
];
|
||||
|
||||
// 提示
|
||||
protected $message = [
|
||||
|
||||
];
|
||||
|
||||
// 场景
|
||||
protected $scene = [
|
||||
'store' => [
|
||||
|
||||
],
|
||||
|
||||
'update' => [
|
||||
|
||||
]
|
||||
];
|
||||
}
|
||||
@@ -69,42 +69,45 @@ class IndexController
|
||||
*/
|
||||
public function createResource()
|
||||
{
|
||||
$options = [
|
||||
'controller' => [
|
||||
'module' => 'crm',
|
||||
'name' => 'approval_flows'
|
||||
],
|
||||
'model' => [
|
||||
'module' => 'crm',
|
||||
'name' => 'approval_flows'
|
||||
],
|
||||
'service' => [
|
||||
'module' => 'crm',
|
||||
'name' => 'approval_flows'
|
||||
],
|
||||
'logic' => [
|
||||
'module' => 'crm',
|
||||
'name' => 'approval_flows'
|
||||
],
|
||||
'validate' => [
|
||||
'module' => 'crm',
|
||||
'name' => 'approval_flows'
|
||||
],
|
||||
'table' => 'approval_flows'
|
||||
];
|
||||
// $options = [
|
||||
// 'controller' => [
|
||||
// 'module' => 'common',
|
||||
// 'name' => 'purchase_order_items'
|
||||
// ],
|
||||
// 'model' => [
|
||||
// 'module' => 'common',
|
||||
// 'name' => 'purchase_order_items'
|
||||
// ],
|
||||
// 'service' => [
|
||||
// 'module' => 'common',
|
||||
// 'name' => 'purchase_order_items'
|
||||
// ],
|
||||
// 'logic' => [
|
||||
// 'module' => 'common',
|
||||
// 'name' => 'purchase_order_items'
|
||||
// ],
|
||||
// 'validate' => [
|
||||
// 'module' => 'common',
|
||||
// 'name' => 'purchase_order_items'
|
||||
// ],
|
||||
// 'table' => 'purchase_order_items'
|
||||
// ];
|
||||
|
||||
$result = (new Generate($options))->doGenerate();
|
||||
return $result;
|
||||
// $result = (new Generate($options))->doGenerate();
|
||||
// return $result;
|
||||
}
|
||||
|
||||
|
||||
public function test(Request $request)
|
||||
{
|
||||
// 菜单迁移
|
||||
// $where[] = ['id', '>', 141];
|
||||
// $list = (new \app\common\utils\MigrationResources())->do('resources_20250916_bak', 'resources_yuanshi', $where);
|
||||
|
||||
$list = (new \app\common\utils\MigrationResources())->getFullResourceTreeOptimized('resources_20250916_bak', []);
|
||||
var_dump($list);
|
||||
// $list = (new \app\common\logic\PurchaseOrdersLogic())->getPiList()->toArray();
|
||||
|
||||
|
||||
// $list = (new \app\common\logic\PurchaseOrdersLogic())->getOrderNoListByPiNo('ces1222')->toArray();
|
||||
|
||||
|
||||
// $list = (new \app\common\logic\PurchaseOrdersLogic())->getOrderItemsListByOrderNo(32)->toArray();
|
||||
// var_dump($list);
|
||||
}
|
||||
}
|
||||
@@ -351,6 +351,11 @@ Route::group('/admin', function () {
|
||||
Route::any('/user/achieved', [app\admin\targets\controller\StatisticsController::class, 'userAchieved']);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Route::group('/purchase/order', function () {
|
||||
Route::any('/predata', [app\common\controller\PurchaseOrdersController::class, 'preQueryData']);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user