|
|
@@ -2,10 +2,7 @@
|
|
|
|
|
|
namespace ghs\controllers;
|
|
|
|
|
|
-use biz\stat\classes\StatOrderCountClass;
|
|
|
use bizGhs\express\services\DadaExpressServices;
|
|
|
-use bizGhs\order\classes\OrderItemClass;
|
|
|
-use bizGhs\order\classes\StockWastageOrderClass;
|
|
|
use bizHd\purchase\classes\PurchaseClass;
|
|
|
use bizHd\purchase\services\PurchaseService;
|
|
|
use bizHd\wx\classes\WxOpenClass;
|
|
|
@@ -14,14 +11,12 @@ use bizGhs\order\classes\OrderClass;
|
|
|
use bizGhs\order\services\OrderService;
|
|
|
use bizHd\saas\services\RegionService;
|
|
|
use bizGhs\product\classes\ProductClass;
|
|
|
-use common\components\dada\dada;
|
|
|
use common\components\dict;
|
|
|
use common\components\dateUtil;
|
|
|
use common\components\freight;
|
|
|
use common\components\httpUtil;
|
|
|
use Yii;
|
|
|
use common\components\util;
|
|
|
-use bizGhs\order\classes\RefundOrderClass;
|
|
|
use biz\shop\classes\ShopAdminClass;
|
|
|
|
|
|
class OrderController extends BaseController
|
|
|
@@ -29,6 +24,67 @@ class OrderController extends BaseController
|
|
|
|
|
|
public $guestAccess = ['create-order', 'order-relate', 'fast-pay'];
|
|
|
|
|
|
+ //微信和支付宝付款码支付复查 shish 20211231
|
|
|
+ public function actionCodePayCheck()
|
|
|
+ {
|
|
|
+ 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 (empty($order)) {
|
|
|
+ util::fail('没有找到订单');
|
|
|
+ }
|
|
|
+ if ($order->status != OrderClass::ORDER_STATUS_UN_PAY) {
|
|
|
+ if ($order->status == OrderClass::ORDER_STATUS_COMPLETE) {
|
|
|
+ util::fail('订单已付款');
|
|
|
+ }
|
|
|
+ util::fail('订单不是待付款状态');
|
|
|
+ }
|
|
|
+ OrderClass::valid($order, $this->shopId);
|
|
|
+ $cgId = $order->purchaseId ?? 0;
|
|
|
+ $cg = PurchaseClass::getById($cgId, true);
|
|
|
+ $orderSn = $cg->orderSn ?? '';
|
|
|
+ if (empty($orderSn)) {
|
|
|
+ util::fail('没有找到采购单');
|
|
|
+ }
|
|
|
+ $payWay = $cg->payWay ?? dict::getDict('payWay', 'wxPay');
|
|
|
+ if ($payWay == dict::getDict('payWay', 'wxPay')) {
|
|
|
+ //微信付款
|
|
|
+ $wx = Yii::getAlias("@vendor/wxPayApi_v3.0.10");
|
|
|
+ require_once($wx . '/lib/WxPay.Api.php');
|
|
|
+ require_once($wx . '/example/WxPay.MicroPay.php');
|
|
|
+
|
|
|
+ //获取微信商户号等信息
|
|
|
+ $sjExtend = WxOpenClass::getGhsWxInfo();
|
|
|
+
|
|
|
+ $microPay = new \MicroPay();
|
|
|
+ $payReturn = $microPay->query($orderSn, $sjExtend);
|
|
|
+ if ($payReturn["return_code"] == "SUCCESS" && $payReturn["result_code"] == "SUCCESS") {
|
|
|
+ if ($payReturn["trade_state"] == "SUCCESS") {
|
|
|
+ //支付成功
|
|
|
+ $transactionId = $payReturn['transaction_id'] ?? '';
|
|
|
+ $openId = $payReturn['openid'] ?? '';
|
|
|
+ PurchaseService::codePay($payWay, $orderSn, $transactionId, $openId);
|
|
|
+ util::success(['returnStatus' => 'SUCCESS']);
|
|
|
+ } else if ($payReturn["trade_state"] == "USERPAYING") {
|
|
|
+ //用户支付中
|
|
|
+ util::fail('正在付款,请稍候再试');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if ($payReturn["err_code"] == "ORDERNOTEXIST") {
|
|
|
+ //交易订单号不存在
|
|
|
+ util::fail('订单没有发起过支付');
|
|
|
+ } else {
|
|
|
+ util::fail('系统错误,请稍候再试');
|
|
|
+ }
|
|
|
+ } elseif ($payWay == dict::getDict('payWay', 'alipay')) {
|
|
|
+ //支付宝付款
|
|
|
+ } else {
|
|
|
+ util::fail('未知付款方式');
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
//微信和支付宝付款码支付 shish 2021.4.11
|
|
|
public function actionCodePay()
|
|
|
{
|
|
|
@@ -73,9 +129,6 @@ class OrderController extends BaseController
|
|
|
|
|
|
if ($isWx) {
|
|
|
|
|
|
- //获取微信商户号等信息
|
|
|
- $sjExtend = WxOpenClass::getGhsWxInfo();
|
|
|
-
|
|
|
try {
|
|
|
|
|
|
$wx = Yii::getAlias("@vendor/wxPayApi_v3.0.10");
|
|
|
@@ -88,9 +141,16 @@ class OrderController extends BaseController
|
|
|
$input->SetTotal_fee($totalFee * 100);
|
|
|
$input->SetOut_trade_no($orderSn);
|
|
|
|
|
|
+ //获取微信商户号等信息
|
|
|
+ $sjExtend = WxOpenClass::getGhsWxInfo();
|
|
|
+
|
|
|
$microPay = new \MicroPay();
|
|
|
$res = $microPay->pay($input, $sjExtend);
|
|
|
if (isset($res["return_code"]) && $res["return_code"] == "SUCCESS") {
|
|
|
+ $transactionId = $res['transaction_id'] ?? '';
|
|
|
+ $openId = $res['openid'] ?? '';
|
|
|
+ $payWay = dict::getDict('payWay', 'wxPay');
|
|
|
+ PurchaseService::codePay($payWay, $orderSn, $transactionId, $openId);
|
|
|
util::success(['returnStatus' => 'SUCCESS']);
|
|
|
}
|
|
|
} catch (\Exception $e) {
|