| | |
| | | * @describe 商城管理 |
| | | */ |
| | | @Slf4j |
| | | @Api(tags = {"商城管理模块"}) |
| | | @Api(tags = {"花城商城管理模块"}) |
| | | @RestController("/shopFlower") |
| | | public class ShopFlowerApi extends BaseController { |
| | | @Value("${excel.userurl}") |
| | |
| | | public R detail(@RequestParam("orderId") Long orderId) { |
| | | return communityService.orderDetailFlower(orderId); |
| | | } |
| | | |
| | | /*@ApiOperation(value = "订单_导出表格") |
| | | @PostMapping("/order/export") |
| | | @ShopOperLog(operType = 12) |
| | | public R export(@RequestBody ComShopOrderExportDTO comShopOrderExportDTO) { |
| | | ClazzUtils.setIfStringIsEmpty(comShopOrderExportDTO); |
| | | String url = excelUrl; |
| | | String uuid = UUID.randomUUID().toString().replace("-", ""); |
| | | // String name=uuid+".xlsx"; |
| | | String ftpUrl = "/mnt/data/web/excel/"; |
| | | |
| | | R r = communityService.shopOrderExportData(comShopOrderExportDTO); |
| | | if (R.isOk(r)) { |
| | | List<ExcelShopOrderDTO> excelShopOrderDTO = |
| | | JSONArray.parseArray(JSONArray.toJSONString(r.getData()), ExcelShopOrderDTO.class); |
| | | if (excelShopOrderDTO == null || excelShopOrderDTO.size() == 0) { |
| | | return R.ok("未找到数据"); |
| | | } |
| | | try { |
| | | SFTPUtil sftp = new SFTPUtil(userName, password, host, port); |
| | | sftp.login(); |
| | | String name = "商城订单-" + new SimpleDateFormat("yyyyMMddhhmmss").format(new Date()) + ".xlsx"; |
| | | boolean existDir = sftp.isExistDir(ftpUrl + name); |
| | | if (!existDir) { |
| | | String property = System.getProperty("user.dir"); |
| | | String fileName = property + File.separator + name; |
| | | // 这里 需要指定写用哪个class去写 |
| | | ExcelWriter excelWriter = null; |
| | | InputStream inputStream = null; |
| | | try { |
| | | excelWriter = EasyExcel.write(fileName, ExcelShopOrderDTO.class) |
| | | .registerWriteHandler(new LongestMatchColumnWidthStyleStrategy()) |
| | | .registerWriteHandler(new CustomSheetWriteHandler()).build(); |
| | | WriteSheet writeSheet = EasyExcel.writerSheet("订单").build(); |
| | | excelWriter.write(excelShopOrderDTO, writeSheet); |
| | | excelWriter.finish(); |
| | | File file = new File(fileName); |
| | | inputStream = new FileInputStream(file); |
| | | sftp.uploadMore(ftpUrl, name, inputStream); |
| | | sftp.logout(); |
| | | inputStream.close(); |
| | | String absolutePath = file.getAbsolutePath(); |
| | | boolean delete = file.delete(); |
| | | log.info("删除excel【{}】结果【{}】", absolutePath, delete); |
| | | } finally { |
| | | // 千万别忘记finish 会帮忙关闭流 |
| | | if (inputStream != null) { |
| | | inputStream.close(); |
| | | } |
| | | if (excelWriter != null) { |
| | | excelWriter.finish(); |
| | | } |
| | | } |
| | | } |
| | | return R.ok(url + URLEncoder.encode(name, "UTF-8")); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | log.error("文件传输失败【{}】", e.getMessage()); |
| | | return R.fail(); |
| | | } |
| | | } |
| | | return R.fail("导出数据失败"); |
| | | } |
| | | |
| | | @ApiOperation(value = "资金_统计信息") |
| | | @GetMapping("/capital/stat") |
| | | public R stat() { |
| | | Long userId = 0L; |
| | | return communityService.getFundsStat(userId); |
| | | } |
| | | |
| | | @ApiOperation(value = "资金_分页列表") |
| | | @PostMapping("/capital/page") |
| | | public R page(@RequestBody PageComShopFundsSearchDTO pageComShopFundsSearchDTO) { |
| | | pageComShopFundsSearchDTO.setUserId(getUserId()); |
| | | ClazzUtils.setIfStringIsEmpty(pageComShopFundsSearchDTO); |
| | | return communityService.pageShopFunds(pageComShopFundsSearchDTO); |
| | | } |
| | | |
| | | @ApiOperation(value = "资金_详情", response = CapitalDetailVO.class) |
| | | @ApiImplicitParam(name = "orderId", value = "订单Id") |
| | | @GetMapping("/capital/capitalDetailByStore") |
| | | R capitalDetailByStore(@RequestParam("orderId") Long orderId) { |
| | | return communityService.capitalDetailByStore(orderId); |
| | | } |
| | | |
| | | @ApiOperation(value = "资金_导出表格") |
| | | @PostMapping("/capital/export") |
| | | @ShopOperLog(operType = 12) |
| | | public R export(@RequestBody ComShopFundsExportDTO comShopFundsExportDTO) { |
| | | ClazzUtils.setIfStringIsEmpty(comShopFundsExportDTO); |
| | | String url = excelUrl; |
| | | String uuid = UUID.randomUUID().toString().replace("-", ""); |
| | | // String name=uuid+".xlsx"; |
| | | String ftpUrl = "/mnt/data/web/excel/"; |
| | | |
| | | Long userId = this.getUserId(); |
| | | comShopFundsExportDTO.setUserId(userId); |
| | | R r = communityService.shopOrderFundsExportData(comShopFundsExportDTO); |
| | | if (R.isOk(r)) { |
| | | List<ExcelShopFundsDTO> excelShopFundsDTO = |
| | | JSONArray.parseArray(JSONArray.toJSONString(r.getData()), ExcelShopFundsDTO.class); |
| | | if (excelShopFundsDTO == null || excelShopFundsDTO.size() == 0) { |
| | | return R.ok("未找到数据"); |
| | | } |
| | | try { |
| | | SFTPUtil sftp = new SFTPUtil(userName, password, host, port); |
| | | sftp.login(); |
| | | String name = "商家资金流水-" + new SimpleDateFormat("yyyyMMddhhmmss").format(new Date()) + ".xlsx"; |
| | | boolean existDir = sftp.isExistDir(ftpUrl + name); |
| | | if (!existDir) { |
| | | String property = System.getProperty("user.dir"); |
| | | String fileName = property + File.separator + name; |
| | | // 这里 需要指定写用哪个class去写 |
| | | ExcelWriter excelWriter = null; |
| | | InputStream inputStream = null; |
| | | try { |
| | | excelWriter = EasyExcel.write(fileName, ExcelShopFundsDTO.class) |
| | | .registerWriteHandler(new LongestMatchColumnWidthStyleStrategy()) |
| | | .registerWriteHandler(new CustomSheetWriteHandler()).build(); |
| | | WriteSheet writeSheet = EasyExcel.writerSheet("订单").build(); |
| | | excelWriter.write(excelShopFundsDTO, writeSheet); |
| | | excelWriter.finish(); |
| | | File file = new File(fileName); |
| | | inputStream = new FileInputStream(file); |
| | | sftp.uploadMore(ftpUrl, name, inputStream); |
| | | sftp.logout(); |
| | | inputStream.close(); |
| | | String absolutePath = file.getAbsolutePath(); |
| | | boolean delete = file.delete(); |
| | | log.info("删除excel【{}】结果【{}】", absolutePath, delete); |
| | | } finally { |
| | | // 千万别忘记finish 会帮忙关闭流 |
| | | if (inputStream != null) { |
| | | inputStream.close(); |
| | | } |
| | | if (excelWriter != null) { |
| | | excelWriter.finish(); |
| | | } |
| | | } |
| | | } |
| | | return R.ok(url + URLEncoder.encode(name, "UTF-8")); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | log.error("文件传输失败【{}】", e.getMessage()); |
| | | return R.fail(); |
| | | } |
| | | } |
| | | return R.fail("导出数据失败"); |
| | | } |
| | | |
| | | @ApiOperation(value = "商家配置修改") |
| | | @PutMapping("/shop/conf") |
| | | public R editConf(@RequestBody ComShopSysConfDTO comShopSysConfDTO) { |
| | | return communityService.editShopSysConf(comShopSysConfDTO); |
| | | } |
| | | |
| | | @ApiOperation(value = "商家配置查询", response = ComShopHiddenConfVO.class) |
| | | @GetMapping("/shop/conf") |
| | | public R getConf() { |
| | | PageComShopSysConfDTO pageComShopSysConfDTO = new PageComShopSysConfDTO(); |
| | | R r = communityService.pageShopSysConf(pageComShopSysConfDTO); |
| | | if (R.isOk(r) && r.getData() != null) { |
| | | ComShopSysConfVO comShopSysConfVO = |
| | | JSONObject.parseObject(JSONObject.toJSONString(r.getData()), ComShopSysConfVO.class); |
| | | if (comShopSysConfVO != null) { |
| | | ComShopHiddenConfVO comShopHiddenConfVO = new ComShopHiddenConfVO(); |
| | | comShopHiddenConfVO.setId(comShopSysConfVO.getId()); |
| | | comShopHiddenConfVO.setHidden(comShopSysConfVO.getVal()); |
| | | return R.ok(comShopHiddenConfVO); |
| | | } |
| | | } |
| | | return r; |
| | | }*/ |
| | | |
| | | } |