def get(self, vendor_id, task_id): logging.info("got vendor_id %r in uri", vendor_id) logging.info("got task_id %r in uri", task_id) ops = self.get_ops_info() task_dao.task_dao().delete(task_id) personal_task_dao.personal_task_dao().delete_by_task(task_id) self.redirect('/vendors/' + vendor_id + '/setup/task')
def get(self, vendor_id): logging.info("got vendor_id %r in uri", vendor_id) account_id = self.get_secure_cookie("account_id") categorys = category_dao.category_dao().query_by_vendor(vendor_id) personal_tasks = personal_task_dao.personal_task_dao().query_by_vendor_account(vendor_id,account_id) for personal_task in personal_tasks: personal_task['create_time'] = timestamp_datetime(personal_task['create_time']) task_id = personal_task['task_id'] task = task_dao.task_dao().query(task_id) trip_router_id = task['triprouter'] triprouter = trip_router_dao.trip_router_dao().query(trip_router_id) personal_task['title'] = triprouter['title'] personal_task['bk_img_url'] = triprouter['bk_img_url'] for category in categorys: if category['_id'] == task['category']: personal_task['category'] = category['title'] break self.render('wx/my-tasks.html', vendor_id=vendor_id, tasks=personal_tasks)
def post(self, vendor_id, task_id): logging.info("got vendor_id %r in uri", vendor_id) logging.info("got voucher_id %r in uri", task_id) ops = self.get_ops_info() _account_id = self.get_argument("account_id", "") logging.info("got _account_id %r", _account_id) _id = str(uuid.uuid1()).replace('-', '') _timestamp = time.time() json = { "_id": _id, "vendor_id": vendor_id, "create_time": _timestamp, "task_id": task_id, "account_id": _account_id, "status": 0 } # 未完成;status=1, 完成 #被分配的任务后,如果参加过某次相关活动,就应该更新这个状态 personal_task_dao.personal_task_dao().create(json) self.redirect('/vendors/' + vendor_id + '/setup/task')
def get(self, vendor_id, task_id): logging.info("got vendor_id %r in uri", vendor_id) logging.info("got task_id %r in uri", task_id) ops = self.get_ops_info() _task = task_dao.task_dao().query(task_id) _task['create_time'] = timestamp_datetime(_task['create_time']) _customers = vendor_member_dao.vendor_member_dao().query_pagination( vendor_id, 0, PAGE_SIZE_LIMIT) # 已分配过该任务的用户剔除 new_customers = [] for _customer in _customers: _account_id = _customer['account_id'] _personal_task = personal_task_dao.personal_task_dao( ).query_by_task_account(task_id, _account_id) if not _personal_task: new_customers.append(_customer) _customers = new_customers for _customer in _customers: _customer['create_time'] = timestamp_datetime( _customer['create_time']) try: _customer['account_nickname'] except: _customer['account_nickname'] = '' try: _customer['account_avatar'] except: _customer['account_avatar'] = '' try: _customer['rank'] = int(_customer['rank']) except: _customer['rank'] = 0 try: _customer['comment'] except: _customer['comment'] = '' counter = self.get_counter(vendor_id) self.render('vendor/task-allocate.html', vendor_id=vendor_id, ops=ops, counter=counter, task=_task, customers=_customers)
def get(self, vendor_id): # 从comm中统一取 myinfo = self.get_myinfo_login() account_id = myinfo['account_id'] nickname = myinfo['nickname'] avatar =myinfo['avatar'] timestamp = time.time() vendor_member = vendor_member_dao.vendor_member_dao().query_not_safe(vendor_id, account_id) if not vendor_member: memeber_id = str(uuid.uuid1()).replace('-', '') _json = {'_id':memeber_id, 'vendor_id':vendor_id, 'account_id':account_id, 'account_nickname':nickname, 'account_avatar':avatar, 'comment':'...', 'bonus':0, 'history_bonus':0, 'vouchers':0, 'crets':0, 'rank':0, 'tour_leader':False, 'distance':0, 'create_time':timestamp, 'last_update_time':timestamp} vendor_member_dao.vendor_member_dao().create(_json) logging.info("create vendor member %r", account_id) else: _json = {'vendor_id':vendor_id, 'account_id':account_id, 'account_nickname':nickname, 'account_avatar':avatar, 'last_update_time':timestamp} vendor_member_dao.vendor_member_dao().update(_json) customer_profile = vendor_member_dao.vendor_member_dao().query_not_safe(vendor_id, account_id) try: customer_profile['bonus'] except: customer_profile['bonus'] = 0 # 金额转换成元 # customer_profile['bonus'] = float(customer_profile['bonus']) / 100 # logging.info("got bonus %r", customer_profile['bonus']) # 转换成元 try: customer_profile['vouchers'] except: customer_profile['vouchers'] = 0 customer_profile['vouchers'] = float(customer_profile['vouchers']) / 100 # 加上任务数量 personal_tasks = personal_task_dao.personal_task_dao().query_by_vendor_account(vendor_id,account_id) customer_profile['tasks'] = len(personal_tasks) self.render('wx/personal-center.html', vendor_id=vendor_id, profile=customer_profile)
def get(self, vendor_id, account_id): logging.info("got vendor_id %r in uri", vendor_id) logging.info("got account_id %r in uri", account_id) ops = self.get_ops_info() access_token = self.get_access_token() url = API_DOMAIN + "/api/clubs/"+vendor_id+"/users/" + account_id http_client = HTTPClient() headers = {"Authorization":"Bearer " + access_token} response = http_client.fetch(url, method="GET", headers=headers) logging.info("got response.body %r", response.body) data = json_decode(response.body) _customer_profile = data['rs'] _contacts = contact_dao.contact_dao().query_by_account(vendor_id, account_id) access_token = self.get_access_token() params = {"filter":"account", "account_id":account_id, "page":1, "limit":20,} url = url_concat(API_DOMAIN + "/api/orders", params) http_client = HTTPClient() headers = {"Authorization":"Bearer " + access_token} response = http_client.fetch(url, method="GET", headers=headers) logging.info("got response.body %r", response.body) data = json_decode(response.body) rs = data['rs'] orders = rs['data'] for order in orders: # 下单时间,timestamp -> %m月%d 星期%w order['create_time'] = timestamp_datetime(float(order['create_time'])) # 合计金额 order['amount'] = float(order['amount']) / 100 order['actual_payment'] = float(order['actual_payment']) / 100 # 取任务 categorys = category_dao.category_dao().query_by_vendor(vendor_id) personal_tasks = personal_task_dao.personal_task_dao().query_by_vendor_account(vendor_id,account_id) logging.info("got personal_tasks============ %r in uri", len(personal_tasks)) for personal_task in personal_tasks: personal_task['create_time'] = timestamp_datetime(personal_task['create_time']) task_id = personal_task['task_id'] task = task_dao.task_dao().query(task_id) trip_router_id = task['triprouter'] triprouter = trip_router_dao.trip_router_dao().query(trip_router_id) personal_task['title'] = triprouter['title'] personal_task['bk_img_url'] = triprouter['bk_img_url'] for category in categorys: if category['_id'] == task['category']: personal_task['category'] = category['title'] break counter = self.get_counter(vendor_id) self.render('vendor/customer-profile.html', access_token=access_token, vendor_id=vendor_id, ops=ops, account_id=account_id, counter=counter, profile=_customer_profile, contacts=_contacts, orders=orders, tasks =personal_tasks)