shish преди 5 години
родител
ревизия
9cc82007e9

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

@@ -183,6 +183,12 @@ class AdminController extends BaseController
         }
         $arr = Json::decode($result);
         $mobile = isset($arr['purePhoneNumber']) ? $arr['purePhoneNumber'] : '';
+
+        $originalMobile = $admin['mobile'] ?? '';
+        if (empty($originalMobile)) {
+            \biz\admin\classes\AdminClass::updateById($this->adminId, ['mobile' => $mobile]);
+        }
+
         util::success(['mobile' => $mobile]);
     }
 

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

@@ -192,8 +192,8 @@ class AuthController extends PublicController
         $result = $curl->get($url);
         $arr = Json::decode($result);
         $sessionKey = isset($arr['session_key']) ? $arr['session_key'] : '';
-        $openid = isset($arr['openid']) ? $arr['openid'] : '';
-        $unionId = isset($arr['unionid']) ?? '';
+        $openid = $arr['openid'] ?? '';
+        $unionId = $arr['unionid'] ?? '';
         if (empty($openid)) {
             Yii::info(json_encode($arr));
             util::fail('没有获取到小程序openId');

+ 6 - 0
app-hd/controllers/AdminController.php

@@ -194,6 +194,12 @@ class AdminController extends BaseController
 		}
 		$arr = Json::decode($result);
 		$mobile = isset($arr['purePhoneNumber']) ? $arr['purePhoneNumber'] : '';
+
+        $originalMobile = $admin['mobile'] ?? '';
+        if (empty($originalMobile)) {
+            \biz\admin\classes\AdminClass::updateById($this->adminId, ['mobile' => $mobile]);
+        }
+
 		util::success(['mobile' => $mobile]);
 	}
 	

+ 2 - 2
app-hd/controllers/AuthController.php

@@ -190,8 +190,8 @@ class AuthController extends PublicController
         $result = $curl->get($url);
         $arr = Json::decode($result);
         $sessionKey = isset($arr['session_key']) ? $arr['session_key'] : '';
-        $openid = isset($arr['openid']) ? $arr['openid'] : '';
-        $unionId = isset($arr['unionid']) ?? '';
+        $openid = $arr['openid'] ?? '';
+        $unionId = $arr['unionid'] ?? '';
         $cacheKey = 'SHOP_MINI_SESSION_KEY_' . $openid;
         Yii::$app->redis->executeCommand('SET', [$cacheKey, $sessionKey]);
         if (empty($openid)) {

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

@@ -110,9 +110,11 @@ class GoodsClass extends BaseClass
         $data['content'] = isset($data['content']) ? $data['content'] : '';
         $data['stock'] = isset($data['stock']) && is_numeric($data['stock']) && $data['stock'] >= 0 ? $data['stock'] : -1;
         $data['sold'] = isset($data['sold']) && is_numeric($data['sold']) && $data['sold'] >= 0 ? $data['sold'] : 0;
+        $data['py'] = stringUtil::getSpelling($data['goodsName']);
         $goodsInfo = self::add($data);
         $id = $goodsInfo['id'];
         $goodsName = $goodsInfo['goodsName'];
+        $py = $data['py'] ?? '';
 
         //处理分类
         $hasCategoryIdList = CategoryClass::getCategoryIdList($merchantId);
@@ -122,7 +124,7 @@ class GoodsClass extends BaseClass
         }
         $addCategory = [];
         foreach ($categoryIdList as $categoryId) {
-            $addCategory[] = ['gId' => $id, 'goodsName' => $goodsName, 'cId' => $categoryId, 'merchantId' => $data['merchantId']];
+            $addCategory[] = ['gId' => $id, 'goodsName' => $goodsName, 'cId' => $categoryId, 'merchantId' => $data['merchantId'], 'py' => $py];
         }
         GoodsCategoryClass::batchAdd($addCategory);
         //处理款式
@@ -146,7 +148,7 @@ class GoodsClass extends BaseClass
         }
         $goodsStyleList = isset($data['goodsStyleList']) && !empty($data['goodsStyleList']) ? $data['goodsStyleList'] : [];
         unset($data['goodsStyleList']);
-
+        $py = stringUtil::getSpelling($data['goodsName']);
         //处理分类
         $merchantId = $data['merchantId'];
         $merchantHasCategoryIdList = CategoryClass::getCategoryIdList($merchantId);
@@ -158,7 +160,7 @@ class GoodsClass extends BaseClass
         GoodsCategoryClass::delGoodsCategory($id);
         $addCategory = [];
         foreach ($categoryIdList as $categoryId) {
-            $addCategory[] = ['gId' => $id, 'goodsName' => $data['goodsName'], 'cId' => $categoryId, 'merchantId' => $data['merchantId']];
+            $addCategory[] = ['gId' => $id, 'goodsName' => $data['goodsName'], 'py' => $py, 'cId' => $categoryId, 'merchantId' => $data['merchantId']];
         }
         GoodsCategoryClass::batchAdd($addCategory);
 
@@ -168,6 +170,7 @@ class GoodsClass extends BaseClass
         }
 
         $data['shopImg'] = json_encode($data['shopImg']);
+        $data['py'] = $py;
         self::updateById($id, $data);
     }
 

+ 39 - 0
console/controllers/GoodsController.php

@@ -0,0 +1,39 @@
+<?php
+
+namespace console\controllers;
+
+use bizHd\goods\classes\GoodsCategoryClass;
+use bizHd\goods\classes\GoodsClass;
+use common\components\stringUtil;
+use Yii;
+use yii\console\Controller;
+
+class GoodsController extends Controller
+{
+
+    //将已有商品的拼音补回 yii goods/py 更新平台公众号
+    public function actionPy()
+    {
+        $list = GoodsClass::getAllByCondition([], null, '*');
+        if (!empty($list)) {
+            foreach ($list as $goods) {
+                $goodsName = $goods['goodsName'];
+                $py = stringUtil::getSpelling($goodsName);
+                $id = $goods['id'];
+                GoodsClass::updateById($id, ['py' => $py]);
+            }
+        }
+
+        $list = GoodsCategoryClass::getAllByCondition([], null, '*');
+        if (!empty($list)) {
+            foreach ($list as $key => $val) {
+                $goodsName = $val['goodsName'];
+                $py = stringUtil::getSpelling($goodsName);
+                $id = $val['id'];
+                GoodsCategoryClass::updateById($id, ['py' => $py]);
+            }
+        }
+
+    }
+
+}

+ 5 - 1
sql.sql

@@ -2201,4 +2201,8 @@ CREATE TABLE `xhShopAd` (
   KEY `multiple` (`merchantId`,`status`,`startTime`,`endTime`)
 )COMMENT='门店图片';
 ALTER TABLE xhShopAd RENAME TO xhShopImg;
-ALTER TABLE `xhCategory` MODIFY `status` TINYINT(4) NOT NULL DEFAULT '1' COMMENT '状态 0停用1启用';
+ALTER TABLE `xhCategory` MODIFY `status` TINYINT(4) NOT NULL DEFAULT '1' COMMENT '状态 0停用1启用';
+ALTER TABLE xhGoods MODIFY `py` VARCHAR(20) NOT NULL DEFAULT '' COMMENT '拼音' AFTER goodsName;
+ALTER TABLE xhGoodsCategory ADD py VARCHAR(50) NOT NULL DEFAULT '' COMMENT '拼音' AFTER `goodsName`;
+
+执行命令将原有的商品拼音补齐 yii goods/py