This commit is contained in:
mkm 2024-01-21 15:41:43 +08:00
parent 16ee8284db
commit 58c27d36cd
4 changed files with 44 additions and 1 deletions

View File

@ -1004,7 +1004,7 @@ class StoreOrderCreateRepository extends StoreOrderRepository
if ($order['consumption_money'] > 0) {
$consumptionDetails[] = [
'user_id' => $uid,
'order_id' => $order['order_id'],
'order_id' => $_order->order_id,
'group_order_id' => $groupOrder->group_order_id,
'coupon_user_id' => $order['consumption_id'],
'type' => 1,

View File

@ -57,6 +57,8 @@ use AlibabaCloud\Tea\Utils\Utils;
use Darabonba\OpenApi\Models\Config;
use AlibabaCloud\SDK\Ocr\V20191230\Models\RecognizeBusinessLicenseRequest;
use AlibabaCloud\Tea\Utils\Utils\RuntimeOptions;
use app\common\repositories\system\attachment\AttachmentRepository;
use crmeb\services\QrcodeService;
/**
* Class Common
@ -634,4 +636,34 @@ class Common extends BaseController
Cache::set('promote_' . app('request')->ip(), $code, 86400);
return app('json')->success();
}
/**
* 生成二维码
*/
public function Qrcode($data)
{
$siteUrl = systemConfig('site_url');
$name = md5('orcode' . date('Ymd')) . '.jpg';
$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);
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;
}
}

View File

@ -30,6 +30,7 @@ use think\App;
use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;
use think\db\exception\ModelNotFoundException;
use app\controller\api\Common;
class User extends BaseController
{
@ -535,4 +536,12 @@ class User extends BaseController
return app('json')->success('修改成功');
}
/**
* 生成二维码
*/
public function qrcode(){
$common= app()->make(Common::class);
$data=$common->Qrcode(['code'=>'shop_'.$this->user->uid,'id'=>$this->user->uid]);
return app('json')->success(['url'=>$data]);
}
}

View File

@ -46,6 +46,8 @@ Route::group('api/', function () {
Route::post('articleCatch', 'api.Upload/article');
//强制登录
Route::group(function () {
Route::any('qrcode', 'api.user.User/qrcode');
Route::post('merchant_license_identify', 'api.Common/merchant_license_identify');//营业执照识别