|
@@ -2,9 +2,19 @@ package cn.com.ty.lift.ud.coupon.service.impl;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.Optional;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
+import cn.com.ty.lift.ud.exception.CatchException;
|
|
|
import cn.com.ty.lift.ud.userCoupon.mapper.UserCouponMapper;
|
|
|
import cn.com.ty.lift.ud.userCoupon.mapper.entity.UserCoupon;
|
|
|
+import cn.com.ty.lift.ud.userInfo.mapper.RoleMapper;
|
|
|
+import cn.com.ty.lift.ud.userInfo.mapper.UserInfoMapper;
|
|
|
+import cn.com.ty.lift.ud.userInfo.mapper.entity.Role;
|
|
|
+import cn.com.ty.lift.ud.userInfo.mapper.entity.UserInfoEntity;
|
|
|
+import cn.com.ty.lift.ud.utils.CurrentUserInfo;
|
|
|
+import cn.com.xwy.boot.web.dto.RestResponse;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
@@ -30,6 +40,12 @@ public class CouponServiceImpl extends ServiceImpl<CouponMapper, Coupon> impleme
|
|
|
@Autowired
|
|
|
private UserCouponMapper userCouponMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private UserInfoMapper userInfoMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private RoleMapper roleMapper;
|
|
|
+
|
|
|
@Override
|
|
|
public void updateByIds(List<Long> ids, Integer status) {
|
|
|
for (Long id : ids) {
|
|
@@ -112,4 +128,42 @@ public class CouponServiceImpl extends ServiceImpl<CouponMapper, Coupon> impleme
|
|
|
return couponMapper.getByCouponId(id);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public RestResponse examine(Coupon param) {
|
|
|
+ String userMobile = CurrentUserInfo.userMobile();
|
|
|
+ try {
|
|
|
+ Coupon couponEntity = Optional.ofNullable(baseMapper.selectById(param.getId())).orElseThrow(() -> new CatchException("该红包不存在"));
|
|
|
+ UserInfoEntity userInfo = Optional.ofNullable(userInfoMapper.getUserByMobile(userMobile)).orElseThrow(() -> new CatchException("该用户不存在"));
|
|
|
+ List<Role> roleList = Optional.ofNullable(roleMapper.getByUserId(userInfo.getUserId())).orElseThrow(() -> new CatchException("该用户不具有审核权限"));
|
|
|
+
|
|
|
+ Map<String, Role> roleMap = roleList.stream().collect(Collectors.toMap(Role::getCode, role -> role));
|
|
|
+
|
|
|
+ //主管审核逻辑
|
|
|
+ if (couponEntity.getCheckFalg() == 2){
|
|
|
+ Optional.ofNullable(roleMap.get("REGION_DIRECTOR")).orElseThrow(() -> new CatchException("该用户不是区域主管,不能审核"));
|
|
|
+ if (param.getCheckFalg() == 1) {
|
|
|
+ baseMapper.updateSatus(param.getId(), 3, 0);
|
|
|
+ return RestResponse.success("审批成功,等待财务审核");
|
|
|
+ } else {
|
|
|
+ baseMapper.updateSatus(param.getId(), 0, 0);
|
|
|
+ return RestResponse.success("驳回成功");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //财务审核逻辑
|
|
|
+ if (couponEntity.getCheckFalg() == 3){
|
|
|
+ Optional.ofNullable(roleMap.get("FINANCE")).orElseThrow(() -> new CatchException("该用户不是财务主管,不能审核"));
|
|
|
+ if (param.getCheckFalg() == 1) {
|
|
|
+ baseMapper.updateSatus(param.getId(), 1, 1);
|
|
|
+ return RestResponse.success("审批通过");
|
|
|
+ } else {
|
|
|
+ baseMapper.updateSatus(param.getId(), 0, 0);
|
|
|
+ return RestResponse.success("驳回成功");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (CatchException e) {
|
|
|
+ return RestResponse.fail(e.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ return RestResponse.fail("操作异常");
|
|
|
+ }
|
|
|
}
|