Esempio n. 1
0
 def generate_date(self, data_list):
     for dic_data in data_list:
         if self.skip_register(dic_data["terminal_code"]):
             equipment = Equipment.create(code=dic_data["terminal_code"])
             EquipmentRegister.create(equipment = equipment, name = dic_data["name"], code = dic_data["customer_code"], \
                                      phone = dic_data["register_id"], agent_name = dic_data["agent_name"], \
                                      register_time = dic_data["customer_createtime"], \
                                      bind_time = dic_data["customer_bindtime"], \
                                      update_time = dic_data["modify_date"], create_time = dic_data["create_date"])
             ServiceItem.create(equipment=equipment,
                                dsinfo_status="yellow",
                                rebate_status=self.get_rebate_status(
                                    dic_data["rebate_color"]),
                                sn_status=dic_data["sn_color"])
Esempio n. 2
0
    def skip_repeat(self, register):
        equipment_register_qs = EquipmentRegister.query().filter(code = register.code)
        if equipment_register_qs.count() > 0:
            self._error_msg = "客户编码重复"
            return False

        return True
Esempio n. 3
0
    def skip_repeat(self, code, month):
        equipment_register_qs = EquipmentRegister.query().filter(code = code)
        if equipment_register_qs.count() == 0:
            self._error_msg = "客户id不存在"
            return False

        self._equipment_register = equipment_register_qs[0]
        equipment_rebate_qs = EquipmentRebate.query(code = self._equipment_register, month = month)
        if equipment_rebate_qs.count() > 0:
            self._error_msg = "数据重复"
            return False


        return True
Esempio n. 4
0
    def skip_repeat(self, code, transaction_time):
        equipment_register_qs = EquipmentRegister.query().filter(code=code)
        if equipment_register_qs.count() == 0:
            self._error_msg = "客户编码不存在"
            return False

        self._equipment_register = equipment_register_qs[0]
        equipment_transaction_qs = EquipmentTransaction.query(code = self._equipment_register, \
                                                              transaction_time = transaction_time)
        if equipment_transaction_qs.count() > 0:
            self._error_msg = "数据重复"
            return False

        return True
Esempio n. 5
0
    def exec_convet(self, register):
        check_repeat = self.skip_repeat(register)
        if check_repeat:
            equipment_qs = Equipment.query().filter(code = register.device_code)
            if equipment_qs.count() > 0:
                equipment = equipment_qs[0]
                equipment_register = EquipmentRegister.create(equipment = equipment, agent_name = register.agent_name, \
                                         code = register.code, phone = register.phone, name = register.name, \
                                         register_time = register.register_time, bind_time = register.bind_time, \
                                         device_code = register.device_code)
                service_item = ServiceItem.query(equipment = equipment)[0]
                service_item.update(dsinfo_status = EquipmentStatusType.YELLOW)
                return True, ""
            else:
                self._error_msg = "此设备SN码系统不存在"

        return False, self._error_msg
Esempio n. 6
0
    def generate_date(self, data_list):
        rebate_list = []
        import_rebate_list = []
        customer_ids = []
        customer_ids = [dic_data["customer_id"] for dic_data in data_list]

        register_mapping = {equipment_register.code:equipment_register for equipment_register in \
                          EquipmentRegister.search(code__in = customer_ids)}

        for dic_data in data_list:
            register = register_mapping.get(dic_data["customer_id"], None)
            if register is None:
                import_rebate_list.append(ImportCustomerRebate(agent_id = dic_data["agent_id"], agent_name = dic_data["agent_name"], code = dic_data["customer_id"], \
                                                       name = dic_data["name"], phone = dic_data["mobile"], \
                                                       register_code = dic_data["customer_id"], \
                                                       register_time = self.tranger_time(dic_data["regist_time"]) if dic_data["regist_time"] else None,
                                                       bind_time = self.tranger_time(dic_data["bind_time"]) if dic_data["bind_time"] else None, \
                                                       month = dic_data["month"], \
                                                       transaction_amount = int(dic_data["money"] * 100) if dic_data["money"] else 0, \
                                                       effective_amount = int(dic_data["effective_money"] * 100) if dic_data["effective_money"] else 0, \
                                                       accumulate_amount = int(dic_data["last_money"] * 100) if dic_data["last_money"] else 0, \
                                                       history_amount = int(dic_data["alllast_money"] * 100) if dic_data["alllast_money"] else 0, \
                                                       type = dic_data["type"], is_rebate = dic_data["is_rebate"], remark = dic_data["remarks"], \
                                                       update_time = dic_data["modify_date"], create_time = dic_data["create_date"], \
                                                       status = "failed", error_text = "客户编码无法匹配"))
            else:
                rebate_list.append(EquipmentRebate(agent_id = dic_data["agent_id"], agent_name = dic_data["agent_name"], code = register, \
                                                   name = dic_data["name"], phone = dic_data["mobile"], \
                                                   register_code = dic_data["customer_id"], \
                                                   register_time = self.tranger_time(dic_data["regist_time"]) if dic_data["regist_time"] else None,
                                                   bind_time = self.tranger_time(dic_data["bind_time"]) if dic_data["bind_time"] else None, \
                                                   month = dic_data["month"], \
                                                   transaction_amount = int(dic_data["money"] * 100) if dic_data["money"] else 0, \
                                                   effective_amount = int(dic_data["effective_money"] * 100) if dic_data["effective_money"] else 0, \
                                                   accumulate_amount = int(dic_data["last_money"] * 100) if dic_data["last_money"] else 0, \
                                                   history_amount = int(dic_data["alllast_money"] * 100) if dic_data["alllast_money"] else 0, \
                                                   type = dic_data["type"], is_rebate = dic_data["is_rebate"], remark = dic_data["remarks"], \
                                                   update_time = dic_data["modify_date"], create_time = dic_data["create_date"]))

        return rebate_list, import_rebate_list
Esempio n. 7
0
    def generate_date(self, data_list):
        transaction_list = []
        import_transaction_list = []
        customer_ids = []
        customer_ids = [dic_data["customer_id"] for dic_data in data_list]

        register_mapping = {equipment_register.code:equipment_register for equipment_register in \
                          EquipmentRegister.search(code__in = customer_ids)}

        for dic_data in data_list:
            register = register_mapping.get(dic_data["customer_id"], None)
            if register is None:
                import_transaction_list.append(ImportCustomerTransaction(agent_name = dic_data["username"], service_code = dic_data["service_id"], \
                                                         code = dic_data["customer_id"], phone = dic_data["mobile"], \
                                                         transaction_year = datetime.datetime(dic_data["transaction_date"].year, dic_data["transaction_date"].month, dic_data["transaction_date"].day) \
                                                         if dic_data["transaction_date"] else None, \
                                                         transaction_day = dic_data["transaction_date"], \
                                                         transaction_code = dic_data["transaction_id"], \
                                                         transaction_money = int(dic_data["total_money"] * 100) if dic_data["total_money"] else 0, \
                                                         fee = int(dic_data["total_brokerage"] * 100) if dic_data["total_brokerage"] else 0, \
                                                         rate = int(dic_data["rate"] * 100) if dic_data["rate"] else 0, \
                                                         other_fee = int(dic_data["other_brokerage"] * 100) if dic_data["other_brokerage"] else 0, \
                                                         transaction_status = dic_data["status"], \
                                                         update_time = dic_data["modify_date"], create_time = dic_data["create_date"], \
                                                         status = "failed", error_text = "客户编码无法匹配"))
            else:
                transaction_list.append(EquipmentTransaction(agent_name = dic_data["username"], service_code = dic_data["service_id"], \
                                                             code = register, phone = dic_data["mobile"], transaction_time = dic_data["transaction_date"], \
                                                             transaction_code = dic_data["transaction_id"], \
                                                             transaction_money = int(dic_data["total_money"] * 100) if dic_data["total_money"] else 0, \
                                                             fee = int(dic_data["total_brokerage"] * 100) if dic_data["total_brokerage"] else 0, \
                                                             rate = int(dic_data["rate"] * 100) if dic_data["rate"] else 0, \
                                                             other_fee = int(dic_data["other_brokerage"] * 100) if dic_data["other_brokerage"] else 0, \
                                                             transaction_status = dic_data["status"], \
                                                             update_time = dic_data["modify_date"], create_time = dic_data["create_date"], \
                                                             ))

        return transaction_list
Esempio n. 8
0
 def skip_register(self, customer_code):
     equipment_register_qs = EquipmentRegister.search(code=customer_code)
     if equipment_register_qs.count() == 0:
         return True
     return False