<?php
namespace Home\Model;

use Think\Model;

header("Content-Type:text/html;CharSet=UTF-8");
class AppliesModel extends Model
{
    /**
     * 企业付款成功
     * @param  int    $id         提现申请ID
     * @param  string $payment_no 提现申请ID
     * @return mix
     */
    public function paySuccess($id, $payment_no)
    {
        if (!$id) {
            die("无法获取提现订单");
        } else {
            $status = $this->where("`id`=$id")->getField("status");
            if ($status == 2) {
                return false;
            } else {
                // 申请记录状态修改
                $data = array();
                $data['payment_no'] = $payment_no;
                $data['status'] = 2;
                $data['dealtime'] = time();
                $result = $this->where("`id`=$id")->save($data);
                // 扣除用户相应的可提佣金并生成提现记录
                return $result;
            }
        }
    }
}