本文整理汇总了PHP中Store::instance方法的典型用法代码示例。如果您正苦于以下问题:PHP Store::instance方法的具体用法?PHP Store::instance怎么用?PHP Store::instance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Store
的用法示例。
在下文中一共展示了Store::instance方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getInstance
public static function getInstance()
{
if (!isset(self::$instance)) {
self::$instance = new Store();
}
return self::$instance;
}
示例2: initialize
public static function initialize($path)
{
Config::setPath($path . 'config/');
self::$request = Request::instance();
self::$config = Config::instance();
self::$store = Store::instance();
}
示例3: get
public static function get()
{
if (null == self::$instance) {
self::$instance = new Redis('localhost');
self::$instance->connect();
}
return self::$instance;
}
示例4: connect
public static function connect()
{
if (!self::$instance) {
self::$instance = new Memcache();
self::$instance->addServer('127.0.0.1', 11211);
}
return self::$instance;
}
示例5: deleteCode
public static function deleteCode($companyId, $code)
{
Gateway::getOnlineStatus();
$store = Store::instance('wymenu');
$ret = $store->delete($companyId . $code);
/*if(Yii::app()->params->has_cache)
{
$ccode = apc_delete($companyId.$code);
}*/
}
示例6: sendCmdAndMessageToClient
/**
* 想某个用户网关发送命令和消息
* @param int $client_id
* @param int $cmd
* @param string $message
* @return bool
*/
protected static function sendCmdAndMessageToClient($client_id, $cmd, $message)
{
// 如果是发给当前用户则直接获取上下文中的地址
if ($client_id === Context::$client_id || $client_id === null) {
$address = Context::$local_ip . ':' . Context::$local_port;
} else {
$address = Store::instance('gateway')->get('client_id-' . $client_id);
if (!$address) {
return false;
}
}
$gateway_data = GatewayProtocol::$empty;
$gateway_data['cmd'] = $cmd;
$gateway_data['client_id'] = $client_id ? $client_id : Context::$client_id;
$gateway_data['body'] = $message;
return self::sendToGateway($address, $gateway_data);
}
示例7: sendToAllGateway
/**
* 向所有gateway发送数据
* @param string $gateway_data
*/
protected static function sendToAllGateway($gateway_data)
{
// 如果有businessWorker实例,说明运行在workerman环境中,通过businessWorker中的长连接发送数据
if (self::$businessWorker) {
foreach (self::$businessWorker->gatewayConnections as $gateway_connection) {
$gateway_connection->send($gateway_data);
}
} else {
$all_addresses = Store::instance('gateway')->get('GLOBAL_GATEWAY_ADDRESS');
if (!$all_addresses) {
throw new \Exception('GLOBAL_GATEWAY_ADDRESS is ' . var_export($all_addresses, true));
}
foreach ($all_addresses as $address) {
self::sendToGateway($address, $gateway_data);
}
}
}
示例8: actionPrintListNetResult
public function actionPrintListNetResult()
{
$companyId = Yii::app()->request->getParam('companyId');
$jobid = Yii::app()->request->getParam('jobid');
Gateway::getOnlineStatus();
$store = Store::instance('wymenu');
$jobresult = $store->get('job_' . $companyId . "_" . $jobid . '_result');
//var_dump($jobresult);exit;
if (empty($jobresult)) {
$ret = array('status' => false, 'msg' => yii::t('app', '任务未返回'));
} else {
if ($jobresult == "success") {
$ret = array('status' => true, 'msg' => yii::t('app', '打印成功'));
} else {
$ret = array('status' => false, 'msg' => yii::t('app', '打印机执行任务失败'));
}
}
Yii::app()->end(json_encode($ret));
}
示例9: actionGateway
public function actionGateway()
{
//var_dump( Yii::app()->request->baseUrl.'/protected/components/Config/Store.php');exit;
var_dump(Gateway::getOnlineStatus());
$store = Store::instance('wymenu');
$printData = $store->get('0000000012');
var_dump($printData);
exit;
$ret = $store->set('0000000012', '上海滩的愛している222');
echo "ddd";
//Gateway::sendToAll(json_encode(array(a=>"上海滩的愛している",b=>"ddddd11111:")));
Gateway::sendToAll('{"a":"上海滩的愛している","b":"ddddd11111:"}');
echo "eee";
}
示例10: actionGetJob
public function actionGetJob()
{
$companyid1 = Yii::app()->request->getParam('companyid', "0");
$jobid1 = Yii::app()->request->getParam('jobid', "0");
$companyid = str_pad($companyid1, 10, "0", STR_PAD_LEFT);
$jobid = str_pad($jobid1, 10, "0", STR_PAD_LEFT);
//var_dump($jobid);exit;
Gateway::getOnlineStatus();
$store = Store::instance('wymenu');
$printData = $store->get($companyid . "_" . $jobid);
if (empty($printData)) {
$criteria = new CDbCriteria();
$criteria->condition = 't.dpid=' . $companyid . ' and t.jobid=' . $jobid;
//.' and t.finish_flag=0';
//$criteria->order = ' t.lid desc ';
//$siteNo = SiteNo::model()->find($criteria);
$orderprintjobs = OrderPrintjobs::model()->find($criteria);
if (!empty($orderprintjobs)) {
$printData = $orderprintjobs->content;
} else {
$printData = "";
}
$store->set($companyid . "_" . $jobid, $printData, 0, 30);
}
// echo $printData;
Yii::app()->end($printData);
}
示例11: actionResetall
public function actionResetall()
{
$typeId = Yii::app()->request->getParam('typeId');
$db = Yii::app()->db;
$sql = '';
if ($typeId == 'product') {
$sql = 'update nb_product set store_number = -1 where dpid=' . $this->companyId;
} else {
$sql = 'update nb_product_set set store_number = -1 where dpid=' . $this->companyId;
}
//var_dump($sql);exit;
$command = $db->createCommand($sql);
if ($command->execute()) {
Gateway::getOnlineStatus();
$store = Store::instance('wymenu');
$pads = Pad::model()->findAll(" dpid = :dpid and delete_flag='0' and pad_type in ('1','2')", array(":dpid" => $this->companyId));
//var_dump($pads);exit;
$sendjsondata = json_encode(array("company_id" => $this->companyId, "do_id" => "sell_off", "do_data" => array(array("product_id" => $id, "type" => $typeId, "num" => $store_number))));
//var_dump($sendjsondata);exit;
foreach ($pads as $pad) {
$clientId = $store->get("padclient_" . $this->companyId . $pad->lid);
//var_dump($clientId,$print_data);exit;
if (!empty($clientId)) {
Gateway::sendToClient($clientId, $sendjsondata);
}
}
Yii::app()->end(json_encode(array("status" => "success")));
} else {
Yii::app()->end(json_encode(array("status" => "fail")));
}
}
示例12: createPadOrder
//.........这里部分代码省略.........
$orderProductId = $se->nextval();
if ($result['store_number'] > 0) {
$sql = 'update nb_product set store_number=store_number-' . $amount . ' where dpid=' . $dpid . ' and lid=' . $goodsArr[0];
$db->createCommand($sql)->execute();
array_push($sellOff, array("product_id" => sprintf("%010d", $goodsArr[0]), "type" => "product", "num" => $result['store_number'] - $amount));
}
$sqladd = 'update nb_product set order_number=order_number+' . $amount . ',favourite_number=favourite_number+' . $amount . ' where dpid=' . $dpid . ' and lid=' . $goodsArr[0];
$db->createCommand($sqladd)->execute();
}
} else {
if ($result) {
if ($result['store_number'] == 0 || $result['store_number'] > 0 && $result['store_number'] < $num) {
throw new Exception(json_encode(array('status' => false, 'dpid' => $dpid, 'jobid' => "0", 'type' => 'local', 'msg' => yii::t('app', $result['product_name'] . '库存不足!'))));
}
} else {
throw new Exception(json_encode(array('status' => false, 'dpid' => $dpid, 'jobid' => "0", 'type' => 'local', 'msg' => yii::t('app', '没有找到该产品请清空后重新下单!'))));
}
$orderProductData = array('lid' => $orderProductId, 'dpid' => $dpid, 'create_at' => $time, 'order_id' => $orderId, 'set_id' => 0, 'product_id' => $goodsArr[0], 'price' => $productPrice, 'update_at' => $time, 'amount' => $num, 'taste_memo' => "", 'product_order_status' => $orderPorductStatus);
$db->createCommand()->insert('nb_order_product', $orderProductData);
$orderPrice += $productPrice * $num;
array_push($printOrderProducts, array('amount' => $num, 'price' => $productPrice, 'product_name' => ProductClass::getProductName($goodsArr[0], $dpid)));
if ($result['store_number'] > 0) {
$sql = 'update nb_product set store_number=store_number-' . $num . ' where dpid=' . $dpid . ' and lid=' . $goodsArr[0];
$db->createCommand($sql)->execute();
array_push($sellOff, array("product_id" => sprintf("%010d", $goodsArr[0]), "type" => "product", "num" => $result['store_number'] - $num));
}
$sqladd = 'update nb_product set order_number=order_number+' . $num . ',favourite_number=favourite_number+' . $num . ' where dpid=' . $dpid . ' and lid=' . $goodsArr[0];
$db->createCommand($sqladd)->execute();
}
}
}
}
$sql = 'update nb_order set should_total=' . $orderPrice . ' where lid=' . $orderId . ' and dpid=' . $dpid;
$db->createCommand($sql)->execute();
// $sql = 'update nb_site_no set status='.$orderPrice.' where lid='.$orderId.' and dpid='.$dpid;
// $db->createCommand($sql)->execute();
// return json_encode(array('status'=>false,'msg'=>"test22"));
//厨打
if ($orderId != '0') {
$order = Order::model()->with('company')->find(' t.lid=:lid and t.dpid=:dpid and t.order_status in(1,2,3)', array(':lid' => $orderId, ':dpid' => $dpid));
//Yii::app()->end(json_encode(array('status'=>false,'msg'=>"234")));
if (empty($order)) {
return json_encode(array('status' => false, 'msg' => "该订单不存在"));
}
}
// return json_encode(array('status'=>false,'msg'=>"test2236"));
if ($order->is_temp == "0") {
// return json_encode(array('status'=>false,'msg'=>"test2235"));
$criteria = new CDbCriteria();
$criteria->condition = 't.dpid=' . $dpid . ' and t.site_id=' . $order->site_id . ' and t.is_temp=' . $order->is_temp;
$criteria->order = ' t.lid desc ';
$siteNo = SiteNo::model()->find($criteria);
//order site 和 siteno都需要更新状态 所以要取出来
$criteria2 = new CDbCriteria();
$criteria2->condition = 't.dpid=' . $dpid . ' and t.lid=' . $order->site_id;
$criteria2->order = ' t.lid desc ';
$site = Site::model()->with("siteType")->find($criteria2);
// return json_encode(array('status'=>false,'msg'=>"test8"));
$printList = Helper::printKitchenAll3($order, $site, $siteNo, false);
} else {
// return json_encode(array('status'=>false,'msg'=>"test223"));
$pad = Pad::model()->with('printer')->find(' t.dpid=:dpid and t.lid=:lid', array(':dpid' => $order->dpid, 'lid' => $padId));
//前面加 barcode
$precode = "1D6B450B" . strtoupper(implode('', unpack('H*', 'A' . $order->lid))) . "0A" . strtoupper(implode('', unpack('H*', 'A' . $order->lid))) . "0A";
$orderProducts = OrderProduct::getOrderProducts($order->lid, $order->dpid);
//var_dump($orderProducts);exit;
//return json_encode(array('status'=>false,'msg'=>"test2234"));
$memo = "清单";
$printList = Helper::printList($order, $orderProducts, $pad, $precode, "0", $memo);
}
if (!$printList['status']) {
throw new Exception(json_encode($printList));
}
//$printList2=array_merge($printList,array('sitenoid'=> $lid));
// }
$transaction->commit();
//估清产品通知
if (!empty($sellOff)) {
Gateway::getOnlineStatus();
$store = Store::instance('wymenu');
$pads = Pad::model()->findAll(" dpid = :dpid and delete_flag='0' and pad_type in ('0','1','2')", array(":dpid" => $dpid));
//var_dump($pads);exit;
$sendjsondata = json_encode(array("company_id" => $dpid, "do_id" => "sell_off", "do_data" => $sellOff));
//var_dump($sendjsondata);exit;
foreach ($pads as $pad) {
$clientId = $store->get("padclient_" . $dpid . $pad->lid);
//var_dump($clientId,$print_data);exit;
if (!empty($clientId)) {
Gateway::sendToClient($clientId, $sendjsondata);
}
}
}
return json_encode($printList);
} catch (Exception $e) {
$transaction->rollback();
//如果操作失败, 数据回滚
throw new Exception($e->getMessage());
//return $e->getMessage();
}
}
示例13: printConetent2
public static function printConetent2(Printer $printer, $contents, $precode, $sufcode, $printserver, $orderid)
{
Gateway::getOnlineStatus();
$store = Store::instance('wymenu');
$contentCode = "";
$contentCodeAll = "";
foreach ($contents as $content) {
//内容编码
if ($printer->language == '1') {
foreach ($content as $line) {
//$strcontent=mb_convert_encoding($line,"GBK","UTF-8");
//$contentCode.=strtoupper(implode('',unpack('H*', $strcontent)))."0A";
$strcontent = mb_convert_encoding(substr($line, 2), "GBK", "UTF-8");
$strfontsize = substr($line, 0, 2);
if ($strfontsize == "br") {
$contentCode .= "0A";
} else {
$contentCode .= "1D21" . $strfontsize . strtoupper(implode('', unpack('H*', $strcontent)));
}
}
} elseif ($printer->language == '2') {
$contentCode .= "1C43011C26";
//日文前导符号
foreach ($content as $line) {
//$strcontent=mb_convert_encoding($line,"SJIS","UTF-8");
//$contentCode.=strtoupper(implode('',unpack('H*', $strcontent)))."0A";
$strcontent = mb_convert_encoding(substr($line, 2), "SJIS", "UTF-8");
$strfontsize = substr($line, 0, 2);
if ($strfontsize == "br") {
$contentCode .= "0A";
} else {
$contentCode .= "1D21" . $strfontsize . strtoupper(implode('', unpack('H*', $strcontent)));
}
}
} else {
return array('status' => false, 'dpid' => $printer->dpid, 'jobid' => '0', 'type' => 'none', 'msg' => yii::t('app', '无法确定打印机语言!'));
}
//加barcode和切纸
$contentCode = $precode . $contentCode . $sufcode;
$contentCodeAll = $contentCodeAll . $contentCode;
$contentCode = "";
}
//任务构建
$se = new Sequence("printer_job_id");
$jobid = $se->nextval();
if ($printserver == '1') {
if ($printer->printer_type != '0') {
return array('status' => false, 'dpid' => $printer->dpid, 'jobid' => '0', 'type' => 'net', 'msg' => yii::t('app', '网络打印的打印机必须是网络打印机!'));
}
$print_data = array("do_id" => "ipPrintContent", "company_id" => $printer->dpid, "job_id" => $jobid, "printer" => $printer->address, "content" => $contentCode);
//$store = Store::instance('wymenu');
//echo 'ss';exit;
$clientId = $store->get("client_" . $printer->dpid);
//var_dump($clientId,$print_data);exit;
if (!empty($clientId)) {
Gateway::sendToClient($clientId, json_encode($print_data));
//Gateway::sendToAll(json_encode($print_data));
return array('status' => true, 'dpid' => $printer->dpid, 'jobid' => $jobid, 'type' => 'net', 'msg' => '');
} else {
return array('status' => false, 'dpid' => $printer->dpid, 'jobid' => '0', 'type' => 'net', 'msg' => yii::t('app', '打印服务器找不到!'));
}
///////////////////
///打印任务不再发送,返回job编号,有pad自己去取
} else {
//主动的同步打印 0
// if($printer->printer_type=='1')//local
// {
// //$ret = $store->set($companyId."_".$jobid,'1C43011C2688A488A482AE82AF82B182F182C982BF82CD0A0A0A0A0A0A1D5601',0,60);
// $store->set($printer->dpid."_".$jobid,$contentCode,0,120);//should 120测试1200
// return array('status'=>true,'dpid'=>$printer->dpid,'jobid'=>$jobid,'type'=>'local','msg'=>'');
// }else{
$seorderprintjobs = new Sequence("order_printjobs");
$orderjobId = $seorderprintjobs->nextval();
$time = date('Y-m-d H:i:s', time());
//插入一条
$orderPrintJob = array('lid' => $orderjobId, 'dpid' => $printer->dpid, 'create_at' => $time, 'orderid' => $orderid, 'jobid' => $jobid, 'update_at' => $time, 'address' => $printer->address, 'content' => $contentCodeAll, 'printer_type' => "0", 'finish_flag' => '0', 'delete_flag' => '0');
Yii::app()->db->createCommand()->insert('nb_order_printjobs', $orderPrintJob);
$store->set($printer->dpid . "_" . $jobid, $contentCodeAll, 0, 30);
//should 120测试1200
return array('status' => true, 'dpid' => $printer->dpid, 'jobid' => $jobid, 'type' => 'net', 'address' => $printer->address, 'msg' => '');
// }
}
}