You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

63 lines
1.9 KiB
PHP

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<?php
// +----------------------------------------------------------------------
// | OneThink [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.onethink.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: huajie <banhuajie@163.com>
// +----------------------------------------------------------------------
namespace Admin\Model;
use Think\Model;
/**
* 文档基础模型
*/
class UserCoinModel extends Model{
/* 自动验证规则 */
protected $_validate = array(
array('num', '/^[1-9](\d+)?$/', '请输入大于0的整数', self::MUST_VALIDATE, 'regex', self::MODEL_BOTH), array('num', [1,999999], '发放数量错误', self::MUST_VALIDATE, 'between', self::MODEL_BOTH),
);
/* 自动完成规则 */
protected $_auto = array(
array('create_time', 'time', self::MODEL_INSERT,'function'),
array('op_id',UID,self::MODEL_INSERT),
);
/**
* 构造函数
* @param string $name 模型名称
* @param string $tablePrefix 表前缀
* @param mixed $connection 数据库连接信息
*/
public function __construct($name = '', $tablePrefix = '', $connection = '') {
/* 设置默认的表前缀 */
$this->tablePrefix ='tab_';
/* 执行构造方法 */
parent::__construct($name, $tablePrefix, $connection);
}
/**
* 平台币记录
* @param $promote_id 渠道ID
* @param $sid 来源ID
* @param $num 数量
* @param $type 类型 1增加 2:减少
*/
public function record($user_id,$num){
$data['user_id'] = $user_id;
$data['user_account']=get_user_account($user_id);
$data['num'] = $num;
$data = $this->create($data);
if(!$data){
return false;
}
$res = $this->add($data);
return $res;
}
}