예제 #1
0
 /**
  * 处理订单问题
  * @param \app\modules\member\controllers\LogisticsController $con
  * @param type $param_get
  */
 public static function fitLogs(LogisticsController $con, $param_get = array())
 {
     //不存在ID直接跳转到错误的页面
     if (!isset($param_get['id']) || empty($param_get['id']) || !isset($param_get['token']) || empty($param_get['token'])) {
         $error = '错误的操作';
         $notices = array('type' => 2, 'msgtitle' => '错误的操作', 'message' => $error, 'backurl' => Url::toRoute('/member/index/index'), 'backtitle' => '返回');
         \Yii::$app->getSession()->setFlash('wechat_fail', array($notices));
         $con->redirect(Url::toRoute('/public/notices'));
         \Yii::$app->end();
     }
     $logis_id = $param_get['id'];
     $token = $param_get['token'];
     //判断这个ID是否已经被处理过了
     $logs = Logistics::findOne($logis_id);
     if (!$logs || $logs->bail_lock != 0) {
         $error = '该信息不存在或者已经被接单。';
         $notices = array('type' => 2, 'msgtitle' => '错误的操作', 'message' => $error, 'backurl' => Url::toRoute('/member/index/index'), 'backtitle' => '返回');
         \Yii::$app->getSession()->setFlash('wechat_fail', array($notices));
         $con->redirect(Url::toRoute('/public/notices'));
         \Yii::$app->end();
     }
     //解密数据
     $jsonstring = \Yii::$app->security->decryptByKey($token, $logs->hash_key);
     $fitdata = json_decode($jsonstring);
     if ($fitdata->tokenstring != $logs->hash_key) {
         $error = '密钥对应不上,不能进行操作。';
         $notices = array('type' => 2, 'msgtitle' => '错误的操作', 'message' => $error, 'backurl' => Url::toRoute('/member/index/index'), 'backtitle' => '返回');
         \Yii::$app->getSession()->setFlash('wechat_fail', array($notices));
         $con->redirect(Url::toRoute('/public/notices'));
         \Yii::$app->end();
     } else {
         $user = \Yii::$app->user->getIdentity();
         $user_id = $user->user_id;
         try {
             $addip = \Yii::$app->request->userIP;
             $conn = \Yii::$app->db;
             $command = $conn->createCommand('call p_lock_logis_Bail(:in_user_id,:logis_id,:in_addip,@out_status,@out_remark)');
             $command->bindParam(":in_user_id", $user_id, PDO::PARAM_INT);
             $command->bindParam(":logis_id", $logis_id, PDO::PARAM_INT);
             $command->bindParam(":in_addip", $addip, PDO::PARAM_STR, 50);
             $command->execute();
             $result = $conn->createCommand("select @out_status as status,@out_remark as remark")->queryOne();
         } catch (Exception $e) {
             $result = ['status' => 0, 'remark' => '系统繁忙,暂时无法处理'];
         }
         $error = $result['remark'];
         $msgtitle = '错误的操作';
         if ($error['status'] == 1) {
             $msgtitle = '担保成功!';
         }
         $notices = array('type' => 2, 'msgtitle' => $msgtitle, 'message' => $error, 'backurl' => Url::toRoute('/member/index/index'), 'backtitle' => '返回');
         \Yii::$app->getSession()->setFlash('wechat_fail', array($notices));
         $con->redirect(Url::toRoute('/public/notices'));
         \Yii::$app->end();
     }
 }
예제 #2
0
 /**
  * 上传物品图片
  */
 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;
 }