public function doSaveInformationAction()
 {
     list($openid, $id, $key) = $this->getInput(array('openid', 'pid', 'key'));
     $this->setOutput($openid, 'openId');
     if (!isset($_SESSION)) {
         @session_start();
     }
     $_SESSION['exchangekey'] = $key;
     //user validation
     $userMoney = $this->getUserMoneyByOpenId($openid);
     if (empty($userMoney) == false && isset($_SESSION['exchangekey'])) {
         $prize = $this->_getCommonDs()->getPrizeById($id);
         //check user money
         if (empty($prize) == false && $prize['dmoney'] <= $userMoney['money']) {
             $deductDMoeny = 0 - $prize['dmoney'];
             $isDeduct = $this->_getMyMoneyDS()->updateMyMoney($userMoney['userid'], $deductDMoeny, 0, $prize['name']);
             if ($isDeduct > 0) {
                 unset($_SESSION['exchangekey']);
                 $this->setOutput($isDeduct, "isDeduct");
             }
             $myMoney = $this->_getMyMoneyDS()->getMyMoney($userMoney['userid']);
             $this->setOutput($myMoney[0], 'myMoney');
             $this->setOutput($prize, "prize");
             list($pid, $receiveContactor, $receivePhone, $receiveQQ, $receiveAddress) = $this->getInput(array('pid', 'receiveContactor', 'receivePhone', 'receiveQQ', 'receiveAddress'));
             $dm = new App_Giftexchange_Dm();
             $dm->setUserId($userMoney['userid'])->setContact($receiveContactor)->setPhoneNumber($receivePhone)->setqq($receiveQQ)->setAddress($receiveAddress)->setProductId($prize['id'])->setCreateTime(Pw::getTime());
             $saveInfo = $this->_getGiftexchangeDS()->add($dm);
             $this->setOutput($saveInfo, 'saveInfo');
         }
     } else {
         $url = WindUrlHelper::createUrl('app/4tmobile/mobilemymoney/run', array('openid' => $openid));
         $this->forwardRedirect($url);
     }
 }
Esempio n. 2
0
 public function doSaveInformationAction()
 {
     $returnMs;
     $userid = $this->loginUser->uid;
     if (!$userid > 0) {
         $returnMsg = "您还没有登录,请登录后在兑换礼品!";
         $this->redirectAndShowMsg($returnMsg);
     }
     $userMoney = $this->_getMyMoneyDS()->getMyMoney($userid);
     $userMoney = $userMoney[0];
     if (empty($userMoney)) {
         $returnMsg = "未知的用户!";
         $this->redirectAndShowMsg($returnMsg);
     }
     $pid = $this->getInput('pid');
     $prize = $this->_getGiftExchange()->getPrizeById($pid);
     if (empty($prize)) {
         $returnMsg = "您所选择的商品不存在,请重新兑换。";
         $this->redirectAndShowMsg($returnMsg);
     }
     if ($prize['dmoney'] > $userMoney['money']) {
         $returnMsg = "您的点币不足,点餐返点币,赶快去点餐吧!";
         $this->redirectAndShowMsg($returnMsg);
     }
     $deductDMoeny = 0 - $prize['dmoney'];
     $isDeduct = $this->_getMyMoneyDS()->updateMyMoney($userMoney['userid'], $deductDMoeny, 0, $prize['name']);
     if ($isDeduct != 1) {
         $returnMsg = "非常抱歉,您刚才的兑换失败了,请再次尝试。";
         $this->redirectAndShowMsg($returnMsg);
     }
     $myMoney = $this->_getMyMoneyDS()->getMyMoney($userMoney['userid']);
     $this->setOutput($myMoney[0], 'myMoney');
     $this->setOutput($prize, "prize");
     list($pid, $receiveContactor, $receivePhone, $receiveQQ, $receiveAddress) = $this->getInput(array('pid', 'receiveContactor', 'receivePhone', 'receiveQQ', 'receiveAddress'));
     $dm = new App_Giftexchange_Dm();
     $dm->setUserId($userMoney['userid'])->setContact($receiveContactor)->setPhoneNumber($receivePhone)->setqq($receiveQQ)->setAddress($receiveAddress)->setProductId($prize['id'])->setCreateTime(Pw::getTime());
     $row = $this->_getGiftExchange()->add($dm);
     if (!$row > 0) {
         $returnMsg = "收货信息保存失败,请联系点餐哟客服人工处理,给您带来的不便我们深表歉意!";
         $this->redirectAndShowMsg($returnMsg);
     }
     if ($row) {
         $nowtime = date('Y-m-d H:i:s');
         Wind::import('LIB:utility.PwMail');
         $mail = new PwMail();
         $mail->sendMail($receiveQQ . '@qq.com', $nowtime . '点餐哟点币兑换', '您已成功兑换' . $prize['name']);
     }
     $returnMsg = "您已成功兑换" . $prize['name'] . ",消耗点币" . $prize['dmoney'] . "个。我们将尽快处理,相关信息将以短信或电话的方式通知您。兑换详情请到零钱包中查看。";
     $this->redirectAndShowMsg($returnMsg);
     die;
 }
Esempio n. 3
0
 public function editAction()
 {
     date_default_timezone_set('PRC');
     list($id, $exchangesuccess, $exceptionexchange) = $this->getInput(array('id', 'exchangesuccess', 'exceptionexchange'));
     $oneGiftExchange = $this->_getGiftExchange()->getOneGiftExchange($id);
     if ($this->getInput('type', 'post') === 'do') {
         if ($exchangesuccess == $exceptionexchange) {
             $this->showError('不能存在两种是');
             return;
         }
         $dm = new App_Giftexchange_Dm();
         $dm->setExchangeSuccess($exchangesuccess)->setExceptionExchange($exceptionexchange)->setUpdateTime(date("Y-m-d H:i:s"));
         $r = $this->_getGiftExchange()->update($id, $dm);
         if ($r == 1) {
             $this->showMessage('更新成功');
         } else {
             $this->showError('更新失败,请联系管理员');
         }
     }
     $this->setOutput($oneGiftExchange, 'oneGiftExchange');
 }
Esempio n. 4
0
 /**
  * update record
  *
  * @param App_Giftexchange_Dm $dm
  * @return multitype:|Ambigous <boolean, number, rowCount>
  */
 public function update($id, App_Giftexchange_Dm $dm)
 {
     if (true !== ($r = $dm->beforeUpdate())) {
         return $r;
     }
     return $this->loadDao()->update($id, $dm->getData());
 }