Ejemplo n.º 1
0
    def handler_function(self):
        args = self.get_request_data()

        newPermissions = {}
        for p in UserConfig.permissions:
            if p in args['setPermissions']:
                newPermissions[p] = 1
            else:
                newPermissions[p] = 0

        DBOps.setOneDoc(
            DBCollonfig.users,
            {'_id': args['_id']},
            {
                '$set': {
                    # 'department': args['department'],
                    'company': args['company'],
                    'tel': args['tel'],
                    'email': args['email'],
                    'qq': args['qq'],
                    'permissions': newPermissions
                }
            })

        # 记录日志
        LogDBOps.writeLog(args['opsUserId'], LogDBConfig.doEditUser)

        args['permissions'] = newPermissions
        self.result['result'] = {'userObj': AccountUtil.resUserData(args)}
        return self.response_success(msg=args['username'] + u'用户信息设置成功!')
Ejemplo n.º 2
0
    def handler_function(self):
        args = self.get_request_data()
        token = args.get('token', None)

        if token:
            setToken, header = Authentication.getVerifyToken(token)
            if setToken.has_key('userId'):
                userId = setToken['userId']
                user = DBOps.getOneDoc(DBCollonfig.users, {'_id': userId})

                DBOps.setOneDoc(DBCollonfig.users, {'_id': user['_id']}, {
                    '$set': {
                        'lastLogin':
                        datetime.now().strftime('%Y-%m-%d %H:%M:%S')
                    }
                })

                self.result['result'] = {
                    'userObj': AccountUtil.resUserData(user)
                }

                return self.response_success()
            else:
                self.result['result'] = {'userObj': None}
                return self.response_failure(u'登录过期')
        else:
            self.result['result'] = {'userObj': None}
            return self.response_failure(u'没有登录')
Ejemplo n.º 3
0
    def handler_function(self):
        args = self.get_request_data()

        username = args['username']
        password = args['password']

        user = DBOps.getOneDoc(DBCollonfig.users, {'username': username})

        if not user:
            return self.response_failure(username + u'用户不存在')

        if user['password'] != Encrypt.password_encrypt(password):
            return self.response_failure(username + u'用户密码错误')

        DBOps.setOneDoc(DBCollonfig.users, {'_id': user['_id']}, {
            '$set': {
                'lastLogin': datetime.now().strftime('%Y-%m-%d %H:%M:%S')
            }
        })

        self.result['result'] = {
            'userObj': AccountUtil.resUserData(user),
            'token': Authentication.generateToken(user['_id'])
        }

        # 记录日志
        LogDBOps.writeLog(user['_id'], LogDBConfig.doLogin)

        return self.response_success()
Ejemplo n.º 4
0
    def handler_function(self):
        args = self.get_request_data()

        DBOps.setOneDoc(DBCollonfig.users, {'_id': args['userId']},
                        {'$set': {
                            'navCollapse': args['setCollapse']
                        }})

        self.response_success()
Ejemplo n.º 5
0
    def handler_function(self):
        args = self.get_request_data()

        createUser = args.get('createUser', None)
        newContacts = args.get('contacts', None)

        error_list = []
        for each in newContacts:
            isExist = DBOps.getOneDoc(
                DBCollonfig.options,
                {
                    '_id': DBCollonfig.orderOption,
                    'contacts.name': each['name']
                }
            )
            if isExist:
                error_list.append(each['name'])

        if error_list:
            msg = u','.join([err for err in error_list]) + u'已存在'
            return self.response_failure(msg=msg)

        for each in newContacts:
            DBOps.setOneDoc(
                DBCollonfig.options,
                {'_id': DBCollonfig.orderOption},
                {
                    '$push': {
                        'contacts': {
                            'name': each['name'],
                            'realName': each['realName'],
                            'createTime': TimeUtil.time_conversion(
                                each['time'], 2
                            ),
                            'createTimeStamp': each['time'],
                            'createUser': createUser,
                            'tel': each['tel'],
                            'email': each['email'],
                            'qq': each['qq'],
                            'payInfo': each['payInfo'],
                            'workClass': each['workClass']
                        }
                    }
                }
            )

        # 记录日志
        LogDBOps.writeLog(args['opsUserId'], LogDBConfig.doCreateContact)

        return self.response_success()
Ejemplo n.º 6
0
    def writeToDB(cls, msg, status):

        if status == 2:
            DBOps.setOneDoc(DBCollonfig.users, {'permissions.summaryOrder': 1},
                            {'$push': {
                                'msg': msg
                            }},
                            multi=True)
        elif status == 3 or status == 1:
            DBOps.setOneDoc(
                DBCollonfig.users,
                {'_id': msg['rcvUserId']},
                {'$push': {
                    'msg': msg
                }},
            )
Ejemplo n.º 7
0
    def handler_function(self):
        args = self.get_request_data()

        DBOps.setOneDoc(
            DBCollonfig.options,
            {'_id': DBCollonfig.orderOption},
            {
                '$pull': {
                    args['optionType']: {
                        'name': args['name']
                    }
                }
            }
        )

        # 记录日志
        LogDBOps.writeLog(args['opsUserId'], self.LogAction[args['optionType']])

        return self.response_success()
Ejemplo n.º 8
0
    def handler_function(self):
        args = self.get_request_data()

        now = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
        DBOps.setOneDoc(
            DBCollonfig.options,
            {'_id': DBCollonfig.orderHelpInfo},
            {
                '$set': {
                    'helpInfo': [{
                        'content': args['helpInfo'],
                        'createTime': now,
                        'createTimeStamp': TimeUtil.time_conversion(now, 1)
                    }]
                }
            }
        )

        # 记录日志
        LogDBOps.writeLog(args['opsUserId'], LogDBConfig.doEditHelpInfo)

        return self.response_success()
Ejemplo n.º 9
0
    def handler_function(self):
        args = self.get_request_data()
        option = args['option']
        createUser = args['createUser']
        now = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
        if args['optionType'] == 'contacts':
            oldContact = DBOps.getOneDoc(
                DBCollonfig.options,
                {
                    '_id': DBCollonfig.orderContact,
                    'contacts.name': option['oldName']
                }
            )
            if not oldContact:
                return self.response_failure(msg=u'外包人员不存在')
            DBOps.setOneDoc(
                DBCollonfig.options,
                {
                    '_id': DBCollonfig.orderContact,
                    'contacts.name': option['oldName']
                },
                {
                    '$set': {
                        'contacts.$.name': option['name'],
                        'contacts.$.realName': option['realName'],
                        'contacts.$.tel': option['tel'],
                        'contacts.$.email': option['email'],
                        'contacts.$.workClass': option['workClass'],
                        'contacts.$.payInfo': option['payInfo'],
                        'contacts.$.qq': option['qq'],
                        'contacts.$.createUser': createUser,
                        'contacts.$.createTime': now,
                        'contacts.$.createTimeStamp': TimeUtil.time_conversion(
                            now, 1
                        ),
                    }
                }
            )

            # 记录日志
            LogDBOps.writeLog(args['opsUserId'], LogDBConfig.doEditContact)

            return self.response_success()
        elif args['optionType'] == 'customers':
            DBOps.setOneDoc(
                DBCollonfig.options,
                {
                    '_id': DBCollonfig.orderCustomer,
                    'customers.name': option['name']
                },
                {
                    '$set': {
                        'customers.$.billInfo': option['billInfo'],
                        'customers.$.mailAddress': option['mailAddress'],
                        'customers.$.createUser': createUser,
                        'customers.$.createTime': now,
                        'customers.$.createTimeStamp': TimeUtil.time_conversion(
                            now, 1
                        ),
                    }
                }
            )

            # 记录日志
            LogDBOps.writeLog(args['opsUserId'], LogDBConfig.doEditCustomer)

            return self.response_success()
        else:
            return self.response_failure(msg=u'没有需要修改的信息')
Ejemplo n.º 10
0
    def handler_function(self):
        args = self.get_request_data()

        setStatus = args.get('status', None)
        orderId = args.get('orderId', None)

        nowStatus = DBOps.getOneDoc(
            DBCollonfig.orders,
            {'_id': orderId}
        )['status']

        if nowStatus == setStatus:
            return self.response_failure(msg='订单状态已被修改!')

        logAction = None

        nowString = datetime.now().strftime(DATETIME_FORMAT)
        setParams = {}
        if setStatus == 1:
            setParams = self.setStatus1(setStatus, args)
            logAction = LogDBConfig.doEditOrder
            if args['opsUserId'] != args['userId']:
                content = {
                    'status': setStatus,
                    'sendUserId': args['opsUserId'],
                    'rcvUserId': args['userId'],
                    'orderTitle': args['title'],
                    'createUser': args['createUser']
                }
                AccountMsg.setOrderMsg(content)

        elif setStatus == 2:
            setParams = self.setStatus2(setStatus, nowString, args)
            logAction = LogDBConfig.doCompleteOrder
            content = {
                'status': setStatus,
                'sendUserId': args['opsUserId'],
                'rcvUserId': 'summaryUser',
                'orderTitle': args['title'],
                'createUser': args['createUser']
            }
            AccountMsg.setOrderMsg(content)

        elif setStatus == 3:
            setParams = self.setStatus3(setStatus, nowString, args)
            logAction = LogDBConfig.doPaymentOrder
            if args['opsUserId'] != args['userId']:
                content = {
                    'status': setStatus,
                    'sendUserId': args['opsUserId'],
                    'rcvUserId': args['userId'],
                    'orderTitle': args['title'],
                    'createUser': args['createUser']
                }
                AccountMsg.setOrderMsg(content)

        DBOps.setOneDoc(
            DBCollonfig.orders,
            {'_id': orderId},
            {'$set': setParams}
        )

        # 记录日志
        LogDBOps.writeLog(args['opsUserId'], logAction)
        self.result['result'] = {'opsTime': nowString}
        return self.response_success(msg='订单状态修改成功!')