|
@@ -1,444 +1,469 @@
|
|
|
-package com.caimei.www.controller.unlimited;
|
|
|
-
|
|
|
-import com.alibaba.fastjson.JSONArray;
|
|
|
-import com.alibaba.fastjson.JSONObject;
|
|
|
-import com.caimei.www.controller.BaseController;
|
|
|
-import com.caimei.www.pojo.page.Parameter;
|
|
|
-import com.caimei.www.pojo.page.ProductDetail;
|
|
|
-import com.caimei.www.pojo.page.ProductList;
|
|
|
-import com.caimei.www.service.page.ProductService;
|
|
|
-import com.caimei.www.service.page.SinglePageService;
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.stereotype.Controller;
|
|
|
-import org.springframework.ui.Model;
|
|
|
-import org.springframework.web.bind.annotation.GetMapping;
|
|
|
-import org.springframework.web.bind.annotation.PathVariable;
|
|
|
-import org.thymeleaf.util.StringUtils;
|
|
|
-
|
|
|
-import java.util.*;
|
|
|
-import java.util.concurrent.atomic.AtomicReference;
|
|
|
-
|
|
|
-/**
|
|
|
- * 商品(product)
|
|
|
- *
|
|
|
- * @author : Charles
|
|
|
- * @date : 2020/6/12
|
|
|
- */
|
|
|
-@Controller
|
|
|
-public class ProductController extends BaseController {
|
|
|
-
|
|
|
- private static final String PRODUCT_LIST_PATH = "product/list";
|
|
|
- private static final String PRODUCT_HOT_PATH = "product/product-hot";
|
|
|
- private static final String PRODUCT_DETAIL_PATH = "product/detail";
|
|
|
- private static final String PRODUCT_SUPPORTING_PATH = "product/product-supporting";
|
|
|
- private static final String PROMOTIONS_LIST_PATH = "product/promotions";
|
|
|
- private static final String INSTRUMENT_PAGE_PATH = "product/instrument";
|
|
|
- private static final String TEMPORARY_PAGE_PATH = "product/temporary";
|
|
|
- private static final String INSTRUMENT_LIST_PATH = "product/instruelist";
|
|
|
- // private static final String QUALITY_AUTHORRIZE_PATH = "product/qualityauthorize";
|
|
|
- /**
|
|
|
- * 新正品联盟页面
|
|
|
- */
|
|
|
- private static final String QUALITY_AUTHORRIZE_PATH = "product/alliance-page";
|
|
|
- private static final String ACTIVITY_TOP_PATH = "activity/activityTopic";
|
|
|
- private static final String CLOUD_BEAUTY_PATH = "activity/beautyTopic";
|
|
|
- private static final String ACTIVITY_COUPON_EXP = "activity/couponExp";
|
|
|
- private static final String ACTIVITY_ATTESTAION = "activity/attestation-new";
|
|
|
- private static final String ACTIVITY_ATTESTAION_NEW = "activity/attestation";
|
|
|
- private static final String ACTIVITY_APPROVE_IFRAME = "activity/approveIframe.html";
|
|
|
- /**
|
|
|
- * 优惠券活动商品列表
|
|
|
- */
|
|
|
- private static final String PRODUCT_COUPON = "product/product-coupon";
|
|
|
- /**
|
|
|
- * 美博会专题页
|
|
|
- */
|
|
|
- private static final String BEAUTY_TOP_PATH = "product/beautytopic";
|
|
|
-
|
|
|
- /**
|
|
|
- * 快捷运营
|
|
|
- */
|
|
|
- private static final String QUICK_OPERATION = "quickOperation/index";
|
|
|
-
|
|
|
- /**
|
|
|
- * 商品详情文件预览
|
|
|
- */
|
|
|
- private static final String PRODUCT_FILE_PREVIEW = "product/filePreview";
|
|
|
-
|
|
|
- private ProductService productService;
|
|
|
-
|
|
|
- private SinglePageService singlePageService;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- public void setProductService(ProductService productService) {
|
|
|
- this.productService = productService;
|
|
|
- }
|
|
|
-
|
|
|
- @Autowired
|
|
|
- public void setSinglePageService(SinglePageService singlePageService) {
|
|
|
- this.singlePageService = singlePageService;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 搜索结果 页面
|
|
|
- */
|
|
|
- @GetMapping("/product/list.html")
|
|
|
- public String list() {
|
|
|
- return PRODUCT_LIST_PATH;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 搜索结果 页面
|
|
|
- */
|
|
|
- @GetMapping("/product/hot.html")
|
|
|
- public String hot() {
|
|
|
- return PRODUCT_HOT_PATH;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 优惠券活动商品列表
|
|
|
- */
|
|
|
- @GetMapping("/product/product-coupon.html")
|
|
|
- public String productCoupon() {
|
|
|
- return PRODUCT_COUPON;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 促销活动商品列表
|
|
|
- */
|
|
|
- @GetMapping("/product/promotions.html")
|
|
|
- public String promotions() {
|
|
|
- return PROMOTIONS_LIST_PATH;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 商品详情页
|
|
|
- */
|
|
|
- @GetMapping("/product-{id}.html")
|
|
|
- public String detail(final Model model, @PathVariable("id") String product) {
|
|
|
- Integer productId = null;
|
|
|
- Integer typeId = 0;
|
|
|
- if (product.contains("-")) {
|
|
|
- String[] split = product.split("-");
|
|
|
- productId = Integer.valueOf(split[0]);
|
|
|
- typeId = Integer.valueOf(split[1]);
|
|
|
- } else {
|
|
|
- productId = Integer.valueOf(product);
|
|
|
- }
|
|
|
- ProductDetail detail = productService.getProductDetailById(productId);
|
|
|
- if (detail == null || detail.getValidFlag() == 0 || detail.getValidFlag() == 9) {
|
|
|
- return super.errorPath();
|
|
|
- }
|
|
|
- List<String> images = productService.getImages(productId);
|
|
|
- List<Parameter> params = productService.getParams(productId);
|
|
|
- List<ProductList> productLists = productService.getProductLists(productId);
|
|
|
- model.addAttribute("lists", productLists);
|
|
|
- model.addAttribute("params", params);
|
|
|
- model.addAttribute("images", images);
|
|
|
- model.addAttribute("productId", productId);
|
|
|
- model.addAttribute("product", detail);
|
|
|
- model.addAttribute("typeId", typeId);
|
|
|
- return PRODUCT_DETAIL_PATH;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 商品详情资料预览
|
|
|
- */
|
|
|
- @GetMapping("/product/filePreview.html")
|
|
|
- public String productFilePreview() {
|
|
|
- return PRODUCT_FILE_PREVIEW;
|
|
|
- };
|
|
|
-
|
|
|
- /**
|
|
|
- * 仪器页
|
|
|
- */
|
|
|
- @GetMapping("/product/type-{id}.html")
|
|
|
- public String instrument(final Model model, @PathVariable("id") Integer id) {
|
|
|
- Integer pageId = singlePageService.getInstrumentPageIdById(id);
|
|
|
- if (pageId == null) {
|
|
|
- return super.errorPath();
|
|
|
- }
|
|
|
- String title = singlePageService.getPageTitleById(id);
|
|
|
- model.addAttribute("pageId", id);
|
|
|
- model.addAttribute("pageTitle", title);
|
|
|
- Integer typeSort = singlePageService.getPageTypeSort(pageId);
|
|
|
- model.addAttribute("typeSort", typeSort);
|
|
|
- // 产品仪器一级分类
|
|
|
- JSONArray bigTypeArr = productService.getTypeClassifyJson(typeSort);
|
|
|
- // 产品仪器楼层数据
|
|
|
- Map<String, Object> floorMap = productService.getTypeFloorJson(pageId);
|
|
|
- model.addAttribute("bigTypeJson", bigTypeArr);
|
|
|
- model.addAttribute("typeFloorJson", floorMap);
|
|
|
- return INSTRUMENT_PAGE_PATH;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 商品分类列表页面
|
|
|
- */
|
|
|
- @GetMapping("/product/classify-{ids}.html")
|
|
|
- public String instruelist(final Model model, @PathVariable("ids") String ids, String bpn, Integer pro, Integer newg) {
|
|
|
- String[] split = ids.split("-");
|
|
|
- // 分类类型:1产品,2仪器,0全部
|
|
|
- Integer typeSort = split.length >= 1 ? Integer.valueOf(split[0]) : 0;
|
|
|
- model.addAttribute("typeSort", typeSort);
|
|
|
- // 一级分类Id
|
|
|
- Integer bigTypeId = split.length >= 2 ? Integer.valueOf(split[1]) : 0;
|
|
|
- model.addAttribute("bigTypeId", bigTypeId);
|
|
|
- // 二级分类Id
|
|
|
- Integer smallTypeId = split.length >= 3 ? Integer.valueOf(split[2]) : 0;
|
|
|
- model.addAttribute("smallTypeId", smallTypeId);
|
|
|
- // 三级级分类Id
|
|
|
- Integer tinyTypeId = split.length >= 4 ? Integer.valueOf(split[3]) : 0;
|
|
|
- model.addAttribute("tinyTypeId", tinyTypeId);
|
|
|
- // 页码
|
|
|
- Integer pageNum = split.length >= 5 ? Integer.valueOf(split[4]) : 1;
|
|
|
- // 每页数量
|
|
|
- Integer pageSize = split.length >= 6 ? Integer.valueOf(split[5]) : 24;
|
|
|
- // 排序字段:价格price,销量sales,人气favorite
|
|
|
- String sortField = split.length >= 7 ? split[6] : "";
|
|
|
- // 排序规则:1降序,其他升序
|
|
|
- Integer sortType = split.length >= 8 ? Integer.valueOf(split[7]) : 1;
|
|
|
- /*
|
|
|
- * 获取一级分类
|
|
|
- */
|
|
|
- JSONArray bigTypeArr = productService.getBigTypeJson(typeSort);
|
|
|
- model.addAttribute("bigTypeJson", bigTypeArr);
|
|
|
- AtomicReference<String> bigTypeName = new AtomicReference<>("");
|
|
|
- bigTypeArr.forEach(temp -> {
|
|
|
- JSONObject bigType = (JSONObject) temp;
|
|
|
- if (null != bigType && bigTypeId.equals(bigType.getInteger("bigTypeId"))) {
|
|
|
- bigTypeName.set(bigType.getString("name"));
|
|
|
- }
|
|
|
- });
|
|
|
- model.addAttribute("bigTypeName", bigTypeName.get());
|
|
|
- /*
|
|
|
- * 获取二级分类
|
|
|
- */
|
|
|
- JSONArray smallTypeArr = productService.getSmallTypeJson(bigTypeId);
|
|
|
- model.addAttribute("smallTypeJson", smallTypeArr);
|
|
|
- AtomicReference<String> smallTypeName = new AtomicReference<>("");
|
|
|
- smallTypeArr.forEach(temp -> {
|
|
|
- JSONObject smallType = (JSONObject) temp;
|
|
|
- if (null != smallType && smallTypeId.equals(smallType.getInteger("smallTypeId"))) {
|
|
|
- smallTypeName.set(smallType.getString("name"));
|
|
|
- }
|
|
|
- });
|
|
|
- model.addAttribute("smallTypeName", smallTypeName.get());
|
|
|
- /*
|
|
|
- * 获取三级分类
|
|
|
- */
|
|
|
- JSONArray tinyTypeArr = productService.getTinyTypeJson(smallTypeId);
|
|
|
- model.addAttribute("tinyTypeJson", tinyTypeArr);
|
|
|
- AtomicReference<String> tinyTypeName = new AtomicReference<>("");
|
|
|
- tinyTypeArr.forEach(temp -> {
|
|
|
- JSONObject tinyType = (JSONObject) temp;
|
|
|
- if (null != tinyType && tinyTypeId.equals(tinyType.getInteger("tinyTypeId"))) {
|
|
|
- tinyTypeName.set(tinyType.getString("name"));
|
|
|
- }
|
|
|
- });
|
|
|
- model.addAttribute("tinyTypeName", tinyTypeName.get());
|
|
|
- /*
|
|
|
- * 获取商品信息
|
|
|
- */
|
|
|
- StringBuilder productParams = new StringBuilder();
|
|
|
- if (tinyTypeId > 0) {
|
|
|
- productParams.append("?id=").append(tinyTypeId).append("&idType=3");
|
|
|
- } else if (smallTypeId > 0) {
|
|
|
- productParams.append("?id=").append(smallTypeId).append("&idType=2");
|
|
|
- } else {
|
|
|
- productParams.append("?id=").append(bigTypeId).append("&idType=1");
|
|
|
- }
|
|
|
- productParams.append("&pageNum=").append(pageNum).append("&pageSize=").append(pageSize).append("&sortField=").append(sortField).append("&sortType=").append(sortType);
|
|
|
- if (newg != null) {
|
|
|
- productParams.append("&newFlag=").append(newg);
|
|
|
- }
|
|
|
- if (pro != null) {
|
|
|
- productParams.append("&promotionFlag=").append(pro);
|
|
|
- }
|
|
|
- if (!StringUtils.isEmpty(bpn)) {
|
|
|
- productParams.append("&brandIds=").append(bpn);
|
|
|
- }
|
|
|
- JSONObject productObj = productService.getProductListJson(productParams.toString());
|
|
|
- Integer totalCount = 0;
|
|
|
- JSONArray productList = new JSONArray();
|
|
|
- if (null != productObj) {
|
|
|
- totalCount = productObj.getInteger("total");
|
|
|
- productList = (JSONArray) productObj.get("items");
|
|
|
- }
|
|
|
- model.addAttribute("productCount", totalCount);
|
|
|
- model.addAttribute("productListJson", productList);
|
|
|
-
|
|
|
- int totalPage = (int) Math.ceil((double) totalCount / pageSize);
|
|
|
- totalPage = totalPage > 0 ? totalPage : 1;
|
|
|
- int[] arr = null;
|
|
|
- if (totalPage <= 6) {
|
|
|
- int[] tmp = new int[]{1, 2, 3, 4, 5, 6};
|
|
|
- arr = Arrays.copyOf(tmp, totalPage);
|
|
|
- } else if (pageNum <= 3) {
|
|
|
- arr = new int[]{1, 2, 3, 4, 5, 0, totalPage};
|
|
|
- } else if (pageNum >= totalPage - 2) {
|
|
|
- arr = new int[]{1, 0, totalPage - 4, totalPage - 3, totalPage - 2, totalPage - 1, totalPage};
|
|
|
- } else {
|
|
|
- arr = new int[]{1, 0, pageNum - 2, pageNum - 1, pageNum, pageNum + 1, pageNum + 2, 0, totalPage};
|
|
|
- }
|
|
|
-
|
|
|
- List<Map<String, Object>> arrPath = new ArrayList<>();
|
|
|
-
|
|
|
- final String basePath = "/product/classify-" + typeSort + "-" + bigTypeId + "-" + smallTypeId + "-" + tinyTypeId;
|
|
|
- if (pageNum > 1) {
|
|
|
- StringBuilder prevPath = new StringBuilder(basePath);
|
|
|
- prevPath.append("-").append(pageNum - 1).append("-").append(pageSize);
|
|
|
- if (!StringUtils.isEmpty(sortField)) {
|
|
|
- prevPath.append("-").append(sortField).append("-").append(sortType).append(".html");
|
|
|
- } else {
|
|
|
- prevPath.append(".html");
|
|
|
- }
|
|
|
- Map<String, Object> tempPath = new HashMap<>();
|
|
|
- tempPath.put("btn", -1);
|
|
|
- tempPath.put("path", prevPath);
|
|
|
- arrPath.add(tempPath);
|
|
|
- }
|
|
|
- for (int j : arr) {
|
|
|
- Map<String, Object> tempPath = new HashMap<>();
|
|
|
- tempPath.put("btn", j);
|
|
|
- if (j > 0) {
|
|
|
- StringBuilder btnPath = new StringBuilder(basePath);
|
|
|
- btnPath.append("-").append(j).append("-").append(pageSize);
|
|
|
- if (!StringUtils.isEmpty(sortField)) {
|
|
|
- btnPath.append("-").append(sortField).append("-").append(sortType).append(".html");
|
|
|
- } else {
|
|
|
- btnPath.append(".html");
|
|
|
- }
|
|
|
- tempPath.put("path", btnPath);
|
|
|
- } else {
|
|
|
- tempPath.put("path", "");
|
|
|
- }
|
|
|
- arrPath.add(tempPath);
|
|
|
- }
|
|
|
- if (pageNum < totalPage) {
|
|
|
- StringBuilder nextPath = new StringBuilder(basePath);
|
|
|
- nextPath.append("-").append(pageNum + 1).append("-").append(pageSize);
|
|
|
- if (!StringUtils.isEmpty(sortField)) {
|
|
|
- nextPath.append("-").append(sortField).append("-").append(sortType).append(".html");
|
|
|
- } else {
|
|
|
- nextPath.append(".html");
|
|
|
- }
|
|
|
- Map<String, Object> tempPath = new HashMap<>();
|
|
|
- tempPath.put("btn", -2);
|
|
|
- tempPath.put("path", nextPath);
|
|
|
- arrPath.add(tempPath);
|
|
|
- }
|
|
|
- model.addAttribute("pageBtnNum", pageNum);
|
|
|
- model.addAttribute("pageBtnList", arrPath);
|
|
|
-
|
|
|
- return INSTRUMENT_LIST_PATH;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 美博会专题页
|
|
|
- */
|
|
|
- @GetMapping("/product/beauty.html")
|
|
|
- public String beautytopic() {
|
|
|
- return BEAUTY_TOP_PATH;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 正品联盟品牌授权商品详情页
|
|
|
- */
|
|
|
- @GetMapping("/product/auth/product-{id}.html")
|
|
|
- public String authorization(final Model model, @PathVariable("id") Integer productId) {
|
|
|
- model.addAttribute("productId", productId);
|
|
|
- return QUALITY_AUTHORRIZE_PATH;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 活动专题页
|
|
|
- */
|
|
|
- @GetMapping("/product/activity-{id}.html")
|
|
|
- public String activityTopic(final Model model, @PathVariable("id") Integer id) {
|
|
|
- Integer pageId = null;
|
|
|
- if (id == 301) {
|
|
|
- // 美体节活动页
|
|
|
- pageId = singlePageService.getInstrumentPageIdById(id);
|
|
|
- if (pageId == null) {
|
|
|
- return super.errorPath();
|
|
|
- }
|
|
|
- return TEMPORARY_PAGE_PATH;
|
|
|
- }
|
|
|
- // 活动专题页
|
|
|
- pageId = singlePageService.getActivityPageIdById(id);
|
|
|
- if (pageId == null) {
|
|
|
- return super.errorPath();
|
|
|
- }
|
|
|
- model.addAttribute("pageId", id);
|
|
|
- return ACTIVITY_TOP_PATH;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 云上美博会
|
|
|
- */
|
|
|
- @GetMapping("/product/beauty-{id}.html")
|
|
|
- public String getCloudBeautyPath(final Model model, @PathVariable("id") Integer id) {
|
|
|
- // 活动专题页
|
|
|
- Integer pageId = singlePageService.getBeautyPageIdById(id);
|
|
|
- if (pageId == null) {
|
|
|
- return super.errorPath();
|
|
|
- }
|
|
|
- model.addAttribute("pageId", id);
|
|
|
- return CLOUD_BEAUTY_PATH;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 优惠券说明页
|
|
|
- */
|
|
|
- @GetMapping("/product/couponExp.html")
|
|
|
- public String getCouponExpPath() {
|
|
|
- return ACTIVITY_COUPON_EXP;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 认证通页面
|
|
|
- */
|
|
|
- @GetMapping("/attestation.html")
|
|
|
- public String getAttestationPath() {
|
|
|
- return ACTIVITY_ATTESTAION;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- *
|
|
|
- */
|
|
|
- @GetMapping("/attestation-new.html")
|
|
|
- public String getAttestationNewPath() {
|
|
|
- return ACTIVITY_ATTESTAION_NEW;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * H5配套商品页
|
|
|
- */
|
|
|
- @GetMapping("/product/product-supporting.html")
|
|
|
- public String getProductSupporting() {
|
|
|
- return PRODUCT_SUPPORTING_PATH;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * H5配套商品页
|
|
|
- */
|
|
|
- @GetMapping("/approve-iframe.html")
|
|
|
- public String getActivityApproveIframe() {
|
|
|
- return ACTIVITY_APPROVE_IFRAME;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 快捷运营
|
|
|
- */
|
|
|
- @GetMapping("/quickOperation/operation-{id}.html")
|
|
|
- public String getQuickOperation(final Model model, @PathVariable("id") Integer id) {
|
|
|
- // 活动专题页
|
|
|
- Integer pageId = singlePageService.getBeautyPageIdById(id);
|
|
|
- if (pageId == null) {
|
|
|
- return super.errorPath();
|
|
|
- }
|
|
|
- model.addAttribute("pageId", id);
|
|
|
- return QUICK_OPERATION;
|
|
|
- }
|
|
|
-}
|
|
|
+package com.caimei.www.controller.unlimited;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.caimei.www.controller.BaseController;
|
|
|
+import com.caimei.www.pojo.page.Parameter;
|
|
|
+import com.caimei.www.pojo.page.ProductDetail;
|
|
|
+import com.caimei.www.pojo.page.ProductList;
|
|
|
+import com.caimei.www.service.page.ProductService;
|
|
|
+import com.caimei.www.service.page.SinglePageService;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Controller;
|
|
|
+import org.springframework.ui.Model;
|
|
|
+import org.springframework.web.bind.annotation.GetMapping;
|
|
|
+import org.springframework.web.bind.annotation.PathVariable;
|
|
|
+import org.thymeleaf.util.StringUtils;
|
|
|
+
|
|
|
+import java.util.*;
|
|
|
+import java.util.concurrent.atomic.AtomicReference;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 商品(product)
|
|
|
+ *
|
|
|
+ * @author : Charles
|
|
|
+ * @date : 2020/6/12
|
|
|
+ */
|
|
|
+@Controller
|
|
|
+public class ProductController extends BaseController {
|
|
|
+
|
|
|
+ private static final String PRODUCT_LIST_PATH = "product/list";
|
|
|
+ private static final String PRODUCT_HOT_PATH = "product/product-hot";
|
|
|
+ private static final String PRODUCT_DETAIL_PATH = "product/detail";
|
|
|
+ private static final String PRODUCT_SUPPORTING_PATH = "product/product-supporting";
|
|
|
+ private static final String PROMOTIONS_LIST_PATH = "product/promotions";
|
|
|
+ private static final String INSTRUMENT_PAGE_PATH = "product/instrument";
|
|
|
+ private static final String TEMPORARY_PAGE_PATH = "product/temporary";
|
|
|
+ private static final String INSTRUMENT_LIST_PATH = "product/instruelist";
|
|
|
+ // private static final String QUALITY_AUTHORRIZE_PATH = "product/qualityauthorize";
|
|
|
+ /**
|
|
|
+ * 新正品联盟页面
|
|
|
+ */
|
|
|
+ private static final String QUALITY_AUTHORRIZE_PATH = "product/alliance-page";
|
|
|
+ private static final String ACTIVITY_TOP_PATH = "activity/activityTopic";
|
|
|
+ private static final String CLOUD_BEAUTY_PATH = "activity/beautyTopic";
|
|
|
+ private static final String ACTIVITY_COUPON_EXP = "activity/couponExp";
|
|
|
+ private static final String ACTIVITY_ATTESTAION = "activity/attestation-new";
|
|
|
+ private static final String ACTIVITY_ATTESTAION_NEW = "activity/attestation";
|
|
|
+ private static final String ACTIVITY_APPROVE_IFRAME = "activity/approveIframe.html";
|
|
|
+ // 服务商入驻
|
|
|
+ private static final String SERVICE_SETTLEMENT_INDEX = "service-settlement/index.html";
|
|
|
+ private static final String SERVICE_SETTLEMENT_INFO = "service-settlement/info.html";
|
|
|
+ private static final String SERVICE_SEARCH_INDEX = "service-settlement/search.html";
|
|
|
+ /**
|
|
|
+ * 优惠券活动商品列表
|
|
|
+ */
|
|
|
+ private static final String PRODUCT_COUPON = "product/product-coupon";
|
|
|
+ /**
|
|
|
+ * 美博会专题页
|
|
|
+ */
|
|
|
+ private static final String BEAUTY_TOP_PATH = "product/beautytopic";
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 快捷运营
|
|
|
+ */
|
|
|
+ private static final String QUICK_OPERATION = "quickOperation/index";
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 商品详情文件预览
|
|
|
+ */
|
|
|
+ private static final String PRODUCT_FILE_PREVIEW = "product/filePreview";
|
|
|
+
|
|
|
+ private ProductService productService;
|
|
|
+
|
|
|
+ private SinglePageService singlePageService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ public void setProductService(ProductService productService) {
|
|
|
+ this.productService = productService;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ public void setSinglePageService(SinglePageService singlePageService) {
|
|
|
+ this.singlePageService = singlePageService;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 搜索结果 页面
|
|
|
+ */
|
|
|
+ @GetMapping("/product/list.html")
|
|
|
+ public String list() {
|
|
|
+ return PRODUCT_LIST_PATH;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 搜索结果 页面
|
|
|
+ */
|
|
|
+ @GetMapping("/product/hot.html")
|
|
|
+ public String hot() {
|
|
|
+ return PRODUCT_HOT_PATH;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 优惠券活动商品列表
|
|
|
+ */
|
|
|
+ @GetMapping("/product/product-coupon.html")
|
|
|
+ public String productCoupon() {
|
|
|
+ return PRODUCT_COUPON;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 促销活动商品列表
|
|
|
+ */
|
|
|
+ @GetMapping("/product/promotions.html")
|
|
|
+ public String promotions() {
|
|
|
+ return PROMOTIONS_LIST_PATH;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 商品详情页
|
|
|
+ */
|
|
|
+ @GetMapping("/product-{id}.html")
|
|
|
+ public String detail(final Model model, @PathVariable("id") String product) {
|
|
|
+ Integer productId = null;
|
|
|
+ Integer typeId = 0;
|
|
|
+ if (product.contains("-")) {
|
|
|
+ String[] split = product.split("-");
|
|
|
+ productId = Integer.valueOf(split[0]);
|
|
|
+ typeId = Integer.valueOf(split[1]);
|
|
|
+ } else {
|
|
|
+ productId = Integer.valueOf(product);
|
|
|
+ }
|
|
|
+ ProductDetail detail = productService.getProductDetailById(productId);
|
|
|
+ if (detail == null || detail.getValidFlag() == 0 || detail.getValidFlag() == 9) {
|
|
|
+ return super.errorPath();
|
|
|
+ }
|
|
|
+ List<String> images = productService.getImages(productId);
|
|
|
+ List<Parameter> params = productService.getParams(productId);
|
|
|
+ List<ProductList> productLists = productService.getProductLists(productId);
|
|
|
+ model.addAttribute("lists", productLists);
|
|
|
+ model.addAttribute("params", params);
|
|
|
+ model.addAttribute("images", images);
|
|
|
+ model.addAttribute("productId", productId);
|
|
|
+ model.addAttribute("product", detail);
|
|
|
+ model.addAttribute("typeId", typeId);
|
|
|
+ return PRODUCT_DETAIL_PATH;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 商品详情资料预览
|
|
|
+ */
|
|
|
+ @GetMapping("/product/filePreview.html")
|
|
|
+ public String productFilePreview() {
|
|
|
+ return PRODUCT_FILE_PREVIEW;
|
|
|
+ };
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 仪器页
|
|
|
+ */
|
|
|
+ @GetMapping("/product/type-{id}.html")
|
|
|
+ public String instrument(final Model model, @PathVariable("id") Integer id) {
|
|
|
+ Integer pageId = singlePageService.getInstrumentPageIdById(id);
|
|
|
+ if (pageId == null) {
|
|
|
+ return super.errorPath();
|
|
|
+ }
|
|
|
+ String title = singlePageService.getPageTitleById(id);
|
|
|
+ model.addAttribute("pageId", id);
|
|
|
+ model.addAttribute("pageTitle", title);
|
|
|
+ Integer typeSort = singlePageService.getPageTypeSort(pageId);
|
|
|
+ model.addAttribute("typeSort", typeSort);
|
|
|
+ // 产品仪器一级分类
|
|
|
+ JSONArray bigTypeArr = productService.getTypeClassifyJson(typeSort);
|
|
|
+ // 产品仪器楼层数据
|
|
|
+ Map<String, Object> floorMap = productService.getTypeFloorJson(pageId);
|
|
|
+ model.addAttribute("bigTypeJson", bigTypeArr);
|
|
|
+ model.addAttribute("typeFloorJson", floorMap);
|
|
|
+ return INSTRUMENT_PAGE_PATH;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 商品分类列表页面
|
|
|
+ */
|
|
|
+ @GetMapping("/product/classify-{ids}.html")
|
|
|
+ public String instruelist(final Model model, @PathVariable("ids") String ids, String bpn, Integer pro, Integer newg) {
|
|
|
+ String[] split = ids.split("-");
|
|
|
+ // 分类类型:1产品,2仪器,0全部
|
|
|
+ Integer typeSort = split.length >= 1 ? Integer.valueOf(split[0]) : 0;
|
|
|
+ model.addAttribute("typeSort", typeSort);
|
|
|
+ // 一级分类Id
|
|
|
+ Integer bigTypeId = split.length >= 2 ? Integer.valueOf(split[1]) : 0;
|
|
|
+ model.addAttribute("bigTypeId", bigTypeId);
|
|
|
+ // 二级分类Id
|
|
|
+ Integer smallTypeId = split.length >= 3 ? Integer.valueOf(split[2]) : 0;
|
|
|
+ model.addAttribute("smallTypeId", smallTypeId);
|
|
|
+ // 三级级分类Id
|
|
|
+ Integer tinyTypeId = split.length >= 4 ? Integer.valueOf(split[3]) : 0;
|
|
|
+ model.addAttribute("tinyTypeId", tinyTypeId);
|
|
|
+ // 页码
|
|
|
+ Integer pageNum = split.length >= 5 ? Integer.valueOf(split[4]) : 1;
|
|
|
+ // 每页数量
|
|
|
+ Integer pageSize = split.length >= 6 ? Integer.valueOf(split[5]) : 24;
|
|
|
+ // 排序字段:价格price,销量sales,人气favorite
|
|
|
+ String sortField = split.length >= 7 ? split[6] : "";
|
|
|
+ // 排序规则:1降序,其他升序
|
|
|
+ Integer sortType = split.length >= 8 ? Integer.valueOf(split[7]) : 1;
|
|
|
+ /*
|
|
|
+ * 获取一级分类
|
|
|
+ */
|
|
|
+ JSONArray bigTypeArr = productService.getBigTypeJson(typeSort);
|
|
|
+ model.addAttribute("bigTypeJson", bigTypeArr);
|
|
|
+ AtomicReference<String> bigTypeName = new AtomicReference<>("");
|
|
|
+ bigTypeArr.forEach(temp -> {
|
|
|
+ JSONObject bigType = (JSONObject) temp;
|
|
|
+ if (null != bigType && bigTypeId.equals(bigType.getInteger("bigTypeId"))) {
|
|
|
+ bigTypeName.set(bigType.getString("name"));
|
|
|
+ }
|
|
|
+ });
|
|
|
+ model.addAttribute("bigTypeName", bigTypeName.get());
|
|
|
+ /*
|
|
|
+ * 获取二级分类
|
|
|
+ */
|
|
|
+ JSONArray smallTypeArr = productService.getSmallTypeJson(bigTypeId);
|
|
|
+ model.addAttribute("smallTypeJson", smallTypeArr);
|
|
|
+ AtomicReference<String> smallTypeName = new AtomicReference<>("");
|
|
|
+ smallTypeArr.forEach(temp -> {
|
|
|
+ JSONObject smallType = (JSONObject) temp;
|
|
|
+ if (null != smallType && smallTypeId.equals(smallType.getInteger("smallTypeId"))) {
|
|
|
+ smallTypeName.set(smallType.getString("name"));
|
|
|
+ }
|
|
|
+ });
|
|
|
+ model.addAttribute("smallTypeName", smallTypeName.get());
|
|
|
+ /*
|
|
|
+ * 获取三级分类
|
|
|
+ */
|
|
|
+ JSONArray tinyTypeArr = productService.getTinyTypeJson(smallTypeId);
|
|
|
+ model.addAttribute("tinyTypeJson", tinyTypeArr);
|
|
|
+ AtomicReference<String> tinyTypeName = new AtomicReference<>("");
|
|
|
+ tinyTypeArr.forEach(temp -> {
|
|
|
+ JSONObject tinyType = (JSONObject) temp;
|
|
|
+ if (null != tinyType && tinyTypeId.equals(tinyType.getInteger("tinyTypeId"))) {
|
|
|
+ tinyTypeName.set(tinyType.getString("name"));
|
|
|
+ }
|
|
|
+ });
|
|
|
+ model.addAttribute("tinyTypeName", tinyTypeName.get());
|
|
|
+ /*
|
|
|
+ * 获取商品信息
|
|
|
+ */
|
|
|
+ StringBuilder productParams = new StringBuilder();
|
|
|
+ if (tinyTypeId > 0) {
|
|
|
+ productParams.append("?id=").append(tinyTypeId).append("&idType=3");
|
|
|
+ } else if (smallTypeId > 0) {
|
|
|
+ productParams.append("?id=").append(smallTypeId).append("&idType=2");
|
|
|
+ } else {
|
|
|
+ productParams.append("?id=").append(bigTypeId).append("&idType=1");
|
|
|
+ }
|
|
|
+ productParams.append("&pageNum=").append(pageNum).append("&pageSize=").append(pageSize).append("&sortField=").append(sortField).append("&sortType=").append(sortType);
|
|
|
+ if (newg != null) {
|
|
|
+ productParams.append("&newFlag=").append(newg);
|
|
|
+ }
|
|
|
+ if (pro != null) {
|
|
|
+ productParams.append("&promotionFlag=").append(pro);
|
|
|
+ }
|
|
|
+ if (!StringUtils.isEmpty(bpn)) {
|
|
|
+ productParams.append("&brandIds=").append(bpn);
|
|
|
+ }
|
|
|
+ JSONObject productObj = productService.getProductListJson(productParams.toString());
|
|
|
+ Integer totalCount = 0;
|
|
|
+ JSONArray productList = new JSONArray();
|
|
|
+ if (null != productObj) {
|
|
|
+ totalCount = productObj.getInteger("total");
|
|
|
+ productList = (JSONArray) productObj.get("items");
|
|
|
+ }
|
|
|
+ model.addAttribute("productCount", totalCount);
|
|
|
+ model.addAttribute("productListJson", productList);
|
|
|
+
|
|
|
+ int totalPage = (int) Math.ceil((double) totalCount / pageSize);
|
|
|
+ totalPage = totalPage > 0 ? totalPage : 1;
|
|
|
+ int[] arr = null;
|
|
|
+ if (totalPage <= 6) {
|
|
|
+ int[] tmp = new int[]{1, 2, 3, 4, 5, 6};
|
|
|
+ arr = Arrays.copyOf(tmp, totalPage);
|
|
|
+ } else if (pageNum <= 3) {
|
|
|
+ arr = new int[]{1, 2, 3, 4, 5, 0, totalPage};
|
|
|
+ } else if (pageNum >= totalPage - 2) {
|
|
|
+ arr = new int[]{1, 0, totalPage - 4, totalPage - 3, totalPage - 2, totalPage - 1, totalPage};
|
|
|
+ } else {
|
|
|
+ arr = new int[]{1, 0, pageNum - 2, pageNum - 1, pageNum, pageNum + 1, pageNum + 2, 0, totalPage};
|
|
|
+ }
|
|
|
+
|
|
|
+ List<Map<String, Object>> arrPath = new ArrayList<>();
|
|
|
+
|
|
|
+ final String basePath = "/product/classify-" + typeSort + "-" + bigTypeId + "-" + smallTypeId + "-" + tinyTypeId;
|
|
|
+ if (pageNum > 1) {
|
|
|
+ StringBuilder prevPath = new StringBuilder(basePath);
|
|
|
+ prevPath.append("-").append(pageNum - 1).append("-").append(pageSize);
|
|
|
+ if (!StringUtils.isEmpty(sortField)) {
|
|
|
+ prevPath.append("-").append(sortField).append("-").append(sortType).append(".html");
|
|
|
+ } else {
|
|
|
+ prevPath.append(".html");
|
|
|
+ }
|
|
|
+ Map<String, Object> tempPath = new HashMap<>();
|
|
|
+ tempPath.put("btn", -1);
|
|
|
+ tempPath.put("path", prevPath);
|
|
|
+ arrPath.add(tempPath);
|
|
|
+ }
|
|
|
+ for (int j : arr) {
|
|
|
+ Map<String, Object> tempPath = new HashMap<>();
|
|
|
+ tempPath.put("btn", j);
|
|
|
+ if (j > 0) {
|
|
|
+ StringBuilder btnPath = new StringBuilder(basePath);
|
|
|
+ btnPath.append("-").append(j).append("-").append(pageSize);
|
|
|
+ if (!StringUtils.isEmpty(sortField)) {
|
|
|
+ btnPath.append("-").append(sortField).append("-").append(sortType).append(".html");
|
|
|
+ } else {
|
|
|
+ btnPath.append(".html");
|
|
|
+ }
|
|
|
+ tempPath.put("path", btnPath);
|
|
|
+ } else {
|
|
|
+ tempPath.put("path", "");
|
|
|
+ }
|
|
|
+ arrPath.add(tempPath);
|
|
|
+ }
|
|
|
+ if (pageNum < totalPage) {
|
|
|
+ StringBuilder nextPath = new StringBuilder(basePath);
|
|
|
+ nextPath.append("-").append(pageNum + 1).append("-").append(pageSize);
|
|
|
+ if (!StringUtils.isEmpty(sortField)) {
|
|
|
+ nextPath.append("-").append(sortField).append("-").append(sortType).append(".html");
|
|
|
+ } else {
|
|
|
+ nextPath.append(".html");
|
|
|
+ }
|
|
|
+ Map<String, Object> tempPath = new HashMap<>();
|
|
|
+ tempPath.put("btn", -2);
|
|
|
+ tempPath.put("path", nextPath);
|
|
|
+ arrPath.add(tempPath);
|
|
|
+ }
|
|
|
+ model.addAttribute("pageBtnNum", pageNum);
|
|
|
+ model.addAttribute("pageBtnList", arrPath);
|
|
|
+
|
|
|
+ return INSTRUMENT_LIST_PATH;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 美博会专题页
|
|
|
+ */
|
|
|
+ @GetMapping("/product/beauty.html")
|
|
|
+ public String beautytopic() {
|
|
|
+ return BEAUTY_TOP_PATH;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 正品联盟品牌授权商品详情页
|
|
|
+ */
|
|
|
+ @GetMapping("/product/auth/product-{id}.html")
|
|
|
+ public String authorization(final Model model, @PathVariable("id") Integer productId) {
|
|
|
+ model.addAttribute("productId", productId);
|
|
|
+ return QUALITY_AUTHORRIZE_PATH;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 活动专题页
|
|
|
+ */
|
|
|
+ @GetMapping("/product/activity-{id}.html")
|
|
|
+ public String activityTopic(final Model model, @PathVariable("id") Integer id) {
|
|
|
+ Integer pageId = null;
|
|
|
+ if (id == 301) {
|
|
|
+ // 美体节活动页
|
|
|
+ pageId = singlePageService.getInstrumentPageIdById(id);
|
|
|
+ if (pageId == null) {
|
|
|
+ return super.errorPath();
|
|
|
+ }
|
|
|
+ return TEMPORARY_PAGE_PATH;
|
|
|
+ }
|
|
|
+ // 活动专题页
|
|
|
+ pageId = singlePageService.getActivityPageIdById(id);
|
|
|
+ if (pageId == null) {
|
|
|
+ return super.errorPath();
|
|
|
+ }
|
|
|
+ model.addAttribute("pageId", id);
|
|
|
+ return ACTIVITY_TOP_PATH;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 云上美博会
|
|
|
+ */
|
|
|
+ @GetMapping("/product/beauty-{id}.html")
|
|
|
+ public String getCloudBeautyPath(final Model model, @PathVariable("id") Integer id) {
|
|
|
+ // 活动专题页
|
|
|
+ Integer pageId = singlePageService.getBeautyPageIdById(id);
|
|
|
+ if (pageId == null) {
|
|
|
+ return super.errorPath();
|
|
|
+ }
|
|
|
+ model.addAttribute("pageId", id);
|
|
|
+ return CLOUD_BEAUTY_PATH;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 优惠券说明页
|
|
|
+ */
|
|
|
+ @GetMapping("/product/couponExp.html")
|
|
|
+ public String getCouponExpPath() {
|
|
|
+ return ACTIVITY_COUPON_EXP;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 认证通页面
|
|
|
+ */
|
|
|
+ @GetMapping("/attestation.html")
|
|
|
+ public String getAttestationPath() {
|
|
|
+ return ACTIVITY_ATTESTAION;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ *
|
|
|
+ */
|
|
|
+ @GetMapping("/attestation-new.html")
|
|
|
+ public String getAttestationNewPath() {
|
|
|
+ return ACTIVITY_ATTESTAION_NEW;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * H5配套商品页
|
|
|
+ */
|
|
|
+ @GetMapping("/product/product-supporting.html")
|
|
|
+ public String getProductSupporting() {
|
|
|
+ return PRODUCT_SUPPORTING_PATH;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * H5配套商品页
|
|
|
+ */
|
|
|
+ @GetMapping("/approve-iframe.html")
|
|
|
+ public String getActivityApproveIframe() {
|
|
|
+ return ACTIVITY_APPROVE_IFRAME;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 快捷运营
|
|
|
+ */
|
|
|
+ @GetMapping("/quickOperation/operation-{id}.html")
|
|
|
+ public String getQuickOperation(final Model model, @PathVariable("id") Integer id) {
|
|
|
+ // 活动专题页
|
|
|
+ Integer pageId = singlePageService.getBeautyPageIdById(id);
|
|
|
+ if (pageId == null) {
|
|
|
+ return super.errorPath();
|
|
|
+ }
|
|
|
+ model.addAttribute("pageId", id);
|
|
|
+ return QUICK_OPERATION;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 服务商入驻首页
|
|
|
+ */
|
|
|
+ @GetMapping("/serviceSettlement.html")
|
|
|
+ public String getServiceSettlement() {
|
|
|
+ return SERVICE_SETTLEMENT_INDEX;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 服务商入驻搜索页
|
|
|
+ */
|
|
|
+ @GetMapping("/servicesSearch.html")
|
|
|
+ public String getServiceSearch() { return SERVICE_SEARCH_INDEX; }
|
|
|
+ /**
|
|
|
+ * 服务商入驻详情
|
|
|
+ */
|
|
|
+ @GetMapping("/settlementInfo.html")
|
|
|
+ public String getSettlementInfo() {
|
|
|
+ return SERVICE_SETTLEMENT_INFO;
|
|
|
+ }
|
|
|
+}
|