Commit da1f08c1 authored by zw's avatar zw

退款申请

parent 9c61b943
......@@ -122,13 +122,38 @@ class PayLog extends Basic
$remark = isset($params["remark"]) ? $params["remark"] : "";
$remark_img = isset($params["remark_img"]) ? json_decode($params["remark_img"], true) : "";
//todo 判断此单是否有付款
$is_ok = $this->service_->addRefund($agent_id,$agent_name,$report_id,$order_id,$order_no,$refund_money,$name,
$phone, $bank,$card_no,$receipt_number,$type,$refund_cause,$pay_log_id,$refund_way,$remark,$remark_img);
$is_ok = $this->service_->addRefund($agent_id, $agent_name, $report_id, $order_id, $order_no, $refund_money, $name,
$phone, $bank, $card_no, $receipt_number, $type, $refund_cause, $pay_log_id, $refund_way, $remark, $remark_img);
if ($is_ok > 0) {
return $this->response("200", "request success", []);
}elseif($is_ok == -2){
} elseif ($is_ok == -2) {
return $this->response("101", "退款金不能大于剩余的支付金额");
}
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 getRefund(){
$params = $this->params;
/* $params = array(
"refund_id" =>1
);*/
if(!isset($params["refund_id"])){
return $this->response("101","请求参数错误");
}
$result = $this->service_->getRefundDetail($params["refund_id"]);
if($result["code"] == 200){
return $this->response("200","success",$result["data"]);
}elseif($result["code"] == 101){
return $this->response("101",$result["msg"]);
}
}
}
\ No newline at end of file
......@@ -18,11 +18,13 @@ class PayLogService
{
private $payLogModel;
private $payLogAdjustmentModel;
private $oRefundModel;
public function __construct()
{
$this->payLogModel = new OPayLogModel();
$this->payLogAdjustmentModel = new OPayLogAdjustment();
$this->oRefundModel = new ORefundModel();
}
public function getBeForNum($order_id)
......@@ -50,8 +52,12 @@ class PayLogService
$where_["is_del"] = 0;
//调整
$adjustment_sum = $this->payLogAdjustmentModel->getAdjustmentSum("money", $where_);
//减去退款
$refund_params["pay_log_id"] = $pay_id;
$refund_params["status"] = array("neq", 4);
$refund_sum = $this->oRefundModel->getRefundSum("refund_money", $refund_params);
$residue_money = $pay_log_arr["money"] - $adjustment_sum;
$residue_money = $pay_log_arr["money"] - $adjustment_sum - $refund_sum;
return $residue_money;
}
......@@ -163,8 +169,7 @@ class PayLogService
return -2;
}
$oRefundModel = new ORefundModel();
$insert_id = $oRefundModel->addRefund($this->refundBin($agent_id, $agent_name, $report_id, $order_id, $order_no, $refund_money, $name,
$insert_id = $this->oRefundModel->addRefund($this->refundBin($agent_id, $agent_name, $report_id, $order_id, $order_no, $refund_money, $name,
$phone, $bank, $card_no, $receipt_number, $type, $refund_cause, $pay_log_id,
$refund_way, $remark)
);
......@@ -221,4 +226,26 @@ class PayLogService
}
/**
* @param $refund_id
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getRefundDetail($refund_id)
{
$field = "id,report_id,agent_id,agent_name,order_no,order_id,refund_money,status,name,phone,bank,card_no,
remark,receipt_number,type,refund_cause,pay_log_id,refund_way";
$params["id"] = $refund_id;
$params["is_del"] = 0;
$result = $this->oRefundModel->selectRefundByOrderNo($field, $params);
if (count($result) > 0) {
return ["code" => 200, "data" => $result[0]];
} else {
return ["code" => 101, "msg" => "没有找到此条退款数据"];
}
}
}
\ No newline at end of file
......@@ -212,12 +212,11 @@ class ORefundModel extends Model{
* @throws \think\exception\DbException
*/
public function getCheckRefundList($pageNo = 1, $pageSize = 15, $order_ = 'id desc', $field = '', $params = '') {
return $this->db_->alias('a')
return Db::table($this->table)
->alias('a')
->field($field)
->join('o_order b', 'a.order_id = b.id', 'left')
->join('a_agents c', 'a.agent_id = c.id', 'left')
->join('o_paylog d', 'a.pay_log_id = d.id', 'left')
->where($params)
->join('o_report b', 'a.report_id = b.id', 'left')
->join('o_financial_audit c', 'a.order_id=c.order_id', 'left')
->limit($pageSize)
->page($pageNo)
->order($order_)
......@@ -231,33 +230,10 @@ class ORefundModel extends Model{
* @return int|string
*/
public function getCheckRefundListTotal($params) {
return $this->db_->alias('a')
->join('o_order b', 'a.order_id = b.id', 'left')
->join('a_agents c', 'a.agent_id = c.id', 'left')
->join('o_paylog d', 'a.pay_log_id = d.id', 'left')
->where($params)
return Db::table($this->table)
->alias('a')
->join('o_report b', 'a.report_id = b.id', 'left')
->join('o_financial_audit c', 'a.order_id=c.order_id', 'left')
->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')
->join('a_agents c', 'a.agent_id = c.id', 'left')
->join('o_paylog d', 'a.pay_log_id = d.id', 'left')
->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
......@@ -563,6 +563,7 @@ Route::group('broker', [
'collectingBill' => ['api_broker/OrderLog/collectingBill', ['method' => 'get|post']],
'collectingBillV2' => ['api_broker/OrderLog/collectingBillV2', ['method' => 'get|post']],
'refund' => ['api_broker/PayLog/refund', ['method' => 'get|post']],
'getRefund' => ['api_broker/PayLog/getRefund', ['method' => 'get|post']],
'bargain' => ['api_broker/OrderLog/bargain', ['method' => 'get|post']],
'statusBargain' => ['api_broker/OrderLog/statusBargain', ['method' => 'get|post']],
'getIsAccountStatement' => ['api_broker/OrderLog/getIsAccountStatement', ['method' => 'get|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