mirror of
https://github.com/crmeb/CRMEB.git
synced 2025-12-12 03:01:18 +00:00
调整H5二维码统一由一个方法生成
This commit is contained in:
parent
a4dc1b3602
commit
fdec995129
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace app\api\controller\activity;
|
namespace app\api\controller\activity;
|
||||||
|
|
||||||
use app\admin\model\system\SystemAttachment;
|
use app\admin\model\system\SystemAttachment;
|
||||||
@ -7,6 +8,7 @@ use app\models\store\StoreCombination;
|
|||||||
use app\models\store\StorePink;
|
use app\models\store\StorePink;
|
||||||
use app\models\store\StoreProductReply;
|
use app\models\store\StoreProductReply;
|
||||||
use app\Request;
|
use app\Request;
|
||||||
|
use crmeb\services\QrcodeService;
|
||||||
use crmeb\services\SystemConfigService;
|
use crmeb\services\SystemConfigService;
|
||||||
use crmeb\services\UploadService;
|
use crmeb\services\UploadService;
|
||||||
use crmeb\services\UtilService;
|
use crmeb\services\UtilService;
|
||||||
@ -48,26 +50,10 @@ class StoreCombinationController
|
|||||||
$combinationOne = $combinationOne->hidden(['mer_id', 'attr', 'sort', 'add_time', 'is_host', 'is_show', 'is_del', 'mer_use', 'cost', 'combination'])->toArray();
|
$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);
|
$combinationOne['images'] = json_decode($combinationOne['images'], true);
|
||||||
list($pink, $pindAll) = StorePink::getPinkAll($id, true);//拼团列表
|
list($pink, $pindAll) = StorePink::getPinkAll($id, true);//拼团列表
|
||||||
//公众号
|
|
||||||
$name = $id.'_combination_detail_wap.jpg';
|
|
||||||
$imageInfo = SystemAttachment::getInfo($name,'name');
|
|
||||||
$siteUrl = sysConfig('site_url');
|
$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'] = UtilService::setSiteUrl($combinationOne['image'], $siteUrl);
|
||||||
$combinationOne['image_base'] = 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;
|
$combinationOne['sale_stock'] = 0;
|
||||||
if ($combinationOne['stock'] > 0) $combinationOne['sale_stock'] = 1;
|
if ($combinationOne['stock'] > 0) $combinationOne['sale_stock'] = 1;
|
||||||
if (!strlen(trim($combinationOne['unit_name']))) $combinationOne['unit_name'] = '个';
|
if (!strlen(trim($combinationOne['unit_name']))) $combinationOne['unit_name'] = '个';
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace app\api\controller\activity;
|
namespace app\api\controller\activity;
|
||||||
|
|
||||||
use app\admin\model\system\SystemAttachment;
|
use app\admin\model\system\SystemAttachment;
|
||||||
@ -7,6 +8,7 @@ use app\models\store\StoreProductReply;
|
|||||||
use app\models\store\StoreSeckill;
|
use app\models\store\StoreSeckill;
|
||||||
use app\Request;
|
use app\Request;
|
||||||
use crmeb\services\GroupDataService;
|
use crmeb\services\GroupDataService;
|
||||||
|
use crmeb\services\QrcodeService;
|
||||||
use crmeb\services\SystemConfigService;
|
use crmeb\services\SystemConfigService;
|
||||||
use crmeb\services\UtilService;
|
use crmeb\services\UtilService;
|
||||||
|
|
||||||
@ -103,29 +105,14 @@ class StoreSeckillController
|
|||||||
* @param $id
|
* @param $id
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function detail(Request $request, $id,$time = 0){
|
public function detail(Request $request, $id, $time = 0)
|
||||||
|
{
|
||||||
if (!$id || !($storeInfo = StoreSeckill::getValidProduct($id))) return app('json')->fail('商品不存在或已下架!');
|
if (!$id || !($storeInfo = StoreSeckill::getValidProduct($id))) return app('json')->fail('商品不存在或已下架!');
|
||||||
$storeInfo = $storeInfo->hidden(['cost', 'add_time', 'is_del'])->toArray();
|
$storeInfo = $storeInfo->hidden(['cost', 'add_time', 'is_del'])->toArray();
|
||||||
|
|
||||||
//公众号
|
|
||||||
$name = $id.'_seckill_detail_wap.jpg';
|
|
||||||
$imageInfo = SystemAttachment::getInfo($name,'name');
|
|
||||||
$siteUrl = sysConfig('site_url');
|
$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'] = UtilService::setSiteUrl($storeInfo['image'], $siteUrl);
|
||||||
$storeInfo['image_base'] = 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();
|
$uid = $request->uid();
|
||||||
$storeInfo['userLike'] = StoreProductRelation::isProductRelation($id, $uid, 'like', 'product_seckill');
|
$storeInfo['userLike'] = StoreProductRelation::isProductRelation($id, $uid, 'like', 'product_seckill');
|
||||||
$storeInfo['like_num'] = StoreProductRelation::productRelationNum($id, 'like', 'product_seckill');
|
$storeInfo['like_num'] = StoreProductRelation::productRelationNum($id, 'like', 'product_seckill');
|
||||||
|
|||||||
@ -10,6 +10,7 @@ use app\models\store\StoreProductRelation;
|
|||||||
use app\models\store\StoreProductReply;
|
use app\models\store\StoreProductReply;
|
||||||
use app\Request;
|
use app\Request;
|
||||||
use crmeb\services\GroupDataService;
|
use crmeb\services\GroupDataService;
|
||||||
|
use crmeb\services\QrcodeService;
|
||||||
use crmeb\services\SystemConfigService;
|
use crmeb\services\SystemConfigService;
|
||||||
use crmeb\services\UtilService;
|
use crmeb\services\UtilService;
|
||||||
|
|
||||||
@ -57,16 +58,10 @@ class StoreProductController
|
|||||||
case 'wechat':
|
case 'wechat':
|
||||||
//公众号
|
//公众号
|
||||||
$name = $id . '_product_detail_' . $user['uid'] . '_is_promoter_' . $user['is_promoter'] . '_wap.jpg';
|
$name = $id . '_product_detail_' . $user['uid'] . '_is_promoter_' . $user['is_promoter'] . '_wap.jpg';
|
||||||
$imageInfo = SystemAttachment::getInfo($name,'name');
|
$url = QrcodeService::getWechatQrcodePath($name, '/detail/' . $id . '?spread=' . $user['uid']);
|
||||||
$siteUrl = sysConfig('site_url');
|
if ($url === false)
|
||||||
if(!$imageInfo){
|
return app('json')->fail('二维码生成失败');
|
||||||
$codeUrl = UtilService::setHttpType($siteUrl.'/detail/'.$id.'?spread='.$user['uid'], 1);//二维码链接
|
else
|
||||||
$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)]);
|
return app('json')->successful(['code' => UtilService::setImageBase64($url)]);
|
||||||
break;
|
break;
|
||||||
case 'routine':
|
case 'routine':
|
||||||
@ -105,34 +100,14 @@ class StoreProductController
|
|||||||
* @param $id
|
* @param $id
|
||||||
* @param int $type
|
* @param int $type
|
||||||
* @return mixed
|
* @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('商品不存在或已下架');
|
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');
|
$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'] = UtilService::setSiteUrl($storeInfo['image'], $siteUrl);
|
||||||
$storeInfo['image_base'] = 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();
|
$uid = $request->uid();
|
||||||
$data['uid'] = $uid;
|
$data['uid'] = $uid;
|
||||||
//替换windows服务器下正反斜杠问题导致图片无法显示
|
//替换windows服务器下正反斜杠问题导致图片无法显示
|
||||||
@ -237,6 +212,7 @@ class StoreProductController
|
|||||||
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));
|
return app('json')->successful(StoreProductReply::productReplyCount($id));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取产品评论
|
* 获取产品评论
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
|
|||||||
@ -8,6 +8,7 @@
|
|||||||
namespace crmeb\services;
|
namespace crmeb\services;
|
||||||
|
|
||||||
|
|
||||||
|
use app\admin\model\system\SystemAttachment;
|
||||||
use app\admin\model\wechat\WechatQrcode as QrcodeModel;
|
use app\admin\model\wechat\WechatQrcode as QrcodeModel;
|
||||||
|
|
||||||
class QrcodeService
|
class QrcodeService
|
||||||
@ -37,4 +38,41 @@ class QrcodeService
|
|||||||
{
|
{
|
||||||
return QrcodeModel::scanQrcode($id, $type);
|
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