修复打印功能,增加判断是否推送打印任务,优化打印信息获取逻辑。

This commit is contained in:
mkm 2024-05-30 16:00:38 +08:00
parent c205a804cd
commit cae70f13aa
2 changed files with 43 additions and 2 deletions

View File

@ -6,6 +6,7 @@ namespace app\admin\controller\retail;
use app\admin\controller\BaseAdminController; use app\admin\controller\BaseAdminController;
use app\admin\lists\retail\CashierclassLists; use app\admin\lists\retail\CashierclassLists;
use app\admin\logic\retail\CashierclassLogic; use app\admin\logic\retail\CashierclassLogic;
use app\admin\logic\retail\CashierinfoLogic;
use app\admin\validate\retail\CashierclassValidate; use app\admin\validate\retail\CashierclassValidate;
use app\common\model\retail\Cashierclass; use app\common\model\retail\Cashierclass;
use Webman\RedisQueue\Redis; use Webman\RedisQueue\Redis;
@ -133,10 +134,21 @@ class CashierclassController extends BaseAdminController
public function prints() public function prints()
{ {
$id = $this->request->get('id'); $id = $this->request->get('id');
$is_push = $this->request->get('is_push',0);
if (!$id) { if (!$id) {
return $this->fail('参数错误'); return $this->fail('参数错误');
} }
Redis::send('push-platform-print', ['order_id' => $id]); if($is_push==0){
return $this->success('正在打印中'); 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);
}
}
} }
} }

View File

@ -5,6 +5,7 @@ namespace app\admin\logic\retail;
use app\common\model\retail\Cashierclass; use app\common\model\retail\Cashierclass;
use app\common\logic\BaseLogic; use app\common\logic\BaseLogic;
use app\common\model\goods\Goods;
use app\common\model\goods\Unit; use app\common\model\goods\Unit;
use app\common\model\merchant\Merchant; use app\common\model\merchant\Merchant;
use app\common\model\retail\Cashierinfo; use app\common\model\retail\Cashierinfo;
@ -164,4 +165,32 @@ class CashierclassLogic extends BaseLogic
} }
return $find; 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;
}
}
} }