Commit e732219a authored by chang20170705's avatar chang20170705

brand

parent bf007f76
package com.egolm.shop.controller; package com.egolm.shop.controller;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
...@@ -63,4 +66,66 @@ public class BrandController { ...@@ -63,4 +66,66 @@ public class BrandController {
return Rjx.jsonOk().set("list", detailList).setPage(page).toString(); return Rjx.jsonOk().set("list", detailList).setPage(page).toString();
} }
@ApiOperation("品牌列表接口按首字母")
@ApiImplicitParams({
@ApiImplicitParam(paramType = "query", name = "OrgNO", dataType = "String", required = true, value = "区域编号", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "ShopNO", dataType = "String", required = false, value = "店铺编号", defaultValue = ""),
})
@RequestMapping(value = "/getBrandList",method=RequestMethod.GET)
public String getBrandList(HttpServletRequest request, HttpServletResponse response) {
List<Map<String,Object>> listMap;
Map<String,Object> params=new HashMap<>();
params.put("OrgNO", request.getParameter("OrgNO"));
params.put("ShopNO", request.getParameter("ShopNO"));
listMap=brandService.getBrandList(params);
String reg = "[A-Z]";
//用map把相同首字母放到同一个list中
Map<String,List> pinMap=new HashMap<>();
for(Map<String,Object> item:listMap) {
String first=((String)item.get("PinyinCode")).substring(0, 1).toUpperCase();
Map<String,String> BrandList=new HashMap<>();
BrandList.put("BrandNO", (String)item.get("BrandNO"));
BrandList.put("BrandName", (String)item.get("BrandName"));
BrandList.put("ImgPath", (String)item.get("ImgPath"));
if(first.matches(reg)) {
if(pinMap.containsKey(first)) {
pinMap.get(first).add(BrandList);
}else {
pinMap.put(first, new ArrayList() {{add(BrandList);}});
}
}else {
if(pinMap.containsKey("#")) {
pinMap.get("#").add(BrandList);
}else {
pinMap.put("#", new ArrayList() {{add(BrandList);}});
}
}
}
//转换输出结果
List<Map<String,Object>> returnList=new ArrayList<>();
for (Entry<String, List> entry : pinMap.entrySet()) {
Map<String,Object> returnMap=new HashMap<>();
returnMap.put("PyCode", entry.getKey());
returnMap.put("BrandList", entry.getValue());
}
return Rjx.jsonOk().set("list", returnList).toJson();
}
@ApiOperation("热销品牌列表")
@ApiImplicitParams({
@ApiImplicitParam(paramType = "query", name = "OrgNO", dataType = "String", required = true, value = "区域编号", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "CompNO", dataType = "String", required = true, value = "组件编号", defaultValue = ""),
})
@RequestMapping(value = "/getHotSaleBrands",method=RequestMethod.GET)
public String getHotSaleBrands(HttpServletRequest request, HttpServletResponse response) {
List<Map<String,Object>> listMap;
Map<String,Object> params=new HashMap<>();
params.put("OrgNO", request.getParameter("OrgNO"));
params.put("CompNO", request.getParameter("CompNO"));
listMap=brandService.getHotSaleBrands(params);
return Rjx.jsonOk().set("list", listMap).toJson();
}
} }
...@@ -5,6 +5,7 @@ import java.util.List; ...@@ -5,6 +5,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
...@@ -72,4 +73,19 @@ public class GoodsController { ...@@ -72,4 +73,19 @@ public class GoodsController {
List<Map<String, Object>> detailList = goodsService.listThinkLike(param, page); List<Map<String, Object>> detailList = goodsService.listThinkLike(param, page);
return Rjx.jsonOk().set("list", detailList).setPage(page).toString(); return Rjx.jsonOk().set("list", detailList).setPage(page).toString();
} }
@ApiOperation("热销商品列表")
@ApiImplicitParams({
@ApiImplicitParam(paramType = "query", name = "OrgNO", dataType = "String", required = true, value = "区域编号", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "CompNO", dataType = "String", required = true, value = "组件编号", defaultValue = ""),
})
@RequestMapping(value = "/getHotSaleGoods",method=RequestMethod.GET)
public String getHotSaleGoods(HttpServletRequest request, HttpServletResponse response) {
List<Map<String,Object>> listMap;
Map<String,Object> params=new HashMap<>();
params.put("OrgNO", request.getParameter("OrgNO"));
params.put("CompNO", request.getParameter("CompNO"));
listMap=goodsService.getHotSaleGoods(params);
return Rjx.jsonOk().set("list", listMap).toJson();
}
} }
...@@ -8,4 +8,6 @@ import com.egolm.common.jdbc.Page; ...@@ -8,4 +8,6 @@ import com.egolm.common.jdbc.Page;
public interface GoodsService { public interface GoodsService {
public List<Map<String,Object>> listThinkLike(Map<String,Object> params, Page page); public List<Map<String,Object>> listThinkLike(Map<String,Object> params, Page page);
public List<Map<String,Object>> getHotSaleGoods(Map<String,Object> map);
} }
package com.egolm.shop.service.impl; package com.egolm.shop.service.impl;
import java.util.ArrayList;
import java.util.Calendar; import java.util.Calendar;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
...@@ -48,4 +49,31 @@ public class GoodsServiceImpl implements GoodsService { ...@@ -48,4 +49,31 @@ public class GoodsServiceImpl implements GoodsService {
return jdbcTemplate.limit(sql, page); return jdbcTemplate.limit(sql, page);
} }
@Override
public List<Map<String, Object>> getHotSaleGoods(Map<String, Object> map) {
List<Map<String,Object>> listMap = new ArrayList<Map<String,Object>>();
String sql="SELECT TOP 20 "
+"GoodsID = a.nGoodsID, "
+"GoodsNO = g.sGoodsNO, "
+"GoodsName = g.sGoodsDesc, "
+"Price = acg.nSalePrice, "
+"MinQty = acg.nMinSaleQty, "
+"SaleUnit = acg.nSaleUnits, "
+"MarketPrice = acg.nMarketPrice, "
+"MarketUnit = acg.sMarketUnit, "
+"SaleQty = sum(a.nSaleQty) "
+"FROM tAgentGoodsDailyOnline a "
+"JOIN tGoods g ON a.nGoodsID = g.nGoodsID "
+"JOIN tAgentContractGoods acg ON a.sAgentContractNO = acg.sAgentContractNO "
+"and a.nGoodsID = acg.nGoodsID "
+"WHERE acg.sOrgNO = ? "
+"GROUP BY a.nGoodsID, g.sGoodsNO, g.sGoodsDesc, "
+"acg.nSalePrice, acg.nMinSaleQty, acg.nSaleUnits, acg.nMarketPrice, acg.sMarketUnit "
+"ORDER BY sum(a.nSaleQty) DESC ";
String OrgNO=(String) map.get("OrgNO");
listMap=jdbcTemplate.queryForList(sql, OrgNO);
return listMap;
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment