public function actionView($id) { $commodityOrderDetail = CommodityOrderDetail::findOne($id); if (empty($commodityOrderDetail)) { throw new HttpException(404, '查看失败,数据不存在!'); } $commodityOrder = CommodityOrder::findOne($commodityOrderDetail->coid); if (empty($commodityOrder)) { throw new HttpException(404, '查看失败,数据不存在!'); } return $this->render('view', ['model' => $commodityOrder]); }
public function validateEntrance($attribute, $params) { echo 'validateEntrance'; $commodityOrderDetail = (new Query())->select(CommodityOrderDetail::tableName() . '.*')->from(CommodityOrder::tableName())->leftJoin(CommodityOrderDetail::tableName(), CommodityOrderDetail::tableName() . '.coid = ' . CommodityOrder::tableName() . '.id')->where('commodity_id = :commodity_id and entrance = :entrance', [':commodity_id' => $this->commodity, ':entrance' => $this->{$attribute}])->one(); if (is_null($commodityOrderDetail)) { return $this->addError($attribute, '浏览入口不存在'); } }
</div> <style> .gv-table{text-align:center;} .gv-table th{text-align:center;} </style> <?php echo GridView::widget(['dataProvider' => $dataProvider, 'summary' => false, 'emptyText' => false, 'tableOptions' => ['class' => 'table table-striped table-bordered gv-table'], 'columns' => [['attribute' => '买家', 'value' => function ($data) { return $data['buyer']; }], ['attribute' => '店铺', 'value' => function ($data) { return $data['shop']; }], ['attribute' => 'ID', 'value' => function ($data) { return $data['commodity']; }], ['attribute' => '订单号', 'value' => function ($data) { return $data['order_no']; }], ['class' => 'yii\\grid\\Column', 'header' => '金额', 'content' => function ($data) { $commodityOrderDetail = (new Query())->select(CommodityOrderDetail::tableName() . '.*')->from(CommodityOrder::tableName())->leftJoin(CommodityOrderDetail::tableName(), CommodityOrderDetail::tableName() . '.coid = ' . CommodityOrder::tableName() . '.id')->where('commodity_id = :commodity_id and entrance = :entrance', [':commodity_id' => $data['commodity'], ':entrance' => $data['entrance']])->one(); $style = ''; if (!is_null($commodityOrderDetail)) { if (floatval($commodityOrderDetail['price']) != floatval($data['money'])) { $style = 'style="color:red;"'; } } return '<span ' . $style . '>' . $data['money'] . '</span>'; }], ['attribute' => '下单时间', 'value' => function ($data) { return $data['order_time']; }], ['attribute' => '收货地址', 'value' => function ($data) { if (empty($data['address'])) { $data['address'] = ''; } return $data['address']; }], ['class' => 'yii\\grid\\Column', 'header' => '审核状态', 'content' => function ($data) {
public function actionUpdate($id) { $model = Order::findOne($id); if (empty($model)) { throw new HttpException(404, '订单不存在!'); } if ($model->uid != 0 && $model->uid != $model->uid && $this->user->rid == 4) { throw new MethodNotAllowedHttpException('权限不够,不能修改!'); } if ($model->statu == Order::$_AUDIT_ACCESS) { throw new MethodNotAllowedHttpException('已审核订单,不能修改!'); } if ($model->load(Yii::$app->request->post())) { $model->scenario = 'update'; // 获取用户输入的数据,验证并保存 $model->statu = Order::$_AUDIT_PEND; $commodityOrderDetail = (new Query())->select(CommodityOrderDetail::tableName() . '.*')->from(CommodityOrder::tableName())->leftJoin(CommodityOrderDetail::tableName(), CommodityOrderDetail::tableName() . '.coid = ' . CommodityOrder::tableName() . '.id')->where('commodity_id = :commodity_id and entrance = :entrance', [':commodity_id' => $model->commodity, ':entrance' => $model->entrance])->one(); $model->fee = $commodityOrderDetail['fee']; if ($model->save()) { $this->redirect('/order/index'); } } echo $model['commodity']; echo $model->shop; return $this->render('update', array('model' => $model)); }
public function actionAllot($id) { $model = CommodityOrder::findOne($id); if (empty($model)) { throw new HttpException(404, '操作失败,放单不存在!'); } $dataProvider = new ActiveDataProvider(['query' => CommodityOrderDetail::find()->where('coid = :coid', [':coid' => $model->id])->orderBy('keyword'), 'pagination' => false]); $users = User::find()->where('rid = 4')->all(); $users_json = array(); $enarray = ['value' => '', 'text' => '未分配']; array_push($users_json, $enarray); foreach ($users as $user) { $enarray = ['value' => $user->id, 'text' => $user->username]; array_push($users_json, $enarray); } $users_json = json_encode($users_json); $recommend_json = [['value' => '1', 'text' => '是'], ['value' => '0', 'text' => '否']]; $recommend_json = json_encode($recommend_json); return $this->render('allot', array('dataProvider' => $dataProvider, 'users_json' => $users_json, 'recommend_json' => $recommend_json)); }