|
@@ -21,6 +21,7 @@ use app\common\repositories\BaseRepository;
|
|
|
use app\common\repositories\community\CommunityRepository;
|
|
|
use app\common\repositories\store\order\StoreOrderRepository;
|
|
|
use app\common\repositories\store\service\StoreServiceRepository;
|
|
|
+use app\common\repositories\store\StorePercentageRepository;
|
|
|
use app\common\repositories\system\attachment\AttachmentRepository;
|
|
|
use app\common\repositories\wechat\WechatUserRepository;
|
|
|
use crmeb\exceptions\AuthException;
|
|
@@ -932,13 +933,14 @@ class UserRepository extends BaseRepository
|
|
|
* @author xaboy
|
|
|
* @day 2020/6/22
|
|
|
*/
|
|
|
- public function bindSpread(User $user, int $spreadUid)
|
|
|
+ public function bindSpread(User $user, int $spreadUid, int $order_id)
|
|
|
{
|
|
|
if ($spreadUid && !$user->spread_uid && $user->uid != $spreadUid && ($spread = $this->dao->get($spreadUid)) && $spread->spread_uid != $user->uid && !$spread->cancel_time) {
|
|
|
$config = systemConfig(['extension_limit', 'extension_limit_day', 'integral_user_give']);
|
|
|
event('user.spread.before', compact('user','spreadUid'));
|
|
|
- Db::transaction(function () use ($spread, $spreadUid, $user, $config) {
|
|
|
+ Db::transaction(function () use ($spread, $spreadUid, $user, $config,$order_id) {
|
|
|
$user->spread_uid = $spreadUid;
|
|
|
+ $user->order_id = $order_id;
|
|
|
$user->spread_time = date('Y-m-d H:i:s');
|
|
|
if ($config['extension_limit'] && $config['extension_limit_day']) {
|
|
|
$user->spread_limit = date('Y-m-d H:i:s', strtotime('+ ' . $config['extension_limit_day'] . ' day'));
|
|
@@ -963,6 +965,16 @@ class UserRepository extends BaseRepository
|
|
|
//TODO 推广人周榜
|
|
|
Cache::zincrby('s_top_' . monday(), 1, $spreadUid);
|
|
|
});
|
|
|
+ if($order_id){
|
|
|
+ //一级注册折扣百分比
|
|
|
+ $store_percentage = new StorePercentageRepository();
|
|
|
+ $store_percentage->deduction_percentage(1,$user->uid,$order_id);
|
|
|
+ $p_user = $repository->get($pid);
|
|
|
+ //二级注册折扣百分比
|
|
|
+ if($p_user->order_id){
|
|
|
+ $store_percentage->deduction_percentage(2,$user->uid,$p_user->order_id);
|
|
|
+ }
|
|
|
+ }
|
|
|
Queue::push(UserBrokerageLevelJob::class, ['uid' => $spreadUid, 'type' => 'spread_user', 'inc' => 1]);
|
|
|
app()->make(UserBrokerageRepository::class)->incMemberValue($user->uid, 'member_share_num', 0);
|
|
|
event('user.spread', compact('user','spreadUid'));
|