123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125 |
- <?php
- namespace app\api\controller\user;
- use app\admin\model\order\StoreOrder;
- use app\models\system\SystemGroupData;
- use app\models\user\Out;
- use app\models\user\User;
- use app\models\user\UserPartake;
- use app\Request;
- use crmeb\services\GroupDataService;
- use crmeb\services\SystemConfigService;
- use crmeb\services\UtilService;
- use think\facade\Db;
- class UserPartakeController
- {
- /**
- * 出局奖励列表
- * @return void
- */
- public function out_list(Request $request)
- {
- [$page, $limit] = UtilService::getMore([['page', 1], ['limit', 10]], $request, true);
- $list = Out::where('status', 1)->where($page, $limit)->order('id DESC')->select()->toArray();
- return app('json')->success($list);
- }
- /**
- * 出局奖励列表
- * @return void
- */
- public function out_detail($id, Request $request)
- {
- $list = Out::where('status', 1)->where('id', $id)->order('id DESC')->find();
- $partake = UserPartake::where('uid', $request->uid())->where('status', 0)->find();
- $list['partake'] = $partake;
- $list = $list ? $list->toArray() : [];
- return app('json')->success($list);
- }
- /**
- * 参加
- * @return void
- */
- public function participate_in(Request $request)
- {
- $data = UtilService::postMore([
- 'out_id'
- ]);
- Db::startTrans();
- $user = User::where('uid', $request->uid())->find();
- if ($user['level'] < 2) return app('json')->fail('等级为团队合伙人才能参与');
- $out = Out::where('id', $data['out_id'])->find();
- if (empty($out)) return app('json')->fail('参与项目不存在');
- if ($out['status'] == 0) return app('json')->fail('参与项目已关闭');
- $partake = UserPartake::where('uid', $request->uid())->where('status', 0)->find();
- if ($partake) return app('json')->fail('当前已有参与中项目,无法参加');
- $res = UserPartake::create([
- 'uid' => $request->uid(),
- 'out_id' => $data['out_id'],
- ]);
- if ($res) {
- Db::commit();
- return app('json')->success('参与成功');
- } else {
- Db::rollback();
- return app('json')->fail('参与失败');
- }
- }
- /**
- * 参与记录
- * @param Request $request
- * @return mixed
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\DbException
- * @throws \think\db\exception\ModelNotFoundException
- */
- public function partake(Request $request)
- {
- $where = UtilService::getMore([
- ['page', 1],
- ['limit', 20],
- ]);
- $data = UserPartake::alias('a')
- ->field('a.*,c.name,c.number')
- ->order('a.id DESC')
- ->leftJoin('out c', 'c.id = a.out_id')
- ->where('uid', $request->uid())
- ->page($where['page'], $where['limit'])
- ->select();
- $data = count($data) ? $data->toArray() : [];
- foreach ($data as &$item) {
- if ($item['money'] == 0) {
- $item['money'] = User::where('uid', $item['uid'])->find()['pay_price'];
- }
- }
- return app('json')->success($data);
- }
- public function user_push_list(Request $request)
- {
- $where = UtilService::getMore([
- ['page', 1],
- ['limit', 20],
- ['uid'],
- ['spread_uid']
- ]);
- $where['spread_uid'] = $request->uid();
- $data = StoreOrder::list($where);
- return app('json')->success($data);
- }
- }
|