|
|
@@ -15,8 +15,10 @@ use bizHd\order\services\OrderService;
|
|
|
use bizHd\saas\services\RegionService;
|
|
|
use bizHd\user\services\UserService;
|
|
|
use bizGhs\order\classes\OrderItemClass;
|
|
|
+use bizHd\wx\classes\WxOpenClass;
|
|
|
use common\components\dict;
|
|
|
use common\components\dateUtil;
|
|
|
+use common\components\payUtil;
|
|
|
use common\services\xhPayToolService;
|
|
|
use Yii;
|
|
|
use common\components\util;
|
|
|
@@ -36,29 +38,15 @@ class OrderController extends BaseController
|
|
|
//微信和支付宝付款码支付 ssh 2021.4.11
|
|
|
public function actionCodePay()
|
|
|
{
|
|
|
- $get = Yii::$app->request->get();
|
|
|
- util::success($get);
|
|
|
-/*
|
|
|
-
|
|
|
ini_set('date.timezone', 'Asia/Shanghai');
|
|
|
header("Content-type: text/html; charset=utf-8");
|
|
|
$get = Yii::$app->request->get();
|
|
|
$id = isset($get['id']) ? $get['id'] : 0;
|
|
|
$order = OrderClass::getById($id, true);
|
|
|
- if (isset($order->status) == false || $order->status != 1) {
|
|
|
- util::fail('不是待付款订单');
|
|
|
- }
|
|
|
- OrderClass::valid($order, $this->shopId);
|
|
|
- $cgId = $order->purchaseId ?? 0;
|
|
|
- $cg = PurchaseClass::getById($cgId, true);
|
|
|
- $orderSn = $cg->orderSn ?? '';
|
|
|
- if (empty($orderSn)) {
|
|
|
- util::fail('没有找到采购单');
|
|
|
- }
|
|
|
- //付款码
|
|
|
+ OrderClass::valid($order, $this->mainId);
|
|
|
$authCode = (string)$get['authCode'] ?? '';
|
|
|
if (empty($authCode)) {
|
|
|
- util::fail('支付失败');
|
|
|
+ util::fail('没有获取到支付码');
|
|
|
}
|
|
|
$wxPrefix = ['10', '11', '12', '13', '14', '15'];
|
|
|
$isWx = false;
|
|
|
@@ -67,26 +55,19 @@ class OrderController extends BaseController
|
|
|
$isWx = true;
|
|
|
}
|
|
|
}
|
|
|
- $deadline = $cg->deadline;
|
|
|
- $current = date("Y-m-d H:i:s");
|
|
|
- if ((strtotime($deadline) + 20) < strtotime($current)) {
|
|
|
- util::fail('订单已经失效');
|
|
|
- }
|
|
|
- $totalFee = $cg->actPrice ?? 0;
|
|
|
-
|
|
|
+ $orderSn = $order->orderSn ?? '';
|
|
|
$outTradeNo = $orderSn;
|
|
|
$subject = '购买商品';
|
|
|
+ $totalFee = $order->orderPrice ?? 0;
|
|
|
$totalAmount = $totalFee;
|
|
|
$body = "门店";
|
|
|
- $capitalType = dict::getDict('capitalType', 'xhPurchase', 'id');
|
|
|
+ $capitalType = dict::getDict('capitalType', 'xhOrder', 'id');
|
|
|
|
|
|
if ($isWx) {
|
|
|
|
|
|
$wxPayWay = dict::getDict('payWay', 'wxPay');
|
|
|
$order->payWay = $wxPayWay;
|
|
|
$order->save();
|
|
|
- $cg->payWay = $wxPayWay;
|
|
|
- $cg->save();
|
|
|
|
|
|
$wx = Yii::getAlias("@vendor/wxPayApi_v3.0.10");
|
|
|
require_once($wx . '/lib/WxPay.Api.php');
|
|
|
@@ -105,27 +86,10 @@ class OrderController extends BaseController
|
|
|
$res = $microPay->pay($input, $sjExtend);
|
|
|
if (isset($res["return_code"]) && $res["return_code"] == "SUCCESS" && isset($res["result_code"]) && $res["result_code"] == 'SUCCESS') {
|
|
|
$transactionId = $res['transaction_id'] ?? '';
|
|
|
- $openId = $res['openid'] ?? '';
|
|
|
- $aliUserId = '';
|
|
|
-
|
|
|
- $cg->onlinePay = dict::getDict('onlinePay', 'yes');
|
|
|
- $cg->codePay = 1;
|
|
|
- $cg->payOpenId = $openId;
|
|
|
- $cg->aliUserId = $aliUserId;
|
|
|
- //自取订单
|
|
|
- $cg->getType = PurchaseClass::GET_TYPE_SELF_GET;
|
|
|
- $cg->save();
|
|
|
-
|
|
|
$order->onlinePay = dict::getDict('onlinePay', 'yes');
|
|
|
- $order->codePay = 1;
|
|
|
- //自取订单
|
|
|
- $order->sendType = OrderClass::SEND_TYPE_NO;
|
|
|
$order->save();
|
|
|
-
|
|
|
$attach = '';
|
|
|
payUtil::thirdPay($wxPayWay, $capitalType, $orderSn, $totalFee, $attach, $transactionId);
|
|
|
-
|
|
|
-
|
|
|
util::success(['returnStatus' => 'SUCCESS']);
|
|
|
} else {
|
|
|
Yii::info(json_encode($res));
|
|
|
@@ -145,8 +109,6 @@ class OrderController extends BaseController
|
|
|
$aliPayWay = dict::getDict('payWay', 'alipay');
|
|
|
$order->payWay = $aliPayWay;
|
|
|
$order->save();
|
|
|
- $cg->payWay = $aliPayWay;
|
|
|
- $cg->save();
|
|
|
|
|
|
$aliF2F = Yii::getAlias("@vendor/alipayF2F");
|
|
|
require_once($aliF2F . '/f2fpay/model/builder/AlipayTradePayContentBuilder.php');
|
|
|
@@ -195,24 +157,9 @@ class OrderController extends BaseController
|
|
|
|
|
|
if ($barPayResult->getTradeStatus() == 'SUCCESS') {
|
|
|
$respond = $barPayResult->getResponse();
|
|
|
- $openId = '';
|
|
|
- $aliUserId = $respond->buyer_user_id ?? '';
|
|
|
$transactionId = $respond->trade_no ?? '';
|
|
|
-
|
|
|
- $cg->onlinePay = dict::getDict('onlinePay', 'yes');
|
|
|
- $cg->codePay = 1;
|
|
|
- $cg->payOpenId = $openId;
|
|
|
- $cg->aliUserId = $aliUserId;
|
|
|
- //自取订单
|
|
|
- $cg->getType = PurchaseClass::GET_TYPE_SELF_GET;
|
|
|
- $cg->save();
|
|
|
-
|
|
|
$order->onlinePay = dict::getDict('onlinePay', 'yes');
|
|
|
- $order->codePay = 1;
|
|
|
- //自取订单
|
|
|
- $order->sendType = OrderClass::SEND_TYPE_NO;
|
|
|
$order->save();
|
|
|
-
|
|
|
$attach = '';
|
|
|
payUtil::thirdPay($aliPayWay, $capitalType, $orderSn, $totalFee, $attach, $transactionId);
|
|
|
|
|
|
@@ -220,7 +167,7 @@ class OrderController extends BaseController
|
|
|
}
|
|
|
util::success(['returnStatus' => 'FAILURE']);
|
|
|
}
|
|
|
-*/
|
|
|
+
|
|
|
}
|
|
|
|
|
|
//开单操作 ssh 20220316
|