Browse Source

付款设置

shish 1 năm trước cách đây
mục cha
commit
511ac516b7

+ 1 - 0
app-mall/controllers/BaseController.php

@@ -69,6 +69,7 @@ class BaseController extends PublicController
                             $customId = $hd->customId ?? 0;
                             $custom = CustomClass::getById($customId, true);
                             $this->custom = $custom;
+                            $this->customId = $customId;
                         }
                     }
                 }

+ 64 - 12
app-mall/controllers/OrderController.php

@@ -7,6 +7,7 @@ use bizHd\custom\classes\HdClass;
 use bizHd\wx\classes\WxOpenClass;
 use bizMall\custom\classes\CustomClass;
 use bizMall\goods\classes\GoodsClass;
+use bizMall\item\classes\ItemClass;
 use bizMall\order\classes\OrderClass;
 use bizMall\order\classes\OrderForwardClass;
 use bizMall\order\classes\OrderGoodsClass;
@@ -586,12 +587,47 @@ class OrderController extends BaseController
         if (empty($gatheringItem)) {
             util::fail('请设置付款用的商品');
         }
+        $gatheringItemInfo = ItemClass::getById($gatheringItem, true);
+        if (empty($gatheringItemInfo)) {
+            util::fail('付款用的商品没有设置');
+        }
+        $ptItemId = $gatheringItemInfo->itemId ?? 0;
+        $classId = $gatheringItemInfo->classId ?? 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('请设置快捷开单的客户');
+            }
+            $customId = $defaultCustomId;
+            $custom = CustomClass::getById($defaultCustomId, true);
+            if (empty($custom)) {
+                util::fail('请设置快捷客户');
+            }
+            $hdId = $custom->hdId;
+            $hd = \bizMall\hd\classes\HdClass::getById($hdId, true);
+            if (empty($hd)) {
+                util::fail('没有花店信息呢');
+            }
+        }
+        $post['hdId'] = $hdId;
+        $post['hdName'] = $hd->name ?? '';
+        $customName = $custom->name ?? '';
+        $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'] = $this->customId;
+        $post['customId'] = $customId;
         $user = isset($this->user->attributes) ? $this->user->attributes : [];
         $post['bookName'] = isset($user['userName']) ? $user['userName'] : '';
         $bookMobile = !empty($post['bookMobile']) && stringUtil::isMobile($post['bookMobile']) ? $post['bookMobile'] : '';
@@ -607,7 +643,7 @@ class OrderController extends BaseController
         $post['actPrice'] = $actPrice;
         $post['realPrice'] = $actPrice;
         $post['mainPay'] = $actPrice;
-        $post['payStyle'] = 0;
+        $post['modifyPrice'] = $actPrice;
         $post['userId'] = $this->userId;
         $post['needPrint'] = dict::getDict('needPrint', 'noNeed');
         $now = time();
@@ -615,12 +651,23 @@ class OrderController extends BaseController
         $post['createTime'] = date("Y-m-d H:i:s", $now);
         $post['deadline'] = $expireTime;
         if ($actPrice <= 0) {
-            util::fail('请填写正确的金额');
+            util::fail('请填写付款金额');
         }
-        //微信支付订单提交不能修改价格
-        $post['modPrice'] = $this->isWx ? 0 : 1;
+
         $post['goodsNum'] = 1;
-        $post['fromType'] = $post['fromType'] ?? 1;
+        $product = [[
+            'productId' => $gatheringItem,
+            'bigNum' => 1,
+            'smallNum' => '',
+            'num' => 1,
+            'unitType' => 0,
+            'property' => 1,
+            'unitPrice' => $actPrice,
+            'itemId' => $classId,
+            'classId' => $classId
+        ]];
+        $post['product'] = $product;
+
         $post['reachDate'] = !empty($post['reachDate']) ? $post['reachDate'] : '00-00-00';
         $post['onlinePay'] = dict::getDict('onlinePay', 'yes');
 
@@ -647,11 +694,16 @@ class OrderController extends BaseController
             $floor = $post['receiveFloor'] ?? '';
             $post['fullAddress'] = $city . $address . $floor;
         }
-
-        $order = OrderClass::addOrder($post);
-        $orderId = $order['id'] ?? 0;
-        $orderSn = $order['orderSn'] ?? '';
+        $hasPay = 0;
+        $post['sendType'] = 1;
+        $post['orderType'] = 2;//花材订单
+        $post['dealPrice'] = 1;
+        $post['fromType'] = 1;
+        $order = \bizHd\order\services\OrderService::createHdOrder($post, $custom, $hasPay);
+        $orderId = $order->id ?? 0;
+        $orderSn = $order->orderSn ?? '';
         if ($payWay == 0) {
+            //微信
             $name = '购买商品';
             $totalFee = $actPrice;
             $user = UserService::getById($this->userId);
@@ -716,8 +768,8 @@ class OrderController extends BaseController
             util::success($new);
 
         } elseif ($payWay == 1) {
-
-            $totalFee = $order['realPrice'];
+            //支付宝
+            $totalFee = $order->actPrice;
             $subject = '购买花材';
             $capitalType = dict::getDict('capitalType', 'xhOrder', 'id');
             $shop = $this->shop;

+ 1 - 1
biz-mall/order/classes/OrderClass.php

@@ -161,7 +161,7 @@ class OrderClass extends BaseClass
         $mainId = $shop->mainId ?? 0;
         $main = MainClass::getLockById($mainId);
         if (empty($main)) {
-            util::fail('没有main信息33');
+            util::fail('没有main信息呢!');
         }
         $riseNum = StatOrderCountClass::addOrder($shop, $main);