Beispiel #1
0
 def register(self):
     if not is_superadmin():
         return AUTHORITY_ERROR
     try:
         data = request.json
         ADnum = data.get('ADnum')
         ADname = data.get('ADname')
         ADpassword = data.get('ADpassword')
         ADlevel = data.get('ADlevel')
     except:
         return PARAMS_ERROR
     try:
         all_adnum = get_model_return_list(
             self.sadmin.get_all_adnum())  # 查看是否有相同的管理员号码
         for adnum_dict in all_adnum:
             if ADnum == adnum_dict['ADnum']:
                 return 'sorry, this adnum is already exists'
         all_adname = get_model_return_list(
             self.sadmin.get_all_adname())  # 查看是否有相同的管理员名
         for adname_dict in all_adname:
             if ADname == adname_dict['ADname']:
                 return 'sorry, this adname is already exists'
         import datetime
         from common.timeformat import format_for_db
         time_time = datetime.datetime.now()
         time_str = datetime.datetime.strftime(time_time, format_for_db)
         adid = str(uuid.uuid1())
         self.sadmin.add_admin(adid, ADnum, ADname, ADpassword, ADlevel,
                               time_str)
         response = import_status("get_admin_success", "OK")
         return response
     except:
         return SYSTEM_ERROR
Beispiel #2
0
    def delete_category(self):
        #删除商品分类
        #self.json_param_miss("post")
        if not is_admin():
            return AUTHORITY_ERROR
        try:
            data = request.json
            PAid = data.get('PAid')

        except:
            return PARAMS_ERROR
        try:
            get_PAstatus = get_model_return_dict(self.sgoods.get_product_category(PAid))
            if not get_PAstatus:
                return PRODUCE_CATEGORY_NOT_EXIST
            # elif get_Parentid == 0:
            #     self.sgoods.add_product_category(PAid, PAname, PAtype)
            if get_PAstatus['PAtype'] == 1:
                categorylist = get_model_return_list(self.sgoods.get_first_product_category_status(PAid))
                if categorylist:
                    return HAS_SECOND_CATEGORY
            if get_PAstatus['PAtype'] == 2:
                product_list = get_model_return_list(self.sgoods.get_product_by_paid(paid=PAid))
                if product_list:
                    return PRODUCE_CATEGORY_HAS_PRODUCT
            delete_category = {}
            delete_category['PAstatus'] = False
            self.sgoods.delete_category(PAid, delete_category)
        except Exception as e:
            print e.message
            return PARAMS_MISS
        response = import_status("delete_product_category_success", "OK")
        return response
Beispiel #3
0
    def students_abo(self):
        """
        获取学生的的详细信息,包括竞赛信息,技能信息
        必须有参数Sid
        :return:
        """
        if not self.sstudents.status:
            return system_error
        args = request.args.to_dict()
        # 判断是否含有参数并校验参数中是否存在Sid,如果没有,抛出异常
        if not args or not self.judgeData.inData("Sid", args):
            return param_miss

        try:
            sid = args["Sid"]
            # 获取数据库中数据
            # 获取学生的基础信息
            student_abo = get_model_return_list(self.sstudents.get_student_abo_by_sid(sid))
            # 获取学生的技能信息
            student_tech = get_model_return_list(self.sstudents.get_student_tech_by_sid(sid))
            # 获取学生的竞赛信息
            student_use = get_model_return_list(self.sstudents.get_student_use_by_sid(sid))
            # 拼装返回结构体
            student_abo[0]["STech"] = student_tech
            student_abo[0]["SCUse"] = student_use
            search_student_abo_success["student_abo"] = student_abo
            return search_student_abo_success
        except Exception as e:
            # 防止系统的莫名错误
            print e.message
            return system_error
Beispiel #4
0
 def get_comMessage(self):
     if is_tourist():
         return TOKEN_ERROR
     try:
         args = request.args.to_dict()
         page = int(args.get('page', 1))  # 页码
         count = int(args.get('count', 10))  # 取出条数
     except Exception as e:
         return PARAMS_ERROR
     if is_admin():
         comMessage_list = get_model_return_list(
             self.smessage.get_comMessage_list(page, count))  # 分页查询出的公司消息列表
         from common.timeformat import get_web_time_str
         for message in comMessage_list:
             message['CMdate'] = get_web_time_str(message['CMdate'])
         comMessage_num = self.smessage.get_commessage_num()  # 公司消息总条数
         data = import_status('get_commessage_list_success', 'OK')
         data['mount'] = int(comMessage_num)
         data['data'] = comMessage_list
         return data
     else:
         comMessage_num = self.smessage.get_commessage_num()  # 公司消息总条数
         print comMessage_num
         comMessage_list = get_model_return_list(
             self.smessage.get_comMessage_list(page, count))  # 分页查询出的公司消息列表
         print len(comMessage_list)
         a = request.user.id
         already_list = get_model_return_list(
             self.smessage.get_alreadyMessage_by_usid(
                 request.user.id))  # 已经阅读的消息的id集合
         already_id_list = []
         for already in already_list:
             already_id_list.append(already['ARmessageid'])
         notread_count = int(comMessage_num) - len(
             already_list)  # 该用户未读的消息条数
         return_message_list = []
         from common.timeformat import get_web_time_str
         for message in comMessage_list:
             message_dic = {}
             if message['CMid'] not in already_id_list:  # 如果没有读,加个标记isread
                 message_dic['isread'] = 0
                 message_dic['CMid'] = message['CMid']
                 message_dic['CMdate'] = get_web_time_str(message['CMdate'])
                 message_dic['CMtype'] = message['CMtype']
                 message_dic['CMtitle'] = message['CMtitle']
                 message_dic['CMfile'] = message['CMfile']
                 return_message_list.append(message_dic)
             else:
                 message_dic['isread'] = 1
                 message_dic['CMid'] = message['CMid']
                 message_dic['CMdate'] = get_web_time_str(message['CMdate'])
                 message_dic['CMtype'] = message['CMtype']
                 message_dic['CMtitle'] = message['CMtitle']
                 message_dic['CMfile'] = message['CMfile']
                 return_message_list.append(message_dic)
         data = import_status('get_commessage_list_success', 'OK')
         data['notread'] = notread_count
         data['data'] = return_message_list
         data['mount'] = int(comMessage_num)
         return data
Beispiel #5
0
    def teachers_abo(self):
        """
        通过Tid来获取教师的详细信息,包括带队经历
        必须有参数Tid
        :return:
        """
        if not self.steachers.status:
            return system_error
        args = request.args.to_dict()
        # 判断是否含有参数并 校验参数中是否存在Tid,如果没有,抛出异常
        if not args or not self.judgeData.inData("Tid", args):
            return param_miss

        try:
            tid = args["Tid"]  # 获取Tid
            # 获取教师的所有基础信息
            teacher_abo = get_model_return_list(
                self.steachers.get_teacher_abo_by_tid(tid))
            # 获取教师的所有竞赛信息
            teacher_use = get_model_return_list(
                self.steachers.get_teacher_use_by_tid(tid))
            # 将竞赛信息拼装进教师基础信息中
            teacher_abo[0]["TCuse"] = teacher_use
            search_teachers_abo_success["teacher_abo"] = teacher_abo
            return search_teachers_abo_success
        except Exception as e:
            # 防止系统的莫名错误
            print e.message
            return system_error
Beispiel #6
0
 def get_all_area(self):
     try:
         province_return = []
         province_list = get_model_return_list(self.smycenter.get_province())
         for province in province_list:
             province_dic = {}
             province_dic['name'] = province['provincename']
             province_dic['id'] = province['provinceid']
             city_list = get_model_return_list(self.smycenter.get_city_by_provincenum(province['provinceid']))
             city_return = []
             for city in city_list:
                     city_dic = {}
                     city_dic['name'] = city['cityname']
                     city_dic['id'] = city['cityid']
                     area_list = get_model_return_list(self.smycenter.get_area_by_citynum(city['cityid']))
                     area_return = []
                     for area in area_list:
                         area_dict = {}
                         area_dict['name'] = area['areaname']
                         area_dict['id'] = area['areaid']
                         area_return.append(area_dict)
                     city_dic['area'] = area_return
                     city_return.append(city_dic)
             province_dic['city'] = city_return
             province_return.append(province_dic)
         res = import_status("get_all_area_success", "OK")
         res['data'] = province_return
     except:
         return SYSTEM_ERROR
     return res
Beispiel #7
0
 def get_shoppingcart(self):
     if not is_ordirnaryuser():
         return TOKEN_ERROR
     product_list = get_model_return_list(self.sgoods.get_shoppingcart_product(request.user.id))
     for product in product_list:
         product_info = get_model_return_dict(self.sgoods.get_product_details(product['PRid']))
         product['PRpic'] = product_info['PRpic']
         product['PRlogisticsfee'] = product_info['PRlogisticsfee']
         product['PRprice'] = product_info['PRprice']
         product['PRname'] = product_info['PRname']
         product_status = self.sgoods.get_product_info(product['PRid'])
         sku_list = get_model_return_list(self.sgoods.get_shoppingcart_sku(request.user.id, product['PRid']))
         for sku in sku_list:
             sku_stok = get_model_return_dict(self.sgoods.get_sku_stock(sku['PSid']))
             if int(sku['number']) > int(sku_stok['PSstock']):
                 sku['SCstatus'] = 2
             sku_status = self.sgoods.get_sku_status(sku['PSid'])
             if not sku_status:
                 sku['SCstatus'] = 3
             if not product_status:
                 sku['SCstatus'] = 4
         product['skulist'] = sku_list
     if len(product_list) != 0:
         return_list = sorted(product_list, key=lambda product: product['skulist'][0]['SCcreatetime'], reverse=True)
     else:
         return_list = []
     response = import_status("get_shoppingcart_success", "OK")
     response['data'] = return_list
     return response
Beispiel #8
0
 def get_order_details(self):
     if is_tourist():
         return TOKEN_ERROR
     data = request.json
     if not data:
         return PARAMS_MISS
     try:
         OIsn = int(data.get('OIsn'))
     except:
         return PARAMS_ERROR
     detail = get_model_return_dict(self.sorder.get_order_details(OIsn))
     from common.timeformat import get_web_time_str
     detail['createtime'] = get_web_time_str(detail['OIcreatetime'])
     product_list = get_model_return_list(
         self.sorder.get_product_list(detail['OIid']))
     for product in product_list:
         product['PRnum'] = 0
         sku_list = get_model_return_list(
             self.sorder.get_sku_list_by_opiid(product['OPIid']))
         for sku in sku_list:
             product['PRnum'] = product['PRnum'] + sku['number']
         product['skulist'] = sku_list
     detail['product_list'] = product_list
     response = import_status("get_orderdetails_success", "OK")
     response['data'] = detail
     return response
Beispiel #9
0
 def get_order_list(self):
     if is_tourist():
         return TOKEN_ERROR
     data = request.json
     if not data:
         return PARAMS_MISS
     try:
         type = int(data.get('type'))
         page = int(data.get('page'))
         count = int(data.get('count'))
     except:
         return PARAMS_ERROR
     order_return_list = []
     if type == 0:
         order_list = get_model_return_list(
             self.sorder.get_allorder_list(request.user.id, page, count))
         state0 = int(self.sorder.get_total_order_num(
             request.user.id)) if self.sorder.get_total_order_num(
                 request.user.id) else 0
         state1 = int(self.sorder.get_order_num(
             request.user.id, 1)) if self.sorder.get_order_num(
                 request.user.id, 1) else 0
         state2 = int(self.sorder.get_order_num(
             request.user.id, 2)) if self.sorder.get_order_num(
                 request.user.id, 2) else 0
         state3 = int(self.sorder.get_order_num(
             request.user.id, 3)) if self.sorder.get_order_num(
                 request.user.id, 3) else 0
         for order in order_list:
             product_list = get_model_return_list(
                 self.sorder.get_product_list(order['OIid']))
             order['product_list'] = product_list
             from common.timeformat import get_web_time_str
             order['OIcreatetime'] = get_web_time_str(order['OIcreatetime'])
             order_return_list.append(order)
         response = import_status("get_orderlist_success", "OK")
         response['data'] = order_return_list
         response['state0_num'] = state0
         response['state1_num'] = state1
         response['state2_num'] = state2
         response['state3_num'] = state3
         return response
     else:
         order_list = get_model_return_list(
             self.sorder.get_order_list(request.user.id, type, page, count))
         if not order_list:
             response = import_status("get_orderlist_success", "OK")
             response['data'] = order_return_list
             return response
         for order in order_list:
             product_list = get_model_return_list(
                 self.sorder.get_product_list(order['OIid']))
             order['product_list'] = product_list
             from common.timeformat import get_web_time_str
             order['OIcreatetime'] = get_web_time_str(order['OIcreatetime'])
             order_return_list.append(order)
         response = import_status("get_orderlist_success", "OK")
         response['data'] = order_return_list
         return response
Beispiel #10
0
    def add_useraddress(self):
        if is_tourist():
            return TOKEN_ERROR

        try:
            data = request.json
            USname = data.get('USname')
            USphonenum = data.get("USphonenum")
            USdatails = data.get("details")
            areaid = data.get("areaid")
            if not areaid:
                cityid = data.get("cityid")
        except:
            return PARAMS_ERROR
        try:
            if areaid:
                all_areaid = get_model_return_list(self.smycenter.get_all_areaid())
                area_list = []
                for area in all_areaid:
                    area_list.append(area['areaid'])
                if areaid not in area_list:
                    return BAD_ADDRESS
                import datetime
                from common.timeformat import format_for_db
                time_time = datetime.datetime.now()
                time_str = datetime.datetime.strftime(time_time, format_for_db)
                uaid = str(uuid.uuid1())
                exist_default = self.smycenter.get_default_address_by_usid(request.user.id)
                uadefault = True if not exist_default else False
                self.smycenter.add_address(uaid, request.user.id, USname, USphonenum, USdatails, areaid, uadefault, time_str, None)
                response = import_status("add_address_success", "OK")
                response['data'] = {
                    "UAid": uaid
                }
                return response
            else :
                all_cityid = get_model_return_list(self.smycenter.get_all_cityid())
                cityid_list = []
                for city in all_cityid:
                    cityid_list.append(city['cityid'])
                if cityid not in cityid_list:
                    return BAD_ADDRESS
                import datetime
                from common.timeformat import format_for_db
                time_time = datetime.datetime.now()
                time_str = datetime.datetime.strftime(time_time, format_for_db)
                uaid = str(uuid.uuid1())
                exist_default = self.smycenter.get_default_address_by_usid(request.user.id)
                uadefault = True if not exist_default else False
                self.smycenter.add_address(uaid, request.user.id, USname, USphonenum, USdatails, None, uadefault, time_str, cityid)
                response = import_status("add_address_success", "OK")
                response['data'] = {
                    "UAid": uaid
                }
                return response
        except:
            return SYSTEM_ERROR
Beispiel #11
0
    def get_product_list(self):
        args = request.args.to_dict()
        try:
            page_num = int(args.get("page_num"))
            page_size = int(args.get("page_size"))
            PRstatus = int(args.get("PRstatus"))
            PRname = args.get("PRname")
            PAid = str(args.get("PAid"))
            PAtype = int(args.get("PAtype"))
            print args
        except:
            return PARAMS_MISS
        product_list = []
        if PAid == '':
            return PARAMS_ERROR
        if PAid == str(0):
            print 'PAid == str(0)'
            product_list = get_model_return_list(self.sgoods.admin_get_product(PRstatus, PRname))
        elif int(PAtype) == 1:
            print 'int(PAtype) == 1'
            paid_list = get_model_return_list(self.sgoods.get_childid(str(PAid)))
            for paid in paid_list:
                product_list = product_list + get_model_return_list(
                    self.sgoods.admin_get_product(PRstatus, PRname, paid['PAid']))
        elif int(PAtype) == 2:
            print 'int(PAtype) == 2'
            product_list = product_list + get_model_return_list(
                self.sgoods.admin_get_product(PRstatus, PRname, PAid))
        print product_list
        for product in product_list:
            print 'for product in product_list'
            print product['PAid']
            category = get_model_return_dict(self.sgoods.get_category_byid(product['PAid']))
            print category
            product['firstpaid'] = category['Parentid']
            parent_category = get_model_return_dict(self.sgoods.get_category_byid(category['Parentid']))
            product['firstpaname'] = parent_category['PAname']
            product['categoryname'] = category['PAname']
            product['PRcreatetime'] = get_web_time_str(product['PRcreatetime'])

        mount = len(product_list)
        page = mount / page_size
        if page == 0 or page == 1 and mount % page_size == 0:
            return_list = product_list[0:]
        else:
            if ((mount - (page_num - 1) * page_size) / page_size) >= 1 and \
                    (mount - (page_num * page_size)) > 0:
                return_list = product_list[((page_num - 1) * page_size):(page_num * page_size)]
            else:
                return_list = product_list[((page_num - 1) * page_size):]
        response = import_status("get_product_list_success", "OK")
        response["data"] = return_list
        response['mount'] = mount
        return response
Beispiel #12
0
    def myinfor(self):
        args = request.args.to_dict()  # 获取到的参数
        print args
        # 判断参数非空
        if not args:
            return param_miss
        # 判断参数中含有Uid
        if not self.judgeData.inData("Uid", args):
            return param_miss

        uid = args["Uid"]
        # 获取用户身份
        utype = self.suser.get_utype_by_uid(uid)
        print utype
        # 判断系统是否异常
        if not self.spersonal.status:
            return system_error

        # 判断用户身份,其中100为学生,101为教师,102为管理员
        if utype == 100:
            sid = self.sstudent.get_sid_by_uid(uid)

            # 获取数据库中数据
            # 获取学生的基础信息
            student_abo = get_model_return_list(
                self.sstudent.get_student_abo_by_sid(sid))
            # 获取学生的技能信息
            student_tech = get_model_return_list(
                self.sstudent.get_student_tech_by_sid(sid))
            # 获取学生的竞赛信息
            student_use = get_model_return_list(
                self.sstudent.get_student_use_by_sid(sid))
            # 拼装返回结构体
            student_abo[0]["STech"] = student_tech
            student_abo[0]["SCUse"] = student_use
            search_student_abo_success["student_abo"] = student_abo
            return search_student_abo_success  # 已修改
        elif utype == 101:
            tid = self.spersonal.get_tid_by_uid(uid)

            # 获取教师的所有基础信息
            teacher_abo = get_model_return_list(
                self.steacher.get_teacher_abo_by_tid(tid))
            # 获取教师的所有竞赛信息
            teacher_use = get_model_return_list(
                self.steacher.get_teacher_use_by_tid(tid))
            # 将竞赛信息拼装进教师基础信息中
            teacher_abo[0]["TCuse"] = teacher_use
            search_teachers_abo_success["teacher_abo"] = teacher_abo
            return search_teachers_abo_success
        elif utype == 102:
            return none_permissions
        else:
            return none_identity
Beispiel #13
0
 def update_admin(self):
     if not is_superadmin():
         return AUTHORITY_ERROR
     try:
         data = request.json
         ADnum = data.get('ADnum')
         ADname = data.get('ADname')
         ADpassword = data.get('ADpassword')
         ADlevel = data.get('ADlevel')
     except:
         return PARAMS_ERROR
     try:
         retnum = False  #判断ADnum是否在admin列表中
         all_adnum = get_model_return_list(self.sadmin.get_all_adnum())
         for adnum_dict in all_adnum:
             if ADnum == int(adnum_dict['ADnum']):
                 retnum = True
         if retnum == False:
             return ADMINNUM_ERROR
         update = {}
         update['ADname'] = ADname
         update['ADpassword'] = ADpassword
         update['ADlevel'] = ADlevel
         self.sadmin.update_admin(ADnum, update)
         response = import_status("update_admin", "OK")
         return response
     except Exception as e:
         print e
         return SYSTEM_ERROR
Beispiel #14
0
 def get_size(self):
     if not is_admin():
         return TOKEN_ERROR
     list = get_model_return_list(self.sgoods.get_size_list())
     response = import_status("get_size_list_success", "OK")
     response['data'] = list
     return response
Beispiel #15
0
    def get_carts_by_uid(self):
        args = request.args.to_dict()
        if "token" not in args:
            return self.param_miss

        #todo uid 验证未实现
        uid = args.get("token")
        res_get_all = {}

        try:
            cart_info_list = []
            cart_list = self.scart.get_carts_by_Uid(uid)
            for cart in cart_list:
                cart_info = get_model_return_list(
                    self.spro.get_all_pro_fro_carts(cart.Pid))[0]
                cart_info["Pnum"] = cart.Pnum
                if cart.Castatus != 1:
                    continue
                cart_info_list.append(cart_info)
            res_get_all["data"] = cart_info_list
            res_get_all["status"] = ok
            from config.messages import messages_get_cart_success as msg
            res_get_all["message"] = msg
            return res_get_all

        except Exception as e:
            print(e.message)
            return self.system_error
Beispiel #16
0
 def get_qrcode(self):
     if is_tourist():
         return TOKEN_ERROR
     try:
         data = request.json
     except:
         return PARAMS_ERROR
     time = datetime.strftime(datetime.now(), format_for_db)
     from common.timeformat import get_web_time_str
     qrcode_list = self.suser.get_qrcode_list(request.user.id)
     if qrcode_list:
         return_list = []
         qrcode_list = get_model_return_list(qrcode_list)
         for code in qrcode_list:
             if str(code['QRovertime']) > time and int(
                     code['QRnumber']) > 0:
                 code['QRovertime'] = get_web_time_str(code['QRovertime'])
                 return_list.append(code)
         response = import_status("get_qrcode_success", "OK")
         response['data'] = return_list
         return response
     else:
         response = import_status("get_qrcode_success", "OK")
         response['data'] = []
         return response
Beispiel #17
0
 def get_agentMessage(self):
     print "hello"
     if is_tourist():
         return TOKEN_ERROR
     try:
         args = request.args.to_dict()
         page = int(args.get('page', 1))  # 页码
         count = int(args.get('count', 15))  # 取出条数
     except Exception as e:
         return PARAMS_ERROR
     from common.timeformat import get_web_time_str
     message_list, mount = self.smessage.get_agentMessage_by_usid(
         request.user.id, page, count)
     message_list = get_model_return_list(message_list)
     message_return = []
     for message in message_list:
         data = {}
         data['USid'] = message['USid']
         data['AMdate'] = get_web_time_str(message['AMdate'])
         data['AMid'] = message['AMid']
         data['AMcontent'] = message['AMcontent']
         data['AMtype'] = message['AMtype']
         message_return.append(data)
     data = import_status('get_agentmessage_list_success', 'OK')
     data['data'] = message_return
     data['mount'] = mount
     return data
Beispiel #18
0
 def timer_fun(self):  # 定时器
     global TIMER
     print "start timer_fun !"
     import datetime
     time_now = datetime.datetime.strftime(datetime.datetime.now(),
                                           '%Y%m%d%H%M%S')
     print time_now
     if time_now[8:10] == '04' or time_now[8:10] == '05' or time_now[
             8:10] == '06':
         order_list = get_model_return_list(
             self.sorder.get_all_order(None, None, None, 2, None, None))
         if order_list:
             for order in order_list:
                 time = datetime.datetime.strptime(order['OIcreatetime'],
                                                   '%Y%m%d%H%M%S')
                 print 'time', time
                 days_10 = (
                     time +
                     datetime.timedelta(days=10)).strftime("%Y%m%d%H%M%S")
                 print 'days_10', days_10
                 if time_now > days_10:
                     self.sorder.update_order(order['OIsn'],
                                              {"OIstatus": 3})
     # 继续添加定时器,周期执行,否则只会执行一次
     print(u'当前线程数为{}'.format(threading.activeCount()))
     TIMER = threading.Timer(3600, self.timer_fun)
     TIMER.setDaemon(True)
     TIMER.start()
Beispiel #19
0
    def get_product_list(self):
        #self.json_param_miss("get")
        args = request.args.to_dict()
        try:
            page_num = int(args.get("page_num"))
            page_size = int(args.get("page_size"))
            PRstatus = int(args.get("PRstatus"))
            PAid = args.get("PAid")
            PAtype = int(args.get("PAtype"))
        except:
            return PARAMS_MISS
        if int(PAid) == 0:
            return_list, mount = self.sgoods.get_product_list(
                page_size, page_num, None, PRstatus)
            return_list = get_model_return_list(return_list)
        elif PAtype == 1:
            paid_list = get_model_return_list(
                self.sgoods.get_childid(int(args.get("PAid"))))
            product_list = []
            for row in paid_list:
                product_list = product_list + (get_model_return_list(
                    self.sgoods.get_type1_product(row['PAid'], PRstatus)))
            mount = len(product_list)
            page = mount / page_size
            if page == 0 or page == 1 and mount % page_num == 0:
                return_list = product_list[0:]
            else:
                if ((mount - (page_num - 1) * page_size)/page_size) >= 1 and \
                        ((mount - (page_num - 1) * page_size)%page_size) > 0:
                    return_list = product_list[((page_num - 1) *
                                                page_size):(page_num *
                                                            page_size)]
                else:
                    return_list = product_list[((page_num - 1) * page_size):]

        elif PAtype == 2:
            return_list, mount = self.sgoods.get_product_list(
                page_size, page_num, PAid, PRstatus)
            return_list = get_model_return_list(return_list)
        else:
            return PARAMS_MISS
        for product in return_list:
            product['PRcreatetime'] = get_web_time_str(product['PRcreatetime'])
        response = import_status("get_product_list_success", "OK")
        response["data"] = return_list
        response['mount'] = mount
        return response
Beispiel #20
0
 def get_province(self):
     try:
         province_list = get_model_return_list(self.smycenter.get_province())
         res = import_status("get_province_list_success", "OK")
         res["data"] = province_list
         return res
     except:
         return SYSTEM_ERROR
Beispiel #21
0
 def get_product_category(self):
     args = request.args.to_dict()
     try:
         PAtype = int(args.get("PAtype"))
         if PAtype == 1:
             product_category = (get_model_return_list(self.sgoods.get_first_product_category(str(0))))
         elif PAtype == 2:
             PAid = args.get("PAid")
             product_category = (get_model_return_list(self.sgoods.get_first_product_category(PAid)))
         else:
             return NO_THIS_CATEGORY
     except Exception as e:
         print(e.message)
         return PARAMS_MISS
     response = import_status("get_product_category_success", "OK")
     response["data"] = product_category
     return response
Beispiel #22
0
 def get_competition_list(self, start_num, page_size, params):
     # 根据筛选条件查询全部竞赛信息
     competitions_list = self.scompetitions.get_competitions_list(
         start_num, page_size, params)
     # [competitions1, 2, 3...]
     if isinstance(competitions_list, list) and competitions_list:
         return get_model_return_list(competitions_list)
     else:
         return []
Beispiel #23
0
 def get_product_category_list(self):
     # 获取商品分类列表
     if is_tourist():
         return TOKEN_ERROR
     first_level = get_model_return_list(self.sgoods.get_first_product_category_status(str(0)))
     options = []
     for parent_category in first_level:
         product_category_list = {}
         parnetid = parent_category['PAid']
         parentname = parent_category['PAname']
         product_category_list['PAid'] = parnetid
         product_category_list['PAname'] = parentname
         child_category = get_model_return_list(self.sgoods.get_first_product_category(parnetid))
         product_category_list['child_category'] = child_category
         options.append(product_category_list)
     response = import_status("get_product_category_list_success", "OK")
     response['data'] = options
     return response
Beispiel #24
0
 def get_area_by_city(self):
     try:
         args = request.args.to_dict()
         city_id = args['cityid']
     except:
         return PARAMS_ERROR
     area_list = get_model_return_list(self.smycenter.get_area_by_citynum(city_id))
     res = import_status("get_area_list_success", "OK")
     res["data"] = area_list
     return res
Beispiel #25
0
 def get_city_by_province(self):
     try:
         args = request.args.to_dict()
         province_id = args["provinceid"]
     except:
         return PARAMS_ERROR
     city_list = get_model_return_list(self.smycenter.get_city_by_provincenum(province_id))
     # map(lambda x: x.hide('_id'), city_list)
     res = import_status("get_city_list_success", "OK")
     res["data"] = city_list
     return res
Beispiel #26
0
    def get_register_record(self):
        if not is_admin():
            return TOKEN_ERROR
        try:
            data = request.json
            status = int(data.get('status'))
            page_size = data.get('page_size')
            page_num = data.get('page_num')
        except:
            return PARAMS_ERROR
        list = get_model_return_list(self.suser.get_register_record(status))
        if not list:
            response = import_status("get_registerinfo_success", "OK")
            response['data'] = []
            return response
        from common.timeformat import get_web_time_str
        for record in list:
            record['IRIcreatetime'] = get_web_time_str(record['IRIcreatetime'])
            record['IRIpaytime'] = get_web_time_str(record['IRIpaytime'])
            record['IRIproof'] = record['IRIproof'].split(',')

            if record['IRIarea']:
                area = get_model_return_dict(
                    self.smycenter.get_area_by_areaid(record['IRIarea']))
                city = get_model_return_dict(
                    self.smycenter.get_city_by_cityid(area['cityid']))
                province = get_model_return_dict(
                    self.smycenter.get_province_by_provinceid(
                        city['provinceid']))
                record['address'] = province['provincename'] + city[
                    'cityname'] + area['areaname']
            else:
                city = get_model_return_dict(
                    self.smycenter.get_city_by_cityid(record['IRIcity']))
                province = get_model_return_dict(
                    self.smycenter.get_province_by_provinceid(
                        city['provinceid']))
                record['address'] = province['provincename'] + city['cityname']

        mount = len(list)
        page = mount / page_size
        if page == 0 or page == 1 and mount % page_size == 0:
            real_return_list = list[0:]
        else:
            if ((mount - (page_num - 1) * page_size) / page_size) >= 1 and \
                    (mount - (page_num * page_size)) > 0:
                real_return_list = list[((page_num - 1) *
                                         page_size):(page_num * page_size)]
            else:
                real_return_list = list[((page_num - 1) * page_size):]
        response = import_status("get_registerinfo_success", "OK")
        response['data'] = real_return_list
        response['mount'] = mount
        return response
Beispiel #27
0
 def get_product_name(self, list):
     name = ''
     for product in list:
         sku_list = get_model_return_list(
             self.sorder.get_sku_list_by_opiid(product['OPIid']))
         productName = product['PRname'].split("返")[0].strip()
         result = re.match('[0-9A-Za-z]+', productName)
         if result:
             productName = result.group()
         for sku in sku_list:
             name = name + productName + sku['colorname'] + sku[
                 'sizename'] + str(sku['number']) + u'件' + ' '
     return name
Beispiel #28
0
 def get_order_details(self):
     if is_tourist():
         return TOKEN_ERROR
     data = request.json
     if not data:
         return PARAMS_MISS
     try:
         OIsn = int(data.get('OIsn'))
     except:
         return PARAMS_ERROR
     detail = get_model_return_dict(self.sorder.get_order_details(OIsn))
     if not detail:
         response = import_status("get_orderdetails_success", "OK")
         response['data'] = []
         return response
     address = get_model_return_dict(
         self.smycenter.get_other_address(request.user.id, detail['UAid']))
     if not address:
         return NO_ADDRESS
     area = get_model_return_dict(
         self.smycenter.get_area_by_areaid(address['areaid']))
     from common.timeformat import get_web_time_str
     if area:
         city = get_model_return_dict(
             self.smycenter.get_city_by_cityid(area['cityid']))
         province = get_model_return_dict(
             self.smycenter.get_province_by_provinceid(city['provinceid']))
         detail['provincename'] = province['provincename']
         detail['cityname'] = city['cityname']
         detail['areaname'] = area['areaname']
         detail['details'] = address['UAdetails']
         detail['username'] = address['UAname']
         detail['userphonenum'] = address['UAphonenum']
         detail['createtime'] = get_web_time_str(address['UAcreatetime'])
     else:
         city = get_model_return_dict(
             self.smycenter.get_city_by_cityid(address['cityid']))
         province = get_model_return_dict(
             self.smycenter.get_province_by_provinceid(city['provinceid']))
         detail['provincename'] = province['provincename']
         detail['cityname'] = city['cityname']
         detail['details'] = address['UAdetails']
         detail['username'] = address['UAname']
         detail['userphonenum'] = address['UAphonenum']
         detail['createtime'] = get_web_time_str(address['UAcreatetime'])
     product_list = get_model_return_list(
         self.sorder.get_product_list(detail['OIid']))
     detail['product_list'] = product_list
     response = import_status("get_orderdetails_success", "OK")
     response['data'] = detail
     return response
Beispiel #29
0
 def get_students_list(self, start_num, page_size, params):
     """
     获取所有的学生数据内容
     :param start_num: 分页查询的页数
     :param page_size: 分页查询的每页记录数
     :param params: 筛选条件,由后端生成
     :return:
     """
     students_list = self.sstudents.get_students_list(start_num, page_size, params)
     # [students_list1, 2, 3...]
     if isinstance(students_list, list) and students_list:
         return get_model_return_list(students_list)
     else:
         return []
Beispiel #30
0
 def modify(self):
     all_order = get_model_return_list(self.sorder.get_all_order(None, None, None, 1, None, None))\
         + get_model_return_list(self.sorder.get_all_order(None, None, None, 2, None, None))\
         + get_model_return_list(self.sorder.get_all_order(None, None, None, 4, None, None)) \
         + get_model_return_list(self.sorder.get_all_order(None, None, None, 5, None, None))
     session = db_session()
     try:
         for order in all_order:
             product_list = get_model_return_list(
                 self.sorder.get_product_list(order['OIid']))
             real_discount = 0
             for product in product_list:
                 check_product = get_model_return_dict(
                     self.sgoods.get_product_info(product['PRid']))
                 sku_list = get_model_return_list(
                     self.sorder.get_sku_list_by_opiid(product['OPIid']))
                 for sku in sku_list:
                     real_discount = real_discount + sku[
                         'number'] * check_product['PAdiscountnum']
             session.query(OrderInfo).filter(
                 OrderInfo.OIid == order['OIid']).update(
                     {'discountnum': real_discount})
         session.commit()
     except:
         session.rollback()
     finally:
         session.close()
     session = db_session()
     try:
         amount_list = get_model_return_list(
             session.query(Amount.AMmonth, Amount.USid).all())
         for amount in amount_list:
             real_amount = 0
             order_list = get_model_return_list(
                 session.query(OrderInfo.discountnum).filter(
                     OrderInfo.USid == amount['USid']).filter(
                         OrderInfo.OIstatus == 2).all())
             for order in order_list:
                 real_amount = real_amount + order['discountnum']
             session.query(Amount).filter(
                 Amount.USid == amount['USid']).update(
                     {'performance': real_amount})
         session.commit()
     except:
         session.rollback()
     finally:
         session.close()