Example #1
0
 public function index()
 {
     $type = strim($GLOBALS['request']['type']);
     $id = intval($GLOBALS['request']['id']);
     $city_name = strim($GLOBALS['request']['city_name']);
     //城市名称
     $deal_id = 0;
     $youhui_id = 0;
     $location_id = 0;
     $event_id = 0;
     $tech_id = 0;
     if ($type == "deal") {
         $deal_id = $id;
         require_once APP_ROOT_PATH . "system/model/deal.php";
         $deal_info = get_deal($deal_id);
         $relate_data_name = $deal_info['name'];
     } elseif ($type == "supplier") {
         $location_id = $id;
         require_once APP_ROOT_PATH . "system/model/supplier.php";
         $location_info = get_location($location_id);
         $relate_data_name = $location_info['name'];
     } elseif ($type == "youhui") {
         $youhui_id = $id;
         require_once APP_ROOT_PATH . "system/model/youhui.php";
         $youhui_info = get_youhui($youhui_id);
         $relate_data_name = $youhui_info['name'];
     } elseif ($type == "event") {
         $event_id = $id;
         require_once APP_ROOT_PATH . "system/model/event.php";
         $event_info = get_event($event_id);
         $relate_data_name = $event_info['name'];
     } elseif ($type == "tech") {
         $tech_id = $id;
         require_once APP_ROOT_PATH . "system/model/tech.php";
         $tech_info = get_tech($tech_id);
         $relate_data_name = $tech_info['name'];
     }
     $page = intval($GLOBALS['request']['page']);
     /*分页*/
     $city_name = strim($GLOBALS['request']['city_name']);
     //城市分类ID
     //检查用户,用户密码
     $user = $GLOBALS['user_info'];
     $user_id = intval($user['id']);
     $root = array();
     $root['return'] = 1;
     $page = $page == 0 ? 1 : $page;
     $page_size = PAGE_SIZE;
     $limit = ($page - 1) * $page_size . "," . $page_size;
     // 		$message_re=m_get_message_list($limit," m.rel_table = 'deal' and m.rel_id=".$tuan_id." and m.is_buy = 1",0);/*购买评论*/
     require_once APP_ROOT_PATH . "system/model/review.php";
     require_once APP_ROOT_PATH . "system/model/user.php";
     $message_re = get_dp_list($limit, $param = array("deal_id" => $deal_id, "youhui_id" => $youhui_id, "event_id" => $event_id, "location_id" => $location_id, "tech_id" => $tech_id, "tag" => ""), "", "");
     foreach ($message_re['list'] as $k => $v) {
         $message_re['list'][$k]['width'] = $v['point'] / 5 * 100;
         $message_re['list'][$k]['create_time'] = to_date($v['create_time']);
         $uinfo = load_user($v['user_id']);
         $message_re['list'][$k]['user_name'] = $uinfo['user_name'];
         foreach ($message_re['list'][$k]['images'] as $kk => $vv) {
             $message_re['list'][$k]['images'][$kk] = get_abs_img_root(get_spec_image($vv, 60, 60, 1));
             $message_re['list'][$k]['oimages'][$kk] = get_abs_img_root($vv);
         }
     }
     $root['message_list'] = $message_re['list'];
     if (count($message_re['list']) > 0) {
         $sql = "select count(*) from " . DB_PREFIX . "supplier_location_dp where  " . $message_re['condition'];
         $message_re['count'] = $GLOBALS['db']->getOne($sql);
     }
     $root['message_count'] = $message_re['count'];
     //$deal = get_deal($tuan_id);
     $dp_info = load_dp_info(array("deal_id" => $deal_id, "youhui_id" => $youhui_id, "event_id" => $event_id, "location_id" => $location_id, "tech_id" => $tech_id));
     $root['name'] = $relate_data_name;
     //星级点评数
     $root['star_1'] = $dp_info['dp_count_1'];
     $root['star_2'] = $dp_info['dp_count_2'];
     $root['star_3'] = $dp_info['dp_count_3'];
     $root['star_4'] = $dp_info['dp_count_4'];
     $root['star_5'] = $dp_info['dp_count_5'];
     $root['star_dp_width_1'] = $dp_info['avg_point_1_percent'];
     $root['star_dp_width_2'] = $dp_info['avg_point_2_percent'];
     $root['star_dp_width_3'] = $dp_info['avg_point_3_percent'];
     $root['star_dp_width_4'] = $dp_info['avg_point_4_percent'];
     $root['star_dp_width_5'] = $dp_info['avg_point_5_percent'];
     $buy_dp_sum = 0.0;
     // 		$buy_dp_group = $GLOBALS['db']->getAll("select point,count(*) as num from ".DB_PREFIX."message where rel_id = ".$tuan_id." and rel_table = 'deal' and pid = 0 and is_buy = 1 group by point");
     // 		foreach($buy_dp_group as $dp_k=>$dp_v)
     // 		{
     // 			$star = intval($dp_v['point']);
     // 			if ($star >= 1 && $star <= 5){
     // 				$root['star_'.$star] = $dp_v['num'];
     // 				$buy_dp_sum += $star * $dp_v['num'];
     // 				$root['star_dp_width_'.$star] = (round($dp_v['num']/ $message_re['count'],1)) * 100;
     // 			}
     // 		}
     //点评平均分
     $root['buy_dp_sum'] = $dp_info['dp_count'];
     $root['buy_dp_avg'] = $dp_info['avg_point'];
     $root['buy_dp_width'] = $dp_info['avg_point'] / 5 * 100;
     $page_total = ceil($message_re['count'] / $page_size);
     $root['page'] = array("page" => $page, "page_total" => $page_total, "page_size" => $page_size);
     $root['allow_dp'] = 0;
     //0:不允许点评;1:允许点评
     //判断用户是否购买了这个商品
     if ($user_id > 0) {
         // 			$sql = "select count(*) from ".DB_PREFIX."deal_order_item as doi left join ".DB_PREFIX."deal_order as do on doi.order_id = do.id where doi.deal_id = ".intval($tuan_id)." and do.user_id = ".intval($user_id)." and do.pay_status = 2";
         // 			//$root['sql'] = $sql;
         // 			if($GLOBALS['db']->getOne($sql)>0)
         // 			{
         // 				$root['allow_dp'] = 1;
         // 			}
         $dp_status = check_dp_status($user_id, array("deal_id" => $deal_id, "youhui_id" => $youhui_id, "event_id" => $event_id, "location_id" => $location_id));
         if ($dp_status['status']) {
             $root['allow_dp'] = 1;
         }
         if ($type == "tech" && $user_id == $id) {
             //技师本身不能给自己点评
             $root['allow_dp'] = 0;
         }
     }
     $root['type'] = $type;
     $root['id'] = $id;
     $root['page_title'] = "点评列表";
     $root['city_name'] = $city_name;
     output($root);
 }
Example #2
0
 public function save()
 {
     global_run();
     if (empty($GLOBALS['user_info'])) {
         $data['status'] = -1;
         $data['info'] = "";
         ajax_return($data);
     }
     require_once APP_ROOT_PATH . "system/model/review.php";
     $deal_id = intval($_REQUEST['deal_id']);
     $youhui_id = intval($_REQUEST['youhui_id']);
     $event_id = intval($_REQUEST['event_id']);
     $location_id = intval($_REQUEST['location_id']);
     $order_item_id = intval($_REQUEST['order_item_id']);
     $youhui_log_id = intval($_REQUEST['youhui_log_id']);
     $event_submit_id = intval($_REQUEST['event_submit_id']);
     $param = array("deal_id" => $deal_id, "youhui_id" => $youhui_id, "event_id" => $event_id, "location_id" => $location_id, "order_item_id" => $order_item_id, "youhui_log_id" => $youhui_log_id, "event_submit_id" => $event_submit_id);
     $checker = check_dp_status($GLOBALS['user_info']['id'], $param);
     if (!$checker['status']) {
         showErr($checker['info'], 1);
     }
     $content = strim(valid_str($_REQUEST['content']));
     //点评内容
     $dp_point = intval($_REQUEST['dp_point']);
     //总评分
     if ($dp_point <= 0) {
         $data['status'] = 0;
         $data['info'] = "请为总评打分";
         ajax_return($data);
     }
     $dp_image = array();
     //点评图片
     foreach ($_REQUEST['dp_image'] as $k => $v) {
         if (strim($v) != "") {
             $dp_image[] = strim($v);
         }
     }
     $tag_group = array();
     //标签分组
     foreach ($_REQUEST['dp_tags'] as $k => $tags_arr) {
         foreach ($tags_arr as $v) {
             if (strim($v) != "") {
                 $v_array = preg_split("/[ ,]/", $v);
                 foreach ($v_array as $kk => $vv) {
                     if (strim($vv) != "") {
                         $tag_group[$k][] = strim(valid_str($vv));
                     }
                 }
             }
         }
     }
     $point_group = array();
     //评分分组
     foreach ($_REQUEST['dp_point_group'] as $k => $v) {
         if (intval($v) > 0) {
             $point_group[$k] = intval($v);
         } else {
             $name = $GLOBALS['db']->getOne("select name from " . DB_PREFIX . "point_group where id = " . intval($k));
             $info = "请打分";
             if ($name) {
                 $info = "请为" . $name . "打分";
             }
             $data['status'] = 0;
             $data['info'] = $info;
             ajax_return($data);
         }
     }
     $result = save_review($GLOBALS['user_info']['id'], $param, $content, $dp_point, $dp_image, $tag_group, $point_group);
     if ($result['status']) {
         //分享
         $attach_list = array();
         if ($result['deal_id'] > 0) {
             require_once APP_ROOT_PATH . "system/model/deal.php";
             $deal_info = get_deal($result['deal_id']);
             if ($deal_info['uname'] != "") {
                 $url_key = $deal_info['uname'];
             } else {
                 $url_key = $deal_info['id'];
             }
             $type = "dealcomment";
             $url_route = array('rel_app_index' => 'index', 'rel_route' => 'deal#' . $url_key, 'rel_param' => '');
             //同步图片
             if ($deal_info['icon']) {
                 require_once APP_ROOT_PATH . "system/utils/es_imagecls.php";
                 $imagecls = new es_imagecls();
                 $info = $imagecls->getImageInfo(APP_ROOT_PATH . $deal_info['icon']);
                 $image_data['width'] = intval($info[0]);
                 $image_data['height'] = intval($info[1]);
                 $image_data['name'] = $deal_info['sub_name'];
                 $image_data['filesize'] = filesize(APP_ROOT_PATH . $deal_info['icon']);
                 $image_data['create_time'] = NOW_TIME;
                 $image_data['user_id'] = intval($GLOBALS['user_info']['id']);
                 $image_data['user_name'] = strim($GLOBALS['user_info']['user_name']);
                 $image_data['path'] = $deal_info['icon'];
                 $image_data['o_path'] = $deal_info['icon'];
                 $GLOBALS['db']->autoExecute(DB_PREFIX . "topic_image", $image_data);
                 $img_id = intval($GLOBALS['db']->insert_id());
                 $attach_list[] = array("type" => "image", "id" => intval($img_id));
             }
         } elseif ($result['youhui_id'] > 0) {
             require_once APP_ROOT_PATH . "system/model/youhui.php";
             $youhui_info = get_youhui($result['youhui_id']);
             $type = "youhuicomment";
             $url_route = array('rel_app_index' => 'index', 'rel_route' => 'youhui#' . $result['youhui_id'], 'rel_param' => '');
             //同步图片
             if ($youhui_info['icon']) {
                 require_once APP_ROOT_PATH . "system/utils/es_imagecls.php";
                 $imagecls = new es_imagecls();
                 $info = $imagecls->getImageInfo(APP_ROOT_PATH . $youhui_info['icon']);
                 $image_data['width'] = intval($info[0]);
                 $image_data['height'] = intval($info[1]);
                 $image_data['name'] = $youhui_info['name'];
                 $image_data['filesize'] = filesize(APP_ROOT_PATH . $youhui_info['icon']);
                 $image_data['create_time'] = NOW_TIME;
                 $image_data['user_id'] = intval($GLOBALS['user_info']['id']);
                 $image_data['user_name'] = strim($GLOBALS['user_info']['user_name']);
                 $image_data['path'] = $youhui_info['icon'];
                 $image_data['o_path'] = $youhui_info['icon'];
                 $GLOBALS['db']->autoExecute(DB_PREFIX . "topic_image", $image_data);
                 $img_id = intval($GLOBALS['db']->insert_id());
                 $attach_list[] = array("type" => "image", "id" => intval($img_id));
             }
         } elseif ($result['event_id'] > 0) {
             require_once APP_ROOT_PATH . "system/model/event.php";
             $event_info = get_event($result['youhui_id']);
             $type = "eventcomment";
             $url_route = array('rel_app_index' => 'index', 'rel_route' => 'event#' . $result['event_id'], 'rel_param' => '');
             //同步图片
             if ($event_info['icon']) {
                 require_once APP_ROOT_PATH . "system/utils/es_imagecls.php";
                 $imagecls = new es_imagecls();
                 $info = $imagecls->getImageInfo(APP_ROOT_PATH . $event_info['icon']);
                 $image_data['width'] = intval($info[0]);
                 $image_data['height'] = intval($info[1]);
                 $image_data['name'] = $event_info['name'];
                 $image_data['filesize'] = filesize(APP_ROOT_PATH . $event_info['icon']);
                 $image_data['create_time'] = NOW_TIME;
                 $image_data['user_id'] = intval($GLOBALS['user_info']['id']);
                 $image_data['user_name'] = strim($GLOBALS['user_info']['user_name']);
                 $image_data['path'] = $event_info['icon'];
                 $image_data['o_path'] = $event_info['icon'];
                 $GLOBALS['db']->autoExecute(DB_PREFIX . "topic_image", $image_data);
                 $img_id = intval($GLOBALS['db']->insert_id());
                 $attach_list[] = array("type" => "image", "id" => intval($img_id));
             }
         } else {
             require_once APP_ROOT_PATH . "system/model/supplier.php";
             $location_info = get_location($result['location_id']);
             $type = "slocationcomment";
             $url_route = array('rel_app_index' => 'index', 'rel_route' => 'store#' . $result['location_id'], 'rel_param' => '');
             //同步图片
             if ($location_info['preview']) {
                 require_once APP_ROOT_PATH . "system/utils/es_imagecls.php";
                 $imagecls = new es_imagecls();
                 $info = $imagecls->getImageInfo(APP_ROOT_PATH . $location_info['preview']);
                 $image_data['width'] = intval($info[0]);
                 $image_data['height'] = intval($info[1]);
                 $image_data['name'] = $location_info['name'];
                 $image_data['filesize'] = filesize(APP_ROOT_PATH . $location_info['preview']);
                 $image_data['create_time'] = NOW_TIME;
                 $image_data['user_id'] = intval($GLOBALS['user_info']['id']);
                 $image_data['user_name'] = strim($GLOBALS['user_info']['user_name']);
                 $image_data['path'] = $location_info['preview'];
                 $image_data['o_path'] = $location_info['preview'];
                 $GLOBALS['db']->autoExecute(DB_PREFIX . "topic_image", $image_data);
                 $img_id = intval($GLOBALS['db']->insert_id());
                 $attach_list[] = array("type" => "image", "id" => intval($img_id));
             }
         }
         foreach ($_REQUEST['topic_image_id'] as $att_id) {
             if (intval($att_id) > 0) {
                 $attach_list[] = array("type" => "image", "id" => intval($att_id));
             }
         }
         require_once APP_ROOT_PATH . "system/model/topic.php";
         $tid = insert_topic($content, "", $type, $group = "", $relay_id = 0, $fav_id = 0, $group_data = "", $attach_list, $url_route);
         if ($tid) {
             $GLOBALS['db']->query("update " . DB_PREFIX . "topic set source_name = '网站' where id = " . intval($tid));
         }
         $result['jump'] = url($url_route['rel_app_index'], $url_route['rel_route'], $url_route['rel_param']);
         ajax_return($result);
     } else {
         ajax_return($result);
     }
 }
Example #3
0
/**
 * 提交保存点评
 * @param unknown_type $user_id 提交点评的会员
 * @param unknown_type $param 参数 详细规则见 check_dp_status函数说明
 * @param unknown_type $content 点评文字内容
 * @param unknown_type $dp_point 总评分
 * @param unknown_type $dp_image 点评的图片数组 array("./public/...","./public/.....");
 * @param unknown_type $tag_group 点评标签(二维数组),格式如下
 * array(
 * 		"group_id" = array("tag","tag")
 * ); 其中group_id为分组的ID,第二维为每个分组中的tag
 * @param unknown_type $point_group 点评评分分组数据,格式如下
 * array(
 * 		"group_id" 	=>	"point"
 * ); 其中group_id为分组的ID,point为对应分组的评分
 * 
 * 返回 array("status"=>bool, "info"=>"消息","location_id"=>"门店的ID","deal_id"=>"","youhui_id"=>"","event_id"=>"");
 */
function save_review($user_id, $param = array("deal_id" => 0, "youhui_id" => 0, "event_id" => 0, "location_id" => 0, "order_item_id" => 0, "youhui_log_id" => 0, "event_submit_id" => 0), $content, $dp_point, $dp_image = array(), $tag_group = array(), $point_group = array())
{
    //获取参数
    $order_item_id = intval($param['order_item_id']);
    //订单商品ID
    $youhui_log_id = intval($param['youhui_log_id']);
    //优惠券领取日志ID
    $event_submit_id = intval($param['event_submit_id']);
    //活动报名日志ID
    if ($order_item_id > 0) {
        $deal_id = intval($GLOBALS['db']->getOne("select deal_id from " . DB_PREFIX . "deal_order_item where id = " . $order_item_id));
    } else {
        $deal_id = intval($param['deal_id']);
    }
    if ($youhui_log_id > 0) {
        $youhui_id = intval($GLOBALS['db']->getOne("select youhui_id from " . DB_PREFIX . "youhui_log where id = " . $youhui_log_id));
    } else {
        $youhui_id = intval($param['youhui_id']);
    }
    if ($event_submit_id > 0) {
        $event_id = intval($GLOBALS['db']->getOne("select event_id from " . DB_PREFIX . "event_submit where id = " . $event_submit_id));
    } else {
        $event_id = intval($param['event_id']);
    }
    $location_id = intval($param['location_id']);
    //部份初始化的变量
    $is_buy = 0;
    //默认的点评为非购物点评
    $avg_price = 0;
    //均价为0
    if ($deal_id > 0) {
        require_once APP_ROOT_PATH . "system/model/deal.php";
        $deal_info = get_deal($deal_id);
        if ($deal_info) {
            //验证是否可以点评
            $checker = check_dp_status($GLOBALS['user_info']['id'], array("deal_id" => $deal_id, "order_item_id" => $order_item_id));
            if (!$checker['status']) {
                return array("status" => false, "info" => $checker['info']);
            } else {
                $supplier_location_id = $checker['supplier_location_id'];
            }
            $is_buy = 1;
            $avg_price = $checker['avg_price'];
        } else {
            return array("status" => false, "info" => "你要点评的商品不存在");
        }
    } elseif ($youhui_id > 0) {
        require_once APP_ROOT_PATH . "system/model/youhui.php";
        $youhui_info = get_youhui($youhui_id);
        if ($youhui_info) {
            //验证是否可以点评
            $checker = check_dp_status($GLOBALS['user_info']['id'], array("youhui_id" => $youhui_id, "youhui_log_id" => $youhui_log_id));
            if (!$checker['status']) {
                return array("status" => false, "info" => $checker['info']);
            } else {
                $supplier_location_id = $checker['supplier_location_id'];
            }
        } else {
            return array("status" => false, "info" => "你要点评的优惠券不存在");
        }
    } elseif ($event_id > 0) {
        require_once APP_ROOT_PATH . "system/model/event.php";
        $event_info = get_event($event_id);
        if ($event_info) {
            //验证是否可以点评
            $checker = check_dp_status($GLOBALS['user_info']['id'], array("event_id" => $event_id, "event_submit_id" => $event_submit_id));
            if (!$checker['status']) {
                return array("status" => false, "info" => $checker['info']);
            } else {
                $supplier_location_id = $checker['supplier_location_id'];
            }
        } else {
            return array("status" => false, "info" => "你要点评的活动不存在");
        }
    } elseif ($location_id > 0) {
        require_once APP_ROOT_PATH . "system/model/supplier.php";
        $location_info = get_location($location_id);
        if ($location_info) {
            //验证是否可以点评
            $checker = check_dp_status($GLOBALS['user_info']['id'], array("location_id" => $location_id));
            if (!$checker['status']) {
                return array("status" => false, "info" => $checker['info']);
            } else {
                $supplier_location_id = $checker['supplier_location_id'];
            }
        } else {
            return array("status" => false, "info" => "你要点评的商家不存在");
        }
    }
    if ($deal_id == 0 && $youhui_id == 0 && $event_id == 0 && $location_id == 0) {
        return array("status" => false, "info" => "非法的数据");
    }
    //点评入库
    $supplier_info = $GLOBALS['db']->getRow("select name,id,new_dp_count_time,supplier_id from " . DB_PREFIX . "supplier_location where id = " . intval($supplier_location_id));
    $supplier_id = $supplier_info['supplier_id'];
    $dp_data = array();
    if ($content != "") {
        $dp_data['is_content'] = 1;
        $dp_data['content'] = $content;
    }
    $dp_data['create_time'] = NOW_TIME;
    $dp_data['point'] = $dp_point;
    $dp_data['user_id'] = $user_id;
    $dp_data['supplier_location_id'] = $supplier_location_id;
    $dp_data['youhui_id'] = $youhui_id;
    $dp_data['event_id'] = $event_id;
    $dp_data['deal_id'] = $deal_id;
    $dp_data['images_cache'] = serialize($dp_image);
    $dp_data['supplier_id'] = $supplier_id;
    $dp_data['status'] = 1;
    if (count($dp_image) > 0) {
        $dp_data['is_img'] = 1;
    }
    $dp_data['avg_price'] = floatval($avg_price);
    $GLOBALS['db']->autoExecute(DB_PREFIX . "supplier_location_dp", $dp_data, "INSERT");
    $dp_id = $GLOBALS['db']->insert_id();
    if ($dp_id > 0) {
        if ($checker['order_item_id']) {
            $GLOBALS['db']->query("update " . DB_PREFIX . "deal_order_item set dp_id = " . $dp_id . " where id = '" . $checker['order_item_id'] . "'");
            $order_id = intval($GLOBALS['db']->getOne("select order_id from " . DB_PREFIX . "deal_order_item where id = " . $checker['order_item_id']));
            update_order_cache($order_id);
            require_once APP_ROOT_PATH . "system/model/deal_order.php";
            distribute_order($order_id);
        }
        if ($checker['youhui_log_id']) {
            $GLOBALS['db']->query("update " . DB_PREFIX . "youhui_log set dp_id = " . $dp_id . " where id = '" . $checker['youhui_log_id'] . "'");
        }
        if ($checker['event_submit_id']) {
            $GLOBALS['db']->query("update " . DB_PREFIX . "event_submit set dp_id = " . $dp_id . " where id = '" . $checker['event_submit_id'] . "'");
        }
        increase_user_active($user_id, "发表了一则点评");
        $GLOBALS['db']->query("update " . DB_PREFIX . "user set dp_count = dp_count + 1 where id = " . $user_id);
        //创建点评图库
        if (count($dp_image) > 0) {
            foreach ($dp_image as $pkey => $photo) {
                //点评图片不入商户图片库
                // 				$c_data = array();
                // 				$c_data['image'] = $photo;
                // 				$c_data['sort'] = 10;
                // 				$c_data['create_time'] = NOW_TIME;
                // 				$c_data['user_id'] = $user_id;
                // 				$c_data['supplier_location_id'] = $supplier_location_id;
                // 				$c_data['dp_id'] = $dp_id;
                // 				$c_data['status'] = 0;
                // 				$GLOBALS['db']->autoExecute(DB_PREFIX."supplier_location_images", $c_data,"INSERT");
                $c_data = array();
                $c_data['image'] = $photo;
                $c_data['dp_id'] = $dp_id;
                $c_data['create_time'] = NOW_TIME;
                $c_data['location_id'] = $supplier_location_id;
                $c_data['supplier_id'] = $supplier_id;
                $GLOBALS['db']->autoExecute(DB_PREFIX . "supplier_location_dp_images", $c_data, "INSERT");
            }
        }
        //创建点评评分
        foreach ($point_group as $group_id => $point) {
            $point_data = array();
            $point_data['group_id'] = $group_id;
            $point_data['dp_id'] = $dp_id;
            $point_data['supplier_location_id'] = $supplier_location_id;
            $point_data['point'] = $point;
            $GLOBALS['db']->autoExecute(DB_PREFIX . "supplier_location_dp_point_result", $point_data, "INSERT");
            //创建商品点评数据
            if ($dp_data['deal_id'] > 0) {
                $point_data = array();
                $point_data['group_id'] = $group_id;
                $point_data['dp_id'] = $dp_id;
                $point_data['deal_id'] = $dp_data['deal_id'];
                $point_data['point'] = $point;
                $GLOBALS['db']->autoExecute(DB_PREFIX . "deal_dp_point_result", $point_data, "INSERT");
            }
            //创建优惠券点评数据
            if ($dp_data['youhui_id'] > 0) {
                $point_data = array();
                $point_data['group_id'] = $group_id;
                $point_data['dp_id'] = $dp_id;
                $point_data['youhui_id'] = $dp_data['youhui_id'];
                $point_data['point'] = $point;
                $GLOBALS['db']->autoExecute(DB_PREFIX . "youhui_dp_point_result", $point_data, "INSERT");
            }
            //创建活动点评数据
            if ($dp_data['event_id'] > 0) {
                $point_data = array();
                $point_data['group_id'] = $group_id;
                $point_data['dp_id'] = $dp_id;
                $point_data['event_id'] = $dp_data['event_id'];
                $point_data['point'] = $point;
                $GLOBALS['db']->autoExecute(DB_PREFIX . "event_dp_point_result", $point_data, "INSERT");
            }
        }
        //创建点评分组的标签
        foreach ($tag_group as $group_id => $tag_row_arr) {
            foreach ($tag_row_arr as $tag_row) {
                $tag_row_data = array();
                $tag_row_data['tags'] = $tag_row;
                $tag_row_data['dp_id'] = $dp_id;
                $tag_row_data['supplier_location_id'] = $supplier_location_id;
                $tag_row_data['group_id'] = $group_id;
                $GLOBALS['db']->autoExecute(DB_PREFIX . "supplier_location_dp_tag_result", $tag_row_data, "INSERT");
                insert_match_item($tag_row, "supplier_location_dp", $dp_id, "tags_match");
                //更新点评的索引
                review_supplier_location_match($supplier_location_id, $tag_row, $group_id);
                //创建商品点评数据
                if ($dp_data['deal_id'] > 0) {
                    $tag_row_data = array();
                    $tag_row_data['tags'] = $tag_row;
                    $tag_row_data['dp_id'] = $dp_id;
                    $tag_row_data['deal_id'] = $dp_data['deal_id'];
                    $tag_row_data['group_id'] = $group_id;
                    $GLOBALS['db']->autoExecute(DB_PREFIX . "deal_dp_tag_result", $tag_row_data, "INSERT");
                }
                //创建优惠券点评数据
                if ($dp_data['youhui_id'] > 0) {
                    $tag_row_data = array();
                    $tag_row_data['tags'] = $tag_row;
                    $tag_row_data['dp_id'] = $dp_id;
                    $tag_row_data['youhui_id'] = $dp_data['youhui_id'];
                    $tag_row_data['group_id'] = $group_id;
                    $GLOBALS['db']->autoExecute(DB_PREFIX . "youhui_dp_tag_result", $tag_row_data, "INSERT");
                }
                //创建活动点评数据
                if ($dp_data['event_id'] > 0) {
                    $tag_row_data = array();
                    $tag_row_data['tags'] = $tag_row;
                    $tag_row_data['dp_id'] = $dp_id;
                    $tag_row_data['event_id'] = $dp_data['event_id'];
                    $tag_row_data['group_id'] = $group_id;
                    $GLOBALS['db']->autoExecute(DB_PREFIX . "event_dp_tag_result", $tag_row_data, "INSERT");
                }
            }
        }
        //更新统计
        syn_supplier_locationcount($supplier_info);
        cache_store_point($supplier_info['id']);
        //统计商品点评数据
        if ($dp_data['deal_id'] > 0) {
            //计算总点评1-5星人数
            $item_data = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "deal where id = " . $dp_data['deal_id']);
            $sql = "select count(*) as total,point from " . DB_PREFIX . "supplier_location_dp  where deal_id = " . $item_data['id'] . " group by point ";
            $data_result = $GLOBALS['db']->getAll($sql);
            foreach ($data_result as $k => $v) {
                $item_data['dp_count_' . $v['point']] = $v['total'];
            }
            $GLOBALS['db']->autoExecute(DB_PREFIX . "deal", $item_data, "UPDATE", " id = " . $item_data['id'] . " ");
            syn_deal_review_count($item_data['id']);
        }
        //创建优惠券点评数据
        if ($dp_data['youhui_id'] > 0) {
            //计算总点评1-5星人数
            $item_data = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "youhui where id = " . $dp_data['youhui_id']);
            $sql = "select count(*) as total,point from " . DB_PREFIX . "supplier_location_dp  where youhui_id = " . $item_data['id'] . " group by point ";
            $data_result = $GLOBALS['db']->getAll($sql);
            foreach ($data_result as $k => $v) {
                $item_data['dp_count_' . $v['point']] = $v['total'];
            }
            $GLOBALS['db']->autoExecute(DB_PREFIX . "youhui", $item_data, "UPDATE", " id = " . $item_data['id'] . " ");
            syn_youhui_review_count($item_data['id']);
        }
        //创建活动点评数据
        if ($dp_data['event_id'] > 0) {
            //计算总点评1-5星人数
            $item_data = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "event where id = " . $dp_data['event_id']);
            $sql = "select count(*) as total,point from " . DB_PREFIX . "supplier_location_dp where event_id = " . $item_data['id'] . " group by point ";
            $data_result = $GLOBALS['db']->getAll($sql);
            foreach ($data_result as $k => $v) {
                $item_data['dp_count_' . $v['point']] = $v['total'];
            }
            $GLOBALS['db']->autoExecute(DB_PREFIX . "event", $item_data, "UPDATE", " id = " . $item_data['id'] . " ");
            syn_event_review_count($item_data['id']);
        }
        $return['location_id'] = $supplier_location_id;
        $return['deal_id'] = $dp_data['deal_id'];
        $return['youhui_id'] = $dp_data['youhui_id'];
        $return['event_id'] = $dp_data['event_id'];
        $return['status'] = 1;
        $return['info'] = "发表成功";
        return $return;
    } else {
        $return['status'] = 0;
        $return['info'] = "数据库异常,提交失败";
        return $return;
    }
}
Example #4
0
 public function index()
 {
     //        global_run();
     //        init_app_page();
     //        $GLOBALS['tmpl']->assign("no_nav", true); //无分类下拉
     //        if (empty($GLOBALS['user_info'])) {
     //            app_redirect(url("index", "user#login"));
     //        }
     require_once APP_ROOT_PATH . "system/model/review.php";
     $order_item_id = intval($_REQUEST['order_item_id']);
     //订单商品ID
     //        $youhui_log_id = intval($_REQUEST['youhui_log_id']);  //优惠券领取日志ID
     //        $event_submit_id = intval($_REQUEST['event_submit_id']); //活动报名日志ID
     if ($order_item_id > 0) {
         $deal_id = intval($GLOBALS['db']->getOne("select deal_id from " . DB_PREFIX . "deal_order_item where id = " . $order_item_id));
     } else {
         $deal_id = intval($_REQUEST['deal_id']);
     }
     //        if ($youhui_log_id > 0) {
     //            $youhui_id = intval($GLOBALS['db']->getOne("select youhui_id from " . DB_PREFIX . "youhui_log where id = " . $youhui_log_id));
     //        } else {
     //            $youhui_id = intval($_REQUEST['youhui_id']);
     //        }
     //
     //        if ($event_submit_id > 0) {
     //            $event_id = intval($GLOBALS['db']->getOne("select event_id from " . DB_PREFIX . "event_submit where id = " . $event_submit_id));
     //        } else {
     //            $event_id = intval($_REQUEST['event_id']);
     //        }
     //
     //        $location_id = intval($_REQUEST['location_id']);
     if ($deal_id > 0) {
         require_once APP_ROOT_PATH . "system/model/deal.php";
         $deal_info = get_deal($deal_id);
         if ($deal_info) {
             //验证是否可以点评
             $checker = check_dp_status($GLOBALS['user_info']['id'], array("deal_id" => $deal_id, "order_item_id" => $order_item_id));
             if (!$checker['status']) {
                 $root['info'] = $checker['info'];
                 $root['status'] = 0;
             }
             $dp_data = load_dp_info(array("deal_id" => $deal_id));
             if ($deal_info['is_shop'] == 1) {
                 $dp_cfg = load_dp_cfg(array("scate_id" => $deal_info['shop_cate_id']));
             } else {
                 $dp_cfg = load_dp_cfg(array("cate_id" => $deal_info['cate_id']));
             }
             $item_info['id'] = $deal_info['id'];
             $item_info['key'] = 'deal_id';
             $item_info['ex_key'] = 'order_item_id';
             $item_info['ex_id'] = $order_item_id;
             $item_info['name'] = $deal_info['sub_name'];
             $item_info['detail'] = $deal_info['name'];
             $item_info['url'] = $deal_info['url'];
             $item_info['image'] = $goods_item['image'] = get_abs_img_root(get_spec_image($deal_info['icon'], 160, 160, 0));
             //                $GLOBALS['tmpl']->assign("dp_data", $dp_data);
             $root['dp_data'] = $dp_data;
             //                $GLOBALS['tmpl']->assign("dp_cfg", $dp_cfg);
             $root['dp_cfg'] = $dp_cfg;
             //                $GLOBALS['tmpl']->assign("item_info", $item_info);
             $root['item_info'] = $item_info;
             //print_r($dp_cfg);
             //输出导航
             $site_nav[] = array('name' => $GLOBALS['lang']['HOME_PAGE'], 'url' => url("index"));
             $site_nav[] = array('name' => $deal_info['sub_name'], 'url' => url("index", "review", array("deal_id" => $deal_info['id'])));
             //                $GLOBALS['tmpl']->assign("site_nav", $site_nav);
             $root['site_nav'] = $site_nav;
             //输出seo
             $page_title = "";
             $page_keyword = "";
             $page_description = "";
             if ($deal_info['supplier_info']['name']) {
                 $page_title .= "[" . $deal_info['supplier_info']['name'] . "]";
                 $page_keyword .= $deal_info['supplier_info']['name'] . ",";
                 $page_description .= $deal_info['supplier_info']['name'] . ",";
             }
             $page_title .= $deal_info['sub_name'];
             $page_keyword .= $deal_info['sub_name'];
             $page_description .= $deal_info['sub_name'];
             //                $GLOBALS['tmpl']->assign("page_title", $page_title);
             $root['page_title'] = $page_title;
             //                $GLOBALS['tmpl']->assign("page_keyword", $page_keyword);
             $root['page_keyword'] = $page_keyword;
             //                $GLOBALS['tmpl']->assign("page_description", $page_description);
             $root['page_description'] = $page_description;
             //输出右侧的其他团购
             if ($deal_info['is_shop'] == 0) {
                 $side_deal_list = get_deal_list(5, array(DEAL_ONLINE, DEAL_NOTICE), array("cid" => $deal_info['cate_id'], "city_id" => $GLOBALS['city']['id']), "", "  d.buy_type <> 1 and d.is_shop = 0 and d.id<>" . $deal_info['id']);
             } elseif ($deal_info['is_shop'] == 1) {
                 if ($deal_info['buy_type'] == 1) {
                     $side_deal_list = get_goods_list(5, array(DEAL_ONLINE, DEAL_NOTICE), array("cid" => $deal_info['shop_cate_id'], "city_id" => $GLOBALS['city']['id']), "", "  d.buy_type = 1 and d.is_shop = 1 and d.id<>" . $deal_info['id']);
                 } else {
                     $side_deal_list = get_goods_list(5, array(DEAL_ONLINE, DEAL_NOTICE), array("cid" => $deal_info['shop_cate_id'], "city_id" => $GLOBALS['city']['id']), "", "  d.buy_type <> 1 and d.is_shop = 1 and d.id<>" . $deal_info['id']);
                 }
             }
             //$side_deal_list = get_deal_list(4,array(DEAL_ONLINE));
             //                $GLOBALS['tmpl']->assign("side_deal_list", $side_deal_list['list']);
             $root['side_deal_list'] = $side_deal_list['list'];
         } else {
             $root['info'] = "你要点评的商品不存在";
             $root['status'] = 0;
         }
     } else {
         app_redirect(url("index"));
     }
     output($root);
     //        $GLOBALS['tmpl']->display("review.html");
 }