Commit a65c2b03 authored by zhangyong's avatar zhangyong

1

parent 48c07c77
package com.egolm.shop.controller;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
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.alibaba.fastjson.JSONObject;
import com.egolm.common.web.ServletUtil;
import com.egolm.shop.service.CartService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
@Api(tags={"购物车相关接口"})
@RestController
@RequestMapping("cart")
public class CartController {
@Autowired
private CartService cartService;
@ApiOperation("加入购物车(JSON格式)")
@ApiImplicitParams({
@ApiImplicitParam(paramType = "query", dataType = "String", required = false, value = "JSON格式", defaultValue = "{\"shopNO\": \"00029975\",\"terminal\": \"wechat\",\"langID\": \"936\",\"cartList\": [{\"goodsID\": \"30771\",\"goodsTypeID\": 0,\"saleQty\": \"24\",\"agentContractNO\": \"600327002\",\"promoGroupNO\":\"\",\"promoPaperNO\":\"00001810100007\" }]}"),
})
@RequestMapping(value = "/appendCart",method=RequestMethod.POST,produces = "application/json")
public String appendCart(HttpServletRequest request, HttpServletResponse response) {
String reqJson = ServletUtil.readReqJson(request);
JSONObject jsonObj = JSONObject.parseObject(reqJson);
System.out.println("appendCart-------"+reqJson);
return cartService.append(jsonObj);
}
@ApiOperation("删除购物车(JSON格式)")
@ApiImplicitParams({
@ApiImplicitParam(paramType = "query", dataType = "String", required = false, value = "JSON格式", defaultValue = "{\"shopNO\": \"00029975\",\"terminal\": \"wechat\",\"langID\": \"936\",\"idxs\": [1,2,3]}"),
})
@RequestMapping(value = "/remove",method=RequestMethod.POST)
public String remove(HttpServletRequest request, HttpServletResponse response) {
String reqJson = ServletUtil.readReqJson(request);
JSONObject jsonObj = JSONObject.parseObject(reqJson);
System.out.println("remove-------"+reqJson);
return cartService.remove(jsonObj);
}
@ApiOperation("修改数量(JSON格式)")
@ApiImplicitParams({
@ApiImplicitParam(paramType = "query", dataType = "String", required = false, value = "JSON格式", defaultValue = "{\"shopNO\": \"00029975\",\"terminal\": \"wechat\",\"langID\": \"936\", \"idx\": 2,\"saleQty\": \"23\" }"),
})
@RequestMapping(value = "/updateQty",method=RequestMethod.POST)
public String updateQty(HttpServletRequest request, HttpServletResponse response) {
String reqJson = ServletUtil.readReqJson(request);
JSONObject jsonObj = JSONObject.parseObject(reqJson);
System.out.println("updateQty-------"+reqJson);
return cartService.updateQty(jsonObj);
}
}
package com.egolm.shop.controller;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
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.shop.service.CategoryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
@Api(tags={"分类相关接口"})
@RestController
@RequestMapping("category")
public class CategoryController {
@Autowired
private CategoryService categoryService;
@ApiOperation("分类列表")
@ApiImplicitParams({
@ApiImplicitParam(paramType = "query", name = "orgNO", dataType = "String", required = true, value = "组织机构", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "scopeTypeID", dataType = "String", required = true, value = "店铺类型", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "langID", dataType = "String", required = false, value = "语言", defaultValue = "936"),
})
@RequestMapping(value = "/queryCategory",method=RequestMethod.GET)
public String queryCategory(HttpServletRequest request, HttpServletResponse response) {
Map<String,Object> params=new HashMap<>();
params.put("orgNO", request.getParameter("orgNO"));
params.put("scopeTypeID", request.getParameter("scopeTypeID"));
params.put("langID", request.getParameter("langID")==null?936:request.getParameter("langID"));
return categoryService.queryCategory(params);
}
}
package com.egolm.shop.controller;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
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.bean.Rjx;
import com.egolm.shop.service.SystemCtrlService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
@Api(tags={"数据字典接口"})
@RestController
@RequestMapping("ctrl")
public class SystemCtrlController {
@Autowired
private SystemCtrlService systemCtrlService;
@ApiOperation("获取字典参数")
@ApiImplicitParams({
@ApiImplicitParam(paramType = "query", name = "code", dataType = "String", required = true, value = "编号", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "langID", dataType = "String", required = false, value = "语言", defaultValue = "936"),
})
@RequestMapping(value = "/getSystemCtrlByCode",method=RequestMethod.GET)
public String createGuest(HttpServletRequest request, HttpServletResponse response) {
String code = request.getParameter("code");
String langID = request.getParameter("langID");
return systemCtrlService.queryTSystemCtrlByCode(code, langID);
}
}
package com.egolm.shop.controller;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
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.bean.Rjx;
import com.egolm.shop.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
@Api(tags={"用户接口"})
@RestController
@RequestMapping("user")
public class UserController {
@Autowired
private UserService userService;
@ApiOperation("创建游客账号")
@ApiImplicitParams({
@ApiImplicitParam(paramType = "query", name = "districtID", dataType = "String", required = true, value = "区域编号", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "orgNO", dataType = "String", required = true, value = "组织机构", defaultValue = "SHBS"),
@ApiImplicitParam(paramType = "query", name = "langID", dataType = "String", required = false, value = "语言", defaultValue = "936"),
})
@RequestMapping(value = "/createGuest",method=RequestMethod.GET)
public String createGuest(HttpServletRequest request, HttpServletResponse response) {
Map<String,Object> params=new HashMap<>();
params.put("orgNO", request.getParameter("orgNO"));
params.put("districtID", request.getParameter("districtID")==null?"":request.getParameter("districtID"));
params.put("langID", request.getParameter("langID")==null?936:request.getParameter("langID"));
Map<String,Object> custMap = userService.createGuest(params);
return Rjx.jsonOk().set("custInfo",custMap).toString();
}
}
package com.egolm.shop.pojo;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.lang.reflect.Field;
import java.sql.SQLException;
import java.util.HashSet;
import java.util.Set;
import com.egolm.common.FileUtil;
import com.egolm.common.StringUtil;
import com.egolm.common.jdbc.dialect.MysqlTo;
import com.egolm.common.jdbc.dialect.SqlServerTo;
public class DB {
private static final String top = "D:\\111";
private static final String root = top ;//+ "\\egolm-domain\\src\\main\\java";
private static final Set<Field> columns = new HashSet<Field>();
private static final String regex = "^[a-z][A-Z].*$";
public static void main(String[] args) throws Exception {
createDomain();
}
public static void checkJsp(File file) throws Exception {
if(file.exists()) {
if(file.isDirectory()) {
File[] files = file.listFiles();
for(File f : files) {
checkJsp(f);
}
} else {
String extName = FileUtil.getExtName(file);
if("JSP".equals(extName)) {
BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(file)));
String text = StringUtil.read(br);
for(Field field : columns) {
String fieldName = field.getName();
if(fieldName.matches(regex)) {
String name = StringUtil.upperFirst(fieldName);
if(text.contains("\\." + name)) {
System.out.println(file.getAbsolutePath());
}
}
}
}
}
}
}
public static void foo(File file) throws FileNotFoundException {
if(file.exists()) {
if(file.isDirectory()) {
File[] files = file.listFiles();
for(File f : files) {
foo(f);
}
} else {
String extName = FileUtil.getExtName(file);
if("JAVA".equals(extName)) {
BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(file)));
String text = StringUtil.read(br);
try {
br.close();
} catch (IOException e) {
e.printStackTrace();
}
boolean boo = false;
for(Field field : columns) {
String columnName = field.getName();
String oname = StringUtil.upperFirst(columnName);
String name = (columnName.matches(regex) ? columnName : StringUtil.upperFirst(columnName));
String osetName = "set" + oname;
String setName = "set" + name;
String ogetName = "get" + oname;
String getName = "get" + name;
if(text.contains(osetName)) {
boo = true;
System.out.println(osetName);
text = text.replaceAll("\\.\\s*" + osetName + "\\s*\\(", "." + setName + "(");
text = text.replaceAll("\\s+" + osetName + "\\s*\\(", " " + setName + "(");
}
if(text.contains(ogetName)) {
boo = true;
System.out.println(ogetName);
text = text.replaceAll("\\.\\s*" + ogetName + "\\s*\\(", "." + getName + "(");
text = text.replaceAll("\\s+" + ogetName + "\\s*\\(", " " + getName + "(");
}
}
if(boo) {
System.out.println(text);
PrintWriter writer = new PrintWriter(new FileOutputStream(file));
writer.append(text);
writer.close();
}
}
}
}
}
public static void cache(File folder) throws FileNotFoundException, ClassNotFoundException, InstantiationException, IllegalAccessException {
File[] files = folder.listFiles();
if(files != null) {
for(File file : files) {
if(file.isDirectory()) {
cache(file);
} else {
String extName = FileUtil.getExtName(file);
if("JAVA".equals(extName)) {
String javaName = getClassFullName(file, null);
//System.out.println(javaName);
String className = javaName.substring(0, javaName.lastIndexOf("."));
try {
Class<?> clz = Class.forName(className);
Field[] fields = clz.getDeclaredFields();
for(Field field : fields) {
columns.add(field);
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}
}
}
public static void createDomain() throws SQLException {
System.out.println("Directory: " + root);
File[] files = new File(root).listFiles();
for(File file : files) {
System.out.println("Delete: " + file.getAbsolutePath());
file.deleteOnExit();
}
new SqlServerTo(root, "com.egolm.shop.pojo", "曲欣亮", "10.10.0.22:1433", "EGOLMDEV", "ERP", "qiyang@2013").execute();
}
public static String getClassFullName(File file, String x) {
String name = file.getName() + (StringUtil.isBlank(x) ? "" : ("." + x));
if(file.getName().equals("com")) {
return name;
} else {
return getClassFullName(file.getParentFile(), name);
}
}
}
package com.egolm.shop.pojo;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import javax.persistence.Entity;
import javax.persistence.Id;
/**
* @author 曲欣亮
* @since 2018-10-09
* @version v-1.0
*/
@Entity(name="tCustomer")
public class TCustomer implements java.io.Serializable {
private static final long serialVersionUID = 1L;
private String token;
private String sEmail;
private Date dCreateDate;
private String sPassword;
private String sOpenID;
private String sMobile;
private String sCustTypeID;
private String sTel;
@Id
private String sCustNO;
private String sHeadImgUrl;
private Date dLastUpdateTime;
private String sSalesmanNO1;
private String sCustLeveTypeID;
private Integer nStep;
private Integer nTag;
private String sCustLeveType;
private String sCustType;
private String sConfirmUser;
private String sCustName;
private Date dConfirmDate;
private String sSalesmanNO2;
private BigDecimal nPoint;
private String sCreateUser;
private String sFax;
private List<TShop> tshop ;
/**
* 无参数构造方法
*/
public TCustomer () {
super();
}
/**
* 全参数构造方法
* @param token
* @param sEmail
* @param dCreateDate
* @param sPassword
* @param sOpenID
* @param sMobile
* @param sCustTypeID
* @param sTel
* @param sCustNO
* @param sHeadImgUrl
* @param dLastUpdateTime
* @param sSalesmanNO1
* @param sCustLeveTypeID
* @param nStep
* @param nTag
* @param sCustLeveType
* @param sCustType
* @param sConfirmUser
* @param sCustName
* @param dConfirmDate
* @param sSalesmanNO2
* @param nPoint
* @param sCreateUser
* @param sFax
*/
public TCustomer(String token, String sEmail, Date dCreateDate, String sPassword, String sOpenID, String sMobile, String sCustTypeID, String sTel, String sCustNO, String sHeadImgUrl, Date dLastUpdateTime, String sSalesmanNO1, String sCustLeveTypeID, Integer nStep, Integer nTag, String sCustLeveType, String sCustType, String sConfirmUser, String sCustName, Date dConfirmDate, String sSalesmanNO2, BigDecimal nPoint, String sCreateUser, String sFax) {
this.token = token;
this.sEmail = sEmail;
this.dCreateDate = dCreateDate;
this.sPassword = sPassword;
this.sOpenID = sOpenID;
this.sMobile = sMobile;
this.sCustTypeID = sCustTypeID;
this.sTel = sTel;
this.sCustNO = sCustNO;
this.sHeadImgUrl = sHeadImgUrl;
this.dLastUpdateTime = dLastUpdateTime;
this.sSalesmanNO1 = sSalesmanNO1;
this.sCustLeveTypeID = sCustLeveTypeID;
this.nStep = nStep;
this.nTag = nTag;
this.sCustLeveType = sCustLeveType;
this.sCustType = sCustType;
this.sConfirmUser = sConfirmUser;
this.sCustName = sCustName;
this.dConfirmDate = dConfirmDate;
this.sSalesmanNO2 = sSalesmanNO2;
this.nPoint = nPoint;
this.sCreateUser = sCreateUser;
this.sFax = sFax;
}
public List<TShop> getTshop() {
return tshop;
}
public void setTshop(List<TShop> tshop) {
this.tshop = tshop;
}
public void setToken(String token) {
this.token = token;
}
public String getToken() {
return token;
}
public void setsEmail(String sEmail) {
this.sEmail = sEmail;
}
public String getsEmail() {
return sEmail;
}
public void setdCreateDate(Date dCreateDate) {
this.dCreateDate = dCreateDate;
}
public Date getdCreateDate() {
return dCreateDate;
}
public void setsPassword(String sPassword) {
this.sPassword = sPassword;
}
public String getsPassword() {
return sPassword;
}
public void setsOpenID(String sOpenID) {
this.sOpenID = sOpenID;
}
public String getsOpenID() {
return sOpenID;
}
public void setsMobile(String sMobile) {
this.sMobile = sMobile;
}
public String getsMobile() {
return sMobile;
}
public void setsCustTypeID(String sCustTypeID) {
this.sCustTypeID = sCustTypeID;
}
public String getsCustTypeID() {
return sCustTypeID;
}
public void setsTel(String sTel) {
this.sTel = sTel;
}
public String getsTel() {
return sTel;
}
public void setsCustNO(String sCustNO) {
this.sCustNO = sCustNO;
}
public String getsCustNO() {
return sCustNO;
}
public void setsHeadImgUrl(String sHeadImgUrl) {
this.sHeadImgUrl = sHeadImgUrl;
}
public String getsHeadImgUrl() {
return sHeadImgUrl;
}
public void setdLastUpdateTime(Date dLastUpdateTime) {
this.dLastUpdateTime = dLastUpdateTime;
}
public Date getdLastUpdateTime() {
return dLastUpdateTime;
}
public void setsSalesmanNO1(String sSalesmanNO1) {
this.sSalesmanNO1 = sSalesmanNO1;
}
public String getsSalesmanNO1() {
return sSalesmanNO1;
}
public void setsCustLeveTypeID(String sCustLeveTypeID) {
this.sCustLeveTypeID = sCustLeveTypeID;
}
public String getsCustLeveTypeID() {
return sCustLeveTypeID;
}
public void setnStep(Integer nStep) {
this.nStep = nStep;
}
public Integer getnStep() {
return nStep;
}
public void setnTag(Integer nTag) {
this.nTag = nTag;
}
public Integer getnTag() {
return nTag;
}
public void setsCustLeveType(String sCustLeveType) {
this.sCustLeveType = sCustLeveType;
}
public String getsCustLeveType() {
return sCustLeveType;
}
public void setsCustType(String sCustType) {
this.sCustType = sCustType;
}
public String getsCustType() {
return sCustType;
}
public void setsConfirmUser(String sConfirmUser) {
this.sConfirmUser = sConfirmUser;
}
public String getsConfirmUser() {
return sConfirmUser;
}
public void setsCustName(String sCustName) {
this.sCustName = sCustName;
}
public String getsCustName() {
return sCustName;
}
public void setdConfirmDate(Date dConfirmDate) {
this.dConfirmDate = dConfirmDate;
}
public Date getdConfirmDate() {
return dConfirmDate;
}
public void setsSalesmanNO2(String sSalesmanNO2) {
this.sSalesmanNO2 = sSalesmanNO2;
}
public String getsSalesmanNO2() {
return sSalesmanNO2;
}
public void setnPoint(BigDecimal nPoint) {
this.nPoint = nPoint;
}
public BigDecimal getnPoint() {
return nPoint;
}
public void setsCreateUser(String sCreateUser) {
this.sCreateUser = sCreateUser;
}
public String getsCreateUser() {
return sCreateUser;
}
public void setsFax(String sFax) {
this.sFax = sFax;
}
public String getsFax() {
return sFax;
}
}
This diff is collapsed.
package com.egolm.shop.service;
import com.alibaba.fastjson.JSONObject;
public interface CartService {
public String append(JSONObject obj);
public String remove(JSONObject obj);
public String updateQty (JSONObject obj);
}
package com.egolm.shop.service;
import java.util.Map;
public interface CategoryService {
public String queryCategory(Map<String,Object> params);
}
package com.egolm.shop.service;
public interface CommonService {
/**
* 保存浏览记录
* @param zone 区域
* @param terminalTypeID 终端类型ID
* @param shopNO
* @param viewTypeID 浏览类型
* @param values
*/
public void saveViewHistory(String zone,String terminalTypeID,String shopNO,String viewTypeID,String values);
}
......@@ -3,6 +3,7 @@ package com.egolm.shop.service;
import java.util.List;
import java.util.Map;
import com.alibaba.fastjson.JSONObject;
import com.egolm.common.jdbc.Page;
public interface GoodsService {
......@@ -12,4 +13,41 @@ public interface GoodsService {
public List<Map<String,Object>> getHotSaleGoods(Map<String,Object> map, Page page);
public List<Map<String,Object>> GetCategoryGoods (Map<String,Object> map, Page page);
List<Map<String, Object>> searchGoods(Map<String, Object> map, Page page);
List<Map<String, Object>> hotSearchKey(Map<String, Object> map, Page page);
String goodsDetail(Map<String, Object> map);
/**
* 查询商品图片
* @Title: goodsPicList
* @Description: TODO(这里用一句话描述这个方法的作用)
* @param: @param goodsID
* @param: @param agentContractNO
* @param: @return
* @return: List<Map<String,Object>>
* @throws
*/
public List<Map<String,Object>> goodsPicList(String goodsID,String agentContractNO );
/**
* 批量查询商品价格
* @Title: queryGoodsPrice
* @Description: TODO(这里用一句话描述这个方法的作用)
* @param: @param params
* @param: @return
* @return: List<Map<String,Object>>
* @throws
*/
public String queryGoodsPrice(JSONObject jsonObj);
/**
* 收藏及取消收藏
* @Title: updateFlavor
* @Description: TODO(这里用一句话描述这个方法的作用)
* @param: @param params
* @param: @return
* @return: String
* @throws
*/
public String updateFlavor(Map<String,Object> params);
}
package com.egolm.shop.service;
public interface SystemCtrlService {
public String queryTSystemCtrlByCode(String sCode,String langID);
}
package com.egolm.shop.service;
import java.util.Map;
import com.egolm.shop.pojo.TCustomer;
import com.egolm.shop.pojo.TShop;
public interface UserService {
public TCustomer getCustomer(String custNO,String shopNO);
public TShop getShop(String shopNO);
public Map<String,Object> createGuest(Map<String,Object> params);
}
package com.egolm.shop.service.impl;
import java.util.ArrayList;
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.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.egolm.common.StringUtil;
import com.egolm.common.Util;
import com.egolm.common.bean.Rjx;
import com.egolm.common.jdbc.JdbcTemplate;
import com.egolm.shop.service.CartService;
@Service
public class CartServiceImpl implements CartService {
private static final Log logger = LogFactory.getLog(CartServiceImpl.class);
@Autowired
private JdbcTemplate jdbcTemplate;
/**
* {
"shopNO": "00029975",
"terminal": "wechat",
"langID": "936",
"cartList": [
{
"goodsID": "10",
"goodsTypeID": 0,
"saleQty": "24",
"agentContractNO": "C001201608120004",
"promoGroupNO": "",
"promoPaperNO": ""
}
]
}
* <p>Title: append</p>
* <p>Description:加入购物车 </p>
* @param obj
* @return
* @see com.egolm.shop.service.CartService#append(com.alibaba.fastjson.JSONObject)
*/
public String append(JSONObject obj) {
String shopNO = obj.getString("shopNO");
String terminal = obj.getString("terminal");
JSONArray cartList = obj.getJSONArray("cartList");
Integer nMaxIdx = jdbcTemplate.queryForInt("select max(nIdx) from tCart where sShopNO = '" + shopNO + "'");
if(nMaxIdx == null) {
nMaxIdx = 0;
}
if(cartList != null && cartList.size() > 0) {
for(int i = 0; i<cartList.size();i++) {
JSONObject cartObj = cartList.getJSONObject(i);
Integer nGoodsTypeID = Util.objTo(cartObj.get("goodsTypeID"), Integer.class, 0);
Integer nSaleQty = Util.objTo(cartObj.get("saleQty"), Integer.class, null);
Integer nGoodsID = Util.objTo(cartObj.get("goodsID"), Integer.class, null);
String sAgentContractNO = Util.objTo(cartObj.get("agentContractNO"), String.class);
String sPromoPaperNO = Util.objTo(cartObj.get("promoPaperNO"), String.class, null);
String sPromoGroupNO = Util.objTo(cartObj.get("promoGroupNO"), String.class, null);
if(StringUtil.isNotBlank(sPromoPaperNO) && StringUtil.isNotBlank(sPromoGroupNO)) {
} else {
List<String> strs = new ArrayList<String>();
strs.add("sShopNO = '" + shopNO + "'");
strs.add("nTag = " + nGoodsTypeID);
strs.add("sAgentContractNO = '" + sAgentContractNO + "'");
strs.add("nGoodsID = " + nGoodsID);
if(StringUtil.isNotBlank(sPromoPaperNO)) {
strs.add("sPromoPaperNO = '" + sPromoPaperNO + "'");
} else {
strs.add("(sPromoPaperNO = '' or sPromoPaperNO is null)");
}
if(StringUtil.isNotBlank(sPromoGroupNO)) {
strs.add("sPromoGroupNO = '" + sPromoGroupNO + "'");
} else {
strs.add("(sPromoGroupNO = '' or sPromoGroupNO is null)");
}
List<Map<String, Object>> list = jdbcTemplate.queryForList("select nIdx, nSaleQty, sPromoPaperNO from tCart" + StringUtil.join(" and ", " where ", "", strs));
if(list.size() == 0) {
Object[] args = new Object[]{shopNO, ++nMaxIdx, nGoodsTypeID, sAgentContractNO, nGoodsID, nSaleQty, sPromoPaperNO, sPromoGroupNO};
jdbcTemplate.executeUpdate("insert into tCart (sShopNO, nIdx, nTag, sAgentContractNO, nGoodsID, nSaleQty, dLastUpdateTime, sPromoPaperNO, sPromoGroupNO) values (?, ?, ?, ?, ?, ?, getdate(), ?, ?)", args);
} else {
Integer nIdx = Util.objTo(list.get(0).get("nIdx"), Integer.class);
Double nQty = Util.objTo(list.get(0).get("nSaleQty"), Double.class);
jdbcTemplate.executeUpdate("update tCart set nSaleQty = " + (nSaleQty + nQty) + " where sShopNO = '" + shopNO + "' and nIdx = " + nIdx);
}
}
}
}
return Rjx.jsonOk().set("count", count(shopNO)).toJson();
}
/**
* 统计购物车数量
* @Title: count
* @Description: TODO(这里用一句话描述这个方法的作用)
* @param: @param shopNO
* @param: @return
* @return: Integer
* @throws
*/
public Integer count(String shopNO) {
return jdbcTemplate.queryForInt("select count(1) from tCart where sShopNO = '" + shopNO + "'");
}
/**
* 删除购物车
* <p>Title: remove</p>
* <p>Description: </p>
* @param obj
* @return
* @see com.egolm.shop.service.CartService#remove(com.alibaba.fastjson.JSONObject)
*
* {"shopNO": "00029975","terminal": "wechat","langID": "936","idxs": [1,2,3]}
*/
@Override
public String remove(JSONObject obj) {
String shopNO = obj.getString("shopNO");
JSONArray idxArray = obj.getJSONArray("idxs");
String terminal = obj.getString("terminal");
System.out.println("idxArray----"+idxArray);
List<String> nIdx = new ArrayList<String>();
if(idxArray == null) {
nIdx.add("0");
}else {
for(int i = 0;i<idxArray.size();i++) {
nIdx.add(idxArray.get(i)+"");
}
}
String sql = "select sPromoPaperNO from tCart where sShopNO = '" + shopNO + "' and nTag = 0" + StringUtil.join(", ", " and nIdx in (", ")", nIdx);
sql = "delete from tCart where sShopNO = '" + shopNO + "' and nTag = 1 and sPromoPaperNO in (" + sql + ")";
jdbcTemplate.executeUpdate(sql);
jdbcTemplate.executeUpdate("delete from tCart where sShopNO = '" + shopNO + "'" + StringUtil.join(", ", " and nIdx in (", ")", nIdx));
return Rjx.jsonOk().set("count", count(shopNO)).toJson();
}
/**
* 修改数量
* @Title: updateQty
* @Description: TODO(这里用一句话描述这个方法的作用)
* @param: @param obj
* @param: @return
* @return: String
* @throws
* {"shopNO": "00029975","terminal": "wechat","langID": "936", "idx": 2,"saleQty": "23" }
*/
public String updateQty (JSONObject obj) {
String shopNO = obj.getString("shopNO");
String idx = obj.getString("idx");
Double saleQty = obj.getDouble("saleQty");
String terminal = obj.getString("terminal");
String langID = obj.getString("langID");
System.out.println(saleQty );
System.out.println(saleQty == 0 );
if(saleQty == 0) {
JSONObject removeObj = new JSONObject();
removeObj.put("shopNO", shopNO);
removeObj.put("terminal", terminal);
removeObj.put("langID", langID);
JSONArray removeIdxArray = new JSONArray();
removeIdxArray.add(idx);
removeObj.put("idxs", removeIdxArray);
System.out.println(removeObj);
this.remove(removeObj);
} else {
jdbcTemplate.executeUpdate("update tCart set nSaleQty = " + saleQty + " where sShopNO = '" + shopNO + "' and nIdx = " + idx);
}
return Rjx.jsonOk().set("count", count(shopNO)).toJson();
}
}
package com.egolm.shop.service.impl;
import java.util.ArrayList;
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.bean.Rjx;
import com.egolm.common.jdbc.JdbcTemplate;
import com.egolm.shop.service.CategoryService;
@Service
public class CategoryServiceImpl implements CategoryService {
private static final Log logger = LogFactory.getLog(CategoryServiceImpl.class);
@Autowired
private JdbcTemplate jdbcTemplate;
/**
* 查询分类
* <p>Title: queryCategory</p>
* <p>Description: </p>
* @param params
* @return
* @see com.egolm.shop.service.CategoryService#queryCategory(java.util.Map)
*/
public String queryCategory(Map<String,Object> params) {
String orgNO = params.get("orgNO")+"";
String scopeTypeID = params.get("scopeTypeID")+"";
String one="select categoryID=sCategoryNO,categoryName=sCategoryDesc,parentID=sUpCategoryNO from tOrgCategory where sOrgNO='"+orgNO+"' and sScopeTypeID='"+scopeTypeID+"' and nCategoryLevel='3'";
String two="select categoryID=sCategoryNO,categoryName=sCategoryDesc,parentID=sUpCategoryNO from tOrgCategory where sOrgNO='"+orgNO+"' and sScopeTypeID='"+scopeTypeID+"' and nCategoryLevel='2'";
String three="select categoryID=sCategoryNO,categoryName=sCategoryDesc,parentID=sUpCategoryNO from tOrgCategory where sOrgNO='"+orgNO+"' and sScopeTypeID='"+scopeTypeID+"' and nCategoryLevel='1'";
try{
//返回树形结构结果
List<Map<String,Object>> list1=jdbcTemplate.queryForList(one);
List<Map<String,Object>> list2=jdbcTemplate.queryForList(two);
List<Map<String,Object>> list3=jdbcTemplate.queryForList(three);
for(Map<String,Object> map1:list1){
List<Map<String,Object>> temp2=new ArrayList<Map<String,Object>>();
for(Map<String,Object> map2:list2){
List<Map<String,Object>> temp3=new ArrayList<Map<String,Object>>();
for(Map<String,Object> map3:list3){
if(map2.get("categoryID").equals(map3.get("parentID"))){
temp3.add(map3);
}
}
map2.put("sonList", temp3);
if(map1.get("categoryID").equals(map2.get("parentID"))){
temp2.add(map2);
}
}
map1.put("sonList", temp2);
}
return Rjx.jsonOk().setData(list1).toJson();
}catch(Exception e) {
return Rjx.jsonErr().setMessage("分类查询出错").toJson();
}
}
}
package com.egolm.shop.service.impl;
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.jdbc.JdbcTemplate;
import com.egolm.shop.service.CommonService;
@Service
public class CommonServiceImpl implements CommonService{
private static final Log logger = LogFactory.getLog(CommonServiceImpl.class);
@Autowired
private JdbcTemplate jdbcTemplate;
/**
* 保存浏览记录
* @param zone 区域
* @param terminalTypeID 终端类型ID
* @param shopNO
* @param viewTypeID 浏览类型
* @param values
*/
public void saveViewHistory(String zone,String terminalTypeID,String shopNO,String viewTypeID,String values){
try{
String checkSql="SELECT "
+ " COUNT(1) "
+ "FROM "
+ " tShopViewHistory v WHERE "
+ " dTradeDate >= CONVERT (DATE, getdate()) "
+ " AND dTradeDate < dateadd( DAY,1,CONVERT (DATE, getdate())) "
+ " AND sOrgNO='"+zone+"' AND sTerminalTypeID='"+terminalTypeID+"' AND sShopNO='"+shopNO+"' AND sViewTypeID='"+viewTypeID+"' AND sValues='"+values+"' ";
int n=jdbcTemplate.queryForInt(checkSql);
if(n>0){
String updateSql=" UPDATE tShopViewHistory "
+ " SET nCount = nCount + 1 "
+ " WHERE "
+ " dTradeDate >= CONVERT (DATE, getdate()) "
+ " AND dTradeDate < dateadd( DAY,1,CONVERT (DATE, getdate())) "
+ " AND sOrgNO='"+zone+"' AND sTerminalTypeID='"+terminalTypeID+"' AND sShopNO='"+shopNO+"' AND sViewTypeID='"+viewTypeID+"' AND sValues='"+values+"' ";
jdbcTemplate.execute(updateSql);
}else{
String viewType="";
if("1".equals(viewTypeID)){
viewType="Articles";
}else if("2".equals(viewTypeID)){
viewType="Categories";
}else if("3".equals(viewTypeID)){
viewType="Brands";
}
String saveSql="insert into tShopViewHistory (dTradeDate,sOrgNO,sTerminalTypeID,sTerminalType,sShopNO,sViewTypeID,sViewType,sValues,nCount,dLastUpdateTime) values (GETDATE(),'"+zone+"','"+terminalTypeID+"','"+terminalTypeID+"','"+shopNO+"','"+viewTypeID+"','"+viewType+"','"+values+"',1,GETDATE())";
jdbcTemplate.execute(saveSql);
}
}catch(Exception e){
logger.error("浏览记录保存失败"+e);
}
}
}
package com.egolm.shop.service.impl;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
......@@ -12,17 +11,32 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.stereotype.Service;
import com.alibaba.fastjson.JSONObject;
import com.egolm.common.DateUtil;
import com.egolm.common.StringUtil;
import com.egolm.common.bean.Rjx;
import com.egolm.common.jdbc.JdbcTemplate;
import com.egolm.common.jdbc.Page;
import com.egolm.common.jdbc.dialect.SqlServerDialect;
import com.egolm.shop.pojo.TCustomer;
import com.egolm.shop.pojo.TShop;
import com.egolm.shop.service.CommonService;
import com.egolm.shop.service.GoodsService;
import com.egolm.shop.service.UserService;
import com.egolm.shop.util.ShopContstrant;
@Service
public class GoodsServiceImpl implements GoodsService {
private static final Log logger = LogFactory.getLog(GoodsServiceImpl.class);
@Autowired
private JdbcTemplate jdbcTemplate;
@Autowired
private UserService userService;
@Autowired
private CommonService commonService;
/**
* 获取当前用户历史购买的商品同分类(三级)下的三个月内购买数量最多的商品Top 20,
* 未登录时获取当前区域三个月内购买数量最多的商品Top 20
......@@ -114,7 +128,7 @@ public class GoodsServiceImpl implements GoodsService {
" AND acw.sWarehouseNO = d.sWarehouseNO " +
" AND acg.sCategoryNO = c.sCategoryNO " +
" AND acg.nTag&1=0 " +
" AND acg.sOrgNO = 'SHBS' " +
" AND acg.sOrgNO = '"+OrgNO+"' " +
" AND (c.sPath LIKE ISNULL((SELECT sPath FROM tCategory WHERE sCategoryNO = ?),'') + '%') " +
" AND (c.sPath LIKE ISNULL((SELECT sPath FROM tCategory WHERE sCategoryNO = ?),'') + '%') " ;
......@@ -122,5 +136,194 @@ public class GoodsServiceImpl implements GoodsService {
return jdbcTemplate.limit(sql,page, DistrictID,DistrictID,CategoryNOA,CategoryNOB);
}
/**
* 热搜词
* <p>Title: hotSearchKey</p>
* <p>Description: </p>
* @param map
* @param page
* @return
* @see com.egolm.shop.service.GoodsService#hotSearchKey(java.util.Map, com.egolm.common.jdbc.Page)
*/
@Override
public List<Map<String, Object>> hotSearchKey(Map<String, Object> map, Page page) {
String OrgNO=(String) map.get("OrgNO");
String sql="SELECT "
+ " searchCount = COUNT (sKeyword), "
+ " keyword = sKeyword "
+ "FROM "
+ " tShopSearchLog slog LEFT JOIN tShop s on(s.sShopNO=slog.sShopNO) "
+ "WHERE "
+ " s.sShopNO=slog.sShopNO "
+ " AND s.sOrgNO='"+OrgNO+"' "
+ " GROUP BY "
+ " s.sOrgNO, "
+ " sKeyword ";
jdbcTemplate.setDialect(new SqlServerDialect());
return jdbcTemplate.limit(sql,page);
}
/**
* 搜索
* <p>Title: searchGoods</p>
* <p>Description: </p>
* @param map
* @param page
* @return
* @see com.egolm.shop.service.GoodsService#searchGoods(java.util.Map, com.egolm.common.jdbc.Page)
*/
@Override
public List<Map<String, Object>> searchGoods(Map<String, Object> map, Page page) {
String orgNO=(String) map.get("orgNO");
String shopNO=(String) map.get("shopNO");
String queryStr=(String) map.get("queryStr");
String sql=" ";
jdbcTemplate.setDialect(new SqlServerDialect());
return jdbcTemplate.limit(sql,page);
}
/**
* 商品详情
* <p>Title: goodsDetail</p>
* <p>Description: </p>
* @param map
* @param page
* @return
* @see com.egolm.shop.service.GoodsService#goodsDetail(java.util.Map, com.egolm.common.jdbc.Page)
*/
@Override
public String goodsDetail(Map<String, Object> map) {
String custNO=(String) map.get("custNO");
String shopNO=(String) map.get("shopNO");
String terminal=(String) map.get("terminal");
String goodsID=(String) map.get("goodsID");
String contractNO=(String) map.get("contractNO");
TCustomer customer = userService.getCustomer(custNO,shopNO);
String goodsInfoSql = GoodsSql.goodsInfoSql(customer,map);
jdbcTemplate.setDialect(new SqlServerDialect());
//正式用户保存浏览记录
if(!customer.getsCustLeveTypeID().equals(ShopContstrant.GUEST_LEVEL_TYPE_ID)) {
commonService.saveViewHistory(customer.getTshop().get(0).getsOrgNO(), terminal, shopNO, "1", goodsID);
}
Map<String,Object> goodsDetailMap = jdbcTemplate.queryForMap(goodsInfoSql);
//获取商品图片
List<Map<String,Object>> picList = goodsPicList(goodsID, contractNO);
return Rjx.jsonOk().set("goodsDetail", goodsDetailMap).set("imgGroup", picList).toJson();
}
/**
* 查询商品图片
* @Title: goodsPicList
* @Description: TODO(这里用一句话描述这个方法的作用)
* @param: @param goodsID
* @param: @param agentContractNO
* @param: @return
* @return: List<Map<String,Object>>
* @throws
*/
public List<Map<String,Object>> goodsPicList(String goodsID,String agentContractNO ){
//查询经销商上传的图片
String agentPicSql="SELECT ID=agp.nItem,picTypeID=agp.sPicTypeID,picType=agp.sPicType,picDesc=agp.sPicDesc,url=agp.sURL "
+ " FROM tAgentGoodsPic agp LEFT JOIN tAgentContractGoods g ON g.nGoodsID = agp.nGoodsID AND g.nAgentID = agp.nAgentID and agp.nTag&1=0 and g.nTag&1=0 "
+ " WHERE g.sAgentContractNO= '"+agentContractNO+"' AND g.nGoodsID = " + goodsID +" ";
//图片库中商品图片
String picSql="SELECT ID=t.nItem,picTypeID=t.sPicTypeID,picType=t.sPicType,picDesc=t.sPicDesc,url=t.sURL FROM tGoodsPic t WHERE t.nGoodsID = " + goodsID + " and t.nTag&1=0 ";
jdbcTemplate.setDialect(new SqlServerDialect());
List<Map<String,Object>> agentPicList = jdbcTemplate.queryForList(agentPicSql);
if(agentPicList != null && agentPicList.size() >0) {
return agentPicList;
}else {
return jdbcTemplate.queryForList(picSql);
}
}
/**
* 批量查询商品价格
* @Title: queryGoodsPrice
* @Description: TODO(这里用一句话描述这个方法的作用)
* @param: @param params
* @param: @return
* @return: List<Map<String,Object>>
* @throws
*/
public String queryGoodsPrice(JSONObject jsonObj){
List goodsIDList= (List) jsonObj.get("goodsList");
String shopNO=(String)jsonObj.get("shopNO");
String custNO=(String)jsonObj.get("custNO");
String terminal=((String) jsonObj.get("terminal")).toLowerCase();
String goodsID="";
for(int i=0;i<goodsIDList.size();i++){
goodsID+=goodsIDList.get(i)+",";
}
System.out.println("custNO "+custNO);
System.out.println("shopNO "+shopNO);
System.out.println("goodsID "+goodsID);
System.out.println("goodsIDList "+goodsIDList);
TCustomer customer = userService.getCustomer(custNO, shopNO);
if(customer == null) {
return Rjx.jsonErr().setMessage("用户不存在").toJson();
}
TShop shop = customer.getTshop().get(0);
String districtID = shop.getsDistrictID();
String priceSql = GoodsSql.goodsPriceSql(goodsID, districtID, shopNO);
jdbcTemplate.setDialect(new SqlServerDialect());
List<Map<String,Object>> priceList = jdbcTemplate.queryForList(priceSql);
return Rjx.jsonOk().setData(priceList).toJson();
}
/**
* 收藏及取消收藏
* @Title: updateFlavor
* @Description: TODO(这里用一句话描述这个方法的作用)
* @param: @param params
* @param: @return
* @return: String
* @throws
*/
public String updateFlavor(Map<String,Object> params){
String goodsID=(String)params.get("goodsID");
String shopNO=(String)params.get("shopNO");
String override=(String)params.get("override");
String sqlD="delete from tFlavorGoods where sShopNO =? and nGoodsID = ?";
String sqlIn=" if not exists (select 1 from tFlavorGoods where sShopNO = ? and nGoodsID = ?)"
+" insert into tFlavorGoods (sShopNO, nGoodsID, dLastUpdateTime) "
+" values (?,?,getdate())";
jdbcTemplate.setDialect(new SqlServerDialect());
if("0".equals(override)) {
try {
jdbcTemplate.executeUpdate(sqlD, shopNO,goodsID);
return Rjx.jsonOk().setMessage("取消收藏成功").toJson();
} catch (Exception e) {
e.printStackTrace();
return Rjx.jsonErr().setMessage("取消收藏失败").toJson();
}
}else if("1".equals(override)) {
try {
jdbcTemplate.executeUpdate(sqlIn, shopNO,goodsID, shopNO,goodsID);
return Rjx.jsonOk().setMessage("收藏成功").toJson();
} catch (Exception e) {
e.printStackTrace();
return Rjx.jsonErr().setMessage("收藏失败").toJson();
}
}
return Rjx.jsonErr().setMessage("操作失败").toJson();
}
}
package com.egolm.shop.service.impl;
import java.util.Map;
import com.egolm.common.StringUtil;
import com.egolm.shop.pojo.TCustomer;
import com.egolm.shop.pojo.TShop;
import com.egolm.shop.util.ShopContstrant;
public class GoodsSql {
/**
* 查询商品详情
* @Title: goodsInfoSql
* @Description: TODO(这里用一句话描述这个方法的作用)
* @param: @param customer
* @param: @param shop
* @param: @param goodsID
* @param: @return
* @return: String
* @throws
*/
public static String goodsInfoSql(TCustomer customer,Map<String, Object> map) {
String goodsID=(String) map.get("goodsID");
String contractNO=(String) map.get("contractNO");
TShop tshop = customer.getTshop().get(0);
String goodInfoSql = "";
if(customer.getsCustLeveTypeID().equals(ShopContstrant.GUEST_LEVEL_TYPE_ID)) { //游客
goodInfoSql="SELECT TOP 1 "
+ " goodsID = g.nGoodsID, "
+ " goodsNO = g.sGoodsNO, "
+ " goodsName = g.sGoodsDesc, "
+ " contractNO = g.sAgentContractNO, "
+ " agentName=g.sAgentName,"
+ " categoryID = g.sCategoryNO, "
+ " tag=g.nTag, "
+ " barcode = g.sMainBarcode, "
+ " brandID = g.sBrandID, "
+ " brand = g.sBrand, "
+ " spec = g.sSpec, "
+ " minSaleQty = g.nMinSaleQty, "
+ " saleUnits = g.nSaleUnits, "
+ " orderUnits = g.nSaleUnits, "
+ " goodsUnit = g.sMarketUnit, "
+ " agentUnit = g.sUnit, "
+ " marketPrice = g.nMarketPrice, "
+ " salePrice = g.nSalePrice, "
+ " realSalePrice =g.nRealSalePrice, "
+ " DCPriority = g.nDCPriority, "
+ " stock = g.nStockQty, "
+ " imgPath = g.sURL, "
+ " flavor = g.Flavor,"
+ " caseUnits=g.nCaseUnits"
+ " FROM "
+ " V_DistrictGoods g "
+ " WHERE "
+ " g.nGoodsID = " + goodsID + " "
+ " AND g.sDistrictID='"+tshop.getsDistrictID()+"' AND (g.sOrgNO='"+tshop.getsOrgNO()+"' or g.sOrgNO='china') "
+ " AND g.nTag&1=0 "
;
}else {
goodInfoSql="SELECT TOP 1 "
+ " goodsID = g.nGoodsID, "
+ " goodsNO = g.sGoodsNO, "
+ " goodsName = g.sGoodsDesc, "
+ " contractNO = g.sAgentContractNO, "
+ " agentName=g.sAgentName,"
+ " categoryID = g.sCategoryNO, "
+ " tag=g.nTag, "
+ " barcode = g.sMainBarcode, "
+ " brandID = g.sBrandID, "
+ " brand = g.sBrand, "
+ " spec = g.sSpec, "
+ " minSaleQty = g.nMinSaleQty, "
+ " saleUnits = g.nSaleUnits, "
+ " orderUnits = g.nSaleUnits, "
+ " goodsUnit = g.sMarketUnit, "
+ " agentUnit = g.sUnit, "
+ " marketPrice = g.nMarketPrice, "
+ " salePrice = g.nSalePrice, "
+ " realSalePrice =g.nRealSalePrice, "
+ " DCPriority = g.nDCPriority, "
+ " stock = g.nStockQty, "
+ " imgPath = g.sURL, "
+ " flavor = g.Flavor,"
+ " caseUnits=g.nCaseUnits"
+ " FROM "
+ " V_CategoryGoods g "
+ " WHERE "
+ " g.nGoodsID = " + goodsID + " "
+ " AND g.sShopNO = '" + tshop.getsShopNO() + "' "
+ " AND g.nTag&1=0 "
;
}
if(StringUtil.isNotEmpty(contractNO)){
goodInfoSql += " AND g.sAgentContractNO='"+contractNO+"' ";
}
return goodInfoSql;
}
/**
* 商品价格SQL
* @Title: goodsPriceSql
* @Description: TODO(这里用一句话描述这个方法的作用)
* @param: @param goodsID
* @param: @param districtID
* @param: @param shopNO
* @param: @return
* @return: String
* @throws
*/
public static String goodsPriceSql(String goodsID,String districtID,String shopNO) {
String priceSql="select t.sWarehouseNO,contractNO=t.sAgentContractNO,goodsID=t.nGoodsID,"
+ "stock = isnull(aso.nStockQty,0) - isnull(aso.nLockedQty,0), "
+ "flavor = ( "
+ " CASE "
+ " WHEN f.nGoodsID IS NULL THEN "
+ " '0' "
+ " ELSE "
+ " '1' "
+ " END "
+ " ), "
+ "levelRealPrice = alp.nRealSalePrice, "
+ "realSalePrice = isnull(alp.nRealSalePrice, t.nRealSalePrice), "
+ "levelPrice = alp.nSalePrice, "
+ "salePrice = isnull(alp.nSalePrice, t.nSalePrice), "
+ "DCPriority=t.nMaxDCPriority,"
+ " tag=t.nTag "
+ " from "
+ "(SELECT "
+ " f1.nTag,f1.sDistrictID, f1.sWarehouseNO, f1.sAgentContractNO, f1.nGoodsID, f2.nMaxDCPriority, f1.nRealSalePrice,f1.nSalePrice "
+ "FROM "
+ " ( "
+ " SELECT "
+ " wd.sDistrictID, "
+ " wd.sWarehouseNO, "
+ " acw.sAgentContractNO, "
+ " acg.nGoodsID, "
+ " wd.nDCPriority, "
+ " acg.nRealSalePrice, "
+ " acg.nSalePrice,"
+ " acg.nTag "
+ " FROM "
+ " tWarehouseDistrict wd "
+ " LEFT JOIN tAgentContractWarehouse acw ON acw.sWarehouseNO = wd.sWarehouseNO "
+ " LEFT JOIN tAgentContractGoods acg ON acg.sAgentContractNO = acw.sAgentContractNO "
+ " WHERE "
+ " wd.sDistrictID = '"+districtID+"' AND wd.nTag&1=0 AND acw.nTag&1=0 "
+ " GROUP BY "
+ " wd.sDistrictID, "
+ " wd.sWarehouseNO, "
+ " acw.sAgentContractNO, "
+ " acg.nGoodsID, "
+ " wd.nDCPriority, "
+ " acg.nRealSalePrice, "
+ " acg.nSalePrice,"
+ " acg.nTag "
+ " ) f1, "
+ " ( "
+ " SELECT "
+ " wd.sDistrictID, "
+ " acw.sAgentContractNO, "
+ " acg.nGoodsID, "
+ " MIN(wd.nDCPriority) nMaxDCPriority "
+ " FROM "
+ " tWarehouseDistrict wd "
+ " LEFT JOIN tAgentContractWarehouse acw ON acw.sWarehouseNO = wd.sWarehouseNO "
+ " LEFT JOIN tAgentContractGoods acg ON acg.sAgentContractNO = acw.sAgentContractNO "
+ " WHERE "
+ " wd.sDistrictID = '"+districtID+"' AND wd.nTag&1=0 AND acw.nTag&1=0 "
+ " GROUP BY "
+ " wd.sDistrictID, "
+ " acw.sAgentContractNO, "
+ " acg.nGoodsID "
+ " ) f2 "
+ "WHERE f1.sDistrictID = f2.sDistrictID and f1.sAgentContractNO = f2.sAgentContractNO and f1.nGoodsID = f2.nGoodsID and f1.nDCPriority = f2.nMaxDCPriority )AS t "
+ "LEFT JOIN tAgentStockOnline aso on (t.sWarehouseNO =aso.sWarehouseNO AND aso.nGoodsID=t.nGoodsID AND t.sAgentContractNO = aso.sAgentContractNO ) "
+ "LEFT JOIN tFlavorGoods f ON (t.nGoodsID = f.nGoodsID AND sShopNO = '"+shopNO+"' ) "
+ " LEFT JOIN tAgentLevelPrice alp ON ( "
+ " t.nGoodsID = alp.nGoodsID "
+ " AND alp.nTag = 0 "
+ " AND alp.nLevelID in (SELECT nLevelID FROM tAgentShopLevel WHERE sShopNO = '"+shopNO+"' and nTag=0 ) ) "
+ "WHERE t.nGoodsID in ("+goodsID.substring(0,goodsID.length()-1)+") " ;
return priceSql;
}
}
\ No newline at end of file
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.bean.Rjx;
import com.egolm.common.jdbc.JdbcTemplate;
import com.egolm.shop.service.SystemCtrlService;
@Service
public class SystemCtrlServiceImpl implements SystemCtrlService {
private static final Log logger = LogFactory.getLog(SystemCtrlServiceImpl.class);
@Autowired
private JdbcTemplate jdbcTemplate;
public String queryTSystemCtrlByCode(String sCode,String langID) {
try {
String sql = "select sDesc, sSysTypeID, sSysType, sValue1, sValue2, sValue3, sMemo from tSystemCtrl where sCode = ? and nTag&1 = 0";
Map<String, Object> mapRsult = jdbcTemplate.queryForMap(sql,sCode);
return Rjx.jsonOk().setData(mapRsult).toJson();
}catch (Exception e) {
logger.error("数据字典查询出错: "+e.getMessage());
return Rjx.jsonErr().setMessage("数据字典查询出错").toJson();
}
}
}
package com.egolm.shop.service.impl;
import java.util.ArrayList;
import java.util.HashMap;
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.beans.factory.annotation.Value;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import com.egolm.common.StringUtil;
import com.egolm.common.jdbc.JdbcTemplate;
import com.egolm.common.jdbc.dialect.SqlServerDialect;
import com.egolm.shop.pojo.TCustomer;
import com.egolm.shop.pojo.TShop;
import com.egolm.shop.service.UserService;
import com.egolm.shop.util.ShopContstrant;
@Service
public class UserServiceImpl implements UserService {
private static final Log logger = LogFactory.getLog(UserServiceImpl.class);
@Value("${redis.guest.key}")
private String guestRedisKey;
@Autowired
private JdbcTemplate jdbcTemplate;
@Autowired
private RedisTemplate redisTemplate;
public TCustomer getCustomer(String custNO,String shopNO) {
if (custNO.contains(ShopContstrant.CUST_SIGN)) {
TCustomer redisCust = (TCustomer)redisTemplate.opsForHash().get(guestRedisKey, custNO);
return redisCust;
}
try {
String sql = "SELECT * FROM tCustomer WHERE sCustNO = ? AND nTag&1=0";
jdbcTemplate.setDialect(new SqlServerDialect());
TCustomer tcustomer = jdbcTemplate.queryForBean(sql, TCustomer.class, custNO);
String shopSql = "SELECT * FROM tShop WHERE nTag&1=0 and sCustNO =? ";
if(StringUtil.isNotEmpty(shopNO)) {
shopSql += " AND sShopNO = ? ";
}
List<TShop> shops = jdbcTemplate.queryForBeans(shopSql, TShop.class, custNO,shopNO);
tcustomer.setTshop(shops);
return tcustomer;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
public TShop getShop(String shopNO) {
if (StringUtil.isEmpty(shopNO)) {
return new TShop();
}
String sql = "SELECT * FROM tShop WHERE sShopNO = ? AND nTag&1=0";
jdbcTemplate.setDialect(new SqlServerDialect());
return jdbcTemplate.queryForBean(sql, TShop.class, shopNO);
}
/**
* 创建游客账号 @Title: createGuest @Description:
* TODO(这里用一句话描述这个方法的作用) @param: @return: void @throws
*/
public Map<String,Object> createGuest(Map<String, Object> params) {
String districtID = params.get("districtID") + "";
String orgNO = params.get("orgNO") + "";
TCustomer customer = new TCustomer();
String randomNum = String.valueOf(Math.random()).substring(2, 6);
String custNO = ShopContstrant.CUST_SIGN + randomNum;
customer.setsCustNO(custNO);// 游客
customer.setsCustName("游客_" + randomNum);
customer.setsCustLeveTypeID("-1");
customer.setsCustLeveType("游客");
TShop tshop = new TShop();
tshop.setsShopNO(randomNum);
tshop.setsShopName("shop_" + randomNum);
tshop.setsCustNO(customer.getsCustNO());
tshop.setsDistrictID(districtID);
tshop.setsOrgNO(orgNO);
List<TShop> listShop = new ArrayList<TShop>();
listShop.add(tshop);
customer.setTshop(listShop);
redisTemplate.opsForHash().put(guestRedisKey, custNO, customer);
Map<String,Object> map = new HashMap<String,Object>();
map.put("custNO", custNO);
map.put("custName", customer.getsCustName());
map.put("custLeveTypeID", customer.getsCustLeveTypeID());
map.put("custLeveType", customer.getsCustLeveType());
map.put("shopNO", tshop.getsShopNO());
map.put("shopName", tshop.getsShopName());
map.put("districtID", tshop.getsDistrictID());
map.put("orgNO", tshop.getsOrgNO());
return map;
}
}
package com.egolm.shop.util;
public class ShopContstrant {
public static final String CUST_SIGN = "T_"; //游客账号标记
public static final String GUEST_LEVEL_TYPE_ID = "-1" ;// 游客 custLevelTypeID 状态
}
......@@ -24,10 +24,12 @@ spring.datasource.timeBetweenEvictionRunsMillis=3600000
spring.redis.database=0
spring.redis.host=10.10.0.15
spring.redis.port=6379
spring.redis.port=16379
spring.redis.password=
spring.redis.timeout=2000
spring.redis.pool.max-active=20
spring.redis.pool.max-wait=2000
spring.redis.pool.max-idle=5
spring.redis.pool.min-idle=0
\ No newline at end of file
spring.redis.pool.min-idle=0
redis.guest.key=B2B_Guest
\ No newline at end of file
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