| | |
| | | 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 org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.math.BigDecimal; |
| | | import java.security.PrivateKey; |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | |
| | | @RequestMapping("/base") |
| | | public class WeiXinV3Controller { |
| | | |
| | | // @Resource |
| | | // @Resource |
| | | // private WechatPaymentService wechatPaymentService; |
| | | // @Autowired |
| | | // private WxAppPayService wxAppPayService; |
| | | @Autowired |
| | | private WxAppPayService wxAppPayService; |
| | | private PayMoneyUtil payMoneyUtil; |
| | | @ResponseBody |
| | | @PostMapping("/testWeiXinV3") |
| | | @ApiOperation(value = "获取添加人员、选择人员说明文案") |
| | |
| | | // 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); |
| | | ResultUtil resultUtil = payMoneyUtil.weixinpayV3("1720719391","购买玩湃惠民卡","15645654askjak13", |
| | | "/base/huimin/callBack/weixinPayHuiminCallback1","99"); |
| | | return resultUtil; |
| | | |
| | | // 将 payParams 返回给你的APP前端,前端使用这些参数调起微信支付SDK |
| | | // return ResponseEntity.ok(payParams); // 示例 |
| | |
| | | } |
| | | return ResultUtil.success(); |
| | | } |
| | | |
| | | } |
| | | // @PostMapping("/test-private-key") |
| | | // public String testPrivateKey() { |
| | | // try { |
| | | // PrivateKey privateKey = WXPaySignatureCertificateUtil.getPrivateKey(); |
| | | // return "私钥加载成功: " + privateKey.getAlgorithm(); |
| | | // } catch (Exception e) { |
| | | // return "私钥加载失败: " + e.getMessage(); |
| | | // } |
| | | // } |
| | | } |