package Ġio . must el id ae . ot ter . ne ot rop ical . api . domain . payment Ċ Ċ import Ġio . must el id ae . ot ter . ne ot rop ical . api . common . ErrorCode Ċ import Ġio . must el id ae . ot ter . ne ot rop ical . api . config . Develop M ist ake Exception Ċ import Ġio . must el id ae . ot ter . ne ot rop ical . api . domain . order . Order Sheet Ċ import Ġio . must el id ae . ot ter . ne ot rop ical . api . domain . payment . client . billing . Billing Pay Client Ċ import Ġio . must el id ae . ot ter . ne ot rop ical . api . domain . payment . client . billing . Default Pay Payload Ċ import Ġio . must el id ae . ot ter . ne ot rop ical . api . domain . payment . client . billing . Pay Type Ċ import Ġjava . time . LocalDate Ċ Ċ class ĠBilling Pre Pay Way Ġ: ĠPay Way Ġ{ ĊĊĠĠĠ Ġoverride Ġval Ġpayment : ĠPayment ĊĠĠĠ Ġprivate Ġval Ġbilling Pay Client : ĠBilling Pay Client ĊĊĠĠĠ Ġoverride Ġfun Ġpay ( ĊĠĠĠĠĠĠĠ Ġamount Of Pay : ĠLong , ĊĠĠĠĠĠĠĠ Ġorder Sheet : ĠOrder Sheet , ĊĠĠĠĠĠĠĠ Ġadjustment Id : ĠLong ĊĠĠĠ Ġ) Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġbook OrderId Ġ= Ġorder Sheet . id ĊĠĠĠĠĠĠĠ Ġval Ġaccount Set tlement Date Ġ= Ġthis . calculate Last Set tlement Date ( order Sheet ) ĊĠĠĠĠĠĠĠ Ġval Ġusing Pay Method Ġ= Ġorder Sheet . estimate Using Pay Method Ġ?: Ġthrow ĠDevelop M ist ake Exception ( ErrorCode . PD 0 2 ) ĊĊĠĠĠĠĠĠĠ Ġpayment . pay ( amount Of Pay , Ġbook OrderId , Ġusing Pay Method . credit Card ?. pay Key , Ġadjustment Id ) ĊĊĠĠĠĠĠĠĠ Ġval Ġpayload Ġ= ĠDefault Pay Payload ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġorder Sheet . product Code , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġorder Sheet . topic Id , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġpayment . userId , ĊĠĠĠĠĠĠĠĠĠĠĠ ĠPay Type . PAY OUT , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġadjustment Id , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġbook OrderId . toString (), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġorder Sheet . products . join ToString Ġ{ Ġit . title Ġ}, ĊĠĠĠĠĠĠĠĠĠĠĠ Ġaccount Set tlement Date , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġamount Of Pay , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġusing Pay Method , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġorder Sheet . pre Define Field ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġval Ġpaid Result Ġ= Ġbilling Pay Client . pay ( order Sheet . userId , Ġpayload ) ĊĊĠĠĠĠĠĠĠ Ġpayment . paid ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġpaid Result . bill Pay Id , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġpaid Result . amount Of Paid , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġpaid Result . paid Methods . map Ġ{ Ġit . method Ġ}, ĊĠĠĠĠĠĠĠĠĠĠĠ Ġpaid Result . transaction Date ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġcalculate Last Set tlement Date ( order Sheet : ĠOrder Sheet ): ĠLocalDate Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġreserve Dates Ġ= Ġorder Sheet . products . filter Ġ{ Ġit . reservation Date Ġ!= Ġnull Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. map Ġ{ Ġit . reservation Date !!. to LocalDate () Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. to Mutable List () ĊĊĠĠĠĠĠĠĠ Ġorder Sheet . set tlement Date ?. let Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġreserve Dates . add ( it ) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġreturn Ġreserve Dates . max Of Ġ{ Ġit Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġcancel ( cause : ĠString ) Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġresult Ġ= Ġbilling Pay Client . cancel Ent ire ( payment . userId , Ġpayment . bill Pay Id !! , Ġcause ) ĊĠĠĠĠĠĠĠ Ġpayment . cancel Ent ire ( result . transaction Date , Ġ 0 ) ĊĠĠĠĠĠĠĠ Ġpayment . append Memo ( cause ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġcancel With Pen alty ( cause : ĠString , Ġamount Of Pen alty : ĠLong ) Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġresult Ġ= Ġbilling Pay Client . cancel Ent ire With Pen alty ( payment . userId , Ġpayment . bill Pay Id !! , Ġcause , Ġamount Of Pen alty ) ĊĠĠĠĠĠĠĠ Ġpayment . cancel Ent ire ( result . transaction Date , Ġresult . penalty Amount !! ) ĊĠĠĠĠĠĠĠ Ġpayment . append Memo ( cause ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġcancel Partial ( cause : ĠString , Ġpartial Cancel Amount : ĠLong ) Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġresult Ġ= Ġbilling Pay Client . cancel Partial ( payment . userId , Ġpayment . bill Pay Id !! , Ġcause , Ġpartial Cancel Amount ) ĊĠĠĠĠĠĠĠ Ġpayment . cancel Partial ( result . transaction Date , Ġpartial Cancel Amount , Ġ 0 ) ĊĠĠĠĠĠĠĠ Ġpayment . append Memo ( cause ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġcancel Partial With Pen alty ( cause : ĠString , Ġpartial Cancel Amount : ĠLong , Ġamount Of Pen alty : ĠLong ) Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġresult Ġ= Ġbilling Pay Client . cancel Partial With Pen alty ( payment . userId , Ġpayment . bill Pay Id !! , Ġcause , Ġpartial Cancel Amount , Ġamount Of Pen alty ) ĊĠĠĠĠĠĠĠ Ġpayment . cancel Partial ( result . transaction Date , Ġpartial Cancel Amount , Ġamount Of Pen alty ) ĊĠĠĠĠĠĠĠ Ġpayment . append Memo ( cause ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġconstructor ( ĊĠĠĠĠĠĠĠ ĠuserId : ĠLong , ĊĠĠĠĠĠĠĠ Ġprice Of Order : ĠLong , ĊĠĠĠĠĠĠĠ Ġbilling Pay Client : ĠBilling Pay Client , ĊĠĠĠ Ġ) Ġ{ ĊĠĠĠĠĠĠĠ Ġthis . payment Ġ= ĠPayment ( userId , Ġprice Of Order , ĠPay Way . Type . PRE _ PAY ) ĊĠĠĠĠĠĠĠ Ġthis . billing Pay Client Ġ= Ġbilling Pay Client ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġconstructor ( payment : ĠPayment , Ġbilling Pay Client : ĠBilling Pay Client ) Ġ{ ĊĠĠĠĠĠĠĠ Ġthis . payment Ġ= Ġpayment ĊĠĠĠĠĠĠĠ Ġthis . billing Pay Client Ġ= Ġbilling Pay Client ĊĠĠĠ Ġ} Ċ } Ċ