kboss/kgadget/src/kgadget.py
2025-09-18 10:47:45 +08:00

223 lines
7.1 KiB
Python

import os
import sys
import hashlib
import argparse
import requests
# from dataui.crud_parser import BricksCRUDProcessor
from accounting.bill import BillAccounting
from accounting.recharge import RechargeAccounting
from accounting.settle import SettleAccounting
from accounting.alipay_recharge import AlipayRechargeAccounting
from accounting.order_to_bill import order2bill
from accounting.getaccount import getCustomerBalance, getAccountByName, get_account_info
from accounting.openaccount import openResellerAccounts
from accounting.openaccount import openCustomerAccounts
from accounting.openaccount import openProviderAccounts
from accounting.openaccount import openOwnerAccounts
from accounting.openaccount import openAllCustomerAccounts
from accounting.openaccount import openAllProviderAccounts
from accounting.openaccount import openAllResellerAccounts
from accounting.businessdate import get_business_date, new_business_date, \
previous_business_date, next_business_date
from accounting.openaccount import openPublisherAccounts
from accounting.openaccount import openUnderwriterAccounts
from accounting.settledate import is_provider_settle_date
from accounting.ledger import accounting_ledger
from ahserver.configuredServer import ConfiguredServer
from ahserver.serverenv import ServerEnv
from cryptography.hazmat.primitives.ciphers.aead import AESGCM
from appPublic.registerfunction import RegisterFunction
from appPublic.objectAction import ObjectAction
from appPublic.log import MyLogger, debug, info, exception
from appPublic.folderUtils import ProgramPath
from appPublic.jsonConfig import getConfig
from appPublic.i18n import getI18N
from appPublic.timeUtils import strdate_add
from appPublic.rc4 import unpassword, password
from ahserver.filedownload import path_encode
from imgThumb import thumb
from myauth import MyAuthAPI
from rf import getPublicKey, getI18nMapping
from version import __version__
from vcode import generate_vcode, check_vcode
from ali_sms_send import send_vcode
from baiDuSmsClient import send_baidu_vcode
from pay import kboss_alipay
from weixinpay import pay_wx
import openpyxl
import pandas
from volcengine_pubapi import volcengine_requestapi
from Crypto.Cipher import AES
import string
from Crypto.Cipher import DES3
from Crypto.Util.Padding import pad, unpad
from Crypto.PublicKey import RSA
from Crypto.Cipher import PKCS1_v1_5
from send_apv import issue_approve
from get_id_by_phone_dd import get_id_by_phone
import base64
import binascii
import io
import struct
from alibabacloud_ecs20140526.client import Client as Ecs20140526Client
from alibabacloud_tea_openapi import models as open_api_models
from alibabacloud_ecs20140526 import models as ecs_20140526_models
from alibabacloud_tea_util import models as util_models
from alibabacloud_tea_util.client import Client as UtilClient
import volcenginesdkcore
import volcenginesdkecs
from volcenginesdkcore.rest import ApiException
#import iam_sample_conf
import dateutil
import zmail
from get_auth_header_res import get_auth_header
import poplib
from email.parser import Parser
from email.header import decode_header
from email.utils import parseaddr
from jingdong_api import JDAPI
from jd_affirm_cancel_pay import jd_confirm_pay_orders, jd_cancel_orders
from get_discount_detail import get_discount
from capitalonline import get_signature
from email_send import email_send
from ucloud.core import exc
from ucloud.client import Client as U_Client
from llmchat import llmchat2json
from collections import defaultdict
from confluent_kafka import Consumer as BaiduKafKaConsumer
from KaiYyEnDecryptUtil import KaiYyEnDecryptUtil
from async_container import async_post
if __name__ == '__main__':
p = ProgramPath()
parser = argparse.ArgumentParser(prog='Kaiyuan cloud Bussiness Operation Support System')
parser.add_argument('-w', '--workdir')
parser.add_argument('-p', '--port')
args = parser.parse_args()
workdir = args.workdir or os.getcwd()
config = getConfig(workdir, NS={'workdir':workdir, 'ProgramPath':p})
port = args.port or config.website.port
port = int(port)
if config.logger:
logger = MyLogger(config.logger.name or 'kgadget',
levelname=config.logger.levelname or 'info',
logfile=config.logger.logfile or None)
else:
logger = MyLogger('kgadget', levelname='info')
server = ConfiguredServer(auth_klass=MyAuthAPI, workdir=workdir)
rf = RegisterFunction()
rf.register('makeThumb',thumb)
rf.register('getPublicKey', getPublicKey)
rf.register('getI18nMapping', getI18nMapping)
g = ServerEnv()
g.AESGCM = AESGCM
g.pay_wx = pay_wx
g.Parser = Parser
g.decode_header = decode_header
g.parseaddr = parseaddr
g.poplib = poplib
g.zmail = zmail
g.get_id_by_phone = get_id_by_phone
#g.iam_sample_conf = iam_sample_conf
g.dateutil = dateutil
g.volcengine_requestapi = volcengine_requestapi
g.volcenginesdkcore = volcenginesdkcore
g.volcenginesdkecs = volcenginesdkecs
g.ApiException = ApiException
g.password_decode = unpassword
g.password_encode = password
g.base64 = base64
g.binascii = binascii
g.io = io
g.struct = struct
g.issue_approve = issue_approve
g.string = string
g.AES = AES
g.DES3 = DES3
g.pad = pad
g.unpad = unpad
g.pandas = pandas
g.alipay = kboss_alipay
g.openpyxl = openpyxl
g.hashlib = hashlib
g.previous_business_date = previous_business_date
g.next_business_date = next_business_date
g.strdate_add = strdate_add
g.get_business_date = get_business_date
g.new_business_date = new_business_date
g.send_vcode = send_baidu_vcode
g.check_vcode = check_vcode
g.accounting_ledger = accounting_ledger
g.generate_vcode = generate_vcode
g.requests = requests
g.AlipayRechargeAccounting = AlipayRechargeAccounting
g.RechargeAccounting = RechargeAccounting
g.BillAccounting = BillAccounting
g.SettleAccounting = SettleAccounting
g.order2bill = order2bill
g.getAccountByName = getAccountByName
g.getCustomerBalance = getCustomerBalance
g.openResellerAccounts = openResellerAccounts
g.getAccountInfo = get_account_info
g.openCustomerAccounts = openCustomerAccounts
g.openProviderAccounts = openProviderAccounts
g.openOwnerAccounts = openOwnerAccounts
g.openAllCustomerAccounts = openAllCustomerAccounts
g.openAllProviderAccounts = openAllProviderAccounts
g.openAllResellerAccounts = openAllResellerAccounts
g.is_provider_settle_date = is_provider_settle_date
g.Ecs20140526Client = Ecs20140526Client
g.open_api_models = open_api_models
g.ecs_20140526_models = ecs_20140526_models
g.util_models = util_models
g.UtilClient = UtilClient
g.get_auth_header = get_auth_header
g.JDAPI = JDAPI()
g.RSA = RSA
g.PKCS1_v1_5 = PKCS1_v1_5
g.get_discount = get_discount
g.jd_cancel_orders = jd_cancel_orders
g.jd_confirm_pay_orders = jd_confirm_pay_orders
g.email_send = email_send
g.get_signature = get_signature
g.exc = exc
g.U_Client = U_Client
g.llmchat2json = llmchat2json
g.defaultdict = defaultdict
g.openPublisherAccounts = openPublisherAccounts
g.openUnderwriterAccounts = openUnderwriterAccounts
g.BaiduKafKaConsumer = BaiduKafKaConsumer
g.KaiYyEnDecryptUtil = KaiYyEnDecryptUtil
g.async_post = async_post
i18n = getI18N(path=workdir)
info(f'gadget version={__version__}')
debug(f'debug mode show ?')
debug(f"{g.password_encode('123456')}")
server.run(port=port)