123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170 |
- <?php
- namespace App\Http\Controllers\Share;
- use App\Http\Controllers\Controller;
- use App\Http\Controllers\Core\Auth;
- use App\Models\Share\FlowerListModel;
- use App\Services\Share\FlowerService;
- use Illuminate\Http\Request;
- class FlowerController extends Controller
- {
- /**
- * 最近10个成功的气泡
- */
- public function bannerlist()
- {
- $fs = new FlowerService();
- $data = $fs->bannerlist();
- return array(
- 'code' => 200,
- 'message' => 'success',
- 'data' => $data
- );
- }
- public function succlist(Request $request)
- {
- $uid = Auth::auth();
- $page = $request->get('page') ?? 1;
- $pages = array(
- 'limit' => 20,
- 'page' => $page
- );
- $fs = new FlowerService();
- $data = $fs->susslist($uid, $pages);
- return array(
- 'code' => 200,
- 'message' => 'success',
- 'data' => $data
- );
- }
- public function faillist(Request $request)
- {
- $uid = Auth::auth();
- $page = $request->get('page') ?? 1;
- $pages = array(
- 'limit' => 20,
- 'page' => $page
- );
- $fs = new FlowerService();
- $data = $fs->faillist($uid, $pages);
- return array(
- 'code' => 200,
- 'message' => 'success',
- 'data' => $data
- );
- }
- /**
- * 检验助力小花红包
- * @param int $list_id
- * @return array
- * @throws \Throwable
- * @throws \Tymon\JWTAuth\Exceptions\JWTException
- */
- public function check(int $list_id)
- {
- $uid = Auth::auth();
- $fs = new FlowerService();
- $data = $fs->check($uid, $list_id);
- return array(
- 'code' => 200,
- 'message' => 'success',
- 'data' => $data
- );
- }
- public function store()
- {
- $uid = Auth::auth();
- $listModel = new FlowerListModel();
- $data = $listModel->where([
- ['uid', $uid],
- ['completeness', '<', 100],
- ['expired_at', '>', time()]
- ])->first();
- if (collect($data)->isEmpty()) {
- $fs = new FlowerService();
- $data = $fs->store($uid);
- $data['get_fee'] = (string)sprintf('%.2f', $data['fee'] * $data['completeness'] / 100);
- return array(
- 'code' => 200,
- 'message' => 'success',
- 'data' => $data
- );
- } else {
- $data['get_fee'] = (string)sprintf('%.2f', $data['fee'] * $data['completeness'] / 100);
- return array(
- 'code' => 200,
- 'message' => 'success',
- 'data' => $data
- );
- }
- }
- public function get(int $list_id)
- {
- $fs = new FlowerService();
- $data = $fs->get($list_id);
- return array(
- 'code' => 200,
- 'message' => 'success',
- 'data' => $data
- );
- }
- /**
- * 某人正在进行的现金红包
- */
- public function ing()
- {
- $uid = Auth::auth();
- $fs = new FlowerService();
- $data = $fs->ing($uid);
- return array(
- 'code' => 200,
- 'message' => 'success',
- 'data' => $data
- );
- }
- /**
- * 上一个小花红包
- */
- public function latest()
- {
- $uid = Auth::auth();
- $fs = new FlowerService();
- $data = $fs->latest($uid);
- return array(
- 'code' => 200,
- 'message' => 'success',
- 'data' => $data
- );
- }
- /**
- * 切换通知
- * @param int $list_id
- * @return array
- * @throws \App\Exceptions\AlertException
- * @throws \Tymon\JWTAuth\Exceptions\JWTException
- */
- public function notice(int $list_id)
- {
- $uid = Auth::auth();
- $rs = new FlowerService();
- if ($rs->notice($uid, $list_id)) {
- return array(
- 'code' => 200,
- 'message' => 'success'
- );
- } else {
- throw new ApiException("系统异常", 500);
- }
- }
- }
|