diff --git a/app/common/controller/FinPaymentApplyController.php b/app/common/controller/FinPaymentApplyController.php index 3bf4b15..6f29595 100644 --- a/app/common/controller/FinPaymentApplyController.php +++ b/app/common/controller/FinPaymentApplyController.php @@ -70,6 +70,16 @@ class FinPaymentApplyController extends BaseController $data['enter_file_last'] = date('Y-m-d H:i:s', ($data['claimed_at']+86400)); //入账资料最后提交时间 $data['claimed_at'] = date('Y-m-d H:i:s', $data['claimed_at']); //认领时间 } + if (isset($data['id'])){ + $finPaymentStock = FinPaymentStock::where('payment_apply_id', $data['id'])->get(); + $stock = []; + foreach ($finPaymentStock as $v) { + $stock[$v['pi_no']]['pi_no'] = $v['pi_no']; + $stock[$v['pi_no']]['stock_id'][] = [$v['stock_id']]; + } + $data['stock'] = array_values($stock); + } + return $data; } diff --git a/app/common/service/FinPaymentApplyService.php b/app/common/service/FinPaymentApplyService.php index e5091fd..ce2bbfd 100644 --- a/app/common/service/FinPaymentApplyService.php +++ b/app/common/service/FinPaymentApplyService.php @@ -58,6 +58,11 @@ class FinPaymentApplyService $config['where']['account_id'] = $p['account_id']; } + // 入账资料超时 + if (isset($p['scene']) && $p['scene'] == 'file_timeout') { + $config['where']['claimed_at'] = ['between', [1, time()-24*60*60]]; + } + // 关键字 if (isset($p['keyword']) && $p['keyword']) { $k = '%' . $p['keyword'] . '%'; @@ -156,7 +161,8 @@ class FinPaymentApplyService $param = $request->all(); $where = []; - + $orWhere = []; + // 汇款国家 if (isset($param['country_id']) && !empty($param['country_id'])) { $where[] = ['country_id', $param['country_id']]; @@ -166,6 +172,14 @@ class FinPaymentApplyService $where[] = ['account_id', $param['account_id']]; } + // 入账资料超时 + if (isset($param['scene']) && $param['scene'] == 'file_timeout') { + $where[] = ['claimed_at', '<', time()-24*60*60]; + $where[] = ['claimed_at', '>', 1]; + $orWhere[] = ['submit_files', '[]']; + $orWhere[] = ['submit_files', '']; + } + // 关键字 if (isset($param['keyword']) && $param['keyword']) { $k = '%' . $param['keyword'] . '%'; @@ -173,7 +187,9 @@ class FinPaymentApplyService } // 构建查询 - $query = $this->modelClass::where($where); + $query = $this->modelClass::where($where)->where(function($query) use ($orWhere) { + $query->orWhere($orWhere); + }); // 是否已关联收款记录的筛选 $correlation = $param['correlation']??''; diff --git a/app/common/service/FinReceiptService.php b/app/common/service/FinReceiptService.php index 1f1c731..d2ec7c7 100644 --- a/app/common/service/FinReceiptService.php +++ b/app/common/service/FinReceiptService.php @@ -4,6 +4,7 @@ namespace app\common\service; use app\common\logic\FinReceiptLogic; use app\common\model\FinPaymentApply; +use app\common\model\FinPaymentStock; use app\common\model\FinReceiptHis; use app\common\validate\FinReceiptValidate; use app\common\traits\crud\CrudServiceTrait; @@ -65,11 +66,11 @@ class FinReceiptService // 没有付款记录的收款记录 if (isset($p['payment_apply']) && $p['payment_apply'] == 'not') { //未认领 - $config['where']['payment_apply_id'] = ['null']; + $config['where']['payment_apply_id'] = 0; } elseif (isset($p['payment_apply']) && $p['payment_apply'] == 'already') { //已认领 - $config['where']['payment_apply_id'] = ['not null']; + $config['where']['payment_apply_id'] = ['>', 0]; } elseif (isset($p['payment_apply']) && $p['payment_apply'] == 'timeout') { //超时未认领 - $config['where']['payment_apply_id'] = ['not null']; + $config['where']['payment_apply_id'] = 0; $config['where']['created_at'] = ['<' ,time() - 24*60*60]; } @@ -213,9 +214,12 @@ class FinReceiptService // 没有付款记录的收款记录 if (isset($param['payment_apply']) && $param['payment_apply'] == 'not') { - $query->whereNull('payment_apply_id'); + $query->where('payment_apply_id', 0); } elseif (isset($param['payment_apply']) && $param['payment_apply'] == 'already') { - $query->whereNotNull('payment_apply_id'); + $query->where('payment_apply_id', '>', 0); + } elseif (isset($param['payment_apply']) && $param['payment_apply'] == 'timeout') { //超时未认领 + $query->where('payment_apply_id', 0); + $query->where('created_at', '<' ,time() - 24*60*60); } if (isset($param['scene']) && $param['scene'] == 'list') { @@ -292,6 +296,7 @@ class FinReceiptService $data = $this->preProcess(ucfirst($scene), $data, $request); $config = $this->buildQueryConfig($request, $scene); FinPaymentApply::where('id', $payment_apply_id)->update(['receipt_id' => $id, 'claimed_at' => time(), 'claimed_by' => $request->user->uid]); + FinPaymentStock::where('payment_apply_id', $payment_apply_id)->update(['receipt_id' => $id]); //折让金额 $payment = FinPaymentApply::where('id', $payment_apply_id)->first(); @@ -301,19 +306,4 @@ class FinReceiptService $updated = $this->logicUpdateBy($config, $data); return $this->postProcess(ucfirst($scene), $data); } - - /** - * 收款记录统计 - * @return bool|int - */ - public function statistics() - { - $finReceipt = FinReceipt::find($id); - if(!empty($finReceipt->received_at)){ - throw new BusinessException('该记录已将确认入账'); - } - $res = $this->logic->credit($id); - $this->afterServiceUpdate(['id'=>$id]); - return $res; - } } \ No newline at end of file diff --git a/app/process/Task.php b/app/process/Task.php index 8f9cea1..aab805d 100644 --- a/app/process/Task.php +++ b/app/process/Task.php @@ -62,7 +62,9 @@ class Task ['created_at', '>', time() - 60 * 60 * 48], ['created_at', '<', time() - 60 * 60 * 24], ]; - $payment = FinPaymentApply::where($where)->orWhere($orWhere)->orderBy('id', 'desc')->get(); + $payment = FinPaymentApply::where($where)->where(function($query) use ($orWhere) { + $query->orWhere($orWhere); + })->orderBy('id', 'desc')->get(); foreach ($payment as $item) { Log::info('fin_payment_apply submit_files ', [$item->toArray()]); $notice = [