public function index() { $root = array(); $ajax = intval($_REQUEST['ajax']); $root['ajax'] = $ajax; $email = strim($GLOBALS['request']['email']); //用户名或邮箱 $pwd = strim($GLOBALS['request']['pwd']); //密码 //检查用户,用户密码 $user = user_check($email, $pwd); $user_id = intval($user['id']); if ($user_id > 0) { $id = intval($_REQUEST['id']); $deal_info = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "deal where id = " . $id . " and is_delete = 0 and is_effect = 1 and user_id = " . intval($GLOBALS['user_info']['id'])); if (!$deal_info) { $root['info'] = "不能更新该项目的动态"; output($root); } else { $data['log_info'] = strim($_REQUEST['log_info']); if ($data['log_info'] == "") { $root['info'] = "请输入更新的内容"; output($root); } $data['image'] = strim($_REQUEST['image']) != "" ? replace_public($_REQUEST['image']) : ""; $data['vedio'] = strim($_REQUEST['vedio']); if ($data['vedio'] != "") { require_once APP_ROOT_PATH . "system/utils/vedio.php"; $vedio = fetch_vedio_url($_REQUEST['vedio']); if ($vedio != "") { $data['source_vedio'] = $vedio; } else { $root['info'] = "非法的视频地址"; output($root); } } $data['user_id'] = intval($GLOBALS['user_info']['id']); $data['deal_id'] = $id; $data['create_time'] = NOW_TIME; $data['user_name'] = $GLOBALS['user_info']['user_name']; $GLOBALS['db']->autoExecute(DB_PREFIX . "deal_log", $data); $GLOBALS['db']->query("update " . DB_PREFIX . "deal set log_count = log_count + 1 where id = " . $deal_info['id']); showSuccess("", $ajax, url("deal#update", array("id" => $deal_info['id']))); } } else { $root['user_login_status'] = 0; output($root); } }
public function investor_one_save() { $ajax = intval($_REQUEST['ajax']); // if(!check_ipop_limit(get_client_ip(),"project_agency_save",30)) // showErr("提交太频繁",$ajax,""); if (!$GLOBALS['user_info']) { showErr("", $ajax, url_wap("user#login")); } $id = intval($_REQUEST['id']); $deal = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "deal where id = " . $id); $is_edit = $deal['is_edit']; $is_effect = $deal['is_effect']; if ($id > 0 && $is_effect == 1) { showErr("项目已提交,不能更改", $ajax, ""); } $data['name'] = strim($_REQUEST['name']); if ($data['name'] == "") { showErr("请填写项目名称", $ajax, ""); } if (msubstr($data['name'], 0, 25) != $data['name']) { showErr("项目名称不超过25个字", $ajax, ""); } $data['investor_authority'] = intval($_REQUEST['investor_authority']); /* if($data['investor_authority']=='') { showErr("请选择项目详细资料查看权限",$ajax,""); } */ $data['cate_id'] = intval($_REQUEST['cate_id']); if ($data['cate_id'] == 0) { showErr("请选择项目分类", $ajax, ""); } $data['tags'] = strim($_REQUEST['tags']); if ($data['tags'] == "") { showErr("请填写项目标签", $ajax, ""); } if (msubstr($data['tags'], 0, 25) != $data['tags']) { showErr("项目标签不超过25个字", $ajax, ""); } $data['project_step'] = intval($_REQUEST['project_step']); /* if($data['project_step']==0) { showErr("请选择项目所属阶段",$ajax,""); } */ $data['business_employee_num'] = intval($_REQUEST['business_employee_num']); if ($data['business_employee_num'] == 0) { showErr("请填写企业员工人数", $ajax, ""); } $data['province'] = strim($_REQUEST['province']); if ($data['province'] == '') { showErr("请选择省份", $ajax, ""); } $data['city'] = strim($_REQUEST['city']); if ($data['city'] == '') { showErr("请选择城市", $ajax, ""); } $data['business_is_exist'] = intval($_REQUEST['business_is_exist']); /* if($data['business_is_exist']==0) { showErr("请选择公司是否已经成立",$ajax,""); } */ $data['business_create_time'] = to_timespan(strim($_REQUEST['business_create_time']), 'Y-m-d'); if ($data['business_is_exist'] == 1) { if ($data['business_create_time'] == 0) { showErr("请选择企业成立时间", $ajax, ""); } } $data['has_another_project'] = intval($_REQUEST['has_another_project']); /* if($data['has_another_project']==0) { showErr("请选择是否有其他项目",$ajax,""); } */ $data['business_name'] = strim($_REQUEST['business_name']); if ($data['business_name'] == "") { showErr("请填写公司全称", $ajax, ""); } $data['business_address'] = strim($_REQUEST['business_address']); if ($data['business_address'] == "") { showErr("请填写办公地址", $ajax, ""); } $data['limit_price'] = floatval($_REQUEST['limit_price']); if ($data['limit_price'] <= 0) { showErr("请输入正确的融资金额", $ajax, ""); } $data['invote_mini_money'] = floatval($_REQUEST['invote_mini_money']); if ($data['invote_mini_money'] <= 0) { showErr("请输入正确的单投资人最低出资", $ajax, ""); } $data['transfer_share'] = floatval($_REQUEST['transfer_share']); if ($data['transfer_share'] == '' || $data['transfer_share'] > 100) { showErr("出让的股份为空或者出让的股份超过100%", $ajax, ""); } $data['business_stock_type'] = intval($_REQUEST['business_stock_type']); /* if($data['business_stock_type']==0) { showErr("请选择众筹股东成立的有限合伙企业入股方式",$ajax,""); } */ $data['business_descripe'] = strim($_REQUEST['business_descripe']); if ($data['business_descripe'] == "") { showErr("请填写企业项目简介", $ajax, ""); } $data['image'] = replace_public(addslashes(trim($_REQUEST['image']))); // echo $_REQUEST['image'];exit; if ($data['image'] == "") { showErr("上传封面图片", $ajax, ""); } require_once APP_ROOT_PATH . "system/libs/words.php"; $data['vedio'] = strim($_REQUEST['vedio']); if ($data['vedio'] != "") { require_once APP_ROOT_PATH . "system/utils/vedio.php"; $vedio = fetch_vedio_url($data['vedio']); if ($vedio != "") { $data['source_vedio'] = $vedio; } else { showErr("非法的视频地址", $ajax, ""); } } $audit_data = deal_investor_info($_REQUEST['audit_data'], 'audit_data', unserialize($deal['audit_data'])); $data['audit_data'] = serialize($audit_data['data']); $data['is_edit'] = 1; $data['type'] = 1; $data['limit_price'] = $data['limit_price'] * 10000; $data['invote_mini_money'] = $data['invote_mini_money'] * 10000; if ($id > 0) { $savenext = intval($_REQUEST['savenext']); $GLOBALS['db']->autoExecute(DB_PREFIX . "deal", $data, "UPDATE", "id=" . $id, "SILENT"); $GLOBALS['db']->query("update " . DB_PREFIX . "deal set deal_extra_cache = '' where id = " . $id); if ($savenext == 0) { showSuccess($id, $ajax, ""); } else { $investor_edit = $GLOBALS['db']->getOne("select investor_edit from " . DB_PREFIX . "deal where id = " . $id . " and is_delete = 0 and user_id = " . intval($GLOBALS['user_info']['id'])); if ($investor_edit == 1) { showSuccess("", $ajax, url_wap("project#investor_edit", array("id" => $id))); } else { showSuccess("", $ajax, url_wap("project#investor_two", array("id" => $id))); } } } else { $data['user_id'] = intval($GLOBALS['user_info']['id']); $data['user_name'] = $GLOBALS['user_info']['user_name']; $data['create_time'] = NOW_TIME; $savenext = intval($_REQUEST['savenext']); $GLOBALS['db']->autoExecute(DB_PREFIX . "deal", $data, "INSERT", "", "SILENT"); $data_id = intval($GLOBALS['db']->insert_id()); if ($data_id == 0) { showErr("保存失败,请联系管理员", $ajax, ""); } else { es_session::delete("deal_image"); if ($savenext == 0) { showSuccess($data_id, $ajax, ""); } else { showSuccess("", $ajax, url_wap("project#investor_two", array("id" => $data_id))); } } } }
public function update_coin() { B('FilterString'); $data = M(MODULE_NAME)->create(); $deal_info = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "deal where id=" . $data['id']); $this->assign("jumpUrl", u(MODULE_NAME . "/edit_enterprise", array("id" => $data['id']))); $log_info = M(MODULE_NAME)->where("id=" . intval($data['id']))->getField("name"); $this->deal_update(intval($data['id'])); //开始验证有效性 if (!check_empty($data['name'])) { $this->error("请输入名称"); } if (!check_empty($data['zc_count_limit']) or floatval($data['zc_count_limit']) < 0) { $data['zc_count_limit'] = 1; } if (floatval($data['limit_price']) <= 0) { $this->error("目标金额要大于0"); } if (floatval($data['digital_right_amount']) <= 0) { $this->error("产品权益总份额要大于0"); } if (floatval($data['price_per_right']) <= 0) { $this->error("产品权益单价要大于0"); } $data['begin_time'] = trim($data['begin_time']) == '' ? 0 : to_timespan($data['begin_time']); $data['end_time'] = trim($data['end_time']) == '' ? 0 : to_timespan($data['end_time']); if ($data['begin_time'] > $data['end_time']) { $this->error("众筹开始时间不能大于众筹结束时间"); } $data['trade_begin_time'] = trim($data['trade_begin_time']) == '' ? 0 : to_timespan($data['trade_begin_time']); $data['trade_end_time'] = trim($data['trade_end_time']) == '' ? 0 : to_timespan($data['trade_end_time']); if ($data['trade_begin_time'] < $data['end_time']) { echo $data['trade_begin_time'] . " "; echo $data['end_time']; $this->error("交易开始时间不能小于众筹结束时间"); } if ($data['trade_begin_time'] > $data['trade_end_time']) { $this->error("交易开始时间不能大于交易结束时间"); } $data['user_name'] = M("User")->where("id=" . intval($data['user_id']))->getField("user_name"); if (!$data['user_name']) { $data['user_name'] = ""; } if ($data['vedio'] != "") { require_once APP_ROOT_PATH . "system/utils/vedio.php"; $vedio = fetch_vedio_url($data['vedio']); if ($vedio != "") { $data['source_vedio'] = $vedio; } else { $this->error("非法的视频地址"); } } else { $data['source_vedio'] = ""; } if ($_REQUEST['ips_bill_no'] > 0) { $data['ips_bill_no'] = intval($data['id']); } else { $data['ips_bill_no'] = ''; } if ($data['is_effect'] == 2 && $data['user_id'] > 0) { $data['is_edit'] = 1; } $ids = $data["pay_type"]; $exit_pay_id = M("coin_item")->where("deal_id=" . intval($deal_info['id']))->select(); for ($i = 0; $i < count($ids); $i++) { $pay_type_id = intval($ids[$i]); $coin_item['pay_type'] = $pay_type_id; $coin_item['deal_id'] = intval($deal_info['id']); //后期参数需要修改 //后期的参数 M("coin_item")->add($coin_item); } $list = M(MODULE_NAME)->save($data); if (false !== $list) { if ($deal_info['is_effect'] != $data['is_effect']) { if ($data['is_effect'] == 1) { $GLOBALS['msg']->manage_msg($GLOBALS['msg']::MSG_ZC_STATUS, $deal_info['user_id'], array('deal_id' => $deal_info['id'], 'deal_status' => $GLOBALS['msg']::CROW_EXAMINE_SUCCESS)); } elseif ($data['is_effect'] == 2) { $GLOBALS['msg']->manage_msg($GLOBALS['msg']::MSG_ZC_STATUS, $deal_info['user_id'], array('deal_id' => $deal_info['id'], 'deal_status' => $GLOBALS['msg']::CROW_EXAMINE_FAIL)); } } if ($data['is_effect'] == 1 && $data['user_id'] > 0) { $deal_count = M("Deal")->where("user_id=" . $data['user_id'] . " and is_effect = 1 and is_delete = 0")->count(); M("User")->where("id=" . $data['user_id'])->setField("build_count", $deal_count); } //成功提示 M("DealFaq")->where("deal_id=" . $data['id'])->delete(); foreach ($_REQUEST['question'] as $k => $v) { if (trim($v) != "" || trim($_REQUEST['answer'][$k]) != '') { $qa = array(); $qa['deal_id'] = $data['id']; $qa['question'] = trim($v); $qa['answer'] = trim($_REQUEST['answer'][$k]); $qa['sort'] = intval($k) + 1; M("DealFaq")->add($qa); } } M("Deal")->where("id=" . $data['id'])->setField("deal_extra_cache", ""); M("DealLog")->where("deal_id=" . $data['id'])->setField("deal_info_cache", ""); M("DealComment")->where("deal_id=" . $data['id'])->setField("deal_info_cache", ""); syn_deal($data['id']); syn_deal_status($data['id']); save_log($log_info . L("UPDATE_SUCCESS"), 1); $this->success(L("UPDATE_SUCCESS")); } else { //错误提示 save_log($log_info . L("UPDATE_FAILED"), 0); $this->error(L("UPDATE_FAILED"), 0, $log_info . L("UPDATE_FAILED")); } }
public function update() { B('FilterString'); $data = M(MODULE_NAME)->create(); $log_info = M(MODULE_NAME)->where("id=" . intval($data['id']))->getField("name"); //开始验证有效性 $this->assign("jumpUrl", u(MODULE_NAME . "/edit", array("id" => $data['id']))); if (!check_empty($data['name'])) { $this->error("请输入名称"); } if (intval($data['cate_id']) == 0) { $this->error("请选择分类"); } $data['begin_time'] = trim($data['begin_time']) == '' ? 0 : to_timespan($data['begin_time']); $data['end_time'] = trim($data['end_time']) == '' ? 0 : to_timespan($data['end_time']); $data['create_time'] = get_gmtime(); $data['user_name'] = M("User")->where("id=" . intval($data['user_id']))->getField("user_name"); if ($data['vedio'] != "") { require_once APP_ROOT_PATH . "system/utils/vedio.php"; $vedio = fetch_vedio_url($data['vedio']); if ($vedio != "") { $data['source_vedio'] = $vedio; } else { $this->error("非法的视频地址"); } } else { $data['source_vedio'] = ""; } $list = M(MODULE_NAME)->save($data); if (false !== $list) { if ($data['is_effect'] == 1 && $data['user_id'] > 0) { $deal_count = M("Deal")->where("user_id=" . $data['user_id'] . " and is_effect = 1 and is_delete = 0")->count(); M("User")->where("id=" . $data['user_id'])->setField("build_count", $deal_count); } //成功提示 M("DealFaq")->where("deal_id=" . $data['id'])->delete(); foreach ($_REQUEST['question'] as $k => $v) { if (trim($v) != "" || trim($_REQUEST['answer'][$k]) != '') { $qa = array(); $qa['deal_id'] = $data['id']; $qa['question'] = trim($v); $qa['answer'] = trim($_REQUEST['answer'][$k]); $qa['sort'] = intval($k) + 1; M("DealFaq")->add($qa); } } syn_deal($data['id']); save_log($log_info . L("UPDATE_SUCCESS"), 1); $this->success(L("UPDATE_SUCCESS")); } else { //错误提示 save_log($log_info . L("UPDATE_FAILED"), 0); $this->error(L("UPDATE_FAILED"), 0, $log_info . L("UPDATE_FAILED")); } }
public function save() { $ajax = intval($_REQUEST['ajax']); if (!check_ipop_limit(get_client_ip(), "project_save", 5)) { showErr("提交太频繁", $ajax, ""); } if (!$GLOBALS['user_info']) { showErr("", $ajax, url("user#login")); } $id = intval($_REQUEST['id']); $data['name'] = strim($_REQUEST['name']); if ($data['name'] == "") { showErr("请填写项目名称", $ajax, ""); } if (msubstr($data['name'], 0, 25) != $data['name']) { showErr("项目名称不超过25个字", $ajax, ""); } $data['cate_id'] = intval($_REQUEST['cate_id']); if ($data['cate_id'] == 0) { showErr("请选择项目分类", $ajax, ""); } $data['province'] = strim($_REQUEST['province']); if ($data['province'] == '') { showErr("请选择省份", $ajax, ""); } $data['city'] = strim($_REQUEST['city']); if ($data['city'] == '') { showErr("请选择城市", $ajax, ""); } $data['brief'] = strim($_REQUEST['brief']); $data['image'] = replace_public(addslashes(trim($_REQUEST['image']))); if ($data['image'] == "") { showErr("上传封面图片", $ajax, ""); } require_once APP_ROOT_PATH . "system/libs/words.php"; $data['tags'] = implode(" ", words::segment($data['name'])); $data['description'] = replace_public(addslashes(trim(valid_tag($_REQUEST['description'])))); // $data['vedio'] = strim($_REQUEST['vedio']); if ($data['vedio'] != "") { require_once APP_ROOT_PATH . "system/utils/vedio.php"; $vedio = fetch_vedio_url($data['vedio']); if ($vedio != "") { $data['source_vedio'] = $vedio; } else { showErr("非法的视频地址", $ajax, ""); } } $data['limit_price'] = doubleval($_REQUEST['limit_price']); if ($data['limit_price'] <= 0) { showErr("请输入正确的目标金额", $ajax, ""); } $data['deal_days'] = doubleval($_REQUEST['deal_days']); if ($data['deal_days'] <= 0) { showErr("请输入正确的上线天数", $ajax, ""); } if ($id > 0) { $savenext = intval($_REQUEST['savenext']); $GLOBALS['db']->autoExecute(DB_PREFIX . "deal", $data, "UPDATE", "id=" . $id, "SILENT"); //追加faq $GLOBALS['db']->query("delete from " . DB_PREFIX . "deal_faq where deal_id = " . $id); $sort = 1; foreach ($_REQUEST['question'] as $kk => $question_item) { if (strim($_REQUEST['question'][$kk]) != "" && strim($_REQUEST['answer'][$kk]) != "" && strim($_REQUEST['question'][$kk]) != "请输入问题" && strim($_REQUEST['answer'][$kk]) != "请输入答案") { $faq_item['deal_id'] = $id; $faq_item['question'] = strim($_REQUEST['question'][$kk]); $faq_item['answer'] = strim($_REQUEST['answer'][$kk]); $faq_item['sort'] = $sort; $GLOBALS['db']->autoExecute(DB_PREFIX . "deal_faq", $faq_item); $sort++; } } if ($savenext == 0) { showSuccess($id, $ajax, ""); } else { showSuccess("", $ajax, url("project#add_item", array("id" => $id))); } } else { $data['user_id'] = intval($GLOBALS['user_info']['id']); $data['user_name'] = $GLOBALS['user_info']['user_name']; $data['create_time'] = NOW_TIME; $savenext = intval($_REQUEST['savenext']); $GLOBALS['db']->autoExecute(DB_PREFIX . "deal", $data, "INSERT", "", "SILENT"); $data_id = intval($GLOBALS['db']->insert_id()); if ($data_id == 0) { showErr("保存失败,请联系管理员", $ajax, ""); } else { es_session::delete("deal_image"); //追加faq $sort = 1; foreach ($_REQUEST['question'] as $kk => $question_item) { if (strim($_REQUEST['question'][$kk]) != "" && strim($_REQUEST['answer'][$kk]) != "" && strim($_REQUEST['question'][$kk]) != "请输入问题" && strim($_REQUEST['answer'][$kk]) != "请输入答案") { $faq_item['deal_id'] = $data_id; $faq_item['question'] = strim($_REQUEST['question'][$kk]); $faq_item['answer'] = strim($_REQUEST['answer'][$kk]); $faq_item['sort'] = $sort; $GLOBALS['db']->autoExecute(DB_PREFIX . "deal_faq", $faq_item); $sort++; } } if ($savenext == 0) { showSuccess($data_id, $ajax, ""); } else { showSuccess("", $ajax, url("project#add_item", array("id" => $data_id))); } } } }
public function save_update() { $ajax = intval($_REQUEST['ajax']); if (!$GLOBALS['user_info']) { showErr("", $ajax, url("user#login")); } $id = intval($_REQUEST['id']); $deal_info = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "deal where id = " . $id . " and is_delete = 0 and is_effect = 1 and user_id = " . intval($GLOBALS['user_info']['id'])); if (!$deal_info) { showErr("不能更新该项目的动态", $ajax); } else { $data['log_info'] = strim($_REQUEST['log_info']); if ($data['log_info'] == "") { showErr("请输入更新的内容", $ajax, ""); } $data['image'] = strim($_REQUEST['image']) != "" ? replace_public($_REQUEST['image']) : ""; $data['vedio'] = strim($_REQUEST['vedio']); if ($data['vedio'] != "") { require_once APP_ROOT_PATH . "system/utils/vedio.php"; $vedio = fetch_vedio_url($_REQUEST['vedio']); if ($vedio != "") { $data['source_vedio'] = $vedio; } else { showErr("非法的视频地址", $ajax, ""); } } $data['user_id'] = intval($GLOBALS['user_info']['id']); $data['deal_id'] = $id; $data['create_time'] = NOW_TIME; $data['user_name'] = $GLOBALS['user_info']['user_name']; $GLOBALS['db']->autoExecute(DB_PREFIX . "deal_log", $data); $GLOBALS['db']->query("update " . DB_PREFIX . "deal set log_count = log_count + 1 where id = " . $deal_info['id']); showSuccess("", $ajax, url("deal#update", array("id" => $deal_info['id']))); } }
public function update_investor() { B('FilterString'); $data = M(MODULE_NAME)->create(); $log_info = M(MODULE_NAME)->where("id=" . intval($data['id']))->getField("name"); $deal_info = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "deal where id=" . $data['id']); //开始验证有效性 $this->assign("jumpUrl", u(MODULE_NAME . "/edit_investor", array("id" => $data['id']))); if (!check_empty($data['name'])) { $this->error("请输入名称"); } if (intval($data['cate_id']) == 0) { $this->error("请选择分类"); } if (floatval($data['limit_price']) <= 0) { $this->error("目标金额要大于0"); } $this->deal_update(intval($data['id'])); $history_info = deal_investor_info($data['history'], 'history'); if ($history_info['status']) { $data['history'] = serialize(array_filter($history_info['data'])); } else { $this->error($history_info['info']); } $stock_info = deal_investor_info($data['stock'], 'stock'); if ($stock_info['status']) { $data['stock'] = serialize(array_filter($stock_info['data'])); } else { $this->error($stock_info['info']); } $unstock_info = deal_investor_info($data['unstock'], 'unstock'); if ($unstock_info['status']) { $data['unstock'] = serialize(array_filter($unstock_info['data'])); } else { $this->error($unstock_info['info']); } $plan_info = deal_investor_info($data['plan'], 'plan'); if ($plan_info['status']) { $data['plan'] = serialize(array_filter($plan_info['data'])); } else { $this->error($plan_info['info']); } $attach_info = deal_investor_info($data['attach'], 'attach'); if ($attach_info['status']) { $data['attach'] = serialize(array_filter($attach_info['data'])); } else { $this->error($attach_info['info']); } //企业资质材料信息 $data['audit_data'] = serialize($data['audit_data']); if ($data['end_time'] > $data['pay_end_time']) { $this->error("支付结束时间要大于项目结束时间"); } elseif ($data['begin_time'] > $data['end_time']) { $this->error("项目结束时间要大于项目开始时间"); } $data['begin_time'] = trim($data['begin_time']) == '' ? 0 : to_timespan($data['begin_time']); $data['end_time'] = trim($data['end_time']) == '' ? 0 : to_timespan($data['end_time']); $data['pay_end_time'] = trim($data['pay_end_time']) == '' ? 0 : to_timespan($data['pay_end_time']); $data['business_create_time'] = trim($data['business_create_time']) == '' ? 0 : to_timespan($data['business_create_time']); $data['user_name'] = M("User")->where("id=" . intval($data['user_id']))->getField("user_name"); if (!$data['user_name']) { $data['user_name'] = ""; } if ($data['vedio'] != "") { require_once APP_ROOT_PATH . "system/utils/vedio.php"; $vedio = fetch_vedio_url($data['vedio']); if ($vedio != "") { $data['source_vedio'] = $vedio; } else { $this->error("非法的视频地址"); } } else { $data['source_vedio'] = ""; } if ($_REQUEST['ips_bill_no'] > 0) { $data['ips_bill_no'] = intval($data['id']); } else { $data['ips_bill_no'] = ''; } $list = M(MODULE_NAME)->save($data); if (false !== $list) { if ($deal_info['is_effect'] != $data['is_effect']) { if ($data['is_effect'] == 1) { $GLOBALS['msg']->manage_msg($GLOBALS['msg']::MSG_ZC_STATUS, $deal_info['user_id'], array('deal_id' => $deal_info['id'], 'deal_status' => $GLOBALS['msg']::CROW_EXAMINE_SUCCESS)); } elseif ($data['is_effect'] == 2) { $GLOBALS['msg']->manage_msg($GLOBALS['msg']::MSG_ZC_STATUS, $deal_info['user_id'], array('deal_id' => $deal_info['id'], 'deal_status' => $GLOBALS['msg']::CROW_EXAMINE_FAIL)); } } if ($data['is_effect'] == 1 && $data['user_id'] > 0) { $deal_count = M("Deal")->where("user_id=" . $data['user_id'] . " and is_effect = 1 and is_delete = 0")->count(); M("User")->where("id=" . $data['user_id'])->setField("build_count", $deal_count); } //成功提示 M("DealFaq")->where("deal_id=" . $data['id'])->delete(); foreach ($_REQUEST['question'] as $k => $v) { if (trim($v) != "" || trim($_REQUEST['answer'][$k]) != '') { $qa = array(); $qa['deal_id'] = $data['id']; $qa['question'] = trim($v); $qa['answer'] = trim($_REQUEST['answer'][$k]); $qa['sort'] = intval($k) + 1; M("DealFaq")->add($qa); } } M("Deal")->where("id=" . $data['id'])->setField("deal_extra_cache", ""); M("DealLog")->where("deal_id=" . $data['id'])->setField("deal_info_cache", ""); M("DealComment")->where("deal_id=" . $data['id'])->setField("deal_info_cache", ""); //syn_deal($data['id']); //syn_deal_status($data['id']); save_log($log_info . L("UPDATE_SUCCESS"), 1); $this->success(L("UPDATE_SUCCESS")); } else { //错误提示 save_log($log_info . L("UPDATE_FAILED"), 0); $this->error(L("UPDATE_FAILED"), 0, $log_info . L("UPDATE_FAILED")); } }
public function index() { $root = array(); $email = strim($GLOBALS['request']['email']); //用户名或邮箱 $pwd = strim($GLOBALS['request']['pwd']); //密码 //检查用户,用户密码 $user = user_check($email, $pwd); $user_id = intval($user['id']); if ($user_id > 0) { $root['user_login_status'] = 1; $id = intval($_REQUEST['id']); $is_edit = $GLOBALS['db']->getOne("select is_edit from " . DB_PREFIX . "deal where id = " . $id); $is_effect = $GLOBALS['db']->getOne("select is_effect from " . DB_PREFIX . "deal where id = " . $id); if ($id > 0 && $is_effect == 1) { $root['info'] = "项目已提交,不能更改"; } $data['name'] = strim($_REQUEST['name']); if ($data['name'] == "") { $root['info'] = "请填写项目名称"; } if (msubstr($data['name'], 0, 25) != $data['name']) { $root['info'] = "项目名称不超过25个字"; } $data['cate_id'] = intval($_REQUEST['cate_id']); if ($data['cate_id'] == 0) { $root['info'] = "请选择项目分类"; } $data['province'] = strim($_REQUEST['province']); if ($data['province'] == '') { $root['info'] = "请选择省份"; } $data['city'] = strim($_REQUEST['city']); if ($data['city'] == '') { $root['info'] = "请选择城市"; } $data['brief'] = strim($_REQUEST['brief']); $data['image'] = replace_public(addslashes(trim($_REQUEST['image']))); if ($data['image'] == "") { $root['info'] = "上传封面图片"; } require_once APP_ROOT_PATH . "system/libs/words.php"; $data['tags'] = implode(" ", words::segment($data['name'])); $data['description'] = replace_public(addslashes(trim(valid_tag($_REQUEST['description'])))); // $data['vedio'] = strim($_REQUEST['vedio']); if ($data['vedio'] != "") { require_once APP_ROOT_PATH . "system/utils/vedio.php"; $vedio = fetch_vedio_url($data['vedio']); if ($vedio != "") { $data['source_vedio'] = $vedio; } else { $root['info'] = "非法的视频地址"; } } $data['limit_price'] = doubleval($_REQUEST['limit_price']); if ($data['limit_price'] <= 0) { $root['info'] = "请输入正确的目标金"; } $data['deal_days'] = doubleval($_REQUEST['deal_days']); if ($data['deal_days'] <= 0) { $root['info'] = "请输入正确的上线天数"; } $data['is_edit'] = 1; if ($id > 0) { $savenext = intval($_REQUEST['savenext']); $GLOBALS['db']->autoExecute(DB_PREFIX . "deal", $data, "UPDATE", "id=" . $id, "SILENT"); //追加faq $GLOBALS['db']->query("delete from " . DB_PREFIX . "deal_faq where deal_id = " . $id); $sort = 1; foreach ($_REQUEST['question'] as $kk => $question_item) { if (strim($_REQUEST['question'][$kk]) != "" && strim($_REQUEST['answer'][$kk]) != "" && strim($_REQUEST['question'][$kk]) != "请输入问题" && strim($_REQUEST['answer'][$kk]) != "请输入答案") { $faq_item['deal_id'] = $id; $faq_item['question'] = strim($_REQUEST['question'][$kk]); $faq_item['answer'] = strim($_REQUEST['answer'][$kk]); $faq_item['sort'] = $sort; $GLOBALS['db']->autoExecute(DB_PREFIX . "deal_faq", $faq_item); $sort++; } } $GLOBALS['db']->query("update " . DB_PREFIX . "deal set deal_extra_cache = '' where id = " . $id); if ($savenext == 0) { showSuccess($id, $ajax, ""); } else { showSuccess("", $ajax, url("project#add_item", array("id" => $id))); } } else { $data['user_id'] = intval($GLOBALS['user_info']['id']); $data['user_name'] = $GLOBALS['user_info']['user_name']; $data['create_time'] = NOW_TIME; $savenext = intval($_REQUEST['savenext']); $GLOBALS['db']->autoExecute(DB_PREFIX . "deal", $data, "INSERT", "", "SILENT"); $data_id = intval($GLOBALS['db']->insert_id()); if ($data_id == 0) { $root['info'] = "保存失败,请联系管理员"; } else { es_session::delete("deal_image"); //追加faq $sort = 1; foreach ($_REQUEST['question'] as $kk => $question_item) { if (strim($_REQUEST['question'][$kk]) != "" && strim($_REQUEST['answer'][$kk]) != "" && strim($_REQUEST['question'][$kk]) != "请输入问题" && strim($_REQUEST['answer'][$kk]) != "请输入答案") { $faq_item['deal_id'] = $data_id; $faq_item['question'] = strim($_REQUEST['question'][$kk]); $faq_item['answer'] = strim($_REQUEST['answer'][$kk]); $faq_item['sort'] = $sort; $GLOBALS['db']->autoExecute(DB_PREFIX . "deal_faq", $faq_item); $sort++; } } if ($savenext == 0) { showSuccess($data_id, $ajax, ""); } else { showSuccess("", $ajax, url("project#add_item", array("id" => $data_id))); } } } } else { $root['response_code'] = 0; $root['show_err'] = "未登录"; $root['user_login_status'] = 0; } output($root); }