|
|
@@ -20,6 +20,7 @@ use app\models\user\Achievement;
|
|
|
use app\models\user\User;
|
|
|
use app\models\user\UserBill;
|
|
|
use app\models\user\UserLevel;
|
|
|
+use app\models\user\UserSpread;
|
|
|
use app\models\user\WechatUser;
|
|
|
use app\Request;
|
|
|
use crmeb\basic\BaseModel;
|
|
|
@@ -43,6 +44,16 @@ class PublicController
|
|
|
|
|
|
public function test(Request $request)
|
|
|
{
|
|
|
+
|
|
|
+ $list = User::where('spread_uid', '<>', 0)->select();
|
|
|
+ foreach ($list as $v) {
|
|
|
+ UserSpread::create([
|
|
|
+ 'uid' => $v['uid'],
|
|
|
+ 'spread_uid' => $v['spread_uid'],
|
|
|
+ 'spread_time' => $v['spread_time'],
|
|
|
+ 'lock' => 1
|
|
|
+ ]);
|
|
|
+ }
|
|
|
// $uid = $request->post('uid');
|
|
|
// $way = $request->post('way');
|
|
|
// $sp = $request->post('spread_uid');
|
|
|
@@ -63,67 +74,67 @@ class PublicController
|
|
|
// }
|
|
|
}
|
|
|
|
|
|
-// public static function spreadIntegral($uid)
|
|
|
-// {
|
|
|
-// $recommend_integral = sys_config('recommend_integral_ratio', 0, true);
|
|
|
-// $integral = bcmul(3000, bcdiv($recommend_integral, 100, 4), 2);
|
|
|
-// if ($integral > 0) {
|
|
|
-// $userInfo = User::getUserInfo($uid);
|
|
|
-// $spreadInfo = User::getUserInfo($userInfo['spread_uid']);
|
|
|
-// if (!$spreadInfo) return true;
|
|
|
-// $res1 = false != User::where('uid', $spreadInfo['uid'])->update(['integral' => bcadd($spreadInfo['integral'], $integral, 2)]);
|
|
|
-// return false != UserBill::income('推荐用户购买商品赠送积分', $spreadInfo['uid'], 'integral', 'spread_gain', $integral, 0, $spreadInfo['integral'], '推荐用户购买商品赠送' . floatval($integral) . '积分');
|
|
|
-// }
|
|
|
-// return true;
|
|
|
-// }
|
|
|
-//
|
|
|
-// public static function pinkRecommend($uid)
|
|
|
-// {
|
|
|
-// $user = User::where('uid', $uid)->find();
|
|
|
-// $spread = User::where('uid', $user['spread_uid'])->find();
|
|
|
-// if (!$spread) return true;
|
|
|
-// if ($spread['last_recommend_award']) $return = sys_config('recommend_double', 0);
|
|
|
-// else $return = sys_config('recommend_single', 0);
|
|
|
-// if ($spread['integral'] < $return) return true;
|
|
|
-// $res = true;
|
|
|
-// if ($return > 0) {
|
|
|
-// $balance_integral = User::where('uid', $spread['uid'])->value('integral');
|
|
|
-// $balance_brokerage = User::where('uid', $spread['uid'])->value('brokerage_price');
|
|
|
-// $res = $res && UserBill::expend('礼包推荐奖[积分转换]', $spread['uid'], 'integral', 'pink_recommend_pay', $return, 0, bcsub($balance_integral, $return, 2), '推荐用户购礼包商品,响亮积分转为推荐奖' . $return);
|
|
|
-// $res = $res && UserBill::income('礼包推荐奖', $spread['uid'], 'now_money', 'brokerage', $return, 0, bcadd($balance_brokerage, $return, 2), '推荐用户购礼包商品' . $return);
|
|
|
-// $res = $res && User::where('uid', $spread['uid'])->dec('integral', $return)->update();
|
|
|
-// $res = $res && User::where('uid', $spread['uid'])->inc('brokerage_price', $return)->update();
|
|
|
-// $res = $res && User::where('uid', $spread['uid'])->update(['last_recommend_award' => ($spread['last_recommend_award'] ? 0 : 1)]);
|
|
|
-// }
|
|
|
-// return $res;
|
|
|
-// }
|
|
|
-//
|
|
|
-// public static function addAchievement($uid)
|
|
|
-// {
|
|
|
-// $res = Achievement::create(
|
|
|
-// [
|
|
|
-// 'uid' => $uid,
|
|
|
-// 'from_uid' => $uid,
|
|
|
-// 'achievement' => 3000,
|
|
|
-// 'order_id' => 0,
|
|
|
-// 'add_time' => time()
|
|
|
-// ]
|
|
|
-// ) && User::where('uid', $uid)->inc('achievement', 3000)->inc('self_achievement', 3000)->update();
|
|
|
-// $spread = User::where('uid', $uid)->value('spread_uid');
|
|
|
-// while ($spread) {
|
|
|
-// $res = $res && Achievement::create(
|
|
|
-// [
|
|
|
-// 'uid' => $spread,
|
|
|
-// 'from_uid' => $uid,
|
|
|
-// 'achievement' => 3000,
|
|
|
-// 'order_id' => 0,
|
|
|
-// 'add_time' => time()
|
|
|
-// ]
|
|
|
-// ) && User::where('uid', $spread)->inc('achievement', 3000)->update();
|
|
|
-// $spread = User::where('uid', $spread)->value('spread_uid');
|
|
|
-// }
|
|
|
-// return $res;
|
|
|
-// }
|
|
|
+ public static function spreadIntegral($uid)
|
|
|
+ {
|
|
|
+ $recommend_integral = sys_config('recommend_integral_ratio', 0, true);
|
|
|
+ $integral = bcmul(3000, bcdiv($recommend_integral, 100, 4), 2);
|
|
|
+ if ($integral > 0) {
|
|
|
+ $userInfo = User::getUserInfo($uid);
|
|
|
+ $spreadInfo = User::getUserInfo($userInfo['spread_uid']);
|
|
|
+ if (!$spreadInfo) return true;
|
|
|
+ $res1 = false != User::where('uid', $spreadInfo['uid'])->update(['integral' => bcadd($spreadInfo['integral'], $integral, 2)]);
|
|
|
+ return false != UserBill::income('推荐用户购买商品赠送积分', $spreadInfo['uid'], 'integral', 'spread_gain', $integral, 0, $spreadInfo['integral'], '推荐用户购买商品赠送' . floatval($integral) . '积分');
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ public static function pinkRecommend($uid)
|
|
|
+ {
|
|
|
+ $user = User::where('uid', $uid)->find();
|
|
|
+ $spread = User::where('uid', $user['spread_uid'])->find();
|
|
|
+ if (!$spread) return true;
|
|
|
+ if ($spread['last_recommend_award']) $return = sys_config('recommend_double', 0);
|
|
|
+ else $return = sys_config('recommend_single', 0);
|
|
|
+ if ($spread['integral'] < $return) return true;
|
|
|
+ $res = true;
|
|
|
+ if ($return > 0) {
|
|
|
+ $balance_integral = User::where('uid', $spread['uid'])->value('integral');
|
|
|
+ $balance_brokerage = User::where('uid', $spread['uid'])->value('brokerage_price');
|
|
|
+ $res = $res && UserBill::expend('礼包推荐奖[积分转换]', $spread['uid'], 'integral', 'pink_recommend_pay', $return, 0, bcsub($balance_integral, $return, 2), '推荐用户购礼包商品,响亮积分转为推荐奖' . $return);
|
|
|
+ $res = $res && UserBill::income('礼包推荐奖', $spread['uid'], 'now_money', 'brokerage', $return, 0, bcadd($balance_brokerage, $return, 2), '推荐用户购礼包商品' . $return);
|
|
|
+ $res = $res && User::where('uid', $spread['uid'])->dec('integral', $return)->update();
|
|
|
+ $res = $res && User::where('uid', $spread['uid'])->inc('brokerage_price', $return)->update();
|
|
|
+ $res = $res && User::where('uid', $spread['uid'])->update(['last_recommend_award' => ($spread['last_recommend_award'] ? 0 : 1)]);
|
|
|
+ }
|
|
|
+ return $res;
|
|
|
+ }
|
|
|
+
|
|
|
+ public static function addAchievement($uid)
|
|
|
+ {
|
|
|
+ $res = Achievement::create(
|
|
|
+ [
|
|
|
+ 'uid' => $uid,
|
|
|
+ 'from_uid' => $uid,
|
|
|
+ 'achievement' => 3000,
|
|
|
+ 'order_id' => 0,
|
|
|
+ 'add_time' => time()
|
|
|
+ ]
|
|
|
+ ) && User::where('uid', $uid)->inc('achievement', 3000)->inc('self_achievement', 3000)->update();
|
|
|
+ $spread = User::where('uid', $uid)->value('spread_uid');
|
|
|
+ while ($spread) {
|
|
|
+ $res = $res && Achievement::create(
|
|
|
+ [
|
|
|
+ 'uid' => $spread,
|
|
|
+ 'from_uid' => $uid,
|
|
|
+ 'achievement' => 3000,
|
|
|
+ 'order_id' => 0,
|
|
|
+ 'add_time' => time()
|
|
|
+ ]
|
|
|
+ ) && User::where('uid', $spread)->inc('achievement', 3000)->update();
|
|
|
+ $spread = User::where('uid', $spread)->value('spread_uid');
|
|
|
+ }
|
|
|
+ return $res;
|
|
|
+ }
|
|
|
|
|
|
public function open(Request $request)
|
|
|
{
|