|
|
@@ -279,8 +279,8 @@ class OrderController extends BaseController
|
|
|
public function actionBatchFetch()
|
|
|
{
|
|
|
$where = ["status" => 2, "sendType" => 1, "shopId" => $this->shopId];
|
|
|
- $orderList = OrderService::getLimitList("id",$where,500,"id desc");
|
|
|
- $ids = ArrayHelper::getColumn($orderList,"id");
|
|
|
+ $orderList = OrderService::getLimitList("id", $where, 500, "id desc");
|
|
|
+ $ids = ArrayHelper::getColumn($orderList, "id");
|
|
|
OrderService::updateByIds($ids, ["status" => 4]);
|
|
|
util::complete($ids);
|
|
|
}
|
|
|
@@ -351,14 +351,10 @@ class OrderController extends BaseController
|
|
|
OrderClass::valid($order, $this->mainId);
|
|
|
$orderSn = $order->orderSn ?? '';
|
|
|
$totalFee = $order->mainPay ?? 0;
|
|
|
- if ($order->status == OrderClass::ORDER_STATUS_COMPLETE) {
|
|
|
+ if ($order->payStatus == 1) {
|
|
|
util::success(['returnStatus' => 'SUCCESS']);
|
|
|
- }
|
|
|
- if ($order->status == OrderClass::ORDER_STATUS_CANCEL) {
|
|
|
- util::complete('订单已取消');
|
|
|
- }
|
|
|
- if ($order->status != OrderClass::ORDER_STATUS_UN_PAY) {
|
|
|
- util::complete('订单不是待付款状态');
|
|
|
+ } else {
|
|
|
+ util::success(['returnStatus' => 'unPay']);
|
|
|
}
|
|
|
|
|
|
$connection = Yii::$app->db;
|
|
|
@@ -437,6 +433,102 @@ class OrderController extends BaseController
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ //微信和支付宝付款码支付复查 ssh 20260716
|
|
|
+ public function actionCodePayVerify()
|
|
|
+ {
|
|
|
+ ini_set('date.timezone', 'Asia/Shanghai');
|
|
|
+ header("Content-type: text/html; charset=utf-8");
|
|
|
+ $get = Yii::$app->request->get();
|
|
|
+ $id = $get['id'] ?? 0;
|
|
|
+
|
|
|
+ util::checkRepeatCommit($id, 3);
|
|
|
+
|
|
|
+ $order = OrderClass::getById($id, true);
|
|
|
+ OrderClass::valid($order, $this->mainId);
|
|
|
+ $orderSn = $order->orderSn ?? '';
|
|
|
+ $totalFee = $order->mainPay ?? 0;
|
|
|
+ if ($order->payStatus == 1) {
|
|
|
+ util::success(['returnStatus' => 'SUCCESS']);
|
|
|
+ } else {
|
|
|
+ util::success(['returnStatus' => 'unPay']);
|
|
|
+ }
|
|
|
+
|
|
|
+ $connection = Yii::$app->db;
|
|
|
+ $transaction = $connection->beginTransaction();
|
|
|
+ try {
|
|
|
+
|
|
|
+ $capitalType = dict::getDict('capitalType', 'xhOrder', 'id');
|
|
|
+
|
|
|
+ $shop = $this->shop;
|
|
|
+ $merchantPrivateKeyPath = Yii::getAlias("@vendor/lakala") . '/production/api_private_key.pem';
|
|
|
+ $lklCertificatePath = Yii::getAlias("@vendor/lakala") . '/production/lkl-apigw-v1.cer';
|
|
|
+ $params = [
|
|
|
+ 'appid' => 'OP00002119',
|
|
|
+ 'serial_no' => '018b08cfddbd',
|
|
|
+ 'merchant_no' => $shop->lklSjNo,
|
|
|
+ 'term_no' => $shop->lklScanTermNo,
|
|
|
+ 'merchantPrivateKeyPath' => $merchantPrivateKeyPath,
|
|
|
+ 'lklCertificatePath' => $lklCertificatePath,
|
|
|
+ ];
|
|
|
+ $laResource = new Lakala($params);
|
|
|
+ $scanParams = ['orderSn' => $orderSn,];
|
|
|
+ $response = $laResource->query($scanParams);
|
|
|
+
|
|
|
+ if (isset($response['code']) && $response['code'] == 'BBS00000') {
|
|
|
+ if (isset($response['resp_data']['trade_state']) && $response['resp_data']['trade_state'] == 'SUCCESS') {
|
|
|
+
|
|
|
+ $payWayType = dict::getDict('payWay', 'wxPay');
|
|
|
+ $account_type = $response['resp_data']['account_type'] ?? '';
|
|
|
+ if ($account_type == 'WECHAT') {
|
|
|
+ $payWayType = dict::getDict('payWay', 'wxPay');
|
|
|
+ }
|
|
|
+ if ($account_type == 'ALIPAY') {
|
|
|
+ $payWayType = dict::getDict('payWay', 'alipay');
|
|
|
+ }
|
|
|
+
|
|
|
+ $transactionId = $response['resp_data']['trade_no'] ?? '';
|
|
|
+ $order->onlinePay = dict::getDict('onlinePay', 'yes');
|
|
|
+ $order->save();
|
|
|
+ $attach = '';
|
|
|
+ payUtil::thirdPay($payWayType, $capitalType, $orderSn, $totalFee, $attach, $transactionId);
|
|
|
+ $transaction->commit();
|
|
|
+
|
|
|
+ //解决重复通知
|
|
|
+ $cacheKey = 'hd_shop_order_pay_check_' . $orderSn;
|
|
|
+ $has = Yii::$app->redis->executeCommand('GET', [$cacheKey]);
|
|
|
+ if (empty($has)) {
|
|
|
+ Yii::$app->redis->executeCommand('SETEX', [$cacheKey, 300, 'has']);
|
|
|
+
|
|
|
+ //打印小票和语音播报
|
|
|
+ $newOrder = OrderClass::getById($id, true);
|
|
|
+ OrderClass::onlinePrint($newOrder);
|
|
|
+ ShopExtClass::hdGatheringReport($newOrder);
|
|
|
+
|
|
|
+ //到店自取订单,并且是待取货状态,则自动完成取货,多处要同步修改,关键词 reach_shop_fetch_goods
|
|
|
+ if ($newOrder->getGoods == 1 && $newOrder->sendType == 1 && $newOrder->status == 2) {
|
|
|
+ $newOrder->status = 4;
|
|
|
+ $newOrder->save();
|
|
|
+ }
|
|
|
+
|
|
|
+ HdDeliveryOrderClass::payAfter($newOrder);
|
|
|
+
|
|
|
+ $shopId = $newOrder->shopId ?? 0;
|
|
|
+ $shop = ShopClass::getById($shopId, true);
|
|
|
+ WxMessageClass::gatheringIncomeInform($shop, $newOrder);
|
|
|
+ }
|
|
|
+
|
|
|
+ util::success(['returnStatus' => 'SUCCESS']);
|
|
|
+ } else {
|
|
|
+ util::success(['returnStatus' => 'PENDING'], '等待支付中...');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ util::success(['returnStatus' => 'PENDING'], '等待支付中...');
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ $transaction->rollBack();
|
|
|
+ util::complete('支付失败');
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 微信和支付宝付款码支付
|
|
|
* 职责:处理商户扫描客户付款码(被扫支付)的请求,调用拉卡拉支付接口并更新本地订单状态(零售端)
|
|
|
@@ -870,7 +962,7 @@ class OrderController extends BaseController
|
|
|
if ($hasPay != dict::getDict('hasPay', 'balance')) {
|
|
|
util::fail('用红包要用余额支付');
|
|
|
} else {
|
|
|
- if($custom->balance < $post['modifyPrice']) {
|
|
|
+ if ($custom->balance < $post['modifyPrice']) {
|
|
|
util::fail('用红包要用余额支付(您的余额不足)');
|
|
|
}
|
|
|
}
|
|
|
@@ -1361,7 +1453,7 @@ class OrderController extends BaseController
|
|
|
}
|
|
|
$list = OrderService::getOrderList($where);
|
|
|
$list['shop'] = $this->shop->attributes ?? [];
|
|
|
-
|
|
|
+
|
|
|
util::success($list);
|
|
|
}
|
|
|
|