|
|
@@ -562,6 +562,7 @@ class StorePink extends BaseModel
|
|
|
TreeRecommend::insertTree($pink_info['uid'], User::where('uid', $pink_info['uid'])->value('spread_uid'));
|
|
|
self::pinkIntegral($pink_info['order_id_key']);
|
|
|
}
|
|
|
+ self::pinkRecommend($pink_info['order_id_key']);
|
|
|
}
|
|
|
}
|
|
|
return $pinkBool;
|
|
|
@@ -647,6 +648,31 @@ class StorePink extends BaseModel
|
|
|
return $res;
|
|
|
}
|
|
|
|
|
|
+ public static function pinkRecommend($order_id)
|
|
|
+ {
|
|
|
+ $product = StoreOrder::get($order_id);
|
|
|
+ if (!$product) return self::setErrorInfo('数据不存在');
|
|
|
+ if ($product['pay_type'] == 'pink_integral') return true;
|
|
|
+ $user = User::where('uid', $product['uid'])->find();
|
|
|
+ if (!$user) return self::setErrorInfo('用户不存在');
|
|
|
+ $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, $order_id, bcsub($balance_integral, $return, 2), '推荐用户拼团,响亮积分转为推荐奖' . $return);
|
|
|
+ $res = $res && UserBill::income('推荐拼团奖', $spread['uid'], 'brokerage_price', 'pink_recommend_income', $return, $order_id, 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;
|
|
|
+ }
|
|
|
+
|
|
|
/*
|
|
|
* 获取参团人和团长和拼团总人数
|
|
|
* @param array $pink
|