My Internet of Things Project (4) Order System

The order system is an independent core business process of the entire platform. It is not complicated in itself. The original original requirements are as follows:

1. The user opens the app and logs in to the main interface.
2. Click scan code, scan the code and shake the QR code on the body.
3. The app displays the deduction and shakes it to start.
4. The user order center displays the consumption details, and the merchant order center displays the income details.

The thinking habit formed by writing code for a long time, the mind immediately became obsessed, and a picture emerged:
there is a rocking car on the side of the road, user Zhang San opens the app, and can't wait to scan the code to rock the car, the system prompts, not logged in, Zhang 3. Enter the mobile phone number and password, log in successfully, and you can scan the code. At this time, the system prompts that the money is not enough. Zhang San can only recharge through the app. After the recharge is successful, continue to scan the code and shake the car. 1 yuan, after 1 second, the shake is activated, and the user can see the details of each consumption in the user center. The merchant can log in to the merchant center through WeChat to check the daily income. After reaching a certain amount of funds, you can apply for cash withdrawal.

From this requirement, we probably know how an overall process should go. The next thing to do is to design functions according to specific business scenarios. It is still the inertial thinking of programmers. The first thing that comes to mind is: the user clicks the scan code to shake the car, and then How to interact with the process of rocking the car to start?
In fact, as I mentioned earlier, the rocking car signal starts this process, and someone is already researching and getting it through. The software only needs to send the relevant protocol. Since the hardware side is in C language, it needs to be considered what method of communication between the two sides is used. Of course, the IoT project is relatively mature now, and there are a lot of related solutions. We use the platform of Alibaba Cloud, and Alibaba Cloud has already provided the entire solution of the IoT suite. We use the MQTT protocol as an interaction center between software and hardware. Just by listening to the name of MQTT, you probably know that MQTT belongs to message middleware. It is slightly different from traditional MQ series products (such as RabbitMQ, ActiveMQ, etc.). The MQTT protocol is for A protocol designed for communication of remote sensors and control devices with limited computing power and working on low-bandwidth, unreliable networks, mainly for small transmissions, with low overhead (fixed-length header is 2 bytes), protocol exchange Minimize to reduce network traffic, such as shaking the car (a smart box is installed on the body of the shaking car, there is a 2G traffic card in the box, and the box sends a signal to the shaking car) This is the business of 2G traffic card. It is very suitable for this.

The general communication process is as simple as this: the software application layer sends the protocol to the MQTT middleware, shakes the box on the body to subscribe to the message, and once the message is received, the box sends a start command to the shaker to start it.

Therefore, the first release process of the order system is as follows:



Note: Due to some secrets of the platform, it is impossible for the order system to describe in detail how to pass a certain parameter, how to query the database, or even paste the core code. If you are interested Technical friends, you can discuss it separately!

The overall functional development is almost the same. Once the core backbone process is completed (it has taken about a month and a half to the first version), of course, we can't wait to put it into the market for model verification. The background of the platform is generating order data one after another. This process will definitely greatly improve morale. Everyone sees hope. In the first 2 or 3 weeks, the bosses are staring at the order page of the operating platform all day and constantly refresh the order records. , every time I see a user top-up order, I am ecstatic.

The road to starting a business is hard. In fact, what every entrepreneur really strives for is not a pure market profit model, nor just a management strategy. I always think that how far a startup can go depends on everyone on this road. How far. At the same time, you can only see further by walking further. Therefore, keeping everything simple, maximizing all interests, and maximizing efficiency are the principles.

Due to the lack of experience in the industry, the rush of time and other reasons, the first version of the online order system has the following bugs:

1. The user app scans the code to determine whether the current vehicle (equipment) is online. If it is online, the user will be deducted. fee, and then send the protocol to MQTT. The judgment device in this version uses a public interface provided by Alibaba Cloud, and Alibaba Cloud later pointed out that this interface cannot be used for the main core business processes, especially the frequently used business scenarios. The device is not actually online, but the user continues to deduct the fee and send the protocol to MQTT. Of course, because the box is not online, the start command will not be sent to the rocker, but the rocker does not start. As a result, during that time, the customer service refunded the fees one by one in the background (the refund is based on the flow chart above. If the box subscribes to the message, it will modify the database status through the order number to know whether the box has been sent or not started. command).

2. Under normal circumstances, the overall process of the device is really online, but at the end of the device (see my picture), the box accepts the start command and sends the command to the rocking cart. This process does not necessarily start 100% of the rocking cart. , the reason is the immature hardware of the rocking car itself. This is completely embarrassing. The device is online, the user is charged, the MQTT protocol is sent, the device subscribes to the message, and the database status is modified to indicate that the start command is sent to the rocker, but the rocker is not started, and there is no way to check it. There is no evidence to retain, the only solution at that time is to try to send users some car rolls for low-key comfort.

Therefore, after discussion, the modification is as follows. When it is determined that the device has returned, the order is placed, that is, the order is placed at the MQTT application layer.



This is the second release of the order process system. After about a week, it was re-optimized. The reason is that there is still a problem, that is, the box sends the command to the rocking cart and it is still not 100% reliable to start, so that if the user scans The code has not been activated, although the fee has not been deducted, but the platform has not placed an order, there is no order basis, and the user experience is not good. At the beginning, due to the limitations of the hardware side, the process on the device side could not be done: the box accepts the start command, sends the command to the rocker, the rocker receives the command and replies to the box, and the box returns the information to MQTT at this time.



The current hardware conditions are not able to perform this process for the time being. The order system is reissued for the third time. The main changes are as follows:

1. The user scans the code and shakes the car. If the device is online and the account balance is sufficient, the next withholding will be made first. order, and then send the protocol to MQTT.

2. The box monitors the MQTT message, receives the message, sends the start command to the shaker, and then reports the message (sends the command to MQTT).

3. The MQTT application side monitors the reported message, receives the message, and checks the serial number certificate. Only then does the specific order business, including user deduction, merchant share, and order status modification.




Although this revision improves the user's no response after scanning the code, and there is a certificate for data tracking, the user experience is relatively improved, but the box sends the start command to the rocking cart and the box reports the message to MQTT. It is still a parallel operation, and there is still a box. Sending the start command to the rocker may not start normally (including the problem of the rocker itself), so the quality of the rocker itself, including the implementation of the starting technology, needs to be continuously improved.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326327729&siteId=291194637