| | |
| | | package com.dsh.activity.controller; |
| | | |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.dsh.activity.entity.*; |
| | | import com.dsh.activity.feignclient.account.StudentClient; |
| | | import com.dsh.activity.feignclient.other.SiteClient; |
| | | import com.dsh.activity.feignclient.other.StoreClient; |
| | | import com.dsh.activity.feignclient.other.model.Site; |
| | | import com.dsh.activity.feignclient.other.model.Store; |
| | | import com.dsh.activity.model.response.*; |
| | | import com.dsh.activity.service.*; |
| | | import com.dsh.activity.util.*; |
| | | //import com.dsh.activity.util.wx.WechatPaymentService; |
| | | import com.dsh.activity.util.wx.WxAppPayService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.ResponseBody; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.math.BigDecimal; |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | import java.time.ZoneId; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | | * @date 2023/6/24 11:27 |
| | | */ |
| | | @RestController |
| | | @RequestMapping("/base") |
| | | public class WeiXinV3Controller { |
| | | |
| | | // @Resource |
| | | // private WechatPaymentService wechatPaymentService; |
| | | @Autowired |
| | | private WxAppPayService wxAppPayService; |
| | | @ResponseBody |
| | | @PostMapping("/testWeiXinV3") |
| | | @ApiOperation(value = "获取添加人员、选择人员说明文案") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") |
| | | }) |
| | | public ResultUtil getContentForStudent() throws Exception { |
| | | // Map<String, Object> stringObjectMap = wechatPaymentService.weChatDoUnifiedOrder(); |
| | | // ... 在你的下单方法中调用 ... |
| | | try { |
| | | String description = "商品描述"; |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS"); |
| | | String outTradeNo =sdf.format(new Date()) + UUIDUtil.getNumberRandom(5); |
| | | BigDecimal amount = new BigDecimal("0.01"); // 支付金额,例如1分钱 |
| | | Map<String, String> payParams = wxAppPayService.createOrder(description, outTradeNo, amount); |
| | | return ResultUtil.success(payParams); |
| | | |
| | | // 将 payParams 返回给你的APP前端,前端使用这些参数调起微信支付SDK |
| | | // return ResponseEntity.ok(payParams); // 示例 |
| | | |
| | | } catch (Exception e) { |
| | | // 处理异常 |
| | | // return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("下单失败"); |
| | | } |
| | | return ResultUtil.success(); |
| | | } |
| | | |
| | | } |
| | | //package com.dsh.activity.controller; |
| | | // |
| | | //import cn.hutool.core.collection.CollUtil; |
| | | //import com.alibaba.fastjson.JSONArray; |
| | | //import com.alibaba.fastjson.JSONObject; |
| | | //import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | //import com.dsh.activity.entity.*; |
| | | //import com.dsh.activity.feignclient.account.StudentClient; |
| | | //import com.dsh.activity.feignclient.other.SiteClient; |
| | | //import com.dsh.activity.feignclient.other.StoreClient; |
| | | //import com.dsh.activity.feignclient.other.model.Site; |
| | | //import com.dsh.activity.feignclient.other.model.Store; |
| | | //import com.dsh.activity.model.response.*; |
| | | //import com.dsh.activity.service.*; |
| | | //import com.dsh.activity.util.*; |
| | | ////import com.dsh.activity.util.wx.WechatPaymentService; |
| | | //import com.dsh.activity.util.wx.WxAppPayService; |
| | | //import io.swagger.annotations.Api; |
| | | //import io.swagger.annotations.ApiImplicitParam; |
| | | //import io.swagger.annotations.ApiImplicitParams; |
| | | //import io.swagger.annotations.ApiOperation; |
| | | //import org.springframework.beans.factory.annotation.Autowired; |
| | | //import org.springframework.web.bind.annotation.PostMapping; |
| | | //import org.springframework.web.bind.annotation.RequestMapping; |
| | | //import org.springframework.web.bind.annotation.ResponseBody; |
| | | //import org.springframework.web.bind.annotation.RestController; |
| | | // |
| | | //import javax.annotation.Resource; |
| | | //import java.math.BigDecimal; |
| | | //import java.text.SimpleDateFormat; |
| | | //import java.time.LocalDate; |
| | | //import java.time.LocalDateTime; |
| | | //import java.time.ZoneId; |
| | | //import java.util.*; |
| | | //import java.util.stream.Collectors; |
| | | // |
| | | ///** |
| | | // * @author zhibing.pu |
| | | // * @date 2023/6/24 11:27 |
| | | // */ |
| | | //@RestController |
| | | //@RequestMapping("/base") |
| | | //public class WeiXinV3Controller { |
| | | // |
| | | //// @Resource |
| | | //// private WechatPaymentService wechatPaymentService; |
| | | // @Autowired |
| | | // private WxAppPayService wxAppPayService; |
| | | // @ResponseBody |
| | | // @PostMapping("/testWeiXinV3") |
| | | // @ApiOperation(value = "获取添加人员、选择人员说明文案") |
| | | // @ApiImplicitParams({ |
| | | // @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") |
| | | // }) |
| | | // public ResultUtil getContentForStudent() throws Exception { |
| | | //// Map<String, Object> stringObjectMap = wechatPaymentService.weChatDoUnifiedOrder(); |
| | | // // ... 在你的下单方法中调用 ... |
| | | // try { |
| | | // String description = "商品描述"; |
| | | // SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS"); |
| | | // String outTradeNo =sdf.format(new Date()) + UUIDUtil.getNumberRandom(5); |
| | | // BigDecimal amount = new BigDecimal("0.01"); // 支付金额,例如1分钱 |
| | | // Map<String, String> payParams = wxAppPayService.createOrder(description, outTradeNo, amount); |
| | | // return ResultUtil.success(payParams); |
| | | // |
| | | // // 将 payParams 返回给你的APP前端,前端使用这些参数调起微信支付SDK |
| | | // // return ResponseEntity.ok(payParams); // 示例 |
| | | // |
| | | // } catch (Exception e) { |
| | | // // 处理异常 |
| | | // // return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("下单失败"); |
| | | // } |
| | | // return ResultUtil.success(); |
| | | // } |
| | | // |
| | | //} |