public function favorites()
 {
     if ($uid = session('uid')) {
         $userCollection = M('userCollection');
         $condition = array('uid' => $uid);
         $count = $userCollection->where($condition)->count();
         // 查询满足要求的总记录数
         $page = getpage($count, 10);
         $data = $userCollection->where($condition)->limit($page->firstRow . ',' . $page->listRows)->select();
         $package = M('package');
         $product = M('product');
         $iconManage = M('IconManager');
         $option = M('ProductCategoryAttrOption');
         $model = M();
         foreach ($data as $key => $value) {
             $pdata = $package->where(array('id' => $value['package_id']))->find();
             $iconAttrData = $model->table('product_attr_relational as a')->join('product_category_attr as p on a.attr_id = p.id')->where("a.product_id='%s' and p.is_detail = 1", $pdata['product_id'])->select();
             $proData = $product->where(array('id' => $pdata['product_id']))->find();
             foreach ($iconAttrData as $k => $v) {
                 if ($v['type'] == 'input' || $v['type'] == 'textarea') {
                     $icon = $iconManage->where(array('id' => $v['icon_id']))->find();
                 } else {
                     $ic = $option->where(array('id' => $v['value']))->find();
                     $icon = $iconManage->where(array('id' => $ic['icon_id']))->find();
                     $icon['option'] = $ic['option'];
                 }
                 $iconAttrData[$k]['icon'] = $icon;
             }
             $data[$key]['pro'] = $iconAttrData;
             $data[$key]['price'] = number_format(usdtosny($pdata['price']));
             $data[$key]['pic'] = $proData['thumbnail'];
             $data[$key]['name'] = $pdata['name'];
             $data[$key]['name_en'] = $pdata['name_en'];
             $data[$key]['pid'] = $proData['id'];
             $data[$key]['areaid'] = $pdata['area_id'];
         }
         $this->assign('page', $page->show());
         $this->assign('data', $data);
         $this->display();
     } else {
         $this->error('尚未登录');
     }
 }
 public function getGoodDatePrice()
 {
     $arr = I();
     $pid = $arr['pid'];
     $date = $arr['date'];
     if ($date < date('Y-m-d')) {
         $this->resultMsg('error', '选择日期不能小于今天', '0');
     }
     $package = M('package');
     $model = M();
     $count = $model->query("SELECT count(*) as count from package_no_provide_date where package_id = '%s' and '%s' BETWEEN startdate and enddate", $pid, $date);
     if (!$count[0]['count']) {
         $price = $model->query("SELECT price from package_date_price where package_id = '%s' and '%s' BETWEEN startdate and enddate", $pid, $date);
         if (count($price) > 1) {
             $this->resultMsg('error', '请联系管理员', '0');
         } else {
             if (count($price) == 1) {
                 $this->resultMsg('success', '当前价格', usdtosny($price[0]['price']));
             } else {
                 $pack = $package->where(array('id' => $pid))->find();
                 $this->resultMsg('success', '当前价格', usdtosny($pack['price']));
             }
         }
     } else {
         $this->resultMsg('success', '当日不可提供价格', '0');
     }
 }