From 211774d08b1e596f6bab91f4b3afa222629b0b28 Mon Sep 17 00:00:00 2001 From: wangxinglong <2371974647@qq.com> Date: Wed, 19 Jan 2022 14:25:17 +0800 Subject: [PATCH] setter --- app/controller/manager/Business.php | 44 ++++++++++++++++++++++++++ app/controller/manager/Statistical.php | 8 +++-- view/manager/business/index.html | 1 + view/manager/statistical/sign.html | 12 ++++--- 4 files changed, 59 insertions(+), 6 deletions(-) diff --git a/app/controller/manager/Business.php b/app/controller/manager/Business.php index ce4d5b0..fe86e4d 100644 --- a/app/controller/manager/Business.php +++ b/app/controller/manager/Business.php @@ -14,6 +14,11 @@ use app\repository\AccountRepository; use app\repository\BusinessRepository; use app\repository\RechargeRepository; use app\service\wx\WechatPay; +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 think\exception\ValidateException; @@ -25,6 +30,8 @@ use think\response\View; class Business extends Base { + protected $noNeedLogin = ['downloadWriteOffCode']; + /** * 商家列表列表 * @@ -432,5 +439,42 @@ class Business extends Base return $this->view(); } + /** + * 下载商家核销二维码 + * */ + public function downloadWriteOffCode() + { + $businessCode = input("business_code/s"); + if(empty($businessCode)){ + return $this->error("商家信息错误"); + } + $qrData = $this->request->domain() . "/business_code_to_coupon_list?business_code=" . $businessCode; + + $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/business/" . $businessCode . ".jpg"; + $result->saveToFile( public_path() . $path); + + return download(public_path() . $path,$businessCode); + } } \ No newline at end of file diff --git a/app/controller/manager/Statistical.php b/app/controller/manager/Statistical.php index 27ff611..b6df7cb 100644 --- a/app/controller/manager/Statistical.php +++ b/app/controller/manager/Statistical.php @@ -3,6 +3,7 @@ namespace app\controller\manager; +use app\model\Member; use app\repository\AccountRepository; use app\repository\CouponRepository; @@ -21,6 +22,7 @@ class Statistical extends Base $agencyCode = input("agencyCode/s"); $this->data["startTime"] = $startTime; $this->data["endTime"] = $endTime; + $this->data["agencyCode"] = $agencyCode; $xDay = diffBetweenTwoDays($startTime, $endTime); if ($xDay > 366) { return $this->error("日期不要超过"); @@ -69,8 +71,10 @@ class Statistical extends Base $receiveDataArray[$item["received_time"]]++; } } - $receiveDataArray= array_values($receiveDataArray); - $this->data["receiveDataArray"]=json_encode($receiveDataArray); + $receiveDataArray = array_values($receiveDataArray); + $this->data["receiveDataArray"] = json_encode($receiveDataArray); + $this->data["agency"] = Member::getAgentAll(); + return $this->view(); } diff --git a/view/manager/business/index.html b/view/manager/business/index.html index 9956c8d..dc0bd6d 100644 --- a/view/manager/business/index.html +++ b/view/manager/business/index.html @@ -56,6 +56,7 @@ 充值记录 基本资料 指派代理商 + 下载核销二维码 代为充值 diff --git a/view/manager/statistical/sign.html b/view/manager/statistical/sign.html index ed4f70f..037e73d 100644 --- a/view/manager/statistical/sign.html +++ b/view/manager/statistical/sign.html @@ -7,7 +7,7 @@