|
|
@@ -30,6 +30,7 @@ use bizMall\user\services\UserService;
|
|
|
use common\components\dateUtil;
|
|
|
use common\components\delivery\util\DeliveryQuoteUtil;
|
|
|
use common\components\dict;
|
|
|
+use common\components\errCode;
|
|
|
use common\components\imgUtil;
|
|
|
use common\components\mapUtil;
|
|
|
use common\components\noticeUtil;
|
|
|
@@ -1566,7 +1567,7 @@ class OrderController extends BaseController
|
|
|
Yii::$app->redis->executeCommand('SETEX', [$cacheKey, 864000, 'has']);
|
|
|
|
|
|
//打印小票和语音播报
|
|
|
- $fields = 'id,orderSn,shopId,mainId,customId,needPrint,payStatus,printNum,fromType,sendType,actPrice,addTime,sendNum,customName,customMobile,shopAdminName,bookName,bookMobile,receiveUserName,receiveMobile,fullAddress,showAddress,reachDate,reachPeriod,anonymity,cardInfo,remark,goodsPrice,sendCost,serviceFee,labourCost,prePrice,orderPrice,discountAmount,realPrice,refundPrice,debt,remainDebtPrice,thirdSn,goodsNum';
|
|
|
+ $fields = 'id,orderSn,shopId,mainId,customId,needPrint,payStatus,printNum,fromType,sendType,actPrice,addTime,sendNum,customName,shopAdminName,bookName,bookMobile,receiveUserName,receiveMobile,fullAddress,showAddress,reachDate,reachPeriod,anonymity,cardInfo,remark,goodsPrice,sendCost,serviceFee,labourCost,prePrice,orderPrice,discountAmount,realPrice,refundPrice,debt,remainDebtPrice,thirdSn,goodsNum';
|
|
|
$order = \bizHd\order\classes\OrderClass::getByCondition(['orderSn' => $orderSn], true, null, $fields);
|
|
|
if (!empty($order)) {
|
|
|
\bizHd\order\classes\OrderClass::onlinePrint($order);
|
|
|
@@ -1603,6 +1604,9 @@ class OrderController extends BaseController
|
|
|
$couponId = isset($post['couponId']) ? $post['couponId'] : 0;
|
|
|
$orderSn = isset($post['orderSn']) ? $post['orderSn'] : 0;
|
|
|
$order = OrderService::getByOrderSn($orderSn);
|
|
|
+ if (empty($order)) {
|
|
|
+ util::fail('订单号无效');
|
|
|
+ }
|
|
|
$orderId = $order['id'];
|
|
|
|
|
|
//验证优惠券是否还有效
|
|
|
@@ -1679,36 +1683,87 @@ class OrderController extends BaseController
|
|
|
OrderService::updateById($orderId, $updateData);
|
|
|
}
|
|
|
|
|
|
- $capitalType = dict::getDict('capitalType', 'xhOrder', 'id');
|
|
|
+ if (bccomp((string)$totalFee, '0', 2) == 1) {
|
|
|
+ $capitalType = dict::getDict('capitalType', 'xhOrder', 'id');
|
|
|
+ $sjExtend = WxOpenClass::getMallWxInfo();
|
|
|
+ $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);
|
|
|
+ $notifyUrl = Yii::$app->params['mallHost'] . "/notice/pay-callback";
|
|
|
+ $wxParams = [
|
|
|
+ 'orderSn' => $orderSn,
|
|
|
+ 'amount' => $totalFee,
|
|
|
+ 'capitalType' => $capitalType,
|
|
|
+ 'notifyUrl' => $notifyUrl,
|
|
|
+ 'wxAppId' => $sjExtend['miniAppId'],
|
|
|
+ 'openId' => $openId,
|
|
|
+ 'subject' => $name,
|
|
|
+ 'couponId' => $couponId,
|
|
|
+ ];
|
|
|
+ $response = $laResource->driveWxPay($wxParams);
|
|
|
+ if(!isset($response['code']) || $response['code'] != 'BBS00000') {
|
|
|
+ $errMsg = $response['msg'] ?? '';
|
|
|
+ noticeUtil::push($errMsg, '15280215347');
|
|
|
+ util::fail('支付失败');
|
|
|
+ }
|
|
|
+ } else if (bccomp((string)$totalFee, '0.00', 2) == 0){
|
|
|
+ Yii::info('付款金额为0');
|
|
|
+ $connection = Yii::$app->db;
|
|
|
+ $transaction = $connection->beginTransaction();
|
|
|
+ try {
|
|
|
+ OrderClass::completeZeroAmountPay($orderId);
|
|
|
+ $transaction->commit();
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ $transaction->rollBack();
|
|
|
+ Yii::error('零元订单支付后续失败:' . $e->getMessage());
|
|
|
+ util::fail('支付失败');
|
|
|
+ }
|
|
|
+
|
|
|
+ $cacheKey = 'mall_order_zero_pay_' . $orderSn;
|
|
|
+ $has = Yii::$app->redis->executeCommand('GET', [$cacheKey]);
|
|
|
+ if (empty($has)) {
|
|
|
+ Yii::$app->redis->executeCommand('SETEX', [$cacheKey, 864000, 'has']);
|
|
|
+ $paidOrder = HdOrderClass::getByCondition(['orderSn' => $orderSn], true);
|
|
|
+ if (!empty($paidOrder)) {
|
|
|
+ HdOrderClass::onlinePrint($paidOrder);
|
|
|
+ //付款成功了,通知发跑腿功能,关键词 hd_pay_after_call_pt,多处要同步修改
|
|
|
+ HdDeliveryOrderClass::payAfter($paidOrder);
|
|
|
|
|
|
- $sjExtend = WxOpenClass::getMallWxInfo();
|
|
|
- $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);
|
|
|
- $notifyUrl = Yii::$app->params['mallHost'] . "/notice/pay-callback";
|
|
|
- $wxParams = [
|
|
|
- 'orderSn' => $orderSn,
|
|
|
- 'amount' => $totalFee,
|
|
|
- 'capitalType' => $capitalType,
|
|
|
- 'notifyUrl' => $notifyUrl,
|
|
|
- 'wxAppId' => $sjExtend['miniAppId'],
|
|
|
- 'openId' => $openId,
|
|
|
- 'subject' => $name,
|
|
|
- 'couponId' => $couponId,
|
|
|
- ];
|
|
|
- $response = $laResource->driveWxPay($wxParams);
|
|
|
- if (!isset($response['code']) || $response['code'] != 'BBS00000') {
|
|
|
- $errMsg = $response['msg'] ?? '';
|
|
|
- noticeUtil::push($errMsg, '15280215347');
|
|
|
- util::fail('支付失败');
|
|
|
+ $shopId = $paidOrder->shopId ?? 0;
|
|
|
+ $shop = ShopClass::getById($shopId, true);
|
|
|
+ $shopExt = \biz\shop\classes\ShopExtClass::getByCondition(['shopId' => $shopId], true);
|
|
|
+ if (!empty($shopExt) && $shopExt->needWork == 1 && $paidOrder->hasWork != 1 && !empty($shop)) {
|
|
|
+ $mainId = $shop->mainId ?? 0;
|
|
|
+ $main = \bizHd\shop\classes\MainClass::getById($mainId, true);
|
|
|
+ \bizHd\work\classes\WorkClass::needWork($paidOrder, $main);
|
|
|
+ $hasWork = \bizHd\work\classes\WorkClass::getByCondition(['orderId' => $orderId], true);
|
|
|
+ if (!empty($hasWork)) {
|
|
|
+ $paidOrder->hasWork = 1;
|
|
|
+ $paidOrder->save();
|
|
|
+ }
|
|
|
+ \biz\shop\classes\ShopExtClass::newWorkRemind($shopExt, $paidOrder);
|
|
|
+ }
|
|
|
+ if (!empty($shop)) {
|
|
|
+ WxMessageClass::hdNewOrderInform($shop, $paidOrder);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $new = [
|
|
|
+ 'id' => $orderId,
|
|
|
+ 'orderSn' => $orderSn,
|
|
|
+ ];
|
|
|
+ util::error(errCode::ORDER_PAY_AMOUNT_ZERO, '付款金额为0', $new);
|
|
|
+ } else {
|
|
|
+ util::fail('付款金额不能为负数');
|
|
|
}
|
|
|
|
|
|
$newParams = isset($response['resp_data']['acc_resp_fields']) ? $response['resp_data']['acc_resp_fields'] : [];
|