public function accessory() { $this->commonProcess(); //check inventory availability $map["isAvailable"] = array('NEQ', "0"); //get item list and paging $itemList = D('Item')->distinct(true)->field('t_item.*, img.image, price.price')->where($map)->join('t_image img ON img.itemId = t_item.itemId AND img.sequence = (SELECT MIN(sequence) FROM t_image WHERE itemId = img.itemId )')->join("t_itemprice price ON price.itemId = t_item.itemId and price.price = (select min(price) from t_itemprice where currency = '" . $this->getCurrency() . "' and itemId = t_item.itemId)")->join("t_category cat ON cat.categoryId = t_item.categoryId and cat.type ='3'")->order('t_item.lastUpdatedDate desc')->page($p . ',18')->select(); $count = D('Item')->field('t_item.*, img.image, price.price')->where($map)->join('t_image img ON img.itemId = t_item.itemId AND img.sequence = (SELECT MIN(sequence) FROM t_image WHERE itemId = img.itemId )')->join("t_itemprice price ON price.itemId = t_item.itemId and price.price = (select min(price) from t_itemprice where currency = '" . $this->getCurrency() . "' and itemId = t_item.itemId)")->join("t_category cat ON cat.categoryId = t_item.categoryId and cat.type ='3'")->order('t_item.lastUpdatedDate desc')->count('distinct t_item.itemId'); //age list for each item for ($i = 0; $i < count($itemList); $i++) { $ageMap["t_inventory.itemId"] = array('EQ', $itemList[$i]["itemId"]); $itemList[$i]["ageList"] = D('Inventory')->field('distinct t_inventory.age')->where($ageMap)->select(); for ($j = 0; $j < count($itemList[$i]["ageList"]); $j++) { $itemList[$i]["ageList"][$j]["age"] = getSizeDescriptionByAge($itemList[$i]["ageList"][$j]["age"]); } } $Page = new \Think\Page($count, 18); $show = $Page->show(); //pageing $this->assign('page', $show); $this->assign('itemList', $itemList); //show item list page $this->display('accessory'); }
function getSizeDescription($size) { if ($size['age'] != '') { //如果是非鞋类商品,按照年龄计算描述 return getSizeDescriptionByAge($size['age']); } else { //鞋类商品 return $size['footSize'] . '码'; } }