Item.php 56.7 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373
<?php
namespace Product;
use LibModels\Web\Product\ItemData;
use WebPlugin\Helpers;
use WebPlugin\Images;
use LibModels\Web\Product\SearchData;
use LibModels\Web\Product\FavoriteData;
use Api\Yohobuy;
use WebPlugin\Cache;
use Configs\WebCacheConfig;
use Configs\ChannelConfig;
use LibModels\Web\Product\BrandData;
use Product\BrandsModel;
class ItemModel
{
    /**
     * 多次并发请求资源
     * @var array
     */
    private static $multiResources = array();

    /**
     * 获取商品信息
     *
     * @param string $productId
     * @param string $goodsId
     * @param string $uid
     * @param int $vipLevel
     * @param string $productSkn
     * @return array
     */
    public static function getProductInfo($productId, $goodsId, $uid, $vipLevel = 0, $productSkn = null)
    {
        $goodsInfo = array();
        $statGoodsInfo = array();
        $banner = array();
        $baseInfo = ItemData::baseInfo($productId, $uid, $productSkn);
        if(empty($baseInfo['productName']) && empty($baseInfo['erpProductId']) && empty($baseInfo['productPriceBo'])) {
            return array();
        }
        $baseInfo['uid'] = $uid;
        $productId = $baseInfo['id'];
        $goodsInfo['name'] = $baseInfo['productName'];
        $goodsInfo['skn'] = $baseInfo['erpProductId'];
        $goodsInfo['productId'] = $productId;
        $goodsInfo['maxSortId'] = $baseInfo['maxSortId'];
        $goodsInfo['smallSortId'] = $baseInfo['smallSortId'];
        $goodsInfo['promotionId'] = $baseInfo['isPromotion'];
        $goodsInfo['goCartUrl'] = Helpers::url('/shopping/cart');
        $brandId = 0;
        //设置并发请求数据
        self::setMultiResourceByProductBaseInfo($baseInfo);
        if(isset($baseInfo['brand']['id'])) {
            $brandId = $baseInfo['brand']['id'];
        }
        //收藏喜欢
        $favoriteData = self::getProductFavoriteData($uid, $productId, $brandId);

        // 商品标签
        $goodsInfo['tags'] = self::getTagsDataByProductInfo($baseInfo);

        // 商品促销短语
        if (!empty($baseInfo['salesPhrase'])) {
            $goodsInfo['saleTip'] = $baseInfo['salesPhrase'];
        }

        // 商品价格
        if (isset($baseInfo['productPriceBo'])) {
            $goodsInfo['marketPrice'] = $baseInfo['productPriceBo']['formatMarketPrice'];
            $goodsInfo['hasOtherPrice'] = true;//非市场价格
            $goodsInfo['salePrice'] = $baseInfo['productPriceBo']['formatSalesPrice'];
            if($goodsInfo['marketPrice'] == $goodsInfo['salePrice']) {//价格相同,只显示市场价格
                unset($goodsInfo['salePrice']);
                $goodsInfo['hasOtherPrice'] = false;
            }
        }

        //VIP数据
        $goodsInfo['vipPrice'] = self::getVipDataByProductBaseInfo($baseInfo, $vipLevel, $uid);
        //促销活动banner
        $goodsInfo['activity'] = self::getActivityDataByProductBaseInfo($baseInfo);

        if (isset($baseInfo['productPriceBo']['yohoCoinNum']) && $baseInfo['productPriceBo']['yohoCoinNum'] !== 0) {
            array_push($goodsInfo['activity'],
                array('type' => '返YOHO币', 'des' => '每件返 ' . $baseInfo['productPriceBo']['yohoCoinNum'] . '个 YOHO币')
            );
        }

        // 上市期
        if (isset($baseInfo['expectArrivalTime']) && !empty($baseInfo['expectArrivalTime'])) {
            $goodsInfo['arrivalDate'] = $baseInfo['expectArrivalTime'] . '月';
            $goodsInfo['presalePrice'] = $baseInfo['productPriceBo']['formatSalesPrice'];
            unset($goodsInfo['salePrice']);
            $goodsInfo['hasOtherPrice'] = false;
        }

        //商品咨询和评论数据
        $consultComment = self::getConsultCommentDataByProductInfo($baseInfo);
        // 品牌信息
        if (!empty($baseInfo['brand'])) {
            $goodsInfo['brandImg'] =  Helpers::getImageUrl($baseInfo['brand']['brandIco'], 47, 47);
            $goodsInfo['brandName'] = $baseInfo['brand']['brandName'];
            $goodsInfo['brandUrl'] = Helpers::url('', array(), $baseInfo['brand']['brandDomain']);
            $banner = self::getBrandDataByProductBaseInfo($baseInfo);
            if(isset($banner['isCollect']) && isset($favoriteData['brand'])) {
                $banner['isCollect'] = $favoriteData['brand'];
            }
        }

        //sku商品信息
        $skuData = self::getSkuDataByProductBaseInfo($baseInfo);
        $goodsInfo['img'] = $skuData['defaultImage'];
        $goodsInfo['colors'] = $skuData['skuGoods'];
        $totalStorageNum = $skuData['totalStorageNum'];

        // 是否收藏
        $goodsInfo['isCollect'] = $favoriteData['product'];
        // 限购商品
        if ($baseInfo['isLimitBuy'] === 'Y') {
            // 是否开售
            $isBeginSale = (isset($baseInfo['saleStatus']) && $baseInfo['saleStatus'] == 1);
            // 限购商品有关的展示状态
            $showStatus = 1;
            if (isset($baseInfo['showStatus'])) {
                $showStatus = intval($baseInfo['showStatus']);
            }

            $fashTopGoods = self::getFashionTopGoodsStatus($uid, $showStatus, $isBeginSale);
            //潮流尖货状态
            $goodsInfo['fashionTopGoods'] = array(
                        'getLimitedCode' => $fashTopGoods['getLimitedCode'],//限购码状态
                        'hasLimitedCode' => $fashTopGoods['hasLimitedCode'],//是否已经获取限购码
                        'limitedCodeSoldOut'=> $fashTopGoods['limitedCodeSoldOut'],//限购码是否已经抢光
                        'getLimitedCodeDis' => $fashTopGoods['getLimitedCodeDis'],//限购码是否失效
                     );
            if($fashTopGoods['soldOut']) {
                $goodsInfo['soldOut'] = $fashTopGoods['soldOut'];
                $totalStorageNum = 0;//改总数为已售磬
            } else {
                $goodsInfo['openSoon'] = $fashTopGoods['openSoon'];//即将开售
                $goodsInfo['dis'] = $fashTopGoods['dis'];//是否失效
                $goodsInfo['buyNow'] = $fashTopGoods['buyNow'];//是否立即购买
            }
        }

        $soldOut = $baseInfo['status'] == 0 || $totalStorageNum === 0;
        $notForSale = $baseInfo['attribute'] == 2;//非卖品
        $virtualGoods = $baseInfo['attribute'] == 3;//虚拟商品
        if (!$soldOut && !$notForSale && !$virtualGoods) {
             $goodsInfo['addToCart'] = true;
           //立即购买或者即将开售存在
            if((isset($goodsInfo['buyNow']) && $goodsInfo['buyNow'])  ||
               (isset($goodsInfo['openSoon']) && $goodsInfo['openSoon'])) {
                unset($goodsInfo['addToCart']);
            }
        }// 非卖品
        elseif ($notForSale) {
            $goodsInfo['notForSale'] = true;
        }
        // 已售磬
        elseif ($soldOut) {
            $goodsInfo['soldOut'] = true;
            unset($goodsInfo['fashionTopGoods']);
        }
        //虚拟商品
        else if($virtualGoods) {
            $goodsInfo['buyNow'] = true;//是否立即购买
            $goodsInfo['buyNowBase'] = Helpers::url('/ticket', array(), 'shopping');
            $goodsInfo['virtualGoods'] = $virtualGoods;
            if(isset($goodsInfo['salePrice'])) {
                $goodsInfo['advancePrice'] = $goodsInfo['salePrice'];//先行价格
                unset($goodsInfo['salePrice']);
            }
        }
        //去掉即将售罄
        if(empty($totalStorageNum) || $soldOut) {
            if(isset($goodsInfo['tags']['isFew'])) {
                unset($goodsInfo['tags']['isFew']);//去掉即将售罄
            }
        }
        //分享相关
        $goodsInfo['weixinUrl'] = Helpers::url($_SERVER['REQUEST_URI'], array(),'item');
        $goodsInfo['sharedTitle'] = $goodsInfo['name'];
        $goodsInfo['shareImg'] = $goodsInfo['img'];
        $goodsInfo['shareDesc'] = $baseInfo['phrase'];

        //统计需要的商品信息
        $statGoodsInfo['uid'] = $uid;
        $statGoodsInfo['skn'] = $baseInfo['erpProductId'];
        $statGoodsInfo['productId'] = $productId;
        $statGoodsInfo['productName'] = str_replace("'", "’",$goodsInfo['name']);
        $statGoodsInfo['brandName'] = empty($goodsInfo['brandName'])? '' : str_replace("'", "’", $goodsInfo['brandName']);
        $statGoodsInfo['marketPrice'] = str_replace('¥', '', $goodsInfo['marketPrice']);
        if(isset($goodsInfo['salePrice'])) {
            $statGoodsInfo['salePrice'] = str_replace('¥', '', $goodsInfo['salePrice']);
        } else {
            $statGoodsInfo['salePrice'] = str_replace('¥', '', $goodsInfo['marketPrice']);
        }

        if (!empty($banner['brandId'])) {
            $domainBrand = BrandsModel::getBrandByDomain($banner['brandDomain']);
            if (!empty($domainBrand['type'])) {
                switch (intval($domainBrand['type'])) {
                    case 1:
                        //多品店不显示
                        $banner = array();
                        break;
                    case 2:
                        if (empty($domainBrand['shopId'])) {
                            break;
                        }
                        //单品店显示新版的店铺banner
                        $basisData = ShopModel::basisTemplate($domainBrand['shopId']);
                        $banner['bgImg'] = empty($basisData['shopTopBanner_base']['detailSrc']) ?
                            $banner['bgImg'] : $basisData['shopTopBanner_base']['detailSrc'];
                        break;
                }
            }
        }

        $statGoodsInfo['imageUrl'] = $goodsInfo['img'];
        $statGoodsInfo['productUrl'] = $goodsInfo['weixinUrl'];
        $statGoodsInfo['smallSortId'] = $goodsInfo['smallSortId'];
        $statGoodsInfo['soldOut'] = intval($soldOut);
        return array('goodsInfo'=> $goodsInfo,'consultComment' => $consultComment, 'banner'=> $banner,'statGoodsInfo' => $statGoodsInfo);
    }

    /**
     * 商品尺码信息
     *
     * @param string $productSkn
     * @param int $maxSortId
     * @return array
     */
    public static function getSizeInfo($productSkn, $maxSortId)
    {
        if (is_numeric($productSkn)) {
            //并发资源中是否存在数据
            $sizeInfo = self::getMultiDataByResourceName('ItemData::sizeInfo');
            if(empty($sizeInfo)) {
                //获取尺码
                $sizeInfo = ItemData::sizeInfo($productSkn);
            }
            if(empty($sizeInfo)) {
                return array();
            }
            $productId = $sizeInfo['productBo']['id'];
            //描述数据
            $description = self::getDescriptionDataBySizeInfo($sizeInfo);
            //尺寸数据
            $size = self::getSizeDataBySizeInfo($sizeInfo);
            //模特卡
            $modelCards = self::getProductModelCard($productId);
            //模特数据
            $reference = self::getReferenceDataBySizeInfo($sizeInfo);
            //洗涤材质
            $material = self::getMaterialDataBySizeInfo($sizeInfo);
            //商品详情页介绍
            $details = self::getDetailDataBySizeInfo($sizeInfo);
            //试穿模特
            $fittingReport = self::getProductModelTry($productSkn);
            //获取尺寸说明
            $sizeAttr = array();
            if(!empty($sizeInfo['sizeInfoBo'])) {
                //根据最大分类ID获取尺寸属性
                $sizeAttr = self::getSizeAttrByMaxSortId($maxSortId, $sizeInfo['sizeInfoBo']);
            }
            return array('material'=> $material, 'size'=> $size, 'reference'=> $reference,
                'modelCards'=> $modelCards,'details'=> $details,'fittingReport' =>$fittingReport,
                'description'=> $description,'sizeTitleJson' => json_encode($sizeAttr));
        }
        else {
            return array();
        }

    }

    /**
     * 获取购物车商品信息
     *
     * @param int $productId
     * @param int $uid
     * @param int $vipLevel
     * @return array
     */
    public static function getCartProductInfo($productId, $uid, $vipLevel)
    {
        $goodsInfo = array();
        $size = array();
        $baseInfo = ItemData::baseInfo($productId, $uid);
        if(!empty($baseInfo)) {
            if(empty($baseInfo['productName']) && empty($baseInfo['erpProductId']) && empty($baseInfo['productPriceBo'])) {
                return array();
            }
            $goodsInfo['name'] = $baseInfo['productName'];
            $goodsInfo['skn'] = $baseInfo['erpProductId'];
            $goodsInfo['productId'] = $productId;
            // 商品促销短语
            if (!empty($baseInfo['salesPhrase'])) {
                $goodsInfo['saleTip'] = $baseInfo['salesPhrase'];
            }

            // 商品价格
            if (isset($baseInfo['productPriceBo'])) {
                $goodsInfo['marketPrice'] = Helpers::transPrice($baseInfo['productPriceBo']['marketPrice']);
                $goodsInfo['salePrice'] = Helpers::transPrice($baseInfo['productPriceBo']['salesPrice']);
                $goodsInfo['hasOtherPrice'] = true;//非市场价格
                if($goodsInfo['marketPrice'] == $goodsInfo['salePrice']) {//价格相同,只显示市场价格
                    unset($goodsInfo['salePrice']);
                    $goodsInfo['hasOtherPrice'] = false;
                }
            }

            // 上市期
            if (isset($baseInfo['expectArrivalTime']) && !empty($baseInfo['expectArrivalTime'])) {
                $goodsInfo['arrivalDate'] = $baseInfo['expectArrivalTime'] . '月';
                $goodsInfo['presalePrice'] = Helpers::transPrice($baseInfo['productPriceBo']['salesPrice']);
                unset($goodsInfo['salePrice']);
                $goodsInfo['hasOtherPrice'] = false;
            }

            //VIP数据
            $goodsInfo['vipPrice'] = self::getVipDataByProductBaseInfo($baseInfo, $vipLevel);
            //sku商品信息
            $skuData = self::getSkuDataByProductBaseInfo($baseInfo);
            $totalStorageNum = $skuData['totalStorageNum'];

            $goodsInfo['img'] = $skuData['defaultImage'];
            $goodsInfo['colors'] = $skuData['skuGoods'];
            $favoriteData = FavoriteData::getUidProductFav($uid, $productId);
            $goodsInfo['isCollect'] = $favoriteData['code'] == 200 && $favoriteData['data'] ? true:false;
            $sizeInfo = ItemData::sizeInfo($baseInfo['erpProductId']);
            if(!empty($sizeInfo)) {
                $size = self::getSizeDataBySizeInfo($sizeInfo);
                $goodsInfo['size'] = $size;
            }

            // 限购商品
            if ($baseInfo['isLimitBuy'] === 'Y') {
                // 是否开售
                $isBeginSale = (isset($baseInfo['saleStatus']) && $baseInfo['saleStatus'] == 1);
                // 限购商品有关的展示状态
                $showStatus = 1;
                if (isset($baseInfo['showStatus'])) {
                    $showStatus = intval($baseInfo['showStatus']);
                }

                $fashTopGoods = self::getFashionTopGoodsStatus($uid, $showStatus, $isBeginSale);
                //潮流尖货状态
                $goodsInfo['fashionTopGoods'] = array(
                    'getLimitedCode' => $fashTopGoods['getLimitedCode'],//限购码状态
                    'hasLimitedCode' => $fashTopGoods['hasLimitedCode'],//是否已经获取限购码
                    'limitedCodeSoldOut'=> $fashTopGoods['limitedCodeSoldOut'],//限购码是否已经抢光
                    'getLimitedCodeDis' => $fashTopGoods['getLimitedCodeDis'],//限购码是否失效
                );
                if($fashTopGoods['soldOut']) {
                    $goodsInfo['soldOut'] = $fashTopGoods['soldOut'];
                    $totalStorageNum = 0;//改总数为已售磬
                } else {
                    $goodsInfo['openSoon'] = $fashTopGoods['openSoon'];//即将开售
                    $goodsInfo['dis'] = $fashTopGoods['dis'];//是否失效
                    $goodsInfo['buyNow'] = $fashTopGoods['buyNow'];//是否立即购买
                }
            }

            //商品状态
            $soldOut = $baseInfo['status'] == 0 || $totalStorageNum === 0;
            $notForSale = $baseInfo['attribute'] == 2;//非卖品
            $virtualGoods = $baseInfo['attribute'] == 3;//虚拟商品
            if (!$soldOut && !$notForSale && !$virtualGoods) {
                $goodsInfo['addToCart'] = true;
                //立即购买或者即将开售存在
                if((isset($goodsInfo['buyNow']) && $goodsInfo['buyNow'])  ||
                    (isset($goodsInfo['openSoon']) && $goodsInfo['openSoon'])) {
                        unset($goodsInfo['addToCart']);
                    }
            }// 非卖品
            elseif ($notForSale) {
                //$goodsInfo['notForSale'] = true;
                $goodsInfo['addToCart'] = true;//赠品
            }
            // 已售磬
            elseif ($soldOut) {
                $goodsInfo['soldOut'] = true;
            }
            else if($virtualGoods) {
                $goodsInfo['buyNow'] = true;//是否立即购买
                $goodsInfo['buyNowBase'] = Helpers::url('/ticket', array(), 'shopping');
                $goodsInfo['virtualGoods'] = $virtualGoods;
                if(isset($goodsInfo['salePrice'])) {
                    $goodsInfo['advancePrice'] = $goodsInfo['salePrice'];//先行价格
                    unset($goodsInfo['salePrice']);
                }
            }

        }
        return $goodsInfo;
    }

    /**
     * 获取分类导航列表
     *
     * @param string $smallSortId
     * @return array
     */
    public static function getSortNav($smallSortId)
    {
        $key = WebCacheConfig::KEY_WEB_ITEM_SORT_DATA.'_'.$smallSortId;
        $navs = Cache::get($key);
        if(empty($navs)) {
            $data = SearchData::getSortByCondition(array('sort'=> $smallSortId));
            if(!empty($data['data'])) {
                $sort = current($data['data']['sort']);
                //一级分类
                $navs[] = array('href' => Helpers::url('', array('msort'=> $sort['sort_id'],
                    'gender' => Helpers::getGenderByCookie()),'list'), 'name' => $sort['sort_name'],'pathTitle' => $sort['sort_name']);
                if(!empty($sort['sub'])) {//二级分类
                    $subSort = current($sort['sub']);
                    $navs[] = array('href' => Helpers::url('', array('msort'=> $sort['sort_id'],'misort'=>$subSort['sort_id'],
                        'gender' => Helpers::getGenderByCookie()),'list'), 'name' => $subSort['sort_name'], 'pathTitle' => $subSort['sort_name']);
                }
                Cache::set($key, $navs);
            }
        }
        if (empty($navs) || !is_array($navs)) {
            return array();
        }
        return $navs;
    }

    /**
     * 获取咨询列表
     *
     * @param int $uid
     * @param int $productId
     * @param int $pageNum
     * @param int $pageSize
     * @return array
     */
    public static function getConsults($uid, $productId, $pageNum = 1, $pageSize = 30)
    {
        $result = array();
        if (is_numeric($productId) && is_numeric($pageNum) && is_numeric($pageSize)) {
            $consultList = ItemData::consultList($uid, $productId, $pageNum, $pageSize);
            if (isset($consultList['code']) && $consultList['code'] === 200) {
                $build = array();
                foreach ($consultList['data']['list'] as $value) {
                    $build['avatar'] = ChannelConfig::$itemHeadDefaultImgIco;
                    $build['question'] = $value['ask'];
                    $build['date'] = $value['ask_time'];
                    $build['answer'] = $value['answer'];
                    $build['id'] = $value['id'];
                    $build['isLike'] = $value['is_like'] === 'Y';
                    $build['like'] = intval($value['like']);
                    $build['isUseful'] = $value['is_useful'] === 'Y';
                    $build['useful'] = intval($value['useful']);
                    $build['total']= $value['total'];
                    $result[] = $build;
                }
            }
        }
        return $result;
    }

    /**
     * 获取评论
     *
     * @param int $productId
     * @param int $pageNum
     * @param int $pageSize
     * @return array
     */
    public static function getComments($productId, $pageNum = 1, $pageSize = 10)
    {
        $result = array();
        if (is_numeric($productId) && is_numeric($pageNum) && is_numeric($pageSize)) {
            $commentList = ItemData::commentList($productId, $pageNum, $pageSize);
            if (isset($commentList['code']) && $commentList['code'] === 200) {
                $build = array();
                foreach ($commentList['data'] as $value) {
                    $headIco = ChannelConfig::$itemHeadDefaultImgIco;
                    if(!empty($value['head_ico'])) {
                        if(preg_match('@http://@', $value['head_ico'])) {
                            $headIco = preg_replace('@http:\/\/img(.+)\.static\.yhbimg\.com\/headimg@', 'http://head.static.yhbimg.com/yhb-head/', $value['head_ico']);
                            $headIco = Images::getImageUrl($headIco, 30, 30);
                        }
                    }
                    $build['avatar'] = $headIco;
                    $build['userName'] = $value['nickname'];
                    $build['color'] = $value['color_name'];
                    $build['size'] = $value['size_name'];
                    $build['comment'] = isset($value['content']) ? $value['content'] : '';
                    $build['date'] = $value['create_time'];
                    $build['total'] = $value['total'];
                    $result[] = $build;
                }
            }
        }
        return  $result;
    }

    /**
     * 获取商品活动banner
     *
     * @param int $productId
     * @return array
     */
    public static function getProductActivityBanner($productId)
    {
        $result = array();
        $data = self::getMultiDataByResourceName('ItemData::getProductBanner');
        if(empty($data)) {
            $data = ItemData::getProductBanner($productId);
        }
        if(isset($data['code']) && $data['code'] == 200 && !empty($data['data']))
        {
            $result['activityImg'] = Images::getImageUrl($data['data']['bannerImg'], 260, 64);
            $result['url'] = $data['data']['promotionUrl'];
        }
        return $result;
    }

    /**
     * 获取商品热区
     *
     * @param string $productId
     * @return array
     */
    public static function getProductHotArea($productId)
    {
        $result = array();
        $data = ItemData::getProductHotArea($productId);
        if(isset($data['code']) && $data['code'] == 200) {
            if(!empty($data['data'])) {
                foreach ($data['data'] as $area) {
                    $temp = array();
                    $pos = 1;
                    if(isset($area['imageUrl'])) {
                        $temp['img'] = Images::getForceSourceUrl($area['imageUrl']);
                    }
                    foreach($area['infos'] as $val) {
                        if(isset($val['product'])) {
                            $point = array('label' => $pos++,'height' => $val['height'],
                                'left' => $val['left'],'top' => $val['top'],
                                'width'=> $val['width'],'product' => array());
                            if(!empty($val['product']['goodsList'])) {
                                $goods = current($val['product']['goodsList']);
                                //封面图
                                $point['img'] = Images::getImageUrl($goods['colorImage'], 60, 60);
                                //商品相关信息
                                $point['product'] = array(
                                    'salePrice' => $val['product']['productPriceBo']['formatSalesPrice'],
                                    'marketPrice' => $val['product']['productPriceBo']['formatMarketPrice'],
                                    'productName' => $val['product']['productName'],
                                    'href' => Helpers::getUrlBySkc($goods['goodsImagesList'][0]['productId'],
                                        $goods['goodsImagesList'][0]['goodsId'], $val['product']['cnAlphabet']),
                                );
                                $point['href'] = $point['product']['href'];
                            }
                        }
                        if(!empty($point)) {
                            $temp['list'][] = $point;
                        }
                    }
                    if(!empty($temp)) {
                        $result[] = $temp;
                    }
                }
            }
        }
        return $result;
    }

    /**
     * 获取商品模特卡
     *
     * @param string $productId
     * @return array
     */
    public static function getProductModelCard($productId)
    {
        $result = array();
        $data = self::getMultiDataByResourceName('ItemData::getProductModelCard');
        if(empty($data)) {
            $data = ItemData::getProductModelCard($productId);
        }
        if(isset($data['code']) && $data['code'] == 200) {
            foreach($data['data'] as $val) {
                $result[] = array(
                    'url' => Images::getForceSourceUrl($val['modelImg']),
                    'size' => $val['size'],
                    'name' => $val['modelName']
                );
            }
        }
        return $result;
    }

    /**
     * 添加咨询
     *
     * @param int $uid
     * @param int $productId
     * @param string $content
     * @return array
     */
    public static function addConsult($uid, $productId, $content)
    {
        return ItemData::addConsult($uid, $productId, $content);
    }

    /**
     * 获取商品的舒适度
     *
     * @param int $productId
     * @return array
     */
    public static function getProductComfort($productId)
    {
        $result = array();
        $comfort = self::getMultiDataByResourceName('ItemData::getProductComfort');
        if(empty($comfort)) {
            $comfort = ItemData::getProductComfort($productId);
        }
        if(!empty($comfort['data'])) {
            foreach($comfort['data'] as $val) {
                $blocks = array();
                $flag = false;
                for($i =1;$i<=5; $i++) {
                    if($i == $val['wearSense']['value']) {
                        $flag = true;
                        $blocks[] = array('cur' => true);
                    } else {
                        $blocks[] = array();
                    }
                }
                //存在,添加
                if($flag) {
                    $result[] = array(
                        'name' => $val['caption']['caption'],
                        'minDes'=> $val['caption']['low'],
                        'blocks'=> $blocks,
                        'maxDes'=>$val['caption']['high']
                    );
                }
            }
        }
        return $result;
    }

    /**
     * 获取商品的喜欢
     * @param int $uid
     * @param int $productId
     * @param int $brandId
     * @return array
     */
    public static function getProductFavoriteData($uid, $productId, $brandId)
    {
        $result = array('product' => false, 'brand' => false);
        if(!empty($uid)) {
            if(!empty($productId)) {
                $productData = self::getMultiDataByResourceName('FavoriteData::getUidProductFav');
                if(empty($productData)) {
                    $productData = FavoriteData::getUidProductFav($uid, $productId);
                }
                $result['product'] = $productData['code'] == 200 && $productData['data'] ? true : false;
            }
            if(!empty($brandId)) {
                $brandData = FavoriteData::isFavoriteBrand($uid, $brandId);
                $result['brand'] = isset($brandData['code']) && $brandData['code'] == 200 ? true : false;
            }
        }
        return $result;
    }

    /**
     * 根据商品信息设置并发请求
     *
     * @param array $productInfo
     */
    private static function setMultiResourceByProductBaseInfo(&$baseInfo)
    {
        $productId = $baseInfo['id'];
        $uid = isset($baseInfo['uid']) ? $baseInfo['uid'] : 0;
        $skn = $baseInfo['erpProductId'];
        $smallSortId = $baseInfo['smallSortId'];
        $brandId = isset($baseInfo['brand']['id']) ? $baseInfo['brand']['id'] : 0;
        $isOnlyUrl = true;
        //获取相关url
        $multiResourcesUrl['ItemData::getProductBanner'] = ItemData::getProductBanner($productId, 'web', $isOnlyUrl);
        $multiResourcesUrl['ItemData::sizeInfo'] = ItemData::sizeInfo($skn, $isOnlyUrl);
        $multiResourcesUrl['ItemData::getProductComfort'] = ItemData::getProductComfort($productId, $isOnlyUrl);
        $multiResourcesUrl['ItemData::getProductModelCard'] = ItemData::getProductModelCard($productId, $isOnlyUrl);
        $multiResourcesUrl['ItemData::getProductModelTry'] = ItemData::getProductModelTry($skn, $isOnlyUrl);
        $multiResourcesUrl['BrandData::getBannerInfo'] = BrandData::getBannerInfo($brandId, $isOnlyUrl);
        if(!empty($uid)) {
            $multiResourcesUrl['FavoriteData::getUidProductFav'] = FavoriteData::getUidProductFav($uid, $productId, $isOnlyUrl);
        }
        self::$multiResources = Yohobuy::getMulti($multiResourcesUrl, array(), false, 5, true);
    }

    /**
     * 根据资源名称获取并发数据
     *
     * @param string $resourceName
     * @return array
     */
    private static function getMultiDataByResourceName($resourceName)
    {
        if(isset(self::$multiResources[$resourceName])) {
            return self::$multiResources[$resourceName];
        } else {
            return false;
        }
    }

    /**
     * 根据最大分类ID获取尺寸属性
     *
     * @param string $maxSortId
     * @param array $sizeList
     * @return array
     */
    private static function getSizeAttrByMaxSortId($maxSortId, array $sizeList)
    {
        $attributeIds = array();
        //不同分类,取得属性值不同
        if ($maxSortId == 1 || $maxSortId == 2) {
            $attributeIds = array(3, 4);
        } elseif ($maxSortId == 3) {
            $attributeIds = array(6, 10);
        } elseif ($maxSortId == 6) {
            $attributeIds = array(13);
        }
        if (empty($attributeIds)) {
            return array();
        }
        $sizeInfos = array();
        $attributeNames = array();
        //获取属性名称
        foreach($sizeList['sizeAttributeBos'] as $size) {
            $attributeNames[$size['id']] = $size['attributeName'];
        }

        foreach($sizeList['sizeBoList'] as $size) {
            $sizeValues = array();
            foreach($size['sortAttributes'] as $sort) {
                if(in_array($sort['id'], $attributeIds)) {
                    if(!empty($sort['sizeValue'])) {
                        $sizeValues[] = $attributeNames[$sort['id']].' '.$sort['sizeValue'].'cm';
                    }
                }
            }
            //获取尺寸属性
            if(!empty($sizeValues)) {
                $sizeInfos[$size['sizeName']] = implode(' / ', $sizeValues);
            }
        }
        return $sizeInfos;
    }

    /**
     * 获取尺寸信息
     *
     * @param array $sizeInfo
     * @return array
     */
    private static function getSizeDataBySizeInfo(array &$sizeInfo)
    {
        $size = array();
        // 尺码信息
        if (!empty($sizeInfo['sizeInfoBo'])) {
            $sizeInfo['sizeInfoBo'] = self::sizeInfoBoSort($sizeInfo['sizeInfoBo']);
            /* 参考尺码 */
            $boyReference = !empty($sizeInfo['productExtra']['boyReference']);
            $girlReference = !empty($sizeInfo['productExtra']['girlReference']);
            $gender = isset($sizeInfo['productDescBo']['gender']) ? $sizeInfo['productDescBo']['gender'] : 3;
            $referenceName = '参考尺码';
            if (($gender == 1 && $boyReference) || ($gender == 2 && $girlReference)) {
                $referenceName = '参考尺码';
            } elseif ($gender == 3 && $boyReference) {
                $referenceName = '参考尺码(男)';
            } elseif ($gender == 3 && $girlReference) {
                $referenceName = '参考尺码(女)';
            }
            // 判断是否显示参考尺码
            $showReference = ($boyReference && !empty($sizeInfo['sizeInfoBo']['sizeBoList'][0]['boyReferSize'])) ||
            ($girlReference && !empty($sizeInfo['sizeInfoBo']['sizeBoList'][0]['girlReferSize']) );

            if (!empty($sizeInfo['sizeInfoBo']['sizeAttributeBos'])) {
                //尺码信息头部
                $size['thead'] = array(0 => array('name' => '吊牌尺码', 'id' => ''));
                //显示参考尺码
                if ($showReference) {
                    $size['thead'][1] = array('name' => $referenceName,'id' => '');
                }
                foreach ($sizeInfo['sizeInfoBo']['sizeAttributeBos'] as $attr) {
                    $size['thead'][] = array('name' => empty($attr['attributeName']) ? ' ' : $attr['attributeName'], 'id' => $attr['id']);
                }
                $sizes = array();
                foreach ($sizeInfo['sizeInfoBo']['sizeBoList'] as $value) {
                    //吊牌尺码
                    $sizes = array($value['sizeName']);
                    //判断是否显示参考尺码
                    if ($boyReference && ($gender == 1 || $gender == 3) && $showReference) {
                        $sizes[] =  empty($value['boyReferSize']['referenceName']) ? ' ' : $value['boyReferSize']['referenceName'];
                    } else if ($girlReference && ($gender == 2 || $gender == 3)  && $showReference) {
                        $sizes[] = empty($value['girlReferSize']['referenceName']) ? ' ' : $value['girlReferSize']['referenceName'];
                    } else {
                        if(isset($size['thead'][1]) && $showReference) {
                            $size['thead'][1] = array();
                        }
                    }
                    //其他尺码信息
                    foreach ($value['sortAttributes'] as $attr) {
                        $sizes[] = empty($attr['sizeValue']) ? ' ' : $attr['sizeValue'];
                    }
                    //尺码信息
                    $size['tbody'][] = $sizes;
                }
                //参考尺码为空
                if(isset($size['thead'][1]) && empty($size['thead'][1]) && $showReference) {
                    unset($size['thead'][1]);
                    $size['thead'] = array_values($size['thead']);
                }
            }
        }

        // 测量方式
        if (!empty($sizeInfo['sizeImage'])) {
            $size['sizeImg'] = $sizeInfo['sizeImage'];
        }
        return $size;
    }

    /**
     * 使sizeBoList id以 sizeAttributeBos id顺序一样
     * @param type array $sizeInfoBo
     * @return type []
     */
    private static function sizeInfoBoSort($sizeInfoBo)
    {
        if (empty($sizeInfoBo['sizeBoList']) || empty($sizeInfoBo['sizeAttributeBos'])) {
            return array();
        }

        foreach ($sizeInfoBo['sizeBoList'] as $sizek => $sizeBoList) {
            $sortArr = array();
            foreach ($sizeBoList['sortAttributes'] as $sortAttributes) {
                $sortArr[$sortAttributes['id']] = $sortAttributes;
            }
            $sizeInfoBo['sizeBoList'][$sizek]['sortAttributes'] = $sortArr;
        }

        foreach ($sizeInfoBo['sizeBoList'] as $sizek => $sizeBoList) {
            $sortArr = array();
            foreach ($sizeInfoBo['sizeAttributeBos'] as $val) {
                $sortArr[] = $sizeBoList['sortAttributes'][$val['id']];
            }
            $sizeInfoBo['sizeBoList'][$sizek]['sortAttributes'] = $sortArr;
        }

        return $sizeInfoBo;
    }

    /**
     * 获取模特数据
     *
     * @param array $sizeInfo
     * @return array
     */
    private static function getReferenceDataBySizeInfo(array &$sizeInfo)
    {
        $reference = array();
        if (!empty($sizeInfo['modelBos'])) {
            // 模特试穿, 竖着输出排列显示
            //模特信息
            $reference['tbody'] = array();
            $reference['thead'] = array(
                array('name' => ''), array('name' => '模特', 'modelCol'=> true),
                array('name' => '身高'),array('name' => '体重'),
                array('name' => '三围'),array('name' => '吊牌尺码'),
                array('name' => '试穿描述'),
            );
            //模特数据
            foreach($sizeInfo['modelBos'] as $value) {
                $modelValue = array(Images::getForceSourceUrl($value['avatar']),
                    $value['modelName'],$value['height'],$value['weight'],$value['vitalStatistics'],
                    $value['fitModelBo']['fit_size'],$value['fitModelBo']['feel']
                );
                //是否有备注
                if (!empty($value['fitModelBo']['fit_remark'])) {
                    $modelValue[] = $value['fitModelBo']['fit_remark'];
                    $reference['thead'][7] = array('name' => '备注','remarkCol' => true);
                }
                $reference['tbody'][] = $modelValue;
            }
        }
        return $reference;
    }

    /**
     * 获取洗涤材质
     *
     * @param array $sizeInfo
     * @return array
     */
    private static function getMaterialDataBySizeInfo(array &$sizeInfo)
    {
        $material = array();
        //洗涤提示
        if (!empty($sizeInfo['washTipsBoList'])) {
            $material['wash'] = array();
            foreach ($sizeInfo['washTipsBoList'] as $value) {
                $material['wash'][] = array('name' => $value['caption'],'img' => $value['img']);
            }
        }

        if (!empty($sizeInfo['productMaterialList'])) {
            //商品材质[洗涤说明]
            $material['materialDetail'] = array();
            foreach ($sizeInfo['productMaterialList'] as $value) {
                $material['materialDetail'][] = array(
                    'img' => $value['imageUrl'],
                    'name' => $value['caption'],
                    'enName' => $value['encaption'],
                    'text' => $value['remark']
                );
            }
        }
        return $material;
    }

    /**
     * 获取描述数据
     *
     * @param array $sizeInfo
     * @return array
     */
    private static function getDescriptionDataBySizeInfo(array &$sizeInfo)
    {
        $description = array();
        // 商品信息
        if (isset($sizeInfo['productDescBo']['erpProductId'])) {
            $sex = '通用';
            switch ($sizeInfo['productDescBo']['gender']) {
                case 1:
                    $sex = '男款';
                    break;
                case 2:
                    $sex = '女款';
                    break;
            }
            $description['basic'][] = array('key' =>'编号','value' => $sizeInfo['productDescBo']['erpProductId']);
            $description['basic'][] = array('key' =>'颜色','value' => $sizeInfo['productDescBo']['colorName'], 'dColor' => true);
            $description['basic'][] = array('key' =>'性别','value' => $sex);
            if (!empty($sizeInfo['productDescBo']['standardBos'])) {
                foreach ($sizeInfo['productDescBo']['standardBos'] as $value) {
                    $description['basic'][] = array('key' => $value['standardName'],  'value'=> $value['standardVal']);
                }
            }
            $description['comfort'] = self::getProductComfort($sizeInfo['productBo']['id']);
        }
        return $description;
    }

    /**
     * 获取商品详情页介绍
     *
     * @param array $sizeInfo
     * @return string
     */
    private static function getDetailDataBySizeInfo(array &$sizeInfo)
    {
        $details = '';
        // 详情配图
        if (isset($sizeInfo['productIntroBo']['productIntro'])) {
            if (!empty($sizeInfo['productDescBo']['phrase'])) {
                $details .= $sizeInfo['productDescBo']['phrase'] . '<br/>';
            }
            //$details .= $sizeInfo['productIntroBo']['productIntro'];
            // 图片换成懒加载方式
            $details .= strtr($sizeInfo['productIntroBo']['productIntro'], array(
                '<img src=' => "<img class=\"lazy\" src=\"data:image/gif;base64,R0lGODlhAQABAJEAAAAAAP///93d3f///yH5BAEAAAMALAAAAAABAAEAAAICVAEAOw==\" data-original=",
                '<img border="0" src=' => "<img border=\"0\" class=\"lazy\" src=\"data:image/gif;base64,R0lGODlhAQABAJEAAAAAAP///93d3f///yH5BAEAAAMALAAAAAABAAEAAAICVAEAOw==\" data-original=",
            ));
        }
        return $details;
    }

    /**
     * 获取sku商品数据
     *
     * @param array $baseInfo
     * @return array
     */
    private static function getSkuDataByProductBaseInfo(array &$baseInfo)
    {
        $totalStorageNum = 0;
        $skuGoods = array();//sku商品
        $defaultImage = '';//默认图
        $chooseSkuFlag = false;//选中sku状态
        if (!empty($baseInfo['goodsList'])) {
            $goodsGroup = array();
            foreach ($baseInfo['goodsList'] as $pos => $value) {

                // 如果status为0,即skc下架时就跳过该商品$value['status'] === 0
                if (empty($value['colorImage']) ) {
                    continue;
                }
                if (isset($value['goodsImagesList'])) {
                    //商品列表
                    $goodsGroup = array(
                        'productSkc' => $value['productSkc'],
                        'src' => Images::getImageUrl($value['colorImage'], 40, 40),
                        'title' => trim($baseInfo['productName']).' '.$value['colorName'],
                        'name' => $value['colorName'],
                        'focus'=> false,
                        'total' => 0,
                        'thumbs' => array(),
                        'size' => array(),
                    );

                    foreach ($value['goodsImagesList'] as $goods) {
                        if(!empty($goods['imageUrl'])) {
                            $goodsGroup['thumbs'][] = array(
                                'url' => '','shower' => Images::getImageUrl($goods['imageUrl'], 420, 560),
                                'img' => Images::getImageUrl($goods['imageUrl'], 75, 100),
                            );
                        }
                    }

                    //缩略图空,不显示
                    if(empty($goodsGroup['thumbs'])) {
                        continue;
                    }

                    //默认第一张图片
                    if($pos == 0)  {
                        $defaultImage = Images::getImageUrl($value['colorImage'], 420, 560);
                    }

                    //商品的尺码列表
                    foreach ($value['goodsSizeBoList'] as $size) {
                        if($baseInfo['attribute'] == 3 ) { //虚拟商品,增加为一件
                            $size['goodsSizeStorageNum'] = $size['goodsSizeStorageNum'] > 1 ? 1: 0;
                        }
                        //如果status为0,即skc下架时就跳过该商品
                        if ($value['status'] === 0) {
                           $size['goodsSizeStorageNum'] = 0;
                        }
                        $goodsGroup['size'][] = array(
                            'name' => $size['sizeName'],
                            'sku' => $size['goodsSizeSkuId'],
                            'num' => intval($size['goodsSizeStorageNum']),
                            'goodsId'=> $size['goodsId']
                        );
                        //单个sku商品的总数
                        $goodsGroup['total'] += intval($size['goodsSizeStorageNum']);

                        if($goodsGroup['total']> 0 && !$chooseSkuFlag) { //默认选中该sku商品
                            $goodsGroup['focus'] = true;
                            $chooseSkuFlag = true;//选中sku商品
                        }
                        $totalStorageNum += intval($size['goodsSizeStorageNum']);
                    }
                }
                $skuGoods[] = $goodsGroup;
            }
            if(!empty($skuGoods) && !$chooseSkuFlag) {//没有选中一个sku商品,默认选中第一个sku商品
                $skuGoods[0]['focus'] = true;
            }
        }
        return array('skuGoods' => $skuGoods,'totalStorageNum' => $totalStorageNum,
            'defaultImage' => $defaultImage);
    }

    /**
     * 获取品牌数据
     *
     * @param array $baseInfo
     * @return array
     */
    private static function getBrandDataByProductBaseInfo(array &$baseInfo)
    {
        if(empty($baseInfo['brand'])) {
            return array();
        }
        $brandId = $baseInfo['brand']['id'];
        $bgImg = '';
        $logo = '';
        $bannerInfo = array();
        $result = self::getMultiDataByResourceName('BrandData::getBannerInfo');
        if(empty($result)) {
            $result = BrandData::getBannerInfo($brandId);//品牌banner
        }
        if(!empty($baseInfo['brand']['brandIco'])) {
            $logo = Images::getForceSourceUrl($baseInfo['brand']['brandIco']);
        }
        if(isset($result['code']) && $result['code'] == 200 && !empty($result['data'])) {
            $bannerInfo = $result['data'];
            if(!empty($bannerInfo['bannerUrl'])) {
                $bgImg = Images::getForceSourceUrl($bannerInfo['bannerUrl']);
            }
        }
        //banner的logo
        if(!empty($bannerInfo['logo']))
        {
            $logo = Images::getForceSourceUrl($bannerInfo['logo']);
        }
        $homeUrl = 'javascript:void(0)';
        if(!empty($baseInfo['brand']['brandDomain'])){
            $homeUrl = Helpers::url('', array(), $baseInfo['brand']['brandDomain']);
        }
        //导航的品牌banner
        return array(
            'brandId' => $baseInfo['brand']['id'],
            'bgColor' => !empty($bannerInfo['colorValue']) ? $bannerInfo['colorValue']: '#000000',
            'bgImg'=> $bgImg,
            'logo'=> $logo,
            'alt' => $baseInfo['brand']['brandName'],
            'brandName' => $baseInfo['brand']['brandName'],
            'brandDomain' => $baseInfo['brand']['brandDomain'],
            'homeUrl'=> $homeUrl,
            'isCollect'=> false
        );
    }

    /**
     * 获取vip数据
     *
     * @param array $baseInfo
     * @param int $vipLevel
     * @param int $uid
     * @return array
     */
    private static function getVipDataByProductBaseInfo(array &$baseInfo, $vipLevel = 0, $uid = 0)
    {
        $vipData = array();
        if (!empty($baseInfo['productPriceBo']['vipPrices'])) {
            $build = array();
            //不是普通会员
            if($vipLevel > 0) {
                foreach ($baseInfo['productPriceBo']['vipPrices'] as $value) {
                    $build['level'] = $value['vipLevel'];
                    $build['price'] = $value['vipPrice'];
                    $build['name'] = $value['vipTitle'];
                    $build['cur'] = ($value['vipLevel'] == $vipLevel) ? true : false;
                    $vipData['prices'][] = $build;
                }
            }
            $vipData['unLogin'] = false;
            //登录状态
            if(empty($uid)) {
                $vipData['unLogin'] = Helpers::url('/signin.html', array());
            }
            if(empty($vipLevel) && !empty($uid)) {
                $vipData['normalUser'] = true;
            }
            //查看vip进度
            $vipData['vipSchedualUrl'] = Helpers::url('/home/vip', array('t' => rand(10000, 9999999)));
        }
        return $vipData;
    }

    /**
     * 获取活动数据(促销相关活动)
     *
     * @param array $baseInfo
     * @return array
     */
    private static function getActivityDataByProductBaseInfo(array &$baseInfo)
    {
        $activity = array();
        //促销活动banner
        $activityBanner = self::getProductActivityBanner($baseInfo['id']);

        if(!empty($activityBanner)) {
            $activity[] = $activityBanner;
        }
        // 促销信息活动
        if (isset($baseInfo['promotionBoList'])) {
            $build = array();
            foreach ($baseInfo['promotionBoList'] as $value) {
                $build['type'] =  $value['promotionType'];
                $build['des'] = $value['promotionTitle'];
                $activity[] = $build;
            }
        }
        return $activity;
    }

    /**
     * 获取标签相关数据
     *
     * @param array $baseInfo
     * @return array
     */
    private static function getTagsDataByProductInfo(array &$baseInfo)
    {
        $tags = array();
        if (!empty($baseInfo['productTagBoList'])) {
            foreach ($baseInfo['productTagBoList'] as $value) {
                switch ($value['tagLabel']) {
                    case 'is_soon_sold_out': // 即将售磬
                        $tags['isFew'] = true;
                        break;
                    case 'is_new': // 新品NEW
                        $tags['isNew'] = true;
                        break;
                    case 'is_discount': // SALE
                        $tags['isSale'] = true;
                        break;
                    case 'is_limited': // 限量
                        $tags['isLimit'] = true;
                        break;
                    case 'is_yohood': // YOHOOD
                        $tags['isNewFestival'] = true;
                        break;
                    case 'is_advance': // 再到着
                        $tags['isReNew'] = true;
                        break;
                    case 'midYear'://年中热促
                        $tags['isYearMidPromotion'] = true;
                        break;
                    case 'yearEnd'://年终大促
                        $tags['isYearEndPromotion'] = true;
                        break;
                }
            }
        }
        return $tags;
    }

    /**
     * 获取模特试穿
     *
     * @param string $productSkn
     * @return array
     */
    public static function getProductModelTry($productSkn)
    {
        $modelTry = array();
        $result = self::getMultiDataByResourceName('ItemData::getProductModelTry');
        if(empty($result)) {
            $result = ItemData::getProductModelTry($productSkn);
        }
        if(isset($result['code']) && $result['code'] == 200 && !empty($result['data'])) {
            //先显示模特信息
            if(isset($result['data']['modelTryBoList']) && !empty($result['data']['modelTryBoList'])) {
                $modelTry['thead'] = array('模特','身高','体重','三围','试穿尺码','试穿描述');
                $modelTry['tbody'] = array();
                foreach($result['data']['modelTryBoList'] as $val) {
                    if(isset($val['modelBo']) && isset($val['sizeBo']) &&
                        isset($val['modelBo']['modelName']) && isset($val['sizeBo']['sizeName'])) {
                        $modelTry['tbody'][] = array($val['modelBo']['modelName'],
                            $val['modelBo']['height'],$val['modelBo']['weight'],$val['modelBo']['vitalStatistics'],
                            $val['sizeBo']['sizeName'], $val['tryDesc']);
                    }
                }
            } else if(isset($result['data']['modelTryImgBoList']) && !empty($result['data']['modelTryImgBoList'])) {//后显示模特图
                $tryImg = current($result['data']['modelTryImgBoList']);
                $modelTry['frImg'] = Images::getForceSourceUrl($tryImg['tryImg']);
            }
        }
        return $modelTry;
    }

    /**
     * 处理限购商品的有关按钮状态(或取现购买以及底部商品购买按钮)
     *
     * @param int $uid
     * @param int $showStatus 限购商品的关联状态
     * @param boolean $isBeginSale 限购商品是否已开售
     */
    private static function getFashionTopGoodsStatus($uid, $showStatus, $isBeginSale)
    {
        //潮流尖货状态
        // getLimitedCode //限购码状态
        //hasLimitedCode //是否已经获取限购码
        //limitedCodeSoldOut //限购码是否已经抢光
        //openSoon//即将开售
        //dis //失效
        //buyNow  //是否立即购买
        $result = array('getLimitedCode' => false, 'hasLimitedCode' => false,
            'limitedCodeSoldOut' => false, 'openSoon' => false, 'dis' => false,
            'buyNow' => false, 'soldOut'=> false, 'getLimitedCodeDis'=> false);
        // 显示获取限购码按钮
        $result['getLimitedCode'] = true;
        switch($showStatus) {
            case 1: // 开售前/后,立即分享获得限购码(用户未领取限购码)
                if ($isBeginSale) { // 开售后
                    $result['buyNow'] = true;
                    $result['dis'] = true;
                } else {
                    $result['openSoon'] = true;
                    $result['hasLimitedCode'] = false;
                }
                break;
            case 2: // 开售后,限购码已抢光(用户未领取限购码)
                $result['buyNow'] = true;
                $result['dis'] = true;
                $result['limitedCodeSoldOut'] = true;
                $result['getLimitedCode'] = false;
                $result['hasLimitedCode'] = false;
                break;
            case 3: // 开售后,商品已经售罄
                $result ['soldOut'] = true;
                $result['getLimitedCode'] = false;
                break;
            case 4: // 开售后,立即购买(用户已领取限购码)
                $result['buyNow'] = true;
                $result['dis'] = false;
                $result['hasLimitedCode'] = true;
                if(!empty($uid)) {//限购码失效
                    $result['getLimitedCodeDis'] = true;
                }
                break;
            case 5: // 开售前,限购码已被抢光(用户未领取限购码)
                $result['openSoon'] = true;
                $result['hasLimitedCode'] = true;
                $result['limitedCodeSoldOut'] = true;
                $result['getLimitedCode'] = false;

                break;
            case 6: // 开售前,即将开售(用户已领取限购码)
                $result['openSoon'] = true;
                $result['hasLimitedCode'] = true;
                if(!empty($uid)) {//限购码失效
                    $result['getLimitedCodeDis'] = true;
                }
                break;
            case 7: // 开售后,用户已经用获得的限购码购买过商品
                $result['buyNow'] = true;
                $result['dis'] = true;
                $result['hasLimitedCode'] = true;
                if(!empty($uid)) {//限购码失效
                    $result['getLimitedCodeDis'] = true;
                }
            default:
                break;
        }
        return $result;

    }

    /**
     * 获取商品咨询和评论数据
     *
     * @param array $baseInfo
     * @return array
     */
    private static function getConsultCommentDataByProductInfo(array &$baseInfo)
    {
        // 商品咨询
        $consultComment['consultNum'] = 0;
        $consultComment['captchaUrl'] = Helpers::url('/passport/images', array('t' => time()));
        if (!empty($baseInfo['consultBoWrapper'])) {
//             $consultComment['consultNum'] = $baseInfo['consultBoWrapper']['consultTotal'];
            $consultComment['consults'] = array();
        }
        // 商品评价
        $consultComment['commentNum'] = 0;
        if (!empty($baseInfo['commentBoWrapper'])) {
//             $consultComment['commentNum'] = $baseInfo['commentBoWrapper']['commentTotal'];
            $consultComment['comments'] = array();
            $consultComment['commentUrl'] = Helpers::url('/home/comment', array());
        }
        return $consultComment;
    }

}