|
@@ -11,6 +11,7 @@ use think\db\exception\DataNotFoundException;
|
|
|
use think\db\exception\DbException;
|
|
|
use think\db\exception\ModelNotFoundException;
|
|
|
use think\Exception;
|
|
|
+use think\facade\Db;
|
|
|
use think\facade\Session;
|
|
|
use crmeb\traits\ModelTrait;
|
|
|
use crmeb\basic\BaseModel;
|
|
@@ -738,142 +739,301 @@ class User extends BaseModel
|
|
|
return $model->where('brokerage_price', '>', $brokerage_price)->count('uid');
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- public static function bonus($type, $money, $uid = 0, $order_id = '')
|
|
|
+ public static function user_count()
|
|
|
{
|
|
|
$model = new self();
|
|
|
$silver_user = $model->where([['level', '=', 1], ['brokerage_price', '<', 200]])->select();// 白银会员
|
|
|
- $silver = count($silver_user);// 白银会员总数
|
|
|
- $silver_user = $silver_user ? $silver_user->toArray() : [];
|
|
|
+ $data['silver'] = count($silver_user);// 白银会员总数
|
|
|
+ $data['silver_user'] = $silver_user ? $silver_user->toArray() : [];
|
|
|
|
|
|
$gold_user = $model->where([['level', '=', 2], ['brokerage_price', '<', 6000]])->select();// 黄金会员
|
|
|
- $gold = count($gold_user);// 黄金会员总数
|
|
|
- $gold_user = $gold_user ? $gold_user->toArray() : [];
|
|
|
+ $data['gold'] = count($gold_user);// 黄金会员总数
|
|
|
+ $data['gold_user'] = $gold_user ? $gold_user->toArray() : [];
|
|
|
|
|
|
$diamonds_user = $model->where([['level', '=', 3]])->select();// 钻石会员总数
|
|
|
- $diamonds = count($diamonds_user);// 钻石会员总数
|
|
|
- $diamonds_user = $diamonds_user ? $diamonds_user->toArray() : [];
|
|
|
- switch ($type){
|
|
|
- case 1:
|
|
|
- //商家转账积分后
|
|
|
- $divide = ($money * 0.1)/($silver+$gold);//白银会员和黄金会员分百分之十的金额
|
|
|
- $diamonds_divide = ($money * 0.01)/$diamonds;//钻石会员销售的百分之1
|
|
|
+ $data['diamonds'] = count($diamonds_user);// 钻石会员总数
|
|
|
+ $data['diamonds_user'] = $diamonds_user ? $diamonds_user->toArray() : [];
|
|
|
+
|
|
|
+ return $data;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 商家转账积分分红
|
|
|
+ * @param $money
|
|
|
+ * @return void
|
|
|
+ * @throws \Exception
|
|
|
+ */
|
|
|
+ public static function bring_forward($money)
|
|
|
+ {
|
|
|
+ $data = self::user_count();
|
|
|
+ $model = new self();
|
|
|
+ $silver_user = $data['silver_user'];
|
|
|
+ $silver = $data['silver'];
|
|
|
+ $gold_user = $data['gold_user'];
|
|
|
+ $gold = $data['gold'];
|
|
|
+ $diamonds_user = $data['diamonds_user'];
|
|
|
+ $diamonds = $data['diamonds'];
|
|
|
+ //商家转账积分后
|
|
|
+ $divide = ($money * 0.1)/($silver+$gold);//白银会员和黄金会员分百分之十的金额
|
|
|
+ $diamonds_divide = ($money * 0.01)/$diamonds;//钻石会员销售的百分之1
|
|
|
+ $user = array_merge($silver_user, $gold_user);
|
|
|
+ if ($user){
|
|
|
+ // 黄金会员和白银会员
|
|
|
+ foreach ($user as &$item){
|
|
|
+ if ($item['level'] == 1){
|
|
|
+ if ($item['brokerage_price']+$divide > 200){
|
|
|
+ $item['brokerage_price'] += 200 - $item['brokerage_price'];
|
|
|
+ UserBill::income('佣金', $item['uid'], 'now_money', 'brokerage', 200 - $item['brokerage_price'], $item['spread_uid'], $item['brokerage_price'], '商家销售额分红,已达到上限');
|
|
|
+ }else{
|
|
|
+ $item['brokerage_price'] += $divide;
|
|
|
+ UserBill::income('佣金', $item['uid'], 'now_money', 'brokerage', $divide, $item['spread_uid'], $item['brokerage_price'], '商家销售额分红');
|
|
|
+ }
|
|
|
+
|
|
|
+ }elseif ($item['level'] == 2){
|
|
|
+ if ($item['brokerage_price']+$divide > 6000){
|
|
|
+ $item['brokerage_price'] += 6000 - $item['brokerage_price'];
|
|
|
+ UserBill::income('佣金', $item['uid'], 'now_money', 'brokerage', 6000 - $item['brokerage_price'], $item['spread_uid'], $item['brokerage_price'], '商家销售额分红,已达到上限');
|
|
|
+ }else{
|
|
|
+ $item['brokerage_price'] += $divide;
|
|
|
+ UserBill::income('佣金', $item['uid'], 'now_money', 'brokerage', $divide, $item['spread_uid'], $item['brokerage_price'], '商家销售额分红');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $model->saveAll($user);
|
|
|
+ }
|
|
|
+
|
|
|
+ if ($diamonds_user){
|
|
|
+ // 钻石会员
|
|
|
+ foreach ($diamonds_user as &$item){
|
|
|
+ $item['brokerage_price'] += $diamonds_divide;
|
|
|
+ UserBill::income('佣金', $item['uid'], 'now_money', 'brokerage', $diamonds_divide, $item['spread_uid'], $item['brokerage_price'], '商家销售额分红');
|
|
|
+ }
|
|
|
+ $model->saveAll($diamonds_user);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public static function gift_bag($order_id)
|
|
|
+ {
|
|
|
+ $data = self::user_count();
|
|
|
+ $model = new self();
|
|
|
+ $silver_user = $data['silver_user'];
|
|
|
+ $silver = $data['silver'];
|
|
|
+ $gold_user = $data['gold_user'];
|
|
|
+ $gold = $data['gold'];
|
|
|
+ $diamonds_user = $data['diamonds_user'];
|
|
|
+ $diamonds = $data['diamonds'];
|
|
|
+ // 礼包分红
|
|
|
+ $order = StoreOrder::where('order_id', $order_id)->find();
|
|
|
+ $user = User::where('uid', $order['uid'])->find();
|
|
|
+ $info = StoreOrderCartInfo::where('oid', $order['id'])->where('product_id', '<=', 2)->select();
|
|
|
+ foreach ($info as $item){
|
|
|
+ $product = StoreProduct::where('id', $item['product_id'])->find();
|
|
|
+ if ($user['spread_uid']){
|
|
|
+ // 当前用户是否有上级
|
|
|
+ $spread = User::where('uid', $user['spread_uid'])->find();
|
|
|
+ if ($spread['level'] == 2){
|
|
|
+ // 如果用户是黄金会员
|
|
|
+ $push = $product['price'] * 0.2; //获得价格百分之20的佣金
|
|
|
+ if ($spread['brokerage_price']+$push > 6000){
|
|
|
+ $max = 6000 - $spread['brokerage_price'];
|
|
|
+ $spread['brokerage_price'] += 6000 - $spread['brokerage_price'];
|
|
|
+ UserBill::income('佣金', $spread['uid'], 'now_money', 'brokerage', $max, $spread['spread_uid'], $spread['brokerage_price'], '直推礼包销售额20%分红,已达到上限');
|
|
|
+ }else{
|
|
|
+ $spread['brokerage_price'] += $push;
|
|
|
+ UserBill::income('佣金', $spread['uid'], 'now_money', 'brokerage', $push, $spread['spread_uid'], $spread['brokerage_price'], '直推礼包销售额20%分红');
|
|
|
+ }
|
|
|
+ $spread->save();
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ if ($product['id'] == 1){
|
|
|
+ $divide = ($product['price'] * 0.1)/$silver; // 200礼包的百分之十白银会员平分
|
|
|
+ $diamonds_divide = ($product['price'] * 0.03)/$diamonds;//钻石会员200礼包的百分之3
|
|
|
+ if ($silver_user){
|
|
|
+ foreach ($silver_user as &$value){
|
|
|
+ if ($value['brokerage_price']+$divide > 200){
|
|
|
+ $max = 200 - $value['brokerage_price'];
|
|
|
+ $value['brokerage_price'] += 200 - $value['brokerage_price'];
|
|
|
+ UserBill::income('佣金', $value['uid'], 'now_money', 'brokerage', $max, $value['spread_uid'], $value['brokerage_price'], '白银会员200礼包销售额分红,已达到上限');
|
|
|
+ }else{
|
|
|
+ $value['brokerage_price'] += $divide;
|
|
|
+ UserBill::income('佣金', $value['uid'], 'now_money', 'brokerage', $divide, $value['spread_uid'], $value['brokerage_price'], '白银会员200礼包销售额分红');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $model->saveAll($silver_user);
|
|
|
+ }
|
|
|
+ if ($diamonds_user){
|
|
|
+ // 钻石会员
|
|
|
+ foreach ($diamonds_user as &$value){
|
|
|
+ $value['brokerage_price'] += $diamonds_divide;
|
|
|
+ UserBill::income('佣金', $value['uid'], 'now_money', 'brokerage', $diamonds_divide, $value['spread_uid'], $value['brokerage_price'], '钻石会员200礼包提成');
|
|
|
+ }
|
|
|
+ $model->saveAll($diamonds_user);
|
|
|
+ }
|
|
|
+ }elseif ($product['id'] == 2){
|
|
|
+ //1991礼包 白银会员和黄金会员分百分之十的金额
|
|
|
+ $divide = ($product['price'] * 0.1)/($silver+$gold);
|
|
|
$user = array_merge($silver_user, $gold_user);
|
|
|
+
|
|
|
+ $top_user = getParent($order['uid']); // 获取到上级所有钻石用户
|
|
|
+ $count = count($top_user);
|
|
|
+ if ($count > 0){
|
|
|
+ $top_divide = ($product['price'] * 0.2)/$count;//1991礼包百分之二十上级所有钻石会员平分
|
|
|
+ foreach ($top_user as $v){
|
|
|
+ $details = self::where('uid', $v)->find();
|
|
|
+ $details['brokerage_price'] += $top_divide;
|
|
|
+ $details->save();
|
|
|
+ UserBill::income('佣金', $details['uid'], 'now_money', 'brokerage', $top_divide, $details['spread_uid'], $details['brokerage_price'], '钻石会员1991礼包销售额20%分红');
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
if ($user){
|
|
|
// 黄金会员和白银会员
|
|
|
- foreach ($user as &$item){
|
|
|
- if ($item['level'] == 1){
|
|
|
- if ($item['brokerage_price']+$divide > 200){
|
|
|
- $item['brokerage_price'] += 200 - $item['brokerage_price'];
|
|
|
- UserBill::income('佣金', $item['uid'], 'now_money', 'brokerage', 200 - $item['brokerage_price'], $item['spread_uid'], $item['brokerage_price'], '商家销售额分红,已达到上限');
|
|
|
+ foreach ($user as &$value){
|
|
|
+ if ($value['level'] == 1){
|
|
|
+ if ($value['brokerage_price']+$divide > 200){
|
|
|
+ $max = 200 - $value['brokerage_price'];
|
|
|
+ $value['brokerage_price'] += 200 - $value['brokerage_price'];
|
|
|
+ UserBill::income('佣金', $value['uid'], 'now_money', 'brokerage', $max, $value['spread_uid'], $value['brokerage_price'], '白银会员1991礼包销售额分红,已达到上限');
|
|
|
}else{
|
|
|
- $item['brokerage_price'] += $divide;
|
|
|
- UserBill::income('佣金', $item['uid'], 'now_money', 'brokerage', $divide, $item['spread_uid'], $item['brokerage_price'], '商家销售额分红');
|
|
|
+ $value['brokerage_price'] += $divide;
|
|
|
+ UserBill::income('佣金', $value['uid'], 'now_money', 'brokerage', $divide, $value['spread_uid'], $value['brokerage_price'], '白银会员1991礼包销售额分红');
|
|
|
}
|
|
|
|
|
|
- }elseif ($item['level'] == 2){
|
|
|
- if ($item['brokerage_price']+$divide > 6000){
|
|
|
- $item['brokerage_price'] += 6000 - $item['brokerage_price'];
|
|
|
- UserBill::income('佣金', $item['uid'], 'now_money', 'brokerage', 6000 - $item['brokerage_price'], $item['spread_uid'], $item['brokerage_price'], '商家销售额分红,已达到上限');
|
|
|
+ }elseif ($value['level'] == 2){
|
|
|
+ if ($value['brokerage_price']+$divide > 6000){
|
|
|
+ $max = 6000 - $value['brokerage_price']; // 到达上限
|
|
|
+ $value['brokerage_price'] += 6000 - $value['brokerage_price'];
|
|
|
+ UserBill::income('佣金', $value['uid'], 'now_money', 'brokerage', $max, $value['spread_uid'], $value['brokerage_price'], '黄金会员1991礼包销售额分红,已达到上限');
|
|
|
}else{
|
|
|
- $item['brokerage_price'] += $divide;
|
|
|
- UserBill::income('佣金', $item['uid'], 'now_money', 'brokerage', $divide, $item['spread_uid'], $item['brokerage_price'], '商家销售额分红');
|
|
|
+ $value['brokerage_price'] += $divide;
|
|
|
+ UserBill::income('佣金', $value['uid'], 'now_money', 'brokerage', $divide, $value['spread_uid'], $value['brokerage_price'], '黄金会员1991礼包销售额分红');
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
$model->saveAll($user);
|
|
|
}
|
|
|
|
|
|
- if ($diamonds_user){
|
|
|
- // 钻石会员
|
|
|
- foreach ($diamonds_user as &$item){
|
|
|
- $item['brokerage_price'] += $diamonds_divide;
|
|
|
- UserBill::income('佣金', $item['uid'], 'now_money', 'brokerage', $diamonds_divide, $item['spread_uid'], $item['brokerage_price'], '商家销售额分红');
|
|
|
- }
|
|
|
- $model->saveAll($diamonds_user);
|
|
|
- }
|
|
|
- break;
|
|
|
- case 2:
|
|
|
- // 礼包分红
|
|
|
- $order = StoreOrder::where('order_id', $order_id)->find();
|
|
|
- $user = User::where('uid', $order['uid'])->find();
|
|
|
- $info = StoreOrderCartInfo::where('oid', $order['id'])->where('product_id', '<=', 2)->select();
|
|
|
- foreach ($info as $item){
|
|
|
- $product = StoreProduct::where('id', $item['product_id'])->find();
|
|
|
- if ($user['spread_uid']){
|
|
|
- // 当前用户是否有上级
|
|
|
- $spread = User::where('uid', $user['spread_uid'])->find();
|
|
|
- if ($spread['level'] == 2){
|
|
|
- // 如果用户是黄金会员
|
|
|
- $push = $product['price'] * 0.2; //获得价格百分之20的佣金
|
|
|
- if ($spread['brokerage_price']+$push > 6000){
|
|
|
- $spread['brokerage_price'] += 6000 - $spread['brokerage_price'];
|
|
|
- UserBill::income('佣金', $spread['uid'], 'now_money', 'brokerage', 6000 - $spread['brokerage_price'], $spread['spread_uid'], $spread['brokerage_price'], '礼包销售额20%分红,已达到上限');
|
|
|
- }else{
|
|
|
- $spread['brokerage_price'] += $push;
|
|
|
- UserBill::income('佣金', $spread['uid'], 'now_money', 'brokerage', $push, $spread['spread_uid'], $spread['brokerage_price'], '礼包销售直推佣金');
|
|
|
- }
|
|
|
- $spread->save();
|
|
|
- }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- }
|
|
|
- if ($product['price'] == 200){
|
|
|
- $divide = ($product['price'] * 0.1)/$silver; // 200礼包的百分之十白银会员平分
|
|
|
- $diamonds_divide = ($product['price'] * 0.03)/$diamonds;//钻石会员200礼包的百分之3
|
|
|
- if ($silver_user){
|
|
|
- foreach ($silver_user as &$value){
|
|
|
- if ($value['brokerage_price']+$divide > 200){
|
|
|
- $value['brokerage_price'] += 200 - $value['brokerage_price'];
|
|
|
- UserBill::income('佣金', $value['uid'], 'now_money', 'brokerage', 200 - $value['brokerage_price'], $value['spread_uid'], $value['brokerage_price'], '200礼包销售额分红,已达到上限');
|
|
|
+ /**
|
|
|
+ * 普通商品确认收货分红
|
|
|
+ * @param $uid
|
|
|
+ * @param $order_id
|
|
|
+ * @return void
|
|
|
+ * @throws DataNotFoundException
|
|
|
+ * @throws DbException
|
|
|
+ * @throws ModelNotFoundException
|
|
|
+ */
|
|
|
+ public static function receiving($uid, $order_id)
|
|
|
+ {
|
|
|
+ $order = StoreOrder::where('order_id', $order_id)->find();
|
|
|
+ $user = User::where('uid', $order['uid'])->find();
|
|
|
+ $info = StoreOrderCartInfo::where('oid', $order['id'])->where('product_id', '>', 2)->select(); // 普通商品
|
|
|
+ if ($user['spread_uid']){
|
|
|
+ $top_user = getParent($uid); // 获取到上级所有钻石用户
|
|
|
+ $count = count($top_user);
|
|
|
+ $s_user = getParents($uid);// 获取到上级所有黄金白银用户
|
|
|
+ $s_count = count($s_user);
|
|
|
+ foreach ($info as $item){
|
|
|
+ $product = StoreProduct::where('id', $item['product_id'])->find();
|
|
|
+ if ($s_count > 0){
|
|
|
+ // 黄金白银会员分红
|
|
|
+ $divide = ($product['price'] * 0.1 )/ $s_count; // 普通商品百分之十的价格黄金和白银会员平分
|
|
|
+ foreach ($s_user as $k => $v){
|
|
|
+ $details = User::where('uid', $v)->find();
|
|
|
+ if ($details['level'] == 1){
|
|
|
+ if ($details['brokerage_price'] < 200){
|
|
|
+ if ($details['brokerage_price']+$divide > 200){
|
|
|
+ $max = 200 - $details['brokerage_price'];
|
|
|
+ $details['brokerage_price'] += $max;
|
|
|
+ $details->save();
|
|
|
+ UserBill::income('佣金', $details['uid'], 'now_money', 'brokerage', $max, $details['spread_uid'], $details['brokerage_price'], '白银会员普通商品分红,已达到上限');
|
|
|
}else{
|
|
|
- $value['brokerage_price'] += $divide;
|
|
|
- UserBill::income('佣金', $value['uid'], 'now_money', 'brokerage', $divide, $value['spread_uid'], $value['brokerage_price'], '200礼包销售额分红');
|
|
|
+ $details['brokerage_price'] += $divide;
|
|
|
+ $details->save();
|
|
|
+ UserBill::income('佣金', $details['uid'], 'now_money', 'brokerage', $divide, $details['spread_uid'], $details['brokerage_price'], '白银会员普通商品分红');
|
|
|
}
|
|
|
}
|
|
|
- $model->saveAll($silver_user);
|
|
|
- }
|
|
|
- if ($diamonds_user){
|
|
|
- // 钻石会员
|
|
|
- foreach ($diamonds_user as &$value){
|
|
|
- $value['brokerage_price'] += $diamonds_divide;
|
|
|
- UserBill::income('佣金', $value['uid'], 'now_money', 'brokerage', $diamonds_divide, $value['spread_uid'], $value['brokerage_price'], '200礼包销售额分红');
|
|
|
- }
|
|
|
- $model->saveAll($diamonds_user);
|
|
|
- }
|
|
|
- }elseif ($product['price'] == 1991){
|
|
|
- //1991礼包 白银会员和黄金会员分百分之十的金额
|
|
|
- $divide = ($product['price'] * 0.1)/($silver+$gold);
|
|
|
- $user = array_merge($silver_user, $gold_user);
|
|
|
- if ($user){
|
|
|
- // 黄金会员和白银会员
|
|
|
- foreach ($user as &$value){
|
|
|
- if ($value['level'] == 1){
|
|
|
- if ($value['brokerage_price']+$divide > 200){
|
|
|
- $value['brokerage_price'] += 200 - $value['brokerage_price'];
|
|
|
- UserBill::income('佣金', $value['uid'], 'now_money', 'brokerage', 200 - $value['brokerage_price'], $value['spread_uid'], $value['brokerage_price'], '1991礼包销售额分红,已达到上限');
|
|
|
- }else{
|
|
|
- $value['brokerage_price'] += $divide;
|
|
|
- UserBill::income('佣金', $value['uid'], 'now_money', 'brokerage', $divide, $value['spread_uid'], $value['brokerage_price'], '1991礼包销售额分红');
|
|
|
- }
|
|
|
-
|
|
|
- }elseif ($value['level'] == 2){
|
|
|
- if ($value['brokerage_price']+$divide > 6000){
|
|
|
- $value['brokerage_price'] += 6000 - $value['brokerage_price'];
|
|
|
- UserBill::income('佣金', $value['uid'], 'now_money', 'brokerage', 6000 - $value['brokerage_price'], $value['spread_uid'], $value['brokerage_price'], '1991礼包销售额分红,已达到上限');
|
|
|
- }else{
|
|
|
- $value['brokerage_price'] += $divide;
|
|
|
- UserBill::income('佣金', $value['uid'], 'now_money', 'brokerage', $divide, $value['spread_uid'], $value['brokerage_price'], '1991礼包销售额分红');
|
|
|
- }
|
|
|
- }
|
|
|
+ }elseif ($details['level'] == 2){
|
|
|
+ if ($details['brokerage_price']+$divide > 6000){
|
|
|
+ $max = 6000 - $details['brokerage_price'];
|
|
|
+ $details['brokerage_price'] += $max;
|
|
|
+ $details->save();
|
|
|
+ UserBill::income('佣金', $details['uid'], 'now_money', 'brokerage', $max, $details['spread_uid'], $details['brokerage_price'], '黄金会员普通商品分红,已达到上限');
|
|
|
+ }else{
|
|
|
+ $details['brokerage_price'] += $divide;
|
|
|
+ $details->save();
|
|
|
+ UserBill::income('佣金', $details['uid'], 'now_money', 'brokerage', $divide, $details['spread_uid'], $details['brokerage_price'], '黄金会员普通商品分红');
|
|
|
}
|
|
|
- $model->saveAll($user);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ if ($count > 0){
|
|
|
+ // 钻石会员分红
|
|
|
+ $top_divide = ($product['price'] * 0.05 )/ $count; // 钻石会员平分普通商品百分之五
|
|
|
+ foreach ($top_user as $v){
|
|
|
+ $details = self::where('uid', $v)->find();
|
|
|
+ $details['brokerage_price'] += $top_divide;
|
|
|
+ $details->save();
|
|
|
+ UserBill::income('佣金', $details['uid'], 'now_money', 'brokerage', $top_divide, $details['spread_uid'], $details['brokerage_price'], '钻石会员普通商品分成');
|
|
|
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 分红
|
|
|
+ * @param $type
|
|
|
+ * @param $money
|
|
|
+ * @param $uid
|
|
|
+ * @param $order_id
|
|
|
+ * @return array
|
|
|
+ * @throws \Exception
|
|
|
+ */
|
|
|
+ public static function bonus($type, $money, $uid = 0, $order_id = '')
|
|
|
+ {
|
|
|
+ switch ($type){
|
|
|
+ case 1:
|
|
|
+ self::bring_forward($money);
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ self::gift_bag($order_id);
|
|
|
+ break;
|
|
|
+ case 3:
|
|
|
+ self::receiving($uid, $order_id);
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
return [];
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ public static function release()
|
|
|
+ {
|
|
|
+ $model = Db::name('release');
|
|
|
+ $time = strtotime('today');
|
|
|
+ if (!$model->where('time', $time)->find()){
|
|
|
+ $user = self::where('integral', '>', 0)->select();
|
|
|
+ foreach ($user as &$item){
|
|
|
+ $release = round($item['integral']) * 0.03;// 释放积分额度
|
|
|
+ $item['integral'] -= $release;
|
|
|
+ $item['voucher'] += $release;
|
|
|
+ UserBill::expend('释放积分', $item['uid'], 'integral', 'release_integral', $release, 0, $item['integral'], '每天释放积分额度');
|
|
|
+ UserBill::income('增加抵用券',$item['uid'], 'voucher', 'release_ivoucher', $release, 0, $item['voucher'], '每天释放积分,变换抵用券');
|
|
|
+ $item->save();
|
|
|
+ }
|
|
|
+ $model->insert([
|
|
|
+ 'time' => $time
|
|
|
+ ]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|