Commit 21a10411 authored by Quxl's avatar Quxl

x

parent 78413d49
......@@ -80,40 +80,6 @@ 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({
@ApiImplicitParam(paramType = "query", name = "custNO", dataType = "String", required = true, value = "账号编码", defaultValue = ""),
......@@ -205,6 +171,38 @@ public class UserController {
return userService.sendSms(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 = "orgNo", dataType = "String", required = false, value = "orgNo", 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 orgNo, 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(orgNo, customerMap);
shopList.add(shopMap);
}
return Rjx.jsonOk().set("customer", customerMap).set("shopList", shopList).setMessage(I18NUtils.getMessage(langID, "Msg_Login_success")).toJson();
}
@ApiOperation("修改认证信息")
@ApiImplicitParams({
@ApiImplicitParam(paramType = "query", dataType = "int", name = "shopId", value = "店铺ID"),
......
......@@ -33,6 +33,6 @@ public interface UserService {
public List<Map<String, Object>> queryShopList(String custNo);
public Map<String, Object> createShop(Map<String, Object> customerMap);
public Map<String, Object> createShop(String orgNo, Map<String, Object> customerMap);
}
package com.egolm.shop.service.impl;
import java.math.BigDecimal;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.sql.Statement;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Date;
......@@ -13,6 +17,9 @@ 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.jdbc.core.PreparedStatementCreator;
import org.springframework.jdbc.support.GeneratedKeyHolder;
import org.springframework.jdbc.support.KeyHolder;
import org.springframework.stereotype.Service;
import com.alibaba.fastjson.JSONObject;
......@@ -20,7 +27,9 @@ import com.egolm.common.HttpsUtil;
import com.egolm.common.StringUtil;
import com.egolm.common.bean.Rjx;
import com.egolm.common.jdbc.JdbcTemplate;
import com.egolm.common.jdbc.dialect.Dialect;
import com.egolm.common.jdbc.dialect.SqlServerDialect;
import com.egolm.common.jdbc.dialect.bean.Sql;
import com.egolm.shop.encrypt.EgoPasswordEncoder;
import com.egolm.shop.pojo.TCommon;
import com.egolm.shop.pojo.TCustomer;
......@@ -483,9 +492,58 @@ public class UserServiceImpl implements UserService {
}
@Override
public Map<String, Object> createShop(Map<String, Object> customerMap) {
return null;
public Map<String, Object> createShop(String orgNo, Map<String, Object> customerMap) {
Map<String, Object> map = new HashMap<String, Object>();
String sCustNO = (String)customerMap.get("sCustNO");
map.put("sCustNO", sCustNO);
map.put("sShopNO", "");
map.put("sShopName", "无名小店");
map.put("sOrgNO", orgNo);
map.put("sShopTypeID", "1");
map.put("sShopType", "杂货店");
map.put("sScopeTypeID", "1");
map.put("sScopeType", "杂货店");
map.put("sProvinceID", "");
map.put("sProvince", "");
map.put("sCityID", "");
map.put("sCity", "");
map.put("sDistrictID", "");
map.put("sDistrict", "");
map.put("nTag", 0);
map.put("sCreateUser", "");
map.put("dCreateDate", new Date());
map.put("dLastUpdateTime", new Date());
map.put("nProperty", 0);
map.put("nAgreementStatus", 1);
Dialect dialect = jdbcTemplate.getDialect();
Sql desc = dialect.argsInsert("tShop", map);
String sql = desc.getSql();
Object[] args = desc.getArgs();
KeyHolder keyHolder = new GeneratedKeyHolder();
jdbcTemplate.update(new PreparedStatementCreator() {
public PreparedStatement createPreparedStatement(Connection connection) throws SQLException {
PreparedStatement ps = connection.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS);
for(int i = 0; i <args.length; i++) {
Object argObj = args[i];
if(argObj instanceof java.util.Date) {
java.util.Date argDate = (java.util.Date)argObj;
ps.setObject(i+1, new java.sql.Timestamp(argDate.getTime()));
} else if(argObj.getClass().isEnum()) {
ps.setObject(i+1, args[i].toString());
} else {
ps.setObject(i+1, args[i]);
}
}
return ps;
}
}, keyHolder);
Object key = keyHolder.getKey();
jdbcTemplate.update("update tShop set sShopNO = RIGHT('00000000'+ CAST(nShopID as varchar(8)), 8) where nShopID = ?", key);
String sShopNO = jdbcTemplate.queryForString("select sShopNO from tShop where nShopID = ?", key);
map.put("sShopNO", sShopNO);
return map;
}
}
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