&$value) { $currentHour = date('H'); $activityEndHour = bcadd((int)$value['time'], (int)$value['continued'], 0); if ($activityEndHour > 24) { $value['time'] = strlen((int)$value['time']) == 2 ? (int)$value['time'] . ':00' : '0' . (int)$value['time'] . ':00'; $value['state'] = '即将开始'; $value['status'] = 2; $value['stop'] = (int)bcadd(strtotime(date('Y-m-d')), bcmul($activityEndHour, 3600, 0)); } else { if ($currentHour >= (int)$value['time'] && $currentHour < $activityEndHour) { $value['time'] = strlen((int)$value['time']) == 2 ? (int)$value['time'] . ':00' : '0' . (int)$value['time'] . ':00'; $value['state'] = '抢购中'; $value['stop'] = (int)bcadd(strtotime(date('Y-m-d')), bcmul($activityEndHour, 3600, 0)); $value['status'] = 1; if (!$seckillTimeIndex) $seckillTimeIndex = $key; } else if ($currentHour < (int)$value['time']) { $value['time'] = strlen((int)$value['time']) == 2 ? (int)$value['time'] . ':00' : '0' . (int)$value['time'] . ':00'; $value['state'] = '即将开始'; $value['status'] = 2; $value['stop'] = (int)bcadd(strtotime(date('Y-m-d')), bcmul($activityEndHour, 3600, 0)); } else if ($currentHour >= $activityEndHour) { $value['time'] = strlen((int)$value['time']) == 2 ? (int)$value['time'] . ':00' : '0' . (int)$value['time'] . ':00'; $value['state'] = '已结束'; $value['status'] = 0; $value['stop'] = (int)bcadd(strtotime(date('Y-m-d')), bcmul($activityEndHour, 3600, 0)); } } } } $data['lovely'] = sys_config('seckill_header_banner'); if (strstr($data['lovely'], 'http') === false && strlen(trim($data['lovely']))) $data['lovely'] = sys_config('site_url') . $data['lovely']; $data['lovely'] = str_replace('\\', '/', $data['lovely']); $data['seckillTime'] = $seckillTime; $data['seckillTimeIndex'] = $seckillTimeIndex; $data['seckillCont'] = StoreWholesale::getWholeContStatus(); return app('json')->successful($data); } /** * 秒杀产品列表 * @param Request $request * @param $time * @return mixed * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException */ public function lst(Request $request, $time) { list($page, $limit) = UtilService::getMore([ ['page', 0], ['limit', 0], ], $request, true); if (!$time) return app('json')->fail('参数错误'); $seckillInfo = StoreWholesale::WholeList($time, $page, $limit); if (count($seckillInfo)) { foreach ($seckillInfo as $key => &$item) { } } return app('json')->successful($seckillInfo); } /** * 秒杀产品详情 * @param Request $request * @param $id * @return mixed */ public function detail(Request $request, $id, $time = 0, $status = 1) { $storeInfo = StoreWholesale::getValidProduct($id); if ($storeInfo) $storeInfo = $storeInfo->hidden(['cost', 'add_time', 'is_del'])->toArray(); else $storeInfo = []; if (!$id || !$storeInfo) return app('json')->fail('商品不存在或已下架!'); $siteUrl = sys_config('site_url'); $storeInfo['image'] = set_file_url($storeInfo['image'], $siteUrl); $storeInfo['image_base'] = set_file_url($storeInfo['image'], $siteUrl); $storeInfo['code_base'] = QrcodeService::getWechatQrcodePath($id . '_seckill_detail_wap.jpg', '/activity/seckill_detail/' . $id . '/' . $time . '/' .$status); $uid = $request->uid(); $storeInfo['uid'] = $uid; $data['storeInfo'] = $storeInfo; $user = $request->user(); $data['isSeckillEnd'] = StoreWholesale::checkStatus($id); return app('json')->successful($data); } /** * 预约 * @param Request $request */ public function reserve(Request $request) { list($package_manager,$price,$day,$proportion,$pass) = UtilService::postMore( [ ['package_manager',0], ['price',0], ['day',0], ['proportion',0], ['pass',0] ],$request,true ); if($package_manager==0) return app('json')->fail('包编号错误'); if($price==0) return app('json')->fail('价值不能为空'); if($day==0) return app('json')->fail('收益天数错误'); if($proportion==0) return app('json')->fail('收益比例不能为空'); $rs = Package::reserve($request->uid(),$package_manager,$price,$day,$proportion,$pass); if($rs) { return app('json')->successful($rs); } else { return app('json')->fail(Package::getErrorInfo()); } } /** * 新人批发 * @param Request $request */ public function news(Request $request) { return app('json')->successful(StoreWholesale::where('is_news',1)->where('is_del',0)->where('is_show',1)->select()->toArray()); } }