Explorar el Código

Merge branch 'master' into zhongqi-IntraCityExpress

shish hace 11 meses
padre
commit
fe43b1bf1e

+ 1 - 1
app-hd/controllers/ItemController.php

@@ -111,7 +111,7 @@ class ItemController extends BaseController
                 util::fail('不是你的客户哦,编号55236');
             }
         }
-        $level = $custom->level ?? 1;
+        $level = 0;
         $field = '*';
 
         $result = ProductClass::getList($field, $where, ['inTurn' => SORT_DESC, 'actualSold' => SORT_DESC]);

+ 21 - 19
app-hd/controllers/OrderController.php

@@ -201,18 +201,18 @@ class OrderController extends BaseController
             util::fail('订单不是待发货状态');
         }
 
-        $workList = WorkClass::getAllByCondition(['orderId' => $id], null, '*', null, true);
-        if (!empty($workList)) {
-            $unComplete = false;
-            foreach ($workList as $work) {
-                if ($work->status != 1) {
-                    $unComplete = true;
-                }
-            }
-            if ($unComplete == true) {
-                util::fail('还有制作单没有完成');
-            }
-        }
+//        $workList = WorkClass::getAllByCondition(['orderId' => $id], null, '*', null, true);
+//        if (!empty($workList)) {
+//            $unComplete = false;
+//            foreach ($workList as $work) {
+//                if ($work->status != 1) {
+//                    $unComplete = true;
+//                }
+//            }
+//            if ($unComplete == true) {
+//                util::fail('还有制作单没有完成');
+//            }
+//        }
 
         $order->status = 4;
         $order->save();
@@ -582,7 +582,7 @@ class OrderController extends BaseController
             $post['product'] = $productList;
 
             //解决重复提交
-            util::checkRepeatCommit($this->adminId, 3);
+            util::checkRepeatCommit($this->adminId, 2);
 
             $reduceStock = $post['reduceStock'] ?? 0;
             if ($reduceStock == 1) {
@@ -1040,11 +1040,11 @@ class OrderController extends BaseController
         if (!empty($status)) {
             $where['status'] = $get['status'];
         }
-        $debt = $get['debt'] ?? 2;
-        if ($debt != 2) {
+        $debt = $get['debt'] ?? -1;
+        if ($debt > -1) {
             $where['debt'] = $debt;
         }
-        if (isset($get['shopAdminId']) && !empty($get['shopAdminId'])) {
+        if (!empty($get['shopAdminId'])) {
             $where['shopAdminId'] = $get['shopAdminId'];
         }
         if (!empty($search)) {
@@ -1069,11 +1069,13 @@ class OrderController extends BaseController
                 }
             }
         }
-        $searchTime = $get['searchTime'] ?? '';
-        if (!empty($searchTime)) {
+        if (isset($get['repeat']) && $get['repeat'] > -1) {
+            $where['repeat'] = $get['repeat'];
+        }
+        if (!empty($get['searchTime'])) {
             $startTime = $get['startTime'] ?? '';
             $endTime = $get['endTime'] ?? '';
-            $period = dateUtil::formatTime($searchTime, $startTime, $endTime);
+            $period = dateUtil::formatTime($get['searchTime'], $startTime, $endTime);
             $where['addTime'] = ['between', [$period['startTime'], $period['endTime']]];
         }
         $list = OrderService::getOrderList($where);

+ 13 - 12
app-hd/controllers/RefundController.php

@@ -84,6 +84,7 @@ class RefundController extends BaseController
         if ($version == 1) {
             util::fail('请升级小程序');
         }
+        $refundType = $post['refundType'] ?? 1;//1退货并退款2只退款
 
         //避免重复提交
         util::checkRepeatCommit($id, 10);
@@ -123,19 +124,20 @@ class RefundController extends BaseController
                 util::fail('负数订单不能发起售后');
             }
 
-            //商品花材结构 property 0花束 1花材
-            //[{productId:0,num:1,unitType:0,unitPrice:12,unitName:'扎',property:1}]
-            $productJson = $post['product'] ?? '';
-            if (empty($productJson)) {
-                util::fail('请选择商品');
-            }
-            $productList = json_decode($productJson, true);
-            if (!is_array($productList)) {
-                util::fail('请选择商品哦');
+            if ($refundType == 1) {
+                //商品花材结构 property 0花束 1花材
+                //[{productId:0,num:1,unitType:0,unitPrice:12,unitName:'扎',property:1}]
+                $productJson = $post['product'] ?? '';
+                if (empty($productJson)) {
+                    util::fail('请选择商品');
+                }
+                $productList = json_decode($productJson, true);
+                if (!is_array($productList)) {
+                    util::fail('请选择商品哦');
+                }
+                $post['product'] = $productList;
             }
 
-            $post['product'] = $productList;
-
             $post['price'] = $post['price'] ?? 0;
             if ($post['price'] <= 0) {
                 util::fail("退款金额不能小于0");
@@ -167,7 +169,6 @@ class RefundController extends BaseController
                 $shopId = $order->shopId;
                 $staffId = $this->shopAdminId;
                 $staffName = $this->shopAdminName;
-                $refundType = $post['refundType'] ?? 1;//1退货并退款2只退款
                 $forwardStock = $refundType == 1 ? 0 : 1;
                 $refundPrice = $post['price'] ?? 0;
 

+ 115 - 113
biz-hd/refund/services/HdRefundService.php

@@ -55,6 +55,7 @@ class HdRefundService extends BaseService
         $order->realPrice = $currentActPrice;
         $order->save();
 
+        $refundType = $post['refundType'] ?? 1;
         $post['orderId'] = $order->id ?? 0;
 
         $data = [];
@@ -76,123 +77,124 @@ class HdRefundService extends BaseService
 
         $postProduct = $post['product'] ?? '';
 
-        //商品花材结构 property 0商品 1花材
-        //[{productId:0,num:1,unitType:0,unitPrice:12,unitName:'扎',property:1}]
-        if (empty($postProduct)) {
-            util::fail('没有退款商品');
-        }
-        $goodsInfoList = [];
-        $itemInfoList = [];
-        $calcAmount = 0;
-        foreach ($postProduct as $current) {
-            $property = $current['property'] ?? 0;
-            if ($property == 0) {
-                $goodsInfoList[] = $current;
-            } else {
-                $itemInfoList[] = $current;
-            }
-            $calcNum = $current['num'] ?? 0;
-            $calcUnitPrice = $current['unitPrice'] ?? 0;
-            $calcPrice = bcmul($calcNum, $calcUnitPrice, 2);
-            $calcAmount = bcadd($calcAmount, $calcPrice, 2);
-        }
-
-        if (floatval($refundPrice) != floatval($calcAmount)) {
-            util::fail('数量与单价的总乘积,与退款金额不一致');
-        }
-
-        if (!empty($itemInfoList)) {
-            $ids = array_column($itemInfoList, 'productId');
-            $productInfo = ProductClass::getByids($ids, null, 'id');
-            $orderItemData = OrderItemClass::getAllByCondition(['orderSn' => $myOrderSn], null, '*', 'itemId', true);
-            if (empty($orderItemData)) {
-                util::fail('没有找到商品');
+        if ($refundType == 1) {
+            //商品花材结构 property 0商品 1花材
+            //[{productId:0,num:1,unitType:0,unitPrice:12,unitName:'扎',property:1}]
+            if (empty($postProduct)) {
+                util::fail('没有退款商品');
             }
-            foreach ($itemInfoList as $currentProduct) {
-                $id = $currentProduct['productId'] ?? 0;
-                $unitPrice = $currentProduct['unitPrice'] ?? 0;
-                $unitType = $currentProduct['unitType'] ?? 0;
-                $unitName = $currentProduct['unitName'] ?? '';
-                $currentRefundNum = $currentProduct['num'] ?? 0;
-                $price = bcmul($currentRefundNum, $unitPrice, 2);
-                $name = $productInfo[$id]['name'] ?? '';
-                $ptItemId = $productInfo[$id]['itemId'] ?? 0;
-                $cover = $productInfo[$id]['cover'] ?? '';
-                $ratio = $productInfo[$id]['ratio'] ?? '';
-                $bigUnit = $productInfo[$id]['bigUnit'] ?? '';
-                $smallUnit = $productInfo[$id]['smallUnit'] ?? '';
-                $currentOrderItem = $orderItemData[$id] ?? null;
-                if (empty($currentOrderItem)) {
-                    util::fail('没有找到退款的花材');
-                }
-                $orderItemNum = $currentOrderItem->num ?? 0;
-                //已退货数
-                $hasRefundNum = $currentOrderItem->refundNum ?? 0;
-                $remainNum = bcsub($orderItemNum, $hasRefundNum);
-                if ($currentRefundNum > $remainNum) {
-                    util::fail("{$name}超过可退数量");
+            $goodsInfoList = [];
+            $itemInfoList = [];
+            $calcAmount = 0;
+            foreach ($postProduct as $current) {
+                $property = $current['property'] ?? 0;
+                if ($property == 0) {
+                    $goodsInfoList[] = $current;
+                } else {
+                    $itemInfoList[] = $current;
                 }
-                $currentOrderItem->refundNum = bcadd($hasRefundNum, $currentRefundNum);
-                $currentOrderItem->save();
-                $thisItemData = [
-                    'refundSn' => $refundSn,
-                    'mainId' => $mainId,
-                    'sjId' => $sjId,
-                    'shopId' => $shopId,
-                    'name' => $name,
-                    'itemId' => $id,
-                    'ptItemId' => $ptItemId,
-                    'num' => $currentRefundNum,
-                    'unitName' => $unitName,
-                    'unitType' => $unitType,
-                    'cover' => $cover,
-                    'ratio' => $ratio,
-                    'bigUnit' => $bigUnit,
-                    'smallUnit' => $smallUnit,
-                    'unitPrice' => $unitPrice,
-                    'price' => $price,
-                ];
-                HdRefundItemClass::addData($thisItemData, $refundSn, $post);
+                $calcNum = $current['num'] ?? 0;
+                $calcUnitPrice = $current['unitPrice'] ?? 0;
+                $calcPrice = bcmul($calcNum, $calcUnitPrice, 2);
+                $calcAmount = bcadd($calcAmount, $calcPrice, 2);
             }
-        }
-        if (!empty($goodsInfoList)) {
-            $ids = array_column($goodsInfoList, 'productId');
-            $goodsData = GoodsClass::getByIds($ids, null, 'id');
-            $orderGoodsData = OrderGoodsClass::getAllByCondition(['orderSn' => $myOrderSn], null, '*', 'goodsId', true);
-            foreach ($goodsInfoList as $currentGoods) {
-                $goodsId = $currentGoods['productId'] ?? 0;
-                $unitPrice = $currentGoods['unitPrice'] ?? 0;
-                $name = $goodsData[$goodsId]['name'] ?? '';
-                $currentRefundNum = $currentGoods['num'] ?? 0;
-                $price = bcmul($currentRefundNum, $unitPrice, 2);
-                $currentOrderGoods = $orderGoodsData[$goodsId] ?? [];
-                if (empty($currentOrderGoods)) {
-                    util::fail('没有找到商品呢');
+            if (floatval($refundPrice) < floatval($calcAmount)) {
+                util::fail('退款金额要大于商品金额总和');
+            }
+
+            if (!empty($itemInfoList)) {
+                $ids = array_column($itemInfoList, 'productId');
+                $productInfo = ProductClass::getByids($ids, null, 'id');
+                $orderItemData = OrderItemClass::getAllByCondition(['orderSn' => $myOrderSn], null, '*', 'itemId', true);
+                if (empty($orderItemData)) {
+                    util::fail('没有找到商品');
                 }
-                $totalNum = $currentOrderGoods->num ?? 0;
-                $hasRefundNum = $currentOrderGoods->refundNum ?? 0;
-                $remainNum = bcsub($totalNum, $hasRefundNum);
-                if ($currentRefundNum > $remainNum) {
-                    util::fail("{$name}超过可退数量");
+                foreach ($itemInfoList as $currentProduct) {
+                    $id = $currentProduct['productId'] ?? 0;
+                    $unitPrice = $currentProduct['unitPrice'] ?? 0;
+                    $unitType = $currentProduct['unitType'] ?? 0;
+                    $unitName = $currentProduct['unitName'] ?? '';
+                    $currentRefundNum = $currentProduct['num'] ?? 0;
+                    $price = bcmul($currentRefundNum, $unitPrice, 2);
+                    $name = $productInfo[$id]['name'] ?? '';
+                    $ptItemId = $productInfo[$id]['itemId'] ?? 0;
+                    $cover = $productInfo[$id]['cover'] ?? '';
+                    $ratio = $productInfo[$id]['ratio'] ?? '';
+                    $bigUnit = $productInfo[$id]['bigUnit'] ?? '';
+                    $smallUnit = $productInfo[$id]['smallUnit'] ?? '';
+                    $currentOrderItem = $orderItemData[$id] ?? null;
+                    if (empty($currentOrderItem)) {
+                        util::fail('没有找到退款的花材');
+                    }
+                    $orderItemNum = $currentOrderItem->num ?? 0;
+                    //已退货数
+                    $hasRefundNum = $currentOrderItem->refundNum ?? 0;
+                    $remainNum = bcsub($orderItemNum, $hasRefundNum);
+                    if ($currentRefundNum > $remainNum) {
+                        util::fail("{$name}超过可退数量");
+                    }
+                    $currentOrderItem->refundNum = bcadd($hasRefundNum, $currentRefundNum);
+                    $currentOrderItem->save();
+                    $thisItemData = [
+                        'refundSn' => $refundSn,
+                        'mainId' => $mainId,
+                        'sjId' => $sjId,
+                        'shopId' => $shopId,
+                        'name' => $name,
+                        'itemId' => $id,
+                        'ptItemId' => $ptItemId,
+                        'num' => $currentRefundNum,
+                        'unitName' => $unitName,
+                        'unitType' => $unitType,
+                        'cover' => $cover,
+                        'ratio' => $ratio,
+                        'bigUnit' => $bigUnit,
+                        'smallUnit' => $smallUnit,
+                        'unitPrice' => $unitPrice,
+                        'price' => $price,
+                    ];
+                    HdRefundItemClass::addData($thisItemData, $refundSn, $post);
                 }
-                $currentOrderGoods->refundNum = bcadd($hasRefundNum, $currentRefundNum);
-                $currentOrderGoods->save();
+            }
+            if (!empty($goodsInfoList)) {
+                $ids = array_column($goodsInfoList, 'productId');
+                $goodsData = GoodsClass::getByIds($ids, null, 'id');
+                $orderGoodsData = OrderGoodsClass::getAllByCondition(['orderSn' => $myOrderSn], null, '*', 'goodsId', true);
+                foreach ($goodsInfoList as $currentGoods) {
+                    $goodsId = $currentGoods['productId'] ?? 0;
+                    $unitPrice = $currentGoods['unitPrice'] ?? 0;
+                    $name = $goodsData[$goodsId]['name'] ?? '';
+                    $currentRefundNum = $currentGoods['num'] ?? 0;
+                    $price = bcmul($currentRefundNum, $unitPrice, 2);
+                    $currentOrderGoods = $orderGoodsData[$goodsId] ?? [];
+                    if (empty($currentOrderGoods)) {
+                        util::fail('没有找到商品呢');
+                    }
+                    $totalNum = $currentOrderGoods->num ?? 0;
+                    $hasRefundNum = $currentOrderGoods->refundNum ?? 0;
+                    $remainNum = bcsub($totalNum, $hasRefundNum);
+                    if ($currentRefundNum > $remainNum) {
+                        util::fail("{$name}超过可退数量");
+                    }
+                    $currentOrderGoods->refundNum = bcadd($hasRefundNum, $currentRefundNum);
+                    $currentOrderGoods->save();
 
-                $cover = $goodsData[$goodsId]['cover'] ?? '';
-                $num = $currentGoods['num'] ?? 0;
-                $saveGoods = [
-                    'refundSn' => $refundSn,
-                    'mainId' => $mainId,
-                    'sjId' => $sjId,
-                    'shopId' => $shopId,
-                    'name' => $name,
-                    'cover' => $cover,
-                    'goodsId' => $goodsId,
-                    'num' => $num,
-                    'unitPrice' => $unitPrice,
-                    'price' => $price,
-                ];
-                HdRefundGoodsClass::addData($saveGoods, $refundSn, $post);
+                    $cover = $goodsData[$goodsId]['cover'] ?? '';
+                    $num = $currentGoods['num'] ?? 0;
+                    $saveGoods = [
+                        'refundSn' => $refundSn,
+                        'mainId' => $mainId,
+                        'sjId' => $sjId,
+                        'shopId' => $shopId,
+                        'name' => $name,
+                        'cover' => $cover,
+                        'goodsId' => $goodsId,
+                        'num' => $num,
+                        'unitPrice' => $unitPrice,
+                        'price' => $price,
+                    ];
+                    HdRefundGoodsClass::addData($saveGoods, $refundSn, $post);
+                }
             }
         }
 
@@ -296,7 +298,7 @@ class HdRefundService extends BaseService
                     $order->debt = 0;
                 }
                 $order->save();
-                CustomClass::skRefundDebtAmountReduce($custom, $refundPrice, $refund,$payWay);
+                CustomClass::skRefundDebtAmountReduce($custom, $refundPrice, $refund, $payWay);
             }
             if ($payWay == dict::getDict('payWay', 'cash')) {
                 //如果现金支付
@@ -310,7 +312,7 @@ class HdRefundService extends BaseService
             }
             if ($payWay == dict::getDict('payWay', 'balancePay')) {
                 //如果是余额支付,客户的余额要增加
-                CustomClass::skRefundDebtAmountReduce($custom, $refundPrice, $refund,$payWay);
+                CustomClass::skRefundDebtAmountReduce($custom, $refundPrice, $refund, $payWay);
             }
         }
         return $refund;

+ 36 - 0
console/controllers/GhsInfoController.php

@@ -0,0 +1,36 @@
+<?php
+
+namespace console\controllers;
+
+use bizHd\ghs\classes\GhsClass;
+use bizHd\ghs\models\Ghs;
+use bizHd\merchant\classes\ShopClass;
+use yii\console\Controller;
+use Yii;
+
+class GhsInfoController extends Controller
+{
+
+    public function actionMobile()
+    {
+        ini_set('memory_limit', '2045M');
+        set_time_limit(0);
+        $query = new \yii\db\Query();
+        $query->from(Ghs::tableName());
+        $query->where(['mobile' => '']);
+        foreach ($query->batch(10) as $batch) {
+            foreach ($batch as $ghs) {
+                $ghsId = $ghs['id'];
+                $shopId = $ghs['shopId'];
+                $shop = ShopClass::getByCondition(['id' => $shopId], true, null, 'id,mobile');
+                if (!empty($shop)) {
+                    $mobile = $shop->mobile;
+                    if (!empty($mobile)) {
+                        GhsClass::updateById($ghsId, ['mobile' => $mobile]);
+                    }
+                }
+            }
+        }
+    }
+
+}