public function getOrderslist() { DB::connection()->enableQueryLog(); $Orders = DB::table('Orders'); $Orders->leftJoin('order_shipping', 'Orders.id', '=', 'order_shipping.order_id'); $Orders->select('Orders.id', 'Orders.buy_tel', 'Orders.order_created', 'Orders.voucher_name', 'Orders.pay_total', 'order_shipping.shipping_code', 'Orders.buy_name', 'Orders.taopix_order_id', 'Orders.item_count', 'Orders.status'); $orderid = Input::get('orderid'); if ($orderid) { $Orders->where('taopix_order_id', $orderid); } $buytel = Input::get('buy_tel'); if ($buytel) { $Orders->where('buy_tel', $buytel); } $buyname = Input::get('buy_name'); if ($buyname) { $Orders->where('buy_name', $buyname); } $createdStart = Input::get('order_created_start'); $createdEnd = Input::get('order_created_end'); if ($createdStart && $createdEnd) { //$where .= ' AND order_created between ' . $createdStart."'"." AND ' ".$createdEnd ."'"; $Orders->whereBetween('order_created', [$createdStart, $createdEnd]); } //var_dump($createdStart.$createdEnd);exit; $orders['search']['orderid'] = $orderid; $orders['search']['buytel'] = $buytel; $orders['search']['buyname'] = $buyname; $orders['search']['createdStart'] = $createdStart; $orders['search']['createdEnd'] = $createdEnd; $rs = $Orders->orderBy('Orders.id', 'desc')->groupBy('taopix_order_id')->paginate(10); $queries = DB::getQueryLog(); if ($rs) { for ($i = 0; $i < count($rs); $i++) { // $rs[$i]['shipping_code'] = OrderShipping::getShippingCode($rs[$i]['id']); //var_dump($rs[$i]->id);exit; $OrderShipping = new OrderShipping(); $shippingCode = $OrderShipping->getShippingCode($rs[$i]->id); if ($shippingCode) { $rs[$i]->shipping_code = $shippingCode; } else { $rs[$i]->shipping_code = 0; } //var_dump($rs[$i]); } } else { return false; } // exit; $orders['data'] = $rs; return $orders; }
public function actionProfile() { $destination = $this->getDestinationAccount(); $lastOrderShipping = OrderShipping::find()->where(['shipping_email' => $destination->email])->orderBy(['order_id' => SORT_DESC])->one(); if (Yii::$app->request->isPost && isset($_REQUEST['password'])) { if (!empty(Yii::$app->request->post('password'))) { $destination->password = Yii::$app->request->post('password'); $destination->save(); Yii::$app->session->setFlash('password-info', Yii::t('app', 'Password updated successfully')); } else { Yii::$app->session->setFlash('password-error', Yii::t('app', 'Password cannot be empty')); } } return $this->render('profile', ['dataProvider' => $this->getBuyersDP($destination), 'destination' => $destination, 'shipping' => $lastOrderShipping]); }
/** * 添加物流单号 */ public function addShippingCode() { $code = Input::get('code'); $id = Input::get('orderid'); $printid = Input::get('printid'); $shippingName = Input::get('shippingName'); $msg = ''; if ($code && $id) { //$data = DB::update("update orders set shipping_code = :code where id = :id", ['code'=>$code, 'id'=>$id]); $item = DB::select("select id from item where order_id = '{$id}' order by id desc limit 1"); $itemId = $item[0]->id; $shippingName = '中通'; //$data = DB::update("insert into order_shipping(order_id,item_id,shipping_code,shipping_name,created_at) values('{$id}','{$itemId}','{$code}','{$shippingName}','".date('Y-m-d H:i:s')."')"); $orderShipping = new OrderShipping(); $orderShipping->order_id = $id; $orderShipping->item_id = $itemId; $orderShipping->shipping_code = $code; $orderShipping->shipping_name = $shippingName; // $orderShipping-> = $date('Y-m-d H:i:s'); $rs = $orderShipping->save(); if ($rs) { //修改状态 $orders = Orders::find($id); $orders->status = 12; $orders->save(); $msg = "{$code}物流单号提交成功"; } else { $msg = "{$code}物流单号提交失败"; } } else { return redirect()->route('order.barcode', ['printid' => $printid, 'err' => "错误的物流号或订单号"]); } return redirect()->route('order.barcode', ['printid' => $printid, 'msg' => $msg]); }