/** * 单个商品修改 * @return type */ public function actionChangeimg() { $p_param = \Yii::$app->request->get(); if (isset($p_param['id'])) { $oneLogistics = Logistics::find()->where("id=:id", [':id' => $p_param['id']])->one(); if ($oneLogistics) { return $this->render('logistics_changeimg', ['model' => $oneLogistics]); \Yii::$app->end(); } } $error = '不存在此物品'; $notices = array('type' => 2, 'msgtitle' => '错误的操作', 'message' => $error, 'backurl' => Url::toRoute('/member/logistics/index'), 'backtitle' => '返回'); \Yii::$app->getSession()->setFlash('wechat_fail', array($notices)); $this->redirect(Url::toRoute('/public/notices')); }
/** * 显示发布人的微信图片 */ public function actionBooks() { $user_id = \Yii::$app->user->getId(); #获得用户的可用资金 $p_param = Yii::$app->request->get(); if (!isset($p_param['id'])) { echo 1; Yii::$app->end(); } $logis = Logistics::find()->where("id=:id", [':id' => $p_param['id']])->one(); if (!isset($logis)) { echo 1; Yii::$app->end(); } if ($user_id == $logis->publis_user_id) { echo '<p>不允许签订自己的物品</p><button type="button" class="btn btn-danger" data-dismiss="modal">关闭</button>'; Yii::$app->end(); } else { echo '<p><h3>请扫描对方微信二维码进一步沟通</h3><br/><em>不真实图片为虚假信息</em><br/><img style="margin:0 auto;" src="' . $logis->user->card_pic2 . '"/></p><button type="button" class="btn btn-danger" data-dismiss="modal">关闭</button>'; Yii::$app->end(); } }
/** * 保存商品 */ public function save() { $newLogis = new Logistics(); $newLogis->setAttributes($this->attributes); $newLogis->setAttribute('user_country', $this->user_country); $newLogis->setAttribute('user_province', $this->user_province); $newLogis->setAttribute('user_city', $this->user_city); $newLogis->setAttribute('user_area', $this->user_area); $newLogis->setAttribute('user_address', $this->user_address); $newLogis->setAttribute('fit_user_id', 0); $newLogis->setAttribute('bail_lock', 0); $newLogis->setAttribute('fee_lock', 0); $newLogis->setAttribute('logis_arrivetime', strtotime($this->logis_arrivetime)); $newLogis->setAttribute('logis_realarrivetime', 0); $newLogis->setAttribute("logis_addtime", time()); $newLogis->setAttribute('logis_addip', \Yii::$app->request->userIp); if ($newLogis->save()) { $logisct_id = \Yii::$app->db->lastInsertID; $result = LogisticsService::lockLogisticsFee($this->publis_user_id, $logisct_id); if ($result['status'] == 1) { return $logisct_id; } else { $this->addError('logis_name', $result['remark']); return FALSE; } } else { return FALSE; } }
/** * * @param int $data * @return \yii\data\ActiveDataProvider */ public static function findMyGifts($data = array()) { if (!isset($data['limit'])) { $data['limit'] = 10; } $query = Logistics::find()->Where('to_user_id=:user_id', [':user_id' => $data['user_id']])->orderBy(" fee_lock asc,id desc "); $countQuery = clone $query; $pages = new Pagination(['totalCount' => $countQuery->count(), 'pageSize' => $data['limit']]); $models = $query->offset($pages->offset)->limit($pages->limit)->all(); return ['models' => $models, 'pages' => $pages]; }
/** * 上传物品图片 */ public function actionLogisticspic() { $p_params = Yii::$app->request->get(); $logis = Logistics::findOne($p_params['id']); if (!$logis) { throw new NotFoundHttpException('Page not found'); } $picture = new UploadForm(); $picture->file = UploadedFile::getInstance($logis, 'logis_s_img'); if ($picture->file !== null && $picture->validate()) { Yii::$app->response->getHeaders()->set('Vary', 'Accept'); Yii::$app->response->format = Response::FORMAT_JSON; $response = []; if ($picture->logisticsSave()) { $response['files'][] = ['name' => $picture->file->name, 'type' => $picture->file->type, 'size' => $picture->file->size, 'url' => '/' . $picture->getImageUrl(), 'thumbnailUrl' => '/' . $picture->getOImageUrl(), 'deleteUrl' => Url::to(['/uploadfile/deleteuserpic', 'id' => $picture->getID()]), 'deleteType' => 'POST']; } else { $response[] = ['error' => '上传错误']; } @unlink($picture->file->tempName); } else { if ($picture->hasErrors()) { $response[] = ['error' => '上传错误']; } else { throw new HttpException(500, '上传错误'); } } return $response; }