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

 

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

我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,$averageMoney,$step

转载于:https://www.cnblogs.com/jianqingwang/p/11474363.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值