|
|
@@ -8,6 +8,7 @@ use biz\user\services\UserAssetService;
|
|
|
use biz\user\services\UserIntegralService;
|
|
|
use biz\user\services\UserService;
|
|
|
use common\services\xhMerchantExtendService;
|
|
|
+use common\services\xhRechargeService;
|
|
|
use Yii;
|
|
|
use common\components\stringUtil;
|
|
|
use common\components\util;
|
|
|
@@ -100,16 +101,46 @@ class UserController extends BaseController
|
|
|
$extend = MerchantExtendService::getByMerchantId($this->merchantId);
|
|
|
$gradeList = xhMerchantExtendService::getGradeList($extend, 'desc');
|
|
|
$growth = isset($gradeList[$memberLevel]['growth']) ? $gradeList[$memberLevel]['growth'] : 0;
|
|
|
-
|
|
|
+
|
|
|
//余额成长值更新
|
|
|
$userId = $user['id'];
|
|
|
$balance = isset($post['balance']) && is_numeric($post['balance']) ? $post['balance'] : 0;
|
|
|
- $data = ['balance' => $balance,'growth'=>$growth];
|
|
|
+ $data = ['balance' => $balance, 'growth' => $growth];
|
|
|
UserAssetService::updateByUserId($userId, $data);
|
|
|
-
|
|
|
+
|
|
|
//会员升级
|
|
|
UserIntegralService::increaseToUpgrade(0, $growth, 0, $userId, $merchantId, $extend);
|
|
|
util::ok();
|
|
|
}
|
|
|
|
|
|
+ //充值 shish 2019.12.1
|
|
|
+ public function actionRecharge()
|
|
|
+ {
|
|
|
+ $post = Yii::$app->request->post();
|
|
|
+ $confirmPassword = isset($post['confirmPassword']) ? $post['confirmPassword'] : '';
|
|
|
+ $verify = AdminService::verifyConfirmPassword($this->adminId, $confirmPassword);
|
|
|
+ if ($verify == false) {
|
|
|
+ util::fail('密码错误');
|
|
|
+ }
|
|
|
+ $userId = isset($post['userId']) ? $post['userId'] : 0;
|
|
|
+ $rechargeAmount = isset($post['rechargeAmount']) ? $post['rechargeAmount'] : 1;
|
|
|
+ $user = UserService::getById($userId);
|
|
|
+ if (empty($user)) {
|
|
|
+ util::fail('找不到客户');
|
|
|
+ }
|
|
|
+ if ($user['merchantId'] != $this->merchantId) {
|
|
|
+ util::fail('您没有权限操作');
|
|
|
+ }
|
|
|
+ $userAsset = UserAssetService::getByUserId($userId);
|
|
|
+ $totalBalance = $userAsset['balance'] + $rechargeAmount;
|
|
|
+ $totalRecharge = $userAsset['totalRecharge'] + $rechargeAmount;
|
|
|
+ $upData['balance'] = $totalBalance;
|
|
|
+ $upData['totalRecharge'] = $totalRecharge;
|
|
|
+ $return = xhRechargeService::recharge($rechargeAmount, $user, $this->adminId, $this->merchant, $this->merchantExtend, $this->merchantAsset);
|
|
|
+ if ($return['code'] == 'A0001') {
|
|
|
+ util::ok();
|
|
|
+ }
|
|
|
+ util::fail();
|
|
|
+ }
|
|
|
+
|
|
|
}
|