|
|
@@ -734,6 +734,130 @@ class PurchaseController extends BaseController
|
|
|
util::fail('没有供货商门店信息');
|
|
|
}
|
|
|
|
|
|
+ $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' => $ghsShop->lklSjNo,
|
|
|
+ 'term_no' => $ghsShop->lklScanTermNo,
|
|
|
+ 'merchantPrivateKeyPath' => $merchantPrivateKeyPath,
|
|
|
+ 'lklCertificatePath' => $lklCertificatePath,
|
|
|
+ ];
|
|
|
+ $laResource = new Lakala($params);
|
|
|
+ $notifyUrl = Yii::$app->params['hdHost'] . "/notice/pay-callback";
|
|
|
+ $wxParams = [
|
|
|
+ 'orderSn' => $orderSn,
|
|
|
+ 'amount' => $totalFee,
|
|
|
+ 'capitalType' => $purchaseCapital,
|
|
|
+ 'notifyUrl' => $notifyUrl,
|
|
|
+ 'wxAppId' => $merchantExtend['miniAppId'],
|
|
|
+ 'openId' => $openId,
|
|
|
+ 'subject' => $name,
|
|
|
+ 'couponId' => $couponId,
|
|
|
+ ];
|
|
|
+ $response = $laResource->cashierPay($wxParams);
|
|
|
+ if (isset($response['code']) == false || $response['code'] != 'BBS00000') {
|
|
|
+ $errMsg = $response['msg'] ?? '';
|
|
|
+ noticeUtil::push($errMsg, '15280215347');
|
|
|
+ util::fail('支付失败');
|
|
|
+ }
|
|
|
+ $newParams = isset($response['resp_data']['acc_resp_fields']) ? $response['resp_data']['acc_resp_fields'] : [];
|
|
|
+ $appId = $newParams['app_id'] ?? '';
|
|
|
+ $nonceStr = $newParams['nonce_str'] ?? '';
|
|
|
+ $paySign = $newParams['pay_sign'] ?? '';
|
|
|
+ $package = $newParams['package'] ?? '';
|
|
|
+ $signType = $newParams['sign_type'] ?? '';
|
|
|
+ $timeStamp = $newParams['time_stamp'] ?? '';
|
|
|
+ $new = [
|
|
|
+ 'id' => $id,
|
|
|
+ 'appId' => $appId,
|
|
|
+ 'nonceStr' => $nonceStr,
|
|
|
+ 'paySign' => $paySign,
|
|
|
+ 'package' => $package,
|
|
|
+ 'signType' => $signType,
|
|
|
+ 'timeStamp' => $timeStamp,
|
|
|
+ 'orderSn' => $orderSn,
|
|
|
+ ];
|
|
|
+ util::success($new);
|
|
|
+ }
|
|
|
+
|
|
|
+ //微信支付 ssh 2021.4.11
|
|
|
+ public function actionWxPay2()
|
|
|
+ {
|
|
|
+ ini_set('date.timezone', 'Asia/Shanghai');
|
|
|
+ $post = Yii::$app->request->post();
|
|
|
+ $couponId = $post['couponId'] ?? 0;
|
|
|
+ $orderSn = isset($post['orderSn']) ? $post['orderSn'] : 0;
|
|
|
+ $order = PurchaseClass::getByCondition(['orderSn' => $orderSn], true);
|
|
|
+ if (empty($order)) {
|
|
|
+ util::fail('订单号无效');
|
|
|
+ }
|
|
|
+ if ($order->status == 5) {
|
|
|
+ util::fail('订单已取消');
|
|
|
+ }
|
|
|
+ if ($order->status != 1) {
|
|
|
+ util::fail('订单不是待付款状态');
|
|
|
+ }
|
|
|
+
|
|
|
+ $deadline = $order->deadline;
|
|
|
+ $current = time();
|
|
|
+
|
|
|
+ if (($current + 50) > strtotime($deadline)) {
|
|
|
+ util::fail('订单已失效,请重新下单');
|
|
|
+ }
|
|
|
+
|
|
|
+ //已经唤起过微信支付了,根据拉卡拉的规则,需要生成新的订单号
|
|
|
+ if ($order->changePrice == 2) {
|
|
|
+ $oldOrderSn = $orderSn;
|
|
|
+ $newOrderSn = orderSn::getPurchaseSn();
|
|
|
+ $newGhsOrderSn = orderSn::getGhsOrderSn();
|
|
|
+ $orderSn = $newOrderSn;
|
|
|
+ $order->orderSn = $newOrderSn;
|
|
|
+ $order->save();
|
|
|
+ PurchaseItemClass::updateByCondition(['orderSn' => $oldOrderSn], ['orderSn' => $newOrderSn]);
|
|
|
+ $saleId = $order->saleId ?? 0;
|
|
|
+ $sale = OrderClass::getById($saleId, true);
|
|
|
+ if (!empty($sale)) {
|
|
|
+ $oldSaleOrderSn = $sale->orderSn ?? '';
|
|
|
+ $sale->orderSn = $newGhsOrderSn;
|
|
|
+ $sale->save();
|
|
|
+ OrderItemClass::updateByCondition(['orderSn' => $oldSaleOrderSn], ['orderSn' => $newGhsOrderSn]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $id = $order->id;
|
|
|
+ $order->changePrice = 2;
|
|
|
+ $order->save();
|
|
|
+
|
|
|
+ $name = $orderSn;
|
|
|
+ $totalFee = $order->realPrice;
|
|
|
+ //强制使用小程序的miniOpenId
|
|
|
+ $openId = isset($this->admin) && !empty($this->admin) ? $this->admin->miniOpenId : '';
|
|
|
+ if (empty($openId)) {
|
|
|
+ $currentShopId = $order->shopId ?? 0;
|
|
|
+ $currentShop = ShopClass::getById($currentShopId, true);
|
|
|
+ $currentShopName = $currentShop->merchantName . ' ' . $currentShop->shopName;
|
|
|
+ $currentMobile = $currentShop->mobile ?? '';
|
|
|
+ noticeUtil::push("花店采购时,发现没有openId,请跟进是否采购成功。{$currentShopName} {$currentMobile}", '15280215347');
|
|
|
+ util::success(['hasError' => 1, 'hasNoMiniOpenId' => 1]);
|
|
|
+ }
|
|
|
+ $purchaseCapital = dict::getDict('capitalType', 'xhPurchase', 'id');
|
|
|
+
|
|
|
+ //花卉宝代为申请的微信支付
|
|
|
+ $merchantExtend = WxOpenClass::getWxInfo();
|
|
|
+
|
|
|
+ $ghsId = $order->ghsId ?? 0;
|
|
|
+ $ghs = GhsClass::getById($ghsId, true);
|
|
|
+ if (empty($ghs)) {
|
|
|
+ util::fail('没有供货商信息');
|
|
|
+ }
|
|
|
+ $ghsShopId = $ghs->shopId ?? 0;
|
|
|
+ $ghsShop = ShopClass::getById($ghsShopId, true);
|
|
|
+ if (empty($ghsShop)) {
|
|
|
+ util::fail('没有供货商门店信息');
|
|
|
+ }
|
|
|
+
|
|
|
$merchantPrivateKeyPath = Yii::getAlias("@vendor/lakala") . '/production/api_private_key.pem';
|
|
|
$lklCertificatePath = Yii::getAlias("@vendor/lakala") . '/production/lkl-apigw-v1.cer';
|
|
|
$params = [
|