增加佣金来源筛选

This commit is contained in:
monanxiao 2023-03-14 15:35:40 +08:00
parent 3b1fb1cda5
commit 9217459610
2 changed files with 45 additions and 6 deletions

View File

@ -112,7 +112,11 @@ class UserBillDao extends BaseDao
public function lockBrokerage($uid)
{
$lst = UserBill::getDB()->where('category', 'brokerage')
->whereIn('type', ['order_one', 'order_two'])->where('uid', $uid)->where('status', 0)->field('link_id,number')->select()->toArray();
->whereIn('type', ['order_one', 'order_two'])
->where('uid', $uid)
->where('status', 0)
->field('link_id,number')
->select()->toArray();
$refundPrice = 0;
if (count($lst)) {
$refundPrice = -1 * UserBill::getDB()->whereIn('link_id', array_column($lst, 'link_id'))->where('uid', $uid)

View File

@ -34,6 +34,7 @@ use think\db\exception\DbException;
use think\db\exception\ModelNotFoundException;
use think\exception\ValidateException;
use think\facade\Db;
use app\common\model\user\UserBill;
class User extends BaseController
{
@ -90,17 +91,17 @@ class User extends BaseController
if($source == 1)
{
$data = [
'total_brokerage_price' => $user->total_brokerage_price, // 可提现金额
'total_extract' => $user->lock_brokerage, // 已提现金额
'yesterday_brokerage' => $user->yesterday_brokerage, // 昨日提现收益
'lock_brokerage' => $user->lock_brokerage, // 冻结中金额
// 'total_brokerage_price' => $this->totalBrokerage($user->uid, $source), // 可提现金额
'total_brokerage_price' => $user->total_brokerage, // 可提现金额
'total_extract' => $this->lockBrokerage($user->uid, $source), // 已提现金额
'yesterday_brokerage' => $this->yesterdayBrokerage($user->uid, $source), // 昨日提现收益
'lock_brokerage' => $this->lockBrokerage($user->uid, $source), // 冻结中金额
'spread_total' => $user->spread_total,
'total_brokerage' => $user->total_brokerage,
'brokerage_price' => $user->brokerage_price,
'show_brokerage' => $show_brokerage,
'broken_day' => (int)systemConfig('lock_brokerage_timer'),
'user_extract_min' => (int)systemConfig('user_extract_min'),
];
return app('json')->success($data);
@ -125,6 +126,40 @@ class User extends BaseController
return app('json')->success($data);
}
public function lockBrokerage($uid, $source)
{
$lst = UserBill::getDB()->where('category', 'brokerage')
->whereIn('type', ['order_one', 'order_two'])
->where('uid', $uid)
->where('source', $source)
->where('status', 0)
->field('link_id,number')
->select()->toArray();
$refundPrice = 0;
if (count($lst)) {
$refundPrice = -1 * UserBill::getDB()->whereIn('link_id', array_column($lst, 'link_id'))->where('uid', $uid)
->where('category', 'brokerage')->whereIn('type', ['refund_two', 'refund_one'])->sum('number');
}
foreach ($lst as $bill) {
$refundPrice = bcadd($refundPrice, $bill['number'], 2);
}
return $refundPrice;
}
public function yesterdayBrokerage($uid, $source)
{
return getModelTime(UserBill::getDB()->where('category', 'brokerage')
->whereIn('type', ['order_one', 'order_two'])->where('source', $source)->where('uid', $uid), 'yesterday')->sum('number');
}
public function totalBrokerage($uid, $source)
{
return bcsub(UserBill::getDB()->where('category', 'brokerage')
->whereIn('type', ['order_one', 'order_two'])->where('source', $source)->where('uid', $uid)->sum('number'),
UserBill::getDB()->where('uid', $uid)
->where('category', 'brokerage')->whereIn('type', ['refund_two', 'refund_one'])->sum('number'), 2);
}
public function brokerage_all()
{
return app('json')->success(app()->make(UserBrokerageRepository::class)->all(0));