Files
fdesk/app/crm/service/StockOrdersService.php
T

86 lines
2.7 KiB
PHP
Raw Normal View History

2025-09-10 13:39:06 +08:00
<?php
namespace app\crm\service;
use support\Request;
use support\exception\BusinessException;
2025-09-10 13:39:06 +08:00
2025-09-22 18:49:18 +08:00
class StockOrdersService extends \app\common\service\StockOrdersService
2025-09-10 13:39:06 +08:00
{
protected function buildQueryConfig(Request $request, string $scene = 'index'): array
{
$p = $request->all();
$config = [];
$config['model'] = $this->modelClass;
switch ($scene) {
case 'index':
// ====== ====== 筛选 ====== ======
// 业务id
if (isset($p['salesperson_id']) && $p['salesperson_id']) {
$config['where']['salesperson_id'] = $p['salesperson_id'];
}
// 初、终版
$config['where']['is_final'] = $p['is_final'] ?? 0;
// 关键字
if (isset($p['keyword']) && $p['keyword']) {
$k = '%' . $p['keyword'] . '%';
foreach (['pi_no', 'order_no', 'customer_snapshot'] as $col) {
$config['orWhere'][] = [$col, 'like', $k];
}
}
$config['order']['id'] = 'desc';
$config['where']['salesperson_id'] = $request->user->uid;
break;
case 'print':
2025-09-10 18:34:20 +08:00
case 'approval':
2025-09-10 13:39:06 +08:00
$config['where']['id'] = $p['id'];
break;
2025-09-11 15:31:37 +08:00
case 'detail':
2025-09-10 13:39:06 +08:00
case 'show':
$config['where']['id'] = $p['id'];
$config['with'][] = 'items';
$config['with'][] = 'items.options';
$config['with'][] = 'items.moneyValues';
$config['with'][] = 'accounts';
$config['with'][] = 'moneyValues';
$config['with'][] = 'salesperson';
break;
case 'store':
break;
case 'update':
$config['where']['id'] = $p['id'];
break;
case 'destroy':
$config['where']['id'] = $p['id'];
break;
}
return $config;
}
2025-09-10 18:34:20 +08:00
/**
* 最终审批
*/
public function serviceUltimateApproval(Request $request)
{
$config = $this->buildQueryConfig($request, 'detail');
$item = $this->logicShow($config);
foreach ($item->items as $k => $v) {
if ($v->vin === '') {
throw new BusinessException('存在未填写vin的车辆,无法完成提交审核');
}
}
$this->logicUpdateBy($config, [
'approval_status' => 1
]);
$this->startApproval($item);
return $this->postProcess('UltimateApproval', $item);
}
2025-09-10 13:39:06 +08:00
}