|
@@ -347,12 +347,14 @@ class providerControl extends SystemControl
|
|
|
$provider_id = $_GET['provider_id'];
|
|
|
$mod_provider = Model('refill_provider');
|
|
|
$mod_price = Model('provider_price');
|
|
|
+
|
|
|
$provider = $mod_provider->getProviderInfo(['provider_id' => $provider_id]);
|
|
|
$provider_name = $provider['name'];
|
|
|
$type = $provider['type'];
|
|
|
|
|
|
$price = $mod_price->getPirce(['provider_name' => $provider_name,'product_type' => $type]);
|
|
|
$cfg = $this->price_cfg($price);
|
|
|
+
|
|
|
if(empty($provider)) {
|
|
|
showMessage('通道不存在');
|
|
|
}
|
|
@@ -363,6 +365,7 @@ class providerControl extends SystemControl
|
|
|
if($effect_time > 0) {
|
|
|
$effect_time = strtotime($effect_time);
|
|
|
}
|
|
|
+
|
|
|
$chprice_helper = new refill\chprice_helper();
|
|
|
$ret = $chprice_helper->update($price['price_id'], $new_cfg, $effect_time, $admininfo['name']);
|
|
|
if($ret) {
|
|
@@ -373,10 +376,13 @@ class providerControl extends SystemControl
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- $cfg_map = $this->map_cfg($cfg);
|
|
|
- $all_specs = $this->all_specs($provider['qualitys'], $type);
|
|
|
- Tpl::output('provider', $provider);
|
|
|
- Tpl::output('cfg_map', $cfg_map);
|
|
|
+ $all_specs = $this->all_specs($cfg['qualitys'], $type);
|
|
|
+ $amounts = $this->map_cfg($cfg,$all_specs);
|
|
|
+
|
|
|
+ Tpl::output('provider_name', $cfg['name']);
|
|
|
+ Tpl::output('product_type', $price['product_type']);
|
|
|
+
|
|
|
+ Tpl::output('amounts', $amounts);
|
|
|
Tpl::output('all_specs', $all_specs);
|
|
|
Tpl::showpage('provider.price.set');
|
|
|
}
|
|
@@ -404,20 +410,43 @@ class providerControl extends SystemControl
|
|
|
return $result;
|
|
|
}
|
|
|
|
|
|
- private function map_cfg($cfg)
|
|
|
+ private function map_cfg($cfg,$all_specs)
|
|
|
{
|
|
|
- $result = [];
|
|
|
$amounts = $cfg['amount'] ?? [];
|
|
|
+
|
|
|
+ $amount_list = [];
|
|
|
foreach ($amounts as $spec => $goods)
|
|
|
{
|
|
|
foreach ($goods as $gitem)
|
|
|
{
|
|
|
$types = $this->card_types($gitem['card_type']);
|
|
|
foreach ($types as $type) {
|
|
|
- $result[$type][$spec] = $gitem['price'] ?? 0;
|
|
|
+ $amount_list[$type][$spec] = $gitem['price'] ?? 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $result = [];
|
|
|
+ foreach ($all_specs as $card_type => $val)
|
|
|
+ {
|
|
|
+ $specs = $val['specs'];
|
|
|
+ foreach ($specs as $spec)
|
|
|
+ {
|
|
|
+ $result[$card_type][$spec] = ['price' => 0,'opened' => 0];
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ foreach ($amount_list as $card_type => $prices)
|
|
|
+ {
|
|
|
+ foreach ($prices as $spec => $price)
|
|
|
+ {
|
|
|
+ if (array_key_exists($card_type, $result) && array_key_exists($spec, $result[$card_type])) {
|
|
|
+ $result[$card_type][$spec]['price'] = $price;
|
|
|
+ $result[$card_type][$spec]['opened'] = 1;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
return $result;
|
|
|
}
|
|
|
|