Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Idea sharing of PHP Red packet algorithm

2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article introduces the knowledge of "the idea sharing of PHP red packet algorithm". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

PHP red packet algorithm

According to the usage scenarios of many requirements, such as sending red packets and bargaining, these two features have the same feature, as follows:

Red packet

1. Total amount

two。 Number of red packets

3. Minimum number of red packets

Bargain price

1. Total amount of bargain

two。 How many people are needed to complete the bargain (the number depends on demand)

Fixed number of bargainers

The number of random bargains

Specify the number of random bargains

Point 2. All three rules need to draw a number of people according to the rules.

3. Minimum bargain amount

Development ideas

The minimum amount of verification parameter is not allowed to be less than 0

The total amount is not allowed to be greater than the quantity multiplied by the minimum amount to allocate the amount

Get the average amount (total amount / remaining amount)

If the average amount is less than or equal to the maximum amount, the minimum amount will be allocated directly.

The minimum value of the amount range ratio is not allowed to be less than-1, and the maximum value is not allowed to be greater than 1.

Calculate the range of the allocated amount (average * (1 + amplitude ratio))

Allocation amount determines that when the allocation amount is less than the minimum amount or the allocation amount is greater than the maximum amount available ((minimum amount + remaining total amount)-(remaining amount × minimum amount)), redistribute amount

If the last one is left, all the remaining amounts will be allocated.

Development code

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report