Compare commits

...

2 Commits

Author SHA1 Message Date
wangxinglong 504c48c71c setter 2021-12-20 10:24:29 +08:00
wangxinglong df11ed6edc setter 2021-12-20 10:14:32 +08:00
4 changed files with 50 additions and 9 deletions

View File

@ -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);

View File

@ -54,9 +54,12 @@ class Coupon extends Base
$fields = [
'id',
'is_verificated as isVerificated',
'type_name',
'money',
'name as couponName',
'business_code',
'business_code as businessCode',
'coupon_id',
'end_time as endTime',
'consumer_name as consumerName',
'verificate_time as verificateTime',
@ -86,13 +89,16 @@ class Coupon extends Base
}
$res = CouponRepository::getInstance()->findList($whereMap, $fields, $page, $size,function ($q){
return $q->with(["couponMain","scoreModel"]);
return $q->with(["couponMain","scoreModel","business"]);
}, $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;
$item->image_url = $item->couponMain->image_url;
}else{
$item->image_url = '';
}
//是否已经打分过了
if(isset($item->scoreModel) && $item->scoreModel){
@ -103,6 +109,33 @@ class Coupon extends Base
$item->score = Score::COMMON_OFF;
}
//到期状态
$expirationStr = '';
$endTime = strtotime($item->endTime);
$ExpirationTime = abs(($endTime - $time) / 86400);
if (($endTime > $time) ) {
$expirationStr = ceil($ExpirationTime)."天后到期";
} else {
$expirationStr = "到期" . ceil($ExpirationTime) . "";
}
$item->expirationStr =$expirationStr;
//商家简称
if(!empty($item->business)){
$item->business_subtitle = $item->business->business_subtitle;
}else{
$item->business_subtitle = '';
}
//图片
if(!empty($item->business)){
$item->business_subtitle = $item->business->business_subtitle;
}else{
$item->business_subtitle = '';
}
});
$res['list'] = multiTwoArrayKeysExcludeFilter($res['list']->toArray(), ['sort_weight']);

View File

@ -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验证失败或已失效']);

View File

@ -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>