<?php
/**
 * 作者: theworld
 * 时间: 2023-03-10
 * 产品信息     
 */

class productIdcsmart {
	/**
	 * 作者: theworld
	 * 时间: 2023-03-10
	 * 所有产品
	 * @return array
	 */
	public function listing($params){
		$where="WHERE (p.servertype='ipmi' OR p.servertype='zjmfcloud') AND p.retired=0 AND p.hidden=0";
		$result = _pdoQuery("SELECT p.id, p.name, p.paytype, pg.name AS group_name
					FROM tblproducts AS p
					JOIN tblproductgroups AS pg ON p.gid = pg.id {$where}
					ORDER BY pg.name, p.order, p.name");		
		foreach($result as $v){
			$products[]=array('id' => $v['id'], 'name' => $v['name'], 'pay_type' => $v['paytype'] == 'onetime' ? 'onetime' : ($v['paytype'] == 'free' ? 'free' :'recurring_prepayment'));
		}
		if($products){
			foreach ($products as $key => $value) {
				$params['productid'] = $value['id'];
				$min = $this->minPrice($params);
				if($value['pay_type']=='recurring_prepayment'){
					$products[$key]['price'] = $min['price'] ?? 0;
					$products[$key]['cycle'] = $min['cycle'] ?? '';
				}else if($value['pay_type']=='onetime'){
					$products[$key]['price'] = $min['price'] ?? 0;
					$products[$key]['cycle'] = '一次性';
				}
			}
			$resultMsg['status']=200;
			$resultMsg['data']['list']=$products;
		}else{
			$resultMsg['status'] =400;
			$resultMsg['msg']="无产品";
		}
		return $resultMsg;
	}

	/**
	 * 作者: theworld
	 * 时间: 2023-03-10
	 * 当前产品
	 * @return array
	 */
	public function detail($params){
		$command = 'GetProducts';
		$postData = array(
		    'pid' => $params['productid'],
		);
		$adminUsername = ''; 

		$result = localAPI($command, $postData, $adminUsername);
		$resultMsg['status'] = 200;
		$product = $result['products']['product'][0] ?? [];
		if(!empty($product)){
			$module = [
				'ipmi' => 'whmcs_dcim',
				'zjmfcloud' => 'whmcs_cloud',
			];
			$version = [
				'ipmi' => '1.0.0',
				'zjmfcloud' => '1.0.0',
			];
			$product['module'] = $module[$product['module']] ?? '';
			$product['version'] = $version[$product['module']] ?? '1.0.0';
			$product['pay_type'] = $product['paytype'] == 'onetime' ? 'onetime' : ($product['paytype'] == 'free' ? 'free' :'recurring_prepayment');
			$min = $this->minPrice($params);
			if($product['pay_type']=='recurring_prepayment'){
				$product['price'] = $min['price'] ?? 0;
				$product['cycle'] = $min['cycle'] ?? '';
			}else if($product['pay_type']=='onetime'){
				$product['price'] = $min['price'] ?? 0;
				$product['cycle'] = '一次性';
			}
		}
		$resultMsg['data']['product'] = $product;
		$resultMsg['data']['customfields'] =  _pdoQuery("SELECT `id`,`fieldname`,`fieldtype`,`description`,`fieldoptions`,`regexpr`,`required`,`showinvoice` FROM `tblcustomfields` WHERE `relid`='{$product['pid']}' AND `type`='product' AND `adminonly`='' AND `showorder`='on' ORDER BY `sortorder`,`id` ASC");
		return $resultMsg;
	}

	/**
	 * 作者: theworld
	 * 时间: 2023-03-10
	 * 产品价格
	 * @params  string $productid  产品ID
	 * @return array
	 */
	public function price($params){	
		if(empty($params['productid'])) return ['status'=>400,'msg'=>'productid不能为空'];

		$product = _pdoSelect("tblproducts","id,paytype","id={$params['productid']}");
		if(!empty($product)){
			$pricing = _pdoSelect("tblpricing","msetupfee,qsetupfee,ssetupfee,asetupfee,bsetupfee,tsetupfee,monthly,quarterly,semiannually,annually,biennially,triennially","`type`='product' AND `currency`='1' AND relid ={$params['productid']}");
			$configurable = array();
			$options = _pdoQuery("SELECT co.*, cog.name AS group_name, cog.description AS group_description
										FROM tblproductconfigoptions AS co
										JOIN tblproductconfiggroups AS cog ON co.gid = cog.id
										JOIN tblproductconfiglinks AS col ON cog.id = col.gid
										WHERE col.pid = {$params['productid']}  AND co.hidden=0");
			//配置项价格
			$options_id=implode(",",array_column($options,"id"));
			if($options_id){
				$configoptionssub = _pdoQuery("
				SELECT cos.* , p.msetupfee, p.qsetupfee, p.ssetupfee, p.asetupfee, p.bsetupfee, p.tsetupfee, p.monthly, p.quarterly, p.semiannually, p.annually, p.biennially, p.triennially
				FROM tblproductconfigoptionssub AS cos
				JOIN tblpricing AS p ON type = 'configoptions' AND currency = 1 AND relid = cos.id
				WHERE cos.configid IN ({$options_id})  AND cos.hidden = 0
				ORDER BY cos.sortorder ASC, cos.id ASC");
				foreach($configoptionssub as $v){
					$configoptionssub2[$v['configid']][]=$v;
				}
			}
			foreach($options as $v){
				$opt=array();
				foreach($configoptionssub2[$v['id']] as $c){
					$ex = explode('|', $c['optionname']);
					$c['firstname'] = $ex[0];
					$c['lastname'] = isset($ex[1]) ? $ex[1] : $ex[0];
					$opt[] = $c;
				}
				$ops=array();
				foreach ($opt as $o){
					$ops[] = array(
						'id'	=> $o['id'],
						'optionname'	=> $o['optionname'],
						'firstname'		=> $o['firstname'],
						'lastname'		=> $o['lastname'],
						'currency'		=> 1,
						'msetupfee'		=> $product['paytype']!='free' ? $o['msetupfee'] : 0,
						'qsetupfee'		=> $product['paytype']!='free' ? $o['qsetupfee'] : 0,
						'ssetupfee'		=> $product['paytype']!='free' ? $o['ssetupfee'] : 0,
						'asetupfee'		=> $product['paytype']!='free' ? $o['asetupfee'] : 0,
						'bsetupfee'		=> $product['paytype']!='free' ? $o['bsetupfee'] : 0,
						'tsetupfee'		=> $product['paytype']!='free' ? $o['tsetupfee'] : 0,
						'monthly'		=> $product['paytype']!='free' ? $o['monthly'] : 0,
						'quarterly'		=> $product['paytype']!='free' ? $o['quarterly'] : 0,
						'semiannually'	=> $product['paytype']!='free' ? $o['semiannually'] : 0,
						'annually'		=> $product['paytype']!='free' ? $o['annually'] : 0,
						'biennially'	=> $product['paytype']!='free' ? $o['biennially'] : 0,
						'triennially'	=> $product['paytype']!='free' ? $o['triennially'] : 0,
					);
				}
				$key = explode('|', $v['optionname']);
				//$key = $key[0];
				$configurable[] = array(
					'id'	=> $v['id'],
					'optionname'	=> $v['optionname'],
					'firstname'		=> $key[0],
					'lastname'		=> isset($key[1]) ? $key[1] : $key[0],
					'optiontype'	=> $v['optiontype'],
					'qtyminimum'	=> $v['qtyminimum'],
					'qtymaximum'	=> $v['qtymaximum'],
					'options'		=> $ops
				);
			}
			if($product['paytype']=='free'){
				foreach ($pricing as $key => $value) {
					$pricing[$key] = 0;
				}
			}
			if(!isset($pricing[$params['billingcycle']]) || $pricing[$params['billingcycle']]<0){
				$resultMsg['status']=400;
				$resultMsg['msg']='不支持该周期';
				return $resultMsg;
			}
			
			$setupfeeArr = [
				'monthly' => 'msetupfee',
				'quarterly' => 'qsetupfee',
				'semiannually' => 'ssetupfee',
				'annually' => 'asetupfee',
				'biennially' => 'bsetupfee',
				'biennially' => 'tsetupfee',
			];
			$setupfee = $setupfeeArr[$params['billingcycle']];
			$price = 0;
			$renew_price = 0;
			$base_price = 0;
			$price += $pricing[$params['billingcycle']];
			$price += $pricing[$setupfee];
			$base_price = $price;
			$renew_price += $pricing[$params['billingcycle']];
			$preview = [];
			foreach ($configurable as $key => $value) {
				$option = $params['configoptions'][$value['id']] ?? 0;
				if(empty($option)){
					continue;
				}
				if($value['optiontype']==4){
					$price += $value['options'][0][$params['billingcycle']]*$option;
					$price += $value['options'][0][$setupfee]*$option;
					$renew_price += $value['options'][0][$params['billingcycle']]*$option;
					$preview[] = ['name' => $value['lastname'], 'value' => $option, 'price' => $value['options'][0][$params['billingcycle']]*$option+$value['options'][0][$setupfee]*$option];
				}else if($value['optiontype']==3 && $option=='1'){
					$price += $value['options'][0][$params['billingcycle']];
					$price += $value['options'][0][$setupfee];
					$renew_price += $value['options'][0][$params['billingcycle']];
					$preview[] = ['name' => $value['lastname'], 'value' => '是', 'price' => $value['options'][0][$params['billingcycle']]+$value['options'][0][$setupfee]];
				}else if($value['optiontype']==1 || $value['optiontype']==2){
					foreach ($value['options'] as $k => $v) {
						if($option==$v['id']){
							$price += $v[$params['billingcycle']];
							$price += $v[$setupfee];
							$renew_price += $v[$params['billingcycle']];
							$preview[] = ['name' => $value['lastname'], 'value' => $v['lastname'], 'price' => $v[$params['billingcycle']]+$v[$setupfee]];
						}
					}
					
				}
			}
			$resultMsg['status']=200;
			$resultMsg['msg']='获取配置选项成功';
			$resultMsg['data']= ['price'=>$price, 'renew_price' => $renew_price, 'base_price' => $base_price, 'preview' => $preview];

		}else{
			$resultMsg['status']=400;
			$resultMsg['msg']="找不到当前产品id对应的产品";
		}
		return $resultMsg;
	}

	/**
	 * 作者: theworld
	 * 时间: 2023-03-10
	 * 产品配置项及配置项价格
	 * @params  string   $productid  产品ID
	 * @return array
	 */
	public function duration($params){		
		if(empty($params['productid'])) return ['status'=>400,'msg'=>'productid不能为空'];

		$product = _pdoSelect("tblproducts","id","id={$params['productid']}");
		if(!empty($product)){
			$pricing = _pdoSelect("tblpricing","msetupfee,qsetupfee,ssetupfee,asetupfee,bsetupfee,tsetupfee,monthly,quarterly,semiannually,annually,biennially,triennially","`type`='product' AND `currency`='1' AND relid ={$params['productid']}");
			$configurable = array();
			$options = _pdoQuery("SELECT co.*, cog.name AS group_name, cog.description AS group_description
										FROM tblproductconfigoptions AS co
										JOIN tblproductconfiggroups AS cog ON co.gid = cog.id
										JOIN tblproductconfiglinks AS col ON cog.id = col.gid
										WHERE col.pid = {$params['productid']}  AND co.hidden=0");
			//配置项价格
			$options_id=implode(",",array_column($options,"id"));
			if($options_id){
				$configoptionssub = _pdoQuery("
				SELECT cos.* , p.msetupfee, p.qsetupfee, p.ssetupfee, p.asetupfee, p.bsetupfee, p.tsetupfee, p.monthly, p.quarterly, p.semiannually, p.annually, p.biennially, p.triennially
				FROM tblproductconfigoptionssub AS cos
				JOIN tblpricing AS p ON type = 'configoptions' AND currency = 1 AND relid = cos.id
				WHERE cos.configid IN ({$options_id})  AND cos.hidden = 0
				ORDER BY cos.sortorder ASC, cos.id ASC");
				foreach($configoptionssub as $v){
					$configoptionssub2[$v['configid']][]=$v;
				}
			}
			foreach($options as $v){
				$opt=array();
				foreach($configoptionssub2[$v['id']] as $c){
					$ex = explode('|', $c['optionname']);
					$c['firstname'] = $ex[0];
					$c['lastname'] = isset($ex[1]) ? $ex[1] : $ex[0];
					$opt[] = $c;
				}
				$ops=array();
				foreach ($opt as $o){
					$ops[] = array(
						'id'	=> $o['id'],
						'optionname'	=> $o['optionname'],
						'firstname'		=> $o['firstname'],
						'lastname'		=> $o['lastname'],
						'currency'		=> 1,
						'msetupfee'		=> $o['msetupfee'],
						'qsetupfee'		=> $o['qsetupfee'],
						'ssetupfee'		=> $o['ssetupfee'],
						'asetupfee'		=> $o['asetupfee'],
						'bsetupfee'		=> $o['bsetupfee'],
						'tsetupfee'		=> $o['tsetupfee'],
						'monthly'		=> $o['monthly'],
						'quarterly'		=> $o['quarterly'],
						'semiannually'	=> $o['semiannually'],
						'annually'		=> $o['annually'],
						'biennially'	=> $o['biennially'],
						'triennially'	=> $o['triennially'],
					);
				}
				$key = explode('|', $v['optionname']);
				//$key = $key[0];
				$configurable[] = array(
					'id'	=> $v['id'],
					'optionname'	=> $v['optionname'],
					'firstname'		=> $key[0],
					'lastname'		=> isset($key[1]) ? $key[1] : $key[0],
					'optiontype'	=> $v['optiontype'],
					'qtyminimum'	=> $v['qtyminimum'],
					'qtymaximum'	=> $v['qtymaximum'],
					'options'		=> $ops
				);
			}

			$billingcycleArr = [
				'monthly' => 0,
				'quarterly' => 0,
				'semiannually' => 0,
				'annually' => 0,
				'biennially' => 0,
				'triennially' => 0,
			];
			foreach ($billingcycleArr as $key => $value) {
				if(!isset($pricing[$key]) || $pricing[$key]<0){
					unset($billingcycleArr[$key]);
				}
			}
			$setupfeeArr = [
				'monthly' => 'msetupfee',
				'quarterly' => 'qsetupfee',
				'semiannually' => 'ssetupfee',
				'annually' => 'asetupfee',
				'biennially' => 'bsetupfee',
				'triennially' => 'tsetupfee',
			];
			foreach ($billingcycleArr as $key => $value) {
				$setupfee = $setupfeeArr[$key];
				$price = 0;
				$price += $pricing[$key];
				$price += $pricing[$setupfee];
				$preview = [];
				foreach ($configurable as $k => $v) {
					$option = $params['configoptions'][$v['id']] ?? 0;
					if(empty($option)){
						continue;
					}
					if($v['optiontype']==4){
						$price += $v['options'][0][$key]*$option;
						$price += $v['options'][0][$setupfee]*$option;
					}else if($v['optiontype']==3 && $option=='1'){
						$price += $v['options'][0][$key];
						$price += $v['options'][0][$setupfee];
					}else if($v['optiontype']==1 || $v['optiontype']==2){
						foreach ($v['options'] as $kk => $vv) {
							if($option==$vv['id']){
								$price += $vv[$key];
								$price += $vv[$setupfee];
							}
						}
						
					}
				}
				$billingcycleArr[$key] = $price;
			}

			$resultMsg['status']=200;
			$resultMsg['msg']='获取周期价格成功';
			$resultMsg['data'] = ['price'=>$billingcycleArr];
		}else{
			$resultMsg['status']=400;
			$resultMsg['msg']="找不到当前产品id对应的产品";
		}
		return $resultMsg;
	}

	/**
	 * 作者: theworld
	 * 时间: 2023-03-10
	 * 产品配置项及配置项价格
	 * @params  string   $productid  产品ID
	 * @return array
	 */
	public function configOptions($params){		
		if(empty($params['productid'])) return ['status'=>400,'msg'=>'productid不能为空'];

		$product = _pdoSelect("tblproducts","id","id={$params['productid']}");
		if(!empty($product)){
			$pricing = _pdoSelect("tblpricing","msetupfee,qsetupfee,ssetupfee,asetupfee,bsetupfee,tsetupfee,monthly,quarterly,semiannually,annually,biennially,triennially","`type`='product' AND `currency`='1' AND relid ={$params['productid']}");
			$configurable = array();
			$options = _pdoQuery("SELECT co.*, cog.name AS group_name, cog.description AS group_description
										FROM tblproductconfigoptions AS co
										JOIN tblproductconfiggroups AS cog ON co.gid = cog.id
										JOIN tblproductconfiglinks AS col ON cog.id = col.gid
										WHERE col.pid = {$params['productid']}  AND co.hidden=0");
			//配置项价格
			$options_id=implode(",",array_column($options,"id"));
			if($options_id){
				$configoptionssub = _pdoQuery("
				SELECT cos.* , p.msetupfee, p.qsetupfee, p.ssetupfee, p.asetupfee, p.bsetupfee, p.tsetupfee, p.monthly, p.quarterly, p.semiannually, p.annually, p.biennially, p.triennially
				FROM tblproductconfigoptionssub AS cos
				JOIN tblpricing AS p ON type = 'configoptions' AND currency = 1 AND relid = cos.id
				WHERE cos.configid IN ({$options_id})  AND cos.hidden = 0
				ORDER BY cos.sortorder ASC, cos.id ASC");
				foreach($configoptionssub as $v){
					$configoptionssub2[$v['configid']][]=$v;
				}
			}
			foreach($options as $v){
				$opt=array();
				foreach($configoptionssub2[$v['id']] as $c){
					$ex = explode('|', $c['optionname']);
					$c['firstname'] = $ex[0];
					$c['lastname'] = isset($ex[1]) ? $ex[1] : $ex[0];
					$opt[] = $c;
				}
				$ops=array();
				foreach ($opt as $o){
					$ops[] = array(
						'id'	=> $o['id'],
						'optionname'	=> $o['optionname'],
						'firstname'		=> $o['firstname'],
						'lastname'		=> $o['lastname'],
						'currency'		=> 1,
						'msetupfee'		=> $o['msetupfee'],
						'qsetupfee'		=> $o['qsetupfee'],
						'ssetupfee'		=> $o['ssetupfee'],
						'asetupfee'		=> $o['asetupfee'],
						'bsetupfee'		=> $o['bsetupfee'],
						'tsetupfee'		=> $o['tsetupfee'],
						'monthly'		=> $o['monthly'],
						'quarterly'		=> $o['quarterly'],
						'semiannually'	=> $o['semiannually'],
						'annually'		=> $o['annually'],
						'biennially'	=> $o['biennially'],
						'triennially'	=> $o['triennially'],
					);
				}
				$key = explode('|', $v['optionname']);
				//$key = $key[0];
				$configurable[] = array(
					'id'	=> $v['id'],
					'optionname'	=> $v['optionname'],
					'firstname'		=> $key[0],
					'lastname'		=> isset($key[1]) ? $key[1] : $key[0],
					'optiontype'	=> $v['optiontype'],
					'qtyminimum'	=> $v['qtyminimum'],
					'qtymaximum'	=> $v['qtymaximum'],
					'options'		=> $ops
				);
			}
			$customfields = _pdoQuery("SELECT id,fieldname,fieldtype,description,fieldoptions,regexpr,required FROM tblcustomfields WHERE type='product' AND relid={$params['productid']} AND showorder='on' AND adminonly!='on'");
			if(!empty($configurable)){
				$resultMsg['status']=200;
				$resultMsg['msg']='获取配置选项成功';
				$resultMsg['data']= ['pricing'=>$pricing, 'configoption' => $configurable, 'customfield' => $customfields];
			}else{
				$resultMsg['status']=400;
				$resultMsg['msg']='当前产品配置选项为空';
			}
		}else{
			$resultMsg['status']=400;
			$resultMsg['msg']="找不到当前产品id对应的产品";
		}
		return $resultMsg;
	}
	
	/**
	 * 作者: theworld
	 * 时间: 2023-03-10
	 * 产品配置项及配置项价格
	 * @params  string   $productid  产品ID
	 * @return array
	 */
	public function minPrice($params){		
		if(empty($params['productid'])) return ['status'=>400,'msg'=>'productid不能为空'];

		$product = _pdoSelect("tblproducts","id","id={$params['productid']}");
		if(!empty($product)){
			$pricing = _pdoSelect("tblpricing","msetupfee,qsetupfee,ssetupfee,asetupfee,bsetupfee,tsetupfee,monthly,quarterly,semiannually,annually,biennially,triennially","`type`='product' AND `currency`='1' AND relid ={$params['productid']}");
			$billingcycleArr = [
				'monthly' => 0,
				'quarterly' => 0,
				'semiannually' => 0,
				'annually' => 0,
				'biennially' => 0,
				'triennially' => 0,
			];
			foreach ($billingcycleArr as $key => $value) {
				if(!isset($pricing[$key]) || $pricing[$key]<0){
					unset($billingcycleArr[$key]);
				}
			}
			$setupfeeArr = [
				'monthly' => 'msetupfee',
				'quarterly' => 'qsetupfee',
				'semiannually' => 'ssetupfee',
				'annually' => 'asetupfee',
				'biennially' => 'bsetupfee',
				'triennially' => 'tsetupfee',
			];
			$configurable = array();
			$options = _pdoQuery("SELECT co.*, cog.name AS group_name, cog.description AS group_description
										FROM tblproductconfigoptions AS co
										JOIN tblproductconfiggroups AS cog ON co.gid = cog.id
										JOIN tblproductconfiglinks AS col ON cog.id = col.gid
										WHERE col.pid = {$params['productid']}  AND co.hidden=0");
			//配置项价格
			$options_id=implode(",",array_column($options,"id"));
			if($options_id){
				$configoptionssub = _pdoQuery("
				SELECT cos.* , p.msetupfee, p.qsetupfee, p.ssetupfee, p.asetupfee, p.bsetupfee, p.tsetupfee, p.monthly, p.quarterly, p.semiannually, p.annually, p.biennially, p.triennially
				FROM tblproductconfigoptionssub AS cos
				JOIN tblpricing AS p ON type = 'configoptions' AND currency = 1 AND relid = cos.id
				WHERE cos.configid IN ({$options_id})  AND cos.hidden = 0
				ORDER BY cos.sortorder ASC, cos.id ASC");
				foreach($configoptionssub as $v){
					$configoptionssub2[$v['configid']][]=$v;
				}
			}
			foreach($options as $v){
				$opt=array();
				foreach($configoptionssub2[$v['id']] as $c){
					$ex = explode('|', $c['optionname']);
					$c['firstname'] = $ex[0];
					$c['lastname'] = isset($ex[1]) ? $ex[1] : $ex[0];
					$opt[] = $c;
				}
				$ops=array();
				foreach ($opt as $o){
					$ops[] = array(
						'id'	=> $o['id'],
						'optionname'	=> $o['optionname'],
						'firstname'		=> $o['firstname'],
						'lastname'		=> $o['lastname'],
						'currency'		=> 1,
						'msetupfee'		=> $o['msetupfee'],
						'qsetupfee'		=> $o['qsetupfee'],
						'ssetupfee'		=> $o['ssetupfee'],
						'asetupfee'		=> $o['asetupfee'],
						'bsetupfee'		=> $o['bsetupfee'],
						'tsetupfee'		=> $o['tsetupfee'],
						'monthly'		=> $o['monthly'],
						'quarterly'		=> $o['quarterly'],
						'semiannually'	=> $o['semiannually'],
						'annually'		=> $o['annually'],
						'biennially'	=> $o['biennially'],
						'triennially'	=> $o['triennially'],
					);
				}
				$key = explode('|', $v['optionname']);
				//$key = $key[0];
				$configurable[] = array(
					'id'	=> $v['id'],
					'optionname'	=> $v['optionname'],
					'firstname'		=> $key[0],
					'lastname'		=> isset($key[1]) ? $key[1] : $key[0],
					'optiontype'	=> $v['optiontype'],
					'qtyminimum'	=> $v['qtyminimum'],
					'qtymaximum'	=> $v['qtymaximum'],
					'options'		=> $ops
				);
			}
			foreach ($billingcycleArr as $key => $value) {
				$setupfee = $setupfeeArr[$key];
				$price = 0;
				$price += $pricing[$key];
				$price += $pricing[$setupfee];
				foreach ($configurable as $k => $v) {
					if($v['optiontype']==4){
						$price += $v['options'][0][$key]*$v['qtyminimum'];
						$price += $v['options'][0][$setupfee]*$v['qtyminimum'];
					}else if($v['optiontype']==1 || $v['optiontype']==2){
						$price += min(array_column($v['options'], $key));
						$price += min(array_column($v['options'], $setupfee));
					}
				}
				$billingcycleArr[$key] = $price;
			}
			
			$price = 0;
			$cycle = '';

			$localCycle = [
		        'monthly' => '月',
		        'quarterly' => '季度',
		        'semiannually' => '半年',
		        'annually' => '年',
		        'biennially' => '两年',
		        'triennially' => '三年',
		    ];
			foreach ($billingcycleArr as $key => $value) {
				$cycle = $localCycle[$key] ?? '';
				$price = $value;
				break;
 			}
			return ['price' => $price, 'cycle' => $cycle];
		}else{
			$resultMsg['status']=400;
			$resultMsg['msg']="找不到当前产品id对应的产品";
		}
		return $resultMsg;
	}
}
