logic.py 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. from wx.dbTools import DB_WX_GZH_User
  2. from yixue import SiZhuLogic, GeJuLogic, ZhenDuanLogic, MBTILogic
  3. from yixue.Models import BaZi, SiZhuResult
  4. from yixue.other import CalcNongLi
  5. from yixue.sizhu import CalcSiZhuByTexts
  6. def get_lucky_day(openid: str):
  7. dt = DB_WX_GZH_User.query_first_by(open_id=openid)
  8. if dt is None:
  9. return "未找到您的信息,请先补充个人信息。https://yixuegzhweb.cxhy.cn/applyUserInfo/?user=" + openid
  10. else:
  11. # 没有四柱信息则先计算四柱并保存
  12. if not dt.has_sizhu():
  13. sizhuResult = SiZhuLogic.calc_si_zhu(dt.born_year, dt.born_month, dt.born_day,
  14. dt.is_know_time(), dt.born_hour, dt.born_minute,
  15. dt.born_sheng, dt.born_shi, dt.born_qu)
  16. # test
  17. # sizhuTexts = ["甲", "子", "甲", "寅", "甲", "丑", "甲", "未"]
  18. print(sizhuResult)
  19. try:
  20. bazi = BaZi.build(sizhuResult)
  21. bazi.is_man = dt.is_man
  22. SiZhuLogic.calc_wu_xing(bazi)
  23. SiZhuLogic.calc_yin_yang(bazi)
  24. SiZhuLogic.calc_shi_shen(bazi)
  25. SiZhuLogic.calc_cang_gans(bazi)
  26. SiZhuLogic.calc_zhang_shengs(bazi)
  27. SiZhuLogic.calc_da_yun(bazi)
  28. SiZhuLogic.calc_gao_nengs(bazi)
  29. SiZhuLogic.calc_counter_and_steps(bazi)
  30. SiZhuLogic.calc_wang_shuai(bazi)
  31. SiZhuLogic.check_muku(bazi)
  32. # 大运流年
  33. # 高能:大运流年
  34. # 高能:冲穿的力量对比
  35. # 神煞
  36. # 凶吉
  37. # 性格诊断,链接、页面、分享
  38. # 运势、链接、页面、分享
  39. # 接口独立出来
  40. # 前端拿不到openid的处理:链接有误,转客服
  41. print(bazi)
  42. except Exception as e:
  43. print(e)
  44. # 计算藏干
  45. ss = DB_WX_GZH_User.new_session()
  46. user = ss.query(DB_WX_GZH_User).filter_by(open_id=openid).first()
  47. if user is not None:
  48. pass
  49. # user.set_sizhu_texts(sizhuTexts)
  50. # ss.commit()
  51. ss.close()
  52. # 有四柱信息,则根据当前的年月日计算高能关系
  53. msg = "您的四柱是: "
  54. return msg
  55. def calc_si_zhu(year: int, month: int, day: int, hour: int, minute: int, sheng: str, shi: str, qu: str):
  56. know_time = hour is not None
  57. result = SiZhuLogic.calc_si_zhu(year, month, day, know_time, hour, minute, sheng, shi, qu)
  58. return result
  59. def calc_nong_li(year: int, month: str, day: str):
  60. return CalcNongLi.run(year, month, day)
  61. def check_date_by_texts(niangan: str, nianzhi: str, yuegan: str, yuezhi: str, rigan: str, rizhi: str, shigan: str,
  62. shizhi: str):
  63. return CalcSiZhuByTexts.run(niangan, nianzhi, yuegan, yuezhi, rigan, rizhi, shigan, shizhi)
  64. def build_bazi(sizhuResult: SiZhuResult, isMan: bool):
  65. bazi = BaZi.build(sizhuResult)
  66. bazi.is_man = isMan
  67. SiZhuLogic.calc_wu_xing(bazi)
  68. SiZhuLogic.calc_yin_yang(bazi)
  69. SiZhuLogic.calc_shi_shen(bazi)
  70. SiZhuLogic.calc_cang_gans(bazi)
  71. SiZhuLogic.calc_zhang_shengs(bazi)
  72. # 禄神是在神煞里面有,这里不单独再看了
  73. SiZhuLogic.calc_da_yun(bazi)
  74. SiZhuLogic.calc_liu_nian(bazi)
  75. SiZhuLogic.calc_liu_yue(bazi)
  76. SiZhuLogic.calc_liu_ri(bazi)
  77. SiZhuLogic.calc_gao_nengs(bazi)
  78. SiZhuLogic.calc_counter_and_steps(bazi)
  79. SiZhuLogic.calc_wang_shuai(bazi)
  80. SiZhuLogic.check_muku(bazi)
  81. SiZhuLogic.check_shen_sha(bazi)
  82. GeJuLogic.calc_tian_gan(bazi)
  83. GeJuLogic.calc_di_zhi(bazi)
  84. GeJuLogic.count_geju_score(bazi)
  85. GeJuLogic.count_dayun_geju_score(bazi)
  86. GeJuLogic.count_liunian_geju_score(bazi)
  87. GeJuLogic.check_xiong_ji(bazi)
  88. SiZhuLogic.calc_dayun_gaoneng(bazi)
  89. SiZhuLogic.calc_dayun_shensha(bazi)
  90. SiZhuLogic.calc_liunian_gaoneng(bazi)
  91. SiZhuLogic.calc_liunian_shensha(bazi)
  92. SiZhuLogic.calc_liuyue_gaoneng(bazi)
  93. SiZhuLogic.calc_liuyue_shensha(bazi)
  94. SiZhuLogic.calc_liuri_gaoneng(bazi)
  95. SiZhuLogic.calc_liuri_shensha(bazi)
  96. SiZhuLogic.calc_yinyuan(bazi)
  97. ZhenDuanLogic.calc_power_percentages(bazi)
  98. ZhenDuanLogic.about_wuxing_shishen_zuozhi(bazi)
  99. ZhenDuanLogic.about_menhu(bazi)
  100. ZhenDuanLogic.about_shen_sha(bazi)
  101. ZhenDuanLogic.about_geju(bazi)
  102. ZhenDuanLogic.about_gaoneng(bazi)
  103. ZhenDuanLogic.about_jiankang(bazi)
  104. ZhenDuanLogic.about_qinggan(bazi)
  105. ZhenDuanLogic.about_dayun(bazi)
  106. ZhenDuanLogic.about_yinyuan(bazi)
  107. # QuShiLogic.calc_qushi(bazi)
  108. MBTILogic.calc(bazi)
  109. return bazi