Commit 06569a88 authored by hujun's avatar hujun

新成交报告审核

parent 8b1fb6d0
...@@ -68,7 +68,6 @@ class Finance extends Basic ...@@ -68,7 +68,6 @@ class Finance extends Basic
* @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException * @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException * @throws \think\exception\DbException
* @throws \think\exception\PDOException
*/ */
public function checkReport() { public function checkReport() {
$data['code'] = 200; $data['code'] = 200;
...@@ -76,11 +75,16 @@ class Finance extends Basic ...@@ -76,11 +75,16 @@ class Finance extends Basic
$data['data'] = []; $data['data'] = [];
$bargain = new OBargainModel(); $bargain = new OBargainModel();
if (empty($this->params['id']) || empty($this->params['check_status'])) { if (empty($this->params['id'])) {
$data['code'] = 101; $data['code'] = 101;
$data['msg'] = 'Id or check_status is null'; $data['msg'] = 'Id or check_status is null';
} else { } else {
$status = $bargain->addCheckBargain($this->params['id'], $this->params['check_status']); $params['audit_id'] = $this->userId;
$params['audit_name'] = $this->userName;
$params['audit_id'] = $this->userId;
$params['audit_level'] = $this->params['check_status'];
$params['remark'] = $this->params['remark'];
$status = $bargain->addCheckBargain($this->params['id'], $params);
if (empty($status)) { if (empty($status)) {
$data['code'] = 101; $data['code'] = 101;
$data['msg'] = '审核失败'; $data['msg'] = '审核失败';
......
...@@ -209,14 +209,13 @@ class OBargainModel extends Model ...@@ -209,14 +209,13 @@ class OBargainModel extends Model
* 成交报告审核 * 成交报告审核
* *
* @param $id * @param $id
* @param $check_status * @param $data
* @return bool * @return bool|false|int
* @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException * @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException * @throws \think\exception\DbException
* @throws \think\exception\PDOException
*/ */
public function addCheckBargain($id, $check_status) { public function addCheckBargain($id, $data) {
$bargain_data = $this->field('id,report_id,agent_id,order_no,order_id')->where([ $bargain_data = $this->field('id,report_id,agent_id,order_no,order_id')->where([
'id' => $id, 'id' => $id,
...@@ -224,30 +223,36 @@ class OBargainModel extends Model ...@@ -224,30 +223,36 @@ class OBargainModel extends Model
])->lock(true)->find(); ])->lock(true)->find();
if ($bargain_data != '') { if ($bargain_data != '') {
$bargain_data['check_status'] = $check_status; $audit = new OFinancialAudit();
$this->save(['check_status'=>$check_status], ['id'=>$bargain_data['id']]); $audit_data = $audit->getLastStep($bargain_data['id']);
$check_data = []; $save_data['bargain_id'] = $bargain_data['id'];
switch ($check_status) { $save_data['agent_id'] = $bargain_data['agent_id'];
case 20 : $save_data['order_no'] = $bargain_data['order_no'];
$check_data['rule'] = '经理';break; $save_data['order_id'] = $bargain_data['order_id'];
case 30 : $save_data['source'] = 1;
$check_data['rule'] = '总监';break; $save_data['status'] = 1;
case 40 : $save_data['remark'] = $data['remark'];
$check_data['rule'] = '出纳';break; $save_data['audit_id'] = $data['audit_id'];
default : $save_data['audit_name'] = $data['audit_name'];
$check_data['rule'] = '专员'; $return = 0;
}
$check_data['bargain_id'] = $bargain_data['id']; //是否有审核记录,只做一次审核。
$check_data['order_no'] = $bargain_data['order_no']; if (isset($audit_data['id'])) {
$check_data['agent_id'] = $bargain_data['agent_id']; //第二、三、四审核
$check_data['order_id'] = $bargain_data['order_id']; if ($audit_data['audit_level'] == ($data['audit_level']-1)) {
$check_data['report_id'] = $bargain_data['report_id']; $save_data['audit_level'] = $data['audit_level'];
$return = $audit->addAudit($save_data);
}
} else {
//第一步审核
if ($data['audit_level'] === "0") {
$save_data['audit_level'] = 0;
$return = $audit->addAudit($save_data);
}
}
Db::table('o_check_bargain')->insert($check_data); if ($return) {
$check_bargain_id = Db::table('o_check_bargain')->getLastInsID();
if ($check_bargain_id) {
$this->commit(); $this->commit();
$result = true; $result = true;
} else { } else {
......
<?php
/**
* Created by PhpStorm.
* User: hujun
* Date: 2018/3/22
* Time: 15:25
*/
namespace app\model;
class OFinancialAudit extends BaseModel
{
/**
* 添加审核通过记录
*
* @param $data
* @return false|int
*/
public function addAudit($data) {
$save_data['bargain_id'] = $data['bargain_id'];
$save_data['agent_id'] = $data['agent_id'];
$save_data['order_no'] = $data['order_no'];
$save_data['order_id'] = $data['order_id'];
$save_data['source'] = $data['source'];
$save_data['status'] = $data['status'];
$save_data['remark'] = $data['remark'];
$save_data['audit_level'] = $data['audit_level'];
$save_data['audit_id'] = $data['audit_id'];
$save_data['audit_name'] = $data['audit_name'];
return $this->save($save_data);
}
/**
* 获取最新审核
*
* @param $bargain_id
* @return array|false|\PDOStatement|string|\think\Model
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getLastStep($bargain_id) {
return $this->field('id,audit_level')->where([
'bargain_id' => $bargain_id,
'status' => 1
])->order('id desc')->find();
}
}
\ No newline at end of file
...@@ -184,7 +184,10 @@ Route::group('index', [ ...@@ -184,7 +184,10 @@ Route::group('index', [
'reportListUndone/:status' => ['index/Finance/reportList', [ 'method' => 'get' ] ,['status'=>21]], //财务 成交报告-已撤销 'reportListUndone/:status' => ['index/Finance/reportList', [ 'method' => 'get' ] ,['status'=>21]], //财务 成交报告-已撤销
'refundList' => ['index/Finance/refundList', [ 'method' => 'get|post' ] ], //财务 退款 'refundList' => ['index/Finance/refundList', [ 'method' => 'get|post' ] ], //财务 退款
'accountList' => ['index/Finance/accountList', [ 'method' => 'get|post' ] ], //财务 账户列表 'accountList' => ['index/Finance/accountList', [ 'method' => 'get|post' ] ], //财务 账户列表
'checkReport' => ['index/Finance/checkReport', [ 'method' => 'post' ] ], //审核成交报告 'checkReportAttache/:check_status' => ['index/Finance/checkReport', [ 'method' => 'post' ], ['check_status'=>0]], //审核成交报告-专员审核
'checkReportManager/:check_status' => ['index/Finance/checkReport', [ 'method' => 'post' ], ['check_status'=>1]], //审核成交报告-经理审核
'checkReportMajordomo/:check_status' => ['index/Finance/checkReport', [ 'method' => 'post' ], ['check_status'=>2]], //审核成交报告-总监审核
'checkReportCashier/:check_status' => ['index/Finance/checkReport', [ 'method' => 'post' ], ['check_status'=>3]], //审核成交报告-出纳审核
'bargainInfo' => ['index/Finance/bargainInfo', [ 'method' => 'get' ] ], //获取成交报告详情 'bargainInfo' => ['index/Finance/bargainInfo', [ 'method' => 'get' ] ], //获取成交报告详情
'editBargainInfo' => ['index/Finance/editBargainInfo', [ 'method' => 'post' ] ], //修改成交报告佣金 'editBargainInfo' => ['index/Finance/editBargainInfo', [ 'method' => 'post' ] ], //修改成交报告佣金
'addBargain' => ['index/Finance/addBargain', [ 'method' => 'post' ] ], //新增成交报告佣金(分佣提成) 'addBargain' => ['index/Finance/addBargain', [ 'method' => 'post' ] ], //新增成交报告佣金(分佣提成)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment