WxApiDao.java 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. package thyyxxk.wxservice_server.dao;
  2. import org.apache.ibatis.annotations.*;
  3. import thyyxxk.wxservice_server.entity.appointment.DoctorInfo;
  4. import thyyxxk.wxservice_server.entity.scheduled.TradeNo;
  5. import thyyxxk.wxservice_server.entity.wxapi.WxPayOrder;
  6. import java.util.List;
  7. /**
  8. * @author dj
  9. */
  10. @Mapper
  11. public interface WxApiDao {
  12. @Select("select rtrim(name) from mz_patient_mi with(nolock) where patient_id=#{patientId}")
  13. String selectPatientName(@Param("patientId") String patientId);
  14. @Select("select * from t_wechat_pay_order with(nolock) where patient_id=#{patientId} and " +
  15. "mzy_request_id=#{mzyRequestId} ")
  16. WxPayOrder selectSameGhOrder(@Param("patientId") String patientId,
  17. @Param("mzyRequestId") Integer mzyRequestId);
  18. @Select("select top 1 * from t_wechat_pay_order with(nolock) where his_ord_num=#{hisOrdNum} " +
  19. "and total_fee=#{cost} order by create_datetime desc")
  20. WxPayOrder selectSameMzPayOrder(@Param("hisOrdNum") String hisOrdNum, @Param("cost") double cost);
  21. @Select("select count(1) from mzy_reqrec WITH(NOLOCK) where psordnum=#{tradeNo} and cancel_mark=0")
  22. int alreadyPaidRegisterFee(@Param("tradeNo") String tradeNo);
  23. @Insert("insert into t_wechat_pay_order (body,open_id,total_fee,patient_id," +
  24. "patient_name,inpatient_no,admiss_times,app_id,mch_id,prepay_id," +
  25. "time_stamp,trade_no,create_order_sign,pay_sign,spbill_create_ip," +
  26. "create_datetime,pay_status,serial_no,order_type,his_ord_num," +
  27. "mzy_request_id,yj_req_no,his_status,query_state_times) " +
  28. "values (#{body},#{openId},#{totalFee},#{patientId},#{patientName},#{inpatientNo}," +
  29. "#{admissTimes},#{appId},#{mchId},#{prepayId},#{timeStamp},#{tradeNo},#{createOrderSign}," +
  30. "#{paySign},#{spbillCreateIp},#{createDatetime},#{payStatus},#{serialNo},#{orderType}," +
  31. "#{hisOrdNum},#{mzyRequestId},#{yjReqNo},0,0)")
  32. void insertNewOrder(WxPayOrder param);
  33. @Update("update t_wechat_pay_order set pay_status=#{status}, pay_datetime=#{successTime}, " +
  34. "query_state_times=(query_state_times+1),last_query_state=getdate() where trade_no=#{tradeNo}")
  35. void updatePayStatusAndPayTime(@Param("tradeNo") String tradeNo, @Param("status") Integer status,
  36. @Param("successTime") String successTime);
  37. @Update("update t_wechat_pay_order set pay_status=#{status},pay_datetime=#{successTime},open_id=#{openId}, " +
  38. "query_state_times=(query_state_times+1),last_query_state=getdate() where trade_no=#{tradeNo}")
  39. void updatePayStatusAndPayTimeAndOpenId(@Param("tradeNo") String tradeNo, @Param("status") Integer status,
  40. @Param("successTime") String successTime, @Param("openId") String openId);
  41. @Update("update t_wechat_pay_order set pay_status=#{status},query_state_times=(query_state_times+1), " +
  42. "last_query_state=getdate() where trade_no=#{tradeNo}")
  43. void updatePayStatusAndQueryTimes(@Param("tradeNo") String tradeNo, @Param("status") Integer status);
  44. @Update("update t_wechat_pay_order set pay_status=#{status},query_state_times=(query_state_times+1), " +
  45. "open_id=#{openId},last_query_state=getdate() where trade_no=#{tradeNo}")
  46. void updatePayStatusAndQueryTimesAndOpenId(@Param("tradeNo") String tradeNo,
  47. @Param("status") Integer status,
  48. @Param("openId") String openId);
  49. @Update("update t_wechat_pay_order set pay_status=#{status} where trade_no=#{tradeNo}")
  50. void updatePayStatusOnly(@Param("tradeNo") String tradeNo, @Param("status") Integer status);
  51. @Select("select count(1) from mz_deposit_file WITH(NOLOCK) where psordnum=#{tradeNo} and pay_mark=0")
  52. int alreadyPayed(@Param("tradeNo") String tradeNo);
  53. @Select("select pay_status from t_wechat_pay_order where trade_no=#{tradeNo} ")
  54. Integer selectPayStatus(@Param("tradeNo") String tradeNo);
  55. @Update("update t_wechat_pay_order set pay_status=4,refund_op_code='99999',refund_reason=#{rea}, " +
  56. "his_status=0,refund_op_datetime=getdate() where trade_no=#{tradeNo}")
  57. void refundOrder(@Param("tradeNo") String tradeNo, @Param("rea") String rea);
  58. @Update("update t_wechat_pay_order set pay_status=4 where trade_no=#{tradeNo}")
  59. void updateRefundStatus(@Param("tradeNo") String tradeNo);
  60. @Update("update t_wechat_pay_order set his_status=1 where trade_no=#{tradeNo}")
  61. void updateSuccessHisStatus(@Param("tradeNo") String tradeNo);
  62. @Select("select * from t_wechat_pay_order with(nolock) where trade_no=#{tradeNo}")
  63. WxPayOrder selectOrderByTradeNo(@Param("tradeNo") String tradeNo);
  64. @Select("select trade_no, query_state_times,offset=datediff(minute,create_datetime,last_query_state) " +
  65. "from t_wechat_pay_order with(nolock) where his_status=0 and order_type<=3 and open_id!='' " +
  66. "and pay_status in (99, 0, 5, 6, 100) ")
  67. List<TradeNo> selectTradeNosForScheduleTask();
  68. @Select("select open_id from t_wechat_patient_bind with(nolock) where patient_id=#{cardNo} and del_flag=0")
  69. List<String> selectOpenIdByPatientId(@Param("cardNo") String cardNo);
  70. @Select("select open_id from t_wechat_patient_bind with(nolock) where ic_card_no=#{cardNo} and del_flag=0")
  71. List<String> selectOpenIdByIcCardNo(@Param("cardNo") String cardNo);
  72. @Select("select rtrim(a.code) doctorCode,rtrim(a.name) doctorName,rtrim(b.name) doctorTitle,rtrim(a.dept_code) deptCode, " +
  73. "deptName=(select rtrim(name) from zd_unit_code with(nolock) where code=a.dept_code), " +
  74. "a.specialty,a.introduction,a.portrait " +
  75. "from a_employee_mi a with(nolock), zd_emp_title b with(nolock) " +
  76. "where a.code=#{doctorCode} and a.emp_tit_code=b.code and " +
  77. "a.code not in ('00000', '00026') and isnull(a.del_flag,0)<>1")
  78. DoctorInfo selectDoctorInfo(@Param("doctorCode") String doctorCode);
  79. @Select("select pay_status from t_wechat_pay_order with(nolock) where trade_no=#{tradeNo}")
  80. Integer selectOrderStatus(@Param("tradeNo") String tradeNo);
  81. @Update("update t_wechat_pay_order set refund_id=#{refundId}, refund_op_code=#{refundOpCode}, his_status=0, " +
  82. "refund_op_datetime=#{refundOpDatetime}, refund_reason=#{refundReason}, pay_status=4 where trade_no=#{tradeNo}")
  83. void updateRefundId(WxPayOrder order);
  84. @Update("update t_wechat_pay_order set pay_status=4, refund_reason=#{msg}, his_status=0 where trade_no=#{tradeNo}")
  85. void alreadyRefund(@Param("tradeNo") String tradeNo, @Param("msg") String msg);
  86. @Update("update t_si_setlinfo set mz_saved=1 where pat_no=#{patId} and times=#{times} and revoked=0")
  87. void updateMzSavedFlag(@Param("patId") String patId, @Param("times") String times);
  88. }