public function action_historyin($order_id) { if (empty(\Session::get(self::SESSION_KEY_CART))) { \Session::set(self::SESSION_KEY_CART, array('orders' => array())); } $cart = \Session::get(self::SESSION_KEY_CART); $order = Model_Order::find($order_id); $total_money = 0; foreach ($order->orderline as $orderline) { $item = Model_Item::find($orderline['item_id']); $quantity = $orderline['num']; switch ($orderline['size']) { case 'S': $price = $item->unit_price_s; break; case 'M': $price = $item->unit_price_m; break; case 'L': $price = $item->unit_price_l; break; default: $price = $item->unit_price; break; } $money = $price * $quantity; array_push($cart['orders'], array('item_id' => $item['id'], 'item_name' => $item['name'], 'size' => $orderline['size'], 'quantity' => $quantity, 'money' => $money)); } foreach ($cart['orders'] as $order) { $total_money += $order['money']; } $cart['total_money'] = $total_money; \Session::set(self::SESSION_KEY_CART, $cart); return Response::redirect('mtpizza/cart'); }
public function action_detail($order_id) { $order = Model_Order::find($order_id); $data['member'] = $order->member; $data['orders'] = $order; $data['details'] = $order->orderline; return View::forge("controlsystem/members/detail", $data); }
public function getDeliveryList() { $deliveryid_list = Session::get(self::DELIVERYID_LIST); $deliverylist = array(); foreach ((array) $deliveryid_list as $idx => $deliveryid) { $order = Model_Order::find($deliveryid); $deliverylist[] = array('index' => $idx, 'orderid' => $deliveryid, 'address' => $order->destination); } return $deliverylist; }
public static function getDetail($order_id) { $order = Model_Order::find($order_id); foreach ($order->orderline as $orderline) { $detail['orderline'][] = array('name' => $orderline->item->name, 'size' => $orderline->size, 'num' => $orderline->num); } $detail['customer'] = array('name' => $order->member->name, 'tel' => $order->member->tel); $detail['address'] = $order->destination; return $detail; }
public function action_cashback($id = 0) { $this->order = \Model_Order::find($id); if (!$this->order) { die('订单不存在'); } if (!$this->cashback()) { die('分红时遇到问题:' . $this->result_message); } die('分红成功'); }
public function action_index() { $user_id = \Session::get(self::SESSION_KEY_USER_ID); $order = Model_Order::find(1); $order->staff_id = 1; $order->save(); //return $this->template->content =var_dump($user_id); $data['staff']['staff_id'] = $order->staff_id; $data['order'] = Model_Order::getDetail($order->id); $this->template->content = View::forge('website/content/whereismypizza', $data); }
public function action_myOrders() { $user = Model_User::find($this->sessUser->id); $orderField = 'created_at'; $qualifiers = ['order_by' => [$orderField], 'where' => array(['user_id', $user->id])]; $orders = Model_Order::find('all', $qualifiers); $data = array('user' => $user, 'orders' => $orders); $view = View::forge('user/myOrders.tpl', $data); $view->set('helper', new Helper(), false); // pass validator return Response::forge($view); }
public function post_deleteOrder() { $order_id = $_POST['order_id']; $deliveryid_list = Session::get(self::DELIVERYID_LIST); if (is_array($deliveryid_list)) { unset($deliveryid_list[array_search($order_id, $deliveryid_list)]); } else { return array('status' => 'NG'); } $deliveryid_list = array_values($deliveryid_list); $order = Model_Order::find($order_id); $order->status = 1; $order->save(); Session::set(self::DELIVERYID_LIST, $deliveryid_list); return array('status' => 'OK'); }
/** * 发起微信支付(公众号JSSDK支付) */ public function action_wxpay() { $this->account = \Session::get('WXAccount', \Model_WXAccount::find(\Input::get('account_id', 1))); if (!\Input::get('openid', false)) { //本站域名 $baseUrl = \Config::get('base_url'); $request_uri = \Input::server('REQUEST_URI', ''); if ($request_uri) { $request_uri = substr($request_uri, 1); } $toUrl = urlencode("{$baseUrl}{$request_uri}"); $callback = "{$baseUrl}wxapi/oauth2_callback?to_url={$toUrl}"; $url = \handler\mp\Tool::createOauthUrlForCode($this->account->app_id, $callback); \Response::redirect($url); } $msg = false; if (!\Input::get('order_id', false)) { $msg = ['status' => 'err', 'msg' => '缺少订单ID', 'errcode' => 0, 'title' => '错误']; } else { if (!$this->account) { $msg = ['status' => 'err', 'msg' => '缺少微信公众号ID', 'errcode' => 0, 'title' => '错误']; } } if ($msg) { \Session::set_flash('msg', $msg); return \Response::forge(\View::forge('message/moblie')); } //订单openid赋值 $order = \Model_Order::find(\Input::get('order_id')); if (!$order->buyer_openid) { $openID = \Model_WechatOpenid::query()->where(['openid' => \Input::get('openid')])->get_one(); if ($openID->wechat->user_id == $order->buyer_id) { $order->buyer_openid = \Input::get('openid'); $order->save(); } } //查询收款帐户 $access = \Model_AccessConfig::query()->where('access_type', 'wxpay')->where('seller_id', $order->from_id)->where('enable', 'ENABLE')->get_one(); $result = \handler\mp\Tool::wxpay_order($this->account, $order, $access, \Input::get('openid')); $params = array('appId' => $this->account->app_id, 'timeStamp' => strval(time()), 'nonceStr' => \Str::random('alnum', 16), 'package' => "prepay_id={$result['prepay_id']}", 'signType' => "MD5"); $params['paySign'] = \handler\mp\Tool::getWxPaySign($params, $access->access_key); $params['to_url'] = "/order/home/delivery/{$order->id}"; return \Response::forge(\View::forge('pay/wxpay', $params)); }
/** * 结束拍品活动 * @param int $id * @throws \Exception * @throws \FuelException */ public function action_end($id = 0) { if (\Input::method() == 'POST') { $msg = ['status' => 'err', 'msg' => '', 'errcode' => 10]; $record = \Model_PlaceBidRecord::query()->where(['lot_id' => $id])->order_by(['bid' => 'DESC'])->get_one(); $order = \Model_Order::find($record->order_id); $order->order_status = 'FINISH'; if ($order->save()) { $msg = ['status' => 'succ', 'msg' => '', 'errcode' => 0]; } if (\Input::is_ajax()) { die(json_encode($msg)); } \Session::set_flash('msg', $msg); } $params = []; $params['item'] = \Model_Lot::find($id); \View::set_global($params); $this->template->content = \View::forge("{$this->theme}/auction/details"); }
public static function getDetail($order_id) { $order = Model_Order::find($order_id); foreach ($order->orderline as $orderline) { switch ($orderline->size) { case 'S': $key = 'unit_price_s'; break; case 'M': $key = 'unit_price_m'; break; case 'L': $key = 'unit_price_l'; break; case '': $key = 'unit_price'; break; } $detail['orderline'][] = array('name' => $orderline->item->name, 'size' => $orderline->size, 'num' => $orderline->num, 'price' => $orderline->item[$key]); } $detail['customer'] = array('name' => $order->member->name, 'tel' => $order->member->tel); $detail['address'] = array('postalcode' => $order->postalcode, 'destination' => $order->destination); return $detail; }
public function post_print($order_id) { $order = Model_Order::find($order_id); $order->print_flag = true; $order->save(); }
/** * 发货 * * @param $id */ protected function delivery($id) { $this->order = \Model_Order::find($id); $this->order->order_status = 'DELIVERY'; $this->order->save(); //发送发货模板消息 $params = ['first' => ['value' => '订单已发货!', 'color' => '#D02090'], 'keyword1' => ['value' => $this->order->order_no, 'color' => '#D02090'], 'keyword2' => ['value' => $this->order->total_fee, 'color' => '#D02090'], 'keyword3' => ['value' => $this->order->order_name, 'color' => '#D02090'], 'keyword4' => ['value' => $this->order->remark1, 'color' => '#D02090'], 'keyword5' => ['value' => '服务员', 'color' => '#D02090'], 'remark' => ['value' => '点击查看订单已使用状态', 'color' => '#D02090']]; $this->sendMsgTemplate('kulOjNg1PT5gxUMZM6VV9GwjWCBdkw_xShlgPjzFM34', $params, 'http://ticket.wangxiaolei.cn'); }
public function action_removeOrder() { $order_id = Input::post('order_id'); $remove_sure = Input::post('remove_sure'); $order = Model_Order::find($order_id); print_r($order); $product_orders = Model_OrderProduct::find('all', array('where' => array('order_id' => $order_id))); if (is_null($order)) { return Response::redirect("/"); } if ($remove_sure !== "yes") { Session::set_flash('remove_sure', 'yes'); Session::set_flash('message', 'Are you sure? If so press remove again'); return Response::redirect("/user/orderDetails/{$order_id}"); } foreach ($product_orders as $product_order) { $product_order->delete(); } $order->delete(); return Response::redirect("/admin/viewAllOrders"); }
public function action_print($order_id) { $data['order'] = Model_Order::find($order_id); return View::forge('ordercheck/orderprint', $data); }
public function post_orderstatus($id) { $order = Model_Order::find($id); $order->status = true; $order->save(); }
public function action_order() { Breadcrumbs::add(Breadcrumb::factory()->set_title(__('My Purchases'))->set_url(Route::url('oc-panel', array('controller' => 'profile', 'action' => 'orders')))); Breadcrumbs::add(Breadcrumb::factory()->set_title(__('Order'))); $this->template->title = __('View Order'); $user = Auth::instance()->get_user(); $id_order = $this->request->param('id'); $order = new Model_Order(); $order->where('id_order', '=', $id_order); //if admin we do not verify the user if ($user->id_role != Model_Role::ROLE_ADMIN) { $order->where('id_user', '=', $user->id_user); } $order->find(); if (!$order->loaded()) { Alert::set(ALERT::WARNING, __('Order could not be loaded')); $this->redirect(Route::url('oc-panel', array('controller' => 'profile', 'action' => 'orders'))); } $this->template->bind('content', $content); $this->template->content = View::factory('oc-panel/profile/order'); $content->order = $order; $content->product = $order->id_product; $content->user = $user; if (core::get('print') == 1) { $this->template->scripts['footer'] = array('js/oc-panel/order.js'); } }
/** * 发货操作 * @param int $id 订单ID */ public static function delivery($id = 0) { $msg = false; $order = \Model_Order::find($id); if (!$order) { $msg = ['status' => 'err', 'msg' => '未找到订单,发货失败', 'title' => '错误']; } else { if (in_array($order->order_status, ['NONE', 'WAIT_PAYMENT'])) { $msg = ['status' => 'err', 'msg' => '订单未付款,发货失败', 'title' => '错误']; } else { if ($order->order_status != 'PAYMENT_SUCCESS') { $msg = ['status' => 'err', 'msg' => '订单状态异常,发货失败', 'title' => '错误']; } } } if ($msg) { \Session::set_flash('msg', $msg); return false; } //微信发货 $account = \Session::get('WXAccount', false); if (!$account) { $account = \Model_WXAccount::find(1); } if ($account->temp_token_valid < time()) { $result = \handler\mp\Tool::generate_token($account->app_id, $account->app_secret); $account->temp_token = $result['token']; $account->temp_token_valid = $result['valid']; $account->save(); } $delivery_count = 0; foreach ($order->details as $detail) { $sn = \Model_GoodsAccount::query()->where(['goods_id' => $detail->goods_id, 'status' => 'NONE'])->get_one(); if (!$sn) { $delivery_count++; continue; } if ($order->buyer_openid) { $remark = "订单号:{$order->order_no}\n用户名:{$sn->account}\n密码:{$sn->password}"; $data = \handler\mp\TemplateMsg::get_buy_goods_success($detail->goods->name, $remark); $params = \handler\mp\TemplateMsg::get_base_params($order->buyer_openid, "ARlIzufqpUc8tvCTAVswkny-_AYwYatkxiw42MOa_uA", "http://mall.doujao.com", $data); $flag = \handler\mp\TemplateMsg::send_msg($account->temp_token, $params); if ($flag) { $sn->status = 'USED'; $sn->order_id = $order->id; $sn->save(); } $detail->is_delivery = 1; $detail->save(); } } if ($delivery_count > 0) { \Session::set_flash('msg', ['status' => 'err', 'msg' => "{$delivery_count}件商品发货失败.原因:库存不足!请联系客服.", 'title' => '错误']); return false; } $order->order_status = 'FINISH'; $order->save(); return true; }