GoodsCategoryLogic.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. namespace app\workerapi\logic;
  3. use app\common\logic\BaseLogic;
  4. use app\common\service\wechat\WeChatConfigService;
  5. use app\common\service\wechat\WeChatMnpService;
  6. use EasyWeChat\MiniApp\Application;
  7. use think\facade\Db;
  8. /**
  9. * 服务商品逻辑处理
  10. * Class GoodsCategoryLogic
  11. * @package app\workerapi\logic
  12. */
  13. class GoodsCategoryLogic extends BaseLogic
  14. {
  15. /**
  16. * @return string|void
  17. */
  18. public static function getQRCode($params)
  19. {
  20. try {
  21. $response = (new WeChatMnpService())->getUnlimitedQRCode(
  22. 'type=2&id='.$params['id'].'worker_number='.$params['user_info']['worker_number'],
  23. "pages/good/good",
  24. 'trial',
  25. false
  26. );
  27. $qrcode = $response->getContent();
  28. if(!is_dir('./uploads/wx_qrcode/'.date('Ymd'))){
  29. mkdir('./uploads/wx_qrcode/'.date('Ymd'));
  30. }
  31. $file_name = 'uploads/wx_qrcode/'.date('Ymd').'/'.time().rand(1000,9999).'.png';
  32. file_put_contents($file_name, $qrcode);
  33. return $file_name;
  34. } catch (\Throwable $e) {
  35. // 失败
  36. echo $e->getMessage();
  37. }
  38. }
  39. }