| | |
| | | if (storeVO == null) { |
| | | return R.fail(); |
| | | } |
| | | R<SysUserVO> sysUserVO = userService.getSysUserVOByAccount(storeVO.getStoreAccount()); |
| | | JSONObject jsonObject = JSON.parseObject(JSON.toJSONString(sysUserVO.getData())); |
| | | SysUserVO entityVo = jsonObject.toJavaObject(SysUserVO.class); |
| | | storeVO.setSysUserId(entityVo.getUserId()); |
| | | storeVO.setLoginUserId(loginUserId); |
| | | R r1 = communityService.saveStore(storeVO); |
| | | R<SysUserVO> sysUserVO = userService.getSysUserVOByPhone(storeVO.getPhone()); |
| | | JSONObject jsonObject = null; |
| | | if (sysUserVO.getData() != null) { |
| | | return R.fail("账号已存在!"); |
| | | } |
| | | AdministratorsUserVO administratorsUserVO = new AdministratorsUserVO(); |
| | | administratorsUserVO.setAccount(storeVO.getStoreAccount()); |
| | | administratorsUserVO.setPassword(storeVO.getStorePassword()); |
| | | administratorsUserVO.setType(5); |
| | | administratorsUserVO.setAreaId(null); |
| | | administratorsUserVO.setStatus(1); |
| | | administratorsUserVO.setPhone(storeVO.getPhone()); |
| | | administratorsUserVO.setRoleId(888888888l); |
| | | administratorsUserVO.setShopStoreName(storeVO.getName()); |
| | | administratorsUserVO.setShopStorePhone(storeVO.getPhone()); |
| | | R r = userService.addUserBackstage(administratorsUserVO); |
| | | //保存sys_user |
| | | if (R.isOk(r1)) { |
| | | AdministratorsUserVO administratorsUserVO = new AdministratorsUserVO(); |
| | | administratorsUserVO.setAccount(storeVO.getStoreAccount()); |
| | | administratorsUserVO.setPassword(storeVO.getStorePassword()); |
| | | administratorsUserVO.setType(5); |
| | | administratorsUserVO.setAreaId(null); |
| | | administratorsUserVO.setStatus(1); |
| | | administratorsUserVO.setPhone(storeVO.getPhone()); |
| | | administratorsUserVO.setRoleId(888888888l); |
| | | administratorsUserVO.setShopStoreName(storeVO.getName()); |
| | | administratorsUserVO.setShopStorePhone(storeVO.getPhone()); |
| | | R r = userService.addUserBackstage(administratorsUserVO); |
| | | if (R.isOk(r)) { |
| | | sysUserVO = userService.getSysUserVOByPhone(storeVO.getPhone()); |
| | | jsonObject = JSON.parseObject(JSON.toJSONString(sysUserVO.getData())); |
| | | SysUserVO entityVo = jsonObject.toJavaObject(SysUserVO.class); |
| | | storeVO.setSysUserId(entityVo.getUserId()); |
| | | storeVO.setLoginUserId(loginUserId); |
| | | communityService.saveStore(storeVO); |
| | | } |
| | | return R.ok(); |
| | | } |
| | |
| | | @PostMapping("/store/edit/{id}") |
| | | @ApiImplicitParam(name = "id", value = "商家id") |
| | | public R editStore(@Valid @RequestBody ShopStoreVO storeVO, @PathVariable("id") Long id) { |
| | | R<LoginUserInfoVO> sysUserVO = userService.getSysUserVOByAccount(storeVO.getStoreAccount()); |
| | | R<LoginUserInfoVO> sysUserVO = userService.getSysUserVOByPhone(storeVO.getPhone()); |
| | | if (sysUserVO.getData() == null) { |
| | | return R.fail("没有相关的用户!"); |
| | | } |
| | | LoginUserInfoVO user = JSON.parseObject(JSON.toJSONString(sysUserVO.getData())).toJavaObject(LoginUserInfoVO.class); |
| | | storeVO.setSysUserId(user.getUserId()); |
| | | |
| | | R<ShopStoreVO> storeInfoVO = communityService.getStoreInfo(id); |
| | | if( storeInfoVO.getCode()==500){ |
| | | if (storeInfoVO.getCode() == 500) { |
| | | return R.fail(storeInfoVO.getMsg()); |
| | | } |
| | | //维护sys_user |
| | |
| | | |
| | | @ApiOperation(value = "新增商品") |
| | | @PostMapping("/goods/save") |
| | | R saveShopGoods(@RequestBody AddShopGoodsVO addShopGoodsVO){ |
| | | R saveShopGoods(@RequestBody AddShopGoodsVO addShopGoodsVO) { |
| | | return communityService.saveShopGoods(addShopGoodsVO); |
| | | } |
| | | |
| | | |
| | | @ApiOperation(value = "编辑商品") |
| | | @PostMapping("/goods/edit/{id}") |
| | | R editShopGoods(@PathVariable("id") Long id,@RequestBody AddShopGoodsVO addShopGoodsVO) { |
| | | return communityService.editShopGoods(id,addShopGoodsVO); |
| | | R editShopGoods(@PathVariable("id") Long id, @RequestBody AddShopGoodsVO addShopGoodsVO) { |
| | | return communityService.editShopGoods(id, addShopGoodsVO); |
| | | } |
| | | |
| | | @ApiOperation(value = "删除商品") |
| | |
| | | } |
| | | |
| | | @ApiOperation(value = "商品上下架") |
| | | @ApiImplicitParams({@ApiImplicitParam(name = "id",value = "商品Id"), |
| | | @ApiImplicitParam(name = "status",value = "1.上架 2.下架 ")}) |
| | | @ApiImplicitParams({@ApiImplicitParam(name = "id", value = "商品Id"), |
| | | @ApiImplicitParam(name = "status", value = "1.上架 2.下架 ")}) |
| | | @GetMapping("/goods/changeStatus") |
| | | R changeStatus(@RequestParam("id") Long id,@RequestParam("status")Integer status) { |
| | | return communityService.changeStatus(id,status); |
| | | R changeStatus(@RequestParam("id") Long id, @RequestParam("status") Integer status) { |
| | | return communityService.changeStatus(id, status); |
| | | } |
| | | |
| | | @ApiOperation(value = "订单_分页列表",response = ComShopOrderSearchVO.class) |
| | | @ApiOperation(value = "订单_分页列表", response = ComShopOrderSearchVO.class) |
| | | @PostMapping("/order/page") |
| | | public R page(@RequestBody @Validated PageComShopOrderSearchDTO pageComShopOrderSearchDTO){ |
| | | public R page(@RequestBody @Validated PageComShopOrderSearchDTO pageComShopOrderSearchDTO) { |
| | | pageComShopOrderSearchDTO.setUserId(this.getUserId()); |
| | | ClazzUtils.setIfStringIsEmpty(pageComShopOrderSearchDTO); |
| | | return communityService.pageShopOrder(pageComShopOrderSearchDTO); |
| | | } |
| | | |
| | | |
| | | @ApiOperation(value = "订单_详细",response = ComShopOrderPageVO.class) |
| | | @ApiOperation(value = "订单_详细", response = ComShopOrderPageVO.class) |
| | | @GetMapping("/order/detail") |
| | | @ShopOperLog(operType = 11) |
| | | public R detail(@RequestParam("orderId") Long orderId){ |
| | | public R detail(@RequestParam("orderId") Long orderId) { |
| | | return communityService.orderDetail(orderId); |
| | | } |
| | | |
| | | @ApiOperation(value = "订单_导出表格") |
| | | @PostMapping("/order/export") |
| | | @ShopOperLog(operType = 12) |
| | | public R export(@RequestBody ComShopOrderExportDTO comShopOrderExportDTO){ |
| | | public R export(@RequestBody ComShopOrderExportDTO comShopOrderExportDTO) { |
| | | ClazzUtils.setIfStringIsEmpty(comShopOrderExportDTO); |
| | | String url=excelUrl; |
| | | String uuid= UUID.randomUUID().toString().replace("-",""); |
| | | String url = excelUrl; |
| | | String uuid = UUID.randomUUID().toString().replace("-", ""); |
| | | //String name=uuid+".xlsx"; |
| | | String ftpUrl="/mnt/data/web/excel/"; |
| | | String ftpUrl = "/mnt/data/web/excel/"; |
| | | |
| | | R<ShopStoreVO> storeR = communityService.getUserStoreInfo(getUserId()); |
| | | |
| | | if(!R.isOk(storeR)){ |
| | | if (!R.isOk(storeR)) { |
| | | return R.fail("用户不是商家"); |
| | | } |
| | | |
| | | ShopStoreVO shopStoreVO = JSONObject.parseObject(JSONObject.toJSONString(storeR.getData()),ShopStoreVO.class); |
| | | ShopStoreVO shopStoreVO = JSONObject.parseObject(JSONObject.toJSONString(storeR.getData()), ShopStoreVO.class); |
| | | Long userId = this.getUserId(); |
| | | comShopOrderExportDTO.setUserId(userId); |
| | | R r=communityService.shopOrderExportData(comShopOrderExportDTO); |
| | | 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){ |
| | | 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); |
| | | SFTPUtil sftp = new SFTPUtil(userName, password, host, port); |
| | | sftp.login(); |
| | | String name = shopStoreVO.getName() +"商城订单-" + new SimpleDateFormat("yyyyMMddhhmmss").format(new Date()) + ".xlsx"; |
| | | boolean existDir = sftp.isExistDir(ftpUrl+name); |
| | | String name = shopStoreVO.getName() + "商城订单-" + 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; |
| | | String fileName = property + File.separator + name; |
| | | // 这里 需要指定写用哪个class去写 |
| | | ExcelWriter excelWriter = null; |
| | | InputStream inputStream=null; |
| | | InputStream inputStream = null; |
| | | try { |
| | | excelWriter = EasyExcel.write(fileName, ExcelShopOrderDTO.class).registerWriteHandler(new LongestMatchColumnWidthStyleStrategy()).registerWriteHandler(new CustomSheetWriteHandler()).build(); |
| | | WriteSheet writeSheet = EasyExcel.writerSheet(shopStoreVO.getName()+"订单").build(); |
| | | WriteSheet writeSheet = EasyExcel.writerSheet(shopStoreVO.getName() + "订单").build(); |
| | | excelWriter.write(excelShopOrderDTO, writeSheet); |
| | | excelWriter.finish(); |
| | | File file=new File(fileName); |
| | | inputStream=new FileInputStream(file); |
| | | 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); |
| | | log.info("删除excel【{}】结果【{}】", absolutePath, delete); |
| | | } finally { |
| | | // 千万别忘记finish 会帮忙关闭流 |
| | | if (inputStream != null) { |
| | |
| | | } |
| | | } |
| | | } |
| | | return R.ok(url+ URLEncoder.encode(name,"UTF-8")); |
| | | return R.ok(url + URLEncoder.encode(name, "UTF-8")); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | log.error("文件传输失败【{}】", e.getMessage()); |
| | |
| | | |
| | | @ApiOperation(value = "资金_统计信息") |
| | | @GetMapping("/capital/stat") |
| | | public R stat(){ |
| | | public R stat() { |
| | | return communityService.getFundsStat(getUserId()); |
| | | } |
| | | |
| | | @ApiOperation(value = "资金_分页列表") |
| | | @PostMapping("/capital/page") |
| | | public R page(@RequestBody PageComShopFundsSearchDTO pageComShopFundsSearchDTO){ |
| | | 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") |
| | | @ApiOperation(value = "资金_详情", response = CapitalDetailVO.class) |
| | | @ApiImplicitParam(name = "orderId", value = "订单Id") |
| | | @GetMapping("/capital/capitalDetailByStore") |
| | | R capitalDetailByStore(@RequestParam("orderId") Long orderId){ |
| | | R capitalDetailByStore(@RequestParam("orderId") Long orderId) { |
| | | return communityService.capitalDetailByStore(orderId); |
| | | } |
| | | |
| | |
| | | @ApiOperation(value = "资金_导出表格") |
| | | @PostMapping("/capital/export") |
| | | @ShopOperLog(operType = 12) |
| | | public R export(@RequestBody ComShopFundsExportDTO comShopFundsExportDTO){ |
| | | public R export(@RequestBody ComShopFundsExportDTO comShopFundsExportDTO) { |
| | | ClazzUtils.setIfStringIsEmpty(comShopFundsExportDTO); |
| | | String url=excelUrl; |
| | | String uuid= UUID.randomUUID().toString().replace("-",""); |
| | | String url = excelUrl; |
| | | String uuid = UUID.randomUUID().toString().replace("-", ""); |
| | | //String name=uuid+".xlsx"; |
| | | String ftpUrl="/mnt/data/web/excel/"; |
| | | String ftpUrl = "/mnt/data/web/excel/"; |
| | | |
| | | R<ShopStoreVO> storeR = communityService.getUserStoreInfo(getUserId()); |
| | | |
| | | if(!R.isOk(storeR)){ |
| | | if (!R.isOk(storeR)) { |
| | | return R.fail("用户不是商家"); |
| | | } |
| | | |
| | | ShopStoreVO shopStoreVO = JSONObject.parseObject(JSONObject.toJSONString(storeR.getData()),ShopStoreVO.class); |
| | | ShopStoreVO shopStoreVO = JSONObject.parseObject(JSONObject.toJSONString(storeR.getData()), ShopStoreVO.class); |
| | | Long userId = this.getUserId(); |
| | | comShopFundsExportDTO.setUserId(userId); |
| | | R r=communityService.shopOrderFundsExportData(comShopFundsExportDTO); |
| | | 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){ |
| | | 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); |
| | | SFTPUtil sftp = new SFTPUtil(userName, password, host, port); |
| | | sftp.login(); |
| | | String name = shopStoreVO.getName() +"-商家资金流水-" + new SimpleDateFormat("yyyyMMddhhmmss").format(new Date()) + ".xlsx"; |
| | | boolean existDir = sftp.isExistDir(ftpUrl+name); |
| | | String name = shopStoreVO.getName() + "-商家资金流水-" + 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; |
| | | String fileName = property + File.separator + name; |
| | | // 这里 需要指定写用哪个class去写 |
| | | ExcelWriter excelWriter = null; |
| | | InputStream inputStream=null; |
| | | InputStream inputStream = null; |
| | | try { |
| | | excelWriter = EasyExcel.write(fileName, ExcelShopFundsDTO.class).registerWriteHandler(new LongestMatchColumnWidthStyleStrategy()).registerWriteHandler(new CustomSheetWriteHandler()).build(); |
| | | WriteSheet writeSheet = EasyExcel.writerSheet(shopStoreVO.getName()+"订单").build(); |
| | | WriteSheet writeSheet = EasyExcel.writerSheet(shopStoreVO.getName() + "订单").build(); |
| | | excelWriter.write(excelShopFundsDTO, writeSheet); |
| | | excelWriter.finish(); |
| | | File file=new File(fileName); |
| | | inputStream=new FileInputStream(file); |
| | | 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); |
| | | log.info("删除excel【{}】结果【{}】", absolutePath, delete); |
| | | } finally { |
| | | // 千万别忘记finish 会帮忙关闭流 |
| | | if (inputStream != null) { |
| | |
| | | } |
| | | } |
| | | } |
| | | return R.ok(url+ URLEncoder.encode(name,"UTF-8")); |
| | | return R.ok(url + URLEncoder.encode(name, "UTF-8")); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | log.error("文件传输失败【{}】", e.getMessage()); |