|
|
@@ -23,37 +23,37 @@ class xhPayToolService
|
|
|
/**
|
|
|
* 余额支付
|
|
|
*/
|
|
|
- public static function balancePay($orderId, $totalFee, $capitalType, $couponId)
|
|
|
+ public static function balancePay($orderSn, $totalFee, $capitalType, $couponId)
|
|
|
{
|
|
|
$payWay = configDict::getConfig('payWay', 'balancePay');
|
|
|
- return self::basePay($orderId, $totalFee, $capitalType, $couponId, $payWay);
|
|
|
+ return self::basePay($orderSn, $totalFee, $capitalType, $couponId, $payWay);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 微信支付
|
|
|
*/
|
|
|
- public static function weixinPay($orderId, $totalFee, $capitalType, $couponId)
|
|
|
+ public static function weixinPay($orderSn, $totalFee, $capitalType, $couponId)
|
|
|
{
|
|
|
$payWay = configDict::getConfig('payWay', 'weixinPay');
|
|
|
- return self::basePay($orderId, $totalFee, $capitalType, $couponId, $payWay);
|
|
|
+ return self::basePay($orderSn, $totalFee, $capitalType, $couponId, $payWay);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 支付宝支付
|
|
|
*/
|
|
|
- public static function alipay($orderId, $totalFee, $capitalType, $couponId, $alipayParams)
|
|
|
+ public static function alipay($orderSn, $totalFee, $capitalType, $couponId, $alipayParams)
|
|
|
{
|
|
|
$payWay = configDict::getConfig('payWay', 'alipay');
|
|
|
- return self::basePay($orderId, $totalFee, $capitalType, $couponId, $payWay, $alipayParams);
|
|
|
+ return self::basePay($orderSn, $totalFee, $capitalType, $couponId, $payWay, $alipayParams);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 现金支付,转店主微信,转店主支付宝
|
|
|
*/
|
|
|
- public static function cashPay($orderId, $totalFee, $capitalType, $couponId)
|
|
|
+ public static function cashPay($orderSn, $totalFee, $capitalType, $couponId)
|
|
|
{
|
|
|
$payWay = configDict::getConfig('payWay', 'cashPay');
|
|
|
- return self::basePay($orderId, $totalFee, $capitalType, $couponId, $payWay);
|
|
|
+ return self::basePay($orderSn, $totalFee, $capitalType, $couponId, $payWay);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -61,7 +61,7 @@ class xhPayToolService
|
|
|
* $capitalType 需要支付订单来源:xhOrder xhActiveOrder xhApplyOrder
|
|
|
* $payWay 支付方式:weixinPay alipay balancePay cashPay
|
|
|
*/
|
|
|
- public static function basePay($orderId, $totalFee, $capitalType, $couponId, $payWay, $alipayParams = [])
|
|
|
+ public static function basePay($orderSn, $totalFee, $capitalType, $couponId, $payWay, $alipayParams = [])
|
|
|
{
|
|
|
$connection = Yii::$app->db;//事务处理
|
|
|
$transaction = $connection->beginTransaction();
|
|
|
@@ -69,31 +69,32 @@ class xhPayToolService
|
|
|
$typeList = configDict::getConfig('capitalType');//流水类型列表
|
|
|
switch ($capitalType) {
|
|
|
case $typeList['xhOrder']['id']://购买商品
|
|
|
- $order = xhOrderService::getById($orderId);
|
|
|
+ $order = xhOrderService::getByOrderSn($orderSn);
|
|
|
break;
|
|
|
case $typeList['xhActiveOrder']['id']://活动报名
|
|
|
- $order = xhActiveOrderService::getById($orderId);
|
|
|
+ $order = xhActiveOrderService::getById($orderSn);
|
|
|
break;
|
|
|
case $typeList['xhApplyOrder']['id']:
|
|
|
- $order = xhApplyOrderService::getById($orderId);
|
|
|
+ $order = xhApplyOrderService::getById($orderSn);
|
|
|
break;
|
|
|
default:
|
|
|
- Yii::warning('获取订单信息失败,回调传过来的 capitalType 不符合要求,capitalType:' . $capitalType . ' orderId:' . $orderId);
|
|
|
+ Yii::warning('获取订单信息失败,回调传过来的 capitalType 不符合要求,capitalType:' . $capitalType . ' orderSn:' . $orderSn);
|
|
|
util::fail('订单流水类型不明确');
|
|
|
}
|
|
|
if (empty($order)) {
|
|
|
- Yii::warning('order info empty,capitalType:' . $capitalType . ' orderId:' . $orderId);
|
|
|
+ Yii::warning('order info empty,capitalType:' . $capitalType . ' orderSn:' . $orderSn);
|
|
|
util::fail('订单信息为空');
|
|
|
}
|
|
|
if ($order['payStatus'] == 1) {
|
|
|
- Yii::warning('already pay,capitalType:' . $capitalType . ' orderId:' . $orderId);
|
|
|
+ Yii::warning('already pay,capitalType:' . $capitalType . ' orderSn:' . $orderSn);
|
|
|
util::fail('已经付款过了');
|
|
|
}
|
|
|
if ($totalFee != $order['actPrice']) {
|
|
|
- Yii::warning('第三方回调金额与订单表里金额不一致,capitalType:' . $capitalType . ' orderId:' . $orderId);
|
|
|
+ Yii::warning('第三方回调金额与订单表里金额不一致,capitalType:' . $capitalType . ' orderSn:' . $orderSn);
|
|
|
util::fail('订单出错了');
|
|
|
}
|
|
|
$orderId = $order['id'];
|
|
|
+ $orderSn = $order['orderSn'];
|
|
|
$userId = $order['userId'];
|
|
|
$totalFee = $order['actPrice'];
|
|
|
$merchantId = $order['merchantId'];
|
|
|
@@ -117,7 +118,7 @@ class xhPayToolService
|
|
|
}
|
|
|
if (empty($userId) && $payWay == $balancePay) {
|
|
|
$transaction->rollBack();
|
|
|
- Yii::warning('未登陆用户无法使用余额支付,capitalType:' . $capitalType . ' orderId:' . $orderId);
|
|
|
+ Yii::warning('未登陆用户无法使用余额支付,capitalType:' . $capitalType . ' orderSn:' . $orderSn);
|
|
|
util::fail('没有登陆不能使用余额支付');
|
|
|
}
|
|
|
$updateData = [];
|
|
|
@@ -146,7 +147,7 @@ class xhPayToolService
|
|
|
|
|
|
$balance = $userAsset['balance'];
|
|
|
if ($payWay == $balancePay && $balance < $totalFee) {
|
|
|
- Yii::warning('余额不足,capitalType:' . $capitalType . ' orderId:' . $orderId);
|
|
|
+ Yii::warning('余额不足,capitalType:' . $capitalType . ' orderSn:' . $orderSn);
|
|
|
util::fail('余额不足');
|
|
|
}
|
|
|
|
|
|
@@ -181,7 +182,7 @@ class xhPayToolService
|
|
|
default:
|
|
|
}
|
|
|
$capitalData = [
|
|
|
- 'relateId' => (string)$orderId,
|
|
|
+ 'relateId' => (string)$orderSn,
|
|
|
'balance' => $mBalance,
|
|
|
'totalIncome' => $mIncome,
|
|
|
'totalExpend' => $mExpend,
|
|
|
@@ -207,19 +208,19 @@ class xhPayToolService
|
|
|
$updateData['payTime'] = $now;
|
|
|
switch ($capitalType) {
|
|
|
case $typeList['xhOrder']['id']://购买商品
|
|
|
- xhOrderService::updateById($orderId, $updateData);
|
|
|
+ xhOrderService::updateById($orderSn, $updateData);
|
|
|
//发货里的下单流程完成
|
|
|
OrderSendClass::placeOrder(['orderId' => $orderId, 'payTime' => $now]);
|
|
|
break;
|
|
|
case $typeList['xhActiveOrder']['id']://活动报名
|
|
|
- xhActiveOrderService::updateById($orderId, $updateData);
|
|
|
+ xhActiveOrderService::updateById($orderSn, $updateData);
|
|
|
break;
|
|
|
case $typeList['xhApplyOrder']['id']://申请服务
|
|
|
$updateData['inviteCodeStatus'] = 1;
|
|
|
- xhApplyOrderService::updateById($orderId, $updateData);
|
|
|
+ xhApplyOrderService::updateById($orderSn, $updateData);
|
|
|
break;
|
|
|
default:
|
|
|
- Yii::warning('更新订单失败,回调传过来的 capitalType 不符合要求,即订单流水类型不明确,capitalType:' . $capitalType . ' orderId:' . $orderId);
|
|
|
+ Yii::warning('更新订单失败,回调传过来的 capitalType 不符合要求,即订单流水类型不明确,capitalType:' . $capitalType . ' orderSn:' . $orderSn);
|
|
|
util::fail('订单流水类型不明确');
|
|
|
}
|
|
|
|
|
|
@@ -241,7 +242,7 @@ class xhPayToolService
|
|
|
'userId' => $userId,
|
|
|
'userName' => $userName,
|
|
|
'merchantId' => $merchantId,
|
|
|
- 'relateId' => (string)$orderId,
|
|
|
+ 'relateId' => (string)$orderSn,
|
|
|
'growth' => $userGrowth,
|
|
|
'num' => floor($totalFee),
|
|
|
'io' => 1,
|
|
|
@@ -256,7 +257,7 @@ class xhPayToolService
|
|
|
xhUserGrowthService::add($integralData);//用户兑换型积分流水增加
|
|
|
|
|
|
$userCapitalData = [
|
|
|
- 'relateId' => (string)$orderId,
|
|
|
+ 'relateId' => (string)$orderSn,
|
|
|
'balance' => $remainBalance,
|
|
|
'totalIncome' => $userAsset['totalIncome'],
|
|
|
'totalExpend' => $userTotalExpend,
|
|
|
@@ -279,7 +280,7 @@ 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']];
|
|
|
+ //$setOrderData = ['id' => $orderSn, 'categoryId' => $order['categoryId'], 'usageId' => $order['usageId']];
|
|
|
//OrderService::setOrderStyle($setOrderData, true);
|
|
|
}
|
|
|
} catch (Exception $e) {
|