3f42f4e7eb80aec789279ad6fab89d6005fcc63a.svn-base 37 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067
  1. package com.chinacreator.videoalliance.order.service;
  2. import java.net.URLEncoder;
  3. import java.sql.SQLException;
  4. import java.text.ParseException;
  5. import java.text.SimpleDateFormat;
  6. import java.util.*;
  7. import com.chinacreator.common.exception.BusinessException;
  8. import com.chinacreator.common.util.DESUtil;
  9. import com.chinacreator.common.util.MD5;
  10. import com.chinacreator.common.util.URLUtil;
  11. import com.chinacreator.common.util.UsermobUtil;
  12. import com.chinacreator.videoalliance.common.bean.AreaInfo;
  13. import com.chinacreator.videoalliance.common.dao.DictionaryDao;
  14. import com.chinacreator.videoalliance.common.util.AreaUtil;
  15. import com.chinacreator.videoalliance.common.util.ConfigUtil;
  16. import com.chinacreator.videoalliance.order.bean.*;
  17. import com.chinacreator.videoalliance.order.dao.BackBusiOrderDao;
  18. import com.chinacreator.videoalliance.order.dao.BackShareOrderDao;
  19. import com.chinacreator.videoalliance.order.dao.BlackWhiteDao;
  20. import com.chinacreator.videoalliance.order.dao.OrderDao;
  21. import com.chinacreator.videoalliance.order.dao.SPDao;
  22. import com.chinacreator.videoalliance.order.util.JsonUtil;
  23. import org.apache.commons.lang.math.NumberUtils;
  24. import org.apache.commons.lang.time.DateFormatUtils;
  25. import org.apache.commons.lang.time.DateUtils;
  26. import org.apache.log4j.Logger;
  27. import org.springframework.beans.factory.annotation.Autowired;
  28. import org.springframework.stereotype.Component;
  29. import org.springframework.util.StringUtils;
  30. /**
  31. * 后向产品服务类
  32. * @author xu.zhou
  33. * @date 20190705
  34. */
  35. @Component
  36. public class BackBusiOrderService {
  37. private static Logger log = Logger.getLogger("orderError");
  38. private static Logger logger = Logger.getLogger(BackBusiOrderService.class);
  39. private static Logger busilog = Logger.getLogger("youtuorder");
  40. @Autowired
  41. private BlackWhiteDao blackWhiteDao;
  42. @Autowired
  43. private SPDao spDao;
  44. @Autowired
  45. private DictionaryDao dictionaryDao;
  46. @Autowired
  47. private BackBusiOrderDao backBusiOrderDao;
  48. @Autowired
  49. private ShareOrderService shareOrderService;
  50. @Autowired
  51. private BackShareOrderDao backShareOrderDao;
  52. @Autowired
  53. private OrderDao orderDao;
  54. /**
  55. * 验证及解密手机号码
  56. * @param orderInfo
  57. * @throws Exception
  58. */
  59. private void checkUserid(OrderInfo orderInfo) throws Exception {
  60. String userid = orderInfo.getUserid();
  61. if ((StringUtils.isEmpty(userid)) || ("null".equals(userid)))
  62. throw new BusinessException("9051", "手机号码无效", new String[0]);
  63. if (!isValid(userid)) {
  64. if(userid.length() >10){
  65. userid = ConfigUtil.decrypt(userid, orderInfo.getCpid());
  66. userid = ConfigUtil.getUserid(userid, orderInfo.getCpid());
  67. }
  68. }
  69. if (isValid(userid)) {
  70. if(userid.length() < 11){//QQ号
  71. if(!org.apache.commons.lang.StringUtils.equals("TX20_twback_old", orderInfo.getChannel())&&!org.apache.commons.lang.StringUtils.equals("TX20_twback", orderInfo.getChannel())){
  72. throw new BusinessException("9051", "手机号码无效", new String[0]);
  73. }
  74. }
  75. }else{
  76. throw new BusinessException("9051", "手机号码无效", new String[0]);
  77. }
  78. orderInfo.setUserid(userid);
  79. }
  80. /**
  81. * 支持QQ号与手机号
  82. * zzb 2020/02/18
  83. * @throws BusinessException
  84. */
  85. private boolean isValid(String usermob) throws BusinessException{
  86. if (usermob == null) {
  87. return false;
  88. }
  89. usermob = usermob.replaceAll("[\\s-]", "");
  90. if(!usermob.matches("^[0-9]*$")){
  91. return false;
  92. }
  93. return true;
  94. }
  95. /**
  96. * 验证签名是否有效
  97. * @param orderInfo
  98. * @param deuserid 加密的手机号码
  99. * @throws Exception
  100. */
  101. public void checkSignChannel(OrderInfo orderInfo, String deuserid) throws Exception {
  102. String sign = orderInfo.getSignature();
  103. if (StringUtils.isEmpty(sign)) {
  104. throw new BusinessException("9054", "signature校验失败");
  105. }
  106. Map cpSpBean = backBusiOrderDao.getCpSp(orderInfo.getCpid(),orderInfo.getSpid());
  107. String pwd = cpSpBean.get("NETPWD").toString();
  108. //Md5(orderid+cpid+spid+userid+type+timestamp+pwd)
  109. String localSign = MD5.MD5Encode(orderInfo.getOrderid() + orderInfo.getCpid()
  110. + orderInfo.getSpid() + deuserid + orderInfo.getTimestamp() + pwd);
  111. if (!localSign.equals(orderInfo.getSignature())) {
  112. throw new BusinessException("9054", "signature校验失败");
  113. }
  114. }
  115. /**
  116. * 订购前验证
  117. * @param orderInfo
  118. * @throws Exception
  119. */
  120. public void checkOrder(OrderInfo orderInfo, String deuserid) throws Exception {
  121. checkCpSpInfo(orderInfo);
  122. checkSignChannel(orderInfo,deuserid);
  123. checkUserid(orderInfo);
  124. String userid = orderInfo.getUserid();
  125. //判断用户黑名单
  126. if (this.blackWhiteDao.isBlackUser(userid, orderInfo.getCpid())) {
  127. throw new BusinessException("9010", "用户为黑名单用户", new String[0]);
  128. }
  129. //获取地市信息
  130. AreaInfo areaInfo = getAreaInfo(userid);
  131. orderInfo.setProvince(areaInfo.getProvince());
  132. orderInfo.setArea(areaInfo.getArea());
  133. if(orderInfo.getProvince() != null && orderDao.isOpen(orderInfo.getSpid(),orderInfo.getCpid(),orderInfo.getProvince())){ // status 为2 表示省份尚未开通
  134. if(!this.blackWhiteDao.isWhiteUserBySpid(userid, orderInfo.getCpid(), orderInfo.getSpid())){//判断用户是否白名单,是则流程继续
  135. throw new BusinessException("9011", "省份尚未开通此业务,敬请期待!");
  136. }
  137. }
  138. }
  139. /**
  140. * 验证业务参数是否合法
  141. * @param orderInfo
  142. * @throws Exception
  143. */
  144. private void checkCpSpInfo(OrderInfo orderInfo)throws Exception {
  145. List<HashMap> confList = backBusiOrderDao.getBackBusiConf(orderInfo.getCpid(), orderInfo.getSpid());
  146. if(confList == null || confList.size() == 0){
  147. throw new BusinessException("9058", "无业务配置信息", new String[0]);
  148. }
  149. HashMap confHm = confList.get(0);
  150. //判断是否配置netdays参数
  151. if(("2".equals(confHm.get("BUSITYPE")) || "3".equals(confHm.get("BUSITYPE")))
  152. && (confHm.get("NETDAYS") == null || "".equals(confHm.get("NETDAYS")))){
  153. throw new BusinessException("9058", "无业务配置信息,NETDAYS", new String[0]);
  154. }
  155. getSPInfo(orderInfo); //设置SP其他信息
  156. }
  157. /**
  158. * 获取手机号码的地市信息
  159. * @param userid
  160. * @return
  161. * @throws Exception
  162. */
  163. private AreaInfo getAreaInfo(String userid) throws Exception {
  164. AreaInfo areaInfo = AreaUtil.getAreaInfoByUserid(userid);
  165. if (areaInfo == null) {
  166. areaInfo = new AreaInfo();
  167. }
  168. return areaInfo;
  169. }
  170. /**
  171. * 设置SP相关信息
  172. * @param orderInfo
  173. * @throws Exception
  174. */
  175. private void getSPInfo(OrderInfo orderInfo) throws Exception {
  176. SPInfo spInfo = this.spDao.findById(orderInfo.getSpid());
  177. if (spInfo != null) {
  178. orderInfo.setSpid(spInfo.getSpid());
  179. orderInfo.setMutex(spInfo.getMutex());
  180. orderInfo.setRelationSp(spInfo.getRelationSp());
  181. orderInfo.setPaytype(spInfo.getPaytype());
  182. orderInfo.setErrorhandle(spInfo.getErrorhandle());
  183. }
  184. }
  185. /**
  186. * 填充BackBusiOrderRec
  187. * @param orderInfo
  188. * @return
  189. * @throws Exception
  190. */
  191. private BackBusiOrderRec getOrderRecBean(OrderInfo orderInfo) throws Exception{
  192. BackBusiOrderRec bean = new BackBusiOrderRec();
  193. bean.setLogid(orderInfo.getReorderid());
  194. bean.setId(backBusiOrderDao.generateID());
  195. bean.setArea(orderInfo.getArea());
  196. bean.setCpid(orderInfo.getCpid());
  197. bean.setSpid(orderInfo.getSpid());
  198. bean.setOrderid(orderInfo.getOrderid());
  199. bean.setProvince(orderInfo.getProvince());
  200. bean.setUserid(orderInfo.getUserid());
  201. bean.setChannel(orderInfo.getOrderchannel());
  202. bean.setVipstatus("4"); //默认设置为不赠送
  203. bean.setType(orderInfo.getType()+"");
  204. if("1".equals(bean.getType())){//退订
  205. bean.setVipstatus(""); //设置为空
  206. }
  207. return bean;
  208. }
  209. /**
  210. * 是否赠送会员重试
  211. * @param orderInfo
  212. * @return
  213. */
  214. public boolean hasVipRetry(OrderInfo orderInfo)throws Exception{
  215. boolean result = false;
  216. List<BackBusiOrderRec> list = backBusiOrderDao.findOrderRecByOrderid(orderInfo.getOrderid());
  217. if(list != null && list.size() > 0){
  218. BackBusiOrderRec orderBean = list.get(0);
  219. //判断是否符合重试条件
  220. if(orderBean.getOrderid().equals(orderInfo.getOrderid())
  221. && orderBean.getUserid().equals(orderInfo.getUserid())
  222. && orderBean.getCpid().equals(orderInfo.getCpid())
  223. && orderBean.getSpid().equals(orderInfo.getSpid())
  224. && "5".equals(orderBean.getVipstatus())
  225. && !"2".equals(orderBean.getBusitype()) //不是纯免流,
  226. ){ //符合重试条件
  227. result = true;
  228. }
  229. //拓维渠道为TX20_twback办理会员+免流产品业务,会员是自己领取,不触发会员重试
  230. if(result && "3".equals(orderBean.getBusitype()) && "TX20_twback".equals(orderInfo.getOrderchannel())){
  231. result = false;
  232. }
  233. }
  234. return result;
  235. }
  236. /**
  237. * 重试会员赠送
  238. * @param orderInfo
  239. * @return
  240. * @throws Exception
  241. */
  242. public String vipRetryBusi(OrderInfo orderInfo)throws Exception{
  243. String errorcode = "-1";
  244. String errorinfo = "";
  245. String result = "-1";
  246. BackBusiOrderRec orderBean = backBusiOrderDao.findOrderRecByOrderid(orderInfo.getOrderid()).get(0);
  247. try {
  248. //判断重试时间是否大于订购记录时间2分钟以上,防止并发请求
  249. if(!backBusiOrderDao.getMinNum(orderBean.getInserttime(),2)){
  250. throw new BusinessException("9073", "重试时间与订购时间相差小于2分钟");
  251. }
  252. //非首次重试
  253. if(orderBean.getRetrytime() != null && !"".equals(orderBean.getRetrytime())){
  254. if(!backBusiOrderDao.getMinNum(orderBean.getInserttime(),2)){
  255. throw new BusinessException("9073", "重试频繁,请稍候再试");
  256. }
  257. }
  258. orderInfo.setType(0); //设置为订购
  259. //判断业务互斥
  260. this.hasMutual(orderInfo); //已办理互斥业务
  261. //获取业务结束时间
  262. String newEndtime = this.getEndTime(orderInfo);
  263. //赠送会员状态,0成功,1待赠送,2赠送中,3失败,4不赠送,5返回9070,7重试失败
  264. orderBean.setVipstatus("2");
  265. //办理结果编码,0成功,1待处理,2处理中,其他为异常
  266. orderBean.setResultcode("2");
  267. orderBean.setResultinfo("重试中");
  268. backBusiOrderDao.updBusiStatus(orderBean.getVipstatus(),orderBean.getResultcode(),orderBean.getResultcode(),orderBean.getId()); //添加订购记录
  269. String sendVipRes = sendVip(orderInfo); //赠送会员
  270. if("9070".equals(sendVipRes)){
  271. orderBean.setVipstatus("5"); //赠送超时
  272. throw new BusinessException("9070","赠送会员超时", new String[0]);
  273. }
  274. //小毛会更新vipstatus值,不以接口返回的为准
  275. sendVipRes = backBusiOrderDao.getVipstatus(orderInfo.getOrderid());
  276. if("0".equals(sendVipRes)){//赠送成功
  277. if("3".equals(orderBean.getBusitype())){
  278. String currtime = backBusiOrderDao.getCurrentTime();
  279. orderInfo.setEndtime(newEndtime);
  280. orderInfo.setOrdertime(currtime);
  281. orderInfo.setEffecttime(currtime);
  282. orderBean.setVipstatus("0");
  283. backBusiOrderDao.order(orderInfo); //新增或更新订购关系
  284. }
  285. }else{
  286. orderBean.setVipstatus("7");
  287. throw new BusinessException("9002","赠送会员未成功", new String[0]);
  288. }
  289. result = "0";
  290. errorcode = "0";
  291. errorinfo = "重试成功";
  292. } catch (Exception e) {
  293. e.printStackTrace();
  294. log.error("userid:"+orderInfo.getUserid()+"订购出现异常,"+e);
  295. if ((e instanceof BusinessException)) {
  296. errorcode = ((BusinessException) e).getCode();
  297. errorinfo = ((BusinessException) e).getMessage();
  298. }else{
  299. errorcode = "8000";
  300. errorinfo ="系统忙,"+e.getMessage();
  301. }
  302. if(errorinfo!=null&&errorinfo.length()>2000){
  303. errorinfo = errorinfo.substring(0, 2000);
  304. }
  305. throw e;
  306. } finally {
  307. if(!"9073".equals(errorcode)){
  308. orderBean.setResultcode(errorcode);
  309. orderBean.setResultinfo(errorinfo);
  310. orderBean.setRetrychannel("1");
  311. orderBean.setRetrycount(Integer.parseInt(orderBean.getRetrycount())+1+"");
  312. backBusiOrderDao.updOrderRecByVipRetry(orderBean); //更新重试记录
  313. saveLog(orderInfo, errorcode, errorinfo);
  314. }
  315. }
  316. return result;
  317. }
  318. /**
  319. * 获取endtime
  320. * @param orderInfo
  321. * @return
  322. */
  323. private String getEndTime(OrderInfo orderInfo)throws Exception{
  324. String endtime = "";
  325. String currEndtime = "";
  326. Map reMap = this.hasEffect(orderInfo);
  327. if((Boolean)reMap.get("hasEffect")){ //存在有效订购关系
  328. Map currOrderInfo = (Map)reMap.get("currOrderInfo");
  329. currEndtime = (String)currOrderInfo.get("ENDTIME");
  330. }
  331. //[{PWD=kijkfds, NETDAYS=31, CHANNEL=test_01, NETDAYS=2, SPID=1168, BUSITYPE=3, CPID=youtu}]
  332. HashMap confHm = backBusiOrderDao.getBackBusiConf(orderInfo.getCpid(), orderInfo.getSpid()).get(0);
  333. //String busiType = confHm.get("BUSITYPE")+"";
  334. //免流或免流+会员两种产品要以netdays参数来确定endtime
  335. if("2".equals(confHm.get("BUSITYPE")) || "3".equals(confHm.get("BUSITYPE"))){
  336. if(currEndtime != null && !"".equals(currEndtime)){
  337. endtime = backBusiOrderDao.endtimeParamDay(confHm.get("NETDAYS")+"", currEndtime);
  338. }else{
  339. endtime = backBusiOrderDao.currParamDay(confHm.get("NETDAYS")+"");
  340. }
  341. }
  342. return endtime;
  343. }
  344. /**
  345. * 业务办理
  346. * @param orderInfo
  347. * @return
  348. * @throws Exception
  349. */
  350. public String orderBusi(OrderInfo orderInfo)throws Exception{
  351. //只有SPID为1168,TYPE为1,reorderid不为空时才走退订流程,只有天猫平台的优酷后台可以退订
  352. if("1168".equals(orderInfo.getSpid()) && orderInfo.getType() == 1 && !StringUtils.isEmpty(orderInfo.getReorderid()) && "youtu_pc01".equals(orderInfo.getOrderchannel())){
  353. orderInfo.setStatus(1);
  354. //return this.cancel(orderInfo);
  355. throw new BusinessException("8000", "暂不提供退订操作", new String[0]);
  356. }else{
  357. orderInfo.setType(0); ////设置为订购
  358. return this.order(orderInfo);
  359. }
  360. }
  361. /**
  362. * 判断结束时间是否大于当前时间
  363. * @param endTime
  364. * @param currTime
  365. * @return
  366. * @throws Exception
  367. */
  368. private boolean compareDate(String endTime, String currTime)throws Exception{
  369. boolean result = false;
  370. SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
  371. Date dateCurrTime = sdf.parse(currTime);
  372. Date dateEndTime = sdf.parse(endTime);
  373. //dateEndTime小于dateCurrTime返回-1,dateEndTime大于dateCurrTime返回1,相等返回0
  374. if(dateEndTime.compareTo(dateCurrTime)>0){
  375. result = true;
  376. }
  377. return result;
  378. }
  379. /**
  380. * 订购业务
  381. * @param orderInfo
  382. * @return
  383. */
  384. public String cancel(OrderInfo orderInfo)throws Exception{
  385. String errorcode = "-1";
  386. String errorinfo = "";
  387. String result = "-1";
  388. BackBusiOrderRec bean = getOrderRecBean(orderInfo);
  389. try{
  390. //判断订购时的订单是否有效
  391. List<BackBusiOrderRec> list = backBusiOrderDao.findOrderRecByOrderid(orderInfo.getReorderid());
  392. if(list != null && list.size() > 0){
  393. boolean secceed = false; //是否有办理成功的订购操作
  394. for(BackBusiOrderRec tmpBean : list){
  395. if("0".equals(tmpBean.getResultcode()) && "0".equals(tmpBean.getType())){
  396. secceed = true;
  397. break;
  398. }
  399. }
  400. //不是办理成功的订购的操作
  401. if(!secceed){
  402. throw new BusinessException("9017", "订购订单号无有效订购关系", new String[0]);
  403. }
  404. }else{
  405. throw new BusinessException("9018", "订购订单号无记录", new String[0]);
  406. }
  407. this.hasDupliOrderid(orderInfo);//判断是否重复订单ID
  408. //{SPID=1168, ID=201907231006328670420, ENDTIME=20200903235959, STATUS=0, ORDERTIME=20190729184037, CPID=youtu, USERID=18673197465}
  409. Map currOrder = backBusiOrderDao.findYoutuOrderRal(bean);
  410. if(currOrder == null || currOrder.size() == 0){
  411. throw new BusinessException("9016", "退订失败,无该用户订购关系或者已失效", new String[0]);
  412. }
  413. String newEndtime = backBusiOrderDao.endtimeMinus31Day(currOrder.get("ENDTIME")+"");
  414. String currtime = backBusiOrderDao.getCurrentTime();
  415. //判断结束时间是否大于当前时间
  416. if(!this.compareDate(newEndtime, currtime)){
  417. newEndtime = currtime; //结束时间小于或等于当前时间
  418. }
  419. orderInfo.setEndtime(newEndtime);
  420. //退订
  421. backBusiOrderDao.cancel(orderInfo);
  422. result = "0";
  423. errorcode = "0";
  424. errorinfo = "成功";
  425. }catch(Exception e){
  426. e.printStackTrace();
  427. log.error("userid:"+orderInfo.getUserid()+"订购出现异常,"+e);
  428. if ((e instanceof BusinessException)) {
  429. errorcode = ((BusinessException) e).getCode();
  430. errorinfo = ((BusinessException) e).getMessage();
  431. }else{
  432. errorcode = "8000";
  433. errorinfo ="系统忙,"+e.getMessage();
  434. }
  435. if(errorinfo!=null&&errorinfo.length()>2000){
  436. errorinfo = errorinfo.substring(0, 2000);
  437. }
  438. throw e;
  439. }finally{
  440. bean.setResultcode(errorcode);
  441. bean.setResultinfo(errorinfo);
  442. if(bean.getResultinfo().indexOf("重复订单") == -1){
  443. backBusiOrderDao.addOrderRec(bean); //添加订购记录
  444. }
  445. saveLog(orderInfo, errorcode, errorinfo);
  446. }
  447. return result;
  448. }
  449. /**
  450. * 订购业务
  451. * @param orderInfo
  452. * @return
  453. */
  454. public String order(OrderInfo orderInfo)throws Exception{
  455. String errorcode = "-1";
  456. String errorinfo = "";
  457. String result = "-1";
  458. String shareErcode = "0";
  459. String shareErnfo = "成功";
  460. BackBusiOrderRec bean = getOrderRecBean(orderInfo);
  461. try {
  462. orderInfo.setType(0); //设置为订购
  463. List<HashMap> confList = backBusiOrderDao.getBackBusiConf(orderInfo.getCpid(), orderInfo.getSpid());
  464. //[{PWD=kijkfds, CHANNEL=test_01, VIPTYPE=2, VIPPOOL=vip_yout, SPID=1168, BUSITYPE=3, CPID=youtu}]
  465. HashMap confHm = confList.get(0);
  466. String busiType = confHm.get("BUSITYPE")+"";
  467. //是否为复合产品,0是,为空或为1时不是
  468. String hasfh = confHm.get("HASFH") == null ? "": confHm.get("HASFH")+"";
  469. //调能力平台标识:0调能力平台并以结果落订购关系,1调能力平台其结果不影响订购关系,为空时不调能力平台
  470. String hasshare = confHm.get("HASSHARE") == null ? "": confHm.get("HASSHARE")+"";
  471. bean.setBusitype(busiType);
  472. this.hasDupliOrderid(orderInfo);//判断是否重复订单ID
  473. this.hasMutual(orderInfo); //已办理互斥业务
  474. String newEndtime = ""; //业务结束时间
  475. String starttime = ""; //业务开始时间
  476. Map<String, String> resMap = this.getBusiTime(orderInfo);
  477. newEndtime = resMap.get("endtime");
  478. starttime = resMap.get("starttime");
  479. //赠送会员状态,0成功,1待赠送,2赠送中,3失败,4不赠送,5赠送超时9070
  480. bean.setVipstatus("2");
  481. //办理结果编码,0成功,1待处理,2处理中,其他为异常
  482. bean.setResultcode("2");
  483. bean.setResultinfo("处理中");
  484. if("1".equals(busiType)){ //会员
  485. bean.setStarttime("");
  486. bean.setEndtime("");
  487. backBusiOrderDao.addOrderRec(bean); //添加订购记录
  488. String sendVipRes = sendVip(orderInfo); //赠送会员
  489. if("9070".equals(sendVipRes)){
  490. bean.setVipstatus("5"); //赠送超时
  491. throw new BusinessException("9070","赠送会员超时", new String[0]);
  492. }
  493. if("0".equals(hasfh)){//是复合产品
  494. this.fhsendvipRes(sendVipRes, bean);
  495. }else{
  496. //小毛会更新vipstatus值,不以接口返回的为准,小毛只有赠送成功或明确赠送失败的才会把vipstatus改为0或3
  497. sendVipRes = backBusiOrderDao.getVipstatus(orderInfo.getOrderid());
  498. if("3".equals(sendVipRes)){//赠送失败
  499. bean.setVipstatus("3");
  500. throw new BusinessException("9002","赠送会员未成功", new String[0]);
  501. }else if("0".equals(sendVipRes)){ //赠送成功
  502. bean.setVipstatus("0");
  503. }else{ //其他当作9070处理
  504. bean.setVipstatus("5"); //赠送超时
  505. throw new BusinessException("9070","赠送会员超时", new String[0]);
  506. }
  507. }
  508. }else if("2".equals(busiType)){ //免流
  509. /****
  510. if("200".equals(orderInfo.getSpid())){
  511. List<OrderInfo> orderlist = orderDao.findByUser(orderInfo.getUserid(),orderInfo.getCpid());
  512. if(orderlist.size()>0 && orderInfo != null){
  513. List<String> spidlist = new ArrayList<String>();
  514. for(OrderInfo oi : orderlist){
  515. String spid = oi.getSpid();
  516. spidlist.add(spid);
  517. }
  518. if(spidlist.contains("979")){
  519. }else{
  520. throw new BusinessException("8051","您未订购相应的产品,不能办理此加油包");
  521. }
  522. }else{
  523. throw new BusinessException("8051","您未订购相应的产品,不能办理此加油包");
  524. }
  525. }
  526. if("201".equals(orderInfo.getSpid())){
  527. List<OrderInfo> orderlist = orderDao.findByUser(orderInfo.getUserid(),orderInfo.getCpid());
  528. if(orderlist.size()>0 && orderInfo != null){
  529. List<String> spidlist = new ArrayList<String>();
  530. for(OrderInfo oi : orderlist){
  531. String spid = oi.getSpid();
  532. spidlist.add(spid);
  533. }
  534. if(spidlist.contains("1018") || spidlist.contains("1017")){
  535. }else{
  536. throw new BusinessException("8051","您未订购相应的产品,不能办理此加油包");
  537. }
  538. }else{
  539. throw new BusinessException("8051","您未订购相应的产品,不能办理此加油包");
  540. }
  541. }
  542. ****/
  543. bean.setVipstatus("4"); //设置为不赠送
  544. bean.setStarttime(starttime);
  545. bean.setEndtime(newEndtime);
  546. backBusiOrderDao.addOrderRec(bean); //添加订购记录
  547. orderInfo.setEndtime(newEndtime);
  548. //设置订购时间
  549. this.setOrderTime(orderInfo);
  550. //调能力平台
  551. this.shareOrder(orderInfo, hasshare);
  552. backBusiOrderDao.order(orderInfo); //新增或更新订购关系
  553. }else if("3".equals(busiType)){ //会员+免流
  554. bean.setEndtime(newEndtime);
  555. bean.setStarttime(starttime);
  556. if("TX20_twback".equals(orderInfo.getOrderchannel())){//拓维订购会员+免流业务
  557. bean.setResultcode("1");
  558. bean.setResultinfo("处理中");
  559. bean.setVipendtime(newEndtime); //设置领取会员的最后时间,默认为订单的endtime
  560. backBusiOrderDao.addOrderRec(bean); //添加订购记录
  561. orderInfo.setEndtime(newEndtime);
  562. //设置订购时间
  563. this.setOrderTime(orderInfo);
  564. bean.setVipstatus("1"); //设置为待赠送,由拓维发短信给用户,由用户自己去领取
  565. //调能力平台
  566. this.shareOrder(orderInfo, hasshare);
  567. backBusiOrderDao.order(orderInfo); //新增或更新订购关系
  568. //更新其他未领取会员的最后领取时间
  569. backBusiOrderDao.updVipEndtime(bean.getUserid(),newEndtime);
  570. }else{
  571. backBusiOrderDao.addOrderRec(bean); //添加订购记录
  572. String sendVipRes = sendVip(orderInfo); //赠送会员
  573. if("9070".equals(sendVipRes)){
  574. bean.setVipstatus("5"); //赠送超时
  575. throw new BusinessException("9070","赠送会员超时", new String[0]);
  576. }
  577. if("0".equals(hasfh)){//是复合产品
  578. orderInfo.setEndtime(newEndtime);
  579. //设置订购时间
  580. this.setOrderTime(orderInfo);
  581. //复合产品赠送会员小毛不会更新后向订购记录表td_backbusi_order_rec的vipstatus记录。
  582. this.fhsendvipRes(sendVipRes, bean);
  583. //调能力平台
  584. this.shareOrder(orderInfo, hasshare);
  585. backBusiOrderDao.order(orderInfo); //新增或更新订购关系
  586. }else{
  587. //小毛会更新vipstatus值,不以接口返回的为准,小毛只有赠送成功或明确赠送失败的才会把vipstatus改为0或3
  588. sendVipRes = backBusiOrderDao.getVipstatus(orderInfo.getOrderid());
  589. if("0".equals(sendVipRes)){//赠送成功
  590. orderInfo.setEndtime(newEndtime);
  591. //设置订购时间
  592. this.setOrderTime(orderInfo);
  593. bean.setVipstatus("0");
  594. //调能力平台
  595. this.shareOrder(orderInfo, hasshare);
  596. backBusiOrderDao.order(orderInfo); //新增或更新订购关系
  597. }else if("3".equals(sendVipRes)){//赠送失败
  598. bean.setVipstatus("3");
  599. throw new BusinessException("9002","赠送会员未成功", new String[0]);
  600. }else{ //其他当作9070处理
  601. bean.setVipstatus("5"); //赠送超时
  602. throw new BusinessException("9070","赠送会员超时", new String[0]);
  603. }
  604. }
  605. }
  606. }
  607. result = "0";
  608. errorcode = "0";
  609. errorinfo = "成功";
  610. if("部分成功".equals(bean.getResultinfo())){
  611. errorinfo = "部分成功";
  612. }
  613. } catch (Exception e) {
  614. e.printStackTrace();
  615. log.error("userid:"+orderInfo.getUserid()+"订购出现异常,"+e);
  616. if ((e instanceof BusinessException)) {
  617. errorcode = ((BusinessException) e).getCode();
  618. errorinfo = ((BusinessException) e).getMessage();
  619. }else{
  620. errorcode = "8000";
  621. errorinfo ="系统忙,"+e.getMessage();
  622. }
  623. if(errorinfo != null && errorinfo.length()>2000){
  624. errorinfo = errorinfo.substring(0, 2000);
  625. }
  626. throw e;
  627. } finally {
  628. bean.setResultcode(errorcode);
  629. bean.setResultinfo(errorinfo);
  630. if(bean.getResultinfo().indexOf("重复订单") == -1){
  631. backBusiOrderDao.addOrderRec(bean); //添加订购记录
  632. //上海权益
  633. if("shanghaiqy".equals(orderInfo.getOrderchannel())){
  634. backBusiOrderDao.updShInPaInfo(bean);
  635. }
  636. }
  637. saveLog(orderInfo, errorcode, errorinfo);
  638. //youtu_pc01是天猫优酷,没有提供回调接口,不进行会员赠送重试
  639. if("9070".equals(bean.getResultcode()) && !"youtu_pc01".equals(bean.getChannel())){//赠送会员超时
  640. //if("TX20_twback".equals(orderInfo.getOrderchannel()) && "3".equals(bean.getBusitype())){
  641. //拓维订购会员+免流产品时,由客户自己领取会员
  642. //}else{
  643. inserVipRetryMq(bean); //推送到队列进行重试
  644. //}
  645. }
  646. }
  647. return result;
  648. }
  649. /**
  650. * 设置当前时间
  651. * @param orderInfo
  652. * @throws Exception
  653. */
  654. private void setOrderTime(OrderInfo orderInfo) throws Exception{
  655. String currtime = this.backBusiOrderDao.getCurrentTime();
  656. orderInfo.setOrdertime(currtime);
  657. orderInfo.setEffecttime(currtime);
  658. }
  659. /**
  660. * 调能力平台
  661. * @param orderInfo
  662. * @param hasshare //调能力平台标识:0调能力平台并以结果落订购关系,1调能力平台其结果不影响订购关系,为空时不调能力平台,
  663. * @throws Exception
  664. */
  665. private void shareOrder(OrderInfo orderInfo, String hasshare) throws Exception{
  666. if("0".equals(hasshare) || "1".equals(hasshare)){
  667. String shareErcode = "0";
  668. String shareErnfo = "成功";
  669. if("0".equals(hasshare)){//以能力平台调用结果落订购关系的要设置渠道为SHARE,此渠道记录在订购关系表和订购日志表中
  670. orderInfo.setChannel("SHARE");
  671. }else{
  672. orderInfo.setChannel("");
  673. }
  674. try {
  675. shareOrderService.order(orderInfo.getUserid(),orderInfo.getCpid(),orderInfo.getSpid());
  676. } catch (BusinessException e) {
  677. e.printStackTrace();
  678. shareErcode = e.getCode();
  679. shareErnfo = e.getMessage();
  680. if("0".equals(hasshare)){
  681. throw new BusinessException("8888","调用能力共享平台订购接口失败");
  682. }
  683. } finally {
  684. saveBackShareLog(orderInfo,shareErcode,shareErnfo);
  685. }
  686. }
  687. }
  688. /**
  689. * 复合产品赠送会员结果解析
  690. * @param sendVipRes
  691. * @param bean
  692. */
  693. private void fhsendvipRes(String sendVipRes, BackBusiOrderRec bean) throws Exception{
  694. //0:成功, -1:部分成功 , 1:失败, 其他可以作为超时处理。
  695. if("0".equals(sendVipRes)){
  696. bean.setVipstatus("0");
  697. }else if("-1".equals(sendVipRes)){//部分成功
  698. bean.setVipstatus("0");
  699. bean.setResultinfo("部分成功");
  700. }else if("1".equals(sendVipRes)){//失败
  701. bean.setVipstatus("3");
  702. throw new BusinessException("9002","赠送会员未成功", new String[0]);
  703. }else{
  704. bean.setVipstatus("5"); //赠送超时
  705. throw new BusinessException("9070","赠送会员超时", new String[0]);
  706. }
  707. }
  708. /**
  709. * 赠送会员
  710. * @param orderInfo
  711. * @return
  712. * @throws Exception
  713. */
  714. private String sendVip(OrderInfo orderInfo){
  715. String resultcode = "3"; //预设失败
  716. /* int retry = 3; //重试次数
  717. for(int i=1; i <= retry; i++){//最多调三次
  718. resultcode = this.invokeSendVip(orderInfo);
  719. if("0".equals(resultcode)){//如果赠送成功就结束重试
  720. break;
  721. }
  722. }*/
  723. resultcode = this.invokeSendVip(orderInfo);
  724. return resultcode;
  725. }
  726. /**
  727. * 调接口送会员
  728. * @param orderInfo
  729. * @return
  730. */
  731. private String invokeSendVip(OrderInfo orderInfo){
  732. String resultcode = "3";
  733. try {
  734. //http://114.255.201.228:86/activity/youkuHX
  735. String vipurl = this.dictionaryDao.getValue("backBusiVipUrl");
  736. String timestamp = (System.currentTimeMillis() / 1000) + "";
  737. String userid = orderInfo.getUserid();
  738. String orderid = orderInfo.getOrderid();
  739. String channel = orderInfo.getOrderchannel();
  740. String cpid = orderInfo.getCpid();
  741. String spid = orderInfo.getSpid();
  742. String pwd = "";
  743. List<HashMap> confList = backBusiOrderDao.getBackBusiConf(orderInfo.getCpid(), orderInfo.getSpid());
  744. pwd = confList.get(0).get("PWD").toString();
  745. if("0".equals(confList.get(0).get("HASFH"))){ //是复合产品
  746. vipurl = this.dictionaryDao.getValue("backBusiGroupVipUrl");
  747. }
  748. userid = DESUtil.encode(userid, pwd);
  749. //MD5(orderid+userid+goodscode+pwd+timestamp)转换为十六进制ASCII 码字符串,共32 个字符,全小写 userid= Des(手机号码,pwd)
  750. //MD5(orderid+userid+timestamp+pwd)转换为十六进制ASCII 码字符串,共32 个字符,全小写
  751. String signature = MD5.MD5Encode(orderid + userid + timestamp + pwd);
  752. signature = signature.toLowerCase();
  753. vipurl = vipurl + "?userid=" + URLEncoder.encode(userid, "utf-8")+ "&orderid="+ orderid + "&cpid=" + cpid + "&spid=" + spid + "&timestamp="
  754. + timestamp + "&signature=" + signature+ "&apptype=2";
  755. busilog.info("vipurl: "+vipurl);
  756. //http://114.255.201.228:86/activity/eshop/vip?userid=iafPbU9aRLghY%2FEVMXFeag%3D%3D&orderid=201906231206498662914&goodscode=pointshop130&timestamp=1561445765&signature=47fe0e3900b29ef88fd0889b7c0e4cc6&apptype=5
  757. String result = URLUtil.get(vipurl,30*1000); //调赠送会员接口,超时时间设置为10秒
  758. busilog.info("赠送会员结果=> userid: " +userid+", orderid: "+orderInfo.getOrderid()+" , result: "+result);
  759. Map<?,?> map = JsonUtil.jsonToMap(result);
  760. resultcode = (String)map.get("resultcode");
  761. if(resultcode.equals("0")){
  762. busilog.info("赠送成功");
  763. }
  764. } catch (Exception e) {
  765. e.printStackTrace();
  766. busilog.error("userid: "+orderInfo.getUserid()+"赠送会员失败,"+e);
  767. }
  768. return resultcode;
  769. }
  770. /**
  771. * 查询本地订购关系表当前是否有已生效的订购关系
  772. * @param orderInfo
  773. * @return
  774. * @throws Exception
  775. */
  776. private Map hasEffect(OrderInfo orderInfo) throws Exception{
  777. Map reMap = new HashMap();
  778. boolean hasEffect = false;
  779. Map currOrderInfo = null;
  780. String currentTime = backBusiOrderDao.getCurrentTime();
  781. //查询用户本地订购关系表未失效的订购数据
  782. currOrderInfo = backBusiOrderDao.findByUserAndSpid(orderInfo.getUserid(),orderInfo.getCpid(),orderInfo.getSpid());
  783. if(currOrderInfo != null){//本地有订购关系
  784. if(Long.parseLong(currOrderInfo.get("ENDTIME").toString()) >= Long.parseLong(currentTime)){ //结束时间大于或等于当前时间,订购关系有效
  785. hasEffect = true;
  786. }
  787. }
  788. reMap.put("hasEffect", hasEffect);
  789. reMap.put("currOrderInfo", currOrderInfo);
  790. return reMap;
  791. }
  792. /**
  793. * 判断业务是否互斥
  794. * @param orderInfo
  795. * @throws Exception
  796. */
  797. private void hasMutual(OrderInfo orderInfo) throws Exception{
  798. boolean result = false;
  799. List<OrderInfo> listOrderInfo = backBusiOrderDao.findByUser(orderInfo.getUserid());
  800. // if(listOrderInfo != null && listOrderInfo.size() > 0){
  801. //
  802. // //快手阿里产品特殊处理
  803. // if("190".equals(orderInfo.getSpid())||"191".equals(orderInfo.getSpid())||"192".equals(orderInfo.getSpid())
  804. // ||"1029".equals(orderInfo.getSpid()) ||"1030".equals(orderInfo.getSpid())){
  805. // for(OrderInfo oldOrderInfo : listOrderInfo){
  806. // if(oldOrderInfo.getSpid().equals(orderInfo.getSpid())){
  807. // throw new BusinessException("9005","本月已订购,请勿重复订购", new String[0]);
  808. // }
  809. //
  810. // }
  811. // }
  812. // }
  813. if (listOrderInfo != null && listOrderInfo.size() > 0
  814. && !StringUtils.isEmpty(orderInfo.getMutex())) {
  815. String[] mutexSpids = orderInfo.getMutex().trim().split(",");
  816. for (String mutexSpid : mutexSpids) {
  817. for (OrderInfo oldOrderInfo : listOrderInfo) {
  818. if (!oldOrderInfo.getSpid().equals(orderInfo.getSpid()) && oldOrderInfo.getSpid().equals(mutexSpid)) {
  819. result = true;
  820. break;
  821. }
  822. }
  823. }
  824. }
  825. if(result){
  826. throw new BusinessException("9003","已办理互斥业务", new String[0]);
  827. }
  828. }
  829. /**
  830. * 判断是否有相同订单
  831. * @param orderInfo
  832. * @return true是,false否
  833. */
  834. private void hasDupliOrderid(OrderInfo orderInfo) throws Exception{
  835. List<BackBusiOrderRec> list = backBusiOrderDao.findOrderRecByOrderid(orderInfo.getOrderid());
  836. if(list != null && list.size() > 0){
  837. throw new BusinessException("9001", "重复订单", new String[0]);
  838. }
  839. }
  840. public String getEndTime(String endTimeStr) throws ParseException {
  841. Calendar calendar = Calendar.getInstance();
  842. Date date = DateUtils.parseDate(endTimeStr.substring(0, 8), new String[] { "yyyyMMdd" });
  843. calendar.setTime(date);
  844. String day = calendar.getActualMaximum(Calendar.DAY_OF_MONTH) + "";
  845. String year = calendar.get(Calendar.YEAR) + "";
  846. String month = calendar.get(Calendar.MONTH) + 1 < 10 ? "0" + (calendar.get(Calendar.MONTH) + 1)
  847. : calendar.get(Calendar.MONTH) + 1 + "";
  848. return year + month + day + "235959";
  849. }
  850. /**
  851. * 写订购日志
  852. * @param orderInfo
  853. * @param errorcode
  854. * @param errorinfo
  855. */
  856. public void saveLog(OrderInfo orderInfo, String errorcode, String errorinfo) {
  857. try {
  858. OrderLog orderLog = new OrderLog();
  859. orderLog.setApptype(orderInfo.getApptype());
  860. orderLog.setArea(orderInfo.getArea());
  861. orderLog.setChannel(orderInfo.getOrderchannel());
  862. orderLog.setOrderstatus(orderInfo.getOrderstatus());
  863. orderLog.setStatus(orderInfo.getStatus());
  864. orderLog.setCpid(orderInfo.getCpid());
  865. orderLog.setIsexperience(orderInfo.getIsexperience());
  866. orderLog.setOrdertype(orderInfo.getOrdertype() + "");
  867. orderLog.setProvince(orderInfo.getProvince());
  868. orderLog.setArea(orderInfo.getArea());
  869. orderLog.setSpid(orderInfo.getSpid());
  870. orderLog.setUserid(orderInfo.getUserid());
  871. orderLog.setErrorcode(errorcode);
  872. orderLog.setErrorinfo(errorinfo);
  873. if(!orderInfo.getTimes().isEmpty()){
  874. orderLog.setTimes((System.currentTimeMillis()-NumberUtils.toLong(orderInfo.getTimes()))+"");
  875. }
  876. this.backBusiOrderDao.addOrderLog(orderLog);
  877. } catch (Exception e) {
  878. e.printStackTrace();
  879. log.error("userid:"+orderInfo.getUserid()+",写订购日志出现异常,"+e.getMessage());
  880. }
  881. }
  882. /**
  883. * 写后向订购能力平台日志
  884. * @param orderInfo
  885. * @param errorcode
  886. * @param errorinfo
  887. */
  888. private void saveBackShareLog(OrderInfo orderInfo,String errorcode,String errorinfo){
  889. BackShareOrderBean bso = new BackShareOrderBean();
  890. bso.setUserid(orderInfo.getUserid());
  891. bso.setErrorcode(errorcode);
  892. bso.setErrorinfo(errorinfo);
  893. bso.setCpid(orderInfo.getCpid());
  894. bso.setSpid(orderInfo.getSpid());
  895. try {
  896. backShareOrderDao.addShareOrderLog(bso);
  897. } catch (Exception e) {
  898. e.printStackTrace();
  899. log.error("userid:"+orderInfo.getUserid()+",写后向订购能力平台日志出现异常,"+e.getMessage());
  900. }
  901. }
  902. /**
  903. * 赠送会员超时异步重试
  904. * @param bean
  905. */
  906. public void inserVipRetryMq(BackBusiOrderRec bean){
  907. try{
  908. Map<String, String> map = new HashMap<String, String>();
  909. map.put("userid", bean.getUserid());
  910. map.put("id", bean.getId());
  911. map.put("orderid", bean.getOrderid());
  912. map.put("type", "vipretry");
  913. //System.out.println("==============赠送会员失败,"+map);
  914. String mqReciveUrl = dictionaryDao.getValue("mqReciveUrl");
  915. //开发环境
  916. //URLUtil.post("http://172.16.33.16:8082/mq-service/recive.do", JsonUtil.objectToJson(map));
  917. //测试环境
  918. //URLUtil.post("http://10.199.99.177:86/mq-service/recive.do", JsonUtil.objectToJson(map));
  919. //生产环境
  920. //URLUtil.post("http://10.199.99.144:8090/mq-service/recive.do", JsonUtil.objectToJson(map));
  921. URLUtil.post(mqReciveUrl, JsonUtil.objectToJson(map));
  922. }catch (Exception e){
  923. e.printStackTrace();
  924. }
  925. }
  926. /**
  927. * 获取开始时间和结束时间
  928. * @param orderInfo
  929. * @return
  930. * @throws Exception
  931. */
  932. private Map<String, String> getBusiTime(OrderInfo orderInfo)throws Exception{
  933. Map<String, String> resMap = new HashMap<String, String>();
  934. String starttime = ""; //业务开始时间
  935. String endtime = ""; //业务结束时间
  936. String currEndtime = "";
  937. Map reMap = this.hasEffect(orderInfo);
  938. HashMap confHm = backBusiOrderDao.getBackBusiConf(orderInfo.getCpid(), orderInfo.getSpid()).get(0);
  939. if((Boolean)reMap.get("hasEffect")){ //存在有效订购关系
  940. if("1".equals(confHm.get("ENDTYPE"))){
  941. throw new BusinessException("9005","本月已订购,请勿重复订购");
  942. }
  943. Map currOrderInfo = (Map)reMap.get("currOrderInfo");
  944. currEndtime = (String)currOrderInfo.get("ENDTIME");
  945. }
  946. //[{PWD=kijkfds, NETDAYS=31, CHANNEL=test_01, NETDAYS=2, SPID=1168, BUSITYPE=3, CPID=youtu}]
  947. //String busiType = confHm.get("BUSITYPE")+"";
  948. //免流或免流+会员两种产品要以netdays参数来确定endtime
  949. if("2".equals(confHm.get("BUSITYPE")) || "3".equals(confHm.get("BUSITYPE"))){
  950. if(currEndtime != null && !"".equals(currEndtime)){
  951. if("3".equals(confHm.get("ENDTYPE"))){
  952. endtime = backBusiOrderDao.endtimeTheMonthLastDay();
  953. }else if("2".equals(confHm.get("ENDTYPE"))){
  954. endtime = backBusiOrderDao.endtimeNextMonthLastDay(currEndtime);
  955. }else{
  956. endtime = backBusiOrderDao.endtimeParamDay(confHm.get("NETDAYS")+"", currEndtime);
  957. }
  958. }else{
  959. if("1".equals(confHm.get("ENDTYPE")) || "2".equals(confHm.get("ENDTYPE"))|| "3".equals(confHm.get("ENDTYPE"))){
  960. endtime = backBusiOrderDao.endtimeTheMonthLastDay(); //特殊产品的结束时间只到本月底
  961. }else {
  962. endtime = backBusiOrderDao.currParamDay(confHm.get("NETDAYS")+"");
  963. }
  964. }
  965. if("1".equals(confHm.get("ENDTYPE")) || "2".equals(confHm.get("ENDTYPE")) || "3".equals(confHm.get("ENDTYPE"))){
  966. starttime = backBusiOrderDao.getKsStartTime(); //特殊产品开始时间就是当天
  967. }else{
  968. starttime = backBusiOrderDao.getStartTime(endtime,confHm.get("NETDAYS")+"");
  969. }
  970. }
  971. resMap.put("starttime", starttime);
  972. resMap.put("endtime", endtime);
  973. return resMap;
  974. }
  975. }