public function actionGetMember() { $card = Yii::app()->request->getParam('card', 0); $criteria = new CDbCriteria(); $criteria->addCondition('dpid=:dpid and delete_flag=0'); if ($card) { $criteria->addCondition('rfid=:card'); $criteria->addCondition('selfcode=:card', 'OR'); $criteria->addCondition('name=:card', 'OR'); $criteria->addCondition('mobile=:card', 'OR'); $criteria->params[':card'] = $card; } $criteria->order = ' lid desc '; $criteria->params[':dpid'] = $this->companyId; $model = MemberCard::model()->find($criteria); if ($model) { $res = array('rfid' => $model->rfid, 'selfcode' => $model->selfcode, 'all_money' => $model->all_money, 'name' => $model->name, 'mobile' => $model->mobile, 'email' => $model->email); Yii::app()->end(json_encode(array('status' => true, 'msg' => $res))); } else { Yii::app()->end(json_encode(array('status' => false, 'msg' => '没有查询到该会员信息'))); } }
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); }