Example #1
0
 public function InsertUserActive($DataArr)
 {
     $oActive = new Lm_Active();
     $this->db->begin();
     $position = Base_Common::getUserDataPositionById($DataArr['UserId']);
     $Id = substr($DataArr['UserId'], 0, -3);
     $table_to_insert = Base_Common::getUserTable($this->table_active, $position);
     $active = $this->db->insert($table_to_insert, $DataArr);
     if ($active) {
         $updateActiveCode = $oActive->updateUserActiveCode($DataArr['ActiveCode'], array('ActiveUser' => $DataArr['UserId'], 'ActiveTime' => $DataArr['ActiveTime']));
         if ($updateActiveCode) {
             $this->db->commit();
             return true;
         } else {
             $this->db->rollback();
             return false;
         }
     } else {
         $this->db->rollback();
         return false;
     }
 }
 /**
  *用户名方式登录
  */
 public function actionOne($UserLotoLog)
 {
     if ($UserLotoLog['LotoPrizeId'] == 5) {
         $AppId = 101;
         $PartnerId = 1;
         //查询用户激活记录
         $checkResult = $this->oUser->GetUserActive($UserLotoLog['UserId'], $AppId, $PartnerId);
         //返回用户激活记录
         if (count($checkResult)) {
             $result = array('return' => 2, 'comment' => "已经激活");
         } else {
             $oActive = new Lm_Active();
             $ActiveCode = $oActive->getUnUsedActiveCode($AppId, $PartnerId, 0, 1);
             $time = time();
             $User = array('AppId' => $AppId, 'PartnerId' => $PartnerId, 'UserId' => $UserLotoLog['UserId'], 'ActiveTime' => $time, 'ActiveCode' => $ActiveCode['0']['ActiveCode']);
             $activeResult = $this->oUser->InsertUserActive($User);
             //检查更新结果
             if (intval($activeResult) == 1) {
                 $this->oPrize->updateLotoLog(1, $UserLotoLog['LotoLogId'], array('PrizeGetTime' => $time, 'Comment' => json_encode(array('PrizeType' => 'autoActive'))));
                 $result = array('return' => 1, 'comment' => "自动激活成功");
             } else {
                 $result = array('return' => 0, 'comment' => "激活失败");
             }
         }
         return $result;
     }
 }