| | |
| | | // 获取下级用户的推荐人(即上级用户) |
| | | $superiorUser = UserModel::detail($model['vip_area_user_id']); |
| | | if ($superiorUser && $superiorUser['referee_id']) { |
| | | $vipUser = VipUserModel::detail($superiorUser['vip_area_user_id']); |
| | | if ($vipUser['grade']['operating_subsidy'] > 0) { |
| | | // 获取补贴比例设置 |
| | | $subsidyRate = $vipUser['grade']['operating_subsidy']; |
| | | // 计算下级收益补贴 |
| | | $subsidyAmount = bcmul($model['vip_area_money'], bcdiv((string)$subsidyRate, '100', 4), 2); |
| | | User::grantMoney($superiorUser['referee_id'], $subsidyAmount, '下级收益补贴'); |
| | | // 记录分销订单 |
| | | self::createDistributionOrder($order, $superiorUser['referee_id'], $subsidyAmount, 'vip_subsidy', $model['vip_area_money']); |
| | | if (UserModel::getOperatingSubsidy($superiorUser['referee_id'],Setting::getItem('basic', $order['app_id']))){ |
| | | $vipUser = VipUserModel::detail($superiorUser['referee_id']); |
| | | if (!empty($vipUser)){ |
| | | if ($vipUser['grade']['operating_subsidy'] > 0) { |
| | | // 获取补贴比例设置 |
| | | $subsidyRate = $vipUser['grade']['operating_subsidy']; |
| | | // 计算下级收益补贴 |
| | | $subsidyAmount = bcmul($model['vip_area_money'], bcdiv((string)$subsidyRate, '100', 4), 2); |
| | | User::grantMoney($superiorUser['referee_id'], $subsidyAmount, '下级收益补贴'); |
| | | // 记录分销订单 |
| | | self::createDistributionOrder($order, $superiorUser['referee_id'], $subsidyAmount, 'vip_subsidy', $model['vip_area_money']); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | |
| | | $viewpoint_money = bcadd($viewpoint_money, ($product['is_viewpoint_money'] ? $product['viewpoint_money'] : $vipGrade['viewpoint_money']), 2); |
| | | }*/ |
| | | if (in_array($product['product_id'], $config['become__buy_product_ids']) || $product['is_vip']) { |
| | | // 获取商品数量 |
| | | // 获取VIP专区商品数量 |
| | | $vip_quantity = bcadd($vip_quantity, $product['total_num'], 2); |
| | | // 为每个商品生成分红订单 |
| | | /*for ($i = 0; $i < $quantity; $i++) { |
| | |
| | | if ($setting['jcaward']){ |
| | | $refereeJc=User::getAllJcUser($userModel['user_id']); |
| | | foreach ($refereeJc as $v){ |
| | | $list[] = array_merge($data, ['vip_area_type' => 70, 'vip_area_money' =>bcmul($product_price_repurchase, bcdiv($v['bonus_percent'], 100, 4), 2),'vip_area_user_id'=>$v['user_id']]); |
| | | if ( (new User())->getViewpointMoneyQualification($v['user_id'], $setting)){ |
| | | $list[] = array_merge($data, ['vip_area_type' => 70, 'vip_area_money' =>bcmul($product_price_repurchase, bcdiv($v['bonus_percent'], 100, 4), 2),'vip_area_user_id'=>$v['user_id']]); |
| | | } |
| | | |
| | | } |
| | | } |
| | | //复购专区平级奖 |
| | | if ($setting['pjaward']){ |
| | | $refereeJc=User::getAllPjUser($userModel['user_id'],$setting['pjaward_level']); |
| | | foreach ($refereeJc as $v){ |
| | | $list[] = array_merge($data, ['vip_area_type' => 80, 'vip_area_money' => bcmul($product_price_repurchase, bcdiv($v['bonus_percent'], 100, 4), 2),'vip_area_user_id'=>$v['user_id']]); |
| | | if ((new User())->getViewpointMoneyQualification($v['user_id'], $setting)) { |
| | | $list[] = array_merge($data, ['vip_area_type' => 80, 'vip_area_money' => bcmul($product_price_repurchase, bcdiv($v['bonus_percent'], 100, 4), 2), 'vip_area_user_id' => $v['user_id']]); |
| | | } |
| | | } |
| | | } |
| | | } |