| | |
| | | package cc.mrbird.febs.pay.controller; |
| | | |
| | | import cc.mrbird.febs.common.entity.FebsResponse; |
| | | import cc.mrbird.febs.common.enumerates.OrderDeliveryStateEnum; |
| | | import cc.mrbird.febs.common.enumerates.OrderStatusEnum; |
| | | import cc.mrbird.febs.common.properties.XcxProperties; |
| | | import cc.mrbird.febs.common.utils.RedisUtils; |
| | | import cc.mrbird.febs.common.utils.SpringContextHolder; |
| | | import cc.mrbird.febs.mall.entity.MallOrderInfo; |
| | | import cc.mrbird.febs.mall.mapper.MallOrderInfoMapper; |
| | | import cc.mrbird.febs.pay.model.NotifyData; |
| | | import cc.mrbird.febs.pay.model.OrderStateDto; |
| | | import cc.mrbird.febs.pay.model.OrderStateMsgVo; |
| | | import cc.mrbird.febs.pay.model.WxTemplateData; |
| | | import cc.mrbird.febs.pay.service.IPayService; |
| | | import cc.mrbird.febs.pay.service.IXcxPayService; |
| | | import cc.mrbird.febs.pay.util.PayThreadPool; |
| | | import cc.mrbird.febs.pay.util.Signature; |
| | | import cc.mrbird.febs.pay.util.Util; |
| | | import cc.mrbird.febs.pay.util.WechatConfigure; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.http.ResponseEntity; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import org.springframework.web.client.RestTemplate; |
| | | import org.thymeleaf.engine.TemplateData; |
| | | |
| | | import javax.servlet.ServletOutputStream; |
| | | import javax.servlet.http.HttpServletRequest; |
| | |
| | | import java.io.IOException; |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | | @Slf4j |
| | | @RestController |
| | |
| | | |
| | | @Autowired |
| | | MallOrderInfoMapper mallOrderInfoMapper; |
| | | @Autowired |
| | | RedisUtils redisUtils; |
| | | |
| | | @Autowired |
| | | private IXcxPayService iXcxPayService; |
| | | |
| | | private final XcxProperties xcxProperties = SpringContextHolder.getBean(XcxProperties.class); |
| | | /** |
| | | * 微信支付回调接口 |
| | | */ |
| | |
| | | BeanUtils.copyProperties(bb,data); |
| | | log.info("----return_code = {}", data.getReturn_code()); |
| | | |
| | | |
| | | // 返回状态码 SUCCESS/FAIL |
| | | if (WechatConfigure.CODE_SUCCESS.equals(data.getReturn_code())) { |
| | | |
| | |
| | | MallOrderInfo order = mallOrderInfoMapper.selectById(Long.valueOf(orderId)); |
| | | |
| | | // 校验签名 |
| | | String paySecret = WechatConfigure.WECHARPAY_SECRET; |
| | | // String paySecret = WechatConfigure.WECHARPAY_SECRET; |
| | | String paySecret = xcxProperties.getWecharpaySecret(); |
| | | if (Signature.checkIsSignValidFromResponseString(notityXml.toString(),paySecret)) { |
| | | // 校验业务结果 |
| | | if (WechatConfigure.CODE_SUCCESS.equals(data.getResult_code())) { |
| | |
| | | if (order != null && OrderStatusEnum.WAIT_PAY.getValue() == order.getStatus()) { |
| | | log.debug("检查支付金额payMoney={},order.getPayMoney()={}", payMoney, order.getAmount()); |
| | | order.setStatus(OrderStatusEnum.WAIT_SHIPPING.getValue()); |
| | | order.setPayResult("1"); |
| | | order.setPayTime(new Date()); |
| | | order.setDeliveryState(OrderDeliveryStateEnum.DELIVERY_WAIT.getValue()); |
| | | mallOrderInfoMapper.updateById(order); |
| | | threadResult.success().message("支付成功"); |
| | | } else { |
| | |
| | | out.flush(); |
| | | out.close(); |
| | | } |
| | | |
| | | @ApiOperation(value = "获取微信订阅TemplateId") |
| | | @GetMapping(value = "/getTemplateId") |
| | | public FebsResponse getTemplateId() { |
| | | return new FebsResponse().success().data(iXcxPayService.getTemplateId()); |
| | | } |
| | | |
| | | } |