public function actionOrderAccount() { $companyId = Yii::app()->request->getParam('companyId', "0"); $orderid = Yii::app()->request->getParam('orderid', "0"); $orderstatus = Yii::app()->request->getParam('orderstatus', "0"); $paycashaccount = floatval(str_replace(",", "", Yii::app()->request->getPost('paycashaccount', "0"))); $payothers = floatval(str_replace(",", "", Yii::app()->request->getPost('payothers', "0"))); $paymemberaccount = floatval(str_replace(",", "", Yii::app()->request->getPost('paymemberaccount', "0"))); $payunionaccount = floatval(str_replace(",", "", Yii::app()->request->getPost('payunionaccount', "0"))); $payshouldaccount = floatval(str_replace(",", "", Yii::app()->request->getPost('payshouldaccount', "0"))); $payoriginaccount = floatval(str_replace(",", "", Yii::app()->request->getPost('payoriginaccount', "0"))); $cardno = Yii::app()->request->getParam('cardno', "0000000000"); $ordermemo = Yii::app()->request->getPost('ordermemo', "0"); //存数order order_pay 0现金,4会员卡,5银联 //写入会员卡消费记录,会员卡总额减少 $ret; $time = date('Y-m-d H:i:s', time()); $db = Yii::app()->db; if (!Until::validOperateJson($companyId, $this)) { Yii::app()->end(json_encode(array('status' => false, 'msg' => "云端不能操作本地数据"))); } $transaction = $db->beginTransaction(); try { $order = Order::model()->with("company")->find(" t.lid=:lid and t.dpid=:dpid", array(":lid" => $orderid, ":dpid" => $companyId)); if ($order->order_status > "3") { $transaction->rollback(); $ret = json_encode(array('status' => false, 'msg' => "已经结单")); Yii::app()->end($ret); } $order->should_total = $payoriginaccount; $order->reality_total = $payshouldaccount; $order->update_at = $time; $order->order_status = $orderstatus; $order->remark = $order->remark + $ordermemo; $order->save(); // $criteria = new CDbCriteria; // $criteria->condition = 't.dpid='.$companyId.' and t.site_id='.$order->site_id.' and t.is_temp='.$order->is_temp ; // $criteria->order = ' t.lid desc '; // $siteNo = SiteNo::model()->find($criteria); // $siteNo->status=$orderstatus; // $siteNo->save(); //为了删除脏数据,这里用全部的update $sitenosql = "update nb_site_no set status=" . $orderstatus . " where dpid=" . $companyId . " and site_id=" . $order->site_id . " and is_temp=" . $order->is_temp; $db->createCommand($sitenosql)->execute(); //order site 和 siteno都需要更新状态 所以要取出来 if ($order->is_temp == "0") { $criteria2 = new CDbCriteria(); $criteria2->condition = 't.dpid=' . $companyId . ' and t.lid=' . $order->site_id; $criteria2->order = ' t.lid desc '; $site = Site::model()->with("siteType")->find($criteria2); $site->status = $orderstatus; $site->save(); } $se = new Sequence("order_pay"); //Yii::app()->end(json_encode(array('status'=>false,'msg'=>"测试啊"))); if ($paycashaccount > 0) { $orderPayId = $se->nextval(); //插入一条 $orderPayData = array('lid' => $orderPayId, 'dpid' => $companyId, 'create_at' => $time, 'order_id' => $orderid, 'update_at' => $time, 'pay_amount' => $paycashaccount, 'paytype' => "0", 'payment_method_id' => "0000000000", 'remark' => '现金付款'); $db->createCommand()->insert('nb_order_pay', $orderPayData); } if ($paymemberaccount > 0) { $membercard = MemberCard::model()->find(' dpid=:dpid and (rfid =:rfid or selfcode =:selfcode) and delete_flag =0', array(":dpid" => $companyId, ":rfid" => $cardno, ":selfcode" => $cardno)); // $ret=json_encode(array('status'=>false,'msg'=>$paymemberaccount )); // Yii::app()->end($ret); if ($membercard->all_money >= $paymemberaccount) { $membercard->all_money = $membercard->all_money - $paymemberaccount; $membercard->save(); } else { $transaction->rollback(); $ret = json_encode(array('status' => false, 'msg' => "会员卡余额不足")); Yii::app()->end($ret); } $orderPayId = $se->nextval(); //插入一条 $orderPayData = array('lid' => $orderPayId, 'dpid' => $companyId, 'create_at' => $time, 'order_id' => $orderid, 'update_at' => $time, 'pay_amount' => $paymemberaccount, 'paytype' => "4", 'payment_method_id' => $cardno, 'remark' => '会员卡付款'); $db->createCommand()->insert('nb_order_pay', $orderPayData); } if ($payunionaccount > 0) { $orderPayId = $se->nextval(); //插入一条 $orderPayData = array('lid' => $orderPayId, 'dpid' => $companyId, 'create_at' => $time, 'order_id' => $orderid, 'update_at' => $time, 'pay_amount' => $payunionaccount, 'paytype' => "5", 'payment_method_id' => "0000000000", 'remark' => '银联卡付款'); $db->createCommand()->insert('nb_order_pay', $orderPayData); } if ($payothers > 0) { $orderPayId = $se->nextval(); //插入一条 $orderPayData = array('lid' => $orderPayId, 'dpid' => $companyId, 'create_at' => $time, 'order_id' => $orderid, 'update_at' => $time, 'pay_amount' => $payothers, 'paytype' => "3", 'payment_method_id' => "3990000000", 'remark' => '大众点评临时'); $db->createCommand()->insert('nb_order_pay', $orderPayData); } $transaction->commit(); $ret = json_encode(array('status' => true, 'msg' => "结单成功")); } catch (Exception $ex) { $transaction->rollback(); $ret = json_encode(array('status' => false, 'msg' => "结单失败")); } Yii::app()->end($ret); }
public function actionOpensiteprint() { if (Yii::app()->request->isPostRequest) { $sid = Yii::app()->request->getPost('sid'); $siteNumber = Yii::app()->request->getPost('siteNumber'); $companyId = Yii::app()->request->getPost('companyId'); $padId = Yii::app()->request->getPost('padId', "0000000000"); if (!Until::validOperateJson($companyId, $this)) { $ret = json_encode(array('status' => 0, 'msg' => yii::t('app', '云端不能操作本地数据'), 'siteid' => $sid)); Yii::app()->end($ret); } //$sid = Yii::app()->request->getPost('sid'); $istemp = Yii::app()->request->getPost('istemp', '0'); $ret = SiteClass::openSite($companyId, $siteNumber, $istemp, $sid); if ($ret["status"] == 1) { $siteno; $site = new Site(); $siteid = $ret['siteid']; $criteria = new CDbCriteria(); $criteria->condition = 't.dpid=' . $companyId . ' and t.site_id=' . $siteid . ' and t.is_temp=' . $istemp; $criteria->order = ' t.lid desc '; $siteno = SiteNo::model()->find($criteria); //Yii::app()->end(json_encode(array('status'=>0,'msg'=>"222"))); //order site 和 siteno都需要更新状态 所以要取出来 if ($istemp == "0") { $criteria2 = new CDbCriteria(); $criteria2->condition = 't.dpid=' . $companyId . ' and t.lid=' . $siteid; $criteria2->order = ' t.lid desc '; $site = Site::model()->with("siteType")->find($criteria2); } $pad = Pad::model()->find(' dpid=:dpid and lid=:lid', array(':dpid' => $companyId, 'lid' => $padId)); if (!empty($pad)) { //$precode="1B70001EFF00";//开钱箱 $precode = ""; $printserver = "1"; $memo = "请等待叫号!"; $ret = Helper::printSite($siteno, $site, $pad, $precode, $printserver, $memo); } else { $ret = array('status' => 0, 'msg' => yii::t('app', '没有找到PAD'), 'siteid' => $siteid); } } Yii::app()->end(json_encode($ret)); } }