//package com.ruoyi.web.controller.app.pay;
//
//
//import com.jeequan.jeepay.JeepayClient;
//import com.jeequan.jeepay.response.PayOrderCreateResponse;
//import com.ruoyi.common.core.controller.BaseController;
//import com.ruoyi.common.core.domain.AjaxResult;
//import com.ruoyi.common.core.redis.RedisCache;
//import com.ruoyi.common.utils.SecurityUtils;
//import com.ruoyi.common.utils.StringUtils;
//import com.ruoyi.system.domain.SysSource;
//import com.ruoyi.system.domain.UserWork;
//import com.ruoyi.system.domain.dto.PublishUserWorkDto;
//import com.ruoyi.system.domain.dto.SourcePriceDto;
//import com.ruoyi.system.domain.vo.PayResponseVo;
//import com.ruoyi.system.service.ISysSourceService;
//import com.ruoyi.system.service.IUserWorkService;
//import com.ruoyi.web.controller.app.baidu.GsonUtils;
//import org.springframework.beans.factory.annotation.Autowired;
//import com.ruoyi.common.utils.uuid.UUID;
//import com.jeequan.jeepay.model.PayOrderCreateReqModel;
//import com.jeequan.jeepay.request.PayOrderCreateRequest;
//import com.alibaba.fastjson.JSONObject;
//import org.springframework.stereotype.Component;
//import org.springframework.stereotype.Service;
//import org.springframework.web.bind.annotation.*;
//
//import java.util.List;
//import java.util.concurrent.TimeUnit;
//import java.util.stream.Collectors;
//
//@Service
//public class PayService {
//    public static final String APPKEY = "";
//    public static String APPID = "";
//    public static String MCHNO = "";
//
//    @Autowired
//    private IUserWorkService userWorkService;
//
//    @Autowired
//    private ISysSourceService sysSourceService;
//
//    @Autowired
//    private RedisCache redisCache;
//
//
//
//    // 生成订单--------将订单数据保存在redis缓存中----缓存时间为10分钟吧
//    public  boolean genOrder(double price) {
//
//
//
//        try {
//
//            // 订单号, 自己生成,用来标识这一次支付.
//            String mchOrderNo = "M" + UUID.randomUUID().toString().replaceAll("-", "");
//
//            // 缓存订单和用户关系, 为了回调函数中写入订单数据库
//            System.out.println("mchOrderNo: " + mchOrderNo);
////            System.out.println(redisCache);
//
//
////            redisCache.setCacheObject(mchOrderNo, userId.toString() + "_" + result, 1, TimeUnit.DAYS);
////            System.out.println(redisCache.getCacheObject(mchOrderNo).toString());
////        log.info("缓存订单和用户关系: mchOrderNo=" + mchOrderNo + ", userId=" + userId);
//
//
////            //---------------------------------------------------测试环境 先注释掉--------------------------------------------------------
////            // 支付方式
////            String wayCode = "QR_CASHIER";
////
////            Byte divisionMode = 0;
////
////            // 前端明确了支付参数的类型 payDataType
////            String payDataType = "codeImgUrl";
////            String authCode = "payurl";
////
////            PayOrderCreateRequest request = new PayOrderCreateRequest();
////            PayOrderCreateReqModel model = new PayOrderCreateReqModel();
////            request.setBizModel(model);
////
////
////            model.setMchNo(MCHNO); // 商户号
////            model.setAppId(APPID);
////            model.setMchOrderNo(mchOrderNo);
////            model.setWayCode(wayCode);
////            model.setAmount(Price);
////            model.setReturnUrl("http://");
////            // paypal通道使用USD类型货币
////            model.setCurrency("CNY");
////            model.setClientIp("127.0.0.1");
////            model.setSubject("" + MCHNO + "");
////            model.setBody("正常订单" + "[" + MCHNO + "]");
////
////            // 支付回调地址
////            model.setNotifyUrl("http://62.234.19.34:8991/wxPay/result/wxRechargeCallback/"+result); //回调地址
////            model.setReturnUrl("");
////            model.setDivisionMode(divisionMode); //分账模式
////
////            //设置扩展参数
////            JSONObject extParams = new JSONObject();
////            if (StringUtils.isNotEmpty(payDataType)) {
////                extParams.put("payDataType", payDataType.trim());
////            }
////            if (StringUtils.isNotEmpty(authCode)) {
////                extParams.put("authCode", authCode.trim());
////            }
////            model.setChannelExtra(extParams.toString());
////
////            JeepayClient jeepayClient = new JeepayClient("http://payment.pay.oetsoft.com",
////                    APPKEY);
////
////            PayOrderCreateResponse payOrderCreateResponse = jeepayClient.execute(request);
////            System.out.println(payOrderCreateResponse.toString());
////            PayResponseVo payResponseVo = JSONObject.parseObject(payOrderCreateResponse.toString(), PayResponseVo.class);
////            String url = payResponseVo.getData().getPayData();
////
////            //-------------------------------------------------测试环境先注释掉-----------------------------------------------------------
//
////        //设置Access-Control-Expose-Headers避免前端调用获取Content-Disposition出现Refused to get unsafe header异常
////
////        response.addHeader("Access-Control-Expose-Headers", "Content-Disposition");
////        response.addHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode("img.jpg", "UTF-8"));
//
//
//            return true;
//        }catch (Exception e){
//            System.out.println(e);
//            return false;
//        }
//    }
//
////    @PostMapping("/WechatPay")
////    public AjaxResult WechatPay(@RequestBody List<PayDto> payDtoList){
////        return null;
////
////    }
//}
