| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- <?php
- namespace console\controllers;
- use bizHd\order\classes\OrderClass;
- use bizHd\order\models\Order;
- use common\components\dict;
- use common\components\noticeUtil;
- use common\components\util;
- use yii\console\Controller;
- use Yii;
- use biz\shop\classes\ShopExtClass;
- use bizHd\shop\classes\ShopClass;
- use bizHd\wx\classes\WxOpenClass;
- use common\components\payUtil;
- use biz\wx\classes\WxMessageClass;
- class HdOrderController extends Controller
- {
- //查询散客的订单是否有付款 ssh 20221231
- public function actionSelect()
- {
- util::stop();
- $query = new \yii\db\Query();
- $query->from(Order::tableName());
- $now = time();
- $current = bcsub($now, 100);
- $time = date("Y-m-d H:i:s", $current);
- $query->where(['status' => 1])->andWhere(['<=', 'addTime', $time]);
- $query->orderBy('addTime ASC');
- foreach ($query->batch() as $batchOrder) {
- foreach ($batchOrder as $order) {
- $connection = Yii::$app->db;
- $transaction = $connection->beginTransaction();
- $id = $order['id'] ?? 0;
- $orderSn = $order['orderSn'] ?? '';
- try {
- $order = OrderClass::getById($id, true);
- $orderSn = $order->orderSn ?? '';
- $totalFee = $order->mainPay ?? 0;
- $capitalType = dict::getDict('capitalType', 'xhOrder', 'id');
- //查询微信是否付款成功
- $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::getMallWxInfo();
- $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'] ?? '';
- // $order->onlinePay = dict::getDict('onlinePay', 'yes');
- // $order->save();
- // $attach = '';
- // payUtil::thirdPay($payWay, $capitalType, $orderSn, $totalFee, $attach, $transactionId);
- //
- // $transaction->commit();
- //
- // //打印小票和语音播报
- // $newOrder = OrderClass::getById($id, true);
- // OrderClass::onlinePrint($newOrder);
- // ShopExtClass::hdGatheringReport($newOrder);
- //
- // $shopId = $newOrder->shopId ?? 0;
- // $shop = ShopClass::getById($shopId, true);
- // WxMessageClass::gatheringIncomeInform($shop, $newOrder);
- noticeUtil::push("订单号{$orderSn}已付款,但还是待付款状态", '15280215347');
- }
- }
- //noticeUtil::push("订单号{$orderSn}没有付款", '15280215347');
- } catch (\Exception $e) {
- $transaction->rollBack();
- $msg = $e->getMessage();
- noticeUtil::push("查询订单是否付款出错了!订单号:{$orderSn},错误信息:{$msg}", '15280215347');
- }
- }
- }
- }
- }
|