function buildArrayResponse($json) { $giftsJSONObj = $this->getServiceJSONObject("gifts", $json); $giftList = array(); if ($giftsJSONObj->__get("gift") instanceof JSONObject) { $giftJSONObj = $giftsJSONObj->__get("gift"); $giftObj = new Gift(); $this->buildObjectFromJSONTree($giftObj, $giftJSONObj); $giftObj->setStrResponse($json); $giftObj->setResponseSuccess($this->isRespponseSuccess($json)); array_push($giftList, $giftObj); } else { $giftJSONArray = $giftsJSONObj->getJSONArray("gift"); for ($i = 0; $i < count($giftJSONArray); $i++) { $giftJSONObj = $giftJSONArray[$i]; $gift = new Gift(); $gift->setStrResponse($json); $gift->setResponseSuccess($this->isRespponseSuccess($json)); $giftJSONObject = new JSONObject($giftJSONObj); $this->buildObjectFromJSONTree($gift, $giftJSONObject); array_push($giftList, $gift); } } return $giftList; }
/** * 分类删除后,所有分类下的Gift的categoryId都修改为0 */ protected function afterDelete() { $model = new Gift(); $attributes = array('categoryId' => 0); $condition = "categoryId={$this->id}"; $model->updateAll($attributes, $condition); }
/** * @covers Gift::get_gift_certificate */ public function testGet_gift_certificate() { $gift = $this->object->get_gift_certificate('4a2vr23p6gx7w82f'); $this->assertJson($gift); $gift_obj = json_decode($gift); $this->assertObjectHasAttribute('error', $gift_obj); $this->assertObjectHasAttribute('key', $gift_obj); $this->assertEquals(33, $gift_obj->gift_array->value); }
/** * 获取礼物信息 * @param int $type // 礼物类型 */ public function actionGetGiftInfo() { // 参数检查 if (!isset($_REQUEST['type'])) { $this->_return('MSG_ERR_LESS_PARAM'); } $type = trim(Yii::app()->request->getParam('type')); $now = date("Y-m-d H:i:s"); if (!is_numeric($type)) { $this->_return('MSG_ERR_FAIL_PARAM'); } $data = Gift::model()->schedule($type); $result = array(); if (is_array($data) && !empty($data)) { foreach ($data as $k => $v) { $temp = array(); $temp['id'] = (int) $v['gift_id']; $temp['url'] = Yii::app()->params['img_url_base'] . $v['url']; $temp['name'] = $v['name']; $temp['type'] = (int) $v['type']; $temp['liking'] = (int) $v['add_liking']; $temp['exp'] = (int) $v['add_exp']; $temp['point'] = (int) $v['add_point']; $temp['vit'] = (int) $v['minus_vit']; $temp['level'] = (int) $v['lv']; $temp['gold'] = (int) $v['gold']; $result[] = $temp; } } $this->_return('MSG_SUCCESS', $result); }
public function topicDetail() { $topic_id = Input::get('topic_id'); $topic = Topic::find($topic_id); if (!isset($topic)) { return Response::view('errors.missing'); } //预载入 $gifts = Gift::where('topic_id', $topic->id)->with(['giftPosters' => function ($query) { $query->orderBy('created_at', 'asc'); }])->get(); $number = 1; foreach ($gifts as $gift) { $gift->img = $gift->giftPosters[0]->url; $gift->number = $number++; } // $gifts = Gift::where('topic_id', '=', $topic->id)->get(); // if(isset($gifts)) // { $number = 1; // foreach($gifts as $gift) // { // $url = GiftPoster::where('gift_id','=',$gift->id)->first()->url; // // $gift->img = StaticController::imageWH($url); // $gift->img = $url; // $gift->number = $number++; // } // } $gifts = $this->isGiftLike($gifts); $type = $this->isTopicLike($topic_id); return View::make('pc.subject')->with(array('topic' => $topic, 'gifts' => $gifts, 'type' => $type)); }
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer the ID of the model to be loaded */ public function loadModel($id) { $model = Gift::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
public function insertData() { $gifts = json_decode(file_get_contents(app_path() . '/storage/gifts.txt')); $topics = json_decode(file_get_contents(app_path() . '/storage/topics.txt')); $gift_posters = json_decode(file_get_contents(app_path() . '/storage/gift_posters.txt')); $gift_photo_intros = json_decode(file_get_contents(app_path() . '/storage/gift_photo_intros.txt')); foreach ($topics as $topic) { $t = new Topic(); $t->id = $topic->id; $t->title = $topic->title; $t->content = $topic->content; $t->topic_url = $topic->topic_url; if (!$t->save()) { return 'topic_false'; } } foreach ($gifts as $gift) { $g = new Gift(); $g->id = $gift->id; $g->topic_id = $gift->topic_id; $g->title = $gift->title; $g->price = $gift->price; $g->content = $gift->content; if (!$g->save()) { return 'gift_false'; } } foreach ($gift_posters as $gift_poster) { $tp = new GiftPoster(); $tp->gift_id = $gift_poster->gift_id; $tp->url = $gift_poster->url; if (!$tp->save()) { return 'gift_poster_false'; } } foreach ($gift_photo_intros as $gift_photo_intro) { $gpi = new GiftPhotoIntro(); $gpi->gift_id = $gift_photo_intro->gift_id; $gpi->url = $gift_photo_intro->url; if (!$gpi->save()) { return 'gift_photo_intro_false'; } } return Response::json(array('errCode' => 0, 'message' => '插入成功')); }
public static function gifts() { $gifts = Gift::orderBy('created_at', 'desc')->get(); foreach ($gifts as $gift) { $url = GiftPoster::where('gift_id', '=', $gift->id)->first()->url; $gift->img = StaticController::imageWH($url); } return $gifts; }
public function home() { $scroll_imgs = ScrollImg::all(); //话题 $topics = Topic::where('topic_url', '!=', '')->orderBy('created_at', 'desc')->get(); $topics = StaticController::page(12, 1, $topics); //每日推荐 $daily = Poster::where('daily_id', '=', 1)->get(); //每日推 $daily = StaticController::page(16, 1, $daily); // $user = Sentry::findUserById(4); // Sentry::login($user,false); // Sentry::logout(); if (Sentry::check()) { foreach ($daily as $recommend) { $gift = Gift::find($recommend->info_url); $recommend->title = $gift->title; $recommend->price = $gift->price; $recommend->taobao_url = $gift->taobao_url; $gift_focus = GiftFocus::where('gift_id', '=', $recommend->info_url)->where('user_id', '=', Sentry::getUser()->id)->first(); /* 2015-09-16 hyy fix */ if (isset($gift_focus)) { $recommend->focus = 1; } else { $recommend->focus = 0; } } } else { foreach ($daily as $recommend) { $gift = Gift::find($recommend->info_url); $recommend->title = $gift->title; $recommend->price = $gift->price; $recommend->taobao_url = $gift->taobao_url; $recommend->focus = 0; } } //精选话题 $articles = DB::table('articles')->orderBy('focus_num', 'desc')->get(); $articles = StaticController::page(12, 1, $articles); if ($articles) { foreach ($articles as $article) { $article_url = ArticlePart::where('article_id', '=', $article->id)->where('type', '=', 'url')->first(); // dd($article_url->content); if (isset($article)) { $article->url = $article_url->content; } else { $article->url = null; } } } return View::make('pc.home')->with(array('topics' => $topics, 'gifts' => $daily, 'articles' => $articles, 'scroll_imgs' => $scroll_imgs)); }
/** * Updates a particular model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id the ID of the model to be updated */ public function actionUpdate($id) { $model = $this->loadModel($id); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Giver'])) { $_POST['Giver']['phone'] = $this->cleanPhoneNumber($_POST['Giver']['phone']); $model->attributes = $_POST['Giver']; if ($model->save()) { $this->redirect(array('view', 'id' => $model->id)); } } $this->render('update', array('model' => $model, 'giftModel' => Gift::model())); }
/** * Queue payment and save gift details. */ function execute() { $journal = $this->request->getJournal(); $journalId = $journal->getId(); // Create new gift and save details import('classes.gift.Gift'); import('classes.payment.ojs.OJSPaymentManager'); $paymentManager = new OJSPaymentManager($this->request); $paymentPlugin =& $paymentManager->getPaymentPlugin(); $gift = new Gift(); if ($paymentPlugin->getName() == 'ManualPayment') { $gift->setStatus(GIFT_STATUS_AWAITING_MANUAL_PAYMENT); } else { $gift->setStatus(GIFT_STATUS_AWAITING_ONLINE_PAYMENT); } $gift->setAssocType(ASSOC_TYPE_JOURNAL); $gift->setAssocId($journalId); $gift->setGiftType(GIFT_TYPE_SUBSCRIPTION); $gift->setGiftAssocId($this->getData('typeId')); $gift->setBuyerFirstName($this->getData('buyerFirstName')); $gift->setBuyerMiddleName($this->getData('buyerMiddleName')); $gift->setBuyerLastName($this->getData('buyerLastName')); $gift->setBuyerEmail($this->getData('buyerEmail')); $gift->setBuyerUserId($this->buyerUserId ? $this->buyerUserId : null); $gift->setRecipientFirstName($this->getData('recipientFirstName')); $gift->setRecipientMiddleName($this->getData('recipientMiddleName')); $gift->setRecipientLastName($this->getData('recipientLastName')); $gift->setRecipientEmail($this->getData('recipientEmail')); $gift->setRecipientUserId(null); $gift->setLocale($this->getData('giftLocale')); $gift->setGiftNoteTitle($this->getData('giftNoteTitle')); $gift->setGiftNote($this->getData('giftNote')); $giftDao = DAORegistry::getDAO('GiftDAO'); $giftId = $giftDao->insertObject($gift); // Create new queued payment $subscriptionTypeDao = DAORegistry::getDAO('SubscriptionTypeDAO'); $subscriptionType =& $subscriptionTypeDao->getSubscriptionType($this->getData('typeId')); $queuedPayment =& $paymentManager->createQueuedPayment($journalId, PAYMENT_TYPE_GIFT, null, $giftId, $subscriptionType->getCost(), $subscriptionType->getCurrencyCodeAlpha()); $queuedPaymentId = $paymentManager->queuePayment($queuedPayment); $paymentManager->displayPaymentForm($queuedPaymentId, $queuedPayment); }
public function selectByLabel() { $inputs = array('char_id' => Input::get('_char'), 'scene_id' => Input::get('scene'), 'object_id' => Input::get('object'), 'price_id' => Input::get('price')); // dd($inputs['object_id']); $per_page = Input::get('per_page'); $page = Input::get('page'); $inputs = array_filter($inputs); // dd(count($inputs)); $query = null; // dd($inputs['price_id']); foreach ($inputs as $key => $value) { if ($query != null) { $query = $query->where($key, $value); } else { $query = Gift::where($key, $value); } } if ($query == null) { // dd(count($gifts)); //标签没有的情况 // $gifts = StaticController::gifts(); $gifts = Gift::orderBy('created_at', 'desc')->get(); $total = ceil(count($gifts) / $per_page); $gifts = StaticController::page($per_page, $page, $gifts); $gifts = $this->addGiftImg($gifts); return Response::json(array('errCode' => 0, 'message' => '没有筛选礼品,返回全部', 'gifts' => $gifts, 'total' => $total)); } $gifts = $query->get(); if (count($gifts) == 0) { // $gifts = StaticController::gifts(); $gifts = Gift::orderBy('created_at', 'desc')->get(); $total = ceil(count($gifts) / $per_page); $gifts = StaticController::page($per_page, $page, $gifts); $gifts = $this->addGiftImg($gifts); return Response::json(array('errCode' => 0, 'message' => '没有筛选礼品,返回全部', 'gifts' => $gifts, 'total' => $total)); } $total = ceil(count($gifts) / $per_page); $gifts = StaticController::page($per_page, $page, $gifts); $gifts = $this->addGiftImg($gifts); return Response::json(array('errCode' => 0, 'message' => '返回搜索数据', 'gifts' => $gifts, 'total' => $total)); }
public function collection() { if (!Sentry::check()) { return Response::json(array('errCode' => 10, 'message' => '请登录')); } $gift_id = Input::get('gift_id'); /* 2015-09-16 hyy 改 start */ $gift_focus = GiftFocus::where('user_id', '=', Sentry::getUser()->id)->where('gift_id', '=', $gift_id)->first(); if (isset($gift_focus)) { try { DB::transaction(function () use($gift_id, $gift_focus) { //礼品收藏人数减1 $gift = Gift::find($gift_id); $gift->focus_num = $gift->focus_num - 1; $gift->save(); $gift_focus->delete(); }); } catch (\Exception $e) { return Response::json(array('errCode' => 11, 'message' => '操作失败')); } /* 2015-09-16 hyy 改 end */ return Response::json(array('errCode' => 0, 'message' => 'cancel')); } else { try { DB::transaction(function () use($gift_id) { //礼品收藏人数加1 $gift = Gift::find($gift_id); $gift->focus_num = $gift->focus_num + 1; $gift->save(); $gift_focus = new GiftFocus(); $gift_focus->user_id = Sentry::getUser()->id; $gift_focus->gift_id = $gift_id; $gift_focus->save(); }); } catch (\Exception $e) { return Response::json(array('errCode' => 11, 'message' => '操作失败')); } return Response::json(array('errCode' => 0, 'message' => 'collect')); } }
/** * 给女神送礼 * @param unknown $user_id * @param unknown $goddess_id * @param unknown $gift_id * @param unknown $number */ public function giveGift($user_id, $goddess_id, $gift_id, $number) { try { $characters_transaction = Yii::app()->db_characters->beginTransaction(); $heroine_transaction = Yii::app()->db_heroine->beginTransaction(); //是否关注女神 if (!Follow::model()->isExitsFollow($user_id, $goddess_id)) { return -3; } //获取礼物信息 $gift_info = Gift::model()->getGiftInfo($gift_id); if ($gift_info) { //获取角色信息 $characters = Characters::model()->getCharactersInfo($user_id); if ($gift_info['is_give'] == 1) { $flowers_counts = $characters['flowers']; if ($number > $flowers_counts) { //赠送鲜花数超过已有鲜花数 $number = $number - $flowers_counts; $temp_num = $flowers_counts; } else { $temp_num = $number; } if ($temp_num != 0) { $characters['flowers'] = $characters['flowers'] - $temp_num; //角色加 经验 积分 $params = array('exp' => $characters['exp'] + $temp_num * $gift_info['add_exp'], 'point' => $characters['point'] + $temp_num * $gift_info['add_point'], 'flowers' => $characters['flowers']); //更新等级 $lv = Level::model()->exp2Level($params['exp']); if (!empty($lv) && strcmp($lv, $characters['level']) != 0) { $params['level'] = $lv; } Characters::model()->updateCharacters($user_id, $params); //女神好感 $follow = Follow::model()->getFollowRow($user_id, $goddess_id); //好感度 $liking_val = $follow['liking'] + $temp_num * $gift_info['add_liking']; //增加女神对角色的好感度 Follow::model()->updateFollow(date('Y-m-d H:i:s'), $user_id, $goddess_id, null, null, $liking_val); //增加魅力值 $glamorousCount = Goddess::model()->getGlamorousCount($goddess_id); $glamorous = array('glamorous' => (int) $glamorousCount + $temp_num * (int) $gift_info['add_glamorous']); Goddess::model()->updateHeroineInfo($goddess_id, $glamorous); //增加用户送礼物给女神记录 $this->createHeroineGift($user_id, $goddess_id, $gift_id, $temp_num); // 提交事务 $characters_transaction->commit(); $heroine_transaction->commit(); $res['log'] = ''; $res['log']['gold'] = 0; $res['result'] = array('point' => (int) $params['point'], 'exp' => (int) $params['exp'], 'vit' => (int) $characters['vit'], 'vit_time' => (int) $characters['vit_time'], 'level' => (int) $lv, 'gold' => (int) $characters['gold'], 'flowers' => (int) $characters['flowers'], 'goddess_id' => (int) $goddess_id, 'liking' => $liking_val); return $res; } } $total = $gift_info['gold'] * $number; //扣金币 if ($total > $characters['gold']) { return -4; } //角色加金币 经验 积分 $params = array('gold' => (int) $characters['gold'] - (int) $total, 'exp' => (int) $characters['exp'] + $number * $gift_info['add_exp'], 'point' => (int) $characters['point'] + $number * $gift_info['add_point']); //更新等级 $lv = Level::model()->exp2Level($params['exp']); if (!empty($lv) && strcmp($lv, $characters['level']) != 0) { $params['level'] = $lv; } Characters::model()->updateCharacters($user_id, $params); //女神好感 $follow = Follow::model()->getFollowRow($user_id, $goddess_id); //好感度 $liking_val = $follow['liking'] + $number * $gift_info['add_liking']; //增加女神对角色的好感度 Follow::model()->updateFollow(date('Y-m-d H:i:s'), $user_id, $goddess_id, null, null, $liking_val); //增加魅力值 $glamorousCount = Goddess::model()->getGlamorousCount($goddess_id); $glamorous = array('glamorous' => (int) $glamorousCount + $number * (int) $gift_info['add_glamorous']); Goddess::model()->updateHeroineInfo($goddess_id, $glamorous); //增加用户送礼物给女神记录 $this->createHeroineGift($user_id, $goddess_id, $gift_id, $number); // 提交事务 $characters_transaction->commit(); $heroine_transaction->commit(); $res['log']['gold'] = -$total; $res['log']['gold_after'] = (int) $characters['gold'] - (int) $total; $res['result'] = array('point' => (int) $params['point'], 'exp' => (int) $params['exp'], 'vit' => (int) $characters['vit'], 'vit_time' => (int) $characters['vit_time'], 'level' => (int) $lv, 'gold' => (int) $params['gold'], 'flowers' => (int) $characters['flowers'], 'goddess_id' => (int) $goddess_id, 'liking' => (int) $liking_val); } else { return -2; } } catch (Exception $e) { error_log($e); $characters_transaction->rollback(); $heroine_transaction->rollback(); //更新失败 return -1; } return $res; }
/** * undocumented function * * @param string $type * @param string $query * @return void * @access public */ function find($type, $query = array()) { $args = func_get_args(); switch ($type) { case 'gift_types': $query['office_id'] = Gift::officeId(); $conditions = array(); if (!empty($query['office_id'])) { $conditions['GiftTypesOffice.office_id'] = $query['office_id']; } $types = ClassRegistry::init('GiftTypesOffice')->find('all', array('conditions' => $conditions, 'contain' => array('GiftType(name, id, humanized)'), 'order' => array('GiftType.name' => 'asc'))); $result = array(); foreach ($types as $t) { $result[$t['GiftType']['id']] = $t['GiftType']['humanized']; } return $result; case 'frequencies': $query['office_id'] = Gift::officeId(); $conditions = array(); if (!empty($query['office_id'])) { $conditions['FrequenciesOffice.office_id'] = $query['office_id']; } $frequencies = ClassRegistry::init('FrequenciesOffice')->find('all', array('conditions' => $conditions, 'contain' => array('Frequency(name, id, humanized)'), 'order' => array('Frequency._order' => 'asc'))); $result = array(); foreach ($frequencies as $f) { $result[$f['Frequency']['id']] = $f['Frequency']['humanized']; } return $result; case 'amounts': $query['office_id'] = Gift::officeId(); $amounts = '5,10,15'; if (!isset($query['options']) && !empty($query['office_id'])) { $amounts = ClassRegistry::init('Office')->find('first', array('conditions' => array('id' => $query['office_id']), 'fields' => array('amounts'))); $amounts = $amounts['Office']['amounts']; } return $amounts; case 'min_amount': $amounts = Gift::find('amounts', $query); return $amounts[0]; case 'currencies': $query['office_id'] = Gift::officeId(); $conditions = array(); if (!empty($query['office_id'])) { $conditions['CurrenciesOffice.office_id'] = $query['office_id']; } $currencies = ClassRegistry::init('CurrenciesOffice')->find('all', array('conditions' => $conditions, 'contain' => array('Currency(iso_code, id)'), 'order' => array('Currency.iso_code' => 'asc'))); return Set::combine($currencies, '/Currency/id', '/Currency/iso_code'); } return call_user_func_array(array('parent', 'find'), $args); }
public function doWebRedGifts() { global $_W, $_GPC; if (!$_W['ispost']) { $this->doWebAuth(); checklogin(); } $modulePublic = '../addons/wwx_fxxt/style/static/'; $foo = $_GPC['foo']; $foos = array('list', 'create', 'modify', 'delete', 'search'); $foo = in_array($foo, $foos) ? $foo : 'list'; require_once WWX_FXXT_ROOT . '/class/Gift.class.php'; if ($foo == 'search') { $fuzzy = $_GPC['fuzzy']; $filters = array(); $filters['title'] = $fuzzy; $g = new Gift(); $ds = $g->getAll($filters, 1, 20); /**GIFT:2.查询所有活动礼品分类**/ $rs = array(); if (!empty($ds)) { foreach ($ds as $row) { $rs[] = array_elements(array('id', 'type', 'title'), $row); } } exit(json_encode($rs)); } if ($foo == 'create') { if ($_W['ispost']) { $input = array_elements(array('title', 'type', 'remark'), $_GPC); $input['remark'] = htmlspecialchars_decode($input['remark']); if ($input['type'] == 'cash') { $input['tag'] = serialize($_GPC['cash']); } else { $input['tag'] = ''; } $g = new Gift(); $ret = $g->create($input); /**GIFT:3.编辑活动礼品分类**/ if (is_error($ret)) { message($ret['message']); } else { message('成功保存礼品信息', $this->createWebUrl('redgifts')); } } $entity = array(); $entity['type'] = 'cash'; $entity['tag'] = array(); load()->func('tpl'); include $this->template('redgifts_form'); } if ($foo == 'modify') { $id = $_GPC['id']; $g = new Gift(); $entity = $g->getOne($id); /**GIFT:1.根据ID查询活动礼品分类**/ if (empty($entity)) { message('访问错误'); } if ($_W['ispost']) { $input = array_elements(array('title', 'type', 'remark'), $_GPC); $input['remark'] = htmlspecialchars_decode($input['remark']); if ($input['type'] == 'cash') { $input['tag'] = serialize($_GPC['cash']); } else { $input['tag'] = ''; } $g = new Gift(); $ret = $g->modify($id, $input); /**GIFT:4.根据ID编辑活动礼品分类**/ if (is_error($ret)) { message($ret['message']); } else { message('成功保存礼品信息', $this->createWebUrl('redgifts')); } } load()->func('tpl'); include $this->template('redgifts_form'); } if ($foo == 'delete') { $id = $_GPC['id']; $g = new Gift(); $g->remove($id); /**GIFT:5.根据ID删除活动礼品分类**/ message('成功删除礼品信息', $this->createWebUrl('redgifts')); } if ($foo == 'list') { $a = new Gift(); $ds = $a->getAll(array()); /**GIFT:2.查询所有活动礼品分类**/ include $this->template('redgifts_list'); } }
public function actionEditUser($id) { $this->layout = "admindashboard"; //for editing users starts here $model = $this->loadModelUser($id); //for getting values from gift model $Gift = Gift::model()->findByAttributes(array('user_id' => $model->id)); // for getting values from gift model //Uncomment the following line if AJAX validation is needed $this->performAjaxValidation($model); if (isset($_POST['Users'])) { $model->attributes = $_POST['Users']; $model->status = $_POST['status']; $Gift->custom_msg = $_POST['custom_msg']; $model->date_modified = date('Y-m-d H:i:s'); if ($model->save()) { $Gift->save(); $this->redirect(array('userList')); } } $this->render('edituser', array('model' => $model, 'Gift' => $Gift)); //for editing users ends here }
public function actionConfirm() { //Check for user action (if the user has already filled in his details or not) if (isset($_SESSION) && isset($_SESSION['userRegisterVal']) && $_SESSION['userRegisterVal']['email'] != '') { $this->layout = "homeinner"; $modelUser = new Users(); //for getting lastly saved value of Gift model $userGiftId = $_SESSION['giftId']; if (isset($userGiftId) && $userGiftId != '') { Yii::app()->user->setFlash('successmessage', 'You have been registered properly.. Please check your mailbox'); } else { Yii::app()->user->setFlash('failuremessage', 'Please fill the form properly again'); } //for getting lastly saved value of Gift model by current user $giftLastValue = Gift::model()->findByAttributes(array('id' => $userGiftId)); //for getting lastly saved value of Gift model by current user //destroying session here.. session_destroy(); //create new session to keep current gift id for fbshare session_start(); $_SESSION['giftId'] = $userGiftId; //render page to view page.... $this->render('finalconfirmed', array('modelUser' => $modelUser, 'maxIdGift' => $userGiftId, 'giftLastValue' => $giftLastValue)); } else { //Redirect to home page $this->redirect('../index.php', ''); } }
} if ($_W['ispost']) { $input = array_elements(array('title', 'type', 'remark'), $_GPC); $input['remark'] = htmlspecialchars_decode($input['remark']); if ($input['type'] == 'cash') { $input['tag'] = serialize($_GPC['cash']); } else { $input['tag'] = ''; } $g = new Gift(); $ret = $g->modify($id, $input); if (is_error($ret)) { message($ret['message']); } else { message('成功保存礼品信息', $this->createWebUrl('gifts')); } } load()->func('tpl'); include $this->template('gifts-form'); } if ($foo == 'delete') { $id = $_GPC['id']; $g = new Gift(); $g->remove($id); message('成功删除礼品信息', $this->createWebUrl('gifts')); } if ($foo == 'list') { $a = new Gift(); $ds = $a->getAll(array()); include $this->template('gifts-list'); }
public function queryRecordCode($code) { global $_W; $condition = "`uniacid`=:uniacid AND `code`=:code"; $pars = array(); $pars[':uniacid'] = $_W['uniacid']; $pars[':code'] = $code; $sql = "SELECT * FROM " . tablename('wwx_fxxt_red_records') . " WHERE {$condition}"; $rec = pdo_fetch($sql, $pars); if (empty($rec)) { return error(-1, '消费码错误'); } if ($rec['status'] == 'complete') { $time = date('Y-m-d H:i', $rec['completed']); $rec['error'] = error(-2, "这个消费码已经于 {$time} 使用过了"); } require_once WWX_FXXT_ROOT . '/class/Gift.class.php'; $g = new Gift(); $gift = $g->getOne($rec['gift']); if (empty($gift)) { $rec['error'] = error(-3, '这个消费码的商品已经失效了'); } if ($gift['type'] != 'coupon') { $rec['error'] = error(-3, '这个消费码的商品属于现金产品, 不能被消费'); } $rec['tag'] = @unserialize($rec['tag']); $rec['gift'] = $gift; $rec['activity'] = $this->getOne($rec['activity']); return $rec; }
public function run() { $i = 0; for ($i = 0; $i < 50; $i++) { Gift::create(['topic_id' => $i + 1, 'title' => '新款阿登', 'price' => '999', 'content' => '床上总是很多零碎的杂物,不知道放在哪里。有了这个宿舍床头收纳架,就不怕床上没空间了。手机、水杯、充电器统统装得下,实用性强而且色彩明亮。舒服温馨的宿舍生活就靠它了。', 'gift_photo_intro' => 'http://7xl6gj.com1.z0.glb.clouddn.com/19.2.jpg', 'scan_num' => rand(1111, 8888), 'focus_num' => rand(1111, 8888), 'taobao_url' => 'https://detail.tmall.com/item.htm?spm=a217e.7765654.1998660470.7.a4lzKx&id=521089667043']); Gift::create(['topic_id' => $i + 1, 'title' => '新款阿登', 'price' => '999', 'content' => '床上总是很多零碎的杂物,不知道放在哪里。有了这个宿舍床头收纳架,就不怕床上没空间了。手机、水杯、充电器统统装得下,实用性强而且色彩明亮。舒服温馨的宿舍生活就靠它了。', 'gift_photo_intro' => 'http://7xl6gj.com1.z0.glb.clouddn.com/19.2.jpg', 'scan_num' => rand(1111, 8888), 'focus_num' => rand(1111, 8888), 'taobao_url' => 'https://detail.tmall.com/item.htm?spm=a217e.7765654.1998660470.7.a4lzKx&id=521089667043']); Gift::create(['topic_id' => $i + 1, 'title' => '新款阿登', 'price' => '999', 'content' => '床上总是很多零碎的杂物,不知道放在哪里。有了这个宿舍床头收纳架,就不怕床上没空间了。手机、水杯、充电器统统装得下,实用性强而且色彩明亮。舒服温馨的宿舍生活就靠它了。', 'gift_photo_intro' => 'http://7xl6gj.com1.z0.glb.clouddn.com/19.2.jpg', 'scan_num' => rand(1111, 8888), 'focus_num' => rand(1111, 8888), 'taobao_url' => 'https://detail.tmall.com/item.htm?spm=a217e.7765654.1998660470.7.a4lzKx&id=521089667043']); Gift::create(['topic_id' => $i + 1, 'title' => '新款阿登', 'price' => '999', 'content' => 'live younger,you need it, trust me', 'gift_photo_intro' => 'http://7xl6gj.com1.z0.glb.clouddn.com/19.2.jpg', 'scan_num' => rand(1111, 8888), 'focus_num' => rand(1111, 8888), 'taobao_url' => 'https://detail.tmall.com/item.htm?spm=a217e.7765654.1998660470.7.a4lzKx&id=521089667043']); } // Gift::create([ // 'topic_id'=>1, // 'title' => '新款阿登', // 'price' =>'999', // 'content' => '床上总是很多零碎的杂物,不知道放在哪里。有了这个宿舍床头收纳架,就不怕床上没空间了。手机、水杯、充电器统统装得下,实用性强而且色彩明亮。舒服温馨的宿舍生活就靠它了。', // 'gift_photo_intro' =>'http://7xl6gj.com1.z0.glb.clouddn.com/19.2.jpg', // 'scan_num' => '7859', // 'focus_num' => '7557', // 'taobao_url' =>'https://detail.tmall.com/item.htm?spm=a217e.7765654.1998660470.7.a4lzKx&id=521089667043' // ]); // Gift::create([ // 'topic_id'=>1, // 'title' => '新款阿登', // 'price' =>'999', // 'content' => '床上总是很多零碎的杂物,不知道放在哪里。有了这个宿舍床头收纳架,就不怕床上没空间了。手机、水杯、充电器统统装得下,实用性强而且色彩明亮。舒服温馨的宿舍生活就靠它了。', // 'gift_photo_intro' =>'http://7xl6gj.com1.z0.glb.clouddn.com/19.2.jpg', // 'scan_num' => '7859', // 'focus_num' => '7557', // 'taobao_url' =>'https://detail.tmall.com/item.htm?spm=a217e.7765654.1998660470.7.a4lzKx&id=521089667043' // ]); // Gift::create([ // 'topic_id'=>1, // 'title' => '新款阿登', // 'price' =>'999', // 'content' => '床上总是很多零碎的杂物,不知道放在哪里。有了这个宿舍床头收纳架,就不怕床上没空间了。手机、水杯、充电器统统装得下,实用性强而且色彩明亮。舒服温馨的宿舍生活就靠它了。', // 'gift_photo_intro' =>'http://7xl6gj.com1.z0.glb.clouddn.com/19.2.jpg', // 'scan_num' => '7859', // 'focus_num' => '7557', // 'taobao_url' =>'https://detail.tmall.com/item.htm?spm=a217e.7765654.1998660470.7.a4lzKx&id=521089667043' // ]); // Gift::create([ // 'topic_id'=>1, // 'title' => '新款阿登', // 'price' =>'999', // 'content' => 'live younger,you need it, trust me', // 'gift_photo_intro' =>'http://7xl6gj.com1.z0.glb.clouddn.com/19.2.jpg', // 'scan_num' => '7859', // 'focus_num' => '7557', // 'taobao_url' =>'https://detail.tmall.com/item.htm?spm=a217e.7765654.1998660470.7.a4lzKx&id=521089667043' // ]); // Gift::create([ // 'topic_id'=>2, // 'title' => '新款阿登', // 'price' =>'999', // 'content' => '床上总是很多零碎的杂物,不知道放在哪里。有了这个宿舍床头收纳架,就不怕床上没空间了。手机、水杯、充电器统统装得下,实用性强而且色彩明亮。舒服温馨的宿舍生活就靠它了。', // 'gift_photo_intro' =>'http://7xl6gj.com1.z0.glb.clouddn.com/19.2.jpg', // 'scan_num' => '7859', // 'focus_num' => '7557', // 'taobao_url' =>'https://detail.tmall.com/item.htm?spm=a217e.7765654.1998660470.7.a4lzKx&id=521089667043' // ]); // Gift::create([ // 'topic_id'=>2, // 'title' => '新款阿登', // 'price' =>'999', // 'content' => '床上总是很多零碎的杂物,不知道放在哪里。有了这个宿舍床头收纳架,就不怕床上没空间了。手机、水杯、充电器统统装得下,实用性强而且色彩明亮。舒服温馨的宿舍生活就靠它了。', // 'gift_photo_intro' =>'http://7xl6gj.com1.z0.glb.clouddn.com/19.2.jpg', // 'scan_num' => '7859', // 'focus_num' => '7557', // 'taobao_url' =>'https://detail.tmall.com/item.htm?spm=a217e.7765654.1998660470.7.a4lzKx&id=521089667043' // ]); // Gift::create([ // 'topic_id'=>2, // 'title' => '新款阿登', // 'price' =>'999', // 'content' => '床上总是很多零碎的杂物,不知道放在哪里。有了这个宿舍床头收纳架,就不怕床上没空间了。手机、水杯、充电器统统装得下,实用性强而且色彩明亮。舒服温馨的宿舍生活就靠它了。', // 'gift_photo_intro' =>'http://7xl6gj.com1.z0.glb.clouddn.com/19.2.jpg', // 'scan_num' => '7859', // 'focus_num' => '7557', // 'taobao_url' =>'https://detail.tmall.com/item.htm?spm=a217e.7765654.1998660470.7.a4lzKx&id=521089667043' // ]); // Gift::create([ // 'topic_id'=>2, // 'title' => '新款阿登', // 'price' =>'999', // 'content' => 'live younger,you need it, trust me', // 'gift_photo_intro' =>'http://7xl6gj.com1.z0.glb.clouddn.com/19.2.jpg', // 'scan_num' => '7859', // 'focus_num' => '7557', // 'taobao_url' =>'https://detail.tmall.com/item.htm?spm=a217e.7765654.1998660470.7.a4lzKx&id=521089667043' // ]); // Gift::create([ // 'topic_id'=>3, // 'title' => '新款阿登', // 'price' =>'999', // 'content' => '床上总是很多零碎的杂物,不知道放在哪里。有了这个宿舍床头收纳架,就不怕床上没空间了。手机、水杯、充电器统统装得下,实用性强而且色彩明亮。舒服温馨的宿舍生活就靠它了。', // 'gift_photo_intro' =>'http://7xl6gj.com1.z0.glb.clouddn.com/19.2.jpg', // 'scan_num' => '7859', // 'focus_num' => '7557', // 'taobao_url' =>'https://detail.tmall.com/item.htm?spm=a217e.7765654.1998660470.7.a4lzKx&id=521089667043' // ]); // Gift::create([ // 'topic_id'=>3, // 'title' => '新款阿登', // 'price' =>'999', // 'content' => '床上总是很多零碎的杂物,不知道放在哪里。有了这个宿舍床头收纳架,就不怕床上没空间了。手机、水杯、充电器统统装得下,实用性强而且色彩明亮。舒服温馨的宿舍生活就靠它了。', // 'gift_photo_intro' =>'http://7xl6gj.com1.z0.glb.clouddn.com/19.2.jpg', // 'scan_num' => '7859', // 'focus_num' => '7557', // 'taobao_url' =>'https://detail.tmall.com/item.htm?spm=a217e.7765654.1998660470.7.a4lzKx&id=521089667043' // ]); // Gift::create([ // 'topic_id'=>3, // 'title' => '新款阿登', // 'price' =>'999', // 'content' => '床上总是很多零碎的杂物,不知道放在哪里。有了这个宿舍床头收纳架,就不怕床上没空间了。手机、水杯、充电器统统装得下,实用性强而且色彩明亮。舒服温馨的宿舍生活就靠它了。', // 'gift_photo_intro' =>'http://7xl6gj.com1.z0.glb.clouddn.com/19.2.jpg', // 'scan_num' => '7859', // 'focus_num' => '7557', // 'taobao_url' =>'https://detail.tmall.com/item.htm?spm=a217e.7765654.1998660470.7.a4lzKx&id=521089667043' // ]); // Gift::create([ // 'topic_id'=>3, // 'title' => '新款阿登', // 'price' =>'999', // 'content' => 'live younger,you need it, trust me', // 'gift_photo_intro' =>'http://7xl6gj.com1.z0.glb.clouddn.com/19.2.jpg', // 'scan_num' => '7859', // 'focus_num' => '7557', // 'taobao_url' =>'https://detail.tmall.com/item.htm?spm=a217e.7765654.1998660470.7.a4lzKx&id=521089667043' // ]); // Gift::create([ // 'topic_id'=>4, // 'title' => '新款阿登', // 'price' =>'999', // 'content' => '床上总是很多零碎的杂物,不知道放在哪里。有了这个宿舍床头收纳架,就不怕床上没空间了。手机、水杯、充电器统统装得下,实用性强而且色彩明亮。舒服温馨的宿舍生活就靠它了。', // 'gift_photo_intro' =>'http://7xl6gj.com1.z0.glb.clouddn.com/19.2.jpg', // 'scan_num' => '7859', // 'focus_num' => '7557', // 'taobao_url' =>'https://detail.tmall.com/item.htm?spm=a217e.7765654.1998660470.7.a4lzKx&id=521089667043' // ]); // Gift::create([ // 'topic_id'=>4, // 'title' => '新款阿登', // 'price' =>'999', // 'content' => '床上总是很多零碎的杂物,不知道放在哪里。有了这个宿舍床头收纳架,就不怕床上没空间了。手机、水杯、充电器统统装得下,实用性强而且色彩明亮。舒服温馨的宿舍生活就靠它了。', // 'gift_photo_intro' =>'http://7xl6gj.com1.z0.glb.clouddn.com/19.2.jpg', // 'scan_num' => '7859', // 'focus_num' => '7557', // 'taobao_url' =>'https://detail.tmall.com/item.htm?spm=a217e.7765654.1998660470.7.a4lzKx&id=521089667043' // ]); // Gift::create([ // 'topic_id'=>4, // 'title' => '新款阿登', // 'price' =>'999', // 'content' => '床上总是很多零碎的杂物,不知道放在哪里。有了这个宿舍床头收纳架,就不怕床上没空间了。手机、水杯、充电器统统装得下,实用性强而且色彩明亮。舒服温馨的宿舍生活就靠它了。', // 'gift_photo_intro' =>'http://7xl6gj.com1.z0.glb.clouddn.com/19.2.jpg', // 'scan_num' => '7859', // 'focus_num' => '7557', // 'taobao_url' =>'https://detail.tmall.com/item.htm?spm=a217e.7765654.1998660470.7.a4lzKx&id=521089667043' // ]); // Gift::create([ // 'topic_id'=>4, // 'title' => '新款阿登', // 'price' =>'999', // 'content' => 'live younger,you need it, trust me', // 'gift_photo_intro' =>'http://7xl6gj.com1.z0.glb.clouddn.com/19.2.jpg', // 'scan_num' => '7859', // 'focus_num' => '7557', // 'taobao_url' =>'https://detail.tmall.com/item.htm?spm=a217e.7765654.1998660470.7.a4lzKx&id=521089667043' // ]); }
/** * 给女神送礼物 * * @param int $user_id * @param string $token * @param int $goddess_id * @param int $gift_id * */ public function actionGiftGiving() { // 参数检查 if (!isset($_REQUEST['user_id']) || !isset($_REQUEST['token']) || !isset($_REQUEST['goddess_id']) || !isset($_REQUEST['gift_id']) || !isset($_REQUEST['gift_num'])) { $this->_return('MSG_ERR_LESS_PARAM'); } $user_id = trim(Yii::app()->request->getParam('user_id')); $token = trim(Yii::app()->request->getParam('token')); $goddess_id = trim(Yii::app()->request->getParam('goddess_id')); $gift_id = trim(Yii::app()->request->getParam('gift_id')); $number = trim(Yii::app()->request->getParam('gift_num')); //判断女神id 和 礼品id 数据类型 if (!is_numeric($goddess_id) || !is_numeric($gift_id)) { $this->_return('MSG_ERR_FAIL_PARAM'); } if (!is_numeric($user_id)) { $this->_return('MSG_ERR_FAIL_PARAM'); } if ($number <= 0) { $this->_return('MSG_ERR_FAIL_PARAM'); } //用户不存在 返回错误 if ($user_id < 1) { $this->_return('MSG_ERR_NO_USER'); } //验证token if (Token::model()->verifyToken($user_id, $token, $GLOBALS['__APPID'])) { //送礼物 $res = Gift::model()->giveGift($user_id, $goddess_id, $gift_id, $number); switch ($res) { case -1: $this->_return('MSG_ERR_UNKOWN'); case -2: $this->_return('MSG_ERR_NO_GIFT'); case -3: $this->_return('MSG_ERR_NO_FOLLOW'); case -4: $this->_return('MSG_ERR_NO_GOLD'); default: break; } if (isset($res['log']['gold_after']) && isset($res['log']['gold'])) { //道具购买 Log::model()->_gold_log($user_id, $res['log']['gold'], $res['log']['gold_after'], 'GOLD_BUY_ITEM', date('Y-m-d H:i:s'), ''); } //送礼物日志 Log::model()->_gift_log($user_id, $goddess_id, $gift_id, $number, $res['log']['gold'], 'DS_TRIBUTE_GIFT', date('Y-m-d H:i:s'), ''); //成功 $this->_return('MSG_SUCCESS', $res['result']); } else { //token 错误 $this->_return('MSG_ERR_TOKEN'); } }
/** * 礼物发送页面 */ public function actionCreate() { //添加补充信息 $this->accessOptions = array(0 => '公开赠送', 1 => '私下赠送(不让其他人知道是你送的)', 2 => '匿名赠送(不让接收礼物的人知道是你送的)'); $model = new GiftUser(); //礼物的种类 $criteria = new CDbCriteria(); $criteria->condition = "status=:status"; $criteria->params = array(':status' => 1); //取得数据总数,分页显示 $total = Gift::model()->count($criteria); $pages = new CPagination($total); $pages->pageSize = self::PAGE_SIZE; $pages->applyLimit($criteria); //获取数据集 $gifts = Gift::model()->findAll($criteria); if (isset($_POST['GiftUser'])) { //传递数据格式为fuid = 1,2,4 /* $friend_str = $_POST['fri_ids']; $friend_ids = explode(',',$friend_str) ; */ $friend_ids = $_POST['friend_ids']; if (empty($friend_ids)) { //请选择好友 throw new CHttpException(404, '请选择好友.'); } $gift_ids = $_POST['gift_ids']; if (empty($gift_ids)) { //请选择礼物的种类 throw new CHttpException(404, '先选择礼物.'); } //先对某个用户发送礼物 foreach ($friend_ids as $toUserid) { //发送各种礼物 foreach ($gift_ids as $giftid) { $model = new GiftUser(); $model->attributes = $_POST['GiftUser']; $model->toUserid = $toUserid; $model->giftid = $giftid; $model->save(); } } //跳转到发送页 $this->redirect(array('send')); } $data = array('gifts' => $gifts, 'model' => $model, 'pages' => $pages); $this->render('create', $data); }
public function topic() { $topic_id = Input::get('topic_id'); $topic = Topic::find($topic_id); if (!isset($topic)) { if (Request::wantsJson()) { return Response::json(array('errCode' => 1, 'message' => 该专题不存在)); } else { return Response::view('errors.missing'); } } $gifts = Gift::where('topic_id', '=', $topic->id)->get(); if (isset($gifts)) { $number = 1; foreach ($gifts as $gift) { $url = GiftPoster::where('gift_id', '=', $gift->id)->first()->url; $gift->img = StaticController::imageWH($url); $gift->number = $number++; } } $gifts = $this->isGiftLike($gifts); $type = $this->isTopicLike($topic_id); if (Request::wantsJson()) { return Response::json(array('errCode' => 0, 'message' => '返回专题页数据', 'topic' => $topic, 'gifts' => $gifts, 'type' => $type)); } return View::make('index/goodsList')->with(array('topic' => $topic, 'gifts' => $gifts, 'type' => $type)); }
public function giftAjax() { // if(!Sentry::check()) // return Response::json(array('errCode'=>1, 'message'=>'请登录')); // $user = Sentry::getUser(); $user = User::find(1); $per_page = Input::get('per_page'); $page = Input::get('page'); $gift_focus = DB::table('gift_focus')->where('user_id', '=', $user->id)->orderBy('created_at', 'desc')->get(); //总页数 $total = ceil(count($gift_focus) / $per_page); // dd($total); //喜欢的礼品 $focus = StaticController::page($per_page, $page, $gift_focus); // dd(count($focus)); $gifts = array(); if ($focus) { foreach ($focus as $gift) { array_push($gifts, Gift::find($gift->gift_id)); } foreach ($gifts as $candy) { $url = GiftPoster::where('gift_id', '=', $candy->id)->first()->url; $candy->img = StaticController::imageWH($url); } } return Response::json(array('errCode' => 0, 'message' => '返回用户喜欢的礼品', 'gifts' => $gifts, 'total' => $total)); }
} } protected function send($activity, $record, $user) { global $_W; $uniacid = $_W['uniacid']; $api = $this->module['config']['api']; if (empty($api)) { return error(-2, '系统还未开放'); } require_once MB_ROOT . '/source/Activity.class.php'; require_once MB_ROOT . '/source/Gift.class.php'; $a = new Activity(); if (empty($record) || $record['status'] == 'complete') { return error(-1, '没有获得现金红包或已经领取过这个现金红包了'); } $g = new Gift(); $gift = $g->getOne($record['gift']); if (empty($gift) && $gift['type'] != 'cash') { return error(-1, '没有获得现金红包'); } $fee = floatval($record['fee']) * 100; $url = 'https://api.mch.weixin.qq.com/mmpaymkttransfers/sendredpack'; $pars = array(); $pars['nonce_str'] = random(32); $pars['mch_billno'] = $api['mchid'] . date('Ymd') . sprintf('%010d', $record['id']); $pars['mch_id'] = $api['mchid']; $pars['wxappid'] = $api['appid']; $pars['nick_name'] = $gift['tag']['provider']; $pars['send_name'] = $gift['tag']['provider']; $pars['re_openid'] = $user['openid']; $pars['total_amount'] = $fee; $pars['min_value'] = $pars['total_amount']; $pars['max_value'] = $pars['total_amount']; $pars['total_num'] = 1; $pars['wishing'] = $gift['tag']['wish']; $pars['client_ip'] = $api['ip']; $pars['act_name'] = $activity['title']; $pars['remark'] = $gift['tag']['remark']; $pars['logo_imgurl'] = tomedia($gift['tag']['image']); $pars['share_content'] = $gift['tag']['content']; $pars['share_imgurl'] = tomedia($gift['tag']['image']); $pars['share_url'] = $_W['siteroot'] . 'app/' . substr($this->createMobileUrl('entry', array('owner' => $user['uid'], 'actid' => $activity['actid'])), 2); ksort($pars, SORT_STRING); $string1 = ''; foreach ($pars as $k => $v) { $string1 .= "{$k}={$v}&"; } $string1 .= "key={$api['password']}"; $pars['sign'] = strtoupper(md5($string1)); $xml = array2xml($pars); $extras = array(); $extras['CURLOPT_CAINFO'] = MB_ROOT . '/cert/rootca.pem.' . $uniacid; $extras['CURLOPT_SSLCERT'] = MB_ROOT . '/cert/apiclient_cert.pem.' . $uniacid; $extras['CURLOPT_SSLKEY'] = MB_ROOT . '/cert/apiclient_key.pem.' . $uniacid; load()->func('communication'); $procResult = null; $resp = ihttp_request($url, $xml, $extras); if (is_error($resp)) { $procResult = $resp; } else { $xml = '<?xml version="1.0" encoding="utf-8"?>' . $resp['content']; $dom = new \DOMDocument(); if ($dom->loadXML($xml)) { $xpath = new \DOMXPath($dom); $code = $xpath->evaluate('string(//xml/return_code)'); $ret = $xpath->evaluate('string(//xml/result_code)'); if (strtolower($code) == 'success' && strtolower($ret) == 'success') { $procResult = true; } else { $error = $xpath->evaluate('string(//xml/err_code_des)'); $procResult = error(-2, $error); } } else { $procResult = error(-1, 'error response'); } } if (is_error($procResult)) { $filters = array(); $filters['uniacid'] = $uniacid; $filters['id'] = $record['id']; $rec = array(); $rec['log'] = $procResult['message']; pdo_update('mbsk_records', $rec, $filters); return $procResult; } else { $a->confirm($record['id'], sprintf('%.2f', $fee / 100)); return true;