Appointment.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. <?php
  2. /*
  3. * @Author: wang jun
  4. * @Date: 2022-01-18 10:57:14
  5. * @Last Modified by: wang jun
  6. * @Last Modified time: 2022-01-19 10:38:56
  7. * 微信类
  8. */
  9. namespace app\index\controller;
  10. use app\index\logic\appointmentlogic;
  11. use app\index\logic\paylogic;
  12. use app\index\logic\wechatlogic;
  13. use app\index\logic\wxuserlogic;
  14. use think\Controller;
  15. use think\Db;
  16. use think\Log;
  17. class Appointment extends Base
  18. {
  19. /**
  20. * 新建申请
  21. *
  22. * @return void
  23. * @author wj
  24. * @date 2022-07-23
  25. */
  26. public function newinfo()
  27. {
  28. $param = request()->post();
  29. Db::startTrans();
  30. try {
  31. $l_wu = new wxuserlogic();
  32. $result = $l_wu->saveinfo($param);
  33. if ($result['status']) {
  34. throw new \Exception($result['msg']);
  35. }
  36. $wudata = $result['data'];
  37. $wid = $wudata['id'];
  38. $param['wid'] = $wid;
  39. $l_a = new appointmentlogic();
  40. $result = $l_a->newinfo($param);
  41. if (!$result['status']) {
  42. throw new \Exception($result['msg']);
  43. }
  44. $adata = $result['data'];
  45. $returnData = [
  46. 'aid' => $adata['id'],
  47. ];
  48. Db::commit();
  49. return backjson(1, $returnData);
  50. } catch (\Exception $e) {
  51. Db::rollback();
  52. return backjson(0, $e->getMessage());
  53. }
  54. }
  55. /**
  56. * 支付核酸检测费用 仅小程序支付
  57. *
  58. * @return void
  59. * @author wj
  60. * @date 2022-07-23
  61. */
  62. public function payorder()
  63. {
  64. $param = request()->post();
  65. $l_p = new paylogic();
  66. $result = $l_p->getappointmentorderforxcx($param);
  67. if (empty($result['status'])) {
  68. return backjson(0, $result['msg']);
  69. }
  70. $orderData = $result['data'];
  71. $l_wechat = new wechatlogic();
  72. $result = $l_wechat->createorder($orderData);
  73. if (empty($result['status'])) {
  74. return backjson(0, $result['msg']);
  75. }
  76. $returnData = $result['data'];
  77. return $returnData;
  78. }
  79. /**
  80. * 支付回调
  81. *
  82. * @return void
  83. * @author wj
  84. * @date 2022-07-23
  85. */
  86. public function pay_call_back()
  87. {
  88. $headerinfo = request()->instance()->header();
  89. log::info($headerinfo);
  90. $reurnData = [
  91. "return_code" => "SUCCESS",
  92. "return_msg" => "OK",
  93. ];
  94. log::info('into callback');
  95. $data = file_get_contents('php://input');
  96. $backdata = (array) simplexml_load_string($data, 'SimpleXMLElement', LIBXML_NOCDATA);
  97. $l_p = new paylogic();
  98. $reulst = $l_p->handleorder($backdata);
  99. if (empty($reulst['status'])) {
  100. $reurnData = [
  101. "return_code" => "FAIL",
  102. "return_msg" => $reulst['msg'],
  103. ];
  104. } else {
  105. $reurnData = [
  106. "return_code" => "SUCCESS",
  107. "return_msg" => $reulst['msg'],
  108. ];
  109. }
  110. $l_wechat = new wechatlogic();
  111. $l_wechat->paybackxml($reurnData);
  112. }
  113. }