Explorar o código

做到了余额支付

shish hai 1 ano
pai
achega
74a288a26a

+ 23 - 44
app-mall/controllers/OrderController.php

@@ -72,20 +72,24 @@ class OrderController extends BaseController
             }
         }
 
-        $custom = CustomClass::getByCondition(['shopId' => $this->shopId, 'userId' => $this->userId], true);
-        $customId = $custom->id ?? 0;
-        if (!empty($custom)) {
-            $post['customId'] = $customId;
-            $customName = $custom->name ?? '';
-            $post['customName'] = $customName;
-            $post['customNamePy'] = stringUtil::py($customName);
-            $hdId = $custom->hdId ?? 0;
-            $hd = HdClass::getById($hdId, true);
-            if (!empty($hd)) {
-                $post['hdId'] = $hd->id ?? 0;
-                $post['hdName'] = $hd->name ?? '';
-            }
+        $hdId = $post['hdId'] ?? 0;
+        $hd = HdClass::getById($hdId, true);
+        if (empty($hd)) {
+            util::fail('没有找到花店');
+        }
+        if ($hd->shopId != $this->shopId) {
+            util::fail('不是你的花店');
+        }
+        $post['hdName'] = $hd->name ?? '';
+        $customId = $hd->customId ?? 0;
+        $custom = CustomClass::getById($customId, true);
+        if (empty($custom)) {
+            util::fail('没有找到客户');
         }
+        $customName = $custom->name ?? '';
+        $post['customName'] = $customName;
+        $post['customNamePy'] = stringUtil::py($customName);
+
 
         $now = time();
         //订单30分钟后过期
@@ -371,35 +375,12 @@ class OrderController extends BaseController
     }
 
 
-    //余额支付 ssh 2019.12.6
+    //余额支付 ssh 20250410
     public function actionBalancePay()
     {
         $post = Yii::$app->request->post();
-        $orderSn = isset($post['orderSn']) ? $post['orderSn'] : 0;
-        $payPassword = isset($post['payPassword']) ? $post['payPassword'] : 0;
-        $couponId = isset($post['couponId']) ? $post['couponId'] : 0;
-
-        //验证优惠券是否还有效
-        if (!empty($couponId)) {
-            //CouponService::checkBeforeUse($couponId, $order['prePrice'], $order['userId']);
-        }
-
-        $order = OrderService::getByOrderSn($orderSn);
-        $userId = $this->userId;
-        $user = UserService::getUserInfo($userId);
-        //验证支付密码是否正确
-        UserService::validPayPassword($payPassword, $user);
-        //支付前验证订单有效性
-        OrderService::checkBeforePay($order);
-        $capitalType = dict::getDict('capitalType', 'xhOrder', 'id');
-        $totalFee = $order['prePrice'];
-        $sourceType = 0;
-        $discountData = OrderService::getDiscountPrice(['price' => $totalFee, 'sourceType' => $sourceType, 'couponId' => $couponId, 'userId' => $this->userId]);
-        $actPrice = $discountData['price'];
-        $callbackParams = [];
-        $respond = xhPayToolService::balancePay($callbackParams, $orderSn, $actPrice, $capitalType, $couponId);
-        $balance = isset($respond['balance']) ? $respond['balance'] : 0;
-        util::success(['discountAmount' => $discountData['discountAmount'], 'discountType' => $discountData['discountType'], 'balance' => $balance]);
+        $orderSn = $post['orderSn'] ?? '';
+        
     }
 
     //获取商城下单要用的微信支付和小程序支付参数 ssh 2019.21.3
@@ -604,18 +585,16 @@ class OrderController extends BaseController
         }
 
         $order = OrderClass::addOrder($post);
-        $orderId = $order['id'];
-        $orderSn = $order['orderSn'];
-        $sjId = $this->sjId;
+        $orderId = $order['id'] ?? 0;
+        $orderSn = $order['orderSn'] ?? '';
         if ($payWay == 0) {
-            $orderId = $order['id'];
             $name = '购买商品';
             $totalFee = $actPrice;
             $user = UserService::getById($this->userId);
             //小程序使用miniOpenId
             $openId = $user['miniOpenId'];
             if (empty($openId)) {
-                $openId = isset($post['miniOpenId']) && !empty($post['miniOpenId']) ? $post['miniOpenId'] : '';
+                $openId = !empty($post['miniOpenId']) ? $post['miniOpenId'] : '';
             }
             if (empty($openId)) {
                 util::fail('没有微信信息');

+ 2 - 0
biz-hd/deduct/classes/DeductClass.php

@@ -59,6 +59,8 @@ class DeductClass extends BaseClass
         $change = [
             'customId' => $customId,
             'customName' => $customName,
+            'hdId' => $hdId,
+            'hdName' => $hdName,
             'relateId' => $relateId,
             'onlinePay' => 1,
             'capitalType' => $capitalType,

+ 11 - 6
biz-hd/order/classes/OrderClass.php

@@ -338,8 +338,13 @@ class OrderClass extends BaseClass
             ShopClass::customKdAddBalance($main, $shop, $amount, $order, $capitalType);
         }
 
+        //客户使用余额付款
+        if ($order->hasPay == 4) {
+
+        }
+
         //有尾款或全欠款
-        if ((isset($order->remainDebtPrice) && $order->remainDebtPrice > 0)) {
+        if (isset($order->remainDebtPrice) && $order->remainDebtPrice > 0) {
             $newCustom = CustomClass::getLockById($customId);
             CustomClass::cgDebtAmountAdd($newCustom, $order);
         }
@@ -607,15 +612,15 @@ class OrderClass extends BaseClass
                 $content .= '<B>到店自取</B><BR><BR>';
             }
         } else {
-            if($order->sendType == 0){
+            if ($order->sendType == 0) {
                 $content .= '<B>送货上门</B><BR><BR>';
-            }else if($order->sendType == 2){
+            } else if ($order->sendType == 2) {
                 $content .= '<B>跑腿到付</B><BR><BR>';
-            }else if($order->sendType == 3){
+            } else if ($order->sendType == 3) {
                 $content .= '<B>物流到付</B><BR><BR>';
-            }else if($order->sendType == 4){
+            } else if ($order->sendType == 4) {
                 $content .= '<B>快递到付</B><BR><BR>';
-            }else{
+            } else {
                 $content .= '';
             }
             if (isset($order->reachDate) && !empty($order->reachDate) && $order->reachDate != '0000-00-00') {

+ 6 - 25
biz-mall/order/services/OrderService.php

@@ -27,41 +27,23 @@ class OrderService extends BaseService
 
     public static function createOrder($data)
     {
+        $customId = $data['customId'] ?? 0;
+        $hdId = $data['hdId'] ?? 0;
         $orderSn = orderSn::getOrderSn();
         $sjId = $data['sjId'] ?? 0;
         $shopId = $data['shopId'] ?? 0;
-        $userId = $data['userId'] ?? 0;
         $mainId = $data['mainId'] ?? 0;
         $shop = ShopClass::getById($shopId, true);
         if (empty($shop)) {
             util::fail('没有找到门店86');
         }
-        $customId = 0;
-        $hdId = 0;
-        if (!empty($userId)) {
-            $custom = CustomClass::getByCondition(['shopId' => $shopId, 'userId' => $userId], true);
-            if (empty($custom)) {
-                util::fail('没有找到客户');
-            }
-            $customId = $custom->id ?? 0;
-        } else {
-            $defaultCustomId = $shop->defaultCustomId ?? 0;
-            if (empty($defaultCustomId)) {
-                util::fail('没有找到默认客户');
-            }
-            $custom = CustomClass::getById($defaultCustomId, true);
-            if (empty($custom)) {
-                util::fail('没有默认客户');
-            }
-            $data['userId'] = $custom->userId ?? 0;
-        }
         $product = $data['product'] ?? [];
         if (empty($product)) {
             util::fail('没有花材');
         }
         $gIds = [];
         $itIds = [];
-        foreach ($product as $key => $val) {
+        foreach ($product as $val) {
             $currentId = $val['productId'] ?? 0;
             $property = $val['property'];
             if ($property == dict::getDict('property', 'goods')) {
@@ -86,7 +68,7 @@ class OrderService extends BaseService
         $priceMap = \bizGhs\custom\classes\CustomClass::$levelPriceKeyMap;
         $addPriceMap = \bizGhs\custom\classes\CustomClass::$levelAddPriceKeyMap;
         foreach ($product as $key => $val) {
-            if (isset($val['property']) == false) {
+            if (!isset($val['property'])) {
                 util::fail('没有找到产品属性');
             }
             $property = $val['property'];
@@ -237,15 +219,14 @@ class OrderService extends BaseService
         $data['payWay'] = dict::getDict('payWay', 'unPay');
         $data['orderSn'] = $orderSn;
         $data['status'] = OrderClass::ORDER_STATUS_UN_PAY;
-        $returnOrder = OrderClass::addOrder($data);
-        return $returnOrder;
+        return OrderClass::addOrder($data);
     }
 
     //获取订单信息 ssh 2019.11.28
     public static function getOrderList($where)
     {
         $data = self::getList('*', $where, 'addTime DESC');
-        if (isset($data['list']) == false || empty($data['list'])) {
+        if (empty($data['list'])) {
             return $data;
         }
         $orderSns = array_column($data['list'], 'orderSn');