|
| xqd
@@ -8,7 +8,10 @@
|
|
|
*/
|
|
|
namespace App\Http\Controllers\Admin\Card;
|
|
|
use App\Http\Controllers\Admin\Controller;
|
|
|
+use App\Models\CardInfoModel;
|
|
|
use App\Models\ProductCategoryModel;
|
|
|
+use App\Models\SettingInfoModel;
|
|
|
+use EasyWeChat\Factory;
|
|
|
use Illuminate\Http\Request;
|
|
|
use App\Repositories\Base\Criteria\OrderBy;
|
|
|
use App\Repositories\Card\Criteria\MultiWhere;
|
|
| xqd
@@ -113,6 +116,34 @@ class InfoController extends Controller
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ public function getQrcode($id)
|
|
|
+ {
|
|
|
+ $this->setting = SettingInfoModel::first();
|
|
|
+
|
|
|
+ $config = [
|
|
|
+ 'app_id' => $this->setting->app_id,
|
|
|
+ 'secret' => $this->setting->app_secret,
|
|
|
+
|
|
|
+ // 指定 API 调用返回结果的类型:array(default)/collection/object/raw/自定义类名
|
|
|
+ 'response_type' => 'array',
|
|
|
+ ];
|
|
|
+
|
|
|
+
|
|
|
+ $app = Factory::miniProgram($config);
|
|
|
+ $response = $app->app_code->getQrCode('/pages/card/active?card_no='.$id);
|
|
|
+ $path = public_path() . '/download';
|
|
|
+ $qrcode = $response->save($path, $id);
|
|
|
+ if ($qrcode) {
|
|
|
+ $qrcode = env('APP_URL') . '/download/' . $id . '.jpg';
|
|
|
+ $card = CardInfoModel::where('card_no',$id)->first();
|
|
|
+ $card->qrcode = $qrcode;
|
|
|
+ $card->save();
|
|
|
+ return true;
|
|
|
+ } else {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
public function store(Request $request)
|
|
|
{
|
|
|
$data = (array) request('data');
|
|
| xqd
@@ -124,6 +155,7 @@ class InfoController extends Controller
|
|
|
for ($i =0 ;$i<$number;$i++){
|
|
|
$data['card_no'] = time() . $i;
|
|
|
$this->repository->create($data);
|
|
|
+ $this->getQrcode($data['card_no']);
|
|
|
}
|
|
|
|
|
|
return back();
|