1.字段添加与初始化(发票申请表)

1.1字段添加

1.1.1生产环境

  1. #电商
  2. ALTER TABLE mall_trade.invoice_apply_record ADD apply_result CHAR(1) NULL
  3. COMMENT '申请结果:1:等待中 2:申请失败 3:申请成功';
  4. #全员营销
  5. ALTER TABLE im.invoice_apply_record ADD apply_result CHAR(1) NULL
  6. COMMENT '申请结果:1:等待中 2:申请失败 3:申请成功';

1.1.2测试环境

  1. #电商
  2. ALTER TABLE test_mall_trade.invoice_apply_record ADD apply_result CHAR(1) NULL
  3. COMMENT '申请结果:1:等待中 2:申请失败 3:申请成功';
  4. #全员营销
  5. ALTER TABLE test_im.invoice_apply_record ADD apply_result CHAR(1) NULL
  6. COMMENT '申请结果:1:等待中 2:申请失败 3:申请成功';

1.2字段初始化(仅需初始化 IM)

1.2.1生产环境

  1. #所有已开票和已邮寄的发票申请 均是申请成功
  2. update im.invoice_apply_record
  3. set apply_result = '3'
  4. where `status` in ('2','3');
  5. #所有纸质(专用)发票申请未开票的 均是等待中
  6. update im.invoice_apply_record
  7. set apply_result ='1'
  8. where `status` = '1' and invoice_type = '2';
  9. #所有电票申请 未开票的 均为开票失败
  10. update im.invoice_apply_record
  11. set apply_result = '2'
  12. where `status`='1' and invoice_type='1';

1.2.2测试环境

  1. #所有已开票和已邮寄的发票申请 均是申请成功
  2. update test_im.invoice_apply_record
  3. set apply_result = '3'
  4. where `status` in ('2','3');
  5. #所有纸质(专用)发票申请未开票的 均是等待中
  6. update test_im.invoice_apply_record
  7. set apply_result ='1'
  8. where `status` = '1' and invoice_type = '2';
  9. #所有电票申请 未开票的 均为开票失败
  10. update test_im.invoice_apply_record
  11. set apply_result = '2'
  12. where `status`='1' and invoice_type='1';

2.YurunCommon数据库表添加

2.1四张新增数据表的创建(生产、测试都适用)

  1. CREATE TABLE invoice_record(
  2. id INT NOT NULL AUTO_INCREMENT COMMENT 'id' ,
  3. invoice_from VARCHAR(32) COMMENT '开票来源 1-电商2-全员营销3-X6' ,
  4. invoice_type CHAR(1) COMMENT '发票类型 1-电子普票2-纸质普票' ,
  5. apply_id INT COMMENT '开票申请id' ,
  6. order_id VARCHAR(32) COMMENT '开票订单id' ,
  7. invoice_serial_no VARCHAR(32) COMMENT '发票流水号' ,
  8. invoice_no VARCHAR(32) COMMENT '发票号码' ,
  9. invoice_code VARCHAR(128) COMMENT '发票代码' ,
  10. total_amount_tax DECIMAL(10,2) COMMENT '价税合计金额' ,
  11. total_amount_notax DECIMAL(10,2) COMMENT '合计不含税金额' ,
  12. total_tax DECIMAL(10,2) COMMENT '合计税额' ,
  13. original_invoice_no VARCHAR(128) COMMENT '原发票票号' ,
  14. original_invoice_code VARCHAR(128) COMMENT '原发票代码' ,
  15. invoice_url VARCHAR(1024) COMMENT '发票url' ,
  16. invoice_status CHAR(1) COMMENT '发票状态 1-未开票2-已开票3-已下载4-已红冲' ,
  17. is_red CHAR(1) COMMENT '是否红冲 0-否1-是' ,
  18. invoice_config_id INT COMMENT '发票配置编号' ,
  19. invoice_time DATETIME COMMENT '开票日期' ,
  20. PRIMARY KEY (id)
  21. ) COMMENT = '发票信息表 ';
  22. CREATE TABLE invoice_detail(
  23. id INT NOT NULL AUTO_INCREMENT COMMENT 'id' ,
  24. invoice_id INT COMMENT '发票id' ,
  25. price DECIMAL(10,2) COMMENT '价格' ,
  26. num INT COMMENT '数量' ,
  27. amount DECIMAL(10,2) COMMENT '合计' ,
  28. tax_amount DECIMAL(10,2) COMMENT '合计税额' ,
  29. tax_rate DECIMAL(10,2) COMMENT '合计税率' ,
  30. order_detail_id INT COMMENT '订单明细编号' ,
  31. PRIMARY KEY (id)
  32. ) COMMENT = '发票明细表 ';
  33. CREATE TABLE invoice_config(
  34. id INT NOT NULL AUTO_INCREMENT COMMENT 'id' ,
  35. user_name VARCHAR(64) COMMENT '平台用户名' ,
  36. password VARCHAR(64) COMMENT '平台密码' ,
  37. taxpayer_id VARCHAR(64) COMMENT '纳税人识别号' ,
  38. authorization_code VARCHAR(32) COMMENT '接入系统平台授权码' ,
  39. qymc VARCHAR(128) COMMENT '开票方名称' ,
  40. nsrdzdah VARCHAR(32) COMMENT '开票方电子档案号' ,
  41. swjgDm VARCHAR(32) COMMENT '税务机构代码' ,
  42. bmbBbh VARCHAR(32) COMMENT '编码表版本号' ,
  43. xhfDz VARCHAR(128) COMMENT '销货方地址' ,
  44. xhfDh VARCHAR(32) COMMENT '销货方电话' ,
  45. xhfYhzh VARCHAR(128) COMMENT '销货方银行账号' ,
  46. version VARCHAR(32) COMMENT '接口版本号' ,
  47. max_bill_amount DECIMAL(10,2) COMMENT '开票面额' ,
  48. issuer_name VARCHAR(32) COMMENT '开票人姓名' ,
  49. payee_name VARCHAR(32) COMMENT '收款人姓名' ,
  50. reviewer_name VARCHAR(32) COMMENT '复核人姓名' ,
  51. PRIMARY KEY (id)
  52. ) COMMENT = '发票主体配置表 ';
  53. CREATE TABLE tax_classification_code(
  54. id INT NOT NULL AUTO_INCREMENT COMMENT 'id' ,
  55. code VARCHAR(32) COMMENT '编码' ,
  56. classification_code VARCHAR(32) COMMENT '分类编码' ,
  57. name VARCHAR(128) COMMENT '分类名称' ,
  58. abbreviation VARCHAR(32) COMMENT '分类简称' ,
  59. tax_rate VARCHAR(32) COMMENT '税率' ,
  60. special_management VARCHAR(32) COMMENT '增值税特殊管理' ,
  61. PRIMARY KEY (id)
  62. ) COMMENT = '税收分类编码表';

2.2税收分类编码表(tax_classification_code)数据初始化

(生产、测试、开发保持一致即可)
请复制开发库的表中数据

2.3发票配置表(invoice_config)初始化

2.3.1生产环境

  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测试环境

  1. 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生产环境

  1. insert into yurun_common.invoice_record
  2. (id,apply_id,invoice_from,invoice_type,order_id,invoice_serial_no,invoice_no,invoice_code,
  3. total_amount_tax,total_amount_notax,total_tax,invoice_url,invoice_status,invoice_time,is_red,
  4. original_invoice_no,original_invoice_code,invoice_config_id)
  5. select
  6. 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,
  7. total_tax,invoice_url, IF(invoice_status = '4','3',invoice_status),create_time,is_red,original_invoice_no,original_invoice_code,1
  8. from
  9. im.invoice_no_record;

2.1.2测试环境

  1. insert into test_yurun_common.invoice_record
  2. (id,apply_id,invoice_from,invoice_type,order_id,invoice_serial_no,invoice_no,invoice_code,
  3. total_amount_tax,total_amount_notax,total_tax,invoice_url,invoice_status,invoice_time,is_red,
  4. original_invoice_no,original_invoice_code,invoice_config_id)
  5. select
  6. 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,
  7. total_tax,invoice_url, IF(invoice_status = '4','3',invoice_status),create_time,is_red,original_invoice_no,original_invoice_code,1
  8. from
  9. im.invoice_no_record;

2.2发票单明细数据迁移

2.2.1生产环境

  1. insert into
  2. yurun_common.invoice_detail
  3. (id,invoice_id,price,num,amount,tax_amount,tax_rate,order_detail_id)
  4. select
  5. id,invoice_id,price,num,amount,tax_amount,tax_rate,order_detail_id
  6. from im.invoice_item_detail;

2.2.2测试环境

  1. insert into
  2. test_yurun_common.invoice_detail
  3. (id,invoice_id,price,num,amount,tax_amount,tax_rate,order_detail_id)
  4. select
  5. id,invoice_id,price,num,amount,tax_amount,tax_rate,order_detail_id
  6. from im.invoice_item_detail;

3.Nacos配置文件

nacos中mall-trade-service.yaml和im-service.yaml中的旧发票配置项可以完全去除

3.1新增发票服务的配置项(invoice-service.yaml)

3.1.1生产环境

  1. # 数据源配置
  2. spring:
  3. datasource:
  4. url: xxxxxxxx
  5. username: xxxx
  6. password: xxxx
  7. invoice:
  8. url: "http://open.jsaisino.com/dianzifapiaoService/slqzconsole.do"
  9. rocketmq:
  10. nameServer: xxxxx
  11. producer:
  12. #超时时间
  13. sendMessageTimeout: 30000
  14. #发送组
  15. group: publicInvoiceGroup
  16. topic:
  17. invoiceApply: invoiceApply_pro
  18. invoiceDownload: invoiceDownload_pro
  19. invoiceResult: invoiceResult_pro
  20. invoiceApplyRed: invoiceApplyRed_pro
  21. invoiceResultRed: invoiceResultRed_pro
  22. consumerGroup:
  23. invoiceApply: invoiceApply_pro
  24. invoiceDownload: invoiceDownload_pro
  25. invoiceApplyRed: invoiceApplyRed_pro

3.1.2测试环境

  1. # 数据源配置
  2. spring:
  3. datasource:
  4. url: jdbc:mysql://10.11.0.215:3306/test_yurun_common?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
  5. username: root
  6. password: 123456
  7. invoice:
  8. url: "http://open.jsaisino.com//FPKJService/invoice/accept"
  9. rocketmq:
  10. nameServer: 10.11.0.215:9876
  11. producer:
  12. #超时时间
  13. sendMessageTimeout: 30000
  14. #发送组
  15. group: publicInvoiceGroup
  16. topic:
  17. invoiceApply: invoiceApply_test174
  18. invoiceDownload: invoiceDownload_test174
  19. invoiceResult: invoiceResult_test174
  20. invoiceApplyRed: invoiceApplyRed_test174
  21. invoiceResultRed: invoiceResultRed_test174
  22. consumerGroup:
  23. invoiceApply: invoiceApply_test174
  24. invoiceDownload: invoiceDownload_test174
  25. invoiceApplyRed: invoiceApplyRed_test174

3.2全员营销配置项(im-service.yaml)

3.2.1生产环境

  1. #添加队列相关配置
  2. rocketmq:
  3. nameServer: xxxxxx
  4. producer:
  5. #超时时间
  6. sendMessageTimeout: 30000
  7. #发送组
  8. group: biGroup
  9. topic:
  10. invoiceApply: invoiceApply_pro
  11. invoiceResult: invoiceResult_pro
  12. consumerGroup:
  13. invoiceResult: invoiceResult_im_pro

3.2.2测试环境

  1. rocketmq:
  2. nameServer: 10.11.0.215:9876
  3. producer:
  4. #超时时间
  5. sendMessageTimeout: 30000
  6. #发送组
  7. group: biGroup
  8. topic:
  9. invoiceApply: invoiceApply_test174
  10. invoiceResult: invoiceResult_test174
  11. consumerGroup:
  12. invoiceResult: invoiceResult_im_test174

3.3电商配置项(mall-trade-service.yaml)

3.3.1生产环境

  1. # 队列配置
  2. rocketmq:
  3. nameServer: xxxxxxxxx
  4. producer:
  5. #超时时间
  6. sendMessageTimeout: 30000
  7. #发送组
  8. group: mallGroup
  9. topic:
  10. autoCancel: mall_autoCancel
  11. autoComplete: mall_autoComplete
  12. autoCloseReturn: mall_autoCloseReturn
  13. invoiceApply: invoiceApply_pro
  14. invoiceResult: invoiceResult_pro
  15. invoiceResultRed: invoiceResultRed_pro
  16. invoiceApplyRed: invoiceApplyRed_pro
  17. consumerGroup:
  18. autoCancel: mall_autoCancel
  19. autoComplete: mall_autoComplete
  20. autoCloseReturn: mall_autoCloseReturn
  21. invoiceResult: invoiceResult_trade_pro
  22. invoiceResultRed: invoiceResultRed_trade_pro

3.3.2测试环境

  1. rocketmq:
  2. nameServer: 10.11.0.215:9876
  3. producer:
  4. #超时时间
  5. sendMessageTimeout: 30000
  6. #发送组
  7. group: mallGroup
  8. topic:
  9. autoCancel: autoCancel_test174
  10. autoComplete: autoComplete_test174
  11. autoCloseReturn: autoCloseReturn_test174
  12. invoiceApply: invoiceApply_test174
  13. invoiceResult: invoiceResult_test174
  14. invoiceResultRed: invoiceResultRed_test174
  15. invoiceApplyRed: invoiceApplyRed_test174
  16. consumerGroup:
  17. autoCancel: autoCancel_test174
  18. autoComplete: autoComplete_test174
  19. autoCloseReturn: autoCloseReturn_test174
  20. invoiceResult: invoiceResult_trade_test174
  21. invoiceResultRed: invoiceResultRed_trade_test174

3.4 文档中心和网关的路由配置

  1. - id: invoice-service
  2. uri: lb://invoice-service
  3. predicates:
  4. - Path=/invoice/**
  5. filters:
  6. - 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