Session Application Two

Source: Internet
Author: User
Tags date now

The Mapper object is obtained from the session, and the Mapper object is used to increase and revise

Date now =NewDate (); Sqlsession Session= This. Yangchebaodbmanagerimpl.getsqlsessionfactory (). Opensession (false); Insurequeryinfomapper insurequeryinfomapper = Session.getmapper (insurequeryinfomapper.class); Insurequotedetailmapper insurequotedetailmapper = Session.getmapper (insurequotedetailmapper.class); Try {            BooleanSemsign =semaphorecontrollerutil.getinstance (). Acquireinsurehandlesemaphore (sqid); if(!semsign) {                Throw NewBadrequestexception ("Common", "request blocked, please try again later"); } insurequeryinfo Insurequeryinfo= This. Queryinsureinfobysqid (Sqid, session); //only the policy quote query information is not empty, and the quote status allows the quotation processing to be processed, to prevent the repeated processing "quote Success"            if(insurequeryinfo!=NULL){                if(Qunabaonotifystatus.canquotehandle (Insurequeryinfo.getstatus ())) {Jsonobject Dealback= Params.optjsonobject ("Dealback"); //because where to go to protect the current is, can only rely on this property to judge, so temporary processingBoolean issimilar = Maputils.getboolean (Dealback, "Issimilar",false); if(issimilar) {notifystatus=qunabaonotifystatus.quote_failed; }                    if(Notifystatus.getcode () = =QunabaoNotifyStatus.QUOTE_FAILED.getCode ()) {                        //Quote Failed}Else if(Notifystatus.getcode () = =QunabaoNotifyStatus.QUOTE_SUCCESSED.getCode ()) {                        //Quote Success//Update the price of travel tax, total price, commercial insurance price, cross-strong insurance Price//increase specific pricing information for each type of insuranceJsonobject Dealoffer = Params.optjsonobject ("Dealoffer"); if(dealback!=NULL&&!Dealback.isempty ()) {Insurequeryinfo.settaxcharge (dealback.optdouble ("Taxcharge", payconstants.default_null_id));//Price of vehicle and vessel taxInsurequeryinfo.settotalcharge (dealback.optdouble ("Totalcharge", payconstants.default_null_id));//Total PriceInsurequeryinfo.setbizcharge (dealback.optdouble ("Bizcharge", payconstants.default_null_id));//Business Insurance PriceInsurequeryinfo.setefccharge (dealback.optdouble ("Efccharge", payconstants.default_null_id));//price of cross-strong insurance                        }                                                if(dealoffer!=NULL&&!Dealoffer.isempty ()) {Jsonobject Suite= Dealoffer.optjsonobject ("Suite"); if(suite!=NULL&&!Suite.isempty ()) {Jsonobject Items= Suite.optjsonobject ("Items"); if(items!=NULL&&!Items.isempty ()) {Set EntrySet=Items.keyset (); Iterator<String> iterator =Entryset.iterator ();  while(Iterator.hasnext ()) {String key=Iterator.next (); Jsonobject Quoteinfo=Items.optjsonobject (key); if(quoteinfo!=NULL&&!Quoteinfo.isempty ()) {Insurequotedetail Insurequotedetail=NewInsurequotedetail (); Insurequotedetail.setsqid (sqid);//Single- sided----such as "6010306151601232422 "Insurequotedetail.setecode (quoteinfo.optstring ("Ecode"));//Protection Item code----For example: "Vehicledemageins"Insurequotedetail.setselidx (quoteinfo.optstring ("Selidx"));//Select an item----For example: 1Insurequotedetail.setselname (quoteinfo.optstring ("caption"));//Select Item NameInsurequotedetail.setamount (quoteinfo.optdouble ("Amount", payconstants.default_null_id));//Protection AmountInsurequotedetail.setcharge (quoteinfo.optdouble ("Charge", payconstants.default_null_id));//actual PremiumsInsurequotedetail.setlistprice (quoteinfo.optdouble ("ListPrice", payconstants.default_null_id));//Original PriceInsurequotedetail.setdiscountrate (quoteinfo.optdouble ("DiscountRate", payconstants.default_null_id));//Discount RateInsurequotedetail.setcreatedate (now);//Record creation Time insurequotedetailmapper.insert (insurequotedetail);//increase the price information of insurance                                        }                                    }                                } }}} insurequeryinfo.setreceivedate (now );//Quote Receipt TimeInsurequeryinfo.setstatus (string.valueof (Notifystatus.getcode ()));//Quote Status----Quote Success/FailureInsurequeryinfo.setremarks (NOTIFYMSG);//Quote Success/Failure description Information insurequeryinfomapper. Updatebyprimarykey (insurequeryinfo);//Update database records                                    }Else{Logger.warn ("Where to go to security callback----" +NOTIFYSTATUS.GETDESC () + "----Single:" +sqid+ "status is:" +insurequeryinfo.getstatus () + "Ignore this callback"); }            }Else{                Throw NewBadrequestexception ("Common", "no information found on the" +sqid+ ");        } session.commit (); } Catch(carsmartexception e) {session.rollback (); Throw NewBadrequestexception ("Common", E.getmessage ()); } Catch(Exception e) {session.rollback ();            Logger.error (E.getmessage (), E); Throw Newinternalerrorexception (e); } finally{session.close ();        Semaphorecontrollerutil.getinstance (). Releaseinsurehandlesemaphore (sqid); }

The second method using the session to get the Mapper object to be updated using the map storage variable, using the session Update method

Map<string, object> parammap=NewHashmap<string, object>(); Parammap.put ("Modelqaid", Modelqaid); Sqlsession Session=NULL; Try{Session= This. Yangchebaodbmanagerimpl.getsqlsessionfactory (). Openreplicablesqlsession (false); Session.update ("Cn.com.carsmart.ws.ibatis.mapper.ComplexQueryNewMapper.updateModelQaViewCnt", Parammap);        Session.commit (); } Catch(Exception e) {if(NULL!=session)            {Session.rollback (); } logger.error ("Method Detail fail" +Exceptionutils.getfullstacktrace (e)); } finally {            if(NULL!=session)            {Session.close (); }        }

Session Application Two

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.