|
|
|
@ -308,7 +308,8 @@ class SeparateAccountsService implements SeparateAccountsServiceInterface |
|
|
|
$this->financialRecordService->storeAwardByPlatNewUserOFLOrder($store->user_id, $global_order_id, $awardAmount); |
|
|
|
$needAward = true; |
|
|
|
|
|
|
|
} else { |
|
|
|
} |
|
|
|
else { |
|
|
|
// 商户当日首单奖励
|
|
|
|
if ( |
|
|
|
$this->userService->isStoreFirstOrderToday( |
|
|
|
@ -346,6 +347,54 @@ class SeparateAccountsService implements SeparateAccountsServiceInterface |
|
|
|
|
|
|
|
// =======线下订单支付完成商户分账 / End=======
|
|
|
|
|
|
|
|
// =======服务商、市场经理奖励分账 / Start=======
|
|
|
|
// 前提A:新用户下单并且订单完成(线上、线下都行)
|
|
|
|
// 奖励规则A:用户是平台新用户,奖励市场经理 1 元,服务商 0.5 元,如果是线上订单,服务商有6%的订单分成
|
|
|
|
// 前提B:新商户旗下产生 10 个新用户
|
|
|
|
// 奖励规则B:奖励市场经理 25 元,服务商 10 元(仅仅奖励一次)
|
|
|
|
// 前提C:用户线上下单并且订单完成
|
|
|
|
// 奖励规则C:奖励服务商账单 6% 分成
|
|
|
|
// 判断是新商户:入驻绑定的时候把关系存在SSDB
|
|
|
|
// =======服务商、市场经理奖励分账 / Start=======
|
|
|
|
|
|
|
|
$MmMpAwardConfig = [ |
|
|
|
'mm_new_user' => 1, |
|
|
|
'mm_new_store' => 25, |
|
|
|
'mp_new_user' => 0.5, |
|
|
|
'mp_new_store' => 10, |
|
|
|
'separate_rate' => 6, |
|
|
|
'limit_new_user_number' => 10, |
|
|
|
]; |
|
|
|
|
|
|
|
// 当前订单(子)对应商户是否有市场经理绑定关系
|
|
|
|
$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); // 市场
|
|
|
|
$mpInfo = MpInfo::query()->find($market->mp_id); // 服务商
|
|
|
|
|
|
|
|
$ssdb = ApplicationContext::getContainer()->get(SSDBTask::class); |
|
|
|
$ssdbName = 'mm_'.$mmInfo->id.'_award_'.$store->id; |
|
|
|
$record = $ssdb->exec('hgetall', $ssdbName); |
|
|
|
|
|
|
|
// 平台新用户
|
|
|
|
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']); // 服务商新用户奖励
|
|
|
|
} |
|
|
|
|
|
|
|
// 判断是否已经奖励过新拓展商户的奖励,没有的话判断新用户个数是否达到要求,进行奖励
|
|
|
|
if ( |
|
|
|
!empty($record) |
|
|
|
&&$record['is_awarded']==0 |
|
|
|
&&$record['new_user_number']>=$MmMpAwardConfig['limit_new_user_number'] |
|
|
|
) { // 存在记录且未发放奖励,同时新用户数已经超过10
|
|
|
|
$this->financialRecordService->mmAwardByNewStore($mmInfo->admin_user_id, $global_order_id, $MmMpAwardConfig['mm_new_store']); // 市场经理新商户奖励
|
|
|
|
$this->financialRecordService->mpAwardByNewStore($mpInfo->admin_user_id, $global_order_id, $MmMpAwardConfig['mp_new_store']); // 服务商新商户奖励
|
|
|
|
} |
|
|
|
|
|
|
|
// =======服务商、市场经理奖励分账 / End=======
|
|
|
|
|
|
|
|
Db::commit(); |
|
|
|
return true; |
|
|
|
} catch (\Exception $e) { |
|
|
|
|