from wx.dbTools import DB_WX_GZH_User from yixue import SiZhuLogic, GeJuLogic, ZhenDuanLogic, MBTILogic from yixue.Models import BaZi, SiZhuResult from yixue.other import CalcNongLi from yixue.sizhu import CalcSiZhuByTexts def get_lucky_day(openid: str): dt = DB_WX_GZH_User.query_first_by(open_id=openid) if dt is None: return "未找到您的信息,请先补充个人信息。https://yixuegzhweb.cxhy.cn/applyUserInfo/?user=" + openid else: # 没有四柱信息则先计算四柱并保存 if not dt.has_sizhu(): sizhuResult = SiZhuLogic.calc_si_zhu(dt.born_year, dt.born_month, dt.born_day, dt.is_know_time(), dt.born_hour, dt.born_minute, dt.born_sheng, dt.born_shi, dt.born_qu) # test # sizhuTexts = ["甲", "子", "甲", "寅", "甲", "丑", "甲", "未"] print(sizhuResult) try: bazi = BaZi.build(sizhuResult) bazi.is_man = dt.is_man SiZhuLogic.calc_wu_xing(bazi) SiZhuLogic.calc_yin_yang(bazi) SiZhuLogic.calc_shi_shen(bazi) SiZhuLogic.calc_cang_gans(bazi) SiZhuLogic.calc_zhang_shengs(bazi) SiZhuLogic.calc_da_yun(bazi) SiZhuLogic.calc_gao_nengs(bazi) SiZhuLogic.calc_counter_and_steps(bazi) SiZhuLogic.calc_wang_shuai(bazi) SiZhuLogic.check_muku(bazi) # 大运流年 # 高能:大运流年 # 高能:冲穿的力量对比 # 神煞 # 凶吉 # 性格诊断,链接、页面、分享 # 运势、链接、页面、分享 # 接口独立出来 # 前端拿不到openid的处理:链接有误,转客服 print(bazi) except Exception as e: print(e) # 计算藏干 ss = DB_WX_GZH_User.new_session() user = ss.query(DB_WX_GZH_User).filter_by(open_id=openid).first() if user is not None: pass # user.set_sizhu_texts(sizhuTexts) # ss.commit() ss.close() # 有四柱信息,则根据当前的年月日计算高能关系 msg = "您的四柱是: " return msg def calc_si_zhu(year: int, month: int, day: int, hour: int, minute: int, sheng: str, shi: str, qu: str): know_time = hour is not None result = SiZhuLogic.calc_si_zhu(year, month, day, know_time, hour, minute, sheng, shi, qu) return result def calc_nong_li(year: int, month: str, day: str): return CalcNongLi.run(year, month, day) def check_date_by_texts(niangan: str, nianzhi: str, yuegan: str, yuezhi: str, rigan: str, rizhi: str, shigan: str, shizhi: str): return CalcSiZhuByTexts.run(niangan, nianzhi, yuegan, yuezhi, rigan, rizhi, shigan, shizhi) def build_bazi(sizhuResult: SiZhuResult, isMan: bool): bazi = BaZi.build(sizhuResult) bazi.is_man = isMan SiZhuLogic.calc_wu_xing(bazi) SiZhuLogic.calc_yin_yang(bazi) SiZhuLogic.calc_shi_shen(bazi) SiZhuLogic.calc_cang_gans(bazi) SiZhuLogic.calc_zhang_shengs(bazi) # 禄神是在神煞里面有,这里不单独再看了 SiZhuLogic.calc_da_yun(bazi) SiZhuLogic.calc_liu_nian(bazi) SiZhuLogic.calc_liu_yue(bazi) SiZhuLogic.calc_liu_ri(bazi) SiZhuLogic.calc_gao_nengs(bazi) SiZhuLogic.calc_counter_and_steps(bazi) SiZhuLogic.calc_wang_shuai(bazi) SiZhuLogic.check_muku(bazi) SiZhuLogic.check_shen_sha(bazi) GeJuLogic.calc_tian_gan(bazi) GeJuLogic.calc_di_zhi(bazi) GeJuLogic.count_geju_score(bazi) GeJuLogic.count_dayun_geju_score(bazi) GeJuLogic.count_liunian_geju_score(bazi) GeJuLogic.check_xiong_ji(bazi) SiZhuLogic.calc_dayun_gaoneng(bazi) SiZhuLogic.calc_dayun_shensha(bazi) SiZhuLogic.calc_liunian_gaoneng(bazi) SiZhuLogic.calc_liunian_shensha(bazi) SiZhuLogic.calc_liuyue_gaoneng(bazi) SiZhuLogic.calc_liuyue_shensha(bazi) SiZhuLogic.calc_liuri_gaoneng(bazi) SiZhuLogic.calc_liuri_shensha(bazi) SiZhuLogic.calc_yinyuan(bazi) ZhenDuanLogic.calc_power_percentages(bazi) ZhenDuanLogic.about_wuxing_shishen_zuozhi(bazi) ZhenDuanLogic.about_menhu(bazi) ZhenDuanLogic.about_shen_sha(bazi) ZhenDuanLogic.about_geju(bazi) ZhenDuanLogic.about_gaoneng(bazi) ZhenDuanLogic.about_jiankang(bazi) ZhenDuanLogic.about_qinggan(bazi) ZhenDuanLogic.about_dayun(bazi) ZhenDuanLogic.about_yinyuan(bazi) # QuShiLogic.calc_qushi(bazi) MBTILogic.calc(bazi) return bazi