public function ajaxNewestOrder() { parent::checkAction("Shop-order"); //只判断一天内没别读取过的 $today = time(); $last_of_24h = $today - 86400; $order_where = array('status' => 2, 'readed' => 0, 'token' => $this->token, 'create_time' => array('gt', $last_of_24h)); if (!empty($this->branch_id)) { $order_where['branch_id'] = $this->branch_id; } $order_db = M('b2c_order'); $new_orders = $order_db->field("order_id,tel,truename,info,create_time,address,price,sn,payment")->where($order_where)->order('id DESC')->select(); $tipMsgs = array(); if (count($new_orders) > 0) { $order_db->where($order_where)->save(array('readed' => 1)); $orders_html_ary = array(); $orders_print_ary = array(); foreach ($new_orders as $key => $order) { $Model = new Model(); $items = $Model->query("select i.product_id, i.count, p.`name`, p.logo_url, i.price, p.intro as desc from tp_b2c_order_item as i LEFT JOIN tp_b2c_product as p on i.product_id = p.product_id where i.order_id =" . $order['order_id'] . " and i.token='{$this->token}'"); $order_items = array(); for ($j = 0; $j < count($items); $j++) { $order_items[$items[$j]['product_id']] = $menus[$j]; } $order["items_list"] = $order_items; $order["href"] = U('Shop/order', array('oid' => $order["sn"])); $order['format_submit_time'] = date("Y-m-d H:i:s", $order['create_time']); $orders_html_item = $this->formatOrder($order); $new_orders[$key]['html'] = $orders_html_item; $order_print_item = $this->formatPrintOrder($order); $new_orders[$key]['print_html'] = $order_print_item; } $now = time(); $now_str = date("Y-m-d H:i:s", $now); $order_count = count($new_orders); $tipMsgs["num"] = $order_count; $tipMsgs["info"] = "您有 {$order_count} 个新订单,最后更新时间为{$now_str}"; $tipMsgs["type"] = "orders"; $tipMsgs["num"] = count($new_orders); $tipMsgs["orders"] = $new_orders; $this->ajaxReturn($tipMsgs, "OK", 1); } else { $now = time(); $now_str = date("Y-m-d H:i:s", $now); $tipMsgs["info"] = "没有新的订单,最后更新时间为" . $now_str; $tipMsgs["type"] = "orders"; $tipMsgs["num"] = 0; $tipMsgs["orders_html"] = ''; $this->ajaxReturn($tipMsgs, "No new order", 0); } }
public function cancel() { parent::checkAction("Dining-order"); $order_sn = intval($_GET['oid']); $order_db = M('dine_order'); $order_where = array('sn' => $order_sn, 'rest_id' => $this->rest_id, 'status' => 2); $order = $order_db->where($order_where)->find(); if ($order) { $ret = $order_db->where($order_where)->save(array('status' => 4)); if ($ret) { $this->success('订单取消成功', U(MODULE_NAME . '/orderList', array('status' => 2))); } else { $this->success('订单取消失败', U(MODULE_NAME . '/orderList', array('status' => 2))); } } }
<?php require substr(dirname(__FILE__), 0, -6) . '/init.inc.php'; Validate::checkSession(); global $_tpl; $_manage = new ManageAction($_tpl); $_manage->_action(); $_tpl->display('manage.tpl');
<?php require '../init.inc.php'; global $templates; $manage = new ManageAction('manage.tpl'); $manage->Action(); $templates->display($manage->tpl);
private function getNewDiningOrderCount() { parent::checkAction("Dining-order"); $rest_id = $_SESSION['manage_dine_branch']; $where = array('token' => $this->token); if (!empty($rest_id)) { $where['id'] = $rest_id; } $rest = M('dine_rest')->where($where)->find(); if ($rest == false) { return array(); } $new_orders = M('dine_order')->where(array('rest_id' => $rest['id'], 'status' => 2))->select(); $tipMsgs = array(); $id = ""; if (count($new_orders) > 0) { $id = $id . "order_"; foreach ($new_orders as $order) { $id = $id . $order['id']; } $tipMsg["href"] = U('Dining/orderList', array('status' => 2)); $tipMsg["type"] = "order"; $tipMsg["num"] = count($new_orders); array_push($tipMsgs, $tipMsg); } $tips["id"] = $id; $tips["msg"] = $tipMsgs; $tips["num"] = count($tipMsgs); return $tips; }
protected function _initialize() { parent::_initialize(); }
public function order() { parent::checkAction("Hotel-order"); $order_sn = intval($_GET['oid']); $order_db = M('hotel_order'); $order = $order_db->where(array('sn' => $order_sn, 'hid' => $this->hotel_id))->find(); if ($order == null) { $this->error('订单不存在', U(MODULE_NAME . '/orderList')); } if ($order['order_status'] == 1) { $order['status_text'] = '已确认'; } else { if ($order['order_status'] == 2) { $order['status_text'] = '用户已取消'; } else { if ($order['order_status'] == 3) { $order['status_text'] = '新订单'; } else { if ($order['order_status'] == 4) { $order['status_text'] = '商户已取消'; } } } } $this->assign('order', $order); $hotel = M('Hotel')->where(array('token' => $this->token, 'id' => $merchant_id, 'status' => 1))->find(); if (!empty($hotel['title'])) { $this->assign('merchant_name', $hotel['title']); } $this->assign('type_text', '宾馆预定'); //默认预约项标题 if (!empty($hotel['default_col_show'])) { $this->assign('default_col_show', unserialize($hotel['default_col_show'])); } //自定义文本预约项标题 $text_cols = unserialize($Hotel['text_cols']); if (!empty($text_cols)) { $tmpTextCols = array(); foreach ($text_cols as $text_col) { if (!empty($text_col[0])) { array_push($tmpTextCols, $text_col[0]); } } // 单行文本列名列表 $this->assign('text_cols_title', $tmpTextCols); } //自定义选择类预约项标题 $select_cols = unserialize($hotel['select_cols']); if (!empty($select_cols)) { $tmpSelCols = array(); foreach ($select_cols as $sel_col) { if (!empty($sel_col[0])) { array_push($tmpSelCols, $sel_col[0]); } } // 单行文本列名列表 $this->assign('select_cols_title', $tmpSelCols); } //订单自定义文本类内容 $textColVals = unserialize($order['text_cols']); $this->assign('text_cols_content', $textColVals); //订单自定义选择类内容 $selectColVals = unserialize($order['select_cols']); $this->assign('select_cols_content', $selectColVals); $this->display(); }
public function addsell() { parent::checkAction("Member-points"); if (!IS_POST) { $this->error('没有提交任何东西'); exit; } // 检查卡号 $cardnum = $this->_post('cardnum'); $card = M('Member_card_create')->where(array('token' => $this->token, 'number' => $cardnum, 'status' => 1))->find(); if (!$card) { $this->error('卡号不存在'); } if (!$card['wecha_id']) { $this->error('改卡号未被领用,无法消费'); } $wecha_id = $card['wecha_id']; $add_expend = floatval($this->_post('add_expend')); $add_expend_time = $this->_post('add_expend_time'); $remark = $this->_post('remark'); if ($add_expend <= 0) { $this->error('消费金额必须大于0元'); exit; } $user_db = M('Userinfo'); //获取商家消费积分设置 tp_member_card_exchange $card_setting = M('Member_card_exchange')->where(array('token' => $this->token))->find(); $ratio = 1; //default ratio if ($card_setting && $card_setting['reward']) { $ratio = $card_setting['reward']; } $data['token'] = $this->token; $data['wecha_id'] = $wecha_id; $data['sign_time'] = strtotime($add_expend_time); $data['score_type'] = 2; $data['delete'] = 0; $data['expense'] = intval($add_expend) * $ratio; $data['sell_expense'] = $add_expend; //消费金额 $data['remark'] = $remark; //备注 //添加消费记录 $back = M('Member_card_sign')->data($data)->add(); //更新消费总记录 // 积分 = 消费总金额 * 积分比例$ratio $userinfo = $user_db->where(array('token' => $this->token, 'wecha_id' => $wecha_id, 'status' => 1))->find(); $back2 = false; if ($userinfo) { $da['total_score'] = $userinfo['total_score'] + $data['expense']; $da['expend_score'] = $userinfo['expend_score'] + $data['expense']; $back2 = $user_db->where(array('token' => $this->token, 'wecha_id' => $wecha_id, 'status' => 1))->save($da); } if ($back && $back2) { $this->success('操作成功'); } else { $this->error('服务器繁忙,请稍候再试'); } }