添加生成二维码
This commit is contained in:
parent
8c5a87a337
commit
10919fb275
@ -39,6 +39,7 @@ use crmeb\basic\BaseController;
|
||||
use crmeb\services\AlipayService;
|
||||
use crmeb\services\CopyCommand;
|
||||
use crmeb\services\MiniProgramService;
|
||||
use crmeb\services\QrcodeService;
|
||||
use crmeb\services\UploadService;
|
||||
use crmeb\services\WechatService;
|
||||
use Exception;
|
||||
@ -673,4 +674,34 @@ class Common extends BaseController
|
||||
return app('json')->success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成二维码
|
||||
*/
|
||||
public function Qrcode($data)
|
||||
{
|
||||
$siteUrl = systemConfig('site_url');
|
||||
$name = 'orcode'.$data['id'] .md5(date('Ymd')) . '.png';
|
||||
$attachmentRepository = app()->make(AttachmentRepository::class);
|
||||
$imageInfo = $attachmentRepository->getWhere(['attachment_name' => $name]);
|
||||
|
||||
if (isset($imageInfo['attachment_src']) && strstr($imageInfo['attachment_src'], 'http') !== false && curl_file_exist($imageInfo['attachment_src']) === false) {
|
||||
$imageInfo->delete();
|
||||
$imageInfo = null;
|
||||
}
|
||||
if (!$imageInfo) {
|
||||
$imageInfo = app()->make(QrcodeService::class)->getQRCodePath($data['code'], $name,['code'=>1]);
|
||||
if (is_string($imageInfo)) throw new ValidateException('二维码生成失败');
|
||||
|
||||
$imageInfo['dir'] = tidy_url($imageInfo['dir'], null, $siteUrl);
|
||||
$attachmentRepository->create(systemConfig('upload_type') ?: 1, -2, $data['id'], [
|
||||
'attachment_category_id' => 0,
|
||||
'attachment_name' => $imageInfo['name'],
|
||||
'attachment_src' => $imageInfo['dir']
|
||||
]);
|
||||
$urlCode = $imageInfo['dir'];
|
||||
} else $urlCode = $imageInfo['attachment_src'];
|
||||
return $urlCode;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -26,6 +26,7 @@ use app\common\repositories\user\UserBillRepository;
|
||||
use app\common\repositories\user\UserBrokerageRepository;
|
||||
use app\common\repositories\user\UserRepository;
|
||||
use app\common\repositories\user\UserVisitRepository;
|
||||
use app\controller\api\Common;
|
||||
use app\validate\api\UserBaseInfoValidate;
|
||||
use crmeb\basic\BaseController;
|
||||
use crmeb\services\MiniProgramService;
|
||||
@ -239,6 +240,7 @@ class User extends BaseController
|
||||
$this->repository->update($this->request->uid(), $data);
|
||||
return app('json')->success('绑定成功');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
* @throws DataNotFoundException
|
||||
@ -575,4 +577,16 @@ class User extends BaseController
|
||||
return app('json')->success(['count' => $count, 'list' => $result]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成二维码
|
||||
*/
|
||||
public function qrcode()
|
||||
{
|
||||
/** @var Common $common */
|
||||
$common = app()->make(Common::class);
|
||||
$siteUrl = systemConfig('site_url');
|
||||
$data = $common->Qrcode(['code' => $siteUrl . 'download/index.html?code=shop_' . $this->user->uid, 'id' => $this->user->uid]);
|
||||
return app('json')->success(['url' => $data]);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -37,6 +37,7 @@ Route::group('api/', function () {
|
||||
Route::post('logout', 'api.Auth/logout');
|
||||
//用户信息
|
||||
Route::get('user', 'api.Auth/userInfo');
|
||||
Route::get('qrcode', 'api.user.User/qrcode');
|
||||
|
||||
//绑定推荐人
|
||||
Route::post('user/spread', 'api.Auth/spread');
|
||||
|
Loading…
x
Reference in New Issue
Block a user