|
|
@@ -43,87 +43,87 @@ class PublicController
|
|
|
|
|
|
public function test(Request $request)
|
|
|
{
|
|
|
- $uid = $request->post('uid');
|
|
|
- $way = $request->post('way');
|
|
|
- $sp = $request->post('spread_uid');
|
|
|
- $userInfo = User::getUserInfo($uid);
|
|
|
- BaseModel::beginTrans();
|
|
|
- try {
|
|
|
- self::addAchievement($uid);
|
|
|
- User::where('uid', $userInfo['uid'])->update(['integral' => bcadd($userInfo['integral'], 3000, 2)]);
|
|
|
- $res2 = false != UserBill::income('购买商品赠送积分', $uid, 'integral', 'gain', 3000, 0, $userInfo['integral'] + 3000, '购买商品赠送' . floatval(3000) . '积分');
|
|
|
- $res = $res2 && self::spreadIntegral($uid);
|
|
|
- TreeRecommend::insertTree($uid, $sp, $way);
|
|
|
- self::pinkRecommend($uid);
|
|
|
- BaseModel::commitTrans();
|
|
|
- return app('json')->success('ok');
|
|
|
- } catch (\Exception $e) {
|
|
|
- BaseModel::rollbackTrans();
|
|
|
- return app('json')->fail($e->getMessage());
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- 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;
|
|
|
+// $uid = $request->post('uid');
|
|
|
+// $way = $request->post('way');
|
|
|
+// $sp = $request->post('spread_uid');
|
|
|
+// $userInfo = User::getUserInfo($uid);
|
|
|
+// BaseModel::beginTrans();
|
|
|
+// try {
|
|
|
+// self::addAchievement($uid);
|
|
|
+// User::where('uid', $userInfo['uid'])->update(['integral' => bcadd($userInfo['integral'], 3000, 2)]);
|
|
|
+// $res2 = false != UserBill::income('购买商品赠送积分', $uid, 'integral', 'gain', 3000, 0, $userInfo['integral'] + 3000, '购买商品赠送' . floatval(3000) . '积分');
|
|
|
+// $res = $res2 && self::spreadIntegral($uid);
|
|
|
+// TreeRecommend::insertTree($uid, $sp, $way);
|
|
|
+// self::pinkRecommend($uid);
|
|
|
+// BaseModel::commitTrans();
|
|
|
+// return app('json')->success('ok');
|
|
|
+// } catch (\Exception $e) {
|
|
|
+// BaseModel::rollbackTrans();
|
|
|
+// return app('json')->fail($e->getMessage());
|
|
|
+// }
|
|
|
}
|
|
|
|
|
|
- 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)
|
|
|
{
|