<?php
/**
*商铺公众号
*/
class gzhAction extends baseAction
{
	/**
	  * @method 商城品牌目录的配件
	  * @http	get
	  * @param  type               string [选填] 默认：all  号码：number  
	  * @param  shopid              string [必填] 店铺ID
	  * @param  brand_id            int [必填] 车型品牌ID
	  * @param  mod1_id             int [必填] 一级车型ID
	  * @param  mod2_id             int [选填] 二级车型ID
	  * @param  mod3_drive          string [选填] 驱动方式
	  * @param  mod3_cc_name         string  [选填] 排量
	  * @param  mod3_cc              int [选填] 排量cc
	  * @param  mod3_kw              int [选填] 功率kw
	  * @param  mod3_engine          string [选填] 发动机
	  * @param  cctran              string [选填] 排量+驱动方式
	  * @param  keyword               string [选填] 关键字
	  * @param  uid                int [选填] 用户ID
	  * @param  page           int [选填] 第几页 默认 1
	  * @param  per            int [选填] 每页数量 默认 20
	  * @author soul
	  * @copyright 2019/5/27
	  * @return {"status":true,"data":[{"pro_id":"177598","prb_name":"ABC","pro_status":"1","pro_name":"\u524d\u5239\u8f66\u76d8","pro_shop_id":"149894","pro_sale_price":"0.00","pro_count":"1","pro_user_discount":"N","pro_sold_count":"0","pri_code":"123456","pri_weight":null,"pri_frt_id":null,"pro_sel_des":null,"pri_invoice":"0","pri_warranty":"0","pri_return_promise":"1","pro_spart_id":"2996_4962","price":"0.00","price_type":1,"pro_price":{"title":"\u9500\u552e\u4ef7","price":"0.00"},"pic":[],"num":[{"factory":"ABC","display":"123456"},{"factory":"OE","display":"A0004212512"}],"mod3_para":"\u8f66\u67b6\u53f7\u5c3e\u53f7\u81f3:L365777"}],"code":0}
	  */
	public function getGzhItem()
	{
		$Params = mvc::$URL_PARAMS;
		$arr = [];
		$shopid = (int) $Params['shopid'];
		$Params['type'] = !empty($Params['type']) && $Params['type'] == 'number'? 'number': 'all';
		if($shopid > 0)
		{
			$B2cSearch = new B2cSearch();
			$res = $B2cSearch->searchGzhItem($shopid, $Params, $Params['per']);
			if(!empty($res['data']['proIds']))
			{
				$B2cProduct = new B2cProduct();
				$res = $B2cProduct->getSuperProductInfo($res['data']['proIds'], $Params['uid'], ['numMain', 'picMain','para'], $Params['mod3_id']);
				$arr = $res['data'];
			}
		}
		LibFc::ReturnJson(true, array_values($arr));
	}


	/**
	  * @method  商城商铺的配件详情
	  * @http  get
	  * @param  proId 产品ID
	  * @author soul 
	  * @copyright 2019/7/22
	  * @return json
			{"status":true,"data":{"pro_id":"122142","prb_name":"FREY","pro_shop_id":"149894","pro_spart_id":"4021_4960","pro_name":"前刹车片","pic":["http:\/\/192.168.1.42\/file_center\/center\/read.php?site=b2c&c=product&f=shop224467\/product\/400\/29c5f7cdd4f74442.jpg&i=42","http:\/\/192.168.1.42\/file_center\/center\/read.php?site=b2c&c=product&f=shop224467\/product\/400\/0f8ae96244c842a1.jpg&i=42","http:\/\/192.168.1.42\/file_center\/center\/read.php?site=b2c&c=product&f=shop224467\/product\/400\/12b5edd2afba0c42.jpg&i=42","http:\/\/192.168.1.42\/file_center\/center\/read.php?site=b2c&c=product&f=shop224467\/product\/400\/f5279863c86ab499.jpg&i=42"],"num":[{"factory":"FREY","display":"845522201"},{"factory":"OE","display":"34116769763"}],"para":[{"name":"制动系统","val":"1","unit":""},{"name":"宽度","val":"2","unit":"mm"},{"name":"高度","val":"5","unit":"mm"}],"models":{"ypc":{"brand_id":"63","brand_etk_id":"2","mod3_id":"4142"}},"nums":{"oe":[{"oe":1,"factory":"OE","display":"34116769763"}],"ref":[{"oe":0,"factory":"FREY","display":"845522201"}]},"brand_id_ypc":"63"},"code":null,"encry":0,"runtime":730}
	  */
	public function getGzhItemDes()
	{
		$Params = mvc::$URL_PARAMS;
		$proArr = [];
		$proId = (int) $_GET['proId'];
		$mod3Id = empty($_GET['mod3Id']) ? (int) $_GET['mod3_id']: (int) $_GET['mod3Id'];
		$B2cProduct = new B2cProduct();
		$res = $B2cProduct->getSuperProductInfo([$proId], $Params['uid'], ['desc', 'para', 'numMain', 'picAll'], $mod3Id);
		if(!empty($res['data']))
		{
			$proArr = $res['data'][$proId];
			$res = $B2cProduct->get('bc_product_model3_link', ['distinct pml3_mod3_id'], sprintf(" and pml3_pro_id =%d", $proId));
			$proArr['models'] = array_column($res['data'], 'pml3_mod3_id');
		}
		LibFc::ReturnJson(true, $proArr);
	}
}