m0_70156489 5 цаг өмнө
parent
commit
75e63dda2b

+ 8 - 10
application/admin/controller/Supplierscorerule.php

@@ -144,26 +144,24 @@ class Supplierscorerule extends Backend
     {
     {
         $qw = trim((string)($params['quality_weight'] ?? ''));
         $qw = trim((string)($params['quality_weight'] ?? ''));
         $pw = trim((string)($params['price_weight'] ?? ''));
         $pw = trim((string)($params['price_weight'] ?? ''));
-        if ($qw === '' || !is_numeric($qw) || (float)$qw < 0) {
-            $this->error('质量分%须为非负数');
+        if ($qw === '' || !preg_match('/^\d+$/', $qw)) {
+            $this->error('质量分%须为非负数');
         }
         }
-        if ($pw === '' || !is_numeric($pw) || (float)$pw < 0) {
-            $this->error('价格分%须为非负数');
+        if ($pw === '' || !preg_match('/^\d+$/', $pw)) {
+            $this->error('价格分%须为非负数');
         }
         }
-        if ((float)$qw + (float)$pw <= 0) {
+        if ((int)$qw + (int)$pw <= 0) {
             $this->error('两项权重之和须大于 0');
             $this->error('两项权重之和须大于 0');
         }
         }
         $status = trim((string)($params['status'] ?? 'normal'));
         $status = trim((string)($params['status'] ?? 'normal'));
         if (!in_array($status, ['normal', 'hidden'], true)) {
         if (!in_array($status, ['normal', 'hidden'], true)) {
             $status = 'normal';
             $status = 'normal';
         }
         }
-        $qwNum = round((float)$qw, 2);
-        $pwNum = round((float)$pw, 2);
-        $qwLabel = rtrim(rtrim(sprintf('%.2F', $qwNum), '0'), '.');
-        $pwLabel = rtrim(rtrim(sprintf('%.2F', $pwNum), '0'), '.');
+        $qwNum = (int)$qw;
+        $pwNum = (int)$pw;
 
 
         return [
         return [
-            'name'           => '质量分' . $qwLabel . '%+价格分' . $pwLabel . '%',
+            'name'           => '质量分' . $qwNum . '%+价格分' . $pwNum . '%',
             'quality_weight' => $qwNum,
             'quality_weight' => $qwNum,
             'price_weight'   => $pwNum,
             'price_weight'   => $pwNum,
             'is_default'     => !empty($params['is_default']) ? 1 : 0,
             'is_default'     => !empty($params['is_default']) ? 1 : 0,

+ 3 - 3
application/admin/view/supplierscorerule/add.html

@@ -2,14 +2,14 @@
     <div class="form-group">
     <div class="form-group">
         <label class="control-label col-xs-12 col-sm-2"><span class="text-danger">*</span> 质量分%:</label>
         <label class="control-label col-xs-12 col-sm-2"><span class="text-danger">*</span> 质量分%:</label>
         <div class="col-xs-12 col-sm-8">
         <div class="col-xs-12 col-sm-8">
-            <input class="form-control" name="row[quality_weight]" type="number" step="0.01" min="0" value="" data-rule="required" placeholder="请输入">
+            <input class="form-control" name="row[quality_weight]" type="number" step="1" min="0" value="" data-rule="required;integer" placeholder="请输入整数,如 50">
         </div>
         </div>
     </div>
     </div>
     <div class="form-group">
     <div class="form-group">
         <label class="control-label col-xs-12 col-sm-2"><span class="text-danger">*</span> 价格分%:</label>
         <label class="control-label col-xs-12 col-sm-2"><span class="text-danger">*</span> 价格分%:</label>
         <div class="col-xs-12 col-sm-8">
         <div class="col-xs-12 col-sm-8">
-            <input class="form-control" name="row[price_weight]" type="number" step="0.01" min="0" value="" data-rule="required" placeholder="请输入">
-            <span class="help-block">总分 = 质量分×质量分% + 价格分×价格分%(两项按比例折算)</span>
+            <input class="form-control" name="row[price_weight]" type="number" step="1" min="0" value="" data-rule="required;integer" placeholder="请输入整数,如 50">
+            <span class="help-block">总分 = 质量分×质量分% + 价格分×价格分%(两项按比例折算,填整数即可,50 表示 50%)</span>
         </div>
         </div>
     </div>
     </div>
     <div class="form-group">
     <div class="form-group">

+ 3 - 3
application/admin/view/supplierscorerule/edit.html

@@ -2,14 +2,14 @@
     <div class="form-group">
     <div class="form-group">
         <label class="control-label col-xs-12 col-sm-2"><span class="text-danger">*</span> 质量分%:</label>
         <label class="control-label col-xs-12 col-sm-2"><span class="text-danger">*</span> 质量分%:</label>
         <div class="col-xs-12 col-sm-8">
         <div class="col-xs-12 col-sm-8">
-            <input class="form-control" name="row[quality_weight]" type="number" step="0.01" min="0" value="{$row.quality_weight|htmlentities}" data-rule="required">
+            <input class="form-control" name="row[quality_weight]" type="number" step="1" min="0" value="{:intval($row['quality_weight'])}" data-rule="required;integer">
         </div>
         </div>
     </div>
     </div>
     <div class="form-group">
     <div class="form-group">
         <label class="control-label col-xs-12 col-sm-2"><span class="text-danger">*</span> 价格分%:</label>
         <label class="control-label col-xs-12 col-sm-2"><span class="text-danger">*</span> 价格分%:</label>
         <div class="col-xs-12 col-sm-8">
         <div class="col-xs-12 col-sm-8">
-            <input class="form-control" name="row[price_weight]" type="number" step="0.01" min="0" value="{$row.price_weight|htmlentities}" data-rule="required">
-            <span class="help-block">总分 = 质量分×质量分% + 价格分×价格分%(两项按比例折算)</span>
+            <input class="form-control" name="row[price_weight]" type="number" step="1" min="0" value="{:intval($row['price_weight'])}" data-rule="required;integer">
+            <span class="help-block">总分 = 质量分×质量分% + 价格分×价格分%(两项按比例折算,填整数即可,50 表示 50%)</span>
         </div>
         </div>
     </div>
     </div>
     <div class="form-group">
     <div class="form-group">

+ 50 - 14
application/common/library/ProcuremenSupplierScore.php

@@ -31,6 +31,7 @@ class ProcuremenSupplierScore
             self::$schemaReady = true;
             self::$schemaReady = true;
             self::ensureDefaultRule();
             self::ensureDefaultRule();
             self::ensureScoreWeightColumns();
             self::ensureScoreWeightColumns();
+            self::ensureIntegerColumns();
 
 
             return;
             return;
         } catch (\Throwable $e) {
         } catch (\Throwable $e) {
@@ -54,6 +55,7 @@ class ProcuremenSupplierScore
         self::$schemaReady = true;
         self::$schemaReady = true;
         self::ensureDefaultRule();
         self::ensureDefaultRule();
         self::ensureScoreWeightColumns();
         self::ensureScoreWeightColumns();
+        self::ensureIntegerColumns();
     }
     }
 
 
     /** 历史表补质量/价格百分比字段 */
     /** 历史表补质量/价格百分比字段 */
@@ -63,13 +65,13 @@ class ProcuremenSupplierScore
             $cols = Db::query("SHOW COLUMNS FROM `" . self::TABLE_SCORE . "` LIKE 'quality_weight'");
             $cols = Db::query("SHOW COLUMNS FROM `" . self::TABLE_SCORE . "` LIKE 'quality_weight'");
             if (!is_array($cols) || $cols === []) {
             if (!is_array($cols) || $cols === []) {
                 Db::execute(
                 Db::execute(
-                    "ALTER TABLE `" . self::TABLE_SCORE . "` ADD COLUMN `quality_weight` decimal(5,2) NOT NULL DEFAULT 50.00 COMMENT '质量百分比' AFTER `quality_score`"
+                    "ALTER TABLE `" . self::TABLE_SCORE . "` ADD COLUMN `quality_weight` int unsigned NOT NULL DEFAULT 50 COMMENT '质量百分比' AFTER `quality_score`"
                 );
                 );
             }
             }
             $cols2 = Db::query("SHOW COLUMNS FROM `" . self::TABLE_SCORE . "` LIKE 'price_weight'");
             $cols2 = Db::query("SHOW COLUMNS FROM `" . self::TABLE_SCORE . "` LIKE 'price_weight'");
             if (!is_array($cols2) || $cols2 === []) {
             if (!is_array($cols2) || $cols2 === []) {
                 Db::execute(
                 Db::execute(
-                    "ALTER TABLE `" . self::TABLE_SCORE . "` ADD COLUMN `price_weight` decimal(5,2) NOT NULL DEFAULT 50.00 COMMENT '价格百分比' AFTER `price_sum`"
+                    "ALTER TABLE `" . self::TABLE_SCORE . "` ADD COLUMN `price_weight` int unsigned NOT NULL DEFAULT 50 COMMENT '价格百分比' AFTER `price_sum`"
                 );
                 );
             }
             }
         } catch (\Throwable $e) {
         } catch (\Throwable $e) {
@@ -77,6 +79,40 @@ class ProcuremenSupplierScore
         }
         }
     }
     }
 
 
+    /** 将权重/质量分/单价合计等字段改为整数(去掉 .00) */
+    protected static function ensureIntegerColumns(): void
+    {
+        $defs = [
+            self::TABLE_RULE => [
+                'quality_weight' => "int unsigned NOT NULL DEFAULT 50 COMMENT '上年度质量评分权重(%)'",
+                'price_weight'   => "int unsigned NOT NULL DEFAULT 50 COMMENT '单价评分权重(%)'",
+            ],
+            self::TABLE_SCORE => [
+                'quality_score'  => "int NOT NULL DEFAULT 0 COMMENT '上年度质量评分'",
+                'quality_weight' => "int unsigned NOT NULL DEFAULT 50 COMMENT '质量百分比'",
+                'price_sum'      => "int NOT NULL DEFAULT 0 COMMENT '本单工序单价合计'",
+                'price_weight'   => "int unsigned NOT NULL DEFAULT 50 COMMENT '价格百分比'",
+            ],
+        ];
+        foreach ($defs as $table => $cols) {
+            foreach ($cols as $col => $def) {
+                try {
+                    $info = Db::query("SHOW COLUMNS FROM `{$table}` LIKE '{$col}'");
+                    if (!is_array($info) || $info === []) {
+                        continue;
+                    }
+                    $type = strtolower((string)($info[0]['Type'] ?? $info[0]['type'] ?? ''));
+                    if (preg_match('/^(tiny|small|medium|big)?int\b/', $type)) {
+                        continue;
+                    }
+                    Db::execute("ALTER TABLE `{$table}` MODIFY COLUMN `{$col}` {$def}");
+                } catch (\Throwable $e) {
+                    Log::write("supplier score int column {$table}.{$col}: " . $e->getMessage(), 'error');
+                }
+            }
+        }
+    }
+
     protected static function ensureDefaultRule(): void
     protected static function ensureDefaultRule(): void
     {
     {
         try {
         try {
@@ -111,7 +147,7 @@ class ProcuremenSupplierScore
     }
     }
 
 
     /**
     /**
-     * @return array{id:int,name:string,quality_weight:float,price_weight:float}
+     * @return array{id:int,name:string,quality_weight:int,price_weight:int}
      */
      */
     public static function getDefaultRule(): array
     public static function getDefaultRule(): array
     {
     {
@@ -129,8 +165,8 @@ class ProcuremenSupplierScore
                 return [
                 return [
                     'id'             => (int)($row['id'] ?? 0),
                     'id'             => (int)($row['id'] ?? 0),
                     'name'           => trim((string)($row['name'] ?? '')),
                     'name'           => trim((string)($row['name'] ?? '')),
-                    'quality_weight' => (float)($row['quality_weight'] ?? 50),
-                    'price_weight'   => (float)($row['price_weight'] ?? 50),
+                    'quality_weight' => (int)($row['quality_weight'] ?? 50),
+                    'price_weight'   => (int)($row['price_weight'] ?? 50),
                 ];
                 ];
             }
             }
         } catch (\Throwable $e) {
         } catch (\Throwable $e) {
@@ -139,8 +175,8 @@ class ProcuremenSupplierScore
         return [
         return [
             'id'             => 0,
             'id'             => 0,
             'name'           => '内置默认',
             'name'           => '内置默认',
-            'quality_weight' => 50.0,
-            'price_weight'   => 50.0,
+            'quality_weight' => 50,
+            'price_weight'   => 50,
         ];
         ];
     }
     }
 
 
@@ -183,7 +219,7 @@ class ProcuremenSupplierScore
                 continue;
                 continue;
             }
             }
             $raw = $r['score'] ?? null;
             $raw = $r['score'] ?? null;
-            $score = ($raw === null || $raw === '') ? 0.0 : (float)$raw;
+            $score = ($raw === null || $raw === '') ? 0 : (int)round((float)$raw);
             $map[$cn] = [
             $map[$cn] = [
                 'id'    => (int)($r['id'] ?? 0),
                 'id'    => (int)($r['id'] ?? 0),
                 'score' => $score,
                 'score' => $score,
@@ -255,12 +291,12 @@ class ProcuremenSupplierScore
                 $priceSum += (float)$am;
                 $priceSum += (float)$am;
                 $hasPrice = true;
                 $hasPrice = true;
             }
             }
-            $quality = (float)($custMap[$cn]['score'] ?? 0);
+            $quality = (int)round((float)($custMap[$cn]['score'] ?? 0));
             $items[$cn] = [
             $items[$cn] = [
                 'company_name'   => $cn,
                 'company_name'   => $cn,
                 'customer_id'    => (int)($custMap[$cn]['id'] ?? 0),
                 'customer_id'    => (int)($custMap[$cn]['id'] ?? 0),
                 'quality_score'  => $quality,
                 'quality_score'  => $quality,
-                'price_sum'      => $hasPrice ? $priceSum : 0.0,
+                'price_sum'      => $hasPrice ? (int)round($priceSum) : 0,
                 'has_price'      => $hasPrice,
                 'has_price'      => $hasPrice,
                 'price_score'    => 0.0,
                 'price_score'    => 0.0,
                 'score'          => 0.0,
                 'score'          => 0.0,
@@ -373,10 +409,10 @@ class ProcuremenSupplierScore
                     'ccydh'          => $ccydh,
                     'ccydh'          => $ccydh,
                     'score'          => (float)($it['score'] ?? 0),
                     'score'          => (float)($it['score'] ?? 0),
                     'rank_no'        => (int)($it['rank_no'] ?? 0),
                     'rank_no'        => (int)($it['rank_no'] ?? 0),
-                    'quality_score'  => (float)($it['quality_score'] ?? 0),
-                    'quality_weight' => (float)($rule['quality_weight'] ?? 50),
-                    'price_sum'      => (float)($it['price_sum'] ?? 0),
-                    'price_weight'   => (float)($rule['price_weight'] ?? 50),
+                    'quality_score'  => (int)round((float)($it['quality_score'] ?? 0)),
+                    'quality_weight' => (int)($rule['quality_weight'] ?? 50),
+                    'price_sum'      => (int)round((float)($it['price_sum'] ?? 0)),
+                    'price_weight'   => (int)($rule['price_weight'] ?? 50),
                     'price_score'    => (float)($it['price_score'] ?? 0),
                     'price_score'    => (float)($it['price_score'] ?? 0),
                     'rule_id'        => (int)($rule['id'] ?? 0),
                     'rule_id'        => (int)($rule['id'] ?? 0),
                     'createtime'     => $now,
                     'createtime'     => $now,

+ 1 - 1
application/extra/site.php

@@ -5,7 +5,7 @@ return array (
   'brand_logo' => 'https://a-7in6-com.oss-cn-hangzhou.aliyuncs.com/xinhua/img/logo1.png',
   'brand_logo' => 'https://a-7in6-com.oss-cn-hangzhou.aliyuncs.com/xinhua/img/logo1.png',
   'beian' => '',
   'beian' => '',
   'cdnurl' => '',
   'cdnurl' => '',
-  'version' => '1.10.30',
+  'version' => '1.10.31',
   'timezone' => 'Asia/Shanghai',
   'timezone' => 'Asia/Shanghai',
   'forbiddenip' => '',
   'forbiddenip' => '',
   'languages' => 
   'languages' => 

+ 6 - 6
application/extra/supplier_score_install.sql

@@ -2,8 +2,8 @@
 CREATE TABLE IF NOT EXISTS `supplier_score_rule` (
 CREATE TABLE IF NOT EXISTS `supplier_score_rule` (
   `id` int unsigned NOT NULL AUTO_INCREMENT,
   `id` int unsigned NOT NULL AUTO_INCREMENT,
   `name` varchar(64) NOT NULL DEFAULT '' COMMENT '规则名称',
   `name` varchar(64) NOT NULL DEFAULT '' COMMENT '规则名称',
-  `quality_weight` decimal(5,2) NOT NULL DEFAULT 50.00 COMMENT '上年度质量评分权重(%)',
-  `price_weight` decimal(5,2) NOT NULL DEFAULT 50.00 COMMENT '单价评分权重(%)',
+  `quality_weight` int unsigned NOT NULL DEFAULT 50 COMMENT '上年度质量评分权重(%)',
+  `price_weight` int unsigned NOT NULL DEFAULT 50 COMMENT '单价评分权重(%)',
   `is_default` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '1=默认计算规则',
   `is_default` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '1=默认计算规则',
   `status` varchar(16) NOT NULL DEFAULT 'normal' COMMENT 'normal/hidden',
   `status` varchar(16) NOT NULL DEFAULT 'normal' COMMENT 'normal/hidden',
   `createtime` datetime DEFAULT NULL,
   `createtime` datetime DEFAULT NULL,
@@ -21,10 +21,10 @@ CREATE TABLE IF NOT EXISTS `supplier_service_score` (
   `ccydh` varchar(64) NOT NULL DEFAULT '' COMMENT '订单号',
   `ccydh` varchar(64) NOT NULL DEFAULT '' COMMENT '订单号',
   `score` decimal(10,2) NOT NULL DEFAULT 0.00 COMMENT '总分',
   `score` decimal(10,2) NOT NULL DEFAULT 0.00 COMMENT '总分',
   `rank_no` int unsigned NOT NULL DEFAULT 0 COMMENT '本单排名',
   `rank_no` int unsigned NOT NULL DEFAULT 0 COMMENT '本单排名',
-  `quality_score` decimal(10,2) NOT NULL DEFAULT 0.00 COMMENT '上年度质量评分',
-  `quality_weight` decimal(5,2) NOT NULL DEFAULT 50.00 COMMENT '质量百分比',
-  `price_sum` decimal(14,4) NOT NULL DEFAULT 0.0000 COMMENT '本单工序单价合计',
-  `price_weight` decimal(5,2) NOT NULL DEFAULT 50.00 COMMENT '价格百分比',
+  `quality_score` int NOT NULL DEFAULT 0 COMMENT '上年度质量评分',
+  `quality_weight` int unsigned NOT NULL DEFAULT 50 COMMENT '质量百分比',
+  `price_sum` int NOT NULL DEFAULT 0 COMMENT '本单工序单价合计',
+  `price_weight` int unsigned NOT NULL DEFAULT 50 COMMENT '价格百分比',
   `price_score` decimal(10,2) NOT NULL DEFAULT 0.00 COMMENT '单价评分值',
   `price_score` decimal(10,2) NOT NULL DEFAULT 0.00 COMMENT '单价评分值',
   `rule_id` int unsigned NOT NULL DEFAULT 0 COMMENT '所用规则ID',
   `rule_id` int unsigned NOT NULL DEFAULT 0 COMMENT '所用规则ID',
   `createtime` datetime DEFAULT NULL,
   `createtime` datetime DEFAULT NULL,

+ 12 - 0
application/extra/supplier_score_int_columns.sql

@@ -0,0 +1,12 @@
+-- 评分相关字段改为整数(去掉 .00)
+-- 规则表
+ALTER TABLE `supplier_score_rule`
+  MODIFY COLUMN `quality_weight` int unsigned NOT NULL DEFAULT 50 COMMENT '上年度质量评分权重(%)',
+  MODIFY COLUMN `price_weight` int unsigned NOT NULL DEFAULT 50 COMMENT '单价评分权重(%)';
+
+-- 服务评分表(总分/单价评分值仍可保留小数)
+ALTER TABLE `supplier_service_score`
+  MODIFY COLUMN `quality_score` int NOT NULL DEFAULT 0 COMMENT '上年度质量评分',
+  MODIFY COLUMN `quality_weight` int unsigned NOT NULL DEFAULT 50 COMMENT '质量百分比',
+  MODIFY COLUMN `price_sum` int NOT NULL DEFAULT 0 COMMENT '本单工序单价合计',
+  MODIFY COLUMN `price_weight` int unsigned NOT NULL DEFAULT 50 COMMENT '价格百分比';

+ 3 - 3
application/extra/supplier_service_score_weight_columns.sql

@@ -1,4 +1,4 @@
--- 供应商服务评分表补:质量百分比、价格百分比
+-- 历史补列(新环境请直接用 supplier_score_install.sql)
 ALTER TABLE `supplier_service_score`
 ALTER TABLE `supplier_service_score`
-  ADD COLUMN `quality_weight` decimal(5,2) NOT NULL DEFAULT 50.00 COMMENT '质量百分比' AFTER `quality_score`,
-  ADD COLUMN `price_weight` decimal(5,2) NOT NULL DEFAULT 50.00 COMMENT '价格百分比' AFTER `price_sum`;
+  ADD COLUMN `quality_weight` int unsigned NOT NULL DEFAULT 50 COMMENT '质量百分比' AFTER `quality_score`,
+  ADD COLUMN `price_weight` int unsigned NOT NULL DEFAULT 50 COMMENT '价格百分比' AFTER `price_sum`;

+ 12 - 2
public/assets/js/backend/supplierscorerule.js

@@ -20,8 +20,18 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                 columns: [[
                 columns: [[
                     {checkbox: true},
                     {checkbox: true},
                     {field: 'id', title: 'ID', width: 60, sortable: true},
                     {field: 'id', title: 'ID', width: 60, sortable: true},
-                    {field: 'quality_weight', title: '质量分%', operate: 'BETWEEN', sortable: true},
-                    {field: 'price_weight', title: '价格分%', operate: 'BETWEEN', sortable: true},
+                    {field: 'quality_weight', title: '质量分%', operate: 'BETWEEN', sortable: true, formatter: function (value) {
+                        if (value === null || value === undefined || value === '') {
+                            return '';
+                        }
+                        return String(parseInt(value, 10));
+                    }},
+                    {field: 'price_weight', title: '价格分%', operate: 'BETWEEN', sortable: true, formatter: function (value) {
+                        if (value === null || value === undefined || value === '') {
+                            return '';
+                        }
+                        return String(parseInt(value, 10));
+                    }},
                     {
                     {
                         field: 'is_default',
                         field: 'is_default',
                         title: '默认',
                         title: '默认',