| 123456789101112131415161718192021222324252627282930313233343536373839404142 |
- <?php
- namespace app\workerapi\logic;
- use app\common\logic\BaseLogic;
- use app\common\service\wechat\WeChatConfigService;
- use app\common\service\wechat\WeChatMnpService;
- use EasyWeChat\MiniApp\Application;
- use think\facade\Db;
- /**
- * 服务商品逻辑处理
- * Class GoodsCategoryLogic
- * @package app\workerapi\logic
- */
- class GoodsCategoryLogic extends BaseLogic
- {
- /**
- * @return string|void
- */
- public static function getQRCode($params)
- {
- try {
- $response = (new WeChatMnpService())->getUnlimitedQRCode(
- 'type=2&id='.$params['id'].'worker_number='.$params['user_info']['worker_number'],
- "pages/good/good",
- 'trial',
- false
- );
- $qrcode = $response->getContent();
- if(!is_dir('./uploads/wx_qrcode/'.date('Ymd'))){
- mkdir('./uploads/wx_qrcode/'.date('Ymd'));
- }
- $file_name = 'uploads/wx_qrcode/'.date('Ymd').'/'.time().rand(1000,9999).'.png';
- file_put_contents($file_name, $qrcode);
- return $file_name;
- } catch (\Throwable $e) {
- // 失败
- echo $e->getMessage();
- }
- }
- }
|