| | |
| | | package com.stylefeng.guns.modular.system.controller.general; |
| | | |
| | | import cn.hutool.system.UserInfo; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.baomidou.mybatisplus.mapper.Wrapper; |
| | | import com.baomidou.mybatisplus.plugins.Page; |
| | |
| | | import com.stylefeng.guns.core.shiro.ShiroUser; |
| | | import com.stylefeng.guns.core.util.DateUtil; |
| | | import com.stylefeng.guns.core.util.SinataUtil; |
| | | import com.stylefeng.guns.modular.system.model.TSystemNotice; |
| | | import com.stylefeng.guns.modular.system.model.TUser; |
| | | import com.stylefeng.guns.modular.system.model.UserRedPacketRecord; |
| | | import com.stylefeng.guns.modular.system.service.ITSystemNoticeService; |
| | | import com.stylefeng.guns.modular.system.service.ITUserService; |
| | | import com.stylefeng.guns.modular.system.service.IUserRedPacketRecordService; |
| | | import com.stylefeng.guns.modular.system.service.impl.UserServiceImpl; |
| | | import com.stylefeng.guns.modular.system.util.ResultUtil; |
| | |
| | | } |
| | | |
| | | |
| | | @Autowired |
| | | private ITSystemNoticeService systemNoticeService; |
| | | |
| | | @Autowired |
| | | private ITUserService userService; |
| | | |
| | | |
| | | @RequestMapping(value = "/direct") |
| | | @ResponseBody |
| | | public ResultUtil direct(String ids, Integer redId) { |
| | |
| | | money = Double.valueOf(String.valueOf(sysRedPacketRecord.getMoney())); |
| | | //计算剩余金额是否够 |
| | | |
| | | if (v <= 0){ |
| | | |
| | | if (v-money*ids.split(",").length < 0){ |
| | | return ResultUtil.error("当前红包剩余金额不足"); |
| | | } |
| | | |
| | |
| | | Double endMoney = Double.valueOf(String.valueOf(sysRedPacketRecord.getEndMoney())); |
| | | int i = new BigDecimal(endMoney).subtract(new BigDecimal(startMoney)).intValue(); |
| | | Random random = new Random(); |
| | | int num = random.nextInt(i); |
| | | int num; |
| | | if (!startMoney.equals(endMoney)){ |
| | | num = random.nextInt(i); |
| | | |
| | | }else { |
| | | num = 0; |
| | | } |
| | | money = new BigDecimal(startMoney).add(new BigDecimal(num)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue(); |
| | | v=v-money; |
| | | if (v<=0){ |
| | | if (v<0){ |
| | | return ResultUtil.success("当前红包为随机红包,可能有部分用户无法领取",null,"当前红包为随机红包,可能有部分用户无法领取"); |
| | | } |
| | | } |
| | |
| | | userRedPacketRecord.setCompanyId(1); |
| | | userRedPacketRecord.setState(1); |
| | | userRedPacketRecord.setOrderId(null); |
| | | // 标记为后台发放的红包 |
| | | userRedPacketRecord.setIsGrant(1); |
| | | userRedPacketRecord.setRedPacketActivityId(redId); |
| | | // userRedPacketRecord.setOrderType(3); |
| | | userRedPacketRecord.setUserId(Integer.valueOf(s)); |
| | | userRedPacketRecordService.insert(userRedPacketRecord); |
| | | |
| | | TUser tUser = userService.selectById(Integer.valueOf(s)); |
| | | Integer language = tUser.getLanguage(); |
| | | try { |
| | | systemNoticeService.addSystemNotice(1, language == 1 ? "您收到一个额度为GHS"+money+"的红包,请查收。" : language == 2 ? "You have received a red envelope with a limit of GHS"+money+". Please check it." : "Vous recevez un paquet rouge avec une limite de ghs+"+money+", veuillez vérifier.", tUser.getId()); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | return ResultUtil.success("指派成功",null,"当前红包为随机红包,可能有部分用户无法领取"); |