| | |
| | | package com.ruoyi.web.controller.api; |
| | | |
| | | |
| | | import cn.afterturn.easypoi.excel.ExcelExportUtil; |
| | | import cn.afterturn.easypoi.excel.entity.ExportParams; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.common.annotation.Log; |
| | | import com.ruoyi.common.basic.PageInfo; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | import com.ruoyi.common.enums.BusinessType; |
| | | import com.ruoyi.common.utils.WebUtils; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.framework.web.service.TokenService; |
| | | import com.ruoyi.system.dto.TransferOrderDto; |
| | | import com.ruoyi.system.export.BigGiftPackageImport; |
| | | import com.ruoyi.system.export.TBigGiftPackageOrderExport; |
| | | import com.ruoyi.system.model.*; |
| | | import com.ruoyi.system.query.AppUserListQuery; |
| | | import com.ruoyi.system.query.BigGiftPackageOrderQuery; |
| | | import com.ruoyi.system.query.OrderTransferQuery; |
| | | import com.ruoyi.system.service.*; |
| | |
| | | import com.ruoyi.system.vo.TOrderTransferVo; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.apache.poi.ss.usermodel.Workbook; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.ServletOutputStream; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | |
| | | import java.io.IOException; |
| | | import java.math.BigDecimal; |
| | | import java.net.URLEncoder; |
| | | import java.time.LocalDateTime; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | |
| | |
| | | @PostMapping(value = "/pageList") |
| | | public R<Page<TBigGiftPackageOrder>> pageList(@RequestBody BigGiftPackageOrderQuery query) { |
| | | Page<TBigGiftPackageOrder> tBigGiftPackageOrderPage = new Page<>(query.getPageNum(), query.getPageSize()); |
| | | List<TBigGiftPackageOrder> list = tBigGiftPackageOrderService.pageList(tBigGiftPackageOrderPage,query); |
| | | List<TBigGiftPackageOrder> list = tBigGiftPackageOrderService.pageList(tBigGiftPackageOrderPage,query); |
| | | tBigGiftPackageOrderPage.setRecords(list); |
| | | return R.ok(tBigGiftPackageOrderPage); |
| | | } |
| | | |
| | | @ApiOperation(value = "导出大礼包订单") |
| | | @Log(title = "大礼包订单-导出", businessType = BusinessType.EXPORT) |
| | | @PostMapping("/export") |
| | | public void export( @RequestBody BigGiftPackageOrderQuery query) { |
| | | List<TBigGiftPackageOrder> list = tBigGiftPackageOrderService.export(query); |
| | | ArrayList<TBigGiftPackageOrderExport> exports = new ArrayList<>(); |
| | | for (TBigGiftPackageOrder order : list) { |
| | | TBigGiftPackageOrderExport export = new TBigGiftPackageOrderExport(); |
| | | export.setCompanyName(order.getCompanyName()); |
| | | export.setOrderNo(order.getCode()); |
| | | export.setCreateTime(order.getCreateTime()); |
| | | export.setUsername(order.getUserName()); |
| | | export.setUserPhone(order.getPhone()); |
| | | export.setOrderAmount(order.getOrderPrice()); |
| | | export.setGoodsName(order.getBigGiftPackageName()); |
| | | export.setPayMethod("微信支付"); |
| | | export.setDeposit(order.getDeposit()); |
| | | export.setBalance(order.getFinalPayment()); |
| | | export.setOrderStatus(order.getStatus()); |
| | | exports.add(export); |
| | | } |
| | | |
| | | |
| | | Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), TBigGiftPackageOrderExport.class, exports); |
| | | HttpServletResponse response = WebUtils.response(); |
| | | assert response != null; |
| | | response.setContentType("application/vnd.ms-excel"); |
| | | response.setCharacterEncoding("utf-8"); |
| | | ServletOutputStream outputStream = null; |
| | | try { |
| | | String fileName = URLEncoder.encode("大礼包订单导出信息.xls", "utf-8"); |
| | | response.setHeader("Content-Disposition", "attachment;filename=" + fileName); |
| | | response.setContentType("application/vnd.ms-excel;charset=UTF-8"); |
| | | response.setHeader("Pragma", "no-cache"); |
| | | response.setHeader("Cache-Control", "no-cache"); |
| | | outputStream = response.getOutputStream(); |
| | | workbook.write(outputStream); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } finally { |
| | | try { |
| | | outputStream.close(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | tBigGiftPackageOrder.setPartnerName(lastUser.getName()); |
| | | } |
| | | } |
| | | Integer bigGiftPackageId = tBigGiftPackageOrder.getBigGiftPackageId(); |
| | | TBigGiftPackage tBigGiftPackage = tBigGiftPackageService.getById(bigGiftPackageId); |
| | | tBigGiftPackageOrder.setBigGiftPackageName(tBigGiftPackage.getName()); |
| | | tBigGiftPackageOrder.setBigGiftPackageCover(tBigGiftPackage.getCoverImage()); |
| | | tBigGiftPackageOrder.setBigGiftPackagePrice(tBigGiftPackage.getTotalPrice()); |
| | | tBigGiftPackageOrder.setBigGiftPackageIntro(tBigGiftPackage.getIntroduction()); |
| | | String bigGiftPackage = tBigGiftPackageOrder.getBigGiftPackage(); |
| | | if(bigGiftPackage!=null){ |
| | | JSONObject jsonObject = JSONObject.parseObject(bigGiftPackage); |
| | | tBigGiftPackageOrder.setBigGiftPackageName(jsonObject.getString("name")); |
| | | tBigGiftPackageOrder.setBigGiftPackageCover(jsonObject.getString("coverImage")); |
| | | tBigGiftPackageOrder.setBigGiftPackagePrice(new BigDecimal(jsonObject.getString("totalPrice"))); |
| | | tBigGiftPackageOrder.setBigGiftPackageIntro(jsonObject.getString("introduction")); |
| | | } |
| | | |
| | | |
| | | // 销量 |
| | | long count = tBigGiftPackageOrderService.count(new LambdaQueryWrapper<TBigGiftPackageOrder>().eq(TBigGiftPackageOrder::getBigGiftPackageId, bigGiftPackageId).ne(TBigGiftPackageOrder::getStatus, 5)); |
| | | long count = tBigGiftPackageOrderService.count(new LambdaQueryWrapper<TBigGiftPackageOrder>().eq(TBigGiftPackageOrder::getBigGiftPackageId, tBigGiftPackageOrder.getBigGiftPackageId()).ne(TBigGiftPackageOrder::getStatus, 5)); |
| | | tBigGiftPackageOrder.setBigGiftPackageSales((int)count); |
| | | |
| | | |
| | |
| | | TCompany tCompany = tCompanyService.getById(companyId); |
| | | tBigGiftPackageOrder.setCompanyName(tCompany.getName()); |
| | | } |
| | | |
| | | |
| | | tBigGiftPackageOrder.setUserName(appUser.getName()); |
| | | tBigGiftPackageOrder.setPhone(appUser.getPhone()); |
| | | return R.ok(tBigGiftPackageOrder); |
| | | } |
| | | |
| | |
| | | return update ? R.ok() : R.fail(); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | @ApiOperation(value = "订单转让列表") |
| | | @PostMapping(value = "/transferList") |
| | | public R<Page<TOrderTransferVo>> transferList(@RequestBody OrderTransferQuery query) { |
| | |
| | | tOrderTransferPage.setRecords(list); |
| | | return R.ok(tOrderTransferPage); |
| | | } |
| | | |
| | | |
| | | @ApiOperation(value = "订单转让--导出") |
| | | @Log(title = "订单转让-导出", businessType = BusinessType.EXPORT) |
| | | @PostMapping("/transferExport") |
| | | public void transferExport(@RequestBody OrderTransferQuery query) { |
| | | List<TOrderTransferVo> list = tOrderTransferService.pageListExport(query); |
| | | |
| | | Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), TOrderTransferVo.class, list); |
| | | HttpServletResponse response = WebUtils.response(); |
| | | assert response != null; |
| | | response.setContentType("application/vnd.ms-excel"); |
| | | response.setCharacterEncoding("utf-8"); |
| | | ServletOutputStream outputStream = null; |
| | | try { |
| | | String fileName = URLEncoder.encode("订单转让导出信息.xls", "utf-8"); |
| | | response.setHeader("Content-Disposition", "attachment;filename=" + fileName); |
| | | response.setContentType("application/vnd.ms-excel;charset=UTF-8"); |
| | | response.setHeader("Pragma", "no-cache"); |
| | | response.setHeader("Cache-Control", "no-cache"); |
| | | outputStream = response.getOutputStream(); |
| | | workbook.write(outputStream); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } finally { |
| | | try { |
| | | outputStream.close(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | @ApiOperation(value = "订单转让详情") |
| | | @PostMapping(value = "/transferDetail/{id}") |
| | |
| | | tOrderTransferVo.setOperateUser(sysUser.getNickName()); |
| | | return R.ok(tOrderTransferVo); |
| | | } |
| | | |
| | | |
| | | @ApiOperation(value = "订单转让删除") |
| | | @DeleteMapping(value = "/transferDelete/{id}") |
| | | @Log(title = "订单转让-删除", businessType = BusinessType.DELETE) |
| | | public R<String> transferDelete(@PathVariable Integer id) { |
| | | TOrderTransfer orderTransfer = tOrderTransferService.getById(id); |
| | | if (orderTransfer == null) { |
| | | return R.fail("订单转让不存在"); |
| | | } |
| | | orderTransfer.setDelFlag(1); |
| | | tOrderTransferService.updateById(orderTransfer); |
| | | return R.ok() ; |
| | | } |
| | | |
| | | |
| | | @ApiOperation(value = "用户管理分页列表") |
| | | @PostMapping(value = "/transferPageUserList") |
| | | public R<PageInfo<TAppUser>> transferPageUserList(@RequestBody AppUserListQuery query) { |
| | | return R.ok(tAppUserService.transferPageUserList(query)); |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | |