You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
80 lines
2.8 KiB
80 lines
2.8 KiB
<?php
|
|
// +----------------------------------------------------------------------
|
|
// | 天诚科技 [ 刘海东 17600099397赋能开发者,助力企业发展 ]
|
|
// +----------------------------------------------------------------------
|
|
// | Copyright (c) 2016~2020 https://www.tczxkj.com All rights reserved.
|
|
// +----------------------------------------------------------------------
|
|
// | Licensed 该系统并不是自由软件,未经许可不能去掉相关版权
|
|
// +----------------------------------------------------------------------
|
|
// | Author:甘肃天诚志信电子商务有限公司 刘海东 联系电话维系17600099397
|
|
// +----------------------------------------------------------------------
|
|
|
|
|
|
namespace app\web\model\user;
|
|
|
|
|
|
use app\web\model\special\Special;
|
|
use basic\ModelBasic;
|
|
use traits\ModelTrait;
|
|
|
|
/**
|
|
* Class UserBill
|
|
* @package app\web\model\user
|
|
*/
|
|
class UserBill extends ModelBasic
|
|
{
|
|
use ModelTrait;
|
|
|
|
protected $insert = ['add_time'];
|
|
|
|
protected function setAddTimeAttr()
|
|
{
|
|
return time();
|
|
}
|
|
|
|
public static function income($title, $uid, $category, $type, $number, $link_id = 0, $balance = 0, $mark = '', $status = 1, $get_uid = 0)
|
|
{
|
|
$pm = 1;
|
|
return self::set(compact('title', 'uid', 'link_id', 'category', 'type', 'number', 'balance', 'mark', 'status', 'pm', 'get_uid'));
|
|
}
|
|
|
|
public static function expend($title, $uid, $category, $type, $number, $link_id = 0, $balance = 0, $mark = '', $status = 1)
|
|
{
|
|
$pm = 0;
|
|
return self::set(compact('title', 'uid', 'link_id', 'category', 'type', 'number', 'balance', 'mark', 'status', 'pm'));
|
|
}
|
|
|
|
/**获取金币
|
|
* @param $uid
|
|
* @param string $type
|
|
* @param $pm
|
|
* @return float|int
|
|
*/
|
|
public static function getUserGoldCoins($uid, $type = 'recharge', $pm, $n)
|
|
{
|
|
$sum = UserBill::where(['uid' => $uid, 'category' => 'gold_num', 'type' => $type, 'pm' => $pm, 'status' => 1])
|
|
->where('number', '>', 0)->sum('number');
|
|
if ($n) {
|
|
$refund_sum = UserBill::where(['uid' => $uid, 'category' => 'gold_num', 'type' => 'return', 'pm' => 0, 'status' => 1])
|
|
->where('number', '>', 0)->sum('number');
|
|
} else {
|
|
$refund_sum = 0;
|
|
}
|
|
return bcsub($sum, $refund_sum, 2);
|
|
}
|
|
|
|
public static function getUserGoldConsumption($uid)
|
|
{
|
|
$sum = UserBill::where(['uid' => $uid, 'category' => 'gold_num', 'pm' => 0, 'status' => 1])
|
|
->where('number', '>', 0)->where('type','in','deduction,return,live_reward')->sum('number');
|
|
return $sum;
|
|
}
|
|
|
|
public static function getUserbalance($uid, $pm)
|
|
{
|
|
$sum = UserBill::where(['uid' => $uid, 'category' => 'now_money', 'pm' => $pm, 'status' => 1])
|
|
->where('number', '>', 0)->sum('number');
|
|
return bcsub($sum, 0, 2);
|
|
}
|
|
|
|
}
|
|
|