Files
spacestation/api/controllers/wxapp/licheb/Loan.php
T
2024-06-04 21:11:42 +08:00

62 lines
1.9 KiB
PHP

<?php
defined('WXAPP_APP') or exit('No direct script access allowed');
/**
* Created by Vim
* User: lcc
* Date: 2021/07/13
* Time: 14:08
*/
require_once APPPATH . 'controllers/wxapp/Wxapp.php';
class Loan extends Wxapp
{
public function __construct($inputs, $app_key)
{
parent::__construct($inputs, $app_key);
$this->login_white = array();//登录白名单
$this->check_status = array();//用户状态校验
$this->check_mobile = array();//需要手机号
$this->check_headimg = array();//授权微信信息
$this->load->model('receiver/order/receiver_orders_model', 'orders_model');
}
protected function get()
{
}
protected function post()
{
}
protected function put()
{
$oid = $this->input_param('o_id');
//贷款相关参数
$downpayment_type = $this->input_param('downpayment_type');
$loan_amount = $this->input_param('loan_amount');
$loan_periods = $this->input_param('loan_periods');
$monthly_payment = $this->input_param('monthly_payment');
$row = $this->orders_model->get(['id' => $oid]);
if (!$row) throw new Exception('参数错误', ERR_PARAMS_ERROR);
$money_json = json_decode($row['money_json'], true);
$data['downpayment_type'] = $downpayment_type;
$money_json['loan_amount'] = $loan_amount ? $loan_amount : 0;
$money_json['loan_periods'] = $loan_periods ? $loan_periods : 0;
$money_json['monthly_payment'] = $monthly_payment ? $monthly_payment : 0;
$data['money_json'] = json_encode($money_json, JSON_UNESCAPED_UNICODE);
$result = $this->orders_model->update($data, ['id' => $row['id']]);
if ($result) {
throw new Exception('修改成功', API_CODE_SUCCESS);
} else {
throw new Exception('修改失败', ERR_PARAMS_ERROR);
}
}
}