Commit a79a24f7 authored by Quxl's avatar Quxl

c

parent 1895bea6
......@@ -198,28 +198,12 @@ public class UserController {
@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 unionId, 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)) {
customerMap = userService.createCustomer(orgNo, openId, mobile);
} else {
throw new XException("手机号码和OPENID不能为空");
}
} else {
userService.saveOpenId((String)customerMap.get("sCustNO"), openId);
}
String custNo = (String)customerMap.get("sCustNO");
List<Map<String, Object>> shopList = userService.queryShopList(orgNo, custNo);
if(shopList.size() == 0) {
shopList = new ArrayList<Map<String, Object>>();
Map<String, Object> shopMap = userService.createShop(orgNo, customerMap);
shopList.add(shopMap);
}
customerMap.put("sShopNO", shopList.get(0).get("sShopNO"));
public String loginByOpenId(String openId, String mobile, String orgNo, String name, String unionId, String langID, HttpServletRequest request, HttpServletResponse response) {
XException.assertNotBlank(orgNo, "组织机构不能为空");
XException.assertNotBlank(openId, "OpenID不能为空");
mobile = StringUtil.isBlank(mobile) ? "" : mobile;
name = StringUtil.isBlank(name) ? "" : name;
userService.loginByOpenId(orgNo, openId, mobile, name);
return this.queryUserInfoByOpenId(orgNo, openId, langID, request, response);
}
......@@ -325,7 +309,13 @@ public class UserController {
String sCustNO = (String)customerMap.get("sCustNO");
List<Map<String, Object>> bankList = userService.queryBankList(sCustNO);
List<Map<String, Object>> shopList = userService.queryShopList(orgNo, sCustNO);
customerMap.put("sShopNO", shopList.get(0).get("sShopNO"));
for(Map<String, Object> shopMap : shopList) {
String sOrgNO = (String)shopMap.get("sOrgNO");
if(orgNo.equals(sOrgNO)) {
customerMap.put("sShopNO", shopMap.get("sShopNO"));
break;
}
}
customerMap.put("nShopID", shopList.get(0).get("nShopID"));
customerMap.put("sEmail", shopList.get(0).get("sEmail"));
customerMap.put("sShopName", shopList.get(0).get("sShopName"));
......
......@@ -49,4 +49,6 @@ public interface UserService {
public List<Map<String, Object>> queryBankList(String sCustNO);
public void loginByOpenId(String orgNo, String openId, String mobile, String name);
}
......@@ -30,6 +30,7 @@ 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.common.jdbc.ResultMutil;
import com.egolm.common.jdbc.dialect.Dialect;
import com.egolm.common.jdbc.dialect.SqlServerDialect;
import com.egolm.common.jdbc.dialect.bean.Sql;
......@@ -803,4 +804,29 @@ public class UserServiceImpl implements UserService {
return jdbcTemplate.queryForList(sql, sCustNO);
}
@Override
public void loginByOpenId(String orgNo, String openId, String mobile, String name) {
String sql = "exec up_B2BUserRegisterLogin ?, ?, ?, ?";
ResultMutil result = jdbcTemplate.executeMutil(sql, orgNo, openId, mobile, name);
List<List<Map<String, Object>>> datas = result.getDatas();
List<Map<String, Object>> sList = datas.get(0);
Map<String, Object> sMap = sList.get(0);
Object Status = sMap.get("Status");
Object ErrorMsg = sMap.get("ErrorMsg");
if(Status != null) {
Integer code = ((Number)Status).intValue();
if(code != 0) {
throwLoginError(ErrorMsg);
}
} else {
throwLoginError(ErrorMsg);
}
}
private void throwLoginError(Object errorMsg) {
if(StringUtil.isBlank(errorMsg)) {
errorMsg = "登陆失败";
}
throw new XException((String)errorMsg);
}
}
\ 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