WxApiDao.java 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. package thyyxxk.wxservice_server.dao;
  2. import com.wechat.pay.java.service.payments.model.Transaction;
  3. import org.apache.ibatis.annotations.*;
  4. import thyyxxk.wxservice_server.entity.PureCodeName;
  5. import thyyxxk.wxservice_server.entity.appointment.DoctorInfo;
  6. import thyyxxk.wxservice_server.entity.electronichealthcard.HisRegister;
  7. import thyyxxk.wxservice_server.entity.paymzfee.MedinsSettle;
  8. import thyyxxk.wxservice_server.entity.scheduled.TradeNo;
  9. import thyyxxk.wxservice_server.entity.wxapi.WxPayOrder;
  10. import java.math.BigDecimal;
  11. import java.util.List;
  12. /**
  13. * @author dj
  14. */
  15. @Mapper
  16. public interface WxApiDao {
  17. @Select("select rtrim(name) from mz_patient_mi with(nolock) where patient_id=#{patientId}")
  18. String selectPatientName(String patientId);
  19. @Select("select top 1 * from t_wechat_pay_order with(nolock) where patient_id=#{patientId} " +
  20. "and mzy_request_id=#{mzyRequestId} and cashpay_amt=#{cost} ")
  21. WxPayOrder selectSameGhOrder(String patientId, Integer mzyRequestId, BigDecimal cost);
  22. @Select("select top 1 * from t_wechat_pay_order with(nolock) where his_ord_num=#{hisOrdNum} " +
  23. "and cashpay_amt=#{cost} order by create_datetime desc")
  24. WxPayOrder selectSameMzPayOrder(String hisOrdNum, BigDecimal cost);
  25. @Select("select count(1) from mzy_reqrec WITH(NOLOCK) where psordnum=#{tradeNo} and cancel_mark=0")
  26. int alreadyPaidRegisterFee(String tradeNo);
  27. @Insert("insert into t_wechat_pay_order (body,openid,total_fee,patient_id," +
  28. "patient_name,inpatient_no,admiss_times,app_id,mch_id,prepay_id," +
  29. "time_stamp,trade_no,create_order_sign,pay_sign,spbill_create_ip," +
  30. "create_datetime,trade_state,serial_no,order_type,his_ord_num," +
  31. "mzy_request_id,yj_req_no,his_status,query_state_times,ap_time," +
  32. "fundpay_amt,acctpay_amt,coupon_amt,cashpay_amt,coupon_id,sgl_check_id," +
  33. "sgl_check_notified,drug_purchase_id,wxmall_package_id,rec_staff) " +
  34. "values (#{body},#{openid},#{totalFee},#{patientId},#{patientName},#{inpatientNo}," +
  35. "#{admissTimes},#{appId},#{mchId},#{prepayId},#{timeStamp},#{tradeNo},#{createOrderSign}," +
  36. "#{paySign},#{spbillCreateIp},#{createDatetime},#{tradeState},#{serialNo},#{orderType}," +
  37. "#{hisOrdNum},#{mzyRequestId},#{yjReqNo},0,0,#{apTime},#{fundpayAmt}," +
  38. "#{acctpayAmt},#{couponAmt},#{cashpayAmt},#{couponId},#{sglCheckId}," +
  39. "#{sglCheckNotified},#{drugPurchaseId},#{wxmallPackageId},#{recStaff})")
  40. void insertNewOrder(WxPayOrder param);
  41. @Select("select * from t_si_setlinfo where pat_no=#{patNo} and times=#{times} and revoked=0")
  42. MedinsSettle selectSettleinfo(String patNo, int times);
  43. @Update("update t_wechat_pay_order set trade_state=#{tradeState}, pay_datetime=#{successTime}, " +
  44. "query_state_times=(query_state_times+1),last_query_state=getdate() where trade_no=#{tradeNo}")
  45. void updatePayStatusAndPayTime(String tradeNo,
  46. Transaction.TradeStateEnum tradeState,
  47. String successTime);
  48. @Update("update t_wechat_pay_order set trade_state=#{tradeState},pay_datetime=#{successTime},openid=#{openid}, " +
  49. "query_state_times=(query_state_times+1),last_query_state=getdate() where trade_no=#{tradeNo}")
  50. void updatePayStatusAndPayTimeAndOpenid(String tradeNo,
  51. Transaction.TradeStateEnum tradeState,
  52. String successTime,
  53. String openid);
  54. @Update("update t_wechat_pay_order set trade_state=#{tradeState},query_state_times=(query_state_times+1), " +
  55. "last_query_state=getdate() where trade_no=#{tradeNo}")
  56. void updatePayStatusAndQueryTimes(String tradeNo,
  57. Transaction.TradeStateEnum tradeState);
  58. @Update("update t_wechat_pay_order set trade_state=#{tradeState},query_state_times=(query_state_times+1), " +
  59. "openid=#{openid},last_query_state=getdate() where trade_no=#{tradeNo}")
  60. void updatePayStatusAndQueryTimesAndOpenid(String tradeNo,
  61. Transaction.TradeStateEnum tradeState,
  62. String openid);
  63. @Update("update t_wechat_pay_order set pay_order_id=#{payOrderId} , mch_order_no=#{mchOrderNo} where trade_no=#{tradeNo}")
  64. int updatePayNo(String payOrderId,String mchOrderNo,String tradeNo);
  65. @Update("update t_wechat_pay_order set trade_state=#{tradeState} where trade_no=#{tradeNo}")
  66. void updatePayStatusOnly(String tradeNo, Transaction.TradeStateEnum tradeState);
  67. @Select("select count(1) from mz_deposit_file WITH(NOLOCK) where psordnum=#{tradeNo} and pay_mark=0")
  68. int alreadyPayed(String tradeNo);
  69. @Select("select trade_state as tradeState,refund_id as name from t_wechat_pay_order where trade_no=#{tradeNo} ")
  70. PureCodeName selectPayStatus(String tradeNo);
  71. @Update("update t_wechat_pay_order set trade_state='REFUND',refund_op_code='99999'," +
  72. "refund_reason=#{reason},his_status=0,refund_op_datetime=getdate() " +
  73. "where trade_no=#{tradeNo}")
  74. void refundOrder(String tradeNo, String reason);
  75. @Update("update t_wechat_pay_order set trade_state='REFUND' where trade_no=#{tradeNo}")
  76. void updateRefundStatus(String tradeNo);
  77. @Update("update t_wechat_pay_order set his_status=1 where trade_no=#{tradeNo}")
  78. void updateSuccessHisStatus(String tradeNo);
  79. @Update("update t_patient_coupons set coupon_state='USED' where id=#{id}")
  80. void couponUsed(String id);
  81. @Select("select datediff(day,getdate(),request_day) as dateDiff, " +
  82. "rtrim(unit_code) as unitCode from mzy_reqrec where psordnum=#{tradeNo}")
  83. HisRegister selectRegisterDateDiff(String tradeNo);
  84. @Select("select count(1) from mz_deposit_file where psordnum=#{tradeNo} and cheque_type='2'")
  85. int selectFundPayCount(String tradeNo);
  86. @Select("select * from t_wechat_pay_order with(nolock) where trade_no=#{tradeNo}")
  87. WxPayOrder selectOrderByTradeNo(String tradeNo);
  88. @Select("select order_type from t_wechat_pay_order with(nolock) where trade_no=#{tradeNo}")
  89. Integer selectOrderType(String tradeNo);
  90. @Select("select trade_no,trade_state,query_state_times, " +
  91. "offset=datediff(minute,create_datetime,last_query_state) " +
  92. "from t_wechat_pay_order with(nolock) " +
  93. "where openid!='' and his_status=0 and order_type in (1,2,3) " +
  94. "and trade_state='NOTPAY' " +
  95. "union " +
  96. "select trade_no,trade_state,query_state_times, " +
  97. "offset=datediff(minute,create_datetime,last_query_state) " +
  98. "from t_wechat_pay_order with(nolock) where order_type=5 " +
  99. "and sgl_check_notified=0 and trade_state in ('NOTPAY','SUCCESS')")
  100. List<TradeNo> selectTradeNosForScheduleTask();
  101. @Select("select openid from t_wechat_patient_bind with(nolock) " +
  102. "where (patient_id=#{cardNo} or ic_card_no=#{cardNo}) and del_flag=0")
  103. List<String> selectOpenidByCardNo(String cardNo);
  104. @Select("select rtrim(a.code) doctorCode,rtrim(a.name) doctorName,rtrim(b.name) doctorTitle,rtrim(a.dept_code) deptCode, " +
  105. "deptName=(select rtrim(name) from zd_unit_code with(nolock) where code=a.dept_code), " +
  106. "a.specialty,a.introduction,a.portrait " +
  107. "from a_employee_mi a with(nolock), zd_emp_title b with(nolock) " +
  108. "where a.code=#{doctorCode} and a.emp_tit_code=b.code and " +
  109. "a.code not in ('00000', '00026') and isnull(a.del_flag,0)<>1")
  110. DoctorInfo selectDoctorInfo(String doctorCode);
  111. @Select("select trade_no from t_wechat_pay_order where his_ord_num=#{hisOrdNum} " +
  112. "and trade_state not in ('SUCCESS','CLOSED')")
  113. List<String> selectTradeNoByHisOrdNum(String hisOrdNum);
  114. @Select("select trade_state from t_wechat_pay_order with(nolock) where trade_no=#{tradeNo}")
  115. Transaction.TradeStateEnum selectOrderStatus(String tradeNo);
  116. @Update("update t_wechat_pay_order set refund_id=#{refundId}, refund_op_code=#{refundOpCode}, his_status=0, " +
  117. "refund_op_datetime=#{refundOpDatetime}, refund_reason=#{refundReason}, trade_state='REFUND' where trade_no=#{tradeNo}")
  118. void updateRefundId(WxPayOrder order);
  119. @Delete("delete from t_wechat_pay_order where trade_no=#{tradeNo}")
  120. void deleteOrder(String tradeNo);
  121. @Update("update t_wechat_pay_order set trade_state='REFUND', refund_reason=#{msg}, his_status=0 where trade_no=#{tradeNo}")
  122. void alreadyRefund(String tradeNo, String msg);
  123. @Update("update t_si_setlinfo set mz_saved=1 where pat_no=#{patId} and times=#{times} and revoked=0")
  124. void updateMzSavedFlag(String patId, String times);
  125. @Update("update t_wechat_pay_order set sgl_check_notified=1 where trade_no=#{tradeNo}")
  126. void updateCytjNotified(String tradeNo);
  127. }