OnePayController.java 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. package com.yihu.wlyy.web.wx;
  2. import com.yihu.wlyy.service.weixin.wxpay.model.BindCard;
  3. import com.yihu.wlyy.service.weixin.wxpay.model.Charge;
  4. import com.yihu.wlyy.service.weixin.wxpay.service.OnePayService;
  5. import com.yihu.wlyy.web.WeixinBaseController;
  6. import io.swagger.annotations.Api;
  7. import io.swagger.annotations.ApiOperation;
  8. import io.swagger.annotations.ApiParam;
  9. import org.springframework.beans.factory.annotation.Autowired;
  10. import org.springframework.http.MediaType;
  11. import org.springframework.stereotype.Controller;
  12. import org.springframework.web.bind.annotation.RequestMapping;
  13. import org.springframework.web.bind.annotation.RequestMethod;
  14. import org.springframework.web.bind.annotation.RequestParam;
  15. import org.springframework.web.bind.annotation.ResponseBody;
  16. /**
  17. * Created by hzp on 2017/05/23.
  18. */
  19. @Controller
  20. @RequestMapping(value = "/onepay", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
  21. @Api(description = "统一支付服务")
  22. public class OnePayController extends WeixinBaseController {
  23. @Autowired
  24. private OnePayService pay;
  25. @RequestMapping(value = "bindCard", method = RequestMethod.POST)
  26. @ApiOperation("查询绑卡信息")
  27. @ResponseBody
  28. public String bindCard() throws Exception {
  29. try {
  30. BindCard bindCard = pay.bindCard(getOpenid()); //oULM4xOARzTFqr9y1aTWuzCQdUL0
  31. return write(200, "查询绑卡信息成功!","data",bindCard);
  32. }
  33. catch (Exception e)
  34. {
  35. return error(-1, e.getMessage());
  36. }
  37. }
  38. @RequestMapping(value = "charge", method = RequestMethod.POST)
  39. @ApiOperation("家庭医生签约支付")
  40. @ResponseBody
  41. public String charge(
  42. @ApiParam(name="orgCode",value="医疗机构编号",defaultValue = "3502050300")
  43. @RequestParam String orgCode,
  44. @ApiParam(name="code",value="签约代码",defaultValue = "044701ea5b2311e68344fa163e8aee56")
  45. @RequestParam String code,
  46. @ApiParam(name="date",value="签约付款时间yyyyMMddHHmmss",defaultValue = "20170523172400")
  47. @RequestParam String date,
  48. @ApiParam(name="cardNo",value="社保卡号",defaultValue = "DC0261911")
  49. @RequestParam String cardNo) throws Exception {
  50. try {
  51. String settleNo = pay.charge(orgCode,code,date,cardNo,getOpenid()); //"oULM4xOARzTFqr9y1aTWuzCQdUL0"
  52. return write(200, "家庭医生签约支付成功!","data",settleNo);
  53. }
  54. catch (Exception e)
  55. {
  56. return error(-1, e.getMessage());
  57. }
  58. }
  59. @RequestMapping(value = "chargeQuery", method = RequestMethod.POST)
  60. @ApiOperation("家庭医生签约支付查询")
  61. @ResponseBody
  62. public String chargeQuery(@ApiParam(name="code",value="签约代码",defaultValue = "20170523172835")
  63. @RequestParam String code) throws Exception {
  64. try {
  65. Charge charge = pay.chargeQuery(code);
  66. return write(200, "家庭医生签约支付查询成功!","data",charge);
  67. }
  68. catch (Exception e)
  69. {
  70. return error(-1, e.getMessage());
  71. }
  72. }
  73. }