public function actionGetCurrentQuestion()
 {
     $customer_id = $this->getParam('customer_id');
     $flag = $this->getParam('flag');
     $current_id = array();
     if ($flag == 'today') {
         $current_id = 2;
     } else {
         $current_id = 1;
     }
     $question = Converter::convertModelToArray(HiQuestion::model()->findByPk($current_id));
     $answers = Converter::convertModelToArray(HiQuestionAnswer::model()->with('customer')->findAllByAttributes(array('customer_id' => $customer_id, 'question_id' => $current_id)));
     if ($flag == 'today') {
         $question['has_answered'] = 0;
         $year = date('Y');
         foreach ($answers as $k => $v) {
             if (strpos('date' . $v['insert_date'], $year)) {
                 $question['has_answered'] = 1;
             }
         }
     } else {
         $question['has_answered'] = 1;
     }
     $question['answers'] = $answers;
     EchoUtility::echoMsgTF($question, '获取问题', $question);
 }
 public function actionGetArticleById()
 {
     $article_id = $this->getParam('article_id');
     $customer_id = $this->getParam('customer_id');
     $article = Converter::convertModelToArray(HiPushArticle::model()->with('sections')->findByPk($article_id));
     $c = new CDbCriteria();
     $c->addCondition("article_ids LIKE '%\"" . (int) $article_id . "\"%' and customer_id = " . $customer_id);
     $article['is_favourite'] = HiPushArticleFavourite::model()->count($c);
     EchoUtility::echoMsgTF(1, '获取文章', $article);
 }
 public function actionGetHomeData()
 {
     $result = array();
     $story_c = new CDbCriteria();
     $story_c->addCondition('follow_count != 0');
     $story_c->order = 'follow_count DESC';
     $stories = Converter::convertModelToArray(HiStory::model()->with('customer')->findAll($story_c));
     $result['story'] = $stories[0];
     $article = Converter::convertModelToArray(HiPushArticle::model()->findByPk(Yii::app()->time_service->getIndex()));
     $result['article'] = $article;
     $question = Converter::convertModelToArray(HiQuestion::model()->findByPk(2));
     $question['cover_image'] = 'http://77fkpo.com5.z0.glb.clouddn.com/603b2cffffeb7c5c950a4c9517e8ee9e.jpg';
     $result['question'] = $question;
     $book = Converter::convertModelToArray(HiBook::model()->with('customer')->findByPk(1));
     $result['book'] = $book;
     EchoUtility::echoMsgTF(true, '获取首页数据', $result);
 }
 public function actionAddComment()
 {
     $section_id = $this->getParam('section_id');
     $story_id = $this->getParam('story_id');
     $customer_id = $this->getParam('customer_id');
     $content = $this->getParam('content');
     $orig_customer_id = $this->getParam('orig_customer_id');
     $newComment = new HiStoryComment();
     $newComment['customer_id'] = $customer_id;
     if (isset($section_id)) {
         $newComment['section_id'] = $section_id;
     }
     if (isset($story_id)) {
         $newComment['story_id'] = $story_id;
     }
     $newComment['orig_customer_id'] = $orig_customer_id;
     $newComment['content'] = $content;
     $newComment['insert_time'] = date('Y-m-d H:i:s', time());
     $newComment->insert();
     $comment = Converter::convertModelToArray(HiStoryComment::model()->with('customer')->findByPk($newComment->getPrimaryKey()));
     EchoUtility::echoMsgTF(1, '插入评论', $comment);
 }
 public function actionGetBookDetail()
 {
     $book_id = $this->getParam('book_id');
     $book = Converter::convertModelToArray(HiBook::model()->with('customer')->findByPk($book_id));
     EchoUtility::echoMsgTF(1, '获取书籍', $book);
 }
Ejemplo n.º 6
0
 public function actionOverdueProducts()
 {
     //取所有上架商品
     $c = new CDbCriteria();
     $c->select = 'product_id';
     $c->addCondition('status = 3');
     $products = HtProduct::model()->findAll($c);
     $products = Converter::convertModelToArray($products);
     $need_sendmail_products = array();
     //取价格计划即将到期或已经过期的商品
     if (is_array($products) && count($products) > 0) {
         foreach ($products as $product) {
             $plans = HtProductPricePlan::model()->findAll('product_id=' . $product['product_id']);
             $plans = Converter::convertModelToArray($plans);
             if (is_array($plans) && count($plans) > 0) {
                 if ($plans[0]['valid_region'] == 0) {
                     //整个区间
                     $date_rule = HtProductDateRule::model()->findByPk($product['product_id']);
                     if ($date_rule) {
                         $to_date = strtotime($date_rule['to_date']);
                         $today = strtotime(date('Y-m-d', time()));
                         if (($to_date - $today) / 86400 <= 15) {
                             $need_sendmail_products[$product['product_id']] = $date_rule['to_date'];
                         }
                     }
                 } else {
                     $to_dates = array();
                     foreach ($plans as $plan) {
                         $to_dates[] = $plan['to_date'];
                     }
                     array_multisort($to_dates, SORT_DESC, $plans);
                     $to_date = strtotime($plans[0]['to_date']);
                     $today = strtotime(date('Y-m-d', time()));
                     if (($to_date - $today) / 86400 <= 15) {
                         $need_sendmail_products[$product['product_id']] = $plans[0]['to_date'];
                     }
                 }
             }
         }
     }
     //发送邮件给供应商负责人
     if (count($need_sendmail_products) > 0) {
         $mail_list = array();
         foreach ($need_sendmail_products as $n => $m) {
             $product_manager = HtProductManager::model()->find('product_id = ' . $n);
             if ($product_manager['manager_name']) {
                 $mail_list[$product_manager['manager_name']][] = "产品ID:{$n},售卖截止时间为{$m},点击<a href='http://backend.hitour.cc/admin/product/edit?product_id=" . $n . "#/editProductPrice'>编辑</a>产品价格体系";
             }
         }
         if (count($mail_list) > 0) {
             foreach ($mail_list as $k => $v) {
                 Mail::sendToOP($k, '售卖即将过期或已过期商品', implode('<br>', $v), 1, '');
             }
         }
     }
 }
 public function actionGetMyComment()
 {
     $orig_customer_id = $this->getParam("customer_id");
     $c = new CDbCriteria();
     $c->addCondition('sc.orig_customer_id = ' . $orig_customer_id);
     $c->group = 'sc.story_id';
     $comments = Converter::convertModelToArray(HiStoryComment::model()->with('story', 'customer')->findAll($c));
     EchoUtility::echoMsgTF(true, '获取评论', $comments);
 }
Ejemplo n.º 8
0
 public function actionGetOrderOut($order_id, $method = '')
 {
     $sql = 'SELECT * FROM ht_order WHERE order_id="' . $order_id . '"';
     $order = Yii::app()->db->createCommand($sql)->queryRow();
     if (empty($order)) {
         echo "Not found order[" . $order_id . "]\n\n";
     } else {
         $order_product = HtOrderProduct::model()->with('product.description')->findByAttributes(array('order_id' => $order_id));
         $order_product = Converter::convertModelToArray($order_product);
         $order['product_id'] = $order_product['product_id'];
         $order['supplier_id'] = $order_product['product']['supplier_id'];
         $out_order_id = PayUtility::genOutTradeNo($order, $order['payment_method']);
         echo 'Order[' . $order_id . '] out_order_id is [' . $out_order_id . ']' . "\n\n";
     }
 }
 public function actionGetStoryList()
 {
     $start = $this->getParam('start');
     $num = $this->getParam('num');
     $c = new CDbCriteria();
     $c->offset = $start;
     $c->limit = $num;
     $stories = Converter::convertModelToArray(HiStory::model()->with('customer')->findAll($c));
     $result = array();
     if (count($stories) < $num) {
         $result['has_more'] = false;
     } else {
         $result['has_more'] = true;
     }
     $result['story_list'] = $stories;
     $result['success'] = true;
     EchoUtility::echoMsgTF(1, '获取段子列表', $result);
 }