Commit 5eda0a72 authored by zhuwei's avatar zhuwei

更新数据

parent e47e52c8
...@@ -315,6 +315,8 @@ class AmercementService ...@@ -315,6 +315,8 @@ class AmercementService
*/ */
public function editAmercement($id, $params, $edit_type, $operation_id) public function editAmercement($id, $params, $edit_type, $operation_id)
{ {
$code = 200;
$msg = '成功';
switch ($edit_type) { switch ($edit_type) {
case 0 : case 0 :
//0编辑 //0编辑
...@@ -343,13 +345,17 @@ class AmercementService ...@@ -343,13 +345,17 @@ class AmercementService
break; break;
case 1 : case 1 :
//1取消 //1取消
$this->cancelAmercement($id); $res = $this->cancelAmercement($id);
$code = $res['code'];
$msg = $res['msg'];
break; break;
default : default :
//2转已支付 //2转已支付
$this->consummationAmercement($id, $operation_id); $res = $this->consummationAmercement($id, $operation_id);
$code = $res['code'];
$msg = $res['msg'];
} }
return ['code' => 200, 'msg' => '成功']; return ['code' => $code, 'msg' => $msg];
} }
/** /**
...@@ -388,15 +394,21 @@ class AmercementService ...@@ -388,15 +394,21 @@ class AmercementService
/** /**
* 更新数据 取消 * 更新数据 取消
* @param $id * @param $id
* @return bool * @return array
*/ */
public function cancelAmercement($id) public function cancelAmercement($id)
{ {
//判断是否有支付过
$payInfo = $this->isPay($id,-1);
if ($payInfo) {//有支付订单号 不允许取消
return [ 'code' => 101, 'msg' => '失败!该罚款有支付订单' ];
} else {//无支付订单号 允许取消
$data = []; $data = [];
$data['id'] = $id; $data['id'] = $id;
$data['status'] = 2; $data['status'] = 2;
$this->m_amercement->updateAmercementData($data); $this->m_amercement->updateAmercementData($data);
return true; return [ 'code' => 200, 'msg' => '已取消' ];
}
} }
...@@ -404,19 +416,45 @@ class AmercementService ...@@ -404,19 +416,45 @@ class AmercementService
* 更新数据 转已支付 * 更新数据 转已支付
* @param $id * @param $id
* @param $operation_id * @param $operation_id
* @return bool * @return array
*/ */
public function consummationAmercement($id, $operation_id) public function consummationAmercement($id, $operation_id)
{ {
//判断是否有支付过
$payInfo = $this->isPay($id);
if ($payInfo) {//已支付
$data = []; $data = [];
$data['id'] = $id; $data['id'] = $id;
$data['status'] = 1; $data['status'] = 1;
$data['operation_id'] = $operation_id; $data['operation_id'] = $operation_id;
$data['operation_time'] = date("Y-m-d H:i:s", time()); $data['operation_time'] = date("Y-m-d H:i:s", time());
$this->m_amercement->updateAmercementData($data); $this->m_amercement->updateAmercementData($data);
return true; return [ 'code' => 200, 'msg' => '已转为已支付' ];
} else {//未支付
return [ 'code' => 101, 'msg' => '失败!暂未支付' ];
}
} }
/**
* 支付状态查询 默认判断是否有支付过
* @param $amercement_id
* @param int $status
* @return array|false|\PDOStatement|string|\think\Model
*/
public function isPay($amercement_id, $status = 1)
{
$amercementPayModel = new OAmercementPayModel();
$where["amercement_id"] = $amercement_id;
$where["status"] = $status;
if($status == -1){
$where["status"] = array( 'neq', 2);//排除支付失败的
}
$payInfo = $amercementPayModel->getAmercementPayInfo($where, "id,status,trade_no");
return $payInfo;
}
/** /**
* 后台罚款账单表 * 后台罚款账单表
* @param $params * @param $params
......
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