kongdeqiang
2024-04-09 fb050c0dafa5363a73540dd9e52b78487e25ba0a
src/main/java/com/boying/controller/phone/TicketController.java
@@ -5,7 +5,6 @@
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.boying.common.R;
import com.boying.common.SystemConfigProperties;
import com.boying.entity.*;
import com.boying.service.*;
@@ -17,6 +16,8 @@
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.io.IOUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
@@ -42,7 +43,13 @@
    private final TicketService ticketService;
    private final SystemConfigProperties systemConfigProperties;
    @Value("${ffpark.uploadPath}")
    private String uploadImgPath;
    @Value("${ffpark.ip2}")
    private String ip2;
//    @Autowired
//    private final SystemConfigProperties systemConfigProperties;
    private final UserService userService;
@@ -61,7 +68,7 @@
    public void getAwardAsByteArray(HttpServletResponse response, HttpServletRequest request) throws IOException {
        String result = request.getParameter("result");
        InputStream in = null;
        in = FileUtils.openInputStream(new File(systemConfigProperties.getUploadImgPath()+result));
        in = FileUtils.openInputStream(new File(uploadImgPath+result));
        response.setContentType(MediaType.IMAGE_PNG_VALUE);
        ServletOutputStream out = response.getOutputStream();
        try {
@@ -96,7 +103,7 @@
            if(multipartFile != null){
                String fileExtension = FilenameUtils.getExtension(multipartFile.getOriginalFilename());//获取后缀
                String newFileName = System.currentTimeMillis() + "." + fileExtension;//图片名称
                String newFilePath = systemConfigProperties.getUploadImgPath() + newFileName;//上传路径
                String newFilePath = uploadImgPath + newFileName;//上传路径
                File destFile = new File(newFilePath);
                FileUtils.writeByteArrayToFile(destFile, multipartFile.getBytes());
                if(i != imgs.size()-1){
@@ -127,12 +134,31 @@
        ticketService.saveOrUpdate(ticket);
        if(StringUtils.isBlank(ticket.getQrUrl())){
            ticket.setQrUrl(systemConfigProperties.getIp2()+"#/index?id="+ticket.getId());
            ticket.setQrUrl(ip2+"#/index?id="+ticket.getId());
            ticketService.saveOrUpdate(ticket);
        }
        if(StringUtils.isNotBlank(ticket.getLng())&&StringUtils.isNotBlank(ticket.getLat())){
            saveLogo(ticket.getAddress(),ticket.getLng(),ticket.getLat());
        }
        if(ticket.getType() == 2){
            try {
                ticket.setPayStatus(1);
                QueryWrapper<TicketBlack> wrapper = new QueryWrapper<>();
                wrapper.lambda()
                        .eq(TicketBlack::getCarNo,ticket.getCarNo());
                List<TicketBlack> list = ticketBlackService.list(wrapper);
                if(list.size()>0){
                    for (TicketBlack ticketBlack : list) {
                        ticketBlackService.removeById(ticketBlack.getId());
                    }
                }
                ticket = ticketService.getNumber(ticket);
                ticket.setPush(0);
                ticketService.uploadInfo(ticket);
            }catch (Exception e){
                e.printStackTrace();
            }
        }
        return R.ok(ticket);
    }
@@ -155,7 +181,7 @@
        updateBlackTicket(ticket);
        ticketService.saveOrUpdate(ticket);
        ticket.setQrUrl(systemConfigProperties.getIp2()+"#/index?id="+ticket.getId());
        ticket.setQrUrl(ip2+"#/index?id="+ticket.getId());
        ticket.setType(1);
        ticketService.saveOrUpdate(ticket);
        return R.ok(ticket);
@@ -195,6 +221,15 @@
        Ticket ticket =ticketService.getById(id);
        ticket.setStatus(3);
        ticketService.saveOrUpdate(ticket);
        QueryWrapper<TicketBlack> wrapper = new QueryWrapper<>();
        wrapper.lambda()
                .eq(TicketBlack::getCarNo,ticket.getCarNo());
        List<TicketBlack> list = ticketBlackService.list(wrapper);
        if(list.size()>0){
            for (TicketBlack ticketBlack : list) {
                ticketBlackService.removeById(ticketBlack.getId());
            }
        }
        return R.ok("操作成功");
    }
@@ -206,7 +241,7 @@
            ticket.setMoneyStr(s.toString());
        }
        if(ticket.getMoney() == 0){
            if(StringUtils.isNotBlank(ticket.getNumber())){
            if(StringUtils.isBlank(ticket.getNumber())){
                ticket = ticketService.getNumber(ticket);
                ticket.setPush(0);
                ticketService.uploadInfo(ticket);
@@ -220,6 +255,9 @@
            ticket.setZfQianMing1("http://127.0.0.1:8089/ffzf/fileinfo/showImg/wangjunxiang.png");
            ticket.setZfQianMing2("http://127.0.0.1:8089/ffzf/fileinfo/showImg/zhangjinglei.png");
        }
        if(StringUtils.isBlank(ticket.getNumber())){
            ticket.setNumber("--");
        }
        ticketService.updateById(ticket);
        return R.ok();
    }