当前位置:网站首页>Dry goods | multi business line with a volume of 100 million, how does Ctrip do the accounting center

Dry goods | multi business line with a volume of 100 million, how does Ctrip do the accounting center

2021-04-01 04:56:19 InfoQ

{"type":"doc","content":[{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":" One 、 Preface "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" The original internal accounting system of Ctrip is established with its own business development , There's something in common , But there are also many differences . But its abstraction of the underlying business is unified , Can be abstracted as : Account opening 、 Bookkeeping 、 Audit . For system development 、 Simplicity of operation and maintenance , Also in order to provide better support for the front desk business , We plan to implement the accounting center system , So as to achieve the accounting system :"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"1)"},{"type":"text","marks":[{"type":"strong"}],"text":" agile "},{"type":"text","text":": Quickly adapt to the changes of business needs , Meeting rapidly changing external needs , Achieving business agility ."}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"2)"},{"type":"text","marks":[{"type":"strong"}],"text":" decoupling "},{"type":"text","text":": Build a functional independent system , Avoid affecting many aspects due to the modification of one function , Reduce the coupling of functions ."}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"3)"},{"type":"text","marks":[{"type":"strong"}],"text":" Reuse "},{"type":"text","text":": Reuse of some common components , Improve development efficiency , Avoid repeated construction , So that data and processes can be controlled ."}]},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":" Two 、 The way to Accounting Center - The basic chapter "}]},{"type":"heading","attrs":{"align":null,"level":3},"content":[{"type":"text","text":"2.1 System Overview "}]},{"type":"heading","attrs":{"align":null,"level":4},"content":[{"type":"text","text":"2.1.1 background "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" The accounting system starts from 2014 The first phase of construction started in , It has experienced two major technical architecture upgrades ."}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong"}],"text":" The first phase of :"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" When the accounting group was first set up , Ctrip's JAVA The technology stack is not perfect ."}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" Technically, we are the first batch of pilot use JAVA Group , Using distributed RPC The frame is Zeroc ICE, It can support multiple languages , adopt slice File generation code , The performance is also quite good , So I used this at the beginning . Message queuing uses RABBITMQ, Cache for REDIS. These clusters are self operating ."}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" Business , Phase I business only supports the mode of single user and single account , Transaction support recharge 、 payment 、 refund 、 Pre authorization class ( Pre authorization freeze , Revocation of pre authorization , Pre authorization complete , Pre authorization complete revocation )、 Withdrawal 、 Transfer accounts , Interfaces are developed independently based on business interfaces ."}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" The system business architecture is as follows :"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"image","attrs":{"src":"https:\/\/static001.geekbang.org\/infoq\/29\/298ff091d5e544670a4d1fdbf2653d5e.jpeg","alt":" picture ","title":null,"style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":null,"fromPaste":true,"pastePass":true}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong"}],"text":" Phase two :"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" With Ctrip JAVA The perfection of technology stack , The second phase is mainly aimed at JAVA The technology stack has been upgraded , Give up the cluster of self operation and maintenance , Using Ctrip JAVA system , Include SOA,qconfig,qmq,qshecdule Technology . The accounting system and the realization of the end of the day are added to the business ."}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" The system business architecture is as follows :"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"image","attrs":{"src":"https:\/\/static001.geekbang.org\/infoq\/55\/55d7e412b4b8b134847cf92e48e79c00.jpeg","alt":" picture ","title":null,"style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":null,"fromPaste":true,"pastePass":true}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" The original accounting core system has the following problems :"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"1) Lack of abstraction : The abstraction of business rules is not enough , If new services need to be coded "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"2) Isolation is not enough : System traffic of different services of the system 、 The data is not isolated , There is a business problem , Risks that affect the overall situation "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"3) Downgrade strategy : I won't support it "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"4) It's difficult to expand "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" Based on the above questions , We have designed and implemented a new unified accounting platform ."}]},{"type":"heading","attrs":{"align":null,"level":4},"content":[{"type":"text","text":"2.1.2 The goal is "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" For the shortcomings of the old system , We set the goal of a unified accounting platform :"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"1) abstract "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"2) Isolation "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"3) Easy to expand "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"4) Configuration change "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"5) Support multi institution and multi currency "}]},{"type":"heading","attrs":{"align":null,"level":3},"content":[{"type":"text","text":"2.2 System architecture and introduction "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" The purpose of the unified accounting system is to establish a set of high availability system based on Ctrip group , Easy to expand , Business customizable accounting system . The system includes scene code system , Accounting front-end system , Accounting core system , Account management system , Accounting system , Asynchronous systems ,job System , Log system . Between the various systems through dubbo Service splitting and decoupling ."}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" The system business architecture is as follows :"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"image","attrs":{"src":"https:\/\/static001.geekbang.org\/infoq\/6c\/6c017580dcdfd12a107181dc06b38e8a.jpeg","alt":" picture ","title":null,"style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":null,"fromPaste":true,"pastePass":true}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"bulletedlist","content":[{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" Front end system : Accounting business processing system , Mainly responsible for the docking of upstream business system , Complete account splitting, etc ."}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" Accounting core system ( Atomic system ): Mainly responsible for account keeping , Record the impact on the merchant 、 user 、 Moving account and details of internal account and other customer accounts ."}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" Management system : Provide foreign merchants 、 user 、 Management services for internal users , Including the creation of 、 Inquire about 、 The state is frozen 、 State unfreezing and other services ."}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" Accounting system : Double entry bookkeeping is used to record transactions according to entry rules , To show the flow of funds ."}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" Basic service system : Provide subjects to the public 、 Entry 、 Transaction code and other basic configuration query services ."}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" Day end system : Audit the accounting system data , Complete data verification ."}]}]}]},{"type":"heading","attrs":{"align":null,"level":3},"content":[{"type":"text","text":"2.3 The system design "}]},{"type":"heading","attrs":{"align":null,"level":4},"content":[{"type":"text","text":"2.3.1 Basic component design "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong"}],"text":"2.3.1.1 The logging component "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" We're going to logger Output , You'll come across the following pain points :"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"1) We often refer to methods , Print the log with exception , And tag write in clog and ES, Handwritten words are a lot of work ."}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"2) Some logs need desensitization , Like cell phone number 、 ID number 、 Card number , Can't output plaintext to log ."}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"3)logger At present, we only support the company's logger Log platform , It is difficult for departments to customize log query and analysis tools ."}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" Therefore, in the design of a unified accounting project of Taiwan Chemical Industry Co., Ltd , Design the log component :"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"1) Unified use of high performance log4j2 replace logback;"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"2) adopt spring aop and annotation, Support method input 、 The ginseng 、 Automatic printing of exception log ;"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"3) Support clog and es Of tag Configuration of , You can get... From the parameters , And pass log4j2 Of ThreadContext Tapping into local threads , In the process of using thread tag share , The code is as follows :"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"image","attrs":{"src":"https:\/\/static001.geekbang.org\/infoq\/90\/90fc1c78c06c1d567f10811c9c52a3f2.png","alt":" picture ","title":null,"style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":null,"fromPaste":true,"pastePass":true}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"4) Support configuration desensitization rules , Desensitization of sensitive information ;"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"5) The company's clog and cat, Asynchronous throw kafka, Asynchronously accept the program for ETL Handle , The Department's own log system ( Like the eagle eye system ,hive Log analysis system );"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"6) throw kafka when , For the original message apache arvo Compression processing , Reduce transmission bandwidth ;"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"7) Support native API, You can do it by hand tag And desensitization ."}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"       "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" The flow chart is as follows :"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"image","attrs":{"src":"https:\/\/static001.geekbang.org\/infoq\/bc\/bceb712817be5d8e71d87bbf8e6d4f92.jpeg","alt":" picture ","title":null,"style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":null,"fromPaste":true,"pastePass":true}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong"}],"text":"2.3.1.2 Sub database sub table component "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" Sub library components , We've researched the company's existing and open source components , Finally, we chose the open source sharding-jdbc."}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"1) Ctrip's dal Components "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"dal Use dal cluster Through the server configuration sub database sub table information , But the whole thing is dal Too heavy , It's a complete ORM frame , Generate sql The tool for does not support generating special custom sql."}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"2) Where did you go qdb Components "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" Through the way of configuration expression or algorithm to configure sub database and sub table , The disadvantage is less documentation , It's easy to step on a hole ."}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"3)MYCAT"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"Mycat Is a middleware , It intercepts what the user sent SQL sentence , First of all, SQL The statement does some specific analysis : Such as fragment analysis 、 Route analysis 、 Read write separation analysis 、 Cache analysis, etc , And then put this SQL Real database sent to the back end , And will return the results to do the appropriate processing , And finally back to the user .Mycat The drawback is that we need to build a set of middleware as interceptor , And it needs self maintenance , The cost is relatively high ."}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"4)sharding-jdbc"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" Dangdang.com is the first open source sub library component launched by dangdang.com , Now become apache project , It is divided into sharding-jdbc、sharding-proxy. The open source community is active . We use lightweight sharding-jdbc, You can write algorithms , Supports accurate slicing 、 Range fragmentation 、 Composite slicing and customization hint Fragmentation , Configuration mode support xml、yml and java api The way . It can basically solve all our sub database and sub table requirements . We package the sub database algorithm into jar package , Easy to use . Configuration we use yml. In use , Need to combine dal cluster Of key, The code example is as follows :"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"image","attrs":{"src":"https:\/\/static001.geekbang.org\/infoq\/14\/14eed01148e1c9024c98105efb7a6232.png","alt":" picture ","title":null,"style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":null,"fromPaste":true,"pastePass":true}},{"type":"heading","attrs":{"align":null,"level":4},"content":[{"type":"text","text":"2.3.2 Front end system design "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" Accounting front is at the top of the whole accounting system , Provide standard transaction interface , Including income 、 Return the money 、 Disbursement 、 Return the money 、 Pre authorization class 、 Transfer and batch interface ."}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong"}],"text":"2.3.2.1 Standard trading interface "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" Integrate the old system before , All business oriented interfaces , As the business continues to iterate , More and more interfaces , Responsibilities are not clear , Duplicate code , Bring a lot of work to maintenance . such as : Optical cash interface , It is divided into personal withdrawal 、 Cash back 、 Commercial withdrawal and directional withdrawal . in addition , The original sub account transaction sequence is hard coded , If there is an increase in sub accounts or a change in the order of transactions , The complexity is multiplied ."}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" We have studied , It is found that accounting treatment has something in common , For transaction order 、 Atomic transaction types can extract attributes . So we built a scene code model ."}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" First , We define sub accounts id, By account type + currency + The business type defines only one sub account ."}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" secondly , By product code + Transaction type to define a transaction order , The transaction order is related to the sub account id, This order is set to the default scene code . As long as the default transaction code and scenario code can be passed in ."}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" Third , Support merchant Custom Scene code , We maintain a back office management system , Allow merchants to customize scene code , After passing the audit , If the interface passes in the scene code number, it can go through the scene code defined by itself ."}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong"}],"text":"2.3.2.2 Asynchronism "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" Our interfaces are all synchronous interfaces , To reduce synchronous response time , Pass secondary work through mq Asynchronous processing . such as : The transfer in Party's income , To the accountant, etc . "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong"}],"text":"2.3.2.3 Database policy "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" In addition to supporting your own payment business , It also supports the output of accounting system to other BU. For the sake of Data permission and mutual non influence , We did data isolation . One thing to note is that , Just do data isolation , The system also uses the same set of , No isolation , Easy to release and maintain . There are two layers of data isolation , The first layer is domain, It's the difference \/BU. The second level is the specific sub database ."}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"sharding The library is also divided into two sets ,Mapping Treasury and transaction Treasury .Mapping The relationship between inventory release request serial number and front serial number . Trading inventory puts all the trading information . Specially , We put reverse transaction and original transaction in the same place DB in , This helps to control the reverse transaction and the original transaction in one thing ."}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" First , We use the request serial number to do hash Algorithm , Spread to mapping db.Mapping db Only the relationship between the request serial number and the preceding serial number is saved ,Mapping db It's also from the sub Treasury , The number of branches is initially fixed , Later extensions can use consistency hash Algorithm for expansion ."}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" Our trading table is divided by weight allocation , The data can be freely distributed by weight .DB Support friendly expansion , Offline and fail over . We have a solution to fail over , If a fragment appears dbconnect abnormal , We'll send the payment monitoring system . The monitoring system will have a set of intelligent algorithms to monitor in real time , When it reaches the threshold, it will automatically trigger the markdown\/markup Mechanism ."}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong"}],"text":"2.3.2.4 exception handling "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" Exception handling in high concurrency scenarios has always been a research topic . In order to adapt to high concurrency scenarios , The front-end does the following exception handling :"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"1) Idempotent mechanism : All interfaces support idempotent operations ."}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"2) Retry mechanism : Retries of calls inside the interface ,job Try again , The upstream can also initiate a failed retrial of the same request message ."}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"3) Query mechanism : All interfaces have a set of query interfaces , The upstream can check the final status of the transaction through the query interface ."}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"4) A notification mechanism : Support success \/ The upstream mechanism is actively informed of the failure result ."}]},{"type":"heading","attrs":{"align":null,"level":4},"content":[{"type":"text","text":"2.3.3 Atomic system design "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" Atomic system process , There are mainly the following steps : Order parameter preprocessing , Split the order , Synchronous actuator , Asynchronous actuator , post-processing , Finally, the encapsulation parameter returns . To facilitate business expansion , system maintenance , In the division and execution part , The system architecture adopts the divider of responsibility chain mode ; The agent carries on the single , produce drivers, Then, it is executed by synchronous and asynchronous executors automatically registered by the system . at present , Only the order register is done asynchronously , follow-up job The system will compensate the task accordingly ."}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" The following diagram shows the system architecture of the atomic system :"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"image","attrs":{"src":"https:\/\/static001.geekbang.org\/infoq\/16\/16f767179fd6bfc8a840321f3a957f1b.png","alt":" picture ","title":null,"style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":null,"fromPaste":true,"pastePass":true}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"PreBizProcess In the part of parameter preprocessing, customized verification and information construction are carried out according to different call domains ."}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"DispatcerControl It's a single part , Because the atomic system is responsible for account balance management , There is no business logic , So the accounting model can be abstracted to adapt to different business needs . Bookkeeping model includes account entry and account exit (Accnt)、 Activities are recorded and recorded (Activity)、 Freezing and unfreezing of funds (Fund)、 Daily register entry and exit (DaliyBook)、 Order registration and accounting (OrderBook) And so on . Accounts for the term of validity concept , Added register management , The daily register summarizes the funds of the account in the same period of validity , The order register is a record of the order dimension of the fund for the period of validity ."}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"SynExecutor Is the synchronous actuator, mainly responsible for the accounting , The freezing and unfreezing of funds , Daily register processing ;AsynExecutor It is an asynchronous actuator responsible for the bookkeeping operation of the order register . The daily register is executed synchronously , The success of daily register can ensure the success of order register , So the asynchronous bookkeeping of order register can ensure the success of bookkeeping and reduce the synchronous processing time of the system ."}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" The post-processing part will send a moving account message , To systems that care about changes in account balances , For example, risk control ."}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"image","attrs":{"src":"https:\/\/static001.geekbang.org\/infoq\/51\/511995babca4996a1f180b7b35e40589.png","alt":" picture ","title":null,"style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":null,"fromPaste":true,"pastePass":true}},{"type":"heading","attrs":{"align":null,"level":4},"content":[{"type":"text","text":"2.3.4 Accounting system design "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" The accounting system uses double entry bookkeeping , It can clearly state where the capital comes from and flows to , Different business involves different sorting rules . Different accounting policies can be configured in the clearing rules , For example, single line 、 Summary bookkeeping and other different strategies ."}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" For the scenario of multiple subjects in the same business , Add extended configuration , Realize the dynamic account of clearing rules ."}]},{"type":"heading","attrs":{"align":null,"level":4},"content":[{"type":"text","text":"2.3.5 Day end system design "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong"}],"text":"2.3.5.1 Why day end systems are needed "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"1) Provide accounting system support "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" To ensure the normal operation of the accounting system , The balance of accounts should be 100% accuracy . The main factors affecting the stability of the accounting system are as follows :"}]},{"type":"bulletedlist","content":[{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" Buffer bookkeeping , Problem performance : The entry has data , There is no data in the details "}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" Accounting asynchronous bookkeeping , Problem performance : Details have data , Entry has no data "}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" Entry rule configuration , Problem performance : In the same entry , The amount of debit and credit is inconsistent "}]}]}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"2) Provide summary bookkeeping voucher for enterprise finance "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" The accounting system records business accounts , These data are part of the financial data of the whole enterprise , It needs to be integrated into the company's big financial system ."}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" The day end system processes accounting entries and maps them into big financial entries , Then summarize , Direct docking with enterprises ERP General ledger ."}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong"}],"text":"2.3.5.2 What does the end of the day system do "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"image","attrs":{"src":"https:\/\/static001.geekbang.org\/infoq\/64\/646efa789758c8a784ede53928707bb5.png","alt":" picture ","title":null,"style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":null,"fromPaste":true,"pastePass":true}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"1) Generate snapshot "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" Every morning statistics as of the previous day of all accounts snapshot ."}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"2) Generate sub account "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" Generate sub account according to snapshot ."}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"3) Generate general ledger "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" Generate account general ledger according to entry flow , Account amount and balance are summarized from the end level account to the first level account ."}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"4) General ledger balance check "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" Balance check : First level debit account balance = First level credit account balance ;"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" A frontal balance check : Debit amount of first level account = Credit amount of first level account "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"5) Check the total score "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" The balance of general ledger account is equal to that of sub account account account . Business 24 Hours of uninterrupted operation , The balance in the account is constantly changing , Unable to accurately get the account balance at the end of the period for verification , Use balance snapshot to check the balance of general ledger account ."}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"6) Audit details "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" Check whether the Sub Ledger is consistent with the entry journal . For accounts with balance changes on the same day , The balance of yesterday is offset with the amount in the entry flow , Check whether the calculated balance is consistent with the snapshot balance ."}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong"}],"text":"2.3.5.3 The challenge of the day end system "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"1)24 Hourly billing "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" In a bank accounting system , about 24 Hour run , There are many options , For example, switch the balance 、 Record different accounts 、 Make up water after daily cutting , But either way , Can't be completely 24 Hour run ."}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" The problem is , The main reason is that we have to check the total score at the end of the day , And the balance of sub account is constantly changing , So we should try to find a way to check the balance of the account at the end of the period ."}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" End of the day system solutions , Use balance snapshot to check with general ledger , In this way, even if the account balance changes , It doesn't affect the total score check ."}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"2) Generate account snapshot "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" There are two ways to generate a snapshot :"}]},{"type":"bulletedlist","content":[{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" Get... From the account balance "}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" The transaction details are updated according to the total amount of the account "}]}]}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" Compared to hundreds of millions of accounts , There are far fewer transactions per day . Adopt the method of dynamic account summary , Less for database operations , Faster processing time ."}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":"br"}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"3) Process complexity 、 It's difficult to test "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"image","attrs":{"src":"https:\/\/static001.geekbang.org\/infoq\/26\/26fb1e5fe172f2ba63dd122d0b8d10fb.png","alt":" picture ","title":null,"style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":null,"fromPaste":true,"pastePass":true}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" Abstract the end of day task model , According to the business boundary, it is divided into : Snapshot generation 、 Separate account generation 、 General ledger generation and other subtasks , Automatically register to task factory , So that you can call ."}]},{"type":"heading","attrs":{"align":null,"level":3},"content":[{"type":"text","text":"2.4 summary "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" This system service access rules 、 Accounting rules are all based on configuration , New account types in business development 、 Business 、 currency 、 Daily changes such as organization can be based on configuration .          "}]},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":" 3、 ... and 、 Postscript "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" Up to now, the construction of Accounting Center , Has completed the basic construction of the accounting center in the Ctrip system , This is only the first step in the construction of China Taiwan , Subsequent planning also includes distributed transactions 、 Hot account processing ; How to make the business access of new institutions more concise and so on ."}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong"}],"text":" Author's brief introduction "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" This is a joint article , The author's team is responsible for the payment and accounting system of Ctrip group 、 Consumer finance accounting system 、 Development of clearing and reconciliation 、 Design and operation and maintenance work ."}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" Reprinted from : Ctrip Technology Center (ID:ctriptech)"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" Link to the original text :"},{"type":"link","attrs":{"href":"https:\/\/mp.weixin.qq.com\/s\/PigndZkDuJgq7Mj_M3-S_A","title":"xxx","type":null},"content":[{"type":"text","text":" dried food | Multi line of business with a volume of 100 million , How does Ctrip do the accounting center "}]}]}]}

版权声明
本文为[InfoQ]所创,转载请带上原文链接,感谢
https://chowdera.com/2021/03/20210329085404968P.html