更新代码
This commit is contained in:
56
app/Api/Controllers/FullController.php
Normal file
56
app/Api/Controllers/FullController.php
Normal file
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: sunny
|
||||
* Date: 2019/2/23
|
||||
* Time: 2:10 PM
|
||||
*/
|
||||
|
||||
namespace App\Api\Controllers;
|
||||
|
||||
|
||||
use Carbon\Carbon;
|
||||
use RuLong\Order\Models\Order;
|
||||
use RuLong\UserAccount\Models\UserAccountLog;
|
||||
use App\User;
|
||||
|
||||
class FullController extends Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
// $this->middleware('auth.api');
|
||||
// $this->user = \Auth::guard('api')->user();
|
||||
// $this->uid = \Auth::guard('api')->id();
|
||||
$this->user = User::find(824);
|
||||
$this->uid = 824;
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户满仓任务完成信息接口,小程序访问满仓页面时请求该接口。
|
||||
* @param
|
||||
* @return array
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$isfull = $this->user->account->act_a > 0 ? true : false;//是否满仓
|
||||
$fullOrder = Order::where(['user_id' => $this->uid, 'item_type' => 'FULL_GIFT'])->whereRaw('substring(cast(status as char),1,1) = 1')->first();//满仓订单
|
||||
$canCreateOrder = !$fullOrder && $isfull ? true : false;//是否可以创建满仓订单
|
||||
$log = UserAccountLog::where('user_id', $this->uid)->where('rule_id', 4)->orderBy('id', 'asc')->first();//完成时间
|
||||
$finished_share_num = $this->user->identity->childrentime([Carbon::today()->toDateTimeString(), Carbon::tomorrow()->toDateTimeString()]);//完成数量
|
||||
return [
|
||||
'data' => [
|
||||
'isfull' => $isfull,
|
||||
'finished_share_num' => $finished_share_num,
|
||||
'unfinished_share_num' => $finished_share_num >= 10 ? 0 : 10 - $finished_share_num,
|
||||
'finished_at' => $log->created_at ?? '',
|
||||
'fullOrder' => [
|
||||
'canCreateOrder' => $canCreateOrder,
|
||||
'order_id' => $fullOrder->id ?? '',
|
||||
],
|
||||
],
|
||||
'status' => 'SUCCESS',
|
||||
'status_code' => 200,
|
||||
];
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user