Merge remote-tracking branch 'origin/test' into test
This commit is contained in:
commit
72ee726ccb
|
|
@ -1,5 +1,7 @@
|
||||||
package com.chaozhanggui.system.cashierservice.service;
|
package com.chaozhanggui.system.cashierservice.service;
|
||||||
|
|
||||||
|
import cn.hutool.core.date.DateUnit;
|
||||||
|
import cn.hutool.core.date.DateUtil;
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import cn.hutool.json.JSONUtil;
|
import cn.hutool.json.JSONUtil;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
|
@ -11,7 +13,10 @@ import com.chaozhanggui.system.cashierservice.mybatis.TbVersionMapper;
|
||||||
import com.chaozhanggui.system.cashierservice.rabbit.RabbitProducer;
|
import com.chaozhanggui.system.cashierservice.rabbit.RabbitProducer;
|
||||||
import com.chaozhanggui.system.cashierservice.sign.CodeEnum;
|
import com.chaozhanggui.system.cashierservice.sign.CodeEnum;
|
||||||
import com.chaozhanggui.system.cashierservice.sign.Result;
|
import com.chaozhanggui.system.cashierservice.sign.Result;
|
||||||
import com.chaozhanggui.system.cashierservice.util.*;
|
import com.chaozhanggui.system.cashierservice.util.MD5Util;
|
||||||
|
import com.chaozhanggui.system.cashierservice.util.RedisCst;
|
||||||
|
import com.chaozhanggui.system.cashierservice.util.RedisUtil;
|
||||||
|
import com.chaozhanggui.system.cashierservice.util.TokenUtil;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
@ -62,7 +67,6 @@ public class LoginService {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (ObjectUtil.isEmpty(loginReq.getSerialNumber())) {
|
if (ObjectUtil.isEmpty(loginReq.getSerialNumber())) {
|
||||||
return Result.fail(CodeEnum.SERIALNUMBER);
|
return Result.fail(CodeEnum.SERIALNUMBER);
|
||||||
}
|
}
|
||||||
|
|
@ -92,7 +96,7 @@ public class LoginService {
|
||||||
return Result.fail(CodeEnum.MERCHANTEIXST);
|
return Result.fail(CodeEnum.MERCHANTEIXST);
|
||||||
}
|
}
|
||||||
|
|
||||||
TbPlussShopStaff tbPlussShopStaff = tbPlussShopStaffMapper.selectByAccountAndShopId(loginReq.getLoginName(),account.getShopId());
|
TbPlussShopStaff tbPlussShopStaff = tbPlussShopStaffMapper.selectByAccountAndShopId(loginReq.getLoginName(), account.getShopId());
|
||||||
if (ObjectUtil.isEmpty(tbPlussShopStaff)) {
|
if (ObjectUtil.isEmpty(tbPlussShopStaff)) {
|
||||||
return Result.fail(CodeEnum.ACCOUNTEIXST);
|
return Result.fail(CodeEnum.ACCOUNTEIXST);
|
||||||
} else if (!tbPlussShopStaff.getStatus()) {
|
} else if (!tbPlussShopStaff.getStatus()) {
|
||||||
|
|
@ -120,7 +124,14 @@ public class LoginService {
|
||||||
tbTokenMapper.insert(tbToken);
|
tbTokenMapper.insert(tbToken);
|
||||||
|
|
||||||
TbShopInfo shopInfo = tbShopInfoMapper.selectByPrimaryKey(Integer.valueOf(account.getShopId()));
|
TbShopInfo shopInfo = tbShopInfoMapper.selectByPrimaryKey(Integer.valueOf(account.getShopId()));
|
||||||
|
if (shopInfo.getExpireAt() != null) {
|
||||||
|
Long expireAt = shopInfo.getExpireAt();
|
||||||
|
Date time = DateUtil.calendar(expireAt).getTime();
|
||||||
|
long expireDays = DateUtil.between(DateUtil.beginOfDay(new Date()), DateUtil.beginOfDay(time), DateUnit.DAY, false);
|
||||||
|
if (expireDays < 0) {
|
||||||
|
return Result.fail("店铺已到期,请联系区域经理续费");
|
||||||
|
}
|
||||||
|
}
|
||||||
redisUtil.saveMessage(key, token, 365 * 24 * 60 * 60);
|
redisUtil.saveMessage(key, token, 365 * 24 * 60 * 60);
|
||||||
|
|
||||||
String uuid = UUID.randomUUID().toString().replaceAll("-", "");
|
String uuid = UUID.randomUUID().toString().replaceAll("-", "");
|
||||||
|
|
@ -129,15 +140,21 @@ public class LoginService {
|
||||||
accountMap.put("accountId", account.getId());
|
accountMap.put("accountId", account.getId());
|
||||||
accountMap.put("merchantName", account.getAccount());
|
accountMap.put("merchantName", account.getAccount());
|
||||||
accountMap.put("loginName", tbPlussShopStaff.getAccount());
|
accountMap.put("loginName", tbPlussShopStaff.getAccount());
|
||||||
accountMap.put("loginAccount",tbPlussShopStaff.getName());
|
accountMap.put("loginAccount", tbPlussShopStaff.getName());
|
||||||
accountMap.put("clientType", loginReq.getClientType());
|
accountMap.put("clientType", loginReq.getClientType());
|
||||||
accountMap.put("shopId", account.getShopId());
|
accountMap.put("shopId", account.getShopId());
|
||||||
accountMap.put("staffId", tbPlussShopStaff.getId());
|
accountMap.put("staffId", tbPlussShopStaff.getId());
|
||||||
accountMap.put("userCode", tbPlussShopStaff.getCode());
|
accountMap.put("userCode", tbPlussShopStaff.getCode());
|
||||||
accountMap.put("token", token);
|
accountMap.put("token", token);
|
||||||
accountMap.put("loginTime", System.currentTimeMillis());
|
accountMap.put("loginTime", System.currentTimeMillis());
|
||||||
|
accountMap.put("expireDate", "");
|
||||||
if (Objects.nonNull(shopInfo)) {
|
if (Objects.nonNull(shopInfo)) {
|
||||||
accountMap.put("shopName", shopInfo.getShopName());
|
accountMap.put("shopName", shopInfo.getShopName());
|
||||||
|
if(shopInfo.getExpireAt() != null) {
|
||||||
|
Long expireAt = shopInfo.getExpireAt();
|
||||||
|
Date time = DateUtil.calendar(expireAt).getTime();
|
||||||
|
accountMap.put("expireDate", DateUtil.formatDate(time));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
accountMap.put("uuid", uuid);
|
accountMap.put("uuid", uuid);
|
||||||
accountMap.put("isStaff", "staff".equals(tbPlussShopStaff.getType()));
|
accountMap.put("isStaff", "staff".equals(tbPlussShopStaff.getType()));
|
||||||
|
|
@ -153,8 +170,8 @@ public class LoginService {
|
||||||
|
|
||||||
public TbVersion getCurrentPcVersion() {
|
public TbVersion getCurrentPcVersion() {
|
||||||
LambdaQueryWrapper<TbVersion> queryWrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<TbVersion> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
queryWrapper.eq(TbVersion::getSource,"PC");
|
queryWrapper.eq(TbVersion::getSource, "PC");
|
||||||
queryWrapper.eq(TbVersion::getSel,1);
|
queryWrapper.eq(TbVersion::getSel, 1);
|
||||||
return versionMapper.selectOne(queryWrapper);
|
return versionMapper.selectOne(queryWrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -162,7 +179,7 @@ public class LoginService {
|
||||||
|
|
||||||
String key = RedisCst.ONLINE_USER.concat(":").concat(clientType).concat(":").concat(loginName);
|
String key = RedisCst.ONLINE_USER.concat(":").concat(clientType).concat(":").concat(loginName);
|
||||||
|
|
||||||
String cacheToken = redisUtil.getMessage(key)+"";
|
String cacheToken = redisUtil.getMessage(key) + "";
|
||||||
|
|
||||||
TbToken tbToken = tbTokenMapper.selectByToken(token);
|
TbToken tbToken = tbTokenMapper.selectByToken(token);
|
||||||
|
|
||||||
|
|
@ -199,32 +216,33 @@ public class LoginService {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Result getShopInfo(String token){
|
public Result getShopInfo(String token) {
|
||||||
JSONObject jsonObject= TokenUtil.parseParamFromToken(token);
|
JSONObject jsonObject = TokenUtil.parseParamFromToken(token);
|
||||||
if(Objects.isNull(jsonObject)){
|
if (Objects.isNull(jsonObject)) {
|
||||||
return Result.fail(CodeEnum.TOKENTERROR);
|
return Result.fail(CodeEnum.TOKENTERROR);
|
||||||
}
|
}
|
||||||
TbShopInfo shopInfo= tbShopInfoMapper.selectByPrimaryKey(Integer.valueOf(jsonObject.getString("shopId")));
|
TbShopInfo shopInfo = tbShopInfoMapper.selectByPrimaryKey(Integer.valueOf(jsonObject.getString("shopId")));
|
||||||
|
|
||||||
return Result.success(SUCCESS,shopInfo);
|
return Result.success(SUCCESS, shopInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Result getStaffDiscount(String token){
|
public Result getStaffDiscount(String token) {
|
||||||
|
|
||||||
JSONObject jsonObject= TokenUtil.parseParamFromToken(token);
|
JSONObject jsonObject = TokenUtil.parseParamFromToken(token);
|
||||||
if(Objects.isNull(jsonObject)){
|
if (Objects.isNull(jsonObject)) {
|
||||||
return Result.fail(CodeEnum.TOKENTERROR);
|
return Result.fail(CodeEnum.TOKENTERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
Integer staffId=Integer.valueOf(jsonObject.getString("staffId"));
|
Integer staffId = Integer.valueOf(jsonObject.getString("staffId"));
|
||||||
|
|
||||||
TbPlussShopStaff staff= tbPlussShopStaffMapper.selectByPrimaryKey(staffId);
|
TbPlussShopStaff staff = tbPlussShopStaffMapper.selectByPrimaryKey(staffId);
|
||||||
if(Objects.nonNull(staff)&&Objects.nonNull(staff.getMaxDiscountAmount())){
|
if (Objects.nonNull(staff) && Objects.nonNull(staff.getMaxDiscountAmount())) {
|
||||||
return Result.success(SUCCESS,staff.getMaxDiscountAmount());
|
return Result.success(SUCCESS, staff.getMaxDiscountAmount());
|
||||||
}
|
}
|
||||||
|
|
||||||
return Result.success(SUCCESS, BigDecimal.ZERO);
|
return Result.success(SUCCESS, BigDecimal.ZERO);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue