|
@@ -7,11 +7,13 @@ import com.qxgmat.data.constants.enums.module.FeedbackModule;
|
|
|
import com.qxgmat.data.constants.enums.module.ProductType;
|
|
|
import com.qxgmat.data.constants.enums.status.DirectionStatus;
|
|
|
import com.qxgmat.data.constants.enums.status.FeedbackStatus;
|
|
|
+import com.qxgmat.data.constants.enums.user.MoneyRange;
|
|
|
import com.qxgmat.data.dao.entity.*;
|
|
|
import com.qxgmat.data.relation.entity.UserPreviewPaperRelation;
|
|
|
import com.qxgmat.dto.admin.extend.*;
|
|
|
import com.qxgmat.dto.admin.request.UserCourseAppointmentDto;
|
|
|
import com.qxgmat.dto.admin.request.UserFeedbackErrorDto;
|
|
|
+import com.qxgmat.dto.admin.request.UserInvoiceDto;
|
|
|
import com.qxgmat.dto.admin.request.UserServiceRecordDto;
|
|
|
import com.qxgmat.dto.admin.response.*;
|
|
|
import com.qxgmat.help.ShiroHelp;
|
|
@@ -23,6 +25,11 @@ import com.qxgmat.service.UsersService;
|
|
|
import com.qxgmat.service.inline.*;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
|
|
+import org.apache.poi.ss.usermodel.Cell;
|
|
|
+import org.apache.poi.ss.usermodel.Row;
|
|
|
+import org.apache.poi.ss.usermodel.Sheet;
|
|
|
+import org.apache.poi.ss.usermodel.Workbook;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -30,8 +37,11 @@ import org.springframework.http.MediaType;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
+import javax.servlet.ServletOutputStream;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
import javax.servlet.http.HttpSession;
|
|
|
+import java.io.*;
|
|
|
import java.util.Collection;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
@@ -90,6 +100,9 @@ public class UserController {
|
|
|
@Autowired
|
|
|
private UserOrderRecordService userOrderRecordService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private UserInvoiceService userInvoiceService;
|
|
|
+
|
|
|
// @RequestMapping(value = "/add", method = RequestMethod.POST)
|
|
|
// @ApiOperation(value = "添加用户信息", httpMethod = "POST")
|
|
|
// public Response<User> add(@RequestBody @Validated UserDto dto, HttpServletRequest request) {
|
|
@@ -267,10 +280,12 @@ public class UserController {
|
|
|
@RequestParam(required = false, defaultValue = "1") int page,
|
|
|
@RequestParam(required = false, defaultValue = "100") int size,
|
|
|
@RequestParam(required = false) String module,
|
|
|
+ @RequestParam(required = false) Integer userId,
|
|
|
@RequestParam(required = false) Integer status,
|
|
|
@RequestParam(required = false) String keyword,
|
|
|
+ @RequestParam(required = false) Integer moneyRang,
|
|
|
HttpSession session) {
|
|
|
- Page<UserFeedbackError> p = userFeedbackErrorService.listAdmin(page, size, FeedbackModule.ValueOf(module), FeedbackStatus.ValueOf(status), keyword);
|
|
|
+ Page<UserFeedbackError> p = userFeedbackErrorService.listAdmin(page, size, FeedbackModule.ValueOf(module), FeedbackStatus.ValueOf(status), keyword, userId, MoneyRange.ValueOf(moneyRang));
|
|
|
List<UserFeedbackErrorInfoDto> pr = Transform.convert(p, UserFeedbackErrorInfoDto.class);
|
|
|
|
|
|
// 绑定用户
|
|
@@ -357,13 +372,13 @@ public class UserController {
|
|
|
return ResponseHelp.success(true);
|
|
|
}
|
|
|
|
|
|
-// @RequestMapping(value = "/course/appointment/delete", method = RequestMethod.DELETE)
|
|
|
-// @ApiOperation(value = "删除课程预约", httpMethod = "DELETE")
|
|
|
-// public Response<Boolean> deleteCourseAppointment(@RequestParam int id, HttpServletRequest request) {
|
|
|
-// userCourseAppointmentService.delete(id);
|
|
|
-// managerLogService.log(request);
|
|
|
-// return ResponseHelp.success(true);
|
|
|
-// }
|
|
|
+ @RequestMapping(value = "/course/appointment/delete", method = RequestMethod.DELETE)
|
|
|
+ @ApiOperation(value = "删除课程预约", httpMethod = "DELETE")
|
|
|
+ public Response<Boolean> deleteCourseAppointment(@RequestParam int id, HttpServletRequest request) {
|
|
|
+ userCourseAppointmentService.delete(id);
|
|
|
+ managerLogService.log(request);
|
|
|
+ return ResponseHelp.success(true);
|
|
|
+ }
|
|
|
|
|
|
@RequestMapping(value = "/course/appointment/detail", method = RequestMethod.GET)
|
|
|
@ApiOperation(value = "获取课程预约", httpMethod = "GET")
|
|
@@ -401,6 +416,107 @@ public class UserController {
|
|
|
return ResponseHelp.success(pr, page, size, p.getTotal());
|
|
|
}
|
|
|
|
|
|
+ @RequestMapping(value = "/invoice/finish", method = RequestMethod.PUT)
|
|
|
+ @ApiOperation(value = "开发票", httpMethod = "PUT")
|
|
|
+ public Response<Boolean> finishData(
|
|
|
+ @RequestParam(required = false) Integer[] ids,
|
|
|
+ HttpServletRequest request) {
|
|
|
+ userInvoiceService.finish(ids);
|
|
|
+ managerLogService.log(request);
|
|
|
+ return ResponseHelp.success(true);
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequestMapping(value = "/invoice/download", method = RequestMethod.PUT)
|
|
|
+ @ApiOperation(value = "下载资料", httpMethod = "PUT")
|
|
|
+ public Response<Boolean> downloadData(
|
|
|
+ @RequestParam(required = false) Integer[] ids,
|
|
|
+ HttpServletRequest request, HttpServletResponse response) throws IOException {
|
|
|
+ managerLogService.log(request);
|
|
|
+ List<UserInvoice> p = userInvoiceService.select(ids);
|
|
|
+ String columnNames[]={"ID","项目名","销售人","负责人","所用技术","备注"};//列名
|
|
|
+ String filename = "发票";
|
|
|
+ //生成一个Excel文件
|
|
|
+ // 创建excel工作簿
|
|
|
+ Workbook wb = new HSSFWorkbook();
|
|
|
+ // 创建第一个sheet(页),并命名
|
|
|
+ Sheet sheet = wb.createSheet();
|
|
|
+ // 创建第一行
|
|
|
+ Row row = sheet.createRow(0);
|
|
|
+ //设置列名
|
|
|
+ for(int i=0;i<columnNames.length;i++){
|
|
|
+ Cell cell = row.createCell(i);
|
|
|
+ cell.setCellValue(columnNames[i]);
|
|
|
+ }
|
|
|
+ int i = 0;
|
|
|
+ for(UserInvoice invoice : p){
|
|
|
+ i+=1;
|
|
|
+ Row r = sheet.createRow(i);
|
|
|
+ Cell cell = r.createCell(0);
|
|
|
+ cell.setCellValue(invoice.getId());
|
|
|
+ }
|
|
|
+ //同理可以设置数据行
|
|
|
+ ByteArrayOutputStream os = new ByteArrayOutputStream();
|
|
|
+ try {
|
|
|
+ wb.write(os);
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ byte[] content = os.toByteArray();
|
|
|
+ InputStream is = new ByteArrayInputStream(content);
|
|
|
+ // 设置response参数,可以打开下载页面
|
|
|
+ response.reset();
|
|
|
+ response.setContentType("application/vnd.ms-excel;charset=utf-8");
|
|
|
+ response.setHeader("Content-Disposition", "attachment;filename="+ new String((filename + ".xls").getBytes(), "iso-8859-1"));
|
|
|
+ ServletOutputStream out = response.getOutputStream();
|
|
|
+ BufferedInputStream bis = null;
|
|
|
+ BufferedOutputStream bos = null;
|
|
|
+ try {
|
|
|
+ bis = new BufferedInputStream(is);
|
|
|
+ bos = new BufferedOutputStream(out);
|
|
|
+ byte[] buff = new byte[2048];
|
|
|
+ int bytesRead;
|
|
|
+ // Simple read/write loop.
|
|
|
+ while (-1 != (bytesRead = bis.read(buff, 0, buff.length))) {
|
|
|
+ bos.write(buff, 0, bytesRead);
|
|
|
+ }
|
|
|
+ } catch (final IOException e) {
|
|
|
+ throw e;
|
|
|
+ } finally {
|
|
|
+ if (bis != null)
|
|
|
+ bis.close();
|
|
|
+ if (bos != null)
|
|
|
+ bos.close();
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequestMapping(value = "/invoice/list", method = RequestMethod.GET)
|
|
|
+ @ApiOperation(value = "发票列表", httpMethod = "GET")
|
|
|
+ public Response<PageMessage<UserInvoiceListDto>> listData(
|
|
|
+ @RequestParam(required = false, defaultValue = "1") int page,
|
|
|
+ @RequestParam(required = false, defaultValue = "100") int size,
|
|
|
+ @RequestParam(required = false) Integer userId,
|
|
|
+ @RequestParam(required = false) Boolean isFinish,
|
|
|
+ @RequestParam(required = false) Boolean isDownload,
|
|
|
+ @RequestParam(required = false, defaultValue = "id") String order,
|
|
|
+ @RequestParam(required = false, defaultValue = "desc") String direction,
|
|
|
+ HttpSession session) {
|
|
|
+ Page<UserInvoice> p = userInvoiceService.listAdmin(page, size, userId, isDownload, isFinish);
|
|
|
+ List<UserInvoiceListDto> pr = Transform.convert(p, UserInvoiceListDto.class);
|
|
|
+
|
|
|
+ // 绑定用户
|
|
|
+ Collection userIds = Transform.getIds(p, UserInvoice.class, "userId");
|
|
|
+ List<User> userList = usersService.select(userIds);
|
|
|
+ Transform.combine(pr, userList, UserInvoiceListDto.class, "userId", "user", User.class, "id", UserExtendDto.class);
|
|
|
+
|
|
|
+ // 绑定订单
|
|
|
+ Collection orderIds = Transform.getIds(p, UserInvoice.class, "orderId");
|
|
|
+ List<UserOrder> orderList = userOrderService.select(orderIds);
|
|
|
+ Transform.combine(pr, orderList, UserInvoiceListDto.class, "orderId", "order", UserOrder.class, "id", UserOrderExtendDto.class);
|
|
|
+
|
|
|
+ return ResponseHelp.success(pr, page, size, p.getTotal());
|
|
|
+ }
|
|
|
+
|
|
|
@RequestMapping(value = "/valid/mobile", method = RequestMethod.GET)
|
|
|
@ApiOperation(value = "验证手机号", notes="查询手机对应账号", httpMethod = "GET")
|
|
|
public Response<Boolean> validMobile(
|