|
|
@@ -38,7 +38,7 @@ class EngineerSettlementLogic extends BaseLogic
|
|
|
* @author likeadmin
|
|
|
* @date 2024/11/15 17:21
|
|
|
*/
|
|
|
- public static function add(array $params): bool
|
|
|
+ public static function add(array $params, $adminId): bool
|
|
|
{
|
|
|
Db::startTrans();
|
|
|
try {
|
|
|
@@ -65,7 +65,7 @@ class EngineerSettlementLogic extends BaseLogic
|
|
|
'title' => '财务打款',
|
|
|
'change_amount' => $param['total_settlement_amount'],
|
|
|
'review_status' => 3,
|
|
|
- 'admin_id' => $param['admin_id'],
|
|
|
+ 'admin_id' => $adminId,
|
|
|
'remark' => '财务打款',
|
|
|
'create_time' => time(),
|
|
|
'update_time' => time(),
|
|
|
@@ -153,9 +153,8 @@ class EngineerSettlementLogic extends BaseLogic
|
|
|
public static function engineerSettlementValidate($params)
|
|
|
{
|
|
|
try {
|
|
|
+ if(empty($params)) throw new \Exception('表格数据为空');
|
|
|
foreach ($params as &$param) {
|
|
|
- $masterWorker = MasterWorker::where('id', $param['master_worker_id'])->where('worker_number', $param['worker_number'])->findOrFail();
|
|
|
- if($masterWorker->user_money < $param['total_settlement_amount']) throw new \Exception('余额不足');
|
|
|
//判断日期时间格式是否正确 2024/1/1 00:00:00 或 2024-1-1 00:00:00
|
|
|
if(!preg_match('/^[0-9]{4}\/[0-9]{1,2}\/[0-9]{1,2} [0-9]{1,2}:[0-9]{1,2}:[0-9]{1,2}$/', $param['settlement_time'])
|
|
|
&& !preg_match('/^[0-9]{4}-[0-9]{1,2}-[0-9]{1,2} [0-9]{1,2}:[0-9]{1,2}:[0-9]{1,2}$/', $param['settlement_time'])){
|
|
|
@@ -163,20 +162,24 @@ class EngineerSettlementLogic extends BaseLogic
|
|
|
}else{
|
|
|
$param['settlement_time'] = date('Y-m-d H:i:s', strtotime($param['settlement_time']));
|
|
|
}
|
|
|
- if(!is_float($param['original_balance']) || !is_float($param['total_settlement_amount']) || !is_float($param['deduction_amount']) || !is_float($param['final_settlement_amount'])){
|
|
|
+ if(!is_numeric($param['original_balance']) || !is_numeric($param['total_settlement_amount']) || !is_numeric($param['deduction_amount']) || !is_numeric($param['final_settlement_amount'])){
|
|
|
throw new \Exception('金额格式错误');
|
|
|
}
|
|
|
- if(!is_int($param['master_worker_id'])){
|
|
|
- throw new \Exception('工程师ID格式错误');
|
|
|
+ if(!preg_match('/^[0-9]*$/', $param['worker_number'])){
|
|
|
+ throw new \Exception('工程师ID格式错误:'.$param['master_worker_id']);
|
|
|
}
|
|
|
- if(!is_numeric($param['worker_number'])){
|
|
|
- throw new \Exception('工程师编号格式错误');
|
|
|
+ if(!preg_match('/^[0-9]*$/', $param['master_worker_id'])){
|
|
|
+ throw new \Exception('工程师ID格式错误:'.$param['master_worker_id']);
|
|
|
}
|
|
|
+ $masterWorker = MasterWorker::where('id', $param['master_worker_id'])->where('worker_number', $param['worker_number'])->findOrEmpty();
|
|
|
+ if($masterWorker->isEmpty()) throw new \Exception('工程师不存在:'.$param['master_worker_id']);
|
|
|
+ if($masterWorker->user_money < $param['total_settlement_amount']) throw new \Exception('余额不足');
|
|
|
}
|
|
|
+ return $params;
|
|
|
} catch (\Exception $e) {
|
|
|
- throw new \Exception($e->getMessage());
|
|
|
+ throw new \Exception($e->getMessage());
|
|
|
}
|
|
|
- return $params;
|
|
|
+
|
|
|
}
|
|
|
|
|
|
|