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('store_id, 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); $business_no = null; $wechatConfig = WechatConfig::find()->where(['store_id' => $ag->store_id])->select('mch_id')->one(); if ($wechatConfig) { $business_no = $wechatConfig->mch_id; } $form = new ShareQrcodeForm(); $form->store_id = $ag->store_id; $formRes = $form->aggregateSaasQrcode($path, $business_no); if($formRes['code'] == 0){ $pic_url = $formRes['data']['pic_url']; } // var_dump($formRes);die; $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 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); } //获取新的二维码信息 public function actionShowQrcode() { $form = new AggregateQrcodeForm(); $res = $form->showQrcode(); return $this->asJson($res); } }