master
wangxinglong 2021-12-20 10:14:32 +08:00
parent 4d0e9951a4
commit df11ed6edc
4 changed files with 31 additions and 8 deletions

View File

@ -133,11 +133,14 @@ class Consumer extends Base
$item->couponName = $item->name; $item->couponName = $item->name;
//到期状态 到期前7天!!!!!!!!没做完 //到期状态 到期前7天!!!!!!!!没做完
// $weekTIme = 7 * 86400; $weekTime = 7 * 86400;
// $endTime = strtotime($item->end_time); $endTime = strtotime($item->end_time);
// if ($endTime > ($time - $weekTIme) && $endTime < $time) { if (($endTime - $time) < $weekTime) {
// $item->couponName $ExpirationTime = ($endTime - $time) / 86400;
// } $item->ExpirationTime = ceil($ExpirationTime);
} else {
$item->ExpirationTime = 0;
}
}); });
return $this->json(0, 'success', $res); return $this->json(0, 'success', $res);

View File

@ -54,6 +54,7 @@ class Coupon extends Base
$fields = [ $fields = [
'id', 'id',
'is_verificated as isVerificated', 'is_verificated as isVerificated',
'type_name',
'money', 'money',
'name as couponName', 'name as couponName',
'business_code as businessCode', 'business_code as businessCode',
@ -88,8 +89,8 @@ class Coupon extends Base
$res = CouponRepository::getInstance()->findList($whereMap, $fields, $page, $size,function ($q){ $res = CouponRepository::getInstance()->findList($whereMap, $fields, $page, $size,function ($q){
return $q->with(["couponMain","scoreModel"]); return $q->with(["couponMain","scoreModel"]);
}, $sortOrder); }, $sortOrder);
$time = time();
$res['list'] ->each(function ($item){ $res['list'] ->each(function ($item) use($time){
//重置优惠券名称 //重置优惠券名称
if(isset($item->couponMain) && $item->couponMain){ if(isset($item->couponMain) && $item->couponMain){
$item->couponName = $item->couponMain->name; $item->couponName = $item->couponMain->name;
@ -103,6 +104,20 @@ class Coupon extends Base
$item->score = Score::COMMON_OFF; $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']); $res['list'] = multiTwoArrayKeysExcludeFilter($res['list']->toArray(), ['sort_weight']);

View File

@ -3,6 +3,7 @@ namespace app\middleware;
use Closure; use Closure;
use app\service\Jwt as JwtService; use app\service\Jwt as JwtService;
use think\facade\Request;
/** /**
* API登录认证需要先调用JWT解析用户信息 * API登录认证需要先调用JWT解析用户信息
@ -12,9 +13,11 @@ use app\service\Jwt as JwtService;
class ApiLogin class ApiLogin
{ {
public function handle($request, Closure $next) { public function handle($request, Closure $next) {
$authorization = $request->authorization ?? ''; $authorization = $request->authorization ?? '';
if (empty($authorization)) { if (empty($authorization)) {
return json(['code' => 6001, 'msg' => '请填写token']); return json(['code' => 6001, 'msg' => '登陆失效']);
} }
if (!JwtService::validate($authorization)) { if (!JwtService::validate($authorization)) {
return json(['code' => 6001, 'msg' => 'token验证失败或已失效']); return json(['code' => 6001, 'msg' => 'token验证失败或已失效']);

View File

@ -6,4 +6,6 @@
RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !^(.*)\.(gif|jpg|jpeg|png|swf|mp4)$ [NC] RewriteCond %{REQUEST_URI} !^(.*)\.(gif|jpg|jpeg|png|swf|mp4)$ [NC]
RewriteRule ^(.*)$ index.php?s=/$1 [QSA,PT,L] RewriteRule ^(.*)$ index.php?s=/$1 [QSA,PT,L]
#增加如下内容
SetEnvIf Authorization .+ HTTP_AUTHORIZATION=$0
</IfModule> </IfModule>