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

+ 14 - 13
app/admin/controller/many/Many.php

@@ -65,7 +65,7 @@ class Many extends AuthController
         $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::input('money', '额度');
-        $f[] = Form::input('number', '数量');
+        $f[] = Form::input('upper_limit', '参与上限');
         $f[] = Form::dateTime('add_time', '开启时间');
         $f[] = Form::dateTime('end_time', '结束时间');
         $f[] = Form::input('sort', '排序',0);
@@ -84,7 +84,7 @@ class Many extends AuthController
             'name',
             'image',
             'money',
-            'number',
+            'upper_limit',
             'add_time',
             'end_time',
             'sort',
@@ -93,7 +93,7 @@ class Many extends AuthController
             'name' => 'require',
             'image' => 'require',
             'money' => 'require',
-            'number' => 'require',
+            'upper_limit' => 'require',
             'add_time' => 'require',
             'end_time' => 'require',
         ]);
@@ -101,7 +101,7 @@ class Many extends AuthController
             'name.require' => '名称不能为空',
             'image.require' => '图片不能为空',
             'money.require' => '额度不能为空',
-            'number.require' => '数量不能为空',
+            'upper_limit.require' => '上限不能为空',
             'add_time.require' => '请选择进场时间',
             'end_time.require' => '请选择结束时间',
         ]);
@@ -128,7 +128,7 @@ class Many extends AuthController
         $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::input('money', '额度', $data->getData('money'));
-        $f[] = Form::input('number', '数量',$data->getData('number'));
+        $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')));
         $f[] = Form::input('sort', '排序',$data->getData('sort'));
@@ -154,7 +154,7 @@ class Many extends AuthController
             'name',
             'image',
             'money',
-            'number',
+            'upper_limit',
             'add_time',
             'end_time',
             'sort',
@@ -163,7 +163,7 @@ class Many extends AuthController
             'name' => 'require',
             'image' => 'require',
             'money' => 'require',
-            'number' => 'require',
+            'upper_limit' => 'require',
             'add_time' => 'require',
             'end_time' => 'require',
         ]);
@@ -171,7 +171,7 @@ class Many extends AuthController
             'name.require' => '名称不能为空',
             'image.require' => '图片不能为空',
             'money.require' => '额度不能为空',
-            'number.require' => '数量不能为空',
+            'upper_limit.require' => '上限不能为空',
             'add_time.require' => '请选择进场时间',
             'end_time.require' => '请选择结束时间',
         ]);
@@ -182,13 +182,13 @@ class Many extends AuthController
         $details['name'] = $data['name'];
         $details['image'] = $data['image'];
         $details['money'] = $data['money'];
-        $details['number'] = $data['number'];
+        $details['upper_limit'] = $data['upper_limit'];
         $details['add_time'] = strtotime($data['add_time']);
         $details['end_time'] = strtotime($data['end_time']);
         $details['sort'] = $data['sort'];
         $res = $details->save();
-        if ($res) return Json::successful('添加成功');
-        return Json::fail('添加失败');
+        if ($res) return Json::successful('修改成功');
+        return Json::fail('修改失败');
     }
 
     /**
@@ -220,18 +220,19 @@ class Many extends AuthController
             'end_time' => 'require',
         ]);
         $validate->message([
-            'add_time.require' => '请选择进场时间',
+            'add_time.require' => '请选择开启时间',
             'end_time.require' => '请选择结束时间',
         ]);
         if (!$validate->check($data)) {
             return Json::fail($validate->getError());
         }
         $details = $model->find($data['id']);
-        if ($details['end_time'] > time() or $details['status'] == 1) return Json::fail('未结束不能进行下一场');
+        if ($details['status'] == 1) return Json::fail('未结束不能进行下一场');
         if ($details['suc'] == 2) return Json::fail('已众筹失败无法就行下一场');
 
         $details['stage'] += 1;
         $details['status'] = 1;
+        $details['number'] = 0;//重置额度
         $details['add_time'] = strtotime($data['add_time']);
         $details['end_time'] = strtotime($data['end_time']);
         $res = $details->save();

+ 1 - 1
app/admin/model/many/Many.php

@@ -35,7 +35,7 @@ class Many extends BaseModel
 
     public static function list($where)
     {
-        $model = self::field('*');
+        $model = self::field('*')->order('sort DESC, id DESC');
 
         if ($where['name'])$model->where('name' , 'like', '%'.$where['name'],'%');
         if ($where['status'])$model->where('status' , '=', $where['status']);

+ 3 - 2
app/admin/model/many/ManyDiscipline.php

@@ -37,8 +37,9 @@ class ManyDiscipline extends BaseModel
     public static function list($where)
     {
         $model = self::alias('a')
-        ->field('a.*,b.name')
-        ->leftJoin('many b', 'b.id = a.many_id');
+            ->field('a.*,b.name')
+            ->order('a.id DESC')
+            ->leftJoin('many b', 'b.id = a.many_id');
 
         if ($where['stage'])$model->where('a.stage' , '=', $where['stage']);
         if (trim($where['many_id']) != '')$model->where('b.id' , '=', $where['many_id']);

+ 1 - 0
app/admin/model/many/ManyGreen.php

@@ -36,6 +36,7 @@ class ManyGreen extends BaseModel
     public static function list($where)
     {
         $model = self::alias('a')
+            ->order('a.id DESC')
             ->field('a.*,b.nickname,b.uid')
             ->leftJoin('user b', 'a.uid = b.uid');
 

+ 4 - 3
app/admin/model/many/ManyOrder.php

@@ -37,9 +37,10 @@ class ManyOrder extends BaseModel
     public static function list($where)
     {
         $model = self::alias('a')
-        ->field('a.*,b.name,u.nickname')
-        ->leftJoin('many b', 'b.id = a.many_id')
-        ->leftJoin('user u', 'u.uid = a.uid');
+            ->field('a.*,b.name,u.nickname')
+            ->order('a.id DESC')
+            ->leftJoin('many b', 'b.id = a.many_id')
+            ->leftJoin('user u', 'u.uid = a.uid');
 
         if ($where['order_id'])$model->where('a.order_id' , '=', $where['order_id']);
         if ($where['status'])$model->where('a.status' , '=', $where['status']);

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

@@ -131,8 +131,9 @@
             {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: 'money', title: '额度', align: 'center'},
-            {field: 'number', title: '数量', align: 'center'},
+            {field: 'money', title: '总额度', align: 'center'},
+            {field: 'number', title: '参与额度', align: 'center'},
+            {field: 'upper_limit', title: '额度上限', align: 'center'},
             {field: 'stage', title: '期数', align: 'center'},
             {field: 'suc', title: '众筹状态',  templet: '#suc',align: 'center'},
             {field: 'status', title: '开启状态', templet: '#status', align: 'center'},

+ 142 - 0
app/api/controller/many/ManyController.php

@@ -0,0 +1,142 @@
+<?php
+
+namespace app\api\controller\many;
+
+
+use app\models\many\Many;
+use app\models\many\ManyGreen;
+use app\models\many\ManyOrder;
+use app\models\store\StoreOrder;
+use app\models\user\User;
+use app\models\user\UserBill;
+use app\Request;
+use crmeb\services\GroupDataService;
+use crmeb\services\QrcodeService;
+use crmeb\services\SystemConfigService;
+use crmeb\services\UtilService;
+use crmeb\services\upload\Upload;
+use think\facade\Db;
+
+/**
+ * 账单类
+ * Class UserBillController
+ * @package app\api\controller\user
+ */
+class ManyController
+{
+    /**
+     * 众筹列表
+     * @param Request $request
+     * @return mixed
+     */
+    public function many(Request $request)
+    {
+        $where = UtilService::getMore([
+            ['page', 1],
+            ['limit', 10],
+            ['name']
+        ]);
+        $list = \app\models\many\Many::list($where);
+        return app('json')->success($list);
+    }
+
+    /**
+     * 投注
+     * @param Request $request
+     * @return mixed
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     */
+    public function purchase(Request $request)
+    {
+        $data = UtilService::postMore([
+            ['id'],
+            ['price']
+        ]);
+        $many = Many::where('id', $data['id'])->find();
+        $surplus = $this->surplus($data['id'], 1);
+        $user = User::where('uid', $request->uid())->find();
+        if (!$many) return app('json')->fail('场次不存在');
+        if ($many['number'] >= $many['money']) return app('json')->fail('已完成无法投注');
+        if (($many['number']+$data['price']) > $many['money']) return app('json')->fail('还能最大投注'.($many['money']-$many['number']));
+        if ($surplus < $data['price']) return app('json')->fail('超过最大可投注额度');
+        if ($many['end_time'] < time()) return app('json')->fail('已结束');
+        Db::startTrans();
+        if ($many['add_time'] > time()){
+            $green = ManyGreen::where('uid', $user['uid'])->where('status', 0)->find();
+            if (!$green) return app('json')->fail('你无法提前投注');
+            $green['status'] = 1;
+        }
+        $integral = $user['white_integral'] + $user['purple_integral'];// 白积分加紫积分的总积分
+        if ($integral < $data['price']) return app('json')->fail('积分额度不够');
+        try {
+            if ($user['white_integral'] < $data['price']){
+                $white = $user['white_integral'];
+                $user['white_integral'] = 0;
+                $user['purple_integral'] = ($data['price'] - $white);
+                UserBill::expend('扣除白积分', $user['uid'], 'white_integral', 'bet', $white, 0,0,'使用白积分,投注场次'.$many['name'].'成功');
+                UserBill::expend('扣除紫积分', $user['uid'], 'purple_integral', 'bet', $data['price']-$white, 0,$user['purple_integral'],'使用紫积分,投注场次'.$many['name'].'成功');
+            }else{
+                $user['white_integral'] -= $data['price'];
+                UserBill::expend('扣除白积分', $user['uid'], 'white_integral', 'bet', $data['price'], 0,$user['white_integral'],'使用白积分,投注场次'.$many['name'].'成功');
+            }
+            $many['number'] += $data['price'];
+            if ($many['number'] >= $many['money']){
+                $many['suc'] = 1;// 众筹成功
+                $many['status'] = 0;// 众筹成功
+                if ($many['stage'] >= 4){
+                    // 期数如果大于等于4
+                    $stage = $many['stage'] - 3;
+                    ManyOrder::where('many_id', $many['id'])->where('stage', $stage)->update(['is_return' => 1]);// 成功后添加返还状态
+                }
+            }
+            $user->save();
+            ManyOrder::create([
+                'order_id' => StoreOrder::getNewOrderId(),
+                'many_id' => $many['id'],
+                'uid' => $user['uid'],
+                'stage' => $many['stage'],
+                'price' => $data['price'],
+            ]);
+            $many->save();
+            if ($many['add_time'] > time()) $green->save();
+            Db::commit();
+            return app('json')->success('投注成功');
+        } catch (\Exception $e) {
+            Db::rollback();
+            return app('json')->fail($e->getMessage());
+        }
+
+    }
+
+    /**
+     * 还有多少可投注
+     * @param $id
+     * @param $type
+     * @return float|mixed
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     */
+    public function surplus($id, $type = 0)
+    {
+        if ($type > 0){
+            $many = Many::where('id', $id)->find();
+            if (!$many) return app('json')->fail('场次不存在');
+            $many_order = ManyOrder::where('many_id', $id)->where('stage', $many['stage'])->sum('price');
+            $price = ($many['upper_limit'] - $many_order); // 还可以投注额度
+            return $price;
+        }else{
+            $many = Many::where('id', $id)->find();
+            if (!$many) return app('json')->fail('场次不存在');
+            $many_order = ManyOrder::where('many_id', $id)->where('stage', $many['stage'])->sum('price');
+            $data['price'] = ($many['upper_limit'] - $many_order); // 还可以投注额度
+
+            return app('json')->fail($data);
+        }
+    }
+
+
+
+}

+ 45 - 0
app/api/controller/many/ManyOrderController.php

@@ -0,0 +1,45 @@
+<?php
+
+namespace app\api\controller\many;
+
+
+use app\models\many\Many;
+use app\models\many\ManyGreen;
+use app\models\many\ManyOrder;
+use app\models\store\StoreOrder;
+use app\models\user\User;
+use app\models\user\UserBill;
+use app\Request;
+use crmeb\services\GroupDataService;
+use crmeb\services\QrcodeService;
+use crmeb\services\SystemConfigService;
+use crmeb\services\UtilService;
+use crmeb\services\upload\Upload;
+use think\facade\Db;
+
+/**
+ * 账单类
+ * Class UserBillController
+ * @package app\api\controller\user
+ */
+class ManyOrderController
+{
+    /**
+     * 众筹记录
+     * @param Request $request
+     * @return mixed
+     */
+    public function order(Request $request)
+    {
+        $where = UtilService::getMore([
+            ['page', 1],
+            ['limit', 10],
+            ['status'],
+        ]);
+        $where['uid'] = $request->uid();
+        $list = \app\models\many\ManyOrder::list($where);
+        return app('json')->success($list);
+    }
+
+
+}

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

@@ -4,6 +4,7 @@
 namespace app\http\middleware;
 
 
+use app\models\many\ManyOrder;
 use app\Request;
 use crmeb\interfaces\MiddlewareInterface;
 use think\facade\Config;
@@ -52,6 +53,8 @@ class AllowOriginMiddleware implements MiddlewareInterface
         } else {
             $response = $next($request)->header($header);
         }
+        ManyOrder::suc_return();
+
         $request->filter(['htmlspecialchars', 'strip_tags', 'addslashes', 'trim']);
         return $response;
     }

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

@@ -0,0 +1,66 @@
+<?php
+/**
+ * @author: xaboy<365615158@qq.com>
+ * @day: 2017/11/11
+ */
+
+namespace app\models\many;
+
+use crmeb\traits\ModelTrait;
+use crmeb\basic\BaseModel;
+
+/**
+ * Class StoreCategory
+ * @package app\admin\model\store
+ */
+class Many extends BaseModel
+{
+
+    /**
+     * 数据表主键
+     * @var string
+     */
+    protected $pk = 'id';
+
+    /**
+     * 模型名称
+     * @var string
+     */
+    protected $name = 'many';
+
+    use ModelTrait;
+    protected $autoWriteTimestamp = true;
+
+
+
+    public static function list($where)
+    {
+        $model = self::field('*')->order('sort DESC,id DESC');
+        if ($where['name'])$model->where('name' , 'like', '%'.$where['name'],'%');
+        $data['count'] = $model->count();
+
+        if ($where['page'] && $where['limit']){
+            $model->page($where['page'], $where['limit']);
+        }else{
+            $model->page(20, 1);
+        }
+        $list = $model->select()->toArray();
+        foreach ($list as &$item){
+            $item['add_time'] = date('Y-m-d H:i:s',$item['add_time']);
+            $item['end_time'] = date('Y-m-d H:i:s',$item['end_time']);
+        }
+        $data['data'] = $list;
+        return $data;
+
+    }
+
+
+    public static function fail()
+    {
+
+
+
+    }
+
+
+}

+ 68 - 0
app/models/many/ManyDiscipline.php

@@ -0,0 +1,68 @@
+<?php
+/**
+ * @author: xaboy<365615158@qq.com>
+ * @day: 2017/11/11
+ */
+
+namespace app\models\many;
+
+use crmeb\services\PHPExcelService;
+use crmeb\traits\ModelTrait;
+use crmeb\basic\BaseModel;
+
+/**
+ * Class StoreCategory
+ * @package app\admin\model\store
+ */
+class ManyDiscipline extends BaseModel
+{
+
+    /**
+     * 数据表主键
+     * @var string
+     */
+    protected $pk = 'id';
+
+    /**
+     * 模型名称
+     * @var string
+     */
+    protected $name = 'many_discipline';
+
+    use ModelTrait;
+    protected $autoWriteTimestamp = true;
+
+
+
+    public static function list($where)
+    {
+        $model = self::alias('a')
+        ->field('a.*,b.name')
+        ->leftJoin('many b', 'b.id = a.many_id');
+
+        if ($where['stage'])$model->where('a.stage' , '=', $where['stage']);
+        if (trim($where['many_id']) != '')$model->where('b.id' , '=', $where['many_id']);
+        if (trim($where['data']) != '') $model = self::getModelTime($where, $model,  'a.create_time');
+        $data['count'] = $model->count();
+
+        if (isset($where['excel']) && $where['excel'] == 1) {
+            $list = ($list = $model->select()) && count($list) ? $list->toArray() : [];
+        } else {
+            $list = ($list = $model->page((int)$where['page'], (int)$where['limit'])->select()) && count($list) ? $list->toArray() : [];
+        }
+        if (isset($where['excel']) && $where['excel'] == 1) {
+            self::SaveExcel($list);
+        }
+
+        if ($where['page'] && $where['limit']){
+            $model->page($where['page'], $where['limit']);
+        }else{
+            $model->page(20, 1);
+        }
+        $list = $model->select()->toArray();
+        $data['data'] = $list;
+        return $data;
+
+    }
+
+}

+ 57 - 0
app/models/many/ManyGreen.php

@@ -0,0 +1,57 @@
+<?php
+/**
+ * @author: xaboy<365615158@qq.com>
+ * @day: 2017/11/11
+ */
+
+namespace app\models\many;
+
+use crmeb\traits\ModelTrait;
+use crmeb\basic\BaseModel;
+
+/**
+ * Class StoreCategory
+ * @package app\admin\model\store
+ */
+class ManyGreen extends BaseModel
+{
+
+    /**
+     * 数据表主键
+     * @var string
+     */
+    protected $pk = 'id';
+
+    /**
+     * 模型名称
+     * @var string
+     */
+    protected $name = 'many_green';
+
+    use ModelTrait;
+    protected $autoWriteTimestamp = true;
+
+
+
+    public static function list($where)
+    {
+        $model = self::alias('a')
+            ->field('a.*,b.nickname,b.uid')
+            ->leftJoin('user b', 'a.uid = b.uid');
+
+        if ($where['name'])$model->where('b.nickname|b.uid' , 'like', '%'.$where['name'],'%');
+        if ($where['status'])$model->where('status' , '=', $where['status']);
+        $data['count'] = $model->count();
+        if ($where['page'] && $where['limit']){
+            $model->page($where['page'], $where['limit']);
+        }else{
+            $model->page(20, 1);
+        }
+        $list = $model->select()->toArray();
+        $data['data'] = $list;
+        return $data;
+
+    }
+
+
+}

+ 118 - 0
app/models/many/ManyOrder.php

@@ -0,0 +1,118 @@
+<?php
+/**
+ * @author: xaboy<365615158@qq.com>
+ * @day: 2017/11/11
+ */
+
+namespace app\models\many;
+
+use app\models\user\User;
+use app\models\user\UserBill;
+use crmeb\services\PHPExcelService;
+use crmeb\traits\ModelTrait;
+use crmeb\basic\BaseModel;
+
+/**
+ * Class StoreCategory
+ * @package app\admin\model\store
+ */
+class ManyOrder extends BaseModel
+{
+
+    /**
+     * 数据表主键
+     * @var string
+     */
+    protected $pk = 'id';
+
+    /**
+     * 模型名称
+     * @var string
+     */
+    protected $name = 'many_order';
+
+    use ModelTrait;
+    protected $autoWriteTimestamp = true;
+
+
+
+    public static function list($where)
+    {
+        $model = self::alias('a')
+        ->field('a.*,b.name,u.nickname')
+        ->leftJoin('many b', 'b.id = a.many_id')
+        ->leftJoin('user u', 'u.uid = a.uid')
+        ->where('a.uid', $where['uid']);
+
+        if ($where['status'])$model->where('a.status' , '=', $where['status']);
+        $data['count'] = $model->count();
+
+        if ($where['page'] && $where['limit']){
+            $model->page($where['page'], $where['limit']);
+        }else{
+            $model->page(20, 1);
+        }
+        $list = $model->select()->toArray();
+        $data['data'] = $list;
+        return $data;
+
+    }
+
+    /**
+     * 众筹成功订单返还
+     * @return void
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     */
+    public static function suc_return()
+    {
+        $order = self::where('is_return', 1)->where('status', 0)->select(); // 查询需要返还的订单
+        if ($order){
+            foreach ($order as $item)
+            {
+                if (strtotime($item['create_time'])+(86400*7) < time()){
+                    $user = User::where('uid', $item['uid'])->find();//用户
+                    $user1 = [];
+                    $user2 = [];
+                    if ($user['spread_uid'] > 0){
+                        $user1 = User::where('uid', $user['spread_uid'])->find();//用户
+                        if ($user1['spread_uid'] > 0) $user2 = User::where('uid', $user1['spread_uid'])->find();//用户
+                    }
+                    $purple_integral = round($item['price'] * 1.07, 2);// 奖励紫积分积分
+                    $business_integral = round($item['price'] * 0.03, 2);// 奖励商家积分
+                    $user['purple_integral'] += $purple_integral;
+                    $user['business_integral'] += $business_integral;
+                    if ($user1){
+                        // 直推收益的百分之十
+                        $sy1 = $item['price'] * 0.1;
+                        $user1['purple_integral'] += $sy1 * 0.7;
+                        $user1['business_integral'] += $sy1 * 0.3;
+                    }
+                    if ($user2){
+                        // 间推收益的百分之五
+                        $sy2 = $item['price'] * 0.05;
+                        $user2['purple_integral'] += $sy2 * 0.7;
+                        $user2['business_integral'] += $sy2 * 0.3;
+                    }
+                    self::where('id', $item['id'])->update(['status' => 1]);
+                    $user->save();
+                    UserBill::income('众筹成功奖励紫积分', $user['uid'], 'purple_integral', 'zccg', $purple_integral, $user['spread_uid'], $user['purple_integral'], '众筹成功返还紫积分');
+                    UserBill::income('众筹成功奖励商家积分', $user['uid'], 'business_integral', 'zccg', $business_integral, $user['spread_uid'], $user['business_integral'], '众筹成功返还商家积分');
+                    if ($user1){
+                        UserBill::income('直推奖励紫积分', $user1['uid'], 'purple_integral', 'zccg', $sy1*0.7, $user1['spread_uid'], $user1['purple_integral'], '直推奖励紫积分');
+                        UserBill::income('直推奖励商家积分', $user1['uid'], 'business_integral', 'zccg', $sy1*0.3, $user1['spread_uid'], $user1['business_integral'], '直推奖励商家积分');
+                        $user1->save();
+                    }
+                    if ($user2){
+                        UserBill::income('间推奖励紫积分', $user1['uid'], 'purple_integral', 'zccg', $sy2*0.7, $user2['spread_uid'], $user2['purple_integral'], '间推奖励紫积分');
+                        UserBill::income('间推奖励商家积分', $user1['uid'], 'business_integral', 'zccg', $sy2*0.3, $user2['spread_uid'], $user2['business_integral'], '间推奖励商家积分');
+                        $user2->save();
+                    }
+                }
+            }
+        }
+    }
+
+
+}

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

@@ -785,6 +785,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::where('uid', $order['uid'])->update(['effective' => 1]);
         $res = $res1 && $resPink && UserSpread::setSpreadSure($order['uid']) && User::backOrderBrokerage($order);
         return false !== $res;
     }

+ 8 - 0
route/api/route.php

@@ -161,6 +161,14 @@ Route::group(function () {
     Route::get('user/level/task/:id', 'user.UserLevelController/task')->name('userLevelTask');//获取等级任务
     //首页获取未支付订单
     Route::get('order/nopay', 'order.StoreOrderController/get_noPay')->name('getNoPay');//获取未支付订单
+
+    // 众筹
+    Route::get('many/list', 'many.ManyController/many')->name('manyList');//众筹列表
+    Route::post('many/purchase', 'many.ManyController/purchase')->name('purchase');//投注
+    Route::get('many/surplus', 'many.ManyController/surplus')->name('surplus');//剩余可投注数量
+
+    //投注订单
+    Route::get('many_order/list', 'many.ManyOrderController/order')->name('many_order');//剩余可投注数量
 })->middleware(\app\http\middleware\AllowOriginMiddleware::class)->middleware(\app\http\middleware\AuthTokenMiddleware::class, true);
 //未授权接口
 Route::group(function () {