加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

PHP拼多多模式,砍价免费拿商品算法

发布时间:2020-12-13 21:30:25 所属栏目:PHP教程 来源:网络整理
导读:? ? 我12年开始做网站,对拼多多关注两三年了,一直对他们的拉新模式很感兴趣,下面我对砍价送礼品的算法跟大家分享下。 ? 拼多多砍价免费拿商品有几个核心的东西: 1.需要拉新多人给商品,这个是直接在数据库配置的 2.是否给商品,如果不想给商品,系统会在

?

?

我12年开始做网站,对拼多多关注两三年了,一直对他们的拉新模式很感兴趣,下面我对砍价送礼品的算法跟大家分享下。

?

拼多多砍价免费拿商品有几个核心的东西:

1.需要拉新多人给商品,这个是直接在数据库配置的

2.是否给商品,如果不想给商品,系统会在接近砍价成功时候,不断返回小金额的砍价,如果金额小于0.01,无论是新的粉丝来砍价还是老会员,都会直接返回0.00元,永远无法砍价到。

3.不满足拉新人数要求,如果砍刀均价已经达到临界值0.01元,都会直接返回0.00元,直到拉新任务完成。

<?php /**拼多多砍价算法 * Created by PhpStorm. * Website

//www.youhuajun.com * User: Benjamin * Date: 2019/9/6 * Time: 9:15 */ class Pinduoduo { /**计算本次折扣金额 * @param $price商品单价 * @param $currentPrice当前商品价格,即折扣后的价格 * @param $followerCount当前拉新人数 * @param $needCount所需拉新人数 * @param $willSucess是否给钱,默认是给钱,不给钱永远砍价不到 */ public function caculateDiscountAmount($price,$currentPrice,$followerCount,$needCount,$isNewFollower=false,$willSucess=true){ if($isNewFollower==false){ $followerCount = $followerCount+1; } $rate = $currentPrice/$price; switch($rate){ case 0.2 <= $rate && $rate<=1: $averageMoney = $followerCount/$needCount; $discountMoney = $this->makeDiscountAmount($currentPrice,$averageMoney); break; case 0 <= $rate && $rate<0.2: $averageMoney = $followerCount/$needCount; //接近价格,但是没有满足人数,直接返回0元 if($averageMoney <= ‘0.01‘&&$followerCount < $needCount){ $discountMoney = ‘0.00‘; break; } $discountMoney = $this->makeDiscountAmount($currentPrice,$averageMoney); //不给商品的,永远无法达到条件 if($willSucess==false){ if(($currentPrice-$discountMoney)<=0){ $discountMoney = ‘0.00‘; } break; } if($isNewFollower==false){ $discountMoney = sprintf("%.2f",$discountMoney/5); if($averageMoney<0.5){ $discountMoney = sprintf("%.2f",$discountMoney/20); } } break; default: $discountMoney = ‘0.00‘; } return $discountMoney; } /**计算指定条件砍价金额 * @param $currentPrice当前价格 * @param $averageMoney平均折扣 * @param int $step * @return float */ private function makeDiscountAmount($currentPrice,$averageMoney,$step=5){ $discountMoney = $currentPrice/$step; if($discountMoney>$averageMoney){ $this->makeDiscountAmount($currentPrice,$step=1); }

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读