def save(self, *args, **kwargs): super(Merchandise, self).save() cacheobj = Merchandise.objects.all() cache.set("Merchandise", list(cacheobj), TIMEOUT) set_pos_info_record() if get_option("POS_IC"): from mysite.iclock.models.dev_comm_operate import update_pos_device_info from mysite.iclock.models.model_device import DEVICE_POS_SERVER, Device dev = Device.objects.filter(device_type=DEVICE_POS_SERVER) if dev: update_pos_device_info(dev, [self], "STOREINFO")
def action(self): if self.object.is_pass == 0: raise Exception(_(u"编号%s人员补贴没有通过审核,操作失败") % self.object.user) if self.object.is_ok == 1: raise Exception(_(u"编号%s人员补贴已被领取,操作失败") % self.object.user) from mysite.iclock.models.model_device import Device, DEVICE_POS_SERVER from mysite.iclock.models.dev_comm_operate import update_pos_device_info dev = Device.objects.filter(device_type=DEVICE_POS_SERVER, device_use_type=2) #查找补贴机 if dev: update_pos_device_info(dev, [self.object], "SUBSIDYLOG") else: raise Exception(_(u"当前系统,没有补贴设备,操作失败"))
def funSaveCardmanage(request): from mysite.personnel.models.model_issuecard import IssueCard, PRIVAGE_CARD, POS_CARD, CARD_LOST, CARD_STOP, CARD_OVERDUE, CARD_VALID from mysite.iclock.models.dev_comm_operate import update_pos_device_info from mysite.iclock.models.model_device import Device, DEVICE_POS_SERVER from mysite.pos.models.model_cardmanage import CardManage from mysite.iclock.models.model_dininghall import Dininghall from mysite.pos.pos_constant import TIMEOUT from django.core.cache import cache obj = request.POST request.session.save() card_privage = obj['card_privage'] card = int(obj['cardno']) sys_card_no = obj['sys_card_no'] pwd = obj['Password'] dining_id = obj['dining'] try: if IssueCard.objects.get(cardno=card): return getJSResponse("result=ISUSE") #卡号已经使用 except: pass try: if IssueCard.objects.get(sys_card_no=sys_card_no): return getJSResponse("result=SYS_ISUSE") #卡账号重复 except: pass try: CardManage(card_no=card, pass_word=pwd, dining_id=dining_id, cardstatus=CARD_VALID, sys_card_no=sys_card_no, card_privage=card_privage).save() IssueCard(cardno=card, sys_card_no=sys_card_no, cardstatus=CARD_VALID, card_privage=card_privage, Password=pwd, type=None).save() dev = Device.objects.filter( device_type=DEVICE_POS_SERVER, dining=Dininghall.objects.get(pk=dining_id)) objcard = IssueCard.objects.get(sys_card_no=sys_card_no) update_pos_device_info(dev, [objcard], "USERINFO") return getJSResponse("result=OK") except: cache.delete("IC_Card_Count") import traceback traceback.print_exc() return getJSResponse("result=FAIL")
def save(self,*args, **kwargs): super(BatchTime,self).save() if get_option("POS_IC"): from mysite.iclock.models.dev_comm_operate import update_pos_device_info,delete_pos_device_info from mysite.iclock.models.model_device import DEVICE_POS_SERVER,Device dev=Device.objects.filter(device_type=DEVICE_POS_SERVER) if dev: if self.isvalid == 1: update_pos_device_info(dev,[self],"TIMESEG") else: delete_pos_device_info(dev,[self],"TIMESEG") key="BatchTime_"+self.code cacheobj = BatchTime.objects.filter(code=self.code,isvalid=1) cache.set(key,list(cacheobj),TIMEOUT) set_pos_info_record()
def DataPostCheck(sender, **kwargs): oldObj = kwargs['oldObj'] newObj = kwargs['newObj'] request = sender if isinstance(newObj, KeyValue): if get_option("POS_IC"): from mysite.iclock.models.dev_comm_operate import update_pos_device_info, delete_pos_device_info from mysite.iclock.models.model_device import DEVICE_POS_SERVER, Device n_dev = newObj.use_mechine.get_query_set() if n_dev: dev = Device.objects.filter(device_type=DEVICE_POS_SERVER) delete_pos_device_info(dev, [newObj], "PRESSKEY") update_pos_device_info(n_dev, [newObj], "PRESSKEY") else: dev = Device.objects.filter(device_type=DEVICE_POS_SERVER) update_pos_device_info(dev, [newObj], "PRESSKEY")
def action(self): from mysite.personnel.models.model_issuecard import IssueCard, CARD_VALID, CARD_STOP, CARD_OVERDUE from mysite.iclock.models.dev_comm_operate import update_pos_device_info, sync_report_user iscard = IssueCard.objects.filter( UserID=self.object.UserID, cardstatus__in=[CARD_VALID, CARD_OVERDUE]) if self.object.is_close_pos == 1: raise Exception(_(u"消费已经关闭!")) self.object.is_close_pos = 1 self.object.save() if iscard: #立即关闭消费 try: if get_option("POS_IC") and iscard[0].sys_card_no: iscard[0].cardstatus = CARD_STOP iscard[0].save(force_update=True) from mysite.iclock.models.model_device import Device, DEVICE_POS_SERVER dev = Device.objects.filter( device_type=DEVICE_POS_SERVER) update_pos_device_info(dev, [iscard[0]], "USERINFO") # if get_option("IACCESS"): # oldObj=iscard[0].UserID # if oldObj.check_accprivilege(): # devs=oldObj.search_accdev_byuser() # sync_report_user(devs,[oldObj]) # if get_option("ATT"): # oldObj=iscard[0].UserID # devs=oldObj.search_device_byuser() # sync_report_user(devs, [oldObj]) elif get_option("POS_ID"): iscard[0].cardstatus = CARD_STOP iscard[0].save(force_update=True) # if get_option("IACCESS"): # oldObj=iscard[0].UserID # if oldObj.check_accprivilege(): # devs=oldObj.search_accdev_byuser() # sync_report_user(devs,[oldObj]) # if get_option("ATT"): # oldObj=iscard[0].UserID # devs=oldObj.search_device_byuser() # sync_report_user(devs, [oldObj]) except: import traceback traceback.print_exc()
def DataPostCheck(sender, **kwargs): oldObj = kwargs['oldObj'] newObj = kwargs['newObj'] request = sender from mysite.pos.pos_constant import TIMEOUT if isinstance(newObj, ICcard): iskey="ICcard_%s" %newObj.pk cache.set(iskey,newObj,TIMEOUT) key1="use_mechine_"+str(newObj.pk) key2="posmeal_"+str(newObj.pk) use_device=newObj.use_mechine.all() cache.set(key1,list(use_device),TIMEOUT) use_meal=newObj.posmeal.all() cache.set(key2,list(use_meal),TIMEOUT) if oldObj and oldObj.use_date <> newObj.use_date: get_isscard_cache(newObj) if get_option("POS_IC"): from mysite.iclock.models.dev_comm_operate import update_pos_device_info dev=Device.objects.filter(device_type=DEVICE_POS_SERVER) if dev: update_pos_device_info(dev,[newObj],"CARDTYPE")#卡类资料
def save(self, *args, **kwargs): from mysite.pos.pos_constant import TIMEOUT if self.pk is not None: self.endtime = self.endtime.replace(second=59) super(Meal, self).save() cacheobj = Meal.objects.all().filter(available=1) cache.set("Meal", list(cacheobj), TIMEOUT) from mysite.personnel.models.model_iccard import ICcard objICcard = ICcard.objects.all() if objICcard: for obj in objICcard: key = "posmeal_" + str(obj.pk) mealcache = obj.posmeal.get_query_set() cache.set(key, list(mealcache), TIMEOUT) if get_option("POS_IC"): from mysite.iclock.models.dev_comm_operate import update_pos_device_info, delete_pos_device_info from mysite.iclock.models.model_device import DEVICE_POS_SERVER, Device dev = Device.objects.filter(device_type=DEVICE_POS_SERVER) if dev: if self.available == 1: update_pos_device_info(dev, [self], "MEALTYPE") else: delete_pos_device_info(dev, [self], "MEALTYPE")
def funIssueAddCardSave(request): from mysite.pos.models import CarCashSZ, CarCashType from mysite.personnel.models.model_emp import Employee from django.core.cache import cache from mysite.pos.pos_constant import TIMEOUT from mysite.iclock.models.dev_comm_operate import update_pos_device_info from mysite.iclock.models.model_device import Device, DEVICE_POS_SERVER from mysite.personnel.models.model_issuecard import IssueCard, CARD_VALID, PRIVAGE_CARD, POS_CARD, CARD_STOP, CARD_OVERDUE obj = request.POST request.session.save() try: if obj.has_key("UserID"): user_id = obj['UserID'] emp = Employee.objects.get(id=user_id) else: user_pin = obj['user_pin'] emp = Employee.objects.get(PIN=user_pin) card = int(obj['cardno']) money = Decimal(obj['blance']) card_serial_no = obj['card_serial_no'] operate_type = obj['operate_type'] sys_card_no = obj['sys_card_no'] type = obj['type'] card_cost = obj['card_cost'] mng_cost = obj['mng_cost'] card_privage = obj['card_privage'] pwd = obj['Password'] newblance = money if operate_type == '12': #换卡 newblance = 0 from mysite.pos.models import ReplenishCard old_sys_card_no = obj['old_sys_card_no'] ReplenishCard(user=emp, oldcardno=old_sys_card_no, newcardno=sys_card_no, blance=0).save() objcard = IssueCard.objects.get(sys_card_no=old_sys_card_no) objcard.cardstatus = CARD_STOP objcard.save() IssueCard(UserID=emp, cardno=card, sys_card_no=sys_card_no, cardstatus=CARD_VALID, card_privage=POS_CARD, card_cost=card_cost, mng_cost=mng_cost, issuedate=datetime.now().date(), type_id=type, blance=0, Password=pwd, card_serial_num=card_serial_no).save() # cache.set("IC_Card_Count",sys_card_no,TIMEOUT) dev = Device.objects.filter(device_type=DEVICE_POS_SERVER) update_pos_device_info(dev, [objcard], "USERINFO") #下发原卡为黑名单 new_objcard = IssueCard.objects.get(sys_card_no=sys_card_no) update_pos_device_info(dev, [new_objcard], "USERINFO") #下发白名单卡 else: #发卡 obj = IssueCard.objects.filter( UserID=emp, cardstatus__in=[CARD_OVERDUE, CARD_VALID], card_privage=POS_CARD, sys_card_no__isnull=True) if obj: obj[0].type_id = type obj[0].blance = money obj[0].Password = pwd obj[0].sys_card_no = sys_card_no obj[0].cardno = card obj[0].card_cost = card_cost obj[0].mng_cost = mng_cost obj[0].card_serial_num = 1 obj[0].issuedate = datetime.now().date() obj[0].create_time = datetime.now() obj[0].save(force_update=True) # cache.set("IC_Card_Count",sys_card_no,TIMEOUT) else: IssueCard(UserID=emp, cardno=card, sys_card_no=sys_card_no, cardstatus=CARD_VALID, card_privage=card_privage, card_cost=card_cost, mng_cost=mng_cost, issuedate=datetime.now().date(), type_id=type, blance=money, Password=pwd, card_serial_num=1).save() # cache.set("IC_Card_Count",sys_card_no,TIMEOUT) objcard = IssueCard.objects.get(sys_card_no=sys_card_no) dev = Device.objects.filter(device_type=DEVICE_POS_SERVER) update_pos_device_info(dev, [objcard], "USERINFO") #下发白名单卡 if card_privage == POS_CARD: # blance_valid(type,newblance,emp)#验证余额 CarCashSZ( user=emp, card=card, checktime=datetime.now(), type_id=7, #cost type 发卡 cardserial=card_serial_no, money=card_cost, sys_card_no=sys_card_no, hide_column=7, blance=newblance, log_flag=2).save() if operate_type <> '12' and money > 0: #换卡 CarCashSZ( user=emp, card=card, sys_card_no=sys_card_no, checktime=datetime.now(), cardserial=card_serial_no, type_id=1, #cost type发卡的时候充值 money=money, hide_column=1, blance=newblance, log_flag=2).save() CarCashSZ( user=emp, card=card, sys_card_no=sys_card_no, checktime=datetime.now(), type_id=11, #cost type 管理费 cardserial=card_serial_no, money=mng_cost, hide_column=11, blance=newblance, log_flag=2).save() return getJSResponse("result=OK") except: import traceback traceback.print_exc() cache.delete("IC_Card_Count") return getJSResponse("result=FAIL")
def action(self): if self.object.is_pass == 0: from mysite.personnel.models.model_issuecard import IssueCard, CARD_VALID, CARD_OVERDUE from mysite.iclock.models.model_device import Device, DEVICE_POS_SERVER try: if get_option("POS_ID"): key = "IssueCard_%s" % self.object.user.Card iscarobj = get_issuecard(key, IssueCard) # iscarobj = IssueCard.objects.get(cardno=self.object.user.Card,cardstatus__in = [CARD_OVERDUE,CARD_VALID]) else: from mysite.personnel.models.model_issuecard import IssueCard, CARD_VALID, CARD_OVERDUE iscarobj = IssueCard.objects.get( sys_card_no=self.object.sys_card_no, cardstatus__in=[CARD_OVERDUE, CARD_VALID]) except: iscarobj = None try: if iscarobj: now = datetime.datetime.now().date() dev = [] valid_date = self.object.valid_date if get_option("POS_IC"): batch = self.object.batch allowance_list = Allowance.objects.filter( sys_card_no=self.object.sys_card_no, batch__lt=batch, is_pass=0) #获取小余当前记录的批次的没有审核的补贴记录 if allowance_list: raise Exception( _(u"编号%s人员存在小于当前补贴批次号的未审核的补贴记录,请先审核小批次的记录!" ) % self.object.user) if get_option("POS_IC") and now > valid_date: raise Exception( _(u"编号%s人员补贴记录已超过补贴有效期") % self.object.user) if iscarobj.cardstatus != CARD_VALID: raise Exception( _(u"编号%s卡已挂失或过期,无法补贴") % self.object.user) if get_option("POS_IC"): dev = Device.objects.filter( device_type=DEVICE_POS_SERVER, device_use_type=2) #查找补贴机 if not dev: raise Exception(_(u"当前系统,没有补贴设备,操作失败")) newblan = iscarobj.blance + self.object.money if iscarobj.type is not None: from mysite.personnel.models.model_iccard import ICcard iccardobj = ICcard.objects.get(pk=iscarobj.type_id) lessmoney = iccardobj.less_money #卡类最小余额 maxmoney = iccardobj.max_money #卡类最大余额 if lessmoney > newblan and lessmoney > 0: raise Exception( _(u"人员编号%s超出卡类最小余额") % self.object.user) if newblan > maxmoney and maxmoney > 0: raise Exception( _(u"人员编号%s超出卡类最大余额") % self.object.user) if maxmoney == 0 and newblan > 10000: raise Exception( _(u"人员编号%s超出系统允许最大余额") % self.object.user) self.object.is_pass = 1 self.object.pass_name = unicode(self.request.user) self.object.save() if get_option("POS_ID"): from mysite.pos.models.model_carcashsz import CarCashSZ from mysite.pos.models.model_carcashtype import CarCashType newblan = iscarobj.blance + self.object.money CarCashSZ( user=self.object.user, card=iscarobj.cardno, checktime=datetime.datetime.now(), type=CarCashType.objects.get(id=2), #消费类型 money=self.object.money, hide_column=2, blance=newblan, ).save() iscarobj.blance = newblan iscarobj.save() else: from mysite.iclock.models.dev_comm_operate import update_pos_device_info if dev: update_pos_device_info(dev, [self.object], "SUBSIDYLOG") else: raise Exception(_(u"编号%s人员没有有效的卡号") % self.object.user) except Exception, e: # raise Exception(_(u"审核失败")) import traceback traceback.print_exc() raise e