Files
huangjingfen/pro_v3.5.1/app/controller/admin/v1/order/OtherOrder.php
apple 78de918c37 Initial commit: queue workspace
Made-with: Cursor
2026-03-21 02:55:24 +08:00

103 lines
3.8 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app\controller\admin\v1\order;
use app\controller\admin\AuthController;
use app\services\order\OtherOrderServices;
use app\services\other\QrcodeServices;
use crmeb\utils\Canvas;
use think\annotation\Inject;
/**
* Class OtherOrder
* @package app\controller\admin\v1\order
*/
class OtherOrder extends AuthController
{
/**
* @var OtherOrderServices
*/
#[Inject]
protected OtherOrderServices $services;
/**
* 线下收银
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function scan_list()
{
$where = $this->request->getMore([
['order_id', ''],
['add_time', ''],
['name', ''],
['page', 1],
['limit', 20],
]);
$data = $this->services->getScanOrderList($where);
return $this->success($data);
}
/**
* 获取线下二维码
* @return mixed
* @throws \Exception
*/
public function offline_scan()
{
[$type] = $this->request->getMore([
['type', 1]
], true);
//生成h5地址
$weixinPage = "/pages/annex/offline_pay/index";
$weixinFileName = "wechat_offline_scan.png";
/** @var QrcodeServices $QrcodeService */
$QrcodeService = app()->make(QrcodeServices::class);
$wechatQrcode = $QrcodeService->getWechatQrcodePath($weixinFileName, $weixinPage, false, false);
//生成小程序地址
$routineQrcode = $QrcodeService->getRoutineQrcodePath(4, 6, 103, $weixinFileName, false);
$qrcod = ['wechat' => $wechatQrcode, 'routine' => $routineQrcode];
if ($type) {
//生成画布
$canvas = Canvas::instance();
$path = 'uploads/offline/';
$imageType = 'jpg';
$siteUrl = sys_config('site_url');
$canvas->setImageUrl(public_path() . 'statics/qrcode/offlines.jpg')->setImageHeight(730)->setImageWidth(500)->pushImageValue();
foreach ($qrcod as $k => $v) {
if ($v) {
$name = 'offline_' . $k;
//再本地接去掉http使用本地绝对路径获取
if (strstr($v, $this->request->host(true)) !== false) {
$v = str_replace([
'https://' . $this->request->host(true) . '/',
'http://' . $this->request->host(true) . '/'
], public_path(), $v);
}
$canvas->setImageUrl($v)->setImageHeight(344)->setImageWidth(344)->setImageLeft(76)->setImageTop(120)->pushImageValue();
$image = $canvas->setFileName($name)->setImageType($imageType)->setPath($path)->setBackgroundWidth(500)->setBackgroundHeight(720)->starDrawChart();
$data[$k] = $image ? $siteUrl . '/' . $image : '';
} else {
$data[$k] = "";
}
}
} else {
$data = ['wechat' => $wechatQrcode, 'routine' => $routineQrcode];
}
return $this->success($data);
}
}