Commit dffc788e authored by hujun's avatar hujun

退款审核

parent e51ea860
......@@ -26,6 +26,7 @@ use app\model\OMarchInModel;
use app\model\OPayLogAdjustment;
use app\model\OrderModel;
use app\model\ORealIncome;
use app\model\ORefundLogModel;
use app\model\OReportModel;
use app\model\OTaxes;
use app\model\OFinancialAudit;
......@@ -3555,4 +3556,68 @@ class Finance extends Basic
}
return $this->response("101", "request faild");
}
/**
* 退款审核
*
* @return \think\Response
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function checkRefund() {
$code = 101;
$msg = '';
if (empty($this->params['refund_id']) || empty($this->params['status'])) {
return $this->response($code, '参数错误');
}
$m_refund = new ORefundModel();
$refund_where['id'] = $this->params['refund_id'];
$refund_where['status'] = ['in', '0,1,4']; // 0申请 1审核中 2退款成功 3已审核4驳回
$refund_where['is_del'] = 0;
$refund_data = $m_refund->selectRefundByOrderNo('id,status', $refund_where);
if (empty($refund_data[0]['id'])) {
return $this->response($code, '没有该退款详情');
}
if (($refund_data[0]['status'] == 4) && ($this->params['status'] == 4)) {
return $this->response($code, '该退款已驳回');
}
$m_refund_log = new ORefundLogModel();
$save_data['refund_id'] = $this->params['refund_id'];
$save_data['remark'] = trim($this->params['remark']);
$save_data['operation_id'] = $this->userId;
$save_data['operation_name'] = $this->userName;
if ($this->params['status'] == 1) {
$log_where['refund_id'] = $this->params['refund_id'];
$log_where['status'] = 1;
$log_where['is_del'] = 0;
$check_num = $m_refund_log->getTotal($log_where);
if ($check_num < 3) {
$save_data['status'] = 1; //审核中
} else {
$save_data['status'] = 3; //已审核
}
$num = $m_refund_log->insertData($save_data);
} else {
$m_refund_log->updateData(['is_del'=>1], ['refund_id'=>$this->params['refund_id'], 'status'=>1]);
$save_data['status'] = 4; //驳回
$num = $m_refund_log->insertData($save_data);
}
if ($num) {
if ($refund_data[0]['status'] != $save_data['status']) {
$m_refund->updateData(['id'=>$this->params['refund_id'],'status'=> $save_data['status']]);
}
$code = 200;
} else {
$msg = '审核失败';
}
return $this->response($code, $msg);
}
}
<?php
/**
* Created by PhpStorm.
* User: 43897
* Date: 2018/12/25
* Time: 13:54
*/
namespace app\model;
use think\Db;
class ORefundLogModel extends BaseModel
{
protected $table = "o_refund_log";
private $db_;
public function __construct($data = [])
{
parent::__construct($data);
$this->db_=Db::name($this->table);
}
public function insertData($data) {
return $this->db_->insert($data);
}
public function updateData($data, $where) {
return $this->db_->where($where)->update($data);
}
}
\ No newline at end of file
......@@ -102,6 +102,15 @@ class ORefundModel extends Model{
if (isset($params["agent_id"])) {
$where_["agent_id"] = $params["agent_id"];
}
if (isset($params["id"])) {
$where_["id"] = $params["id"];
}
if (isset($params["is_del"])) {
$where_["is_del"] = $params["is_del"];
}
if (isset($params["status"])) {
$where_["status"] = $params["status"];
}
return $this->db_
->field($filed)
......@@ -230,6 +239,10 @@ class ORefundModel extends Model{
->count();
}
/**
* @param $params
* @return float|int
*/
public function getSumMoney($params) {
return $this->db_->alias('a')
->join('o_order b', 'a.order_id = b.id', 'left')
......@@ -238,4 +251,13 @@ class ORefundModel extends Model{
->where($params)
->sum('a.refund_money');
}
/**
* @param $data
* @param $where
* @return ORefundModel
*/
public function updateData($data, $where) {
return $this->where($where)->update($data);
}
}
\ No newline at end of file
......@@ -280,6 +280,7 @@ Route::group('index', [
'getPayLogTotalPrice' => ['index/Finance/getPayLogTotalPrice', ['method' => 'get']],//佣金统计
'delPayLog' => ['index/Finance/delPayLog', ['method' => 'POST']],//删除收款
'refundPayLog' => ['index/Finance/refundPayLog', ['method' => 'POST']],//退款
'checkRefund' => ['index/Finance/checkRefund', ['method' => 'POST']],//退款审核
'performanceInfo' => ['index/PerformanceInfo/performanceInfo', ['method' => 'post|get']],//业绩明细
'getPerformanceInfoExcel' => ['index/PerformanceInfo/getPerformanceInfoExcel', ['method' => 'post|get']],//业绩明细
......
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