|
|
@@ -3,9 +3,15 @@
|
|
|
namespace mall\controllers;
|
|
|
|
|
|
use bizMall\shop\classes\ShopClass;
|
|
|
+use common\components\dict;
|
|
|
+use common\components\noticeUtil;
|
|
|
+use common\components\payUtil;
|
|
|
use common\components\util;
|
|
|
use Yii;
|
|
|
use common\components\lakala\Lakala;
|
|
|
+use bizHd\order\classes\OrderClass;
|
|
|
+use biz\shop\classes\ShopExtClass;
|
|
|
+use biz\wx\classes\WxMessageClass;
|
|
|
|
|
|
class TestController extends BaseController
|
|
|
{
|
|
|
@@ -41,7 +47,70 @@ class TestController extends BaseController
|
|
|
if (isset($response['code']) == false || $response['code'] != '000000') {
|
|
|
util::fail('支付失败了');
|
|
|
}
|
|
|
- print_r($response);
|
|
|
+ $postData = $response['resp_data'] ?? [];
|
|
|
+ $orderTradeInfoList = $postData['order_trade_info_list'] ?? [];
|
|
|
+ if (empty($orderTradeInfoList)) {
|
|
|
+ util::fail('数据错误');
|
|
|
+ }
|
|
|
+ $orderTradeInfo = current($orderTradeInfoList);
|
|
|
+ $payMode = $orderTradeInfo['pay_mode'] ?? null;
|
|
|
+ if (empty($payMode)) {
|
|
|
+ noticeUtil::push('收银台支付回调失败了,没有找到钱包类型,请注意,orderSn:' . $orderSn, '15280215347');
|
|
|
+ util::end();
|
|
|
+ }
|
|
|
+ $trade_amount = $orderTradeInfo['trade_amount'] ?? 0;
|
|
|
+ $totalFee = $trade_amount / 100;
|
|
|
+ $orderStatus = $postData['order_status'];
|
|
|
+ $transactionId = $postData['pay_order_no'] ?? 0;
|
|
|
+ $tradeType = $orderTradeInfo['trade_type'] ?? '';
|
|
|
+ if ($tradeType != 'PAY') {
|
|
|
+ noticeUtil::push('收银台支付回调验证失败了,不是消费的回调,orderSn:' . $orderSn, '15280215347');
|
|
|
+ util::end();
|
|
|
+ }
|
|
|
+ $capitalType = dict::getDict('capitalType', 'xhOrder', 'id');
|
|
|
+
|
|
|
+ $connection = Yii::$app->db;
|
|
|
+ $transaction = $connection->beginTransaction();
|
|
|
+ try {
|
|
|
+ if ($orderStatus == 2) {
|
|
|
+ $payWayType = null;
|
|
|
+ if ($payMode == 'ALIPAY') {
|
|
|
+ $payWayType = dict::getDict('payWay', 'alipay');
|
|
|
+ }
|
|
|
+ if ($payMode == 'WECHAT') {
|
|
|
+ $payWayType = dict::getDict('wxPay', 'alipay');
|
|
|
+ }
|
|
|
+ if (isset($payWayType) == false) {
|
|
|
+ noticeUtil::push('收银台支付回调验证失败了,没有找到支付方式,orderSn:' . $orderSn, '15280215347');
|
|
|
+ util::end();
|
|
|
+ }
|
|
|
+
|
|
|
+ $attach = '';
|
|
|
+ payUtil::thirdPay($payWayType, $capitalType, $orderSn, $totalFee, $attach, $transactionId);
|
|
|
+ $transaction->commit();
|
|
|
+
|
|
|
+ //打印小票和语音播报
|
|
|
+ $order = OrderClass::getByCondition(['orderSn' => $orderSn], true);
|
|
|
+ ShopExtClass::hdGatheringReport($order);
|
|
|
+ OrderClass::onlinePrint($order);
|
|
|
+
|
|
|
+ $shopId = $order->shopId ?? 0;
|
|
|
+ $shop = ShopClass::getById($shopId, true);
|
|
|
+ if (in_array($order->fromType, [dict::getDict("fromType", "shop"), dict::getDict("fromType", "friend")])) {
|
|
|
+ //您有新的收入提醒
|
|
|
+ WxMessageClass::gatheringIncomeInform($shop, $order);
|
|
|
+ }
|
|
|
+ if ($order->fromType == dict::getDict("fromType", "mall")) {
|
|
|
+ //来自商城的新订单微信通知
|
|
|
+ WxMessageClass::hdNewOrderInform($shop, $order);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //请不要修改
|
|
|
+ echo "SUCCESS";
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ $transaction->rollBack();
|
|
|
+ Yii::error("失败原因:" . $e->getMessage());
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
}
|