| | |
| | | import com.stylefeng.guns.core.base.controller.BaseController; |
| | | import com.stylefeng.guns.core.common.constant.factory.PageFactory; |
| | | import com.stylefeng.guns.core.shiro.ShiroKit; |
| | | 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.UserRedPacketRecord; |
| | | 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; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.ResponseBody; |
| | |
| | | import com.stylefeng.guns.modular.system.model.SysRedPacketRecord; |
| | | import com.stylefeng.guns.modular.system.service.ISysRedPacketRecordService; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.Calendar; |
| | | import java.util.Date; |
| | | import java.util.Map; |
| | | import java.util.Random; |
| | | |
| | | /** |
| | | * 控制器 |
| | |
| | | |
| | | @Autowired |
| | | private ISysRedPacketRecordService sysRedPacketRecordService; |
| | | @Autowired |
| | | private IUserRedPacketRecordService userRedPacketRecordService; |
| | | |
| | | |
| | | /** |
| | | * 跳转到首页 |
| | |
| | | @RequestMapping("") |
| | | public String index() { |
| | | return PREFIX + "sysRedPacketRecord.html"; |
| | | } |
| | | |
| | | @RequestMapping("/tUser") |
| | | public String tUser() { |
| | | return PREFIX + "tUser.html"; |
| | | } |
| | | |
| | | /** |
| | |
| | | return PREFIX + "sysRedPacketRecord_edit.html"; |
| | | } |
| | | |
| | | |
| | | @RequestMapping(value = "/direct") |
| | | @ResponseBody |
| | | public ResultUtil direct(String ids, Integer redId) { |
| | | |
| | | System.err.println("========="+ids+"======="+redId); |
| | | Double money = 0D; |
| | | |
| | | |
| | | SysRedPacketRecord sysRedPacketRecord = sysRedPacketRecordService.selectById(redId); |
| | | if(null != sysRedPacketRecord){ |
| | | Integer type = sysRedPacketRecord.getType(); |
| | | if(type == 1){//固定金额 |
| | | money = Double.valueOf(String.valueOf(sysRedPacketRecord.getMoney())); |
| | | }else{//随机金额 |
| | | Double startMoney = Double.valueOf(String.valueOf(sysRedPacketRecord.getStartMoney())); |
| | | 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); |
| | | money = new BigDecimal(startMoney).add(new BigDecimal(num)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue(); |
| | | } |
| | | |
| | | } |
| | | String[] split = ids.split(","); |
| | | for (String s : split) { |
| | | if(money > 0){ |
| | | //添加临时红包数据 |
| | | UserRedPacketRecord userRedPacketRecord = new UserRedPacketRecord(); |
| | | userRedPacketRecord.setMoney(money); |
| | | userRedPacketRecord.setInsertTime(new Date()); |
| | | userRedPacketRecord.setCompanyId(1); |
| | | userRedPacketRecord.setState(0); |
| | | userRedPacketRecord.setOrderId(null); |
| | | userRedPacketRecord.setOrderType(3); |
| | | userRedPacketRecord.setUserId(Integer.valueOf(s)); |
| | | userRedPacketRecordService.insert(userRedPacketRecord); |
| | | } |
| | | } |
| | | return ResultUtil.success(); |
| | | } |
| | | /** |
| | | * 获取列表 |
| | | */ |