From cae70f13aa870c958a59b53ef3f987b54040ad9b Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Thu, 30 May 2024 16:00:38 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=89=93=E5=8D=B0=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=EF=BC=8C=E5=A2=9E=E5=8A=A0=E5=88=A4=E6=96=AD=E6=98=AF?= =?UTF-8?q?=E5=90=A6=E6=8E=A8=E9=80=81=E6=89=93=E5=8D=B0=E4=BB=BB=E5=8A=A1?= =?UTF-8?q?=EF=BC=8C=E4=BC=98=E5=8C=96=E6=89=93=E5=8D=B0=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E8=8E=B7=E5=8F=96=E9=80=BB=E8=BE=91=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../retail/CashierclassController.php | 16 ++++++++-- app/admin/logic/retail/CashierclassLogic.php | 29 +++++++++++++++++++ 2 files changed, 43 insertions(+), 2 deletions(-) diff --git a/app/admin/controller/retail/CashierclassController.php b/app/admin/controller/retail/CashierclassController.php index d9b9e87..07b9375 100644 --- a/app/admin/controller/retail/CashierclassController.php +++ b/app/admin/controller/retail/CashierclassController.php @@ -6,6 +6,7 @@ namespace app\admin\controller\retail; use app\admin\controller\BaseAdminController; use app\admin\lists\retail\CashierclassLists; use app\admin\logic\retail\CashierclassLogic; +use app\admin\logic\retail\CashierinfoLogic; use app\admin\validate\retail\CashierclassValidate; use app\common\model\retail\Cashierclass; use Webman\RedisQueue\Redis; @@ -133,10 +134,21 @@ class CashierclassController extends BaseAdminController public function prints() { $id = $this->request->get('id'); + $is_push = $this->request->get('is_push',0); if (!$id) { return $this->fail('参数错误'); } - Redis::send('push-platform-print', ['order_id' => $id]); - return $this->success('正在打印中'); + if($is_push==0){ + Redis::send('push-platform-print', ['order_id' => $id]); + return $this->success('正在打印中'); + }else{ + $res=CashierclassLogic::prints($id); + if(CashierclassLogic::hasError()){ + return $this->fail('打印失败'); + }else{ + return $this->success('ok',$res); + } + } + } } diff --git a/app/admin/logic/retail/CashierclassLogic.php b/app/admin/logic/retail/CashierclassLogic.php index 0a52bc4..6362811 100644 --- a/app/admin/logic/retail/CashierclassLogic.php +++ b/app/admin/logic/retail/CashierclassLogic.php @@ -5,6 +5,7 @@ namespace app\admin\logic\retail; use app\common\model\retail\Cashierclass; use app\common\logic\BaseLogic; +use app\common\model\goods\Goods; use app\common\model\goods\Unit; use app\common\model\merchant\Merchant; use app\common\model\retail\Cashierinfo; @@ -164,4 +165,32 @@ class CashierclassLogic extends BaseLogic } return $find; } + + /** + * 打印 + */ + public static function prints($id){ + $find = Cashierclass::where('id', $id)->where('is_print',0)->field('id,merchant,real_name,user_phone,user_address,uid,number,total,actual,create_time')->find(); + if ($find) { + $merchant = Merchant::where('mer_id', $find['merchant'])->field('mer_name,uid,service_phone')->find(); + $mer_user_info = User::where('id', $merchant['uid'])->field('real_name,mobile')->find(); + $user = User::where('id', $find['uid'])->field('nickname,mobile')->find(); + $find['mer_name'] = $merchant['mer_name']; + $find['mer_phone'] = $merchant['service_phone']; + $find['mer_nickname'] = $mer_user_info['real_name']; + $find['mer_user_mobile'] = $mer_user_info['mobile']; + $find['nickname'] = $user['nickname']; + $find['user_mobile'] = $user['mobile']; + $find['info'] = Cashierinfo::where('pid', $find['id'])->field('goods,nums,price,total')->select()->each(function ($item) { + $goods = Goods::where('id', $item['goods'])->field('name,unit')->find(); + $item['unit_name'] = Unit::where('id', $goods['unit'])->value('name'); + $item['goods_name'] = $goods['name']; + return $item; + }); + return $find; + }else{ + self::setError('订单不存在'); + return false; + } + } } \ No newline at end of file