提交 59070118 编写于 作者: D devil

订单取货码改为图片、公共下载目录优化

上级 22a16fa5
......@@ -208,18 +208,18 @@
<?php endif ?>
</td>
</tr>
<tr class="<?php if(is_writable(ROOT.'public/download/sourcecode')){ echo 'yes'; } else { echo 'am-danger'; } ?>">
<td>./public/download/sourcecode</td>
<tr class="<?php if(is_writable(ROOT.'public/download')){ echo 'yes'; } else { echo 'am-danger'; } ?>">
<td>./public/download</td>
<td>可写</td>
<td>
<?php if (is_writable(ROOT.'public/download/sourcecode')): ?>
<?php if (is_writable(ROOT.'public/download')): ?>
可写
<?php else: ?>
不可写
<?php endif ?>
</td>
<td>
<?php if (is_writable(ROOT.'public/download/sourcecode')): ?>
<?php if (is_writable(ROOT.'public/download')): ?>
<?php else: ?>
×
......
......@@ -116,16 +116,19 @@ class AppMiniService
return DataReturn('配置信息不能为空', -1);
}
// 源码包目录是否存在
// 源码目录不存在则创建
\base\FileUtil::CreateDir(self::$new_root);
// 源码目标目录是否存在
if(!is_dir(self::$new_root))
{
return DataReturn('源码目录不存在['.self::$new_root.']', -1);
return DataReturn('源码目标目录不存在['.self::$new_root.']', -1);
}
// 源码包目录是否有权限
// 源码目标目录没有权限
if(!is_writable(self::$new_root))
{
return DataReturn('源码目录没有权限['.self::$new_root.']', -1);
return DataReturn('源码目标目录没有权限['.self::$new_root.']', -1);
}
// 目录不存在则创建
......
......@@ -778,7 +778,7 @@ class OrderService
// 自提模式 添加订单取货码
if($v['order_model'] == 2)
{
$v['extraction_data'] = self::OrdersExtractionData($v['id']);
$v['extraction_data'] = self::OrdersExtractionData($v['id'], $v['user_id']);
}
}
......@@ -928,19 +928,49 @@ class OrderService
* @version 1.0.0
* @date 2019-11-26
* @desc description
* @param [int] $order_id [订单id]
* @param [int] $order_id [订单id]
* @param [int] $user_id [用户id]
*/
private static function OrdersExtractionData($order_id)
private static function OrdersExtractionData($order_id, $user_id)
{
// 必须返回的内容格式
$result = [
'code' => null,
'images' => null,
];
// 获取取货码
$code = Db::name('OrderExtractionCode')->where(['order_id'=>$order_id])->value('code');
if(!empty($code))
{
$result['code'] = $code;
$result['images'] = MyUrl('index/qrcode/index', ['content'=>urlencode(base64_encode($code))]);
// 生成二维码参数
$qrcode_params = [
'content' => $code,
'root_path' => ROOT.'public',
'path' => DS.'download'.DS.'order'.DS.'extraction_ode'.DS,
'filename' => $user_id.'_'.$order_id.'.png',
];
// 图片不存在则去生成二维码图片并保存至目录
$file = $qrcode_params['root_path'].$qrcode_params['path'].$qrcode_params['filename'];
if(!file_exists($file))
{
$ret = (new \base\Qrcode())->Create($qrcode_params);
if($ret['code'] == 0)
{
$result['images'] = $qrcode_params['path'].$qrcode_params['filename'];
}
} else {
$result['images'] = $qrcode_params['path'].$qrcode_params['filename'];
}
// 展示地址处理
if(!empty($result['images']))
{
$result['images'] = ResourcesService::AttachmentPathViewHandle($result['images']);
}
}
return $result;
}
......
......@@ -15,7 +15,7 @@
return [
// 开发模式
'is_develop' => false,
'is_develop' => true,
// 默认编码
'default_charset' => 'utf-8',
......
......@@ -66,6 +66,7 @@ class Qrcode
ob_clean();
}
\QRcode::png($content, false, $level, $point_size, $mr);
die;
}
/**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册