Esempio n. 1
0
    def new_meal(self):
        args = request.args.to_dict()
        print(self.title.format("args"))
        print(args)
        print(self.title.format("args"))
        if "token" not in args and "MSid" not in args:
            return PARAMS_MISS
        USid = token_to_usid(args["token"])
        MSid = args["MSid"]
        user = self.susers.get_user_by_usid(USid)
        if not user:
            return import_status("ERROR_NONE_USER", "GROUPMEAL_ERROR",
                                 "ERROR_NONE_USER")
        mess = self.smess.get_mess_by_msid(MSid)
        if not mess:
            return SYSTEM_ERROR
        # TODO 用户改为管理员
        data = request.data
        print(self.title.format("data"))
        print(data)
        print(self.title.format("data"))
        data = json.loads(data)

        meal_not_null_keys = ["MEname", "MEimage", "MEprice", "MEtype"]
        meal_null_keys = [
            "MEinfo", "MEdprice", "MEweight", "MEinventory", "MEprotein",
            "MEfat", "MEcarbohydrate", "MEcalorie", "MEinorganic", "MEcalcium",
            "MEphosphorus", "MEiron"
        ]

        for row in data.keys():
            if row not in meal_not_null_keys and row not in meal_null_keys:
                return PARAMS_REDUNDANCY

        data["MEvolume"] = 0
        data["MEfraction"] = 0
        data["MEstatus"] = 281
        data["MEtag"] = 296
        data["MSid"] = args["MSid"]
        data["MEid"] = str(uuid.uuid1())
        MEtype = data["MEtype"]
        data["MEtype"] = self.num_word_change(word=MEtype)

        print data
        new_meal = add_model("Meals", **data)
        print(self.title.format("new_meal"))
        print(new_meal)
        print(self.title.format("new_meal"))
        if not new_meal:
            return SYSTEM_ERROR

        return import_status("SUCCESS_ADD_MEAL", "OK")
Esempio n. 2
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)
        user = self.susers.get_user_by_usid(Uid)
        if not user:
            return SYSTEM_ERROR
        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["OMtime"])
        order_abo["is_index"] = 701
        if int(order_abo["OMstatus"]) >= 305 and int(
                order_abo["OMstatus"]) <= 310:
            order_abo["is_index"] = 702
        order_abo["OMstatus"] = self.status_num_change(
            num=order_abo["OMstatus"])
        # TODO 优惠券解析CPid

        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
        for row in order_items:
            product = get_model_return_dict(
                self.smeal.get_meal_by_meid(row["MEid"]))
            print(self.title.format("product"))
            print(product)
            print(self.title.format("product"))
            row.update(product)

        response_make_main_order = import_status("SUCCESS_GET_ORDER", "OK")
        response_make_main_order["data"] = order_abo
        return response_make_main_order
Esempio n. 3
0
    def update_first_user(self):
        args = request.args.to_dict()
        print(self.title.format("args"))
        print(args)
        print(self.title.format("args"))
        if "token" not in args:
            return PARAMS_MISS
        token = args.get("token")
        Uid = token_to_usid(token)
        is_user = self.susers.get_user_by_usid(Uid)
        print(self.title.format("is_user"))
        print(is_user)
        print(self.title.format("is_user"))
        if not is_user:
            return import_status("ERROR_MESSAGE_NONE_USER", "GROUPMEAL_ERROR", "ERROR_CODE_NONE_USER")

        data = request.data
        data = json.loads(data)
        print(self.title.format("data"))
        print(data)
        print(self.title.format("data"))

        if "USheight" not in data or "USweight" not in data or "USbirthday" not in data or "UScardno" not in data or "USworker" not in data:
            return PARAMS_MISS
        users = data
        # TODO 创建优惠券过程

        update_info = self.susers.update_users_by_uid(Uid, users)
        print(self.title.format("update_info"))
        print(update_info)
        print(self.title.format("update_info"))
        if not update_info:
            return SYSTEM_ERROR

        uslevel = self.susers.get_uslevel_by_usid(Uid)
        print(self.title.format("uslevel"))
        print(uslevel)
        print(self.title.format("uslevel"))
        if not uslevel:
            return SYSTEM_ERROR
        update_info = {
            "USlevel": uslevel + 1
        }
        update_uslevel = self.susers.update_users_by_uid(Uid, update_info)
        print(self.title.format("update_uslevel"))
        print(update_uslevel)
        print(self.title.format("update_uslevel"))
        if not update_uslevel:
            return SYSTEM_ERROR
        back_response = import_status("SUCCESS_MESSAGE_UPDATE_INFO", "OK")
        return back_response
Esempio n. 4
0
    def get_carts_by_uid(self):
        args = request.args.to_dict()
        print(self.title.format("args"))
        print(args)
        print(self.title.format("args"))
        if "token" not in args or "MSid" not in args:
            return PARAMS_MISS

        token = args.get("token")
        USid = token_to_usid(token)
        MSid = args["MSid"]
        is_user = self.susers.get_user_by_usid(USid)
        print(self.title.format("is_user"))
        print(is_user)
        print(self.title.format("is_user"))
        if not is_user:
            return import_status("ERROR_MESSAGE_NONE_USER", "GROUPMEAL_ERROR",
                                 "ERROR_CODE_NONE_USER")
        mess = self.smess.get_mess_by_msid(MSid)
        if not mess:
            return SYSTEM_ERROR
        cart_list = get_model_return_list(self.scart.get_carts_by_Uid(USid))
        print(self.title.format("cartlist"))
        print(cart_list)
        print(self.title.format("cartlist"))

        i = len(cart_list) - 1
        while i >= 0:
            MEid = cart_list[i]["MEid"]
            msid = self.smeal.get_msid_by_meid(MEid)
            print(self.title.format("msid"))
            print(msid)
            print(self.title.format("msid"))
            if msid != MSid:
                cart_list.remove(cart_list[i])
            else:
                meal = get_model_return_dict(self.smeal.get_meal_by_meid(MEid))
                print(self.title.format("meal"))
                print(meal)
                print(self.title.format("meal"))
                if not meal:
                    return SYSTEM_ERROR
                for key in meal.keys():
                    cart_list[i][key] = meal[key]
            i = i - 1

        back_response = import_status("SUCCESS_GET_MESSAGE", "OK")
        back_response["data"] = cart_list
        return back_response
Esempio n. 5
0
    def del_product(self):
        args = request.args.to_dict()
        print(self.title.format("args"))
        print(args)
        print(self.title.format("args"))
        if "token" not in args:
            return PARAMS_MISS
        data = json.loads(request.data)
        print(self.title.format("data"))
        print(data)
        print(self.title.format("data"))

        if "PRid" not in data:
            return PARAMS_MISS
        token = args.get("token")
        uid = token_to_usid(token)
        return self.del_cart(uid, data.get("PRid"))
Esempio n. 6
0
    def shelf_or_obtained(self):
        args = request.args.to_dict()
        print(self.title.format("args"))
        print(args)
        print(self.title.format("args"))
        if "token" not in args and "MEid" not in args:
            return PARAMS_MISS
        USid = token_to_usid(args["token"])
        user = self.susers.get_user_by_usid(USid)
        if not user:
            return import_status("ERROR_NONE_USER", "GROUPMEAL_ERROR",
                                 "ERROR_NONE_USER")
        # TODO 食堂的存在验证
        data = request.data
        print(self.title.format("data"))
        print(data)
        print(self.title.format("data"))
        data = json.loads(data)

        meal_not_null_keys = ["MEname", "MEimage", "MEprice", "MEtype"]
        meal_null_keys = [
            "MEinfo", "MEdprice", "MEweight", "MEinventory", "MEprotein",
            "MEfat", "MEcarbohydrate", "MEcalorie", "MEinorganic", "MEcalcium",
            "MEphosphorus", "MEiron"
        ]

        for row in meal_not_null_keys:
            if row not in data.keys():
                return PARAMS_MISS
        for row in data.keys():
            if row not in meal_not_null_keys and row not in meal_null_keys:
                return PARAMS_REDUNDANCY
        if "MEtag" in data:
            data["MEtag"] = self.tag_word_change(word=data["MEtag"])
        if "MEtype" in data:
            data["MEtype"] = self.num_word_change(word=data["MEtype"])
        MEid = args["MEid"]

        update_meal = self.smeals.update_meal(MEid, data)
        print(self.title.format("update_meal"))
        print(update_meal)
        print(self.title.format("update_meal"))
        if not update_meal:
            return SYSTEM_ERROR

        return import_status("SUCCESS_UPDATE_MEAL", "OK")
Esempio n. 7
0
    def update_info(self):
        args = request.args.to_dict()
        print(self.title.format("args"))
        print(args)
        print(self.title.format("args"))
        if "token" not in args:
            return PARAMS_MISS
        token = args.get("token")
        Uid = token_to_usid(token)
        is_user = self.susers.get_user_by_usid(Uid)
        print(self.title.format("is_user"))
        print(is_user)
        print(self.title.format("is_user"))
        if not is_user:
            return import_status("ERROR_MESSAGE_NONE_USER", "GROUPMEAL_ERROR", "ERROR_CODE_NONE_USER")

        data = request.data
        print(self.title.format("data"))
        print(data)
        print(self.title.format("data"))
        data = json.loads(data)

        users = {}
        if "USname" in data:
            users["USname"] = data["USname"]
        if "USsex" in data:
            Usex = data["USsex"].encode("utf8")
            print Usex
            if Usex == "男":
                Usex = 101
            else:
                Usex = 102
            users["USsex"] = Usex

        update_info = self.susers.update_users_by_uid(Uid, users)
        print(self.title.format("update_info"))
        print(update_info)
        print(self.title.format("update_info"))
        if not update_info:
            return SYSTEM_ERROR

        back_response = import_status("SUCCESS_MESSAGE_UPDATE_INFO", "OK")
        return back_response
Esempio n. 8
0
    def update_order_status(self):
        args = request.args.to_dict()
        data = request.data
        data = json.loads(data)

        if "token" not in args:
            return PARAMS_MISS
        if "OMstatus" not in data or "OMid" not in data:
            return PARAMS_MISS
        # 处理token过程,这里未设计
        token = args.get("token")
        USid = token_to_usid(token)
        user = self.susers.get_user_by_usid(USid)
        if not user:
            return SYSTEM_ERROR

        OMstatus = self.status_num_change(
            status=data["OMstatus"].encode("utf8"))
        if not OMstatus:
            return import_status("ERROR_UNKNOWN_OMSTATUS", "GROUPMEAL_ERROR",
                                 "ERROR_UNKNOWN_OMSTATUS")

        OMid = data["OMid"]
        usid = self.sorders.get_usid_by_omid(OMid)
        if USid != usid:
            return import_status("ERROR_NONE_PERMISSION", "GROUPMEAL_ERROR",
                                 "ERROR_NONE_PERMISSION")

        update_OMstatus = {}
        update_OMstatus["OMstatus"] = OMstatus

        response_update_order_status = self.sorders.update_order_by_oid(
            OMid, update_OMstatus)

        if not response_update_order_status:
            return SYSTEM_ERROR

        return import_status("SUCCESS_UPDATE_ORDER", "OK")
Esempio n. 9
0
    def get_first_user(self):
        args = request.args.to_dict()
        print(self.title.format("args"))
        print(args)
        print(self.title.format("args"))
        if "token" not in args:
            return PARAMS_MISS
        token = args.get("token")
        Uid = token_to_usid(token)

        users_info = get_model_return_dict(self.susers.get_first_user_by_usid(Uid))
        users_info["USbirthday"] = self.make_birthday(users_info["USbirthday"])
        users_info["USheight"] = str(users_info["USheight"]) + "cm"
        users_info["USweight"] = str(users_info["USweight"]) + "kg"
        print(self.title.format("users_info"))
        print(users_info)
        print(self.title.format("users_info"))
        if not users_info:
            return SYSTEM_ERROR

        back_response = import_status("SUCCESS_GET_MESSAGE", "OK")
        back_response["data"] = users_info
        return back_response
Esempio n. 10
0
    def get_review(self):
        args = request.args.to_dict()
        print(self.title.format("args"))
        print(args)
        print(self.title.format("args"))

        if "OMid" not in args.keys() or "token" not in args.keys():
            return PARAMS_MISS

        token = args.get("token")
        USid = token_to_usid(token)
        # TODO USid的作用?

        OMid = get_str(args, "OMid")

        all_review = get_model_return_list(
            self.service_review.get_review(OMid))
        print(self.title.format("all_review"))
        print(all_review)
        print(self.title.format("all_review"))
        if not all_review:
            return SYSTEM_ERROR

        for row in all_review:
            product = get_model_return_dict(
                self.smeal.get_meal_by_meid(row.get("MEid")))
            print(self.title.format("product"))
            print(product)
            print(self.title.format("product"))
            if not product:
                return SYSTEM_ERROR
            row.update(product)

        back_response = import_status("SUCCESS_MESSAGE_ADD_REVIEW", "OK")
        back_response["data"] = all_review
        return back_response
Esempio n. 11
0
    def add_or_update_cart(self):
        args = request.args.to_dict()
        print(self.title.format("args"))
        print(args)
        print(self.title.format("args"))
        data = json.loads(request.data)
        print(self.title.format("data"))
        print(data)
        print(self.title.format("data"))

        if "token" not in args:
            return PARAMS_MISS
        token = args.get("token")
        USid = token_to_usid(token)
        MEid = data["MEid"]
        CAnumber = data["CAnumber"]
        if CAnumber <= 0:
            PBnumber = self.scart.get_canumber_by_meid_and_usid(MEid, USid)
            if not PBnumber:
                return SYSTEM_ERROR
            pnum = int(CAnumber) + int(PBnumber)
            if pnum <= 0:
                return self.del_cart(USid, MEid)
            else:
                cart = self.scart.get_cart_by_usid_meid(USid, MEid)
                print(self.title.format("cart"))
                print(cart)
                print(self.title.format("cart"))
                if not cart:
                    return SYSTEM_ERROR
                self.scart.update_num_cart(pnum, cart.CAid)
        else:
            try:
                if not self.smeal.get_meal_by_meid(MEid):
                    return import_status("ERROR_MESSAGE_NONE_PRODUCT",
                                         "GROUPMEAL_ERROR",
                                         "ERROR_NONE_PRODUCT")
                cart = self.scart.get_cart_by_usid_meid(USid, MEid)
                print(self.title.format("cart"))
                print(cart)
                print(self.title.format("cart"))
                if cart:
                    PBnumber = self.scart.get_canumber_by_meid_and_usid(
                        MEid, USid)
                    pnum = int(CAnumber) + int(PBnumber)
                    self.scart.update_num_cart(pnum, cart.CAid)
                else:
                    add_model(
                        "Cart", **{
                            "CAid": str(uuid.uuid1()),
                            "CAnumber": CAnumber,
                            "USid": USid,
                            "MEid": MEid
                        })
            except dberror:
                return SYSTEM_ERROR
            except Exception as e:
                print(e.message)
                return SYSTEM_ERROR

        return import_status("SUCCESS_MESSAGE_UPDATE_CART", "OK")
Esempio n. 12
0
    def get_eat(self):
        args = request.args.to_dict()
        print(self.title.format("args"))
        print(args)
        print(self.title.format("args"))
        if "token" not in args:
            return PARAMS_MISS
        USid = token_to_usid(args["token"])
        response_data = {
            "calorie": 0,
            "protein": 0,
            "fat": 0,
            "carbohydrate": 0,
            "inorganic": 0,
            "calcium": 0,
            "phosphorus": 0,
            "iron": 0
        }
        if "timedetail" in args:
            timedetail = int(args["timedetail"])
            time_now = datetime.datetime.now() + datetime.timedelta(
                days=timedetail)
            date = time_now.strftime("%Y%m%d%H%M%S")[0:8]
            time_start = date + "000000"
            time_end = date + "235959"
            all_order = get_model_return_list(
                self.sorder.get_all_order_by_time(time_start, time_end, USid))
            print(self.title.format("all_order"))
            print(all_order)
            print(self.title.format("all_order"))
            if not all_order:
                return SYSTEM_ERROR
            for order in all_order:
                OMid = order["OMid"]
                meal_list = get_model_return_list(
                    self.sorder.get_order_item_by_oid(OMid))
                for meal in meal_list:
                    MEnumber = meal["MEnumber"]
                    MEid = meal["MEid"]
                    meal_abo = get_model_return_dict(
                        self.smeal.get_meal_nutrition_by_meid(MEid))
                    response_data[
                        "calorie"] += meal_abo["MEcalorie"] * MEnumber
                    response_data[
                        "protein"] += meal_abo["MEprotein"] * MEnumber
                    response_data["fat"] += meal_abo["MEfat"] * MEnumber
                    response_data["carbohydrate"] += meal_abo[
                        "MEcarbohydrate"] * MEnumber
                    response_data[
                        "inorganic"] += meal_abo["MEinorganic"] * MEnumber
                    response_data[
                        "calcium"] += meal_abo["MEcalcium"] * MEnumber
                    response_data[
                        "phosphorus"] += meal_abo["MEphosphorus"] * MEnumber
                    response_data["iron"] += meal_abo["MEiron"] * MEnumber

        if "timestart" in args and "timeend" in args:
            return
        response = import_status("SUCCESS_GET_EAT", "OK")
        response["data"] = response_data
        return response
Esempio n. 13
0
    def make_main_order(self):
        args = request.args.to_dict()
        data = request.data
        data = json.loads(data)
        print(self.title.format("args"))
        print(args)
        print(self.title.format("args"))
        print(self.title.format("data"))
        print(data)
        print(self.title.format("data"))

        if "token" not in args or "MSid" not in args:
            return PARAMS_MISS

        params_list = ["Order_items", "OMtotal", "OMtime"]
        for params in params_list:
            if params not in data:
                return PARAMS_MISS
        null_params = ["OMabo", "CPid"]
        for params in data.keys():
            if params not in null_params and params not in params_list:
                return PARAMS_REDUNDANCY

        token = args.get("token")
        Uid = token_to_usid(token)
        user = self.susers.get_user_by_usid(Uid)
        if not user:
            return SYSTEM_ERROR
        MSid = args["MSid"]
        OMtime = timeformate.get_db_time_str(data["OMtime"])

        order_item = data["Order_items"]
        OMcode = self.make_code()
        import uuid
        OMid = str(uuid.uuid1())
        try:
            for op in order_item:
                MEstatus = self.smeal.get_mestatus_by_meid(op["MEid"])
                print(self.title.format("MEstatus"))
                print(MEstatus)
                print(self.title.format("MEstatus"))
                if MEstatus != 281:
                    return import_status("error_no_pro", "GROUPMEAL_ERROR",
                                         "error_no_pro")
                msid = self.smeal.get_msid_by_meid(op["MEid"])
                if msid != MSid:
                    return import_status("ERROR_MEAL_IN_MESS",
                                         "GROUPMEAL_ERROR",
                                         "ERROR_MEAL_IN_MESS")
                add_model(
                    "OrderPart", **{
                        "OPid": str(uuid.uuid1()),
                        "OMid": OMid,
                        "MEid": op["MEid"],
                        "MEnumber": op["MEnumber"]
                    })
                volume = self.smeal.get_mevolume_by_meid(op["MEid"])
                volume = volume + 1
                update_meal = self.smeal.update_meal(op["MEid"],
                                                     {"MEvolume": volume})
                if not update_meal:
                    return SYSTEM_ERROR

                cart = get_model_return_dict(
                    self.scart.get_cart_by_usid_meid(Uid, op["MEid"]))
                print(self.title.format("cartt"))
                print(cart)
                print(self.title.format("cartt"))
                self.scart.del_carts(cart.get("CAid"))

            print(self.title.format("success add orderpart"))
            # TODO 增加优惠券id
            self.sorders.add_model(
                "OrderMain", **{
                    "OMid": OMid,
                    "OMtime": OMtime,
                    "OMstatus": 301,
                    "USid": Uid,
                    "OMcode": OMcode,
                    "OMabo": data["OMabo"],
                    "OMtotal": data["OMtotal"]
                })

            # self.scoupons.update_carbackage(get_str(data, "CAid"))
            response_make_main_order = import_status("SUCCESS_MAKE_ORDER",
                                                     "OK")
            response_make_main_order["data"] = {}
            response_make_main_order["data"]["OMid"] = OMid
            return response_make_main_order
        except Exception as e:
            print(self.title.format("error"))
            print(e.message)
            print(self.title.format("error"))
            return SYSTEM_ERROR
Esempio n. 14
0
    def create_review(self):
        args = request.args.to_dict()
        print(self.title.format("args"))
        print(args)
        print(self.title.format("args"))
        if "token" not in args.keys() or "OMid" not in args.keys():
            return PARAMS_MISS

        token = args.get("token")
        USid = token_to_usid(token)
        OMid = get_str(args, "OMid")
        OMstatus = self.service_order.get_omstatus_by_omid(OMid)
        if OMstatus != 305:
            return import_status("ERROR_MESSAGE_WRONG_OMSTATUS",
                                 "GROUPMEAL_ERROR",
                                 "ERROR_CODE_WRONG_OMSTATUS")

        data = request.data
        data = json.loads(data)
        print(self.title.format("data"))
        print(data)
        print(self.title.format("data"))

        for row in data:
            print(self.title.format("data_item"))
            print(row)
            print(self.title.format("data_item"))
            if "MEid" not in row or "REscore" not in row or "REfscore" not in row:
                return PARAMS_MISS
            if "REcontent" in row:
                REcontent = row["REcontent"]
            else:
                REcontent = None
            PRid = row["MEid"]
            REscore = row["REscore"]
            print(self.title.format("REscore"))
            print(REscore)
            print(self.title.format("REscore"))
            try:
                add_model(
                    "Review", **{
                        "REid": str(uuid.uuid1()),
                        "OMid": OMid,
                        "MEid": PRid,
                        "REscore": REscore,
                        "REcontent": REcontent,
                        "REfscore": row["REfscore"]
                    })
            except Exception as e:
                print(self.title.format("add_review"))
                print(e.message)
                print(self.title.format("add_review"))
                return SYSTEM_ERROR

            product_volue = self.smeal.get_mevolume_by_meid(PRid)
            product_score = self.smeal.get_mefrac_by_meid(PRid)

            score = (product_score * product_volue + REscore) / product_volue
            product = {"MEfraction": score}
            update_product = self.smeal.update_meal(PRid, product)
            print(self.title.format("update_product"))
            print(update_product)
            print(self.title.format("update_product"))
            if not update_product:
                return SYSTEM_ERROR

            order = {"OMstatus": 306}
            update_order = self.service_order.update_order_by_oid(OMid, order)
            print(self.title.format("update_order"))
            print(update_order)
            print(self.title.format("update_order"))
            if not update_order:
                return SYSTEM_ERROR

        back_response = import_status("SUCCESS_MESSAGE_ADD_REVIEW", "OK")
        return back_response
Esempio n. 15
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:
                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["CPid"] = cart_pkg.CPid
                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