Project introduction

  • Project name: it is not convenient to reveal
  • Company size: The whole project was about 10 people at the front and back end, no testing, no testing before the first release.
  • Number of users: The average number of each school on the saas platform is 3,000 to 4,000, and the school with the largest formal environment has more than 20,000 students and parents. During the rush hour, when every student swiped their card, the number of notifications was terrifying.
  • Project: With the help of the enterprise wechat platform, develop the application on the enterprise wechat platform, and let the school users install the application we developed and use it through the school’s enterprise wechat. Different roles can see different application lists in enterprise wechat. Users can click on the application to jump to the project business platform to do business. Enterprise wechat message push involves the notification of teachers and students and attendance, and attendance is connected to enterprise wechat push message through the application of “intelligent security”. A home-school communication solution integrating teachers, schools and parents was formed. At that time, Tencent’s own enterprise wechat background home-school communication module had not yet been developed.
  • Main core applications: personal center, notification of homework, intelligent security, class album, address book, etc. Some snapshots of mobile applications are as follows:

Intelligent securityPersonal centerThe address book

  • Responsibilities: Back-end Java development.
  • Tasks: Enterprise wechat interface API development, including enterprise wechat application authorization installation, address book management development, application home page development, data callback development, instruction callback development, application menu interface development, etc., sorting out business and enterprise wechat message push logic, etc.
  • Main technology stack: Enterprise wechat HTTP interface API, back-end: Springboot + Spring + Mybatis +mysql, cache: Redis, message middleware: RaabitMq
  • Development premise: the unit applying for enterprise wechat as a service provider must have the domain name of port 80 or port 443 for the record.

Project background

  • Background: One day, it was sunny and sunny. As I had only been in the company for less than half a year, I was writing about the interface and paddling around. Suddenly, I was called to the office by the leader. Added 19 years recruit the most worthy person is me (probably because I’m going to low wages) don’t fool me, just as I was thinking as he spoke of leadership: the client right now, “he said to put one million on the table, see we have ability to get, now the customer request our own WeChat apps to the enterprise, enterprise WeChat? When I know wechat public number, small program, enterprise wechat is what? I have no idea. Do we have our own app? No, has anyone ever contacted and developed enterprise wechat? No? So your task now is to study the enterprise wechat API for two weeks, and after a month, you need to release a version of the enterprise wechat based application. I touch my hair is still thick head out to study enterprise wechat, the pit road opened.

Locked up in a dark room 997

  1. Service division: First split four services: wechat user center (and enterprise wechat docking and message push), agent distribution service (enterprise wechat application main jump agent layer is mainly for user authentication and user traffic distribution), core business service (main business), user center service (existing).
  2. I was mainly responsible for the wechat User Center at that time, and the leader personally took charge of the agent distribution service module.
  3. As I was completely unfamiliar with the enterprise wechat API, I could understand all the official documents, but I could not understand the main logic, and there was no product to refer to. Totally hard look, experiment write. On the road of trial and error tottering wechat API address.
  4. Locked office, 997 began to study everyday WeChat interface, 3, 4 am in the south third ring road often meet, said a digression, then ride a bike to go home at three o ‘clock in the morning, walk under the viaduct was wild dogs chase, almost chewed me a month didn’t come and wash jeans, once thought do daughter-in-law not allowed to sleep in the company.
  5. From wechat application general parameter configuration, to enterprise wechat to obtain third-party credentials, obtain pre-authorization code, set authorization configuration, obtain enterprise permanent authorization code, obtain enterprise authorization information, obtain enterprise credentials, and then to obtain enterprise wechat personal information. All developed by me, the last micro channel service number, micro channel small program are integrated into the micro channel service center this is later. Later business modules are also involved in the development, pure business logic will not be described here.
  6. Within 30 days, four applications have been completed, which can be installed on the enterprise wechat of the school. So far, more than 50 applications have been connected, involving campus payment, attendance, micro official website, intelligent marking, online homework and so on.
  7. Other effects: the performance of that month was A. The salary increased by 1000 yuan half A year after I joined the company, but the salary was too low to save my life. In the end, I was responsible for the whole project both internally and externally.
  8. Screenshot of the code of wechat Service center. To prove that I actually wrote it.

  1. The main business flow chart and capability center are the initial version of wechat service center.

  1. A screenshot of part of wechat enterprise wechat.

Conclusion thinking

  • First pit: WeChat application gateway service center, is the customer click the entry application modules, and customer accept the message module is placed in a service, leading to a large amount of news service is not available, all affect the enterprise WeChat application is not available, the mean message module affect the user experience, finally into application service and message module menu module.
  • The second pit: because the enterprise wechat interface to call the token for the same IP and the same period of time is limited, the enterprise wechat token I start with the local cache redis 2 hours expired, after the expiration of the enterprise wechat interface request, after the request is successful and then cached to the local Redis. It seems that there is no problem, but if many requests are made in the second after the expiration, they will call the interface of enterprise wechat to obtain the token, resulting in the interface exceeding the limit and unable to obtain the token. My stupid solution to this solution is to set up a service to obtain the token from enterprise wechat in one hour and 59 minutes. Then update the token to Redis to ensure that the token of the same enterprise wechat in Redis will never expire.
  • The third pit: there was not much data in the local test once, and it took too long for a school with more than 10,000 people to pull the data from the school’s address book online (the old user center could not change it). Solution: add redis cache temporarily when going online, sacrifice certain consistency to ensure the final consistency of data, and fetch data from Redis every time. Modify school user data in the Redis cache by using scheduled tasks or adding and modifying interfaces. Lesson: It is best that the test environment is exactly the same as the official environment, after which we usually test it again during pre-release.
  • The fourth pit: it is the only pit I stayed up all night. Once in a test, I found that the redirection code of enterprise wechat OAuth2.0 had been reported to have been used. However, I could not find the reason. When you can’t find a problem, make sure the code is ok, look outside the programmer’s box, and ignore formal and testing conditional HTTP requests in such a way that HTTPS requests are not easily hijacked.

It turned out to be a small project bonus

One sunny afternoon a year later, I was called by the leader to give us a small project bonus as a reward for being locked up in a dark room.

The mystery of the project remains unsolved

At that time, there were really a million customers waiting for the enterprise wechat project?

note

This article is participating in the “Nuggets 2021 Spring Recruiting activity”, click to see the details of the activity