Browse Source

引入软删除,初始化ssdb记录市场经理新用户数据

master
weigang 5 years ago
parent
commit
5b4ab910cf
  1. 4
      app/Model/MmInfo.php
  2. 5
      app/Model/MpInfo.php
  3. 24
      app/Service/SeparateAccountsService.php

4
app/Model/MmInfo.php

@ -2,7 +2,11 @@
namespace App\Model;
use Hyperf\Database\Model\SoftDeletes;
class MmInfo extends Model
{
use SoftDeletes;
protected $table = 'lanzu_mm_info';
}

5
app/Model/MpInfo.php

@ -2,7 +2,12 @@
namespace App\Model;
use Hyperf\Database\Model\SoftDeletes;
class MpInfo extends Model
{
use SoftDeletes;
protected $table = 'lanzu_mp_info';
}

24
app/Service/SeparateAccountsService.php

@ -4,6 +4,7 @@ namespace App\Service;
use App\Commons\Log;
use App\Constants\LogLabel;
use App\Constants\SsdbKeysPrefix;
use App\Model\FinancialRecord;
use App\Model\Market;
use App\Model\MmInfo;
@ -189,7 +190,15 @@ class SeparateAccountsService implements SeparateAccountsServiceInterface
$mpInfo = MpInfo::query()->find($market->mp_id); // 服务商
$ssdbName = 'mm_'.$mmInfo->id.'_award_'.$store->id;
$record = $ssdb->exec('hgetall', $ssdbName);
// 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 ($this->userService->isPlatformNewUser($orderMain->user_id, $orderMain->id)) {
@ -198,6 +207,8 @@ class SeparateAccountsService implements SeparateAccountsServiceInterface
$this->financialRecordService->mpAwardByPlatNewUser($mpInfo->admin_user_id, $global_order_id, $MmMpAwardConfig['mp_new_user'], '市场经理「'.$mmInfo->name.'」发展新用户'); // 服务商新用户奖励
}
$record = $ssdb->exec('hgetall', $ssdbName);
// 判断是否已经奖励过新拓展商户的奖励,没有的话判断新用户个数是否达到要求,进行奖励
if (
!empty($record)
@ -374,7 +385,15 @@ class SeparateAccountsService implements SeparateAccountsServiceInterface
$ssdb = ApplicationContext::getContainer()->get(SSDBTask::class);
$ssdbName = 'mm_'.$mmInfo->id.'_award_'.$store->id;
$record = $ssdb->exec('hgetall', $ssdbName);
// 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 ($this->userService->isPlatformNewUser($orderMain->user_id, $orderMain->id)) {
@ -383,6 +402,7 @@ class SeparateAccountsService implements SeparateAccountsServiceInterface
$this->financialRecordService->mpAwardByPlatNewUser($mpInfo->admin_user_id, $global_order_id, $MmMpAwardConfig['mp_new_user'], '市场经理「'.$mmInfo->name.'」发展新用户'); // 服务商新用户奖励
}
$record = $ssdb->exec('hgetall', $ssdbName);
// 判断是否已经奖励过新拓展商户的奖励,没有的话判断新用户个数是否达到要求,进行奖励
if (
!empty($record)

Loading…
Cancel
Save