|
|
@ -13,7 +13,6 @@ import com.bsd.say.mapper.CouponMapper;
|
|
|
|
import com.bsd.say.mapper.RecordMapper;
|
|
|
|
import com.bsd.say.mapper.RecordMapper;
|
|
|
|
import com.bsd.say.mapper.UsersMapper;
|
|
|
|
import com.bsd.say.mapper.UsersMapper;
|
|
|
|
import com.bsd.say.service.AwardListService;
|
|
|
|
import com.bsd.say.service.AwardListService;
|
|
|
|
import com.bsd.say.service.CouponService;
|
|
|
|
|
|
|
|
import com.bsd.say.util.LogUtils;
|
|
|
|
import com.bsd.say.util.LogUtils;
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
import org.slf4j.Logger;
|
|
|
@ -56,51 +55,53 @@ public class AwardListServiceImpl extends BaseServiceImpl<AwardListMapper, Award
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 抽奖
|
|
|
|
* 抽奖
|
|
|
|
|
|
|
|
*
|
|
|
|
* @param ajaxRequest
|
|
|
|
* @param ajaxRequest
|
|
|
|
* @return
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public AjaxResult award(AjaxRequest ajaxRequest) {
|
|
|
|
public AjaxResult award(AjaxRequest ajaxRequest) {
|
|
|
|
synchronized(this){
|
|
|
|
|
|
|
|
|
|
|
|
synchronized (this) {
|
|
|
|
AjaxResult ajaxResult = new AjaxResult();
|
|
|
|
AjaxResult ajaxResult = new AjaxResult();
|
|
|
|
JSONObject data = ajaxRequest.getData();
|
|
|
|
JSONObject data = ajaxRequest.getData();
|
|
|
|
if (data == null){
|
|
|
|
if (data == null) {
|
|
|
|
ajaxResult.setRetcode(AjaxResult.FAILED);
|
|
|
|
ajaxResult.setRetcode(AjaxResult.FAILED);
|
|
|
|
ajaxResult.setRetmsg("DATA MISSING");
|
|
|
|
ajaxResult.setRetmsg("DATA MISSING");
|
|
|
|
return ajaxResult;
|
|
|
|
return ajaxResult;
|
|
|
|
}else {
|
|
|
|
} else {
|
|
|
|
String openId = data.getString("openId");
|
|
|
|
String openId = data.getString("openId");
|
|
|
|
// String code = data.getString("code");
|
|
|
|
// String code = data.getString("code");
|
|
|
|
if (StringUtils.isEmpty(openId)){
|
|
|
|
if (StringUtils.isEmpty(openId)) {
|
|
|
|
ajaxResult.setRetcode(AjaxResult.FAILED);
|
|
|
|
ajaxResult.setRetcode(AjaxResult.FAILED);
|
|
|
|
ajaxResult.setRetmsg("openId MISSING");
|
|
|
|
ajaxResult.setRetmsg("openId MISSING");
|
|
|
|
return ajaxResult;
|
|
|
|
return ajaxResult;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
JSONObject userInfo = weixinService.getUserInfoByOpenId(openId);
|
|
|
|
JSONObject userInfo = weixinService.getUserInfoByOpenId(openId);
|
|
|
|
String unionId = userInfo.getString("unionid");
|
|
|
|
String unionId = userInfo.getString("unionid");
|
|
|
|
logger.info("union_id:"+unionId);
|
|
|
|
logger.info("union_id:" + unionId);
|
|
|
|
Users users = usersMapper.selectOne(Wrappers.<Users>lambdaQuery().eq(Users::getOpenId,openId)
|
|
|
|
Users users = usersMapper.selectOne(Wrappers.<Users>lambdaQuery().eq(Users::getOpenId, openId)
|
|
|
|
.and(queryWrapper1 -> queryWrapper1.eq(Users::getState,1)));
|
|
|
|
.and(queryWrapper1 -> queryWrapper1.eq(Users::getState, 1)));
|
|
|
|
AwardList maxIdAward = awardListMapper.selectByMaxId();
|
|
|
|
AwardList maxIdAward = awardListMapper.selectByMaxId();
|
|
|
|
Integer newAwardNumner = maxIdAward.getAwardNumber()+ 1;
|
|
|
|
Integer newAwardNumner = maxIdAward.getAwardNumber() + 1;
|
|
|
|
AwardList awardList = new AwardList();
|
|
|
|
AwardList awardList = new AwardList();
|
|
|
|
awardList.setUserId(users.getId());
|
|
|
|
awardList.setUserId(users.getId());
|
|
|
|
awardList.setAwardNumber(newAwardNumner);
|
|
|
|
awardList.setAwardNumber(newAwardNumner);
|
|
|
|
awardList.setCreateDateTime(new Date());
|
|
|
|
awardList.setCreateDateTime(new Date());
|
|
|
|
awardList.setUpdateDateTime(new Date());
|
|
|
|
awardList.setUpdateDateTime(new Date());
|
|
|
|
//中大奖
|
|
|
|
//中大奖
|
|
|
|
if (newAwardNumner % rule == 0){
|
|
|
|
if (newAwardNumner % rule == 0) {
|
|
|
|
if (newAwardNumner > rule * amount){
|
|
|
|
if (newAwardNumner > rule * amount) {
|
|
|
|
logger.info("没一等奖了");
|
|
|
|
logger.info("没一等奖了");
|
|
|
|
awardList.setAwardName("波司登优惠券");
|
|
|
|
awardList.setAwardName("波司登优惠券");
|
|
|
|
awardList.setAwardType(2);
|
|
|
|
awardList.setAwardType(2);
|
|
|
|
ajaxResult.setRetmsg("恭喜中二等奖,优惠券");
|
|
|
|
ajaxResult.setRetmsg("恭喜中二等奖,优惠券");
|
|
|
|
}else {
|
|
|
|
} else {
|
|
|
|
awardList.setAwardName("波司登羽绒服");
|
|
|
|
awardList.setAwardName("波司登羽绒服");
|
|
|
|
awardList.setAwardType(1);
|
|
|
|
awardList.setAwardType(1);
|
|
|
|
ajaxResult.setRetmsg("恭喜中一等奖,羽绒服");
|
|
|
|
ajaxResult.setRetmsg("恭喜中一等奖,羽绒服");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}else {
|
|
|
|
} else {
|
|
|
|
awardList.setAwardName("波司登优惠券");
|
|
|
|
awardList.setAwardName("波司登优惠券");
|
|
|
|
awardList.setAwardType(2);
|
|
|
|
awardList.setAwardType(2);
|
|
|
|
ajaxResult.setRetmsg("恭喜中二等奖,优惠券");
|
|
|
|
ajaxResult.setRetmsg("恭喜中二等奖,优惠券");
|
|
|
@ -116,6 +117,7 @@ public class AwardListServiceImpl extends BaseServiceImpl<AwardListMapper, Award
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 判断有没有抽过奖品 微信code必传
|
|
|
|
* 判断有没有抽过奖品 微信code必传
|
|
|
|
|
|
|
|
*
|
|
|
|
* @param ajaxRequest
|
|
|
|
* @param ajaxRequest
|
|
|
|
* @return
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
*/
|
|
|
@ -123,22 +125,22 @@ public class AwardListServiceImpl extends BaseServiceImpl<AwardListMapper, Award
|
|
|
|
public AjaxResult isValidLottery(AjaxRequest ajaxRequest) {
|
|
|
|
public AjaxResult isValidLottery(AjaxRequest ajaxRequest) {
|
|
|
|
AjaxResult ajaxResult = new AjaxResult();
|
|
|
|
AjaxResult ajaxResult = new AjaxResult();
|
|
|
|
JSONObject data = ajaxRequest.getData();
|
|
|
|
JSONObject data = ajaxRequest.getData();
|
|
|
|
if (data == null){
|
|
|
|
if (data == null) {
|
|
|
|
ajaxResult.setRetcode(AjaxResult.FAILED);
|
|
|
|
ajaxResult.setRetcode(AjaxResult.FAILED);
|
|
|
|
ajaxResult.setRetmsg("DATA MISSING");
|
|
|
|
ajaxResult.setRetmsg("DATA MISSING");
|
|
|
|
return ajaxResult;
|
|
|
|
return ajaxResult;
|
|
|
|
}else {
|
|
|
|
} else {
|
|
|
|
// String code = data.getString("code");
|
|
|
|
// String code = data.getString("code");
|
|
|
|
String openId = data.getString("openId");
|
|
|
|
String openId = data.getString("openId");
|
|
|
|
if (StringUtils.isEmpty(openId)){
|
|
|
|
if (StringUtils.isEmpty(openId)) {
|
|
|
|
ajaxResult.setRetcode(AjaxResult.FAILED);
|
|
|
|
ajaxResult.setRetcode(AjaxResult.FAILED);
|
|
|
|
ajaxResult.setRetmsg("openId MISSING");
|
|
|
|
ajaxResult.setRetmsg("openId MISSING");
|
|
|
|
return ajaxResult;
|
|
|
|
return ajaxResult;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
|
|
Users users = usersMapper.selectOne(Wrappers.<Users>lambdaQuery().eq(Users::getOpenId,openId)
|
|
|
|
Users users = usersMapper.selectOne(Wrappers.<Users>lambdaQuery().eq(Users::getOpenId, openId)
|
|
|
|
.and(queryWrapper1 -> queryWrapper1.eq(Users::getState,1)));
|
|
|
|
.and(queryWrapper1 -> queryWrapper1.eq(Users::getState, 1)));
|
|
|
|
if (users == null){
|
|
|
|
if (users == null) {
|
|
|
|
//新会员直接创,肯定没抽过奖
|
|
|
|
//新会员直接创,肯定没抽过奖
|
|
|
|
Users newUsers = new Users();
|
|
|
|
Users newUsers = new Users();
|
|
|
|
newUsers.setOpenId(openId);
|
|
|
|
newUsers.setOpenId(openId);
|
|
|
@ -149,23 +151,23 @@ public class AwardListServiceImpl extends BaseServiceImpl<AwardListMapper, Award
|
|
|
|
ajaxResult.setRetmsg("可以抽奖");
|
|
|
|
ajaxResult.setRetmsg("可以抽奖");
|
|
|
|
ajaxResult.setRetcode(AjaxResult.SUCCESS);
|
|
|
|
ajaxResult.setRetcode(AjaxResult.SUCCESS);
|
|
|
|
ajaxResult.setData(true);
|
|
|
|
ajaxResult.setData(true);
|
|
|
|
}else {
|
|
|
|
} else {
|
|
|
|
if (users.getUserType() == 1){
|
|
|
|
if (users.getUserType() == 1) {
|
|
|
|
//既是寄件人又是收信人
|
|
|
|
//既是寄件人又是收信人
|
|
|
|
users.setUserType(3);
|
|
|
|
users.setUserType(3);
|
|
|
|
usersMapper.updateById(users);
|
|
|
|
usersMapper.updateById(users);
|
|
|
|
}else if (users.getUserType() == 0){
|
|
|
|
} else if (users.getUserType() == 0) {
|
|
|
|
users.setUserType(2);
|
|
|
|
users.setUserType(2);
|
|
|
|
usersMapper.updateById(users);
|
|
|
|
usersMapper.updateById(users);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
List<AwardList> awardList = awardListMapper.selectList(Wrappers.<AwardList>lambdaQuery()
|
|
|
|
List<AwardList> awardList = awardListMapper.selectList(Wrappers.<AwardList>lambdaQuery()
|
|
|
|
.eq(AwardList::getUserId,users.getId()).and(queryWrapper1 -> queryWrapper1
|
|
|
|
.eq(AwardList::getUserId, users.getId()).and(queryWrapper1 -> queryWrapper1
|
|
|
|
.eq(AwardList::getState,1)));
|
|
|
|
.eq(AwardList::getState, 1)));
|
|
|
|
if (awardList.size() == 0 || awardList == null){
|
|
|
|
if (awardList.size() == 0 || awardList == null) {
|
|
|
|
ajaxResult.setRetmsg("可以抽奖");
|
|
|
|
ajaxResult.setRetmsg("可以抽奖");
|
|
|
|
ajaxResult.setRetcode(AjaxResult.SUCCESS);
|
|
|
|
ajaxResult.setRetcode(AjaxResult.SUCCESS);
|
|
|
|
ajaxResult.setData(true);
|
|
|
|
ajaxResult.setData(true);
|
|
|
|
}else {
|
|
|
|
} else {
|
|
|
|
ajaxResult.setRetmsg("已经抽过了");
|
|
|
|
ajaxResult.setRetmsg("已经抽过了");
|
|
|
|
ajaxResult.setRetcode(AjaxResult.SUCCESS);
|
|
|
|
ajaxResult.setRetcode(AjaxResult.SUCCESS);
|
|
|
|
ajaxResult.setData(false);
|
|
|
|
ajaxResult.setData(false);
|
|
|
@ -178,6 +180,7 @@ public class AwardListServiceImpl extends BaseServiceImpl<AwardListMapper, Award
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 一等奖填写地址信息 (校验验证码)
|
|
|
|
* 一等奖填写地址信息 (校验验证码)
|
|
|
|
|
|
|
|
*
|
|
|
|
* @param ajaxRequest
|
|
|
|
* @param ajaxRequest
|
|
|
|
* @return
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
*/
|
|
|
@ -185,44 +188,44 @@ public class AwardListServiceImpl extends BaseServiceImpl<AwardListMapper, Award
|
|
|
|
public AjaxResult saveAward(AjaxRequest ajaxRequest) {
|
|
|
|
public AjaxResult saveAward(AjaxRequest ajaxRequest) {
|
|
|
|
AjaxResult ajaxResult = new AjaxResult();
|
|
|
|
AjaxResult ajaxResult = new AjaxResult();
|
|
|
|
JSONObject data = ajaxRequest.getData();
|
|
|
|
JSONObject data = ajaxRequest.getData();
|
|
|
|
if (data == null){
|
|
|
|
if (data == null) {
|
|
|
|
ajaxResult.setRetcode(AjaxResult.FAILED);
|
|
|
|
ajaxResult.setRetcode(AjaxResult.FAILED);
|
|
|
|
ajaxResult.setRetmsg("DATA MISSING");
|
|
|
|
ajaxResult.setRetmsg("DATA MISSING");
|
|
|
|
return ajaxResult;
|
|
|
|
return ajaxResult;
|
|
|
|
}else{
|
|
|
|
} else {
|
|
|
|
// String code = data.getString("code");
|
|
|
|
// String code = data.getString("code");
|
|
|
|
String openId = data.getString("openId");
|
|
|
|
String openId = data.getString("openId");
|
|
|
|
String phone = data.getString("phone");
|
|
|
|
String phone = data.getString("phone");
|
|
|
|
String noteCode = data.getString("noteCode");
|
|
|
|
String noteCode = data.getString("noteCode");
|
|
|
|
String address = data.getString("address");
|
|
|
|
String address = data.getString("address");
|
|
|
|
String receiverName = data.getString("receiverName");
|
|
|
|
String receiverName = data.getString("receiverName");
|
|
|
|
if (StringUtils.isBlank(openId)||StringUtils.isBlank(phone)
|
|
|
|
if (StringUtils.isBlank(openId) || StringUtils.isBlank(phone)
|
|
|
|
||StringUtils.isBlank(noteCode)||StringUtils.isBlank(receiverName)){
|
|
|
|
|| StringUtils.isBlank(noteCode) || StringUtils.isBlank(receiverName)) {
|
|
|
|
ajaxResult.setRetcode(AjaxResult.FAILED);
|
|
|
|
ajaxResult.setRetcode(AjaxResult.FAILED);
|
|
|
|
ajaxResult.setRetmsg("PARAM MISSING");
|
|
|
|
ajaxResult.setRetmsg("PARAM MISSING");
|
|
|
|
return ajaxResult;
|
|
|
|
return ajaxResult;
|
|
|
|
}else {
|
|
|
|
} else {
|
|
|
|
if (noteCode.equals(redisTemplate.opsForValue().get(phone))){
|
|
|
|
if (noteCode.equals(redisTemplate.opsForValue().get(phone))) {
|
|
|
|
//验证成功
|
|
|
|
//验证成功
|
|
|
|
JSONObject userInfo = weixinService.getUserInfoByOpenId(openId);
|
|
|
|
JSONObject userInfo = weixinService.getUserInfoByOpenId(openId);
|
|
|
|
String unionId = userInfo.getString("unionid");
|
|
|
|
String unionId = userInfo.getString("unionid");
|
|
|
|
// String unionId = weixinService.getUnionId(openId);
|
|
|
|
// String unionId = weixinService.getUnionId(openId);
|
|
|
|
logger.info("union_id:"+unionId);
|
|
|
|
logger.info("union_id:" + unionId);
|
|
|
|
Users users = usersMapper.selectOne(Wrappers.<Users>lambdaQuery().eq(Users::getOpenId,openId)
|
|
|
|
Users users = usersMapper.selectOne(Wrappers.<Users>lambdaQuery().eq(Users::getOpenId, openId)
|
|
|
|
.and(queryWrapper1 -> queryWrapper1.eq(Users::getState,1)));
|
|
|
|
.and(queryWrapper1 -> queryWrapper1.eq(Users::getState, 1)));
|
|
|
|
if (users == null){
|
|
|
|
if (users == null) {
|
|
|
|
ajaxResult.setRetcode(AjaxResult.FAILED);
|
|
|
|
ajaxResult.setRetcode(AjaxResult.FAILED);
|
|
|
|
ajaxResult.setRetmsg("NOT FOUND USERS");
|
|
|
|
ajaxResult.setRetmsg("NOT FOUND USERS");
|
|
|
|
return ajaxResult;
|
|
|
|
return ajaxResult;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
AwardList awardList = awardListMapper.selectOne(Wrappers.<AwardList>lambdaQuery().eq(AwardList::getUserId,users.getId())
|
|
|
|
AwardList awardList = awardListMapper.selectOne(Wrappers.<AwardList>lambdaQuery().eq(AwardList::getUserId, users.getId())
|
|
|
|
.and(queryWrapper1 -> queryWrapper1.eq(AwardList::getState,1)));
|
|
|
|
.and(queryWrapper1 -> queryWrapper1.eq(AwardList::getState, 1)));
|
|
|
|
if (awardList == null){
|
|
|
|
if (awardList == null) {
|
|
|
|
ajaxResult.setRetcode(AjaxResult.FAILED);
|
|
|
|
ajaxResult.setRetcode(AjaxResult.FAILED);
|
|
|
|
ajaxResult.setRetmsg("NOT FOUND AWARD");
|
|
|
|
ajaxResult.setRetmsg("NOT FOUND AWARD");
|
|
|
|
return ajaxResult;
|
|
|
|
return ajaxResult;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (StringUtils.isBlank(address)){
|
|
|
|
if (StringUtils.isBlank(address)) {
|
|
|
|
ajaxResult.setRetcode(AjaxResult.FAILED);
|
|
|
|
ajaxResult.setRetcode(AjaxResult.FAILED);
|
|
|
|
ajaxResult.setRetmsg("ADDRESS MISSING");
|
|
|
|
ajaxResult.setRetmsg("ADDRESS MISSING");
|
|
|
|
return ajaxResult;
|
|
|
|
return ajaxResult;
|
|
|
@ -236,14 +239,14 @@ public class AwardListServiceImpl extends BaseServiceImpl<AwardListMapper, Award
|
|
|
|
ajaxResult.setRetcode(AjaxResult.SUCCESS);
|
|
|
|
ajaxResult.setRetcode(AjaxResult.SUCCESS);
|
|
|
|
|
|
|
|
|
|
|
|
//抽中一等奖,必定微信来源
|
|
|
|
//抽中一等奖,必定微信来源
|
|
|
|
Record record = recordMapper.selectOne(Wrappers.<Record>lambdaQuery().eq(Record::getOpenId,openId)
|
|
|
|
Record record = recordMapper.selectOne(Wrappers.<Record>lambdaQuery().eq(Record::getOpenId, openId)
|
|
|
|
.and(queryWrapper1 -> queryWrapper1.eq(Record::getState,1)));
|
|
|
|
.and(queryWrapper1 -> queryWrapper1.eq(Record::getState, 1)));
|
|
|
|
record.setIsAward("中奖");
|
|
|
|
record.setIsAward("中奖");
|
|
|
|
record.setAwardName(receiverName);
|
|
|
|
record.setAwardName(receiverName);
|
|
|
|
record.setAddress(address);
|
|
|
|
record.setAddress(address);
|
|
|
|
record.setAwardPhone(phone);
|
|
|
|
record.setAwardPhone(phone);
|
|
|
|
recordMapper.updateById(record);
|
|
|
|
recordMapper.updateById(record);
|
|
|
|
}else {
|
|
|
|
} else {
|
|
|
|
//短信验证失败
|
|
|
|
//短信验证失败
|
|
|
|
ajaxResult.setRetcode(AjaxResult.FAILED);
|
|
|
|
ajaxResult.setRetcode(AjaxResult.FAILED);
|
|
|
|
ajaxResult.setRetmsg("验证码错误或已超时,请重新填写");
|
|
|
|
ajaxResult.setRetmsg("验证码错误或已超时,请重新填写");
|
|
|
@ -255,6 +258,7 @@ public class AwardListServiceImpl extends BaseServiceImpl<AwardListMapper, Award
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 通过code获取个人优惠券和抽奖
|
|
|
|
* 通过code获取个人优惠券和抽奖
|
|
|
|
|
|
|
|
*
|
|
|
|
* @param ajaxRequest
|
|
|
|
* @param ajaxRequest
|
|
|
|
* @return
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
*/
|
|
|
@ -262,45 +266,45 @@ public class AwardListServiceImpl extends BaseServiceImpl<AwardListMapper, Award
|
|
|
|
public AjaxResult getAwardList(AjaxRequest ajaxRequest) {
|
|
|
|
public AjaxResult getAwardList(AjaxRequest ajaxRequest) {
|
|
|
|
AjaxResult ajaxResult = new AjaxResult();
|
|
|
|
AjaxResult ajaxResult = new AjaxResult();
|
|
|
|
JSONObject data = ajaxRequest.getData();
|
|
|
|
JSONObject data = ajaxRequest.getData();
|
|
|
|
if (data == null){
|
|
|
|
if (data == null) {
|
|
|
|
ajaxResult.setRetcode(AjaxResult.FAILED);
|
|
|
|
ajaxResult.setRetcode(AjaxResult.FAILED);
|
|
|
|
ajaxResult.setRetmsg("DATA MISSING");
|
|
|
|
ajaxResult.setRetmsg("DATA MISSING");
|
|
|
|
return ajaxResult;
|
|
|
|
return ajaxResult;
|
|
|
|
}else{
|
|
|
|
} else {
|
|
|
|
String openId = data.getString("openId");
|
|
|
|
String openId = data.getString("openId");
|
|
|
|
// String code = data.getString("code");
|
|
|
|
// String code = data.getString("code");
|
|
|
|
if (StringUtils.isBlank(openId)){
|
|
|
|
if (StringUtils.isBlank(openId)) {
|
|
|
|
ajaxResult.setRetcode(AjaxResult.FAILED);
|
|
|
|
ajaxResult.setRetcode(AjaxResult.FAILED);
|
|
|
|
ajaxResult.setRetmsg("CODE MISSING");
|
|
|
|
ajaxResult.setRetmsg("CODE MISSING");
|
|
|
|
return ajaxResult;
|
|
|
|
return ajaxResult;
|
|
|
|
}else {
|
|
|
|
} else {
|
|
|
|
JSONObject userInfo = weixinService.getUserInfoByOpenId(openId);
|
|
|
|
JSONObject userInfo = weixinService.getUserInfoByOpenId(openId);
|
|
|
|
String unionId = userInfo.getString("unionid");
|
|
|
|
String unionId = userInfo.getString("unionid");
|
|
|
|
logger.info("union_id:"+unionId);
|
|
|
|
logger.info("union_id:" + unionId);
|
|
|
|
Users users = usersMapper.selectOne(Wrappers.<Users>lambdaQuery().eq(Users::getOpenId,openId)
|
|
|
|
Users users = usersMapper.selectOne(Wrappers.<Users>lambdaQuery().eq(Users::getOpenId, openId)
|
|
|
|
.and(queryWrapper1 -> queryWrapper1.eq(Users::getState,1)));
|
|
|
|
.and(queryWrapper1 -> queryWrapper1.eq(Users::getState, 1)));
|
|
|
|
if (users == null){
|
|
|
|
if (users == null) {
|
|
|
|
ajaxResult.setRetcode(AjaxResult.SUCCESS);
|
|
|
|
ajaxResult.setRetcode(AjaxResult.SUCCESS);
|
|
|
|
return ajaxResult;
|
|
|
|
return ajaxResult;
|
|
|
|
}else {
|
|
|
|
} else {
|
|
|
|
Coupon coupon = couponMapper.selectOne(Wrappers.<Coupon>lambdaQuery().eq(Coupon::getUserId,users.getId())
|
|
|
|
Coupon coupon = couponMapper.selectOne(Wrappers.<Coupon>lambdaQuery().eq(Coupon::getUserId, users.getId())
|
|
|
|
.and(queryWrapper1 -> queryWrapper1.eq(Coupon::getState,1)));
|
|
|
|
.and(queryWrapper1 -> queryWrapper1.eq(Coupon::getState, 1)));
|
|
|
|
AwardList awardList = awardListMapper.selectOne(Wrappers.<AwardList>lambdaQuery().eq(AwardList::getUserId,users.getId())
|
|
|
|
AwardList awardList = awardListMapper.selectOne(Wrappers.<AwardList>lambdaQuery().eq(AwardList::getUserId, users.getId())
|
|
|
|
.and(queryWrapper1 -> queryWrapper1.eq(AwardList::getState,1)));
|
|
|
|
.and(queryWrapper1 -> queryWrapper1.eq(AwardList::getState, 1)));
|
|
|
|
JSONObject result = new JSONObject();
|
|
|
|
JSONObject result = new JSONObject();
|
|
|
|
if (coupon != null){
|
|
|
|
if (coupon != null) {
|
|
|
|
String jsonString = JSONObject.toJSONString(coupon);
|
|
|
|
String jsonString = JSONObject.toJSONString(coupon);
|
|
|
|
JSONObject jsonObject = JSONObject.parseObject(jsonString);
|
|
|
|
JSONObject jsonObject = JSONObject.parseObject(jsonString);
|
|
|
|
result.put("coupon",jsonObject);
|
|
|
|
result.put("coupon", jsonObject);
|
|
|
|
}else {
|
|
|
|
} else {
|
|
|
|
result.put("coupon",new JSONObject());
|
|
|
|
result.put("coupon", new JSONObject());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (awardList != null){
|
|
|
|
if (awardList != null) {
|
|
|
|
String jsonString = JSONObject.toJSONString(awardList);
|
|
|
|
String jsonString = JSONObject.toJSONString(awardList);
|
|
|
|
JSONObject jsonObject = JSONObject.parseObject(jsonString);
|
|
|
|
JSONObject jsonObject = JSONObject.parseObject(jsonString);
|
|
|
|
result.put("awardList",jsonObject);
|
|
|
|
result.put("awardList", jsonObject);
|
|
|
|
}else {
|
|
|
|
} else {
|
|
|
|
result.put("awardList",new JSONObject());
|
|
|
|
result.put("awardList", new JSONObject());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ajaxResult.setRetmsg("SUCCESS");
|
|
|
|
ajaxResult.setRetmsg("SUCCESS");
|
|
|
|
ajaxResult.setData(result);
|
|
|
|
ajaxResult.setData(result);
|
|
|
|