Ver Fonte

花材初始化

shish há 5 anos atrás
pai
commit
58ecb20a50

+ 5 - 0
app/ghs/controllers/ShopController.php

@@ -143,6 +143,11 @@ class ShopController extends BaseController
 	//获取所有门店linqh 2021.1.31
     public function actionAll()
     {
+
+
+
+
+
         $res = [];
         //adminId 为 super 才有权限看到所有的门店
         if($this->admin['super']==1){

+ 11 - 0
biz-pt/item/classes/UnitClass.php

@@ -0,0 +1,11 @@
+<?php
+namespace bizPt\item\classes;
+
+use bizPt\base\classes\BaseClass;
+
+class UnitClass extends BaseClass
+{
+
+    public static $baseFile = '\bizPt\item\models\Unit';
+
+}

+ 13 - 0
biz-pt/item/models/Unit.php

@@ -0,0 +1,13 @@
+<?php
+namespace bizPt\item\models;
+use bizPt\base\models\Base;
+
+class Unit extends Base
+{
+
+    public static function tableName()
+    {
+        return 'xhUnit';
+    }
+
+}

+ 9 - 0
biz-pt/item/services/UnitService.php

@@ -0,0 +1,9 @@
+<?php
+namespace bizPt\item\services;
+
+use bizPt\base\services\BaseService;
+
+class UnitService extends BaseService
+{
+
+}

+ 85 - 0
console/controllers/ItemController.php

@@ -0,0 +1,85 @@
+<?php
+
+namespace console\controllers;
+
+use bizPt\item\classes\ItemClass;
+use bizPt\item\classes\ItemClassClass;
+use bizPt\item\classes\UnitClass;
+use yii\console\Controller;
+use Yii;
+
+/**
+ * 花材初始化 shish 2021.2.18
+ */
+class ItemController extends Controller
+{
+
+    //花材初始化 ./yii item/init
+    public function actionInit()
+    {
+        $phpExcelFile = Yii::getAlias("@vendor/phpoffice/phpexcel/");
+        require_once($phpExcelFile . 'Classes/PHPExcel/IOFactory.php');//查询接口
+        $dir = Yii::$app->basePath;
+        $filename = $dir . '/goods.xls';
+
+        $fileType = \PHPExcel_IOFactory::identify($filename); //文件名自动判断文件类型
+
+        $excelReader = \PHPExcel_IOFactory::createReader($fileType);
+
+        $objPHPExcel = $excelReader->load($filename);//$file_url即Excel文件的路径
+
+        $sheet = $objPHPExcel->getSheet(0);//获取第一个工作表
+
+        $highestRow = $sheet->getHighestRow();//取得总行数
+
+        $highestColumn = $sheet->getHighestColumn(); //取得总列数
+
+        $changeData = [];
+        for ($j = 2; $j <= $highestRow; $j++) {
+            $str = '';
+            for ($k = 'A'; $k <= $highestColumn; $k++) {
+                $str .= $objPHPExcel->getActiveSheet()->getCell("$k$j")->getValue() . '\\';
+            }
+            //explode:函数把字符串分割为数组。
+            $string = explode("\\", $str);
+            array_pop($string);
+            array_push($changeData, $string);
+        }
+        if (!empty($changeData)) {
+
+            $classList = ItemClassClass::getAllByCondition([], null, '*', 'name');
+
+            $unitList = UnitClass::getAllByCondition([], null, '*', 'name');
+
+            foreach ($changeData as $key => $item) {
+                $name = $item[1];
+                $alias = $item[2];
+                $className = $item[3];
+                $classId = isset($classList[$className]['id']) ? $classList[$className]['id'] : 0;
+                $py = strtolower($item[4]);
+                $big = $item[5] ?? '';
+                $big = $big == '枝' ? '支' : $big;
+                $bigId = isset($unitList[$big]['id']) ? $unitList[$big]['id'] : 0;
+                $small = $item[6] ?? '';
+                $small = $small == '枝' ? '支' : $small;
+                $smallId = isset($unitList[$small]['id']) ? $unitList[$small]['id'] : 0;
+                $ratio = isset($item[7]) && !empty($item[7]) ? $item[7] : 0;
+                if(empty($name)){
+                    continue;
+                }
+                $data = [
+                    'name'=>$name,
+                    'alias'=>$alias,
+                    'py'=>$py,
+                    'classId'=>$classId,
+                    'unitNum'=>$ratio,
+                    'bigUnit'=>$bigId,
+                    'smallUnit'=>$smallId,
+                ];
+                print_r($data);
+                ItemClass::add($data);
+            }
+        }
+    }
+
+}

BIN
console/goods.xls


+ 23 - 1
sql.sql

@@ -1117,4 +1117,26 @@ ALTER TABLE xhExpressLocal RENAME TO xhExpress;
 ALTER TABLE xhOrderExpress CHANGE `merchantId` `sjId` INT(11) NOT NULL DEFAULT '0' COMMENT '商家id';
 ALTER TABLE xhGhsOrderExpress CHANGE `merchantId` `sjId` INT(11) NOT NULL DEFAULT '0' COMMENT '商家id';
 ALTER TABLE xhOrderExpress CHANGE `sideId` `expressId` INT(11) NOT NULL DEFAULT '0' COMMENT '配送方id';
-ALTER TABLE xhGhsOrderExpress CHANGE `sideId` `expressId` INT(11) NOT NULL DEFAULT '0' COMMENT '配送方id';
+ALTER TABLE xhGhsOrderExpress CHANGE `sideId` `expressId` INT(11) NOT NULL DEFAULT '0' COMMENT '配送方id';
+
+===============
+== shish 2021-2-18
+ALTER TABLE `xhItem` MODIFY `unitNum` TINYINT(4) NOT NULL DEFAULT '0' COMMENT '大小单位转换比例,每扎多少支';
+ALTER TABLE `xhItem` MODIFY `unitWeight` DECIMAL(9,2) NOT NULL DEFAULT '0.00' COMMENT '大单位重量,每扎多少公斤';
+ALTER TABLE `xhItem` MODIFY `unitCost` DECIMAL(9,2) NOT NULL DEFAULT '0.00' COMMENT '大单位采购价,每扎成本价,采购价';
+ALTER TABLE `xhItem` MODIFY `unitAddPrice` DECIMAL(9,2) NOT NULL DEFAULT '0.00' COMMENT '大单位加价,每扎加价';
+ALTER TABLE `xhGhsItem` MODIFY `unitWeight` FLOAT(10,2) NOT NULL DEFAULT '0.00' COMMENT '大单位重量,每扎重量(斤)';
+ALTER TABLE `xhGhsItem` MODIFY `unitCost` DECIMAL(9,2) NOT NULL DEFAULT '0.00' COMMENT '大单位采购价,每扎成本价,采购价';
+ALTER TABLE `xhGhsItem` MODIFY `unitAddPrice` DECIMAL(9,2) NOT NULL DEFAULT '0.00' COMMENT '大单位加价,每扎加价';
+ALTER TABLE xhItem ADD alias VARCHAR(50) NOT NULL DEFAULT '' COMMENT '花材别名' AFTER `name`;
+
+TRUNCATE `xhItem`;
+ALTER TABLE xhItem AUTO_INCREMENT=1000;
+
+请直接将xhItem xhItemClass xhUnit 表和数据迁移到线上
+
+ALTER TABLE xhItemClass ADD `group` TINYINT NOT NULL DEFAULT 0 COMMENT ' 所属分组,0默认平台的分类' AFTER `name`;
+ALTER TABLE xhItem ADD classId INT NOT NULL DEFAULT 0 COMMENT '平台分类id' AFTER `cover`;
+ALTER TABLE `xhItem`
+MODIFY COLUMN `addTime`  TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '添加时间',
+MODIFY COLUMN `updateTime`  TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间';