/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Order::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['orderID' => $this->orderID, 'userID' => $this->userID, 'productID' => $this->productID, 'record' => $this->record]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Order::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); // if (!$this->validate()) { // // uncomment the following line if you do not want to return any records when validation fails // // $query->where('0=1'); // return $dataProvider; // } $query->andFilterWhere(['id' => $this->id, 'created_at' => $this->created_at, 'item_id' => $this->item_id]); $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'email', $this->email])->andFilterWhere(['like', 'tel', $this->tel])->andFilterWhere(['like', 'message', $this->message]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Order::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['order_id' => $this->order_id, 'order_created_date' => $this->order_created_date, 'user_id' => $this->user_id, 'product_id' => $this->product_id, 'product_quantity' => $this->product_quantity]); $query->andFilterWhere(['like', 'product_name', $this->product_name]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $uid = Yii::$app->user->identity->id; $query = Order::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['user_id' => $uid, 'product_id' => $this->product_id, 'id' => $this->id]); $query->andFilterWhere(['like', 'username', $this->username])->andFilterWhere(['like', 'qty', $this->qty])->andFilterWhere(['like', 'date', $this->date])->andFilterWhere(['like', 'Status', $this->Status]); return $dataProvider; }
/** * Finds the Order model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Order the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Order::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
public function actionLista() { $order = new Order(); $Orders = $order->getUserandOrders(); return $this->render('lista', ['Orders' => $Orders]); }
public function getOrder() { // 第一个参数为要关联的子表模型类名, // 第二个参数指定 通过子表的customer_id,关联主表的id字段 return $this->hasMany(Order::className(), ['userId' => 'id']); }
/** * 用户支持产品和支付金额统计 * Action AllSupportNumPrice */ public function actionAllSupportNumPrice() { $i = 0; $mMemberStat = new MemberStat(); $mOrder = new Order(); do { $i++; $startnum = ($i - 1) * self::GROUP_NUMBER; $data = $mMemberStat->find()->select('uid')->offset($startnum)->limit(self::GROUP_NUMBER)->asArray()->all(); foreach ($data as $key => $value) { $result = $mOrder->find()->select(['count(product_id) as num', 'sum(totalpay) as price'])->where(['uid' => $value['uid'], 'ispay' => self::PAY_SUCCESS, 'status' => self::ORDER_NORMAL])->asArray()->all(); $price = floatval($result[0]['price']); $num = intval($result[0]['num']); $sql = "update `i_member_stat` set `support_num` = " . $num . ",`support_price` = " . $price . " where `uid` = " . $value['uid']; $q = Yii::$app->db->createCommand($sql)->execute(); echo "uid = " . $value['uid']; echo ";"; echo "support_num = " . $num . "\n"; echo "uid = " . $value['uid']; echo ";"; echo "support_price = " . $price . "\n"; } } while ($data); }
/** * 365活动生成专题页 * @param $rel_id int 产品活动ID * @测试地址:http://test.idaiyan.cn/activity/generationh5?rel_id=32837 * @测试地址:http://dev.idaiyan.cn/activity/generationh5?rel_id=32821 */ public function actionGenerationh5() { $parr = Yii::$app->request->get(); $rel_id = isset($parr['rel_id']) && $parr['rel_id'] && is_numeric($parr['rel_id']) ? intval($parr['rel_id']) : $this->redirect(['product/index']); $session = Yii::$app->session; $session->isActive ? '' : $session->open(); if (!empty($_SESSION['user']['uid'])) { $uid = $_SESSION['user']['uid']; //查询用户有没有购买该商品 $model_order = new Order(); $res = $model_order->Mycheckpay($uid, $rel_id); if ($res) { if ($res['ispay'] == 1) { //订单完成 ,已经购买 $isready = 1; } else { $isready = 2; //下过订单,还没有支付 } } else { $isready = 0; } $user = $_SESSION['user']; } else { $uid = 0; $isready = 0; $user = array(); } // print_r($user);exit; $status = ActivityProduct::STATUS_VERIFY_THROUGH; $activityproduct_model = new ActivityProduct(); $actdetail = $activityproduct_model->getDetailBypk($rel_id); if (!$actdetail) { return $this->redirect(['product']); exit; } $actdetail['product']['user_oriented_age'] = str_pad($actdetail['product']['user_oriented_age'], 4, '0', STR_PAD_LEFT); $acprattr_model = new ActivityProductAttrVal(); $acprattr = $acprattr_model->getRealAttrVals($rel_id, 7); if (isset($acprattr['end_time']['val'])) { $acprattr['end_time']['val'] = explode('-', $acprattr['end_time']['val']); } if (!empty($acprattr['video']['val']['video_url'])) { if (substr($acprattr['video']['val']['video_url'], 0, 4) == 'http') { $acprattr['video']['val']['video_url'] = Yii::$app->util->generalVideo($acprattr['video']['val']['video_url']); } } $_SESSION['activityProduct']['price'] = isset($acprattr['discount_price']['val']['price']) ? $acprattr['discount_price']['val']['price'] : '1'; // echo "<pre>"; // print_r($actdetail); // exit; //查询该产品 type=4 的 图片 用在 首屏背景图那里 $mpimg = new ProductImage(); $fourimg = $mpimg->getByTypeAndPid(ProductImage::TYPE_CATIONFIRST, $actdetail['product_id']); $this->layout = false; return $this->render('generationh5', ['actdetail' => $actdetail, 'acprattr' => $acprattr, 'fourimg' => $fourimg, 'uid' => $uid, 'user' => $user, 'isready' => $isready]); }
public function actionNotify() { file_put_contents('/tmp/test.log', "\n\n return:" . 'testda1hongyes', FILE_APPEND); echo 'op'; exit; //使用通用通知接口 $notify = new \Notify_pub(); //存储微信的回调 $xml = $GLOBALS['HTTP_RAW_POST_DATA']; $notify->saveData($xml); file_put_contents('/tmp/test.log', "\n\n return:" . 'test2' . $xml, FILE_APPEND); //验证签名,并回应微信。 //对后台通知交互时,如果微信收到商户的应答不是成功或超时,微信认为通知失败, //微信会通过一定的策略(如30分钟共8次)定期重新发起通知, //尽可能提高通知的成功率,但微信不保证通知最终能成功。 if ($notify->checkSign() == FALSE) { file_put_contents('/tmp/test.log', "\n\n return:" . 'test3', FILE_APPEND); $notify->setReturnParameter("return_code", "FAIL"); //返回状态码 $notify->setReturnParameter("return_msg", "签名失败"); //返回信息 } else { file_put_contents('/tmp/test.log', "\n\n return:" . 'test4', FILE_APPEND); $notify->setReturnParameter("return_code", "SUCCESS"); //设置返回码 } $returnXml = $notify->returnXml(); file_put_contents('/tmp/test.log', "\n\n return:" . 'test5' . $returnXml, FILE_APPEND); //==商户根据实际情况设置相应的处理流程,此处仅作举例======= if ($notify->checkSign() == TRUE) { if ($notify->data["return_code"] == 'SUCCESS' && $notify->data["result_code"] == 'SUCCESS') { $orderno = $notify->data["out_trade_no"]; /* 通过id获取订单信息 更改订单的支付状态*/ $support = Order::findOne(['orderno' => $orderno]); if (!$support['ispay']) { $support->ispay = '1'; return $support->save(); echo $return ? 'success' : ''; } // file_put_contents('/tmp/test.log',"\n\n return:".$return,FILE_APPEND); } } }
/** * @return \yii\db\ActiveQuery */ public function getOrders() { return $this->hasMany(Order::className(), ['user_id' => 'id']); }
public function actionBuysuccess() { $user = PublicLibrary::is_login(); if ($user && $user['uid'] != 'weixin') { $uid = isset($user['uid']) ? $user['uid'] : ''; } else { $this->redirect(['baiying/index']); } $parr = Yii::$app->request->get(); //获取地址栏中get过来的信息 // echo '<pre>'; // print_r($parr); $orderno = strip_tags($parr['orderno']) ? strip_tags($parr['orderno']) : ''; $model_order = new Order(); $res = $model_order->Paysuccess($orderno); $this->layout = false; $rel_id = $res['rel_id']; $acti_id = $res['acti_id']; $mactpro = new ActivityProduct(); $productattr = $mactpro->getDetailBypk($rel_id); $mapattrval = new ActivityProductAttrVal(); $acprattr = $mapattrval->getRealAttrVals($rel_id, $acti_id); return $this->render('buysuccess', ['acprattr' => $acprattr, 'productattr' => $productattr]); }
public function actionUserpayment() { $orderId = Yii::$app->request->get("id"); $userId = Yii::$app->session->get(FVariable::$session_userId_str); if (!$userId) { return $this->redirect(FVariable::$siteLogin_view); } if (!$orderId) { return $this->redirect(FVariable::$home_view); } $order = new Order(); $orderNo = $order->findOrderId($orderId, $userId, GlobalArray::$orderStateConstantArray['waitPay']); if ($orderNo) { return $this->render(FVariable::$userOrderpayment_view, ['orderNo' => $orderNo]); } else { return $this->redirect(FVariable::$home_view); } }
public function findOrderId($id, $userId, $orderStatus) { $OrderAll = Order::find()->where(array('id' => $id, 'userId' => $userId, 'orderStatus' => $orderStatus))->one(); if (!$OrderAll) { return false; } return $OrderAll; }
use yii\helpers\Html; use common\widgets\GlobalArray; AppAsset::register($this); AppAsset::addCss($this, '/css/font-awesome.css'); ?> <div class="evaluate"> <div class="evaluate-head"> <div>商品信息</div> <div>购买时间</div> <div>数量</div> </div> <div class="evaluate-con"> <?php $productDetails = \frontend\models\OrderDetail::findByOrderDetail($details->id); $order = \frontend\models\Order::findOne($details->id); $orderDetail = $order->getProductDetail()->all(); foreach ($orderDetail as $detk => $detv) { $product = \frontend\models\OrderDetail::findOne($detv['id']); $product = $product->getProduct()->one(); ?> <div> <div class="eva-img"><img src="<?php echo GlobalArray::$imgUrlArray['0'] . $product['productLogo']; ?> " /><?php echo $product['productName']; ?> </div> <div><?php echo date('Y-m-d', strtotime($details->orderTime));
public function getOrders() { // all() 调用getOrders 时需要 调用orders 时不需要 return $this->hasMany(Order::className(), ['member_id' => 'id'])->asArray(); }
/** * @return \yii\db\ActiveQuery */ public function getOrder() { return $this->hasOne(Order::className(), ['id' => 'order_id']); }
/** *删除订单,进入回收站 *@param array $id 订单id */ public function actionDelOrder() { //判断登陆 $user = PublicLibrary::is_login(); if (empty($user)) { echo "<script>window.location.href='/user/login';</script>"; exit; } $id = Yii::$app->request->Post('id') ? Yii::$app->request->Post('id') : ''; $uid = intval($user['uid']); $orderModel = new Order(); //$id[0] = 'ddaDSD'; //$id[1] = 46; if (!empty($id)) { if (is_array($id)) { $ids = array_map('intval', $id); $order = $orderModel->getHubDel($uid, $ids); if ($order) { $message = "放入回收站成功!"; echo PublicLibrary::format_res_encode('0', $message, ''); } else { $message = "放入回收站失败!"; echo PublicLibrary::format_res_encode('1', $message, ''); } } else { $ids = $id; $order = $orderModel->getHubDel($uid, $ids); if ($order) { $message = "放入回收站成功!"; echo PublicLibrary::format_res_encode('0', $message, ''); } else { $message = "放入回收站失败!"; echo PublicLibrary::format_res_encode('1', $message, ''); } } } else { $message = "此订单无法删除!"; echo PublicLibrary::format_res_encode('3', $message, ''); } // echo "<script>alert('$message'),window.location.href='index.php?r=ucenter/my-order';</script>"; }
public function actionWeixinpaydone() { //用户是否登陆 $user = PublicLibrary::is_login(); if (isset($user['uid'])) { $uid = $user['uid']; } else { return $this->redirect(['product/index']); exit; } //接收传递过来的信息 $data = Yii::$app->request->get(); $orderno = isset($data['orderno']) ? strip_tags($data['orderno']) : ''; //判断该订单是不是这个用户的 $model_order = new Order(); $res = $model_order->getByOrderNo($orderno, $uid); if (!$res) { return $this->redirect(['product/index']); exit; } $photo = $res['product']['name']; $album = $res['product']['album']; $ispay = $res['ispay']; //显示支付成功页面 return $this->render('alipay-return', ['order' => $res, 'isPay' => $ispay]); }
/** * @return \yii\db\ActiveQuery */ public function getOrders() { return $this->hasMany(Order::className(), ['productID' => 'productID']); }
public function getOrder() { //同样第一个参数指定关联的子表模型类名 return $this->hasOne(Order::className(), ['id' => 'orderId']); }
public function actionSubmit() { $model = new Order(); $model->scenario = 'submit'; if ($model->load(Yii::$app->request->post()) && $model->validate()) { $model->save(); //ToDo отправка сообщения по почте $model_Email = Email::find()->where(['id' => 1])->one(); $currEmail = $model_Email->email; if ($model->save()) { Yii::$app->mailer->compose(['html' => 'order'], ['model' => $model])->setFrom($model->email)->setTo($currEmail)->setSubject('CОБЩЕНИЕ VinnieGuitar - Новый заказ')->setTextBody('<b>HTML content</b>')->send(); Yii::$app->getSession()->setFlash('success', 'Ваш заказ принят!'); return $this->redirect(\Yii::$app->request->getReferrer()); } else { Yii::$app->getSession()->setFlash('error', 'Ошибка . Ваш заказ не принят!'); // либо страница отображается первый раз, либо есть ошибка в данных return $this->redirect(\Yii::$app->request->getReferrer()); } } }
public function actionAlipayReturn() { $data = Yii::$app->request->get(); /* $data = array ( 'body' => '测试商品', 'buyer_email' => '*****@*****.**', 'buyer_id' => '2088002336746485', 'exterface' => 'create_direct_pay_by_user', 'is_success' => 'T', 'notify_id' => 'RqPnCoPT3K9%2Fvwbh3InTs%2FZBNErNo1YRPH5%2BP%2BfYEDbLzoUY7QdU4VLRgBvQDF5ZImOT', 'notify_time' => '2015-04-23 13:56:10', 'notify_type' => 'trade_status_sync', 'out_trade_no' => 'IDY000009', 'payment_type' => '1', 'seller_email' => '*****@*****.**', 'seller_id' => '2088411582940602', 'subject' => '测试商品', 'total_fee' => '0.01', 'trade_no' => '2015042300001000480051224268', 'trade_status' => 'TRADE_SUCCESS', 'sign' => '3cfc49a535c7bbb519c3e237080142ec', 'sign_type' => 'MD5' ); */ $user = Yii::$app->util->isLogin(); $para_filter = AlipayDirect::paraFilter($data); $para_sort = AlipayDirect::argSort($para_filter); $mysign = Yii::$app->alipay->buildRequestMysign($para_sort); if ($data['sign'] !== $mysign || !$user) { $this->redirect(Url::toRoute('main/index')); } $isPay = true; $sign = $data['sign']; $tradeNo = $data['trade_no']; $tradeStatus = $data['trade_status']; $outTradeNo = $data['out_trade_no']; $notifyTime = $data['notify_time']; $isSuccess = $data['is_success']; // TODO: 需要有签名验证处理 // XXX: 需要再次明确$isSuccess的用途 if (!$isSuccess || $tradeStatus !== 'TRADE_SUCCESS' && $tradeStatus !== 'TRADE_FINISHED') { $isPay = false; } $mOrder = new Order(); $order = $mOrder->getByOrderNo($outTradeNo, $user['uid']); if ($order) { $now = time(); $order['ispay'] = Order::STATUS_ISPAY; $order['update_time'] = $now; $order['pay_at'] = $now; // XXX: weixinno字段应该调整字段命名 $order['trade_no'] = $tradeNo; if (!$order->save()) { $isPay = false; } else { try { $mActiProd = new ActivityProduct(); $mActiProd->changeStock($order['rel_id'], 1); } catch (Exception $e) { // TODO: 需要增加日志记录 } } } else { // TODO: 订单不存在处理 $isPay = false; } $refreshUrl = Url::toRoute(['demo/alipay-result', 'orderno' => $order['orderno']]); echo <<<EOF <script type="text/javascript"> window.top.location = "{$refreshUrl}"; </script> EOF; }
public function actionReturnurl() { $this->alipay_config = (new AlipayConfig())->getAliConfig(); $alipayNotify = new AlipayNotify($this->alipay_config); $verify_result = $alipayNotify->verifyReturn(); //验证成功 if ($verify_result) { //商户订单号 $out_trade_no = $_GET['out_trade_no']; //支付宝交易号 $trade_no = $_GET['trade_no']; //交易状态 $trade_status = $_GET['trade_status']; if ($_GET['trade_status'] == 'TRADE_FINISHED' || $_GET['trade_status'] == 'TRADE_SUCCESS') { //判断该笔订单是否在商户网站中已经做过处理 $orderModel = new Order(); $isOk = $orderModel->updateOrderByOrderNoAndStatus($out_trade_no, 1); //支付成功,更新订单状态 if (!$isOk) { $erorr = '订单已经支付成功,但订单状态更新失败 原因不明 订单号:' . $out_trade_no . ',发生时间:' . date('Y-m-d H:i:s', time()); Yii::getLogger()->log($erorr, Logger::LEVEL_ERROR); } return $this->render(FVariable::$paySuccess_view, ['out_trade_no' => $out_trade_no]); } else { echo "trade_status=" . $_GET['trade_status']; $erorr = '订单已经支付成功,但支付宝返回状态不对 联系支付宝客服查明 单号:' . $out_trade_no . ',发生时间:' . date('Y-m-d H:i:s', time()); Yii::getLogger()->log($erorr, Logger::LEVEL_ERROR); return $this->render(FVariable::$payFail_view); } } return $this->render(FVariable::$payFail_view); }
public static function getOrderNumber() { $yCode = date('y'); //年份数 $mCode = date('m'); //月份 $dCode = date('d'); //日 $tCode = substr(time(), -3); //时间戳的后五位 $iCode = substr(microtime(), 2, 3); //返回时间戳和微秒数,从第二位开始取3位 $rCode = sprintf('%02d', rand(0, 99)); //返回0~99的随机整数 $orderNo = $yCode . '' . $mCode . '' . $dCode . '' . $tCode . '' . $iCode . '' . $rCode; while (Order::findOne($orderNo)) { $orderNo = Tool::getOrderNumber(); } return $orderNo; }
echo $this->render(FVariable::$layoutVipordermenu_view, ['order_vip' => $order_vip, 'orderIndex' => $orderIndex, 'orderStay' => $orderStay, 'orderFinish' => $orderFinish, 'orderEvaluate' => $orderEvaluate, 'orderCancel' => $orderCancel]); ?> </div> <div class="order-con"> <ul> <?php foreach ($orderCanceled as $k => $v) { echo "<li>"; echo "<div class='order-con-head'>"; echo "<span class='ord-number'>订单号:<b>" . $v->orderNo . "</b></span>"; echo "<span class='ord-times'>" . $v->orderTime . "</span>"; echo "</div>"; echo "<div class='order-sub-con'>"; echo "<div class='sub-con-list'>"; $order = \frontend\models\Order::findOne($v->id); $orderDetail = $order->getProductDetail()->all(); $addressName = \frontend\models\UserAddress::findOne($v->addressId); $addressName = $addressName->userName; foreach ($orderDetail as $detk => $detv) { echo "<div class='sub-row'>"; echo "<div>"; $product = \frontend\models\OrderDetail::findOne($detv['id']); $product = $product->getProduct()->one(); echo "<img src='" . GlobalArray::$imgUrlArray['0'] . $product['productLogo'] . "' class='img-responsive' />"; echo "</div>"; echo "<div>" . $product['productName'] . "</div>"; echo "<div>" . $detv['productCount'] . "包</div>"; echo "<div>" . '¥' . $detv['productPrice'] . "</div>"; echo "</div>"; }
/** * 数据修复 * * @param string $type 统计类型 * - support_num 支持人数 * - paied_num 支付数量 * - partake_num 参与人数 * - amount 总金额 * 默认为空 * @param string $method 统计方式 * - product 产品统计(默认) * - activity 活动产品统计 * @param string $ids 产品ID集合 * 产品ID集合的格式为"产品ID1,产品ID2,.....产品IDN" */ public function actionRepair($type = '', $method = 'product', $ids = '') { $page = 1; $perPage = 50; $startNum = ($page - 1) * $perPage; $result = []; $options = []; $count = 0; $mOrder = new Order(); $types = ['support_num', 'paied_num', 'partake_num', 'amount']; $methods = ['product', 'activity']; $type = trim($type); $time = microtime(true); $log = new FileTarget(); if (!$type) { die("Error: Param type is empty\n"); } if (!in_array($type, $types)) { die("Error: Illegal Type\n"); } if (!in_array($method, $methods)) { die("Error: Illegal Method\n"); } if ($method == 'activity') { $ac = ActivityProductStat::find(); } else { $ac = ProductStat::find(); } $log->logFile = Yii::$app->getRuntimePath() . '/logs/' . self::LOGNAME_PREFIX . $method . '_' . $type . '_' . date('YmdHis') . '.log'; if ($ids) { $ids = array_map('trim', explode(',', $ids)); $ids = array_map('intval', $ids); $ids = array_filter($ids); $ids = array_unique($ids); $result = $ac->where(['product_id' => $ids])->all(); } else { $result = $ac->offset($startNum)->limit($perPage)->all(); } $this->_logger($log, 'Process Start'); $this->_logger($log, 'Type:' . strtoupper($type)); echo "Process Start\n"; echo 'Type:' . strtoupper($type) . "\n"; while ($result) { if ($result) { foreach ($result as $item) { if (isset($item['product_id']) && $item['product_id']) { $options['product_id'] = $item['product_id']; if (isset($item['acti_id']) && $item['acti_id']) { $options['acti_id'] = $item['acti_id']; } $count = $mOrder->getCountByType($type, $options); if ($count === NULL || $count === false) { continue; } $item[$type] = $count; if ($item->save()) { $this->_logger($log, 'Updated: pid=' . $item['product_id'] . ', count=' . $count); echo 'Updated: pid=' . $item['product_id'] . ', count=' . $count . "\n"; } else { $this->_logger($log, 'Error: pid=' . $item['product_id']); echo 'Error: pid=' . $item['product_id'] . "\n"; } } } } if ($ids) { break; } else { echo "========== Page {$page} finished processing ==========\n\n"; $startNum = ($page - 1) * $perPage; $page++; $result = $ac->offset($startNum)->limit($perPage)->all(); } } echo "Process Over\n"; $this->_logger($log, 'Process Over'); $log->export(); }