hrjy 2 years ago
parent
commit
8e74e8433d

+ 1 - 0
app/admin/view/order/store_order/index.php

@@ -540,6 +540,7 @@
             {field: 'order_id', title: '订单号', sort: true, event: 'order_id', width: '14%', templet: '#order_id'},
             {field: 'nickname', title: '用户信息', templet: '#userinfo', width: '10%', align: 'center'},
             {field: 'spread_uid', title: '推荐人信息', templet: '#spread_uid', width: '10%', align: 'center'},
+            {field: 'real_name', title: '收货人消息', templet: '#real_name', width: '10%'},
             {field: 'info', title: '商品信息', templet: "#info", height: 'full-20'},
             {field: 'pay_price', title: '实际支付', width: '8%', align: 'center'},
             {field: 'paid', title: '支付状态', templet: '#paid', width: '8%', align: 'center'},

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

@@ -718,9 +718,27 @@ class UserController
         ];
         if (count($userId) > 0){
             $user1 = User::field('uid,nickname,avatar,add_time,phone')->where('spread_uid', '=', $request->uid())->select();
+            if ($user1){
+                foreach ($user1 as &$item){
+                    $item['price'] =  ManyOrder::where('uid', $item['uid'])->where('status', 1)->sum('price');
+                }
+            }
+
             $uids = User::field('uid,nickname,avatar,add_time,phone')->where('spread_uid', '=', $request->uid())->column('uid');
             $user2 = User::field('uid,nickname,avatar,add_time,phone')->where('spread_uid', 'in', $uids)->select();
+            if ($user2){
+                foreach ($user2 as &$item){
+                    $item['price'] =  ManyOrder::where('uid', $item['uid'])->where('status', 1)->sum('price');
+                }
+            }
+
             $use_list =  User::field('uid,nickname,avatar,add_time,phone')->where('uid', 'in', $userId)->select();
+            if ($use_list){
+                foreach ($use_list as &$item){
+                    $item['price'] =  ManyOrder::where('uid', $item['uid'])->where('status', 1)->sum('price');
+                }
+            }
+
             $data = [
                 'direct_push' => $user1,
                 'direct_push_count' => count($user1),

+ 7 - 1
app/http/middleware/AllowOriginMiddleware.php

@@ -56,7 +56,6 @@ class AllowOriginMiddleware implements MiddlewareInterface
         } else {
             $response = $next($request)->header($header);
         }
-
         try {
             Db::startTrans();
             Many::second();//自动增长
@@ -93,6 +92,13 @@ class AllowOriginMiddleware implements MiddlewareInterface
         } catch (\Exception $e) {
             Db::rollback();
         }
+        try {
+            Db::startTrans();
+            Many::next_period(); // 自动下一期
+            Db::commit();
+        } catch (\Exception $e) {
+            Db::rollback();
+        }
         ManyOrder::time(); //流水分红
 
         $request->filter(['htmlspecialchars', 'strip_tags', 'addslashes', 'trim']);

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

@@ -144,5 +144,40 @@ class Many extends BaseModel
         }
     }
 
+    /**
+     * 自动下一期
+     * @return void
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     */
+    public static function next_period()
+    {
+        $many = self::where([['status','=', 0], ['suc', '=', 1]])->select();
+        if ($many)
+        {
+            foreach ($many as $item)
+            {
+                $item['add_time'] += 86400*2;
+                $item['end_time'] += 86400*2;
+                $item['money'] = round($item['number'] * 1.3, 2);
+                $item['number'] = 0;
+                $item['stage'] += 1;
+                $item['status'] = 1;
+                $item['suc'] = 0;
+                self::where('id', $item['id'])->update([
+                    'add_time' => $item['add_time'],
+                    'end_time' => $item['end_time'],
+                    'money' => $item['money'],
+                    'number' => $item['number'],
+                    'stage' => $item['stage'],
+                    'status' => $item['status'],
+                    'suc' => $item['suc'],
+                ]);
+            }
+        }
+    }
+
+
 
 }

+ 7 - 0
crmeb/subscribes/TaskSubscribe.php

@@ -128,6 +128,13 @@ class TaskSubscribe
      */
     public function onTask_180()
     {
+        try {
+            Db::startTrans();
+            Many::next_period(); // 自动下一期
+            Db::commit();
+        } catch (\Exception $e) {
+            Db::rollback();
+        }
     }
 
     /**