| | |
| | | import com.dsh.communityWorldCup.service.IWorldCupPaymentParticipantService; |
| | | import com.dsh.communityWorldCup.service.IWorldCupService; |
| | | import com.dsh.communityWorldCup.service.IWorldCupStoreService; |
| | | import com.dsh.communityWorldCup.util.PayMoneyUtil; |
| | | import com.dsh.communityWorldCup.util.ResultUtil; |
| | | import com.dsh.communityWorldCup.util.TokenUtil; |
| | | import groovy.util.logging.Log4j; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.PrintWriter; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | |
| | | @RestController |
| | | @RequestMapping("") |
| | | public class WorldCupController { |
| | | |
| | | Logger log = LoggerFactory.getLogger(WorldCupController.class); |
| | | |
| | | @Autowired |
| | | private TokenUtil tokenUtil; |
| | |
| | | |
| | | @Resource |
| | | private StoreClient storeClient; |
| | | |
| | | @Autowired |
| | | private PayMoneyUtil payMoneyUtil; |
| | | |
| | | |
| | | |
| | |
| | | |
| | | |
| | | |
| | | public ResultUtil paymentWorldCup() |
| | | @ResponseBody |
| | | @PostMapping("/api/worldCup/checkPaymentMethod") |
| | | @ApiOperation(value = "世界杯报名前校验支付方式【2.0】", tags = {"APP-社区世界杯"}) |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") |
| | | }) |
| | | public ResultUtil<CheckPaymentMethodVo> checkPaymentMethod(CheckPaymentMethod checkPaymentMethod){ |
| | | try { |
| | | Integer uid = tokenUtil.getUserIdFormRedis(); |
| | | if(null == uid){ |
| | | return ResultUtil.success(); |
| | | } |
| | | checkPaymentMethod.setUid(uid); |
| | | CheckPaymentMethodVo checkPaymentMethodVo = worldCupService.checkPaymentMethod(checkPaymentMethod); |
| | | return ResultUtil.success(checkPaymentMethodVo); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return ResultUtil.runErr(); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/api/worldCup/paymentWorldCup") |
| | | @ApiOperation(value = "世界杯报名【2.0】", tags = {"APP-社区世界杯"}) |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") |
| | | }) |
| | | public ResultUtil paymentWorldCup(PaymentWorldCup paymentWorldCup){ |
| | | try { |
| | | Integer uid = tokenUtil.getUserIdFormRedis(); |
| | | if(null == uid){ |
| | | return ResultUtil.success(); |
| | | } |
| | | paymentWorldCup.setUid(uid); |
| | | return worldCupService.paymentWorldCup(paymentWorldCup); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return ResultUtil.runErr(); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 微信支付回调 |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/base/worldCup/wxPayWorldCupCallback") |
| | | public void wxPayWorldCupCallback(HttpServletRequest request, HttpServletResponse response){ |
| | | try { |
| | | Map<String, String> map = payMoneyUtil.weixinpayCallback(request); |
| | | if(null != map){ |
| | | String code = map.get("out_trade_no"); |
| | | String transaction_id = map.get("transaction_id"); |
| | | String result = map.get("result"); |
| | | ResultUtil resultUtil = worldCupService.paymentWorldCupCallback(code, transaction_id); |
| | | if(resultUtil.getCode() == 200){ |
| | | PrintWriter out = response.getWriter(); |
| | | out.println(result); |
| | | out.flush(); |
| | | out.close(); |
| | | }else{ |
| | | log.error("社区世界杯报名微信支付回业务处理异常:" + resultUtil.getMsg()); |
| | | } |
| | | }else{ |
| | | log.error("社区世界杯报名微信支付回调解析异常"); |
| | | } |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 支付宝支付回调 |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/base/worldCup/aliPayWorldCupCallback") |
| | | public void aliPayWorldCupCallback(HttpServletRequest request, HttpServletResponse response){ |
| | | try { |
| | | Map<String, String> map = payMoneyUtil.alipayCallback(request); |
| | | if(null != map){ |
| | | String code = map.get("out_trade_no"); |
| | | String transaction_id = map.get("trade_no"); |
| | | String result = map.get("result"); |
| | | ResultUtil resultUtil = worldCupService.paymentWorldCupCallback(code, transaction_id); |
| | | if(resultUtil.getCode() == 200){ |
| | | PrintWriter out = response.getWriter(); |
| | | out.println(result); |
| | | out.flush(); |
| | | out.close(); |
| | | }else{ |
| | | log.error("社区世界杯报名支付宝支付回业务处理异常:" + resultUtil.getMsg()); |
| | | } |
| | | }else{ |
| | | log.error("社区世界杯报名付宝支支付回调解析异常"); |
| | | } |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |