Bläddra i källkod

Merge branch 'zhongqi-lakala-jingjian' of git.huaml.com:zhh/huahuibao into zhongqi-lakala-jingjian

shizhongqi 1 månad sedan
förälder
incheckning
eadace744c

+ 2 - 2
app-ghs/controllers/ConsoleController.php

@@ -50,7 +50,7 @@ class ConsoleController extends BaseController
         $overview = [
             ['name' => "库存数", "url" => '/admin/stat/stock', 'value' => $totalItemNum, 'type' => 1],
             ['name' => "库存值", "url" => '/admin/stat/stock', 'value' => $totalCost, 'type' => 1],
-            ['name' => "应收款", "url" => '/admin/shop/debtChange', 'value' => $may, 'type' => 1],
+            ['name' => "应收款", "url" => '', 'value' => $may, 'type' => 1],
             ['name' => "未命名", "url" => '/admin/home/member', 'value' => 0, 'type' => 4],
             ['name' => "总访客", "url" => '/admin/home/member', 'value' => 0, 'type' => 4],
             ['name' => "总订单", "url" => '/admin/home/order', 'value' => 0, 'type' => 4],
@@ -177,7 +177,7 @@ class ConsoleController extends BaseController
         //$notice[] = ['title' => '客户多个订单开始支持一键分享', 'action' => '查看', 'page' => '/admin/book/detail?id=calc'];
         //$notice[] = ['title' => '如果你发现一个问题很重要,一直没给你处理,在小群多反应几次,用反应次数强调重要性,目前批发店多反应问题多,都在排队。', 'action' => '', 'page' => ''];
         //$notice[] = ['title' => '新功能:客户端和后台使用跑腿的流程', 'action' => '', 'page' => '/admin/book/detail?id=use_pt'];
-        //$notice[] = ['title' => '新订单通知预计明天恢复', 'action' => '', 'page' => ''];
+        //$notice[] = ['title' => '明年1月1号起,所有人介绍新批发店的分红政策,将会统一调整,请知悉', 'action' => '', 'page' => ''];
         //$notice[] = ['title' => '急事请连续打二次电话 15280215347', 'action' => '', 'page' => ''];
 
         $mainId = $this->mainId;

+ 6 - 0
app-ghs/controllers/CustomController.php

@@ -1094,6 +1094,8 @@ class CustomController extends BaseController
         $id = $get['id'] ?? 0;
         $homeAmount = $get['homeAmount'] ?? 0;
         $homeNum = $get['homeNum'] ?? 0;
+        $homeUnMeet = $get['homeUnMeet'] ?? 2;
+        $homeUnFee = $get['homeUnFee'] ?? 0;
         if (isset($get['homeType'])) {
             //早期系统有带这个参数,来判断
             util::fail('请升级系统');
@@ -1112,9 +1114,13 @@ class CustomController extends BaseController
         }
         $custom->homeAmount = $homeAmount;
         $custom->homeNum = $homeNum;
+        $custom->homeUnMeet = $homeUnMeet;
+        $custom->homeUnFee = $homeUnFee;
         $custom->save();
         $ghs->homeAmount = $homeAmount;
         $ghs->homeNum = $homeNum;
+        $ghs->homeUnMeet = $homeUnMeet;
+        $ghs->homeUnFee = $homeUnFee;
         $ghs->save();
         util::complete('修改成功');
     }

Filskillnaden har hållts tillbaka eftersom den är för stor
+ 1 - 1
app-ghs/controllers/OrderController.php


+ 88 - 0
app-ghs/controllers/ShMethodController.php

@@ -0,0 +1,88 @@
+<?php
+/**
+ * 用途:配送方式配置控制器
+ * 谁用:供货商系统管理员
+ * 解决什么问题:提供配送方式(送货、自取、跑腿、快递、物流)配置的获取和保存接口
+ */
+
+namespace ghs\controllers;
+
+use bizGhs\order\classes\ShMethodClass;
+use Yii;
+use common\components\util;
+
+class ShMethodController extends BaseController
+{
+    /**
+     * 获取指定配送方式的配置
+     * GET 参数:
+     * - style: 配送类型 (0: 送货, 1: 自取, 2: 跑腿, 3: 快递, 4: 物流)
+     */
+    public function actionGetConfig()
+    {
+        $style = Yii::$app->request->get('style', 0);
+        try {
+            $config = ShMethodClass::getConfig($this->shopId, $this->mainId, $style);
+            util::success($config);
+        } catch (\Exception $e) {
+            util::fail($e->getMessage());
+        }
+    }
+
+    /**
+     * 获取门店所有的5种配送方式配置
+     * 如果数据库里没有,则取默认配置进行初始化
+     */
+    public function actionGetAllConfig()
+    {
+        try {
+            $configs = ShMethodClass::getAllConfigs($this->shopId, $this->mainId);
+            util::success($configs);
+        } catch (\Exception $e) {
+            util::fail($e->getMessage());
+        }
+    }
+
+    /**
+     * 获取所有配送方式的排序和别名信息
+     */
+    public function actionGetSorts()
+    {
+        try {
+            $sorts = ShMethodClass::getSorts($this->mainId);
+            util::success($sorts);
+        } catch (\Exception $e) {
+            util::fail($e->getMessage());
+        }
+    }
+
+    /**
+     * 保存指定配送方式的配置
+     * POST 参数:
+     * - id: 配置ID(可选)
+     * - style: 配送类型 (0: 送货, 1: 自取, 2: 跑腿, 3: 快递, 4: 物流)
+     * - name: 名称
+     * - status: 状态 (0: 禁用, 1: 启用)
+     * - sort: 排序
+     * - minAmount: 最低消费金额
+     * - minNum: 最低消费数量
+     * - unMeet: 不满条件处理方式 (0: 收运费, 1: 不能下单, 2: 收包装费)
+     * - unMeetFee: 运费/包装费金额
+     * - startKm: 起步公里数
+     * - startPrice: 起步价格
+     * - perKmPrice: 超出起步每公里加价
+     * - changeRate: 临时涨价比例 (%)
+     * - explains: 说明项列表 (二维数组,包含 explain, color, fontWeight, sort)
+     * - reduceRules: 跑腿满减规则列表 (二维数组,包含 meetNum, meetAmount, freeKm, sort)
+     */
+    public function actionSaveConfig()
+    {
+        $post = Yii::$app->request->post();
+        try {
+            ShMethodClass::saveConfig($this->shopId, $this->mainId, $post);
+            util::complete('保存成功');
+        } catch (\Exception $e) {
+            util::fail($e->getMessage());
+        }
+    }
+}

+ 7 - 3
app-hd/controllers/ProductController.php

@@ -999,9 +999,13 @@ class ProductController extends BaseController
         if (empty($product)) {
             util::fail('没有花材信息');
         }
-        $ghsInfo = GhsClass::getById($ghsId, true, 'giveLevel');
+        $ghsInfo = GhsClass::getById($ghsId, true, 'id,giveLevel,risePercent,riseRange');
         $level = isset($ghsInfo->giveLevel) ? $ghsInfo->giveLevel : 1;
-        $list = ProductClass::groupProductInfo([$product], $level);
+
+        $risePercent = $ghsInfo->risePercent ?? 0;
+        $riseRange = $ghsInfo->riseRange ?? 0;
+        $params = ['risePercent' => $risePercent, 'riseRange' => $riseRange];
+        $list = ProductClass::groupProductInfo([$product], $level, $params);
         $product = current($list);
 
         $mainId = $product['mainId'] ?? 0;
@@ -1139,4 +1143,4 @@ class ProductController extends BaseController
         }
     }
 
-}
+}

+ 0 - 5
biz-ghs/order/classes/OrderClass.php

@@ -1949,11 +1949,6 @@ class OrderClass extends BaseClass
                 $showPrice = 0;
             }
 
-            //东莞我要花 不带价格
-            if (isset($orderInfo->mainId) && $orderInfo->mainId == 2644) {
-                $showPrice = 0;
-            }
-
             //衡阳昕得鲜花批发,线上下单,不显示价格
             if (isset($orderInfo->mainId) && $orderInfo->mainId == 85744) {
                 if (!empty($orderInfo->customShopAdminId)) {

+ 15 - 0
biz-ghs/order/classes/ShExplainClass.php

@@ -0,0 +1,15 @@
+<?php
+/**
+ * 用途:配送方式说明项业务逻辑类
+ * 谁用:供货商系统
+ * 解决什么问题:处理说明项的增删改查
+ */
+
+namespace bizGhs\order\classes;
+
+use bizGhs\base\classes\BaseClass;
+
+class ShExplainClass extends BaseClass
+{
+    public static $baseFile = '\bizGhs\order\models\ShExplain';
+}

+ 265 - 0
biz-ghs/order/classes/ShMethodClass.php

@@ -0,0 +1,265 @@
+<?php
+/**
+ * 用途:配送方式配置业务逻辑类
+ * 谁用:供货商系统
+ * 解决什么问题:处理配送方式的查询、保存、默认初始化等业务逻辑
+ */
+
+namespace bizGhs\order\classes;
+
+use bizGhs\base\classes\BaseClass;
+use common\components\dict;
+use Yii;
+
+class ShMethodClass extends BaseClass
+{
+    public static $baseFile = '\bizGhs\order\models\ShMethod';
+
+    /**
+     * 获取所有配送方式的排序和别名信息
+     * @param int $mainId 商户ID
+     * @return array
+     */
+    public static function getSorts($mainId)
+    {
+        $list = [];
+        $aliases = [
+            0 => '送货',
+            1 => '自取',
+            2 => '跑腿',
+            3 => '物流',
+            4 => '快递'
+        ];
+        for ($style = 0; $style <= 4; $style++) {
+            $config = self::getByCondition(['mainId' => $mainId, 'style' => $style]);
+            $sort = 0;
+            $alias = $aliases[$style];
+            $status = 1;
+            if (!empty($config)) {
+                $sort = isset($config['sort']) ? (int)$config['sort'] : 0;
+                $alias = !empty($config['name']) ? $config['name'] : $aliases[$style];
+                $status = isset($config['status']) ? (int)$config['status'] : 1;
+            }
+            $list[] = [
+                'style' => $style,
+                'name' => $alias,
+                'sort' => $sort,
+                'status' => $status
+            ];
+        }
+        return $list;
+    }
+
+    /**
+     * 获取指定门店和类型的配送方式配置,若不存在则进行默认初始化
+     * @param int $shopId 门店ID
+     * @param int $mainId 商户ID
+     * @param int $style 配送类型 (0: 送货, 1: 自取, 2: 跑腿, 3: 物流, 4: 快递)
+     * @return array
+     */
+    public static function getConfig($shopId, $mainId, $style)
+    {
+        // 复杂分支/关键逻辑:优化。后端的查询全部由 shopId 改为 mainId,只根据 mainId 和 style 进行查询。
+        $config = self::getByCondition(['mainId' => $mainId, 'style' => $style]);
+        if (empty($config)) {
+            // 从字典配置中读取对应类型的默认配置
+            $defaultConfig = dict::getDict('shMethod', $style);
+            
+            $initData = array_merge([
+                'shopId' => $shopId, // shopId 仅作为保存预留字段存入
+                'mainId' => $mainId,
+                'style' => $style,
+            ], $defaultConfig);
+
+            $config = self::add($initData, true);
+            $config = $config->toArray();
+        }
+
+        // 获取关联的说明项
+        $config['explains'] = ShExplainClass::getAllByCondition(
+            ['methodId' => $config['id']],
+            'sort ASC, id ASC'
+        );
+
+        // 如果 is_跑腿 (style为2),获取关联的满减规则
+        if ($style == 2) {
+            $config['reduceRules'] = ShReduceRuleClass::getAllByCondition(
+                ['methodId' => $config['id']],
+                'sort ASC, id ASC'
+            );
+        } else {
+            $config['reduceRules'] = [];
+        }
+
+        return $config;
+    }
+
+    /**
+     * 一次性获取商户所有的5种配送方式配置,减少数据库查询交互。
+     * 如果数据库里没有对应配置,则自动采用 dict.php 里的默认参数进行填充并完成入库。
+     * @param int $shopId 门店ID
+     * @param int $mainId 商户ID
+     * @return array
+     */
+    public static function getAllConfigs($shopId, $mainId)
+    {
+        // 1. 一次性从数据库中查询当前商户的所有配送方式配置
+        $configsMap = self::getAllByCondition(['mainId' => $mainId], null, '*', 'style', true);
+
+        // 2. 补齐缺失的配送方式,并做初始化入库
+        for ($style = 0; $style <= 4; $style++) {
+            if (!isset($configsMap[$style])) {
+                $defaultConfig = dict::getDict('shMethod', $style);
+                $initData = array_merge([
+                    'shopId' => $shopId, // shopId 仅作为保存预留字段存入
+                    'mainId' => $mainId,
+                    'style' => $style,
+                ], $defaultConfig);
+
+                $configObj = self::add($initData, true);
+                $configsMap[$style] = $configObj;
+            }
+        }
+
+        // 将 ActiveRecord 统一转换为 array,并提取 methodIds 用于批量子表查询
+        $configsArray = [];
+        $methodIds = [];
+        foreach ($configsMap as $style => $configObj) {
+            $configArr = $configObj instanceof \yii\db\ActiveRecord ? $configObj->toArray() : $configObj;
+            $configsArray[$style] = $configArr;
+            $methodIds[] = (int)$configArr['id'];
+        }
+
+        // 3. 批量查询所有的说明项 (xhShExplain) - 仅 1 次查询
+        $allExplains = [];
+        if (!empty($methodIds)) {
+            $allExplains = ShExplainClass::getAllByCondition(['methodId' => ['in', $methodIds]], 'sort ASC, id ASC');
+        }
+        $explainsMap = [];
+        foreach ($allExplains as $exp) {
+            $explainsMap[(int)$exp['methodId']][] = $exp;
+        }
+
+        // 4. 批量查询所有的跑腿满减规则 (xhShReduceRule) - 仅 1 次查询
+        $allReduceRules = [];
+        if (!empty($methodIds)) {
+            $allReduceRules = ShReduceRuleClass::getAllByCondition(['methodId' => ['in', $methodIds]], 'sort ASC, id ASC');
+        }
+        $reduceRulesMap = [];
+        foreach ($allReduceRules as $rule) {
+            $reduceRulesMap[(int)$rule['methodId']][] = $rule;
+        }
+
+        // 5. 将批量查出的说明项和规则,合并填充到 5 个配送方式中
+        $result = [];
+        for ($style = 0; $style <= 4; $style++) {
+            $config = $configsArray[$style];
+            $methodId = (int)$config['id'];
+            
+            $config['explains'] = $explainsMap[$methodId] ?? [];
+            $config['reduceRules'] = ($style == 2) ? ($reduceRulesMap[$methodId] ?? []) : [];
+            
+            $result[] = $config;
+        }
+
+        return $result;
+    }
+
+    /**
+     * 保存配送方式配置,包含说明项和满减规则
+     * @param int $shopId 门店ID
+     * @param int $mainId 商户ID
+     * @param array $data 配置数据
+     * @return bool
+     * @throws \Exception
+     */
+    public static function saveConfig($shopId, $mainId, $data)
+    {
+        $id = $data['id'] ?? 0;
+        $style = $data['style'] ?? 0;
+
+        $config = null;
+        if ($id > 0) {
+            // 复杂分支/关键逻辑:优化。后端的查询全部由 shopId 改为 mainId。
+            $config = self::getByCondition(['id' => $id, 'mainId' => $mainId], true);
+        }
+
+        if (empty($config)) {
+            // 复杂分支/关键逻辑:优化。后端的查询全部由 shopId 改为 mainId。
+            $config = self::getByCondition(['mainId' => $mainId, 'style' => $style], true);
+        }
+
+        $saveData = [
+            'name' => $data['name'] ?? '',
+            'status' => isset($data['status']) ? (int)$data['status'] : 1,
+            'sort' => isset($data['sort']) ? (int)$data['sort'] : 0,
+            'minAmount' => isset($data['minAmount']) ? (float)$data['minAmount'] : 0.00,
+            'minNum' => isset($data['minNum']) ? (int)$data['minNum'] : 0,
+            'unMeet' => isset($data['unMeet']) ? (int)$data['unMeet'] : 0,
+            'unMeetFee' => isset($data['unMeetFee']) ? (float)$data['unMeetFee'] : 0.00,
+            'startKm' => isset($data['startKm']) ? (float)$data['startKm'] : 0.00,
+            'startPrice' => isset($data['startPrice']) ? (float)$data['startPrice'] : 0.00,
+            'perKmPrice' => isset($data['perKmPrice']) ? (float)$data['perKmPrice'] : 0.00,
+            'changeRate' => isset($data['changeRate']) ? (float)$data['changeRate'] : 0.00,
+        ];
+
+        $transaction = Yii::$app->db->beginTransaction();
+        try {
+            if (empty($config)) {
+                $saveData['shopId'] = $shopId; // shopId 作为保存预留字段存入
+                $saveData['mainId'] = $mainId;
+                $saveData['style'] = $style;
+                $config = self::add($saveData, true);
+            } else {
+                self::updateByCondition(['id' => $config->id], $saveData);
+            }
+
+            $methodId = $config->id;
+
+            // 1. 保存说明项 (xhShExplain)
+            ShExplainClass::deleteByCondition(['methodId' => $methodId]);
+            if (!empty($data['explains']) && is_array($data['explains'])) {
+                $explainRows = [];
+                foreach ($data['explains'] as $index => $exp) {
+                    if (empty($exp['explain'])) {
+                        continue;
+                    }
+                    $explainRows[] = [
+                        'methodId' => $methodId,
+                        'explain' => $exp['explain'],
+                        'color' => isset($exp['color']) ? (int)$exp['color'] : 1,
+                        'fontWeight' => isset($exp['fontWeight']) ? (int)$exp['fontWeight'] : 1,
+                        'sort' => isset($exp['sort']) ? (int)$exp['sort'] : $index,
+                    ];
+                }
+                if (!empty($explainRows)) {
+                    ShExplainClass::batchAdd($explainRows);
+                }
+            }
+
+            // 2. 保存跑腿满减规则 (xhShReduceRule)
+            ShReduceRuleClass::deleteByCondition(['methodId' => $methodId]);
+            if ($style == 2 && !empty($data['reduceRules']) && is_array($data['reduceRules'])) {
+                $ruleRows = [];
+                foreach ($data['reduceRules'] as $index => $rule) {
+                    $ruleRows[] = [
+                        'methodId' => $methodId,
+                        'meetNum' => isset($rule['meetNum']) ? (int)$rule['meetNum'] : 0,
+                        'meetAmount' => isset($rule['meetAmount']) ? (float)$rule['meetAmount'] : 0.00,
+                        'freeKm' => isset($rule['freeKm']) ? (float)$rule['freeKm'] : 0.00,
+                        'sort' => isset($rule['sort']) ? (int)$rule['sort'] : $index,
+                    ];
+                }
+                if (!empty($ruleRows)) {
+                    ShReduceRuleClass::batchAdd($ruleRows);
+                }
+            }
+
+            $transaction->commit();
+            return true;
+        } catch (\Exception $e) {
+            $transaction->rollBack();
+            throw $e;
+        }
+    }
+}

+ 15 - 0
biz-ghs/order/classes/ShReduceRuleClass.php

@@ -0,0 +1,15 @@
+<?php
+/**
+ * 用途:跑腿满减规则业务逻辑类
+ * 谁用:供货商系统
+ * 解决什么问题:处理满减规则的增删改查
+ */
+
+namespace bizGhs\order\classes;
+
+use bizGhs\base\classes\BaseClass;
+
+class ShReduceRuleClass extends BaseClass
+{
+    public static $baseFile = '\bizGhs\order\models\ShReduceRule';
+}

+ 22 - 0
biz-ghs/order/models/ShExplain.php

@@ -0,0 +1,22 @@
+<?php
+/**
+ * 用途:配送方式说明项模型
+ * 谁用:供货商系统
+ * 解决什么问题:存储每种配送方式下的说明文字、颜色、加粗等配置
+ */
+
+namespace bizGhs\order\models;
+
+use bizGhs\base\models\Base;
+
+class ShExplain extends Base
+{
+    /**
+     * 返回对应的数据库表名
+     * @return string
+     */
+    public static function tableName()
+    {
+        return 'xhShExplain';
+    }
+}

+ 22 - 0
biz-ghs/order/models/ShMethod.php

@@ -0,0 +1,22 @@
+<?php
+/**
+ * 用途:配送方式配置主表模型
+ * 谁用:供货商系统
+ * 解决什么问题:存储送货、自取、跑腿、快递、物流等配送方式的基础配置数据
+ */
+
+namespace bizGhs\order\models;
+
+use bizGhs\base\models\Base;
+
+class ShMethod extends Base
+{
+    /**
+     * 返回对应的数据库表名
+     * @return string
+     */
+    public static function tableName()
+    {
+        return 'xhShMethod';
+    }
+}

+ 22 - 0
biz-ghs/order/models/ShReduceRule.php

@@ -0,0 +1,22 @@
+<?php
+/**
+ * 用途:跑腿满减规则模型
+ * 谁用:供货商系统
+ * 解决什么问题:存储跑腿配送方式下的满减/免运费规则(如:满 X 扎且满 Y 元,免 Z 公里内跑腿费)
+ */
+
+namespace bizGhs\order\models;
+
+use bizGhs\base\models\Base;
+
+class ShReduceRule extends Base
+{
+    /**
+     * 返回对应的数据库表名
+     * @return string
+     */
+    public static function tableName()
+    {
+        return 'xhShReduceRule';
+    }
+}

+ 0 - 19
biz-ghs/product/classes/ProductClass.php

@@ -642,24 +642,6 @@ class ProductClass extends BaseClass
             //今日特价、会员价
             $price = self::getFinalPrice($v, $level, $priceMap, $addPriceMap);
 
-            //零售做特价时的原价
-            if ($level == 0) {
-                //零售做特价时显示的原价,不能删除
-                if (isset($v['skPrice'])) {
-                    $list[$k]['prePrice'] = $v['skPrice'];
-                }
-            }
-
-            if (isset($v['discountPrice']) && $v['discountPrice'] > 0) {
-                if ($level == 1) {
-                    $price = floatval($v['discountPrice']);
-                }
-                if ($level == 2) {
-                    $hjDiscountPrice = $v['hjDiscountPrice'] ?? 0;
-                    $price = $hjDiscountPrice;
-                }
-            }
-
             $list[$k]['price'] = $price;
             $list[$k]['bigPrice'] = $price;
             $smallRatio = $v['smallRatio'] ?? 0;
@@ -879,7 +861,6 @@ class ProductClass extends BaseClass
                 $price = 0.01;
             }
         }
-
         return $price;
     }
 

+ 68 - 24
biz-hd/order/classes/OrderClass.php

@@ -898,6 +898,8 @@ class OrderClass extends BaseClass
         $shopId = $order->shopId ?? 0;
         $shop = ShopClass::getById($shopId, true);
         $sjId = $shop->sjId ?? 0;
+        // 复杂分支/关键逻辑:云打印字号与批发端一致,读取门店 fontSize 配置(0 加粗,1 放大)
+        $fontSizeType = $shop->fontSize ?? 0;
         $sj = SjClass::getById($sjId, true);
         $sjName = $sj->name ?? '';
         $shopName = $shop->shopName ?? '';
@@ -1030,9 +1032,8 @@ class OrderClass extends BaseClass
 
         if (!empty($respond['product'])) {
             foreach ($respond['product'] as $current) {
-                $content = self::printGroup($current, $content);
+                $content = self::printGroup($current, $content, $fontSizeType);
             }
-            $content .= '--------------------------------<BR>';
         }
 
         if (!empty($respond['refund'])) {
@@ -1076,7 +1077,7 @@ class OrderClass extends BaseClass
         if (!empty($respond['discountAmount']) && $respond['discountAmount'] > 0) {
             $content .= '优惠扣除:-' . floatval($respond['discountAmount']) . '<BR>';
         }
-        $content .= '订单金额:' . floatval($respond['orderPrice']) . '<BR>';
+        $content .= '<B>金额:' . floatval($respond['orderPrice']) . '</B><BR>';
         if (isset($respond['refundPrice']) && $respond['refundPrice'] > 0) {
             $content .= '退款金额:' . floatval($respond['refundPrice']) . '<BR>';
         }
@@ -1129,13 +1130,21 @@ class OrderClass extends BaseClass
         $orderItemList = OrderItemClass::getAllByCondition(['orderSn' => $orderSn], null, '*');
         if (!empty($orderItemList)) {
             foreach ($orderItemList as $itemKey => $itemVal) {
-                $unitName = $itemVal['unitName'] ?? '';
+                $unitName = $itemVal['unitName'] ?? '';
                 $unitPrice = $itemVal['unitPrice'] ? floatval($itemVal['unitPrice']) : 0;
+                $itemNum = $itemVal['num'] ?? 0;
                 $printProduct[] = [
                     'name' => $itemVal['name'] ?? '',
-                    'num' => $itemVal['num'] . $unitName . '*' . $unitPrice,
+                    // 第二行小字:数量 * 单价 = 金额,排版与批发端一致
+                    'num' => floatval($itemNum) . $unitName . ' * ' . $unitPrice . '元',
                     'price' => floatval($itemVal['price']),
-                    'sn' => '',
+                    'unitPrice' => $unitPrice,
+                    'itemNum' => $itemNum,
+                    'refundNum' => $itemVal['refundNum'] ?? 0,
+                    'unitName' => $unitName,
+                    'remark' => $itemVal['remark'] ?? '',
+                    'ratioType' => $itemVal['ratioType'] ?? null,
+                    'ratio' => $itemVal['ratio'] ?? '',
                 ];
             }
         }
@@ -1144,12 +1153,23 @@ class OrderClass extends BaseClass
             foreach ($orderGoodsList as $itemKey => $itemVal) {
                 $unitName = $itemVal['unitName'] ?? '份';
                 $unitPrice = $itemVal['unitPrice'] ? floatval($itemVal['unitPrice']) : 0;
+                $itemNum = $itemVal['num'] ?? 0;
+                $name = $itemVal['name'] ?? '';
                 $sn = $itemVal['sn'] ?? '';
+                if (!empty($sn)) {
+                    $name = '#' . $sn . ' ' . $name;
+                }
                 $printProduct[] = [
-                    'name' => $itemVal['name'] ?? '',
-                    'num' => $itemVal['num'] . $unitName . '*' . $unitPrice,
+                    'name' => $name,
+                    'num' => floatval($itemNum) . $unitName . ' * ' . $unitPrice . '元',
                     'price' => floatval($itemVal['price']),
-                    'sn' => $sn,
+                    'unitPrice' => $unitPrice,
+                    'itemNum' => $itemNum,
+                    'refundNum' => 0,
+                    'unitName' => $unitName,
+                    'remark' => '',
+                    'ratioType' => null,
+                    'ratio' => '',
                 ];
             }
         }
@@ -1182,28 +1202,52 @@ class OrderClass extends BaseClass
         return $printData;
     }
 
-    public static function printGroup($current, $content)
+    /**
+     * 职责:组装零售云打印单条商品行,排版与批发端 printGroup 一致
+     * 入参:$current 商品行数据, $content 已拼接内容, $fontSizeType 字号类型(0 加粗,1 放大)
+     * 返回:拼接后的打印内容
+     * 关键边界:第一行「数量+单位+名称」大字,第二行「数量*单价=金额」小字
+     */
+    public static function printGroup($current, $content, $fontSizeType = 0)
     {
         //58mm的机器,一行打印16个汉字,32个字母
+        $productPrice = $current['price'] ?? '';
+        $unitPrice = $current['unitPrice'] ?? '';
         $name = $current['name'] ?? '';
-        if (!empty($current['sn'])) {
-            $name = '#' . $current['sn'] . ' ' . $name;
+        if (floatval($unitPrice) == 0.01) {
+            $name = $name . '(送)';
         }
-        $content .= $name . '<BR>';
-        $name = str_repeat(' ', 10);
-
         $productNum = $current['num'] ?? '';
-        $blankNum = bcsub(12, strlen($productNum));
-        if ($blankNum > 0) {
-            $productNum = $productNum . str_repeat(' ', $blankNum);
+        $itemNum = $current['itemNum'] ?? 0;
+        $refundNum = $current['refundNum'] ?? 0;
+        $unitName = $current['unitName'] ?? '扎';
+        $remark = $current['remark'] ?? '';
+        $ratioType = $current['ratioType'] === null ? -1 : intval($current['ratioType']);
+        $ratio = $current['ratio'] ?? '';
+
+        $lastNum = bcsub($itemNum, $refundNum);
+
+        // 第一行:数量在前,名称在后(与批发端一致)
+        if (!empty($remark)) {
+            $show = $lastNum . $unitName . ' ' . $name . "【" . $remark . "】";
+        } else {
+            $show = $lastNum . $unitName . ' ' . $name;
         }
-
-        $productPrice = $current['price'] ?? '';
-        $blankNum = bcsub(7, strlen($productPrice));
-        if ($blankNum > 0) {
-            $productPrice = $productPrice . str_repeat(' ', $blankNum);
+        if ($fontSizeType == 1) {
+            $content .= '<L>' . $show . '</L><BR>';
+        } else {
+            $content .= '<B>' . $show . '</B><BR>';
+        }
+        if ($refundNum > 0) {
+            $content .= '(买' . $itemNum . $unitName . ' 退' . $refundNum . $unitName . ')<BR>';
         }
-        $content .= $name . " " . $productNum . ' ' . $productPrice . '<BR><BR>';
+        // 第二行:小字体的数量和价格明细
+        if (floatval($unitPrice) == 0.01) {
+            $content .= $productNum . ' = ' . $productPrice . '元 赠送价<BR>';
+        } else {
+            $content .= $productNum . ' = ' . $productPrice . '元  ' . ($ratioType == 0 ? $ratio . '支装' : ($ratioType == 1 ? '若干支装' : '')) . '<BR>';
+        }
+        $content .= '--------------------------------<BR>';
         return $content;
     }
 

+ 73 - 0
common/components/dict.php

@@ -8,6 +8,79 @@ class dict
 {
 
     public static $data = [
+        // 配送方式默认配置
+        'shMethod' => [
+            0 => [
+                'name' => '送货',
+                'originName' => '送货',
+                'status' => 1,
+                'sort' => 1,
+                'minAmount' => 0.00,
+                'minNum' => 0,
+                'unMeet' => 0,
+                'unMeetFee' => 0.00,
+                'startKm' => 0.00,
+                'startPrice' => 0.00,
+                'perKmPrice' => 0.00,
+                'changeRate' => 0.00
+            ],
+            1 => [
+                'name' => '自取',
+                'originName' => '自取',
+                'status' => 1,
+                'sort' => 2,
+                'minAmount' => 0.00,
+                'minNum' => 0,
+                'unMeet' => 0,
+                'unMeetFee' => 0.00,
+                'startKm' => 0.00,
+                'startPrice' => 0.00,
+                'perKmPrice' => 0.00,
+                'changeRate' => 0.00
+            ],
+            2 => [
+                'name' => '跑腿',
+                'originName' => '跑腿',
+                'status' => 1,
+                'sort' => 3,
+                'minAmount' => 0.00,
+                'minNum' => 0,
+                'unMeet' => 0,
+                'unMeetFee' => 0.00,
+                'startKm' => 0.00,
+                'startPrice' => 0.00,
+                'perKmPrice' => 0.00,
+                'changeRate' => 0.00
+            ],
+            4 => [
+                'name' => '快递',
+                'originName' => '快递',
+                'status' => 1,
+                'sort' => 4,
+                'minAmount' => 0.00,
+                'minNum' => 0,
+                'unMeet' => 0,
+                'unMeetFee' => 0.00,
+                'startKm' => 0.00,
+                'startPrice' => 0.00,
+                'perKmPrice' => 0.00,
+                'changeRate' => 0.00
+            ],
+            3 => [
+                'name' => '物流',
+                'originName' => '物流',
+                'status' => 1,
+                'sort' => 5,
+                'minAmount' => 0.00,
+                'minNum' => 0,
+                'unMeet' => 0,
+                'unMeetFee' => 0.00,
+                'startKm' => 0.00,
+                'startPrice' => 0.00,
+                'perKmPrice' => 0.00,
+                'changeRate' => 0.00
+            ],
+        ],
         //APP通知打开关闭状态 1打开 0关闭
         'appNotice' => 1,
         //微信通知打开关闭状态 1打开 0关闭

Vissa filer visades inte eftersom för många filer har ändrats