Jelajahi Sumber

Merge branch 'master' into zhongqi-delivery

shish 8 bulan lalu
induk
melakukan
d30eb03f7d

+ 14 - 2
app-ghs/controllers/CustomController.php

@@ -127,7 +127,19 @@ class CustomController extends BaseController
 
         $staff = $this->shopAdmin;
         if (isset($staff->finance) == false || $staff->finance == 0) {
-            util::fail('无法充值销单。。。');
+            if ($this->shopId == 17118) {
+                //淘花里中山店,没有财务权限要能销账
+                if (!in_array($this->adminId, [17908])) {
+                    util::fail('你不能充值销账哦');
+                }
+            } elseif ($this->shopId == 72366) {
+                //淘花里小榄店,没有财务权限要能销账
+                if (!in_array($this->adminId, [69792])) {
+                    util::fail('你不能充值销账哦');
+                }
+            } else {
+                util::fail('无法充值销单。。。');
+            }
         }
 
         //多个地方需要同步修改clear_order_power
@@ -200,7 +212,7 @@ class CustomController extends BaseController
             }
             //淘花里小榄店 thl_xl_clear
             if (in_array($this->shopId, [72366])) {
-                if (!in_array($this->adminId, [69792,55445,55707,69792])) {
+                if (!in_array($this->adminId, [69792, 55445, 55707, 69792])) {
                     util::fail('你不能销单那。。');
                 }
             }

+ 47 - 0
app-ghs/controllers/ProductController.php

@@ -15,6 +15,7 @@ use bizGhs\cp\classes\CpItemClass;
 use bizGhs\custom\classes\CustomClass;
 use bizGhs\item\classes\ItemClass;
 use bizGhs\item\classes\ItemClassClass;
+use bizGhs\item\classes\UnitChangeClass;
 use bizGhs\merchant\classes\ShopClass;
 use bizGhs\notify\classes\NotifyClass;
 use bizGhs\order\classes\PurchaseOrderClass;
@@ -1317,6 +1318,18 @@ class ProductController extends BaseController
         $respond['hasRightChange'] = $hasRightRespond['hasRightChange'];
         $respond['hasRightChangeReason'] = $hasRightRespond['reason'];
 
+        //查出拆散的子花材
+        $part = UnitChangeClass::getByCondition(['big' => $id], true);
+        $partAcceptItem = 0;
+        $partAcceptItemName = '';
+        if (!empty($part)) {
+            $partAcceptItem = $part->small;
+            $small = ProductClass::getByCondition(['id' => $partAcceptItem], true, false, 'id,name');
+            $partAcceptItemName = $small->name ?? '';;
+        }
+        $respond['partAcceptItem'] = $partAcceptItem;
+        $respond['partAcceptItemName'] = $partAcceptItemName;
+
         $respond['cpInfo'] = $cpInfo;
         util::success($respond);
     }
@@ -1684,4 +1697,38 @@ class ProductController extends BaseController
         util::complete('修改成功');
     }
 
+    //修改拆散接收的花材 ssh 20251124
+    public function actionModifyPartAcceptItem()
+    {
+        $get = Yii::$app->request->get();
+        $smallId = $get['small'] ?? 0;
+        $bigId = $get['big'] ?? 0;
+        $small = ProductClass::getById($smallId, true);
+        if (empty($small)) {
+            util::fail('子花材没找到');
+        }
+        $smallName = $small->name ?? '';
+        if ($small->mainId != $this->mainId) {
+            util::fail($smallName . '不是你的花材');
+        }
+        if ($small->ratio != 1) {
+            util::fail($smallName . '不是1支装的');
+        }
+        $big = ProductClass::getById($bigId, true);
+        if (empty($big)) {
+            util::fail('没有找到花材');
+        }
+        if ($big->mainId != $this->mainId) {
+            util::fail('不是你的花材呢');
+        }
+        $change = UnitChangeClass::getByCondition(['big' => $bigId], true);
+        if (empty($change)) {
+            UnitChangeClass::add(['big' => $bigId, 'small' => $smallId], true);
+        } else {
+            $change->small = $smallId;
+            $change->save();
+        }
+        util::complete('修改成功');
+    }
+
 }

+ 1 - 1
app-ghs/controllers/RenewController.php

@@ -124,7 +124,7 @@ class RenewController extends BaseController
             if (getenv('YII_ENV') == 'production') {
                 $staff = $this->shopAdmin;
                 if ($price < 1580 && $staff->mobile != 15280215347) {
-                    util::fail('金额不能低于年费');
+                    //util::fail('金额不能低于年费');
                 }
             }
             $name = "购买系统";

+ 2 - 1
app-ghs/controllers/TestController.php

@@ -428,7 +428,8 @@ class TestController extends BaseController
             //['name' => '晋江花多多鲜花', 'merchantNo' => '8223970599200EW', 'wx' => [825459643, 825460214], 'zfb' => '2088080677754761'],
             //['name' => '昆明源花汇鲜花', 'merchantNo' => '8227310599200VZ', 'wx' => [826321533, 826321247], 'zfb' => '2088080751421086'],
             //['name' => '厦门厦茗绿植批发', 'merchantNo' => '8223930599200GK', 'wx' => [826594015, 826593264], 'zfb' => '2088080774924483'],
-            ['name' => '珠海淘花里', 'merchantNo' => '82258505992007T', 'wx' => [831476540, 831477416], 'zfb' => '2088180135238924'],
+            //['name' => '珠海淘花里', 'merchantNo' => '82258505992007T', 'wx' => [831476540, 831477416], 'zfb' => '2088180135238924'],
+            ['name' => '龙岩花掌柜', 'merchantNo' => '82240505992005D', 'wx' => [832139093, 832139074], 'zfb' => '2088180163717015'],
             ['name' => '惠州美天鲜花水口店', 'merchantNo' => '8225950599200CY', 'wx' => [827536311, 827535872], 'zfb' => '2088080848565460'],
             ['name' => '深圳鼎盛皇室花卉', 'merchantNo' => '8225840599201MF', 'wx' => [807078304, 807076486], 'zfb' => '2088970117746334'],
             //['name' => '东莞惠雅鲜花(莞城店)', 'merchantNo' => '8226020599200GJ', 'wx' => [796953190, 796976959], 'zfb' => '2088770940104912'],

+ 48 - 1
app-hd/controllers/ProductController.php

@@ -10,6 +10,7 @@ use bizGhs\item\classes\ItemClassClass;
 use bizGhs\product\classes\ProductClass;
 use bizGhs\product\services\ProductService;
 use bizHd\admin\classes\ShopAdminClass;
+use bizHd\item\classes\UnitChangeClass;
 use bizHd\purchase\classes\PurchaseClass;
 use bizHd\purchase\classes\PurchaseItemClass;
 use bizHd\pictext\classes\PicTextGhsItemClass;
@@ -778,6 +779,18 @@ class ProductController extends BaseController
             $respond['images'] = $respond['shortCover'];
         }
 
+        //查出拆散的子花材
+        $part = UnitChangeClass::getByCondition(['big' => $id], true);
+        $partAcceptItem = 0;
+        $partAcceptItemName = '';
+        if (!empty($part)) {
+            $partAcceptItem = $part->small;
+            $small = ProductClass::getByCondition(['id' => $partAcceptItem], true, false, 'id,name');
+            $partAcceptItemName = $small->name ?? '';;
+        }
+        $respond['partAcceptItem'] = $partAcceptItem;
+        $respond['partAcceptItemName'] = $partAcceptItemName;
+
         util::success($respond);
     }
 
@@ -944,4 +957,38 @@ class ProductController extends BaseController
         util::complete('修改成功');
     }
 
-}
+    //修改拆散接收的花材 ssh 20251124
+    public function actionModifyPartAcceptItem()
+    {
+        $get = Yii::$app->request->get();
+        $smallId = $get['small'] ?? 0;
+        $bigId = $get['big'] ?? 0;
+        $small = ProductClass::getById($smallId, true);
+        if (empty($small)) {
+            util::fail('子花材没找到');
+        }
+        $smallName = $small->name ?? '';
+        if ($small->mainId != $this->mainId) {
+            util::fail($smallName . '不是你的花材');
+        }
+        if ($small->ratio != 1) {
+            util::fail($smallName . '不是1支装的');
+        }
+        $big = ProductClass::getById($bigId, true);
+        if (empty($big)) {
+            util::fail('没有找到花材');
+        }
+        if ($big->mainId != $this->mainId) {
+            util::fail('不是你的花材呢');
+        }
+        $change = UnitChangeClass::getByCondition(['big' => $bigId], true);
+        if (empty($change)) {
+            UnitChangeClass::add(['big' => $bigId, 'small' => $smallId], true);
+        } else {
+            $change->small = $smallId;
+            $change->save();
+        }
+        util::complete('修改成功');
+    }
+
+}

+ 3 - 0
app-hd/controllers/PurchaseController.php

@@ -1047,6 +1047,8 @@ class PurchaseController extends BaseController
     {
         ini_set('date.timezone', 'Asia/Shanghai');
         $post = Yii::$app->request->post();
+        //默认是支付宝支付
+        $payWay = $post['payWay'] ?? 1;
         $orderSn = isset($post['orderSn']) ? $post['orderSn'] : 0;
         $order = PurchaseClass::getByCondition(['orderSn' => $orderSn], true);
         if (empty($order)) {
@@ -1154,6 +1156,7 @@ class PurchaseController extends BaseController
             'capitalType' => $purchaseCapital,
             'notifyUrl' => $notifyUrl,
             'subject' => $name,
+            'payWay' => $payWay,
         ];
         $response = $laResource->cashierPay($wxParams);
         if (isset($response['code']) == false || $response['code'] != '000000') {

+ 22 - 0
biz-ghs/item/classes/UnitChangeClass.php

@@ -0,0 +1,22 @@
+<?php
+
+namespace bizGhs\item\classes;
+
+use biz\item\classes\PtItemCatClass;
+use biz\item\classes\PtItemCatRelateClass;
+use biz\item\classes\PtItemClass;
+use biz\shop\classes\ShopExtClass;
+use bizGhs\base\classes\BaseClass;
+use bizGhs\book\classes\BookItemClass;
+use bizGhs\order\classes\CheckOrderClass;
+use bizGhs\product\classes\ProductClass;
+use common\components\imgUtil;
+use common\components\util;
+use common\services\xhItemService;
+
+class UnitChangeClass extends BaseClass
+{
+
+    public static $baseFile = '\bizGhs\item\models\UnitChange';
+
+}

+ 11 - 0
biz-ghs/item/models/UnitChange.php

@@ -0,0 +1,11 @@
+<?php
+namespace bizGhs\item\models;
+use bizGhs\base\models\Base;
+
+class UnitChange extends Base
+{
+    public static function tableName()
+    {
+        return 'xhUnitChange';
+    }
+}

+ 11 - 0
biz-ghs/item/services/UnitChangeService.php

@@ -0,0 +1,11 @@
+<?php
+namespace bizGhs\item\services;
+
+use bizGhs\base\services\BaseService;
+
+class UnitChangeService extends BaseService
+{
+
+    public static $baseFile = '\bizGhs\item\classes\UnitChangeClass';
+
+}

+ 46 - 0
biz-ghs/part/classes/PartClass.php

@@ -3,6 +3,7 @@
 namespace bizGhs\part\classes;
 
 use bizGhs\base\classes\BaseClass;
+use bizGhs\item\classes\UnitChangeClass;
 use bizGhs\product\classes\ProductClass;
 use bizGhs\shop\classes\MainClass;
 use bizGhs\stock\classes\StockRecordClass;
@@ -113,6 +114,51 @@ class PartClass extends BaseClass
         $order->cost = $totalCost;
         $order->save();
         \bizHd\part\classes\StatPartClass::replace($main, $totalCost, $totalNum);
+
+        //拆散后子花材的库存需要增加,多处要同步修改,关键词part_to_sub_item
+        $ids = array_column($productInfoList, 'productId');
+        $bigInfoList = ProductClass::getAllByCondition(['id' => ['in', $ids]], null, 'id,name,ratio', 'id');
+        $map = UnitChangeClass::getAllByCondition(['big' => ['in', $ids]], null, '*', 'big');
+        if (!empty($map)) {
+            foreach ($productInfoList as $key => $value) {
+                $num = $value['bigNum'] ?? 0;
+                $productId = $value['productId'] ?? 0;
+                $mapInfo = $map[$productId] ?? [];
+                $bigInfo = $bigInfoList[$productId] ?? [];
+                if (!empty($mapInfo) && !empty($bigInfo)) {
+                    $bigRatio = $bigInfo['ratio'] ?? 0;
+                    $bigName = $bigInfo['name'] ?? '';
+                    $totalNum = bcmul($num, $bigRatio);
+                    $smallId = $mapInfo['small'] ?? 0;
+                    $stockInfo = ProductClass::addStock($smallId, $totalNum, 0);
+
+                    $smallInfo = ProductClass::getById($smallId, true);
+                    $sjId = $smallInfo->sjId ?? 0;
+                    $shopId = $smallInfo->shopId ?? 0;
+                    $ptItemId = $smallInfo->itemId ?? 0;
+                    $mainId = $smallInfo->mainId ?? 0;
+
+                    $oldStock = $stockInfo['oldStock'] ?? 0;
+                    $newStock = $stockInfo['newStock'] ?? 0;
+                    //库存变动记录
+                    $recordData = [];
+                    $recordData['relateName'] = $data['shopAdminName'] ?? '';
+                    $recordData['itemNum'] = $totalNum;
+                    $recordData['sjId'] = $sjId;
+                    $recordData['shopId'] = $shopId;
+                    $recordData['mainId'] = $mainId;
+                    $recordData['orderSn'] = $orderSn;
+                    $recordData['itemId'] = $ptItemId;
+                    $recordData['oldStock'] = $oldStock; //当时库存
+                    $recordData['productId'] = $smallId;
+                    $recordData['newStock'] = $newStock;// 最新库存
+                    $recordData['io'] = 1;
+                    $recordData['remark'] = "拆散{$num}扎 " . $bigName;
+                    StockRecordClass::partItemAddRecord($recordData);
+                }
+            }
+        }
+
         return $order;
     }
 

+ 7 - 1
biz-ghs/stock/classes/StockRecordClass.php

@@ -32,7 +32,7 @@ class StockRecordClass extends BaseClass
     const STOCK_RECORD_TYPE_GOODS_WASTAGE_CANCEL = 15;//取消制作已报损
     const STOCK_RECORD_TYPE_HD_REFUND = 16;//花店退货退款
     const STOCK_RECORD_TYPE_GHS_REFUND = 17;//供货商申请退货退款
-    const STOCK_RECORD_TYPE_PART = 18;//供货商申请退货退款
+    const STOCK_RECORD_TYPE_PART = 18;//拆散
     const STOCK_RECORD_TYPE_GIVE = 19;//赠送
     const STOCK_RECORD_TYPE_ACCEPT = 20;//接收赠送
 
@@ -170,6 +170,12 @@ class StockRecordClass extends BaseClass
         self::add($refundRecord);
     }
 
+    public static function partItemAddRecord($refundRecord)
+    {
+        $refundRecord['recordType'] = self::STOCK_RECORD_TYPE_PART;
+        self::add($refundRecord);
+    }
+
     //采购订单流水记录
     public static function addPurchaseOrderRecord($data)
     {

+ 12 - 0
biz-hd/item/classes/UnitChangeClass.php

@@ -0,0 +1,12 @@
+<?php
+
+namespace bizHd\item\classes;
+
+use bizHd\base\classes\BaseClass;
+
+class UnitChangeClass extends BaseClass
+{
+
+    public static $baseFile = '\bizHd\item\models\UnitChange';
+
+}

+ 12 - 0
biz-hd/item/models/UnitChange.php

@@ -0,0 +1,12 @@
+<?php
+namespace bizHd\item\models;
+use bizHd\base\models\Base;
+class UnitChange extends Base
+{
+
+    public static function tableName()
+    {
+        return 'xhUnitChange';
+    }
+
+}

+ 47 - 1
biz-hd/part/classes/PartClass.php

@@ -3,6 +3,7 @@
 namespace bizHd\part\classes;
 
 use bizHd\base\classes\BaseClass;
+use bizHd\item\classes\UnitChangeClass;
 use bizHd\shop\classes\MainClass;
 use common\components\dict;
 use common\components\orderSn;
@@ -98,7 +99,7 @@ class PartClass extends BaseClass
         StockRecordClass::addRecordByOrder($stockData, StockRecordClass::STOCK_RECORD_TYPE_PART);
         $main = MainClass::getLockById($mainId);
         if (empty($main)) {
-            util::fail('没有main信息29');
+            util::fail('没有main信息');
         }
         $totalCost = 0;
         $totalNum = 0;
@@ -111,6 +112,51 @@ class PartClass extends BaseClass
         $order->cost = $totalCost;
         $order->save();
         StatPartClass::replace($main, $totalCost, $totalNum);
+
+        //拆散后子花材的库存需要增加,多处要同步修改,关键词part_to_sub_item
+        $ids = array_column($productInfoList, 'productId');
+        $bigInfoList = ProductClass::getAllByCondition(['id' => ['in', $ids]], null, 'id,name,ratio', 'id');
+        $map = UnitChangeClass::getAllByCondition(['big' => ['in', $ids]], null, '*', 'big');
+        if (!empty($map)) {
+            foreach ($productInfoList as $key => $value) {
+                $num = $value['bigNum'] ?? 0;
+                $productId = $value['productId'] ?? 0;
+                $mapInfo = $map[$productId] ?? [];
+                $bigInfo = $bigInfoList[$productId] ?? [];
+                if (!empty($mapInfo) && !empty($bigInfo)) {
+                    $bigRatio = $bigInfo['ratio'] ?? 0;
+                    $bigName = $bigInfo['name'] ?? '';
+                    $totalNum = bcmul($num, $bigRatio);
+                    $smallId = $mapInfo['small'] ?? 0;
+                    $stockInfo = ProductClass::addStock($smallId, $totalNum, 0);
+
+                    $smallInfo = ProductClass::getById($smallId, true);
+                    $sjId = $smallInfo->sjId ?? 0;
+                    $shopId = $smallInfo->shopId ?? 0;
+                    $ptItemId = $smallInfo->itemId ?? 0;
+                    $mainId = $smallInfo->mainId ?? 0;
+
+                    $oldStock = $stockInfo['oldStock'] ?? 0;
+                    $newStock = $stockInfo['newStock'] ?? 0;
+                    //库存变动记录
+                    $recordData = [];
+                    $recordData['relateName'] = $data['shopAdminName'] ?? '';
+                    $recordData['itemNum'] = $totalNum;
+                    $recordData['sjId'] = $sjId;
+                    $recordData['shopId'] = $shopId;
+                    $recordData['mainId'] = $mainId;
+                    $recordData['orderSn'] = $orderSn;
+                    $recordData['itemId'] = $ptItemId;
+                    $recordData['oldStock'] = $oldStock; //当时库存
+                    $recordData['productId'] = $smallId;
+                    $recordData['newStock'] = $newStock;// 最新库存
+                    $recordData['io'] = 1;
+                    $recordData['remark'] = "拆散{$num}扎 " . $bigName;
+                    StockRecordClass::partItemAddRecord($recordData);
+                }
+            }
+        }
+
         return $order;
     }
 

+ 4 - 2
common/components/lakala/Lakala.php

@@ -126,12 +126,14 @@ class Lakala
     {
         $orderSn = $params['orderSn'];
         $amount = $params['amount'];
+        $payWay = $params['payWay'] ?? 1;
+        $payMode = $payWay==1?'ALIPAY':'WECHAT';
         $notifyUrl = $params['notifyUrl'];
         $subject = $params['subject'];
         $capitalType = $params['capitalType'];
         $time = time() + 108000;
         $orderEfficientTime = date("YmdHis", $time);
-        $bus = json_encode([['busi_type' => 'SCPAY', 'params' => ['pay_mode' => 'ALIPAY']]]);
+        $bus = json_encode([['busi_type' => 'SCPAY', 'params' => ['pay_mode' => $payMode]]]);
         $arr = [
             'merchant_no' => $this->merchant_no,
             'term_no' => $this->term_no,
@@ -142,7 +144,7 @@ class Lakala
             'notify_url' => $notifyUrl,
             'order_efficient_time' => $orderEfficientTime,
             'busi_type_param' => $bus,
-            'counter_param' => json_encode(['pay_mode' => 'ALIPAY']),
+            'counter_param' => json_encode(['pay_mode' => $payMode]),
             'counter_remark' => '{"capitalType":' . $capitalType . '}'
         ];
         $baseRequestVO = [