This commit is contained in:
songliang 2023-06-15 14:42:40 +08:00
parent d00e49a3e1
commit 21c4162538
2 changed files with 30 additions and 9 deletions

View File

@ -153,7 +153,7 @@ class Shop(object):
],
'response': [
_common.RspHead(),
['pay_methods', [_common.PayMethod()], '支付方式列表'],
['!pay_methods', [_common.PayMethod()], '支付方式列表'],
]
},
]

View File

@ -1,13 +1,33 @@
<?php
namespace mt;
use phpcommon;
class PayMethod {
public static function get($id)
class PayMethod
{
return getXVal(self::getMetaList(), $id);
public static function getPayMethods($token_type)
{
self::cachePayMethodsInTokenType();
$methods = getXVal(self::$cachePayMethodsInTokenTypeList, $token_type, null);
return $methods;
}
protected static function cachePayMethodsInTokenType()
{
if (!self::$cachePayMethodsInTokenTypeList) {
self::$cachePayMethodsInTokenTypeList = array();
foreach (self::getMetaList() as $meta) {
if (!getXVal(self::$cachePayMethodsInTokenTypeList, $meta['shop_token_type'], null)) {
self::$cachePayMethodsInTokenTypeList[$meta['shop_token_type']] = array();
}
array_push(self::$cachePayMethodsInTokenTypeList[$meta['shop_token_type']], $meta);
}
}
return self::$cachePayMethodsInTokenTypeList;
}
protected static function getMetaList()
@ -18,5 +38,6 @@ class PayMethod {
return self::$metaList;
}
protected static $cachePayMethodsInTokenTypeList;
protected static $metaList;
}