def update_card(): # print(request.json) id = request.json.get('id', None) prod_name = request.json.get('prod_name', None) card = request.json.get('card', None) isused = request.json.get('isused', None) reuse = request.json.get('reuse', None) methord = request.json.get('methord', None) #update,add,delete if methord not in ['update','delete','add','add_all']: return 'Missing methord', 400 # 调用smtp函数发送邮件 try: if methord == 'update': if not all([id,prod_name,card]): return 'Missing data 1', 400 Card.query.filter_by(id = id).update({'prod_name':prod_name,'card':card,'isused':isused,'reuse':reuse}) elif methord == 'delete': if not id: return 'Missing data', 400 Card.query.filter_by(id = id).delete() # elif methord == 'add': else: if not all([prod_name,card]): return 'Missing data', 400 # print(card.split('\n')) tmp_cards = list(filter(None,card.split('\n'))) if len(tmp_cards) >1: reuse = False db.session.add_all([Card(prod_name,card=x,isused=0,reuse=reuse) for x in tmp_cards]) db.session.commit() # 重定向登录界面 return '修改成功', 200 except Exception as e: log(e) return '数据库异常', 500
def init_db(update=False): # db.session.add(User('admin','123456')) # 管理员信息 db.session.add(AdminUser('*****@*****.**','$2b$12$BKSXKYuCgeXjr8IEbK02re0VhkFoAz7f3aHF3kYAMLzYaEiObqPYm')) # 邮箱配置 # db.session.add(Smtp('*****@*****.**','卡密发卡网','smtp.qq.com','465','xxxxxxxxx',True)) # 支付渠道 db.session.add(Payment('支付宝当面付','./aipay.png',"{'APPID':'2016091800537528','alipay_public_key':'MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA4AHTfGleo8WI3qb+mSWOjJRyn6Vh8XvO6YsQmJjPnNKhvACHTHcU+PCUWUKZ54fSVhMkFZEQWMtAGeOt3lGy3pMBS96anh841gxJc2NUljU14ESXnDn4QdVe4bosmYvfko46wfA0fGClHdpO8UUiJGLj1W5alv10CwiCrYRDtx93SLIuQgwJn4yBC1/kE/KENOaWaA45dXIQvKh2P0lTbm0AvwYMVvYB+eB1GtOGQbuFJXUxWaMa0byTo9wSllhgyiIkOH+HJ9oOZIweGlsrezeUUdr3EEX97k25LdnUt/oQK8FIfthexfWZpT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Y+ozkp7xhizvLVfsmX+MKqPtl6nggiWETJJyvMQnjMgKLmSvhsopMwZ1QKBgGV36az2BOK3VITGq3Y7YBf5DUN76uPpwOOPryiUgs+hhfEcVX55TSg8WLPYUjAGXtHNpKVTAXfU0PPvTgjv3Yo1cC+okkU7pNQrkLB1lti8z9Z+ilSzKf5tJIzOP7V437p1GHNDwJ9qsDhe2VnwxXxjh4wSwxSsIWlhJFuZ4hovAoGAFgm8Fmqof3InlH/79D3IyyUdciTkdIhTQ6yPx2dioYstMOOIsg8sUZjCSKvBSNo/7wj1slqRTROyMja37Bnq39/bqwMkWSaohSVYEn7FBAaNhQOEvBBTMjI0OK00n9cZL5QgdzMv6t5A0JottSJOPU8jFChJC2Yoe0IHR4ATGikCgYB2smi7/ptKiGdwmiuUHsF/U3jfjpHyHwLrXjoSU+mwV+GjqcdbtkSP1suGjN8tcdbFvLSCRX/IRdFHYJeuPUXQtZtiC431+upasbEiJ1xZ2KcK3lKf0mOn10kPD5QC7mmsfmjz4cw9cSrBjmcWGXeIwIXPLhOAAIzpHqy8oP/F/g=='}",'官方接口 稳定可靠',True)) db.session.add(Payment('虎皮椒支付宝','./aipay.png',"{'appid':'XXXXXX','AppSecret':'YYYYY'}",'官方合作接口 个人账户到账',False)) db.session.add(Payment('虎皮椒微信','./aipay.png',"{'appid':'XXXXXX','AppSecret':'YYYYY'}",'官方合作接口 个人账户到账',True)) db.session.add(Payment('PAYJS支付宝','./aipay.png',"{'payjs_key':'XXXXXX','mchid':'YYYYY','mchid':'ZZZZZZZ'}",'官方合作接口 个人账户到账',False)) db.session.add(Payment('PAYJS微信','./aipay.png',"{'payjs_key':'XXXXXX','mchid':'YYYYY','mchid':'ZZZZZZZ'}",'官方合作接口 个人账户到账',False)) db.session.add(Payment('码支付支付宝','./aipay.png',"{'codepay_id':'58027','codepay_key':'fgl454542WSDJHEJHDJZpTRrmbn','token':'jljCGU3pRvXXXXXXXXXXXb1iq'}",'挂机宝 个人账户到账',False)) db.session.add(Payment('码支付微信','./aipay.png',"{'codepay_id':'58027','codepay_key':'fgl454542WSDJHEJHDJZpTRrmbn','token':'jljCGU3pRvXXXXXXXXXXXb1iq'}",'挂机宝 个人账户到账',False)) db.session.add(Payment('码支付QQ','./aipay.png',"{'codepay_id':'58027','codepay_key':'fgl454542WSDJHEJHDJZpTRrmbn','token':'jljCGU3pRvXXXXXXXXXXXb1iq'}",'挂机宝 个人账户到账',False)) # 商品分类 db.session.add(ProdCag('账户ID','虚拟账号类商品','100')) db.session.add(ProdCag('激活码','单独激活类商品','1000')) db.session.add(ProdCag('第三分类','单独激活类商品','1000')) # 商品设置 db.session.add(ProdInfo('账户ID','香港ID','示例:适用于苹果IOS设备登录app store下载港区特有游戏或软件','./upload/images/451244.png','100','下单后获得港区账号密码,苹果手机端打开app store登录账号,即可下载港区软件,完成后注销并重新登录自己的账号,已安装的应用就就可以正常使用',\ 9.99, True,0,0,True)) db.session.add(ProdInfo('账户ID','香港ID2','示例:适用于苹果IOS设备登录app store下载港区特有游戏或软件','./upload/images/451244.png','100','下单后获得港区账号密码,苹果手机端打开app store登录账号,即可下载港区软件,完成后注销并重新登录自己的账号,已安装的应用就就可以正常使用',\ 9.99, True,0,0,True)) db.session.add(ProdInfo('账户ID','香港ID3','示例:适用于苹果IOS设备登录app store下载港区特有游戏或软件','./upload/images/451244.png','100','下单后获得港区账号密码,苹果手机端打开app store登录账号,即可下载港区软件,完成后注销并重新登录自己的账号,已安装的应用就就可以正常使用',\ 9.99, False,0,0,False)) db.session.add(ProdInfo('激活码','香港ID4','示例:适用于苹果IOS设备登录app store下载港区特有游戏或软件','./upload/images/451244.png','100','下单后获得港区账号密码,苹果手机端打开app store登录账号,即可下载港区软件,完成后注销并重新登录自己的账号,已安装的应用就就可以正常使用',\ 9.99, False,0,0,False)) db.session.add(ProdInfo('激活码','香港ID5','示例:适用于苹果IOS设备登录app store下载港区特有游戏或软件','./upload/images/451244.png','100','下单后获得港区账号密码,苹果手机端打开app store登录账号,即可下载港区软件,完成后注销并重新登录自己的账号,已安装的应用就就可以正常使用',\ 9.99, True,0,0,True)) db.session.add(ProdInfo('激活码','香港ID6','示例:适用于苹果IOS设备登录app store下载港区特有游戏或软件','./upload/images/451244.png','100','下单后获得港区账号密码,苹果手机端打开app store登录账号,即可下载港区软件,完成后注销并重新登录自己的账号,已安装的应用就就可以正常使用',\ 9.99, True,0,0,False)) # 卡密设置 db.session.add(Card('香港ID','454545454454545454',False,False)) db.session.add(Card('香港ID','555555555555555555',True,False)) db.session.add(Card('香港ID','666666666666666666',False,False)) # 系统配置 db.session.add(Config('web_name','KAMIFAKA','网站名称',True)) db.session.add(Config('web_keyword','关键词、收录词汇','网站关键词',True)) db.session.add(Config('web_url','https://baiyue.one','网站地址,支付回调时调用',True)) db.session.add(Config('web_bg_url','https://cdn.jsdelivr.net/gh/Baiyuetribe/yyycode@dev/colorfull.jpg','网站背景图片',True)) db.session.add(Config('web_logo','./logo.png','logo',True)) db.session.add(Config('contact_us','<p>Lorem ipsum dolor sit amet, <code>consectetur</code> adipisicing. Ut enim ad minim veniam, quis nostrud<code>exercitation</code> 示例,请在管理后台>>网站设置里修改,支持HTML格式</p>','首页-联系我们',True)) db.session.add(Config('web_footer','','可填写备案或统计信息',True)) db.session.add(Config('top_notice','首页公告栏信息,请在管理后台网站设置里修改,支持HTML格式','首页公告',True)) db.session.add(Config('modal_notice','','全局弹窗信息',True)) db.session.add(Config('toast_notice','欢迎访问本站!','加载后欢迎也消息',True)) db.session.add(Config('login_captcha','false','登录验证码',True)) db.session.add(Config('search_captcha','false','查询订单验证码',True)) db.session.add(Config('theme','list_theme','主题',True)) db.session.add(Config('kamiFaka','https://github.com/Baiyuetribe/kamiFaka','Github项目地址,用于手动检测新版',False)) db.session.add(Config('kamiFaka_v','0.3.0','Github项目地址,用于手动检测新版',False)) # 通知栏 # db.session.add(Message(True,'示例:顶部消息栏通知','顶部公告')) # db.session.add(Message(False,'示例:弹窗消息','全局弹窗公告')) # 通知渠道 :名称;对管理员开关;对用户开关;对管理员需要管理员账号;用户无;名称+config+管理员+admin_switch+user_switch db.session.add(Notice('邮箱通知',"{'sendname':'no_replay','sendmail':'*****@*****.**','smtp_address':'smtp.qq.com','smtp_port':'465','smtp_pwd':'ZZZZZZZ'}",'*****@*****.**',False,False)) db.session.add(Notice('微信通知',"{'token':'XXXXXXXXXXXXXXXX'}",'xxxxxxxxxxxxxxxx',False,False)) db.session.add(Notice('TG通知',"{'TG_TOKEN':'1290570937:AAHaXA2uOvDoGKbGeY4xVIi5kR7K55saXhs'}",'472835979',True,False)) db.session.add(Notice('短信通知',"{'appid':'XXXXXX','AppSecret':'YYYYY'}",'15347875415',False,False)) # 订单信息【测试环境】 db.session.add(Order('baiyue4512454544','香港ID','支付宝当面付','1563254111','请求尽快发货',9.99,1,0.9,'账号:xxxxx;密码:xxxx')) db.session.add(Order('baiyue4512454546','香港ID','虎皮椒微信','*****@*****.**','非常感谢',9.99,3,1.97,None)) #卡密为None或‘’空都可以 db.session.add(Order('baiyue4512454548','香港ID','虎皮椒支付宝','*****@*****.**','不错',9.99,1,0.9,'')) db.session.add(Order('baiyue4512454549','香港ID','虎皮椒支付宝','*****@*****.**','不错',9.99,1,1.9,'')) # db.session.commit()