|
|
@@ -291,30 +291,39 @@ class UserService extends BaseService
|
|
|
public static function addUser($data)
|
|
|
{
|
|
|
//merchantId $source $realName $member $growth $balance $mobile
|
|
|
- validate::easyCheck(['merchantId','source','mobile'], $data);
|
|
|
+ //必传参数
|
|
|
+ validate::easyCheck(['merchantId', 'mobile'], $data);
|
|
|
|
|
|
$merchantId = $data['merchantId'];
|
|
|
- $source = $data['source'];
|
|
|
+ $source = isset($data['source']) ? $data['source'] : 0;
|
|
|
$mobile = $data['mobile'];
|
|
|
$realName = isset($data['realName']) ? $data['realName'] : $mobile;
|
|
|
-
|
|
|
+ $member = isset($data['member']) ? $data['member'] : -1;
|
|
|
+ $balance = isset($data['balance']) ? $data['balance'] : 0;
|
|
|
+
|
|
|
$originalInfo = [];
|
|
|
$originalInfo['merchantId'] = $merchantId;
|
|
|
$originalInfo['mobile'] = $mobile;
|
|
|
$originalInfo['realName'] = $realName;
|
|
|
-
|
|
|
+
|
|
|
$user = UserService::replaceUser($originalInfo, $source, $merchantId);
|
|
|
-
|
|
|
- //等级
|
|
|
+
|
|
|
$extend = MerchantExtendService::getByMerchantId($merchantId);
|
|
|
- $gradeList = xhMerchantExtendService::getGradeList($extend, 'desc');
|
|
|
- $growth = isset($gradeList[$member]['growth']) ? $gradeList[$member]['growth'] : 0;
|
|
|
-
|
|
|
+
|
|
|
+ //等级
|
|
|
+ $growth = 0;
|
|
|
+ if ($member > 0) {
|
|
|
+ $gradeList = xhMerchantExtendService::getGradeList($extend, 'desc');
|
|
|
+ $growth = isset($gradeList[$member]['growth']) ? $gradeList[$member]['growth'] : 0;
|
|
|
+ }
|
|
|
+
|
|
|
//余额成长值更新
|
|
|
$userId = $user['id'];
|
|
|
- $data = ['balance' => $balance, 'growth' => $growth];
|
|
|
+ $data = [];
|
|
|
+ $data['growth'] = $growth;
|
|
|
+ $data['balance'] = $balance > 0 ? $balance : 0;
|
|
|
UserAssetService::updateByUserId($userId, $data);
|
|
|
-
|
|
|
+
|
|
|
//会员升级
|
|
|
UserIntegralService::increaseToUpgrade(0, $growth, 0, $userId, $merchantId, $extend);
|
|
|
}
|