0, 'msg' => '缺少参数,请刷新重试'); return $res; } $map = array( $this::STORE_ID => $store_id, $this::STATUS => 2 ); $print_set = $this->getSelect($map);//查询该门店是否配置打印机或已开启打印机 if (empty($print_set)) { $res = array('status' => 0, 'msg' => '暂无可用打印机,请查看后台'); return $res; } $res = array( 'status' => 1, 'msg' => '查询打印机成功', 'data' => array( 'print_set' => $print_set ) ); return $res; } /** * 获取打印信息 * @param $parameter * @return mixed */ public function getPrintInfo($parameter) { $BillModel = D('RetailBillOrder'); $SellModel = D('RetailSell'); $store_id = $parameter['store_id']; $bill_id = $parameter['bill_id']; $store_name = D('RetailStore')->getFindField(array('id' => $store_id), 'storetag'); //门店名称 $map = array( $BillModel::ID => strval($bill_id), $BillModel::STORE_ID => $store_id, ); $bill_order = $BillModel->getFind($map);//查询要打印的订单详情 if (empty($bill_order)) { $res = array('status' => 0, 'msg' => '订单不存在'); return $res; } $vip_info = array(); if (!empty($bill_order[$BillModel::VID])) { $VipModel = D('RetailVip'); $vip_info = $VipModel->getFind(array($VipModel::ID => $bill_order[$BillModel::VID])); } $type = $bill_order[$BillModel::TYPE]; $bill_online = array(); if ($type == 1) {//商城 $BillOnlineModel = D('RetailBillOnline'); $bill_online = $BillOnlineModel->getFind(array($BillOnlineModel::BILL_ID => $bill_id)); $address_info['phone'] = $bill_online[$BillOnlineModel::USER_PHONE]; $address_info['name'] = $bill_online[$BillOnlineModel::USER_NAME]; if ($bill_online[$BillOnlineModel::PICKUP_TYPE] == 2 || $bill_online[$BillOnlineModel::PICKUP_TYPE] == 3) { //配送 $address_info['address'] = $bill_online[$BillOnlineModel::USER_ADDRESS]; } else { $address_info['address'] = "自提"; } switch ($bill_online['pickup_type']) { case 1: $bill_online['pickup_name'] = "自提"; break; case 2: $bill_online['pickup_name'] = "商家配送"; break; case 3: $bill_online['pickup_name'] = "快递发货"; break; default: $bill_online['pickup_name'] = "不详"; break; } switch ($bill_online['order_genre']) { case 4: //预售活动 $advance_order = D("RetailBillAdvance")->getFind(array('bill_id' => $bill_order['id'])); if ($advance_order['advance_type'] == 2) { //定金+尾款 $advance_order['all_arrive_price'] = $advance_order['all_arrive_price'] ? $advance_order['all_arrive_price'] : ''; //定金抵现 $advance_order['earnest_pay_time'] = date('Y-m-d H:i:s', $advance_order['earnest_pay_time']); //定金支付时间 $advance_order['tail_price'] = round($bill_order['all_money'] - $advance_order['all_earnest_price'], 2); //尾款 } if ($advance_order['state'] == 2) { $trade_date = D("RetailPayOrder")->getFindField(array('id' => $advance_order['tail_pay_order_id']), "trade_date"); $advance_order['tail_time'] = date('Y-m-d H:i:s', $trade_date); } break; } } else { $address_info = array(); } $map = array( 's.' . $SellModel::BILL_ID => $bill_id, ); $sell_goods = $SellModel->getSelectAndGoods($map, 's.*,g.label_id'); $bill_order['before_money'] = 0; foreach ($sell_goods as &$val) { if ($val['goods_gifts_id']) { $val['goods_name'] = '[赠]' . $val['goods_name']; } $val['unit_price'] = $val['price']; $val['before_money'] = round($val['unit_price'] * $val['num'], 2); $bill_order['before_money'] += $val['before_money']; } $BillDisModel = D('RetailBillDiscount'); $bill_discount = $BillDisModel->getFind(array($BillDisModel::BILL_ID => $bill_id)); if ($type == 1 && $bill_online['order_genre'] == 4) { $pay_list = D("RetailBillAdvance")->payMode($advance_order); } else { //支付方式列表 $pay_list = getPayTypeList($bill_order[$BillModel::PAY_TYPE], $bill_order[$BillModel::ALL_MONEY], $bill_order[$BillModel::ID]); } $cashier_name = ''; //收银员姓名 if (!empty($bill_order[$BillModel::CASHIER_ID])) { $CashierModel = D('RetailCashier'); $cashier_name = $CashierModel->getFindField(array($CashierModel::ID => $bill_order[$BillModel::CASHIER_ID]), $CashierModel::NAME); } $guide_name = '';//导购员姓名 if (!empty($bill_order[$BillModel::GUIDE_ID])) { $GuideModel = D('RetailGuide'); $guide_name = $GuideModel->getFindField(array($GuideModel::ID => $bill_order[$BillModel::GUIDE_ID]), $GuideModel::NAME); } $print_info = array( 'store_name' => $store_name, 'bill_order' => $bill_order, 'pay_list' => $pay_list, 'address_info' => $address_info, 'bill_online' => $bill_online, 'bill_discount' => $bill_discount, 'vip_info' => $vip_info, 'guide_name' => $guide_name, 'cashier_name' => $cashier_name, ); if ($type == 1 && $bill_online['order_genre'] == 4) { //线上预售活动订单信息 $print_info['advance_order'] = $advance_order; } $res = array( 'status' => 1, 'msg' => '查询成功', 'data' => array( 'print_info' => $print_info, 'type' => $type, 'sell_goods' => $sell_goods ) ); return $res; } }