|
@@ -753,29 +753,23 @@ class User extends BaseModel
|
|
|
$user = self::where('uid', $uid)->find();
|
|
|
$number = $number * 0.3;
|
|
|
$release = StoreOrderRelease::where('uid', $uid)->where('status', 0)->select();
|
|
|
- $re_integral = sys_config('re_integral') / 100;
|
|
|
- $contribution = sys_config('contribution') / 100;
|
|
|
if ($release) {
|
|
|
foreach ($release as $item) {
|
|
|
if ($number > 0) {
|
|
|
if ($item['already'] + $number > $item['to_release']) {
|
|
|
$n1 = $item['to_release'] - $item['already'];// 释放量
|
|
|
$number -= $n1;
|
|
|
- $integral = $n1 * $re_integral;// 积分
|
|
|
- $user_contribution = $n1 * $contribution;// 贡献值
|
|
|
+ $integral = $n1;// 积分
|
|
|
$item['already'] += $n1;
|
|
|
$item['status'] = 1;
|
|
|
} else {
|
|
|
$n1 = $number;
|
|
|
- $integral = $n1 * $re_integral;// 积分
|
|
|
- $user_contribution = $n1 * $contribution;// 贡献值
|
|
|
+ $integral = $n1;// 积分
|
|
|
$number = 0;
|
|
|
$item['already'] += $n1;
|
|
|
}
|
|
|
- User::where('uid', $user['uid'])->inc('integral', $integral)->update();
|
|
|
- User::where('uid', $user['uid'])->inc('contribution', $user_contribution)->update();
|
|
|
- UserBill::income('直推奖励释放积分', $user['uid'], 'integral', 'zt_integral', $integral, 0, $user['integral'] + $integral, '直推奖励释放订单' . $item['order_id'] . '积分');
|
|
|
- UserBill::income('直推奖励贡献值', $user['uid'], 'contribution', 'zt_contribution', $user_contribution, 0, $user['contribution'] + $user_contribution, '直推奖励释放订单' . $item['order_id'] . '贡献值');
|
|
|
+ User::where('uid', $user['uid'])->inc('dynamic_integral', $integral)->update();
|
|
|
+ UserBill::income('直推奖励释放动态积分', $user['uid'], 'dynamic_integral', 'zt_dynamic_integral', $integral, 0, $user['dynamic_integral'] + $integral, '直推奖励释放订单' . $item['order_id'] . '动态积分');
|
|
|
StoreOrderRelease::where('id', $item['id'])->update(['already' => $item['already'], 'status' => $item['status']]);
|
|
|
}
|
|
|
|
|
@@ -810,4 +804,149 @@ class User extends BaseModel
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 团队奖励
|
|
|
+ * @return void
|
|
|
+ * @throws \think\db\exception\DataNotFoundException
|
|
|
+ * @throws \think\db\exception\DbException
|
|
|
+ * @throws \think\db\exception\ModelNotFoundException
|
|
|
+ */
|
|
|
+ public static function push()
|
|
|
+ {
|
|
|
+ if (!Push::where('add_time', strtotime('today'))->find()){
|
|
|
+ $user = User::select();
|
|
|
+ foreach ($user as $item)
|
|
|
+ {
|
|
|
+ $price = UserRelease::whereBetweenTime('create_time', strtotime('yesterday'), strtotime('today'))->where('uid', $item['uid'])->sum('release');// 昨天释放收益
|
|
|
+ if ($item['spread_uid'] > 0 and $price > 0){
|
|
|
+ $spread = getParent($item['spread_uid'], $user->toArray());// 找到所有上级
|
|
|
+ $v1 = 0;
|
|
|
+ $v2 = 0;
|
|
|
+ $v3 = 0;
|
|
|
+ $one = sys_config('one_release')/100; // v1团队比例
|
|
|
+ $one_level = sys_config('one_level')/100; // v1平级比例
|
|
|
+ $tow = sys_config('tow_release')/100; // v2团队比例
|
|
|
+ $tow_level = sys_config('tow_level')/100;// v2平级比例
|
|
|
+ $three = sys_config('tr_release')/100;// v3比例
|
|
|
+ $three_level = sys_config('tr_level')/100;// v3比例
|
|
|
+ foreach ($spread as $value) {
|
|
|
+ $details = User::where('uid', $value)->find();
|
|
|
+ $release = StoreOrderRelease::where('uid', $details['uid'])->where('status', 0)->select();
|
|
|
+ if (count($release) > 0 and $details['level'] > 0){
|
|
|
+ if ($details['level'] == 1){
|
|
|
+ if ($v2 == 0 and $v3 == 0){
|
|
|
+ // 没有发放v2和v3的奖励
|
|
|
+ if ($v1 == 0) { // 没有发放v1的奖励
|
|
|
+ $jl = $price * $one;
|
|
|
+ $details['dynamic_integral'] += $jl; // v1团队奖励
|
|
|
+ $v1++;
|
|
|
+ }elseif ($v1 == 1){// 发放v1奖励1次
|
|
|
+ $jl = ($price*$one)*$one_level;//平级的百分之五
|
|
|
+ $details['dynamic_integral'] += $jl; // v1团队奖励平级
|
|
|
+ $v1++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }elseif ($details['level'] == 2){
|
|
|
+ if ($v3 == 0){
|
|
|
+ // 没有发放v3的奖励
|
|
|
+ if ($v1 == 0 and $v2 == 0) { // 没有发放v1和v2的奖励的奖励
|
|
|
+ $jl = $price * $tow;
|
|
|
+ $details['dynamic_integral'] += $jl; // v2团队奖励
|
|
|
+ $v2++;
|
|
|
+ }elseif($v1 == 0 and $v2 == 1) { // 没有发放v1和v2的奖励的奖励
|
|
|
+ $jl = ($price * $tow)*$tow_level;
|
|
|
+ $details['dynamic_integral'] += $jl; // v2团队奖励平级
|
|
|
+ $v2++;
|
|
|
+ }elseif ($v1 > 0 and $v2 == 0){// 发放v1奖励,没有发放v2的奖励
|
|
|
+ $jl = $price * ($tow - $one);
|
|
|
+ $details['dynamic_integral'] += $jl; // v2团队奖励
|
|
|
+ $v2++;
|
|
|
+ }elseif ($v1 > 0 and $v2 == 1){// 发放v1奖励,发放v2的奖励一次
|
|
|
+ $jl = ($price * ($tow - $one))*$tow_level; // 拿到平级的百分之五
|
|
|
+ $details['dynamic_integral'] += $jl; // v2团队奖励平级
|
|
|
+ $v2++;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }elseif ($details['level'] == 3){
|
|
|
+ if ($v1 == 0 and $v2 == 0 and $v3 == 0) { // 没有发放v1和v2v3的奖励的奖励
|
|
|
+ $jl = $price * $three;
|
|
|
+ $details['dynamic_integral'] += $jl; // v3团队奖励
|
|
|
+ $v3++;
|
|
|
+ }elseif ($v1 == 0 and $v2 == 0 and $v3 == 1) {// 没有发放v1和v2的奖励的奖励
|
|
|
+ $jl = ($price * $three) * $three_level; // 拿到平级的百分之五
|
|
|
+ $details['dynamic_integral'] += $jl; // v3团队奖励平级
|
|
|
+ $v3++;
|
|
|
+ }elseif ($v1 > 0 and $v2 == 0 and $v3 == 0){// 发放v1奖励,没有发放v2v3的奖励
|
|
|
+ $jl = $price * ($three - $one);
|
|
|
+ $details['dynamic_integral'] += $jl; // v3团队奖励
|
|
|
+ $v3++;
|
|
|
+ }elseif ($v1 > 0 and $v2 == 0 and $v3 == 1){// 发放v1奖励,没有发放v2v3的奖励
|
|
|
+ $jl = ($price * ($three - $one)) * $three_level;
|
|
|
+ $details['dynamic_integral'] += $jl; // v3团队奖励平级
|
|
|
+ $v3++;
|
|
|
+ }elseif ($v1 == 0 and $v2 > 0 and $v3 == 0){// 发放v1奖励,发放v2的奖励,没有发放v3的奖励
|
|
|
+ $jl = ($price * ($three - $tow));
|
|
|
+ $details['dynamic_integral'] += $jl; // v3团队奖励
|
|
|
+ $v3++;
|
|
|
+ }elseif ($v1 == 0 and $v2 > 0 and $v3 == 1){// 发放v1奖励,发放v2的奖励,发放v3的奖励
|
|
|
+ $jl = ($price * ($three - $tow)) * $three_level; // 拿到平级的百分之五
|
|
|
+ $details['dynamic_integral'] += $jl; // v3团队奖励
|
|
|
+ $v3++;
|
|
|
+ }elseif ($v1 > 0 and $v2 > 0 and $v3 == 0){// 发放v1奖励,发放v2的奖励,发放v3的奖励
|
|
|
+ $jl = ($price * ($three - $tow));
|
|
|
+ $details['dynamic_integral'] += $jl; // v3团队奖励
|
|
|
+ $v3++;
|
|
|
+ }elseif ($v1 > 0 and $v2 > 0 and $v3 == 1){// 发放v1奖励,发放v2的奖励,发放v3的奖励
|
|
|
+ $jl = ($price * ($three - $tow)) *$three_level;
|
|
|
+ $details['dynamic_integral'] += $jl; // v3团队奖励平级
|
|
|
+ $v3++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if ($jl > 0){
|
|
|
+ $bill = $jl;
|
|
|
+ foreach ($release as $item) {
|
|
|
+ if ($jl > 0) {
|
|
|
+ if ($item['already'] + $jl > $item['to_release']) {
|
|
|
+ $integral = $item['to_release'] - $item['already'];// 释放量
|
|
|
+ $jl -= $integral;
|
|
|
+ $item['already'] += $integral;
|
|
|
+ $item['status'] = 1;
|
|
|
+ } else {
|
|
|
+ $integral = $jl;
|
|
|
+ $jl = 0;
|
|
|
+ $item['already'] += $integral;
|
|
|
+ }
|
|
|
+ StoreOrderRelease::where('id', $item['id'])->update(['already' => $item['already'], 'status' => $item['status']]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $details->save();
|
|
|
+ UserBill::income('团队奖励释放动态积分', $details['uid'], 'dynamic_integral', 'team', $jl==0?$bill:$jl, 0,$details['dynamic_integral'], 'v'.$details['level'].'团队奖励释放动态积分');
|
|
|
+ }
|
|
|
+ $jl = 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 更新推送时间
|
|
|
+ * @return void
|
|
|
+ * @throws \think\db\exception\DataNotFoundException
|
|
|
+ * @throws \think\db\exception\DbException
|
|
|
+ * @throws \think\db\exception\ModelNotFoundException
|
|
|
+ */
|
|
|
+ public static function time()
|
|
|
+ {
|
|
|
+ if (!Push::where('add_time', strtotime('today'))->find()) {
|
|
|
+ Push::create(['add_time' => strtotime('today')]); //存入数据库信息
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|