Bladeren bron

fix conflicts

shizhongqi 4 jaren geleden
bovenliggende
commit
1913f9072c

+ 9 - 2
app-hd/controllers/BaseController.php

@@ -2,6 +2,7 @@
 
 namespace hd\controllers;
 
+use biz\shop\classes\MainClass;
 use biz\sj\classes\SjClass;
 use bizHd\admin\classes\AdminClass;
 use biz\shop\classes\ShopAdminClass;
@@ -16,7 +17,7 @@ class BaseController extends PublicController
 {
 
     public $admin, $adminId, $adminAvatar, $account, $customId = 0, $custom;
-    public $sjId = 0, $sj = [], $sjExtend = [], $signPackage, $shopId = 0, $mainId = 0, $shop = [], $shopAdminId = 0, $shopAdmin = [];
+    public $sjId = 0, $sj = [], $sjExtend = [], $signPackage, $shopId = 0, $mainId = 0, $main = [], $shop = [], $shopAdminId = 0, $shopAdmin = [];
     public $appId;
     public $isWx = false;
     public $isLogin = false;
@@ -62,7 +63,13 @@ class BaseController extends PublicController
                 util::fail('没有找到店铺');
             }
             $this->shop = $shop;
-            $this->mainId = $shop->mainId ?? 0;
+            $mainId = $shop->mainId ?? 0;
+            $this->mainId = $mainId;
+            $main = MainClass::getById($mainId, true);
+            if (empty($main)) {
+                util::fail('没有找到main信息');
+            }
+            $this->main = $main;
             $shopAdmin = ShopAdminClass::getByCondition(['shopId' => $currentShopId, 'adminId' => $adminId], true);
             if (empty($shopAdmin)) {
                 util::logout('没有找到员工信息');

+ 8 - 1
app-hd/controllers/CategoryController.php

@@ -90,12 +90,19 @@ class CategoryController extends BaseController
         $where = [];
         $where['mainId'] = $this->mainId;
         $where['cId'] = $catId;
-        $where['flower'] = $get['flower'] ?? 0;
+        $flower = $get['flower'] ?? '';
+        if (is_numeric($flower)) {
+            $where['flower'] = $flower;
+        }
         $where['delStatus'] = $get['delStatus'] ?? 0;
         $status = $get['status'] ?? '';
         if (is_numeric($status)) {
             $where['status'] = $status;
         }
+        $flowerNum = $get['flowerNum'] ?? 0;
+        if (!empty($flowerNum)) {
+            $where['flowerNum'] = $flowerNum;
+        }
         $data = GoodsCategoryService::getGoodsList($where);
         util::success($data);
     }

+ 4 - 3
app-hd/controllers/MainController.php

@@ -102,8 +102,9 @@ class MainController extends BaseController
     public function actionMy()
     {
         $shop = $this->shop;
-        $balance = $shop->balance ?? 0.00;
-        $txBalance = $shop->txBalance ?? 0.00;
+        $main = $this->main;
+        $balance = $main->balance ?? 0.00;
+        $txBalance = $main->txBalance ?? 0.00;
         $sj = isset($this->sj) && !empty($this->sj) ? $this->sj->attributes : [];
         $shopImg = Yii::$app->params['hdImgHost'] . 'retail/default-img.png';
         $deadline = $sj['deadline'] ?? '';
@@ -113,7 +114,7 @@ class MainController extends BaseController
         $mobile = $relation['mobile'] ?? '';
         $sjName = $sj['name'] ?? '';
         $shopName = $shop->shopName ?? '';
-        $cashAccount = $shop->cashAccount ?? '';
+        $cashAccount = $main->cashAccount ?? '';
         $data = [
             'balance' => $balance,
             'txBalance' => $txBalance,

+ 2 - 0
app-hd/controllers/OrderController.php

@@ -307,6 +307,8 @@ class OrderController extends BaseController
         //订单30分钟后过期
         $expireTime = $now + 1800;
         $post['deadline'] = $expireTime;
+        $post['staffId'] = $this->shopAdminId ?? 0;
+        $post['staffName'] = $this->shopAdmin->name ?? '';
         //商城
         $post['fromType'] = 1;
         //客户

+ 4 - 4
app-hd/controllers/RefundController.php

@@ -21,7 +21,7 @@ class RefundController extends BaseController
         $where['mainId'] = $this->mainId;
         $orderSn = $get['orderSn'] ?? '';
         if (!empty($orderSn)) {
-            $where['relateOrderSn'] = $orderSn;
+            $where['orderSn'] = $orderSn;
         }
         $list = HdRefundClass::getOrderList($where);
         util::success($list);
@@ -33,9 +33,9 @@ class RefundController extends BaseController
         $id = Yii::$app->request->get('id', 0);
         $refund = HdRefundClass::getById($id, true);
         HdRefundClass::valid($refund, $this->mainId);
-        $orderSn = $refund->orderSn ?? '';
-        $itemList = HdRefundItemClass::getItemListBySn($orderSn);
-        $goodsList = HdRefundGoodsClass::getGoodsListBySn($orderSn);
+        $refundSn = $refund->refundSn ?? '';
+        $itemList = HdRefundItemClass::getItemListBySn($refundSn);
+        $goodsList = HdRefundGoodsClass::getGoodsListBySn($refundSn);
         util::success(['info' => $refund, 'itemList' => $itemList, 'goodsList' => $goodsList]);
     }
 

+ 1 - 1
biz-ghs/order/services/OrderService.php

@@ -683,7 +683,7 @@ class OrderService extends BaseService
         $capitalType = dict::getDict('capitalType', 'xhGhsOrder', 'id');
         $shopAdminId = $order->shopAdminId ?? 0;
         $shopAdminName = $order->shopAdminName ?? '';
-        $event = '单';
+        $event = '单';
         if ($isPurchase) {
             $event = '客户采购';
             if (isset($custom->name) && !empty($custom->name)) {

+ 4 - 6
biz-hd/goods/classes/GoodsClass.php

@@ -241,6 +241,7 @@ class GoodsClass extends BaseClass
             $data['shopImg'] = json_encode($data['shopImg']);
         }
         $data['py'] = stringUtil::py($data['name']);
+        $flowerNum = $data['flowerNum'] ?? 0;
         $info = self::add($data, true);
         $id = $info->id;
         $name = $info->name;
@@ -255,13 +256,14 @@ class GoodsClass extends BaseClass
             $cName = $categoryData[$catId]['categoryName'];
             $addCategory = [
                 'gId' => $id,
-                'name' => $name,
+                'goodsName' => $name,
                 'cId' => $catId,
                 'cName' => $cName,
                 'sjId' => $sjId,
                 'py' => $py,
                 'mainId' => $mainId,
                 'flower' => $flower,
+                'flowerNum' => $flowerNum,
             ];
             GoodsCategoryClass::add($addCategory);
             CategoryClass::counters(['goodsNum' => 1], ['id' => $catId]);
@@ -360,11 +362,7 @@ class GoodsClass extends BaseClass
         // 当前商品的分类
         $goodsHasCategoryIds = GoodsCategoryService::getGoodsHasCategoryIds($id);
         // 分类商品数-1
-        CategoryClass::counters([
-            'goodsNum' => -1
-        ], [
-            'id' => $goodsHasCategoryIds
-        ]);
+        CategoryClass::counters(['goodsNum' => -1], ['id' => $goodsHasCategoryIds]);
         GoodsClass::updateById($id, ['delStatus' => 1]);
         GoodsCategoryClass::updateByCondition(['gId' => $id], ['delStatus' => 1]);
     }

+ 2 - 2
biz-hd/order/classes/OrderClass.php

@@ -53,9 +53,9 @@ class OrderClass extends BaseClass
     const SEND_TYPE_THIRD = 3;
 
     //正常订单
-    const REFUND_NO = 1;
+    const REFUND_NO = 0;
     //已退款订单
-    const REFUND_YES = 2;
+    const REFUND_YES = 1;
 
     //送达时间段
     public static $reachPeriod = [0 => '上午', 1 => '下午', 2 => '晚上'];

+ 5 - 3
biz-hd/order/classes/OrderGoodsClass.php

@@ -24,7 +24,7 @@ class OrderGoodsClass extends BaseClass
     const ACTION_WASTAGE = 'wastage'; //取消消耗花材
     const ACTION_WASTAGE_CANCEL = 'wastageCancel'; //取消消耗花材
 
-    public static function addData($data)
+    public static function addData($data, $custom)
     {
         $orderSn = $data['orderSn'] ?? '';
         $sjId = $data['sjId'] ?? 0;
@@ -32,8 +32,9 @@ class OrderGoodsClass extends BaseClass
         $mainId = $data['mainId'] ?? 0;
         $goodsId = $data['goodsId'] ?? 0;
         $num = $data['num'] ?? 0;
+        $customName = $custom['name'] ?? '';
         //减库存
-        self::changeStockBySellGoods($orderSn, $sjId, $shopId, $mainId, $goodsId, $num);
+        self::changeStockBySellGoods($orderSn, $sjId, $shopId, $mainId, $goodsId, $num, $customName);
         return self::add($data);
     }
 
@@ -214,7 +215,7 @@ class OrderGoodsClass extends BaseClass
     }
 
     //销售成品库存变更方法(减库存)
-    public static function changeStockBySellGoods($orderSn, $sjId, $shopId, $mainId, $goodsId, $goodsNum)
+    public static function changeStockBySellGoods($orderSn, $sjId, $shopId, $mainId, $goodsId, $goodsNum, $customName)
     {
         //减成品库存
         $respond = GoodsClass::decreaseStock($goodsId, $mainId, $goodsNum);
@@ -229,6 +230,7 @@ class OrderGoodsClass extends BaseClass
         $data['goodsNum'] = $goodsNum;
         $data['oldStock'] = $oldStock;
         $data['newStock'] = $newStock;
+        $data['relateName'] = $customName;
         GoodsStockRecordClass::sellGoods($data);
         return true;
     }

+ 3 - 1
biz-hd/order/services/OrderService.php

@@ -37,6 +37,8 @@ class OrderService extends BaseService
         $sjId = $data['sjId'] ?? 0;
         $shopId = $data['shopId'] ?? 0;
         $mainId = $data['mainId'] ?? 0;
+        $staffId = $data['staffId'] ?? 0;
+        $staffName = $data['staffName'] ?? '';
 
         $groupCover = '';
 
@@ -144,7 +146,7 @@ class OrderService extends BaseService
                     'mainId' => $mainId,
                 ];
                 //库存变化在这里
-                OrderGoodsClass::addData($currentGoodsData);
+                OrderGoodsClass::addData($currentGoodsData, $custom);
                 $groupGoodsData[] = [
                     'goodsId' => $currentId,
                     'num' => $num,

+ 10 - 0
biz-hd/refund/services/HdRefundService.php

@@ -93,9 +93,11 @@ class HdRefundService extends BaseService
                 }
                 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'] ?? '';
@@ -130,6 +132,8 @@ class HdRefundService extends BaseService
                         'ratio' => $ratio,
                         'bigUnit' => $bigUnit,
                         'smallUnit' => $smallUnit,
+                        'unitPrice' => $unitPrice,
+                        'price' => $price,
                     ];
                     HdRefundItemClass::addData($thisItemData, $refundSn, $post);
                 }
@@ -140,8 +144,10 @@ class HdRefundService extends BaseService
                 $orderGoodsData = OrderGoodsClass::getAllByCondition(['orderSn' => $xsOrderSn], 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('没有找到商品呢');
@@ -160,10 +166,14 @@ class HdRefundService extends BaseService
                     $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);
                 }

+ 2 - 0
biz-hd/work/classes/WorkClass.php

@@ -60,6 +60,7 @@ class WorkClass extends BaseClass
         $goodsId = $work->goodsId ?? 0;
         $bigNum = $work->bigNum ?? 0;
         $smallNum = $work->smallNum ?? 0;
+        $flowerNum = $work->flowerNum ?? 0;
         //没有商品生成商品
         if (empty($goodsId)) {
             $name = $work->name ?? '';
@@ -78,6 +79,7 @@ class WorkClass extends BaseClass
                 'workId' => $workId,
                 'workSn' => $workSn,
                 'flower' => 1,
+                'flowerNum' => $flowerNum,
             ];
             if (!empty($catId)) {
                 $goodsData['catIds'] = [$catId];

+ 5 - 1
biz/sj/services/MerchantService.php

@@ -2,6 +2,7 @@
 
 namespace biz\sj\services;
 
+use biz\shop\classes\MainClass;
 use biz\sj\classes\SjClass;
 use biz\wx\classes\WxMessageClass;
 use bizGhs\custom\services\CustomService;
@@ -148,14 +149,17 @@ class MerchantService extends BaseService
         ];
         GoodsSettingClass::add($setData);
 
-        //创建门店
+        $main = MainClass::add(['id' => null], true);
+        $mainId = $main->id ?? 0;
 
+        //创建门店
         $shopData = [
             'shopName' => '首店',
             'sjId' => $sjId,
             'merchantName' => $sjName,
             'telephone' => $mobile,
             'default' => 1,
+            'mainId' => $mainId,
             'parentId' => $applyData['introSjId'] ?? 0,
             'parentShopId' => $applyData['introShopId'] ?? 0,
             'mobile' => $mobile,

+ 9 - 0
sql.txt

@@ -953,4 +953,13 @@ ALTER TABLE xhMain ADD `totalPdSub` DECIMAL(15,2) NOT NULL DEFAULT '0.00' COMMEN
 ALTER TABLE xhMain ADD `totalWast` DECIMAL(15,2) NOT NULL DEFAULT '0.00' COMMENT '累计报损' AFTER `totalStockOut`;
 ALTER TABLE xhMain ADD `totalRefund` DECIMAL(15,2) NOT NULL DEFAULT '0.00' COMMENT '累计退款金额' AFTER `totalStockOut`;
 
+ALTER TABLE xhHdRefundItem ADD unitPrice DECIMAL(15,2) NOT NULL DEFAULT '0.00' COMMENT '单价' AFTER `unitName`;
+ALTER TABLE xhHdRefundItem ADD price DECIMAL(15,2) NOT NULL DEFAULT '0.00' COMMENT '总金额' AFTER `unitPrice`;
+ALTER TABLE xhHdRefundGoods ADD unitPrice DECIMAL(15,2) NOT NULL DEFAULT '0.00' COMMENT '单价' AFTER `num`;
+ALTER TABLE xhHdRefundGoods ADD price DECIMAL(15,2) NOT NULL DEFAULT '0.00' COMMENT '总金额' AFTER `unitPrice`;
+
+ALTER TABLE xhHdRefundItem MODIFY `num` INT NOT NULL DEFAULT 0 COMMENT '花材数量';
+
+ALTER TABLE xhGoodsCategory ADD flowerNum SMALLINT(6) NOT NULL DEFAULT '0' COMMENT '多少朵' AFTER `flower`;
+
 ---ssh 20220424