“I work in technology in Taotian” If you are a merchant in Five Elements, how do you settle the accounts?

Let me tell you about the financial development of Taotiantao factory.

Financial development is so unfamiliar, what is it? Okay, now if you are a merchant in the Five Elements, and you sell things on Taobao. When a consumer buys something from you, does Taobao need to pay you to settle the transaction order? In addition, does Taobao also charge you a service fee? Part of the responsibilities of financial development is to mainly deal with you as a merchant, sending and deducting money. In addition, we will not discuss the part that directly deducts money from consumers here, so we are actually fine with high concurrency, but there are still quite a few challenges.

The reason why the author is “not ashamed” to talk about it here is, firstly, to explain that financial management is not just simple reports and SQL, it has many business and technical challenges. Secondly, I hope it can bring some interest to all students, so that they can Join us to take on the challenge 🙂

Author: Wang Yihui (Xiao Hui)

1. Preface

You have to spend money for personal food, clothing, welcome and transportation. Holiday red envelopes and year-end wages are also recorded in the accounts. This is especially true for a company. No matter what new projects are launched, what activities are held, where money should be collected and where money should be spent, there must be no omissions or mistakes. for example

  • When the consumer buys something on Taobao, it comes with free shipping. He didn’t pay, but as a merchant, you will be charged logistics fees, warehouse operation fees, and package material fees;

  • When a consumer wants to buy a refrigerator on Taobao, the platform will give him an ice tray or plastic wrap when he places the order, and he won’t pay. Consumers may not think about why they can buy one and get one free. However, this is naturally because the platform has this marketing activity behind it, and when the transaction is brokered, you as a merchant have to pay a service fee;

  • Another example is when consumers need reviews when buying something. Sometimes the page will prompt consumers to give red envelopes to consumers if they rate them. Similarly, we need to deduct your money and then use the money as red envelopes to consumers;

  • Another example is that if consumers buy goods with freight insurance, they do not need to pay separately. However, if you provide freight insurance, you must pay the insurance company;

  • In addition, if you are collecting money, you need to issue an invoice to the consumer; if you are sending money, you need to issue an invoice to Taotian.

And so on, and Taotian itself can also be understood as a large merchant. The process of dealing with money between him and you can be simply described as follows:

The quotation can be simply understood as we will sign a relevant agreement with the merchant when you enter the platform as a merchant or register for subsequent activities to clarify the charging standards for various fees. So as financial developers, how do we manage the company’s money transfer and collection from a technical system?

2. Define the problem

2.1 Business issues

? 2.1.1 You ask: Why did you deduct so much money from me?

As mentioned before, both parties will clearly quote the price, but how do you know if Taotian made a miscalculation and deducted more money? Soit is necessary for you to check the bill Taotian gives you to see if it is consistent with your expected expenditure. And more importantly, you have to calculate your accounts well. You need to know how much money you have invested in each product link provided to consumers, how much money you have earned, and how much money you have not yet received. Otherwise, how would you know whether to invest money in this product link, or how to continue investing? To put it professionally, as a merchant, you also have your own financial team. They will calculate the company’s return on investment (ROI) through statistics and analysis of the company’s business data, and provide the company with detailed financial reports on a regular basis. Report so that the company’s leadership can understand the company’s operating status and formulate appropriate strategies for the company’s development. So as a financial developer not only can we not make mistakes or delay the payment, we must also have evidence – that is, we must have clear bills and corresponding business analysis data.

? 2.1.2 Taotian asks: How is my ROI?

Then our independently accounted BU business naturally pays more attention to the details of cost expenditures, calculating our own ROI, issuing financial reports and deciding how to invest in the future. So as a financial developer we need to ensure that the external and internal data are consistent, and the internal data will be actually used for analysis, decision-making and auditing.

Receivables and payables vs. actual payment

In addition, when dealing with company finances specifically, we also need to distinguish between receivables and payables and actual receipts and payments.

Receivables and payables refer to the amounts that the company should receive or pay within a period of time, while actual payments refer to the amounts that the company actually receives or pays. If you send money to someone else, and their account is frozen by the bank and cannot be collected, this is a receivable but not paid; similarly, if you receive money from someone else, but his account does not have that much money, this is a receivable but not collected; and those Money that has not been settled successfully is called unsettled. Just like a businessman will ask “Why did you deduct so much money from me?”, our finances need to look at the current financial situation of the company in terms of accounts receivable and payable, and we should also pay attention to the non-settlement and recovery of the settled money in a timely manner.

Of course, if there are only actual receipts and payments in the financial report, there will be compliance risks. So as a financial developer we must clearly record receivables and payables through reasonable design, and ensure that receivables and payables can accurately correspond to actual receipts and payments to avoid capital losses.

Integration of business and finance

The concept of integrating industry and finance was born from the complex domestic commercial activities. It is a big concept in itself. Compared with the simplicity of the words, its interpretation is complicated. Here are some personal inaccurate explanations.

  • Industry: refers to all business activities and business operations of the enterprise;

  • Finance: Financial accounting (helping companies count money) and management accounting (helping companies make money).

The core goal of the integration of business and finance is to establish a mapping relationship between data in the two fields of finance and business operations, thereby allowing timely and accurate interpretation of problems in business operations from a financial perspective.

The current positive implementation of the integration of industry and finance in the technical field of Taochang Factory can be simply expressed as the following process

  • Acquiring: Collect basic financial data;

  • Industry and financial link: complete the industry and financial data;

  • Industry and finance integration: generate accounts receivable and payable documents;

  • Write-off: Settled according to accounts receivable and payable documents.

So as a financial developer we need to integrate business and finance, so that we can solve the problem of where data such as bills and financial reports come from.

? 2.1.2 Taotian Question: The code is not in place, and the capital is lost.

When it comes to capital losses, we have to mention a Chinese proverb, “If you often walk by the river, how can your shoes not get wet?”; or the foreign Murphy’s Law, “What should happen will definitely happen.” In other words, there will always be bugs in the code, there will always be times when business logic is not considered enough, there will always be times when third-party system calls do not meet expectations, etc., but there must be no capital losses.

So as a financial developer, how can you achieve no capital loss?

2.2 Technical difficulties

After talking about the business questions asked above, you have to ask these questions in actual development:

  • Business and financial data are scattered everywhere, how can they be related?

  • There are hundreds of settlement scenarios, how to quickly access them?

  • There are hundreds of bill categories, how to quickly access them?

  • With tens of billions of bills, can you hold it?

  • There are hundreds of bill categories. What should I do if my finances need to be looked at from a different angle from time to time?

  • The process is so long, how to make all the data match?

3. Core technology

Don’t worry, we all have solutions.

3.1 Fast connection: Taobao TMF 2.0

TMF, the full name of Trade Module Framwork, was born from the business scenario of Alibaba’s trading platform. On Double 11 in 2017, Alibaba’s transaction peak reached 325,000 transactions/second. At the same time, the system needs to support all transaction needs of dozens of business units across the group: we must consider how to respond to demand faster and speed up the release cycle; how to provide New small businesses provide rapid support and lower entry barriers; whether the business is open enough to enable self-service expansion; whether the new needs already have reusable assets in other business units, etc. The core architecture of TMF is as follows:

The resulting TMF successfully provides a solution for quickly connecting multiple business processes to the platform. Let’s simulate its technical implementation process in a financial settlement scenario:

  1. The logistics fee business party found you, and you followed the industry-finance integration process to realize the receipt, industry-finance link, industry-finance integration and write-off of a transaction’s logistics fees.

  2. The business side of the marketing campaign of buying a refrigerator and getting free ice trays hopes that you will also find you. You find that some information on the receipt can be reused, as can other processes, and almost the entire write-off process can be reused. You think of the design pattern. The strategy model and responsibility chain model inside encapsulate a series of strategy interfaces, allowing different businesses to implement different strategy interfaces, and decide which business logic to follow by judging the business identity.

  3. With more and more business, you will find that there are more strategic points in the process that need to be developed and implemented by the corresponding business side. At this time, the business side needs to understand the specific settlement process to achieve each point, access and debug thresholds Too high. So you introduced TMF2.0, encapsulated your policy interfaces into template classes, and developed extension points. Access users only need to implement the extension points, and some necessary logic must be specified through model verification. Logic, abstract methods, etc. will “force” the access party to implement them.

  4. There are more and more template classes, and business development still needs to sort out which extension points they need to implement. At this time, you further encapsulate the class generation logic of the extension points into an interactive GUI (we are an IDEA plug-in), and the business side only You need to fill in some information, and the corresponding classes and some common codes can be generated, so that novices know what extension points they want to implement; veterans also avoid copying and pasting.

  5. The business logic is more complex, so that the template class becomes longer and longer as it is written, so TMF can be used to encapsulate the policy interface and template class into a product that solves a common business problem, allowing business developers to directly implement the product in the form of a JAR package. specific logic, and then load the corresponding JAR package when starting the application. In fact, we have not reached step 5 yet.

In this way, we solved the problem of how to quickly access the settlement scenario.

3.2 Correct Clearance: Integration of Money and Accounts

Just like the quotation-billing-settlement-bill-invoice process introduced at the beginning, the money account has a natural sequential relationship on the business link, so whether the entire process can be automated, that is, intelligently sensing market quotations, according to After transaction billing and settlement, automatically generating bills and invoices is an issue worth considering in terms of business, efficiency and data quality. Especially in terms of data quality, only when our data is imported from the outside as little as possible and is consumed from top to bottom in the business process, can the problem of data consistency be solved naturally. The expression of money and account integration in business process:

? 3.2.1 Unification of underlying data models

Take an example of a common data model in bills, expressed as a two-dimensional table:

It can be seen that in addition to the abstracted owner_id, bill_type, and bill_id, their respective attributes are not consistent for different bills. If you want to unify these bills, you need to use the Schma-Free feature of Alibaba Cloud’s TabelStore, that is, for the wide rows of TableStore In terms of the model, each row can have different attribute columns, and there is no limit to the number of data columns. This feature well meets the problem of difficulty in abstracting and unifying different attribute columns when storing bills. At the same time, when the business changes, any attribute column changes can also be made. The unified architecture is shown in the figure below, in which hologres is selected as the database for aggregated data by taking advantage of its column storage characteristics that are suitable for OLAP.

? 3.2.2 Unification of detailed data query and download

TableStore supports JDBC syntax, and we can directly use existing SQL generation tools such as Mybatis Plus. But there is actually a simpler way, that is, because all subsequent business queries are actually a table, we can actually write a generation tool class that assembles query parameters, which can receive JSON to assemble information including different bill types. Query parameters for query and export. Taking logistics service fee query as an example, the JSON configuration is as follows:

{<!-- --></code><code> "billType":"XXX_FEE",</code><code> "billName":"XXX bill",</code><code> " fields":[</code><code> {<!-- --></code><code> "field":"a_field",</code><code> "translate":"a field"</code><code> },</code><code> {<!-- --></code><code> "field":"b_field",</code><code> "translate":" b field"</code><code> }</code><code> ],</code><code> "search":[</code><code> {<!-- --></code><code> "queryType":"TERM_QUERY",</code><code> "targetColumnName":"id",</code><code> "name":"primary key"</code><code> }</code><code> ],</code><code> "order":[</code><code> {<!-- --></code><code> "orderType":"DESC", </code><code> "targetColumnName":"a_field"</code><code> }</code><code> ]</code><code>}

The role of this string of JSON is to generate a query parameter for OTS, telling OTS which fields we want to check, what the where conditions are, and what sorting order they are based on.

? 3.2.3 Unification of aggregated data module rendering

Design diagram of data dashboard:

Make the following abstraction:

After abstracting the model, cooperate with the corresponding module loader to realize the function of inputting a JSON structure and outputting all the structures and data required by the front end. In this way, the front-end page structure can be decided by the back-end, and the front-end only needs to be responsible for the rendering logic of the corresponding module. In this way, the access speed of subsequent new classic graphics modules can be greatly accelerated. At the same time, changes in the page structure no longer require the trouble of repeated changes on the front end, and can be controlled by the back end. In addition, in addition to the page structure itself, the amount names, icons, etc. on the page are also controlled by the backend in Diamond. If there are changes, they can be changed very efficiently.

In this way, we solved the problem of how to quickly access tens of billions of bills and make all data consistent. In particular, we have to abstract the front-end graphics from time to time when looking at finance from a different perspective.

3.3 Steady conduct: before, during and after the event

? 3.3.1 Prior agreement and evaluation

Before formal development, each business access or change needs to be evaluated by the business party, product managers and senior students in the field, and the conclusions are implemented into documents for subsequent reference and focus. On the other hand, in actual development, standardized naming and type conventions will save a lot of tedious work.

? 3.3.2 In-process testing, Code Review

Test

In actual business development, the time span of the data involved in the bill is long, and the billing rules are often changing. How to cover various abnormal cases while ensuring the data quality of transformation in the long term is worth thinking about. Testing is a good means to help us discover problems as early as possible, and it is also a necessary means to ensure that unexpected changes will not occur in the long term. However, in actual production, in addition to ordinary unit testing, we may also need to develop our own tools based on business needs. For example, based on simple parameterized testing:

@ParameterizedTest</code><code>@CsvSource(value = {<!-- --></code><code> "1,2",</code><code> "3,4" </code><code>})</code><code>void should_show_how_to_parse_multi_args_with_csv(Integer in,Integer out){<!-- --></code><code> assertEquals(out,in + 1);</code><code>}

Compared with @CsvSource, the re-development of @JsonFileSource allows the incoming of objects in JSON format, and covers every historical change in billing logic, so our confidence in the correctness of data processing is greatly increased.

Code Review

The importance of CR is undoubted. It is not only the last step for code to go online, but also an important means for both CR parties to learn quickly. In Taotian, there are many seniors who write good code. Only when newcomers come to Taotian can they see the excellent code they wrote, and only then can they get CR by them.

? 3.3.3 Post-automated testing and capital loss monitoring

Automated testing

During the actual production process, every change in the previously written test will trigger its execution, thereby protecting the original logic from unexpected changes and protecting it.

In addition, when we import data into the data warehouse, we may encounter data quality errors in each step of ETL, such as:

  • If the connection to the source system is incorrect, data extraction may fail;

  • Data conversion may fail due to data type conflicts;

  • Because the data producer has added or changed storage logic, the processed data is abnormal.

Data task monitoring

For errors that are not single points in the ETL process, we monitor some data task indicators, such as quantity, feature values, non-null values, etc. In the process of long-term maintenance of data consumption logic, the data quality assurance of each record must be based on agreement and testing.

Data verification

Verification is a post-facto guarantee whether the code execution logic meets expectations. For example, if you think that one current transaction should produce two capital flows, you can check the number of transactions and capital flows of the fait accompli to know whether the running system actually guarantees that one transaction should produce two capital flows. logic.

In this way, we try our best to ensure that there is no loss of capital. That is to ensure that all fund flows are accurate.

4. Summary

The company’s financial management is far more than just sending and receiving money, and it is far more than the integration of business and finance and the integration of money and accounts. The integration of business and finance is also a very big topic, and it takes more than a few books to explain it clearly. The author’s ability is limited and I cannot fully guarantee that the concepts expressed are accurate. I hope everyone will read it critically. However, the author briefly introduced the integration of business and finance and the integration of money and accounts. I don’t know if it has aroused a little bit of interest among you outstanding people. Come and join us!

If you are interested in financial technology, please send us an email: [email protected] to communicate more and hope to work with you!

The knowledge points of the article match the official knowledge files, and you can further learn related knowledge. Java skill treeUse JDBC to operate the databaseDatabase operation 139421 people are learning the system