1. 前台JSP页面:
<%@ page contentType="text/html; charset=UTF-8" %> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %> <%@ page isELIgnored="false" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>方案报价</title> <link href="/ebusiness/b2c/accident/pc/common/css/main.css" rel="stylesheet" type="text/css"/> <link href="/ebusiness/b2c/accident/pc/common/quickQuote/css/citySelector.css" rel="stylesheet"> <link href="/ebusiness/b2c/accident/pc/common/plan/css/baojia.css" type="text/css" rel="stylesheet" media="all"> <style> .yes{ background:#f5f5f5;} .no{ background:#e9e9e9;} </style> </head> <body> <div class="header"> <div class="w1000"> <img src="/ebusiness/b2c/accident/pc/common/img/fuwurexian.gif" width="246" height="32" class="fl" /> </div> <div style="position:absolute; right:55px; z-index:20; top:9px;"> <a href="javascript:;" class="zhuce">注册</a><a href="javascript:;" class="menu_denglu">登录</a><a href="http://192.168.11.158:9696/b2c/" class="website">安联全球网站</a> </div> </div> <div class="w1000"> <div class="logo"> <img src="/ebusiness/b2c/accident/pc/common/img/logo_1.gif" style="margin-bottom:3px;" /> <img src="/ebusiness/b2c/accident/pc/common/img/logo_2.gif" /> </div> </div> <div class="navBg"> <div class="w1000"> <img src="/ebusiness/b2c/accident/pc/common/img/step1.gif" width="800" height="50" style="padding-top:82px; margin-left:198px;" /> </div> </div> <div class="clear10"></div> <form id="planForm" action="/ebusiness/b2c/processFillInsuranceInfo.do?actionType=prepareInsert" method="post" onsubmit="planSubmit();"> <input id="destinationRegionCode" type="hidden" name="destinationRegionCode" value="${destination }" /> <!--旅游目的地国家编码 --> <input id="planCodeSize" type="hidden" value="${planCodeSize }"/> <!-- --> <input type="hidden" name="riskCode" value="${riskCode }"/> <!-- --> <!-- 每份保费 也有问题同下面--> <input id="unitPremium" type="hidden" name="unitPremium" value="${unitPremium }" /> <input id="isHighRisk" type="hidden" name="isHighRisk" value="${isHighRisk }"/> <!-- 高风险 --> <!-- 客户选择的planCode,也有问题同下面--> <input id="default_planCode" type="hidden" name="planCode" value="${planCode }" /> <!-- 用户选择的planCName(默认为plan2) 为填写保单页面提供,这里目前有问题需要判断只有一个plan的情况--> <input type="hidden" name="planCName" value="${planCName }" /> <input id="isExistHidden" type="hidden" /> <!--旅游目的地国家的输入内容ajax验证 --> <div class="w1000"> <div class="title2" style="margin-top:20px;">旅游险</div> <div style="line-height:50px; border-bottom:1px dashed #bfbfbf; width:97%; margin:auto auto 20px auto;">报价信息</div> <table width="97%" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td height="40" align="right">旅行目的地:</td> <td width="190"> <input id="citySelect" class="baojiaInput" type="text" onchange="getBenefitInfoAndPrice();" value="${destinationCName }" /> </td> <td class="tishi_gantanhao">不承保地区 <p id="citySelectHiddenDiv" style="display: none; color: red; margin-top: 0px; max-height: 5px" >请选择目的地国家</p> </td> <td width="190" align="right">旅行类型:</td> <td width="190"> <select id="travlSelect" onchange="changePeriodDaysForTravlType();" class="baojiaInput" style="width:174px;"> <option value="1">单次旅行</option> <option value="2">全年旅行</option> </select> </td> <td style="color:#ff0000;"> </td> </tr> <tr> <td height="40" align="right">保险起期:</td> <td> <input id="startDate" name="startDate" class="baojiaInput" value='${requestScope.startDate }' type="text" onchange="changePeriodDays();" onFocus="startDateMethod()" onblur="checkStartDate();" readonly="readonly"/> <p id="startDateHiddenDiv" style="display: none; color: red; margin-top: 0px; max-height: 5px" >请选择保险起期</p> </td> <td class="tishi_gantanhao">重要注意事项</td> <td width="190" align="right">保险止期:</td> <td> <div id="DIV_endDate"> <input id="endDate" name="endDate" class="baojiaInput" type="text" value='${requestScope.endDate }' onFocus="endDateMethod();" onchange="changePeriodDays();" readonly="readonly" /> </div> </td> <td> 24时止 共 <span id="periodDays" style="color:#ff0000;">${requestScope.periodDays } </span> 天 <p id="endDateHiddenDiv" style="display: none; color: red; margin-top: 0px; max-height: 5px" >请选择保险止期</p> </td> </tr> <tr> <td height="40" align="right">被保险人数:</td> <td> <input id="totalInsuredNum" type="text" onblur="checktotalInsuredNum(this.value);" value="1" class="baojiaInput" autocomplete="off" /> <p id="totalInsuredNumHiddenDiv" style="display: none; color: red; margin-top: 0px; max-height: 5px" >请输入被保险人数</p> </td> <td>共 <span id="totalInsuredNumSpan" style="color:#ff0000;"> 1 </span> 人</td> <td width="190" align="right">手机号:</td> <td> <input id="phoneNumberValue" type="text" name="phoneNumber" class="baojiaInput" value="${requestScope.phoneNumber }" onclick="hidePhoneNumberDiv();" onblur="checkPhoneNumber(this.value);" maxlength="11"/> <p id="phoneNumberHide" style="display:none;color: red;"></p> </td> <td> </td> </tr> <tr> <td height="40" align="right">高风险:</td> <td colspan="5"> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="20" height="40"><input type="checkbox" name="checkbox" id="isHighRiskButton" class="danxuankuangInput1" onclick="isHighRiskMethod();"/></td> <td class="tishi_gantanhao">什么是高风险</td> </tr> </table> </td> </tr> </table> <div style="border-bottom:2px solid #ff752b; margin:20px auto auto auto;"></div> <div style=" width:97%; margin:20px auto auto auto;">方案选择</div> </div> <div class="comparison_page"> <div class="comparison_page_left"> <div class="table"> <img src="/ebusiness/b2c/accident/pc/common/img/icon_rexiaochanpin.gif" width="120" height="40" style="margin-left:700px; margin-bottom:8px;" /> <ul> <li class="service"><!-- 保障类型 --> <ul> <li class="header"> <span style="font-size:20px;color:#004994;font-weight:normal;">保障类型</span> </li> <li style="height:310px;"> 旅行阻碍保障 <div class="ovrlay" style="display:none;">指客户车辆在道路行驶过程中,如因爆胎或轮胎故障而无法行驶,安联全球救援提供更换轮胎的服务,但需由客户自行提供备用车胎,如无法提供由于更换新胎所产生的费用需要有客户自行承担。</div> <span class="faq"></span> </li> <li style="background:#e9e9e9; height:340px;"> 意外伤害和医疗保障 <div class="ovrlay" style="display:none;">指客户车辆由于电力不足原因造成的车辆无法启动情况发生时,安联全球救援将提供接电启动服务。</div> <span class="faq"></span> </li> <li style="height:206px;"> 紧急救援 <div class="ovrlay" style="display:none;"></div> <span class="faq"></span> </li> <li style="background:#e9e9e9; height:258px;"> 财产损失 <div class="ovrlay" style="display:none;">指客户如遇钥匙丢失问题(或锁在车内),安联全球救援将优先协助取备用钥匙;也可建议客户拨打110协调或客户自取备用钥匙,安联全球救援报销同城对应级别公里数限制内的出租车费。</div> <span class="faq"></span> </li> <li> 个人责任 <div class="ovrlay" style="display:none;">指客户车辆由于故障无法继续行驶,安联全球救援将派遣专业技师到达现场进行救援,竭尽全力在现场将您的爱车修理成功。(服务仅包含在不解体情况下,30分钟内的维修服务)。</div> <span class="faq"></span> </li> <li class="row more" style="height:300px;background:#e9e9e9;"> <span class="text">特色服务</span> <div class="ovrlay" style="display:none;">当顾客的汽车出现非事故或者交通事故导致不能行驶,须将车辆拖至指定修理厂进行修理后,如果修复时间大于72小时,安联全球救援将承担修理期间从第四天起相应的代步出租车的费用。代步出租车、住宿服务和继续旅行服务,顾客只可选择其中一项。</div> <span class="faq"></span> </li> <li class="no">保费</li> </ul> </li> <li class="service"><!-- 保障范围 --> <ul> <li class="header"><span style="font-size:20px;color:#004994;font-weight:normal;">保障范围</span></li> <li class="yes">行李丢失或损坏销</li> <li class="yes">航班延误</li> <li class="yes">旅行延误</li> <li class="yes">旅行缩短</li> <li class="yes">旅行取消</li> <li class="yes">行李延误</li> <li class="no">意外身故或伤残</li> <li class="row no" style="height:70px;">住院医疗费用<br />门诊医疗费用<br />牙科医疗费用</li> <li class="no">公共交通工具意外双倍赔付</li> <li class="no">意外住院津贴</li> <li class="no">急性病身故</li> <li class="no">急性病住院津贴</li> <li class="yes">医疗运送和送返</li> <li class="yes">亲属慰问探望</li> <li class="yes">身故遗体送返</li> <li class="yes">旅行期间的非法拘禁及绑架</li> <li class="no">旅行证件丢失</li> <li class="no">信用卡盗刷</li> <li class="no">个人现金丢失</li> <li class="no">家居保障</li> <li class="row no">手机保险(非Iphone免赔20%,Iphone免赔25%)</li> <li class="yes">个人第三者责任</li> <li class="no">补课费用补贴</li> <li class="no">期末考试缺席补偿</li> <li class="no">学业中断补偿</li> <li class="no">信息咨询</li> <li class="no">信息传递</li> <li class="no">在线医疗翻译</li> <li class="no">-------------</li> </ul> </li> <li id="plan1" class="version3"><!-- plan1 --> <input id="plan1_planCode" type="hidden" value="${planCodes[0] }" /> <input id="plan1_planCName" type="hidden" value="${planCNames[0] }" /> <ul onclick="fillUnitPremiumAndSumPremium('plan1')"> <li class="header" > <p style="line-height: 48px;"> ${planCNames[0] } </p> </li> <li class="row">5,000<br />(单件物品赔付限额1,000元)</li> <li class="">-</li> <li class="row">800<br />(每4小时延误赔偿400元)</li> <li class="yes">-</li> <li class="yes">-</li> <li class="row">1,000<br />(每6小时延误赔偿500元)</li> <li class="no">500000</li> <li class="row no" style="height:70px;"><span class="no">No</span></li> <li class="no">-</li> <li class="no">No</li> <li class="no">-</li> <li class="no">-</li> <li class="yes">600000</li> <li class="yes">40000</li> <li class="row yes">160,000<br />(丧葬费以20,000为限)</li> <li class="yes">-</li> <li class="no">2000</li> <li class="no">4000</li> <li class="no">-</li> <li class="no">-</li> <li class="row no">-</li> <li class="yes">600000</li> <li class="no">6000</li> <li class="no">6000</li> <li class="no">100000</li> <li class="no">Yes</li> <li class="no">Yes</li> <li class="no">Yes</li> <li class="footer">${priceList[0] }元</li> </ul> </li> <li id="plan2" class="version2 hover"><!-- plan2 --> <input id="plan2_planCode" type="hidden" value="${planCodes[1] }" /> <input id="plan2_planCName" type="hidden" value="${planCNames[1] }" /> <ul onclick="fillUnitPremiumAndSumPremium('plan2')"> <li class="header11" style=" height:68px; padding-top:20px; line-height:1em;"> <p style="font-size:16px;padding-bottom: 10px;">${planCNames[1] }</p> <input type="hidden" value="${planCodes[1] }" /> </li> <c:forEach var="prpDitemKindBenefitDto2" items="${prpDitemKindBenefitDtos2 }"> <li class="yes"><c:out value="${prpDitemKindBenefitDto2.instructions }"></c:out></li> </c:forEach> <li class="footer">${priceList[1] }元</li> </ul> </li> <li id="plan3" class="version3"><!-- plan3 --> <input id="plan3_planCode" type="hidden" value="${planCodes[2] }" /> <input id="plan3_planCName" type="hidden" value="${planCNames[2] }" /> <ul onclick="fillUnitPremiumAndSumPremium('plan3')"> <li class="header11" style=" height:68px; padding-top:20px; line-height:1em;"> <p style="font-size:16px;padding-bottom: 10px;">${planCNames[2] } </p> <input type="hidden" value="${planCodes[2] }" /> </li> <c:forEach var="prpDitemKindBenefitDto3" items="${prpDitemKindBenefitDtos3 }"> <li class="yes"><c:out value="${prpDitemKindBenefitDto3.instructions }"></c:out></li> </c:forEach> <li>${priceList[2] }元</li> </ul> </li> </ul> <div style="clear:both; height:40px;"></div> <input type="button" name="button" id="button" value="立即投保" class="menu_lijitoubao fr" onClick="planSubmit();" /> <div class="fr" style="color:#ff742b; margin-right:20px;">保费: <span id="totalPrice" style="font-size:24px"> ${requestScope.priceList[1] } </span> 元</div> </div> </div> </div> </form> <jsp:include page="/admin/common/StaticJavascript.jsp" /> <div style=" clear:both; font-size:0; height:30px; width:100%; overflow:hidden;"></div> <div class="footer"> <div class="w1003"> <a href="/lianxiwomen.jhtml">联系我们</a> | <a href="/falvshengming.jhtml">法律声明</a> | <a href="/youqinglianjie.jhtml">友情链接</a> | <a href="/wangzhanditu.jhtml">网站地图</a> | <a href="/cookie.jhtml">隐私和Cookie</a> <br /> Copyright © 2015 安联财产保险(中国)有限公司 版权所有 粤ICP备07058166号-2 </div> </div> <script src="/ebusiness/b2c/accident/pc/common/plan/js/citySelector1.js" type="text/javascript" ></script> <script src="/ebusiness/b2c/accident/pc/common/plan/js/datePicker/WdatePicker.js" type="text/javascript" ></script> <script src="/ebusiness/b2c/accident/pc/common/plan/js/getPlanList.js" type="text/javascript" ></script> <script src="/ebusiness/b2c/accident/pc/common/plan/js/js_b1.js" type="text/javascript" ></script> <script src="/ebusiness/b2c/accident/pc/common/plan/js/js_b2.js" type="text/javascript" ></script> <script> //返回顶部 $("body").append('<div class="gotop" id="gotop"><div>'); $(window).scroll(function(){$(document).scrollTop()>100?$("#gotop").fadeIn():$("#gotop").fadeOut()}); $("#gotop").click(function(){$("html,body").animate({scrollTop:0},100)}) </script> </body> </html>2. JS部分:
window.onload=function(){ var planCodeSize = document.getElementById("planCodeSize").value; // alert(planCodeSize); if(planCodeSize == 1){ document.getElementById("plan2").style.display = "none"; document.getElementById("plan3").style.display = "none"; }else if(planCodeSize == 2){ document.getElementById("plan3").style.display = "none"; } } function startDateMethod(){ WdatePicker({disabledDates:['%y-%M-%d'],minDate:new Date(),maxDate:'#F{$dp.$D(\'endDate\')}'}); } function endDateMethod(){ WdatePicker({disabledDates:['%y-%M-%d'],minDate:'#F{$dp.$D(\'startDate\')||new Date()}'}); } function endDateMethodbeifen(){ WdatePicker({minDate:'#F{$dp.$D(\'startDate\')||new Date()}',maxDate:'#F{$dp.$D(\'startDate\',{d:181});}'}); } /* * 1.旅游国家目的地非空验证 * 2.ajax请求查证:是否存在“目的地”中填写的国家 * --不存在:reslut为no; * --存在: result为''(空字符串); */ function checkDestination(){ var destinationValue = document.getElementById('citySelect').value; document.getElementById("citySelectHiddenDiv").style.display = "none"; if(destinationValue == ""){ document.getElementById("citySelectHiddenDiv").style.display = "block"; document.getElementById('citySelect').focus(); }else{ $.ajax({ type: "POST", url: "/ebusiness/b2c/processPlanAction.do?actionType=checkDestination", data: "destination="+destinationValue, success: function(result) { document.getElementById("isExistHidden").value = result; } }); } } /*投保人数验证*/ function checktotalInsuredNum(value){ var reg = /^[1-9]+[0-9]*]*$/; if(!reg.test(value)){ document.getElementById("totalInsuredNumHiddenDiv").innerHTML = '被保险人数量为正整数'; document.getElementById("totalInsuredNumHiddenDiv").style.display = "block"; document.getElementById('totalInsuredNum').focus(); } else { document.getElementById("totalInsuredNumHiddenDiv").style.display = "none"; document.getElementById("totalInsuredNumSpan").innerHTML = value; /*将总保费=人数X每份保费*/ var unitPremium = document.getElementById("unitPremium").value; document.getElementById("totalPrice").innerHTML = unitPremium * value; } } /*被保险人数的非空验证 function checkTotalInsuredNum(){ var totalInsuredNumValue = document.getElementById("totalInsuredNum").value; document.getElementById("totalInsuredNumHiddenDiv").style.display = "none"; if(totalInsuredNumValue == ""){ document.getElementById("totalInsuredNumHiddenDiv").style.display = "block"; }; }*/ /*隐藏手机号验证div*/ function hidePhoneNumberDiv(){ document.getElementById("phoneNumberHide").style.display='none'; } /*手机号验证*/ function checkPhoneNumber(phoneNumber){ if(phoneNumber != ''){ var reg = /^0?1[3|4|5|8][0-9]\d{8}$/; if (!(reg.test(phoneNumber))) { document.getElementById("phoneNumberHide").innerHTML='手机号格式有误'; document.getElementById("phoneNumberHide").style.display='inline'; } }; } /*==================得到ul中最后一个li=======================*/ function getLastLi(li_id){ var li = document.getElementById(li_id); var ul = li.getElementsByTagName("ul")[0]; var liList = ul.getElementsByTagName("li"); return liList[liList.length-1]; } /*==================得到ul中第一个li=======================*/ function getFirstLi(li_id){ var li = document.getElementById(li_id); var ul = li.getElementsByTagName("ul")[0]; var liList = ul.getElementsByTagName("li"); return liList[0]; } /*==========改变每份保费和总保费=======*/ function fillUnitPremiumAndSumPremium(li_id){ var totalInsuredNum = document.getElementById("totalInsuredNum").value; var planPrice = getLastLi(li_id).innerHTML; var planPriceValue = planPrice.split("元")[0]; //alert(planPriceValue); if(totalInsuredNum == '' || totalInsuredNum == 0){ document.getElementById("totalInsuredNum").focus(); document.getElementById("totalInsuredNumHiddenDiv").innerHTML = '请正确输入被保险人数'; document.getElementById("totalInsuredNumHiddenDiv").style.display = "block"; }else{ var sumPremium = planPriceValue * totalInsuredNum; document.getElementById("unitPremium").value = planPriceValue; document.getElementById("totalPrice").innerHTML = sumPremium; var id1 = li_id+"_planCName"; var value1 = document.getElementById(id1).value; document.getElementsByName("planCName")[0].value = value1; var id2 = li_id+"_planCode"; var value2 = document.getElementById(id2).value; document.getElementsByName("planCode")[0].value = value2; } } /*是否高风险*/ function isHighRiskMethod(){ var isHighRiskCheked = document.getElementById("isHighRiskButton").checked; if(isHighRiskCheked){ document.getElementById("isHighRisk").value = "highRisk"; getBenefitInfoAndPrice(); //alert(isHighRiskCheked); }else{ document.getElementById("isHighRisk").value = "notHighRisk"; getBenefitInfoAndPrice(); //alert(isHighRiskCheked); } } /*保险起期的非空验证*/ function checkStartDate(){ var startDateValue = document.getElementById("startDate").value; document.getElementById("startDateHiddenDiv").style.display = "none"; if(startDateValue == ""){ document.getElementById("startDateHiddenDiv").style.display = "block"; }; } /*保险止期的非空验证*/ function checkEndDate(){ var endDateValue = document.getElementById("endDate").value; document.getElementById("endDateHiddenDiv").style.display = "none"; if(endDateValue == ""){ document.getElementById("endDateHiddenDiv").style.display = "block"; }; } /*旅行类型改变时触发的js方法*/ function changePeriodDaysForTravlType(){ var startDateValue = document.getElementById("startDate").value; var endDateValue = document.getElementById("endDate").value; if(startDateValue != ''){ var selectValue = document.getElementById('travlSelect').value; if(selectValue == 2){ var newEndDate = getNewDay(startDateValue,364); document.getElementById('DIV_endDate').innerHTML= '<input id="endDate" name="endDate" class="baojiaInput" type="text" readonly="readonly" value="'+newEndDate+'"/> '; //document.getElementById("endDate").value = newEndDate; //为“回程日期”标签赋值 function $(id){ return document.getElementById(id); } var endDate = new Date($("endDate").value.replace(/-/g, "/")), startDate = new Date($("startDate").value.replace(/-/g, "/")), d3 = new Date(endDate - startDate).getTime() / (1000 * 60 * 60 * 24); $("periodDays").innerHTML = d3 + 1; getBenefitInfoAndPrice(); }else{ document.getElementById('DIV_endDate').innerHTML= '<input id="endDate" name="endDate" class="baojiaInput" type="text" value="" onFocus="endDateMethod();" onchange="changePeriodDays();" readonly="readonly" />'; //document.getElementById("endDate").value = ''; var d3 = 0; document.getElementById("periodDays").innerHTML = d3; } } } /*计算共N天并且调用报价接口:旅行类型、保险起期、保险止期触发此方法*/ function changePeriodDays(){ var startDateValue = document.getElementById("startDate").value; var endDateValue = document.getElementById("endDate").value; if(startDateValue != ''&& endDateValue != ''){ var selectValue = document.getElementById('travlSelect').value; if(selectValue == 2){ var newEndDate = getNewDay(startDateValue,364); document.getElementById("endDate").value = newEndDate; //为“回程日期”标签赋值 function $(id){ return document.getElementById(id); } var endDate = new Date($("endDate").value.replace(/-/g, "/")), startDate = new Date($("startDate").value.replace(/-/g, "/")), d3 = new Date(endDate - startDate).getTime() / (1000 * 60 * 60 * 24); $("periodDays").innerHTML = d3 + 1; getBenefitInfoAndPrice(); }else{ function $(id){ return document.getElementById(id); } var endDate = new Date($("endDate").value.replace(/-/g, "/")), startDate = new Date($("startDate").value.replace(/-/g, "/")), d3 = new Date(endDate - startDate).getTime() / (1000 * 60 * 60 * 24); $("periodDays").innerHTML = d3 + 1; getBenefitInfoAndPrice(); } } } /*function travlTypeToChangeEnDate(selectValue){ alert("aa"); var endDateTag = document.getElementById('endDate'); //var selectValue = document.getElementById('travlSelect').value; if(selectValue == 2){ endDateTag.disabled="disabled"; } }*/ //日期加上天数得到新的日期 //dateTemp 需要参加计算的日期,days要添加的天数,返回新的日期,日期格式:YYYY-MM-DD function getNewDay(dateTemp, days) { var dateTemp = dateTemp.split("-"); var nDate = new Date(dateTemp[1] + '/' + dateTemp[2] + '/' + dateTemp[0]); //转换为MM/DD/YYYY格式 var millSeconds = nDate.getTime() + (days * 24 * 60 * 60 * 1000); var rDate = new Date(millSeconds); var year = rDate.getFullYear(); var month = rDate.getMonth() + 1; if (month < 10) month = "0" + month; var date = rDate.getDate(); if (date < 10) date = "0" + date; return (year + "-" + month + "-" + date); } /* * 提交时验证:目的地国家不能为空,国家名正确;被保人数量不能为空,填写正确; * 手机号格式必须正确,起保日期和终保日期不能为空 */ function planSubmit(){ var citySelectValue = document.getElementById("citySelect").value; var startDateValue = document.getElementById("startDate").value; var endDateValue = document.getElementById("endDate").value; var totalInsuredNumValue = document.getElementById("totalInsuredNum").value; var destinationValue = document.getElementById('citySelect').value; var isExist = findEn(destinationValue); var totalInsuredNumValue = document.getElementById("totalInsuredNum").value; checktotalInsuredNum(totalInsuredNumValue); var phoneNumberValue = document.getElementById("phoneNumberValue").value; checkPhoneNumber(phoneNumberValue); var totalPrice = document.getElementById("totalPrice").innerHTML; if(destinationValue == ''|| typeof(isExist) == 'undefined'){ document.getElementById("citySelectHiddenDiv").style.display = "block"; document.getElementById('citySelect').focus(); }else if(document.getElementById("totalInsuredNumHiddenDiv").style.display != 'none'){ document.getElementById('totalInsuredNum').focus(); }else if(document.getElementById("phoneNumberHide").style.display != 'none'){ document.getElementById('phoneNumberHide').focus(); }else if(startDateValue == ''){ document.getElementById("startDateHiddenDiv").style.display = "block"; document.getElementById("startDateHiddenDiv").focus(); }else if(endDateValue == ''){ document.getElementById("endDateHiddenDiv").style.display = "block"; document.getElementById("endDateHiddenDiv").focus(); }else if(totalInsuredNumValue == ''){ document.getElementById("totalInsuredNumHiddenDiv").style.display = "block"; document.getElementById("totalInsuredNumHiddenDiv").focus(); }else if(totalPrice == "-"){ alert("请选择一款保险产品!"); document.getElementById("r30_t1").focus(); }else{ var citySelectValue = document.getElementById("citySelect").value; var regionCode = findEn(citySelectValue); document.getElementById("destinationRegionCode").value = regionCode; document.getElementById("planForm").submit(); } } /*使用AJAX去后台查询plan1plan2plan3对应的benefit信息和报价信息*/ function getBenefitInfoAndPrice(){ var isHighRisk = document.getElementById("isHighRisk").value; var citySelectValue = document.getElementById("citySelect").value; var startDateValue = document.getElementById("startDate").value; var endDateValue = document.getElementById("endDate").value; var totalInsuredNumValue = document.getElementById("totalInsuredNum").value; var regionCode = findEn(citySelectValue); var riskCode = document.getElementsByName("riskCode")[0].value; document.getElementById("destinationRegionCode").value = regionCode; if(citySelectValue == '' || typeof(regionCode) == "undefined"){ document.getElementById("citySelectHiddenDiv").style.display = "block"; document.getElementById('citySelect').focus(); }else if(startDateValue == ''){ document.getElementById("startDateHiddenDiv").style.display = "block"; }else if(endDateValue == ''){ document.getElementById("endDateHiddenDiv").style.display = "block"; }else if(totalInsuredNumValue == ''){ document.getElementById("totalInsuredNumHiddenDiv").style.display = "block"; }else{ document.getElementById("citySelectHiddenDiv").style.display = "none"; document.getElementById("startDateHiddenDiv").style.display = "none"; document.getElementById("endDateHiddenDiv").style.display = "none"; document.getElementById("totalInsuredNumHiddenDiv").style.display = "none"; if(citySelectValue != '' && startDateValue != '' && endDateValue != '' && totalInsuredNumValue != ''){ $.ajax({ type: "POST", url: "/ebusiness/b2c/processPlanAction.do?actionType=query", data: "destination="+regionCode+"&methodType=ajax&startDate="+startDateValue+"&endDate="+endDateValue+"&isHighRisk="+isHighRisk+"&riskCode="+riskCode, success: function(jsonData) { var bigJSON = eval("("+jsonData+")"); var priceListJSON = bigJSON.priceListJSON; var planCNamesJSON = bigJSON.planCNamesJSON; var planCodesJSON = bigJSON.planCodesJSON; var prpDitemKindBenefitDtos1JSON = bigJSON.plan1; var prpDitemKindBenefitDtos2JSON = bigJSON.plan2; var prpDitemKindBenefitDtos3JSON = bigJSON.plan3; var length = planCNamesJSON.length; if(length == 1){ document.getElementById("plan2").style.display = "none"; document.getElementById("plan3").style.display = "none"; var li_plan1 = document.getElementById("plan1"); var ul = li_plan1.getElementsByTagName("ul")[0]; //plan中文名 var liList = ul.getElementsByTagName("li"); liList[0].innerHTML = planCNamesJSON[0]; //为plan赋中文名称 document.getElementById("plan1_planCode").value = planCodesJSON[0]; //为隐藏的planCode标签赋值 document.getElementById("plan1_planCName").value = planCNamesJSON[0]; //为隐藏的planCName标签赋值 document.getElementById("default_planCode").value = planCodesJSON[0]; //为隐藏的default_planCode标签赋值 for(var i=1; i < prpDitemKindBenefitDtos1JSON.length - 1; i++ ){ //保障范围说明 liList[i].innerHTML = prpDitemKindBenefitDtos1JSON[i - 1]; } liList[liList.length-1].innerHTML = priceListJSON[0] + "元"; //plan的保费 fillUnitPremiumAndSumPremium("plan1"); }else if(length == 2){ var li_plan2 = document.getElementById("plan2"); li_plan2.style.display = "block"; var li_plan3 = document.getElementById("plan3"); li_plan3.style.display = "none"; var li_plan1 = document.getElementById("plan1"); var ul = li_plan1.getElementsByTagName("ul")[0]; var liList = ul.getElementsByTagName("li"); liList[0].innerHTML = planCNamesJSON[0]; //为plan赋中文名称 document.getElementById("plan1_planCode").value = planCodesJSON[0]; //为隐藏的planCode标签赋值 document.getElementById("plan1_planCName").value = planCNamesJSON[0]; //为隐藏的planCName标签赋值 document.getElementById("plan2_planCode").value = planCodesJSON[1]; //为隐藏的planCode标签赋值 document.getElementById("plan2_planCName").value = planCNamesJSON[1]; //为隐藏的planCName标签赋值 document.getElementById("default_planCode").value = planCodesJSON[1]; //为隐藏的default_planCode标签赋值 for(var i=1; i < prpDitemKindBenefitDtos1JSON.length - 1; i++ ){ liList[i].innerHTML = prpDitemKindBenefitDtos1JSON[i - 1]; } liList[liList.length-1].innerHTML = priceListJSON[0] + "元"; //plan2的显示方式比较特殊 var li_plan2 = document.getElementById("plan2"); var ul = li_plan2.getElementsByTagName("ul")[0]; var liList = ul.getElementsByTagName("li"); for(var i=0; i < liList.length; i++ ){ //删掉ul下面所有的li标签 ul.removeChild(liList[i]); } for(var i=0; i < prpDitemKindBenefitDtos2JSON.length+2; i++ ){ //创建24/28个li标签 var htmlLi = document.createElement("li"); ul.appendChild(htmlLi); } liList = ul.getElementsByTagName("li"); liList[0].innerHTML = planCNamesJSON[1]; for(var i=1; i <= prpDitemKindBenefitDtos2JSON.length; i++ ){ //为所有的li赋值 liList[i].innerHTML = prpDitemKindBenefitDtos2JSON[i - 1]; } liList[liList.length-1].innerHTML = priceListJSON[1] + "元"; fillUnitPremiumAndSumPremium("plan2"); }else if(length == 3){ var li_plan2 = document.getElementById("plan2"); li_plan2.style.display = "block"; var li_plan3 = document.getElementById("plan3"); li_plan3.style.display = "block"; document.getElementById("plan1_planCode").value = planCodesJSON[0]; //为隐藏的planCode标签赋值 document.getElementById("plan1_planCName").value = planCNamesJSON[0]; //为隐藏的planCName标签赋值 document.getElementById("plan2_planCode").value = planCodesJSON[1]; //为隐藏的planCode标签赋值 document.getElementById("plan2_planCName").value = planCNamesJSON[1]; //为隐藏的planCName标签赋值 document.getElementById("plan3_planCode").value = planCodesJSON[2]; //为隐藏的planCode标签赋值 document.getElementById("plan3_planCName").value = planCNamesJSON[2]; //为隐藏的planCName标签赋值 document.getElementById("default_planCode").value = planCodesJSON[1]; //为隐藏的default_planCode标签赋值 var li_plan1 = document.getElementById("plan1"); var ul = li_plan1.getElementsByTagName("ul")[0]; var liList = ul.getElementsByTagName("li"); liList[0].innerHTML = planCNamesJSON[0]; for(var i=1; i < prpDitemKindBenefitDtos1JSON.length - 1; i++ ){ liList[i].innerHTML = prpDitemKindBenefitDtos1JSON[i - 1]; } liList[liList.length-1].innerHTML = priceListJSON[0] + "元"; //plan2的显示方式比较特殊 var li_plan2 = document.getElementById("plan2"); var ul = li_plan2.getElementsByTagName("ul")[0]; var liList = ul.getElementsByTagName("li"); for(var i=0; i < liList.length; i++ ){ //删掉ul下面所有的li标签 ul.removeChild(liList[i]); } for(var i=0; i < prpDitemKindBenefitDtos2JSON.length+2; i++ ){ //创建24/28个li标签 var htmlLi = document.createElement("li"); ul.appendChild(htmlLi); } liList = ul.getElementsByTagName("li"); liList[0].innerHTML = planCNamesJSON[1]; for(var i=1; i <= prpDitemKindBenefitDtos2JSON.length; i++ ){ //为所有的li赋值 liList[i].innerHTML = prpDitemKindBenefitDtos2JSON[i - 1]; } liList[liList.length-1].innerHTML = priceListJSON[1] + "元"; //plan3的显示方式比较特殊 var li_plan3 = document.getElementById("plan3"); var ul = li_plan3.getElementsByTagName("ul")[0]; var liList = ul.getElementsByTagName("li"); for(var i=0; i < liList.length; i++ ){ //删掉ul下面所有的li标签 ul.removeChild(liList[i]); } for(var i=0; i < prpDitemKindBenefitDtos3JSON.length+2; i++ ){ //创建24/28个li标签 var htmlLi = document.createElement("li"); ul.appendChild(htmlLi); } liList = ul.getElementsByTagName("li"); liList[0].innerHTML = planCNamesJSON[1]; for(var i=1; i <= prpDitemKindBenefitDtos3JSON.length; i++ ){ //为所有的li赋值 liList[i].innerHTML = prpDitemKindBenefitDtos3JSON[i - 1]; } liList[liList.length-1].innerHTML = priceListJSON[2] + "元"; fillUnitPremiumAndSumPremium("plan2"); } //alert("priceList="+priceList); //fillUnitPremiumAndSumPremium("plan1"); //为总保费赋值,此时需要乘以人数 }, error: function(jsonData) { //alert(eval(jsonData)); //alert("获取产品价格失败!"); } }); } } }; //传一个中文参数进来,获得国家中文名对应的缩写或者regionCode function findEn(citySelect) { // 付给一个 city变量 var city = Vcity.allCity; // 拆分字符串为一个数组 for ( var i = 0; i < city.length; i++) { var cityDom = city[i]; //再拆分数据后 判断其第一个元素 与 参数相等后,返回第二个元素 if (cityDom.split('|')[0] == citySelect) { return cityDom.split('|')[2]; } } }
3. 后台ACTION代码:
package com.sinosoft.b2c.propertyInsurance.accident.common.plan.ui.control.action; import java.io.PrintWriter; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Calendar; import java.util.Collection; import java.util.Date; import java.util.GregorianCalendar; import java.util.List; import java.util.Map; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import net.sf.json.JSONArray; import net.sf.json.JSONObject; import com.sinosoft.admin.productConfig.propertyInsurance.bl.facade.domain.BLPrpDitemKindBenefitFacade; import com.sinosoft.admin.productConfig.propertyInsurance.bl.facade.domain.BLPrpDkindFacade; import com.sinosoft.admin.productConfig.propertyInsurance.bl.facade.domain.BLPrpDregionFacade; import com.sinosoft.admin.productConfig.propertyInsurance.bl.facade.domain.BLPrpDriskPlanFacade; import com.sinosoft.admin.productConfig.propertyInsurance.bl.facade.domain.BLPrpProductDregionFacade; import com.sinosoft.admin.productConfig.propertyInsurance.dto.domain.PrpDitemKindBenefitDto; import com.sinosoft.admin.productConfig.propertyInsurance.dto.domain.PrpDkindDto; import com.sinosoft.admin.productConfig.propertyInsurance.dto.domain.PrpDregionDto; import com.sinosoft.admin.productConfig.propertyInsurance.dto.domain.PrpDriskPlanDto; import com.sinosoft.admin.productConfig.propertyInsurance.dto.domain.PrpProductDregionDto; import com.sinosoft.b2c.propertyInsurance.accident.common.plan.dto.custom.ProductBenefitInfo; import com.sinosoft.b2c.propertyInsurance.accident.common.plan.dto.custom.ProductBenefitKindNameAndPlanName; import com.sinosoft.b2c.propertyInsurance.accident.common.plan.interfaces.anlian.webservice.dto.RequestPricingDto; import com.sinosoft.b2c.propertyInsurance.accident.common.plan.interfaces.anlian.webservice.dto.TravelDto; import com.sinosoft.b2c.propertyInsurance.accident.common.plan.interfaces.anlian.webservice.impl.RiskPlanPrimiumImpl; import com.sinosoft.sysframework.common.util.SqlUtils; import com.sinosoft.sysframework.web.control.BaseProcessAction; public class UIPlanAction extends BaseProcessAction { public static int daysBetween(String startDate,String endDate) throws ParseException{ SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd"); Calendar cal = Calendar.getInstance(); cal.setTime(sdf.parse(startDate)); long time1 = cal.getTimeInMillis(); cal.setTime(sdf.parse(endDate)); long time2 = cal.getTimeInMillis(); long between_days=(time2-time1)/(1000*3600*24); return Integer.parseInt(String.valueOf(between_days)); } public void query(HttpServletRequest request, HttpServletResponse response) throws Exception { String pageRiskCode = request.getParameter("riskCode"); String methodType = request.getParameter("methodType"); //判断是否是ajax请求 response.setContentType("text/html;charset=UTF-8"); BLPrpDriskPlanFacade blPrpDriskPlanFacade = new BLPrpDriskPlanFacade(); BLPrpProductDregionFacade blPrpProductDregionFacade = new BLPrpProductDregionFacade(); BLPrpDitemKindBenefitFacade prpDitemKindBenefitFacade = new BLPrpDitemKindBenefitFacade(); //if判断中代码主要让"快速报价"方式能够进入到 "28"对应的方法中 if("".equals(pageRiskCode) || null == pageRiskCode){ String pageDestination = request.getParameter("destination"); //获得“快速报价”传来的目的地缩写 //通过地域代码:regionCode(也就是国家缩写)在PrpProductRegion表中得到riskCode List<PrpProductDregionDto> prpProductDregionDtoList = (List<PrpProductDregionDto>) blPrpProductDregionFacade.findByConditions(" regioncode ='" +pageDestination+"'" ); pageRiskCode = prpProductDregionDtoList.get(0).getRiskCode(); } String riskPlanConditions = "1=1"; riskPlanConditions += SqlUtils.convertString("PrpDriskPlan.riskCode",pageRiskCode); List<PrpDriskPlanDto> prpdRiskPlanDtos = (List<PrpDriskPlanDto>) blPrpDriskPlanFacade.findByConditions(riskPlanConditions); String classCode = prpdRiskPlanDtos.get(0).getClassCode(); /*途径一:通过"产品详情页面"进入“方案报价页面”*/ //留学生险才能进入到此方法中 if ("29".equals(classCode)){ String pageStartDate = request.getParameter("startDate"); String pageEndDate = request.getParameter("endDate"); String studentRiskCode = request.getParameter("riskCode"); //AJAX方法传递的“是否高风险”字段值 String isHighRisk = request.getParameter("isHighRisk"); // if("2902".equals(studentRiskCode)){ // isHighRisk = "highRisk"; // } if(isHighRisk != null && !("".equals(isHighRisk))){ //通过isHighRisk是否有值来确定是从“方案报价”页面通过ajax方式进入到此方法中 if(isHighRisk.equals("notHighRisk")){ studentRiskCode = "2901"; //留学生旅游险(不含高风险) }else{ studentRiskCode = "2902"; //留学生旅游险(含高风险) } } String prpdriskplanConditions = "1=1"; prpdriskplanConditions += SqlUtils.convertString("PrpDRiskPlan.riskCode",studentRiskCode); prpdriskplanConditions += " ORDER BY SerialNo asc"; //通过riskCode在prpdriskplan表中得到其所对应的三个planCode : TAP001,TAPOO2,TAP003 List<PrpDriskPlanDto> prpDriskPlanDtos = (List<PrpDriskPlanDto>) blPrpDriskPlanFacade.findByConditions(prpdriskplanConditions); ArrayList<String> planCodes = new ArrayList<String>(); ArrayList<String> planCNames = new ArrayList<String>(); String planCode; //完成功能后,需要优化 String planCName; //完成功能后,需要优化 for(int i = 0; i < prpDriskPlanDtos.size(); i++){ planCode = prpDriskPlanDtos.get(i).getPlanCode(); planCName = prpDriskPlanDtos.get(i).getPlanCName(); planCodes.add(planCode); planCNames.add(planCName); } //得到plan1的benefit说明的dtos String conditions1 = "1=1"; conditions1 += SqlUtils.convertString("PrpDitemKindBenefit.riskCode",studentRiskCode); conditions1 += SqlUtils.convertString("PrpDitemKindBenefit.planCode",planCodes.get(0)); conditions1 += " ORDER BY KindCode asc"; List<PrpDitemKindBenefitDto> prpDitemKindBenefitDtos1 = (List<PrpDitemKindBenefitDto>) prpDitemKindBenefitFacade.findByConditions(conditions1); //在PrpDKind表中查找benefit大类的名称 String DKindconditions = "1=1"; DKindconditions += SqlUtils.convertString("PrpDKind.mainOrAdditionalFlag","mainrisk"); DKindconditions += " ORDER BY KindCode asc"; BLPrpDkindFacade blPrpDkindFacade = new BLPrpDkindFacade(); List<PrpDkindDto> prpDkindDtos = (List<PrpDkindDto>) blPrpDkindFacade.findByConditions(DKindconditions); String maxKindCode = prpDitemKindBenefitDtos1.get(prpDitemKindBenefitDtos1.size() - 1).getKindCode(); maxKindCode = maxKindCode.substring(0, maxKindCode.indexOf(".")); ArrayList<String> productKindNames = new ArrayList<String>(); //为“方案报价页面”benefit大类循环提供数据 if(maxKindCode.equals("6")){ for (int i = 0; i < 5; i++) { productKindNames.add(i, prpDkindDtos.get(i).getKindCName()); } } //得到plan2的benefit说明的dtos List<PrpDitemKindBenefitDto> prpDitemKindBenefitDtos2 = new ArrayList<PrpDitemKindBenefitDto>(); if(planCodes.size() == 2){ String conditions2 = "1=1"; conditions2 += SqlUtils.convertString("PrpDitemKindBenefit.riskCode",studentRiskCode); conditions2 += SqlUtils.convertString("PrpDitemKindBenefit.planCode",planCodes.get(1)); conditions2 += " ORDER BY KindCode asc"; prpDitemKindBenefitDtos2 = (ArrayList<PrpDitemKindBenefitDto>) prpDitemKindBenefitFacade.findByConditions(conditions2); } /*===========================调用报价接口开始(没有目的地国家,没有开始日期和结束日期)================================== */ //在这里调用"报价接口":需要的参数[目的地国家缩写regionCode,开始时间(没有默认当前日期),结束时间(当前日期+4天),planCode1,planCode2,planCode3] //String interfaceConditions = "1=1"; //interfaceConditions += SqlUtils.convertString("PrpProductDregion.riskCode",studentRiskCode); //List<PrpProductDregionDto> PrpProductDregionDtoList = (List<PrpProductDregionDto>) blPrpProductDregionFacade.findByConditions(interfaceConditions); //A:得到riskCode所对多个国家中的第一个regionCode只为报价接口使用 String regionCode = "US"; //B.为出发日期和回城日期赋值 if(pageStartDate == null && pageEndDate == null){ SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); GregorianCalendar calendar = new GregorianCalendar(); calendar.setTime(new Date()); calendar.add(5, 1); // 5表示“天”,1表示增加1天(不能为当天) pageStartDate = dateFormat.format(calendar.getTime()); calendar.add(5, 3); // 5表示“天”,3表示增加3天 pageEndDate = dateFormat.format(calendar.getTime()); //C:返程日期赋值 } //C:获得3个planCode组成集合 // if(isHighRisk != null && "highRisk".equals(isHighRisk)){ // planCodes.add("highRisk"); // } RiskPlanPrimiumImpl impl = new RiskPlanPrimiumImpl(); TravelDto travelDto = new TravelDto(); travelDto.setDestinationLocation(regionCode); travelDto.setStartDate(pageStartDate); travelDto.setEndDate(pageEndDate); travelDto.setOriginLocation("CN");//默认为CN RequestPricingDto requestPricingDto = new RequestPricingDto(); requestPricingDto.setTravelDescription(travelDto); Map priceMap = impl.getRiskPlanPrimium(planCodes, requestPricingDto); ArrayList<String> priceList = new ArrayList<String>(); for(int i=0;i<planCodes.size();i++){ priceList.add(String.valueOf(priceMap.get(planCodes.get(i)))); } JSONObject bigJSONObject = new JSONObject(); ArrayList<String> prpDitemKindBenefitStrings1 = new ArrayList<String>(); ArrayList<String> prpDitemKindBenefitStrings2 = new ArrayList<String>(); if(planCodes.size() == 1 && "ajax".equals(methodType)){ for (PrpDitemKindBenefitDto prpDitemKindBenefitDto : prpDitemKindBenefitDtos1) { prpDitemKindBenefitStrings1.add(prpDitemKindBenefitDto.getInstructions()); } JSONArray prpDitemKindBenefitDtos1JSON = JSONArray.fromObject(prpDitemKindBenefitStrings1); JSONArray priceListJSON = JSONArray.fromObject(priceList); JSONArray planCNamesJSON = JSONArray.fromObject(planCNames); JSONArray planCodesJSON = JSONArray.fromObject(planCodes); bigJSONObject.put("priceListJSON", priceListJSON); bigJSONObject.put("planCNamesJSON", planCNamesJSON); bigJSONObject.put("planCodesJSON", planCodesJSON); bigJSONObject.put("plan1", prpDitemKindBenefitDtos1JSON); System.out.println("planCNamesJSON jsonArray =====>"+planCNamesJSON.toString()); System.out.println("priceListJSON jsonArray =====>"+priceListJSON.toString()); System.out.println("plan1 jsonArray =====>"+prpDitemKindBenefitDtos1JSON.toString()); PrintWriter printWriter = response.getWriter(); printWriter.write(bigJSONObject.toString()); printWriter.flush(); request.setAttribute("riskCode", studentRiskCode); }else if(planCodes.size() == 2 && "ajax".equals(methodType)){ for (PrpDitemKindBenefitDto prpDitemKindBenefitDto : prpDitemKindBenefitDtos1) { prpDitemKindBenefitStrings1.add(prpDitemKindBenefitDto.getInstructions()); } for (PrpDitemKindBenefitDto prpDitemKindBenefitDto : prpDitemKindBenefitDtos2) { prpDitemKindBenefitStrings2.add(prpDitemKindBenefitDto.getInstructions()); } JSONArray prpDitemKindBenefitDtos1JSON = JSONArray.fromObject(prpDitemKindBenefitStrings1); JSONArray prpDitemKindBenefitDtos2JSON = JSONArray.fromObject(prpDitemKindBenefitStrings2); JSONArray priceListJSON = JSONArray.fromObject(priceList); JSONArray planCNamesJSON = JSONArray.fromObject(planCNames); JSONArray planCodesJSON = JSONArray.fromObject(planCodes); bigJSONObject.put("priceListJSON", priceListJSON); bigJSONObject.put("planCNamesJSON", planCNamesJSON); bigJSONObject.put("planCodesJSON", planCodesJSON); bigJSONObject.put("plan1", prpDitemKindBenefitDtos1JSON); bigJSONObject.put("plan2", prpDitemKindBenefitDtos2JSON); System.out.println("planCNamesJSON jsonArray =====>"+planCNamesJSON.toString()); System.out.println("priceListJSON jsonArray =====>"+priceListJSON.toString()); System.out.println("plan1 jsonArray =====>"+prpDitemKindBenefitDtos1JSON.toString()); System.out.println("plan2 jsonArray =====>"+prpDitemKindBenefitDtos2JSON.toString()); PrintWriter printWriter = response.getWriter(); printWriter.write(bigJSONObject.toString()); printWriter.flush(); request.setAttribute("riskCode", studentRiskCode); } else { request.setAttribute("isHighRisk", isHighRisk); request.setAttribute("priceList", priceList); request.setAttribute("riskCode", studentRiskCode); request.setAttribute("startDate", pageStartDate); request.setAttribute("endDate", pageEndDate); request.setAttribute("periodDays", daysBetween(pageStartDate, pageEndDate)+1); request.setAttribute("planCodes", planCodes); request.setAttribute("planCodeSize", planCodes.size()); request.setAttribute("planCNames", planCNames); request.setAttribute("planCName", planCNames.get(1)); //防止用户直接点击"立即投保"而为planCName赋初始值 request.setAttribute("planCode", planCodes.get(1)); //防止用户直接点击"立即投保"而为planCode赋初始值 request.setAttribute("unitPremium", priceList.get(1)); //防止用户直接点击"立即投保"而为unitPremium(每份保费)赋初始值 request.setAttribute("productKindNames", productKindNames); request.setAttribute("prpDitemKindBenefitDtos1", prpDitemKindBenefitDtos1); request.setAttribute("prpDitemKindBenefitDtos2", prpDitemKindBenefitDtos2); } } //========================================================================================================================================================== //========================================================================================================================================================== /*途径二:获取通过"快速报价页面"进入‘方案报价页面’所传递的数据*/ //旅游险才能进入到此方法中 if ("28".equals(classCode)){ //获取快速报价旅行目的地的缩写也就是regionCode String pageDestination = request.getParameter("destination"); String quickRiskCode = request.getParameter("riskCode"); String destinationCName = request.getParameter("destinationCName"); //获取快速报价出发日期 String pageStartDate = request.getParameter("startDate"); //获取快速报价回程日期 String pageEndDate = request.getParameter("endDate"); //获取快速报价手机号 String pagePhoneNumber = request.getParameter("phoneNumber"); //AJAX方法传递的“是否高风险”字段值 String isHighRisk = request.getParameter("isHighRisk"); String planCName = request.getParameter("planCName");//不知道是干啥的????? ArrayList<String> planCodes = new ArrayList<String>(); ArrayList<String> planCNames = new ArrayList<String>(); ArrayList<String> productKindNames = new ArrayList<String>(); //为“方案报价页面”benefit大类中文名提供数据 if(pageDestination != null && !("".equals(pageDestination))){ //有目的地缩写,就要用目的地缩写去得到RiskCode //通过地域代码:regionCode(也就是国家缩写)在PrPProductRegion表中得到riskCode List<PrpProductDregionDto> prpProductDregionDtoList = (List<PrpProductDregionDto>) blPrpProductDregionFacade.findByConditions(" regioncode ='" +pageDestination+"'" ); quickRiskCode = prpProductDregionDtoList.get(0).getRiskCode(); } if(pageStartDate == null && pageEndDate == null){ SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); GregorianCalendar calendar = new GregorianCalendar(); calendar.setTime(new Date()); calendar.add(5, 1); // 5表示“天”,1表示增加1天(不能为当天) pageStartDate = dateFormat.format(calendar.getTime()); calendar.add(5, 3); // 5表示“天”,3表示增加3天 pageEndDate = dateFormat.format(calendar.getTime()); //C:返程日期赋值 } //通过riskCode在prpdriskplan表中得到其所对应的三个planCode : TAP001,TAPOO2,TAP003 String prpdriskplanConditions = "1=1"; prpdriskplanConditions += SqlUtils.convertString("PrpDRiskPlan.riskCode",quickRiskCode); prpdriskplanConditions += " ORDER BY SerialNo asc"; List<PrpDriskPlanDto> prpDriskPlanDtos = (List<PrpDriskPlanDto>) blPrpDriskPlanFacade.findByConditions(prpdriskplanConditions); String planCode; //完成功能后,需要优化 // String planCName; //完成功能后,需要优化 for(int i = 0; i < prpDriskPlanDtos.size(); i++){ planCode = prpDriskPlanDtos.get(i).getPlanCode(); planCName = prpDriskPlanDtos.get(i).getPlanCName(); planCodes.add(planCode); planCNames.add(planCName); } //得到plan1的benefit说明的dtos String conditions1 = "1=1"; conditions1 += SqlUtils.convertString("PrpDitemKindBenefit.riskCode",quickRiskCode); conditions1 += SqlUtils.convertString("PrpDitemKindBenefit.planCode",planCodes.get(0)); conditions1 += " ORDER BY KindCode asc"; List<PrpDitemKindBenefitDto> prpDitemKindBenefitDtos1 = (List<PrpDitemKindBenefitDto>) prpDitemKindBenefitFacade.findByConditions(conditions1); //在PrpDKind表中查找benefit大类的中文名称 存入到===> productKindNames String DKindconditions = "1=1"; DKindconditions += SqlUtils.convertString("PrpDKind.mainOrAdditionalFlag","mainrisk"); DKindconditions += " ORDER BY KindCode asc"; BLPrpDkindFacade blPrpDkindFacade = new BLPrpDkindFacade(); List<PrpDkindDto> prpDkindDtos = (List<PrpDkindDto>) blPrpDkindFacade.findByConditions(DKindconditions); String maxKindCode = prpDitemKindBenefitDtos1.get(prpDitemKindBenefitDtos1.size() - 1).getKindCode(); maxKindCode = maxKindCode.substring(0, maxKindCode.indexOf(".")); if(maxKindCode.equals("5")){ String kindCName; PrpDkindDto dto; for (int i = 0; i < 5; i++) { dto = prpDkindDtos.get(i); kindCName = dto.getKindCName(); productKindNames.add(i, kindCName); } }else if(maxKindCode.equals("6")){ for (int i = 0; i < 5; i++) { productKindNames.add(i, prpDkindDtos.get(i).getKindCName()); } } //得到plan2的benefit说明的dtos List<PrpDitemKindBenefitDto> prpDitemKindBenefitDtos2 = new ArrayList<PrpDitemKindBenefitDto>(); List<PrpDitemKindBenefitDto> prpDitemKindBenefitDtos3 = new ArrayList<PrpDitemKindBenefitDto>(); if(planCodes.size() == 2){ String conditions2 = "1=1"; conditions2 += SqlUtils.convertString("PrpDitemKindBenefit.riskCode",quickRiskCode); conditions2 += SqlUtils.convertString("PrpDitemKindBenefit.planCode",planCodes.get(1)); conditions2 += " ORDER BY KindCode asc"; prpDitemKindBenefitDtos2 = (ArrayList<PrpDitemKindBenefitDto>) prpDitemKindBenefitFacade.findByConditions(conditions2); } //得到plan3的benefit说明的dtos if(planCodes.size() >= 3){ String conditions2 = "1=1"; conditions2 += SqlUtils.convertString("PrpDitemKindBenefit.riskCode",quickRiskCode); conditions2 += SqlUtils.convertString("PrpDitemKindBenefit.planCode",planCodes.get(1)); conditions2 += " ORDER BY KindCode asc"; prpDitemKindBenefitDtos2 = (ArrayList<PrpDitemKindBenefitDto>) prpDitemKindBenefitFacade.findByConditions(conditions2); String conditions3 = "1=1"; conditions3 += SqlUtils.convertString("PrpDitemKindBenefit.riskCode",quickRiskCode); conditions3 += SqlUtils.convertString("PrpDitemKindBenefit.planCode",planCodes.get(2)); conditions3 += " ORDER BY KindCode asc"; prpDitemKindBenefitDtos3 = (ArrayList<PrpDitemKindBenefitDto>) prpDitemKindBenefitFacade.findByConditions(conditions3); } /*===========================调用报价接口开始================================== */ //在这里调用"报价接口":需要的参数[目的地国家缩写regionCode,开始时间,结束时间,planCode1,planCode2,planCode3] if(isHighRisk != null && "highRisk".equals(isHighRisk)){ planCodes.add("highRisk"); } RiskPlanPrimiumImpl impl = new RiskPlanPrimiumImpl(); TravelDto travelDto = new TravelDto(); travelDto.setDestinationLocation(pageDestination); travelDto.setStartDate(pageStartDate); travelDto.setEndDate(pageEndDate); travelDto.setOriginLocation("CN");//默认为CN RequestPricingDto requestPricingDto = new RequestPricingDto(); requestPricingDto.setTravelDescription(travelDto); Map priceMap = impl.getRiskPlanPrimium(planCodes, requestPricingDto); ArrayList<String> priceList = new ArrayList<String>(); for(int i=0;i<planCodes.size();i++){ priceList.add(String.valueOf(priceMap.get(planCodes.get(i)))); } JSONObject bigJSONObject = new JSONObject(); ArrayList<String> prpDitemKindBenefitStrings1 = new ArrayList<String>(); ArrayList<String> prpDitemKindBenefitStrings2 = new ArrayList<String>(); ArrayList<String> prpDitemKindBenefitStrings3 = new ArrayList<String>(); if(planCodes.size() == 1 && "ajax".equals(methodType)){ for (PrpDitemKindBenefitDto prpDitemKindBenefitDto : prpDitemKindBenefitDtos1) { prpDitemKindBenefitStrings1.add(prpDitemKindBenefitDto.getInstructions()); } JSONArray prpDitemKindBenefitDtos1JSON = JSONArray.fromObject(prpDitemKindBenefitStrings1); JSONArray priceListJSON = JSONArray.fromObject(priceList); JSONArray planCNamesJSON = JSONArray.fromObject(planCNames); JSONArray planCodesJSON = JSONArray.fromObject(planCodes); bigJSONObject.put("priceListJSON", priceListJSON); bigJSONObject.put("planCNamesJSON", planCNamesJSON); bigJSONObject.put("planCodesJSON", planCodesJSON); bigJSONObject.put("plan1", prpDitemKindBenefitDtos1JSON); System.out.println("planCNamesJSON jsonArray =====>"+planCNamesJSON.toString()); System.out.println("priceListJSON jsonArray =====>"+priceListJSON.toString()); System.out.println("plan1 jsonArray =====>"+prpDitemKindBenefitDtos1JSON.toString()); PrintWriter printWriter = response.getWriter(); printWriter.write(bigJSONObject.toString()); printWriter.flush(); request.setAttribute("riskCode", quickRiskCode); }else if(planCodes.size() == 2 && "ajax".equals(methodType)){ for (PrpDitemKindBenefitDto prpDitemKindBenefitDto : prpDitemKindBenefitDtos1) { prpDitemKindBenefitStrings1.add(prpDitemKindBenefitDto.getInstructions()); } for (PrpDitemKindBenefitDto prpDitemKindBenefitDto : prpDitemKindBenefitDtos2) { prpDitemKindBenefitStrings2.add(prpDitemKindBenefitDto.getInstructions()); } JSONArray prpDitemKindBenefitDtos1JSON = JSONArray.fromObject(prpDitemKindBenefitStrings1); JSONArray prpDitemKindBenefitDtos2JSON = JSONArray.fromObject(prpDitemKindBenefitStrings2); JSONArray priceListJSON = JSONArray.fromObject(priceList); JSONArray planCNamesJSON = JSONArray.fromObject(planCNames); JSONArray planCodesJSON = JSONArray.fromObject(planCodes); bigJSONObject.put("priceListJSON", priceListJSON); bigJSONObject.put("planCNamesJSON", planCNamesJSON); bigJSONObject.put("planCodesJSON", planCodesJSON); bigJSONObject.put("plan1", prpDitemKindBenefitDtos1JSON); bigJSONObject.put("plan2", prpDitemKindBenefitDtos2JSON); System.out.println("planCNamesJSON jsonArray =====>"+planCNamesJSON.toString()); System.out.println("priceListJSON jsonArray =====>"+priceListJSON.toString()); System.out.println("plan1 jsonArray =====>"+prpDitemKindBenefitDtos1JSON.toString()); System.out.println("plan2 jsonArray =====>"+prpDitemKindBenefitDtos2JSON.toString()); PrintWriter printWriter = response.getWriter(); printWriter.write(bigJSONObject.toString()); printWriter.flush(); request.setAttribute("riskCode", quickRiskCode); }else if(planCodes.size() >= 3 && "ajax".equals(methodType)){ for (PrpDitemKindBenefitDto prpDitemKindBenefitDto : prpDitemKindBenefitDtos1) { prpDitemKindBenefitStrings1.add(prpDitemKindBenefitDto.getInstructions()); } for (PrpDitemKindBenefitDto prpDitemKindBenefitDto : prpDitemKindBenefitDtos2) { prpDitemKindBenefitStrings2.add(prpDitemKindBenefitDto.getInstructions()); } for (PrpDitemKindBenefitDto prpDitemKindBenefitDto : prpDitemKindBenefitDtos3) { prpDitemKindBenefitStrings3.add(prpDitemKindBenefitDto.getInstructions()); } JSONArray prpDitemKindBenefitDtos1JSON = JSONArray.fromObject(prpDitemKindBenefitStrings1); JSONArray prpDitemKindBenefitDtos2JSON = JSONArray.fromObject(prpDitemKindBenefitStrings2); JSONArray prpDitemKindBenefitDtos3JSON = JSONArray.fromObject(prpDitemKindBenefitStrings3); JSONArray priceListJSON = JSONArray.fromObject(priceList); JSONArray planCNamesJSON = JSONArray.fromObject(planCNames); JSONArray planCodesJSON = JSONArray.fromObject(planCodes); bigJSONObject.put("priceListJSON", priceListJSON); bigJSONObject.put("planCNamesJSON", planCNamesJSON); bigJSONObject.put("planCodesJSON", planCodesJSON); bigJSONObject.put("plan1", prpDitemKindBenefitDtos1JSON); bigJSONObject.put("plan2", prpDitemKindBenefitDtos2JSON); bigJSONObject.put("plan3", prpDitemKindBenefitDtos3JSON); System.out.println("bigJSONObject jsonArray =====>"+bigJSONObject.toString()); System.out.println("planCNamesJSON jsonArray =====>"+planCNamesJSON.toString()); System.out.println("priceListJSON jsonArray =====>"+priceListJSON.toString()); System.out.println("plan1 jsonArray =====>"+prpDitemKindBenefitDtos1JSON.toString()); System.out.println("plan2 jsonArray =====>"+prpDitemKindBenefitDtos2JSON.toString()); System.out.println("plan3 jsonArray =====>"+prpDitemKindBenefitDtos3JSON.toString()); PrintWriter printWriter = response.getWriter(); printWriter.print(bigJSONObject.toString()); printWriter.flush(); request.setAttribute("riskCode", quickRiskCode); }else{ /*---------------将‘快速报价页面’填写的值传递到‘方案报价页’(开始)--------------------*/ request.setAttribute("destination", pageDestination); //‘填写投保信息’需要国家所写,防止用户直接点击'立即投保' request.setAttribute("destinationCName", destinationCName); //为旅行目的地赋值 request.setAttribute("startDate", pageStartDate); request.setAttribute("endDate", pageEndDate); request.setAttribute("phoneNumber", pagePhoneNumber); request.setAttribute("planCName", planCName); //为"填写投保信息页"传递客户选择的plan名称 /*---------------将‘快速报价页面’填写的值传递到‘方案报价页’(结束)--------------------*/ request.setAttribute("priceList", priceList); request.setAttribute("riskCode", quickRiskCode); request.setAttribute("periodDays", daysBetween(pageStartDate, pageEndDate)+1); request.setAttribute("planCodes", planCodes); request.setAttribute("planCodeSize", planCodes.size()); request.setAttribute("planCNames", planCNames); request.setAttribute("planCName", planCNames.get(1)); //防止用户直接点击"立即投保"而为planCName赋初始值 request.setAttribute("planCode", planCodes.get(1)); //防止用户直接点击"立即投保"而为planCode赋初始值 request.setAttribute("unitPremium", priceList.get(1)); //防止用户直接点击"立即投保"而为unitPremium(每份保费)赋初始值 request.setAttribute("productKindNames", productKindNames); request.setAttribute("prpDitemKindBenefitDtos1", prpDitemKindBenefitDtos1); request.setAttribute("prpDitemKindBenefitDtos2", prpDitemKindBenefitDtos2); request.setAttribute("prpDitemKindBenefitDtos3", prpDitemKindBenefitDtos3); } } //====================================================================================================================================================== //====================================================================================================================================================== if ("30".equals(classCode)){ //获取快速报价旅行目的地的缩写也就是regionCode String pageDestination = request.getParameter("destination"); String oldRiskCode = request.getParameter("riskCode"); String destinationCName = request.getParameter("destinationCName"); //获取快速报价出发日期 String pageStartDate = request.getParameter("startDate"); //获取快速报价回程日期 String pageEndDate = request.getParameter("endDate"); //获取快速报价手机号 String pagePhoneNumber = request.getParameter("phoneNumber"); //AJAX方法传递的“是否高风险”字段值 String isHighRisk = request.getParameter("isHighRisk"); String planCName = request.getParameter("planCName");//不知道是干啥的????? ArrayList<String> planCodes = new ArrayList<String>(); ArrayList<String> planCNames = new ArrayList<String>(); ArrayList<String> oldRiskCodes = new ArrayList<String>(); ArrayList<String> productKindNames = new ArrayList<String>(); //为“方案报价页面”benefit大类中文名提供数据 if(pageStartDate == null && pageEndDate == null){ SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); GregorianCalendar calendar = new GregorianCalendar(); calendar.setTime(new Date()); calendar.add(5, 1); // 5表示“天”,1表示增加1天(不能为当天) pageStartDate = dateFormat.format(calendar.getTime()); calendar.add(5, 3); // 5表示“天”,3表示增加3天 pageEndDate = dateFormat.format(calendar.getTime()); //C:返程日期赋值 } if(methodType == null || "".equals(methodType)){ //通过"产品详情页面"进入到"报价页面"时,用riskCode在prpdriskplan表中得到其所对应的一个planCode : TAP001 String prpdriskplanConditions = "1=1"; prpdriskplanConditions += SqlUtils.convertString("PrpDRiskPlan.riskCode",oldRiskCode); prpdriskplanConditions += " ORDER BY SerialNo asc"; List<PrpDriskPlanDto> prpDriskPlanDtos = (List<PrpDriskPlanDto>) blPrpDriskPlanFacade.findByConditions(prpdriskplanConditions); oldRiskCodes.add(oldRiskCode); String planCode; //完成功能后,需要优化 // String planCName; //完成功能后,需要优化 for(int i = 0; i < prpDriskPlanDtos.size(); i++){ planCode = prpDriskPlanDtos.get(i).getPlanCode(); planCName = prpDriskPlanDtos.get(i).getPlanCName(); planCodes.add(planCode); planCNames.add(planCName); } }else{ String Conditions = "1=1"; Conditions += SqlUtils.convertString("PrpProductDregion.ClassCode","30"); Conditions += SqlUtils.convertString("PrpProductDregion.RegionCode",pageDestination); List<PrpProductDregionDto> prpProductDregionDtoList = (List<PrpProductDregionDto>) blPrpProductDregionFacade.findByConditions(Conditions); List<PrpDriskPlanDto> prpDriskPlanDtos = new ArrayList<PrpDriskPlanDto>(); for (int i=0; i< prpProductDregionDtoList.size();i++) { oldRiskCodes.add(prpProductDregionDtoList.get(i).getRiskCode()); String prpdriskplanConditions = "1=1"; prpdriskplanConditions += SqlUtils.convertString("PrpDRiskPlan.riskCode",oldRiskCodes.get(i)); prpdriskplanConditions += " ORDER BY SerialNo asc"; prpDriskPlanDtos = (List<PrpDriskPlanDto>) blPrpDriskPlanFacade.findByConditions(prpdriskplanConditions); planCodes.add(prpDriskPlanDtos.get(0).getPlanCode()); planCNames.add(prpDriskPlanDtos.get(0).getPlanCName()); } } //得到plan1的benefit说明的dtos String conditions1 = "1=1"; conditions1 += SqlUtils.convertString("PrpDitemKindBenefit.riskCode",oldRiskCodes.get(0)); conditions1 += SqlUtils.convertString("PrpDitemKindBenefit.planCode",planCodes.get(0)); conditions1 += " ORDER BY KindCode asc"; List<PrpDitemKindBenefitDto> prpDitemKindBenefitDtos1 = (List<PrpDitemKindBenefitDto>) prpDitemKindBenefitFacade.findByConditions(conditions1); //在PrpDKind表中查找benefit大类的中文名称 存入到===> productKindNames String DKindconditions = "1=1"; DKindconditions += SqlUtils.convertString("PrpDKind.mainOrAdditionalFlag","mainrisk"); DKindconditions += " ORDER BY KindCode asc"; BLPrpDkindFacade blPrpDkindFacade = new BLPrpDkindFacade(); List<PrpDkindDto> prpDkindDtos = (List<PrpDkindDto>) blPrpDkindFacade.findByConditions(DKindconditions); String maxKindCode = prpDitemKindBenefitDtos1.get(prpDitemKindBenefitDtos1.size() - 1).getKindCode(); maxKindCode = maxKindCode.substring(0, maxKindCode.indexOf(".")); if(maxKindCode.equals("5")){ String kindCName; PrpDkindDto dto; for (int i = 0; i < 5; i++) { dto = prpDkindDtos.get(i); kindCName = dto.getKindCName(); productKindNames.add(i, kindCName); } }else if(maxKindCode.equals("6")){ for (int i = 0; i < 6; i++) { productKindNames.add(i, prpDkindDtos.get(i).getKindCName()); } } //得到plan2的benefit说明的dtos List<PrpDitemKindBenefitDto> prpDitemKindBenefitDtos2 = new ArrayList<PrpDitemKindBenefitDto>(); List<PrpDitemKindBenefitDto> prpDitemKindBenefitDtos3 = new ArrayList<PrpDitemKindBenefitDto>(); if(oldRiskCodes.size() == 2){ String conditions2 = "1=1"; conditions2 += SqlUtils.convertString("PrpDitemKindBenefit.riskCode",oldRiskCodes.get(1)); conditions2 += SqlUtils.convertString("PrpDitemKindBenefit.planCode",planCodes.get(1)); conditions2 += " ORDER BY KindCode asc"; prpDitemKindBenefitDtos2 = (ArrayList<PrpDitemKindBenefitDto>) prpDitemKindBenefitFacade.findByConditions(conditions2); } //得到plan3的benefit说明的dtos if(oldRiskCodes.size() >= 3){ String conditions2 = "1=1"; conditions2 += SqlUtils.convertString("PrpDitemKindBenefit.riskCode",oldRiskCodes.get(1)); conditions2 += SqlUtils.convertString("PrpDitemKindBenefit.planCode",planCodes.get(1)); conditions2 += " ORDER BY KindCode asc"; prpDitemKindBenefitDtos2 = (ArrayList<PrpDitemKindBenefitDto>) prpDitemKindBenefitFacade.findByConditions(conditions2); String conditions3 = "1=1"; conditions3 += SqlUtils.convertString("PrpDitemKindBenefit.riskCode",oldRiskCodes.get(2)); conditions3 += SqlUtils.convertString("PrpDitemKindBenefit.planCode",planCodes.get(2)); conditions3 += " ORDER BY KindCode asc"; prpDitemKindBenefitDtos3 = (ArrayList<PrpDitemKindBenefitDto>) prpDitemKindBenefitFacade.findByConditions(conditions3); } /*===========================调用报价接口开始================================== */ //在这里调用"报价接口":需要的参数[目的地国家缩写regionCode,开始时间,结束时间,planCode1,planCode2,planCode3] if(isHighRisk != null && "highRisk".equals(isHighRisk)){ planCodes.add("highRisk"); } RiskPlanPrimiumImpl impl = new RiskPlanPrimiumImpl(); TravelDto travelDto = new TravelDto(); travelDto.setDestinationLocation(pageDestination); travelDto.setStartDate(pageStartDate); travelDto.setEndDate(pageEndDate); travelDto.setOriginLocation("CN");//默认为CN RequestPricingDto requestPricingDto = new RequestPricingDto(); requestPricingDto.setTravelDescription(travelDto); Map priceMap = impl.getRiskPlanPrimium(planCodes, requestPricingDto); ArrayList<String> priceList = new ArrayList<String>(); for(int i=0;i<planCodes.size();i++){ priceList.add(String.valueOf(priceMap.get(planCodes.get(i)))); } JSONObject bigJSONObject = new JSONObject(); ArrayList<String> prpDitemKindBenefitStrings1 = new ArrayList<String>(); ArrayList<String> prpDitemKindBenefitStrings2 = new ArrayList<String>(); ArrayList<String> prpDitemKindBenefitStrings3 = new ArrayList<String>(); if(oldRiskCodes.size() == 1 && "ajax".equals(methodType)){ for (PrpDitemKindBenefitDto prpDitemKindBenefitDto : prpDitemKindBenefitDtos1) { prpDitemKindBenefitStrings1.add(prpDitemKindBenefitDto.getInstructions()); } JSONArray prpDitemKindBenefitDtos1JSON = JSONArray.fromObject(prpDitemKindBenefitStrings1); JSONArray priceListJSON = JSONArray.fromObject(priceList); JSONArray planCNamesJSON = JSONArray.fromObject(planCNames); JSONArray planCodesJSON = JSONArray.fromObject(planCodes); bigJSONObject.put("priceListJSON", priceListJSON); bigJSONObject.put("planCNamesJSON", planCNamesJSON); bigJSONObject.put("planCodesJSON", planCodesJSON); bigJSONObject.put("plan1", prpDitemKindBenefitDtos1JSON); System.out.println("planCNamesJSON jsonArray =====>"+planCNamesJSON.toString()); System.out.println("priceListJSON jsonArray =====>"+priceListJSON.toString()); System.out.println("plan1 jsonArray =====>"+prpDitemKindBenefitDtos1JSON.toString()); PrintWriter printWriter = response.getWriter(); printWriter.write(bigJSONObject.toString()); printWriter.flush(); request.setAttribute("riskCode", oldRiskCode); }else if(oldRiskCodes.size() == 2 && "ajax".equals(methodType)){ for (PrpDitemKindBenefitDto prpDitemKindBenefitDto : prpDitemKindBenefitDtos1) { prpDitemKindBenefitStrings1.add(prpDitemKindBenefitDto.getInstructions()); } for (PrpDitemKindBenefitDto prpDitemKindBenefitDto : prpDitemKindBenefitDtos2) { prpDitemKindBenefitStrings2.add(prpDitemKindBenefitDto.getInstructions()); } JSONArray prpDitemKindBenefitDtos1JSON = JSONArray.fromObject(prpDitemKindBenefitStrings1); JSONArray prpDitemKindBenefitDtos2JSON = JSONArray.fromObject(prpDitemKindBenefitStrings2); JSONArray priceListJSON = JSONArray.fromObject(priceList); JSONArray planCNamesJSON = JSONArray.fromObject(planCNames); JSONArray planCodesJSON = JSONArray.fromObject(planCodes); bigJSONObject.put("priceListJSON", priceListJSON); bigJSONObject.put("planCNamesJSON", planCNamesJSON); bigJSONObject.put("planCodesJSON", planCodesJSON); bigJSONObject.put("plan1", prpDitemKindBenefitDtos1JSON); bigJSONObject.put("plan2", prpDitemKindBenefitDtos2JSON); System.out.println("planCNamesJSON jsonArray =====>"+planCNamesJSON.toString()); System.out.println("priceListJSON jsonArray =====>"+priceListJSON.toString()); System.out.println("plan1 jsonArray =====>"+prpDitemKindBenefitDtos1JSON.toString()); System.out.println("plan2 jsonArray =====>"+prpDitemKindBenefitDtos2JSON.toString()); PrintWriter printWriter = response.getWriter(); printWriter.write(bigJSONObject.toString()); printWriter.flush(); request.setAttribute("riskCode", oldRiskCode); }else if(oldRiskCodes.size() == 3 && "ajax".equals(methodType)){ for (PrpDitemKindBenefitDto prpDitemKindBenefitDto : prpDitemKindBenefitDtos1) { prpDitemKindBenefitStrings1.add(prpDitemKindBenefitDto.getInstructions()); } for (PrpDitemKindBenefitDto prpDitemKindBenefitDto : prpDitemKindBenefitDtos2) { prpDitemKindBenefitStrings2.add(prpDitemKindBenefitDto.getInstructions()); } for (PrpDitemKindBenefitDto prpDitemKindBenefitDto : prpDitemKindBenefitDtos3) { prpDitemKindBenefitStrings3.add(prpDitemKindBenefitDto.getInstructions()); } JSONArray prpDitemKindBenefitDtos1JSON = JSONArray.fromObject(prpDitemKindBenefitStrings1); JSONArray prpDitemKindBenefitDtos2JSON = JSONArray.fromObject(prpDitemKindBenefitStrings2); JSONArray prpDitemKindBenefitDtos3JSON = JSONArray.fromObject(prpDitemKindBenefitStrings3); JSONArray priceListJSON = JSONArray.fromObject(priceList); JSONArray planCNamesJSON = JSONArray.fromObject(planCNames); JSONArray planCodesJSON = JSONArray.fromObject(planCodes); bigJSONObject.put("priceListJSON", priceListJSON); bigJSONObject.put("planCNamesJSON", planCNamesJSON); bigJSONObject.put("planCodesJSON", planCodesJSON); bigJSONObject.put("plan1", prpDitemKindBenefitDtos1JSON); bigJSONObject.put("plan2", prpDitemKindBenefitDtos2JSON); bigJSONObject.put("plan3", prpDitemKindBenefitDtos3JSON); System.out.println("bigJSONObject jsonArray =====>"+bigJSONObject.toString()); System.out.println("planCNamesJSON jsonArray =====>"+planCNamesJSON.toString()); System.out.println("priceListJSON jsonArray =====>"+priceListJSON.toString()); System.out.println("plan1 jsonArray =====>"+prpDitemKindBenefitDtos1JSON.toString()); System.out.println("plan2 jsonArray =====>"+prpDitemKindBenefitDtos2JSON.toString()); System.out.println("plan3 jsonArray =====>"+prpDitemKindBenefitDtos3JSON.toString()); PrintWriter printWriter = response.getWriter(); printWriter.print(bigJSONObject.toString()); printWriter.flush(); request.setAttribute("riskCode", oldRiskCode); }else{ /*---------------将‘快速报价页面’填写的值传递到‘方案报价页’(开始)--------------------*/ request.setAttribute("destination", pageDestination); //‘填写投保信息’需要国家所写,防止用户直接点击'立即投保' request.setAttribute("destinationCName", destinationCName); //为旅行目的地赋值 request.setAttribute("startDate", pageStartDate); request.setAttribute("endDate", pageEndDate); request.setAttribute("phoneNumber", pagePhoneNumber); request.setAttribute("planCName", planCName); //为"填写投保信息页"传递客户选择的plan名称 /*---------------将‘快速报价页面’填写的值传递到‘方案报价页’(结束)--------------------*/ request.setAttribute("priceList", priceList); request.setAttribute("riskCode", oldRiskCode); request.setAttribute("periodDays", daysBetween(pageStartDate, pageEndDate)+1); request.setAttribute("planCodes", planCodes); request.setAttribute("planCodeSize", planCodes.size()); request.setAttribute("planCNames", planCNames); request.setAttribute("planCName", planCNames.get(0)); //防止用户直接点击"立即投保"而为planCName赋初始值(注意:老年人险从"产品详情页面"进入只显示一款plan) request.setAttribute("planCode", planCodes.get(0)); //防止用户直接点击"立即投保"而为planCode赋初始值 request.setAttribute("unitPremium", priceList.get(0)); //防止用户直接点击"立即投保"而为unitPremium(每份保费)赋初始值 request.setAttribute("productKindNames", productKindNames); request.setAttribute("prpDitemKindBenefitDtos1", prpDitemKindBenefitDtos1); request.setAttribute("prpDitemKindBenefitDtos2", prpDitemKindBenefitDtos2); request.setAttribute("prpDitemKindBenefitDtos3", prpDitemKindBenefitDtos3); } } } public void checkDestination(HttpServletRequest request, HttpServletResponse response) throws Exception { String destination = request.getParameter("destination"); BLPrpDregionFacade blPrpDregionFacade = new BLPrpDregionFacade(); String conditions = "1=1"; // conditions += "AND (lower(agentCode) like '%"+fieldValue.toLowerCase()+"%' or lower(agentName) like '%"+fieldValue.toLowerCase()+"%')"; // 1=1 AND (prpDregion.regionCName = '荷属安地列斯群岛') conditions += "AND (prpDregion.regionCName like '%"+ destination +"%')"; List<PrpDregionDto> prpDregionList = (List<PrpDregionDto>) blPrpDregionFacade.findByConditions(conditions); if(prpDregionList.size() == 0){ PrintWriter printWriter = response.getWriter(); printWriter.write("no"); printWriter.flush(); } } }