Java fresh e-commerce platform - "another order" functional architecture and detailed design in e-commerce (APP / applet)
Note: in the actual business scenario (no matter TO B or TO C), whether it's leisure food, catering, fruit, daily necessities, mother and baby and other high-frequency purchasing industries, or other industries, "another order" can greatly shorten the buyer's re order process and promote transformation.
So there is a "one more order" function for fresh e-commerce platform. As long as the buyer clicks "one more order" in the order list, order details or payment success, the goods in the order can be added to the shopping cart again, which is convenient, fast and efficient
The above words can be summed up as "another order" and the following information
1. The function of another order is in the order list or order details, or in payment success
2. The user clicks "another order" to add the goods to the shopping cart
3. The purpose is to facilitate the user to place an order again by adding the shopping cart
The simple flow chart is as follows:
For this basic flow chart, I have the following thoughts:
-
What is another order?
2. Why do you want to make another one?
3. How to make a single? How to judge and deal with business logic?
4. How about the final code and actual combat?
1. What is another order?
Note: another order is a process of ordering the products that have been purchased conveniently again according to human inertia and inertia.
2. Why do you want to make another one?
Note: convenient and fast service users, whether TOB or TOC user groups, have a very fast and efficient function click again, which has very significant characteristics and click volume in promoting purchasing power
3. How to make another one? How to judge and deal with business logic?
Note: through the above analysis, we find that the function of the second order has the following features:
1. The function of another order is in the order list or order details, or in payment success
2. The user clicks "another order" to add the goods to the shopping cart
3. The purpose is to facilitate the user to place an order again by adding the shopping cart
Since "another order" exists in any order, there may be some historical orders with a long time. When you click Add to the shopping cart and jump to the shopping cart page, you will see that the goods have been removed from the shelves
Price has changed and so on. How should businesses judge and deal with it at this time?
First look at the basic flow chart:
In fact, the core judgment is three points:
1. Judge whether the goods are off the shelves. The goods removed from the shelves are simply and roughly handled without display. Or when you join the shopping cart, the display will be off the shelf.
2. To judge whether there is any change in the commodity price, regardless of whether there is any change, it is necessary to obtain the latest price. What can be done better here is to compare the original price, indicating that it is price reduction and price increase
3. Judge whether the goods are still in stock. If there is no stock, it can also be added to the reminder of lack of stock, but it can not be used as the basis for order submission.
4. How about the final code and actual combat?
/** * Another order. * @param userId * @param orderId */ @Override public void copyOrderToCart(Integer userId, Integer orderId) throws ServiceException { List<OrderGoods> orderGoodsList = orderGoodsService.getListOrderGoodsByOrderId(orderId); if(CollectionUtils.isEmpty(orderGoodsList)) { throw new ServiceException(ServiceExceptionCode.PARAM_INVALID.getCode(), "Another item list cannot be empty"); } List<Cart> resultCartList = new ArrayList<Cart>(); for(OrderGoods orderGoods : orderGoodsList) { //Judge whether goods can be purchased Goods goods = goodsService.findById(orderGoods.getGoodsId()); //Object is not empty, and goods are on sale if (goods != null && goods.getOnSale()) { //Determine whether this specification exists in the shopping cart Cart existCart = queryExist(goods.getId(), userId); if (existCart == null) { //Get specification information,Judge specification stock Cart cart = new Cart(); cart.setUserId(userId); cart.setGoodsId(orderGoods.getGoodsId()); cart.setGoodsSn(orderGoods.getGoodsSn()); cart.setGoodsName(orderGoods.getGoodsName()); cart.setPicUrl(orderGoods.getPicUrl()); cart.setChecked(true); cart.setNumber(orderGoods.getNumber()); cart.setPrice(orderGoods.getPrice()); cart.setAddTime(LocalDateTime.now()); cart.setUpdateTime(LocalDateTime.now()); cart.setDeleted(false); resultCartList.add(cart); } else { //Obtain inventory of goods int num = existCart.getNumber() + orderGoods.getNumber(); if (num <= orderGoods.getNumber()) { //If the stock is enough,Update cart existCart.setNumber(num); cartMapper.updateCart(existCart); } } } } if(CollectionUtils.isNotEmpty(resultCartList)) { //New batch addition cartMapper.batchAddCart(resultCartList); } }
The relevant rules are summarized as follows:
1. Add "another order" to the order list of the buyer side applet and the order whose details meet the conditions, and support one click to add the goods in the order to the shopping cart;
2. At present, the goods supported for another order are ordinary orders of physical goods type, and marketing activity orders such as cycle purchase and group buying are not supported;
3. The "next order" button position is arranged according to the corresponding order status and the priority of each operation button;
4. Click "another order" to add the batch of goods in the current order to the shopping cart, and the information such as product specification, quantity and product message will take the settings of the current order;
5. If the same item already exists in the original shopping cart, the "next order" will not delete the original item, but will overlap in quantity;
6. When clicking another order, the product price and specification information may have changed. Click "another order" to recheck. Currently, price calculation of all marketing activities only supports limited time discount, user-defined member price and member discount;
7. When clicking another order, if there is any increase or decrease in the item message field, it will be rechecked, and unqualified products will be prompted that another order is not supported;
8. One more order for multiple products in batch. If some products are not supported, the supported products will be added to the shopping cart. If not, a prompt will be given.
The final example is as follows:
Screenshot of actual operation:
Contact QQ: 137071249
QQ group: 793305035