예제 #1
0
def check_order_store_quantity(store_id, oid):
    result = 0
    items = OrderItem.select().where(OrderItem.order == oid)
    r = 0
    if store_id:
        for i in items:
            if i.product.is_store == 1:  # and i.product.store.id == int(store_id)
                r += 1
            else:
                r += check_store_product_quantity(store_id,
                                                  i.product_standard.id)
        if r == items.count():
            result = 1
    else:
        list = []
        order = Order.get(Order.id == oid)
        store = Store.select().where(Store.status == 1)
        sid = 0
        for s in store:
            ss = getDistanceAS(order.take_address.replace(' ', ''), s.id)
            if ss['flag'] == 1:
                list.append(float(ss['data']))
                if float(ss['data']) < setting.PeiSongDistance:
                    sid = s.id
        for i in items:
            if i.product.is_store == 1 and i.product.store.id == sid:
                r += 1
            else:
                r += check_store_product_quantity(sid, i.product_standard.id)
        if r == items.count():
            result = 1
    return result
예제 #2
0
파일: store.py 프로젝트: scaperow/carive
    def post(self):
        username = self.get_argument("username", None)
        password = self.get_argument("password", None)

        if username and password:
            try:
                user = AdminUser.get(AdminUser.username == username)
                if user.check_password(password):
                    if user.isactive == 1:
                        if not user.store:
                            storeid = 0
                        else:
                            storeid = user.store
                        if not user.front_user:
                            frontuserid = 0
                        else:
                            frontuserid = user.front_user
                        qstore = Store.select().where(Store.id == storeid)
                        qfront_user = User.select().where(
                            User.id == frontuserid)
                        if qstore.count() > 0 and qfront_user.count() > 0:
                            user.updatesignin()
                            self.session['store'] = user
                            self.session.save()
                            self.redirect("/store/index")
                            return
                        else:
                            self.flash("此帐户未关联经销商或经销商未绑定前台用户。")
                    else:
                        self.flash("此账户被禁止登录,请联系管理员。")
                else:
                    self.flash("密码错误")
            except Exception, e:
                print e
                self.flash("此用户不存在")
예제 #3
0
파일: store.py 프로젝트: scaperow/carive
 def post(self):
     result = {"flag": 0, "msg": "", "data": ""}
     try:
         args = simplejson.loads(self.request.body)
         username = args["username"]
         password = args["password"]
         if username and password:
             quser = AdminUser.select().where(
                 AdminUser.username == username)
             if quser.count() > 0 and quser[0].check_password(password):
                 user = quser[0]
                 if user.isactive == 1:
                     if self.vrole("J", user.roles):
                         if not user.store:
                             storeid = 0
                         else:
                             storeid = user.store
                         if not user.front_user:
                             frontuserid = 0
                         else:
                             frontuserid = user.front_user
                         qstore = Store.select().where(Store.id == storeid)
                         qfront_user = User.select().where(
                             User.id == frontuserid)
                         if qstore.count() > 0 and qfront_user.count() > 0:
                             user.updatesignin()
                             result["flag"] = 1
                             result["data"] = {
                                 'adminid': user.id,
                                 'storeid': qstore[0].id,
                                 'front_user': user.front_user,
                                 'storename': qstore[0].name,
                             }
                         else:
                             result["flag"] = 0
                             result["msg"] = "此帐户未关联经销商或经销商未绑定前台用户。"
                     else:
                         result["flag"] = 0
                         result["msg"] = "此账户没有经销商的登录权限。"
                 else:
                     result["flag"] = 0
                     result["msg"] = "此账户被禁止登录,请联系管理员。"
             else:
                 if quser.count() > 0:
                     result["flag"] = 0
                     result["msg"] = "密码错误。"
                 else:
                     result["flag"] = 0
                     result["msg"] = "此用户不存在"
         else:
             result["flag"] = 0
             result["msg"] = "请输入用户名或者密码"
     except Exception, e:
         result["flag"] = 0
         result["msg"] = e
예제 #4
0
파일: map.py 프로젝트: scaperow/carive
def getMinDistanceStore(address):
    result = {"flag": 0, "msg": "", "data": ""}
    try:
        if address:

            if address.count('枫林绿洲') > 0:
                address = address.replace('小区', '')
            qstore = Store.select().where((Store.status == 1)
                                          & (Store.storetype == 0))
            point = getPointByAddress(address)
            minDistance = 10000
            minStore = None
            for store in qstore:
                minD = getDistance(point["lng"], point["lat"], float(store.x),
                                   float(store.y))
                if minD < minDistance:
                    minDistance = minD
                    minStore = store
            if minDistance > 0 and minStore and minDistance < minStore.psdistance:
                result["flag"] = 1
                result["data"] = {
                    "id": minStore.id,
                    "name": minStore.name,
                    "distance": minDistance,
                    "byprice": minStore.byprice,
                    "freight": minStore.freight,
                }
            else:
                result["flag"] = 0
                result["msg"] = "在该地址附近未找到可以配送的经销商!"
                result["data"] = ""
        else:
            result["flag"] = 0
            result["msg"] = "地址不能为空!"

    except Exception, ex:
        result["flag"] = 0
        result["msg"] = "地址或者经销商信息错误!"
예제 #5
0
파일: offline.py 프로젝트: scaperow/carive
 def get(self):
     result = []
     q = Store.select().where(Store.status == 1)
     for n in q:
         result.append({'ID': n.id, 'Name': n.name})
     self.write(simplejson.dumps(result))
예제 #6
0
 def __init__(self):
     self.all_stores = Store.select().where(Store.active == 1)