def add(request): # 0:成功,-1:不成功 result = {"code": 0, "msg": "操作成功!!"} # 获取页面的数据 room = request.POST.get("room") floorid = request.POST.get("floorid") floorno = request.POST.get("floorno") room_type_id = request.POST.get("room_type_id") # 判断一下这个楼房是否存在,如果存在,就不能添加 u = Mo.objects.filter(room=room, floorid=floorid) if u: result["code"] = -1 result["msg"] = "用户已经存在,不能添加!!" else: # 插到数据库里面 m = Mo() m.room = room m.floorid = floorid m.floorno = floorno m.status = 0 m.room_type_id = room_type_id m.updatetime = datetime.now().strftime("%Y-%m-%d %H:%M:%S") m.createtime = datetime.now().strftime("%Y-%m-%d %H:%M:%S") # 真正的保存 m.save() return JsonResponse(result)
def add(request): # 0:成功,-1:不成功 result = {"code": 0, "msg": "操作成功!!"} # 获取页面的数据 name = request.POST.get("name") idcard = request.POST.get("idcard") sex = request.POST.get("sex") type = request.POST.get("type") address = request.POST.get("address") tel = request.POST.get("tel") # 判断一下这个楼房是否存在,如果存在,就不能添加 u = Mo.objects.filter(idcard=idcard) if u: result["code"] = -1 result["msg"] = "客户已经存在,不能添加!!" else: # 插到数据库里面 m = Mo() m.name = name m.idcard = idcard m.sex = sex m.type = type m.address = address m.tel = tel m.createtime = datetime.now().strftime("%Y-%m-%d %H:%M:%S") m.updatetime = datetime.now().strftime("%Y-%m-%d %H:%M:%S") # 真正的保存 m.save() return JsonResponse(result)
def add(request): # 0:成功,-1:不成功 result = {"code": 0, "msg": "操作成功!!"} # 获取页面的数据 custumer_id = request.POST.get("custumer_id") room_id = request.POST.get("room_id") time_ins = request.POST.get("time_in") day = int(request.POST.get("day")) time_in = datetime.datetime.strptime(time_ins, '%Y-%m-%d %H:%M:%S') # 判断一下这个楼房是否存在,如果存在,就不能添加(在他入住的时间段内)? now = datetime.datetime.now() u = Mo.objects.filter(custumer_id=custumer_id, room_id=room_id, time_out__lte=now) if u: result["code"] = -1 result["msg"] = "客户已经入住,不能添加!!" else: # 插到数据库里面 m = Mo() m.custumer_id = custumer_id m.room_id = room_id m.time_in = time_in m.day = day delta = datetime.timedelta(days=day) n_days = time_in + delta m.time_out = n_days m.createtime = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S") m.updatetime = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S") # 真正的保存 m.save() return JsonResponse(result)
def bill_income(request): # 0:成功,-1:不成功 result = {"code": 0, "msg": "操作成功!!"} # 获取页面的数据 remark = request.POST.get("remark") money = request.POST.get("money") inType = int(request.POST.get("inType")) bill = request.POST.get("bill") # 判断一下这个楼房是否存在,如果存在,就不能添加(在他入住的时间段内)? # 插到数据库里面 m = Mo() m.remark = remark m.money = money m.in_type = inType m.bill = bill m.type = 0 m.create_time = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S") # 真正的保存 m.save() # 更新账单表 Bill.objects.filter(id=bill).update( status=0, inmoney=0, updatetime=datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")) return JsonResponse(result)
def add(request): # 0:成功,-1:不成功 result = {"code": 0, "msg": "操作成功!!"} # 获取页面的数据 custumer_id = request.POST.get("custumer_id") room_id = request.POST.get("room_id") time_ins = request.POST.get("time_in") day = int(request.POST.get("day")) time_in = datetime.datetime.strptime(time_ins, '%Y-%m-%d %H:%M:%S') # 判断一下这个楼房是否存在,如果存在,就不能添加(在他入住的时间段内)? now = datetime.datetime.now() u = Mo.objects.filter(custumer_id=custumer_id, room_id=room_id, time_out__lte=now) if u: result["code"] = -1 result["msg"] = "客户已经入住,不能添加!!" else: room = Room.objects.filter(id=room_id).values( "id", 'status', 'room_type_id', 'room_type_id__vip_price', 'room_type_id__price', 'room_type_id__typename') custumer = Custumer.objects.filter(id=custumer_id) # 生成账单 b = Bill() if custumer[0].type == 1: all_money = room[0]["room_type_id__vip_price"] * day else: all_money = room[0]["room_type_id__price"] * day b.money = all_money b.inmoney = 0 b.room = room_id b.status = 1 b.createtime = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S") b.updatetime = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S") b.save() # yb = Bill.objects.filter(room=b.room,status=b.status,money=b.money) # 插到数据库里面 nroom = Room() nroom.id = room[0]["id"] m = Mo() m.bill = b m.custumer_id = custumer[0] m.room_id = nroom m.time_in = time_in m.day = day delta = datetime.timedelta(days=day) n_days = time_in + delta m.time_out = n_days m.createtime = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S") m.updatetime = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S") # 真正的保存 m.save() updatetime = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S") # 更新房间状态 Room.objects.filter(id=nroom.id).update(status=1, updatetime=updatetime) return JsonResponse(result)
def add(request): # 0:成功,-1:不成功 result = {"code": 0, "msg": "操作成功!!"} # 获取页面的数据 no = request.POST.get("no") name = request.POST.get("name") floorno = request.POST.get("floorno") remark = request.POST.get("remark") # 判断一下这个楼房是否存在,如果存在,就不能添加 u = Mo.objects.filter(no=no) if u: result["code"] = -1 result["msg"] = "用户已经存在,不能添加!!" else: # 插到数据库里面 m = Mo() m.no = no m.name = name m.floorno = floorno m.status = 0 m.remark = remark m.updatetime = datetime.now().strftime("%Y-%m-%d %H:%M:%S") m.createtime = datetime.now().strftime("%Y-%m-%d %H:%M:%S") # 真正的保存 m.save() # 楼房新建后,房间就自动生成 f = Mo.objects.filter(no=no) u = RoomType.objects.all() fno = int(f[0].floorno) # 插到数据库里面 for i in range(0, fno): for k in range(1, 9): rm = Room() # 楼房id+楼房单元+层+房间号 roomNo = str(f[0].id) + str( f[0].no) + str(i + 1) + str("0") + str(k) rm.room = roomNo rm.floorid = f[0].id rm.floorno = i + 1 rm.status = 0 rm.room_type_id = u[0].id rm.updatetime = datetime.now().strftime("%Y-%m-%d %H:%M:%S") rm.createtime = datetime.now().strftime("%Y-%m-%d %H:%M:%S") # 真正的保存 rm.save() return JsonResponse(result)
def add(request): # 0:成功,-1:不成功 result = {"code": 0, "msg": "操作成功!!"} # 获取页面的数据 typename = request.POST.get("typename") price = request.POST.get("price") vip_price = request.POST.get("vip_price") # 判断一下这个楼房是否存在,如果存在,就不能添加 u = Mo.objects.filter(typename=typename) if u: result["code"] = -1 result["msg"] = "类型经存在,不能添加!!" else: # 插到数据库里面 m = Mo() m.typename = typename m.price = price m.vip_price = vip_price m.updatetime = datetime.now().strftime("%Y-%m-%d %H:%M:%S") # 真正的保存 m.save() return JsonResponse(result)