提交 0401e840 作者: 张小凤

user(add)

上级 bab66b72
......@@ -49,9 +49,9 @@ public class AuthHandler {
BaseAccountDTO account = JsonUtil.parseJsonToObj(json, BaseAccountDTO.class);
// 如果是PC管理端-获取部门缓存信息
if (JwtConstant.SXTB_ACCOUNT_TOKEN.equals(account.getTokenPort())) {
/* if (JwtConstant.SXTB_ACCOUNT_TOKEN.equals(account.getTokenPort())) {
account.getCompanyInfo().setCompanys(this.getCompanys(account.getCompanyInfo().getId()));
}
}*/
return account;
}
......@@ -61,7 +61,7 @@ public class AuthHandler {
map.put(JwtConstant.ROLEIDKEY, roleId);
map.put(JwtConstant.TOKEN_TYPE, tokenType);
String token = JwtUtil.createJwt(map);
loginInfo.setTokenPort(tokenType);
// loginInfo.setTokenPort(tokenType);
// 缓存登录token-jwt
stringRedisTemplate.opsForValue().set(
......@@ -70,12 +70,12 @@ public class AuthHandler {
// 平台PC管理端登录保存-单位的id及无限下级id集合
if (JwtConstant.SXTB_ACCOUNT_TOKEN.equals(tokenType)) {
if (loginInfo.getCompanyInfo() != null && !CollectionUtils.isEmpty(loginInfo.getCompanyInfo().getCompanys())) {
/*if (loginInfo.getCompanyInfo() != null && !CollectionUtils.isEmpty(loginInfo.getCompanyInfo().getCompanys())) {
List<Integer> companys = loginInfo.getCompanyInfo().getCompanys();
this.refreshCompanys(companys, loginInfo.getCompanyInfo().getId());
// 置为null--省内存
loginInfo.getCompanyInfo().setCompanys(null);
}
}*/
}
// 缓存登录对象
stringRedisTemplate.opsForValue().set(token, JsonUtil.parseObjToJson(loginInfo), JwtConstant.EXPIRATION,
......
package com.mmc.oms.controller;
import com.alibaba.fastjson.JSONObject;
import com.mmc.oms.common.AuthHandler;
import com.mmc.oms.common.BizException;
import com.mmc.oms.common.ResultEnum;
import com.mmc.oms.jwt.JwtConstant;
import com.mmc.oms.model.dto.BaseAccountDTO;
import com.mmc.oms.model.dto.CurrentUserDTO;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import javax.servlet.http.HttpServletRequest;
......@@ -18,6 +23,8 @@ public abstract class BaseController {
@Autowired
private AuthHandler authHandler;
@Autowired
private StringRedisTemplate stringRedisTemplate;
/**
* 获取当前用户
*
......@@ -35,7 +42,14 @@ public abstract class BaseController {
* 获取当前登录账号信息
*/
public BaseAccountDTO getCurrentAccount(HttpServletRequest request) {
String token = request.getHeader(JwtConstant.TOKENKEY);
return authHandler.getCurrentAccount(token);
String token = request.getHeader("token");
String json = stringRedisTemplate.opsForValue().get(token);
if (StringUtils.isBlank(json)){
throw new BizException(ResultEnum.LOGIN_ACCOUNT_STATUS_ERROR);
}
BaseAccountDTO baseAccountDTO= JSONObject.parseObject(json, BaseAccountDTO.class);
return baseAccountDTO;
}
}
......@@ -122,9 +122,9 @@ public class CouponUserController extends BaseController {
@RequestParam String uuid,
@RequestParam String phone) {
BaseAccountDTO countDTO = new BaseAccountDTO();
countDTO.setId(uid);
countDTO.setUserAccountId(uid);
countDTO.setUid(uuid);
countDTO.setAccountPhone(phone);
countDTO.setPhoneNum(phone);
return couponUserService.receiveCoupon(id, countDTO);
}
......@@ -167,9 +167,9 @@ public class CouponUserController extends BaseController {
@RequestParam String uuid,
@RequestParam String phone) {
BaseAccountDTO countDTO = new BaseAccountDTO();
countDTO.setId(uid);
countDTO.setUserAccountId(uid);
countDTO.setUid(uuid);
countDTO.setAccountPhone(phone);
countDTO.setPhoneNum(phone);
return couponUserService.receiveCouponList(id, countDTO);
}
......
......@@ -17,7 +17,7 @@ import javax.servlet.http.HttpServletRequest;
@RestController
@RequestMapping("/RentalOrders")
@Api(tags = {"web租赁订单"})
public class RentalOrdersController {
public class RentalOrdersController extends BaseController{
@Autowired private RentalOrdersService rentalOrdersService;
......@@ -41,8 +41,7 @@ public class RentalOrdersController {
@PostMapping("listPcWechatOrder")
public ResultBody listPcWechatOrder(HttpServletRequest request, @RequestBody OrderInfoQO param) {
return ResultBody.success(
// this.getCurrentAccount(request)
rentalOrdersService.listPcOrderInfo(param, null));
rentalOrdersService.listPcOrderInfo(param, this.getCurrentAccount(request)));
}
@ApiOperation(value = "小程序-云仓-订单-分页-列表")
......@@ -50,6 +49,6 @@ public class RentalOrdersController {
@PostMapping("listPageWechatOrder")
public ResultBody listPageWechatOrder(
HttpServletRequest request, @RequestBody OrderInfoQO param) {
return ResultBody.success(rentalOrdersService.listPageWechatOrder(null, param));
return ResultBody.success(rentalOrdersService.listPageWechatOrder(this.getCurrentAccount(request), param));
}
}
......@@ -21,77 +21,27 @@ import java.io.Serializable;
//@ApiModel(value = "com.mmc.csf.model.dto.BaseAccountDTO", description = "登录信息DTO")
public class BaseAccountDTO implements Serializable {
private static final long serialVersionUID = -2979712090903806216L;
private Integer id;
private String uid;
private String accountPhone;
@ApiModelProperty(value = "token")
private String token;
@ApiModelProperty(value = "账号id")
private Integer userAccountId;
@ApiModelProperty(value = "账号")
private String accountNo;
private String accountName;
private String tokenPort;
@ApiModelProperty(value = "角色ID")
private Integer roleId;
@ApiModelProperty(value = "是否为管理角色:0否 1是")
private Integer admin;// 是否为管理角色
@ApiModelProperty(value = "是否为运营角色:0否 1是")
private Integer operate;
@ApiModelProperty(value = "是否PMC发货专员:0否 1是")
private Integer pmc;
@ApiModelProperty(value = "单位信息")
private CompanyCacheDTO companyInfo;// 单位信息
@ApiModelProperty(value = "账号uid")
private String uid;
@ApiModelProperty(value = "手机号")
private String phoneNum;
@ApiModelProperty(value = "用户名称")
private String userName;
@ApiModelProperty(value = "用户昵称")
private String nickName;
public BaseAccountDTO(UserAccountDTO user) {
this.id = user.getId();
this.accountNo = user.getAccountNo();
this.accountName = user.getUserName();
this.roleId = user.getRoleInfo() == null ? null : user.getRoleInfo().getId();
this.admin = user.getRoleInfo() == null ? null : user.getRoleInfo().getAdmin();
this.operate = user.getRoleInfo() == null ? null : user.getRoleInfo().getOperate();
this.pmc = user.getRoleInfo() == null ? null : user.getRoleInfo().getPmc();
}
public BaseAccountDTO(RepoAccountDTO account) {
this.id = account.getId();
this.accountName = account.getAccountName();
this.uid = account.getUid();
this.accountPhone = account.getPhoneNum();
}
public BaseAccountDTO(MallUserDTO account) {
this.id = account.getId();
this.accountName = account.getNickName();
this.uid = account.getUid();
this.accountPhone = account.getPhoneNum();
}
public BaseAccountDTO(FlyerAccountDTO account) {
this.id = account.getId();
this.accountName = account.getAccountName();
this.uid = account.getUid();
this.accountPhone = account.getPhoneNum();
}
/**
* 是否为科比特超级管理员单位(是:无单位资源限制 否:只能看当前和下级单位的资源)
* @return
*/
public boolean isManage() {
if(this.getCompanyInfo()==null){
return false;
}
if(this.getCompanyInfo().getManage()==null){
return false;
}
return this.getCompanyInfo().getManage() == 1;
}
/**
* 判断是否已授权
*
* @return
*/
// public boolean authorized() {
// if (StringUtils.isBlank(this.accountName) || StringUtils.isBlank(this.accountPhone)) {
// return false;
// }
// return true;
// }
}
......@@ -29,14 +29,14 @@ public class OrderInfoQO implements Serializable {
@ApiModelProperty(value = "关键字")
private String keyword;
@ApiModelProperty(value = "买家账号")
private String buyerAccount;
@ApiModelProperty(value = "买家名称")
private String buyerName;
@ApiModelProperty(value = "订单编号")
private String orderNo;
@ApiModelProperty(value = "商品id")
private String wareInfoId;
@ApiModelProperty(value = "商品编号")
private String wareNo;
@ApiModelProperty(value = "商品名称")
private String wareTitle;
......
......@@ -72,7 +72,7 @@ public class CouponUserServiceImpl extends ServiceImpl<CouponUserDao, CouponUser
@Override
public ResultBody getMyList(Integer status,Integer pageNo,Integer pageSize, BaseAccountDTO currentAccount) {
Integer uid = currentAccount.getId();
Integer uid = currentAccount.getUserAccountId();
LambdaQueryWrapper<CouponUserDO> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(CouponUserDO::getUid, uid);
if (status == null) {
......@@ -127,7 +127,7 @@ public class CouponUserServiceImpl extends ServiceImpl<CouponUserDao, CouponUser
if (!couponDO.getGetType().equals(CouponConstants.COUPON_USR_TYPE_ACTIVITY)){
//查看当前优惠券是否限制每人领取
LambdaQueryWrapper<CouponUserDO> queryWrap = new LambdaQueryWrapper<>();
queryWrap.eq(CouponUserDO::getUid, currentAccount.getId()).eq(CouponUserDO::getCouponId, id);
queryWrap.eq(CouponUserDO::getUid, currentAccount.getUserAccountId()).eq(CouponUserDO::getCouponId, id);
long count = this.count(queryWrap);
if (count >= couponDO.getRestrictedAccess()) {
return ResultBody.error("已领取,不可重复领取");
......@@ -149,9 +149,9 @@ public class CouponUserServiceImpl extends ServiceImpl<CouponUserDao, CouponUser
}
CouponUserDO couponUser = new CouponUserDO(couponDO);
couponUser.setUid(currentAccount.getId());
couponUser.setUid(currentAccount.getUserAccountId());
couponUser.setUuid(currentAccount.getUid());
couponUser.setUserPhone(currentAccount.getAccountPhone());
couponUser.setUserPhone(currentAccount.getPhoneNum());
//如果优惠券是活动券 则为活动领取
if (CouponConstants.COUPON_USR_TYPE_ACTIVITY.equals(couponDO.getGetType())){
couponUser.setGainType(CouponConstants.STORE_COUPON_USER_TYPE_ACTIVITY);
......@@ -185,7 +185,7 @@ public class CouponUserServiceImpl extends ServiceImpl<CouponUserDao, CouponUser
});
if (execute) {
asynSendUserAppletMsg(currentAccount.getId(),couponDO) ;
asynSendUserAppletMsg(currentAccount.getUserAccountId(),couponDO) ;
return ResultBody.success();
} else {
return ResultBody.error("领取失败,请稍后再试");
......@@ -270,7 +270,7 @@ public class CouponUserServiceImpl extends ServiceImpl<CouponUserDao, CouponUser
//查看当前优惠券是否限制每人领取
if (couponDO.getIsLimited()){
LambdaQueryWrapper<CouponUserDO> queryWrap = new LambdaQueryWrapper<>();
queryWrap.eq(CouponUserDO::getUid, currentAccount.getId()).eq(CouponUserDO::getCouponId, couponDO.getId());
queryWrap.eq(CouponUserDO::getUid, currentAccount.getUserAccountId()).eq(CouponUserDO::getCouponId, couponDO.getId());
long count = this.count(queryWrap);
if (count >= couponDO.getRestrictedAccess()) {
sb.append("优惠券名称:" + couponDO.getCouponName() + "-该优惠券已领取,不可重复领取;");
......@@ -293,9 +293,9 @@ public class CouponUserServiceImpl extends ServiceImpl<CouponUserDao, CouponUser
couponDO.setUseEndTime(DateUtil.offsetDay(dateTime, couponDay));
}
CouponUserDO couponUser = new CouponUserDO(couponDO);
couponUser.setUid(currentAccount.getId());
couponUser.setUid(currentAccount.getUserAccountId());
couponUser.setUuid(currentAccount.getUid());
couponUser.setUserPhone(currentAccount.getAccountPhone());
couponUser.setUserPhone(currentAccount.getPhoneNum());
//如果优惠券是活动券 则为活动领取
if (CouponConstants.COUPON_USR_TYPE_ACTIVITY.equals(couponDO.getGetType())){
couponUser.setGainType(CouponConstants.STORE_COUPON_USER_TYPE_ACTIVITY);
......@@ -337,7 +337,7 @@ public class CouponUserServiceImpl extends ServiceImpl<CouponUserDao, CouponUser
System.out.println(collect);
log.info("消息发送成功"+collect);
collect.stream().forEach(t->{
asynSendUserAppletMsgList(currentAccount.getId(),t);
asynSendUserAppletMsgList(currentAccount.getUserAccountId(),t);
});
return ResultBody.success(sb);
} else {
......@@ -512,7 +512,7 @@ public class CouponUserServiceImpl extends ServiceImpl<CouponUserDao, CouponUser
//获取用户当前已领取未使用的优惠券
HashMap<Integer, CouponUserDO> couponUserMap = new HashMap<>();
Integer userId = currentAccount.getId();
Integer userId = currentAccount.getUserAccountId();
LambdaQueryWrapper<CouponUserDO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(CouponUserDO::getUid, userId);
List<CouponUserDO> list = this.list(lambdaQueryWrapper);
......
......@@ -66,7 +66,7 @@ public class RentalOrdersServiceImpl implements RentalOrdersService {
public ResultBody addLease(BaseAccountDTO account, RentalOrderVO param) {
// 通过用户获取渠道等级id 未完善
Integer channelLevelId = getChannelLevel(account.getId());
Integer channelLevelId = getChannelLevel(account.getUserAccountId());
// 通过渠道等级获取每一天的单价 未完善
Double unitPrice = getUnitPrice(param, channelLevelId);
......@@ -249,9 +249,8 @@ public class RentalOrdersServiceImpl implements RentalOrdersService {
@Override
public PageResult listPcOrderInfo(OrderInfoQO param, BaseAccountDTO cuser) {
if (!cuser.isManage()) {
param.setCompanys(cuser.getCompanyInfo().getCompanys());
}
Integer count = rentalOrdersDao.countPcOrderInfo(param);
if (count == 0) {
return PageResult.buildPage(param.getPageNo(), param.getPageSize(), count);
......@@ -270,7 +269,7 @@ public class RentalOrdersServiceImpl implements RentalOrdersService {
@Override
public PageResult listPageWechatOrder(BaseAccountDTO account, OrderInfoQO param) {
param.setRepoAccountId(account.getId());
param.setRepoAccountId(account.getUserAccountId());
int count = rentalOrdersDao.countPageOrderInfo(param);
if (count == 0) {
return PageResult.buildPage(param.getPageNo(), param.getPageSize(), count);
......
......@@ -203,27 +203,27 @@
select count(*)
from order_info o
<where>1=1
<if test=" keyword1 != null and keyword1 != '' ">
<if test=" buyerName != null and buyerName != '' ">
and (
o.uid like CONCAT('%',#{keyword1},'%')
or o.buyer_name like CONCAT('%',#{keyword1},'%')
o.uid like CONCAT('%',#{buyerName},'%')
or o.buyer_name like CONCAT('%',#{buyerName},'%')
)
</if>
<if test=" keyword2 != null and keyword2 != '' ">
<if test=" orderNo != null and orderNo != '' ">
and (
o.order_no like CONCAT('%',#{keyword2},'%')
o.order_no like CONCAT('%',#{orderNo},'%')
)
</if>
<if test=" keyword3 != null and keyword3 != '' ">
<if test=" wareNo != null and wareNo != '' ">
and (
o.ware_no like CONCAT('%',#{keyword3},'%')
o.ware_no like CONCAT('%',#{wareNo},'%')
)
</if>
<if test=" keyword4 != null and keyword4 != '' ">
<if test=" wareTitle != null and wareTitle != '' ">
and (
o.ware_title like CONCAT('%',#{keyword4},'%')
o.ware_title like CONCAT('%',#{wareTitle},'%')
)
</if>
<if test=" startTime != null and startTime != '' ">
......@@ -261,27 +261,27 @@
from order_info o
inner join order_receipt rp on rp.order_info_id=o.id
<where>1=1
<if test=" keyword1 != null and keyword1 != '' ">
<if test=" buyerName != null and buyerName != '' ">
and (
o.uid like CONCAT('%',#{keyword1},'%')
or o.buyer_name like CONCAT('%',#{keyword1},'%')
o.uid like CONCAT('%',#{buyerName},'%')
or o.buyer_name like CONCAT('%',#{buyerName},'%')
)
</if>
<if test=" keyword2 != null and keyword2 != '' ">
<if test=" orderNo != null and orderNo != '' ">
and (
o.order_no like CONCAT('%',#{keyword2},'%')
o.order_no like CONCAT('%',#{orderNo},'%')
)
</if>
<if test=" keyword3 != null and keyword3 != '' ">
<if test=" wareNo != null and wareNo != '' ">
and (
o.ware_no like CONCAT('%',#{keyword3},'%')
o.ware_no like CONCAT('%',#{wareNo},'%')
)
</if>
<if test=" keyword4 != null and keyword4 != '' ">
<if test=" wareTitle != null and wareTitle != '' ">
and (
o.ware_title like CONCAT('%',#{keyword4},'%')
o.ware_title like CONCAT('%',#{wareTitle},'%')
)
</if>
<if test=" startTime != null and startTime != '' ">
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论