OtherOrder.php 3.6 KB

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