|
@@ -20,6 +20,7 @@ import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Controller;
|
|
import org.springframework.stereotype.Controller;
|
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
@@ -129,12 +130,14 @@ public class AppUserInfoController {
|
|
*/
|
|
*/
|
|
@RequestMapping(value = "/addAppUserInfo", method = RequestMethod.POST)
|
|
@RequestMapping(value = "/addAppUserInfo", method = RequestMethod.POST)
|
|
@ResponseBody
|
|
@ResponseBody
|
|
|
|
+ @Transactional
|
|
public String addAppUserInfo(@RequestBody AppUserInfoRequest request){
|
|
public String addAppUserInfo(@RequestBody AppUserInfoRequest request){
|
|
Gson gson =new Gson();
|
|
Gson gson =new Gson();
|
|
ResultData resultData=null;
|
|
ResultData resultData=null;
|
|
try{
|
|
try{
|
|
|
|
+ logger.info("前端传入参数:" +request.toString());
|
|
AppUserInfo appUserInfo =new AppUserInfo();
|
|
AppUserInfo appUserInfo =new AppUserInfo();
|
|
- //CustomerPoints customerPoints = new CustomerPoints();
|
|
|
|
|
|
+ CustomerPoints customerPoints = new CustomerPoints();
|
|
String openId = ""; //此参数用于查询该用户是否已注册过
|
|
String openId = ""; //此参数用于查询该用户是否已注册过
|
|
if(request.getUserType()!=null){
|
|
if(request.getUserType()!=null){
|
|
//1-微信公众号
|
|
//1-微信公众号
|
|
@@ -143,63 +146,67 @@ public class AppUserInfoController {
|
|
appUserInfo.setBlogToken(request.getBlogToken());
|
|
appUserInfo.setBlogToken(request.getBlogToken());
|
|
openId = request.getBlogOpenid();
|
|
openId = request.getBlogOpenid();
|
|
appUserInfo.setBlogOpenid(openId);
|
|
appUserInfo.setBlogOpenid(openId);
|
|
- //customerPoints.setBlogOpenId(openId);
|
|
|
|
|
|
+ customerPoints.setBlogOpenId(openId);
|
|
//2-微信小程序
|
|
//2-微信小程序
|
|
}else if(request.getUserType().equals("2") &&StringUtils.isNotBlank(request.getMinaOpenid())){
|
|
}else if(request.getUserType().equals("2") &&StringUtils.isNotBlank(request.getMinaOpenid())){
|
|
appUserInfo.setUserType(request.getUserType());
|
|
appUserInfo.setUserType(request.getUserType());
|
|
appUserInfo.setMinaToken(request.getMinaToken());
|
|
appUserInfo.setMinaToken(request.getMinaToken());
|
|
openId = request.getMinaOpenid();
|
|
openId = request.getMinaOpenid();
|
|
appUserInfo.setMinaOpenid(openId);
|
|
appUserInfo.setMinaOpenid(openId);
|
|
- //customerPoints.setMinaOpenId(openId);
|
|
|
|
|
|
+ customerPoints.setMinaOpenId(openId);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if(StringUtils.isNotBlank(request.getBlogNickName())){
|
|
if(StringUtils.isNotBlank(request.getBlogNickName())){
|
|
appUserInfo.setBlogNickName(request.getBlogNickName());
|
|
appUserInfo.setBlogNickName(request.getBlogNickName());
|
|
- //customerPoints.setCustomerName(request.getBlogNickName());
|
|
|
|
|
|
+ customerPoints.setCustomerName(request.getBlogNickName());
|
|
}
|
|
}
|
|
if(StringUtils.isNotBlank(request.getMobilePhone())){
|
|
if(StringUtils.isNotBlank(request.getMobilePhone())){
|
|
appUserInfo.setMobilePhone(request.getMobilePhone());
|
|
appUserInfo.setMobilePhone(request.getMobilePhone());
|
|
- //customerPoints.setMobilePhone(request.getMobilePhone());
|
|
|
|
|
|
+ customerPoints.setMobilePhone(request.getMobilePhone());
|
|
}
|
|
}
|
|
if(StringUtils.isNotBlank(request.getBlogProfilePhoto())){
|
|
if(StringUtils.isNotBlank(request.getBlogProfilePhoto())){
|
|
appUserInfo.setBlogProfilePhoto(request.getBlogProfilePhoto());
|
|
appUserInfo.setBlogProfilePhoto(request.getBlogProfilePhoto());
|
|
}
|
|
}
|
|
if(StringUtils.isNotBlank(request.getUnionId())){
|
|
if(StringUtils.isNotBlank(request.getUnionId())){
|
|
appUserInfo.setUnionId(request.getUnionId());
|
|
appUserInfo.setUnionId(request.getUnionId());
|
|
- //customerPoints.setUnionId(request.getUnionId());
|
|
|
|
|
|
+ customerPoints.setUnionId(request.getUnionId());
|
|
}
|
|
}
|
|
|
|
|
|
appUserInfo.setRegisteDate(new Date());
|
|
appUserInfo.setRegisteDate(new Date());
|
|
appUserInfo.setUpdateDate(new Date());
|
|
appUserInfo.setUpdateDate(new Date());
|
|
|
|
|
|
- //customerPoints.setCreateTime(new Date());
|
|
|
|
-// customerPoints.setUnionId(request.getUnionId());
|
|
|
|
-// customerPoints.setPoints(0);
|
|
|
|
-// customerPoints.setConsumptionPoints(0);
|
|
|
|
-// customerPoints.setAccumulatePoints(0);
|
|
|
|
-// customerPoints.setInvalidPoints(0);
|
|
|
|
|
|
+ customerPoints.setCreateTime(new Date());
|
|
|
|
+ customerPoints.setUnionId(request.getUnionId());
|
|
|
|
+ customerPoints.setPoints(0);
|
|
|
|
+ customerPoints.setConsumptionPoints(0);
|
|
|
|
+ customerPoints.setAccumulatePoints(0);
|
|
|
|
+ customerPoints.setInvalidPoints(0);
|
|
|
|
+ customerPoints.setStationId(request.getStationId());
|
|
|
|
+ customerPoints.setStationName(request.getStationName());
|
|
|
|
|
|
if(StringUtils.isNotBlank(request.getSexFlag())){
|
|
if(StringUtils.isNotBlank(request.getSexFlag())){
|
|
appUserInfo.setSexFlag(request.getSexFlag());
|
|
appUserInfo.setSexFlag(request.getSexFlag());
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+ logger.info("插入数据库用户信息参数:"+appUserInfo.toString());
|
|
Map<String, Object> params = new HashMap<>();
|
|
Map<String, Object> params = new HashMap<>();
|
|
params.put("openId", openId); //注册用户openId
|
|
params.put("openId", openId); //注册用户openId
|
|
params.put("userType", request.getUserType()); //用户类型
|
|
params.put("userType", request.getUserType()); //用户类型
|
|
//判断该用户是否已存在
|
|
//判断该用户是否已存在
|
|
int count = appUserInfoService.isExistAppUser(params);
|
|
int count = appUserInfoService.isExistAppUser(params);
|
|
if(count > 0){
|
|
if(count > 0){
|
|
-// boolean boo = customerPointsService.isExistCustomerPointsInfo(customerPoints);
|
|
|
|
-// if(!boo){
|
|
|
|
-// customerPointsService.insertCustomerPointsInfo(customerPoints);
|
|
|
|
-// }
|
|
|
|
-// if(appUserInfoService.getUserUnionId(appUserInfo)==null){
|
|
|
|
-// appUserInfoService.updateUnionId(appUserInfo);
|
|
|
|
-// }
|
|
|
|
|
|
+ boolean boo = customerPointsService.isExistCustomerPointsInfo(customerPoints);
|
|
|
|
+ if(!boo){
|
|
|
|
+ customerPointsService.insertCustomerPointsInfo(customerPoints);
|
|
|
|
+ }
|
|
|
|
+ String userUnionId = appUserInfoService.getUserUnionId(appUserInfo);
|
|
|
|
+
|
|
|
|
+ if(!StringUtils.isNotBlank(userUnionId)){
|
|
|
|
+ appUserInfoService.updateUnionId(appUserInfo);
|
|
|
|
+ }
|
|
resultData = ResultData.error(CodeMsg.USER_EXSIST);
|
|
resultData = ResultData.error(CodeMsg.USER_EXSIST);
|
|
}else {
|
|
}else {
|
|
appUserInfoService.AddAppUserInfo(appUserInfo);
|
|
appUserInfoService.AddAppUserInfo(appUserInfo);
|
|
-// customerPointsService.insertCustomerPointsInfo(customerPoints);
|
|
|
|
|
|
+ customerPointsService.insertCustomerPointsInfo(customerPoints);
|
|
resultData = ResultData.success(CodeMsg.SUCCESS);
|
|
resultData = ResultData.success(CodeMsg.SUCCESS);
|
|
}
|
|
}
|
|
}catch (Exception e){
|
|
}catch (Exception e){
|