| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107 |
- <?php
- /**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
- namespace app\modules\admin\controllers;
- use app\models\AggregateQrcode;
- use app\modules\admin\models\AggregateQrcodeForm;
- use app\modules\client\models\v1\NewSalesmanForm;
- use app\utils\QrCode;
- class AggregateQrcodeController extends BaseController
- {
- //创建url
- public function actionCreateUrl(){
- $form = new AggregateQrcodeForm();
- $form->number = post_params('number');
- $res = $form->createdUrl();
- return $this->asJson($res);
- }
- //展示列表
- public function actionQrcodeList(){
- $form = new AggregateQrcodeForm();
- $form->name = get_params('name');
- $form->salesman_name = get_params('salesman_name');
- $form->status = get_params('status');
- $res = $form->qrcodeList();
- return $this->asJson($res);
- }
- //生成二维码
- public function actionQrcodeCreate(){
- if(empty(post_params('ids'))){
- return [
- 'code'=>1,
- 'msg'=>'没有选择数据'
- ];
- }
- $ids = post_params('ids');
- $img = [];
- foreach ($ids as $index=>$item){
- $filename = md5(date('Ym').$item);
- $path = \Yii::$app->runtimePath . '/image/' . $filename . '.jpg';
- $pic_url = str_replace('http://', 'https://', \Yii::$app->request->hostInfo . '/runtime/image/' . $filename . '.jpg');
- if (file_exists($path)) {
- $img[]= $pic_url;
- continue;
- }
- $ag = AggregateQrcode::find()->where(['id'=>$item])->select('param_url,id,qrcode_url')->one();
- if(empty($ag->qrcode_url) || !file_exists(str_replace(\Yii::$app->request->hostInfo,\Yii::$app->basePath,$ag->qrcode_url))){
- if(!empty($ag->param_url)){
- $text = $ag->param_url;
- QrCode::image($text, 500, false, 'L', 'JPEG', 0, ['255,255,255', '0,0,0'], 1, false, $path);
- $img[]= $pic_url;
- $ag->qrcode_url = $pic_url;
- $ag->save();
- }
- }else{
- $img[]= $ag->qrcode_url;
- }
- }
- return $this->asJson([
- 'code'=>0,
- 'msg'=>'',
- 'data'=>$img
- ]);
- }
- //删除
- public function actionDelUrl(){
- $form = new AggregateQrcodeForm();
- $form->ids = post_params('ids');
- $res = $form->urlDel();
- return $this->asJson($res);
- }
- //手动绑定商城
- public function actionBindQrcode(){
- $form = new AggregateQrcodeForm();
- $form->store_id = post_params("store_id");
- $form->id = post_params("id");
- $form->salesman_id = post_params("salesman_id");
- $res = $form->bindStore();
- return $this->asJson($res);
- }
- //手动绑定微信/支付宝
- public function actionBindQrcodeOnline(){
- $form = new AggregateQrcodeForm();
- $form->id = post_params("id");
- $form->type = post_params("type");
- $res = $form->bindQrcode();
- return $this->asJson($res);
- }
- //绑定普通二维码
- public function actionBindMini(){
- $form = new NewSalesmanForm();
- $form->type = post_params("type",'weixin');
- $form->mini_id = post_params("id");
- $res = $form->bindPayQrcode();
- return $this->asJson($res);
- }
- //小程序绑定信息
- public function actionMiniInfo(){
- $form = new AggregateQrcodeForm();
- $res = $form->qrcodeBindInfo();
- return $this->asJson($res);
- }
- }
|