Search in sources :

Example 51 with QueryWrapper

use of com.baomidou.mybatisplus.core.conditions.query.QueryWrapper in project waynboot-mall by wayn111.

the class OrderServiceImpl method aliPayNotify.

@Override
public void aliPayNotify(HttpServletRequest request, HttpServletResponse response) throws AlipayApiException {
    // 将异步通知中收到的所有参数都存放到map中
    Map<String, String[]> parameterMap = request.getParameterMap();
    Map<String, String> paramsMap = new HashMap<>();
    parameterMap.forEach((s, strings) -> {
        paramsMap.put(s, strings[0]);
    });
    // 调用SDK验证签名
    boolean signVerified = AlipaySignature.rsaCheckV1(paramsMap, alipayConfig.getAlipayPublicKey(), alipayConfig.getCharset(), alipayConfig.getSigntype());
    if (!signVerified) {
        log.error("支付宝支付回调:验签失败");
        return;
    }
    log.info("支付宝支付回调:开始");
    // 验签成功后,按照支付结果异步通知中的描述,对支付结果中的业务内容进行二次校验,校验成功后在response中返回success并继续商户自身业务处理,校验失败返回failure
    String orderSn = request.getParameter("orderSn");
    Order order = getOne(new QueryWrapper<Order>().eq("order_sn", orderSn));
    if (order == null) {
        log.error("支付宝支付回调:订单不存在,orderSn:{}", orderSn);
        return;
    }
    // 检查这个订单是否已经处理过
    if (OrderUtil.hasPayed(order)) {
        log.error("支付宝支付回调:订单已经处理过了,orderSn:{}", orderSn);
        return;
    }
    order.setPayId("0xsdfsadfas-ali");
    order.setPayTime(LocalDateTime.now());
    order.setOrderStatus(OrderUtil.STATUS_PAY);
    order.setUpdateTime(new Date());
    if (!updateById(order)) {
        log.error("支付宝支付回调: 更新订单状态失败,order:{}", JSON.toJSONString(order.getOrderSn()));
        return;
    }
    // 订单支付成功以后,会发送短信给用户,以及发送邮件给管理员
    String email = iMemberService.getById(order.getUserId()).getEmail();
    if (StringUtils.isNotBlank(email)) {
        iMailService.sendEmail("新订单通知", order.toString(), email, WaynConfig.getMobileUrl() + "/message/email");
    }
    // 删除redis中订单id
    redisCache.deleteZsetObject("order_zset", order.getId());
    // 取消订单超时未支付任务
    taskService.removeTask(new OrderUnpaidTask(order.getId()));
    log.info("支付宝支付回调:结束");
}
Also used : LambdaQueryWrapper(com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper) QueryWrapper(com.baomidou.mybatisplus.core.conditions.query.QueryWrapper) OrderUnpaidTask(com.wayn.mobile.api.task.OrderUnpaidTask)

Example 52 with QueryWrapper

use of com.baomidou.mybatisplus.core.conditions.query.QueryWrapper in project waynboot-mall by wayn111.

the class LoginController method registry.

@PostMapping("/registry")
public R registry(@RequestBody RegistryObj registryObj) {
    if (!StringUtils.equalsIgnoreCase(registryObj.getPassword(), registryObj.getConfirmPassword())) {
        return R.error(ReturnCodeEnum.USER_TWO_PASSWORD_NOT_SAME_ERROR);
    }
    // 验证手机号是否唯一
    long count = iMemberService.count(Wrappers.lambdaQuery(Member.class).eq(Member::getMobile, registryObj.getMobile()));
    iMemberService.count(new QueryWrapper<Member>().eq("mobile", registryObj.getMobile()));
    if (count > 0) {
        return R.error(ReturnCodeEnum.USER_PHONE_HAS_REGISTER_ERROR);
    }
    // String redisCode = redisCache.getCacheObject(registryObj.getKey());
    // // 判断验证码
    // if (registryObj.getCode() == null || !redisCode.equals(registryObj.getCode().trim().toLowerCase())) {
    // return R.error("验证码不正确");
    // }
    // 
    // redisCache.deleteObject(registryObj.getKey());
    String redisEmailCode = redisCache.getCacheObject(registryObj.getEmailKey());
    // 判断邮箱验证码
    if (registryObj.getEmailCode() == null || !redisEmailCode.equals(registryObj.getEmailCode().trim().toLowerCase())) {
        return R.error(ReturnCodeEnum.USER_EMAIL_CODE_ERROR);
    }
    // 删除验证码
    redisCache.deleteObject(registryObj.getEmailKey());
    Member member = new Member();
    member.setNickname("昵称" + new Date().getTime() / 1000);
    String avatar = SysConstants.DEFAULT_AVATAR;
    member.setAvatar(avatar);
    member.setMobile(registryObj.getMobile());
    member.setEmail(registryObj.getEmail());
    member.setPassword(SecurityUtils.encryptPassword(registryObj.getPassword()));
    member.setCreateTime(new Date());
    return R.result(iMemberService.save(member));
}
Also used : QueryWrapper(com.baomidou.mybatisplus.core.conditions.query.QueryWrapper) Member(com.wayn.common.core.domain.shop.Member) Date(java.util.Date)

Example 53 with QueryWrapper

use of com.baomidou.mybatisplus.core.conditions.query.QueryWrapper in project weather-push by yangh124.

the class RedisServiceImpl method redisHolidayByKey.

@Override
public Holiday redisHolidayByKey(LocalDate date) {
    DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
    String dateStr = date.format(formatter);
    String key = "holiday:" + date.getYear() + ":map";
    Boolean b = redisTemplate.hasKey(key);
    Map<String, Holiday> map = new HashMap<>();
    if (!BooleanUtil.isTrue(b)) {
        int year = LocalDate.now().getYear();
        LambdaQueryWrapper<Holiday> queryWrapper = new QueryWrapper<Holiday>().lambda().eq(Holiday::getYear, year);
        List<Holiday> list = holidayService.list(queryWrapper);
        if (CollUtil.isNotEmpty(list)) {
            map = list.stream().collect(Collectors.toMap(a -> a.getHolidayDate().format(formatter), a -> a));
            List<Object> argList = new ArrayList<>();
            argList.add(map.size() << 1 + 2);
            argList.add(86400L);
            for (String s : map.keySet()) {
                argList.add(s);
                argList.add(map.get(s));
            }
            Object[] args = argList.toArray();
            redisTemplate.execute(RedisScript.of(hmsetLua), Collections.singletonList(key), args);
        }
        return map.get(dateStr);
    } else {
        Object o = redisTemplate.opsForHash().get(key, dateStr);
        if (null != o) {
            return (Holiday) o;
        } else {
            return null;
        }
    }
}
Also used : QueryWrapper(com.baomidou.mybatisplus.core.conditions.query.QueryWrapper) LambdaQueryWrapper(com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper) Holiday(com.yh.weatherpush.entity.Holiday) DateTimeFormatter(java.time.format.DateTimeFormatter)

Example 54 with QueryWrapper

use of com.baomidou.mybatisplus.core.conditions.query.QueryWrapper in project dubbo-admin by apache.

the class MockRuleServiceImpl method createOrUpdateMockRule.

@Override
public void createOrUpdateMockRule(MockRuleDTO mockRule) {
    if (Objects.isNull(mockRule.getServiceName()) || Objects.isNull(mockRule.getMethodName()) || Objects.isNull(mockRule.getRule())) {
        throw new IllegalStateException("Param serviceName, methodName, rule cannot be null");
    }
    MockRule rule = MockRule.toMockRule(mockRule);
    QueryWrapper<MockRule> queryWrapper = new QueryWrapper<>();
    queryWrapper.eq("service_name", mockRule.getServiceName());
    queryWrapper.eq("method_name", mockRule.getMethodName());
    MockRule existRule = mockRuleMapper.selectOne(queryWrapper);
    // check if we can save or update the rule, we need keep the serviceName + methodName is unique.
    if (Objects.nonNull(existRule)) {
        if (Objects.equals(rule.getServiceName(), existRule.getServiceName()) && Objects.equals(rule.getMethodName(), existRule.getMethodName())) {
            if (!Objects.equals(rule.getId(), existRule.getId())) {
                throw new DuplicateKeyException("Service Name and Method Name must be unique");
            }
        }
    }
    if (Objects.nonNull(rule.getId())) {
        mockRuleMapper.updateById(rule);
        return;
    }
    mockRuleMapper.insert(rule);
}
Also used : QueryWrapper(com.baomidou.mybatisplus.core.conditions.query.QueryWrapper) MockRule(org.apache.dubbo.admin.model.domain.MockRule) DuplicateKeyException(org.springframework.dao.DuplicateKeyException)

Example 55 with QueryWrapper

use of com.baomidou.mybatisplus.core.conditions.query.QueryWrapper in project dubbo-admin by apache.

the class MockRuleServiceImpl method getMockData.

@Override
public MockResult getMockData(MockContext mockContext) {
    QueryWrapper<MockRule> queryWrapper = new QueryWrapper<>();
    queryWrapper.eq("service_name", mockContext.getServiceName());
    queryWrapper.eq("method_name", mockContext.getMethodName());
    MockRule mockRule = mockRuleMapper.selectOne(queryWrapper);
    MockResult mockResult = new MockResult();
    if (Objects.isNull(mockRule)) {
        return mockResult;
    }
    mockResult.setEnable(mockRule.getEnable());
    mockResult.setContent(mockRule.getRule());
    return mockResult;
}
Also used : MockResult(org.apache.dubbo.mock.api.MockResult) QueryWrapper(com.baomidou.mybatisplus.core.conditions.query.QueryWrapper) MockRule(org.apache.dubbo.admin.model.domain.MockRule)

Aggregations

QueryWrapper (com.baomidou.mybatisplus.core.conditions.query.QueryWrapper)723 Transactional (org.springframework.transaction.annotation.Transactional)98 IPage (com.baomidou.mybatisplus.core.metadata.IPage)82 UserRolesVo (top.hcode.hoj.pojo.vo.UserRolesVo)74 LambdaQueryWrapper (com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper)72 Page (com.baomidou.mybatisplus.extension.plugins.pagination.Page)65 ArrayList (java.util.ArrayList)61 Session (org.apache.shiro.session.Session)61 StatusFailException (top.hcode.hoj.common.exception.StatusFailException)60 StatusForbiddenException (top.hcode.hoj.common.exception.StatusForbiddenException)55 Problem (top.hcode.hoj.pojo.entity.problem.Problem)50 UpdateWrapper (com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper)45 Date (java.util.Date)44 HttpServletRequest (javax.servlet.http.HttpServletRequest)35 HashMap (java.util.HashMap)34 RequiresAuthentication (org.apache.shiro.authz.annotation.RequiresAuthentication)34 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)34 ApiOperation (io.swagger.annotations.ApiOperation)32 HttpSession (javax.servlet.http.HttpSession)31 Judge (top.hcode.hoj.pojo.entity.judge.Judge)30