|
@@ -16,18 +16,22 @@ class mchannel_item
|
|
|
public function add_channel($spec,$card_type,$quality,$chname)
|
|
|
{
|
|
|
$key = "{$quality}-{$card_type}-{$spec}";
|
|
|
- if(array_key_exists($key,$this->mChannelMap))
|
|
|
- {
|
|
|
- $chanels = $this->mChannelMap[$key];
|
|
|
- if(!in_array($chname,$chanels)) {
|
|
|
- $this->mChannelMap[$key][] = $chname;
|
|
|
- }
|
|
|
+ if(!array_key_exists($key,$this->mChannelMap)) {
|
|
|
+ $this->mChannelMap[$key] = [];
|
|
|
+ }
|
|
|
+ $chanels = $this->mChannelMap[$key];
|
|
|
+ if(!in_array($chname,$chanels)) {
|
|
|
+ $this->mChannelMap[$key][] = $chname;
|
|
|
}
|
|
|
}
|
|
|
public function find($spec,$card_type,$quality)
|
|
|
{
|
|
|
$key = "{$quality}-{$card_type}-{$spec}";
|
|
|
- $chanels = $this->mChannelMap[$key];
|
|
|
+ if(array_key_exists($key,$this->mChannelMap)) {
|
|
|
+ $chanels = $this->mChannelMap[$key];
|
|
|
+ } else {
|
|
|
+ $chanels = [];
|
|
|
+ }
|
|
|
|
|
|
return $chanels;
|
|
|
}
|
|
@@ -109,38 +113,49 @@ class rgroup_ctl
|
|
|
|
|
|
private function load_merchant($groups)
|
|
|
{
|
|
|
- $mchitems = Model('')->table('merchant')->limit(1000)->select();//读取数据库,获取机构列表
|
|
|
+ $mchitems = Model('')->table('merchant')->limit(1000)->select();
|
|
|
foreach ($mchitems as $item)
|
|
|
{
|
|
|
$mchid = intval($item['mchid']);
|
|
|
- $gids = explode(',',$item[]); //通过分析item 通道参数,获取gids
|
|
|
- if(empty($gids)) continue;
|
|
|
+ $ids_text = $item['group_ids'];
|
|
|
+
|
|
|
+ if (empty($ids_text)) continue;
|
|
|
+ $gids = explode(',', $ids_text);
|
|
|
+ if (empty($gids)) continue;
|
|
|
+
|
|
|
$mchchannel = new mchannel_item($mchid);
|
|
|
- $this->mMch2Channel[$mchid] = $mchchannel;
|
|
|
|
|
|
+ $has_group = false;
|
|
|
foreach ($gids as $gid)
|
|
|
{
|
|
|
- if(array_key_exists($gid,$groups))
|
|
|
+ if (array_key_exists($gid, $groups))
|
|
|
{
|
|
|
- $group = $groups[$gid];
|
|
|
- $chitems = $group->infos;
|
|
|
+ $has_group = true;
|
|
|
+
|
|
|
+ $group = $groups[$gid];
|
|
|
+ $chitems = $group->infos();
|
|
|
foreach ($chitems as $text) {
|
|
|
- [$spec,$card_type,$quality,$chname] = $this->parase($text);
|
|
|
- $mchchannel->add_channel($spec,$card_type,$quality,$chname);
|
|
|
+ [$spec, $card_type, $quality, $chname] = $this->parase($text);
|
|
|
+ $mchchannel->add_channel($spec, $card_type, $quality, $chname);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
+ if ($has_group) {
|
|
|
+ $this->mMch2Channel[$mchid] = $mchchannel;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
private function parase($text)
|
|
|
{
|
|
|
$data = explode('-',$text);
|
|
|
- $spec = $data[3];
|
|
|
- $card_type = $data[2];
|
|
|
+
|
|
|
$quality = $data[0];
|
|
|
$chname = $data[1];
|
|
|
+ $card_type = $data[2];
|
|
|
+ $spec = $data[3];
|
|
|
+
|
|
|
return [$spec,$card_type,$quality,$chname];
|
|
|
}
|
|
|
}
|