產(chǎn)生原因,生成海報傳參缺少類型。
【產(chǎn)品名稱】:CRMEB標準版/ PRO版 / 多店版 /多商戶 /知識付費/ JAVA版
【產(chǎn)品版本】: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參數(shù);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('小程序尚未發(fā)布,無法生成商品海報');
}
return $url;
}
}
}