setter
parent
d38e6b7555
commit
b4c233d8bf
|
@ -12,6 +12,11 @@ use app\repository\BusinessRepository;
|
||||||
use app\repository\CouponRepository;
|
use app\repository\CouponRepository;
|
||||||
use app\validate\CouponRelease;
|
use app\validate\CouponRelease;
|
||||||
use app\validate\CouponUsingRule;
|
use app\validate\CouponUsingRule;
|
||||||
|
use Endroid\QrCode\Builder\Builder;
|
||||||
|
use Endroid\QrCode\Encoding\Encoding;
|
||||||
|
use Endroid\QrCode\ErrorCorrectionLevel\ErrorCorrectionLevelHigh;
|
||||||
|
use Endroid\QrCode\RoundBlockSizeMode\RoundBlockSizeModeMargin;
|
||||||
|
use Endroid\QrCode\Writer\PngWriter;
|
||||||
use Exception;
|
use Exception;
|
||||||
use think\facade\Config;
|
use think\facade\Config;
|
||||||
use think\facade\Db;
|
use think\facade\Db;
|
||||||
|
@ -25,6 +30,7 @@ use think\facade\Config as CConfig;
|
||||||
class Coupon extends Base
|
class Coupon extends Base
|
||||||
{
|
{
|
||||||
|
|
||||||
|
protected $noNeedLogin = ["downloadQrCode"];
|
||||||
protected function initialize()
|
protected function initialize()
|
||||||
{
|
{
|
||||||
parent::initialize(); // TODO: Change the autogenerated stub
|
parent::initialize(); // TODO: Change the autogenerated stub
|
||||||
|
@ -353,6 +359,45 @@ class Coupon extends Base
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 下载小程序二维码
|
||||||
|
* */
|
||||||
|
public function downloadQrCode()
|
||||||
|
{
|
||||||
|
$id = input("id/d");
|
||||||
|
$couponMain = CouponMain::findById($id);
|
||||||
|
if(empty($couponMain)){
|
||||||
|
return $this->json(4001,"优惠券不存在");
|
||||||
|
}
|
||||||
|
|
||||||
|
$qrData = $this->request->domain() . "/coupon_info?id={$id}&business_code={$couponMain['business_code']}" ;
|
||||||
|
|
||||||
|
$w = 3000;//尺寸
|
||||||
|
|
||||||
|
$logoImg = app()->getRootPath().'public/static/images/icon-logo.jpg';
|
||||||
|
|
||||||
|
$result = Builder::create()
|
||||||
|
->writer(new PngWriter())
|
||||||
|
->writerOptions([])
|
||||||
|
->data($qrData)
|
||||||
|
->encoding(new Encoding('UTF-8'))
|
||||||
|
->errorCorrectionLevel(new ErrorCorrectionLevelHigh())
|
||||||
|
->size($w)
|
||||||
|
->margin(10)
|
||||||
|
->roundBlockSizeMode(new RoundBlockSizeModeMargin())
|
||||||
|
->logoPath($logoImg)
|
||||||
|
->logoResizeToHeight(ceil($w/6))
|
||||||
|
->logoResizeToWidth(ceil($w/6))
|
||||||
|
->logoPunchoutBackground(true)
|
||||||
|
->build();
|
||||||
|
header(
|
||||||
|
"Content-type: image/jpg"
|
||||||
|
);
|
||||||
|
$path = "/storage/coupon/{$id}.jpg";
|
||||||
|
$result->saveToFile( public_path() . $path);
|
||||||
|
|
||||||
|
return download(public_path() . $path,$couponMain['name']);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -86,12 +86,14 @@
|
||||||
|
|
||||||
<!-- 操作列 -->
|
<!-- 操作列 -->
|
||||||
<script type="text/html" id="row-operate">
|
<script type="text/html" id="row-operate">
|
||||||
|
|
||||||
<a class="layui-btn layui-btn-primary layui-btn-xs" data-href="/manager/coupon/info.html?id={{d.id}}" data-title="【{{ d.name }}】详情" lay-event="info">详情</a>
|
<a class="layui-btn layui-btn-primary layui-btn-xs" data-href="/manager/coupon/info.html?id={{d.id}}" data-title="【{{ d.name }}】详情" lay-event="info">详情</a>
|
||||||
{{# if(d.on_shelf == 1){ }}
|
{{# if(d.on_shelf == 1){ }}
|
||||||
<a class="layui-btn layui-btn-xs" data-href="/manager/coupon/shelf.html?id={{d.id}}&&on_shelf=0" lay-event="shelf">上架</a>
|
<a class="layui-btn layui-btn-xs" data-href="/manager/coupon/shelf.html?id={{d.id}}&&on_shelf=0" lay-event="shelf">上架</a>
|
||||||
{{# }else{ }}
|
{{# }else{ }}
|
||||||
<a class="layui-btn layui-btn-xs" data-href="/manager/coupon/shelf.html?id={{d.id}}&&on_shelf=1" lay-event="shelf">下架</a>
|
<a class="layui-btn layui-btn-xs" data-href="/manager/coupon/shelf.html?id={{d.id}}&&on_shelf=1" lay-event="shelf">下架</a>
|
||||||
{{# } }}
|
{{# } }}
|
||||||
|
<a class="layui-btn layui-btn-primary layui-btn-xs" target="_blank" href="/manager/coupon/downloadQrCode.html?id={{d.id}}">下载二维码</a>
|
||||||
<a class="layui-btn layui-btn-primary layui-btn-xs" data-href="/manager/coupon/edit.html?id={{d.id}}" data-title="【{{ d.name }}】编辑" lay-event="info">编辑</a>
|
<a class="layui-btn layui-btn-primary layui-btn-xs" data-href="/manager/coupon/edit.html?id={{d.id}}" data-title="【{{ d.name }}】编辑" lay-event="info">编辑</a>
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue