Commit 315d365d authored by hujun's avatar hujun

撤销

parent ae296507
......@@ -312,4 +312,29 @@ class PayLogService
}
}
/**
* 计算收款-退款
*
* @param $bargain_id
* @return bool|float|int
*/
public function getPayLogRefundSurplusMoney($bargain_id) {
if (empty($bargain_id)) {
return false;
}
$pay_id = $this->payLogModel->getFieldValue('id', ['bargain_id'=>$bargain_id]);
if (empty($pay_id)) {
return false;
}
$money = $this->payLogModel->getSum('money', ['id'=>$pay_id]);
if ($money > 0) {
$refund_money = $this->oRefundModel->getRefundSum('refund_money', ['pay_log_id'=>$pay_id]);
$result = $money - $refund_money;
} else {
$result = 0;
}
return $result;
}
}
\ No newline at end of file
......@@ -2282,10 +2282,10 @@ class Finance extends Basic
return $this->response(101, '参数错误');
}
$m_pay = new OPayLogModel();
$num = $m_pay->getCount(['bargain_id'=>$this->params['bargain_id'],'is_del'=>0]);
if ($num > 0 ) {
return $this->response(101, '存在收款,不能删除!');
$service_pay = new PayLogService();
$money = $service_pay->getPayLogRefundSurplusMoney($this->params['bargain_id']);
if ($money > 0 ) {
return $this->response(101, '存在收款或退款,不能撤销!');
}
$check = $this->updatePerformanceAll($this->params['bargain_id']);
......
......@@ -490,6 +490,10 @@ class OPayLogModel extends Model
* @return float|int
*/
public function getSum($filed,$params){
if (!isset($params['is_del'])) {
$params['is_del'] = 0;
}
return $this->db_
->where($params)
->sum($filed);
......@@ -561,4 +565,11 @@ class OPayLogModel extends Model
public function getCount($where) {
return $this->db_->where($where)->count('id');
}
public function getFieldValue($field, $where) {
if (!isset($params['is_del'])) {
$params['is_del'] = 0;
}
return $this->db_->where($where)->value($field);
}
}
\ No newline at end of file
......@@ -253,6 +253,9 @@ class ORefundModel extends Model{
public function getRefundSum($field, $params)
{
if (!isset($params['is_del'])) {
$params['is_del'] = 0;
}
$data = $this->db_
->where($params)
->sum($field);
......
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