diff --git a/app/data/controller/UserRebate.php b/app/data/controller/UserRebate.php index 785d9b0a9..99edfc341 100644 --- a/app/data/controller/UserRebate.php +++ b/app/data/controller/UserRebate.php @@ -29,12 +29,16 @@ class UserRebate extends Controller */ public function index() { + $this->title = '用户返利记录'; + // 统计所有返利 + $this->rebate = UserUpgradeService::instance()->syncRebate(0); + // 创建查询对象 $query = $this->_query($this->table)->equal('type')->like('name,order_no'); - // 会员查询 + // 会员条件查询 $db = $this->_query('DataUser')->like('nickname#order_nickname,phone#order_phone')->db(); if ($db->getOptions('where')) $query->whereRaw("order_uid in {$db->field('id')->buildSql()}"); - // 代理查询 + // 代理条件查询 $db = $this->_query('DataUser')->like('nickname#agent_nickname,phone#agent_phone')->db(); if ($db->getOptions('where')) $query->whereRaw("uid in {$db->field('id')->buildSql()}"); // 查询分页 diff --git a/app/data/service/UserUpgradeService.php b/app/data/service/UserUpgradeService.php index b5ffe7d35..15906e826 100644 --- a/app/data/service/UserUpgradeService.php +++ b/app/data/service/UserUpgradeService.php @@ -69,12 +69,18 @@ class UserUpgradeService extends Service */ public function syncRebate(int $uuid): array { - $count = abs($this->app->db->name('DataUserTransfer')->where("uid='{$uuid}' and status>0")->sum('amount')); - $total = abs($this->app->db->name('DataUserRebate')->where("uid='{$uuid}' and status=1 and deleted=0")->sum('amount')); - $locks = abs($this->app->db->name('DataUserRebate')->where("uid='{$uuid}' and status=0 and deleted=0")->sum('amount')); - $this->app->db->name('DataUser')->where(['id' => $uuid])->update([ - 'rebate_total' => $total, 'rebate_used' => $count, 'rebate_lock' => $locks, - ]); + if ($uuid > 0) { + $count = abs($this->app->db->name('DataUserTransfer')->where("uid='{$uuid}' and status>0")->sum('amount')); + $total = abs($this->app->db->name('DataUserRebate')->where("uid='{$uuid}' and status=1 and deleted=0")->sum('amount')); + $locks = abs($this->app->db->name('DataUserRebate')->where("uid='{$uuid}' and status=0 and deleted=0")->sum('amount')); + $this->app->db->name('DataUser')->where(['id' => $uuid])->update([ + 'rebate_total' => $total, 'rebate_used' => $count, 'rebate_lock' => $locks, + ]); + } else { + $count = abs($this->app->db->name('DataUserTransfer')->whereRaw("status>0")->sum('amount')); + $total = abs($this->app->db->name('DataUserRebate')->where("status=1 and deleted=0")->sum('amount')); + $locks = abs($this->app->db->name('DataUserRebate')->where("status=0 and deleted=0")->sum('amount')); + } return [$total, $count, $locks]; } diff --git a/app/data/view/user_rebate/index.html b/app/data/view/user_rebate/index.html index ef15aa440..24111be67 100644 --- a/app/data/view/user_rebate/index.html +++ b/app/data/view/user_rebate/index.html @@ -1,9 +1,10 @@ {extend name="../../admin/view/main"} {block name="content"} -
- 统计:已产生返利累计 {$total.total|default=0.00} 元,已提现 {$total.used|default=0.00} 元,未提现 0 元 +
+ 统计,已产生返利累计 {$rebate.0|default=0.00} 元( 不含锁定 {$rebate.2|default='0.00'} 元 ),累计已提现 {$total.1|default=0.00} 元。
+
{include file='user_rebate/index_search'} diff --git a/app/data/view/user_upgrade/index.html b/app/data/view/user_upgrade/index.html index 54b469307..39a16e4fd 100644 --- a/app/data/view/user_upgrade/index.html +++ b/app/data/view/user_upgrade/index.html @@ -11,7 +11,7 @@ {/block} {block name='content'} -
+
注意,用户等级配置不能随意修改或删除,会影响系统结算与用户升级!