步力宝模式系统介绍:步力宝系统开发:15889726201
1、创客:购买398元养生鞋一双,直推奖励:128元
2、区县代理:
①直推5名创客,
②团队销量累积20双
直推奖励:①164元
级差奖励:①并享受创客团队下单,36元每双
3、市级代理:
①直推10名创客,
②培养2个区县代理且在不同的直推线,
③团队销量累计100双
直推奖励:①190元
级差奖励:
①享受创客团队下单,62元每双,
②享受区县代理团队下单,26元每双
平级奖:享受市级代理团队下单,5元每双
4、省级代理:
①直推15名创客,
②培养出2个市级代理,且在不同的直推线,
③团队累计销量600双
直推奖励:208元;
级差奖励:
①享受创客团队下单,80元每双
②享受区县代理团队下单44元每双,
③享受与市级代理团队下单18元每双
平级奖:享受省级代理团队下单,6元每双
步力宝商城会员升级核心源码
public function detection(int $uid)
{
//商城会员是否开启
if (!sys_config(‘member_func_status’)) {
return true;
}
/** @var UserServices $userServices */
$userServices = app()->make(UserServices::class);
$user = $userServices->getUserInfo($uid);
if (!$user) {
throw new ApiException(410284);
}
/** @var SystemUserLevelServices $systemUserLevel */
$systemUserLevel = app()->make(SystemUserLevelServices::class);
$userAllLevel = $systemUserLevel->getList([[‘is_del’, ‘=’, 0], [‘is_show’, ‘=’, 1], [‘id’, ‘>’, $user[‘level’]]]);
if (!$userAllLevel) {
return true;
}
$data = [];
$data[‘add_time’] = time();
$userLevel = $this->dao->getColumn([‘uid’ => $uid, ‘status’ => 1, ‘is_del’ => 0], ‘level_id’);
$level_id = 0;
foreach ($userAllLevel as $vipinfo) {
$is_update = false;
/*if (in_array($vipinfo[‘id’], $userLevel)) {
continue;
}*/
//必须自购1双。
if( $user[‘buy_num’] < 1 )
break;
$total_num = $user[‘buy_num’] + $user[‘buy_team_num’];
if( $vipinfo[‘buy_num’] > 0)
{
if( $total_num < $vipinfo[‘buy_num’] )
continue;
$is_update = true;
}
//判断团队购买数量
if( $vipinfo[‘team_num’] > 0)
{
if( $total_num < $vipinfo[‘team_num’] )
continue;
$is_update = true;
}
/*if( in_array($vipinfo[‘id’],[‘2′,’3′,’4’]) )
{
//改成计算自购和团队总和
$total_num = $user[‘buy_num’] + $user[‘buy_team_num’];
//等级为2,3,4时。满足其中一个即可。
if( $vipinfo[‘buy_num’] > 0)
{
if( $total_num >= $vipinfo[‘buy_num’] )
$is_update = true;
}
if( $vipinfo[‘team_num’] > 0)
{
if( $total_num >= $vipinfo[‘team_num’] )
$is_update = true;
}
if( ! $is_update )
continue;
} else {
//判断自购数量
if( $vipinfo[‘buy_num’] > 0)
{
if( $user[‘buy_num’] < $vipinfo[‘buy_num’] )
continue;
$is_update = true;
}
//判断团队购买数量
if( $vipinfo[‘team_num’] > 0)
{
if( $user[‘buy_team_num’] < $vipinfo[‘team_num’] )
continue;
$is_update = true;
}
}*/
//判断直推董事数量
if( $vipinfo[‘spread_vip5’] > 0)
{
if( User::where(‘spread_uid’,$user[‘uid’])->where(‘level’,’>’,’4′)->count() < $vipinfo[‘spread_vip5’] )
continue;
$is_update = true;
}
if( $vipinfo[‘xiaoqu_yeji’] > 0 )
{
if( User::where(‘spread_uid’,$user[‘uid’])->where(‘buy_team_num’,’>=’,$vipinfo[‘xiaoqu_yeji’])->count() < 2 )
continue;
$is_update = true;
}
if( ! $is_update )
continue;
$data[‘mark’] = ‘尊敬的用户’ . $user[‘nickname’] . ‘在’ . date(‘Y-m-d H:i:s’, time()) . ‘成为了’ . $vipinfo[‘name’];
$uservip = $this->dao->getOne([‘uid’ => $uid, ‘level_id’ => $vipinfo[‘id’]]);
if ($uservip) {
//降级在升级情况
$data[‘status’] = 1;
$data[‘is_del’] = 0;
if (!$this->dao->update($uservip[‘id’], $data, ‘id’)) {
throw new ApiException(410285);
}
} else {
$data = array_merge($data, [
‘is_forever’ => $vipinfo[‘is_forever’],
‘status’ => 1,
‘is_del’ => 0,
‘grade’ => $vipinfo[‘grade’],
‘uid’ => $uid,
‘level_id’ => $vipinfo[‘id’],
‘discount’ => $vipinfo[‘discount’],
]);
if (!$this->dao->save($data)) {
throw new ApiException(410285);
}
}
$data[‘add_time’] += 1;
$level_id = $vipinfo[‘grade’];
}
if( $level_id > 0 )
{
if (!$userServices->update($uid, [‘level’ => $level_id], ‘uid’)) {
throw new ApiException(410285);
}
}
return true;
}
步力宝商城分销奖励核心源码
public function sendLevelDiffReward( $goods_info,$up_level,$uid,$ouid,$oid)
{
$spread_uid = User::where(‘uid’,$uid)->value(‘spread_uid’);
if( $spread_uid < 1 )
return false;
if( SystemUserLevel::where(‘id’,’>’,$up_level)->count() < 1 )
return false;
$spread_level = User::where(‘uid’,$spread_uid)->value(‘level’);
//如果上级等级比我的小
if( $spread_level > $up_level )
{
$total_reward = 0;
//计算出奖励金额
foreach ( $goods_info as $val )
{
$discount_name = $val[‘discount_type’] == 1 ? ‘discount’ : ‘discount2’;
//获取上次的折扣比例
if( $up_level < 1)
{
$up_rate = 100;
} else {
$up_rate = SystemUserLevel::where(‘id’,$up_level)->value($discount_name);
}
//获取上级的折扣比例
$spread_rate = SystemUserLevel::where(‘id’,$spread_level)->value($discount_name);
//如果折扣相同,或者上次比例比上级比例更低,则不进行计算
if( $up_rate <= $spread_rate )
continue;
$reward_rate = bcsub($up_rate,$spread_rate,2);
$reward = bcmul($val[‘total_price’],bcdiv($reward_rate,100,4),2);
//总奖励金额
$total_reward = bcadd($total_reward,$reward,2);
}
if( $total_reward > 0 )
{
/** @var UserMoneyServices $services */
$services = app()->make(UserMoneyServices::class);
User::where(‘uid’,$spread_uid)->inc(‘now_money’,$total_reward)->update();
$balance = User::where(‘uid’,$spread_uid)->value(‘now_money’);
$services->income(‘level_diff_reward’,$spread_uid,[‘number’=>$total_reward,’uid’=>$ouid],$balance,$oid);
}
//继续查找上级
$this->sendLevelDiffReward($goods_info,$spread_level,$spread_uid,$ouid,$oid);
} else {
//跳过,继续向上找
$this->sendLevelDiffReward($goods_info,$up_level,$spread_uid,$ouid,$oid);
}
}