def get(self): try: uid = self.get_current_user().get('Fid') order_srv = OrderServices(self.db) company_service.set_db(self.db) orders = order_srv.query_orders_by_customer_id(uid) lstdata = [] for order in orders: dictionary = {} dictionary['id'] = order.Fid dictionary['order_id_user'] = order.Forder_id_user dictionary['uid'] = order.Fuid dictionary['uid_mct'] = order.Fuid_mct company = company_service.get_company_by_uid(order.Fuid_mct) dictionary[ 'merchant_logo_url'] = company.Fphoto_url if company else '' dictionary['order_type'] = order.Forder_type dictionary['user_name'] = order.Fuser_name dictionary['user_mobi'] = order.Fuser_mobi dictionary['user_birth'] = order.Fuser_birth dictionary['uid_stf'] = order.Fuid_stf dictionary['amount'] = order.Famount dictionary['comment'] = order.Fcomment dictionary['create_time'] = datetime_format_2( format="%Y-%m-%d", input_date=order.Fcreate_time) lstdata.append(dictionary) except Exception, e: pass return self.write( ujson.dumps({ 'stat': '1001', 'list': [], 'data': {}, 'info': '查询用户订单失败,失败原因:' + e.message }))
def insert_users(session): ''' :param session: 0:试衣 1:摄影 2:选样 3:定稿 4:取件 :return: ''' service = OrderServices(session) evaluation_categorys = [{ 'schedule_type_id': '0', 'name': '试衣评价' }, { 'schedule_type_id': '1', 'name': '摄影评价' }, { 'schedule_type_id': '1', 'name': '化妆评价' }, { 'schedule_type_id': '2', 'name': '选样评价' }, { 'schedule_type_id': '3', 'name': '定稿评价' }, { 'schedule_type_id': '4', 'name': '取件评价' }] for evaluation_category in evaluation_categorys: service.create_evaluation_category(**evaluation_category)
def get(self, *args, **kwargs): #订单图表展示 self.get_paras_dict() order_db = OrderServices(self.db) sps_db = ServiceProductService(self.db) query = order_db.query_order_to_chart(**self.qdict) #添加订单为零数据 res = [] last_timestamp = 0 if self.qdict.get('interval', '') == "week": #按周搜索 interval = 3600 * 24 * 7 elif self.qdict.get('interval', '') == "month": #按月搜索 interval = 3600 * 24 * 31 else: interval = 3600 * 24 #按日搜索 for value in query:#循环结果集query if(not last_timestamp):#如果前一个时间点时间戳为空 last_timestamp = time.mktime(time.strptime(value[0],'%Y-%m-%d'))#初始化上一个时间戳 #计算偏移 if self.qdict.get('interval', '') == "week": #周偏移,星期一偏移为0,星期二偏移为1 last_timestamp = last_timestamp - value[2] * 3600 * 24 elif self.qdict.get('interval', '') == "month": #月偏移 last_timestamp = last_timestamp - (value[3] - 1) * 3600 * 24 #重置偏移 date = time.strftime('%Y-%m-%d', time.localtime(last_timestamp)) res.append([date, value[1]]) continue else: now_timestamp = time.mktime(time.strptime(value[0],'%Y-%m-%d')) if self.qdict.get('interval', '') == "week": now_timestamp = now_timestamp - value[2] * 3600 * 24 elif self.qdict.get('interval', '') == "month": now_timestamp = now_timestamp - (value[3] - 1) * 3600 * 24 date_res = time.strftime('%Y-%m-%d', time.localtime(now_timestamp)) #计算与上一个时间点相差时间 diff = math.ceil((last_timestamp - now_timestamp) / interval - 1) while(diff):#插入为0结果集 date = time.strftime('%Y-%m-%d', time.localtime(now_timestamp + diff * interval)) res.append([date, 0]) diff = diff - 1 res.append([date_res, value[1]]) last_timestamp = now_timestamp if(not self.qdict.get('end_time', '')): res = res[:30]; self.echo('ops/orders/order_chart.html',{ 'interval': INTERVAL_TYPE, 'data_info': res[-30:], 'order_type': ORDER_TYPE, 'status': ORDER_STATUS, 'user_db': UserMsgCache(self.db), 'sps_db' : sps_db, 'qdict': self.qdict, })
def post(self,order_type,refer_id,merchant_id, **kwargs): try: self.get_paras_dict() series_serivce.set_db(self.db) series_serivce.query_series() order_service = OrderServices(self.db) user_id = self.current_user and self.current_user.get('Fid') or None order_service.create_bespeak_orders(merchant_id,order_type,refer_id,self.qdict.get('phone'),user_id=user_id) self.write_json({'code':200,'info':'预定成功'}) except Exception,e: pass
def get(self): merchant_id = self.get_current_user().get('Fmerchant_id') input_date = self.get_argument('input_date', datetime_format(format='%Y-%m-%d')) _category = self.get_argument('schedule_categeory', None) schedule_type = self.get_argument('schedule_type', 0) schedule_service.set_db(self.db) schedule_category = schedule_service.query_schedule_category( merchant_id) query = OrderServices(self.db).query_orders_by_schedule_date( merchant_id, schedule_type, input_date, schedule_category=_category) orders = self.get_page_data(query) self.echo('crm/schedules/shot_schedule_detail.html', { 'ORDER_TYPES': ORDER_TYPES, "input_date": input_date, "schedule_category": schedule_category, 'orders': orders, '_category': _category, 'schedule_type': schedule_type, 'SCHEDULE_TYPE': _SCHEDULE_TYPE }, layout='crm/common/base.html')
def post(self, order_type, refer_id, merchant_id, **kwargs): self.get_paras_dict() series_serivce.set_db(self.db) series_serivce.query_series() order_service = OrderServices(self.db) try: user_id = self.current_user and self.current_user.get( 'Fid') or None order_service.create_bespeak_orders(merchant_id, order_type, refer_id, self.qdict.get('phone'), user_id=user_id) series = series_serivce.query_series( merchant_id=merchant_id).order_by('Fcreate_time desc').limit( 2).offset(0) if self.request.uri.startswith('/api/json/'): company = self.db.query( Company.Fcompany_name).filter(Company.Fdeleted == 0) lst_series = [] for s in series: d = self.obj_to_dict(s, SERIES_KEYS) d.update({ 'company_name': company.filter( Company.Fuser_id == s.Fmerchant_id).scalar() }) lst_series.append(d) self.write_json({'stat': 'ok', 'data': lst_series, 'info': ''}) else: self.echo('views/merchant/order_success.html', { 'series': series, 'merchant_id': merchant_id }, layout='') except Exception, e: self.captureException(*sys.exc_info())
def get(self, schedule_type, input_date, **kwargs): merchant_id = self.current_user.get('Fmerchant_id') schedule_service.set_db(self.db) orders = OrderServices(self.db).query_orders_by_schedule_date( merchant_id, schedule_type, input_date) name = u'档期明细导出' type_name = _SCHEDULE_TYPE[int(schedule_type)] file_name = datetime_format( format='%Y%m%d%H%M%S') + str(type_name) + u'档期明细导出' + '.xls' clumns = (u'订单号码', u'客户姓名', u'客户手机', u'订单类型', u'订单余额', u'订单时间', u'排期时间') file = xlwt.Workbook(encoding='utf-8') #注意这里的Workbook首字母是大写,无语吧 table = file.add_sheet(name) table.write_merge(0, 0, 0, 6, name) for c in clumns: table.write(1, clumns.index(c), c) index = 2 for i in xrange(7): table.col(i).width = 5000 for order in orders: table.write(index, 0, order.Forder_id_user) table.write(index, 1, order.Fuser_name) table.write(index, 2, order.Fuser_mobi) table.write(index, 3, ORDER_TYPES[order.Forder_type]) table.write(index, 4, str(order.Famount)) table.write( index, 5, datetime_format(format='%Y-%m-%d', input_date=order.Fcreate_time)) table.write(index, 6, input_date) index += 1 file.save(file_name) self.set_header('Content-Type', 'application/octet-stream') self.set_header('Content-Disposition', 'attachment; filename=' + file_name) with open(file_name, 'rb') as f: data = f.read() self.write(data) self.finish()
from common.permission_control import Mobile_login_control from utils.message.sms import send_phone_msg from conf.msg_conf import PASSWD_TEMPLATE, ORDER_CONFIRM_TEMPLATE from utils.random_utils import create_random_passwd from utils.message.sms import send_phone_msg from services.users.user_services import UserServices from services.ablums.photos_service import PhotosServices from services.schedules.schedules_service import ScheduleService from models.album_do import Albums from utils.common_util import is_mobile from utils.datetime_util import datetime_format from utils.date_util import datetime_format_2 import datetime import sys order_serice = OrderServices() user_service = UserServices() schedule_service = ScheduleService() class CHandlerOrdersList(MobileBaseHandler): @Mobile_login_control() @company_permission_control('orders_view') def get(self): try: order_status = self.get_argument('order_status', '') uid = self.get_current_user().get('Fmerchant_id') TEMP_STATUS = _ORDER_STATUS TEMP_STATUS.append('全部订单') tmp_status = order_status if not tmp_status: