| | |
| | | import cc.mrbird.febs.common.entity.FebsResponse; |
| | | import cc.mrbird.febs.common.entity.QueryRequest; |
| | | import cc.mrbird.febs.common.utils.OssUtils; |
| | | import cc.mrbird.febs.dapp.dto.AddMallGoodsDto; |
| | | import cc.mrbird.febs.dapp.dto.HlmBasicPerkDto; |
| | | import cc.mrbird.febs.dapp.dto.MallGoodsUpdateDto; |
| | | import cc.mrbird.febs.dapp.dto.MallOrderInfoDto; |
| | | import cc.mrbird.febs.dapp.entity.MallGoods; |
| | | import cc.mrbird.febs.dapp.entity.MallOrderInfo; |
| | | import cc.mrbird.febs.dapp.enumerate.DataDictionaryEnum; |
| | | import cc.mrbird.febs.dapp.dto.*; |
| | | import cc.mrbird.febs.dapp.entity.*; |
| | | import cc.mrbird.febs.dapp.mapper.DappMemberDao; |
| | | import cc.mrbird.febs.dapp.mapper.MallAddressInfoMapper; |
| | | import cc.mrbird.febs.dapp.mapper.MallOrderInfoMapper; |
| | | import cc.mrbird.febs.dapp.service.IAdminMallGoodsService; |
| | | import cc.mrbird.febs.dapp.service.IMallNewsInfoService; |
| | | import cc.mrbird.febs.dapp.utils.ExcelSheetPO; |
| | | import cc.mrbird.febs.dapp.utils.ExcelUtil; |
| | | import cc.mrbird.febs.dapp.utils.ExcelVersion; |
| | | import cc.mrbird.febs.dapp.utils.ResponseHeadUtil; |
| | | import cc.mrbird.febs.dapp.vo.AdminMallGoodsCategoryTreeVo; |
| | | import cc.mrbird.febs.dapp.vo.MallOrderItemVo; |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.date.DateUtil; |
| | | import cn.hutool.core.util.IdUtil; |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | |
| | | import sun.misc.BASE64Encoder; |
| | | |
| | | import javax.imageio.ImageIO; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import javax.validation.Valid; |
| | | import javax.validation.constraints.NotNull; |
| | | import java.awt.image.BufferedImage; |
| | | import java.io.ByteArrayOutputStream; |
| | | import java.io.File; |
| | | import java.io.IOException; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.io.OutputStream; |
| | | import java.net.URLEncoder; |
| | | import java.util.*; |
| | | |
| | | @Slf4j |
| | | @Validated |
| | |
| | | public class AdminMallGoodsController extends BaseController { |
| | | |
| | | private final IAdminMallGoodsService adminMallGoodsService; |
| | | private final MallOrderInfoMapper mallOrderInfoMapper; |
| | | private final MallAddressInfoMapper mallAddressInfoMapper; |
| | | private final DappMemberDao dappMemberDao; |
| | | |
| | | |
| | | /** |
| | | * 商品分类-选择 |
| | | */ |
| | | @GetMapping("categorys/tree") |
| | | @ControllerEndpoint(exceptionMessage = "获取分类失败") |
| | | public List<AdminMallGoodsCategoryTreeVo> getParentCategorys(){ |
| | | return adminMallGoodsService.getParentCategorys(); |
| | | } |
| | | |
| | | /** |
| | | * 商品分类列表 |
| | | * @param mallGoodsCategory |
| | | * @param request |
| | | * @return |
| | | */ |
| | | @GetMapping("categoryList") |
| | | public FebsResponse getCategoryList(MallGoodsCategory mallGoodsCategory, QueryRequest request) { |
| | | Map<String, Object> data = getDataTable(adminMallGoodsService.getCategoryList(mallGoodsCategory, request)); |
| | | return new FebsResponse().success().data(data); |
| | | } |
| | | |
| | | /** |
| | | * 商品分类-新增 |
| | | */ |
| | | @PostMapping("addCategory") |
| | | @ControllerEndpoint(operation = " 商品分类-新增", exceptionMessage = "操作失败") |
| | | public FebsResponse addCategory(@Valid MallGoodsCategory mallGoodsCategory) { |
| | | return adminMallGoodsService.addCategory(mallGoodsCategory); |
| | | } |
| | | |
| | | /** |
| | | * 商品分类-编辑 |
| | | */ |
| | | @PostMapping("updateCategory") |
| | | @ControllerEndpoint(operation = " 商品分类-编辑", exceptionMessage = "操作失败") |
| | | public FebsResponse updateCategory(@Valid MallGoodsCategory mallGoodsCategory) { |
| | | return adminMallGoodsService.updateCategory(mallGoodsCategory); |
| | | } |
| | | |
| | | /** |
| | | * 商品分类-删除 |
| | | */ |
| | | @GetMapping("delCategary/{id}") |
| | | @ControllerEndpoint(operation = " 商品分类-删除", exceptionMessage = "操作失败") |
| | | public FebsResponse delCategary(@NotNull(message = "{required}") @PathVariable Long id) { |
| | | return adminMallGoodsService.delCategary(id); |
| | | } |
| | | |
| | | /** |
| | | * 图片上传 |
| | |
| | | // 图片大小(长宽)压缩比例 从0-1,1表示原图 |
| | | .scale(1f) |
| | | // 图片质量压缩比例 从0-1,越接近1质量越好 |
| | | .outputQuality(0.5f) |
| | | .outputQuality(1f) |
| | | .asBufferedImage(); |
| | | //对内存中的图片文件进行Base64处理 |
| | | ByteArrayOutputStream newBaos = new ByteArrayOutputStream();//io流 |
| | |
| | | return new FebsResponse().success().data(dataTable); |
| | | } |
| | | |
| | | /** |
| | | * 订单列表-发货 |
| | | */ |
| | | @PostMapping("deliverGoods") |
| | | @ControllerEndpoint(operation = "订单列表-发货", exceptionMessage = "操作失败") |
| | | public FebsResponse deliverGoods(@Valid DeliverGoodsDto deliverGoodsDto) { |
| | | return adminMallGoodsService.deliverGoods(deliverGoodsDto); |
| | | } |
| | | |
| | | /** |
| | | * 订单列表-删除订单 |
| | | * |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @GetMapping("delOrder/{id}") |
| | | @ControllerEndpoint(operation = "订单列表-删除订单", exceptionMessage = "操作失败") |
| | | public FebsResponse delOrder(@NotNull(message = "{required}") @PathVariable Long id) { |
| | | return adminMallGoodsService.delOrder(id); |
| | | } |
| | | |
| | | @GetMapping(value = "/findDicByType/{type}") |
| | | public FebsResponse findDicByType(@PathVariable("type") String type) { |
| | | return new FebsResponse().success().data(adminMallGoodsService.findDataDicByType(type)); |
| | |
| | | |
| | | |
| | | |
| | | /** |
| | | * 轮播图---列表 |
| | | */ |
| | | @GetMapping("platformBanner") |
| | | public FebsResponse platformBanner(PlatformBanner platformBannerEntity, QueryRequest request) { |
| | | Map<String, Object> data = getDataTable(adminMallGoodsService.findPlatformBannerInPage(platformBannerEntity, request)); |
| | | return new FebsResponse().success().data(data); |
| | | } |
| | | |
| | | /** |
| | | * 轮播图---确认 |
| | | * @return |
| | | */ |
| | | @PostMapping("platformBannerConfirm") |
| | | @ControllerEndpoint(operation = "轮播图---确认", exceptionMessage = "设置失败") |
| | | public FebsResponse platformBannerConfirm(@Valid PlatformBanner platformBannerEntity) { |
| | | return adminMallGoodsService.platformBannerConfirm(platformBannerEntity); |
| | | } |
| | | |
| | | /** |
| | | * 轮播图---删除 |
| | | * @return |
| | | */ |
| | | @GetMapping("platformBannerDelete/{id}") |
| | | @ControllerEndpoint(operation = "轮播图---删除", exceptionMessage = "删除失败") |
| | | public FebsResponse platformBannerDelete(@NotNull(message = "{required}") @PathVariable Long id) { |
| | | return adminMallGoodsService.platformBannerDelete(id); |
| | | } |
| | | |
| | | /** |
| | | * 轮播图---新增 |
| | | */ |
| | | @PostMapping("platformBannerAdds") |
| | | @ControllerEndpoint(operation = "轮播图---新增", exceptionMessage = "新增失败") |
| | | public FebsResponse platformBannerAdds(@Valid PlatformBanner platformBannerEntity) { |
| | | adminMallGoodsService.platformBannerAdd(platformBannerEntity); |
| | | return new FebsResponse().success(); |
| | | } |
| | | |
| | | private final IMallNewsInfoService mallNewsInfoService; |
| | | |
| | | /** |
| | | * 新闻中心-列表 |
| | | * @param mallNewsInfo |
| | | * @param request |
| | | * @return |
| | | */ |
| | | @GetMapping("getNewInfoList") |
| | | public FebsResponse getNewInfoList(MallNewsInfo mallNewsInfo, QueryRequest request) { |
| | | Map<String, Object> data = getDataTable(mallNewsInfoService.getNewInfoList(mallNewsInfo, request)); |
| | | return new FebsResponse().success().data(data); |
| | | } |
| | | |
| | | /** |
| | | * 新闻中心-新增 |
| | | */ |
| | | @PostMapping("addNewsInfo") |
| | | @ControllerEndpoint(operation = " 新闻中心-新增", exceptionMessage = "操作失败") |
| | | public FebsResponse addNewsInfo(@Valid MallNewsInfoDto mallNewsInfoDto) { |
| | | return mallNewsInfoService.addNewsInfo(mallNewsInfoDto); |
| | | } |
| | | |
| | | /** |
| | | * 新闻中心-删除 |
| | | */ |
| | | @GetMapping("delNewsInfo/{id}") |
| | | @ControllerEndpoint(operation = " 新闻中心-删除", exceptionMessage = "操作失败") |
| | | public FebsResponse delNewsInfo(@NotNull(message = "{required}") @PathVariable Long id) { |
| | | return mallNewsInfoService.delNewsInfo(id); |
| | | } |
| | | |
| | | /** |
| | | * 新闻中心-更新 |
| | | */ |
| | | @PostMapping("updateNewsInfo") |
| | | @ControllerEndpoint(operation = "新闻中心-更新", exceptionMessage = "操作失败") |
| | | public FebsResponse updateNewsInfo(@Valid MallNewsInfoDto mallNewsInfoDto) { |
| | | return mallNewsInfoService.updateNewsInfo(mallNewsInfoDto); |
| | | } |
| | | |
| | | |
| | | @GetMapping("findNewsCategoryList") |
| | | @ControllerEndpoint(operation = "新闻分类列表", exceptionMessage = "获取失败") |
| | | public FebsResponse findNewsCategoryList(MallNewsCategory mallNewsCategory, QueryRequest request) { |
| | | return new FebsResponse().success().data(getDataTable(mallNewsInfoService.findNewsCategoryInPage(mallNewsCategory, request))); |
| | | } |
| | | |
| | | @PostMapping("addOrModifyNewsCategory") |
| | | @ControllerEndpoint(operation = "新闻分类", exceptionMessage = "新增失败") |
| | | public FebsResponse addOrModifyNewsCategory(MallNewsCategory mallNewsCategory) { |
| | | mallNewsInfoService.addOrModifyNewsCategory(mallNewsCategory); |
| | | return new FebsResponse().success().message("新增成功"); |
| | | } |
| | | |
| | | /** |
| | | * 新闻分类-删除 |
| | | */ |
| | | @GetMapping("delNewsCategoryInfo/{id}") |
| | | @ControllerEndpoint(operation = "新闻分类-删除", exceptionMessage = "操作失败") |
| | | public FebsResponse delNewsCategoryInfo(@NotNull(message = "{required}") @PathVariable Long id) { |
| | | return mallNewsInfoService.delNewsCategoryInfo(id); |
| | | } |
| | | |
| | | @GetMapping(value = "findAllCategoryList") |
| | | public FebsResponse findAllCategoryList() { |
| | | List<MallNewsCategory> categories = mallNewsInfoService.findAllCategory(); |
| | | return new FebsResponse().success().data(categories); |
| | | } |
| | | |
| | | @PostMapping(value = "/topNews/{id}") |
| | | public FebsResponse topNews(@PathVariable Long id) { |
| | | MallNewsInfo mallNewsInfo = new MallNewsInfo(); |
| | | mallNewsInfo.setIsTop(1); |
| | | mallNewsInfo.setId(id); |
| | | mallNewsInfoService.updateById(mallNewsInfo); |
| | | return new FebsResponse().success(); |
| | | } |
| | | |
| | | @PostMapping(value = "/unTopNews/{id}") |
| | | public FebsResponse unTopNews(@PathVariable Long id) { |
| | | MallNewsInfo mallNewsInfo = new MallNewsInfo(); |
| | | mallNewsInfo.setIsTop(2); |
| | | mallNewsInfo.setId(id); |
| | | mallNewsInfoService.updateById(mallNewsInfo); |
| | | return new FebsResponse().success(); |
| | | } |
| | | |
| | | @GetMapping("exportOrderList") |
| | | @ControllerEndpoint(operation = "订单列表", exceptionMessage = "导出失败") |
| | | public FebsResponse exportOrderList(MallOrderInfo mallOrderInfo, HttpServletResponse response) throws IOException { |
| | | |
| | | List<ExcelSheetPO> res = new ArrayList<>(); |
| | | ExcelSheetPO orderSheet = new ExcelSheetPO(); |
| | | String title = "订单列表"; |
| | | orderSheet.setSheetName(title); |
| | | orderSheet.setTitle(title); |
| | | String[] header = {"订单编号", "收货姓名", "收货电话", "收货地址", "提货方式","订单状态","发货状态","下单时间", "商品详情", "金额", "物流单号", "物流公司", "物流公司码"}; |
| | | orderSheet.setHeaders(header); |
| | | |
| | | QueryRequest request = new QueryRequest(); |
| | | request.setPageNum(1); |
| | | request.setPageSize(9999); |
| | | List<MallOrderInfo> dataList = new ArrayList<>(); |
| | | String orderIds = mallOrderInfo.getOrderIds(); |
| | | List<String> ids = StrUtil.splitTrim(orderIds, ","); |
| | | for(String id : ids){ |
| | | long orderId = Long.parseLong(id); |
| | | MallOrderInfo mallOrderInfo1 = mallOrderInfoMapper.selectById(orderId); |
| | | if(ObjectUtil.isNotEmpty(mallOrderInfo1) |
| | | && MallOrderInfo.DELIVER_STATUS_WAIT == mallOrderInfo1.getDeliverState() |
| | | && 1 == mallOrderInfo1.getDeliverType()){ |
| | | dataList.add(mallOrderInfo1); |
| | | } |
| | | } |
| | | List<List<Object>> list = new ArrayList<>(); |
| | | if (dataList.size() > 0) { |
| | | for (MallOrderInfo item : dataList) { |
| | | List<Object> temp = new ArrayList<>(); |
| | | temp.add(item.getOrderNo()); |
| | | MallAddressInfo mallAddressInfo = mallAddressInfoMapper.selectById(item.getAddressId()); |
| | | // temp.add(item.getAmount()); |
| | | // temp.add(DateUtil.format(item.getOrderTime(), "yyyy-MM-dd HH:mm:ss")); |
| | | // temp.add("快递配送"); |
| | | temp.add(mallAddressInfo.getName()); |
| | | temp.add(mallAddressInfo.getPhone()); |
| | | temp.add(mallAddressInfo.getArea()+mallAddressInfo.getAddress()); |
| | | temp.add("快递寄送"); |
| | | temp.add("已支付"); |
| | | temp.add("待发货"); |
| | | temp.add(DateUtil.format(item.getPayTime(),"yyyy-MM-dd HH:mm:ss")); |
| | | |
| | | List<MallOrderItemVo> mallOrderItemVoList = dappMemberDao.selectMallOrderItemVoByOrderId(item.getId()); |
| | | if (CollUtil.isNotEmpty(mallOrderItemVoList)) { |
| | | StringBuilder sb = new StringBuilder(); |
| | | for (MallOrderItemVo itemItem : mallOrderItemVoList) { |
| | | if (StrUtil.isNotBlank(sb)) { |
| | | sb.append(";" + itemItem.getGoodsName()+"-"+itemItem.getPrice() + "*" + itemItem.getCnt()); |
| | | } else { |
| | | sb.append(itemItem.getGoodsName()+"-"+itemItem.getPrice() + "*" + itemItem.getCnt()); |
| | | } |
| | | } |
| | | temp.add(sb.toString()); |
| | | } else { |
| | | temp.add(""); |
| | | } |
| | | temp.add(item.getAmount()); |
| | | 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 = response.getOutputStream(); |
| | | ExcelUtil.createWorkbookAtOutStream(ExcelVersion.V2007, res, os, true); |
| | | return null; |
| | | } |
| | | |
| | | @PostMapping(value = "/importDeliver") |
| | | @ControllerEndpoint(operation = "导入发货", exceptionMessage = "导入失败") |
| | | public FebsResponse importDeliver(@RequestBody MultipartFile file) throws IOException { |
| | | if (file.isEmpty()) { |
| | | return new FebsResponse().fail(); |
| | | } |
| | | |
| | | String fileName = file.getOriginalFilename(); |
| | | String dirPath = "/home/javaweb/webresource/"; |
| | | |
| | | File saveFile = new File(new File(dirPath).getAbsolutePath() + File.separator + fileName); |
| | | if (!saveFile.exists()) { |
| | | if (!saveFile.getParentFile().exists()) { |
| | | saveFile.getParentFile().mkdirs(); |
| | | } |
| | | } |
| | | |
| | | file.transferTo(saveFile); |
| | | |
| | | List<ExcelSheetPO> data = ExcelUtil.readExcel(saveFile, null, null); |
| | | if (CollUtil.isEmpty(data)) { |
| | | return new FebsResponse().fail(); |
| | | } |
| | | |
| | | List<List<Object>> dataList = data.get(0).getDataList(); |
| | | |
| | | int expressNoIndex = -1; |
| | | int expressComIndex = -1; |
| | | int expressCodeIndex = -1; |
| | | for (int i = 1; i < dataList.size(); i++) { |
| | | List<Object> objects = dataList.get(i); |
| | | |
| | | String expressNo = ""; |
| | | String expressCom = ""; |
| | | for (int j = 0; j < objects.size(); j++) { |
| | | Object obj = objects.get(j); |
| | | if ("物流单号".equals(obj)) { |
| | | expressNoIndex = j; |
| | | } |
| | | |
| | | if ("物流公司".equals(obj)) { |
| | | expressComIndex = j; |
| | | } |
| | | |
| | | if ("物流公司码".equals(obj)) { |
| | | expressCodeIndex = j; |
| | | } |
| | | |
| | | if (j == expressNoIndex) { |
| | | expressNo = (String) objects.get(j); |
| | | } |
| | | |
| | | if (j == expressComIndex) { |
| | | expressCom = (String) objects.get(j); |
| | | } |
| | | |
| | | } |
| | | |
| | | if (StrUtil.isNotBlank(expressNo) && StrUtil.isNotBlank(expressCom)) { |
| | | String orderNo = (String) objects.get(0); |
| | | |
| | | DeliverGoodsDto deliverGoods = new DeliverGoodsDto(); |
| | | deliverGoods.setOrderNo(orderNo); |
| | | deliverGoods.setExpressCom(expressCom); |
| | | deliverGoods.setExpressNo(expressNo); |
| | | adminMallGoodsService.deliverGoodsByOrderNo(deliverGoods); |
| | | } |
| | | |
| | | |
| | | } |
| | | return new FebsResponse().success(); |
| | | } |
| | | |
| | | |
| | | |
| | | } |