|  |  |  | 
|---|
|  |  |  | import cc.mrbird.febs.common.controller.BaseController; | 
|---|
|  |  |  | import cc.mrbird.febs.common.entity.FebsResponse; | 
|---|
|  |  |  | import cc.mrbird.febs.common.entity.QueryRequest; | 
|---|
|  |  |  | import cc.mrbird.febs.common.exception.FebsException; | 
|---|
|  |  |  | import cc.mrbird.febs.common.utils.RedisUtils; | 
|---|
|  |  |  | import cc.mrbird.febs.common.utils.excl.ExcelSheetPO; | 
|---|
|  |  |  | import cc.mrbird.febs.common.utils.excl.ExcelUtil; | 
|---|
|  |  |  | import cc.mrbird.febs.common.utils.excl.ExcelVersion; | 
|---|
|  |  |  | import cc.mrbird.febs.common.utils.excl.ResponseHeadUtil; | 
|---|
|  |  |  | import cc.mrbird.febs.mall.dto.AdminHappyActivityCategoryDto; | 
|---|
|  |  |  | import cc.mrbird.febs.mall.dto.activity.AdminActivityOptionAddDto; | 
|---|
|  |  |  | import cc.mrbird.febs.mall.dto.activity.AdminCategoryAddDto; | 
|---|
|  |  |  | import cc.mrbird.febs.mall.dto.activity.AdminCategoryUpdateDto; | 
|---|
|  |  |  | import cc.mrbird.febs.mall.dto.AdminMallGoodsCommentDto; | 
|---|
|  |  |  | import cc.mrbird.febs.mall.dto.activity.*; | 
|---|
|  |  |  | import cc.mrbird.febs.mall.entity.HappyActivity; | 
|---|
|  |  |  | import cc.mrbird.febs.mall.entity.HappyActivityOption; | 
|---|
|  |  |  | import cc.mrbird.febs.mall.entity.HappyActivityOrder; | 
|---|
|  |  |  | import cc.mrbird.febs.mall.service.IAdminHappyActivityService; | 
|---|
|  |  |  | import cc.mrbird.febs.mall.vo.activity.AdminHappyActivityOrderCheckVo; | 
|---|
|  |  |  | import cn.hutool.core.date.DatePattern; | 
|---|
|  |  |  | import cn.hutool.core.date.DateUtil; | 
|---|
|  |  |  | import cn.hutool.core.util.ObjectUtil; | 
|---|
|  |  |  | import cn.hutool.core.util.StrUtil; | 
|---|
|  |  |  | import lombok.RequiredArgsConstructor; | 
|---|
|  |  |  | import lombok.SneakyThrows; | 
|---|
|  |  |  | import lombok.extern.slf4j.Slf4j; | 
|---|
|  |  |  | import org.springframework.validation.annotation.Validated; | 
|---|
|  |  |  | import org.springframework.web.bind.annotation.*; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import javax.servlet.http.HttpServletResponse; | 
|---|
|  |  |  | import javax.validation.Valid; | 
|---|
|  |  |  | import javax.validation.constraints.NotNull; | 
|---|
|  |  |  | import java.io.OutputStream; | 
|---|
|  |  |  | import java.net.URLEncoder; | 
|---|
|  |  |  | import java.util.ArrayList; | 
|---|
|  |  |  | import java.util.Date; | 
|---|
|  |  |  | import java.util.List; | 
|---|
|  |  |  | import java.util.Map; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Slf4j | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 获取全部活动 | 
|---|
|  |  |  | * 获取全部投票活动 | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @GetMapping(value = "/allActivities") | 
|---|
|  |  |  | public FebsResponse allActivities() { | 
|---|
|  |  |  | return new FebsResponse().success().data(adminHappyActivityService.allActivities()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 获取全部众筹活动 | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @GetMapping(value = "/allOrderActivities") | 
|---|
|  |  |  | public FebsResponse allOrderActivities() { | 
|---|
|  |  |  | return new FebsResponse().success().data(adminHappyActivityService.allOrderActivities()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | 
|---|
|  |  |  | return new FebsResponse().success().data(data); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 订单 | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @GetMapping("activityOrderList") | 
|---|
|  |  |  | public FebsResponse activityOrderList(AdminHappyActivityOrderDto dto, QueryRequest request) { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Map<String, Object> data = getDataTable(adminHappyActivityService.activityOrderList(dto, request)); | 
|---|
|  |  |  | return new FebsResponse().success().data(data); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 订单-手动核销 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @PostMapping("checkOrder") | 
|---|
|  |  |  | @ControllerEndpoint(operation = "订单-手动核销", exceptionMessage = "操作失败") | 
|---|
|  |  |  | public FebsResponse checkOrder(@RequestBody List<Long> dto) { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return adminHappyActivityService.checkOrder(dto); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 订单-删除 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @GetMapping("activityOrderDel/{id}") | 
|---|
|  |  |  | @ControllerEndpoint(operation = "订单-删除", exceptionMessage = "操作失败") | 
|---|
|  |  |  | public FebsResponse activityOrderDel(@NotNull(message = "{required}") @PathVariable Long id) { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return adminHappyActivityService.activityOrderDel(id); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 评论列表 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @GetMapping("commentList") | 
|---|
|  |  |  | public FebsResponse getCommentList(AdminActivityCommentDto dto, QueryRequest request) { | 
|---|
|  |  |  | Map<String, Object> data = getDataTable(adminHappyActivityService.getCommentListInPage(dto, request)); | 
|---|
|  |  |  | return new FebsResponse().success().data(data); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 评论列表-显示评论 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @GetMapping("showStateSwitchOn/{id}") | 
|---|
|  |  |  | @ControllerEndpoint(operation = "评论列表-显示评论", exceptionMessage = "设置失败") | 
|---|
|  |  |  | public FebsResponse showStateSwitchOn(@NotNull(message = "{required}") @PathVariable Long id) { | 
|---|
|  |  |  | return adminHappyActivityService.showStateSwitchOn(id); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @SneakyThrows | 
|---|
|  |  |  | @GetMapping("/exportOptionList") | 
|---|
|  |  |  | public void exportOptionList(@RequestParam Map<String, String> params, HttpServletResponse response) { | 
|---|
|  |  |  | List<ExcelSheetPO> res = new ArrayList<>(); | 
|---|
|  |  |  | ExcelSheetPO orderSheet = new ExcelSheetPO(); | 
|---|
|  |  |  | String title = "报名列表"; | 
|---|
|  |  |  | orderSheet.setTitle(title); | 
|---|
|  |  |  | String[] header = {"序号", "姓名", "联系方式", "兴趣爱好","家庭住址","地区","是否签约mcn机构", "备注"}; | 
|---|
|  |  |  | orderSheet.setHeaders(header); | 
|---|
|  |  |  | List<HappyActivityOption> dataList = adminHappyActivityService.getVoteOptionListForExport(params); | 
|---|
|  |  |  | List<List<Object>> list = new ArrayList<>(); | 
|---|
|  |  |  | if (dataList.size() > 0) { | 
|---|
|  |  |  | int i = 0; | 
|---|
|  |  |  | for (HappyActivityOption item : dataList) { | 
|---|
|  |  |  | i++; | 
|---|
|  |  |  | List<Object> temp = new ArrayList<>(); | 
|---|
|  |  |  | temp.add(i); | 
|---|
|  |  |  | temp.add(item.getOptionName()); | 
|---|
|  |  |  | temp.add(item.getMobilePhone()); | 
|---|
|  |  |  | temp.add(item.getHobby()); | 
|---|
|  |  |  | temp.add(item.getAddress()); | 
|---|
|  |  |  | temp.add(item.getProvince()+item.getCity()); | 
|---|
|  |  |  | temp.add(item.getMcnState() == 1 ?"是":"否"); | 
|---|
|  |  |  | temp.add(item.getDescription()); | 
|---|
|  |  |  | list.add(temp); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | orderSheet.setDataList(list); | 
|---|
|  |  |  | res.add(orderSheet); | 
|---|
|  |  |  | response = ResponseHeadUtil.setExcelHead(response); | 
|---|
|  |  |  | response.setHeader("Content-Disposition", | 
|---|
|  |  |  | "attachment;filename=" + URLEncoder.encode(title + DateUtil.format(new Date(), "yyyyMMDDHHmmss") + ".xlsx".trim(), "UTF-8")); | 
|---|
|  |  |  | OutputStream os = null; | 
|---|
|  |  |  | os = response.getOutputStream(); | 
|---|
|  |  |  | ExcelUtil.createWorkbookAtOutStream(ExcelVersion.V2007, res, os, false); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @SneakyThrows | 
|---|
|  |  |  | @GetMapping("/exportOrderList") | 
|---|
|  |  |  | public void exportOrderList(@RequestParam Map<String, String> params, HttpServletResponse response) { | 
|---|
|  |  |  | //获取查询参数 | 
|---|
|  |  |  | if(ObjectUtil.isEmpty(params.get("activityId"))){ | 
|---|
|  |  |  | throw new FebsException("请选择活动"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | String activityId = params.get("activityId"); | 
|---|
|  |  |  | HappyActivity happyActivity = adminHappyActivityService.getBaseMapper().selectById(activityId); | 
|---|
|  |  |  | if(ObjectUtil.isEmpty(happyActivity)){ | 
|---|
|  |  |  | throw new FebsException("活动不存在"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | List<ExcelSheetPO> res = new ArrayList<>(); | 
|---|
|  |  |  | ExcelSheetPO orderSheet = new ExcelSheetPO(); | 
|---|
|  |  |  | String title = happyActivity.getName() + "的订单"; | 
|---|
|  |  |  | orderSheet.setTitle(title); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | String[] header = {"序号","用户", "编号", "单价", "数量","总价","使用状态", "支付方式"}; | 
|---|
|  |  |  | orderSheet.setHeaders(header); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | List<HappyActivityOrder> orderListForExport = adminHappyActivityService.getOrderListForExport(params); | 
|---|
|  |  |  | List<List<Object>> list = new ArrayList<>(); | 
|---|
|  |  |  | if (orderListForExport.size() > 0) { | 
|---|
|  |  |  | int i = 0; | 
|---|
|  |  |  | for (HappyActivityOrder item : orderListForExport) { | 
|---|
|  |  |  | i++; | 
|---|
|  |  |  | List<Object> temp = new ArrayList<>(); | 
|---|
|  |  |  | temp.add(i); | 
|---|
|  |  |  | temp.add(item.getName()); | 
|---|
|  |  |  | temp.add(item.getOrderNo()); | 
|---|
|  |  |  | temp.add(item.getPrice()); | 
|---|
|  |  |  | temp.add(item.getNumCnt()); | 
|---|
|  |  |  | temp.add(item.getAmount()); | 
|---|
|  |  |  | temp.add(item.getState() == 2 ? "待使用" : "已使用"); | 
|---|
|  |  |  | temp.add(item.getPayType() == 0 ?"免费":"微信支付"); | 
|---|
|  |  |  | list.add(temp); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | orderSheet.setDataList(list); | 
|---|
|  |  |  | res.add(orderSheet); | 
|---|
|  |  |  | response = ResponseHeadUtil.setExcelHead(response); | 
|---|
|  |  |  | response.setHeader("Content-Disposition", | 
|---|
|  |  |  | "attachment;filename=" + URLEncoder.encode(title + DateUtil.format(new Date(), DatePattern.NORM_DATETIME_PATTERN) + ".xlsx".trim(), "UTF-8")); | 
|---|
|  |  |  | OutputStream os = null; | 
|---|
|  |  |  | os = response.getOutputStream(); | 
|---|
|  |  |  | ExcelUtil.createWorkbookAtOutStream(ExcelVersion.V2007, res, os, false); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 核销记录列表 | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @GetMapping("activityOrderCheckList") | 
|---|
|  |  |  | public FebsResponse activityOrderCheckList(AdminHappyActivityOrderCheckDto dto, QueryRequest request) { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Map<String, Object> data = getDataTable(adminHappyActivityService.activityOrderCheckList(dto, request)); | 
|---|
|  |  |  | return new FebsResponse().success().data(data); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 核销记录-手动核销 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @PostMapping("checkOrderItem") | 
|---|
|  |  |  | @ControllerEndpoint(operation = "核销记录-手动核销", exceptionMessage = "操作失败") | 
|---|
|  |  |  | public FebsResponse checkOrderItem(@RequestBody List<Long> dto) { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return adminHappyActivityService.checkOrderItem(dto); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @SneakyThrows | 
|---|
|  |  |  | @GetMapping("/exportOrderCheckList") | 
|---|
|  |  |  | public void exportOrderCheckList(@RequestParam Map<String, String> params, HttpServletResponse response) { | 
|---|
|  |  |  | //获取查询参数 | 
|---|
|  |  |  | if(ObjectUtil.isEmpty(params.get("activityId"))){ | 
|---|
|  |  |  | throw new FebsException("请选择活动"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | String activityId = params.get("activityId"); | 
|---|
|  |  |  | HappyActivity happyActivity = adminHappyActivityService.getBaseMapper().selectById(activityId); | 
|---|
|  |  |  | if(ObjectUtil.isEmpty(happyActivity)){ | 
|---|
|  |  |  | throw new FebsException("活动不存在"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | List<ExcelSheetPO> res = new ArrayList<>(); | 
|---|
|  |  |  | ExcelSheetPO orderSheet = new ExcelSheetPO(); | 
|---|
|  |  |  | String title = happyActivity.getName() + "的核销记录"; | 
|---|
|  |  |  | orderSheet.setTitle(title); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | String[] header = {"序号", "票号","参与人","电话", "地址","使用状态","核销时间","核销员", "姓名", "联系方式"}; | 
|---|
|  |  |  | orderSheet.setHeaders(header); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | List<AdminHappyActivityOrderCheckVo> orderListForExport = adminHappyActivityService.getOrderCheckListForExport(params); | 
|---|
|  |  |  | List<List<Object>> list = new ArrayList<>(); | 
|---|
|  |  |  | if (orderListForExport.size() > 0) { | 
|---|
|  |  |  | int i = 0; | 
|---|
|  |  |  | for (AdminHappyActivityOrderCheckVo item : orderListForExport) { | 
|---|
|  |  |  | i++; | 
|---|
|  |  |  | List<Object> temp = new ArrayList<>(); | 
|---|
|  |  |  | temp.add(i); | 
|---|
|  |  |  | temp.add(item.getCode()); | 
|---|
|  |  |  | temp.add(item.getName()); | 
|---|
|  |  |  | temp.add(item.getPhone()); | 
|---|
|  |  |  | temp.add(item.getAddress()); | 
|---|
|  |  |  | temp.add(item.getState() == 1 ? "已使用" : "待使用"); | 
|---|
|  |  |  | temp.add(item.getState() == 1 ? item.getUpdatedTime() : ""); | 
|---|
|  |  |  | temp.add(item.getCheckName()); | 
|---|
|  |  |  | temp.add(item.getCheckRealName()); | 
|---|
|  |  |  | temp.add(item.getCheckPhone()); | 
|---|
|  |  |  | list.add(temp); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | orderSheet.setDataList(list); | 
|---|
|  |  |  | res.add(orderSheet); | 
|---|
|  |  |  | response = ResponseHeadUtil.setExcelHead(response); | 
|---|
|  |  |  | response.setHeader("Content-Disposition", | 
|---|
|  |  |  | "attachment;filename=" + URLEncoder.encode(title + DateUtil.format(new Date(), DatePattern.NORM_DATETIME_PATTERN) + ".xlsx".trim(), "UTF-8")); | 
|---|
|  |  |  | OutputStream os = null; | 
|---|
|  |  |  | os = response.getOutputStream(); | 
|---|
|  |  |  | ExcelUtil.createWorkbookAtOutStream(ExcelVersion.V2007, res, os, false); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|