| | |
| | | package com.panzhihua.applets.api; |
| | | |
| | | import java.io.File; |
| | | import java.io.IOException; |
| | | import java.io.InputStream; |
| | | import java.util.Arrays; |
| | | import java.util.Base64; |
| | | import java.util.List; |
| | | import java.util.UUID; |
| | | import java.util.concurrent.TimeUnit; |
| | | import java.util.concurrent.atomic.AtomicBoolean; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | |
| | | import cn.binarywang.wx.miniapp.api.WxMaSecCheckService; |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.panzhihua.applets.config.MinioUtil; |
| | | import com.panzhihua.applets.config.WxMaConfiguration; |
| | | import com.panzhihua.applets.umf.UmfPayUtil; |
| | | import com.panzhihua.applets.unionpay.*; |
| | | import com.panzhihua.common.constants.Constants; |
| | | import com.panzhihua.common.constants.FtpConstants; |
| | | import com.panzhihua.common.constants.UserConstants; |
| | | import com.panzhihua.common.controller.BaseController; |
| | | import com.panzhihua.common.model.dtos.bracelet.BraceletEarlyWarningDO; |
| | | import com.panzhihua.common.model.vos.R; |
| | | import com.panzhihua.common.model.vos.community.Base64File; |
| | | import com.panzhihua.common.model.vos.community.WeatherVO; |
| | | import com.panzhihua.common.model.vos.user.UserPhoneVO; |
| | | import com.panzhihua.common.service.bracelet.CommunityBraceletService; |
| | | import com.panzhihua.common.service.community.CommunityService; |
| | | import com.panzhihua.common.utlis.*; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import net.coobird.thumbnailator.Thumbnails; |
| | | import org.apache.commons.io.FilenameUtils; |
| | | import org.apache.commons.lang3.RandomUtils; |
| | |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.panzhihua.applets.config.WxMaConfiguration; |
| | | import com.panzhihua.common.constants.Constants; |
| | | import com.panzhihua.common.constants.FtpConstants; |
| | | import com.panzhihua.common.constants.UserConstants; |
| | | import com.panzhihua.common.model.vos.R; |
| | | import com.panzhihua.common.model.vos.community.WeatherVO; |
| | | import com.panzhihua.common.model.vos.user.UserPhoneVO; |
| | | import com.panzhihua.common.service.community.CommunityService; |
| | | import com.panzhihua.common.utlis.HttpUtils; |
| | | import com.panzhihua.common.utlis.SFTPUtil; |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.io.File; |
| | | import java.io.IOException; |
| | | import java.io.InputStream; |
| | | import java.time.LocalDateTime; |
| | | import java.util.*; |
| | | import java.util.concurrent.TimeUnit; |
| | | import java.util.concurrent.atomic.AtomicBoolean; |
| | | |
| | | import cn.binarywang.wx.miniapp.api.WxMaSecCheckService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import static com.panzhihua.common.utlis.FileTypeUploadUtils.assertAllowed; |
| | | import static com.panzhihua.common.utlis.PayUtil.makeUUID; |
| | | |
| | | /** |
| | | * @program: springcloud_k8s_panzhihuazhihuishequ |
| | |
| | | private int port; |
| | | @Value("${ftp.url}") |
| | | private String url; |
| | | @Value("${minio.url}") |
| | | private String minUrl; |
| | | @Resource |
| | | private WxMaConfiguration wxMaConfiguration; |
| | | @Resource |
| | | private CommunityService communityService; |
| | | |
| | | @Resource |
| | | private CommunityBraceletService communityBraceletService; |
| | | @Resource |
| | | private MinioUtil minioUtil; |
| | | @Resource |
| | | private UmfPayUtil umfPayUtil; |
| | | |
| | | public static void main(String[] args) { |
| | | // int nextInt = RandomUtils.nextInt(99999, 1000000); |
| | |
| | | @PostMapping(value = "/uploadimages", consumes = "multipart/*", headers = "content-type=multipart/form-date") |
| | | public R uploadImages(@RequestParam MultipartFile file, HttpServletRequest request) { |
| | | try { |
| | | assertAllowed(file, MimeTypeUtils.DEFAULT_ALLOWED_EXTENSION); |
| | | String extension = FilenameUtils.getExtension(file.getOriginalFilename()); |
| | | String name = UUID.randomUUID().toString().replaceAll("-", "") + "." + extension; |
| | | String imageUrl = minioUtil.upload(file, name); |
| | | return R.ok(imageUrl); |
| | | } catch (Exception e) { |
| | | log.error("上传照片失败【{}】", e.getMessage()); |
| | | return R.fail(); |
| | | } |
| | | } |
| | | |
| | | @ApiOperation(value = "文件流上传接口") |
| | | @PostMapping(value = "/uploadImagesInputStream") |
| | | public R uploadImagesInputStream(@RequestBody Base64File file, HttpServletRequest request) { |
| | | if(StringUtils.isEmpty(file.getFile())){ |
| | | return R.fail("文件不能为Null"); |
| | | } |
| | | try { |
| | | String name = UUID.randomUUID().toString().replaceAll("-", "") + ".jpg"; |
| | | InputStream is = minioUtil.base64StrToInputStream(file.getFile().replace("data:image/png;base64,","").replace("data:image/jpg;base64,","").replace("data:image/jpeg;base64,","")); |
| | | String imageUrl = minioUtil.uploadInputStream(is, name); |
| | | return R.ok(imageUrl); |
| | | } catch (Exception e) { |
| | | log.error("上传照片失败【{}】", e.getMessage()); |
| | |
| | | @PostMapping(value = "/uploadimagescompress", consumes = "multipart/*", headers = "content-type=multipart/form-date") |
| | | public R uploadImagesComPress(@RequestParam MultipartFile file, HttpServletRequest request) { |
| | | try { |
| | | assertAllowed(file, MimeTypeUtils.DEFAULT_ALLOWED_EXTENSION); |
| | | String extension = FilenameUtils.getExtension(file.getOriginalFilename()); |
| | | String uuid=UUID.randomUUID().toString().replaceAll("-", ""); |
| | | String name = uuid + "."+ extension; |
| | | String imageUrl = minioUtil.upload(file, name); |
| | | Thumbnails.of(file.getInputStream()).scale(1).outputQuality(0.01).outputFormat("jpg").toFile(FtpConstants.FTPFILEPATH_IDCARD+uuid+"-compress"); |
| | | return R.ok(url + "/idcard/" + uuid+"-compress.jpg"); |
| | | String fileName = minioUtil.uploadRetFileName(file, name); |
| | | Thumbnails.of(file.getInputStream()).scale(0.5).outputQuality(0.71).outputFormat("jpg").toFile(uuid+"_compress"); |
| | | File file1=new File(uuid+"_compress.jpg"); |
| | | String imageUrl = minioUtil.uploadFile(file1, uuid+"_compress.jpg"); |
| | | //上传完压缩图后把原图清理,防止文件服务器资源爆满 |
| | | minioUtil.removeMinio(fileName); |
| | | return R.ok(imageUrl); |
| | | } catch (Exception e) { |
| | | log.error("上传照片失败【{}】", e.getMessage()); |
| | | return R.fail(); |
| | |
| | | String result = HttpUtils.sendGet(url, param); |
| | | return R.ok(JSON.parseObject(result)); |
| | | } |
| | | |
| | | @ApiOperation(value = "获取安全知识培训跳转url") |
| | | @GetMapping(value = "getSafety") |
| | | public R getSafety() |
| | | { |
| | | return R.ok("https://pzh.axhpx.com/Wechat/"); |
| | | } |
| | | |
| | | |
| | | @ApiOperation("uu洗车下单接口") |
| | | @GetMapping("/uuPay") |
| | | public R uuPay(@RequestParam("orderid") String orderid,@RequestParam("openid")String openid,@RequestParam("amount")String amount){ |
| | | Map map=umfPayUtil.pay(orderid, DateUtils.getCurrentDateString(),openid,amount); |
| | | return R.ok(map); |
| | | } |
| | | |
| | | @ApiOperation("无水洗车下单接口") |
| | | @GetMapping("/wsPay") |
| | | public R wsPay(@RequestParam("orderid") String orderid,@RequestParam("openid")String openid,@RequestParam("amount")String amount){ |
| | | Map map=umfPayUtil.pay2(orderid, DateUtils.getCurrentDateString(),openid,amount); |
| | | return R.ok(map); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | @ApiOperation("uu洗车银联下单接口") |
| | | @GetMapping("/uuUnionpayPay") |
| | | public R uuUnionpayPay(@RequestParam("amount")String amount, |
| | | @RequestParam("productId")String productId, |
| | | @RequestParam("openId")String openId){ |
| | | |
| | | LocalDateTime time=DateUtils.getCurrentDate(); |
| | | String merOrderId= UnionpayContent.TOP4+time.format(DateUtils.format_ymdhms_yyyyMMddmmHHssSSS)+makeUUID(7); |
| | | String map= UnifiedOrder.sendOrder(amount,"uu洗车下单",productId,openId,time,merOrderId); |
| | | communityService.add(productId,merOrderId,amount); |
| | | return R.ok(map); |
| | | } |
| | | |
| | | @ApiOperation("无水洗车银联下单接口") |
| | | @GetMapping("/wsUnionpayPay") |
| | | public R wsUnionpayPay(@RequestParam("amount")String amount, |
| | | @RequestParam("productId")String productId, |
| | | @RequestParam("openId")String openId){ |
| | | LocalDateTime time=DateUtils.getCurrentDate(); |
| | | String merOrderId= UnionpayContent.TOP4+time.format(DateUtils.format_ymdhms_yyyyMMddmmHHssSSS)+makeUUID(7); |
| | | String map= UnifiedOrder.sendOrder(amount,"无水洗车下单",productId,openId,time,merOrderId); |
| | | communityService.add(productId,merOrderId,amount); |
| | | return R.ok(map); |
| | | } |
| | | |
| | | @ApiOperation("uu洗车银联退款接口") |
| | | @GetMapping("/uuUnionpayRefund") |
| | | public R uuUnionpayRefundPay(@RequestParam("refundAmount")String refundAmount, |
| | | @RequestParam("refundOrderId")String refundOrderId){ |
| | | String map= Refund.sendOrder(refundAmount,refundOrderId); |
| | | return R.ok(map); |
| | | } |
| | | |
| | | @ApiOperation("无水洗车银联退款接口") |
| | | @GetMapping("/wsUnionpayRefund") |
| | | public R wsUnionpayRefundPay(@RequestParam("refundAmount")String refundAmount, |
| | | @RequestParam("refundOrderId")String refundOrderId){ |
| | | String map= Refund.sendOrder(refundAmount,refundOrderId); |
| | | return R.ok(map); |
| | | } |
| | | |
| | | |
| | | @ApiOperation("银联支付查询接口") |
| | | @GetMapping("/unionpayQuery") |
| | | public R unionpayRefundPay(@RequestParam("merOrderId")String merOrderId){ |
| | | String map= Query.query(merOrderId); |
| | | return R.ok(map); |
| | | } |
| | | |
| | | @ApiOperation("银联退款查询接口") |
| | | @GetMapping("/unionpayRefundQuery") |
| | | public R unionpayRefundQuery(@RequestParam("merOrderId")String merOrderId){ |
| | | String map= RefundQuery.refundQuery(merOrderId); |
| | | return R.ok(map); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取预警数据 |
| | | * @param communityId |
| | | * @return |
| | | */ |
| | | @ApiOperation("微信手环人员处理工单列表") |
| | | @GetMapping("bracelet/getEarlyWarningList") |
| | | public R getList(@RequestParam("pageNum") Integer pageNum, |
| | | @RequestParam("pageSize") Integer pageSize, |
| | | @RequestParam("communityId") String communityId, |
| | | @RequestParam("disposeUserId") String disposeUserId, |
| | | @RequestParam("type") String type) |
| | | { |
| | | return communityBraceletService.getList(pageNum,pageSize,communityId,"",disposeUserId,type,"",""); |
| | | } |
| | | |
| | | /** |
| | | * 微信处理接口 |
| | | * @param braceletEarlyWarningDO |
| | | * @return |
| | | */ |
| | | @PostMapping("bracelet/WXdispose") |
| | | public R WXdispose(@RequestBody BraceletEarlyWarningDO braceletEarlyWarningDO) |
| | | { |
| | | if(StringUtils.isEmpty(braceletEarlyWarningDO.getDisposeText())) |
| | | { |
| | | return R.fail("处理内容不能为空"); |
| | | } |
| | | braceletEarlyWarningDO.setDisposeType("2"); |
| | | return communityBraceletService.WXdispose(braceletEarlyWarningDO); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | } |