Commit f6791767 authored by clone's avatar clone

1

parent 8b9a027b
...@@ -145,50 +145,13 @@ class Amercement extends Basic ...@@ -145,50 +145,13 @@ class Amercement extends Basic
} }
$arr["oritranflow"] = $params["tranflow"]; $arr["oritranflow"] = $params["tranflow"];
$data = json_encode($arr); $result = $this->s_amercement->getPayStatusByNo($arr);
$curl = new \app\chat\utils\CurlUtil(); if ($result["code"] == 200) {
$curl->headers = [ return $this->response("200", "success", $result["msg"]);
"Accept" => "application/json",
"Content-Type" => "application/json;charset=utf-8",
];
$curl->options = [
"CURLOPT_SSL_VERIFYPEER" => 0,
"CURLOPT_SSL_VERIFYHOST" => 2,
];
$url = $this->buildSendUrl();
$response = $curl->post($url, $data);
$result = json_decode($response, true);
if ($result && $result["code"] == 0) {
$status = 0;
$is_success = $result["data"]["oritranstatus"];
if ($is_success == "01") {
$status = 1;
} elseif ($is_success == "02") {
$status = 3;
} else {
$status = 2;
}
$remark = $result["data"]["orirespmsg"];
$is_ok = $this->s_amercement->updatePayAmercement($params["tranflow"], $status, $remark);
if ($is_ok > 0) {
return $this->response("200", "success", ["status" => $status, "remark" => $remark]);
} else {
return $this->response("101", "查询异常请稍后再试");
}
} else { } else {
return $this->response("101", $result["msg"]); return $this->response("101", $result["msg"]);
} }
} }
/**
* 请求api
* @return string
*/
private function buildSendUrl()
{
return "http://120.55.43.9/api/pay/trans_result";
}
} }
\ No newline at end of file
...@@ -302,7 +302,7 @@ class AmercementService ...@@ -302,7 +302,7 @@ class AmercementService
} }
$result['img'] = $this->getAmercementImage($result['id']); $result['img'] = $this->getAmercementImage($result['id']);
$payInfo = $this->isPay($id); $payInfo = $this->isPay($id);
$result['trade_no'] = isset($payInfo['trade_no']) && !empty($payInfo['trade_no']) ? $payInfo['trade_no']:''; $result['trade_no'] = isset($payInfo['trade_no']) && !empty($payInfo['trade_no']) ? $payInfo['trade_no'] : '';
return $result; return $result;
} }
...@@ -401,15 +401,15 @@ class AmercementService ...@@ -401,15 +401,15 @@ class AmercementService
public function cancelAmercement($id) public function cancelAmercement($id)
{ {
//判断是否有支付过 //判断是否有支付过
$payInfo = $this->isPay($id,-1); $payInfo = $this->isPay($id, -1);
if ($payInfo) {//有支付订单号 不允许取消 if ($payInfo) {//有支付订单号 不允许取消
return [ 'code' => 101, 'msg' => '失败!该罚款有支付订单' ]; return ['code' => 101, 'msg' => '失败!该罚款有支付订单'];
} else {//无支付订单号 允许取消 } 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 [ 'code' => 200, 'msg' => '已取消' ]; return ['code' => 200, 'msg' => '已取消'];
} }
} }
...@@ -431,9 +431,9 @@ class AmercementService ...@@ -431,9 +431,9 @@ class AmercementService
$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 [ 'code' => 200, 'msg' => '已转为已支付' ]; return ['code' => 200, 'msg' => '已转为已支付'];
} else {//未支付 } else {//未支付
return [ 'code' => 101, 'msg' => '失败!暂未支付' ]; return ['code' => 101, 'msg' => '失败!暂未支付'];
} }
} }
...@@ -448,15 +448,14 @@ class AmercementService ...@@ -448,15 +448,14 @@ class AmercementService
$amercementPayModel = new OAmercementPayModel(); $amercementPayModel = new OAmercementPayModel();
$where["amercement_id"] = $amercement_id; $where["amercement_id"] = $amercement_id;
$where["status"] = $status; $where["status"] = $status;
if($status == -1){ if ($status == -1) {
$where["status"] = array( 'neq', 2);//排除支付失败的 $where["status"] = array('neq', 2);//排除支付失败的
} }
$payInfo = $amercementPayModel->getAmercementPayInfo($where, "id,status,trade_no"); $payInfo = $amercementPayModel->getAmercementPayInfo($where, "id,status,trade_no");
return $payInfo; return $payInfo;
} }
/** /**
* 后台罚款账单表 * 后台罚款账单表
* @param $params * @param $params
...@@ -697,17 +696,31 @@ class AmercementService ...@@ -697,17 +696,31 @@ class AmercementService
{ {
//todo 判断是否有支付过 //todo 判断是否有支付过
$amercementPayModel = new OAmercementPayModel(); $amercementPayModel = new OAmercementPayModel();
$where["amercement_id"] = $amercement_id; $where["amercement_id"] = $amercement_id;
$where["status"] = 1; $where["status"] = 1;
$payInfo1 = $amercementPayModel->getAmercementPayInfo($where, "id,status,trade_no"); $payInfo1 = $amercementPayModel->getAmercementPayInfo($where, "id,status,trade_no");
if ($payInfo1) { if (count($payInfo1) > 0) {
return ["code" => '101', "msg" => "订单已支付"]; return ["code" => '101', "msg" => "订单已支付"];
} }
$where["amercement_id"] = $amercement_id; $where_["amercement_id"] = $amercement_id;
$where["trade_no"] = $trade_no; $payInfo = $amercementPayModel->getAmercementPayList($where_, "id,status,trade_no");
$payInfo2 = $amercementPayModel->getAmercementPayInfo($where, "id,status,trade_no");
$is_exits = false;
foreach ($payInfo as $item) {
if ($item["trade_no"] == $trade_no) {
$is_exits = true;
}
$arr["oritranflow"] = $item["trade_no"];
$curlRes = $this->getPayStatusByNo($arr);
if ($curlRes["code"] == 200 && $curlRes["status"] == 1) {
return ["code" => '101', "msg" => "订单已支付"];
} else if ($curlRes["code"] == 200 && $curlRes["status"] > 1) {
return ["code" => '101', "msg" => "该笔支付已发起,请到支付宝>>我的>>账单进行支付。如已支付,则请等待几分钟该列表的状态才会刷新!"];
}
if ($payInfo2) { }
if ($is_exits) {
return ["code" => '101', "msg" => "订单等待支付中"]; return ["code" => '101', "msg" => "订单等待支付中"];
} else { } else {
$arr["amercement_id"] = $amercement_id; $arr["amercement_id"] = $amercement_id;
...@@ -723,10 +736,12 @@ class AmercementService ...@@ -723,10 +736,12 @@ class AmercementService
public function updatePayAmercement($trade_no, $status, $remark) public function updatePayAmercement($trade_no, $status, $remark)
{ {
$amercementPayModel = new OAmercementPayModel(); $amercementPayModel = new OAmercementPayModel();
big_log('status' . $status);
big_log('trade_no' . $trade_no);
//罚款记录改已支付 //罚款记录改已支付
if($status == 1){ if ($status == 1) {
$payInfo = $amercementPayModel->getAmercementPayInfo(['trade_no'=>$trade_no], "amercement_id"); $payInfo = $amercementPayModel->getAmercementPayInfo(['trade_no' => $trade_no], "amercement_id");
if(isset($payInfo['amercement_id']) && $payInfo['amercement_id'] > 0){ if (isset($payInfo['amercement_id']) && $payInfo['amercement_id'] > 0) {
$data = []; $data = [];
$data['id'] = $payInfo['amercement_id']; $data['id'] = $payInfo['amercement_id'];
$data['status'] = 1; $data['status'] = 1;
...@@ -740,5 +755,59 @@ class AmercementService ...@@ -740,5 +755,59 @@ class AmercementService
return $amercementPayModel->updateAmercementPayData($trade_no, $update); return $amercementPayModel->updateAmercementPayData($trade_no, $update);
} }
/**
* @param $arr
* @return array
*/
public function getPayStatusByNo($arr)
{
$data = json_encode($arr);
$curl = new \app\chat\utils\CurlUtil();
$curl->headers = [
"Accept" => "application/json",
"Content-Type" => "application/json;charset=utf-8",
];
$curl->options = [
"CURLOPT_SSL_VERIFYPEER" => 0,
"CURLOPT_SSL_VERIFYHOST" => 2,
];
$url = $this->buildSendUrl();
$response = $curl->post($url, $data);
$result = json_decode($response, true);
if ($result && $result["code"] == 0) {
$status = 0;
$is_success = $result["data"]["oritranstatus"];
if ($is_success == "01") {
$status = 1;
} elseif ($is_success == "02") {
$status = 3;
} else {
$status = 2;
}
$remark = $result["data"]["orirespmsg"];
$is_ok = $this->updatePayAmercement($arr["tranflow"], $status, $remark);
if ($is_ok > 0) {
$res["status"] = $status;
$res["remark"] = $remark;
return ["code" => "200", "msg" => $res];
} else {
return ["code" => "101", "msg" => "查询异常请稍后再试"];
}
} else {
return ["code" => "101", "msg" => $result["msg"]];
}
}
/**
* 请求api
* @return string
*/
private function buildSendUrl()
{
return "http://120.55.43.9/api/pay/trans_result";
}
} }
\ No newline at end of file
...@@ -41,6 +41,15 @@ class OAmercementPayModel extends Model ...@@ -41,6 +41,15 @@ class OAmercementPayModel extends Model
return $result; return $result;
} }
public function getAmercementPayList($params, $field)
{
$result = $this->db_
->field($field)
->where($params)
->select();
return $result;
}
/**更新数据 /**更新数据
* @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