diff --git a/app/data/controller/UserRebate.php b/app/data/controller/UserRebate.php new file mode 100644 index 000000000..f7b5837ce --- /dev/null +++ b/app/data/controller/UserRebate.php @@ -0,0 +1,38 @@ +skey = 'RebateRule'; + $this->title = '返利奖励配置'; + if ($this->request->isGet()) { + $this->data = sysdata($this->skey); + $this->levels = UserUpgradeService::instance()->levels(); + $this->fetch(); + } else { + sysdata($this->skey, $this->request->post()); + $this->success('奖励修改成功'); + } + } + +} \ No newline at end of file diff --git a/app/data/service/RebateCurrentService.php b/app/data/service/RebateCurrentService.php index 9ea1263b6..e2e263b63 100644 --- a/app/data/service/RebateCurrentService.php +++ b/app/data/service/RebateCurrentService.php @@ -18,6 +18,7 @@ class RebateCurrentService extends Service const PRIZE_04 = 'PRIZE04'; const PRIZE_05 = 'PRIZE05'; const PRIZE_06 = 'PRIZE06'; + const PRIZE_07 = 'PRIZE07'; const PRIZES = [ self::PRIZE_01 => ['code' => self::PRIZE_01, 'name' => '首推奖励', 'func' => '_prize01'], @@ -26,6 +27,7 @@ class RebateCurrentService extends Service self::PRIZE_04 => ['code' => self::PRIZE_04, 'name' => '间接团队', 'func' => '_prize04'], self::PRIZE_05 => ['code' => self::PRIZE_05, 'name' => '差额奖励', 'func' => '_prize05'], self::PRIZE_06 => ['code' => self::PRIZE_06, 'name' => '管理奖励', 'func' => '_prize06'], + self::PRIZE_07 => ['code' => self::PRIZE_07, 'name' => '升级奖励', 'func' => '_prize07'], ]; /** diff --git a/app/data/service/UserUpgradeService.php b/app/data/service/UserUpgradeService.php index 6c7d50355..10714c0b0 100644 --- a/app/data/service/UserUpgradeService.php +++ b/app/data/service/UserUpgradeService.php @@ -70,7 +70,20 @@ class UserUpgradeService extends Service } /** - * 同步计算用户级别 + * 获取用户等级数据 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + */ + public function levels(): array + { + $query = $this->app->db->name('DataUserUpgrade'); + return $query->where(['status' => 1])->order('number asc')->select()->toArray(); + } + + /** + * 同步计算用户等级 * @param integer $uid 指定用户UID * @param boolean $parent 同步计算上级 * @return boolean @@ -88,7 +101,7 @@ class UserUpgradeService extends Service $teamsIndirect = $this->app->db->name('DataUser')->where(['pid2' => $uid])->count(); $teamsUsers = $this->app->db->name('DataUser')->where(['pid1|pid2' => $uid])->count(); $orderAmount = $this->app->db->name('ShopOrder')->where("uid={$uid} and status>=4")->sum('amount_total'); - // 计算用户级别 + // 计算用户等级 foreach ($this->app->db->name('DataUserUpgrade')->where(['status' => 1])->order('number desc')->cursor() as $item) { $l1 = empty($item['goods_vip_status']) || $user['buy_vip_entry'] > 0; $l2 = empty($item['teams_users_status']) || $item['teams_users_number'] <= $teamsUsers; diff --git a/app/data/view/user_rebate/config.html b/app/data/view/user_rebate/config.html new file mode 100644 index 000000000..3fd9b9905 --- /dev/null +++ b/app/data/view/user_rebate/config.html @@ -0,0 +1,263 @@ +{extend name="../../admin/view/main"} + +{block name='content'} +