Exemplo n.º 1
0
    def get_order_abo(self):
        args = request.args.to_dict()
        if "token" not in args or "OMid" not in args:
            return PARAMS_MISS

        print(self.title.format("args"))
        print(args)
        print(self.title.format("args"))
        Oid = args["OMid"]
        token = args.get("token")
        Uid = token_to_usid(token)
        order_abo = get_model_return_dict(
            self.sorders.get_order_abo_by_oid(Oid))
        print(self.title.format("order_abo"))
        print(order_abo)
        print(self.title.format("order_abo"))
        order_abo["OMtime"] = timeformate.get_web_time_str(
            order_abo.get("OMtime"))
        order_abo["is_index"] = 701
        if self.checktime() or order_abo.get("OMstatus") > 21 or order_abo.get(
                "OMstatus") == 0:
            order_abo["is_index"] = 702
        order_abo["OMstatus"] = self.get_status_name_by_status(
            order_abo.get("OMstatus"))
        order_abo["OMdate"] = timeformate.get_web_time_str(
            order_abo.get("OMdate"))

        users = get_model_return_dict(self.susers.get_uname_utel_by_uid(Uid))
        print(self.title.format("users"))
        print(users)
        print(self.title.format("users"))
        order_abo.update(users)
        order_items = get_model_return_list(
            self.sorders.get_order_item_by_oid(Oid))
        print(self.title.format("order_items"))
        print(order_items)
        print(self.title.format("order_items"))

        order_abo["Orderitems"] = order_items
        addabo = get_model_return_dict(
            self.sadd.get_addabo_by_addid(order_abo.get("AAid")))
        print(self.title.format("addabo"))
        print(addabo)
        print(self.title.format("addabo"))
        order_abo.update(addabo)
        for row in order_items:
            product = get_model_return_dict(
                self.sproduct.get_product_all_by_pid(row.get("PRid")))
            print(self.title.format("product"))
            print(product)
            print(self.title.format("product"))
            row.update(product)

        response_make_main_order = import_status("messages_get_item_ok", "OK")
        response_make_main_order["data"] = order_abo
        return response_make_main_order
Exemplo n.º 2
0
    def get_order_list(self):
        args = request.args.to_dict()
        if "token" not in args:
            return PARAMS_MISS

        print(self.title.format("args"))
        print(args)
        print(self.title.format("args"))

        token = args.get("token")
        Uid = token_to_usid(token)
        # 暂时不处理过滤
        order_list = get_model_return_list(
            self.sorders.get_all_order_by_uid(Uid))
        print(self.title.format("order_list"))
        print(order_list)
        print(self.title.format("order_list"))

        data = []
        if order_list:
            for row in order_list:
                status = row.get("OMstatus")
                row["OMtime"] = timeformate.get_web_time_str(
                    str(row.get("OMtime")))
                if status > 21 or status == 0 or self.checktime():
                    row["is_index"] = 702
                else:
                    row["is_index"] = 701
                row["OMstatus"] = self.get_status_name_by_status(status)
                row["Orderitems"] = []
                order_items = get_model_return_list(
                    self.sorders.get_order_item_by_oid(row.get("OMid")))
                print(self.title.format("order_items"))
                print(order_items)
                print(self.title.format("order_items"))
                for raw in order_items:
                    Pid = raw.get("PRid")
                    PRnumber = raw.get("PRnumber")
                    product = get_model_return_dict(
                        self.sproduct.get_product_all_by_pid(Pid))
                    product["PRid"] = Pid
                    product["PRnumber"] = PRnumber
                    print(self.title.format("product"))
                    print(product)
                    print(self.title.format("product"))
                    row["Orderitems"].append(product)
                data.append(row)

        response_make_main_order = import_status("messages_get_item_ok", "OK")
        from LoveBreakfast.config.urlconfig import product_url_list
        response_make_main_order["sowing"] = product_url_list
        response_make_main_order["data"] = data

        return response_make_main_order
Exemplo n.º 3
0
    def get_host(self):
        args = request.args.to_dict()
        print(self.title.format('args'))
        print(args)
        print(self.title.format('args'))

        if "VSid" not in args:
            return PARAMS_MISS
        vsid = args.get("VSid")
        votes = todict(self.svotes.get_votes(vsid))
        print(self.title.format('votes'))
        print(votes)
        print(self.title.format('votes'))

        # votes.pop("VSstartTime")
        # votes.pop("VSendTime")
        time_now = get_db_time_str()
        time_status = "时间没问题"
        time_status_code = 200
        if votes.get("VSstartTime") and time_now < votes.get("VSstartTime"):
            time_status_code = 405601
            time_status = "答题时间未到"
        if votes.get("VSendTime") and time_now > votes.get("VSendTime"):
            time_status_code = 405602
            time_status = "答题时间已超"

        votes["VSstartTime"] = get_web_time_str(votes.get("VSstartTime"),
                                                format_forweb_no_HMS)

        votes["VSendTime"] = get_web_time_str(votes.get("VSendTime"),
                                              format_forweb_no_HMS)
        votes["VStime"] = "2018-08-10"
        votes["TimeStatus"] = time_status
        votes["TimeStatusCode"] = time_status_code
        response = import_status("SUCCESS_MESSAGE_GET_VOTE", "OK")
        response["data"] = votes
        return response
Exemplo n.º 4
0
    def get_cart_pkg(self):
        args = request.args.to_dict()
        if "token" not in args:
            return PARAMS_MISS
        token = args.get("token")
        uid = token_to_usid(token)

        try:
            cart_list = []
            cart_pkgs = self.scoupons.get_cardpackage_by_uid(uid)
            print(self.title.format("cart_pkgs"))
            print(cart_pkgs)
            print(self.title.format("cart_pkgs"))
            for cart_pkg in cart_pkgs:
                if cart_pkg.CAstatus == 2:
                    continue
                coupon = self.scoupons.get_coupons_by_couid(cart_pkg.COid)
                print(self.title.format("coupon"))
                print(coupon)
                print(self.title.format("coupon"))

                cart = {}
                COtype = coupon.COtype
                print(self.title.format("COtype"))
                print(COtype)
                print(self.title.format("COtype"))
                cart["CAid"] = cart_pkg.CAid
                cart["COid"] = cart_pkg.COid
                if COtype == 801:
                    COfilter = coupon.COfilter
                    cart["COuse"] = "满{0}元可用".format(COfilter)
                    COcut = coupon.COamount
                    cart["COcut"] = str(COcut) + "元"
                    COstart = coupon.COstart
                    cart["COstart"] = get_web_time_str(COstart, format_forweb_no_HMS)
                    COend = coupon.COend
                    cart["COend"] = get_web_time_str(COend, format_forweb_no_HMS)
                elif COtype == 802:
                    COfilter = coupon.COfilter
                    cart["COuse"] = "满{0}元可用".format(COfilter)
                    cart["COcut"] = str(coupon.COdiscount * 10) + "折"
                    COstart = coupon.COstart
                    cart["COstart"] = get_web_time_str(COstart, format_forweb_no_HMS)
                    COend = coupon.COend
                    cart["COend"] = get_web_time_str(COend, format_forweb_no_HMS)
                elif COtype == 803:
                    CObrand = coupon.CObrand.encode("utf8")
                    cart["COuse"] = "限{0}商品可用".format(str(CObrand))
                    cart["COcut"] = str(coupon.COamount) + "元"
                    COstart = coupon.COstart
                    cart["COstart"] = get_web_time_str(COstart, format_forweb_no_HMS)
                    COend = coupon.COend
                    cart["COend"] = get_web_time_str(COend, format_forweb_no_HMS)
                elif COtype == 804:
                    cart["COuse"] = "无限制"
                    cart["COcut"] = str(coupon.COamount) + "元"
                    COstart = coupon.COstart
                    cart["COstart"] = get_web_time_str(COstart, format_forweb_no_HMS)
                    COend = coupon.COend
                    cart["COend"] = get_web_time_str(COend, format_forweb_no_HMS)
                else:
                    return
                cart_list.append(cart)
        except Exception as e:
            print("ERROR: " + e.message)
            return SYSTEM_ERROR
        result = import_status("messages_get_carpkg_success", "OK")
        result["data"] = cart_list
        return result