产生原因,生成海报传参缺少类型。
【产品名称】:CRMEB标准版/ PRO版 / 多店版 /多商户 /知识付费/ JAVA版
【产品版本】:v4.6.0
【使用终端】:小程序/ H5 / 公众号
修复方法:
1. app/api/controller/v1/store/StoreProductController.php的 code方法
/**
* 商品分享二维码 推广员
* @param Request $request
* @param string|int $id
* @return mixed
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
*/
public function code(Request $request, $id)
{
$type = $request->get('type', 0);
$code = $this->services->getCode((int)$id, $request->get('user_type', 'wechat'), $request->user(), $type);
return app('json')->success(['code' => $code]);
}
2. app/services/product/product/StoreProductServices.php 的 getCode方法,增加 type参数;getRoutineQrcodePath()方法type替换为$type
/**
* 商品分享二维码 推广员
* @param int $id
* @param string $userType
* @param array|User $user
* @param int $type 1 = 拼团,2 = 秒杀
* @return string
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
*/
public function getCode(int $id, string $userType, $user, int $type = 0)
{
if (!$id) {
throw new ApiException('id不能为空');
}
//验证普通商品
if (0 === $type && !$this->isValidProduct($id)) {
throw new ApiException(410294);
}
switch ($userType) {
case 'wechat':
//公众号
$name = $id . '_product_detail_' . $user['uid'] . '_is_promoter_' . $user['is_promoter'] . '_wap.jpg';
/** @var QrcodeServices $qrcodeService */
$qrcodeService = app()->make(QrcodeServices::class);
$url = $qrcodeService->getWechatQrcodePath($name, '/pages/goods_details/index?id=' . $id . '&spread=' . $user['uid']);
if ($url === false) {
throw new ApiException(410167);
}
return image_to_base64($url);
case 'routine':
/** @var QrcodeServices $qrcodeService */
$qrcodeService = app()->make(QrcodeServices::class);
$url = $qrcodeService->getRoutineQrcodePath($id, $user['uid'], $type, ['is_promoter' => $user['is_promoter']]);
if (!$url) {
throw new ApiException(410167);
} else {
if ($url == 'unpublished') {
throw new ApiException('小程序尚未发布,无法生成商品海报');
}
return $url;
}
}
}
{{item.user_info.nickname ? item.user_info.nickname : item.user_name}}
作者 管理员 企业
{{itemf.name}}
{{itemc.user_info.nickname}}
{{itemc.user_name}}
回复 {{itemc.comment_user_info.nickname}}
{{itemf.name}}