hrjy пре 2 година
родитељ
комит
ea5c75dcf8

+ 2 - 2
.constant

@@ -1,3 +1,3 @@
 <?php
-define('INSTALL_DATE',1578360044);
-define('SERIALNUMBER','N2L6Px');
+define('INSTALL_DATE',1666141191);
+define('SERIALNUMBER','qMJzAF');

+ 0 - 1
.example.env

@@ -1 +0,0 @@
-APP_DEBUG = true

[APP]
DEFAULT_TIMEZONE = Asia/Shanghai

[DATABASE]
TYPE = mysql
HOSTNAME = 127.0.0.1
DATABASE = test
USERNAME = username
PASSWORD = password
HOSTPORT = 3306
CHARSET = utf8
DEBUG = true

[LANG]
default_lang = zh-cn

+ 0 - 8
.htaccess

@@ -1,8 +0,0 @@
-<IfModule mod_rewrite.c>
-  Options +FollowSymlinks -Multiviews
-  RewriteEngine On
-
-  RewriteCond %{REQUEST_FILENAME} !-d
-  RewriteCond %{REQUEST_FILENAME} !-f
-  RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]
-</IfModule>

+ 0 - 7
app/admin/controller/wechat/index.php

@@ -1,7 +0,0 @@
-<?php
-/**
- * Created by PhpStorm.
- * User: Administrator
- * Date: 2018/4/18 0018
- * Time: 上午 10:44
- */

+ 51 - 43
app/admin/model/system/SystemUserTask.php

@@ -41,54 +41,62 @@ class SystemUserTask extends BaseModel
      * @var array
      */
     protected static $TaskType = [
+//        [
+//            'type' => 'SatisfactionIntegral',
+//            'name' => '满足积分{$num}',
+//            'real_name' => '积分数',
+//            'max_number' => 0,
+//            'min_number' => 0,
+//            'unit' => '分'
+//        ],
+//        [
+//            'type' => 'ConsumptionAmount',
+//            'name' => '消费满{$num}',
+//            'real_name' => '消费金额',
+//            'max_number' => 0,
+//            'min_number' => 0,
+//            'unit' => '元'
+//        ],
+//        [
+//            'type' => 'ConsumptionFrequency',
+//            'name' => '消费{$num}',
+//            'real_name' => '消费次数',
+//            'max_number' => 0,
+//            'min_number' => 0,
+//            'unit' => '次'
+//        ],
+//        [
+//            'type' => 'CumulativeAttendance',
+//            'name' => '累计签到{$num}',
+//            'real_name' => '累计签到',
+//            'max_number' => 365,
+//            'min_number' => 1,
+//            'unit' => '天'
+//        ],
+//        [
+//            'type' => 'InviteGoodFriends',
+//            'name' => '邀请好友{$num}成为下线',
+//            'real_name' => '邀请好友成为下线',
+//            'max_number' => 1000,
+//            'min_number' => 1,
+//            'unit' => '人'
+//        ],
+//        [
+//            'type' => 'InviteGoodFriendsLevel',
+//            'name' => '邀请好友{$num}成为会员',
+//            'real_name' => '邀请好友成为会员',
+//            'max_number' => 1000,
+//            'min_number' => 1,
+//            'unit' => '人'
+//        ],
         [
-            'type' => 'SatisfactionIntegral',
-            'name' => '满足积分{$num}',
-            'real_name' => '积分数',
-            'max_number' => 0,
-            'min_number' => 0,
-            'unit' => '分'
-        ],
-        [
-            'type' => 'ConsumptionAmount',
-            'name' => '消费满{$num}',
-            'real_name' => '消费金额',
+            'type' => 'CumulativeConsumption',
+            'name' => '小区业绩累计{$num}消费',
+            'real_name' => '累计消费',
             'max_number' => 0,
             'min_number' => 0,
             'unit' => '元'
         ],
-        [
-            'type' => 'ConsumptionFrequency',
-            'name' => '消费{$num}',
-            'real_name' => '消费次数',
-            'max_number' => 0,
-            'min_number' => 0,
-            'unit' => '次'
-        ],
-        [
-            'type' => 'CumulativeAttendance',
-            'name' => '累计签到{$num}',
-            'real_name' => '累计签到',
-            'max_number' => 365,
-            'min_number' => 1,
-            'unit' => '天'
-        ],
-        [
-            'type' => 'InviteGoodFriends',
-            'name' => '邀请好友{$num}成为下线',
-            'real_name' => '邀请好友成为下线',
-            'max_number' => 1000,
-            'min_number' => 1,
-            'unit' => '人'
-        ],
-        [
-            'type' => 'InviteGoodFriendsLevel',
-            'name' => '邀请好友{$num}成为会员',
-            'real_name' => '邀请好友成为会员',
-            'max_number' => 1000,
-            'min_number' => 1,
-            'unit' => '人'
-        ],
     ];
 
     public function profile()

+ 7 - 0
app/admin/model/user/User.php

@@ -174,6 +174,13 @@ class User extends BaseModel
                     $item['sex'] = '女';
                 } else $item['sex'] = '保密';
                 $item['vip_name'] = false;
+                if ($item['identity'] == 0){
+                    $item['identity'] = '粉丝';
+                }elseif ($item['identity'] == 1){
+                    $item['identity'] = '店员';
+                }elseif ($item['identity'] == 2){
+                    $item['identity'] = '店长';
+                }
                 $levelinfo = UserLevel::where('uid', $item['uid'])->where('is_del', 0)->order('grade desc')->field('level_id,is_forever,valid_time')->find();
                 if ($levelinfo) {
                     if ($levelinfo['is_forever']) $item['vip_name'] = SystemUserLevel::where('id', $levelinfo['level_id'])->value('name');

+ 1 - 1
app/admin/view/index/index.php

@@ -5,7 +5,7 @@
     <meta name="viewport" content="width=device-width, initial-scale=1.0">
     <meta name="renderer" content="webkit">
     <meta http-equiv="Cache-Control" content="no-siteapp" />
-    <title>Liuniu管理系统</title>
+    <title>大健康管理系统</title>
     <!--[if lt IE 9]>
     <meta http-equiv="refresh" content="0;ie.html" />
     <![endif]-->

+ 1 - 1
app/admin/view/login/index.php

@@ -17,7 +17,7 @@
     </script>
 </head>
 <body class="gray-bg login-bg">
-<canvas id="canvas" width="900" height="300" style="position: fixed;top: -50px;width: 60%;left: 20%"></canvas>
+<!--<canvasanvas id="canvas" width="900" height="300" style="position: fixed;top: -50px;width: 60%;left: 20%"></canvasanvas>-->
 <div class="middle-box text-center loginscreen  animated fadeInDown">
     <div class="login-group">
         <h3 class="login-logo">

+ 2 - 1
app/admin/view/user/user/index.php

@@ -314,7 +314,8 @@
             {field: 'extract_count_price', title: '累计提现',align:'center',width:'6%'},
             {field: 'integral', title: '积分',width:'6%',sort:true,event:'integral',align:'center'},
             {field: 'spread_uid_nickname', title: '推荐人',align:'center'},
-            {field: 'sex', title: '性别',width:'4%',align:'center'},
+            // {field: 'sex', title: '性别',width:'4%',align:'center'},
+            {field: 'identity', title: '身份',width:'4%',align:'center'},
             {field: 'data_time', title: '访问日期',align:'center',width:'12%',templet:'#data_time'},
             // {field: 'status', title: '状态',templet:"#checkboxstatus",width:'6%',align:'center'},
             {field: 'user_type', title: '用户类型',width:'6%',align:'center'},

+ 7 - 7
app/api/controller/AuthController.php

@@ -197,13 +197,13 @@ class AuthController
             return app('json')->fail($e->getError());
         }
         $verifyCode = CacheService::get('code_' . $account);
-        if (!$verifyCode)
-            return app('json')->fail('请先获取验证码');
-        $verifyCode = substr($verifyCode, 0, 6);
-        if ($verifyCode != $captcha)
-            return app('json')->fail('验证码错误');
-        if (strlen(trim($password)) < 6 || strlen(trim($password)) > 16)
-            return app('json')->fail('密码必须是在6到16位之间');
+//        if (!$verifyCode)
+//            return app('json')->fail('请先获取验证码');
+//        $verifyCode = substr($verifyCode, 0, 6);
+//        if ($verifyCode != $captcha)
+//            return app('json')->fail('验证码错误');
+//        if (strlen(trim($password)) < 6 || strlen(trim($password)) > 16)
+//            return app('json')->fail('密码必须是在6到16位之间');
         if ($password == '123456') return app('json')->fail('密码太过简单,请输入较为复杂的密码');
         $registerStatus = User::register($account, $password, $spread);
         if ($registerStatus) return app('json')->success('注册成功');

+ 21 - 0
app/api/controller/user/UserController.php

@@ -25,6 +25,7 @@ use app\models\user\UserExtract;
 use app\models\user\UserNotice;
 use crmeb\services\GroupDataService;
 use crmeb\services\UtilService;
+use think\facade\Db;
 
 /**
  * 用户类
@@ -54,6 +55,7 @@ class UserController
             ->where('add_time', '>', $search_time)
             ->where('pm', 0)
             ->sum('number');
+        User::upgrade($info['uid']);
         $info['broken_commission'] = bcsub($brokerage_commission, $refund_commission, 2);
         if ($info['broken_commission'] < 0)
             $info['broken_commission'] = 0;
@@ -113,6 +115,7 @@ class UserController
                 $user['promoter_price'] = bcsub($storeBrokeragePrice, $price, 2);
             }
         }
+        User::upgrade($user['uid']);
         //可提现佣金
         //返佣 +
         $brokerage_commission = UserBill::where(['uid' => $user['uid'], 'category' => 'now_money', 'type' => 'brokerage'])
@@ -611,4 +614,22 @@ class UserController
         $puid = $request->post('puid/d', 0);
         return app('json')->success(User::setSpread($puid, $request->uid()));
     }
+
+    /**
+     * 定时分红
+     * @return void
+     */
+    public function bonus()
+    {
+//        if (date('d', time()) == 1){
+            try {
+                Db::startTrans();
+                User::bonus();
+                User::creation();
+                Db::commit();
+            } catch (\Exception $e) {
+                Db::rollback();
+            }
+//        }
+    }
 }

+ 81 - 0
app/common.php

@@ -593,4 +593,85 @@ if (!function_exists('do_request')) {
         curl_close($curl);
         return $result;
     }
+
+
+    if (!function_exists('pr')) {
+        function pr($var, $int = '')
+        {
+            $template = PHP_SAPI !== 'cli' ? '<pre>%s</pre>' : "\n%s\n";
+            printf($template, print_r($var, true));
+            if (!empty($int)) {
+                exit($int);
+            }
+
+        }
+    }
+
+    if (!function_exists('get_downline')){
+        //所有下级
+        function get_downline($members,$id){
+            $arr=array();
+            foreach ($members as $key => $v) {
+                if($v['spread_uid']==$id){  //pid为0的是顶级分类
+
+                    $arr[]=$v['uid'];
+                    $arr = array_merge($arr,get_downline($members,$v['uid']));
+                }
+            }
+            return $arr;
+
+        }
+    }
+
+    if (!function_exists('get_downline_area')){
+        //所有小区下级
+        function get_downline_area($members,$id){
+            $arr=array();
+            foreach ($members as $key => $v) {
+                if($v['spread_uid']==$id){  //pid为0的是顶级分类
+                    if ($v['line'] <= 2){
+                        $arr[]=$v['uid'];
+                        $arr = array_merge($arr,get_downline($members,$v['uid']));
+                    }
+
+                }
+            }
+            return $arr;
+
+        }
+    }
+
+
+    if (!function_exists('getParent')){
+        //获取指定级别的所有上级
+        function getParent($p_id,$array) {
+            $subs=array();
+            foreach($array as $item){
+                if($item['uid'] == $p_id){
+                    $subs[]=$item['uid'];//这里自己看着办,我是获取用户名
+                    if ($item['spread_uid'] and $item['line'] >= 3){
+                        return $subs;
+                    }
+                    $subs=array_merge($subs,getParent($item['spread_uid'],$array));
+                }
+
+            }
+            return $subs;
+        }
+    }
+
+    if (!function_exists('getParents')){
+        //获取指定级别的所有上级
+        function getParents($p_id,$array) {
+            $subs=array();
+            foreach($array as $item){
+                if($item['uid'] == $p_id){
+                    $subs[]=$item['uid'];//这里自己看着办,我是获取用户名
+                    $subs=array_merge($subs,getParent($item['spread_uid'],$array));
+                }
+
+            }
+            return $subs;
+        }
+    }
 }

+ 1 - 0
app/models/store/StoreOrder.php

@@ -777,6 +777,7 @@ class StoreOrder extends BaseModel
         UserBill::expend('购买商品', $order['uid'], 'now_money', 'pay_money', $order['pay_price'], $order['id'], $now_money, '支付' . floatval($order['pay_price']) . '元购买商品');
         //支付成功后
         event('OrderPaySuccess', [$order, $formId]);
+        User::upgrade($order['uid']);
         $res = $res1 && $resPink && UserSpread::setSpreadSure($order['uid']) && User::backOrderBrokerage($order);
         return false !== $res;
     }

+ 4 - 2
app/models/store/StoreProduct.php

@@ -8,6 +8,7 @@
 namespace app\models\store;
 
 use app\admin\model\store\StoreProductAttrValue as StoreProductAttrValueModel;
+use app\admin\model\user\User;
 use app\models\system\SystemUserLevel;
 use app\models\user\UserLevel;
 use crmeb\basic\BaseModel;
@@ -502,7 +503,7 @@ class StoreProduct extends BaseModel
      * @param bool $type true = 一级返佣, fasle = 二级返佣
      * @return array
      */
-    public static function getProductBrokerage(array $cartId, bool $type = true)
+    public static function getProductBrokerage(int $uid, array $cartId, bool $type = true)
     {
         $cartInfo = StoreOrderCartInfo::whereIn('cart_id', $cartId)->column('cart_info');
         $oneBrokerageReal = 0;//一级返佣金额
@@ -546,7 +547,8 @@ class StoreProduct extends BaseModel
         }
         if ($type) {
             //获取后台一级返佣比例
-            $storeBrokerageRatio = sys_config('store_brokerage_ratio');
+            $user = User::where('uid', $uid)->find();
+            $storeBrokerageRatio = $user['identity'] == 1? sys_config('store_brokerage_ratio') : sys_config('shopowner');
             //一级返佣比例 小于等于零时直接返回 不返佣
             if ($storeBrokerageRatio <= 0) {
                 return [$oneBrokerageReal, $oneBrokerageVirtual];

+ 18 - 0
app/models/system/SystemUserTask.php

@@ -247,6 +247,24 @@ class SystemUserTask extends BaseModel
         return ['还需签到{$num}天', $sumCount, $isComplete];
     }
 
+
+    /**
+     * 累计签到
+     * @param int $task_id 任务id
+     * @param int $uid 用户id
+     * @param int $start_time 查询开始时间
+     * @param int $number 限定数量
+     * @return Boolean
+     * */
+    public static function CumulativeConsumption($task_id, $uid = 0, $start_time = 0, $number = 0)
+    {
+        $isComplete = false;
+        $uids = get_downline_area(User::select(), $uid);
+        $order_price = StoreOrder::where('paid', 1)->where('status', '>=', 0)->where('uid', 'in', $uids)->sum('pay_price');
+        if ($order_price >= $number) $isComplete = UserTaskFinish::setFinish($uid, $task_id) ? true : false;
+        return ['还需签到{$num}天', $order_price, $isComplete];
+    }
+
     /**
      * 设置任务完成情况
      * @param int $task_id 任务id

+ 209 - 5
app/models/user/User.php

@@ -296,7 +296,7 @@ class User extends BaseModel
         if (!$userInfo || !$userInfo['spread_uid'] || $userInfo['spread_uid'] == $orderInfo['uid']) return true;
         if (!User::be(['uid' => $userInfo['spread_uid'], 'is_promoter' => 1])) return self::backOrderBrokerageTwo($orderInfo, $open);
         $cartId = is_string($orderInfo['cart_id']) ? json_decode($orderInfo['cart_id'], true) : $orderInfo['cart_id'];
-        list($realBrokeragePrice, $virtualBrokeragePrice) = StoreProduct::getProductBrokerage($cartId);
+        list($realBrokeragePrice, $virtualBrokeragePrice) = StoreProduct::getProductBrokerage($userInfo['spread_uid'],$cartId);
         //TODO 返佣金额小于等于0 直接返回不返佣金
         if ($realBrokeragePrice <= 0 && $virtualBrokeragePrice <= 0) return true;
         //TODO 获取上级推广员信息
@@ -316,12 +316,52 @@ class User extends BaseModel
         }
         if ($realBrokeragePrice > 0) {
             $spreadUserInfo = User::getUserInfo($userInfo['spread_uid']);
+
             //TODO 上级推广员返佣之后的金额
-            $mark = $userInfo['nickname'] . '成功消费[实体产品]' . floatval($orderInfo['pay_price']) . '元,奖励推广佣金' . floatval($realBrokeragePrice);
+
             //TODO 添加推广记录
-            $res = UserBill::income('获得推广佣金', $userInfo['spread_uid'], 'now_money', 'brokerage', $realBrokeragePrice, $orderInfo['id'], $spreadUserInfo['brokerage_price'], $mark, 0);
+            $brokerage_price = $realBrokeragePrice * 0.95;// 到账佣金
+            $integral =  $realBrokeragePrice * 0.05;// 到账积分
+
+            $mark = $userInfo['nickname'] . '成功消费[实体产品]' . floatval($orderInfo['pay_price']) . '元,奖励推广佣金' . floatval($brokerage_price);
+            $mark1 = $userInfo['nickname'] . '成功消费[实体产品]' . floatval($orderInfo['pay_price']) . '元,奖励推广积分' . floatval($integral);
+
+
+            $res = UserBill::income('获得推广佣金', $userInfo['spread_uid'], 'now_money', 'brokerage', $brokerage_price, $orderInfo['id'], $spreadUserInfo['brokerage_price'] + $brokerage_price, $mark, 0);
+            $res = UserBill::income('获得推广积分', $userInfo['spread_uid'], 'integral', 'push', $integral, $orderInfo['id'], $spreadUserInfo['integral'] + $integral, $mark1, 0);
+
+            $res2 = self::bcInc($userInfo['spread_uid'], 'brokerage_price', $brokerage_price, 'uid');
+            $res2 = self::bcInc($userInfo['spread_uid'], 'integral', $integral, 'uid');
+
+
+            $uid = getParent($userInfo['spread_uid'],User::select());
+            if (count($uid) >= 2){
+                $uid1 = array_pop($uid);
+                $uid2 = array_pop($uid);
+                $user1 = User::where('uid', $uid1)->find();
+                $user2 = User::where('uid', $uid2)->find();
+                if ($user1['identity'] == 2){
+                    $brokerage_price = ($orderInfo['pay_price'] * sys_config('shopowner')/100 * 0.7) * 0.3 * 0.95;// 到账佣金
+                    $integral =   ($orderInfo['pay_price'] * sys_config('shopowner')/100 * 0.7) * 0.3 * 0.05;// 到账积分
+
+                    UserBill::income('获得推广佣金', $uid1, 'now_money', 'brokerage', $brokerage_price, $orderInfo['id'], $user1['brokerage_price'] + $brokerage_price, '店长平级佣金奖励', 0);
+                    UserBill::income('获得推广积分', $uid1, 'integral', 'Level', $integral, $orderInfo['id'], $user1['integral'] + $integral, '店长平级积分奖励', 0);
+                    self::bcInc($uid1, 'brokerage_price', $brokerage_price, 'uid'); //那二代店长业绩的百分之30
+                    self::bcInc($uid1, 'integral', $integral, 'uid'); //那二代店长业绩的百分之30
+                }
+                if ($user2['identity'] == 2){
+                    $brokerage_price = ($orderInfo['pay_price'] *  sys_config('shopowner')/100 * 0.7) * 0.95;// 到账佣金
+                    $integral =   ($orderInfo['pay_price'] *  sys_config('shopowner')/100 * 0.7) * 0.05;// 到账积分
+
+
+                    UserBill::income('获得推广佣金', $uid2, 'now_money', 'brokerage', $brokerage_price, $orderInfo['id'], $user2['brokerage_price'] + $brokerage_price, '店长平级佣金奖励', 0);
+                    UserBill::income('获得推广积分', $uid2, 'integral', 'Level', $integral, $orderInfo['id'], $user2['brokerage_price'] + $integral, '店长平级积分奖励', 0);
+                    self::bcInc($uid2, 'brokerage_price',$brokerage_price, 'uid'); //那二代店长业绩的百分之30
+                    self::bcInc($uid2, 'brokerage_price', $integral, 'uid'); //那二代店长业绩的百分之30
+                }
+            }
         }
-        $res = $res && self::backOrderBrokerageTwo($orderInfo);
+//        $res = $res && self::backOrderBrokerageTwo($orderInfo);
 //        $open && self::checkTrans($res);
         return $res;
     }
@@ -346,9 +386,9 @@ class User extends BaseModel
         if (!User::be(['uid' => $userInfoTwo['spread_uid'], 'is_promoter' => 1])) return true;
         $cartId = is_string($orderInfo['cart_id']) ? json_decode($orderInfo['cart_id'], true) : $orderInfo['cart_id'];
         list($realBrokeragePrice, $virtualBrokeragePrice) = StoreProduct::getProductBrokerage($cartId, false);
+
         //TODO 返佣金额小于等于0 直接返回不返佣金
         if ($realBrokeragePrice <= 0 && $virtualBrokeragePrice <= 0) return true;
-
 //        $open && self::beginTrans();
         $res = true;
         if ($virtualBrokeragePrice > 0) {
@@ -736,4 +776,168 @@ class User extends BaseModel
         }
         return $model->where('brokerage_price', '>', $brokerage_price)->count('uid');
     }
+
+    /**
+     * 升级店长店员
+     * @param $uid
+     * @return void
+     * @throws DataNotFoundException
+     * @throws DbException
+     * @throws ModelNotFoundException
+     */
+    public static function upgrade($uid)
+    {
+        $user = User::where('uid', $uid)->find();
+        if ($user['identity'] == 0){
+            $price = StoreOrder::where('uid', $uid)->where('paid', 1)->sum('pay_price');
+            if ($price >= sys_config('cumulative')){
+                $user['identity'] = 1;
+                if ($user['spread_uid']){
+                    $spd = User::where('uid', $user['spread_uid'])->find();
+                    $user['line'] = $spd['lines'] + 1;
+                    $spd['lines'] += 1;
+                    $spd->save();
+                }
+            }
+        }elseif ($user['identity'] == 1){
+            $count = User::where('spread_uid', $user['uid'])->where('identity', 1)->count();
+            if ($count >= sys_config('push_clerk')){
+                $user['identity'] = 2;
+            }
+
+        }
+        $res = $user->save();
+        if ($user['spread_uid']){
+            $spd = User::where('uid', $user['spread_uid'])->find();
+            $count = User::where('spread_uid', $spd['uid'])->where('identity', 1)->count();
+            if ($count >= sys_config('push_clerk')){
+                $spd['identity'] = 2;
+            }
+            $spd->save();
+        }
+        if ($res) return true;
+        return false;
+    }
+
+    /**
+     * 团队奖励分红
+     * @return void
+     * @throws DataNotFoundException
+     * @throws DbException
+     * @throws ModelNotFoundException
+     */
+    public static function bonus()
+    {
+
+        $user = User::select();
+        foreach ($user as $item)
+        {
+            $start_time = date('Y-m-01 00:00:00', strtotime('-1 month'));
+            $end_time = date('Y-m-d 23:59:59', strtotime(-date('d').'day'));
+            $price = StoreOrder::whereBetweenTime('add_time', strtotime('yesterday'), strtotime('today'))->where('paid', 1)->where('uid', $item['uid'])->sum('pay_price');// 月结
+            if ($item['spread_uid'] > 0 and $price > 0){
+                $spread = getParents($item['spread_uid'], $user->toArray());// 找到所有上级
+                $v1 = 0;
+                $v2 = 0;
+                $v3 = 0;
+                $one = sys_config('area')/100; // 区代
+                $tow = sys_config('city')/100; // 市代
+                $three = sys_config('partner')/100;// 合伙人
+                foreach ($spread as $value) {
+                        $details = User::where('uid', $value)->find();
+                        if ($details['level'] > 0){
+                            if ($details['level'] == 1){
+                                if ($v2 == 0 and $v3 == 0){
+                                    // 没有发放市代和合伙人的奖励
+                                    if ($v1 == 0) { // 没有发放v1的奖励
+                                        $jl = $price * $one;
+                                        $details['dynamic_integral'] += $jl; // 区代团队奖励
+                                        $v1++;
+                                    }
+                                }
+                            }elseif ($details['level'] == 2){
+                                if ($v3 == 0){
+                                    // 没有发放合伙人的奖励
+                                    if ($v1 == 0 and $v2 == 0) { // 没有发放区代和市代的奖励的奖励
+                                        $jl = $price * $tow;// 市代团队奖励
+                                        $v2++;
+                                    }elseif ($v1 > 0 and $v2 == 0){// 发放区代奖励,没有发放市代的奖励
+                                        $jl = $price * ($tow - $one); // 市代团队奖励
+                                        $v2++;
+                                    }
+
+                                }
+
+                            }elseif ($details['level'] == 3){
+                                if ($v1 == 0 and $v2 == 0 and $v3 == 0) { // 没有发放区代和市代,合伙人的奖励的奖励
+                                    $jl = $price * $three;  // 合伙人团队奖励
+                                    $v3++;
+                                }elseif ($v1 > 0 and $v2 == 0 and $v3 == 0){// 发放区代奖励,没有发放市代,合伙人的奖励
+                                    $jl = $price * ($three - $one);  // 合伙人团队奖励
+                                    $v3++;
+                                }elseif ($v1 == 0 and $v2 > 0 and $v3 == 0){// 没有发放区代奖励,发放市代的奖励,没有发放合伙人的奖励
+                                    $jl = ($price * ($three - $tow));  // 合伙人团队奖励
+                                    $v3++;
+                                }elseif ($v1 > 0 and $v2 > 0 and $v3 == 0){// 发放区代奖励,发放市代的奖励,发放合伙人的奖励
+                                    $jl = ($price * ($three - $tow));  // 合伙人团队奖励
+                                    $v3++;
+                                }
+                            }
+                            if ($jl > 0){
+                                $brokerage_price = $jl * 0.95;// 到账佣金
+                                $integral = $jl * 0.05;// 到账积分
+                                User::where('uid', $value)->inc('brokerage_price', $brokerage_price)->update();
+                                User::where('uid', $value)->inc('integral', $integral)->update();
+                                if ($details['level'] == 3) {
+                                    $bl =  $three;
+                                    if ($v2 > 0 and $v1 > 0) $bl -= $tow;
+                                    if ($v2 > 0 and $v1 == 0) $bl -= $tow;
+                                    if ($v2 == 0 and $v1 > 0) $bl -= $one;
+
+                                }
+                                if ($details['level'] == 2){
+                                    $bl =  $tow;
+                                    if ($v1 > 0) $bl -= $one;
+                                }
+                                if ($details['level'] == 1) $bl =  $one;
+                                UserBill::income('获得推广佣金', $details['uid'], 'now_money', 'brokerage', $brokerage_price, $item['uid'],$details['brokerage_price'] + $brokerage_price, '用户'.$item['uid'].'月结'.$price.'团队奖励比例'.$bl.'的95%佣金');
+                                UserBill::income('获得推广积分', $details['uid'], 'integral', 'bonus', $integral, $item['uid'],$details['integral'] + $integral, '用户'.$item['uid'].'月结'.$price.'团队奖励比例'.$bl.'的5%积分');
+                            }
+                            $jl = 0;
+                        }
+
+                }
+            }
+        }
+    }
+
+    /**
+     * 联创分红
+     * @return void
+     * @throws DataNotFoundException
+     * @throws DbException
+     * @throws ModelNotFoundException
+     */
+    public static function creation()
+    {
+        $user = User::where('level', 4)->select();
+        if (count($user) > 0){
+            $start_time = date('Y-m-01 00:00:00', strtotime('-1 month'));
+            $end_time = date('Y-m-d 23:59:59', strtotime(-date('d').'day'));
+            $price = StoreOrder::whereBetweenTime('add_time',strtotime('yesterday'), strtotime('today'))->where('paid', 1)->sum('pay_price');// 月结
+            if ($price > 0){
+                foreach ($user as $item)
+                {
+                    $brokerage_price = ($price * sys_config('link')/100) * 0.95;// 到账佣金
+                    $integral =  ($price * sys_config('link')/100) * 0.05;// 到账积分
+                    User::where('uid', $item['uid'])->inc('brokerage_price', $brokerage_price)->update();
+                    User::where('uid', $item['uid'])->inc('integral', $integral)->update();
+                    UserBill::income('联创分红佣金', $item['uid'], 'now_money', 'brokerage', $brokerage_price, $item['uid'],$item['brokerage_price'] + $brokerage_price, '联创分红奖励比例'.(sys_config('link')/100).'的95%佣金');
+                    UserBill::income('联创分红积分', $item['uid'], 'integral', 'creation', $integral, $item['uid'],$item['integral'] + $integral, '联创分红奖励比例'.(sys_config('link')/100).'的5%积分');
+                }
+            }
+
+        }
+
+    }
 }

+ 2 - 0
app/wap/.gitignore

@@ -0,0 +1,2 @@
+*
+!.gitignore

+ 0 - 8
public/.htaccess

@@ -1,8 +0,0 @@
-<IfModule mod_rewrite.c>
-  Options +FollowSymlinks -Multiviews
-  RewriteEngine On
-
-  RewriteCond %{REQUEST_FILENAME} !-d
-  RewriteCond %{REQUEST_FILENAME} !-f
-  RewriteRule ^(.*)$ index.php?/$1 [QSA,PT,L]
-</IfModule>

+ 5 - 6
public/nginx.htaccess

@@ -1,6 +1,5 @@
-location / { 
-   if (!-e $request_filename) {
-   rewrite  ^(.*)$  /index.php?s=/$1  last;
-   break;
-    }
- }
+location / {
+        if (!-e $request_filename){
+                rewrite  ^(.*)$  /index.php?s=$1  last;   break;
+        }
+}

+ 2 - 0
route/api/route.php

@@ -231,6 +231,8 @@ Route::group(function () {
     Route::get('store_list', 'PublicController/store_list')->name('storeList');
     //获取城市列表
     Route::get('city_list', 'PublicController/city_list')->name('cityList');
+    //定时分红
+    Route::get('bonus', 'user.userController/bonus')->name('bonus');
 
 
 })->middleware(\app\http\middleware\AllowOriginMiddleware::class)->middleware(\app\http\middleware\AuthTokenMiddleware::class, false);

+ 2 - 1
route/wap/route.php

@@ -11,5 +11,6 @@
 use think\facade\Route;
 
 Route::miss(function () {
-    return redirect(sys_config('site_url') . '/index');
+//    return redirect(sys_config('site_url') . '/index');
+    return view(app()->getRootPath() . 'public' . DS . 'index.html');
 });