<?php
namespace Smi\Model;

use Think\Model;

header("Content-type:text/html;charset=utf-8");
class UsersModel extends Model
{
    /**
     * 提现可用佣金
     * @param  string $openid 用户标识
     * @param  float  $money  佣金
     * @return boolean
     */
    public function takeFund($openid, $money, $partner_trade_no, $payment_no = "")
    {
        if ($openid) {
            if ($money || $money == 0) {
                $this->where("`openid`='$openid'")->lock()->setDec("fund_enable", $money);
                $this->where("`openid`='$openid'")->lock()->setInc("fund_got", $money);
                M("fundApply")->where("`partner_trade_no`='{$partner_trade_no}'")->setField("payment_no", $payment_no);
                return true;
            } else {
                return false;
            }
        } else {
            return false;
        }
    }
}