Commit 78413d49 authored by Quxl's avatar Quxl

x

parent b7790b56
package com.egolm.shop.controller;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
......@@ -11,6 +12,7 @@ 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.CategoryService;
import io.swagger.annotations.Api;
......@@ -35,14 +37,28 @@ public class CategoryController {
@ApiImplicitParam(paramType = "query", name = "sign", dataType = "String", required = true, value = "签名", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "timestamp", dataType = "String", required = true, value = "时间戳", defaultValue = "")
})
@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);
}
@ApiOperation("分类列表")
@ApiImplicitParams({
@ApiImplicitParam(paramType = "query", name = "level", dataType = "int", required = true, value = "级别", defaultValue = "3"),
@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 = "terminal", dataType = "String", required = false, value = "终端标识", defaultValue = "wechat"),
@ApiImplicitParam(paramType = "query", name = "langID", dataType = "String", required = false, value = "语言", defaultValue = "936"),
@ApiImplicitParam(paramType = "query", name = "sign", dataType = "String", required = true, value = "签名", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "timestamp", dataType = "String", required = true, value = "时间戳", defaultValue = "")
})
@RequestMapping(value = "/queryCategoryByLevel",method=RequestMethod.GET)
public String queryCategoryByLevel(String orgNO, String scopeTypeID, Integer level, HttpServletRequest request, HttpServletResponse response) {
List<Map<String, Object>> list = categoryService.queryCategoryByLevel(orgNO, scopeTypeID, level);
return Rjx.jsonOk().set("list", list).toJson();
}
}
package com.egolm.shop.controller;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
......@@ -13,8 +15,10 @@ import org.springframework.web.bind.annotation.RestController;
import com.egolm.common.StringUtil;
import com.egolm.common.bean.Rjx;
import com.egolm.shop.config.XException;
import com.egolm.shop.pojo.TCustomer;
import com.egolm.shop.service.UserService;
import com.egolm.shop.util.I18NUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
......@@ -76,6 +80,39 @@ public class UserController {
return userService.login(params);
}
@ApiOperation("小程序登陆")
@ApiImplicitParams({
@ApiImplicitParam(paramType = "query", name = "openID", dataType = "String", required = false, value = "OPENID", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "mobile", dataType = "String", required = false, value = "手机号", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "langID", dataType = "String", required = false, value = "语言", defaultValue = "936"),
@ApiImplicitParam(paramType = "query", name = "terminal", dataType = "String", required = true, value = "终端标识", defaultValue = "wechat"),
@ApiImplicitParam(paramType = "query", name = "sign", dataType = "String", required = true, value = "签名", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "timestamp", dataType = "String", required = true, value = "时间戳", defaultValue = "")
})
@RequestMapping(value = "/loginByOpenId",method=RequestMethod.POST)
public String loginByOpenId(String openId, String mobile, String langID, HttpServletRequest request, HttpServletResponse response) {
Map<String, Object> customerMap = userService.queryCustomerByOpenId(openId);
if(customerMap == null) {
customerMap = userService.queryCustomerByMobile(mobile);
}
if(customerMap == null) {
if(StringUtil.isNotBlank(openId, mobile)) {
throw new XException("手机号码和OPENID不能为空");
}
customerMap = userService.createCustomer(openId, mobile);
}
String custNo = (String)customerMap.get("sCustNO");
List<Map<String, Object>> shopList = userService.queryShopList(custNo);
if(shopList.size() == 0) {
shopList = new ArrayList<Map<String, Object>>();
Map<String, Object> shopMap = userService.createShop(customerMap);
shopList.add(shopMap);
}
return Rjx.jsonOk().set("customer", customerMap).set("shopList", shopList).setMessage(I18NUtils.getMessage(langID, "Msg_Login_success")).toJson();
}
@ApiOperation("获取用户信息")
@ApiImplicitParams({
......
package com.egolm.shop.service;
import java.util.List;
import java.util.Map;
public interface CategoryService {
public String queryCategory(Map<String,Object> params);
public List<Map<String, Object>> queryCategoryByLevel(String orgNO, String scopeTypeID, Integer level);
}
package com.egolm.shop.service;
import java.util.List;
import java.util.Map;
import com.egolm.shop.pojo.TCustomer;
......@@ -23,4 +24,15 @@ public interface UserService {
public boolean checkShopExists(String custNO,String shopNO);
public String modifyShopAuthInfo(Map<String, Object> parameters);
public Map<String, Object> queryCustomerByOpenId(String openId);
public Map<String, Object> queryCustomerByMobile(String mobile);
public Map<String, Object> createCustomer(String openId, String mobile);
public List<Map<String, Object>> queryShopList(String custNo);
public Map<String, Object> createShop(Map<String, Object> customerMap);
}
......@@ -65,4 +65,10 @@ public class CategoryServiceImpl implements CategoryService {
}
}
public List<Map<String, Object>> queryCategoryByLevel(String orgNO, String scopeTypeID, Integer level) {
String three="select categoryID=sCategoryNO,categoryName=sCategoryDesc,parentID=sUpCategoryNO from tOrgCategory where sOrgNO=? and sScopeTypeID=? and nCategoryLevel= ?";
List<Map<String,Object>> list3=jdbcTemplate.queryForList(three, orgNO, scopeTypeID, level);
return list3;
}
}
......@@ -446,4 +446,46 @@ public class UserServiceImpl implements UserService {
return Rjx.jsonOk().setMessage(I18NUtils.getMessage(langID, "Msg_SMS_success")).toJson();
}
@Override
public Map<String, Object> queryCustomerByOpenId(String openId) {
List<Map<String, Object>> list = jdbcTemplate.queryForList("select * from tCustomer where sOpenID = ?", openId);
return list.size() == 0 ? null : list.get(0);
}
@Override
public Map<String, Object> queryCustomerByMobile(String mobile) {
List<Map<String, Object>> list = jdbcTemplate.queryForList("select * from tCustomer where sMobile = ?", mobile);
return list.size() == 0 ? null : list.get(0);
}
@Override
public Map<String, Object> createCustomer(String openId, String mobile) {
Map<String, Object> map = new HashMap<String, Object>();
map.put("sOpenID", openId);
map.put("sMobile", mobile);
map.put("sCustNO", mobile);
map.put("sCustName", mobile);
map.put("sCustLevelType", "普通客户");
map.put("sCustLevelTypeID", "1");
map.put("nTag", 0);
map.put("sCreateUser", "");
map.put("dCreateDate", new Date());
map.put("dLastUpdateTime", new Date());
map.put("nStep", 1);
jdbcTemplate.save("tCustomer", map);
return map;
}
@Override
public List<Map<String, Object>> queryShopList(String custNo) {
List<Map<String, Object>> shopList = jdbcTemplate.queryForList("select * from tShop where sCustNO = ?", custNo);
return shopList;
}
@Override
public Map<String, Object> createShop(Map<String, Object> customerMap) {
return null;
}
}
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