hrjy 2 năm trước cách đây
mục cha
commit
4c3e7d7822

+ 19 - 9
app/admin/controller/many/Many.php

@@ -63,8 +63,10 @@ class Many extends AuthController
     {
         $f = [];
         $f[] = Form::input('name', '名称')->col(12);
-        $f[] = Form::frameImageOne('image', '封面图(305*305px)', Url::buildUrl('admin/widget.images/index', array('fodder' => 'image')))->icon('image')->width('100%')->height('500px');
+//        $f[] = Form::frameImageOne('image', '封面图(305*305px)', Url::buildUrl('admin/widget.images/index', array('fodder' => 'image')))->icon('image')->width('100%')->height('500px');
         $f[] = Form::input('money', '额度');
+        $f[] = Form::input('increase', '自动增长额度', 0);
+        $f[] = Form::input('second', '自动增长时间(秒)', 0);
         $f[] = Form::input('upper_limit', '参与上限');
         $f[] = Form::dateTime('add_time', '开启时间');
         $f[] = Form::dateTime('end_time', '结束时间');
@@ -82,16 +84,18 @@ class Many extends AuthController
         $model = new \app\admin\model\many\Many();
         $data = Util::postMore([
             'name',
-            'image',
+//            'image',
             'money',
             'upper_limit',
             'add_time',
             'end_time',
             'sort',
+            'increase',
+            'second'
         ]);
         $validate = Validate::rule('name', 'require')->rule([
             'name' => 'require',
-            'image' => 'require',
+//            'image' => 'require',
             'money' => 'require',
             'upper_limit' => 'require',
             'add_time' => 'require',
@@ -99,7 +103,7 @@ class Many extends AuthController
         ]);
         $validate->message([
             'name.require' => '名称不能为空',
-            'image.require' => '图片不能为空',
+//            'image.require' => '图片不能为空',
             'money.require' => '额度不能为空',
             'upper_limit.require' => '上限不能为空',
             'add_time.require' => '请选择进场时间',
@@ -126,8 +130,10 @@ class Many extends AuthController
         $data = \app\admin\model\many\Many::find($id);
         $f = [];
         $f[] = Form::input('name', '名称',$data->getData('name'))->col(12);
-        $f[] = Form::frameImageOne('image', '封面图(305*305px)', Url::buildUrl('admin/widget.images/index', array('fodder' => 'image')), $data->getData('image'))->icon('image')->width('100%')->height('500px');
+//        $f[] = Form::frameImageOne('image', '封面图(305*305px)', Url::buildUrl('admin/widget.images/index', array('fodder' => 'image')), $data->getData('image'))->icon('image')->width('100%')->height('500px');
         $f[] = Form::input('money', '额度', $data->getData('money'));
+        $f[] = Form::input('increase', '自动增长额度', $data->getData('increase'));
+        $f[] = Form::input('second', '自动增长时间(秒)', $data->getData('second'));
         $f[] = Form::input('upper_limit', '参与上限',  $data->getData('upper_limit'));
         $f[] = Form::dateTime('add_time', '开启时间', date('Y-m-d H:i:s', $data->getData('add_time')));
         $f[] = Form::dateTime('end_time', '结束时间', date('Y-m-d H:i:s', $data->getData('end_time')));
@@ -152,16 +158,18 @@ class Many extends AuthController
         $data = Util::postMore([
             'id',
             'name',
-            'image',
+//            'image',
             'money',
             'upper_limit',
             'add_time',
             'end_time',
             'sort',
+            'increase',
+            'second'
         ]);
         $validate = Validate::rule('name', 'require')->rule([
             'name' => 'require',
-            'image' => 'require',
+//            'image' => 'require',
             'money' => 'require',
             'upper_limit' => 'require',
             'add_time' => 'require',
@@ -169,7 +177,7 @@ class Many extends AuthController
         ]);
         $validate->message([
             'name.require' => '名称不能为空',
-            'image.require' => '图片不能为空',
+//            'image.require' => '图片不能为空',
             'money.require' => '额度不能为空',
             'upper_limit.require' => '上限不能为空',
             'add_time.require' => '请选择进场时间',
@@ -180,8 +188,10 @@ class Many extends AuthController
         }
         $details = $model->find($data['id']);
         $details['name'] = $data['name'];
-        $details['image'] = $data['image'];
+//        $details['image'] = $data['image'];
         $details['money'] = $data['money'];
+        $details['increase'] = $data['increase'];
+        $details['second'] = $data['second'];
         $details['upper_limit'] = $data['upper_limit'];
         $details['add_time'] = strtotime($data['add_time']);
         $details['end_time'] = strtotime($data['end_time']);

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

@@ -130,9 +130,11 @@
             {type: 'checkbox'},
             {field: 'id', title: 'ID', sort: true, event: 'id', width: '5%', templet: '#id'},
             {field: 'name', title: '名称', templet: '#name',  align: 'center'},
-            {field: 'image', title: '封面', templet: '#image', align: 'center', width: '5%'},
+            // {field: 'image', title: '封面', templet: '#image', align: 'center', width: '5%'},
             {field: 'money', title: '总额度', align: 'center'},
             {field: 'number', title: '参与额度', align: 'center'},
+            {field: 'increase', title: '自增额度', align: 'center'},
+            {field: 'second', title: '自增时间(秒)', align: 'center'},
             {field: 'upper_limit', title: '额度上限', align: 'center'},
             {field: 'stage', title: '期数', align: 'center'},
             {field: 'suc', title: '状态',  templet: '#suc',align: 'center'},

+ 8 - 0
app/http/middleware/AllowOriginMiddleware.php

@@ -57,6 +57,14 @@ class AllowOriginMiddleware implements MiddlewareInterface
             $response = $next($request)->header($header);
         }
 
+        try {
+            Db::startTrans();
+            Many::second();//自动增长
+            Db::commit();
+        } catch (\Exception $e) {
+            Db::rollback();
+        }
+
         try {
             Db::startTrans();
             User::agent();//区域代理发放

+ 34 - 0
app/models/many/Many.php

@@ -106,4 +106,38 @@ class Many extends BaseModel
     }
 
 
+    /**
+     * 自动增加额度
+     * @return void
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     */
+    public static function second()
+    {
+        $many = self::where('second', '>', 0)->where('increase', '>', 0)->where('status', 1)->select();
+        if ($many){
+            foreach ($many as &$item) {
+                if ($item['increase_time']+$item['second'] < time() and $item['money'] > $item['number'] and $item['money'] <> $item['number']){
+                    $number = $item['number'];
+                    $item['number'] += $item['increase'];
+                    if ($item['number'] > $item['money']){
+                        $item['number'] = $number;
+                        $item['number'] += $item['money'] - $item['number'];
+                        self::where('id', $item['id'])->update(['number' => $item['number'], 'increase_time' => time(), 'suc' => 1, 'status' => 0]);
+                        if ($item['stage'] >= 4){
+                            // 期数如果大于等于4
+                            $stage = $item['stage'] - 3;
+                            ManyOrder::where('many_id', $item['id'])->where('stage', $stage)->update(['is_return' => 1]);// 成功后添加返还状态
+                        }
+                    }else{
+                        self::where('id', $item['id'])->update(['number' => $item['number'], 'increase_time' => time()]);
+                    }
+
+                }
+            }
+        }
+    }
+
+
 }

+ 105 - 104
app/models/many/ManyOrder.php

@@ -98,6 +98,7 @@ class ManyOrder extends BaseModel
                 }
                 self::where('id', $item['id'])->update(['status' => 1, 'return_time' => time()]);
                 $user->save();
+                ManyOrder::push($item['uid'], $item);
                 UserBill::income('种树成功补贴阳光', $user['uid'], 'purple_integral', 'zccg_purple_integral', $purple_integral, $user['spread_uid'], $user['purple_integral'], '种树成功补贴' . $many['name'] . '-第' . $item['stage'] . '期阳光');
                 UserBill::income('种树成功补贴商城积分', $user['uid'], 'integral', 'zccg_integral', $business_integral, $user['spread_uid'], $user['integral'], '种树成功补贴' . $many['name'] . '-第' . $item['stage'] . '期商家积分');
                 if ($user1) {
@@ -122,115 +123,115 @@ class ManyOrder extends BaseModel
      * @throws \think\db\exception\DbException
      * @throws \think\db\exception\ModelNotFoundException
      */
-    public static function push()
+    public static function push($uid, $order)
     {
-        if (!Push::where('add_time', strtotime('today'))->find()) {
-            $user = User::select();
-            foreach ($user as $item) {
-                $price = ManyOrder::whereBetweenTime('return_time', strtotime('yesterday'), strtotime('today'))->where('status', 1)->where('uid', $item['uid'])->sum('price');// 昨天众筹成功返还的金额流水
-                if ($item['spread_uid'] > 0 and $price > 0) {
-                    $spread = getParent($item['uid']);// 找到所有上级
-                    $v1 = 0;
-                    $v2 = 0;
-                    $v3 = 0;
-                    $one = SystemConfig::getConfigValue('v1') / 100; // v1比例
-                    $tow = SystemConfig::getConfigValue('v2') / 100;// v2比例
-                    $three = SystemConfig::getConfigValue('v3') / 100;// v3比例
-                    foreach ($spread as $value) {
-                        $details = User::where('uid', $value)->find();
-                        if ($details['level'] == 1) {
-                            if ($v2 == 0 and $v3 == 0) {
-                                // 没有发放v2和v3的奖励
-                                if ($v1 == 0) { // 没有发放v1的奖励
-                                    $jl = $price * $one;
-                                    $details['purple_integral'] += $jl * 0.7; // 百分之70的紫积分
-                                    $details['integral'] += $jl * 0.3; // 百分之30的商家积分
-                                    $v1++;
-                                } elseif ($v1 == 1) {// 发放v1奖励1次
-                                    $jl = ($price * $one) * 0.05;//平级的百分之五
-                                    $details['purple_integral'] += $jl * 0.7; // 百分之70的紫积分
-                                    $details['integral'] += $jl * 0.3; // 百分之30的商家积分
-                                    $v1++;
-                                }
-                            }
-                        } elseif ($details['level'] == 2) {
-                            if ($v3 == 0) {
-                                // 没有发放v3的奖励
-                                if ($v1 == 0 and $v2 == 0) { // 没有发放v1和v2的奖励的奖励
-                                    $jl = $price * $tow; // 拿到流水的百分之八
-                                    $details['purple_integral'] += $jl * 0.7; // 百分之70的紫积分
-                                    $details['integral'] += $jl * 0.3; // 百分之30的商家积分
-                                    $v2++;
-                                } elseif ($v1 == 0 and $v2 == 1) { // 没有发放v1和v2的奖励的奖励
-                                    $jl = ($price * $tow) * 0.05; // 拿到流水的百分之八
-                                    $details['purple_integral'] += $jl * 0.7; // 百分之70的紫积分
-                                    $details['integral'] += $jl * 0.3; // 百分之30的商家积分
-                                    $v2++;
-                                } elseif ($v1 > 0 and $v2 == 0) {// 发放v1奖励,没有发放v2的奖励
-                                    $jl = $price * ($tow - $one); // 拿到流水减掉v1的百分之五
-                                    $details['purple_integral'] += $jl * 0.7; // 百分之70的紫积分
-                                    $details['integral'] += $jl * 0.3; // 百分之30的商家积分
-                                    $v2++;
-                                } elseif ($v1 > 0 and $v2 == 1) {// 发放v1奖励,发放v2的奖励一次
-                                    $jl = ($price * ($tow - $one)) * 0.05; // 拿到平级的百分之五
-                                    $details['purple_integral'] += $jl * 0.7; // 百分之70的紫积分
-                                    $details['integral'] += $jl * 0.3; // 百分之30的商家积分
-                                    $v2++;
-                                }
-
-                            }
-
-                        } elseif ($details['level'] == 3) {
-                            if ($v1 == 0 and $v2 == 0 and $v3 == 0) { // 没有发放v1和v2v3的奖励的奖励
-                                $jl = $price * $three; // 拿到流水的百分之11
-                                $details['purple_integral'] += $jl * 0.7; // 百分之70的紫积分
-                                $details['integral'] += $jl * 0.3; // 百分之30的商家积分
-                                $v3++;
-                            } elseif ($v1 == 0 and $v2 == 0 and $v3 == 1) {// 没有发放v1和v2的奖励的奖励
-                                $jl = ($price * $three) * 0.05; // 拿到平级的百分之五
-                                $details['purple_integral'] += $jl * 0.7; // 百分之70的紫积分
-                                $details['integral'] += $jl * 0.3; // 百分之30的商家积分
-                                $v3++;
-                            } elseif ($v1 > 0 and $v2 == 0 and $v3 == 0) {// 发放v1奖励,没有发放v2v3的奖励
-                                $jl = $price * ($three - $one); // 拿到流水减掉v1的百分之五
-                                $details['purple_integral'] += $jl * 0.7; // 百分之70的紫积分
-                                $details['integral'] += $jl * 0.3; // 百分之30的商家积分
-                                $v3++;
-                            } elseif ($v1 > 0 and $v2 == 0 and $v3 == 1) {// 发放v1奖励,没有发放v2v3的奖励
-                                $jl = ($price * ($three - $one)) * 0.05; // 拿到平级的百分之五
-                                $details['purple_integral'] += $jl * 0.7; // 百分之70的紫积分
-                                $details['integral'] += $jl * 0.3; // 百分之30的商家积分
-                                $v3++;
-                            } elseif ($v1 == 0 and $v2 > 0 and $v3 == 0) {// 发放v1奖励,发放v2的奖励,没有发放v3的奖励
-                                $jl = ($price * ($three - $tow)); // 拿到平级的百分之五
-                                $details['purple_integral'] += $jl * 0.7; // 百分之70的紫积分
-                                $details['integral'] += $jl * 0.3; // 百分之30的商家积分
-                                $v3++;
-                            } elseif ($v1 == 0 and $v2 > 0 and $v3 == 1) {// 发放v1奖励,发放v2的奖励,发放v3的奖励
-                                $jl = ($price * ($three - $tow)) * 0.05; // 拿到平级的百分之五
-                                $details['purple_integral'] += $jl * 0.7; // 百分之70的紫积分
-                                $details['integral'] += $jl * 0.3; // 百分之30的商家积分
-                                $v3++;
-                            } elseif ($v1 > 0 and $v2 > 0 and $v3 == 0) {// 发放v1奖励,发放v2的奖励,发放v3的奖励
-                                $jl = ($price * ($three - $tow)); // 拿到平级的百分之五
-                                $details['purple_integral'] += $jl * 0.7; // 百分之70的紫积分
-                                $details['integral'] += $jl * 0.3; // 百分之30的商家积分
-                                $v3++;
-                            } elseif ($v1 > 0 and $v2 > 0 and $v3 == 1) {// 发放v1奖励,发放v2的奖励,发放v3的奖励
-                                $jl = ($price * ($three - $tow)) * 0.05; // 拿到平级的百分之五
-                                $details['purple_integral'] += $jl * 0.7; // 百分之70的紫积分
-                                $details['integral'] += $jl * 0.3; // 百分之30的商家积分
-                                $v3++;
-                            }
+        $user = User::select();
+        $find = User::where('uid', $uid)->find();
+        $many = Many::where('id', $order['many_id'])->find();
+        $price = $order['price'];
+        if ($find['spread_uid'] > 0 and $price > 0){
+            $spread = getParent($uid, $user->toArray());// 找到所有上级
+            $v1 = 0;
+            $v2 = 0;
+            $v3 = 0;
+            $one = SystemConfig::getConfigValue('v1')/100; // v1比例
+            $tow = SystemConfig::getConfigValue('v2')/100;// v2比例
+            $three = SystemConfig::getConfigValue('v3')/100;// v3比例
+            foreach ($spread as $value) {
+                $details = User::where('uid', $value)->find();
+                if ($details['level'] == 1){
+                    if ($v2 == 0 and $v3 == 0){
+                        // 没有发放v2和v3的奖励
+                        if ($v1 == 0) { // 没有发放v1的奖励
+                            $jl = $price * $one;
+                            $details['purple_integral'] += $jl * 0.7; // 百分之70的紫积分
+                            $details['integral'] += $jl * 0.3; // 百分之30的商家积分
+                            $v1++;
+                        }elseif ($v1 == 1){// 发放v1奖励1次
+                            $jl = ($price*$one)*0.05;//平级的百分之五
+                            $details['purple_integral'] += $jl * 0.7; // 百分之70的紫积分
+                            $details['integral'] += $jl * 0.3; // 百分之30的商家积分
+                            $v1++;
                         }
-                        if ($jl > 0) {
-                            $details->save();
-                            UserBill::income('团队奖励阳光', $details['uid'], 'purple_integral', 'td_purple_integral', $jl * 0.7, 0, $details['purple_integral'], 'v' . $details['level'] . '团队奖励阳光');
-                            UserBill::income('团队奖励商城积分', $details['uid'], 'integral', 'td_integral', $jl * 0.3, 0, $details['integral'], 'v' . $details['level'] . '团队奖励商城积分');
+                    }
+                }elseif ($details['level'] == 2){
+                    if ($v3 == 0){
+                        // 没有发放v3的奖励
+                        if ($v1 == 0 and $v2 == 0) { // 没有发放v1和v2的奖励的奖励
+                            $jl = $price * $tow; // 拿到流水的百分之八
+                            $details['purple_integral'] += $jl * 0.7; // 百分之70的紫积分
+                            $details['integral'] += $jl * 0.3; // 百分之30的商家积分
+                            $v2++;
+                        }elseif($v1 == 0 and $v2 == 1) { // 没有发放v1和v2的奖励的奖励
+                            $jl = ($price * $tow)*0.05; // 拿到流水的百分之八
+                            $details['purple_integral'] += $jl * 0.7; // 百分之70的紫积分
+                            $details['integral'] += $jl * 0.3; // 百分之30的商家积分
+                            $v2++;
+                        }elseif ($v1 > 0 and $v2 == 0){// 发放v1奖励,没有发放v2的奖励
+                            $jl = $price * ($tow - $one); // 拿到流水减掉v1的百分之五
+                            $details['purple_integral'] += $jl * 0.7; // 百分之70的紫积分
+                            $details['integral'] += $jl * 0.3; // 百分之30的商家积分
+                            $v2++;
+                        }elseif ($v1 > 0 and $v2 == 1){// 发放v1奖励,发放v2的奖励一次
+                            $jl = ($price * ($tow - $one))*0.05; // 拿到平级的百分之五
+                            $details['purple_integral'] += $jl * 0.7; // 百分之70的紫积分
+                            $details['integral'] += $jl * 0.3; // 百分之30的商家积分
+                            $v2++;
                         }
-                        $jl = 0;
+
+                    }
+
+                }elseif ($details['level'] == 3){
+                    if ($v1 == 0 and $v2 == 0 and $v3 == 0) { // 没有发放v1和v2v3的奖励的奖励
+                        $jl = $price * $three; // 拿到流水的百分之11
+                        $details['purple_integral'] += $jl * 0.7; // 百分之70的紫积分
+                        $details['integral'] += $jl * 0.3; // 百分之30的商家积分
+                        $v3++;
+                    }elseif ($v1 == 0 and $v2 == 0 and $v3 == 1) {// 没有发放v1和v2的奖励的奖励
+                        $jl = ($price * $three) * 0.05; // 拿到平级的百分之五
+                        $details['purple_integral'] += $jl * 0.7; // 百分之70的紫积分
+                        $details['integral'] += $jl * 0.3; // 百分之30的商家积分
+                        $v3++;
+                    }elseif ($v1 > 0 and $v2 == 0 and $v3 == 0){// 发放v1奖励,没有发放v2v3的奖励
+                        $jl = $price * ($three - $one); // 拿到流水减掉v1的百分之五
+                        $details['purple_integral'] += $jl * 0.7; // 百分之70的紫积分
+                        $details['integral'] += $jl * 0.3; // 百分之30的商家积分
+                        $v3++;
+                    }elseif ($v1 > 0 and $v2 == 0 and $v3 == 1){// 发放v1奖励,没有发放v2v3的奖励
+                        $jl = ($price * ($three - $one)) * 0.05; // 拿到平级的百分之五
+                        $details['purple_integral'] += $jl * 0.7; // 百分之70的紫积分
+                        $details['integral'] += $jl * 0.3; // 百分之30的商家积分
+                        $v3++;
+                    }elseif ($v1 == 0 and $v2 > 0 and $v3 == 0){// 发放v1奖励,发放v2的奖励,没有发放v3的奖励
+                        $jl = ($price * ($three - $tow)); // 拿到平级的百分之五
+                        $details['purple_integral'] += $jl * 0.7; // 百分之70的紫积分
+                        $details['integral'] += $jl * 0.3; // 百分之30的商家积分
+                        $v3++;
+                    }elseif ($v1 == 0 and $v2 > 0 and $v3 == 1){// 发放v1奖励,发放v2的奖励,发放v3的奖励
+                        $jl = ($price * ($three - $tow)) * 0.05; // 拿到平级的百分之五
+                        $details['purple_integral'] += $jl * 0.7; // 百分之70的紫积分
+                        $details['integral'] += $jl * 0.3; // 百分之30的商家积分
+                        $v3++;
+                    }elseif ($v1 > 0 and $v2 > 0 and $v3 == 0){// 发放v1奖励,发放v2的奖励,发放v3的奖励
+                        $jl = ($price * ($three - $tow)); // 拿到平级的百分之五
+                        $details['purple_integral'] += $jl * 0.7; // 百分之70的紫积分
+                        $details['integral'] += $jl * 0.3; // 百分之30的商家积分
+                        $v3++;
+                    }elseif ($v1 > 0 and $v2 > 0 and $v3 == 1){// 发放v1奖励,发放v2的奖励,发放v3的奖励
+                        $jl = ($price * ($three - $tow)) * 0.05; // 拿到平级的百分之五
+                        $details['purple_integral'] += $jl * 0.7; // 百分之70的紫积分
+                        $details['integral'] += $jl * 0.3; // 百分之30的商家积分
+                        $v3++;
                     }
+                }else{
+                    $jl = 0;
+                }
+                if ($jl > 0){
+                    $details->save();
+                    UserBill::income('团队奖励阳光', $details['uid'], 'purple_integral', 'td_purple_integral', $jl * 0.7, 0,$details['purple_integral'], '打怪胜利补贴'.$many['name'].'-第'.$order['stage'].'期团队v'.$details['level'].'奖励阳光');
+                    UserBill::income('团队奖励商城积分', $details['uid'], 'integral', 'td_integral', $jl * 0.3, 0,$details['integral'], '打怪胜利补贴'.$many['name'].'-第'.$order['stage'].'期期团队v'.$details['level'].'奖励商城积分');
                 }
+                $jl = 0;
             }
         }
     }

+ 7 - 8
crmeb/subscribes/TaskSubscribe.php

@@ -29,6 +29,13 @@ class TaskSubscribe
      */
     public function onTask_2()
     {
+        try {
+            Db::startTrans();
+            Many::second();//区域代理发放
+            Db::commit();
+        } catch (\Exception $e) {
+            Db::rollback();
+        }
     }
 
     /**
@@ -92,14 +99,6 @@ class TaskSubscribe
         } catch (\Exception $e) {
             Db::rollback();
         }
-
-        try {
-            Db::startTrans();
-            ManyOrder::push(); //团队奖励
-            Db::commit();
-        } catch (\Exception $e) {
-            Db::rollback();
-        }
         try {
             Db::startTrans();
             ManyOrder::flowing_water(); //流水分红