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);
}
}
......@@ -12,9 +12,11 @@ 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.StringUtil;
import com.egolm.common.bean.Rjx;
import com.egolm.common.jdbc.Page;
import com.egolm.common.web.ServletUtil;
import com.egolm.shop.service.GoodsService;
import io.swagger.annotations.Api;
......@@ -32,28 +34,28 @@ public class GoodsController {
@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 = "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"),
})
@RequestMapping(value = "/thinkLike",method=RequestMethod.GET)
public String thinkLike(HttpServletRequest request) {
String orgNO = request.getParameter("OrgNO");
String compNO = request.getParameter("CompNO");
String orgNO = request.getParameter("orgNO");
String compNO = request.getParameter("compNO");
String userNO = "nouserNO";
try {
userNO = request.getParameter("UserNO");
userNO = request.getParameter("userNO");
if(StringUtil.isEmpty(userNO)) {
userNO = "nouserNO";
}
} catch (Exception e) {
userNO = "nouserNO";
}
String langId = request.getParameter("LangID");
String langId = request.getParameter("langID");
String index = "1";
String limit = "20";
String limit = "10";
if(!StringUtil.isNotEmpty(orgNO,compNO,limit,index)) {
return Rjx.json().setCode(-1).setMessage("参数缺失").toJson();
......@@ -75,17 +77,18 @@ public class GoodsController {
@ApiOperation("热销商品列表")
@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 = "orgNO", dataType = "String", required = true, value = "区域编号", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "compNO", dataType = "String", required = true, value = "组件编号", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "index", dataType = "String", required = false, value = "第几页", defaultValue = "1"),
@ApiImplicitParam(paramType = "query", name = "limit", dataType = "String", required = false, value = "每页数量", defaultValue = "20"),
@ApiImplicitParam(paramType = "query", name = "langID", dataType = "String", required = false, value = "语言", defaultValue = "936"),
})
@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"));
params.put("OrgNO", request.getParameter("orgNO"));
params.put("CompNO", request.getParameter("compNO"));
Page page=new Page();
page.setIndex(Long.valueOf(request.getParameter("index")==null?"1":request.getParameter("index")));
page.setLimit(Long.valueOf(request.getParameter("limit")==null?"20":request.getParameter("limit")));
......@@ -96,27 +99,142 @@ public class GoodsController {
@ApiOperation("分类商品页数据")
@ApiImplicitParams({
@ApiImplicitParam(paramType = "query", name = "OrgNO", dataType = "String", required = true, value = "区域编号", defaultValue = "SHBS"),
@ApiImplicitParam(paramType = "query", name = "ShopNO", dataType = "String", required = false, value = "店铺件编号", defaultValue = "00029997"),
@ApiImplicitParam(paramType = "query", name = "CategoryNOA", dataType = "String", required = false, value = "一级分类编码", defaultValue = "%"),
@ApiImplicitParam(paramType = "query", name = "CategoryNOB", dataType = "String", required = false, value = "二级分类编码", defaultValue = "%"),
@ApiImplicitParam(paramType = "query", name = "orgNO", dataType = "String", required = true, value = "区域编号", defaultValue = "SHBS"),
@ApiImplicitParam(paramType = "query", name = "shopNO", dataType = "String", required = false, value = "店铺件编号", defaultValue = "00029997"),
@ApiImplicitParam(paramType = "query", name = "categoryNOA", dataType = "String", required = false, value = "一级分类编码", defaultValue = "%"),
@ApiImplicitParam(paramType = "query", name = "categoryNOB", dataType = "String", required = false, value = "二级分类编码", defaultValue = "%"),
@ApiImplicitParam(paramType = "query", name = "index", dataType = "String", required = false, value = "第几页", defaultValue = "1"),
@ApiImplicitParam(paramType = "query", name = "limit", dataType = "String", required = false, value = "每页数量", defaultValue = "20"),
@ApiImplicitParam(paramType = "query", name = "langID", dataType = "String", required = false, value = "语言", defaultValue = "936"),
})
@RequestMapping(value = "/getCategoryGoods",method=RequestMethod.GET)
public String getCategoryGoods(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")==null?"":request.getParameter("ShopNO"));
params.put("CategoryNOA", request.getParameter("categoryNOA")==null?"%":request.getParameter("categoryNOA"));
params.put("CategoryNOB", request.getParameter("categoryNOB")==null?"%":request.getParameter("categoryNOB"));
Page page=new Page();
page.setIndex(Long.valueOf(request.getParameter("index")==null?"1":request.getParameter("index")));
page.setLimit(Long.valueOf(request.getParameter("limit")==null?"20":request.getParameter("limit")));
page.setLimitKey("GoodsID desc");
listMap=goodsService.GetCategoryGoods(params,page);
return Rjx.jsonOk().set("list", listMap).set("page",page).toJson();
}
@ApiOperation("热搜词")
@ApiImplicitParams({
@ApiImplicitParam(paramType = "query", name = "orgNO", dataType = "String", required = true, value = "区域编号", defaultValue = "SHBS"),
@ApiImplicitParam(paramType = "query", name = "shopNO", dataType = "String", required = false, value = "店铺编号", defaultValue = "00029997"),
@ApiImplicitParam(paramType = "query", name = "index", dataType = "String", required = false, value = "第几页", defaultValue = "1"),
@ApiImplicitParam(paramType = "query", name = "limit", dataType = "String", required = false, value = "每页数量", defaultValue = "20"),
@ApiImplicitParam(paramType = "query", name = "langID", dataType = "String", required = false, value = "语言", defaultValue = "936"),
})
@RequestMapping(value = "/GetCategoryGoods",method=RequestMethod.GET)
public String GetCategoryGoods(HttpServletRequest request, HttpServletResponse response) {
@RequestMapping(value = "/hotSearchKey",method=RequestMethod.GET)
public String hotSearchKey(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")==null?"":request.getParameter("ShopNO"));
params.put("CategoryNOA", request.getParameter("CategoryNOA")==null?"%":request.getParameter("CategoryNOA"));
params.put("CategoryNOB", request.getParameter("CategoryNOB")==null?"%":request.getParameter("CategoryNOB"));
Page page=new Page();
page.setIndex(Long.valueOf(request.getParameter("index")==null?"1":request.getParameter("index")));
page.setLimit(Long.valueOf(request.getParameter("limit")==null?"20":request.getParameter("limit")));
page.setLimit(Long.valueOf(request.getParameter("limit")==null?"10":request.getParameter("limit")));
listMap=goodsService.hotSearchKey(params,page);
return Rjx.jsonOk().set("list", listMap).set("page",page).toJson();
}
@ApiOperation("统一搜索(未完成,要弄搜索引擎)")
@ApiImplicitParams({
@ApiImplicitParam(paramType = "query", name = "orgNO", dataType = "String", required = true, value = "区域编号", defaultValue = "SHBS"),
@ApiImplicitParam(paramType = "query", name = "shopNO", dataType = "String", required = false, value = "店铺编号", defaultValue = "00029997"),
@ApiImplicitParam(paramType = "query", name = "queryStr", dataType = "String", required = false, value = "搜索内容()", defaultValue = "%"),
@ApiImplicitParam(paramType = "query", name = "index", dataType = "String", required = false, value = "第几页", defaultValue = "1"),
@ApiImplicitParam(paramType = "query", name = "limit", dataType = "String", required = false, value = "每页数量", defaultValue = "20"),
@ApiImplicitParam(paramType = "query", name = "langID", dataType = "String", required = false, value = "语言", defaultValue = "936"),
})
@RequestMapping(value = "/searchGoods",method=RequestMethod.GET)
public String searchGoods(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")==null?"":request.getParameter("shopNO"));
params.put("queryStr", request.getParameter("queryStr")==null?"%":request.getParameter("queryStr"));
Page page=new Page();
page.setIndex(Long.valueOf(request.getParameter("index")==null?"1":request.getParameter("index")));
page.setLimit(Long.valueOf(request.getParameter("limit")==null?"10":request.getParameter("limit")));
page.setLimitKey("GoodsID desc");
listMap=goodsService.GetCategoryGoods(params,page);
return Rjx.jsonOk().set("list", listMap).set("page",page).toJson();
}
@ApiOperation("商品详情")
@ApiImplicitParams({
@ApiImplicitParam(paramType = "query", name = "goodsID", dataType = "String", required = true, value = "商品编号", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "contractNO", dataType = "String", required = false, value = "合同编号", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "custNO", dataType = "String", required = true, value = "用户账号", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "shopNO", dataType = "String", required = true, value = "店铺编号", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "terminal", dataType = "String", required = true, value = "终端", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "langID", dataType = "String", required = false, value = "语言", defaultValue = "936"),
})
@RequestMapping(value = "/goodsDetail",method=RequestMethod.GET)
public String goodsDetail(HttpServletRequest request, HttpServletResponse response) {
Map<String,Object> params=new HashMap<>();
params.put("custNO", request.getParameter("custNO"));
params.put("shopNO", request.getParameter("shopNO")==null?"":request.getParameter("shopNO"));
params.put("goodsID", request.getParameter("goodsID")==null?"":request.getParameter("goodsID"));
params.put("contractNO", request.getParameter("contractNO")==null?"":request.getParameter("contractNO"));
params.put("langID", request.getParameter("langID")==null?936:request.getParameter("langID"));
params.put("terminal", request.getParameter("terminal")==null?"":request.getParameter("terminal"));
return goodsService.goodsDetail(params);
}
@ApiOperation("批量查询商品价格 (参数为json对象)")
@ApiImplicitParams({
@ApiImplicitParam(paramType = "query", dataType = "String", required = false, value = "JSON格式", defaultValue = "{\"goodsList\": [\"10\",\"12\"],\"custNO\": \"15996801133\",\"shopNO\": \"00029975\",\"terminal\": \"wechat\",\"langID\": 936}"),
})
@RequestMapping(value = "/queryGoodsPrice",method=RequestMethod.POST,produces = "application/json")
public String queryGoodsPrice(HttpServletRequest request, HttpServletResponse response) {
String reqJson = ServletUtil.readReqJson(request);
JSONObject jsonObj = JSONObject.parseObject(reqJson);
System.out.println("reqJson-------"+reqJson);
return goodsService.queryGoodsPrice(jsonObj);
}
@ApiOperation("收藏及取消收藏")
@ApiImplicitParams({
@ApiImplicitParam(paramType = "query", name = "goodsID", dataType = "String", required = true, value = "商品编号", defaultValue = "10"),
@ApiImplicitParam(paramType = "query", name = "shopNO", dataType = "String", required = true, value = "店铺编号", defaultValue = "00029975"),
@ApiImplicitParam(paramType = "query", name = "override", dataType = "String", required = true, value = "收藏状态(1为收藏,0为取消)", defaultValue = "1"),
@ApiImplicitParam(paramType = "query", name = "langID", dataType = "String", required = false, value = "语言", defaultValue = "936"),
})
@RequestMapping(value = "/myFlavor",method=RequestMethod.GET)
public String myFlavor(HttpServletRequest request, HttpServletResponse response) {
String goodsID = request.getParameter("goodsID");
String shopNO = request.getParameter("shopNO");
String override = request.getParameter("override");
String langID = request.getParameter("langID");
Map<String,Object> params=new HashMap<>();
params.put("goodsID", goodsID);
params.put("shopNO", shopNO);
params.put("override", override);
params.put("langID", langID);
return goodsService.updateFlavor(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;
}
}
package com.egolm.shop.pojo;
import javax.persistence.Entity;
import javax.persistence.Id;
import java.util.Date;
import java.math.BigDecimal;
/**
* @author 曲欣亮
* @since 2018-10-09
* @version v-1.0
*/
@Entity(name="tShop")
public class TShop implements java.io.Serializable {
private static final long serialVersionUID = 1L;
private BigDecimal nStoreArea;
private String sGender;
private Date dCreateDate;
private String sScopeType;
private String sCityID;
private String sShopName;
private Date dLastUpdateTime;
private String sMemo;
private String sFax;
private String sSalesmanNO2;
private String sShopTypeID;
private Integer nCashier;
private Integer nProperty;
private String sEmail;
private Integer nTag;
private String sTerminalType;
private String sShopType;
private Integer nFreezer;
@Id
private Integer nShopID;
private Integer nAgreementStatus;
private String sLongitude;
private Integer nInternet;
private String sDistrict;
private String sConfirmUser;
private String sContacts;
private String sStreetID;
private String sCustNO;
private String sPostalcode;
private String sLatitude;
private Date dLastSaleTime;
private String sProvinceID;
private String sStreet;
private String sOrgNO;
private Date dFirstSaleDate;
private String sShopPolicyNO;
private Date dLatestVisitTime;
private String sCity;
private Integer nShopAge;
private String sShopNO;
private String sDistrictID;
private Date dConfirmDate;
private String sSalesmanNO1;
private String sShopFacia;
private String sTel;
private String sAddress;
private String sCreateUser;
private String sProvince;
private String sTerminalTypeID;
private String sScopeTypeID;
/**
* 无参数构造方法
*/
public TShop () {
super();
}
/**
* 全参数构造方法
* @param nStoreArea
* @param sGender
* @param dCreateDate
* @param sScopeType
* @param sCityID
* @param sShopName
* @param dLastUpdateTime
* @param sMemo
* @param sFax
* @param sSalesmanNO2
* @param sShopTypeID
* @param nCashier
* @param nProperty
* @param sEmail
* @param nTag
* @param sTerminalType
* @param sShopType
* @param nFreezer
* @param nShopID
* @param nAgreementStatus
* @param sLongitude
* @param nInternet
* @param sDistrict
* @param sConfirmUser
* @param sContacts
* @param sStreetID
* @param sCustNO
* @param sPostalcode
* @param sLatitude
* @param dLastSaleTime
* @param sProvinceID
* @param sStreet
* @param sOrgNO
* @param dFirstSaleDate
* @param sShopPolicyNO
* @param dLatestVisitTime
* @param sCity
* @param nShopAge
* @param sShopNO
* @param sDistrictID
* @param dConfirmDate
* @param sSalesmanNO1
* @param sShopFacia
* @param sTel
* @param sAddress
* @param sCreateUser
* @param sProvince
* @param sTerminalTypeID
* @param sScopeTypeID
*/
public TShop(BigDecimal nStoreArea, String sGender, Date dCreateDate, String sScopeType, String sCityID, String sShopName, Date dLastUpdateTime, String sMemo, String sFax, String sSalesmanNO2, String sShopTypeID, Integer nCashier, Integer nProperty, String sEmail, Integer nTag, String sTerminalType, String sShopType, Integer nFreezer, Integer nShopID, Integer nAgreementStatus, String sLongitude, Integer nInternet, String sDistrict, String sConfirmUser, String sContacts, String sStreetID, String sCustNO, String sPostalcode, String sLatitude, Date dLastSaleTime, String sProvinceID, String sStreet, String sOrgNO, Date dFirstSaleDate, String sShopPolicyNO, Date dLatestVisitTime, String sCity, Integer nShopAge, String sShopNO, String sDistrictID, Date dConfirmDate, String sSalesmanNO1, String sShopFacia, String sTel, String sAddress, String sCreateUser, String sProvince, String sTerminalTypeID, String sScopeTypeID) {
this.nStoreArea = nStoreArea;
this.sGender = sGender;
this.dCreateDate = dCreateDate;
this.sScopeType = sScopeType;
this.sCityID = sCityID;
this.sShopName = sShopName;
this.dLastUpdateTime = dLastUpdateTime;
this.sMemo = sMemo;
this.sFax = sFax;
this.sSalesmanNO2 = sSalesmanNO2;
this.sShopTypeID = sShopTypeID;
this.nCashier = nCashier;
this.nProperty = nProperty;
this.sEmail = sEmail;
this.nTag = nTag;
this.sTerminalType = sTerminalType;
this.sShopType = sShopType;
this.nFreezer = nFreezer;
this.nShopID = nShopID;
this.nAgreementStatus = nAgreementStatus;
this.sLongitude = sLongitude;
this.nInternet = nInternet;
this.sDistrict = sDistrict;
this.sConfirmUser = sConfirmUser;
this.sContacts = sContacts;
this.sStreetID = sStreetID;
this.sCustNO = sCustNO;
this.sPostalcode = sPostalcode;
this.sLatitude = sLatitude;
this.dLastSaleTime = dLastSaleTime;
this.sProvinceID = sProvinceID;
this.sStreet = sStreet;
this.sOrgNO = sOrgNO;
this.dFirstSaleDate = dFirstSaleDate;
this.sShopPolicyNO = sShopPolicyNO;
this.dLatestVisitTime = dLatestVisitTime;
this.sCity = sCity;
this.nShopAge = nShopAge;
this.sShopNO = sShopNO;
this.sDistrictID = sDistrictID;
this.dConfirmDate = dConfirmDate;
this.sSalesmanNO1 = sSalesmanNO1;
this.sShopFacia = sShopFacia;
this.sTel = sTel;
this.sAddress = sAddress;
this.sCreateUser = sCreateUser;
this.sProvince = sProvince;
this.sTerminalTypeID = sTerminalTypeID;
this.sScopeTypeID = sScopeTypeID;
}
public void setnStoreArea(BigDecimal nStoreArea) {
this.nStoreArea = nStoreArea;
}
public BigDecimal getnStoreArea() {
return nStoreArea;
}
public void setsGender(String sGender) {
this.sGender = sGender;
}
public String getsGender() {
return sGender;
}
public void setdCreateDate(Date dCreateDate) {
this.dCreateDate = dCreateDate;
}
public Date getdCreateDate() {
return dCreateDate;
}
public void setsScopeType(String sScopeType) {
this.sScopeType = sScopeType;
}
public String getsScopeType() {
return sScopeType;
}
public void setsCityID(String sCityID) {
this.sCityID = sCityID;
}
public String getsCityID() {
return sCityID;
}
public void setsShopName(String sShopName) {
this.sShopName = sShopName;
}
public String getsShopName() {
return sShopName;
}
public void setdLastUpdateTime(Date dLastUpdateTime) {
this.dLastUpdateTime = dLastUpdateTime;
}
public Date getdLastUpdateTime() {
return dLastUpdateTime;
}
public void setsMemo(String sMemo) {
this.sMemo = sMemo;
}
public String getsMemo() {
return sMemo;
}
public void setsFax(String sFax) {
this.sFax = sFax;
}
public String getsFax() {
return sFax;
}
public void setsSalesmanNO2(String sSalesmanNO2) {
this.sSalesmanNO2 = sSalesmanNO2;
}
public String getsSalesmanNO2() {
return sSalesmanNO2;
}
public void setsShopTypeID(String sShopTypeID) {
this.sShopTypeID = sShopTypeID;
}
public String getsShopTypeID() {
return sShopTypeID;
}
public void setnCashier(Integer nCashier) {
this.nCashier = nCashier;
}
public Integer getnCashier() {
return nCashier;
}
public void setnProperty(Integer nProperty) {
this.nProperty = nProperty;
}
public Integer getnProperty() {
return nProperty;
}
public void setsEmail(String sEmail) {
this.sEmail = sEmail;
}
public String getsEmail() {
return sEmail;
}
public void setnTag(Integer nTag) {
this.nTag = nTag;
}
public Integer getnTag() {
return nTag;
}
public void setsTerminalType(String sTerminalType) {
this.sTerminalType = sTerminalType;
}
public String getsTerminalType() {
return sTerminalType;
}
public void setsShopType(String sShopType) {
this.sShopType = sShopType;
}
public String getsShopType() {
return sShopType;
}
public void setnFreezer(Integer nFreezer) {
this.nFreezer = nFreezer;
}
public Integer getnFreezer() {
return nFreezer;
}
public void setnShopID(Integer nShopID) {
this.nShopID = nShopID;
}
public Integer getnShopID() {
return nShopID;
}
public void setnAgreementStatus(Integer nAgreementStatus) {
this.nAgreementStatus = nAgreementStatus;
}
public Integer getnAgreementStatus() {
return nAgreementStatus;
}
public void setsLongitude(String sLongitude) {
this.sLongitude = sLongitude;
}
public String getsLongitude() {
return sLongitude;
}
public void setnInternet(Integer nInternet) {
this.nInternet = nInternet;
}
public Integer getnInternet() {
return nInternet;
}
public void setsDistrict(String sDistrict) {
this.sDistrict = sDistrict;
}
public String getsDistrict() {
return sDistrict;
}
public void setsConfirmUser(String sConfirmUser) {
this.sConfirmUser = sConfirmUser;
}
public String getsConfirmUser() {
return sConfirmUser;
}
public void setsContacts(String sContacts) {
this.sContacts = sContacts;
}
public String getsContacts() {
return sContacts;
}
public void setsStreetID(String sStreetID) {
this.sStreetID = sStreetID;
}
public String getsStreetID() {
return sStreetID;
}
public void setsCustNO(String sCustNO) {
this.sCustNO = sCustNO;
}
public String getsCustNO() {
return sCustNO;
}
public void setsPostalcode(String sPostalcode) {
this.sPostalcode = sPostalcode;
}
public String getsPostalcode() {
return sPostalcode;
}
public void setsLatitude(String sLatitude) {
this.sLatitude = sLatitude;
}
public String getsLatitude() {
return sLatitude;
}
public void setdLastSaleTime(Date dLastSaleTime) {
this.dLastSaleTime = dLastSaleTime;
}
public Date getdLastSaleTime() {
return dLastSaleTime;
}
public void setsProvinceID(String sProvinceID) {
this.sProvinceID = sProvinceID;
}
public String getsProvinceID() {
return sProvinceID;
}
public void setsStreet(String sStreet) {
this.sStreet = sStreet;
}
public String getsStreet() {
return sStreet;
}
public void setsOrgNO(String sOrgNO) {
this.sOrgNO = sOrgNO;
}
public String getsOrgNO() {
return sOrgNO;
}
public void setdFirstSaleDate(Date dFirstSaleDate) {
this.dFirstSaleDate = dFirstSaleDate;
}
public Date getdFirstSaleDate() {
return dFirstSaleDate;
}
public void setsShopPolicyNO(String sShopPolicyNO) {
this.sShopPolicyNO = sShopPolicyNO;
}
public String getsShopPolicyNO() {
return sShopPolicyNO;
}
public void setdLatestVisitTime(Date dLatestVisitTime) {
this.dLatestVisitTime = dLatestVisitTime;
}
public Date getdLatestVisitTime() {
return dLatestVisitTime;
}
public void setsCity(String sCity) {
this.sCity = sCity;
}
public String getsCity() {
return sCity;
}
public void setnShopAge(Integer nShopAge) {
this.nShopAge = nShopAge;
}
public Integer getnShopAge() {
return nShopAge;
}
public void setsShopNO(String sShopNO) {
this.sShopNO = sShopNO;
}
public String getsShopNO() {
return sShopNO;
}
public void setsDistrictID(String sDistrictID) {
this.sDistrictID = sDistrictID;
}
public String getsDistrictID() {
return sDistrictID;
}
public void setdConfirmDate(Date dConfirmDate) {
this.dConfirmDate = dConfirmDate;
}
public Date getdConfirmDate() {
return dConfirmDate;
}
public void setsSalesmanNO1(String sSalesmanNO1) {
this.sSalesmanNO1 = sSalesmanNO1;
}
public String getsSalesmanNO1() {
return sSalesmanNO1;
}
public void setsShopFacia(String sShopFacia) {
this.sShopFacia = sShopFacia;
}
public String getsShopFacia() {
return sShopFacia;
}
public void setsTel(String sTel) {
this.sTel = sTel;
}
public String getsTel() {
return sTel;
}
public void setsAddress(String sAddress) {
this.sAddress = sAddress;
}
public String getsAddress() {
return sAddress;
}
public void setsCreateUser(String sCreateUser) {
this.sCreateUser = sCreateUser;
}
public String getsCreateUser() {
return sCreateUser;
}
public void setsProvince(String sProvince) {
this.sProvince = sProvince;
}
public String getsProvince() {
return sProvince;
}
public void setsTerminalTypeID(String sTerminalTypeID) {
this.sTerminalTypeID = sTerminalTypeID;
}
public String getsTerminalTypeID() {
return sTerminalTypeID;
}
public void setsScopeTypeID(String sScopeTypeID) {
this.sScopeTypeID = sScopeTypeID;
}
public String getsScopeTypeID() {
return sScopeTypeID;
}
}
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
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