Quellcode durchsuchen

余额支付优化

shish vor 6 Jahren
Ursprung
Commit
457e737775
2 geänderte Dateien mit 21 neuen und 21 gelöschten Zeilen
  1. 4 4
      app/client/controllers/OrderController.php
  2. 17 17
      common/services/xhPayToolService.php

+ 4 - 4
app/client/controllers/OrderController.php

@@ -142,9 +142,9 @@ class OrderController extends BaseController
 		$payPassword = isset($post['payPassword']) ? $post['payPassword'] : 0;
 		$couponId = isset($post['couponId']) ? $post['couponId'] : 0;
 		$order = OrderService::getById($orderId);
-
+		
 		//dd(password_hash('123456', PASSWORD_BCRYPT));
-
+		
 		//验证支付密码是否正确
 		UserService::validPayPassword($payPassword, $this->user);
 		
@@ -154,8 +154,8 @@ class OrderController extends BaseController
 		$typeList = configDict::getConfig('capitalType');
 		$capitalType = $typeList['xhOrder']['id'];
 		$totalFee = $order['actPrice'];
-		$return = xhPayToolService::balancePay($orderId, $totalFee, $capitalType, $couponId);
-		util::success($return);
+		xhPayToolService::balancePay($orderId, $totalFee, $capitalType, $couponId);
+		util::success('支付成功');
 	}
 	
 	//获取商城下单要用的微信支付参数 shish 2019.21.3

+ 17 - 17
common/services/xhPayToolService.php

@@ -6,6 +6,7 @@ use biz\order\services\OrderService;
 use biz\user\services\UserAssetService;
 use biz\user\services\UserService;
 use common\components\stringUtil;
+use common\components\util;
 use Yii;
 use common\components\configDict;
 use linslin\yii2\curl;
@@ -77,19 +78,19 @@ class xhPayToolService
 					break;
 				default:
 					Yii::warning('获取订单信息失败,回调传过来的 capitalType 不符合要求,capitalType:' . $capitalType . ' orderId:' . $orderId);
-					return ['code' => 'A0002', 'msg' => '订单流水类型不明确'];
+					util::fail('订单流水类型不明确');
 			}
 			if (empty($order)) {
 				Yii::warning('order info empty,capitalType:' . $capitalType . ' orderId:' . $orderId);
-				return ['code' => 'A0002', 'msg' => '订单信息为空'];
+				util::fail('订单信息为空');
 			}
 			if ($order['payStatus'] == 1) {
 				Yii::warning('already pay,capitalType:' . $capitalType . ' orderId:' . $orderId);
-				return ['code' => 'A0002', 'msg' => '已经付款过了'];
+				util::fail('已经付款过了');
 			}
 			if ($totalFee != $order['actPrice']) {
 				Yii::warning('第三方回调金额与订单表里金额不一致,capitalType:' . $capitalType . ' orderId:' . $orderId);
-				return ['code' => 'A0002', 'msg' => '订单出错了'];
+				util::fail('订单出错了');
 			}
 			$orderId = $order['id'];
 			$userId = $order['userId'];
@@ -111,12 +112,12 @@ class xhPayToolService
 			//余额支付
 			$balancePay = configDict::getConfig('payWay', 'balancePay');//余额支付
 			if ($payWay == $balancePay && !empty($order['deadline']) && $now > $order['deadline']) {
-				return ['code' => 'A0002', 'msg' => '订单已经过期'];
+				util::fail('订单已经过期');
 			}
 			if (empty($userId) && $payWay == $balancePay) {
 				$transaction->rollBack();
 				Yii::warning('未登陆用户无法使用余额支付,capitalType:' . $capitalType . ' orderId:' . $orderId);
-				return ['code' => 'A0002', 'msg' => '未登陆用户无法使用余额支付'];
+				util::fail('没有登陆不能使用余额支付');
 			}
 			$updateData = [];
 			$updateData['alipayId'] = $alipayId;
@@ -141,13 +142,13 @@ class xhPayToolService
 				$userAsset = xhUserAssetService::getByUserId($userId);
 			}
 			if (empty($user)) {
-				return ['code' => 'A0002', 'msg' => '没有用户信息'];
+				util::fail('没有客户信息');
 			}
 			
 			$balance = $userAsset['balance'];
 			if ($payWay == $balancePay && $balance < $totalFee) {
 				Yii::warning('余额不足,capitalType:' . $capitalType . ' orderId:' . $orderId);
-				return ['code' => 'A0002', 'msg' => '余额不足'];
+				util::fail('余额不足');
 			}
 			
 			$mAsset = xhMerchantAssetService::getByMerchantId($merchantId);
@@ -218,17 +219,17 @@ class xhPayToolService
 					break;
 				default:
 					Yii::warning('更新订单失败,回调传过来的 capitalType 不符合要求,即订单流水类型不明确,capitalType:' . $capitalType . ' orderId:' . $orderId);
-					return ['code' => 'A0002', 'msg' => '订单流水类型不明确'];
+					util::fail('订单流水类型不明确');
 			}
-
+			
 			//抵销优惠券并分成
 			//CouponService::destroyToGetReward(['id' => $couponId]);
-
+			
 			if (isset($order['inviteCode']) && !empty($order['inviteCode'])) {
 				$invitedMerchantId = isset($order['invitedMerchantId']) ? $order['invitedMerchantId'] : 0;
 				xhInviteService::updateByCode($order['inviteCode'], ['takeStatus' => 1, 'inviteUseTo' => 0, 'targetId' => $orderId, 'invitedMerchantId' => $invitedMerchantId]);
 			}
-
+			
 			//累计消费
 			$userTotalExpend = stringUtil::calcAdd($userAsset['totalExpend'], $totalFee);
 			//成长值增加
@@ -260,7 +261,7 @@ class xhPayToolService
 				'addTime' => $now,
 			];
 			xhUserGrowthService::add($integralData);//用户兑换型积分流水增加
-
+			
 			$userCapitalData = [
 				'relateId' => (string)$orderId,
 				'balance' => $remainBalance,
@@ -285,13 +286,12 @@ class xhPayToolService
 			
 			//订单有选择分类和用途,则直接进行老带新的发放和资金分类登记 shish 2019.9.3
 			if (isset($order['categoryId']) && !empty($order['categoryId']) && isset($order['usageId']) && !empty($order['usageId'])) {
-				$setOrderData = ['id' => $orderId, 'categoryId' => $order['categoryId'], 'usageId' => $order['usageId']];
-				OrderService::setOrderStyle($setOrderData,true);
+				//$setOrderData = ['id' => $orderId, 'categoryId' => $order['categoryId'], 'usageId' => $order['usageId']];
+				//OrderService::setOrderStyle($setOrderData, true);
 			}
-			return ['code' => 'A0001', 'msg' => '支付成功', 'data' => ['orderId' => $orderId]];
 		} catch (Exception $e) {
 			$transaction->rollBack();
-			return ['code' => 'A0002', 'msg' => '支付没有成功'];
+			util::fail('支付没有成功');
 		}
 	}