OtherOrder.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\controller\admin\v1\order;
  12. use app\controller\admin\AuthController;
  13. use app\services\order\OtherOrderServices;
  14. use app\services\other\QrcodeServices;
  15. use crmeb\utils\Canvas;
  16. use think\facade\App;
  17. /**
  18. * Class OtherOrder
  19. * @package app\controller\admin\v1\order
  20. */
  21. class OtherOrder extends AuthController
  22. {
  23. /**
  24. * OtherOrder constructor.
  25. * @param App $app
  26. * @param OtherOrderServices $service
  27. */
  28. public function __construct(App $app, OtherOrderServices $service)
  29. {
  30. parent::__construct($app);
  31. $this->services = $service;
  32. }
  33. /**
  34. * 线下收银
  35. * @return mixed
  36. * @throws \think\db\exception\DataNotFoundException
  37. * @throws \think\db\exception\DbException
  38. * @throws \think\db\exception\ModelNotFoundException
  39. */
  40. public function scan_list()
  41. {
  42. $where = $this->request->getMore([
  43. ['order_id', ''],
  44. ['add_time', ''],
  45. ['name', ''],
  46. ['page', 1],
  47. ['limit', 20],
  48. ]);
  49. $data = $this->services->getScanOrderList($where);
  50. return $this->success($data);
  51. }
  52. /**
  53. * 获取线下二维码
  54. * @return mixed
  55. * @throws \Exception
  56. */
  57. public function offline_scan()
  58. {
  59. [$type] = $this->request->getMore([
  60. ['type', 1]
  61. ], true);
  62. //生成h5地址
  63. $weixinPage = "/pages/annex/offline_pay/index";
  64. $weixinFileName = "wechat_offline_scan.png";
  65. /** @var QrcodeServices $QrcodeService */
  66. $QrcodeService = app()->make(QrcodeServices::class);
  67. $wechatQrcode = $QrcodeService->getWechatQrcodePath($weixinFileName, $weixinPage, false, false);
  68. //生成小程序地址
  69. $routineQrcode = $QrcodeService->getRoutineQrcodePath(4, 6, 3, [], false);
  70. $qrcod = ['wechat' => $wechatQrcode, 'routine' => $routineQrcode];
  71. if ($type) {
  72. //生成画布
  73. $canvas = Canvas::instance();
  74. $path = 'uploads/offline/';
  75. $imageType = 'jpg';
  76. $siteUrl = sys_config('site_url');
  77. $canvas->setImageUrl(public_path() . 'statics/qrcode/offlines.jpg')->setImageHeight(730)->setImageWidth(500)->pushImageValue();
  78. foreach ($qrcod as $k => $v) {
  79. if ($v) {
  80. $name = 'offline_' . $k;
  81. $canvas->setImageUrl($v)->setImageHeight(344)->setImageWidth(344)->setImageLeft(76)->setImageTop(120)->pushImageValue();
  82. $image = $canvas->setFileName($name)->setImageType($imageType)->setPath($path)->setBackgroundWidth(500)->setBackgroundHeight(720)->starDrawChart();
  83. $data[$k] = $image ? $siteUrl . '/' . $image : '';
  84. } else {
  85. $data[$k] = "";
  86. }
  87. }
  88. } else {
  89. $data = ['wechat' => $wechatQrcode, 'routine' => $routineQrcode];
  90. }
  91. return $this->success($data);
  92. }
  93. }