فهرست منبع

充值接口可以了

shish 6 سال پیش
والد
کامیت
4dabe8b595
2فایلهای تغییر یافته به همراه36 افزوده شده و 39 حذف شده
  1. 34 3
      app/business/controllers/UserController.php
  2. 2 36
      common/services/xhWxOpenService.php

+ 34 - 3
app/business/controllers/UserController.php

@@ -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();
+	}
+
 }

+ 2 - 36
common/services/xhWxOpenService.php

@@ -9,42 +9,8 @@ class xhWxOpenService {
 
 	public static function getById($id=0)
 	{
-		$defaultId		= configDict::getConfig('openId');
-		$id				= empty($id) ? $defaultId : $id;
-		$preKey			= configDict::getCacheKey('wxOpen');
-		$cacheKey		= $preKey.$id;
-		$cacheData		= Yii::$app->redis->executeCommand('HGETALL', [$cacheKey]);
-		$data			= [];
-		$list			= [];
-		if(!empty($cacheData)){
-			if(!empty($cacheData)){
-				$x		= 0;
-				foreach($cacheData as $cKey => $cVal){
-					if($cKey%2 == 0){
-						$list[$x]['key'] = $cVal;
-					}else{
-						$list[$x]['value'] = $cVal;
-						$x++;
-					}
-				}
-				foreach($list as $lKey => $lVal){
-					$data[$lVal['key']]	= $lVal['value'];
-				}
-			}
-		}else{
-			$condition		= ['id' => $id];
-			$merchant		= xhWxOpen::getByCondition($condition);
-			if(!empty($merchant)){
-				$arr		= [$cacheKey];
-				foreach($merchant as $key => $val){
-					$arr[]	= $key;
-					$arr[]	= $val;
-				}
-				Yii::$app->redis->executeCommand('HMSET', $arr);
-			}
-			$data			= $merchant;
-		}
-		return $data;
+		$merchant		= xhWxOpen::getByCondition($condition);
+		return $merchant;
 	}
 	
 	public static function updateById($id, $data)