mirror of
https://github.com/crmeb/CRMEB.git
synced 2025-12-10 17:42:50 +00:00
调整H5二维码统一由一个方法生成
This commit is contained in:
parent
a4dc1b3602
commit
fdec995129
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller\activity;
|
||||
|
||||
use app\admin\model\system\SystemAttachment;
|
||||
@ -7,6 +8,7 @@ use app\models\store\StoreCombination;
|
||||
use app\models\store\StorePink;
|
||||
use app\models\store\StoreProductReply;
|
||||
use app\Request;
|
||||
use crmeb\services\QrcodeService;
|
||||
use crmeb\services\SystemConfigService;
|
||||
use crmeb\services\UploadService;
|
||||
use crmeb\services\UtilService;
|
||||
@ -27,12 +29,12 @@ class StoreCombinationController
|
||||
public function lst(Request $request)
|
||||
{
|
||||
list($page, $limit) = UtilService::getMore([
|
||||
['page',1],
|
||||
['limit',10],
|
||||
],$request, true);
|
||||
['page', 1],
|
||||
['limit', 10],
|
||||
], $request, true);
|
||||
$combinationList = StoreCombination::getAll($page, $limit);
|
||||
if(!count($combinationList)) return app('json')->successful([]);
|
||||
return app('json')->successful($combinationList->hidden(['info','product_id','images','mer_id','attr','sort','stock','sales','add_time','is_del','is_show','browse','cost','is_show','start_time','stop_time','description','postage','is_postage','is_host','mer_use','combination'])->toArray());
|
||||
if (!count($combinationList)) return app('json')->successful([]);
|
||||
return app('json')->successful($combinationList->hidden(['info', 'product_id', 'images', 'mer_id', 'attr', 'sort', 'stock', 'sales', 'add_time', 'is_del', 'is_show', 'browse', 'cost', 'is_show', 'start_time', 'stop_time', 'description', 'postage', 'is_postage', 'is_host', 'mer_use', 'combination'])->toArray());
|
||||
}
|
||||
|
||||
|
||||
@ -44,49 +46,33 @@ class StoreCombinationController
|
||||
*/
|
||||
public function detail(Request $request, $id)
|
||||
{
|
||||
if(!$id || !($combinationOne = StoreCombination::getCombinationOne($id))) return app('json')->fail('拼团不存在或已下架');
|
||||
$combinationOne = $combinationOne->hidden(['mer_id','attr','sort','add_time','is_host','is_show','is_del','mer_use','cost','combination'])->toArray();
|
||||
$combinationOne['images'] = json_decode($combinationOne['images'],true);
|
||||
list($pink ,$pindAll)= StorePink::getPinkAll($id,true);//拼团列表
|
||||
//公众号
|
||||
$name = $id.'_combination_detail_wap.jpg';
|
||||
$imageInfo = SystemAttachment::getInfo($name,'name');
|
||||
if (!$id || !($combinationOne = StoreCombination::getCombinationOne($id))) return app('json')->fail('拼团不存在或已下架');
|
||||
$combinationOne = $combinationOne->hidden(['mer_id', 'attr', 'sort', 'add_time', 'is_host', 'is_show', 'is_del', 'mer_use', 'cost', 'combination'])->toArray();
|
||||
$combinationOne['images'] = json_decode($combinationOne['images'], true);
|
||||
list($pink, $pindAll) = StorePink::getPinkAll($id, true);//拼团列表
|
||||
$siteUrl = sysConfig('site_url');
|
||||
if(!$imageInfo){
|
||||
$codeUrl = UtilService::setHttpType($siteUrl.'/activity/group_detail/'.$id, 1);//二维码链接
|
||||
$imageInfo = UtilService::getQRCodePath($codeUrl, $name);
|
||||
if(is_array($imageInfo)){
|
||||
SystemAttachment::attachmentAdd($imageInfo['name'],$imageInfo['size'],$imageInfo['type'],$imageInfo['dir'],$imageInfo['thumb_path'],1,$imageInfo['image_type'],$imageInfo['time'],2);
|
||||
$url = $imageInfo['dir'];
|
||||
}else {
|
||||
$url = '';
|
||||
$imageInfo = ['image_type'=>0];
|
||||
}
|
||||
}else $url = $imageInfo['att_dir'];
|
||||
if($imageInfo['image_type'] == 1)
|
||||
$url = $siteUrl.$url;
|
||||
$combinationOne['image'] = UtilService::setSiteUrl($combinationOne['image'], $siteUrl);
|
||||
$combinationOne['image_base'] = UtilService::setSiteUrl($combinationOne['image'], $siteUrl);
|
||||
$combinationOne['code_base'] = $url;
|
||||
$combinationOne['code_base'] = QrcodeService::getWechatQrcodePath($id . '_combination_detail_wap.jpg', '/activity/group_detail/' . $id);
|
||||
$combinationOne['sale_stock'] = 0;
|
||||
if($combinationOne['stock'] > 0) $combinationOne['sale_stock'] = 1;
|
||||
if(!strlen(trim($combinationOne['unit_name']))) $combinationOne['unit_name'] = '个';
|
||||
if ($combinationOne['stock'] > 0) $combinationOne['sale_stock'] = 1;
|
||||
if (!strlen(trim($combinationOne['unit_name']))) $combinationOne['unit_name'] = '个';
|
||||
$uid = $request->uid();
|
||||
$data['pink'] = $pink;
|
||||
$data['pindAll'] = $pindAll;
|
||||
$data['storeInfo'] = $combinationOne;
|
||||
$data['pink_ok_list']=StorePink::getPinkOkList($uid);
|
||||
$data['pink_ok_sum']=StorePink::getPinkOkSumTotalNum($id);
|
||||
$data['pink_ok_list'] = StorePink::getPinkOkList($uid);
|
||||
$data['pink_ok_sum'] = StorePink::getPinkOkSumTotalNum($id);
|
||||
$data['reply'] = StoreProductReply::getRecProductReply($combinationOne['product_id']);
|
||||
$data['replyCount'] = StoreProductReply::productValidWhere()->where('product_id',$combinationOne['product_id'])->count();
|
||||
if($data['replyCount']){
|
||||
$goodReply=StoreProductReply::productValidWhere()->where('product_id',$combinationOne['product_id'])->where('product_score',5)->count();
|
||||
$data['replyCount'] = StoreProductReply::productValidWhere()->where('product_id', $combinationOne['product_id'])->count();
|
||||
if ($data['replyCount']) {
|
||||
$goodReply = StoreProductReply::productValidWhere()->where('product_id', $combinationOne['product_id'])->where('product_score', 5)->count();
|
||||
$data['replyChance'] = $goodReply;
|
||||
if($goodReply){
|
||||
$data['replyChance'] = bcdiv($goodReply,$data['replyCount'],2);
|
||||
$data['replyChance'] = bcmul($data['replyChance'],100,3);
|
||||
if ($goodReply) {
|
||||
$data['replyChance'] = bcdiv($goodReply, $data['replyCount'], 2);
|
||||
$data['replyChance'] = bcmul($data['replyChance'], 100, 3);
|
||||
}
|
||||
}else $data['replyChance']=0;
|
||||
} else $data['replyChance'] = 0;
|
||||
return app('json')->successful($data);
|
||||
}
|
||||
|
||||
@ -102,52 +88,52 @@ class StoreCombinationController
|
||||
$userBool = 0;//判断当前用户是否在团内 0未在 1在
|
||||
$pinkBool = 0;//判断拼团是否成功 0未在 1在
|
||||
$user = $request->user();
|
||||
if(!$id) return app('json')->fail('参数错误');
|
||||
if (!$id) return app('json')->fail('参数错误');
|
||||
$pink = StorePink::getPinkUserOne($id);
|
||||
if(!$pink) return app('json')->fail('参数错误');
|
||||
if(isset($pink['is_refund']) && $pink['is_refund']) {
|
||||
if($pink['is_refund'] != $pink['id']){
|
||||
if (!$pink) return app('json')->fail('参数错误');
|
||||
if (isset($pink['is_refund']) && $pink['is_refund']) {
|
||||
if ($pink['is_refund'] != $pink['id']) {
|
||||
$id = $pink['is_refund'];
|
||||
return $this->pink($request,$id);
|
||||
}else{
|
||||
return $this->pink($request, $id);
|
||||
} else {
|
||||
return app('json')->fail('订单已退款');
|
||||
}
|
||||
}
|
||||
list($pinkAll,$pinkT,$count,$idAll,$uidAll) = StorePink::getPinkMemberAndPinkK($pink);
|
||||
if($pinkT['status'] == 2){
|
||||
list($pinkAll, $pinkT, $count, $idAll, $uidAll) = StorePink::getPinkMemberAndPinkK($pink);
|
||||
if ($pinkT['status'] == 2) {
|
||||
$pinkBool = 1;
|
||||
$is_ok = 1;
|
||||
}else if($pinkT['status'] == 3){
|
||||
} else if ($pinkT['status'] == 3) {
|
||||
$pinkBool = -1;
|
||||
$is_ok = 0;
|
||||
}else{
|
||||
if($count < 1){//组团完成
|
||||
} else {
|
||||
if ($count < 1) {//组团完成
|
||||
$is_ok = 1;
|
||||
$pinkBool = StorePink::PinkComplete($uidAll,$idAll,$user['uid'],$pinkT);
|
||||
}else{
|
||||
$pinkBool = StorePink::PinkFail($pinkAll,$pinkT,$pinkBool);
|
||||
$pinkBool = StorePink::PinkComplete($uidAll, $idAll, $user['uid'], $pinkT);
|
||||
} else {
|
||||
$pinkBool = StorePink::PinkFail($pinkAll, $pinkT, $pinkBool);
|
||||
}
|
||||
}
|
||||
if(!empty($pinkAll)){
|
||||
foreach ($pinkAll as $v){
|
||||
if($v['uid'] == $user['uid']) $userBool = 1;
|
||||
if (!empty($pinkAll)) {
|
||||
foreach ($pinkAll as $v) {
|
||||
if ($v['uid'] == $user['uid']) $userBool = 1;
|
||||
}
|
||||
}
|
||||
if($pinkT['uid'] == $user['uid']) $userBool = 1;
|
||||
if ($pinkT['uid'] == $user['uid']) $userBool = 1;
|
||||
$combinationOne = StoreCombination::getCombinationOne($pink['cid']);
|
||||
if(!$combinationOne) return app('json')->fail('拼团不存在或已下架');
|
||||
if (!$combinationOne) return app('json')->fail('拼团不存在或已下架');
|
||||
$data['userInfo']['uid'] = $user['uid'];
|
||||
$data['userInfo']['nickname'] = $user['nickname'];
|
||||
$data['userInfo']['avatar'] = $user['avatar'];
|
||||
$data['is_ok'] = $is_ok;
|
||||
$data['userBool'] = $userBool;
|
||||
$data['pinkBool'] = $pinkBool;
|
||||
$data['store_combination'] = $combinationOne->hidden(['mer_id','images','attr','info','sort','sales','stock','add_time','is_host','is_show','is_del','combination','mer_use','is_postage','postage','description','start_time','stop_time','cost','browse','product_price'])->toArray();
|
||||
$data['store_combination'] = $combinationOne->hidden(['mer_id', 'images', 'attr', 'info', 'sort', 'sales', 'stock', 'add_time', 'is_host', 'is_show', 'is_del', 'combination', 'mer_use', 'is_postage', 'postage', 'description', 'start_time', 'stop_time', 'cost', 'browse', 'product_price'])->toArray();
|
||||
$data['pinkT'] = $pinkT;
|
||||
$data['pinkAll'] = $pinkAll;
|
||||
$data['count'] = $count <= 0 ? 0 : $count;
|
||||
$data['store_combination_host'] = StoreCombination::getCombinationHost();
|
||||
$data['current_pink_order'] = StorePink::getCurrentPink($id,$user['uid']);
|
||||
$data['current_pink_order'] = StorePink::getCurrentPink($id, $user['uid']);
|
||||
return app('json')->successful($data);
|
||||
}
|
||||
|
||||
@ -159,16 +145,16 @@ class StoreCombinationController
|
||||
public function remove(Request $request)
|
||||
{
|
||||
list($id, $cid) = UtilService::postMore([
|
||||
['id',0],
|
||||
['cid',0],
|
||||
],$request, true);
|
||||
if(!$id || !$cid) return app('json')->fail('缺少参数');
|
||||
$res = StorePink::removePink($request->uid(),$cid,$id);
|
||||
if($res){
|
||||
['id', 0],
|
||||
['cid', 0],
|
||||
], $request, true);
|
||||
if (!$id || !$cid) return app('json')->fail('缺少参数');
|
||||
$res = StorePink::removePink($request->uid(), $cid, $id);
|
||||
if ($res) {
|
||||
return app('json')->successful('取消成功');
|
||||
}
|
||||
$error = StorePink::getErrorInfo();
|
||||
if(is_array($error)) return app('json')->status($error['status'],$error['msg']);
|
||||
if (is_array($error)) return app('json')->status($error['status'], $error['msg']);
|
||||
return app('json')->fail($error);
|
||||
}
|
||||
|
||||
@ -180,70 +166,70 @@ class StoreCombinationController
|
||||
*/
|
||||
public function poster(Request $request)
|
||||
{
|
||||
list($pinkId, $from) = UtilService::postMore([['id',0],['from','wechat']],$request,true);
|
||||
if(!$pinkId) return app('json')->fail('参数错误');
|
||||
list($pinkId, $from) = UtilService::postMore([['id', 0], ['from', 'wechat']], $request, true);
|
||||
if (!$pinkId) return app('json')->fail('参数错误');
|
||||
$user = $request->user();
|
||||
$pinkInfo = StorePink::getPinkUserOne($pinkId);
|
||||
$storeCombinationInfo = StoreCombination::getCombinationOne($pinkInfo['cid']);
|
||||
$data['title'] = $storeCombinationInfo['title'];
|
||||
$data['image'] = $storeCombinationInfo['image'];
|
||||
$data['price'] = $pinkInfo['total_price'];
|
||||
$data['label'] = $pinkInfo['people'].'人团';
|
||||
if($pinkInfo['k_id']) $pinkAll = StorePink::getPinkMember($pinkInfo['k_id']);
|
||||
$data['label'] = $pinkInfo['people'] . '人团';
|
||||
if ($pinkInfo['k_id']) $pinkAll = StorePink::getPinkMember($pinkInfo['k_id']);
|
||||
else $pinkAll = StorePink::getPinkMember($pinkInfo['id']);
|
||||
$count = count($pinkAll)+1;
|
||||
$data['msg'] = '原价¥'.$storeCombinationInfo['product_price'].' 还差'.(int)bcsub((int)$pinkInfo['people'],$count,0).'人拼团成功';
|
||||
try{
|
||||
$count = count($pinkAll) + 1;
|
||||
$data['msg'] = '原价¥' . $storeCombinationInfo['product_price'] . ' 还差' . (int)bcsub((int)$pinkInfo['people'], $count, 0) . '人拼团成功';
|
||||
try {
|
||||
$siteUrl = sysConfig('site_url');
|
||||
if($from == 'routine'){
|
||||
if ($from == 'routine') {
|
||||
//小程序
|
||||
$name = $pinkId.'_'.$user['uid'].'_'.$user['is_promoter'].'_pink_share_routine.jpg';
|
||||
$imageInfo = SystemAttachment::getInfo($name,'name');
|
||||
if(!$imageInfo){
|
||||
$valueData = 'id='.$pinkId;
|
||||
if($user['is_promoter'] || sysConfig('store_brokerage_statu')==2) $valueData.='&pid='.$user['uid'];
|
||||
$res = RoutineCode::getPageCode('pages/activity/goods_combination_status/index',$valueData,280);
|
||||
if(!$res) return app('json')->fail('二维码生成失败');
|
||||
$imageInfo = UploadService::instance()->setUploadPath('routine/activity/pink/code')->imageStream($name,$res);
|
||||
if(!is_array($imageInfo)) return app('json')->fail($imageInfo);
|
||||
if($imageInfo['image_type'] == 1) $remoteImage = UtilService::remoteImage($siteUrl.$imageInfo['dir']);
|
||||
$name = $pinkId . '_' . $user['uid'] . '_' . $user['is_promoter'] . '_pink_share_routine.jpg';
|
||||
$imageInfo = SystemAttachment::getInfo($name, 'name');
|
||||
if (!$imageInfo) {
|
||||
$valueData = 'id=' . $pinkId;
|
||||
if ($user['is_promoter'] || sysConfig('store_brokerage_statu') == 2) $valueData .= '&pid=' . $user['uid'];
|
||||
$res = RoutineCode::getPageCode('pages/activity/goods_combination_status/index', $valueData, 280);
|
||||
if (!$res) return app('json')->fail('二维码生成失败');
|
||||
$imageInfo = UploadService::instance()->setUploadPath('routine/activity/pink/code')->imageStream($name, $res);
|
||||
if (!is_array($imageInfo)) return app('json')->fail($imageInfo);
|
||||
if ($imageInfo['image_type'] == 1) $remoteImage = UtilService::remoteImage($siteUrl . $imageInfo['dir']);
|
||||
else $remoteImage = UtilService::remoteImage($imageInfo['dir']);
|
||||
if(!$remoteImage['status']) return app('json')->fail($remoteImage['msg']);
|
||||
SystemAttachment::attachmentAdd($imageInfo['name'],$imageInfo['size'],$imageInfo['type'],$imageInfo['dir'],$imageInfo['thumb_path'],1,$imageInfo['image_type'],$imageInfo['time'],2);
|
||||
if (!$remoteImage['status']) return app('json')->fail($remoteImage['msg']);
|
||||
SystemAttachment::attachmentAdd($imageInfo['name'], $imageInfo['size'], $imageInfo['type'], $imageInfo['dir'], $imageInfo['thumb_path'], 1, $imageInfo['image_type'], $imageInfo['time'], 2);
|
||||
$url = $imageInfo['dir'];
|
||||
}else $url = $imageInfo['att_dir'];
|
||||
} else $url = $imageInfo['att_dir'];
|
||||
$data['url'] = $url;
|
||||
if($imageInfo['image_type'] == 1)
|
||||
$data['url'] = $siteUrl.$url;
|
||||
$posterImage = UtilService::setShareMarketingPoster($data,'routine/activity/pink/poster');
|
||||
if(!is_array($posterImage)) return app('json')->fail('海报生成失败');
|
||||
SystemAttachment::attachmentAdd($posterImage['name'],$posterImage['size'],$posterImage['type'],$posterImage['dir'],$posterImage['thumb_path'],1,$posterImage['image_type'],$posterImage['time'],2);
|
||||
if($posterImage['image_type'] == 1) $posterImage['dir'] = $siteUrl.$posterImage['dir'];
|
||||
if ($imageInfo['image_type'] == 1)
|
||||
$data['url'] = $siteUrl . $url;
|
||||
$posterImage = UtilService::setShareMarketingPoster($data, 'routine/activity/pink/poster');
|
||||
if (!is_array($posterImage)) return app('json')->fail('海报生成失败');
|
||||
SystemAttachment::attachmentAdd($posterImage['name'], $posterImage['size'], $posterImage['type'], $posterImage['dir'], $posterImage['thumb_path'], 1, $posterImage['image_type'], $posterImage['time'], 2);
|
||||
if ($posterImage['image_type'] == 1) $posterImage['dir'] = $siteUrl . $posterImage['dir'];
|
||||
$routinePosterImage = UtilService::setHttpType($posterImage['dir'], 0);//小程序推广海报
|
||||
return app('json')->successful(['url'=>$routinePosterImage]);
|
||||
}else if($from == 'wechat'){
|
||||
return app('json')->successful(['url' => $routinePosterImage]);
|
||||
} else if ($from == 'wechat') {
|
||||
//公众号
|
||||
$name = $pinkId.'_'.$user['uid'].'_'.$user['is_promoter'].'_pink_share_wap.jpg';
|
||||
$imageInfo = SystemAttachment::getInfo($name,'name');
|
||||
if(!$imageInfo){
|
||||
$codeUrl = UtilService::setHttpType($siteUrl.'/activity/group_rule/'.$pinkId.'?spread='.$user['uid'], 1);//二维码链接
|
||||
$name = $pinkId . '_' . $user['uid'] . '_' . $user['is_promoter'] . '_pink_share_wap.jpg';
|
||||
$imageInfo = SystemAttachment::getInfo($name, 'name');
|
||||
if (!$imageInfo) {
|
||||
$codeUrl = UtilService::setHttpType($siteUrl . '/activity/group_rule/' . $pinkId . '?spread=' . $user['uid'], 1);//二维码链接
|
||||
$imageInfo = UtilService::getQRCodePath($codeUrl, $name);
|
||||
if(!$imageInfo) return app('json')->fail('二维码生成失败');
|
||||
SystemAttachment::attachmentAdd($imageInfo['name'],$imageInfo['size'],$imageInfo['type'],$imageInfo['dir'],$imageInfo['thumb_path'],1,$imageInfo['image_type'],$imageInfo['time'],2);
|
||||
if (!$imageInfo) return app('json')->fail('二维码生成失败');
|
||||
SystemAttachment::attachmentAdd($imageInfo['name'], $imageInfo['size'], $imageInfo['type'], $imageInfo['dir'], $imageInfo['thumb_path'], 1, $imageInfo['image_type'], $imageInfo['time'], 2);
|
||||
$url = $imageInfo['dir'];
|
||||
}else $url = $imageInfo['att_dir'];
|
||||
} else $url = $imageInfo['att_dir'];
|
||||
$data['url'] = $url;
|
||||
if($imageInfo['image_type'] == 1) $data['url'] = $siteUrl.$url;
|
||||
$posterImage = UtilService::setShareMarketingPoster($data,'wap/activity/pink/poster');
|
||||
if(!is_array($posterImage)) return app('json')->fail('海报生成失败');
|
||||
SystemAttachment::attachmentAdd($posterImage['name'],$posterImage['size'],$posterImage['type'],$posterImage['dir'],$posterImage['thumb_path'],1,$posterImage['image_type'],$posterImage['time'],2);
|
||||
if($posterImage['image_type'] == 1) $posterImage['dir'] = $siteUrl.$posterImage['dir'];
|
||||
if ($imageInfo['image_type'] == 1) $data['url'] = $siteUrl . $url;
|
||||
$posterImage = UtilService::setShareMarketingPoster($data, 'wap/activity/pink/poster');
|
||||
if (!is_array($posterImage)) return app('json')->fail('海报生成失败');
|
||||
SystemAttachment::attachmentAdd($posterImage['name'], $posterImage['size'], $posterImage['type'], $posterImage['dir'], $posterImage['thumb_path'], 1, $posterImage['image_type'], $posterImage['time'], 2);
|
||||
if ($posterImage['image_type'] == 1) $posterImage['dir'] = $siteUrl . $posterImage['dir'];
|
||||
$wapPosterImage = UtilService::setHttpType($posterImage['dir'], 1);//公众号推广海报
|
||||
return app('json')->successful(['url'=>$wapPosterImage]);
|
||||
return app('json')->successful(['url' => $wapPosterImage]);
|
||||
}
|
||||
return app('json')->fail('参数错误');
|
||||
}catch (\Exception $e){
|
||||
return app('json')->fail(['line'=>$e->getLine(),'message'=>$e->getMessage()]);
|
||||
} catch (\Exception $e) {
|
||||
return app('json')->fail(['line' => $e->getLine(), 'message' => $e->getMessage()]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller\activity;
|
||||
|
||||
use app\admin\model\system\SystemAttachment;
|
||||
@ -7,6 +8,7 @@ use app\models\store\StoreProductReply;
|
||||
use app\models\store\StoreSeckill;
|
||||
use app\Request;
|
||||
use crmeb\services\GroupDataService;
|
||||
use crmeb\services\QrcodeService;
|
||||
use crmeb\services\SystemConfigService;
|
||||
use crmeb\services\UtilService;
|
||||
|
||||
@ -29,39 +31,39 @@ class StoreSeckillController
|
||||
//秒杀时间段
|
||||
$seckillTime = GroupDataService::getData('routine_seckill_time') ?? [];
|
||||
$seckillTimeIndex = 0;
|
||||
if(count($seckillTime)){
|
||||
foreach($seckillTime as $key=>&$value){
|
||||
if (count($seckillTime)) {
|
||||
foreach ($seckillTime as $key => &$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';
|
||||
$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['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['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';
|
||||
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['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));
|
||||
$value['stop'] = (int)bcadd(strtotime(date('Y-m-d')), bcmul($activityEndHour, 3600, 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$data['lovely'] = sysConfig('seckill_header_banner');
|
||||
if(strstr($data['lovely'],'http') === false && strlen(trim($data['lovely']))) $data['lovely'] = sysConfig('site_url').$data['lovely'];
|
||||
$data['lovely'] = str_replace('\\','/',$data['lovely']);
|
||||
if (strstr($data['lovely'], 'http') === false && strlen(trim($data['lovely']))) $data['lovely'] = sysConfig('site_url') . $data['lovely'];
|
||||
$data['lovely'] = str_replace('\\', '/', $data['lovely']);
|
||||
$data['seckillTime'] = $seckillTime;
|
||||
$data['seckillTimeIndex'] = $seckillTimeIndex;
|
||||
return app('json')->successful($data);
|
||||
@ -79,18 +81,18 @@ class StoreSeckillController
|
||||
public function lst(Request $request, $time)
|
||||
{
|
||||
list($page, $limit) = UtilService::getMore([
|
||||
['page',0],
|
||||
['limit',0],
|
||||
],$request, true);
|
||||
if(!$time) return app('json')->fail('参数错误');
|
||||
['page', 0],
|
||||
['limit', 0],
|
||||
], $request, true);
|
||||
if (!$time) return app('json')->fail('参数错误');
|
||||
$timeInfo = GroupDataService::getDataNumber((int)$time);
|
||||
$activityEndHour = bcadd((int)$timeInfo['time'],(int)$timeInfo['continued'],0);
|
||||
$startTime = bcadd(strtotime(date('Y-m-d')),bcmul($timeInfo['time'],3600,0));
|
||||
$stopTime = bcadd(strtotime(date('Y-m-d')),bcmul($activityEndHour,3600,0));
|
||||
$activityEndHour = bcadd((int)$timeInfo['time'], (int)$timeInfo['continued'], 0);
|
||||
$startTime = bcadd(strtotime(date('Y-m-d')), bcmul($timeInfo['time'], 3600, 0));
|
||||
$stopTime = bcadd(strtotime(date('Y-m-d')), bcmul($activityEndHour, 3600, 0));
|
||||
$seckillInfo = StoreSeckill::seckillList($startTime, $stopTime, $page, $limit);
|
||||
if(count($seckillInfo)){
|
||||
foreach ($seckillInfo as $key=>&$item){
|
||||
$percent = (int)bcmul(bcdiv($item['sales'],bcadd($item['stock'],$item['sales'],0),2),100,0);
|
||||
if (count($seckillInfo)) {
|
||||
foreach ($seckillInfo as $key => &$item) {
|
||||
$percent = (int)bcmul(bcdiv($item['sales'], bcadd($item['stock'], $item['sales'], 0), 2), 100, 0);
|
||||
$item['percent'] = $percent ? $percent : 10;
|
||||
}
|
||||
}
|
||||
@ -103,38 +105,23 @@ class StoreSeckillController
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function detail(Request $request, $id,$time = 0){
|
||||
if(!$id || !($storeInfo = StoreSeckill::getValidProduct($id))) return app('json')->fail('商品不存在或已下架!');
|
||||
$storeInfo = $storeInfo->hidden(['cost','add_time','is_del'])->toArray();
|
||||
|
||||
//公众号
|
||||
$name = $id.'_seckill_detail_wap.jpg';
|
||||
$imageInfo = SystemAttachment::getInfo($name,'name');
|
||||
public function detail(Request $request, $id, $time = 0)
|
||||
{
|
||||
if (!$id || !($storeInfo = StoreSeckill::getValidProduct($id))) return app('json')->fail('商品不存在或已下架!');
|
||||
$storeInfo = $storeInfo->hidden(['cost', 'add_time', 'is_del'])->toArray();
|
||||
$siteUrl = sysConfig('site_url');
|
||||
if(!$imageInfo){
|
||||
$codeUrl = UtilService::setHttpType($siteUrl.'/activity/seckill_detail/'.$id.'/'.$time, 1);//二维码链接
|
||||
$imageInfo = UtilService::getQRCodePath($codeUrl, $name);
|
||||
if(is_array($imageInfo)){
|
||||
SystemAttachment::attachmentAdd($imageInfo['name'],$imageInfo['size'],$imageInfo['type'],$imageInfo['dir'],$imageInfo['thumb_path'],1,$imageInfo['image_type'],$imageInfo['time'],2);
|
||||
$url = $imageInfo['dir'];
|
||||
}else {
|
||||
$url = '';
|
||||
$imageInfo = ['image_type'=>0];
|
||||
}
|
||||
}else $url = $imageInfo['att_dir'];
|
||||
if($imageInfo['image_type'] == 1) $url = $siteUrl.$url;
|
||||
$storeInfo['image'] = UtilService::setSiteUrl($storeInfo['image'], $siteUrl);
|
||||
$storeInfo['image_base'] = UtilService::setSiteUrl($storeInfo['image'], $siteUrl);
|
||||
$storeInfo['code_base'] = $url;
|
||||
$storeInfo['code_base'] = QrcodeService::getWechatQrcodePath($id . '_seckill_detail_wap.jpg', '/activity/seckill_detail/' . $id . '/' . $time);
|
||||
$uid = $request->uid();
|
||||
$storeInfo['userLike'] = StoreProductRelation::isProductRelation($id, $uid, 'like', 'product_seckill');
|
||||
$storeInfo['like_num'] = StoreProductRelation::productRelationNum($id,'like','product_seckill');
|
||||
$storeInfo['userCollect'] = StoreProductRelation::isProductRelation($id, $uid,'collect','product_seckill');
|
||||
$storeInfo['like_num'] = StoreProductRelation::productRelationNum($id, 'like', 'product_seckill');
|
||||
$storeInfo['userCollect'] = StoreProductRelation::isProductRelation($id, $uid, 'collect', 'product_seckill');
|
||||
$storeInfo['uid'] = $uid;
|
||||
$data['storeInfo'] = $storeInfo;
|
||||
setView($uid,$id,$storeInfo['product_id'],'viwe');
|
||||
setView($uid, $id, $storeInfo['product_id'], 'viwe');
|
||||
$data['reply'] = StoreProductReply::getRecProductReply($storeInfo['product_id']);
|
||||
$data['replyCount'] = StoreProductReply::productValidWhere()->where('product_id',$storeInfo['product_id'])->count();
|
||||
$data['replyCount'] = StoreProductReply::productValidWhere()->where('product_id', $storeInfo['product_id'])->count();
|
||||
return app('json')->successful($data);
|
||||
}
|
||||
}
|
||||
@ -10,6 +10,7 @@ use app\models\store\StoreProductRelation;
|
||||
use app\models\store\StoreProductReply;
|
||||
use app\Request;
|
||||
use crmeb\services\GroupDataService;
|
||||
use crmeb\services\QrcodeService;
|
||||
use crmeb\services\SystemConfigService;
|
||||
use crmeb\services\UtilService;
|
||||
|
||||
@ -49,52 +50,46 @@ class StoreProductController
|
||||
*/
|
||||
public function code(Request $request, $id)
|
||||
{
|
||||
if (!$id || !($storeInfo = StoreProduct::getValidProduct($id,'id'))) return app('json')->fail('商品不存在或已下架');
|
||||
$userType = $request->get('user_type','wechat');
|
||||
if (!$id || !($storeInfo = StoreProduct::getValidProduct($id, 'id'))) return app('json')->fail('商品不存在或已下架');
|
||||
$userType = $request->get('user_type', 'wechat');
|
||||
$user = $request->user();
|
||||
try{
|
||||
switch ($userType){
|
||||
try {
|
||||
switch ($userType) {
|
||||
case 'wechat':
|
||||
//公众号
|
||||
$name = $id.'_product_detail_'.$user['uid'].'_is_promoter_'.$user['is_promoter'].'_wap.jpg';
|
||||
$imageInfo = SystemAttachment::getInfo($name,'name');
|
||||
$siteUrl = sysConfig('site_url');
|
||||
if(!$imageInfo){
|
||||
$codeUrl = UtilService::setHttpType($siteUrl.'/detail/'.$id.'?spread='.$user['uid'], 1);//二维码链接
|
||||
$imageInfo = UtilService::getQRCodePath($codeUrl, $name);
|
||||
if(is_string($imageInfo)) return app('json')->fail('二维码生成失败');
|
||||
SystemAttachment::attachmentAdd($imageInfo['name'],$imageInfo['size'],$imageInfo['type'],$imageInfo['dir'],$imageInfo['thumb_path'],1,$imageInfo['image_type'],$imageInfo['time'],2);
|
||||
$url = $imageInfo['dir'];
|
||||
}else $url = $imageInfo['att_dir'];
|
||||
if($imageInfo['image_type'] == 1) $url = $siteUrl.$url;
|
||||
return app('json')->successful(['code'=>UtilService::setImageBase64($url)]);
|
||||
$name = $id . '_product_detail_' . $user['uid'] . '_is_promoter_' . $user['is_promoter'] . '_wap.jpg';
|
||||
$url = QrcodeService::getWechatQrcodePath($name, '/detail/' . $id . '?spread=' . $user['uid']);
|
||||
if ($url === false)
|
||||
return app('json')->fail('二维码生成失败');
|
||||
else
|
||||
return app('json')->successful(['code' => UtilService::setImageBase64($url)]);
|
||||
break;
|
||||
case 'routine':
|
||||
//小程序
|
||||
$name = $id.'_'.$user['uid'].'_'.$user['is_promoter'].'_product.jpg';
|
||||
$imageInfo = SystemAttachment::getInfo($name,'name');
|
||||
$siteUrl = sysConfig('site_url').DS;
|
||||
if(!$imageInfo){
|
||||
$data='id='.$id;
|
||||
if($user['is_promoter'] || sysConfig('store_brokerage_statu')==2) $data.='&pid='.$user['uid'];
|
||||
$res = \app\models\routine\RoutineCode::getPageCode('pages/goods_details/index',$data,280);
|
||||
if(!$res) return app('json')->fail('二维码生成失败');
|
||||
$imageInfo = \crmeb\services\UploadService::instance()->setUploadPath('routine/product')->imageStream($name,$res);
|
||||
if(is_string($imageInfo)) return app('json')->fail($imageInfo);
|
||||
if($imageInfo['image_type'] == 1) $remoteImage = UtilService::remoteImage($siteUrl.$imageInfo['dir']);
|
||||
$name = $id . '_' . $user['uid'] . '_' . $user['is_promoter'] . '_product.jpg';
|
||||
$imageInfo = SystemAttachment::getInfo($name, 'name');
|
||||
$siteUrl = sysConfig('site_url') . DS;
|
||||
if (!$imageInfo) {
|
||||
$data = 'id=' . $id;
|
||||
if ($user['is_promoter'] || sysConfig('store_brokerage_statu') == 2) $data .= '&pid=' . $user['uid'];
|
||||
$res = \app\models\routine\RoutineCode::getPageCode('pages/goods_details/index', $data, 280);
|
||||
if (!$res) return app('json')->fail('二维码生成失败');
|
||||
$imageInfo = \crmeb\services\UploadService::instance()->setUploadPath('routine/product')->imageStream($name, $res);
|
||||
if (is_string($imageInfo)) return app('json')->fail($imageInfo);
|
||||
if ($imageInfo['image_type'] == 1) $remoteImage = UtilService::remoteImage($siteUrl . $imageInfo['dir']);
|
||||
else $remoteImage = UtilService::remoteImage($imageInfo['dir']);
|
||||
if(!$remoteImage['status']) return app('json')->fail('小程序二维码未能生成');
|
||||
SystemAttachment::attachmentAdd($imageInfo['name'],$imageInfo['size'],$imageInfo['type'],$imageInfo['dir'],$imageInfo['thumb_path'],1,$imageInfo['image_type'],$imageInfo['time'],2);
|
||||
if (!$remoteImage['status']) return app('json')->fail('小程序二维码未能生成');
|
||||
SystemAttachment::attachmentAdd($imageInfo['name'], $imageInfo['size'], $imageInfo['type'], $imageInfo['dir'], $imageInfo['thumb_path'], 1, $imageInfo['image_type'], $imageInfo['time'], 2);
|
||||
$url = $imageInfo['dir'];
|
||||
}else $url = $imageInfo['att_dir'];
|
||||
if($imageInfo['image_type'] == 1) $url = $siteUrl.$url;
|
||||
return app('json')->successful(['code'=>$url]);
|
||||
} else $url = $imageInfo['att_dir'];
|
||||
if ($imageInfo['image_type'] == 1) $url = $siteUrl . $url;
|
||||
return app('json')->successful(['code' => $url]);
|
||||
}
|
||||
}catch (\Exception $e){
|
||||
return app('json')->fail($e->getMessage(),[
|
||||
'code'=>$e->getCode(),
|
||||
'line'=>$e->getLine(),
|
||||
'message'=>$e->getMessage()
|
||||
} catch (\Exception $e) {
|
||||
return app('json')->fail($e->getMessage(), [
|
||||
'code' => $e->getCode(),
|
||||
'line' => $e->getLine(),
|
||||
'message' => $e->getMessage()
|
||||
]);
|
||||
}
|
||||
}
|
||||
@ -105,34 +100,14 @@ class StoreProductController
|
||||
* @param $id
|
||||
* @param int $type
|
||||
* @return mixed
|
||||
* @throws \think\Exception
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
*/
|
||||
public function detail(Request $request, $id,$type = 0)
|
||||
public function detail(Request $request, $id, $type = 0)
|
||||
{
|
||||
if (!$id || !($storeInfo = StoreProduct::getValidProduct($id))) return app('json')->fail('商品不存在或已下架');
|
||||
|
||||
//公众号
|
||||
$name = $id.'_product_detail_wap.jpg';
|
||||
$imageInfo = SystemAttachment::getInfo($name,'name');
|
||||
$siteUrl = sysConfig('site_url');
|
||||
if(!$imageInfo){
|
||||
$codeUrl = UtilService::setHttpType($siteUrl.'/detail/'.$id, 1);//二维码链接
|
||||
$imageInfo = UtilService::getQRCodePath($codeUrl, $name);
|
||||
if(is_array($imageInfo)){
|
||||
SystemAttachment::attachmentAdd($imageInfo['name'],$imageInfo['size'],$imageInfo['type'],$imageInfo['dir'],$imageInfo['thumb_path'],1,$imageInfo['image_type'],$imageInfo['time'],2);
|
||||
$url = $imageInfo['dir'];
|
||||
}else {
|
||||
$url = '';
|
||||
$imageInfo = ['image_type'=>0];
|
||||
}
|
||||
}else $url = $imageInfo['att_dir'];
|
||||
if($imageInfo['image_type'] == 1) $url = $siteUrl.$url;
|
||||
$storeInfo['image'] = UtilService::setSiteUrl($storeInfo['image'], $siteUrl);
|
||||
$storeInfo['image_base'] = UtilService::setSiteUrl($storeInfo['image'], $siteUrl);
|
||||
$storeInfo['code_base'] = $url;
|
||||
$storeInfo['code_base'] = QrcodeService::getWechatQrcodePath($id . '_product_detail_wap.jpg', '/detail/' . $id);
|
||||
$uid = $request->uid();
|
||||
$data['uid'] = $uid;
|
||||
//替换windows服务器下正反斜杠问题导致图片无法显示
|
||||
@ -141,38 +116,38 @@ class StoreProductController
|
||||
}, $storeInfo['description']);
|
||||
$storeInfo['userCollect'] = StoreProductRelation::isProductRelation($id, $uid, 'collect');
|
||||
$storeInfo['userLike'] = StoreProductRelation::isProductRelation($id, $uid, 'like');
|
||||
list($productAttr, $productValue) = StoreProductAttr::getProductAttrDetail($id,$uid,$type);
|
||||
list($productAttr, $productValue) = StoreProductAttr::getProductAttrDetail($id, $uid, $type);
|
||||
setView($uid, $id, $storeInfo['cate_id'], 'viwe');
|
||||
$data['storeInfo'] = StoreProduct::setLevelPrice($storeInfo, $uid, true);
|
||||
$data['similarity'] = StoreProduct::cateIdBySimilarityProduct($storeInfo['cate_id'], 'id,store_name,image,price,sales,ficti', 4);
|
||||
$data['productAttr'] = $productAttr;
|
||||
$data['productValue'] = $productValue;
|
||||
$data['priceName'] = 0;
|
||||
if($uid){
|
||||
if ($uid) {
|
||||
$storeBrokerageStatus = sysConfig('store_brokerage_statu') ?? 1;
|
||||
if($storeBrokerageStatus == 2)
|
||||
if ($storeBrokerageStatus == 2)
|
||||
$data['priceName'] = StoreProduct::getPacketPrice($storeInfo, $productValue);
|
||||
else{
|
||||
else {
|
||||
$user = $request->user();
|
||||
if($user->is_promoter)
|
||||
if ($user->is_promoter)
|
||||
$data['priceName'] = StoreProduct::getPacketPrice($storeInfo, $productValue);
|
||||
}
|
||||
if(!strlen(trim($data['priceName'])))
|
||||
if (!strlen(trim($data['priceName'])))
|
||||
$data['priceName'] = 0;
|
||||
}
|
||||
$data['reply'] = StoreProductReply::getRecProductReply($storeInfo['id']);
|
||||
$data['replyCount'] = StoreProductReply::productValidWhere()->where('product_id', $storeInfo['id'])->count();
|
||||
if ($data['replyCount']) {
|
||||
$goodReply = StoreProductReply::productValidWhere()->where('product_id', $storeInfo['id'])->where('product_score', 5)->count();
|
||||
$data['replyChance'] = $goodReply;
|
||||
if($goodReply){
|
||||
$data['replyChance'] = $goodReply;
|
||||
if ($goodReply) {
|
||||
$data['replyChance'] = bcdiv($goodReply, $data['replyCount'], 2);
|
||||
$data['replyChance'] = bcmul($data['replyChance'], 100, 2);
|
||||
}
|
||||
} else $data['replyChance'] = 0;
|
||||
$data['mer_id'] = $storeInfo['mer_id'];
|
||||
$data['system_store'] = ($res = SystemStore::getStoreDispose()) ? $res : [];
|
||||
$data['good_list'] = StoreProduct::getGoodList(18,'image,store_name,price,id,ot_price');
|
||||
$data['good_list'] = StoreProduct::getGoodList(18, 'image,store_name,price,id,ot_price');
|
||||
$data['mapKey'] = sysConfig('tengxun_map_key');
|
||||
$data['store_self_mention'] = (int)sysConfig('store_self_mention') ?? 0;//门店自提是否开启
|
||||
return app('json')->successful($data);
|
||||
@ -190,11 +165,11 @@ class StoreProductController
|
||||
public function product_hot(Request $request)
|
||||
{
|
||||
list($page, $limit) = UtilService::getMore([
|
||||
['page',0],
|
||||
['limit',0]
|
||||
['page', 0],
|
||||
['limit', 0]
|
||||
], $request, true);
|
||||
if(!$limit) return app('json')->successful([]);
|
||||
$productHot = StoreProduct::getHotProductLoading('id,image,store_name,cate_id,price,unit_name,ot_price',(int)$page,(int)$limit);
|
||||
if (!$limit) return app('json')->successful([]);
|
||||
$productHot = StoreProduct::getHotProductLoading('id,image,store_name,cate_id,price,unit_name,ot_price', (int)$page, (int)$limit);
|
||||
return app('json')->successful($productHot);
|
||||
}
|
||||
|
||||
@ -207,21 +182,21 @@ class StoreProductController
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
*/
|
||||
public function groom_list(Request $request,$type)
|
||||
public function groom_list(Request $request, $type)
|
||||
{
|
||||
$info['banner'] = [];
|
||||
$info['list'] = [];
|
||||
if($type == 1){//TODO 精品推荐
|
||||
$info['banner'] = GroupDataService::getData('routine_home_bast_banner')?:[];//TODO 首页精品推荐图片
|
||||
if ($type == 1) {//TODO 精品推荐
|
||||
$info['banner'] = GroupDataService::getData('routine_home_bast_banner') ?: [];//TODO 首页精品推荐图片
|
||||
$info['list'] = StoreProduct::getBestProduct('id,image,store_name,cate_id,price,ot_price,IFNULL(sales,0) + IFNULL(ficti,0) as sales,unit_name,sort');//TODO 精品推荐个数
|
||||
}else if($type == 2){//TODO 热门榜单
|
||||
$info['banner'] = GroupDataService::getData('routine_home_hot_banner')?:[];//TODO 热门榜单 猜你喜欢推荐图片
|
||||
$info['list'] = StoreProduct::getHotProduct('id,image,store_name,cate_id,price,ot_price,unit_name,sort,IFNULL(sales,0) + IFNULL(ficti,0) as sales',0,$request->uid());//TODO 热门榜单 猜你喜欢
|
||||
}else if($type == 3){//TODO 首发新品
|
||||
$info['banner'] = GroupDataService::getData('routine_home_new_banner')?:[];//TODO 首发新品推荐图片
|
||||
$info['list'] = StoreProduct::getNewProduct('id,image,store_name,cate_id,price,ot_price,unit_name,sort,IFNULL(sales,0) + IFNULL(ficti,0) as sales',0,$request->uid());//TODO 首发新品
|
||||
}else if($type == 4){//TODO 促销单品
|
||||
$info['banner'] = GroupDataService::getData('routine_home_benefit_banner')?:[];//TODO 促销单品推荐图片
|
||||
} else if ($type == 2) {//TODO 热门榜单
|
||||
$info['banner'] = GroupDataService::getData('routine_home_hot_banner') ?: [];//TODO 热门榜单 猜你喜欢推荐图片
|
||||
$info['list'] = StoreProduct::getHotProduct('id,image,store_name,cate_id,price,ot_price,unit_name,sort,IFNULL(sales,0) + IFNULL(ficti,0) as sales', 0, $request->uid());//TODO 热门榜单 猜你喜欢
|
||||
} else if ($type == 3) {//TODO 首发新品
|
||||
$info['banner'] = GroupDataService::getData('routine_home_new_banner') ?: [];//TODO 首发新品推荐图片
|
||||
$info['list'] = StoreProduct::getNewProduct('id,image,store_name,cate_id,price,ot_price,unit_name,sort,IFNULL(sales,0) + IFNULL(ficti,0) as sales', 0, $request->uid());//TODO 首发新品
|
||||
} else if ($type == 4) {//TODO 促销单品
|
||||
$info['banner'] = GroupDataService::getData('routine_home_benefit_banner') ?: [];//TODO 促销单品推荐图片
|
||||
$info['list'] = StoreProduct::getBenefitProduct('id,image,store_name,cate_id,price,ot_price,stock,unit_name,sort');//TODO 促销单品
|
||||
}
|
||||
return app('json')->successful($info);
|
||||
@ -234,9 +209,10 @@ class StoreProductController
|
||||
*/
|
||||
public function reply_config($id)
|
||||
{
|
||||
if(!$id || !is_numeric($id)) return app('json')->fail('参数错误!');
|
||||
if (!$id || !is_numeric($id)) return app('json')->fail('参数错误!');
|
||||
return app('json')->successful(StoreProductReply::productReplyCount($id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取产品评论
|
||||
* @param Request $request
|
||||
@ -247,10 +223,10 @@ class StoreProductController
|
||||
public function reply_list(Request $request, $id)
|
||||
{
|
||||
list($page, $limit, $type) = UtilService::getMore([
|
||||
['page',0],['limit',0],['type',0]
|
||||
['page', 0], ['limit', 0], ['type', 0]
|
||||
], $request, true);
|
||||
if(!$id || !is_numeric($id)) return app('json')->fail('参数错误!');
|
||||
$list = StoreProductReply::getProductReplyList($id,(int)$type,$page,$limit);
|
||||
if (!$id || !is_numeric($id)) return app('json')->fail('参数错误!');
|
||||
$list = StoreProductReply::getProductReplyList($id, (int)$type, $page, $limit);
|
||||
return app('json')->successful($list);
|
||||
}
|
||||
|
||||
|
||||
@ -8,6 +8,7 @@
|
||||
namespace crmeb\services;
|
||||
|
||||
|
||||
use app\admin\model\system\SystemAttachment;
|
||||
use app\admin\model\wechat\WechatQrcode as QrcodeModel;
|
||||
|
||||
class QrcodeService
|
||||
@ -37,4 +38,41 @@ class QrcodeService
|
||||
{
|
||||
return QrcodeModel::scanQrcode($id, $type);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取二维码完整路径,不存在则自动生成
|
||||
* @param string $name 路径名
|
||||
* @param string $link 需要生成二维码的跳转路径
|
||||
* @param int $type https 1 = http , 0 = https
|
||||
* @param bool $force 是否返回false
|
||||
* @return bool|mixed|string
|
||||
*/
|
||||
public static function getWechatQrcodePath(string $name, string $link, int $type = 1, bool $force = false)
|
||||
{
|
||||
try {
|
||||
$imageInfo = SystemAttachment::getInfo($name, 'name');
|
||||
$siteUrl = sysConfig('site_url');
|
||||
if (!$imageInfo) {
|
||||
$codeUrl = UtilService::setHttpType($siteUrl . $link, $type);//二维码链接
|
||||
$imageInfo = UtilService::getQRCodePath($codeUrl, $name);
|
||||
if (is_string($imageInfo) && $force)
|
||||
return false;
|
||||
if (is_array($imageInfo)) {
|
||||
SystemAttachment::attachmentAdd($imageInfo['name'], $imageInfo['size'], $imageInfo['type'], $imageInfo['dir'], $imageInfo['thumb_path'], 1, $imageInfo['image_type'], $imageInfo['time'], 2);
|
||||
$url = $imageInfo['dir'];
|
||||
} else {
|
||||
$url = '';
|
||||
$imageInfo = ['image_type' => 0];
|
||||
}
|
||||
} else $url = $imageInfo['att_dir'];
|
||||
if ($imageInfo['image_type'] == 1) $url = $siteUrl . $url;
|
||||
return $url;
|
||||
} catch (\Throwable $e) {
|
||||
if ($force)
|
||||
return false;
|
||||
else
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user