Exemplo n.º 1
0
function syn_deal($deal_id)
{
    $deal_info = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "crowd where id = " . $deal_id);
    if ($deal_info) {
        $deal_info['comment_count'] = intval($GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "crowd_comment where deal_id = " . $deal_info['id'] . " and log_id = 0"));
        $deal_info['support_count'] = intval($GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "crowd_support_log where deal_id = " . $deal_info['id']));
        $deal_info['focus_count'] = intval($GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "crowd_focus_log where deal_id = " . $deal_info['id']));
        $deal_info['view_count'] = intval($GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "crowd_visit_log where deal_id = " . $deal_info['id']));
        $deal_info['support_amount'] = doubleval($GLOBALS['db']->getOne("select sum(price) from " . DB_PREFIX . "crowd_support_log where deal_id = " . $deal_info['id']));
        $deal_info['delivery_fee_amount'] = doubleval($GLOBALS['db']->getOne("select sum(delivery_fee) from " . DB_PREFIX . "crowd_order where deal_id = " . $deal_info['id'] . " and order_status=3 "));
        if ($deal_info['type'] == 0) {
            $deal_info["virtual_num"] = $GLOBALS['db']->getOne("select sum(virtual_person) from " . DB_PREFIX . "crowd_item where deal_id=" . $deal_id);
            $deal_info["virtual_price"] = $GLOBALS['db']->getOne("select sum(virtual_person*price) from " . DB_PREFIX . "crowd_item where deal_id=" . $deal_id);
            if ($deal_info['support_amount'] + $deal_info["virtual_price"] >= $deal_info['limit_price']) {
                $deal_info['is_success'] = 1;
            } else {
                $deal_info['is_success'] = 0;
            }
        } elseif ($deal_info['type'] == 1) {
        }
        if ($deal_info['pay_radio'] > 0) {
            $deal_info['pay_amount'] = $deal_info['support_amount'] * (1 - $deal_info['pay_radio']) + $deal_info['delivery_fee_amount'];
        } else {
            $deal_info['pay_amount'] = $deal_info['support_amount'] * (1 - app_conf("PAY_RADIO")) + $deal_info['delivery_fee_amount'];
        }
        $deal_info['tags_match'] = "";
        $deal_info['tags_match_row'] = "";
        $GLOBALS['db']->autoExecute(DB_PREFIX . "crowd", $deal_info, $mode = 'UPDATE', "id=" . $deal_info['id'], $querymode = 'SILENT');
        $tags_arr = preg_split("/[, ]/", $deal_info["tags"]);
        foreach ($tags_arr as $tgs) {
            if (trim($tgs) != "") {
                insert_match_item(trim($tgs), "crowd", $deal_info['id'], "tags_match");
            }
        }
        $name_arr = div_str($deal_info['name']);
        foreach ($name_arr as $name_item) {
            if (trim($name_item) != "") {
                insert_match_item(trim($name_item), "crowd", $deal_info['id'], "name_match");
            }
        }
    }
}
Exemplo n.º 2
0
function review_supplier_location_match($location_id, $tags, $group_id)
{
    $location = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "supplier_location where id = " . $location_id);
    if ($location) {
        $location['tags_match'] = "";
        $location['tags_match_row'] = "";
        //标签
        $tags_arr = explode(" ", $tags);
        foreach ($tags_arr as $tgs) {
            //同步 supplier_tag 表
            $tag_data = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "supplier_tag where tag_name = '" . trim($tgs) . "' and supplier_location_id = " . $location_id . " and group_id = " . $group_id);
            if ($tag_data) {
                $tag_data['total_count'] = intval($tag_data['total_count']) + 1;
                $GLOBALS['db']->autoExecute(DB_PREFIX . "supplier_tag", $tag_data, "UPDATE", "tag_name = '" . trim($tgs) . "' and supplier_location_id = " . $location_id . " and group_id = " . $group_id);
            } else {
                $tag_data['tag_name'] = trim($tgs);
                $tag_data['supplier_location_id'] = $location_id;
                $tag_data['group_id'] = $group_id;
                $tag_data['total_count'] = 1;
                $GLOBALS['db']->autoExecute(DB_PREFIX . "supplier_tag", $tag_data, "INSERT");
            }
            insert_match_item(trim($tgs), "supplier_location", $location_id, "tags_match");
        }
    }
}
Exemplo n.º 3
0
function syn_deal_match($deal_id)
{
    $deal = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "deal where id = " . $deal_id);
    if ($deal) {
        $deal['name_match'] = "";
        $deal['name_match_row'] = "";
        $deal['deal_cate_match'] = "";
        $deal['deal_cate_match_row'] = "";
        $deal['type_match'] = "";
        $deal['type_match_row'] = "";
        $deal['tag_match'] = "";
        $deal['tag_match_row'] = "";
        $GLOBALS['db']->autoExecute(DB_PREFIX . "deal", $deal, $mode = 'UPDATE', "id=" . $deal_id, $querymode = 'SILENT');
        //同步名称
        $name_arr = div_str(trim($deal['name']));
        foreach ($name_arr as $name_item) {
            insert_match_item($name_item, "deal", $deal_id, "name_match");
        }
        //分类类别
        $deal_cate = array();
        get_all_parent_id(intval($deal['cate_id']), DB_PREFIX . "deal_cate", $deal_cate);
        if (count($deal_cate) > 0) {
            $deal_cates = $GLOBALS['db']->getAll("select name from " . DB_PREFIX . "deal_cate where id in (" . implode(",", $deal_cate) . ")");
            foreach ($deal_cates as $row) {
                insert_match_item(trim($row['name']), "deal", $deal_id, "deal_cate_match");
            }
        }
        $goods_cate = array();
        get_all_parent_id(intval($deal['type_id']), DB_PREFIX . "deal_loan_type", $goods_cate);
        if (count($goods_cate) > 0) {
            $goods_cates = $GLOBALS['db']->getAll("select name from " . DB_PREFIX . "deal_loan_type where id in (" . implode(",", $goods_cate) . ")");
            foreach ($goods_cates as $row) {
                insert_match_item(trim($row['name']), "deal", $deal_id, "type_match");
            }
        }
    }
}
Exemplo n.º 4
0
 function update()
 {
     //B('FilterString');
     $name = $this->getActionName();
     $model = D($name);
     if (false === ($data = $model->create())) {
         $this->error($model->getError());
     }
     $id = $data[$model->getPk()];
     if ($data['reply_content'] != "" && $data['reply_time'] == "") {
         $data['reply_time'] = NOW_TIME;
     }
     // 更新数据
     $list = $model->save($data);
     $dp = $model->getById($id);
     if (false !== $list) {
         //成功提示
         $group_points = $_REQUEST['group_point'];
         foreach ($group_points as $group_id => $point) {
             $model->query("update " . DB_PREFIX . "supplier_location_dp_point_result set point = " . $point . " where group_id = " . $group_id . " and dp_id = " . $id . " and supplier_location_id = " . $dp['supplier_location_id']);
             M()->query("update " . DB_PREFIX . "deal_dp_point_result set point = " . $point . " where group_id = " . $group_id . " and dp_id = " . $id . " and deal_id = " . $dp['deal_id']);
             M()->query("update " . DB_PREFIX . "youhui_dp_point_result set point = " . $point . " where group_id = " . $group_id . " and dp_id = " . $id . " and youhui_id = " . $dp['youhui_id']);
             M()->query("update " . DB_PREFIX . "event_dp_point_result set point = " . $point . " where group_id = " . $group_id . " and dp_id = " . $id . " and event_id = " . $dp['event_id']);
         }
         $group_tags = $_REQUEST['group_tag'];
         M()->query("update " . DB_PREFIX . "supplier_location_dp set tags_match = '',tags_match_row='' where id = " . $id);
         foreach ($group_tags as $group_id => $tags) {
             $model->query("update " . DB_PREFIX . "supplier_location_dp_tag_result set tags = '" . $tags . "' where group_id = " . $group_id . " and dp_id = " . $id . " and supplier_location_id = " . $dp['supplier_location_id']);
             M()->query("update " . DB_PREFIX . "deal_dp_tag_result set tags = '" . $tags . "' where group_id = " . $group_id . " and dp_id = " . $id . " and deal_id = " . $dp['deal_id']);
             M()->query("update " . DB_PREFIX . "youhui_dp_tag_result set tags = '" . $tags . "' where group_id = " . $group_id . " and dp_id = " . $id . " and youhui_id = " . $dp['youhui_id']);
             M()->query("update " . DB_PREFIX . "event_dp_tag_result set tags = '" . $tags . "' where group_id = " . $group_id . " and dp_id = " . $id . " and event_id = " . $dp['event_id']);
             insert_match_item($tags, "supplier_location_dp", $id, "tags_match");
             //更新点评的索引
         }
         $count = M("SupplierLocationDpReply")->where("dp_id=" . $id)->count();
         $model->where("id=" . $id)->setField("reply_count", $count);
         $supplier_info['id'] = $dp['supplier_location_id'];
         syn_supplier_locationcount($supplier_info);
         save_log($dp . L("UPDATE_SUCCESS"), 1);
         $this->assign('jumpUrl', Cookie::get('_currentUrl_'));
         $this->success(L('UPDATE_SUCCESS'));
     } else {
         //错误提示
         $dbErr = M()->getDbError();
         save_log($dp . L("UPDATE_FAILED") . $dbErr, 0);
         $this->error(L('EDIT_ERROR'));
     }
 }