|
|
@@ -6,6 +6,7 @@ use biz\product\classes\ProductClass;
|
|
|
use biz\shop\classes\ShopClass;
|
|
|
use biz\wx\classes\WxMessageClass;
|
|
|
use bizHd\custom\classes\HdClass;
|
|
|
+use bizHd\order\classes\ScanPayClass;
|
|
|
use bizHd\wx\classes\WxOpenClass;
|
|
|
use bizMall\custom\classes\CustomClass;
|
|
|
use bizMall\goods\classes\GoodsClass;
|
|
|
@@ -803,26 +804,12 @@ class OrderController extends BaseController
|
|
|
if (empty($shop)) {
|
|
|
util::fail('没有门店信息');
|
|
|
}
|
|
|
- $ext = ShopExtClass::getByCondition(['shopId' => $shopId], true);
|
|
|
- $gatheringItem = !empty($ext) ? $ext->gatheringItem : 0;
|
|
|
- if (empty($gatheringItem)) {
|
|
|
- util::fail('请设置付款用的商品');
|
|
|
- }
|
|
|
- $gatheringItemInfo = ItemClass::getById($gatheringItem, true);
|
|
|
- if (empty($gatheringItemInfo)) {
|
|
|
- util::fail('付款用的商品没有设置');
|
|
|
- }
|
|
|
- $ptItemId = $gatheringItemInfo->itemId ?? 0;
|
|
|
- $classId = $gatheringItemInfo->classId ?? 0;
|
|
|
- //收款码是否算收入由ext gatherRepeat决定
|
|
|
- $post['repeat'] = $ext->gatherRepeat ?? 0;
|
|
|
$customId = $this->customId;
|
|
|
$custom = $this->custom;
|
|
|
$hdId = $this->hdId;
|
|
|
$hd = $this->hd;
|
|
|
if (empty($customId) || empty($hdId)) {
|
|
|
//考虑没有登录时的付款
|
|
|
- $shop = $this->shop;
|
|
|
$defaultCustomId = $shop->defaultCustomId ?? 0;
|
|
|
if (empty($defaultCustomId)) {
|
|
|
util::fail('请设置快捷开单的客户');
|
|
|
@@ -830,7 +817,7 @@ class OrderController extends BaseController
|
|
|
$customId = $defaultCustomId;
|
|
|
$custom = CustomClass::getById($defaultCustomId, true);
|
|
|
if (empty($custom)) {
|
|
|
- util::fail('请设置快捷客户');
|
|
|
+ util::fail('无效的快捷客户');
|
|
|
}
|
|
|
$hdId = $custom->hdId;
|
|
|
$hd = \bizMall\hd\classes\HdClass::getById($hdId, true);
|
|
|
@@ -844,89 +831,27 @@ class OrderController extends BaseController
|
|
|
$customPy = $custom->py ?? '';
|
|
|
$post['customName'] = $customName;
|
|
|
$post['customNamePy'] = $customPy;
|
|
|
- $post['gatheringItem'] = $gatheringItem;
|
|
|
$post['shopId'] = $shopId;
|
|
|
$post['mainId'] = $this->mainId;
|
|
|
- $post['sjId'] = $this->sjId;
|
|
|
- $post['store'] = 0;
|
|
|
$post['customId'] = $customId;
|
|
|
- $user = $this->user->attributes ?? [];
|
|
|
- $post['bookName'] = $user['userName'] ?? '';
|
|
|
- $bookMobile = !empty($post['bookMobile']) && stringUtil::isMobile($post['bookMobile']) ? $post['bookMobile'] : '';
|
|
|
- $bookMobile = empty($bookMobile) && !empty($user['mobile']) ? $user['mobile'] : $bookMobile;
|
|
|
- $post['bookMobile'] = $bookMobile;
|
|
|
+
|
|
|
$prePrice = round($post['prePrice'], 2);
|
|
|
- $couponId = $post['couponId'] ?? 0;
|
|
|
- $discountData = OrderService::getDiscountPrice(['price' => $prePrice, 'sourceType' => 0, 'couponId' => $couponId, 'userId' => $this->userId]);
|
|
|
- $actPrice = $discountData['price'];
|
|
|
- $post['discountType'] = $discountData['discountType'];
|
|
|
- $post['discountAmount'] = $discountData['discountAmount'];
|
|
|
- $post['orderPrice'] = $actPrice;
|
|
|
- $post['actPrice'] = $actPrice;
|
|
|
- $post['realPrice'] = $actPrice;
|
|
|
- $post['mainPay'] = $actPrice;
|
|
|
- $post['modifyPrice'] = $actPrice;
|
|
|
+ $actPrice = $prePrice;
|
|
|
+ if ($actPrice <= 0) {
|
|
|
+ util::fail('请填写付款金额');
|
|
|
+ }
|
|
|
$post['userId'] = $this->userId;
|
|
|
- $post['needPrint'] = dict::getDict('needPrint', 'noNeed');
|
|
|
$now = time();
|
|
|
$expireTime = $now + 300;//订单5分钟后过期
|
|
|
$post['createTime'] = date("Y-m-d H:i:s", $now);
|
|
|
- $post['deadline'] = $expireTime;
|
|
|
- if ($actPrice <= 0) {
|
|
|
- util::fail('请填写付款金额');
|
|
|
- }
|
|
|
-
|
|
|
- $post['goodsNum'] = 1;
|
|
|
- $product = [[
|
|
|
- 'productId' => $gatheringItem,
|
|
|
- 'bigNum' => 1,
|
|
|
- 'smallNum' => '',
|
|
|
- 'num' => 1,
|
|
|
- 'unitType' => 0,
|
|
|
- 'property' => 1,
|
|
|
- 'unitPrice' => $actPrice,
|
|
|
- 'itemId' => $ptItemId,
|
|
|
- 'classId' => $classId
|
|
|
- ]];
|
|
|
- $post['product'] = $product;
|
|
|
-
|
|
|
- $post['reachDate'] = !empty($post['reachDate']) ? $post['reachDate'] : '00-00-00';
|
|
|
- $post['onlinePay'] = dict::getDict('onlinePay', 'yes');
|
|
|
-
|
|
|
- //前端未修改时这边做兼容
|
|
|
- if (!empty($post['receiveAddress'])) {
|
|
|
- $post['address'] = $post['receiveAddress'];
|
|
|
- if (!empty($post['receiveProvince'])) {
|
|
|
- $post['province'] = $post['receiveProvince'];
|
|
|
- }
|
|
|
- if (!empty($post['receiveCity'])) {
|
|
|
- $post['city'] = $post['receiveCity'];
|
|
|
- }
|
|
|
- if (!empty($post['receiveFloor'])) {
|
|
|
- $post['floor'] = $post['receiveFloor'];
|
|
|
- }
|
|
|
- if (!empty($post['latitude'])) {
|
|
|
- $post['lat'] = $post['latitude'];
|
|
|
- }
|
|
|
- if (!empty($post['longitude'])) {
|
|
|
- $post['long'] = $post['longitude'];
|
|
|
- }
|
|
|
- $city = $post['receiveCity'] ?? '';
|
|
|
- $address = $post['receiveAddress'];
|
|
|
- $floor = $post['receiveFloor'] ?? '';
|
|
|
- $post['fullAddress'] = $city . $address . $floor;
|
|
|
- }
|
|
|
- $hasPay = 0;
|
|
|
- $post['sendType'] = 1;
|
|
|
- $post['orderType'] = 2;//花材订单
|
|
|
- $post['dealPrice'] = 1;
|
|
|
- $post['fromType'] = 1;
|
|
|
- $order = \bizHd\order\services\OrderService::createHdOrder($post, $custom, $hasPay);
|
|
|
+ $post['deadline'] = date("Y-m-d H:i:s", $expireTime);
|
|
|
+ $order = ScanPayClass::addOrder($post);
|
|
|
$orderId = $order->id ?? 0;
|
|
|
$orderSn = $order->orderSn ?? '';
|
|
|
+ $capitalType = dict::getDict('capitalType', 'scanPay', 'id');
|
|
|
if ($payWay == 0) {
|
|
|
//微信
|
|
|
- $name = '购买商品';
|
|
|
+ $name = '购买鲜花,扫码付款';
|
|
|
$totalFee = $actPrice;
|
|
|
$user = UserService::getById($this->userId);
|
|
|
//小程序使用miniOpenId
|
|
|
@@ -937,10 +862,8 @@ class OrderController extends BaseController
|
|
|
if (empty($openId)) {
|
|
|
util::fail('没有微信信息');
|
|
|
}
|
|
|
- $capitalType = dict::getDict('capitalType', 'xhOrder', 'id');
|
|
|
|
|
|
$sjExtend = WxOpenClass::getMallWxInfo();
|
|
|
- $shop = $this->shop;
|
|
|
$merchantPrivateKeyPath = Yii::getAlias("@vendor/lakala") . '/production/api_private_key.pem';
|
|
|
$lklCertificatePath = Yii::getAlias("@vendor/lakala") . '/production/lkl-apigw-v1.cer';
|
|
|
$params = [
|
|
|
@@ -961,7 +884,7 @@ class OrderController extends BaseController
|
|
|
'wxAppId' => $sjExtend['miniAppId'],
|
|
|
'openId' => $openId,
|
|
|
'subject' => $name,
|
|
|
- 'couponId' => $couponId,
|
|
|
+ 'couponId' => 0,
|
|
|
];
|
|
|
$response = $laResource->driveWxPay($wxParams);
|
|
|
if (!isset($response['code']) || $response['code'] != 'BBS00000') {
|
|
|
@@ -992,9 +915,7 @@ class OrderController extends BaseController
|
|
|
} elseif ($payWay == 1) {
|
|
|
//支付宝
|
|
|
$totalFee = $actPrice;
|
|
|
- $subject = '购买花材';
|
|
|
- $capitalType = dict::getDict('capitalType', 'xhOrder', 'id');
|
|
|
- $shop = $this->shop;
|
|
|
+ $subject = '购买鲜花,扫码付款';
|
|
|
$merchantPrivateKeyPath = Yii::getAlias("@vendor/lakala") . '/production/api_private_key.pem';
|
|
|
$lklCertificatePath = Yii::getAlias("@vendor/lakala") . '/production/lkl-apigw-v1.cer';
|
|
|
$params = [
|
|
|
@@ -1018,22 +939,14 @@ class OrderController extends BaseController
|
|
|
if (!isset($response['code']) || $response['code'] != '000000') {
|
|
|
util::fail('支付失败了');
|
|
|
}
|
|
|
- $url = $response['resp_data']['counter_url'] ? $response['resp_data']['counter_url'] : '';
|
|
|
+ $url = $response['resp_data']['counter_url'] ?? '';
|
|
|
if (empty($url)) {
|
|
|
util::fail('支付失败');
|
|
|
}
|
|
|
util::success(['url' => $url]);
|
|
|
} elseif ($payWay == 2) {
|
|
|
- util::fail('无效的支付方式');
|
|
|
- //余额支付,验证支付密码是否正确
|
|
|
- $payPassword = isset($post['payPassword']) ? $post['payPassword'] : 0;
|
|
|
- $user = UserService::getUserInfo($this->userId);
|
|
|
- UserService::validPayPassword($payPassword, $user);
|
|
|
- $capitalType = dict::getDict('capitalType', 'xhOrder', 'id');
|
|
|
- $callbackParams = [];
|
|
|
- $respond = xhPayToolService::balancePay($callbackParams, $orderSn, $actPrice, $capitalType, $couponId);
|
|
|
- $balance = isset($respond['balance']) ? $respond['balance'] : 0;
|
|
|
- util::success(['discountAmount' => $discountData['discountAmount'], 'discountType' => $discountData['discountType'], 'orderSn' => $orderSn, 'orderId' => $orderId, 'balance' => $balance]);
|
|
|
+ //余额支付
|
|
|
+ util::fail('暂不支持');
|
|
|
} else {
|
|
|
util::fail('无效的支付方式');
|
|
|
}
|