Explorar o código

商品列表多语言翻译

root %!s(int64=2) %!d(string=hai) anos
pai
achega
f50a888625

+ 98 - 4
backendApi/modules/v1/models/lists/shop/GoodsList.php

@@ -64,7 +64,7 @@ class GoodsList extends \common\libs\dataList\DataList implements DataListInterf
                 'GIFT_TYPE' => [
                     'header' => \Yii::t('ctx', 'shopListProductsType'), // 商品类型
                     'value' => function($row){
-                        $giftType = ShopGoods::GIFT_TYPE;
+                        $giftType = $this->getGiftType();//ShopGoods::GIFT_TYPE;
                         $gift = explode(',',$row['GIFT_TYPE']);
                         $value = '';
                         foreach ($gift as $v){
@@ -78,7 +78,7 @@ class GoodsList extends \common\libs\dataList\DataList implements DataListInterf
                 'CATEGORY_TYPE' => [
                     'header' => \Yii::t('ctx', 'shopListProductCategory'), // 商品分类
                     'value' => function($row) {
-                        $categoryType = array_column(ShopGoods::CATEGORY_TYPE, NULL, 'id');
+                        $categoryType =  array_column($this->getCategoryType(), NULL, 'id'); //array_column(ShopGoods::CATEGORY_TYPE, NULL, 'id');
                         return $categoryType[$row['CATEGORY_TYPE']]['name'] ?? '';
                     },
                     'headerOther' => ['width' => '150'],
@@ -86,7 +86,7 @@ class GoodsList extends \common\libs\dataList\DataList implements DataListInterf
                 'SELL_TYPE' => [
                     'header' => \Yii::t('ctx', 'shopListPaymentMode'), // 购买方式
                     'value' => function($row){
-                        $sellType = ShopGoods::SALE_TYPE;
+                        $sellType =  $this->getSaleType(); //ShopGoods::SALE_TYPE;
                         $sel = explode(',',$row['SELL_TYPE']);
                         $value = '';
                         foreach ($sel as $v){
@@ -228,10 +228,104 @@ class GoodsList extends \common\libs\dataList\DataList implements DataListInterf
                 'CATEGORY_TYPE' => [
                     'name' => \Yii::t('ctx', 'shopListProductCategory'), 
                     'other'=> 'select', 
-                    'selectData'=> ShopGoods::CATEGORY_TYPE
+                    // 翻译无法使用const,改成其他方式
+                    // 'selectData'=> ShopGoods::CATEGORY_TYPE
+                    'selectData'=> $this->getCategoryType()
                 ], // 商品分类
             ];
         }
         return $this->filterTypes;
     }
+
+    public function getCategoryType() {
+        $saleType = $this->getSaleType();
+        return [
+            [
+                'id' => 1,
+                'name' => \Yii::t('ctx', 'shopListStandardProducts'),//普通商品
+                'sell_type' => [
+                    $saleType[1],
+    //                self::SALE_TYPE[3],
+                    $saleType[7],
+                ]
+            ],
+    //        [
+    //            'id' => 4,
+    //            'name' => 'Travel bonus products',//旅游积分商品
+    //            'sell_type' => [
+    //                self::SALE_TYPE[4]
+    //            ]
+    //        ],
+            [
+                'id' => 5,
+                'name' => \Yii::t('ctx', 'shopListCarFundProducts'),
+                'sell_type' => [
+                    $saleType[5]
+                ]
+            ],
+            [
+                'id' => 6,
+                'name' => \Yii::t('ctx', 'shopListVillaFundProducts'),
+                'sell_type' => [
+                    $saleType[6]
+                ]
+            ],
+        ];
+    }
+
+    public function getSaleType() {
+        return [
+            1 => [
+                'id' => 1,
+                'name' => \Yii::t('ctx', 'shopListAccountBalance'), //余额购买
+                'label' => 'cash',
+            ],
+    //        2 => [
+    //            'id' => 2,
+    //            'name' => '复消兑换',
+    //        ],
+    //        3 => [
+    //            'id' => 3,
+    //            'name' => '兑换点数',
+    //            'label' => 'exchange',
+    //        ],
+            4 => [
+                'id' => 4,
+                'name' => \Yii::t('ctx', 'shopListPayTravelBonus'), // 旅游积分
+                'label' => 'tourism_points',
+            ],
+            5 => [
+                'id' => 5,
+                'name' => \Yii::t('ctx', 'shopListPayCarFund'), // 车奖积分
+                'label' => 'garage_points',
+            ],
+            6 => [
+                'id' => 6,
+                'name' => \Yii::t('ctx', 'shopListPayVillaFund'), // 房奖积分
+                'label' => 'villa_points',
+            ],
+            7 => [
+                'id' => 7,
+                'name' => 'PayStack', // PayStack
+                'label' => 'pay_stack',
+            ],
+        ];
+    }
+
+    public function getGiftType() {
+        return [
+            1 =>[
+                'name'=>\Yii::t('ctx', 'shopList1stPurchase'),//报单区
+            ],
+            2 =>[
+                'name'=>\Yii::t('ctx', 'shopListRepeatPurchase'),//复消区
+            ],
+            3 =>[
+                'name'=>\Yii::t('ctx', 'shopListEntryArea')//'Office Entry area',//工作室报单
+            ],
+            4 =>[
+                'name'=>\Yii::t('ctx', 'shopListResellingArea')//'Office Reselling area',//工作室复消
+            ],
+        ];
+    }
 }

+ 10 - 2
common/messages/en-US/ctx.php

@@ -186,11 +186,19 @@ return [
     'shopListOnSale' => 'On sale',
     'shopListSoldOut' => 'Sold out',
     'shopListUpdatedAt' => 'Update Time',
-    'shopListEntryArea' => 'Entry area',
-    'shopListResellingArea' => 'Reselling area',
+    'shopListEntryArea' => 'Office Entry area',
+    'shopListResellingArea' => 'Office Reselling area',
     'shopList1stPurchase' => '1st Purchase',
     'shopListRepeatPurchase' => 'Repeat Purchase',
 
+    'shopListStandardProducts' => 'Standard Products',
+    'shopListCarFundProducts' => 'Car Fund Products',
+    'shopListVillaFundProducts' => 'Villa Fund Products',
+    'shopListAccountBalance' => 'Account Balance',
+    'shopListPayTravelBonus' => 'Travel Bonus',
+    'shopListPayCarFund' => 'Car Fund',
+    'shopListPayVillaFund' => 'Villa Fund',
+
     'shopExportListName' => 'Goods_List',
     'shopProductAddSucceededNotice' => 'Product add succeeded',
     'shopProductEditSucceed'=>'Product editing succeeded',

+ 8 - 0
common/messages/zh-CN/ctx.php

@@ -190,6 +190,14 @@ return [
     'shopListResellingArea' => '工作室复消',
     'shopList1stPurchase' => '报单区',
     'shopListRepeatPurchase' => '复消区',
+    'shopListStandardProducts' => '普通商品',
+    'shopListCarFundProducts' => '车奖商品',
+    'shopListVillaFundProducts' => '房奖商品',
+    'shopListAccountBalance' => '余额购买',
+    'shopListPayTravelBonus' => '旅游积分',
+    'shopListPayCarFund' => '车奖积分',
+    'shopListPayVillaFund' => '房奖积分',
+    
     
 
     'shopExportListName' => '商品列表',