Exemple #1
0
 public static function findBuyOrder($data = array())
 {
     if (!isset($data['p_param']['status'])) {
         $status = 0;
     } else {
         $status = intval($data['p_param']['status']);
     }
     if (!isset($data['limit'])) {
         $data['limit'] = 10;
     }
     $model = new ProductOrder();
     $dataProvider = new ActiveDataProvider(['query' => $model->find()->Where('p_user_id=:user_id AND order_status=:status ', [':user_id' => $data['user_id'], ':status' => $status])->orderBy('addtime desc'), 'pagination' => ['pagesize' => $data['limit']]]);
     return $dataProvider;
 }
 /**
  * Finds the ProductOrder model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return ProductOrder the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = ProductOrder::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
 public function getModel($id)
 {
     $productOrder = ProductOrder::findOne(['id' => $id, 'user_id' => Yii::$app->user->identity->id]);
     if (!$productOrder) {
         throw new NotFoundHttpException(Yii::t('app', 'specify product order could not be found.'));
     } else {
         return $productOrder;
     }
 }
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = ProductOrder::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, 'user_id' => $this->user_id, 'paid_time' => $this->paid_time, 'total_price' => $this->total_price, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at, 'status' => $this->status, 'payment' => $this->payment, 'shipment' => $this->shipment]);
     $query->andFilterWhere(['like', 'address', $this->address])->andFilterWhere(['like', 'contact', $this->contact])->andFilterWhere(['like', 'out_order_no', $this->out_order_no])->andFilterWhere(['like', 'charge_id', $this->charge_id]);
     return $dataProvider;
 }
 /**
  * 单个商品修改
  * @return type
  */
 public function actionSuccessbuy()
 {
     $user_id = \Yii::$app->user->getId();
     #获得用户的可用资金
     $p_param = \Yii::$app->request->get();
     if (!isset($p_param['id'])) {
         echo 1;
         \Yii::$app->end();
     }
     $order = ProductOrder::find()->where("order_id=:id AND user_id=:user_id ", [':id' => $p_param['id'], ':user_id' => $user_id])->one();
     if (!isset($order)) {
         echo 1;
         \Yii::$app->end();
     }
     if (isset($p_param['sure']) && $p_param['sure'] == 1) {
         #调有存储过程冻结资金并生成订单
         try {
             $addip = \Yii::$app->request->userIP;
             $in_p_user_id = $order->user_id;
             $order_id = $order->order_id;
             $conn = \Yii::$app->db;
             $command = $conn->createCommand('call p_success_Product_Order(:in_p_user_id,:order_id,:in_addip,@out_status,@out_remark)');
             $command->bindParam(":in_p_user_id", $in_p_user_id, PDO::PARAM_INT);
             $command->bindParam(":order_id", $order_id, PDO::PARAM_INT);
             $command->bindParam(":in_addip", $addip, PDO::PARAM_STR, 50);
             $command->execute();
             $fit = $conn->createCommand("select @out_status as status,@out_remark as remark")->queryOne();
         } catch (Exception $e) {
             $fit = ['remark' => '系统繁忙,暂时无法处理', 'status' => 0];
         }
     } else {
         $fit = [];
     }
     return $this->renderAjax('ajax_successbuy', ['order' => $order, 'p_param' => $p_param, 'fit' => $fit]);
 }
Exemple #6
0
echo $model->paid_time ? Yii::$app->formatter->asDatetime($model->paid_time) : '';
?>
			</div>
		</div>
	</div>

    <?php 
echo $form->field($model, 'total_price')->textInput(['maxlength' => true]);
?>

    <?php 
echo $form->field($model, 'contact')->textInput(['maxlength' => true]);
?>

    <?php 
echo $form->field($model, 'status')->dropDownList(ProductOrder::getStatusLabels());
?>

    <?php 
echo $form->field($model, 'payment')->dropDownList(ProductOrder::$paymentList);
?>

    <?php 
echo $form->field($model, 'shipment')->dropDownList(ProductOrder::$shipmentList);
?>

	<div class="form-group">
		<label class="control-label col-sm-3"><?php 
echo Yii::t('app', 'Out Order No');
?>
</label>
 public function down()
 {
     $this->dropColumn(ProductOrder::tableName(), 'out_order_no');
     $this->dropColumn(ProductOrder::tableName(), 'charge_id');
 }
 public function down()
 {
     $this->dropColumn(ProductOrder::tableName(), 'payment');
     $this->dropColumn(ProductOrder::tableName(), 'shipment');
 }
Exemple #9
0
<?php

use yii\helpers\Html;
use yii\grid\GridView;
use common\models\ProductOrder;
/* @var $this yii\web\View */
/* @var $searchModel backend\models\ProductOrderSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = Yii::t('app', 'Product Orders');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="product-order-index">
    <style type='text/css'>
        .product-order-grid-view {
            overflow: auto;
            overflow-y: hidden;
        }
    </style>
    <div class='product-order-grid-view'>
        <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => ['id', ['attribute' => 'user_id', 'value' => 'user.username', 'filter' => false], 'address', ['attribute' => 'paid_time', 'value' => function ($model) {
    return $model->paid_time ? Yii::$app->formatter->asDatetime($model->paid_time) : '';
}, 'filter' => false], 'total_price', 'contact', ['attribute' => 'updated_at', 'format' => 'datetime', 'filter' => false], ['attribute' => 'status', 'value' => 'statusLabel', 'filter' => false, 'filter' => Html::activeDropDownList($searchModel, 'status', ProductOrder::getStatusLabels(), ['class' => 'form-control', 'prompt' => '请选择'])], ['attribute' => 'payment', 'value' => 'paymentLabel', 'filter' => false, 'filter' => Html::activeDropDownList($searchModel, 'payment', ProductOrder::$paymentList, ['class' => 'form-control', 'prompt' => '请选择'])], ['attribute' => 'shipment', 'value' => 'shipmentLabel', 'filter' => Html::activeDropDownList($searchModel, 'shipment', ProductOrder::$shipmentList, ['class' => 'form-control', 'prompt' => '请选择'])], 'out_order_no', 'charge_id', ['class' => 'yii\\grid\\ActionColumn']]]);
?>
    </div>
</div>