Exemple #1
0
 def create(self, shop_info, result_mapping):
     shop_qs = Shop.query().filter(channel = shop_info.channel, \
                                 name = shop_info.name)
     if shop_qs.count():
         shop = shop_qs[0]
     else:
         shop = Shop.create(**shop_info)
     return shop
Exemple #2
0
    def generate_date(self, data_list):
        shop_list = []
        for dic_data in data_list:
            shop = Shop.get_shop_buyname(name=dic_data["name"])
            if shop is None:

                shop_list.append(Shop(channel = self.get_channel(dic_data["channle_name"]), name = dic_data["name"], freight = 900, \
                                      single_repair_money = int(dic_data["remoney"] * 100), single_point_money = int(dic_data["bucmoney"] * 100), \
                                      is_distribution = self.get_is_distribution(dic_data["isdistribution"]), update_time = dic_data["modify_date"], \
                                      create_time = dic_data["create_date"]))

        return shop_list
Exemple #3
0
    def get_shop(self, shop_name, shopname, terminal_code):
        shop = None
        shop_name = shop_name
        if not shop_name:
            shop_name = shopname

        if shop_name:
            shop = Shop.get_shop_buyname(shop_name)
            if shop is None:
                shop = Shop.create(name = shop_name, update_time = self._modify_date, create_time = self._create_date)
        else:
            shop = Shop.get_shop_buyname("系统店铺")
            RecordError.create(remark = "缺少店铺:{c}".format(c = terminal_code))
        return shop
Exemple #4
0
 def calc(self):
     if not hasattr(self, '_enume'):
         from model.store.model_shop import Shop
         self._enume = []
         for shop in Shop.query():
             self._enume.append(shop)
     return random.choice(self._enume)
Exemple #5
0
    def is_name_exist(cls, name, shop=None):
        """判断渠道名称是否存在"""

        shop_qs = Shop.search(name=name)

        if shop is not None:
            shop_qs = shop_qs.filter(~Q(id=shop.id))

        if shop_qs.count() > 0:
            raise BusinessError("该名称已存在")
        return True
Exemple #6
0
    def search(cls, current_page, **search_info):
        """查询店铺列表"""
        if "channel_id" in search_info:
            channel = ChannelServer.get(search_info["channel_id"])
            search_info.update({"channel": channel})

        shop_qs = Shop.query(**search_info)
        if "name" in search_info:
            keyword = search_info.pop('name')
            shop_qs = shop_qs.filter(Q(name__contains = keyword) \
                        | Q(channel__name__contains = keyword))

        shop_qs = shop_qs.order_by("-create_time")
        return Splitor(current_page, shop_qs)
Exemple #7
0
    def check_data_integrity(self, buyinfo):
        if not buyinfo.device_code:
            self._error_msg = "缺少设备编码"
            return False
        if not buyinfo.order_sn:
            self._error_msg = "缺少订单编号"
            return False,
        if not buyinfo.shop_name:
            self._error_msg = "缺少店铺名称"
            return False
        if not buyinfo.buy_name:
            self._error_msg = "缺少购买人姓名"
            return False
        if not buyinfo.buy_phone:
            self._error_msg = "缺少购买人联系方式"
            return False
        if not buyinfo.goods_sn:
            self._error_msg = "缺少商品编号"
            return False
        if not buyinfo.remark:
            self._error_msg = "缺少备注信息"
            return False

        check_repeat = self.skip_repeat(buyinfo.device_code)
        if not check_repeat:
            return False

        check_remark = self.analysis_remark(buyinfo.remark)
        if not check_remark:
            return False

        shop = Shop.get_shop_buyname(buyinfo.shop_name)
        if shop is None:
            self._error_msg = "该店铺系统不存在,请通知相关人员进行添加"
        else:
            self._shop = shop

        return True
Exemple #8
0
 def match(cls, keyword, size=5):
     """匹配店铺列表"""
     return Shop.query(name=keyword).order_by('-create_time')[:size]
Exemple #9
0
    def get_byname(cls, name):
        """根据名称查询店铺"""

        return Shop.get_shop_buyname(name)
Exemple #10
0
    def search_all(cls, **search_info):
        """查询所有店铺列表"""

        return Shop.query(**search_info).order_by("-create_time")
Exemple #11
0
 def get(cls, shop_id):
     """获取店铺详情"""
     shop = Shop.get_byid(shop_id)
     if shop is None:
         raise BusinessError("店铺不存在")
     return shop
Exemple #12
0
 def generate(cls, **attr):
     """创建店铺"""
     Shop.create(**attr)
Exemple #13
0
 def get_shop(self, shop_name):
     return Shop.get_shop_buyname(name=shop_name)