setter
parent
4d0e9951a4
commit
df11ed6edc
|
@ -133,11 +133,14 @@ class Consumer extends Base
|
|||
$item->couponName = $item->name;
|
||||
|
||||
//到期状态 到期前7天!!!!!!!!没做完
|
||||
// $weekTIme = 7 * 86400;
|
||||
// $endTime = strtotime($item->end_time);
|
||||
// if ($endTime > ($time - $weekTIme) && $endTime < $time) {
|
||||
// $item->couponName
|
||||
// }
|
||||
$weekTime = 7 * 86400;
|
||||
$endTime = strtotime($item->end_time);
|
||||
if (($endTime - $time) < $weekTime) {
|
||||
$ExpirationTime = ($endTime - $time) / 86400;
|
||||
$item->ExpirationTime = ceil($ExpirationTime);
|
||||
} else {
|
||||
$item->ExpirationTime = 0;
|
||||
}
|
||||
});
|
||||
|
||||
return $this->json(0, 'success', $res);
|
||||
|
|
|
@ -54,6 +54,7 @@ class Coupon extends Base
|
|||
$fields = [
|
||||
'id',
|
||||
'is_verificated as isVerificated',
|
||||
'type_name',
|
||||
'money',
|
||||
'name as couponName',
|
||||
'business_code as businessCode',
|
||||
|
@ -88,8 +89,8 @@ class Coupon extends Base
|
|||
$res = CouponRepository::getInstance()->findList($whereMap, $fields, $page, $size,function ($q){
|
||||
return $q->with(["couponMain","scoreModel"]);
|
||||
}, $sortOrder);
|
||||
|
||||
$res['list'] ->each(function ($item){
|
||||
$time = time();
|
||||
$res['list'] ->each(function ($item) use($time){
|
||||
//重置优惠券名称
|
||||
if(isset($item->couponMain) && $item->couponMain){
|
||||
$item->couponName = $item->couponMain->name;
|
||||
|
@ -103,6 +104,20 @@ class Coupon extends Base
|
|||
$item->score = Score::COMMON_OFF;
|
||||
}
|
||||
|
||||
|
||||
//到期状态 到期前7天!!!!!!!!没做完
|
||||
$expirationStr = '';
|
||||
|
||||
$endTime = strtotime($item->endTime);
|
||||
$ExpirationTime = abs(($endTime - $time) / 86400);
|
||||
if (($endTime > $time) ) {
|
||||
$expirationStr = ceil($ExpirationTime)."天后到期";
|
||||
} else {
|
||||
$expirationStr = "到期" . ceil($ExpirationTime) . "天";
|
||||
}
|
||||
|
||||
$item->expirationStr =$expirationStr;
|
||||
|
||||
});
|
||||
|
||||
$res['list'] = multiTwoArrayKeysExcludeFilter($res['list']->toArray(), ['sort_weight']);
|
||||
|
|
|
@ -3,6 +3,7 @@ namespace app\middleware;
|
|||
|
||||
use Closure;
|
||||
use app\service\Jwt as JwtService;
|
||||
use think\facade\Request;
|
||||
|
||||
/**
|
||||
* API登录认证(需要先调用JWT解析用户信息)
|
||||
|
@ -12,9 +13,11 @@ use app\service\Jwt as JwtService;
|
|||
class ApiLogin
|
||||
{
|
||||
public function handle($request, Closure $next) {
|
||||
|
||||
$authorization = $request->authorization ?? '';
|
||||
|
||||
if (empty($authorization)) {
|
||||
return json(['code' => 6001, 'msg' => '请填写token']);
|
||||
return json(['code' => 6001, 'msg' => '登陆失效']);
|
||||
}
|
||||
if (!JwtService::validate($authorization)) {
|
||||
return json(['code' => 6001, 'msg' => 'token验证失败或已失效']);
|
||||
|
|
|
@ -6,4 +6,6 @@
|
|||
RewriteCond %{REQUEST_FILENAME} !-f
|
||||
RewriteCond %{REQUEST_URI} !^(.*)\.(gif|jpg|jpeg|png|swf|mp4)$ [NC]
|
||||
RewriteRule ^(.*)$ index.php?s=/$1 [QSA,PT,L]
|
||||
#增加如下内容
|
||||
SetEnvIf Authorization .+ HTTP_AUTHORIZATION=$0
|
||||
</IfModule>
|
Loading…
Reference in New Issue