def get(self): suppliers = self.db.query( 'select id from supplier where agent_id = %s', self.current_user.id) sql = """select g.id gid, g.short_name, g.sales_price, s.short_name sname, g.sales_count from goods g join supplier s on g.supplier_id = s.id where g.deleted = 0 """ params = [] supplier_name = '' if suppliers: sql += 'and s.id in (%s)' % ','.join(['%s'] * len(suppliers)) params = [supplier.id for supplier in suppliers] if 'supplier_name' in self.request.arguments: supplier_name = self.get_argument('supplier_name') sql += 'and s.short_name like %s' params.append('%' + supplier_name + '%') goods = Paginator(self, sql, params) else: sql += 'and g.id < 0' goods = Paginator(self, sql, params) self.render('supplier/goods.html', goods=goods, supplier_name=supplier_name)
def get(self): sql = """select wb.id, wb.name, wb.phone, wb.remark, wb.time, wb.date, wb.status, wb.created_at, ss.name sname, wb.wbs_id from wx_booking wb join supplier_shop ss on wb.shop_id = ss.id where wb.wx_id = %s order by wb.created_at desc""" page = Paginator(self, sql, [self.current_user.wx_id], page_size=10) self.render('book/orders.html', orders=page.rows, links=page.boot_links())
def get(self, supplier_id): sql = 'select ss.* from supplier_shop ss where ss.supplier_id = %s and ss.deleted =0 order by id desc' page = Paginator(self, sql, [supplier_id]) supplier = self.db.get('select * from supplier where id=%s', supplier_id) self.render('supplier/shop/list.html', page=page, supplier=supplier)
def get(self): form = Form(self.request.arguments, search_list) unrecommend_sql = """select g.id, g.short_name, g.created_at, g.purchase_price, g.sales_price from goods g join supplier s on g.supplier_id = s.id where g.off_sale_at > NOW() and g.deleted = 0 and g.id not in (select goods_id from ktv_product_goods union select gpp.goods_id from goods_property gpp where gpp.name = 'hidden' and gpp.value = 1 union select gq.goods_id from goods_property gq where gq.name = 'recommend' and gq.value = 1) """ params = [] if form.supplier.value: unrecommend_sql += 'and g.supplier_id = %s ' params.append(form.supplier.value) if form.goods.value: unrecommend_sql += 'and g.short_name like %s ' params.append('%' + form.goods.value + '%') unrecommend_sql += 'order by g.created_at desc ' page = Paginator(self, unrecommend_sql, params) recommend_sql = """select distinct(g.id), g.short_name, g.created_at, g.purchase_price, g.sales_price from goods g join (select gpp.goods_id from goods_property gpp where gpp.name = 'recommend' and gpp.value = 1 and gpp.goods_id not in (select gq.goods_id from goods_property gq where gq.name='hidden' and gq.value = 1)) gp on gp.goods_id = g.id where g.off_sale_at > NOW() and g.deleted = 0 and g.id not in (select goods_id from ktv_product_goods) order by g.created_at desc """ recommend_page = self.db.query(recommend_sql) self.render('seewi/recommend.html', form=form, page=page, recommend_page=recommend_page)
def get(self): # 银乐迪类的ktv产品不显示 sql = """select g.id, g.short_name, g.face_value, g.sales_price, g.created_by, g.purchase_price, g.created_at, g.status, s.short_name supplier_name from goods g,supplier s where g.supplier_id = s.id and g.deleted = 0 and g.status <> "PREPARE" and g.id not in (select goods_id from ktv_product_goods) """ form = Form(self.request.arguments, list_schema) params = [] if form.supplier.value: sql += 'and g.supplier_id=%s ' params.append(form.supplier.value) if form.goods.value: sql += 'and g.short_name like %s ' params.append('%' + form.goods.value + '%') if form.status.value: sql += 'and g.status = %s' params.append(form.status.value) sql += 'order by g.created_at desc' page = Paginator(self, sql, params) self.render('goods/list.html', page=page, form=form)
def get(self): """ 商户财务明细 """ form = Form(self.request.arguments, list_schema) sql = """select ass.created_at,a.type, ass.remark, ass.type, ass.trade_type, ass.amount,ass.status from account_sequence ass left join account a on a.id = ass.account_id where display <> 2 """ supplier = self.db.get('select * from supplier where id =%s and deleted=0', self.current_user.supplier_id) #查找商户门店对应的账户信息 account_sql = 'select account_id from supplier_shop where 1=1 ' account_sql += 'and id = %s ' if supplier.separate_account == '1' and self.current_user.shop_id != 0 else 'and supplier_id = %s ' account_params = [self.current_user.shop_id if supplier.separate_account == '1' and self.current_user.shop_id != 0 else supplier.id] accounts = self.db.query(account_sql, *account_params) sql += 'and ass.account_id in (%s) ' % ','.join(['%s'] * len(accounts)) params = [str(i.account_id) for i in accounts] if form.start_date.value: sql += "and ass.created_at >= %s " params.append(form.start_date.value) if form.end_date.value: sql += "and ass.created_at <= %s " params.append(form.end_date.value) if form.type.value: sql += "and ass.type = %s " params.append(form.type.value) sql += "order by ass.created_at desc" page = Paginator(self, sql, params) self.render("finance/sequence.html", form=form, page=page, supplier_user=self.current_user)
def get(self): sql = 'select w.* from withdraw_bill w, account a ' \ 'where w.account_id=a.id and a.type=3 and a.uid=%s order by id desc' params = [self.current_user.id] page = Paginator(self, sql, params) self.render('finance/withdraw/list.html', page=page)
def get(self): sql = """select am.* from wx_app_msg am, supplier sp where am.sp_id=sp.id and sp.id=%s and am.deleted=0 order by am.created_at desc""" page = Paginator(self, sql, [self.current_user.supplier_id]) for item in page.rows: item.cover = img_url(item.cover) self.render('wx/app_msg/list.html', page=page, img_url=img_url)
def get(self): form = Form(self.request.arguments, search_list) sql = """ select kps.*, kp.name, (select group_concat(ss.name, ' (', ksps.room_count, ')') from ktv_shop ksps, supplier_shop ss where ksps.shop_id = ss.id and ksps.schedule_id = kps.id) as shop_info, (select group_concat(kdr.start_day,' 至 ', kdr.end_day) from ktv_date_range kdr where kdr.schedule_id = kps.id) as date_range from ktv_price_schedule kps, ktv_product kp where kps.product_id = kp.id and kps.supplier_id=%s """ params = [self.current_user.supplier_id] if form.shop.value: sql += 'and kps.id in (select schedule_id from ktv_shop where shop_id=%s) ' params.append(form.shop.value) if form.product.value: sql += 'and kps.product_id=%s ' params.append(form.product.value) if form.box.value: sql += 'and kps.room_type=%s ' params.append(form.box.value) sql += 'order by kps.created_at desc' page = Paginator(self, sql, params) shops = self.db.query('select * from supplier_shop where deleted=0 and supplier_id = %s', self.current_user.supplier_id) products = self.db.query('select * from ktv_product where deleted=0 and supplier_id = %s', self.current_user.supplier_id) self.render('ktv/price/show.html', shops=shops, products=products, page=page, form=form)
def get(self): sql = 'select a.*, o.name sale from agent a join operator o on a.sales_id = o.id where a.deleted = 0 ' \ 'order by created_at desc ' page = Paginator(self, sql, []) self.render('agent/list.html', page=page)
def get(self): user = self.current_user sql = 'select wm.*, m.wx_name, m.mobile, m.id mid from wx_msg wm, member m ' \ 'where wm.sent_from=m.id and sent_to=%s order by id desc' page = Paginator(self, sql, [user.supplier_id]) self.render('wx/msg/show.html', page=page)
def get(self): """ 提现申请管理 """ form = Form(self.request.arguments, list_schema) sql = 'select wb.*,a.type account_type from withdraw_bill wb, account a where a.id=wb.account_id ' params = [] if form.supplier.value: supplier = self.db.get( 'select * from supplier where id =%s and deleted=0', form.supplier.value) if supplier.separate_account == '0': accounts = [supplier] else: accounts = self.db.query( 'select account_id from supplier_shop ' 'where deleted=0 and supplier_id=%s', form.supplier.value) sql += 'and wb.account_id in (%s) ' % ','.join( ['%s'] * len(accounts)) params = [str(i.account_id) for i in accounts] if form.status.value: sql += 'and wb.status=%s ' params.append(form.status.value) if form.apply_time_start.value: sql += "and wb.applied_at >= %s " params.append(form.apply_time_start.value) if form.apply_time_end.value: sql += "and wb.applied_at <= %s " params.append(form.apply_time_end.value) sql += " order by wb.applied_at desc" page = Paginator(self, sql, params) self.render("finance/withdraw/list.html", page=page, form=form)
def get(self): form = Form(self.request.arguments, sn_schema) act_id = self.get_argument('act_id', 0) sql = 'select r.*, s.*, s.id sid, m.id mid, m.mobile from wx_activity_rewards r join wx_activity_sn s ' \ 'left join member m on s.mem_id=m.id where r.id=s.rewards_id ' \ 'and r.act_id=%s ' params = [act_id] if form.sn.value: sql += ' and s.sn=%s ' params.append(form.sn.value) if form.mobile.value: sql += ' and m.mobile=%s ' params.append(form.mobile.value) if form.status.value: sql += ' and s.status=%s ' params.append(form.status.value) if form.type.value: sql += ' and r.type like %s ' params.append('%' + form.type.value + '%') if form.name.value: sql += ' and r.name like %s ' params.append('%' + form.name.value + '%') page = Paginator(self, sql, params) self.render('wx/activity/sn_list.html', page=page, form=form, act_id=act_id)
def get(self): form = Form(self.request.arguments, list_schema) sql = """select g.id, g.short_name, g.face_value, g.sales_price, g.created_by, g.purchase_price, g.stock, g.status, gds.dsid, gp.name gpname from goods g left join (select goods_id, group_concat(concat(gds.distributor_shop_id, '-', case when gds.distributor_shop_id=7 then extra else gds.distributor_goods_id end)) dsid from goods_distributor_shop gds where status='ON_SALE' group by goods_id) gds on g.id=gds.goods_id left join goods_property gp on g.id = gp.goods_id and gp.name = "is_wx_goods" and gp.value = "1" where g.deleted=0 and gp.name is null and g.supplier_id = %s """ params = [self.current_user.supplier_id] if form.goods.value: sql += 'and g.short_name like %s ' params.append('%' + form.goods.value + '%') if form.status.value: sql += 'and g.status = %s ' params.append(form.status.value) sql += 'order by g.id desc' page = Paginator(self, sql, params) self.render('goods/list.html', page=page, form=form)
def get(self): form = Form(self.request.arguments, list_schema) params = [] sql = '''select p.*, a1.name as "city", a2.name as "district" from pool_supplier p, area1 a1, area1 a2 where p.city_id = a1.id and p.district_id = a2.id and p.state = 1''' if form.brand.value: sql += ' and p.brand_name like %s' params.append('%' + form.brand.value + '%') if form.city.value: sql += ' and a1.type = %s and a1.name like %s ' params.append('city') params.append('%' + form.city.value + '%') if form.district.value: sql += ' and a2.type = %s and a2.name like %s' params.append('district') params.append('%' + form.district.value + '%') if form.status.value: sql += ' and p.category = %s' params.append(form.status.value) page = Paginator(self, sql, params) supplier_count = self.db.get( 'select count(*) as count from pool_supplier where agent_id = %s', self.current_user.id).count max_select = self.current_user.supplier_limit - supplier_count self.render('supplier/pool/list.html', page=page, form=form, max=max_select)
def get(self): sql = """select wx.*, ss.name sname, wbs.info from wx_booking wx join supplier_shop ss on wx.shop_id = ss.id join wx_booking_setting wbs on wx.wbs_id = wbs.id where wx.sp_id = %s order by wx.created_at desc """ args = [self.current_user.supplier_id] date = '' shop = 0 if 'date' in self.request.arguments and self.get_argument('date'): date = self.get_argument('date') sql += 'and wx.date = %s ' args.append(self.get_argument('date')) if 'shop' in self.request.arguments and self.get_argument('shop'): shop = self.get_argument('shop') sql += 'and wx.shop_id = %s ' args.append(self.get_argument('shop')) orders = Paginator(self, sql, args) shops = self.db.query( 'select id, name from supplier_shop where supplier_id = %s', self.current_user.supplier_id) params = { 'orders': orders, 'shops': shops, 'date': date, 'shop': shop, 'json': json } self.render('wx/book/order.html', **params)
def get(self): form = Form(self.request.arguments, notice_schema) sql = 'select * from news where deleted = 0 and type = 1 order by created_at desc' params = [] page = Paginator(self, sql, params) self.render('admin/notice_list.html', form=form, page=page)
def get(self): user = self.current_user sql = 'select * from wx_activity where sp_id=%s and is_active=1 and start_at < NOW() and expire_at > NOW()' \ ' and deleted=0' page = Paginator(self, sql, [user.sp_id], page_size=5) self.render('activity/list.html', page=page) pass
def get(self): sql = """select id, info from wx_booking_setting where sp_id = %s and deleted = 0 order by op_time desc """ page = Paginator(self, sql, [self.current_user.supplier_id]) for item in page.rows: item.info = json.loads(item.info) item.info['pic'] = img_url(item.info['pic']) self.render('wx/book/list.html', page=page)
def get(self): sql = 'select * from stock_batch where supplier_id = %s order by id desc' params = [self.current_user.supplier_id] page = Paginator(self, sql, params) wait_orders = wait_send_orders(self) self.render('real/show.html', page=page, unload_number=len(wait_orders))
def get(self, supplier_id): sql = """select kp.*, s.short_name supplier_name from ktv_product kp left join supplier s on kp.supplier_id = s.id where kp.deleted = 0 and s.id=%s""" params = [supplier_id] page = Paginator(self, sql, params) supplier = self.db.get('select * from supplier where id=%s', supplier_id) self.render('supplier/ktv_show.html', page=page, supplier=supplier)
def get(self): user = self.current_user list_type = self.get_argument('type', 'unused') sql = 'select * from wx_activity_rewards r, wx_activity_sn s where r.id=s.rewards_id and s.mem_id=%s ' if list_type == 'unused': sql += ' and s.status = 2 ' else: sql += ' and s.status = 3 ' rewards = Paginator(self, sql, [user.id], page_size=10) self.render('activity/sn_list.html', rewards=rewards, type=list_type)
def get(self): sql = """ select em.amount, em.created_at, s.name, s.short_name from external_money em, supplier s where em.uid=s.id and em.type=1 and em.source=3 and s.agent_id=%s order by em.id desc """ page = Paginator(self, sql, [self.current_user.id]) self.render('finance/supplier_money.html', page=page)
def get(self): uid = self.get_argument('agent_id') sql = 'select * from contract where deleted = 0 and type = 2 and uid = %s order by created_at desc' contracts = Paginator(self, sql, [uid]) agent = self.db.get( 'select id, name, short_name from agent where id = %s', uid) self.render('agent/contract/list.html', contracts=contracts, agent=agent)
def get(self): sql = """select g.short_name, oi.num, o.status, o.created_at, o.payment, o.id from orders o, order_item oi, goods g where o.id = oi.order_id and oi.goods_id = g.id and o.distributor_user_id = %s order by o.created_at desc""" params = [self.current_user.wx_id] page = Paginator(self, sql, params) self.render('mall/order_list.html', page=page)
def get(self): sql = """ select g.* from goods g where g.deleted = 0 and g.generate_type = 'IMPORT' """ form = Form(self.request.arguments, list_schema) params = [] if form.goods.value: sql += 'and g.name like %s ' params.append('%' + form.goods.value + '%') page = Paginator(self, sql, params) self.render('coupon/imported.html', page=page, form=form)
def get(self): sql = """select si.*,s.name sku_name from stock_item si,sku s where si.deleted = 0 and s.id = si.sku_id """ form = Form(self.request.arguments, stock_schema) params = [] if form.sku.value: sql += 'and s.name like %s ' params.append('%' + form.sku.value + '%') sql += 'order by si.id desc' page = Paginator(self, sql, params) self.render('real/stock_list.html', page=page, form=form)
def get(self, supplier_id): sql = """select s.name, s.short_name, c.* from supplier s, contract c where c.deleted=0 and s.id = c.uid and c.uid=%s and c.type=1""" params = [supplier_id] page = Paginator(self, sql, params) supplier = self.db.get('select * from supplier where id=%s', supplier_id) self.render('supplier/contract/list.html', page=page, supplier=supplier)
def get(self, supplier_id): supplier = self.db.get('select * from supplier where id=%s', supplier_id) sql = """select wa.*, ss.name shop_name from withdraw_account wa left join supplier_shop ss on wa.type="SUPPLIER_SHOP" and ss.id=wa.uid where wa.deleted=0 and ( (wa.type="SUPPLIER" and wa.uid=%s) or (wa.type="SUPPLIER_SHOP" and wa.uid in (select id from supplier_shop where deleted=0 and supplier_id=%s)))""" page = Paginator(self, sql, [supplier_id, supplier_id]) self.render('supplier/bank/list.html', supplier=supplier, page=page)
def get(self): sql = 'select * from wx_points where mem_id = %s ' page = Paginator(self, sql, [self.current_user.id], page_size=10) now = datetime.now().replace(hour=0, minute=0, second=0) sum = 0 sign = False points = self.db.query('select * from wx_points where mem_id = %s', self.current_user.id) for point in points: if point.expire_type == '1' or (point.expire_type == '0' and point.expire_at >= now): sum += point.num if not sign and point.created_at >= now: sign = True params = { 'points': page.rows, 'sum': sum, 'current_user': self.current_user, 'sign': sign, 'links': page.boot_links() } self.render('member/sign.html', **params)
def get(self): user = self.db.get( 'select shop_id, supplier_id from supplier_user where id = %s and deleted = 0 ', self.current_user.id) if not user.shop_id: sql = 'select * from supplier_shop where supplier_id = %s and deleted = 0' params = [user.supplier_id] else: sql = 'select * from supplier_shop where id = %s and deleted = 0' params = [user.shop_id] page = Paginator(self, sql, params) self.render('shop/show.html', page=page)
def get(self): user = self.current_user if user.level == 0: # 不是会员,先跳转到加入会员页面 self.redirect(url_concat(self.reverse_url('member_join'), {'wx_id': user.wx_id})) else: # 查询有效的预约信息 sql = 'select id, info from wx_booking_setting where sp_id = %s and deleted=0' page = Paginator(self, sql, [user.sp_id], page_size=10) lists = [{'id': b.id, 'info': json.loads(b.info, object_hook=json_hook)} for b in page.rows] # 查询用户已提交的预约 orders = self.db.get('select count(*) num from wx_booking where wx_id = %s', self.current_user.wx_id)['num'] self.render('book/list.html', lists=lists, orders=orders, img_url=img_url, links=page.boot_links())