def GET(self): if logged(): render = create_render() result = 0 if logged(helper.PRIV_USER | helper.PRIV_MCH): # 提醒改密码 db_user = db.user.find_one({'uname': session.uname}, {'pwd_update': 1}) if int(time.time()) - db_user.get('pwd_update', 0) > 3600 * 24 * 30: raise web.seeother('/settings_user?set_pwd=1') else: return render.portal(session.uname, get_privilege_name(), [result]) else: return render.portal(session.uname, get_privilege_name(), [result]) else: render = create_render() db_sys = db.user.find_one({'uname': 'settings'}) if db_sys == None: signup = 0 else: signup = db_sys['signup'] # 生成验证码 rand = app_helper.my_rand(4).upper() session.uid = rand # uid 临时存放验证码 session.menu_level = 0 # 暂存输入验证码次数 png2 = rand_code.gen_rand_png(rand) return render.login(signup, png2)
def GET(self): if helper.logged(helper.PRIV_USER, 'REPORT_REPORT2'): render = helper.create_render() param = web.input(tuan_id='', status='', pt_order_id='') if param['tuan_id'] != '': # 按tuan_id查活动订单 condition = {'tuan_id': param['tuan_id']} if param['status'] == 'FAIL': condition['status'] = {'$in': ['FAIL1', 'FAIL2', 'FAIL3']} elif param['status'] != '': condition['status'] = param['status'] r = db.pt_order.find(condition) return render.report_pt_order(helper.get_session_uname(), helper.get_privilege_name(), r, helper.PT_REGION) elif param['pt_order_id'] != '': # 按 pt_order_id 查活动订单详情 r = db.pt_order.find_one({'pt_order_id': param['pt_order_id']}) r2 = db.pt_store.find_one({'tuan_id': r['tuan_id']}, {'title': 1}) return render.report_pt_order_detail( helper.get_session_uname(), helper.get_privilege_name(), r, helper.PT_REGION, r2['title']) else: # 清单 db_sku = db.pt_store.find({}, { 'tuan_id': 1, 'title': 1, 'region_id': 1, }).sort([('_id', 1)]) pt_orders = {} skus = [] for i in db_sku: r = db.pt_order.find({'tuan_id': i['tuan_id']}, {'status': 1}) succ1 = open1 = fail1 = 0 for j in r: if j['status'] == 'OPEN': open1 += 1 elif j['status'] == 'SUCC': succ1 += 1 elif j['status'] in ['FAIL1', 'FAIL2', 'FAIL3']: fail1 += 1 pt_orders[i['tuan_id']] = (succ1, open1, fail1) skus.append({ '_id': i['_id'], 'tuan_id': i['tuan_id'], 'title': i['title'], 'region_id': i['region_id'], 'pt_orders': (succ1, open1, fail1), }) return render.report_pt_store(helper.get_session_uname(), helper.get_privilege_name(), skus, helper.PT_REGION) else: raise web.seeother('/')
def GET(self): # 计算盘点数据 if helper.logged(helper.PRIV_USER, 'POS_AUDIT'): render = helper.create_render() user_data = web.input(audit='', cat='2') if user_data.audit == '': return render.info('参数错误!') # 查找shop db_shop = helper.get_shop_by_uid() # 是否还有未结束账期的 db_audit = db.shop_audit.find_one({ '_id': ObjectId(user_data.audit), 'shop': db_shop['shop'], }) if db_audit == None: return render.info('未查到账期数据!') audit_stock = db_audit['stock'].copy() skus = [] for i in audit_stock.keys(): skus.append(audit_stock[i]['sku']) #print skus # 取得sku信息 db_sku = db.sku_store.find({'_id': { '$in': skus }}, { 'unit': 1, 'base_sku': 1 }) tmp_sku = {} for i in db_sku: base_sku = db.dereference(i['base_sku']) tmp_sku[i['_id']] = (base_sku['name'], helper.UNIT_TYPE[i['unit']]) #print tmp_sku if user_data.cat == '1': return render.pos_audit_commit( helper.get_session_uname(), helper.get_privilege_name(), (db_audit['begin_date'], db_audit['end_date']), audit_stock, tmp_sku, (db_audit['revenue'], db_audit['cost'], db_audit['gross'], db_audit['loss'])) else: return render.pos_audit_commit2( helper.get_session_uname(), helper.get_privilege_name(), (db_audit['begin_date'], db_audit['end_date']), audit_stock, tmp_sku, (db_audit['revenue'], db_audit['cost'], db_audit['gross'], db_audit['loss'])) else: raise web.seeother('/')
def GET(self): if not helper.logged(helper.PRIV_USER, 'TICKET_OP'): raise web.seeother('/') render = helper.create_render() user_data = web.input(ticket_id='', follow_id='') if user_data.ticket_id == '': return render.info('参数错误!') # 用户列表, 及东华用户列表 user_list = {} db_user = db.user.find({}) for u in db_user: if u['login'] == 0: continue if 'TICKET_OP' in helper.get_privilege_name( u['privilege'], u['menu_level']): user_list[u['uname']] = u['full_name'] # 准备数据 follow_data = {'follow_id': 'n/a'} image_list = [] db_obj = db.ticket.find_one({'_id': ObjectId(user_data.ticket_id)}) if db_obj is None: return render.info('未找到问题数据!') follow_list = db_obj.get('follow_list') if user_data['follow_id'].isdigit() and len(follow_list) > int( user_data['follow_id']): # 修改帖子 # 已存在的follow follow_id = int(user_data['follow_id']) follow_data = follow_list[follow_id] follow_data['follow_id'] = follow_id # 只有回复人本人才能修改 if follow_data['follow_uid'] != helper.get_session_uname(): return render.info('不是回复人本人,不能修改!') follow_data['ticket_id'] = user_data.ticket_id for x in follow_data.get('images', []): r2 = db.base_image.find_one({'image': x}) if r2: image_list.append((x, r2['file'])) # 对于只保存一半数据的记录处理 follow_data['follow_uid'] = helper.get_session_uname() follow_data['follow_name'] = user_list[helper.get_session_uname()] return render.ticket_follow(helper.get_session_uname(), helper.get_privilege_name(), follow_data, image_list, user_list)
def GET(self): if not helper.logged(helper.PRIV_USER, 'TICKET_OP'): raise web.seeother('/') render = helper.create_render() user_data = web.input(ticket_id='') # 用户列表, 及东华用户列表 user_list = {} db_user = db.user.find({}) for u in db_user: if u['login'] == 0: continue if 'TICKET_OP' in helper.get_privilege_name( u['privilege'], u['menu_level']): user_list[u['uname']] = u['full_name'] # 准备数据 ticket_data = {'ticket_id': 'n/a', 'status': 'OPEN'} image_list = [] if user_data.ticket_id == '': return render.info('参数错误!') db_obj = db.ticket.find_one({'_id': ObjectId(user_data.ticket_id)}) if db_obj is None: return render.info('未找到数据!') # 已存在的obj ticket_data = db_obj ticket_data['ticket_id'] = ticket_data['_id'] # 处理问题里的附件 for x in db_obj.get('images', []): r2 = db.base_image.find_one({'image': x}) if r2: image_list.append((x, r2['file'])) # 处理回复帖子里的附件 for xx in db_obj.get('follow_list', []): xx['image_list'] = [] for x in xx.get('images', []): r2 = db.base_image.find_one({'image': x}) if r2: xx['image_list'].append((x, r2['file'])) # 对于只保存一半数据的记录处理 ticket_data['open_name'] = user_list[ticket_data['open_uid']] return render.ticket_thread(helper.get_session_uname(), helper.get_privilege_name(), ticket_data, user_list, helper.TICKET_TYPE, helper.TICKET_SOURCE, helper.TICKET_STATUS, image_list)
def GET(self): if not logged(helper.PRIV_USER | helper.PRIV_MCH): raise web.seeother('/') render = create_render() if web.input(set_pwd='')['set_pwd'] == '1': return render.settings_user(session.uname, get_privilege_name(), self._get_settings(), '请重新设置密码') else: return render.settings_user(session.uname, get_privilege_name(), self._get_settings())
def GET(self): if helper.logged(helper.PRIV_USER,'POS_REPORT_USER'): render = helper.create_render(globals={'round':round}) user_data=web.input(start_date='') if user_data['start_date']=='': return render.pos_report_user(helper.get_session_uname(), helper.get_privilege_name()) # 查找shop db_shop = helper.get_shop_by_uid() begin_date = '%s 00:00:00' % user_data['start_date'] end_date = '%s 23:59:59' % user_data['start_date'] #print begin_date, end_date, db_shop['_id'] # 统计销货 db_sale = db.order_offline.find({ 'shop' : db_shop['shop'], 'user' : helper.get_session_uname(), 'status' : 'PAID', '$and' : [{'paid_time' : {'$gt' : begin_date}}, {'paid_time' : {'$lt' : end_date}}], }, {'order_id':1,'due':1,'pay':1,'change':1,'paid_time':1}) # 销货单流水 total = 0.0 count = 0 for i in db_sale: count += 1 total += float(i['due']) # 统计退货 db_return = db.order_return.find({ 'shop' : db_shop['shop'], 'user' : helper.get_session_uname(), '$and' : [{'return_time' : {'$gt' : begin_date}}, {'return_time' : {'$lt' : end_date}}], }, {'total':1,'return_time':1}) # 退货单流水 total2 = 0.0 count2 = 0 for i in db_return: count2 += 1 total2 += float(i['total']) return render.pos_report_user_ret(helper.get_session_uname(), helper.get_privilege_name(), count, total, count2, total2, user_data.start_date) else: raise web.seeother('/')
def GET(self): if helper.logged(helper.PRIV_USER, 'REPORT_VOICE'): render = helper.create_render() #user_data=web.input(start_date='', shop='__ALL__', ret_type='table') # 显示最近30天的 start_date = helper.time_str(time.time() - 3600 * 24 * 30, format=1) # 起至时间 begin_date = '%s 00:00:00' % start_date #end_date = '%s 23:59:59' % start_date #print begin_date, end_date # db_voice = db.customer_voice.find({ 'time': { '$gt': begin_date } }, { '_id': 0 }).sort([('_id', -1)]) return render.report_voice(helper.get_session_uname(), helper.get_privilege_name(), db_voice) else: raise web.seeother('/')
def GET(self): if not helper.logged(helper.PRIV_MCH, 'TOPIC_STORE'): raise web.seeother('/') mch_id = helper.get_session_mch_id() render = helper.create_render() user_data = web.input(tpc_id='') obj_data = {'tpc_id': 'n/a'} obj_list = [] if user_data.tpc_id != '': db_obj = db.topic_store.find_one({ 'tpc_id': user_data.tpc_id, 'mch_id': mch_id }) if db_obj is not None: # 已存在的obj obj_data = db_obj obj_list = db.obj_store.find({ 'obj_type': 'topic', 'tpc_id': user_data.tpc_id }) return render.topic_store_edit(helper.get_session_uname(), helper.get_privilege_name(), obj_data, obj_list)
def GET(self): if not helper.logged(helper.PRIV_USER, 'CATEGORY'): raise web.seeother('/') render = helper.create_render() user_data = web.input() # 专辑上架商品 r2 = db.online_topic_obj.find(sort=[('sort_weight', 1)]) online_obj = [i['tpc_id'] for i in r2] # 可上架的专辑 all_obj = {} r3 = db.topic_store.find({'status': 'PASSED'}) for i in r3: all_obj[i['tpc_id']] = { 'tpc_name': i['tpc_name'], 'mch_id': i['mch_id'], 'tpc_id': i['tpc_id'] } # 所有商家 all_mch = {} r4 = db.merchant.find({'available': 1}) for i in r4: all_mch[i['mch_id']] = i['mch_name'] return render.topic_plat_edit(helper.get_session_uname(), helper.get_privilege_name(), online_obj, all_obj, all_mch)
def GET(self): if not helper.logged(helper.PRIV_MCH, 'OBJ_STORE'): raise web.seeother('/') mch_id = helper.get_session_mch_id() render = helper.create_render() user_data = web.input(obj_id='', exam_id='') if user_data.obj_id.strip() == '': return render.info('obj_id不能为空!') exam_data = {'exam_id': 'n/a'} if user_data.exam_id != '': db_exam = db.exam_info.find_one({ 'exam_id': user_data.exam_id, 'mch_id': mch_id }) if db_exam != None: # 已存在的obj exam_data = db_exam return render.exam_edit(helper.get_session_uname(), helper.get_privilege_name(), exam_data, user_data.obj_id)
def GET(self): if logged(helper.PRIV_USER): render = create_render() user_data = web.input(todo='') if user_data.todo == '': return render.info('参数错误!') auth_level = -1 if session.uname in setting.auth_user: auth_level = 999 elif session.uname in setting.cs_admin: auth_level = 1 db_todo = db.order_app.find_one({'order_id': user_data.todo}) if db_todo != None: db_shop = db.base_shop.find_one({'_id': db_todo['shop']}) if db_todo.has_key('shop_0'): db_shop_0 = db.base_shop.find_one( {'_id': db_todo['shop_0']}) else: db_shop_0 = {'name': 'n/a'} return render.view_event( session.uname, get_privilege_name(), user_data.todo, db_todo, int(time.time() - db_todo['e_time']), auth_level, (db_shop['name'], db_shop_0['name']), helper.ORDER_STATUS['APP'][db_todo['status']]) # 授权客服才能修改 else: return render.info('出错,请重新提交。') else: raise web.seeother('/')
def GET(self): if helper.logged(helper.PRIV_USER, 'PLAT_BASE_SKU'): render = helper.create_render() skus = [] db_sku = db.base_sku.find({}, { 'name': 1, 'note': 1, 'available': 1, 'image': 1, 'original': 1, }).sort([('_id', 1)]) for u in db_sku: skus.append(( u['_id'], u['name'], u['note'], u['available'], u['image'][0] if u.has_key('image') and len(u['image']) > 0 else '', u['original'], )) return render.base_sku(helper.get_session_uname(), helper.get_privilege_name(), skus) else: raise web.seeother('/')
def POST(self): import re if logged(helper.PRIV_USER, 'CRM'): render = create_render() user_data = web.input(cat='', content='') if user_data.cat == '' or user_data.content == '': return render.info('错误的参数!') condi = { user_data.cat: { '$in': [ re.compile('^.*%s.*' % user_data.content.strip().encode('utf-8')) ] }, #'status':{'$nin':['TIMEOUT']} } db_todo = db.order_app.find(condi, { 'order_id': 1, 'uname': 1, 'paid_time': 1, 'status': 1 }).sort([('b_time', -1)]) if db_todo.count() > 0: return render.report_order(session.uname, get_privilege_name(), db_todo, helper.ORDER_STATUS) else: return render.info('未查到订单信息。') else: raise web.seeother('/')
def GET(self): if helper.logged(helper.PRIV_USER, 'CRM'): render = helper.create_render() return render.crm(helper.get_session_uname(), helper.get_privilege_name()) else: raise web.seeother('/')
def GET(self): if helper.logged(helper.PRIV_USER,'PLAT_SKU_STORE'): render = helper.create_render() skus=[] db_sku=db.sku_store.find({},{ 'product_id' : 1, 'base_sku' : 1, 'note' : 1, 'available' : 1, 'is_pack' : 1, 'unit' : 1, #'unit_num' : 1, 'ref_price' : 1, 'ref_cost' : 1, 'list_in_app': 1, 'app_title' : 1, }).sort([('_id',1)]) for u in db_sku: base_sku = db.dereference(u['base_sku']) # 准备数据 skus.append((u['_id'], base_sku['name'] if len(u['app_title'].strip())==0 else u['app_title'], u['note'], u['available'], base_sku['image'][0] if base_sku.has_key('image') and len(base_sku['image'])>0 else '', '', helper.UNIT_TYPE[u['unit']], u['is_pack'], u['ref_price'], u['product_id'], u['ref_cost'], u['list_in_app'] )) return render.sku_store(helper.get_session_uname(), helper.get_privilege_name(), skus) else: raise web.seeother('/')
def GET(self): if not logged(helper.PRIV_ADMIN): raise web.seeother('/') render = create_render() user_data = web.input(uid='') r3 = db.merchant.find({'available': 1}) db_user = { '_id': 'n/a', 'menu_level': 60 * '-', 'time': int(time.time()) } if user_data.uid != '': r2 = db.user.find_one({'_id': ObjectId(user_data.uid)}) if r2: db_user = r2 if db_user['_id'] == 'n/a': user_level_name = [] else: user_level_name = get_privilege_name(db_user['privilege'], db_user['menu_level']) return render.user_setting(session.uname, user_level[session.privilege], db_user, time_str(db_user['time']), user_level_name, r3)
def GET(self): if helper.logged(helper.PRIV_USER, 'REPORT_QUERY'): render = helper.create_render() return render.report_query(helper.get_session_uname(), helper.get_privilege_name()) else: raise web.seeother('/')
def GET(self): if logged(helper.PRIV_ADMIN): render = create_render() user_data = web.input(uid='') if user_data.uid == '': return render.info('错误的参数!') db_user = db.user.find_one({'_id': ObjectId(user_data.uid)}) if db_user != None: db_shop = db.base_shop.find( { 'available': 1, 'type': { '$in': ['chain', 'store', 'dark'] } }, { 'name': 1, 'type': 1 }) shops = [] for s in db_shop: shops.append( (s['_id'], s['name'], helper.SHOP_TYPE[s['type']])) return render.user_setting( session.uname, user_level[session.privilege], db_user, time_str(db_user['time']), get_privilege_name(db_user['privilege'], db_user['menu_level']), shops) else: return render.info('错误的参数!') else: raise web.seeother('/')
def GET(self): if not helper.logged(helper.PRIV_USER, 'CHECK_OBJ'): raise web.seeother('/') user_data=web.input(page='0') render = helper.create_render() if not user_data['page'].isdigit(): return render.info('参数错误!') db_sku = db.obj_store.find({'obj_type':'course','status':{'$in':['WAIT', 'PASSED', 'DENY']}}, # 只显示精品课程 sort=[('obj_id', -1)], limit=PAGE_SIZE, skip=int(user_data['page'])*PAGE_SIZE ) sku_data = [] for x in db_sku: one = { 'obj_id' : x['obj_id'], 'obj_name' : x['obj_name'], 'title' : x['title'], 'price' : x['price'], 'note' : x['note'], 'status' : x.get('status','SAVED'), } sku_data.append(one) num = db_sku.count() if num%PAGE_SIZE>0: num = num / PAGE_SIZE + 1 else: num = num / PAGE_SIZE return render.check_obj(helper.get_session_uname(), helper.get_privilege_name(), sku_data, range(0, num), helper.OBJ_STATUS)
def GET(self): if logged(helper.PRIV_USER): render = create_render() return render.settings_user(session.uname, get_privilege_name(), self._get_settings()) else: raise web.seeother('/')
def GET(self): if helper.logged(helper.PRIV_DELIVERY, 'DELVERY_ORDER'): render = helper.create_render(globals={'str': str}) user_data = web.input(order='', status='') if '' in (user_data.order, user_data.status): return render.info('错误的参数!') # 查找门店 db_shop = helper.get_shop_by_uid() # 查询工单信息 db_order = db.order_app.find_one({ 'order_id': user_data.order, 'shop': ObjectId(db_shop['shop']) }) if db_order == None: return render.info('order错误的参数!') # 查询 站点信息 s = db.base_shop.find_one({'_id': db_shop['shop']}, { 'name': 1, 'type': 1 }) shop_name = '%s(%s)' % (s['name'].encode('utf-8'), helper.SHOP_TYPE[s['type']]) return render.delivery_order_view(helper.get_session_uname(), helper.get_privilege_name(), db_order, shop_name, user_data.status, helper.ORDER_STATUS, db_order['history']) else: raise web.seeother('/')
def GET(self): if helper.logged(helper.PRIV_USER,'PLAT_PT_STORE'): render = helper.create_render() return render.pt_store_new(helper.get_session_uname(), helper.get_privilege_name(), helper.PT_REGION) else: raise web.seeother('/')
def GET(self): if helper.logged(helper.PRIV_USER, 'PLAT_BASE_SKU'): render = helper.create_render() return render.base_sku_new(helper.get_session_uname(), helper.get_privilege_name()) else: raise web.seeother('/')
def GET(self): if helper.logged(helper.PRIV_USER, 'STOCK_INVENTORY'): render = helper.create_render() user_data = web.input(sku='') if user_data.sku == '': return render.info('错误的参数!') db_sku = db.sku_store.find_one({'_id': ObjectId(user_data.sku)}) if db_sku != None: db_shop = db.base_shop.find({'available': 1}, { 'name': 1, 'type': 1 }) shops = [] for s in db_shop: shops.append( (s['_id'], s['name'], helper.SHOP_TYPE[s['type']])) base_sku = db.dereference(db_sku['base_sku']) return render.stock_invent_edit( helper.get_session_uname(), helper.get_privilege_name(), db_sku, { 'name': base_sku['name'], 'original': base_sku['original'] }, helper.UNIT_TYPE, shops) else: return render.info('错误的参数!') else: raise web.seeother('/')
def GET(self): if helper.logged(helper.PRIV_USER): render = helper.create_render() user_data = web.input(sku='') if user_data.sku == '': return render.info('错误的参数!') # 检查用户是否有此店权限 db_shop = helper.get_shop_by_uid() # 查找店面信息 db_shop2 = helper.get_shop(db_shop['shop']) if db_shop2 == None: return render.info('未找到所属门店!') db_sku = db.sku_store.find_one({'_id': ObjectId(user_data.sku)}) if db_sku != None: base_sku = db.dereference(db_sku['base_sku']) return render.damage_sku( helper.get_session_uname(), helper.get_privilege_name(), db_sku, { 'name': base_sku['name'], 'original': base_sku['original'] }, helper.UNIT_TYPE, (str(db_shop2['_id']), db_shop2['name'], helper.SHOP_TYPE[db_shop2['type']]), helper.get_inventory(ObjectId(user_data.sku), db_shop['shop'])) else: return render.info('错误的参数!') else: raise web.seeother('/')
def GET(self): if not helper.logged(helper.PRIV_USER, 'DOCTOR_USE'): raise web.seeother('/') user_data = web.input(page='0') render = helper.create_render() if not user_data['page'].isdigit(): return render.info('参数错误!') # 分页获取数据 db_sku = db.pages.find({ 'first_page': 1, 'available': 1 }, sort=[('page_code', 1)], limit=PAGE_SIZE, skip=int(user_data['page']) * PAGE_SIZE) num = db_sku.count() if num % PAGE_SIZE > 0: num = num / PAGE_SIZE + 1 else: num = num / PAGE_SIZE return render.diagnose(helper.get_session_uname(), helper.get_privilege_name(), db_sku, range(0, num))
def GET(self): if helper.logged(helper.PRIV_USER, 'PLAT_BASE_SHOP'): render = helper.create_render(plain=True) db_shop = db.base_shop.find( { 'type': { '$in': ['chain', 'store', 'dark', 'counter'] } }, { 'name': 1, 'type': 1, 'poly': 1, 'poly_xy': 1, 'app_shop': 1, }).sort([('_id', 1)]) data = [] for i in db_shop: data.append({ 'id': i['_id'], 'name': i['name'], 'poly': i.get('poly', ''), 'poly_xy': i.get('poly_xy', []), 'app_shop': i.get('app_shop', 0) }) return render.map_shops(helper.get_session_uname(), helper.get_privilege_name(), data) else: raise web.seeother('/')
def GET(self): if not helper.logged(helper.PRIV_USER, 'TALKBOT'): raise web.seeother('/') user_data = web.input(page='0', rule_name='') render = helper.create_render() if not user_data['page'].isdigit(): return render.info('参数错误!') conditions = {} rule_name = user_data.rule_name.strip() if rule_name != '': conditions = { '$or': [ { 'key_word': { '$regex': u'%s.*' % (rule_name.replace('*', '\\*').replace( '?', '\\?')), '$options': 'i' } }, { 'reply': { '$regex': u'%s.*' % (rule_name.replace('*', '\\*').replace( '?', '\\?')), '$options': 'i' } }, { 'rule_name': { '$regex': u'%s.*' % (rule_name.replace('*', '\\*').replace( '?', '\\?')), '$options': 'i' } }, ] } # 分页获取数据 db_sku = db.bayes.find(conditions, sort=[('available', -1), ('rule_name', 1)], limit=PAGE_SIZE, skip=int(user_data['page']) * PAGE_SIZE) num = db_sku.count() if num % PAGE_SIZE > 0: num = num / PAGE_SIZE + 1 else: num = num / PAGE_SIZE return render.bayes(helper.get_session_uname(), helper.get_privilege_name(), db_sku, range(0, num), rule_name, int(user_data['page']))
def GET(self): if helper.logged(helper.PRIV_USER, 'BATCH_JOB'): render = helper.create_render() user_data = web.input(tuan_id='', sheng='') # 查找shop db_shop = helper.get_shop_by_uid() shop_name = helper.get_shop(db_shop['shop']) # 统计线上订单 condition = { 'shop': db_shop['shop'], 'status': 'PAID', 'type': { '$in': ['TUAN', 'SINGLE'] }, # 目前只拼团用 'address.8': re.compile('^%s.*' % user_data.sheng.strip().encode('utf-8')) } db_sale2 = db.order_app.find( condition, { 'order_id': 1, 'paid_time': 1, 'cart': 1, 'type': 1, 'status': 1, 'address': 1, }).sort([('_id', 1)]) r = db.pt_store.find_one({'tuan_id': user_data['tuan_id']}, {'title': 1}) if r: title = r['title'] else: title = 'n/a' skus = [] count = 0 for i in db_sale2: if i['cart'][0]['tuan_id'] != user_data['tuan_id']: continue else: # 只记录知道活动的订单号 skus.append(i['order_id']) count += 1 if count == 100: # 一次只处理100个 break return render.batch_paid(helper.get_session_uname(), helper.get_privilege_name(), skus, len(skus), shop_name, user_data['tuan_id'], title, user_data['sheng']) else: raise web.seeother('/')