1.字段添加与初始化(发票申请表)
1.1字段添加
1.1.1生产环境
#电商
ALTER TABLE mall_trade.invoice_apply_record ADD apply_result CHAR(1) NULL
COMMENT '申请结果:1:等待中 2:申请失败 3:申请成功';
#全员营销
ALTER TABLE im.invoice_apply_record ADD apply_result CHAR(1) NULL
COMMENT '申请结果:1:等待中 2:申请失败 3:申请成功';
1.1.2测试环境
#电商
ALTER TABLE test_mall_trade.invoice_apply_record ADD apply_result CHAR(1) NULL
COMMENT '申请结果:1:等待中 2:申请失败 3:申请成功';
#全员营销
ALTER TABLE test_im.invoice_apply_record ADD apply_result CHAR(1) NULL
COMMENT '申请结果:1:等待中 2:申请失败 3:申请成功';
1.2字段初始化(仅需初始化 IM)
1.2.1生产环境
#所有已开票和已邮寄的发票申请 均是申请成功
update im.invoice_apply_record
set apply_result = '3'
where `status` in ('2','3');
#所有纸质(专用)发票申请未开票的 均是等待中
update im.invoice_apply_record
set apply_result ='1'
where `status` = '1' and invoice_type = '2';
#所有电票申请 未开票的 均为开票失败
update im.invoice_apply_record
set apply_result = '2'
where `status`='1' and invoice_type='1';
1.2.2测试环境
#所有已开票和已邮寄的发票申请 均是申请成功
update test_im.invoice_apply_record
set apply_result = '3'
where `status` in ('2','3');
#所有纸质(专用)发票申请未开票的 均是等待中
update test_im.invoice_apply_record
set apply_result ='1'
where `status` = '1' and invoice_type = '2';
#所有电票申请 未开票的 均为开票失败
update test_im.invoice_apply_record
set apply_result = '2'
where `status`='1' and invoice_type='1';
2.YurunCommon数据库表添加
2.1四张新增数据表的创建(生产、测试都适用)
CREATE TABLE invoice_record(
id INT NOT NULL AUTO_INCREMENT COMMENT 'id' ,
invoice_from VARCHAR(32) COMMENT '开票来源 1-电商2-全员营销3-X6' ,
invoice_type CHAR(1) COMMENT '发票类型 1-电子普票2-纸质普票' ,
apply_id INT COMMENT '开票申请id' ,
order_id VARCHAR(32) COMMENT '开票订单id' ,
invoice_serial_no VARCHAR(32) COMMENT '发票流水号' ,
invoice_no VARCHAR(32) COMMENT '发票号码' ,
invoice_code VARCHAR(128) COMMENT '发票代码' ,
total_amount_tax DECIMAL(10,2) COMMENT '价税合计金额' ,
total_amount_notax DECIMAL(10,2) COMMENT '合计不含税金额' ,
total_tax DECIMAL(10,2) COMMENT '合计税额' ,
original_invoice_no VARCHAR(128) COMMENT '原发票票号' ,
original_invoice_code VARCHAR(128) COMMENT '原发票代码' ,
invoice_url VARCHAR(1024) COMMENT '发票url' ,
invoice_status CHAR(1) COMMENT '发票状态 1-未开票2-已开票3-已下载4-已红冲' ,
is_red CHAR(1) COMMENT '是否红冲 0-否1-是' ,
invoice_config_id INT COMMENT '发票配置编号' ,
invoice_time DATETIME COMMENT '开票日期' ,
PRIMARY KEY (id)
) COMMENT = '发票信息表 ';
CREATE TABLE invoice_detail(
id INT NOT NULL AUTO_INCREMENT COMMENT 'id' ,
invoice_id INT COMMENT '发票id' ,
price DECIMAL(10,2) COMMENT '价格' ,
num INT COMMENT '数量' ,
amount DECIMAL(10,2) COMMENT '合计' ,
tax_amount DECIMAL(10,2) COMMENT '合计税额' ,
tax_rate DECIMAL(10,2) COMMENT '合计税率' ,
order_detail_id INT COMMENT '订单明细编号' ,
PRIMARY KEY (id)
) COMMENT = '发票明细表 ';
CREATE TABLE invoice_config(
id INT NOT NULL AUTO_INCREMENT COMMENT 'id' ,
user_name VARCHAR(64) COMMENT '平台用户名' ,
password VARCHAR(64) COMMENT '平台密码' ,
taxpayer_id VARCHAR(64) COMMENT '纳税人识别号' ,
authorization_code VARCHAR(32) COMMENT '接入系统平台授权码' ,
qymc VARCHAR(128) COMMENT '开票方名称' ,
nsrdzdah VARCHAR(32) COMMENT '开票方电子档案号' ,
swjgDm VARCHAR(32) COMMENT '税务机构代码' ,
bmbBbh VARCHAR(32) COMMENT '编码表版本号' ,
xhfDz VARCHAR(128) COMMENT '销货方地址' ,
xhfDh VARCHAR(32) COMMENT '销货方电话' ,
xhfYhzh VARCHAR(128) COMMENT '销货方银行账号' ,
version VARCHAR(32) COMMENT '接口版本号' ,
max_bill_amount DECIMAL(10,2) COMMENT '开票面额' ,
issuer_name VARCHAR(32) COMMENT '开票人姓名' ,
payee_name VARCHAR(32) COMMENT '收款人姓名' ,
reviewer_name VARCHAR(32) COMMENT '复核人姓名' ,
PRIMARY KEY (id)
) COMMENT = '发票主体配置表 ';
CREATE TABLE tax_classification_code(
id INT NOT NULL AUTO_INCREMENT COMMENT 'id' ,
code VARCHAR(32) COMMENT '编码' ,
classification_code VARCHAR(32) COMMENT '分类编码' ,
name VARCHAR(128) COMMENT '分类名称' ,
abbreviation VARCHAR(32) COMMENT '分类简称' ,
tax_rate VARCHAR(32) COMMENT '税率' ,
special_management VARCHAR(32) COMMENT '增值税特殊管理' ,
PRIMARY KEY (id)
) COMMENT = '税收分类编码表';
2.2税收分类编码表(tax_classification_code)数据初始化
2.3发票配置表(invoice_config)初始化
2.3.1生产环境
INSERT INTO `yurun_common`.`invoice_config`(`id`, `user_name`, `password`, `taxpayer_id`, `authorization_code`, `qymc`, `nsrdzdah`, `swjg_dm`, `bmb_bbh`, `xhf_dz`, `xhf_dh`, `xhf_yhzh`, `version`, `max_bill_amount`, `issuer_name`, `payee_name`, `reviewer_name`) VALUES (1, 'xaJ8DlpY', '3201000130NDgxYjE4N2RiODA4Yjk3MQ==', '91320105067086195W', 'XFYE6BJ24H', '南京雨润连锁经营管理有限公司', NULL, NULL, '18.0', '江苏南京浦口区桥林紫峰路19号', '025-66200131', '中国农业银行南京汉中西路支行 10107001040219131', '2.0', 100000.00, '熊钰馨', '吕小娣', '孔祥晨');
2.3.2测试环境
INSERT INTO `test_yurun_common`.`invoice_config`(`id`, `user_name`, `password`, `taxpayer_id`, `authorization_code`, `qymc`, `nsrdzdah`, `swjg_dm`, `bmb_bbh`, `xhf_dz`, `xhf_dh`, `xhf_yhzh`, `version`, `max_bill_amount`, `issuer_name`, `payee_name`, `reviewer_name`) VALUES (1, 'P0000001', '3201000020MzkwM2IwZDAxM2MxY2ExOQ==', '150300201007206301', '5056bf7539', '51盒子开发十', NULL, NULL, '18.0', '江苏南京中山路129号中南国际大厦20楼21楼', '025-84701918', '中国银行股份有限公司南京中南大厦支行 531358191694', '2.0', 100000.00, '熊钰馨', '吕小娣', '孔祥晨');
2.全员营销数据迁移
2.1发票单数据迁移
2.1.1生产环境
insert into yurun_common.invoice_record
(id,apply_id,invoice_from,invoice_type,order_id,invoice_serial_no,invoice_no,invoice_code,
total_amount_tax,total_amount_notax,total_tax,invoice_url,invoice_status,invoice_time,is_red,
original_invoice_no,original_invoice_code,invoice_config_id)
select
id,apply_id,'2',IF(invoice_type = '2','1','2') ,order_id,invoice_serial_no,invoice_no,invoice_code,total_amount_tax,total_amount_notax,
total_tax,invoice_url, IF(invoice_status = '4','3',invoice_status),create_time,is_red,original_invoice_no,original_invoice_code,1
from
im.invoice_no_record;
2.1.2测试环境
insert into test_yurun_common.invoice_record
(id,apply_id,invoice_from,invoice_type,order_id,invoice_serial_no,invoice_no,invoice_code,
total_amount_tax,total_amount_notax,total_tax,invoice_url,invoice_status,invoice_time,is_red,
original_invoice_no,original_invoice_code,invoice_config_id)
select
id,apply_id,'2',IF(invoice_type = '2','1','2') ,order_id,invoice_serial_no,invoice_no,invoice_code,total_amount_tax,total_amount_notax,
total_tax,invoice_url, IF(invoice_status = '4','3',invoice_status),create_time,is_red,original_invoice_no,original_invoice_code,1
from
im.invoice_no_record;
2.2发票单明细数据迁移
2.2.1生产环境
insert into
yurun_common.invoice_detail
(id,invoice_id,price,num,amount,tax_amount,tax_rate,order_detail_id)
select
id,invoice_id,price,num,amount,tax_amount,tax_rate,order_detail_id
from im.invoice_item_detail;
2.2.2测试环境
insert into
test_yurun_common.invoice_detail
(id,invoice_id,price,num,amount,tax_amount,tax_rate,order_detail_id)
select
id,invoice_id,price,num,amount,tax_amount,tax_rate,order_detail_id
from im.invoice_item_detail;
3.Nacos配置文件
nacos中mall-trade-service.yaml和im-service.yaml中的旧发票配置项可以完全去除
3.1新增发票服务的配置项(invoice-service.yaml)
3.1.1生产环境
# 数据源配置
spring:
datasource:
url: xxxxx:xxx
username: xxxx
password: xxxx
invoice:
url: "http://open.jsaisino.com/dianzifapiaoService/slqzconsole.do"
rocketmq:
nameServer: xxxxx
producer:
#超时时间
sendMessageTimeout: 30000
#发送组
group: publicInvoiceGroup
topic:
invoiceApply: invoiceApply_pro
invoiceDownload: invoiceDownload_pro
invoiceResult: invoiceResult_pro
invoiceApplyRed: invoiceApplyRed_pro
invoiceResultRed: invoiceResultRed_pro
consumerGroup:
invoiceApply: invoiceApply_pro
invoiceDownload: invoiceDownload_pro
invoiceApplyRed: invoiceApplyRed_pro
3.1.2测试环境
# 数据源配置
spring:
datasource:
url: jdbc:mysql://10.11.0.215:3306/test_yurun_common?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
username: root
password: 123456
invoice:
url: "http://open.jsaisino.com//FPKJService/invoice/accept"
rocketmq:
nameServer: 10.11.0.215:9876
producer:
#超时时间
sendMessageTimeout: 30000
#发送组
group: publicInvoiceGroup
topic:
invoiceApply: invoiceApply_test174
invoiceDownload: invoiceDownload_test174
invoiceResult: invoiceResult_test174
invoiceApplyRed: invoiceApplyRed_test174
invoiceResultRed: invoiceResultRed_test174
consumerGroup:
invoiceApply: invoiceApply_test174
invoiceDownload: invoiceDownload_test174
invoiceApplyRed: invoiceApplyRed_test174
3.2全员营销配置项(im-service.yaml)
3.2.1生产环境
#添加队列相关配置
rocketmq:
nameServer: xxxxxx
producer:
#超时时间
sendMessageTimeout: 30000
#发送组
group: biGroup
topic:
invoiceApply: invoiceApply_pro
invoiceResult: invoiceResult_pro
consumerGroup:
invoiceResult: invoiceResult_im_pro
3.2.2测试环境
rocketmq:
nameServer: 10.11.0.215:9876
producer:
#超时时间
sendMessageTimeout: 30000
#发送组
group: biGroup
topic:
invoiceApply: invoiceApply_test174
invoiceResult: invoiceResult_test174
consumerGroup:
invoiceResult: invoiceResult_im_test174
3.3电商配置项(mall-trade-service.yaml)
3.3.1生产环境
# 队列配置
rocketmq:
nameServer: xxxxxxxxx
producer:
#超时时间
sendMessageTimeout: 30000
#发送组
group: mallGroup
topic:
autoCancel: mall_autoCancel
autoComplete: mall_autoComplete
autoCloseReturn: mall_autoCloseReturn
invoiceApply: invoiceApply_pro
invoiceResult: invoiceResult_pro
invoiceResultRed: invoiceResultRed_pro
invoiceApplyRed: invoiceApplyRed_pro
consumerGroup:
autoCancel: mall_autoCancel
autoComplete: mall_autoComplete
autoCloseReturn: mall_autoCloseReturn
invoiceResult: invoiceResult_trade_pro
invoiceResultRed: invoiceResultRed_trade_pro
3.3.2测试环境
rocketmq:
nameServer: 10.11.0.215:9876
producer:
#超时时间
sendMessageTimeout: 30000
#发送组
group: mallGroup
topic:
autoCancel: autoCancel_test174
autoComplete: autoComplete_test174
autoCloseReturn: autoCloseReturn_test174
invoiceApply: invoiceApply_test174
invoiceResult: invoiceResult_test174
invoiceResultRed: invoiceResultRed_test174
invoiceApplyRed: invoiceApplyRed_test174
consumerGroup:
autoCancel: autoCancel_test174
autoComplete: autoComplete_test174
autoCloseReturn: autoCloseReturn_test174
invoiceResult: invoiceResult_trade_test174
invoiceResultRed: invoiceResultRed_trade_test174
3.4 文档中心和网关的路由配置
- id: invoice-service
uri: lb://invoice-service
predicates:
- Path=/invoice/**
filters:
- StripPrefix=1
4.队列Topic创建
队列作用 | 开发 | 测试 | 生产 |
---|---|---|---|
正票开具申请队列 | invoiceApply_dev | invoiceApply_test174 | invoiceApply_pro |
红票开具申请队列 | invoiceApplyRed_dev | invoiceApplyRed_test174 | invoiceApplyRed_pro |
正票结果队列 | invoiceResult_dev | invoiceResult_test174 | invoiceResult_pro |
红票结果队列 | invoiceResultRed_dev | invoiceResultRed_test174 | invoiceResultRed_pro |
下载队列 | invoiceDownload_dev | invoiceDownload_test174 | invoiceDownload_pro |