|
|
|
@ -389,39 +389,44 @@ class SeparateAccountsService implements SeparateAccountsServiceInterface |
|
|
|
|
|
|
|
// 当前订单(子)对应商户是否有市场经理绑定关系
|
|
|
|
$store = Store::query()->find($order['store_id']); // 商户
|
|
|
|
$mmInfo = MmInfo::query()->where(['user_id' => $store->mm_user_id])->first(); // 市场经理
|
|
|
|
$market = Market::query()->find($mmInfo->market_id); // 市场
|
|
|
|
// $mmInfo = MmInfo::query()->where(['user_id' => $store->mm_user_id])->first(); // 市场经理
|
|
|
|
$market = Market::query()->find($orderMain->market_id); // 市场
|
|
|
|
$mpInfo = MpInfo::query()->find($market->mp_id); // 服务商
|
|
|
|
|
|
|
|
$ssdb = ApplicationContext::getContainer()->get(SSDBTask::class); |
|
|
|
$ssdbName = 'mm_'.$mmInfo->id.'_award_'.$store->id; |
|
|
|
if (!empty($mpInfo)) { |
|
|
|
$ssdb = ApplicationContext::getContainer()->get(SSDBTask::class); |
|
|
|
// $ssdbName = 'mm_'.$mmInfo->id.'_award_'.$store->id;
|
|
|
|
$ssdbName = 'mm_'.$mpInfo->id.'_award_'.$store->id; |
|
|
|
|
|
|
|
// TODO 暂时在这里初始化
|
|
|
|
if (!$ssdb->exec('hexists', $ssdbName, 'is_awarded')) { |
|
|
|
$ssdb->exec('hset', $ssdbName, 'is_awarded', 0); |
|
|
|
} |
|
|
|
// TODO 暂时在这里初始化
|
|
|
|
if (!$ssdb->exec('hexists', $ssdbName, 'is_awarded')) { |
|
|
|
$ssdb->exec('hset', $ssdbName, 'is_awarded', 0); |
|
|
|
} |
|
|
|
|
|
|
|
if (!$ssdb->exec('hexists', $ssdbName, 'new_user_number')) { |
|
|
|
$ssdb->exec('hset', $ssdbName, 'new_user_number', 0); |
|
|
|
} |
|
|
|
if (!$ssdb->exec('hexists', $ssdbName, 'new_user_number')) { |
|
|
|
$ssdb->exec('hset', $ssdbName, 'new_user_number', 0); |
|
|
|
} |
|
|
|
|
|
|
|
// 平台新用户
|
|
|
|
if ($this->userService->isPlatformNewUser($orderMain->user_id, $orderMain->id)) { |
|
|
|
$ssdb->exec('hincr', $ssdbName, 'new_user_number', 1); |
|
|
|
$this->financialRecordService->mmAwardByPlatNewUser($mmInfo->admin_user_id, $global_order_id, $MmMpAwardConfig['mm_new_user'], '发展新用户'); // 市场经理新用户奖励
|
|
|
|
$this->financialRecordService->mpAwardByPlatNewUser($mpInfo->admin_user_id, $global_order_id, $MmMpAwardConfig['mp_new_user'], '市场经理「'.$mmInfo->name.'」发展新用户'); // 服务商新用户奖励
|
|
|
|
} |
|
|
|
// 平台新用户
|
|
|
|
if ($this->userService->isPlatformNewUser($orderMain->user_id, $orderMain->id)) { |
|
|
|
$ssdb->exec('hincr', $ssdbName, 'new_user_number', 1); |
|
|
|
// $this->financialRecordService->mmAwardByPlatNewUser($mmInfo->admin_user_id, $global_order_id, $MmMpAwardConfig['mm_new_user'], '发展新用户'); // 市场经理新用户奖励
|
|
|
|
// $this->financialRecordService->mpAwardByPlatNewUser($mpInfo->admin_user_id, $global_order_id, $MmMpAwardConfig['mp_new_user'], '市场经理「'.$mmInfo->name.'」发展新用户'); // 服务商新用户奖励
|
|
|
|
$this->financialRecordService->mpAwardByPlatNewUser($mpInfo->admin_user_id, $global_order_id, $MmMpAwardConfig['mp_new_user'], '发展新用户'); // 服务商新用户奖励
|
|
|
|
} |
|
|
|
|
|
|
|
$record = $ssdb->exec('hgetall', $ssdbName); |
|
|
|
// 判断是否已经奖励过新拓展商户的奖励,没有的话判断新用户个数是否达到要求,进行奖励
|
|
|
|
if ( |
|
|
|
!empty($record) |
|
|
|
&&$record['is_awarded']==0 |
|
|
|
&&$record['new_user_number']>=$MmMpAwardConfig['limit_new_user_number'] |
|
|
|
) { // 存在记录且未发放奖励,同时新用户数已经超过10
|
|
|
|
$ssdb->exec('hset', $ssdbName, 'is_awarded', 1); |
|
|
|
$this->financialRecordService->mmAwardByNewStore($mmInfo->admin_user_id, $global_order_id, $MmMpAwardConfig['mm_new_store'], '发展新商户【'.$store->name.'】'); // 市场经理新商户奖励
|
|
|
|
$this->financialRecordService->mpAwardByNewStore($mpInfo->admin_user_id, $global_order_id, $MmMpAwardConfig['mp_new_store'], '市场经理「'.$mmInfo->name.'」发展新新商户【'.$store->name.'】'); // 服务商新商户奖励
|
|
|
|
$record = $ssdb->exec('hgetall', $ssdbName); |
|
|
|
// 判断是否已经奖励过新拓展商户的奖励,没有的话判断新用户个数是否达到要求,进行奖励
|
|
|
|
if ( |
|
|
|
!empty($record) |
|
|
|
&&$record['is_awarded']==0 |
|
|
|
&&$record['new_user_number']>=$MmMpAwardConfig['limit_new_user_number'] |
|
|
|
) { // 存在记录且未发放奖励,同时新用户数已经超过10
|
|
|
|
$ssdb->exec('hset', $ssdbName, 'is_awarded', 1); |
|
|
|
// $this->financialRecordService->mmAwardByNewStore($mmInfo->admin_user_id, $global_order_id, $MmMpAwardConfig['mm_new_store'], '发展新商户【'.$store->name.'】'); // 市场经理新商户奖励
|
|
|
|
// $this->financialRecordService->mpAwardByNewStore($mpInfo->admin_user_id, $global_order_id, $MmMpAwardConfig['mp_new_store'], '市场经理「'.$mmInfo->name.'」发展新新商户【'.$store->name.'】'); // 服务商新商户奖励
|
|
|
|
$this->financialRecordService->mpAwardByNewStore($mpInfo->admin_user_id, $global_order_id, $MmMpAwardConfig['mp_new_store'], '发展新商户【'.$store->name.'】'); // 服务商新商户奖励
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// =======服务商、市场经理奖励分账 / End=======
|
|
|
|
|