Ejemplo n.º 1
0
    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('/')
Ejemplo n.º 2
0
    def GET(self):
        if helper.logged(helper.PRIV_USER):
            render = helper.create_render()
            user_data = web.input(todo='')

            if user_data.todo == '':
                return render.info('参数错误!')

            auth_level = -1
            session_uname = helper.get_session_uname()
            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:

                # 获取订单购物车中商品信息
                product_detail = []  # 产品及对应详情
                for index, u in enumerate(db_todo['cart']):
                    data = {
                        'product_id': u['product_id'],
                        'title': u['title'],
                        'num': int(u['num2']),
                        'price': '%.2f' % (float(u['price']) / int(u['num2'])),
                        'total_fee': u['price'],
                    }
                    product_detail.append(data)

                # due减去运费 2016-06-20 lf
                due_no_delivery = float(db_todo['due']) - float(
                    db_todo.get('delivery_fee', '0.00'))
                # 计算总已退款金额
                old_refund_total = '0.00'
                if db_todo.get('refund_his', '') != '':
                    for fee in db_todo['refund_his']:
                        old_refund_total = float(old_refund_total) + float(
                            fee.values()[0])
                max_refund_fee = '%.2f' % (float(db_todo['due']) -
                                           float(old_refund_total))

                # 地址省份
                county_name, _, _ = city_code.county_id_to_city_name(
                    db_todo['address'][8])

                return render.view_event(
                    helper.get_session_uname(), helper.get_privilege_name(),
                    user_data.todo, db_todo,
                    int(time.time() - db_todo['e_time']), auth_level,
                    helper.ORDER_STATUS[db_todo['status']],
                    helper.REFUND_REASON, product_detail, due_no_delivery,
                    max_refund_fee, county_name)  # 授权客服才能修改
            else:
                return render.info('出错,请重新提交。')
        else:
            raise web.seeother('/')
Ejemplo n.º 3
0
    def GET(self):
        if helper.logged(helper.PRIV_DELIVERY, 'DELVERY_ORDER'):
            render = helper.create_render(globals={'str': str})
            param = web.input(status='')

            if param.status == '':
                return render.info('错误的参数!')

            # 查找门店
            db_shop = helper.get_shop_by_uid()

            condition = {
                'shop': ObjectId(db_shop['shop']),
                'runner.uname': helper.get_session_uname(),
            }
            if param.status == 'DISPATCH':
                condition['status'] = 'DISPATCH'
            elif param.status == 'ONROAD':
                condition['status'] = 'ONROAD'
            elif param.status == 'COMPLETE':
                condition['status'] = 'COMPLETE'
            else:
                condition['status'] = {
                    '$nin':
                    ['COMPLETE', 'DISPATCH', 'ONROAD', 'DUE', 'TIMEOUT']
                }

            if param.status in ['COMPLETE']:
                tday = helper.time_str(format=1)
                begin_d = '%s 00:00:00' % tday
                end_d = '%s 23:59:59' % tday
                begin_t = int(
                    time.mktime(time.strptime(begin_d, "%Y-%m-%d %H:%M:%S")))
                end_t = int(
                    time.mktime(time.strptime(end_d, "%Y-%m-%d %H:%M:%S")))
                condition['$and'] = [{
                    'b_time': {
                        '$gt': begin_t
                    }
                }, {
                    'b_time': {
                        '$lt': end_t
                    }
                }]

            db_order = db.order_app.find(condition, {
                'order_id': 1,
                'status': 1,
                'address': 1,
                'history': 1
            }).sort([('_id', 1)])
            return render.delivery_order(helper.get_session_uname(),
                                         helper.get_privilege_name(), db_order,
                                         helper.ORDER_STATUS, param.status)
        else:
            raise web.seeother('/')
Ejemplo n.º 4
0
    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)
Ejemplo n.º 5
0
    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('/')
Ejemplo n.º 6
0
    def POST(self):
        if not helper.logged(helper.PRIV_USER, 'DATA_MODIFY'):
            raise web.seeother('/')
        render = helper.create_render()
        user_data = web.input(note_id='', note_code='', note_content='')

        note_code = user_data.note_code.strip().upper()  # note_code 都是用大写字母
        if note_code == '':
            return render.info('索引编码不能为空!')

        version = user_data.version.strip()

        # 排除同名
        find_condition = {'note_code': note_code, 'version': version}

        if user_data['note_id'] == 'n/a':  # 新建
            note_id = None
            message = '新建'
        else:
            note_id = ObjectId(user_data['note_id'])
            message = '修改'
            find_condition['_id'] = {'$ne': note_id}  # 排除自己

        r1 = db.notes.find_one(find_condition)
        if r1 is not None:
            return render.info('索引编码已存在,不能重复!')

        try:
            update_set = {
                'note_code': note_code,
                'version': version,  # 版本说明  2018-10-18
                'note_content': user_data['note_content'],
                'last_tick': int(time.time()),  # 更新时间戳
                'weight': int(user_data['weight']),
            }
        except ValueError:
            return render.info('请在相应字段输入数字!')

        if note_id is None:
            update_set['history'] = [(helper.time_str(),
                                      helper.get_session_uname(), message)]
            r2 = db.notes.insert_one(update_set)
        else:
            db.notes.update_one(
                {'_id': note_id},
                {
                    '$set': update_set,
                    '$push': {
                        'history': (helper.time_str(),
                                    helper.get_session_uname(), message),
                    }  # 纪录操作历史
                })

        return render.info('成功保存!', '/plat/notes')
Ejemplo n.º 7
0
	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('/')
Ejemplo n.º 8
0
    def POST(self):
        if helper.logged(helper.PRIV_USER):
            render = helper.create_render()
            user_data = web.input(product_id='', weight='')

            if '' in (user_data.product_id, user_data.weight):
                return json.dumps({'ret': -1, 'msg': '参数错误'})

            #  取得门店id
            db_shop = helper.get_shop_by_uid()

            # 报损数量/重量
            if user_data['product_id'][2] in ('1', '3'):
                weight = int(user_data['weight'])
            else:
                weight = float(user_data['weight'])

            db.order_damage.insert_one({
                'shop':
                db_shop['shop'],
                'product_id':
                user_data['product_id'],
                'num':
                '%.2f' % weight,
                'history': [(helper.time_str(), helper.get_session_uname(),
                             '报损操作')],  # 纪录操作历史
            })

            # 调整站点库存,
            r = db.inventory.update_one(  # u-prod
                {
                    'shop': db_shop['shop'],
                    'product_id': user_data['product_id'],
                },
                {
                    '$inc': {
                        'num': 0 - weight
                    },  # 减少库存
                    '$push': {
                        'history':
                        (helper.time_str(), helper.get_session_uname(),
                         '报损操作导致库存减少 %.2f ' % float(weight))
                    },
                })
            # 更新第3方库存 2015-10-10
            helper.elm_modify_num(db_shop['shop'], user_data['product_id'])

            return render.info('已报损!数量:%.2f。' % weight, '/pos/inventory')
        else:
            raise web.seeother('/')
Ejemplo n.º 9
0
    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('/')
Ejemplo n.º 10
0
	def POST(self):
		if helper.logged(helper.PRIV_USER,'APP_PUSH'):
			render = helper.create_render()
			user_data=web.input(phone='',content='')

			if user_data.phone.strip()=='': # 发送全部
				r=jpush.jpush(user_data.content)
				#r = False # 测试时关闭全部发送
			else:
				# 发送指定号码,最多1000个号码
				r=jpush.jpush(user_data.content, user_data.phone)

			# 记录发送日志
			db.jpush_log.insert({ 
				'push_time' : helper.time_str(),
				'user'      : helper.get_session_uname(),
				'phone'     : user_data.phone.strip(),
				'content'   : user_data.content,
				'result'    : r
			})

			if r!=False:
				return render.info('发送成功! '+r,'/plat/push_msg')
			else:
				return render.info('发送失败!','/plat/push_msg')
		else:
		    raise web.seeother('/')
Ejemplo n.º 11
0
 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('/')
Ejemplo n.º 12
0
    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('/')
Ejemplo n.º 13
0
 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('/')
Ejemplo n.º 14
0
    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)
Ejemplo n.º 15
0
    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('/')
Ejemplo n.º 16
0
    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)
Ejemplo n.º 17
0
    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('/')
Ejemplo n.º 18
0
    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)
Ejemplo n.º 19
0
 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('/')
Ejemplo n.º 20
0
def topic_change_status(tpc_id, status, comment='审核状态修改', check_comment=''):
    # 修改专辑状态
    update_set = {'status': status}
    if len(check_comment) > 0:
        update_set['check_comment'] = check_comment

    db.topic_store.update_one(
        {'tpc_id': tpc_id},
        {
            '$set': update_set,
            '$push': {
                'history':
                (helper.time_str(), helper.get_session_uname(), comment),
            }  # 纪录操作历史
        })

    # 专辑下商品同时更新状态
    db.obj_store.update_many({
        'obj_type': 'topic',
        'tpc_id': tpc_id
    }, {
        '$set': {
            'status': status
        },
    })
Ejemplo n.º 21
0
	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('/')
Ejemplo n.º 22
0
    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)
Ejemplo n.º 23
0
    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('/')
Ejemplo n.º 24
0
    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))
Ejemplo n.º 25
0
    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']))
Ejemplo n.º 26
0
    def POST(self):
        web.header("Content-Type", "application/json")
        if helper.logged(helper.PRIV_USER, 'POS_INVENTORY'):
            user_data = web.input(product_id='', online='')

            if '' in (user_data.product_id, user_data.online):
                return json.dumps({'ret': -1, 'msg': '参数错误'})

            # 查找shop
            db_shop = helper.get_shop_by_uid()

            db_invent = db.inventory.update_one(
                {
                    'product_id': user_data.product_id,
                    'shop': db_shop['shop'],
                }, {
                    '$set': {
                        'online': int(user_data.online)
                    },
                    '$push': {
                        'history':
                        (helper.time_str(), helper.get_session_uname(),
                         '上下架标志修改为 %s' % str(user_data.online))
                    },
                })

            return json.dumps({'ret': 0, 'msg': '操作完成'})
        else:
            return json.dumps({'ret': -3, 'msg': '无权限访问'})
Ejemplo n.º 27
0
    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('/')
Ejemplo n.º 28
0
	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('/')
Ejemplo n.º 29
0
    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('/')
Ejemplo n.º 30
0
    def POST(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='')

        if user_data.tpc_name.strip() == '':
            return render.info('品名不能为空!')

        if user_data['tpc_id'] == 'n/a':  # 新建
            db_pk = db.user.find_one_and_update({'uname': 'settings'},
                                                {'$inc': {
                                                    'sa_count': 1
                                                }}, {'sa_count': 1})
            tpc_id = '2%07d' % db_pk['sa_count']
            message = '新建'
        else:
            tpc_id = user_data['tpc_id']
            message = '修改'

        try:
            update_set = {
                'tpc_id': tpc_id,
                'tpc_name': user_data['tpc_name'],
                'title': user_data['title'],
                'title2': user_data['title2'],
                'description': user_data['description'],
                'note': user_data['note'],
                'last_tick': int(time.time()),  # 更新时间戳
                'image': user_data['image'].split(','),  # 图片
                'price': int(float(user_data['price']) * 100),  # 单位: 分
                'status':
                'SAVED',  # 审核状态: SAVED 已修改未提交 WAIT 提交等待审核  PASS 审核通过 NOGO 审核拒绝
            }
        except ValueError:
            return render.info('请在相应字段输入数字!')

        r2 = db.topic_store.find_one_and_update(
            {
                'tpc_id': tpc_id,
                'mch_id': mch_id
            },
            {
                '$set': update_set,
                '$push': {
                    'history':
                    (helper.time_str(), helper.get_session_uname(), message),
                }  # 纪录操作历史
            },
            upsert=True)

        if r2 and r2.get('status') != 'SAVED':
            object_helper.topic_change_status(tpc_id, 'SAVED', u'专辑修改')

        return render.info('成功保存!', '/mch/topic_store')