Example #1
0
 /**
  * @inheritdoc
  */
 public function init()
 {
     $this->userId = Yii::$app->session->get('userId');
     if (!empty($this->userId)) {
         $this->userInfo = User::find()->where(['userId' => $this->userId])->one();
     }
     if (empty($this->userInfo)) {
         Tool::throwCustomerException('please login first!');
     }
     parent::init();
 }
Example #2
0
 /**
  * modify info
  */
 public function actionModifyinfo()
 {
     //get data
     $data = Tool::getAll();
     $data['id'] = Yii::$app->session->get('userId');
     $result = UserLogical::getInstance()->modifyInfo($data);
     if ($result) {
         Tool::outputJson('success!');
     }
     Tool::throwCustomerException('failed!');
 }
Example #3
0
 /**
  */
 public function doPay()
 {
     switch ($this->paymentType) {
         case self::PAYMENT_TYPE_WEI_XIN:
             break;
         case self::PAYMENT_TYPE_ALI_PAY:
             break;
         default:
             Tool::throwCustomerException('paymentType not exist!');
     }
 }
Example #4
0
 /**
  * @param $data
  * @return bool|int
  * @throws \Exception
  */
 public function modifyInfo($data)
 {
     if (!is_array($data) || empty($data) || !isset($data['id']) || empty($data['id'])) {
         return false;
     }
     $oldInfo = $this->findDataModel(['id' => (int) $data['id']]);
     if (empty($oldInfo)) {
         Tool::throwCustomerException('please login first!');
     }
     foreach ($data as $key => $val) {
         if ($this->isHadField($key) && "{$oldInfo->{$key}}" !== "{$val}") {
             $oldInfo->{$key} = $val;
         }
     }
     return $oldInfo->update();
 }