|
@@ -1,14 +1,19 @@
|
|
|
package com.qs.mp.admin.service.impl;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.qs.mp.admin.domain.Ticket;
|
|
|
import com.qs.mp.admin.domain.excel.TicketExcel;
|
|
|
import com.qs.mp.admin.mapper.TicketMapper;
|
|
|
import com.qs.mp.admin.service.ITicketService;
|
|
|
+import com.qs.mp.common.exception.ServiceException;
|
|
|
+import com.qs.mp.common.utils.RSAUtil;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
@@ -35,11 +40,28 @@ public class TicketServiceImpl extends ServiceImpl<TicketMapper, Ticket> impleme
|
|
|
@Override
|
|
|
@Transactional
|
|
|
public int importTicket(List<TicketExcel> ticketExcelList) {
|
|
|
- // TODO Auto-generated method stub
|
|
|
if (null != ticketExcelList && ticketExcelList.size() > 0) {
|
|
|
+ List<Ticket> ticketList = new ArrayList<Ticket>();
|
|
|
for (TicketExcel ticketExcel : ticketExcelList) {
|
|
|
-
|
|
|
-
|
|
|
+ if(null != ticketExcel && StringUtils.isNotBlank(ticketExcel.getSerialNo())) {
|
|
|
+ LambdaQueryWrapper<Ticket> ticketQueryWrapper = new LambdaQueryWrapper<Ticket>();
|
|
|
+ ticketQueryWrapper.eq(Ticket::getSerialNo, ticketExcel.getSerialNo());
|
|
|
+ Ticket ticket = ticketService.getOne(ticketQueryWrapper);
|
|
|
+ if(null != ticket && StringUtils.isNotBlank(ticket.getTicketId())) {
|
|
|
+ Ticket updateTicket = new Ticket();
|
|
|
+ updateTicket.setTicketId(ticket.getTicketId());
|
|
|
+ updateTicket.setCipherLuckyNum(RSAUtil.encrypt(ticketExcel.getCipherLuckyNum()));
|
|
|
+ updateTicket.setDrawNum(ticketExcel.getDrawNum());
|
|
|
+ ticketList.add(updateTicket);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(null != ticketList && ticketList.size() > 0) {
|
|
|
+ boolean res = ticketService.updateBatchById(ticketList);
|
|
|
+ if(!res) {
|
|
|
+ throw new ServiceException("满票导入失败,请联系管理员");
|
|
|
+ }
|
|
|
+ return ticketList.size();
|
|
|
}
|
|
|
}
|
|
|
return 0;
|