Beispiel #1
0
    def exec_convet(self, import_mobile_phone):

        check_phone = self.skip_mobile_phone(import_mobile_phone.phone_number)

        if not check_phone:
            return False, self._error_msg

        staff = self.get_staff(import_mobile_phone.name)

        if self._mobile_phone is None:
            Mobilephone.create(staff = staff, name = import_mobile_phone.name, \
                              identity = staff.identity if staff is not None else import_mobile_phone.identity, \
                              phone_number = import_mobile_phone.phone_number, \
                              card_password = import_mobile_phone.card_password, operator = import_mobile_phone.operator, \
                              rent = import_mobile_phone.rent, status = self.get_phone_status(import_mobile_phone.phone_status), \
                              phone_remark = self.get_remark(import_mobile_phone.phone_remark, import_mobile_phone.department) , \
                              )
        else:
            self._mobile_phone.update(staff = staff, name = import_mobile_phone.name, \
                                identity = staff.identity if staff is not None else import_mobile_phone.identity, \
                                phone_number = import_mobile_phone.phone_number, \
                                card_password = import_mobile_phone.card_password, operator = import_mobile_phone.operator, \
                                rent = import_mobile_phone.rent, status = self.get_phone_status(import_mobile_phone.phone_status), \
                                phone_remark = self.get_remark(import_mobile_phone.phone_remark, import_mobile_phone.department) , \
                                )

        return True, ""
Beispiel #2
0
 def create(self, mobilephone_info, result_mapping):
     mobilephone_qs = Mobilephone.query().filter(
         phone_number=mobilephone_info.phone_number)
     if mobilephone_qs.count():
         mobilephone = mobilephone_qs[0]
     else:
         mobilephone = Mobilephone.create(**mobilephone_info)
     return mobilephone
Beispiel #3
0
 def calc(self, has_none=False):
     if not hasattr(self, '_enume'):
         from model.store.model_mobilephone import Mobilephone
         self._enume = [None] if has_none else []
         for staff in Mobilephone.query().filter(id__gt=1):
             self._enume.append(staff)
     return random.choice(self._enume)
Beispiel #4
0
    def get(cls, mobile_phone_id):
        """查询手机信息"""
        mobilephone = Mobilephone.get_byid(mobile_phone_id)
        if mobilephone is None:
            raise BusinessError("此手机不存在")

        return mobilephone
Beispiel #5
0
    def generate(cls, **attrs):
        """添加手机"""
        mobilephone = Mobilephone.create(**attrs)
        if mobilephone is None:
            raise BusinessError("手机添加失败")

        return mobilephone
Beispiel #6
0
    def get_mobile_phone(self, phone_number):
        mobile_phone = None
        mobile_phone_qs = Mobilephone.query().filter(phone_number=phone_number)
        if mobile_phone_qs.count() > 0:
            mobile_phone = mobile_phone_qs[0]

        return mobile_phone
Beispiel #7
0
    def remove(cls, mobile_phone_id):
        """删除手机"""

        mobilephone = Mobilephone.get_byid(mobile_phone_id)
        if mobilephone is None:
            raise BusinessError("此手机不存在")

        mobilephone.delete()
        return True
Beispiel #8
0
    def skip_mobile_phone(self, phone_number):
        if not phone_number:
            self._error_msg = "缺少手机号"
            return False

        mobile_phone_qs = Mobilephone.query().filter(phone_number=phone_number)
        if mobile_phone_qs.count() > 0:
            self._mobile_phone = mobile_phone_qs[0]

        return True
Beispiel #9
0
    def is_phone_exist(cls, phone, mobilephone = None):
        """判断手机号是否存在"""

        mobilephone_qs = Mobilephone.query().filter(phone_number = phone)
        if mobilephone is not None:
            mobilephone_qs = mobilephone_qs.filter(~Q(id = mobilephone.id))

        if mobilephone_qs.count() > 0:
            raise BusinessError("该手机号已存在")

        return True
Beispiel #10
0
    def exec_convet(self, mobile_devices):
        check_mobile_devices = self.skip_mobile_devices(
            mobile_devices.mobile_code)
        if check_mobile_devices:
            devices = MobileDevices.create(code = mobile_devices.mobile_code, brand = mobile_devices.brand, \
                                                  model = mobile_devices.model, price = mobile_devices.price, \
                                                  status = self.get_devices_status(mobile_devices.mobile_status), \
                                                  remark = self.get_mobile_devices_remark(mobile_devices.mobile_remark, mobile_devices.department), \
                                                  imei = mobile_devices.imei, \
                                                  )
            mobile_phone_staff = self.get_staff(mobile_devices.real_name)

            mobile_phone = self.get_mobile_phone(mobile_devices.phone_number)
            if mobile_phone is None:
                Mobilephone.create(devices = devices, staff = mobile_phone_staff, name = mobile_devices.real_name, \
                                   identity = mobile_phone_staff.identity if mobile_phone_staff else "", wechat_nick = mobile_devices.wechat_nick, \
                                   wechat_number = mobile_devices.wechat_number, wechat_password = mobile_devices.wechat_password, \
                                   pay_password = mobile_devices.pay_password, wechat_remark = mobile_devices.wechat_remark, \
                                   phone_number = mobile_devices.phone_number, operator = mobile_devices.operator, \
                                   phone_remark = mobile_devices.phone_remark, flow_card_number = mobile_devices.flow_card_number, \
                                   )
            else:
                mobile_phone.update(devices = devices, staff = mobile_phone_staff, name = mobile_devices.real_name, \
                                   identity = mobile_phone_staff.identity if mobile_phone_staff else "", wechat_nick = mobile_devices.wechat_nick, \
                                   wechat_number = mobile_devices.wechat_number, wechat_password = mobile_devices.wechat_password, \
                                   pay_password = mobile_devices.pay_password, wechat_remark = mobile_devices.wechat_remark, \
                                   phone_number = mobile_devices.phone_number, operator = mobile_devices.operator, \
                                   phone_remark = mobile_devices.phone_remark, flow_card_number = mobile_devices.flow_card_number, \
                                   )

            mobile_maintain_staff = self.get_staff(mobile_devices.group_member)
            if mobile_maintain_staff is not None:
                MobileMaintain.create(devices = devices, staff = mobile_maintain_staff, \
                                      remark = self.get_mobile_maintain_remark(mobile_devices.group_leader))
            return True, ""

        return False, self._error_msg
Beispiel #11
0
 def search_qs(cls, **search_info):
     """查询手机列表"""
     return Mobilephone.query(**search_info)