ArticleDirectory
- 1.1 quotation Management
- 1.2 non-use mode solution
- 1.3 what's the problem?
Author: Yunfei Longxing published on read: 1082 comments: 4
First of all, I would like to thank many of my friends for their support, comments, and encouragement. I only have to work hard and write some blog posts to reward everyone for their kindness!
Next, I want to write another mode that is simple but frequently used-Rule mode.
Strategy 1 Scenario 1.1 quotation Management
It is a very important and complex issue for customers in the Sales Department. For example:
(1) The full price is reported to common customers or new customers.
(2) discounts for the prices quoted by old customers based on the customer's service life
(3) A certain discount is given to the price quoted by the major account based on the cumulative consumption amount of the major account
(4) The customer's purchase quantity and amount should also be considered. For example, although the customer is a new user, the quantity of one purchase is very large, or the total amount is very high, there will be a certain discount.
(5) In addition, the quoter's position also determines whether he has the permission to make a certain floating discount on the price.
Even in different stages, the prices for customers are also different. Generally, the quotation is relatively high at the beginning, and the closer it is to the deal stage, the more reasonable it is.
In short, the quotation to the customer is very complicated. Therefore, in some CRM (Customer Relationship Management) systems, there is a separate quotation management module to process complicated quotation functions.
To simplify the demo, we assume that a simplified quote management is required to implement the following functions:
(1) report full price to common customers or new customers
(2) a 5% discount for the prices quoted by old customers
(3) A unified discount of 10% for prices quoted by major customers
How can this problem be achieved?
1.2 non-use mode solution
To enable the function of reporting different prices to different personnel, it is difficult to judge. Soon, a friend can write the following implementation:CodeThe sample code is as follows:
/** * Price management: Mainly used to calculate the price quoted to the customer */ Public class price { /** * Quote, calculate different prices for different types * @ Param goodsprice original price * @ Param customertype customer type * @ Return: the price that should be quoted to the customer */ Public double quote (double goodsprice, string customertype ){ If (customertype. Equals ("regular customer ")){ System.Out. Println ("No discounts for new customers or common customers "); Return goodsprice; } Else if (customertype. Equals ("old customer ")){ System.Out. Println ("5% discount for old customers "); Return goodsprice * (1-0.05 ); } Else if (customertype. Equals ("major account ")){ System.Out. Println ("10% discount for major customers "); Return goodsprice * (1-0.1 ); } // The remaining personnel are quoted as original price Return goodsprice; } } |
1.3 what's the problem?
The above statement is very simple and easy to think about, but if you think about it, the problem is not small. For example:
(1) first question: the price class contains all the quotation calculation items.AlgorithmThe pricing method, especially the quotation method, is complex and difficult to maintain.
Some may think that this is very simple. Can we take these algorithms out of the quote method and form an independent method to solve this problem? Write the following implementation code. The sample code is as follows:
/** * Price management: Mainly used to calculate the price quoted to the customer */ Public class price { /** * Quote, calculate different prices for different types * @ Param goodsprice original price * @ Param customertype customer type * @ Return: the price that should be quoted to the customer */ Public double quote (double goodsprice, string customertype ){ If (customertype. Equals ("regular customer ")){ Return this. calcpricefornormal (goodsprice ); } Else if (customertype. Equals ("old customer ")){ Return this. calcpriceforold (goodsprice ); } Else if (customertype. Equals ("major account ")){ Return this. calcpriceforlarge (goodsprice ); } // The remaining personnel are quoted as original price Return goodsprice; } /** * Calculate the quoted price for a new or common customer * @ Param goodsprice original price * @ Return: the price that should be quoted to the customer */ Private double calcpricefornormal (double goodsprice ){ System.Out. Println ("No discounts for new customers or common customers "); Return goodsprice; } /** * Calculate the quoted price for old customers * @ Param goodsprice original price * @ Return: the price that should be quoted to the customer */ Private double calcpriceforold (double goodsprice ){ System.Out. Println ("5% discount for old customers "); Return goodsprice * (1-0.05 ); } /** * Calculate the quoted price for major customers * @ Param goodsprice original price * @ Return: the price that should be quoted to the customer */ Private double calcpriceforlarge (double goodsprice ){ System.Out. Println ("10% discount for major customers "); Return goodsprice * (1-0.1 ); } } |
This looks a little better than it was at the beginning, and the method for calculating the quotation will be slightly simpler, so the maintenance will be slightly better, and a certain algorithm has changed, you can directly modify the corresponding private method. It is easier to scale up. For example, if you want to add a "Strategic Partner Customer" type, the price is off, you only need to add a private method in the price class to calculate the new price, and then add an else-if in the quote calculation method. It looks pretty good.
Is it really good?
Think about the problem, but it's just moving from the quote calculation method to the price class. If there are 100 or more such calculation methods, this will make the price class very huge, difficult to maintain. In addition, maintenance and expansion both need to modify the existing code, which is very bad and violates the open-close principle.
(2) The second problem: it is often necessary to use different computing methods at different times.
For example, during the company's anniversary, all customers will receive an additional 3% discount. during seasonal promotions, regular customers will receive an additional 2% discount, while regular customers will receive an additional 3% discount, major customers increase the discount by 5%. This means that the quote calculation method is often modified or switched.
Usually it should be switched, because after the promotion time, it is still back to the normal price system. In the current price category, the quote calculation method is fixed to call various calculation methods, which makes it difficult to switch and call different calculation methods, you need to modify the call code in if-else every time.
Some may think,So how should we implement it so that the price calculation algorithm in the price class can easily implement maintenance, scalability, and dynamic switching?
To be continued ......
Comment: 4 view comments and post comments
Annual software R & D team management conference (Shanghai, 7.10-7.11)
Latest news:
· Run Ubuntu video display in hd2 again with WM)
· Apple launched its mobile advertising platform, Iads, with orders worth $60 million)
· 50 ultra-convenient tools provided by web designers (below))
· Municipal Adjustment Company: the global market share of IE browser has finally begun to rise)
Cisco promises to launch Flip cameras that support WiFi and video clients that support FaceTime)
Recommended for editing: domain-driven design practices
website navigation: blog home page personal homepage news flash team blog community knowledge base