def add_one_debt(uid,cid,num,t): if not str(cid).isdigit(): return {'msg':'id不存在','status':2} if not is_float(num): return {'msg':'数量错误','status':2} if not is_date(t): return {'msg':'日期错误','status':2} ll = [v[0] for v in CardDao.find_card(uid)] if cid not in ll: return {'msg':'id不存在','status':2} try: DebtDao.add_debt(uid, cid, dt.datetime.strptime(t,'%Y-%m-%d'), num) except Exception as e: res = {'msg':'输入错误:' + str(e),'status':2} else: res = {'msg':'添加成功','status':1} return res
def quick_repay_by_card(uid, in_cid, num, date, out_cid): if not str(in_cid).isdigit(): return {'msg': 'id不存在', 'status': 2} if not is_float(num): return {'msg': '数量错误', 'status': 2} if not is_date(date): return {'msg': '日期错误', 'status': 2} t = dt.datetime.strptime(date, '%Y-%m-%d') # rl = round(num*1.006,2) try: DebtDao.add_debt(uid, out_cid, t, num) # 临时改rl为 num RepayDao.add_repay(uid, in_cid, t, num) except Exception as e: res = {'msg': '输入错误:' + str(e), 'status': 1} else: res = {'msg': '添加成功', 'status': 1} return res