Commit 19e41fa2 authored by 黄毅's avatar 黄毅

1

parent bdf85900
package com.egolm.shop.controller;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.egolm.common.StringUtil;
import com.egolm.common.bean.Rjx;
import com.egolm.common.jdbc.Page;
import com.egolm.shop.service.BrandService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
@Api(tags={"品牌相关接口"})
@RestController
@RequestMapping("brand")
public class BrandController {
@Autowired
private BrandService brandService;
@ApiOperation("首页Banner图片")
@ApiImplicitParams({
@ApiImplicitParam(paramType = "query", name = "OrgNO", dataType = "String", required = true, value = "区域编号", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "CompNO", dataType = "String", required = true, value = "组件编号", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "LangID", dataType = "String", required = false, value = "语言", defaultValue = "936"),
@ApiImplicitParam(paramType = "query", name = "index", dataType = "int", required = true, value = "页码", defaultValue = "1"),
@ApiImplicitParam(paramType = "query", name = "limit", dataType = "int", required = true, value = "每页显示数", defaultValue = "10"),
})
@RequestMapping(value = "/getBanner",method=RequestMethod.GET)
public String getBanner(HttpServletRequest request) {
String orgNO = request.getParameter("OrgNO");
String compNO = request.getParameter("CompNO");
String langId = request.getParameter("LangID");
String index = request.getParameter("index");
String limit = request.getParameter("limit");
if(!StringUtil.isNotEmpty(orgNO,compNO,limit,index)) {
return Rjx.json().setCode(-1).setMessage("参数缺失").toJson();
}
Map<String, Object> param = new HashMap<String, Object>();
param.put("orgNO", orgNO);
param.put("compNO", compNO);
param.put("LangID", langId==""?"936":langId);
Page page = new Page();
page.setIndex(Long.valueOf(index));
page.setLimit(Long.valueOf(limit));
page.setLimitKey("Idx asc");
List<Map<String, Object>> detailList = brandService.listBanner(param, page);
return Rjx.jsonOk().set("list", detailList).setPage(page).toString();
}
}
package com.egolm.shop.controller;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.egolm.common.StringUtil;
import com.egolm.common.bean.Rjx;
import com.egolm.common.jdbc.Page;
import com.egolm.shop.service.GoodsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
@Api(tags={"商品相关接口"})
@RestController
@RequestMapping("goods")
public class GoodsController {
@Autowired
private GoodsService goodsService;
@ApiOperation("猜你喜欢商品")
@ApiImplicitParams({
@ApiImplicitParam(paramType = "query", name = "OrgNO", dataType = "String", required = true, value = "区域编号", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "UserNO", dataType = "String", required = false, value = "用户编号", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "CompNO", dataType = "String", required = true, value = "组件编号", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "LangID", dataType = "String", required = false, value = "语言", defaultValue = "936"),
@ApiImplicitParam(paramType = "query", name = "index", dataType = "int", required = true, value = "页码", defaultValue = "1"),
@ApiImplicitParam(paramType = "query", name = "limit", dataType = "int", required = true, value = "每页显示数", defaultValue = "10"),
})
@RequestMapping(value = "/thinkLike",method=RequestMethod.GET)
public String thinkLike(HttpServletRequest request) {
String orgNO = request.getParameter("OrgNO");
String compNO = request.getParameter("CompNO");
String userNO = "nouserNO";
try {
userNO = request.getParameter("UserNO");
if(StringUtil.isEmpty(userNO)) {
userNO = "nouserNO";
}
} catch (Exception e) {
userNO = "nouserNO";
}
String langId = request.getParameter("LangID");
String index = request.getParameter("index");
String limit = request.getParameter("limit");
if(!StringUtil.isNotEmpty(orgNO,compNO,limit,index)) {
return Rjx.json().setCode(-1).setMessage("参数缺失").toJson();
}
Map<String, Object> param = new HashMap<String, Object>();
param.put("orgNO", orgNO);
param.put("compNO", compNO);
param.put("userNO", userNO);
param.put("LangID", langId==""?"936":langId);
Page page = new Page();
page.setIndex(Long.valueOf(index));
page.setLimit(Long.valueOf(limit));
List<Map<String, Object>> detailList = goodsService.listThinkLike(param, page);
return Rjx.jsonOk().set("list", detailList).setPage(page).toString();
}
}
package com.egolm.shop.service;
import java.util.List;
import java.util.Map;
import com.egolm.common.jdbc.Page;
public interface BrandService {
public List<Map<String,Object>> listBanner(Map<String,Object> params, Page page);
}
......@@ -3,6 +3,9 @@ package com.egolm.shop.service;
import java.util.List;
import java.util.Map;
import com.egolm.common.jdbc.Page;
public interface GoodsService {
public List<Map<String,Object>> listThinkLike(Map<String,Object> params, Page page);
}
......@@ -3,14 +3,32 @@ package com.egolm.shop.service.impl;
import java.util.List;
import java.util.Map;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.egolm.common.StringUtil;
import com.egolm.common.jdbc.JdbcTemplate;
import com.egolm.common.jdbc.Page;
import com.egolm.shop.service.BrandService;
@Service
public class BrandServiceImpl implements BrandService {
public List<Map<String,Object>> listBanner(Map<String,Object> params){
return null;
private static final Log logger = LogFactory.getLog(BrandServiceImpl.class);
@Autowired
private JdbcTemplate jdbcTemplate;
/*
* 获取首页Banner图片列表
* (non-Javadoc)
* @see com.egolm.shop.service.BrandService#listBanner(java.util.Map)
*/
@Override
public List<Map<String,Object>> listBanner(Map<String,Object> params, Page page){
String orgNO = params.get("orgNO")+"";
String sql = "select nItem BannerID, nIdx Idx, sTitle Title, sLinkType LinkType, sLinkPath LinkUrl, sImagePath ImgPath from tBanner where sOrgList like '%" + orgNO + "%'";
return jdbcTemplate.limit(sql, page);
}
}
package com.egolm.shop.service.impl;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Map;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.egolm.common.DateUtil;
import com.egolm.common.StringUtil;
import com.egolm.common.jdbc.JdbcTemplate;
import com.egolm.common.jdbc.Page;
import com.egolm.shop.service.GoodsService;
@Service
public class GoodsServiceImpl implements GoodsService {
private static final Log logger = LogFactory.getLog(GoodsServiceImpl.class);
@Autowired
private JdbcTemplate jdbcTemplate;
/**
* 获取当前用户历史购买的商品同分类(三级)下的三个月内购买数量最多的商品Top 20,
* 未登录时获取当前区域三个月内购买数量最多的商品Top 20
*/
@Override
public List<Map<String,Object>> listThinkLike(Map<String,Object> params, Page page){
String userNO = params.get("userNO")+"";
String orgNO = params.get("orgNO")+"";
Calendar cal = Calendar.getInstance();
cal.setTime(new Date());
cal.add(Calendar.DATE, -90);
Date date = new Date(cal.getTime().getTime());
String beginDate = DateUtil.format(date);
String endDate = DateUtil.format(new Date());
String sql = "select TOP 20 a.nGoodsID GoodsID, g.sGoodsNO GoodsNO, g.sGoodsDesc GoodsName, acg.nSalePrice Price, acg.sSpec Spec, acg.sUnit Unit, acg.nMinSaleQty MinQty, "
+ " acg.nSaleUnits SaleUnit, acg.nMarketPrice MarketPrice, sum(a.nSaleQty) SaleQty from tAgentGoodsDailyOnline a join tGoods g on a.nGoodsID = g.nGoodsID "
+ " join tAgentContractGoods acg on a.sAgentContractNO = acg.sAgentContractNO and a.nGoodsID = acg.nGoodsID ";
if(!userNO.equals("nouserNO")&&!StringUtil.isEmpty(userNO)) {
sql += " ,tUserOrg tu, tUserAgent ua where acg.sOrgNO = '" + orgNO + "' and acg.sOrgNO = tu.sOrgNO and tu.sUserNO = '" + userNO + "' and tu.nTag&1 = 0"
+ " and acg.nAgentID = ua.nAgentID and ua.sUserNO = '" + userNO + "' and ua.nTag&1 = 0 and a.dTradeDate >= '" + beginDate + "' and a.dTradeDate < '" + endDate + "' ";
}else {
sql += " where acg.sOrgNO = '" + orgNO + "' and a.dTradeDate >= '" + beginDate + "' and a.dTradeDate < '" + endDate +"'";
}
sql += " group by a.nGoodsID, g.sGoodsNO, g.sGoodsDesc, acg.nSalePrice, acg.sSpec, acg.sUnit, acg.nMinSaleQty, acg.nSaleUnits, acg.nMarketPrice, acg.sMarketUnit order by "
+ " sum(a.nSaleQty) desc";
System.out.println(sql);
return jdbcTemplate.queryForList(sql);
//return jdbcTemplate.limit(sql, page);
}
}
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