diff --git a/sql/v2.1.sql b/sql/v2.1.sql index c42c64bb..a1ce2890 100644 --- a/sql/v2.1.sql +++ b/sql/v2.1.sql @@ -1,113 +1,263 @@ CREATE TABLE `xhpc_tradebill_internet_check_record` ( - `id` INT(11) NOT NULL AUTO_INCREMENT COMMENT 'ID', - `create_time` DATETIME(6) NOT NULL COMMENT '创建时间', - `create_by` VARCHAR(30) NULL DEFAULT NULL COMMENT '创建人' COLLATE 'utf8mb4_unicode_ci', - `update_time` DATETIME(6) NOT NULL COMMENT '更新时间', - `update_by` VARCHAR(30) NULL DEFAULT NULL COMMENT '更新人' COLLATE 'utf8mb4_unicode_ci', - `upload_id` INT(11) NOT NULL COMMENT '文件上传ID', - `history_order_no` BIGINT(20) NULL DEFAULT NULL COMMENT '历史订单ID', - `user_id` VARCHAR(64) NULL DEFAULT NULL COMMENT '用户ID' COLLATE 'utf8mb4_unicode_ci', - `internet_name` VARCHAR(64) NULL DEFAULT NULL COMMENT '流量方' COLLATE 'utf8mb4_unicode_ci', - `platform_internet_serial_number` VARCHAR(32) NULL DEFAULT NULL COMMENT '平台-第三方订单号' COLLATE 'utf8mb4_unicode_ci', - `platform_serial_number` VARCHAR(32) NULL DEFAULT NULL COMMENT '平台-订单号' COLLATE 'utf8mb4_unicode_ci', - `platform_charge_station` VARCHAR(32) NULL DEFAULT NULL COMMENT '平台-场站名称' COLLATE 'utf8mb4_unicode_ci', - `platform_start_soc` VARCHAR(10) NULL DEFAULT NULL COMMENT '平台-开始SOC' COLLATE 'utf8mb4_unicode_ci', - `platform_end_soc` VARCHAR(10) NULL DEFAULT NULL COMMENT '平台-结束SOC' COLLATE 'utf8mb4_unicode_ci', + `id` INT(11) NOT NULL AUTO_INCREMENT COMMENT 'ID', + `create_time` DATETIME(6) NOT NULL COMMENT '创建时间', + `create_by` VARCHAR(30) NULL DEFAULT NULL COMMENT '创建人' COLLATE 'utf8mb4_unicode_ci', + `update_time` DATETIME(6) NOT NULL COMMENT '更新时间', + `update_by` VARCHAR(30) NULL DEFAULT NULL COMMENT '更新人' COLLATE 'utf8mb4_unicode_ci', + `upload_id` INT(11) NOT NULL COMMENT '文件上传ID', + `history_order_no` BIGINT(20) NULL DEFAULT NULL COMMENT '历史订单ID', + `user_id` VARCHAR(64) NULL DEFAULT NULL COMMENT '用户ID' COLLATE 'utf8mb4_unicode_ci', + `internet_name` VARCHAR(64) NULL DEFAULT NULL COMMENT '流量方' COLLATE 'utf8mb4_unicode_ci', + `platform_internet_serial_number` VARCHAR(32) NULL DEFAULT NULL COMMENT '平台-第三方订单号' COLLATE 'utf8mb4_unicode_ci', + `platform_serial_number` VARCHAR(32) NULL DEFAULT NULL COMMENT '平台-订单号' COLLATE 'utf8mb4_unicode_ci', + `platform_charge_station` VARCHAR(32) NULL DEFAULT NULL COMMENT '平台-场站名称' COLLATE 'utf8mb4_unicode_ci', + `platform_start_soc` VARCHAR(10) NULL DEFAULT NULL COMMENT '平台-开始SOC' COLLATE 'utf8mb4_unicode_ci', + `platform_end_soc` VARCHAR(10) NULL DEFAULT NULL COMMENT '平台-结束SOC' COLLATE 'utf8mb4_unicode_ci', `platform_charging_degree` DECIMAL(10, 2) NULL DEFAULT NULL COMMENT '平台-充电电量', - `platform_charging_time` VARCHAR(20) NULL DEFAULT NULL COMMENT '平台-充电时长' COLLATE 'utf8mb4_unicode_ci', - `platform_start_time` DATETIME(6) NULL DEFAULT NULL COMMENT '平台-开始充电时间', - `platform_end_time` DATETIME(6) NULL DEFAULT NULL COMMENT '平台-结束充电时间', + `platform_charging_time` VARCHAR(20) NULL DEFAULT NULL COMMENT '平台-充电时长' COLLATE 'utf8mb4_unicode_ci', + `platform_start_time` DATETIME(6) NULL DEFAULT NULL COMMENT '平台-开始充电时间', + `platform_end_time` DATETIME(6) NULL DEFAULT NULL COMMENT '平台-结束充电时间', `platform_order_amount` DECIMAL(10, 2) NULL DEFAULT NULL COMMENT '平台-订单总金额', `platform_power_amount` DECIMAL(10, 2) NULL DEFAULT NULL COMMENT '平台-电费', `platform_server_amount` DECIMAL(10, 2) NULL DEFAULT NULL COMMENT '平台-服务费', `platform_discount_amount` DECIMAL(10, 2) NULL DEFAULT NULL COMMENT '平台-折扣金额', `platform_pay_amount` DECIMAL(10, 2) NULL DEFAULT NULL COMMENT '平台-支付金额', - `internet_serial_number` VARCHAR(32) NULL DEFAULT NULL COMMENT '流量方-订单号' COLLATE 'utf8mb4_unicode_ci', - `internet_charge_station` VARCHAR(32) NULL DEFAULT NULL COMMENT '流量方-场站名称' COLLATE 'utf8mb4_unicode_ci', - `internet_start_soc` VARCHAR(10) NULL DEFAULT NULL COMMENT '流量方-开始SOC' COLLATE 'utf8mb4_unicode_ci', - `internet_end_soc` VARCHAR(10) NULL DEFAULT NULL COMMENT '流量方-结束SOC' COLLATE 'utf8mb4_unicode_ci', + `internet_serial_number` VARCHAR(32) NULL DEFAULT NULL COMMENT '流量方-订单号' COLLATE 'utf8mb4_unicode_ci', + `internet_charge_station` VARCHAR(32) NULL DEFAULT NULL COMMENT '流量方-场站名称' COLLATE 'utf8mb4_unicode_ci', + `internet_start_soc` VARCHAR(10) NULL DEFAULT NULL COMMENT '流量方-开始SOC' COLLATE 'utf8mb4_unicode_ci', + `internet_end_soc` VARCHAR(10) NULL DEFAULT NULL COMMENT '流量方-结束SOC' COLLATE 'utf8mb4_unicode_ci', `internet_charging_degree` DECIMAL(10, 2) NULL DEFAULT NULL COMMENT '流量方-充电电量', - `internet_charging_time` VARCHAR(20) NULL DEFAULT NULL COMMENT '流量方-充电时长(单位:分钟)' COLLATE 'utf8mb4_unicode_ci', - `internet_start_time` DATETIME(6) NULL DEFAULT NULL COMMENT '流量方-开始充电时间', - `internet_end_time` DATETIME(6) NULL DEFAULT NULL COMMENT '流量方-结束充电时间', + `internet_charging_time` VARCHAR(20) NULL DEFAULT NULL COMMENT '流量方-充电时长(单位:分钟)' COLLATE 'utf8mb4_unicode_ci', + `internet_start_time` DATETIME(6) NULL DEFAULT NULL COMMENT '流量方-开始充电时间', + `internet_end_time` DATETIME(6) NULL DEFAULT NULL COMMENT '流量方-结束充电时间', `internet_order_amount` DECIMAL(10, 2) NULL DEFAULT NULL COMMENT '流量方-订单总金额', `internet_power_amount` DECIMAL(10, 2) NULL DEFAULT NULL COMMENT '流量方-电费', `internet_server_amount` DECIMAL(10, 2) NULL DEFAULT NULL COMMENT '流量方-服务费', `internet_discount_amount` DECIMAL(10, 2) NULL DEFAULT NULL COMMENT '流量方-折扣费', `internet_pay_amount` DECIMAL(10, 2) NULL DEFAULT NULL COMMENT '流量方-支付金额', - `remark` VARCHAR(200) NULL DEFAULT NULL COMMENT '备注' COLLATE 'utf8mb4_unicode_ci', - `status` SMALLINT(6) NOT NULL COMMENT '状态(0-待对账,1-对账异常,2-对账正常)', + `remark` VARCHAR(200) NULL DEFAULT NULL COMMENT '备注' COLLATE 'utf8mb4_unicode_ci', + `status` SMALLINT(6) NOT NULL COMMENT '状态(0-待对账,1-对账异常,2-对账正常)', PRIMARY KEY (`id`) USING BTREE -) - COLLATE = 'utf8mb4_unicode_ci' +) COLLATE = 'utf8mb4_unicode_ci' ENGINE = InnoDB ROW_FORMAT = DYNAMIC AUTO_INCREMENT = 34670 ; -ALTER TABLE `xhpc_app_user` ADD COLUMN `is_refund` int(4) NULL DEFAULT 0 COMMENT '是否退款 0 不退款 1 退款' AFTER `soc`; -ALTER TABLE `xhpc_community_personnel` ADD COLUMN `is_refund_application` int(10) NULL DEFAULT 0 COMMENT '是否有退款订单审核(0无 1有)' AFTER `is_refund`; -ALTER TABLE `xhpc_community_personnel` ADD COLUMN `soc` int(10) NULL DEFAULT NULL COMMENT '用户设置的SOC' AFTER `is_refund_application`; -ALTER TABLE `xhpc_community_personnel` ADD COLUMN `avatar` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '头像地址' AFTER `soc`; -ALTER TABLE `xhpc_community_personnel` ADD COLUMN `weixin_open_id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL AFTER `avatar`; -ALTER TABLE `xhpc_community_personnel` ADD COLUMN `alipay_open_id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL AFTER `weixin_open_id`; -ALTER TABLE `xhpc_community_personnel` ADD COLUMN `weixin_login` int(10) NULL DEFAULT 0 COMMENT '微信是否登录(0未登录 1已登录)' AFTER `alipay_open_id`; -ALTER TABLE `xhpc_community_personnel` ADD COLUMN `alipay_login` int(10) NULL DEFAULT 0 COMMENT '支付宝是否登录(0未登录 1已登录)' AFTER `weixin_login`; -ALTER TABLE `xhpc_community_personnel` ADD COLUMN `is_refund` int(4) NULL DEFAULT 0 COMMENT '是否退款 0 不退款 1 退款' AFTER `soc`; -ALTER TABLE `xhpc_customers_personnel` ADD COLUMN `is_refund_application` int(10) NULL DEFAULT 0 COMMENT '是否有退款订单审核(0无 1有)' AFTER `remark`; -ALTER TABLE `xhpc_customers_personnel` ADD COLUMN `soc` int(10) NULL DEFAULT NULL COMMENT '用户设置的SOC' AFTER `is_refund_application`; -ALTER TABLE `xhpc_customers_personnel` ADD COLUMN `avatar` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '头像地址' AFTER `soc`; -ALTER TABLE `xhpc_customers_personnel` ADD COLUMN `weixin_open_id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL AFTER `avatar`; -ALTER TABLE `xhpc_customers_personnel` ADD COLUMN `alipay_open_id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL AFTER `weixin_open_id`; -ALTER TABLE `xhpc_customers_personnel` ADD COLUMN `weixin_login` int(10) NULL DEFAULT 0 COMMENT '微信是否登录(0未登录 1已登录)' AFTER `alipay_open_id`; -ALTER TABLE `xhpc_customers_personnel` ADD COLUMN `alipay_login` int(10) NULL DEFAULT 0 COMMENT '支付宝是否登录(0未登录 1已登录)' AFTER `weixin_login`; -ALTER TABLE `xhpc_customers_personnel` ADD COLUMN `is_refund` int(4) NULL DEFAULT 0 COMMENT '是否退款 0 不退款 1 退款' AFTER `soc`; +ALTER TABLE `xhpc_app_user` + ADD COLUMN `is_refund` int(4) NULL DEFAULT 0 COMMENT '是否退款 0 不退款 1 退款' AFTER `soc`; +ALTER TABLE `xhpc_community_personnel` + ADD COLUMN `is_refund_application` int(10) NULL DEFAULT 0 COMMENT '是否有退款订单审核(0无 1有)' AFTER `is_refund`; +ALTER TABLE `xhpc_community_personnel` + ADD COLUMN `soc` int(10) NULL DEFAULT NULL COMMENT '用户设置的SOC' AFTER `is_refund_application`; +ALTER TABLE `xhpc_community_personnel` + ADD COLUMN `avatar` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '头像地址' AFTER `soc`; +ALTER TABLE `xhpc_community_personnel` + ADD COLUMN `weixin_open_id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL AFTER `avatar`; +ALTER TABLE `xhpc_community_personnel` + ADD COLUMN `alipay_open_id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL AFTER `weixin_open_id`; +ALTER TABLE `xhpc_community_personnel` + ADD COLUMN `weixin_login` int(10) NULL DEFAULT 0 COMMENT '微信是否登录(0未登录 1已登录)' AFTER `alipay_open_id`; +ALTER TABLE `xhpc_community_personnel` + ADD COLUMN `alipay_login` int(10) NULL DEFAULT 0 COMMENT '支付宝是否登录(0未登录 1已登录)' AFTER `weixin_login`; +ALTER TABLE `xhpc_community_personnel` + ADD COLUMN `is_refund` int(4) NULL DEFAULT 0 COMMENT '是否退款 0 不退款 1 退款' AFTER `soc`; +ALTER TABLE `xhpc_customers_personnel` + ADD COLUMN `is_refund_application` int(10) NULL DEFAULT 0 COMMENT '是否有退款订单审核(0无 1有)' AFTER `remark`; +ALTER TABLE `xhpc_customers_personnel` + ADD COLUMN `soc` int(10) NULL DEFAULT NULL COMMENT '用户设置的SOC' AFTER `is_refund_application`; +ALTER TABLE `xhpc_customers_personnel` + ADD COLUMN `avatar` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '头像地址' AFTER `soc`; +ALTER TABLE `xhpc_customers_personnel` + ADD COLUMN `weixin_open_id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL AFTER `avatar`; +ALTER TABLE `xhpc_customers_personnel` + ADD COLUMN `alipay_open_id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL AFTER `weixin_open_id`; +ALTER TABLE `xhpc_customers_personnel` + ADD COLUMN `weixin_login` int(10) NULL DEFAULT 0 COMMENT '微信是否登录(0未登录 1已登录)' AFTER `alipay_open_id`; +ALTER TABLE `xhpc_customers_personnel` + ADD COLUMN `alipay_login` int(10) NULL DEFAULT 0 COMMENT '支付宝是否登录(0未登录 1已登录)' AFTER `weixin_login`; +ALTER TABLE `xhpc_customers_personnel` + ADD COLUMN `is_refund` int(4) NULL DEFAULT 0 COMMENT '是否退款 0 不退款 1 退款' AFTER `soc`; -CREATE TABLE `xhpc_user_login` ( - `user_login_id` bigint(20) NOT NULL AUTO_INCREMENT, - `app_user_id` bigint(20) DEFAULT NULL COMMENT '用户id', - `account` varchar(50) DEFAULT NULL COMMENT '账号', - `user_type` int(4) NOT NULL COMMENT '用户类型 0 C端用户 1 流量方用户 2社区用户 3B端用户)', - `open_id` varchar(50) DEFAULT NULL COMMENT 'openid', - `type` int(4) DEFAULT '0' COMMENT '1 微信 2支付宝', - `status` int(4) DEFAULT '1' COMMENT '0退出 1登录', - `del_flag` int(1) DEFAULT '0' COMMENT '删除标志(0代表存在 2代表删除)', - `create_by` varchar(64) DEFAULT '' COMMENT '创建者', - `create_time` datetime DEFAULT NULL COMMENT '创建时间', - `update_by` varchar(64) DEFAULT '' COMMENT '更新者', - `update_time` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', - `remark` varchar(500) DEFAULT NULL COMMENT '备注', - PRIMARY KEY (`user_login_id`) +CREATE TABLE `xhpc_user_login` +( + `user_login_id` bigint(20) NOT NULL AUTO_INCREMENT, + `app_user_id` bigint(20) DEFAULT NULL COMMENT '用户id', + `account` varchar(50) DEFAULT NULL COMMENT '账号', + `user_type` int(4) NOT NULL COMMENT '用户类型 0 C端用户 1 流量方用户 2社区用户 3B端用户)', + `open_id` varchar(50) DEFAULT NULL COMMENT 'openid', + `type` int(4) DEFAULT '0' COMMENT '1 微信 2支付宝', + `status` int(4) DEFAULT '1' COMMENT '0退出 1登录', + `del_flag` int(1) DEFAULT '0' COMMENT '删除标志(0代表存在 2代表删除)', + `create_by` varchar(64) DEFAULT '' COMMENT '创建者', + `create_time` datetime DEFAULT NULL COMMENT '创建时间', + `update_by` varchar(64) DEFAULT '' COMMENT '更新者', + `update_time` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', + `remark` varchar(500) DEFAULT NULL COMMENT '备注', + PRIMARY KEY (`user_login_id`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COMMENT ='小程序用户最后一次登录记录'; CREATE TABLE `xhpc_tenant` ( - `tenant_id` VARCHAR(12) NULL DEFAULT '000000' COMMENT '租户ID', - `tenant_name` VARCHAR(50) NOT NULL COMMENT '租户名称', - `domain` VARCHAR(255) NULL DEFAULT NULL COMMENT '域名地址', + `tenant_id` VARCHAR(12) NULL DEFAULT '000000' COMMENT '租户ID', + `tenant_name` VARCHAR(50) NOT NULL COMMENT '租户名称', + `domain` VARCHAR(255) NULL DEFAULT NULL COMMENT '域名地址', `background_url` VARCHAR(1000) NULL DEFAULT NULL COMMENT '系统背景', - `linkman` VARCHAR(20) NULL DEFAULT NULL COMMENT '联系人', - `contact_number` VARCHAR(20) NULL DEFAULT NULL COMMENT '联系电话', - `address` VARCHAR(255) NULL DEFAULT NULL COMMENT '联系地址', - `station_quote` INT(11) NULL DEFAULT '-1' COMMENT '场站限额', - `station_pile_quote` INT(11) NULL DEFAULT '-1' COMMENT '每站桩限额', - `expire_time` DATETIME NULL DEFAULT NULL COMMENT '过期时间', - `create_user` BIGINT(64) NULL DEFAULT NULL COMMENT '创建人', - `create_dept` BIGINT(64) NULL DEFAULT NULL COMMENT '创建部门', - `create_time` DATETIME NULL DEFAULT NULL COMMENT '创建时间', - `update_user` BIGINT(64) NULL DEFAULT NULL COMMENT '修改人', - `update_time` DATETIME NULL DEFAULT NULL COMMENT '修改时间', - `status` INT(2) NULL DEFAULT NULL COMMENT '状态', - `is_deleted` INT(2) NULL DEFAULT '0' COMMENT '是否已删除', + `linkman` VARCHAR(20) NULL DEFAULT NULL COMMENT '联系人', + `contact_number` VARCHAR(20) NULL DEFAULT NULL COMMENT '联系电话', + `address` VARCHAR(255) NULL DEFAULT NULL COMMENT '联系地址', + `station_quote` INT(11) NULL DEFAULT '-1' COMMENT '场站限额', + `station_pile_quote` INT(11) NULL DEFAULT '-1' COMMENT '每站桩限额', + `expire_time` DATETIME NULL DEFAULT NULL COMMENT '过期时间', + `create_user` BIGINT(64) NULL DEFAULT NULL COMMENT '创建人', + `create_dept` BIGINT(64) NULL DEFAULT NULL COMMENT '创建部门', + `create_time` DATETIME NULL DEFAULT NULL COMMENT '创建时间', + `update_user` BIGINT(64) NULL DEFAULT NULL COMMENT '修改人', + `update_time` DATETIME NULL DEFAULT NULL COMMENT '修改时间', + `status` INT(2) NULL DEFAULT NULL COMMENT '状态', + `is_deleted` INT(2) NULL DEFAULT '0' COMMENT '是否已删除', PRIMARY KEY (`tenant_id`) USING BTREE -) - COMMENT ='租户表' +) COMMENT ='租户表' COLLATE = 'utf8mb4_general_ci' ENGINE = InnoDB ; + +CREATE TABLE `xhpc_tradebill_upload_record` +( + `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID', + `create_time` datetime(6) NOT NULL COMMENT '创建时间', + `create_by` varchar(30) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '创建人', + `update_time` datetime(6) NOT NULL COMMENT '更新时间', + `update_by` varchar(30) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '更新人', + `source` varchar(32) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '来源', + `file_name` varchar(64) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '文件名称', + `url` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '文件地址', + `type` smallint(6) NOT NULL COMMENT '文件类型(1-微信充值,2-微信退款,3-支付宝充值,4-支付宝退款,5-恒大,6-小桔,7-新电途,8-特来电)', + `status` smallint(6) NOT NULL COMMENT '状态(0-未对账,1-已对账)', + `del_flag` smallint(6) NOT NULL COMMENT '删除标识(0-正常,2-已删除)', + `success_count` int(11) NOT NULL COMMENT '对账成功记录数量', + `fail_count` int(11) NOT NULL COMMENT '对账失败记录数量', + `uncheck_count` int(11) NOT NULL COMMENT '未对账记录数量', + `checked_count` int(11) NOT NULL COMMENT '已对账记录数量', + `tenant_id` varchar(12) COLLATE utf8mb4_unicode_ci DEFAULT '000000' COMMENT '租户id', + PRIMARY KEY (`id`) USING BTREE +) ENGINE=InnoDB + COMMENT = '对账单上传记录表' + AUTO_INCREMENT=1 + DEFAULT CHARSET=utf8mb4 + COLLATE='utf8mb4_general_ci' + ROW_FORMAT=DYNAMIC; + + + +CREATE TABLE `xhpc_tradebill_payment_check_record` +( + `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID', + `create_time` datetime(6) NOT NULL COMMENT '创建时间', + `create_by` varchar(30) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '创建人', + `update_time` datetime(6) NOT NULL COMMENT '更新时间', + `update_by` varchar(30) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '更新人', + `upload_id` int(11) NOT NULL COMMENT '文件上传ID', + `order_type` smallint(6) DEFAULT NULL COMMENT '订单类型(1-充值,2-退款)', + `payment_channel` smallint(6) DEFAULT NULL COMMENT '充值渠道(1微信 2支付宝)', + `platform_order_number` varchar(32) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '平台-订单ID', + `platform_pay_number` varchar(32) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '平台-支付订单号', + `platform_user_id` varchar(64) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '平台-用户ID', + `platform_amount` decimal(10, 2) DEFAULT NULL COMMENT '平台-金额', + `platform_pay_time` datetime(6) DEFAULT NULL COMMENT '平台-支付时间', + `payment_pay_number` varchar(32) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '支付方-订单号', + `payment_user_id` varchar(64) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '支付方-用户ID', + `payment_amount` decimal(10, 2) DEFAULT NULL COMMENT '支付方-支付金额', + `payment_pay_time` datetime(6) DEFAULT NULL COMMENT '支付方-支付时间', + `status` smallint(6) NOT NULL COMMENT '状态(0-待对账,1-对账异常,2-对账正常)', + `remark` varchar(200) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '备注', + `tenant_id` varchar(12) COLLATE utf8mb4_unicode_ci DEFAULT '000000' COMMENT '租户id', + PRIMARY KEY (`id`) USING BTREE +) ENGINE=InnoDB + COMMENT = '支付平台对账明细表' + AUTO_INCREMENT=1 + DEFAULT CHARSET=utf8mb4 + COLLATE='utf8mb4_general_ci' + ROW_FORMAT=DYNAMIC; + + + +CREATE TABLE `xhpc_tradebill_internet_check_record` +( + `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID', + `create_time` datetime(6) NOT NULL COMMENT '创建时间', + `create_by` varchar(30) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '创建人', + `update_time` datetime(6) NOT NULL COMMENT '更新时间', + `update_by` varchar(30) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '更新人', + `upload_id` int(11) NOT NULL COMMENT '文件上传ID', + `history_order_no` bigint(20) DEFAULT NULL COMMENT '历史订单ID', + `user_id` varchar(64) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '用户ID', + `internet_name` varchar(64) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '流量方', + `platform_internet_serial_number` varchar(32) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '平台-第三方订单号', + `platform_serial_number` varchar(32) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '平台-订单号', + `platform_charge_station` varchar(32) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '平台-场站名称', + `platform_start_soc` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '平台-开始SOC', + `platform_end_soc` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '平台-结束SOC', + `platform_charging_degree` decimal(10, 2) DEFAULT NULL COMMENT '平台-充电电量', + `platform_charging_time` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '平台-充电时长', + `platform_start_time` datetime(6) DEFAULT NULL COMMENT '平台-开始充电时间', + `platform_end_time` datetime(6) DEFAULT NULL COMMENT '平台-结束充电时间', + `platform_order_amount` decimal(10, 2) DEFAULT NULL COMMENT '平台-订单总金额', + `platform_power_amount` decimal(10, 2) DEFAULT NULL COMMENT '平台-电费', + `platform_server_amount` decimal(10, 2) DEFAULT NULL COMMENT '平台-服务费', + `platform_discount_amount` decimal(10, 2) DEFAULT NULL COMMENT '平台-折扣金额', + `platform_pay_amount` decimal(10, 2) DEFAULT NULL COMMENT '平台-支付金额', + `internet_serial_number` varchar(32) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '流量方-订单号', + `internet_charge_station` varchar(32) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '流量方-场站名称', + `internet_start_soc` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '流量方-开始SOC', + `internet_end_soc` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '流量方-结束SOC', + `internet_charging_degree` decimal(10, 2) DEFAULT NULL COMMENT '流量方-充电电量', + `internet_charging_time` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '流量方-充电时长(单位:分钟)', + `internet_start_time` datetime(6) DEFAULT NULL COMMENT '流量方-开始充电时间', + `internet_end_time` datetime(6) DEFAULT NULL COMMENT '流量方-结束充电时间', + `internet_order_amount` decimal(10, 2) DEFAULT NULL COMMENT '流量方-订单总金额', + `internet_power_amount` decimal(10, 2) DEFAULT NULL COMMENT '流量方-电费', + `internet_server_amount` decimal(10, 2) DEFAULT NULL COMMENT '流量方-服务费', + `internet_discount_amount` decimal(10, 2) DEFAULT NULL COMMENT '流量方-折扣费', + `internet_pay_amount` decimal(10, 2) DEFAULT NULL COMMENT '流量方-支付金额', + `remark` varchar(200) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '备注', + `status` smallint(6) NOT NULL COMMENT '状态(0-待对账,1-对账异常,2-对账正常)', + `tenant_id` varchar(12) COLLATE utf8mb4_unicode_ci DEFAULT '000000' COMMENT '租户id', + PRIMARY KEY (`id`) USING BTREE +) ENGINE=InnoDB + COMMENT = '流量方对账明细表' + AUTO_INCREMENT=1 + DEFAULT CHARSET=utf8mb4 + COLLATE='utf8mb4_general_ci' + ROW_FORMAT=DYNAMIC; + + +CREATE TABLE `xhpc_device_message` +( + `device_message_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '消息id', + `type` varchar(50) DEFAULT NULL COMMENT '设备类型(PILE-充电桩,TERMINAL-终端)', + `serial_number` varchar(32) DEFAULT NULL COMMENT '设备流水号', + `content` text CHARACTER SET utf8 COMMENT '报文16进制原文', + `reply_content` text COMMENT '回复的报文', + `status` int(10) DEFAULT '0' COMMENT '状态(0正常 1停用)', + `create_time` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '创建时间', + `create_by` varchar(30) CHARACTER SET utf8 DEFAULT NULL COMMENT '创建者', + `update_time` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', + `update_by` varchar(30) CHARACTER SET utf8 DEFAULT NULL COMMENT '更新者', + `remark` text CHARACTER SET utf8 COMMENT '备注', + `tenant_id` varchar(12) DEFAULT '000000' COMMENT '租户id', + PRIMARY KEY (`device_message_id`) USING BTREE +) ENGINE=InnoDB + COMMENT = '设备运行信息表' + AUTO_INCREMENT=1 + DEFAULT CHARSET=utf8mb4 + COLLATE='utf8mb4_general_ci' + ROW_FORMAT=DYNAMIC; + + ALTER TABLE `et_auth_sec_token` ADD COLUMN `tenant_id` VARCHAR(12) NULL DEFAULT '000000' COMMENT '租户id'; ALTER TABLE `et_charge_order_info` @@ -281,3 +431,47 @@ ALTER TABLE `xhpc_vin_blacklist` ALTER TABLE `xhpc_user_account_statement` ADD COLUMN `source` INT(4) NULL DEFAULT '0' COMMENT '订单来源(0 C端用户 1 流量方用户 2社区用户 3B端用户)' AFTER `tenant_id`; + +ALTER TABLE `xhpc_app_user` + ADD COLUMN `soc_protect` INT(4) NULL DEFAULT '0' COMMENT '是否开启电池保护 0 未开启 1开启' AFTER `tenant_id`; +ALTER TABLE `xhpc_community_personnel` + ADD COLUMN `soc_protect` INT(4) NULL DEFAULT '0' COMMENT '是否开启电池保护 0 未开启 1开启' AFTER `tenant_id`; +ALTER TABLE `xhpc_customers_personnel` + ADD COLUMN `soc_protect` INT(4) NULL DEFAULT '0' COMMENT '是否开启电池保护 0 未开启 1开启' AFTER `tenant_id`; + +ALTER TABLE `xhpc_setting_config` + CHANGE COLUMN `zhb_server_url` `zhb_server_url` VARCHAR(255) NULL DEFAULT NULL COMMENT '支付宝网管' COLLATE 'utf8mb4_general_ci' AFTER `zfb_alipay_root_cert`; + +CREATE TABLE `xhpc_setting_config` ( + `setting_config_id` BIGINT(20) NOT NULL AUTO_INCREMENT, + `wx_app_id` VARCHAR(50) NULL DEFAULT NULL COMMENT '微信小程序id' COLLATE 'utf8mb4_general_ci', + `wx_app_secret` VARCHAR(50) NULL DEFAULT NULL COMMENT '微信小程序密钥' COLLATE 'utf8mb4_general_ci', + `wx_mch_id` VARCHAR(20) NULL DEFAULT NULL COMMENT '微信商户id' COLLATE 'utf8mb4_general_ci', + `wx_mch_key` VARCHAR(50) NULL DEFAULT NULL COMMENT '微信商户平台Key' COLLATE 'utf8mb4_general_ci', + `wx_payment_url` VARCHAR(255) NULL DEFAULT NULL COMMENT '微信小程序支付地址' COLLATE 'utf8mb4_general_ci', + `wx_callback_url` VARCHAR(255) NULL DEFAULT NULL COMMENT '微信回调地址' COLLATE 'utf8mb4_general_ci', + `wx_transfers_url` VARCHAR(255) NULL DEFAULT NULL COMMENT '向微信用户个人付款地址' COLLATE 'utf8mb4_general_ci', + `wx_apiclient_cert_pem` VARCHAR(255) NULL DEFAULT NULL COMMENT '微信证书' COLLATE 'utf8mb4_general_ci', + `wx_apiclient_key_pem` VARCHAR(255) NULL DEFAULT NULL COMMENT '微信证书' COLLATE 'utf8mb4_general_ci', + `wx_app_cert_public_key` VARCHAR(255) NULL DEFAULT NULL COMMENT '微信证书' COLLATE 'utf8mb4_general_ci', + `zfb_app_id` VARCHAR(50) NULL DEFAULT NULL COMMENT '支付宝appid' COLLATE 'utf8mb4_general_ci', + `zfb_private_key` VARCHAR(500) NULL DEFAULT NULL COMMENT '支付宝应用私钥' COLLATE 'utf8mb4_general_ci', + `zfb_callback_url` VARCHAR(255) NULL DEFAULT NULL COMMENT '支付宝回调地址' COLLATE 'utf8mb4_general_ci', + `zfb_app_cert_public_key` VARCHAR(255) NULL DEFAULT NULL COMMENT '支付宝应用公钥证书路径' COLLATE 'utf8mb4_general_ci', + `zfb_alipay_cert_public_key_rsa` VARCHAR(255) NULL DEFAULT NULL COMMENT '支付宝公钥证书路径' COLLATE 'utf8mb4_general_ci', + `zfb_alipay_root_cert` VARCHAR(255) NULL DEFAULT NULL COMMENT '支付宝根证书路径' COLLATE 'utf8mb4_general_ci', + `zhb_server_url` VARCHAR(255) NULL DEFAULT NULL COMMENT '支付宝网管' COLLATE 'utf8mb4_general_ci', + `status` INT(4) NULL DEFAULT '0' COMMENT '1微信 2支付宝', + `del_flag` INT(1) NULL DEFAULT '0' COMMENT '删除标志(0代表存在 1代表删除)', + `create_by` VARCHAR(64) NULL DEFAULT '' COMMENT '创建者' COLLATE 'utf8mb4_general_ci', + `create_time` DATETIME NULL DEFAULT NULL COMMENT '创建时间', + `update_by` VARCHAR(64) NULL DEFAULT '' COMMENT '更新者' COLLATE 'utf8mb4_general_ci', + `update_time` DATETIME NULL DEFAULT NULL COMMENT '更新时间', + `remark` VARCHAR(500) NULL DEFAULT NULL COMMENT '备注' COLLATE 'utf8mb4_general_ci', + `tenant_id` VARCHAR(12) NULL DEFAULT '000000' COMMENT '租户id' COLLATE 'utf8mb4_general_ci', + PRIMARY KEY (`setting_config_id`) USING BTREE +) + COLLATE='utf8mb4_general_ci' +ENGINE=InnoDB +AUTO_INCREMENT=3 +; diff --git a/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/DaoAspect.java b/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/DaoAspect.java new file mode 100644 index 00000000..57f36847 --- /dev/null +++ b/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/DaoAspect.java @@ -0,0 +1,160 @@ +package com.xhpc.charging.station; + + +import com.xhpc.common.core.constant.CacheConstants; +import com.xhpc.common.core.utils.SecurityUtils; +import com.xhpc.common.core.utils.StringUtils; +import com.xhpc.common.redis.service.RedisService; +import com.xhpc.system.api.model.LoginUser; +import org.apache.commons.beanutils.BeanUtils; +import org.aspectj.lang.ProceedingJoinPoint; +import org.aspectj.lang.annotation.Around; +import org.aspectj.lang.annotation.Aspect; +import org.aspectj.lang.annotation.Pointcut; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Configuration; +import org.springframework.stereotype.Component; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; + +import javax.servlet.http.HttpServletRequest; +import java.util.Date; + +/* + * TODO AO切面,插入创建人,创建时间,修改人,修改时间 + * @author fjd + * @date 2020-07-09 11:59 + */ +@Aspect +@Component +@Configuration +public class DaoAspect { + + private static final String CREATE_USER = "createBy"; + private static final String CREATE_TIME = "createTime"; + private static final String UPDATE_USER = "updateBy"; + private static final String UPDATE_TIME = "updateTime"; + private static final String TENANT_ID = "tenantId"; + + @Pointcut("execution(* com.xhpc..*.update*(..))") + public void daoUpdate() { + + } + + @Pointcut("execution(* com.xhpc..*.insert*(..))") + public void daoCreate() { + + } + + @Autowired + private RedisService redisService; + + @Around("daoUpdate()") + public Object doAroundUpdate(ProceedingJoinPoint point) throws Throwable { + + ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); + if (attributes == null) { + return point.proceed(); + } + HttpServletRequest request = attributes.getRequest(); + try { + String token = request.getHeader(CacheConstants.HEADER); + token = token.substring(7); + LoginUser loginUser = new LoginUser(); + try { + loginUser = redisService.getCacheObject(CacheConstants.LOGIN_TOKEN_KEY + token); + } catch (Exception e) { + } + String userName = ""; + try { + userName = SecurityUtils.getUsername(); + } catch (Exception e) { + } + if (StringUtils.isEmpty(userName)) { + userName = loginUser.getUsername(); + } + if (StringUtils.isEmpty(userName)) { + userName = "admin"; + } + if (userName != null) { + Object[] objects = point.getArgs(); + if (objects != null && objects.length > 0) { + for (Object arg : objects) { + if (isProperty(arg, UPDATE_USER) && StringUtils.isEmpty(BeanUtils.getProperty(arg, UPDATE_USER))) { + BeanUtils.setProperty(arg, UPDATE_USER, userName); + } + if (isProperty(arg, UPDATE_TIME) && StringUtils.isEmpty(BeanUtils.getProperty(arg, UPDATE_TIME))) { + BeanUtils.setProperty(arg, UPDATE_TIME, new Date()); + } + } + } + } + } catch (Exception e) { + } + Object object = point.proceed(); + return object; + + } + + @Around("daoCreate()") + public Object doAroundCreate(ProceedingJoinPoint point) throws Throwable { + + ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); + if (attributes == null) { + return point.proceed(); + } + HttpServletRequest request = attributes.getRequest(); + try { + Object[] objects = point.getArgs(); + if (objects != null && objects.length > 0) { + for (Object arg : objects) { + String token = request.getHeader(CacheConstants.HEADER); + token = token.substring(7); + LoginUser loginUser = new LoginUser(); + try { + loginUser = redisService.getCacheObject(CacheConstants.LOGIN_TOKEN_KEY + token); + } catch (Exception e) { + } + String userName = ""; + try { + userName = SecurityUtils.getUsername(); + } catch (Exception e) { + } + if (StringUtils.isEmpty(userName)) { + userName = loginUser.getUsername(); + } + if (StringUtils.isEmpty(userName)) { + userName = "admin"; + } + Date date = new Date(); + if (isProperty(arg, CREATE_USER) && StringUtils.isEmpty(BeanUtils.getProperty(arg, CREATE_USER))) { + BeanUtils.setProperty(arg, CREATE_USER, userName); + } + if (isProperty(arg, UPDATE_USER) && StringUtils.isEmpty(BeanUtils.getProperty(arg, UPDATE_USER))) { + BeanUtils.setProperty(arg, UPDATE_USER, userName); + } + + if (isProperty(arg, CREATE_TIME) && StringUtils.isEmpty(BeanUtils.getProperty(arg, CREATE_TIME))) { + BeanUtils.setProperty(arg, CREATE_TIME, date); + } + if (isProperty(arg, UPDATE_TIME) && StringUtils.isEmpty(BeanUtils.getProperty(arg, UPDATE_TIME))) { + BeanUtils.setProperty(arg, UPDATE_TIME, date); + } + + if (isProperty(arg, TENANT_ID) && StringUtils.isEmpty(BeanUtils.getProperty(arg, TENANT_ID))) { + BeanUtils.setProperty(arg, TENANT_ID, loginUser.getTenantId()); + } + } + } + } catch (Exception e) { + } + Object object = point.proceed(); + return object; + } + + public static boolean isProperty(Object bean, String field) { + + return StringUtils.isProperty(bean, field); + } + +} diff --git a/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/service/XhpcChargingPileServiceImpl.java b/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/service/XhpcChargingPileServiceImpl.java index 727372a3..9f0f0b6a 100644 --- a/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/service/XhpcChargingPileServiceImpl.java +++ b/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/service/XhpcChargingPileServiceImpl.java @@ -19,7 +19,7 @@ import com.xhpc.common.domain.XhpcChargingPile; import com.xhpc.common.domain.XhpcChargingStation; import com.xhpc.common.domain.XhpcTerminal; import com.xhpc.common.enums.ConnectorTypeEnum; -import com.xhpc.common.enums.EquipmentTypeEnum; +import com.xhpc.common.enums.PileEquipmentTypeEnum; import com.xhpc.common.enums.PowerTypeEnum; import com.xhpc.common.util.LogUserUtils; import com.xhpc.system.api.model.LoginUser; @@ -371,7 +371,7 @@ public class XhpcChargingPileServiceImpl implements IXhpcChargingPileService { pile.setType(PowerTypeEnum.getCodeByName(pile.getTypeName())); pile.setConnectorType(ConnectorTypeEnum.getCodeByName(pile.getConnectorTypeName())); - pile.setEquipmentType(EquipmentTypeEnum.getCodeByName(pile.getEquipmentTypeName())); + pile.setEquipmentType(PileEquipmentTypeEnum.getCodeByName(pile.getEquipmentTypeName())); XhpcChargingStation station = xhpcChargingStationService.selectXhpcChargingStationByName(pile.getChargingStationName()); if(station == null){ diff --git a/xhpc-modules/xhpc-charging-station/src/main/resources/mapper/XhpcChargingStationMapper.xml b/xhpc-modules/xhpc-charging-station/src/main/resources/mapper/XhpcChargingStationMapper.xml index 5ed1000e..0d529603 100644 --- a/xhpc-modules/xhpc-charging-station/src/main/resources/mapper/XhpcChargingStationMapper.xml +++ b/xhpc-modules/xhpc-charging-station/src/main/resources/mapper/XhpcChargingStationMapper.xml @@ -846,7 +846,8 @@ select IF(SUM(total_power) IS NULL, 0, SUM(total_power)) as chargingDegreeSum, COUNT(history_order_id) as realTimeOrderIdCount, - COUNT(DISTINCT user_id) as userIdCount + ((SELECT count(user_id) from xhpc_history_order where charging_station_id =#{chargingStationId} and create_time >= #{createTime} and source=1 ) + + (SELECT count(DISTINCT user_id) from xhpc_history_order where charging_station_id =#{chargingStationId} and create_time >= #{createTime} and source!=1 )) as userIdCount from xhpc_history_order where charging_station_id =#{chargingStationId} and create_time >= #{createTime} diff --git a/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/api/UserTypeService.java b/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/api/UserTypeService.java index 0df29642..4508fe61 100644 --- a/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/api/UserTypeService.java +++ b/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/api/UserTypeService.java @@ -7,6 +7,8 @@ import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestParam; +import java.math.BigDecimal; + /** * @author yuyang * @date 2021/12/29 10:23 @@ -21,4 +23,21 @@ public interface UserTypeService { */ @GetMapping("/common/getUser") R getUser(@RequestParam(value = "phone")String phone,@RequestParam(value = "userId")Long userId,@RequestParam(value = "userType")Integer userType,@RequestParam(value = "serialNumber")String serialNumber,@RequestParam(value = "tenantId")String tenantId); + + + + /** + * 根据用户类型,用户id,充值记录,增加流水 + * @param money 充值金额 + * @param userId 充值用户 + * @param userType 用户类型 + * @param tenantId 租户id + * @param type 充值渠道(1微信 2支付宝 3平台) + * @param status 1 充值 2退款 + * @param remark 备注 + * @return + */ + @GetMapping("/common/insertUserBalance") + R insertUserBalance(@RequestParam(value = "money")BigDecimal money, @RequestParam(value = "userId")Long userId, @RequestParam(value = "userType")Integer userType, @RequestParam(value = "tenantId")String tenantId, @RequestParam(value = "type")Integer type, @RequestParam(value = "status")Integer status, @RequestParam(value = "remark")String remark,@RequestParam(value = "moneyOrderId")Long moneyOrderId); + } diff --git a/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/api/factory/UserTypeFallbackFactory.java b/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/api/factory/UserTypeFallbackFactory.java index 242ff7e3..0e956717 100644 --- a/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/api/factory/UserTypeFallbackFactory.java +++ b/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/api/factory/UserTypeFallbackFactory.java @@ -7,6 +7,8 @@ import org.slf4j.LoggerFactory; import org.springframework.cloud.openfeign.FallbackFactory; import org.springframework.stereotype.Component; +import java.math.BigDecimal; + /** * @author yuyang * @date 2021/12/29 10:27 @@ -23,6 +25,11 @@ public class UserTypeFallbackFactory implements FallbackFactory public R getUser(String phone, Long userId, Integer userType,String serialNumber,String tenantId) { return R.fail("用户信息获取失败:" + cause.getMessage()); } + + @Override + public R insertUserBalance(BigDecimal money,Long userId, Integer userType, String tenantId, Integer type,Integer status,String remark,Long moneyOrderId) { + return R.fail("添加用户金额信息失败:" + cause.getMessage()); + } }; } } diff --git a/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/domain/XhpcRechargeOrder.java b/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/domain/XhpcRechargeOrder.java similarity index 98% rename from xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/domain/XhpcRechargeOrder.java rename to xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/domain/XhpcRechargeOrder.java index ac7ff9d2..a49a30aa 100644 --- a/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/domain/XhpcRechargeOrder.java +++ b/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/domain/XhpcRechargeOrder.java @@ -1,4 +1,4 @@ -package com.xhpc.payment.domain; +package com.xhpc.common.domain; import com.xhpc.common.core.web.domain.BaseEntity; diff --git a/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/domain/XhpcRefundOrder.java b/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/domain/XhpcRefundOrder.java similarity index 99% rename from xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/domain/XhpcRefundOrder.java rename to xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/domain/XhpcRefundOrder.java index c7485ef9..1325a56b 100644 --- a/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/domain/XhpcRefundOrder.java +++ b/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/domain/XhpcRefundOrder.java @@ -1,4 +1,4 @@ -package com.xhpc.payment.domain; +package com.xhpc.common.domain; import com.xhpc.common.core.web.domain.BaseEntity; diff --git a/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/enums/EquipmentTypeEnum.java b/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/enums/PileEquipmentTypeEnum.java similarity index 79% rename from xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/enums/EquipmentTypeEnum.java rename to xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/enums/PileEquipmentTypeEnum.java index 20293364..234f0e51 100644 --- a/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/enums/EquipmentTypeEnum.java +++ b/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/enums/PileEquipmentTypeEnum.java @@ -4,7 +4,7 @@ package com.xhpc.common.enums; /** * 设备类型 */ -public enum EquipmentTypeEnum { +public enum PileEquipmentTypeEnum { DC(1, "直流设备"), AC(2, "交流设备"), @@ -16,14 +16,14 @@ public enum EquipmentTypeEnum { private final int code; private final String name; - EquipmentTypeEnum(int code, String name){ + PileEquipmentTypeEnum(int code, String name){ this.code = code; this.name = name; } //根据code获取name public static String getNameByCode(int code) { - for (EquipmentTypeEnum typeEnum : EquipmentTypeEnum.values()) { + for (PileEquipmentTypeEnum typeEnum : PileEquipmentTypeEnum.values()) { //移除交办 if (typeEnum.code == code) { return typeEnum.name; @@ -34,7 +34,7 @@ public enum EquipmentTypeEnum { //根据code获取name public static Integer getCodeByName(String name) { - for (EquipmentTypeEnum typeEnum : EquipmentTypeEnum.values()) { + for (PileEquipmentTypeEnum typeEnum : PileEquipmentTypeEnum.values()) { //移除交办 if (typeEnum.name.equals(name)) { return typeEnum.code; diff --git a/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/enums/StationDeviceEnum.java b/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/enums/StationDeviceEnum.java new file mode 100644 index 00000000..e3b22ac4 --- /dev/null +++ b/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/enums/StationDeviceEnum.java @@ -0,0 +1,52 @@ +package com.xhpc.common.enums; + +public enum StationDeviceEnum { + + STATION("STATION", "充电站"), + PILE("PILE", "充电桩"), + TERMINAL("TERMINAL", "充电终端"), + BARRIER("BARRIER", "道闸"), + GROUND_LOCK("GROUND_LOCK", "地锁") + ; + + + private final String code; + private final String name; + + StationDeviceEnum(String code, String name){ + this.code = code; + this.name = name; + } + + //根据code获取name + public static String getNameByCode(String code) { + for (StationDeviceEnum typeEnum : StationDeviceEnum.values()) { + //移除交办 + if (typeEnum.code.equals(code)) { + return typeEnum.name; + } + } + return ""; + } + + //根据name获取code + public static String getCodeByName(String name) { + for (StationDeviceEnum typeEnum : StationDeviceEnum.values()) { + //移除交办 + if (typeEnum.name.equals(name)) { + return typeEnum.code; + } + } + return null; + } + + public String getCode() { + + return code; + } + + public String getName() { + + return name; + } +} diff --git a/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/util/UserTypeUtil.java b/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/util/UserTypeUtil.java index 3394ceb7..da87eb51 100644 --- a/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/util/UserTypeUtil.java +++ b/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/util/UserTypeUtil.java @@ -26,4 +26,51 @@ public class UserTypeUtil { //重新登录 public static final Integer LOGIN_TYPE = 1999; + + /** + * 微信操作渠道 + */ + public static final Integer OPERATION_WX_TYPE = 1; + + /** + * 支付宝操作渠道 + */ + public static final Integer OPERATION_ALI_PAY_TYPE = 2; + + /** + * 用户增加余额 + */ + public static final Integer INSERT_BALANCE = 1; + /** + * 用户减少余额 + */ + public static final Integer UPDATE_BALANCE = 2; + + /** + * 微信支付 + */ + public static final Integer RECHARGE_WX = 1; + /** + * 支付宝支付 + */ + public static final Integer RECHARGE_ZHB = 2; + /** + * 平台支付 + */ + public static final Integer RECHARGE_PT = 3; + + /** + * 支付状态-待支付 + */ + public static final Integer RECHARGE_STATUS_ZERO= 0; + /** + * 支付状态-充值成功 + */ + public static final Integer RECHARGE_STATUS_ONE = 1; + /** + * 支付状态-充值失败 + */ + public static final Integer RECHARGE_STATUS_TWO = 2; + + } diff --git a/xhpc-modules/xhpc-general/src/main/java/com/xhpc/general/DaoAspect.java b/xhpc-modules/xhpc-general/src/main/java/com/xhpc/general/DaoAspect.java new file mode 100644 index 00000000..afa7ebd7 --- /dev/null +++ b/xhpc-modules/xhpc-general/src/main/java/com/xhpc/general/DaoAspect.java @@ -0,0 +1,160 @@ +package com.xhpc.general; + + +import com.xhpc.common.core.constant.CacheConstants; +import com.xhpc.common.core.utils.SecurityUtils; +import com.xhpc.common.core.utils.StringUtils; +import com.xhpc.common.redis.service.RedisService; +import com.xhpc.system.api.model.LoginUser; +import org.apache.commons.beanutils.BeanUtils; +import org.aspectj.lang.ProceedingJoinPoint; +import org.aspectj.lang.annotation.Around; +import org.aspectj.lang.annotation.Aspect; +import org.aspectj.lang.annotation.Pointcut; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Configuration; +import org.springframework.stereotype.Component; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; + +import javax.servlet.http.HttpServletRequest; +import java.util.Date; + +/* + * TODO AO切面,插入创建人,创建时间,修改人,修改时间 + * @author fjd + * @date 2020-07-09 11:59 + */ +@Aspect +@Component +@Configuration +public class DaoAspect { + + private static final String CREATE_USER = "createBy"; + private static final String CREATE_TIME = "createTime"; + private static final String UPDATE_USER = "updateBy"; + private static final String UPDATE_TIME = "updateTime"; + private static final String TENANT_ID = "tenantId"; + + @Pointcut("execution(* com.xhpc..*.update*(..))") + public void daoUpdate() { + + } + + @Pointcut("execution(* com.xhpc..*.insert*(..))") + public void daoCreate() { + + } + + @Autowired + private RedisService redisService; + + @Around("daoUpdate()") + public Object doAroundUpdate(ProceedingJoinPoint point) throws Throwable { + + ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); + if (attributes == null) { + return point.proceed(); + } + HttpServletRequest request = attributes.getRequest(); + try { + String token = request.getHeader(CacheConstants.HEADER); + token = token.substring(7); + LoginUser loginUser = new LoginUser(); + try { + loginUser = redisService.getCacheObject(CacheConstants.LOGIN_TOKEN_KEY + token); + } catch (Exception e) { + } + String userName = ""; + try { + userName = SecurityUtils.getUsername(); + } catch (Exception e) { + } + if (StringUtils.isEmpty(userName)) { + userName = loginUser.getUsername(); + } + if (StringUtils.isEmpty(userName)) { + userName = "admin"; + } + if (userName != null) { + Object[] objects = point.getArgs(); + if (objects != null && objects.length > 0) { + for (Object arg : objects) { + if (isProperty(arg, UPDATE_USER) && StringUtils.isEmpty(BeanUtils.getProperty(arg, UPDATE_USER))) { + BeanUtils.setProperty(arg, UPDATE_USER, userName); + } + if (isProperty(arg, UPDATE_TIME) && StringUtils.isEmpty(BeanUtils.getProperty(arg, UPDATE_TIME))) { + BeanUtils.setProperty(arg, UPDATE_TIME, new Date()); + } + } + } + } + } catch (Exception e) { + } + Object object = point.proceed(); + return object; + + } + + @Around("daoCreate()") + public Object doAroundCreate(ProceedingJoinPoint point) throws Throwable { + + ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); + if (attributes == null) { + return point.proceed(); + } + HttpServletRequest request = attributes.getRequest(); + try { + Object[] objects = point.getArgs(); + if (objects != null && objects.length > 0) { + for (Object arg : objects) { + String token = request.getHeader(CacheConstants.HEADER); + token = token.substring(7); + LoginUser loginUser = new LoginUser(); + try { + loginUser = redisService.getCacheObject(CacheConstants.LOGIN_TOKEN_KEY + token); + } catch (Exception e) { + } + String userName = ""; + try { + userName = SecurityUtils.getUsername(); + } catch (Exception e) { + } + if (StringUtils.isEmpty(userName)) { + userName = loginUser.getUsername(); + } + if (StringUtils.isEmpty(userName)) { + userName = "admin"; + } + Date date = new Date(); + if (isProperty(arg, CREATE_USER) && StringUtils.isEmpty(BeanUtils.getProperty(arg, CREATE_USER))) { + BeanUtils.setProperty(arg, CREATE_USER, userName); + } + if (isProperty(arg, UPDATE_USER) && StringUtils.isEmpty(BeanUtils.getProperty(arg, UPDATE_USER))) { + BeanUtils.setProperty(arg, UPDATE_USER, userName); + } + + if (isProperty(arg, CREATE_TIME) && StringUtils.isEmpty(BeanUtils.getProperty(arg, CREATE_TIME))) { + BeanUtils.setProperty(arg, CREATE_TIME, date); + } + if (isProperty(arg, UPDATE_TIME) && StringUtils.isEmpty(BeanUtils.getProperty(arg, UPDATE_TIME))) { + BeanUtils.setProperty(arg, UPDATE_TIME, date); + } + + if (isProperty(arg, TENANT_ID) && StringUtils.isEmpty(BeanUtils.getProperty(arg, TENANT_ID))) { + BeanUtils.setProperty(arg, TENANT_ID, loginUser.getTenantId()); + } + } + } + } catch (Exception e) { + } + Object object = point.proceed(); + return object; + } + + public static boolean isProperty(Object bean, String field) { + + return StringUtils.isProperty(bean, field); + } + +} diff --git a/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/DaoAspect.java b/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/DaoAspect.java new file mode 100644 index 00000000..8dfe8aaf --- /dev/null +++ b/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/DaoAspect.java @@ -0,0 +1,160 @@ +package com.xhpc.invoice.aspect; + + +import com.xhpc.common.core.constant.CacheConstants; +import com.xhpc.common.core.utils.SecurityUtils; +import com.xhpc.common.core.utils.StringUtils; +import com.xhpc.common.redis.service.RedisService; +import com.xhpc.system.api.model.LoginUser; +import org.apache.commons.beanutils.BeanUtils; +import org.aspectj.lang.ProceedingJoinPoint; +import org.aspectj.lang.annotation.Around; +import org.aspectj.lang.annotation.Aspect; +import org.aspectj.lang.annotation.Pointcut; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Configuration; +import org.springframework.stereotype.Component; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; + +import javax.servlet.http.HttpServletRequest; +import java.util.Date; + +/* + * TODO AO切面,插入创建人,创建时间,修改人,修改时间 + * @author fjd + * @date 2020-07-09 11:59 + */ +@Aspect +@Component +@Configuration +public class DaoAspect { + + private static final String CREATE_USER = "createBy"; + private static final String CREATE_TIME = "createTime"; + private static final String UPDATE_USER = "updateBy"; + private static final String UPDATE_TIME = "updateTime"; + private static final String TENANT_ID = "tenantId"; + + @Pointcut("execution(* com.xhpc..*.update*(..))") + public void daoUpdate() { + + } + + @Pointcut("execution(* com.xhpc..*.insert*(..))") + public void daoCreate() { + + } + + @Autowired + private RedisService redisService; + + @Around("daoUpdate()") + public Object doAroundUpdate(ProceedingJoinPoint point) throws Throwable { + + ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); + if (attributes == null) { + return point.proceed(); + } + HttpServletRequest request = attributes.getRequest(); + try { + String token = request.getHeader(CacheConstants.HEADER); + token = token.substring(7); + LoginUser loginUser = new LoginUser(); + try { + loginUser = redisService.getCacheObject(CacheConstants.LOGIN_TOKEN_KEY + token); + } catch (Exception e) { + } + String userName = ""; + try { + userName = SecurityUtils.getUsername(); + } catch (Exception e) { + } + if (StringUtils.isEmpty(userName)) { + userName = loginUser.getUsername(); + } + if (StringUtils.isEmpty(userName)) { + userName = "admin"; + } + if (userName != null) { + Object[] objects = point.getArgs(); + if (objects != null && objects.length > 0) { + for (Object arg : objects) { + if (isProperty(arg, UPDATE_USER) && StringUtils.isEmpty(BeanUtils.getProperty(arg, UPDATE_USER))) { + BeanUtils.setProperty(arg, UPDATE_USER, userName); + } + if (isProperty(arg, UPDATE_TIME) && StringUtils.isEmpty(BeanUtils.getProperty(arg, UPDATE_TIME))) { + BeanUtils.setProperty(arg, UPDATE_TIME, new Date()); + } + } + } + } + } catch (Exception e) { + } + Object object = point.proceed(); + return object; + + } + + @Around("daoCreate()") + public Object doAroundCreate(ProceedingJoinPoint point) throws Throwable { + + ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); + if (attributes == null) { + return point.proceed(); + } + HttpServletRequest request = attributes.getRequest(); + try { + Object[] objects = point.getArgs(); + if (objects != null && objects.length > 0) { + for (Object arg : objects) { + String token = request.getHeader(CacheConstants.HEADER); + token = token.substring(7); + LoginUser loginUser = new LoginUser(); + try { + loginUser = redisService.getCacheObject(CacheConstants.LOGIN_TOKEN_KEY + token); + } catch (Exception e) { + } + String userName = ""; + try { + userName = SecurityUtils.getUsername(); + } catch (Exception e) { + } + if (StringUtils.isEmpty(userName)) { + userName = loginUser.getUsername(); + } + if (StringUtils.isEmpty(userName)) { + userName = "admin"; + } + Date date = new Date(); + if (isProperty(arg, CREATE_USER) && StringUtils.isEmpty(BeanUtils.getProperty(arg, CREATE_USER))) { + BeanUtils.setProperty(arg, CREATE_USER, userName); + } + if (isProperty(arg, UPDATE_USER) && StringUtils.isEmpty(BeanUtils.getProperty(arg, UPDATE_USER))) { + BeanUtils.setProperty(arg, UPDATE_USER, userName); + } + + if (isProperty(arg, CREATE_TIME) && StringUtils.isEmpty(BeanUtils.getProperty(arg, CREATE_TIME))) { + BeanUtils.setProperty(arg, CREATE_TIME, date); + } + if (isProperty(arg, UPDATE_TIME) && StringUtils.isEmpty(BeanUtils.getProperty(arg, UPDATE_TIME))) { + BeanUtils.setProperty(arg, UPDATE_TIME, date); + } + + if (isProperty(arg, TENANT_ID) && StringUtils.isEmpty(BeanUtils.getProperty(arg, TENANT_ID))) { + BeanUtils.setProperty(arg, TENANT_ID, loginUser.getTenantId()); + } + } + } + } catch (Exception e) { + } + Object object = point.proceed(); + return object; + } + + public static boolean isProperty(Object bean, String field) { + + return StringUtils.isProperty(bean, field); + } + +} diff --git a/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/pojo/XhpcInvoice.java b/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/pojo/XhpcInvoice.java index 474fa6e5..26450ac0 100644 --- a/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/pojo/XhpcInvoice.java +++ b/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/pojo/XhpcInvoice.java @@ -159,6 +159,8 @@ public class XhpcInvoice implements Serializable { */ private Integer delFlag; + private String tenantId; + private static final long serialVersionUID = 1L; -} \ No newline at end of file +} diff --git a/xhpc-modules/xhpc-invoice/src/main/resources/mapper/XhpcInvoiceMapper.xml b/xhpc-modules/xhpc-invoice/src/main/resources/mapper/XhpcInvoiceMapper.xml index d77b9192..2bcd6dfc 100644 --- a/xhpc-modules/xhpc-invoice/src/main/resources/mapper/XhpcInvoiceMapper.xml +++ b/xhpc-modules/xhpc-invoice/src/main/resources/mapper/XhpcInvoiceMapper.xml @@ -261,7 +261,7 @@ creator_id, creator_type, creator, create_time, `status`, invoicing_time, drawer, finance_notes, electric_invoice_url, - updator, update_time, del_flag) + updator, update_time, del_flag, tenant_id) values (#{receiveEmail,jdbcType=VARCHAR}, #{titleType,jdbcType=INTEGER}, #{titleContent,jdbcType=VARCHAR}, #{dutyNumber,jdbcType=VARCHAR}, #{invoiceContent,jdbcType=VARCHAR}, #{invoiceMoney,jdbcType=DECIMAL}, #{invoiceOrderEletricTotalMoney,jdbcType=DECIMAL}, #{invoiceOrderServiceTotalMoney,jdbcType=DECIMAL}, @@ -270,7 +270,8 @@ #{creatorId,jdbcType=BIGINT}, #{creatorType,jdbcType=INTEGER}, #{creator,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, #{status,jdbcType=INTEGER}, #{invoicingTime,jdbcType=TIMESTAMP}, #{drawer,jdbcType=VARCHAR}, #{financeNotes,jdbcType=VARCHAR}, #{electricInvoiceUrl,jdbcType=VARCHAR}, - #{updator,jdbcType=BIGINT}, #{updateTime,jdbcType=DATE}, #{delFlag,jdbcType=INTEGER}) + #{updator,jdbcType=BIGINT}, #{updateTime,jdbcType=DATE}, #{delFlag,jdbcType=INTEGER}, + #{tenantId,jdbcType=VARCHAR}) @@ -354,6 +355,9 @@ del_flag, + + tenant_id + @@ -434,6 +438,9 @@ #{delFlag,jdbcType=INTEGER}, + + #{tenantId,jdbcType=INTEGER}, + del_flag, + + tenant_id, + @@ -598,6 +608,9 @@ #{delFlag,jdbcType=INTEGER}, + + #{tenantId,jdbcType=INTEGER}, + @@ -749,4 +762,4 @@ WHERE invoice_id = #{invoiceId}; - \ No newline at end of file + diff --git a/xhpc-modules/xhpc-log/.gitignore b/xhpc-modules/xhpc-log/.gitignore new file mode 100644 index 00000000..54283dd4 --- /dev/null +++ b/xhpc-modules/xhpc-log/.gitignore @@ -0,0 +1,35 @@ +HELP.md +target/ +.mvn/ +!.mvn/wrapper/maven-wrapper.jar +!**/src/main/**/target/ +!**/src/test/**/target/ + +### STS ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### IntelliJ IDEA ### +.idea/ +.idea +*.iws +*.iml +*.ipr + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +build/ +!**/src/main/**/build/ +!**/src/test/**/build/ + +### VS Code ### +.vscode/ diff --git a/xhpc-modules/xhpc-log/pom.xml b/xhpc-modules/xhpc-log/pom.xml new file mode 100644 index 00000000..01edd8a5 --- /dev/null +++ b/xhpc-modules/xhpc-log/pom.xml @@ -0,0 +1,132 @@ + + + + com.ruoyi + xhpc-modules + 3.0.0 + + 4.0.0 + + xhpc-log + + + 日志服务 + + + 8 + 8 + + + + + org.mybatis.spring.boot + mybatis-spring-boot-starter + + + org.mybatis + mybatis + 3.5.6 + + + com.github.pagehelper + pagehelper-spring-boot-starter + + + + + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-discovery + + + + + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-config + + + + + com.alibaba.cloud + spring-cloud-starter-alibaba-sentinel + + + + org.springframework.boot + spring-boot-starter-actuator + + + + org.springframework.boot + spring-boot-starter-web + + + + + mysql + mysql-connector-java + + + + + com.ruoyi + ruoyi-common-datasource + + + + + com.ruoyi + ruoyi-common-core + + + + com.ruoyi + xhpc-common + 3.0.0 + compile + + + + org.apache.ant + ant + 1.10.12 + + + com.aliyun.oss + aliyun-sdk-oss + 3.10.2 + compile + + + + + + ${project.artifactId} + + + src/main/resources + + + src/main/java + + **/*.xml + + + + + + org.springframework.boot + spring-boot-maven-plugin + 2.4.0 + + + + repackage + + + + + + + + diff --git a/xhpc-modules/xhpc-log/src/main/java/com/xhpc/log/XhpcLogApplication.java b/xhpc-modules/xhpc-log/src/main/java/com/xhpc/log/XhpcLogApplication.java new file mode 100644 index 00000000..cbb90fdd --- /dev/null +++ b/xhpc-modules/xhpc-log/src/main/java/com/xhpc/log/XhpcLogApplication.java @@ -0,0 +1,22 @@ +package com.xhpc.log; + +import com.xhpc.common.security.annotation.EnableCustomConfig; +import com.xhpc.common.security.annotation.EnableRyFeignClients; +import org.mybatis.spring.annotation.MapperScan; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.cloud.client.discovery.EnableDiscoveryClient; + + +@EnableCustomConfig +@SpringBootApplication +@EnableRyFeignClients +@EnableDiscoveryClient +@MapperScan("com.xhpc.log.mapper") +public class XhpcLogApplication { + + public static void main(String[] args) { + + SpringApplication.run(XhpcLogApplication.class, args); + } +} diff --git a/xhpc-modules/xhpc-log/src/main/java/com/xhpc/log/controller/OrderLogController.java b/xhpc-modules/xhpc-log/src/main/java/com/xhpc/log/controller/OrderLogController.java new file mode 100644 index 00000000..d36403e1 --- /dev/null +++ b/xhpc-modules/xhpc-log/src/main/java/com/xhpc/log/controller/OrderLogController.java @@ -0,0 +1,61 @@ +package com.xhpc.log.controller; + +import com.xhpc.common.core.utils.SecurityUtils; +import com.xhpc.common.core.web.controller.BaseController; +import com.xhpc.common.core.web.page.TableDataInfo; +import com.xhpc.common.enums.StationDeviceEnum; +import com.xhpc.log.service.OrderLogService; +import lombok.extern.java.Log; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletResponse; +import java.util.HashMap; +import java.util.Map; + + +/** + * 订单报文日志 + */ +@RestController +@RequestMapping("/log/order/") +public class OrderLogController extends BaseController { + + @Resource + OrderLogService orderLogService; + + @GetMapping("/getPage") + public TableDataInfo getOrderPage(@RequestParam(required = false) String tenantId, + @RequestParam(required = false) Integer number){ + + startPage(); + Map params = new HashMap<>(); + params.put("operatorId", SecurityUtils.getUserId()); + params.put("number", number); + params.put("tenantId", tenantId); + return getDataTable(orderLogService.getOrderPage(params)); + } + + + @GetMapping("/{orderId}") + public TableDataInfo getOrderDetailPage(@PathVariable("orderId") String orderId){ + startPage(); + return getDataTable(orderLogService.getOrderDetailPage(orderId)); + } + + + @GetMapping("/export") + public void export(HttpServletResponse response, + @RequestParam(required = false) String tenantId, + @RequestParam(required = false) Integer number, + @RequestParam(required = false) String serialNumber) throws Exception { + + Map params = new HashMap<>(); + params.put("operatorId", SecurityUtils.getUserId()); + params.put("number", number); + params.put("serialNumber", serialNumber); + params.put("tenantId", tenantId); + orderLogService.export(response, params); + } + +} diff --git a/xhpc-modules/xhpc-log/src/main/java/com/xhpc/log/controller/PileLogController.java b/xhpc-modules/xhpc-log/src/main/java/com/xhpc/log/controller/PileLogController.java new file mode 100644 index 00000000..9d50a7f8 --- /dev/null +++ b/xhpc-modules/xhpc-log/src/main/java/com/xhpc/log/controller/PileLogController.java @@ -0,0 +1,62 @@ +package com.xhpc.log.controller; + + +import com.xhpc.common.core.utils.SecurityUtils; +import com.xhpc.common.core.web.controller.BaseController; +import com.xhpc.common.core.web.page.TableDataInfo; +import com.xhpc.common.enums.StationDeviceEnum; +import com.xhpc.log.service.PileLogService; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletResponse; +import java.util.HashMap; +import java.util.Map; + + +/** + * 桩运行日志 + */ +@RestController +@RequestMapping("/log/pile") +public class PileLogController extends BaseController { + + @Resource + PileLogService pileLogService; + + + @GetMapping("/getPage") + public TableDataInfo getPilePage(@RequestParam(required = false) String tenantId, + @RequestParam(required = false) Integer number) { + startPage(); + + Map params = new HashMap<>(); + params.put("operatorId", SecurityUtils.getUserId()); + params.put("number", number); + params.put("tenantId", tenantId); + return getDataTable(pileLogService.getPilePage(params)); + } + + + @GetMapping("/{pileId}") + public TableDataInfo getPileDetailPage(@PathVariable("pileId") String pileId) { + startPage(); + return getDataTable(pileLogService.getPileRunLogPage(pileId)); + } + + @GetMapping("/export") + public void export(HttpServletResponse response, + @RequestParam(required = false) String tenantId, + @RequestParam(required = false) Integer number, + @RequestParam(required = false) String serialNumber) throws Exception { + + Map params = new HashMap<>(); + params.put("operatorId", SecurityUtils.getUserId()); + params.put("number", number); + params.put("type", StationDeviceEnum.PILE.getCode()); + params.put("serialNumber", serialNumber); + params.put("tenantId", tenantId); + pileLogService.export(response, params); + } + +} diff --git a/xhpc-modules/xhpc-log/src/main/java/com/xhpc/log/controller/StationLogController.java b/xhpc-modules/xhpc-log/src/main/java/com/xhpc/log/controller/StationLogController.java new file mode 100644 index 00000000..52f3afdf --- /dev/null +++ b/xhpc-modules/xhpc-log/src/main/java/com/xhpc/log/controller/StationLogController.java @@ -0,0 +1,46 @@ +package com.xhpc.log.controller; + + +import com.xhpc.common.core.utils.SecurityUtils; +import com.xhpc.common.core.web.controller.BaseController; +import com.xhpc.common.core.web.domain.AjaxResult; +import com.xhpc.common.core.web.page.TableDataInfo; +import com.xhpc.log.service.StationLogService; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import java.util.HashMap; +import java.util.Map; + +@RestController +@RequestMapping("/log/station") +public class StationLogController extends BaseController { + + + @Resource + StationLogService stationLogService; + + @GetMapping("/getPage") + public TableDataInfo getPilePage(@RequestParam(required = false) String tenantId, + @RequestParam(required = false) Integer number) { + startPage(); + Map params = new HashMap<>(); + params.put("operatorId", SecurityUtils.getUserId()); + params.put("number", number); + params.put("tenantId", tenantId); + return getDataTable(stationLogService.getStationPage(params)); + } + + + @GetMapping("/{stationId}") + public TableDataInfo getPileDetailPage(@PathVariable("stationId") Long stationId) { + startPage(); + return getDataTable(stationLogService.getStationRatePage(stationId)); + } + + + @GetMapping("/rate/{rateId}") + public AjaxResult getRateInfo(@PathVariable("rateId") Integer rateId) { + return AjaxResult.success(stationLogService.getRateInfo(rateId)); + } +} diff --git a/xhpc-modules/xhpc-log/src/main/java/com/xhpc/log/controller/SystemLogController.java b/xhpc-modules/xhpc-log/src/main/java/com/xhpc/log/controller/SystemLogController.java new file mode 100644 index 00000000..3ec85d2a --- /dev/null +++ b/xhpc-modules/xhpc-log/src/main/java/com/xhpc/log/controller/SystemLogController.java @@ -0,0 +1,38 @@ +package com.xhpc.log.controller; + + +import com.xhpc.common.core.utils.SecurityUtils; +import com.xhpc.common.core.web.controller.BaseController; +import com.xhpc.common.core.web.page.TableDataInfo; +import com.xhpc.log.service.SystemLogService; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; +import java.util.HashMap; +import java.util.Map; + +/** + * 系统操作日志 + */ +@RestController +@RequestMapping("/log/system") +public class SystemLogController extends BaseController { + + + @Resource + SystemLogService systemLogService; + + + @GetMapping("/oper/getPage") + public TableDataInfo getPage(@RequestParam(required = false) String tenantId, + @RequestParam(required = false) Integer number){ + startPage(); + Map params = new HashMap<>(); + params.put("operName", SecurityUtils.getUsername()); + params.put("tenantId", tenantId); + return getDataTable(systemLogService.getPage(params)); + } +} diff --git a/xhpc-modules/xhpc-log/src/main/java/com/xhpc/log/domain/XhpcChargeOrderDomain.java b/xhpc-modules/xhpc-log/src/main/java/com/xhpc/log/domain/XhpcChargeOrderDomain.java new file mode 100644 index 00000000..2279e246 --- /dev/null +++ b/xhpc-modules/xhpc-log/src/main/java/com/xhpc/log/domain/XhpcChargeOrderDomain.java @@ -0,0 +1,170 @@ +package com.xhpc.log.domain; + +import lombok.Data; + +import javax.persistence.Table; +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.Date; + + +@Data +@Table(name="xhpc_charge_order") +public class XhpcChargeOrderDomain implements Serializable { + /** + * 充电订单id + */ + private Long chargeOrderId; + + /** + * 电站id + */ + private Long chargingStationId; + + /** + * 用户id + */ + private Long userId; + + /** + * 终端id + */ + private Long terminalId; + + /** + * 互联网流水订单号 + */ + private String internetSerialNumber; + + /** + * 订单编号 + */ + private String serialNumber; + + /** + * 充电启始soc + */ + private String startSoc; + + /** + * 结束soc + */ + private String endSoc; + + /** + * 订单来源(0C端用户 1流量用户) + */ + private Integer source; + + /** + * 状态(-1准备充电 0开始充电 1自动结算,2异常,3平台结算) + */ + private Integer status; + + /** + * 删除标志(0代表存在 1代表删除) + */ + private Integer delFlag; + + /** + * 创建时间 + */ + private Date createTime; + + /** + * 创建者 + */ + private String createBy; + + /** + * 更新时间 + */ + private Date updateTime; + + /** + * 更新者 + */ + private String updateBy; + + /** + * 备注 + */ + private String remark; + + /** + * 费率模型id + */ + private Long rateModelId; + + /** + * 充电方式 + */ + private String chargingMode; + + /** + * 开始充电时间 + */ + private Date startTime; + + /** + * 结束充电时间 + */ + private Date endTime; + + /** + * 充电时长 + */ + private String chargingTime; + + /** + * 充电度数 + */ + private BigDecimal chargingDegree; + + /** + * 协议定,停止方式 + */ + private Integer type; + + /** + * 异常备注 + */ + private String erroRemark; + + /** + * 总金额 + */ + private BigDecimal amountCharged; + + /** + * 功率 + */ + private String power; + + /** + * 充电时长(秒) + */ + private Long chargingTimeNumber; + + /** + * 司机唯一标识(手机号) + */ + private String driverId; + + /** + * 充电金额 + */ + private Integer chargingAmt; + + /** + * 车牌 + */ + private String plateNum; + + /** + * 符合Evcs标准的订单号,并非来自第三方的订单号 + */ + private String evcsOrderNo; + + private static final long serialVersionUID = 1L; +} \ No newline at end of file diff --git a/xhpc-modules/xhpc-log/src/main/java/com/xhpc/log/domain/XhpcDeviceMessageDomain.java b/xhpc-modules/xhpc-log/src/main/java/com/xhpc/log/domain/XhpcDeviceMessageDomain.java new file mode 100644 index 00000000..674a9108 --- /dev/null +++ b/xhpc-modules/xhpc-log/src/main/java/com/xhpc/log/domain/XhpcDeviceMessageDomain.java @@ -0,0 +1,32 @@ +package com.xhpc.log.domain; + + +import lombok.Data; + +import java.util.Date; + +@Data +public class XhpcDeviceMessageDomain { + + private Long deviceMessageId; + + private String type; + + private String serialNumber; + + private String content; + + private String replyContent; + + private Integer status; + + private Date createTime; + + private String createBy; + + private Date updateTime; + + private String updateBy; + + private String remark; +} diff --git a/xhpc-modules/xhpc-log/src/main/java/com/xhpc/log/domain/XhpcHistoryOrderDomain.java b/xhpc-modules/xhpc-log/src/main/java/com/xhpc/log/domain/XhpcHistoryOrderDomain.java new file mode 100644 index 00000000..9840e54d --- /dev/null +++ b/xhpc-modules/xhpc-log/src/main/java/com/xhpc/log/domain/XhpcHistoryOrderDomain.java @@ -0,0 +1,250 @@ +package com.xhpc.log.domain; + +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.Date; + +/** + * xhpc_history_order + * @author + */ +@Data +public class XhpcHistoryOrderDomain implements Serializable { + /** + * 历史订单id + */ + private Long historyOrderId; + + /** + * 电站id + */ + private Long chargingStationId; + + /** + * 场站名称 + */ + private String chargingStationName; + + /** + * 充电订单id + */ + private Long chargeOrderId; + + /** + * 用户id + */ + private Long userId; + + /** + * 终端id + */ + private Long terminalId; + + /** + * 订单编号 + */ + private String serialNumber; + + /** + * 流量方订单号 + */ + private String internetSerialNumber; + + /** + * 总电费 + */ + private BigDecimal powerPriceTotal; + + /** + * 总服务费 + */ + private BigDecimal servicePriceTotal; + + /** + * 订单总价 + */ + private BigDecimal totalPrice; + + /** + * 电站活动抵扣--抵扣的总金额 + */ + private BigDecimal promotionDiscount; + + /** + * 实际价格-用户支付的钱 + */ + private BigDecimal actPrice; + + /** + * 实收电费-运营商电费 + */ + private BigDecimal actPowerPrice; + + /** + * 实收服务费-运营商服务费 + */ + private BigDecimal actServicePrice; + + /** + * 流量方总金额抽成 + */ + private BigDecimal internetCommission; + + /** + * 流量方服务费抽成 + */ + private BigDecimal internetSvcCommission; + + /** + * 平台总金额抽成 + */ + private BigDecimal platformCommission; + + /** + * 平台服务费抽成 + */ + private BigDecimal platformSvcCommisssion; + + /** + * 运维总抽成 + */ + private BigDecimal operationCommission; + + /** + * 运维服务费抽成 + */ + private BigDecimal operationSvcCommission; + + /** + * 开始充电soc + */ + private String startSoc; + + /** + * 结束时soc + */ + private String endSoc; + + /** + * 对账状态(0待确认 1已确认,2待提交,3待审核) + */ + private Integer reconciliationStatus; + + /** + * 清分状态(0待清分 1清分在途,2已提现,3待提交,4待审核) + */ + private Integer sortingStatus; + + /** + * 1 自动结算 2 平台结算 + */ + private Byte type; + + /** + * 状态(0正常 1停用) + */ + private Integer status; + + /** + * 删除标志(0代表存在 2代表删除) + */ + private Integer delFlag; + + /** + * 创建时间 + */ + private Date createTime; + + /** + * 创建者 + */ + private String createBy; + + /** + * 更新时间 + */ + private Date updateTime; + + /** + * 更新者 + */ + private String updateBy; + + /** + * 备注 + */ + private String remark; + + /** + * 0未统计 1小时统计 2 其他统计 + */ + private Integer state; + + /** + * VIN 码 + */ + private String vinNormal; + + private String searchValue; + + /** + * 运营商在EVCS分配的唯一OperatorID + */ + private String operatorIdEvcs; + + private Integer chargeModelEvcs; + + private Double connectorPowerEvcs; + + private Double meterValueEndEvcs; + + private Double meterValueStartEvcs; + + private String operatorId3rdptyEvcs; + + private Date startTime; + + /** + * 结束时间 + */ + private Date endTime; + + private Integer stopReasonEvcs; + + private Double totalPower; + + private String userNameEvcs; + + private String phone; + + /** + * 互联网订单流水号 + */ + private String evcsOrderNo; + + /** + * -1:未推送/推送失败 0:成功 1:争议交易 2~99:自定义 + */ + private Integer confirmResult; + + private Long rateModelId; + + /** + * 充电方式 + */ + private String chargingMode; + + /** + * 充电度数 + */ + private Double chargingDegree; + + /** + * 充电时长 + */ + private String chargingTime; + + private static final long serialVersionUID = 1L; +} \ No newline at end of file diff --git a/xhpc-modules/xhpc-log/src/main/java/com/xhpc/log/domain/XhpcMessageDomain.java b/xhpc-modules/xhpc-log/src/main/java/com/xhpc/log/domain/XhpcMessageDomain.java new file mode 100644 index 00000000..1f097d60 --- /dev/null +++ b/xhpc-modules/xhpc-log/src/main/java/com/xhpc/log/domain/XhpcMessageDomain.java @@ -0,0 +1,54 @@ +package com.xhpc.log.domain; + +import com.xhpc.common.core.web.domain.BaseEntity; + +/** + * program: ruoyi + * User: HongYun + * Date:2021-09-13 15 + */ +public class XhpcMessageDomain extends BaseEntity { + + private Long messageId; + private String chargeOrderNo; + private String content; + private Integer status; + + public Long getMessageId() { + + return messageId; + } + + public void setMessageId(Long messageId) { + + this.messageId = messageId; + } + + public String getChargeOrderNo() { + + return chargeOrderNo; + } + + public void setChargeOrderNo(String chargeOrderNo) { + + this.chargeOrderNo = chargeOrderNo; + } + + public String getContent() { + + return content; + } + + public void setContent(String content) { + + this.content = content; + } + + public Integer getStatus() { + return status; + } + + public void setStatus(Integer status) { + this.status = status; + } +} diff --git a/xhpc-modules/xhpc-log/src/main/java/com/xhpc/log/mapper/SysOperLogMapper.java b/xhpc-modules/xhpc-log/src/main/java/com/xhpc/log/mapper/SysOperLogMapper.java new file mode 100644 index 00000000..84571810 --- /dev/null +++ b/xhpc-modules/xhpc-log/src/main/java/com/xhpc/log/mapper/SysOperLogMapper.java @@ -0,0 +1,17 @@ +package com.xhpc.log.mapper; + +import org.apache.ibatis.annotations.Param; + +import java.util.List; +import java.util.Map; + +/** + * 操作日志 数据层 + * + * @author ruoyi + */ +public interface SysOperLogMapper { + + List> selectUserOperLog(@Param("params") Map params); + +} diff --git a/xhpc-modules/xhpc-log/src/main/java/com/xhpc/log/mapper/XhpcChargingPileMapper.java b/xhpc-modules/xhpc-log/src/main/java/com/xhpc/log/mapper/XhpcChargingPileMapper.java new file mode 100644 index 00000000..3712feba --- /dev/null +++ b/xhpc-modules/xhpc-log/src/main/java/com/xhpc/log/mapper/XhpcChargingPileMapper.java @@ -0,0 +1,57 @@ +package com.xhpc.log.mapper; + +import com.xhpc.common.domain.XhpcChargingPile; +import org.apache.ibatis.annotations.Param; + +import java.util.List; +import java.util.Map; + +/** + * @author yuyang + * @date 2021/7/27 14:37 + */ +public interface XhpcChargingPileMapper { + + + /** + * 桩列表 + * + */ + List> selectXhpcChargingPileList(@Param("params")Map params); + + /** + * 终端 + * + * @param xhpcChargingPile 终端 + * @return 结果 + */ + int addXhpcChargingPile(XhpcChargingPile xhpcChargingPile); + + + /** + * 查询电站 + * + * @param chargingStationId 电站ID + * @return 电站 + */ + Map selectXhpcChargingStationById(Long chargingStationId); + + /** + * 查询桩 + * + * @param chargingPileId 终端ID + * @return 电站 + */ + XhpcChargingPile selectXhpcChargingPileById(Long chargingPileId); + + /** + * 终端列表 + * + * @param chargingPileId 桩id + * @return + */ + List> selectXhpcTerminalList(@Param("chargingPileId") Long chargingPileId); + + + XhpcChargingPile getXhpcChargingPileBySerialNumber(@Param("serialNumber") String serialNumber); +} diff --git a/xhpc-modules/xhpc-log/src/main/java/com/xhpc/log/mapper/XhpcChargingStationMapper.java b/xhpc-modules/xhpc-log/src/main/java/com/xhpc/log/mapper/XhpcChargingStationMapper.java new file mode 100644 index 00000000..119f695f --- /dev/null +++ b/xhpc-modules/xhpc-log/src/main/java/com/xhpc/log/mapper/XhpcChargingStationMapper.java @@ -0,0 +1,28 @@ +package com.xhpc.log.mapper; + +import org.apache.ibatis.annotations.Param; + +import java.util.List; +import java.util.Map; + +/** + * 电站Mapper接口 + * + * @author yuyang + * @date 2021-07-19 + */ +public interface XhpcChargingStationMapper { + + /** + * 查询电站列表 + * + * @return 电站集合 + */ + List> selectXhpcChargingStationList(@Param("params")Map params); + + + List> selectRateListByStationId(@Param("stationId")Long stationId); + + + List> selectRateTimeListByRateId(@Param("rateId")Integer rateId); +} diff --git a/xhpc-modules/xhpc-log/src/main/java/com/xhpc/log/mapper/XhpcDeviceMessageMapper.java b/xhpc-modules/xhpc-log/src/main/java/com/xhpc/log/mapper/XhpcDeviceMessageMapper.java new file mode 100644 index 00000000..7f6dda18 --- /dev/null +++ b/xhpc-modules/xhpc-log/src/main/java/com/xhpc/log/mapper/XhpcDeviceMessageMapper.java @@ -0,0 +1,18 @@ +package com.xhpc.log.mapper; + + +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; +import java.util.Map; + +@Mapper +public interface XhpcDeviceMessageMapper { + + List> selectListByTypeAndSerialNumber(@Param("type") String type, + @Param("serialNumber")String serialNumber); + + + List> selectListByParams(@Param("params")Map params); +} diff --git a/xhpc-modules/xhpc-log/src/main/java/com/xhpc/log/mapper/XhpcHistoryOrderMapper.java b/xhpc-modules/xhpc-log/src/main/java/com/xhpc/log/mapper/XhpcHistoryOrderMapper.java new file mode 100644 index 00000000..fbe1baa4 --- /dev/null +++ b/xhpc-modules/xhpc-log/src/main/java/com/xhpc/log/mapper/XhpcHistoryOrderMapper.java @@ -0,0 +1,15 @@ +package com.xhpc.log.mapper; + +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; +import java.util.Map; + +@Mapper +public interface XhpcHistoryOrderMapper { + + + List> getOrderPage(@Param("params")Map params); + +} \ No newline at end of file diff --git a/xhpc-modules/xhpc-log/src/main/java/com/xhpc/log/mapper/XhpcMessageMapper.java b/xhpc-modules/xhpc-log/src/main/java/com/xhpc/log/mapper/XhpcMessageMapper.java new file mode 100644 index 00000000..420215ad --- /dev/null +++ b/xhpc-modules/xhpc-log/src/main/java/com/xhpc/log/mapper/XhpcMessageMapper.java @@ -0,0 +1,19 @@ +package com.xhpc.log.mapper; + + +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; +import java.util.Map; + + +@Mapper +public interface XhpcMessageMapper { + + + List> getOrderMessagePage(@Param("serialNumber")String serialNumber); + + + List> getOrderMessageByParams(@Param("params")Map params); +} diff --git a/xhpc-modules/xhpc-log/src/main/java/com/xhpc/log/service/OrderLogService.java b/xhpc-modules/xhpc-log/src/main/java/com/xhpc/log/service/OrderLogService.java new file mode 100644 index 00000000..604b7475 --- /dev/null +++ b/xhpc-modules/xhpc-log/src/main/java/com/xhpc/log/service/OrderLogService.java @@ -0,0 +1,17 @@ +package com.xhpc.log.service; + +import javax.servlet.http.HttpServletResponse; +import java.util.List; +import java.util.Map; + +public interface OrderLogService { + + + List> getOrderPage(Map params); + + + List> getOrderDetailPage(String orderId); + + + void export(HttpServletResponse response, Map params) throws Exception; +} diff --git a/xhpc-modules/xhpc-log/src/main/java/com/xhpc/log/service/PileLogService.java b/xhpc-modules/xhpc-log/src/main/java/com/xhpc/log/service/PileLogService.java new file mode 100644 index 00000000..b57710b9 --- /dev/null +++ b/xhpc-modules/xhpc-log/src/main/java/com/xhpc/log/service/PileLogService.java @@ -0,0 +1,16 @@ +package com.xhpc.log.service; + +import javax.servlet.http.HttpServletResponse; +import java.util.List; +import java.util.Map; + +public interface PileLogService { + + + List> getPilePage(Map params); + + + List> getPileRunLogPage(String pileId); + + void export(HttpServletResponse response, Map params) throws Exception; +} diff --git a/xhpc-modules/xhpc-log/src/main/java/com/xhpc/log/service/StationLogService.java b/xhpc-modules/xhpc-log/src/main/java/com/xhpc/log/service/StationLogService.java new file mode 100644 index 00000000..955ee274 --- /dev/null +++ b/xhpc-modules/xhpc-log/src/main/java/com/xhpc/log/service/StationLogService.java @@ -0,0 +1,16 @@ +package com.xhpc.log.service; + +import java.util.List; +import java.util.Map; + +public interface StationLogService { + + + List> getStationPage(Map params); + + + List> getStationRatePage(Long stationId); + + + List> getRateInfo(int rateId); +} diff --git a/xhpc-modules/xhpc-log/src/main/java/com/xhpc/log/service/SystemLogService.java b/xhpc-modules/xhpc-log/src/main/java/com/xhpc/log/service/SystemLogService.java new file mode 100644 index 00000000..4ae604db --- /dev/null +++ b/xhpc-modules/xhpc-log/src/main/java/com/xhpc/log/service/SystemLogService.java @@ -0,0 +1,11 @@ +package com.xhpc.log.service; + + +import java.util.List; +import java.util.Map; + +public interface SystemLogService { + + List> getPage(Map params); + +} diff --git a/xhpc-modules/xhpc-log/src/main/java/com/xhpc/log/service/impl/OrderLogServiceImpl.java b/xhpc-modules/xhpc-log/src/main/java/com/xhpc/log/service/impl/OrderLogServiceImpl.java new file mode 100644 index 00000000..015256f4 --- /dev/null +++ b/xhpc-modules/xhpc-log/src/main/java/com/xhpc/log/service/impl/OrderLogServiceImpl.java @@ -0,0 +1,69 @@ +package com.xhpc.log.service.impl; + + +import cn.hutool.core.io.IoUtil; +import cn.hutool.poi.excel.ExcelUtil; +import cn.hutool.poi.excel.ExcelWriter; +import com.xhpc.log.mapper.XhpcHistoryOrderMapper; +import com.xhpc.log.mapper.XhpcMessageMapper; +import com.xhpc.log.service.OrderLogService; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import javax.servlet.ServletOutputStream; +import javax.servlet.http.HttpServletResponse; +import java.util.List; +import java.util.Map; + +@Service +public class OrderLogServiceImpl implements OrderLogService { + + @Resource + XhpcHistoryOrderMapper historyOrderMapper; + + @Resource + XhpcMessageMapper messageMapper; + + + @Override + public List> getOrderPage(Map params){ + return historyOrderMapper.getOrderPage(params); + } + + + @Override + public List> getOrderDetailPage(String orderId){ + return messageMapper.getOrderMessagePage(orderId); + } + + + @Override + public void export(HttpServletResponse response, Map params) throws Exception{ + List> list = messageMapper.getOrderMessageByParams(params); + + ExcelWriter writer = ExcelUtil.getWriter(true); + writer.addHeaderAlias("serialNumber", "订单号"); + writer.addHeaderAlias("sourceName", "订单来源"); + writer.addHeaderAlias("chargingDegree", "充电电量"); + writer.addHeaderAlias("amountCharged", "总金额"); + writer.addHeaderAlias("chargingTime", "充电时长"); + writer.addHeaderAlias("startSOc", "充电启始soc"); + writer.addHeaderAlias("endSoc", "结束soc"); + writer.addHeaderAlias("startTime", "充电开始时间"); + writer.addHeaderAlias("endTime", "充电结束时间"); + writer.addHeaderAlias("power", "电桩功率(KW)"); + writer.addHeaderAlias("content", "充电报文"); + writer.addHeaderAlias("remark", "备注描述"); + writer.addHeaderAlias("createTime", "发送时间"); + + writer.setOnlyAlias(true); + writer.write(list, true); + response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); + response.setCharacterEncoding("utf-8"); + ServletOutputStream out = response.getOutputStream(); + + writer.flush(out, true); + writer.close(); + IoUtil.close(out); + } +} diff --git a/xhpc-modules/xhpc-log/src/main/java/com/xhpc/log/service/impl/PileLogServiceImpl.java b/xhpc-modules/xhpc-log/src/main/java/com/xhpc/log/service/impl/PileLogServiceImpl.java new file mode 100644 index 00000000..0b817f6f --- /dev/null +++ b/xhpc-modules/xhpc-log/src/main/java/com/xhpc/log/service/impl/PileLogServiceImpl.java @@ -0,0 +1,66 @@ +package com.xhpc.log.service.impl; + +import cn.hutool.core.io.IoUtil; +import cn.hutool.poi.excel.ExcelUtil; +import cn.hutool.poi.excel.ExcelWriter; +import com.xhpc.common.enums.StationDeviceEnum; +import com.xhpc.log.mapper.XhpcChargingPileMapper; +import com.xhpc.log.mapper.XhpcDeviceMessageMapper; +import com.xhpc.log.service.PileLogService; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import javax.servlet.ServletOutputStream; +import javax.servlet.http.HttpServletResponse; +import java.util.List; +import java.util.Map; + + +@Service +public class PileLogServiceImpl implements PileLogService { + + @Resource + XhpcChargingPileMapper pileMapper; + + @Resource + XhpcDeviceMessageMapper deviceMessageMapper; + + @Override + public List> getPilePage(Map params){ + + return pileMapper.selectXhpcChargingPileList(params); + } + + + @Override + public List> getPileRunLogPage(String pileId){ + return deviceMessageMapper.selectListByTypeAndSerialNumber(StationDeviceEnum.PILE.getCode(), pileId); + } + + @Override + public void export(HttpServletResponse response, Map params) throws Exception{ + List> list = deviceMessageMapper.selectListByParams(params); + + ExcelWriter writer = ExcelUtil.getWriter(true); + writer.addHeaderAlias("chargingStationName", "场站名称"); + writer.addHeaderAlias("chargingPileName", "充电桩名称"); + writer.addHeaderAlias("serialNumber", "桩编码"); + writer.addHeaderAlias("brandModel", "费率"); + writer.addHeaderAlias("pileType", "电桩类型"); + writer.addHeaderAlias("power", "电桩功率(KW)"); + writer.addHeaderAlias("content", "充电桩上传平台报文"); + writer.addHeaderAlias("replyContent", "平台回复报文"); + writer.addHeaderAlias("remark", "备注描述"); + writer.addHeaderAlias("createTime", "发送时间"); + + writer.setOnlyAlias(true); + writer.write(list, true); + response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); + response.setCharacterEncoding("utf-8"); + ServletOutputStream out = response.getOutputStream(); + + writer.flush(out, true); + writer.close(); + IoUtil.close(out); + } +} diff --git a/xhpc-modules/xhpc-log/src/main/java/com/xhpc/log/service/impl/StationLogServiceImpl.java b/xhpc-modules/xhpc-log/src/main/java/com/xhpc/log/service/impl/StationLogServiceImpl.java new file mode 100644 index 00000000..c7f1f066 --- /dev/null +++ b/xhpc-modules/xhpc-log/src/main/java/com/xhpc/log/service/impl/StationLogServiceImpl.java @@ -0,0 +1,34 @@ +package com.xhpc.log.service.impl; + +import com.xhpc.log.mapper.XhpcChargingStationMapper; +import com.xhpc.log.service.StationLogService; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.List; +import java.util.Map; + + +@Service +public class StationLogServiceImpl implements StationLogService { + + @Resource + XhpcChargingStationMapper stationMapper; + + @Override + public List> getStationPage(Map params){ + return stationMapper.selectXhpcChargingStationList(params); + } + + + @Override + public List> getStationRatePage(Long stationId){ + return stationMapper.selectRateListByStationId(stationId); + } + + + @Override + public List> getRateInfo(int rateId){ + return stationMapper.selectRateTimeListByRateId(rateId); + } +} diff --git a/xhpc-modules/xhpc-log/src/main/java/com/xhpc/log/service/impl/SystemLogServiceImpl.java b/xhpc-modules/xhpc-log/src/main/java/com/xhpc/log/service/impl/SystemLogServiceImpl.java new file mode 100644 index 00000000..67dfb434 --- /dev/null +++ b/xhpc-modules/xhpc-log/src/main/java/com/xhpc/log/service/impl/SystemLogServiceImpl.java @@ -0,0 +1,22 @@ +package com.xhpc.log.service.impl; + +import com.xhpc.log.mapper.SysOperLogMapper; +import com.xhpc.log.service.SystemLogService; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.List; +import java.util.Map; + + +@Service +public class SystemLogServiceImpl implements SystemLogService { + + @Resource + SysOperLogMapper operLogMapper; + + @Override + public List> getPage(Map params){ + return operLogMapper.selectUserOperLog(params); + } +} diff --git a/xhpc-modules/xhpc-log/src/main/resources/banner.txt b/xhpc-modules/xhpc-log/src/main/resources/banner.txt new file mode 100644 index 00000000..be49df70 --- /dev/null +++ b/xhpc-modules/xhpc-log/src/main/resources/banner.txt @@ -0,0 +1,9 @@ +Spring Boot Version: ${spring-boot.version} +Spring Application Name: ${spring.application.name} + + ,--. +,--. ,--. | ,---. ,---. ,---. + \ `' / | .-. | | .-. | | .--' + / /. \ | | | | | '-' ' \ `--. +'--' '--' `--' `--' | |-' `---' + `--' diff --git a/xhpc-modules/xhpc-log/src/main/resources/bootstrap.yml b/xhpc-modules/xhpc-log/src/main/resources/bootstrap.yml new file mode 100644 index 00000000..ac095b69 --- /dev/null +++ b/xhpc-modules/xhpc-log/src/main/resources/bootstrap.yml @@ -0,0 +1,90 @@ + +# Tomcat +server: + port: 8890 + +# Spring +spring: + application: + # 应用名称 + name: xhpc-log + profiles: + # 环境配置 + active: dev + cloud: + nacos: + discovery: + # 服务注册地址 + server-addr: 127.0.0.1:8848 + config: + # 配置中心地址 + server-addr: 127.0.0.1:8848 + # 配置文件格式 + file-extension: yml + # 共享配置 + shared-configs: + - application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension} +logging: + level: + root: info + com.xhpc.tradebill.mapper: debug + + file: + path: "d:\\logs" + + pattern: + console: '%d{yyyy/MM/dd-HH:mm:ss} [%thread] %-5level %logger- %msg%n' + file: '%d{yyyy/MM/dd-HH:mm:ss} [%thread] %-5level %logger- %msg%n' + +wx: + pay: + appId: "wxd0a48e00319ef8a7" + mchId: "1514355771" + mchKey: "sichuanxianghuakejiyouxiangongsi" + keyPath: + + +alibaba: + pay: + gatewayDomain: "https://openapi.alipay.com/gateway.do" + serverDomain: "https://www.scxhua.cn/prod-api/xhpc-payment/alipay/notifyUrl" + publicKey: + privateKey: "MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCGHX1s315EKjoIBkNiF3IxCAmvtVg+TdCDL/XmJZWdcZ23tEWmmIMsLRCLUKsaPfTEhnqD6EFJnmpJu4teDImo3aDbOoO31YFEXjMXUnTTS/dtDVEo1OecsRL+Re43KSohOkIL1TMyTuNfeIglQTuhCSZ3LOEOx4OHpYwcrLp8p1ORvAS7x35nsmjLp3oQTJo9RWfzfEaKbm6cxsWLKyr5/5eGDXrUHNC5hIDLjoJbe6iqNKyIiPJHtPZfJ36PcWa7PFvx4X+Ded32KZb2AA3p9w/HX7gn1MnRfT5NGH0k3ggxLNarDU8g6JjQYgNtmE/R8gbp99BudZNfDoSF1llNAgMBAAECggEAaTa9bSoXM/bErALt3ghyx1B8+OGVpts5F5IKoVEe/PNjPfkpIzdGwONhtUnF0cKFQaAWgWE1xuGGlO2Sumevn1Cvnw1axF+1F8Om5UcE67cPFvh5kUTlpyGrutt1tMSQjpy7r7jEf1UwP3e5pzBz7TPWf2wv635OC56uOtivPJZ+8vg7VYon/mNXQuL4AavoxfSDtvo0ad30X2fK1WKeeBtgiT4UzV6ZGZh5igKQHM4lVvmbo/jOeQD0KAod7pRe/h4FBFmCVIWwgW+I+Hnzp8A/nJezoowJ3jiTt0FodC9uBCT64ZCz5dVCryD62LDVjKBxB7cfIoQA+PxCiXr9QQKBgQD+2v38J/MlfK/XCYldclzumizwIw6T0Mv6XvYwXQHYgYDKYNF6k1LhMEUo7fP3EsPdV8h/nXmdU4qadOVm6QSJ/rGEl22yGlO7woUzTY/Ls9eknoqfMYuyI1+ICMnNxmesQbWyc0cOHh44cEF+icfJxEDAmrHGLmBVsKuLUJUuVQKBgQCGt663TF7mixghiUOcT11zC1fqG+dIcvAwHpCHfdxsniYRqnv+SLf6eC5PCkQ5aNAAl/ywOLQAWS0XgYti3LyZ4iuGIYcUE0IDDmhWl68V27iXcLIK+rBRqBGxSdk8xR+zSE8fpO4mXpxn8SH0Butex8PJ+oHTbmdXIUAXdn6HGQKBgQCvAB1rqtsRoL72ADxtCHy78u5srwXxhmyqrc6LgzIjQzn2vejaLJO6wfSbmFnwDNimAwNQbgf2ekkwqphjxBozz8qB66GNrPpWccoZYmcdT48CIUO68MCmQBf3R2GbhWPnKu/ja7kc/p1tz9eJVn70E2kLWK4+EdZgwQHqlhj6SQKBgF4AmbdpYOb5s9Li1vyhHJIEHkpLQi15lkPdb/g7SK26BNJa5b5fu5DYf2fDwCtXCZ0AcN/+EQwVLbOzPzGy2R9/g+NKTdkiPvOnAAM8QH2+HaX+ix3CI3o3DnFpGF6hJieRkzR/f3Ximryks451rZMrTWEIncKMzSstFm3Izy0xAoGBAJQaMqlzpM+QaJiytJNeqRpPWRsi0Dkf4XqJXPWLOrApSISsafZF5vk2ZOeIqRsVCBH3LdfVIJxEBAF4l/Sd2q7xC9JHawJDqa4ea7VwL68ANH2w3jcJ3j6DQqf7NIe/lSGxYF6Jt+74oRFHxN3GDSf+z91DYfZz8hQnyphKDNEJ" + appId: "2021002156615717" + certPath: "/www/wwwroot/scxhua.cn/xhpc-payment/appCertPublicKey.crt" + publicCertPath: "/www/wwwroot/scxhua.cn/xhpc-payment/alipayCertPublicKey_RSA2.crt" + rootCertPath: "/www/wwwroot/scxhua.cn/xhpc-payment/alipayRootCert.crt" + +###获取微信openid地址 +#WXGETJSCODE: "https://api.weixin.qq.com/sns/jscode2session?appid=wxb14ef93e9b7901f3&secret=b5c5672141b5930c30a1abee95a2dcbf&js_code=" +###阿里云身份证验证地址 +#VERIFYCARD: "http://idenauthen.market.alicloudapi.com/idenAuthentication" +##阿里云身份证验证地址appcode +#APPCODE: "APPCODE e26d9088b58e24af69411d5933cece47" +##小程序appid +#APPID: "wxd0a48e00319ef8a7" +##小程序绑定商户id +#MCHID: "1514355771" +##商户后台设置的key +#KEY: "sichuanxianghuakejiyouxiangongsi" +##微信小程序支付地址 +#WXPAYUNIFIEDORDER: "https://api.mch.weixin.qq.com/pay/unifiedorder" +##微信支付回调地址 +#SERVERDOMAIN: "http://www.scxhua.cn/prod-api/xhpc-payment/wx/paymentCallback" +##微信小程序支付地址 +#WXTRANSFERS: "https://api.mch.weixin.qq.com/mmpaymkttransfers/promotion/transfers" + +##支付宝支付回调地址 +#ALIPAYPSERVERDOMAIN: "https://www.scxhua.cn/prod-api/xhpc-payment/alipay/notifyUrl" +##支付宝公钥 +#ALIPAYPUBLICKEY: +##应用私钥 +#ALIPAYPRIVATEKEY: "MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCGHX1s315EKjoIBkNiF3IxCAmvtVg+TdCDL/XmJZWdcZ23tEWmmIMsLRCLUKsaPfTEhnqD6EFJnmpJu4teDImo3aDbOoO31YFEXjMXUnTTS/dtDVEo1OecsRL+Re43KSohOkIL1TMyTuNfeIglQTuhCSZ3LOEOx4OHpYwcrLp8p1ORvAS7x35nsmjLp3oQTJo9RWfzfEaKbm6cxsWLKyr5/5eGDXrUHNC5hIDLjoJbe6iqNKyIiPJHtPZfJ36PcWa7PFvx4X+Ded32KZb2AA3p9w/HX7gn1MnRfT5NGH0k3ggxLNarDU8g6JjQYgNtmE/R8gbp99BudZNfDoSF1llNAgMBAAECggEAaTa9bSoXM/bErALt3ghyx1B8+OGVpts5F5IKoVEe/PNjPfkpIzdGwONhtUnF0cKFQaAWgWE1xuGGlO2Sumevn1Cvnw1axF+1F8Om5UcE67cPFvh5kUTlpyGrutt1tMSQjpy7r7jEf1UwP3e5pzBz7TPWf2wv635OC56uOtivPJZ+8vg7VYon/mNXQuL4AavoxfSDtvo0ad30X2fK1WKeeBtgiT4UzV6ZGZh5igKQHM4lVvmbo/jOeQD0KAod7pRe/h4FBFmCVIWwgW+I+Hnzp8A/nJezoowJ3jiTt0FodC9uBCT64ZCz5dVCryD62LDVjKBxB7cfIoQA+PxCiXr9QQKBgQD+2v38J/MlfK/XCYldclzumizwIw6T0Mv6XvYwXQHYgYDKYNF6k1LhMEUo7fP3EsPdV8h/nXmdU4qadOVm6QSJ/rGEl22yGlO7woUzTY/Ls9eknoqfMYuyI1+ICMnNxmesQbWyc0cOHh44cEF+icfJxEDAmrHGLmBVsKuLUJUuVQKBgQCGt663TF7mixghiUOcT11zC1fqG+dIcvAwHpCHfdxsniYRqnv+SLf6eC5PCkQ5aNAAl/ywOLQAWS0XgYti3LyZ4iuGIYcUE0IDDmhWl68V27iXcLIK+rBRqBGxSdk8xR+zSE8fpO4mXpxn8SH0Butex8PJ+oHTbmdXIUAXdn6HGQKBgQCvAB1rqtsRoL72ADxtCHy78u5srwXxhmyqrc6LgzIjQzn2vejaLJO6wfSbmFnwDNimAwNQbgf2ekkwqphjxBozz8qB66GNrPpWccoZYmcdT48CIUO68MCmQBf3R2GbhWPnKu/ja7kc/p1tz9eJVn70E2kLWK4+EdZgwQHqlhj6SQKBgF4AmbdpYOb5s9Li1vyhHJIEHkpLQi15lkPdb/g7SK26BNJa5b5fu5DYf2fDwCtXCZ0AcN/+EQwVLbOzPzGy2R9/g+NKTdkiPvOnAAM8QH2+HaX+ix3CI3o3DnFpGF6hJieRkzR/f3Ximryks451rZMrTWEIncKMzSstFm3Izy0xAoGBAJQaMqlzpM+QaJiytJNeqRpPWRsi0Dkf4XqJXPWLOrApSISsafZF5vk2ZOeIqRsVCBH3LdfVIJxEBAF4l/Sd2q7xC9JHawJDqa4ea7VwL68ANH2w3jcJ3j6DQqf7NIe/lSGxYF6Jt+74oRFHxN3GDSf+z91DYfZz8hQnyphKDNEJ" +##支付宝appid +#ALIPAYAPPID: "2021002156615717" +##应用公钥证书路径 +#CERTPATH: "/www/wwwroot/scxhua.cn/xhpc-payment/appCertPublicKey.crt" +##支付宝公钥证书路径 +#PUBLICCERTPATH: "/www/wwwroot/scxhua.cn/xhpc-payment/alipayCertPublicKey_RSA2.crt" +##支付宝根证书路径 +#ROOTCRETPATH: "/www/wwwroot/scxhua.cn/xhpc-payment/alipayRootCert.crt" \ No newline at end of file diff --git a/xhpc-modules/xhpc-log/src/main/resources/logback.xml b/xhpc-modules/xhpc-log/src/main/resources/logback.xml new file mode 100644 index 00000000..05979096 --- /dev/null +++ b/xhpc-modules/xhpc-log/src/main/resources/logback.xml @@ -0,0 +1,75 @@ + + + + + + + + + + + ${log.pattern} + + + + + + ${log.path}/info.log + + + + ${log.path}/info.%d{yyyy-MM-dd}.log + + 60 + + + ${log.pattern} + + + + INFO + + ACCEPT + + DENY + + + + + ${log.path}/error.log + + + + ${log.path}/error.%d{yyyy-MM-dd}.log + + 60 + + + ${log.pattern} + + + + ERROR + + ACCEPT + + DENY + + + + + + + + + + + + + + + + + + diff --git a/xhpc-modules/xhpc-log/src/main/resources/mapper/SysOperLogMapper.xml b/xhpc-modules/xhpc-log/src/main/resources/mapper/SysOperLogMapper.xml new file mode 100644 index 00000000..72b22665 --- /dev/null +++ b/xhpc-modules/xhpc-log/src/main/resources/mapper/SysOperLogMapper.xml @@ -0,0 +1,33 @@ + + + + + + + diff --git a/xhpc-modules/xhpc-log/src/main/resources/mapper/XhpcChargingPileMapper.xml b/xhpc-modules/xhpc-log/src/main/resources/mapper/XhpcChargingPileMapper.xml new file mode 100644 index 00000000..ae681be0 --- /dev/null +++ b/xhpc-modules/xhpc-log/src/main/resources/mapper/XhpcChargingPileMapper.xml @@ -0,0 +1,426 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + select charging_pile_id, + charging_station_id, + name, + national_standard, + power, + auxiliary_power_supply, + input_voltage, + max_voltage, + min_voltage, + max_electric_current, + min_electric_current, + serial_number, + type, + program_version, + network_link_type, + gun_number, + communication_protocol_version, + communication_operator, + sim_card, + rate_model_id, + status, + del_flag, + create_time, + create_by, + update_time, + update_by, + remark, + rate_model_id, + brand_model, + production_date productionDate, + manufacture_name manufactureName, + connector_type connectorType, + current, + equipment_type equipmentType + from xhpc_charging_pile + + + + + insert into xhpc_charging_pile + + + charging_station_id, + + + name, + + + national_standard, + + + power, + + + auxiliary_power_supply, + + + input_voltage, + + + max_voltage, + + + min_voltage, + + + max_electric_current, + + + min_electric_current, + + + serial_number, + + + type, + + + program_version, + + + network_link_type, + + + gun_number, + + + communication_protocol_version, + + + communication_operator, + + + sim_card, + + + rate_model_id, + + + status, + + + del_flag, + + + create_time, + + + create_by, + + + update_time, + + + update_by, + + + remark, + + + brand_model, + + + production_date, + + + manufacture_name, + + + connector_type, + + + current, + + + equipment_type + + + + + #{chargingStationId}, + + + #{name}, + + + #{nationalStandard}, + + + #{power}, + + + #{auxiliaryPowerSupply}, + + + #{inputVoltage}, + + + #{maxVoltage}, + + + #{minVoltage}, + + + #{maxElectricCurrent}, + + + #{minElectriCurrent}, + + + #{serialNumber}, + + + #{type}, + + + #{programVersion}, + + + #{networkLinkType}, + + + #{gunNumber}, + + + #{communicationProtocolVersion}, + + + #{communicationOperator}, + + + #{simCard}, + + + #{rateModelId}, + + + #{status}, + + + #{delFlag}, + + + #{createTime}, + + + #{createBy}, + + + #{updateTime}, + + + #{updateBy}, + + + #{remark}, + + + #{brandModel}, + + + #{productionDate}, + + + #{manufactureName}, + + + #{connectorType}, + + + #{current}, + + + #{equipmentType} + + + + + + + + + + + + + diff --git a/xhpc-modules/xhpc-log/src/main/resources/mapper/XhpcChargingStationMapper.xml b/xhpc-modules/xhpc-log/src/main/resources/mapper/XhpcChargingStationMapper.xml new file mode 100644 index 00000000..5a0e6bc0 --- /dev/null +++ b/xhpc-modules/xhpc-log/src/main/resources/mapper/XhpcChargingStationMapper.xml @@ -0,0 +1,53 @@ + + + + + + + + + + + + diff --git a/xhpc-modules/xhpc-log/src/main/resources/mapper/XhpcDeviceMessageMapper.xml b/xhpc-modules/xhpc-log/src/main/resources/mapper/XhpcDeviceMessageMapper.xml new file mode 100644 index 00000000..599fca67 --- /dev/null +++ b/xhpc-modules/xhpc-log/src/main/resources/mapper/XhpcDeviceMessageMapper.xml @@ -0,0 +1,63 @@ + + + + + + + + + + diff --git a/xhpc-modules/xhpc-log/src/main/resources/mapper/XhpcHistoryOrderMapper.xml b/xhpc-modules/xhpc-log/src/main/resources/mapper/XhpcHistoryOrderMapper.xml new file mode 100644 index 00000000..13134066 --- /dev/null +++ b/xhpc-modules/xhpc-log/src/main/resources/mapper/XhpcHistoryOrderMapper.xml @@ -0,0 +1,32 @@ + + + + + + + + + \ No newline at end of file diff --git a/xhpc-modules/xhpc-log/src/main/resources/mapper/XhpcMessageMapper.xml b/xhpc-modules/xhpc-log/src/main/resources/mapper/XhpcMessageMapper.xml new file mode 100644 index 00000000..a5c6585e --- /dev/null +++ b/xhpc-modules/xhpc-log/src/main/resources/mapper/XhpcMessageMapper.xml @@ -0,0 +1,52 @@ + + + + + + + + + diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/aspect/DaoAspect.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/aspect/DaoAspect.java index 3ce86cc4..fde262d8 100644 --- a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/aspect/DaoAspect.java +++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/aspect/DaoAspect.java @@ -33,6 +33,7 @@ public class DaoAspect { private static final String CREATE_TIME = "createTime"; private static final String UPDATE_USER = "updateBy"; private static final String UPDATE_TIME = "updateTime"; + private static final String TENANT_ID = "tenantId"; @Pointcut("execution(* com.xhpc..*.update*(..))") public void daoUpdate() { @@ -134,6 +135,10 @@ public class DaoAspect { if (isProperty(arg, UPDATE_TIME) && StringUtils.isEmpty(BeanUtils.getProperty(arg, UPDATE_TIME))) { BeanUtils.setProperty(arg, UPDATE_TIME, date); } + + if (isProperty(arg, TENANT_ID) && StringUtils.isEmpty(BeanUtils.getProperty(arg, TENANT_ID))) { + BeanUtils.setProperty(arg, TENANT_ID, loginUser.getTenantId()); + } } } } catch (Exception e) { diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/Calc.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/Calc.java new file mode 100644 index 00000000..3f309482 --- /dev/null +++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/Calc.java @@ -0,0 +1,371 @@ +package com.xhpc.order.service.impl; + +import org.springframework.expression.Expression; +import org.springframework.expression.ExpressionParser; +import org.springframework.expression.spel.standard.SpelExpressionParser; +import org.springframework.expression.spel.support.StandardEvaluationContext; + +import java.io.IOException; +import java.io.Reader; +import java.io.StreamTokenizer; +import java.io.StringReader; +import java.math.BigDecimal; +import java.util.HashMap; +import java.util.Map; + +public class Calc { + + public static void main(String[] argv) { + + test("-1 + 2", 1); + test("2 * (3 * (4 + 5)) / 9 / 6", 1); + test("max(1, 2 + 3)", 5); + test("min(3 - 1, 1)", 1); + + Map map = new HashMap<>(); + map.put("totalPower", new BigDecimal("400000.000000")); + StandardEvaluationContext stdContext = new StandardEvaluationContext(); + stdContext.setVariables(map); + String ruleExpression = "#totalPower >= 500000 ? 'e1' : 'e2'"; + // Evaluate the SpEL expression + ExpressionParser parser = new SpelExpressionParser(); + Expression expression = parser.parseExpression(ruleExpression); + String rs = expression.getValue(stdContext, String.class); + System.out.println(rs); + } + + private static void test(String s, double x) { + + double v = eval(s); + System.out.println((v == x) + ": " + s + " = " + v); + } + + private static double eval(String s) { + + Parser p = Parser.parse(s); + double v = p.value(); + + if (p.isValid()) { + return v; + } else { + throw new ArithmeticException("error check: " + p.error() + ": " + s); + } + } + +} + +/** + * Parse via recursive descent using the following LL(1) grammar: + * + * expr = [addop] term {(addop) term} end + * term = factor {(mulop) factor} end + * factor = word | number | "(" expr ")" end + * word = name ["(" expr] ["," expr] ")"] end + * addop = "+" | "-" + * mulop = "*" | "/" + * + * + * @param s the string to be evaluated. + * @see + * Recursive descent parser. + */ +class Parser extends Object { + + private final StreamTokenizer tokens; + private int token; + private final double value; + private String error; + + private Parser(String s) { + + Reader reader = new StringReader(s); + tokens = new StreamTokenizer(reader); + tokens.ordinaryChar(Symbol.SLASH.toChar()); + + getToken(); + value = expr(); + if (!tokenIs(Symbol.END)) + putError("syntax error"); + } + + public static Parser parse(String s) { + + return new Parser(s); + } + + public boolean isValid() { + + return error == null; + } + + public double value() { + + return value; + } + + public String error() { + + return error; + } + + // expr = [addop] term {(addop) term} end + private double expr() { + + BigDecimal sign = BigDecimal.ONE; + accept(Symbol.PLUS); + if (accept(Symbol.MINUS)) { + sign = BigDecimal.valueOf(-1); + } + BigDecimal value = sign.multiply(term()); + while (Symbol.isAddOp(token)) { + if (accept(Symbol.PLUS)) { + value = value.add(term()); + } + if (accept(Symbol.MINUS)) { + value = value.subtract(term()); + } + } + return value.doubleValue(); + } + + // term = factor {(mulop) factor} end + private BigDecimal term() { + + BigDecimal value = factor(); + while (Symbol.isMulOp(token)) { + if (accept(Symbol.STAR)) { + value = value.multiply(factor()); + } + if (accept(Symbol.SLASH)) { + value = value.divide(factor()); + } + } + return value; + } + + // factor = word | number | "(" expr ")" end + private BigDecimal factor() { + + BigDecimal value = BigDecimal.ZERO; + if (tokenIs(Symbol.WORD)) { + value = word(); + } else if (tokenIs(Symbol.NUMBER)) { + value = new BigDecimal(tokens.nval); + getToken(); + } else if (accept(Symbol.OPEN)) { + value = BigDecimal.valueOf(expr()); + expect(Symbol.CLOSE); + } else { + putError("factor error"); + getToken(); + } + return value; + } + + // word = name ["(" expr] ["," expr] ")"] end + private BigDecimal word() { + + BigDecimal value = BigDecimal.ZERO; + String name = tokens.sval; + FunctionAdapter fa = Function.lookup(name); + getToken(); + if (fa != null) { + int count = fa.getCount(); + if (count == 0) { + value = BigDecimal.valueOf(fa.eval()); + } else if (accept(Symbol.OPEN)) { + double[] args = new double[count]; + for (int i = 0; i < count; i++) { + args[i] = expr(); + if (i < count - 1) + expect(Symbol.COMMA); + } + value = BigDecimal.valueOf(fa.eval(args)); + expect(Symbol.CLOSE); + } else putError("missing " + Symbol.OPEN.toChar()); + } else putError("undefined " + name); + return value; + } + + /** + * Fetch the next token in the stream. + */ + private void getToken() { + + try { + token = tokens.nextToken(); + } catch (IOException e) { + putError("i/o error " + e.getMessage()); + } + } + + /** + * Return true if the current token matches the given symbol. + */ + private boolean tokenIs(Symbol symbol) { + + return token == symbol.token(); + } + + /** + * Require a matching symbol; gerate an error if it's unexpected. + */ + private void expect(Symbol symbol) { + + if (accept(symbol)) return; + putError("missing " + symbol.toChar()); + } + + /** + * Advance if the current token matches the given symbol. + */ + private boolean accept(Symbol symbol) { + + if (tokenIs(symbol)) { + getToken(); + return true; + } + return false; + } + + /** + * Generate an error; ignore line numbers. + */ + private void putError(String s) { + + if (error == null) + error = s + " at " + tokens.toString().replaceAll(",.*$", ""); + } + +} + +/** + * Enumerate the terminal symbols recognized by the Parser. + * Each symbol's token field is initialized with a value that + * matches one returned by StreamTokenizer's nextToken() method. + */ +enum Symbol { + PLUS('+'), MINUS('-'), STAR('*'), SLASH('/'), + OPEN('('), CLOSE(')'), COMMA(','), + END(StreamTokenizer.TT_EOF), + WORD(StreamTokenizer.TT_WORD), + NUMBER(StreamTokenizer.TT_NUMBER); + + private final int token; + + Symbol(int token) { + + this.token = token; + } + + /** + * Return this symbol's token. + */ + public int token() { + + return this.token; + } + + /** + * If printable, return character for this symbol's token. + */ + public char toChar() { + + if (this.token < 32) return '\ufffd'; + else return (char) this.token; + } + + /** + * Return if the given token matches PLUS or MINUS. + */ + public static boolean isAddOp(int token) { + + return token == PLUS.token || token == MINUS.token; + } + + /** + * Return if the given token matches STAR or SLASH. + */ + public static boolean isMulOp(int token) { + + return token == STAR.token || token == SLASH.token; + } +} + +/** + * Enumerate the available functions. Although an enum may define + * constant-specific methods, an included adpter or interface + * is perhaps easier to read, initialize and maintain. + */ +enum Function { + MAX(new Max()), + MIN(new Min()); + + private final FunctionAdapter fa; + + /** + * Construct a Function with the specified adapter. + **/ + Function(FunctionAdapter fa) { + + this.fa = fa; + } + + /** + * Return a Function's adapter by name; null if unknown. + */ + public static FunctionAdapter lookup(String name) { + + Function f; + try { + f = Enum.valueOf(Function.class, name.toUpperCase()); + } catch (RuntimeException e) { + return null; + } + return f.fa; + } +} + +/** + * Adapt to functions with a variable number of arguments. + * Concrete implementations should override getCount() to indicate + * the expected number of arguments. The default is one. + */ +abstract class FunctionAdapter { + + public int getCount() { + + return 1; + } + + abstract double eval(double... args); + +} + +class Max extends FunctionAdapter { + + public int getCount() { + + return 2; + } + + public double eval(double... args) { + + return Math.max(args[0], args[1]); + } + +} + +class Min extends FunctionAdapter { + + public int getCount() { + + return 2; + } + + public double eval(double... args) { + + return Math.min(args[0], args[1]); + } + +} diff --git a/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/aspect/DaoAspect.java b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/aspect/DaoAspect.java index f1b194b5..49887a2a 100644 --- a/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/aspect/DaoAspect.java +++ b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/aspect/DaoAspect.java @@ -33,6 +33,7 @@ public class DaoAspect { private static final String CREATE_TIME = "createTime"; private static final String UPDATE_USER = "updateBy"; private static final String UPDATE_TIME = "updateTime"; + private static final String TENANT_ID = "tenantId"; @Pointcut("execution(* com.xhpc..*.update*(..))") public void daoUpdate() { @@ -135,6 +136,9 @@ public class DaoAspect { if (isProperty(arg, UPDATE_TIME) && StringUtils.isEmpty(BeanUtils.getProperty(arg, UPDATE_TIME))) { BeanUtils.setProperty(arg, UPDATE_TIME, date); } + if (isProperty(arg, TENANT_ID) && StringUtils.isEmpty(BeanUtils.getProperty(arg, TENANT_ID))) { + BeanUtils.setProperty(arg, TENANT_ID, loginUser.getTenantId()); + } } } } catch (Exception e) { diff --git a/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/controller/AlipayPaymentController.java b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/controller/AlipayPaymentController.java index 432b2813..1e2cb869 100644 --- a/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/controller/AlipayPaymentController.java +++ b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/controller/AlipayPaymentController.java @@ -1,34 +1,32 @@ package com.xhpc.payment.controller; -import cn.hutool.core.date.DateUtil; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.alipay.api.AlipayApiException; import com.alipay.api.AlipayClient; import com.alipay.api.CertAlipayRequest; import com.alipay.api.DefaultAlipayClient; -import com.alipay.api.domain.AlipayTradeAppPayModel; import com.alipay.api.internal.util.AlipaySignature; import com.alipay.api.internal.util.AntCertificationUtil; -import com.alipay.api.request.AlipayTradeAppPayRequest; import com.alipay.api.request.AlipayTradeCreateRequest; -import com.alipay.api.request.AlipayTradeRoyaltyRelationBindRequest; import com.alipay.api.response.AlipayTradeCreateResponse; -import com.alipay.api.response.AlipayTradeRoyaltyRelationBindResponse; import com.xhpc.common.api.PowerPileService; +import com.xhpc.common.api.UserTypeService; import com.xhpc.common.core.constant.HttpStatus; import com.xhpc.common.core.constant.StatusConstants; import com.xhpc.common.core.domain.R; import com.xhpc.common.core.utils.StringUtils; import com.xhpc.common.core.web.domain.AjaxResult; import com.xhpc.common.data.down.StartChargingData; -import com.xhpc.payment.domain.AlipayNotifyParam; -import com.xhpc.payment.domain.XhpcAppUser; -import com.xhpc.payment.domain.XhpcRechargeOrder; -import com.xhpc.payment.domain.XhpcUserAccountStatement; +import com.xhpc.common.domain.XhpcRechargeOrder; +import com.xhpc.common.security.service.TokenService; +import com.xhpc.common.util.UserTypeUtil; +import com.xhpc.payment.domain.*; import com.xhpc.payment.mapper.XhpcUserAccountStatementMapper; +import com.xhpc.payment.service.IXhpcCommonPayment; import com.xhpc.payment.service.IXhpcRechargeOrderService; import com.xhpc.payment.service.IXhpcRefundOrderService; +import com.xhpc.system.api.model.LoginUser; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.slf4j.Logger; @@ -59,6 +57,13 @@ public class AlipayPaymentController { private PowerPileService powerPileService; @Autowired private IXhpcRefundOrderService iXhpcRefundOrderService; + @Autowired + private TokenService tokenService; + @Autowired + private IXhpcCommonPayment xhpcCommonPayment; + @Autowired + private UserTypeService userTypeService; + private static final Logger logger = LoggerFactory.getLogger(AlipayPaymentController.class); @@ -83,30 +88,40 @@ public class AlipayPaymentController { if (StringUtils.isEmpty(userId)) { return AjaxResult.error(HttpStatus.NOT_NULL, "用户信息不能为空"); } - Map refundOrder = iXhpcRefundOrderService.getNotRefundOrder(Long.parseLong(userId)); + + LoginUser loginUser = tokenService.getLoginUser(servletRequest); + Long userid = loginUser.getUserid(); + Integer userType = loginUser.getUserType(); + String tenantId = loginUser.getTenantId(); + + Map refundOrder = iXhpcRefundOrderService.getNotRefundOrder(userid,userType,tenantId); if (StringUtils.isNotNull(refundOrder)) { return AjaxResult.error(HttpStatus.ALREADY_EXISTING, "用户存正在退款"); } - String orderNumber = StringUtils.numFormat(Long.parseLong(userId), 1, StatusConstants.FLOWING_WATER_RECHARGE_TYPE); + String orderNumber = StringUtils.numFormat(userid, 1, StatusConstants.FLOWING_WATER_RECHARGE_TYPE); + XhpcSettingConfig xhpcSettingConfig = xhpcCommonPayment.getXhpcSettingConfigTenantId(UserTypeUtil.OPERATION_ALI_PAY_TYPE, tenantId); + if(xhpcSettingConfig ==null){ + return AjaxResult.error(HttpStatus.ALREADY_EXISTING, "支付宝充值失败,继续充值请联系客服"); + } //生成充值订单 - XhpcRechargeOrder xhpcRechargeOrder = iXhpcRechargeOrderService.addRechargeOrder(userId, BigDecimal.valueOf(Double.parseDouble(amount)), "2", orderNumber); + XhpcRechargeOrder xhpcRechargeOrder = iXhpcRechargeOrderService.addRechargeOrder(userId+"", BigDecimal.valueOf(Double.parseDouble(amount)), "2", orderNumber,userType); String attach = attachYu(StringUtils.valueOf(xhpcRechargeOrder.getRechargeOrderId()), StringUtils.valueOf(amount), null, orderNumber); /** 初始化 **/ CertAlipayRequest certAlipayRequest = new CertAlipayRequest(); /** 支付宝网关 **/ - certAlipayRequest.setServerUrl("https://openapi.alipay.com/gateway.do"); + certAlipayRequest.setServerUrl(xhpcSettingConfig.getZhbServerUrl()); /** 应用id,如何获取请参考:https://opensupport.alipay.com/support/helpcenter/190/201602493024 **/ - certAlipayRequest.setAppId(environment.getProperty("ALIPAYAPPID")); + certAlipayRequest.setAppId(xhpcSettingConfig.getZfbAppId()); /** 应用私钥, 如何获取请参考:https://opensupport.alipay.com/support/helpcenter/207/201602471154?ant_source=antsupport **/ - certAlipayRequest.setPrivateKey(environment.getProperty("ALIPAYPRIVATEKEY")); + certAlipayRequest.setPrivateKey(xhpcSettingConfig.getZfbPrivateKey()); /** 应用公钥证书路径,下载后保存位置的绝对路径 **/ - certAlipayRequest.setCertPath(environment.getProperty("CERTPATH")); + certAlipayRequest.setCertPath(xhpcSettingConfig.getZfbAppCertPublicKey()); /** 支付宝公钥证书路径,下载后保存位置的绝对路径 **/ - certAlipayRequest.setAlipayPublicCertPath(environment.getProperty("PUBLICCERTPATH")); + certAlipayRequest.setAlipayPublicCertPath(xhpcSettingConfig.getZfbAlipayCertPublicKeyRsa()); /** 支付宝根证书路径,下载后保存位置的绝对路径 **/ - certAlipayRequest.setRootCertPath(environment.getProperty("ROOTCRETPATH")); + certAlipayRequest.setRootCertPath(xhpcSettingConfig.getZfbAlipayRootCert()); /** 设置签名类型 **/ certAlipayRequest.setSignType("RSA2"); /** 设置请求格式,固定值json **/ @@ -125,7 +140,7 @@ public class AlipayPaymentController { "\"passback_params\":\""+encode+"\"," + "\"buyer_id\":\""+openid+"\"" + "}"); - request.setNotifyUrl(environment.getProperty("ALIPAYPSERVERDOMAIN")); + request.setNotifyUrl(xhpcSettingConfig.getZfbCallbackUrl()); try { //这里和普通的接口调用不同,使用的是sdkExecute AlipayTradeCreateResponse response = alipayClient.certificateExecute(request); @@ -153,43 +168,47 @@ public class AlipayPaymentController { Map params = convertRequestParamsToMap(request); // 将异步通知中收到的待验证所有参数都存放到map中 logger.info("<<<<<<<<<<<>>>>>>>>"+params); - logger.info("<<<<<<<<<<<<>>>>>>>>>"); try{ - String publiccertpath = getAlipayPublicKey(environment.getProperty("PUBLICCERTPATH")); - logger.info("<<<<<<<<<<<<支付宝公钥证书>>>>>>>>>"+publiccertpath); - // 调用SDK验证签名 - boolean signVerified = AlipaySignature.rsaCheckV1(params, publiccertpath, "utf-8", "RSA2"); - logger.info("<<<<<<<<<<<<验证签名>>>>>>>>>"+signVerified); - if (signVerified) { - //("支付宝回调签名认证成功"); - AlipayNotifyParam param = buildAlipayNotifyParam(params); - String trade_status = param.getTradeStatus(); - // 支付成功 - if (trade_status.equals("TRADE_SUCCESS") || trade_status.equals("TRADE_FINISHED")) { - // 处理支付成功逻辑 - try{ - String passbackParams = param.getPassbackParams(); - String tradeStatus = param.getTradeStatus(); - if ("TRADE_SUCCESS".equals(tradeStatus)) { - // 业务参数主要转码回来 - JSONObject jsonObject = JSON.parseObject(URLDecoder.decode(passbackParams)); - logger.info("<<<<<<<<<<<>>>>>>>>"+jsonObject.toString()); - String out_trade_no = jsonObject.getString("out_trade_no"); - String transaction_id = params.get("trade_no"); - paymentCallback(out_trade_no, transaction_id); + XhpcRechargeOrder xhpcRechargeOrder = iXhpcRechargeOrderService.infoRechargeOrderNumber(params.get("out_trade_no").toString()); + if(xhpcRechargeOrder!=null){ + XhpcSettingConfig xhpcSettingConfig = xhpcCommonPayment.getXhpcSettingConfigTenantId(UserTypeUtil.OPERATION_ALI_PAY_TYPE, xhpcRechargeOrder.getTenantId()); + if(xhpcSettingConfig !=null){ + String publiccertpath = getAlipayPublicKey(xhpcSettingConfig.getZfbAlipayCertPublicKeyRsa()); + logger.info("<<<<<<<<<<<<支付宝公钥证书>>>>>>>>>"+publiccertpath); + // 调用SDK验证签名 + boolean signVerified = AlipaySignature.rsaCheckV1(params, publiccertpath, "utf-8", "RSA2"); + logger.info("<<<<<<<<<<<<验证签名>>>>>>>>>"+signVerified); + if (signVerified) { + //("支付宝回调签名认证成功"); + AlipayNotifyParam param = buildAlipayNotifyParam(params); + String trade_status = param.getTradeStatus(); + // 支付成功 + if (trade_status.equals("TRADE_SUCCESS") || trade_status.equals("TRADE_FINISHED")) { + // 处理支付成功逻辑 + try{ + String passbackParams = param.getPassbackParams(); + String tradeStatus = param.getTradeStatus(); + if ("TRADE_SUCCESS".equals(tradeStatus)) { + // 业务参数主要转码回来 + JSONObject jsonObject = JSON.parseObject(URLDecoder.decode(passbackParams)); + String out_trade_no = jsonObject.getString("out_trade_no"); + String transaction_id = params.get("trade_no"); + paymentCallback(out_trade_no, transaction_id); + } + }catch (Exception e){ + //("支付宝回调业务处理报错,params:" + paramsJson, e); + } + }else{ + //("没有处理支付宝回调业务,支付宝交易状态:{},params:{}",trade_status,paramsJson); } - }catch (Exception e){ - //("支付宝回调业务处理报错,params:" + paramsJson, e); + // 业务处理失败,可查看日志进行补偿,跟支付宝已经没多大关系。 + return "success"; + }else{ + return "failure"; } - }else{ - //("没有处理支付宝回调业务,支付宝交易状态:{},params:{}",trade_status,paramsJson); } - - // 业务处理失败,可查看日志进行补偿,跟支付宝已经没多大关系。 - return "success"; - }else{ - return "failure"; } + return "failure"; }catch (Exception e){ e.printStackTrace(); //logger.error("支付宝回调签名认证失败,paramsJson:{},errorMsg:{}", paramsJson, e.getMessage()); @@ -252,31 +271,41 @@ public class AlipayPaymentController { //修改充值订单状态 iXhpcRechargeOrderService.updateRechargeOrder(xhpcRechargeOrder.getRechargeOrderId(), StatusConstants.OPERATION_ALI_PAY_TYPE, StatusConstants.RECHARGE_ORDER_STATUS_SUCCESS, transaction_id); } - Map appUserInfo = xhpcUserAccountStatementMapper.appUserInfo(xhpcRechargeOrder.getUserId()); - if (StringUtils.isNotNull(appUserInfo)) { - String balance = StringUtils.valueOf(appUserInfo.get("balance")); + Long userId = xhpcRechargeOrder.getUserId(); + Integer source = xhpcRechargeOrder.getSource(); + String tenantId = xhpcRechargeOrder.getTenantId(); + //判断用户 + R user = userTypeService.getUser(null,userId, source, null, tenantId); + if(user !=null && user.getData() !=null){ + Map map = (Map)user.getData(); + String balance = StringUtils.valueOf(map.get("balance")); BigDecimal money = BigDecimal.valueOf(Double.valueOf(balance)).add(xhpcRechargeOrder.getAmount()); //判断用户是否在充电中 - String serialMumber = xhpcUserAccountStatementMapper.getUserHistotyChargeOrder(xhpcRechargeOrder.getUserId()); + String serialMumber = xhpcUserAccountStatementMapper.getUserHistotyChargeOrder(xhpcRechargeOrder.getUserId(),source,tenantId); logger.info("<<<<<<<<<<<<充电终端>>>>>>>>>serialMumber:"+serialMumber); if(!"".equals(serialMumber) && serialMumber !=null){ //充电中 postRefreshBalance(money, serialMumber); } - //增加用户余额 - XhpcAppUser xhpcAppUser = new XhpcAppUser(); - xhpcAppUser.setAppUserId(xhpcRechargeOrder.getUserId()); - xhpcAppUser.setBalance(money); - xhpcUserAccountStatementMapper.updateAppUserBalance(xhpcAppUser); - XhpcUserAccountStatement xhpcUserAccountStatement = new XhpcUserAccountStatement(); - xhpcUserAccountStatement.setType(StatusConstants.FLOWING_WATER_RECHARGE_TYPE); - xhpcUserAccountStatement.setRechargeOrderId(xhpcRechargeOrder.getRechargeOrderId()); - xhpcUserAccountStatement.setUserId(xhpcRechargeOrder.getUserId()); - xhpcUserAccountStatement.setAmount(xhpcRechargeOrder.getAmount()); - xhpcUserAccountStatement.setRemainingSum(xhpcAppUser.getBalance()); - xhpcUserAccountStatement.setCreateTime(new Date()); - xhpcUserAccountStatement.setRemark("支付宝充值订单!"); - xhpcUserAccountStatementMapper.insert(xhpcUserAccountStatement); + if(UserTypeUtil.USER_TYPE.equals(xhpcRechargeOrder.getSource())){ + //增加用户余额 + XhpcAppUser xhpcAppUser = new XhpcAppUser(); + xhpcAppUser.setAppUserId(xhpcRechargeOrder.getUserId()); + xhpcAppUser.setBalance(money); + xhpcUserAccountStatementMapper.updateAppUserBalance(xhpcAppUser); + XhpcUserAccountStatement xhpcUserAccountStatement = new XhpcUserAccountStatement(); + xhpcUserAccountStatement.setType(StatusConstants.FLOWING_WATER_RECHARGE_TYPE); + xhpcUserAccountStatement.setRechargeOrderId(xhpcRechargeOrder.getRechargeOrderId()); + xhpcUserAccountStatement.setUserId(xhpcRechargeOrder.getUserId()); + xhpcUserAccountStatement.setAmount(xhpcRechargeOrder.getAmount()); + xhpcUserAccountStatement.setRemainingSum(xhpcAppUser.getBalance()); + xhpcUserAccountStatement.setCreateTime(new Date()); + xhpcUserAccountStatement.setRemark("支付宝充值订单!"); + xhpcUserAccountStatementMapper.insert(xhpcUserAccountStatement); + }else{ + //增加用户余额 + userTypeService.insertUserBalance(money,userId,source,tenantId,UserTypeUtil.RECHARGE_ZHB,UserTypeUtil.INSERT_BALANCE,null,xhpcRechargeOrder.getRechargeOrderId()); + } } } diff --git a/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/controller/WxPaymentController.java b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/controller/WxPaymentController.java index ced388b9..e5fdab6d 100644 --- a/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/controller/WxPaymentController.java +++ b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/controller/WxPaymentController.java @@ -1,6 +1,7 @@ package com.xhpc.payment.controller; import com.xhpc.common.api.PowerPileService; +import com.xhpc.common.api.UserTypeService; import com.xhpc.common.core.constant.HttpStatus; import com.xhpc.common.core.constant.StatusConstants; import com.xhpc.common.core.domain.R; @@ -8,12 +9,17 @@ import com.xhpc.common.core.utils.StringUtils; import com.xhpc.common.core.utils.WXPayUtil; import com.xhpc.common.core.web.domain.AjaxResult; import com.xhpc.common.data.down.StartChargingData; +import com.xhpc.common.security.service.TokenService; +import com.xhpc.common.util.UserTypeUtil; import com.xhpc.payment.domain.XhpcAppUser; -import com.xhpc.payment.domain.XhpcRechargeOrder; +import com.xhpc.common.domain.XhpcRechargeOrder; +import com.xhpc.payment.domain.XhpcSettingConfig; import com.xhpc.payment.domain.XhpcUserAccountStatement; import com.xhpc.payment.mapper.XhpcUserAccountStatementMapper; +import com.xhpc.payment.service.IXhpcCommonPayment; import com.xhpc.payment.service.IXhpcRechargeOrderService; import com.xhpc.payment.service.IXhpcRefundOrderService; +import com.xhpc.system.api.model.LoginUser; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.slf4j.Logger; @@ -54,26 +60,22 @@ public class WxPaymentController { @Autowired private IXhpcRechargeOrderService iXhpcRechargeOrderService; - @Autowired private XhpcUserAccountStatementMapper xhpcUserAccountStatementMapper; - @Autowired private IXhpcRefundOrderService iXhpcRefundOrderService; - @Autowired private Environment environment; - @Autowired private PowerPileService powerPileService; + @Autowired + private TokenService tokenService; + @Autowired + private UserTypeService userTypeService; + @Autowired + private IXhpcCommonPayment xhpcCommonPayment; private static final Logger logger = LoggerFactory.getLogger(WxPaymentController.class); - private int number; - - @PostConstruct - public void init(){ - number =1; - } @PostMapping("/payment") @ApiOperation(value = "微信支付") @@ -96,10 +98,12 @@ public class WxPaymentController { return AjaxResult.error(HttpStatus.NOT_NULL, "请在我的里面进行充值"); } String userId = StringUtils.valueOf(map.get("userId")); -// if (StringUtils.isEmpty(userId)) { -// return AjaxResult.error(HttpStatus.NOT_NULL, "用户信息不能为空"); -// } - Map refundOrder = iXhpcRefundOrderService.getNotRefundOrder(Long.parseLong(userId)); + + LoginUser loginUser = tokenService.getLoginUser(servletRequest); + Long userid = loginUser.getUserid(); + Integer userType = loginUser.getUserType(); + String tenantId = loginUser.getTenantId(); + Map refundOrder = iXhpcRefundOrderService.getNotRefundOrder(userid,userType,tenantId); if (StringUtils.isNotNull(refundOrder)) { return AjaxResult.error(HttpStatus.ALREADY_EXISTING, "用户存正在退款"); } @@ -108,8 +112,13 @@ public class WxPaymentController { if (0.0 == amount1) { return AjaxResult.error(HttpStatus.NOT_NULL, "充值金额不能为0"); } + XhpcSettingConfig xhpcSettingConfig = xhpcCommonPayment.getXhpcSettingConfigTenantId(UserTypeUtil.OPERATION_WX_TYPE, tenantId); + if(xhpcSettingConfig ==null){ + return AjaxResult.error(HttpStatus.ALREADY_EXISTING, "支付宝充值失败,继续充值请联系客服"); + } + //生成充值订单 - XhpcRechargeOrder xhpcRechargeOrder = iXhpcRechargeOrderService.addRechargeOrder(userId, BigDecimal.valueOf(Double.parseDouble(amount)), "1", orderNumber); + XhpcRechargeOrder xhpcRechargeOrder = iXhpcRechargeOrderService.addRechargeOrder(userId, BigDecimal.valueOf(Double.parseDouble(amount)), "1", orderNumber,userType); //附加数据(否) String attach = attachYu(StringUtils.valueOf(xhpcRechargeOrder.getRechargeOrderId()), StringUtils.valueOf(amount), null, orderNumber); //商品描述(是) @@ -132,7 +141,7 @@ public class WxPaymentController { BufferedReader in = null; StringBuffer result = new StringBuffer(); try { - URL realUrl = new URL(environment.getProperty("WXPAYUNIFIEDORDER")); + URL realUrl = new URL(xhpcSettingConfig.getWxPaymentUrl()); // 打开和URL之间的连接 URLConnection conn = realUrl.openConnection(); // 设置通用的请求属性 @@ -145,7 +154,7 @@ public class WxPaymentController { conn.setDoInput(true); // 获取URLConnection对象对应的输出流 out = new PrintWriter(conn.getOutputStream()); - out.print(createXMLParam(Fee, attach, tradeType, spbillCreateIp, outTradeNo, body, timeStr, environment.getProperty("SERVERDOMAIN"), environment.getProperty("APPID"), environment.getProperty("MCHID"), environment.getProperty("KEY"), openid)); + out.print(createXMLParam(Fee, attach, tradeType, spbillCreateIp, outTradeNo, body, timeStr, xhpcSettingConfig.getWxCallbackUrl(), xhpcSettingConfig.getWxAppId(), xhpcSettingConfig.getWxMchId(), xhpcSettingConfig.getWxMchKey(), openid)); // flush输出流的缓冲 out.flush(); // 定义BufferedReader输入流来读取URL的响应 @@ -174,7 +183,7 @@ public class WxPaymentController { } } //app - Map sign = createSign(result.toString(), Double.parseDouble(amount)); + Map sign = createSign(result.toString(), Double.parseDouble(amount),xhpcSettingConfig.getWxMchKey()); return AjaxResult.success(sign); } @@ -184,7 +193,7 @@ public class WxPaymentController { * @param result xml格式字符串 * @return */ - public Map createSign(String result, Double amount) { + public Map createSign(String result, Double amount,String key) { try { Map map = WXPayUtil.xmlToMap(result); String return_code = map.get("return_code"); @@ -206,7 +215,7 @@ public class WxPaymentController { map1.put("timestamp", timeStr); map1.put("sign", map.get("sign")); map1.put("url", map.get("code_url")); - map1.put("key", environment.getProperty("KEY")); + map1.put("key", key); return map1; } } catch (Exception e) { @@ -365,32 +374,43 @@ public class WxPaymentController { //修改充值订单状态 iXhpcRechargeOrderService.updateRechargeOrder(xhpcRechargeOrder.getRechargeOrderId(), StatusConstants.OPERATION_WX_TYPE, StatusConstants.RECHARGE_ORDER_STATUS_SUCCESS, transaction_id); } - Map appUserInfo = xhpcUserAccountStatementMapper.appUserInfo(xhpcRechargeOrder.getUserId()); - if (StringUtils.isNotNull(appUserInfo)) { - String balance = StringUtils.valueOf(appUserInfo.get("balance")); + + Long userId = xhpcRechargeOrder.getUserId(); + Integer source = xhpcRechargeOrder.getSource(); + String tenantId = xhpcRechargeOrder.getTenantId(); + R user = userTypeService.getUser(null,userId, source, null, tenantId); + if(user !=null && user.getData() !=null){ + Map map = (Map)user.getData(); + String balance = StringUtils.valueOf(map.get("balance")); BigDecimal money = BigDecimal.valueOf(Double.valueOf(balance)).add(xhpcRechargeOrder.getAmount()); //判断用户是否在充电中 - String serialMumber = xhpcUserAccountStatementMapper.getUserHistotyChargeOrder(xhpcRechargeOrder.getUserId()); + String serialMumber = xhpcUserAccountStatementMapper.getUserHistotyChargeOrder(xhpcRechargeOrder.getUserId(),source,tenantId); logger.info("<<<<<<<<<<<<充电终端>>>>>>>>>serialMumber:"+serialMumber); if(!"".equals(serialMumber) && serialMumber !=null){ - //充电中 - postRefreshBalance(money, serialMumber); + //充电中 + postRefreshBalance(money, serialMumber); + } + if(UserTypeUtil.USER_TYPE.equals(xhpcRechargeOrder.getSource())){ + //增加用户余额 + XhpcAppUser xhpcAppUser = new XhpcAppUser(); + xhpcAppUser.setAppUserId(xhpcRechargeOrder.getUserId()); + xhpcAppUser.setBalance(money); + xhpcUserAccountStatementMapper.updateAppUserBalance(xhpcAppUser); + XhpcUserAccountStatement xhpcUserAccountStatement = new XhpcUserAccountStatement(); + xhpcUserAccountStatement.setType(StatusConstants.FLOWING_WATER_RECHARGE_TYPE); + xhpcUserAccountStatement.setRechargeOrderId(xhpcRechargeOrder.getRechargeOrderId()); + xhpcUserAccountStatement.setUserId(xhpcRechargeOrder.getUserId()); + xhpcUserAccountStatement.setAmount(xhpcRechargeOrder.getAmount()); + xhpcUserAccountStatement.setRemainingSum(xhpcAppUser.getBalance()); + xhpcUserAccountStatement.setCreateTime(new Date()); + xhpcUserAccountStatement.setRemark("微信充值订单!"); + xhpcUserAccountStatementMapper.insert(xhpcUserAccountStatement); + }else{ + //增加用户余额 + userTypeService.insertUserBalance(money,userId,source,tenantId, UserTypeUtil.RECHARGE_WX,UserTypeUtil.INSERT_BALANCE,null,xhpcRechargeOrder.getRechargeOrderId()); } - //增加用户余额 - XhpcAppUser xhpcAppUser = new XhpcAppUser(); - xhpcAppUser.setAppUserId(xhpcRechargeOrder.getUserId()); - xhpcAppUser.setBalance(money); - xhpcUserAccountStatementMapper.updateAppUserBalance(xhpcAppUser); - XhpcUserAccountStatement xhpcUserAccountStatement = new XhpcUserAccountStatement(); - xhpcUserAccountStatement.setType(StatusConstants.FLOWING_WATER_RECHARGE_TYPE); - xhpcUserAccountStatement.setRechargeOrderId(xhpcRechargeOrder.getRechargeOrderId()); - xhpcUserAccountStatement.setUserId(xhpcRechargeOrder.getUserId()); - xhpcUserAccountStatement.setAmount(xhpcRechargeOrder.getAmount()); - xhpcUserAccountStatement.setRemainingSum(xhpcAppUser.getBalance()); - xhpcUserAccountStatement.setCreateTime(new Date()); - xhpcUserAccountStatement.setRemark("微信充值订单!"); - xhpcUserAccountStatementMapper.insert(xhpcUserAccountStatement); } + } private void postRefreshBalance(BigDecimal money, String serialMumber) { diff --git a/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/controller/XhpcRefundAuditController.java b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/controller/XhpcRefundAuditController.java index 7133c268..df85b500 100644 --- a/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/controller/XhpcRefundAuditController.java +++ b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/controller/XhpcRefundAuditController.java @@ -16,13 +16,15 @@ import com.xhpc.common.core.utils.WXPayUtil; import com.xhpc.common.core.web.controller.BaseController; import com.xhpc.common.core.web.domain.AjaxResult; import com.xhpc.common.core.web.page.TableDataInfo; +import com.xhpc.common.security.service.TokenService; import com.xhpc.payment.domain.XhpcAppUser; import com.xhpc.payment.domain.XhpcRefundAudit; -import com.xhpc.payment.domain.XhpcRefundOrder; +import com.xhpc.common.domain.XhpcRefundOrder; import com.xhpc.payment.mapper.XhpcUserAccountStatementMapper; import com.xhpc.payment.service.IXhpcRefundAuditService; import com.xhpc.payment.service.IXhpcRefundOrderService; import com.xhpc.payment.service.impl.XhpcUserAccountStatementServiceImpl; +import com.xhpc.system.api.model.LoginUser; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.apache.http.HttpEntity; @@ -45,6 +47,7 @@ import org.springframework.transaction.interceptor.TransactionAspectSupport; import org.springframework.web.bind.annotation.*; import javax.net.ssl.SSLContext; +import javax.servlet.http.HttpServletRequest; import java.io.File; import java.io.FileInputStream; import java.io.IOException; @@ -77,6 +80,8 @@ public class XhpcRefundAuditController extends BaseController { @Autowired private SmsService smsService; + @Autowired + private TokenService tokenService; private static final Logger logger = LoggerFactory.getLogger(XhpcRefundAuditController.class); /** @@ -160,12 +165,16 @@ public class XhpcRefundAuditController extends BaseController { @PostMapping("/cancelExamine") @ApiOperation(value = "取消申请") @Transactional - public AjaxResult cancelExamine(@RequestBody Map map) { + public AjaxResult cancelExamine(HttpServletRequest request, @RequestBody Map map) { String userId = StringUtils.valueOf(map.get("userId")); if (StringUtils.isEmpty(userId)) { return AjaxResult.error(HttpStatus.NOT_NULL, "用户id不能为空"); } - Map refundOrder = iXhpcRefundOrderService.getNotRefundOrder(Long.parseLong(userId)); + LoginUser loginUser = tokenService.getLoginUser(request); + Long userid = loginUser.getUserid(); + Integer userType = loginUser.getUserType(); + String tenantId = loginUser.getTenantId(); + Map refundOrder = iXhpcRefundOrderService.getNotRefundOrder(userid,userType,tenantId); if (StringUtils.isNull(refundOrder)) { return AjaxResult.error(HttpStatus.DATA_ERROR, "退款订单不存在"); } diff --git a/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/controller/XhpcRefundOrderController.java b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/controller/XhpcRefundOrderController.java index 655b0d23..86b29c50 100644 --- a/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/controller/XhpcRefundOrderController.java +++ b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/controller/XhpcRefundOrderController.java @@ -6,12 +6,15 @@ import com.xhpc.common.core.utils.StringUtils; import com.xhpc.common.core.web.controller.BaseController; import com.xhpc.common.core.web.domain.AjaxResult; import com.xhpc.common.core.web.page.TableDataInfo; +import com.xhpc.common.security.service.TokenService; import com.xhpc.payment.service.IXhpcRefundOrderService; +import com.xhpc.system.api.model.LoginUser; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; +import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.math.BigDecimal; @@ -25,7 +28,8 @@ public class XhpcRefundOrderController extends BaseController { @Autowired private IXhpcRefundOrderService iXhpcRefundOrderService; - + @Autowired + private TokenService tokenService; /** * 申请退款 * @@ -94,8 +98,12 @@ public class XhpcRefundOrderController extends BaseController { */ @GetMapping("/getNotRefundOrder") @ApiOperation(value = "用户id查询未完成退款订单") - public AjaxResult getNotRefundOrder(@RequestParam Long userId) { - return AjaxResult.success(iXhpcRefundOrderService.getNotRefundOrder(userId)); + public AjaxResult getNotRefundOrder(HttpServletRequest request, @RequestParam Long userId) { + LoginUser loginUser = tokenService.getLoginUser(request); + Long userid = loginUser.getUserid(); + Integer userType = loginUser.getUserType(); + String tenantId = loginUser.getTenantId(); + return AjaxResult.success(iXhpcRefundOrderService.getNotRefundOrder(userid,userType,tenantId)); } /** diff --git a/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/domain/XhpcSettingConfig.java b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/domain/XhpcSettingConfig.java new file mode 100644 index 00000000..6c256745 --- /dev/null +++ b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/domain/XhpcSettingConfig.java @@ -0,0 +1,100 @@ +package com.xhpc.payment.domain; + +import com.xhpc.common.core.web.domain.BaseEntity; +import lombok.Data; + +/** + * @author yuyang + * @date 2022/1/6 14:33 + */ +@Data +public class XhpcSettingConfig extends BaseEntity { + + /** + * 支付设置 + */ + private Long settingConfigId; + + /** + * 微信小程序id + */ + private String wxAppId; + + /** + * 微信小程序密钥 + */ + private String wxAppSecret; + /** + * 微信商户id + */ + private String wxMchId; + /** + * 微信商户平台Key + */ + private String wxMchKey; + /** + * 微信小程序支付地址 + */ + private String wxPaymentUrl; + /** + * 微信回调地址 + */ + private String wxCallbackUrl; + /** + * 向微信用户个人付款地址 + */ + private String wxTransfersUrl; + /** + * 微信证书 + */ + private String wxApiclientCertPem; + /** + * 微信证书 + */ + private String wxApiclientKeyPem; + /** + * 微信证书 + */ + private String wxAppCertPublicKey; + /** + * 支付宝appid + */ + private String zfbAppId; + /** + * 支付宝应用私钥 + */ + private String zfbPrivateKey; + /** + * 支付宝回调地址 + */ + private String zfbCallbackUrl; + /** + * 支付宝应用公钥证书路径 + */ + private String zfbAppCertPublicKey; + /** + * 支付宝公钥证书路径 + */ + private String zfbAlipayCertPublicKeyRsa; + /** + * 支付宝根证书路径 + */ + private String zfbAlipayRootCert; + /** + * 支付宝网管 + */ + private String zhbServerUrl; + /** + * 1微信 2支付宝 + */ + private Integer status; + /** + *删除标志(0代表存在 1代表删除) + */ + private Integer delFlag; + /** + *租户id + */ + private String tenantId; + +} diff --git a/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/mapper/XhpcCommonPaymentMapper.java b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/mapper/XhpcCommonPaymentMapper.java new file mode 100644 index 00000000..3f543b1a --- /dev/null +++ b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/mapper/XhpcCommonPaymentMapper.java @@ -0,0 +1,16 @@ +package com.xhpc.payment.mapper; + +import com.xhpc.payment.domain.XhpcSettingConfig; +import org.apache.ibatis.annotations.Param; + +/** + * @author yuyang + * @date 2022/1/6 14:31 + */ +public interface XhpcCommonPaymentMapper { + + /** + * 根据租户id获取支付信息 + */ + XhpcSettingConfig getXhpcSettingConfigTenantId(@Param("status") Integer status,@Param("tenantId") String tenantId); +} diff --git a/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/mapper/XhpcRechargeOrderMapper.java b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/mapper/XhpcRechargeOrderMapper.java index e0734153..ae67f17f 100644 --- a/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/mapper/XhpcRechargeOrderMapper.java +++ b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/mapper/XhpcRechargeOrderMapper.java @@ -1,6 +1,6 @@ package com.xhpc.payment.mapper; -import com.xhpc.payment.domain.XhpcRechargeOrder; +import com.xhpc.common.domain.XhpcRechargeOrder; import org.apache.ibatis.annotations.Param; import java.util.List; diff --git a/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/mapper/XhpcRefundOrderMapper.java b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/mapper/XhpcRefundOrderMapper.java index 0b82e388..7c619a6c 100644 --- a/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/mapper/XhpcRefundOrderMapper.java +++ b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/mapper/XhpcRefundOrderMapper.java @@ -1,6 +1,6 @@ package com.xhpc.payment.mapper; -import com.xhpc.payment.domain.XhpcRefundOrder; +import com.xhpc.common.domain.XhpcRefundOrder; import org.apache.ibatis.annotations.Param; import java.util.List; @@ -94,7 +94,7 @@ public interface XhpcRefundOrderMapper { * @param userId 用户id * @return 结果 */ - public Map getNotRefundOrder(@Param("userId") Long userId); + public Map getNotRefundOrder(@Param("userId") Long userId,@Param("userType")Integer userType,@Param("tenantId")String tenantId); /** diff --git a/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/mapper/XhpcUserAccountStatementMapper.java b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/mapper/XhpcUserAccountStatementMapper.java index 77b4c458..0738c2e7 100644 --- a/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/mapper/XhpcUserAccountStatementMapper.java +++ b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/mapper/XhpcUserAccountStatementMapper.java @@ -70,6 +70,6 @@ public interface XhpcUserAccountStatementMapper { * @param userId * @return */ - String getUserHistotyChargeOrder(@Param("userId") Long userId); + String getUserHistotyChargeOrder(@Param("userId") Long userId,@Param("source") Integer source,@Param("tenantId")String tenantId); } diff --git a/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/service/IXhpcCommonPayment.java b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/service/IXhpcCommonPayment.java new file mode 100644 index 00000000..a0b616b1 --- /dev/null +++ b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/service/IXhpcCommonPayment.java @@ -0,0 +1,15 @@ +package com.xhpc.payment.service; + +import com.xhpc.payment.domain.XhpcSettingConfig; + +/** + * @author yuyang + * @date 2022/1/6 14:29 + */ +public interface IXhpcCommonPayment { + + /** + * 根据租户id获取支付信息 + */ + XhpcSettingConfig getXhpcSettingConfigTenantId(Integer status,String tenantId); +} diff --git a/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/service/IXhpcRechargeOrderService.java b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/service/IXhpcRechargeOrderService.java index 11a43ceb..fefa9812 100644 --- a/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/service/IXhpcRechargeOrderService.java +++ b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/service/IXhpcRechargeOrderService.java @@ -1,6 +1,6 @@ package com.xhpc.payment.service; -import com.xhpc.payment.domain.XhpcRechargeOrder; +import com.xhpc.common.domain.XhpcRechargeOrder; import javax.servlet.http.HttpServletResponse; import java.io.IOException; @@ -76,7 +76,7 @@ public interface IXhpcRechargeOrderService { * @param type 充值渠道(1微信 2支付宝) * @return */ - public XhpcRechargeOrder addRechargeOrder(String appUserId, BigDecimal amount, String type, String orderNumber); + public XhpcRechargeOrder addRechargeOrder(String appUserId, BigDecimal amount, String type, String orderNumber,Integer userType); /** * 修改订单状态 充值订单 diff --git a/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/service/IXhpcRefundOrderService.java b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/service/IXhpcRefundOrderService.java index a05cbd02..d57e7c95 100644 --- a/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/service/IXhpcRefundOrderService.java +++ b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/service/IXhpcRefundOrderService.java @@ -1,8 +1,7 @@ package com.xhpc.payment.service; import com.xhpc.common.core.web.domain.AjaxResult; -import com.xhpc.payment.domain.XhpcRefundOrder; -import org.apache.ibatis.annotations.Param; +import com.xhpc.common.domain.XhpcRefundOrder; import javax.servlet.http.HttpServletResponse; import java.io.IOException; @@ -88,7 +87,7 @@ public interface IXhpcRefundOrderService { * @param userId 用户id * @return 结果 */ - public Map getNotRefundOrder(Long userId); + public Map getNotRefundOrder(Long userId,Integer userType,String tenantId); /** * 修改退款订单信息 diff --git a/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/service/impl/XhpcCommonPaymentImpl.java b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/service/impl/XhpcCommonPaymentImpl.java new file mode 100644 index 00000000..62945d05 --- /dev/null +++ b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/service/impl/XhpcCommonPaymentImpl.java @@ -0,0 +1,22 @@ +package com.xhpc.payment.service.impl; + +import com.xhpc.payment.domain.XhpcSettingConfig; +import com.xhpc.payment.mapper.XhpcCommonPaymentMapper; +import com.xhpc.payment.service.IXhpcCommonPayment; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +/** + * @author yuyang + * @date 2022/1/6 14:29 + */ +@Service +public class XhpcCommonPaymentImpl implements IXhpcCommonPayment { + + @Autowired + private XhpcCommonPaymentMapper xhpcCommonPaymentMapper; + @Override + public XhpcSettingConfig getXhpcSettingConfigTenantId(Integer status, String tenantId) { + return xhpcCommonPaymentMapper.getXhpcSettingConfigTenantId(status, tenantId); + } +} diff --git a/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/service/impl/XhpcRechargeOrderServiceImpl.java b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/service/impl/XhpcRechargeOrderServiceImpl.java index 0b80771c..106a3800 100644 --- a/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/service/impl/XhpcRechargeOrderServiceImpl.java +++ b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/service/impl/XhpcRechargeOrderServiceImpl.java @@ -4,8 +4,7 @@ import cn.hutool.core.io.IoUtil; import cn.hutool.poi.excel.ExcelUtil; import cn.hutool.poi.excel.ExcelWriter; import com.xhpc.common.core.constant.StatusConstants; -import com.xhpc.common.core.utils.StringUtils; -import com.xhpc.payment.domain.XhpcRechargeOrder; +import com.xhpc.common.domain.XhpcRechargeOrder; import com.xhpc.payment.mapper.XhpcRechargeOrderMapper; import com.xhpc.payment.service.IXhpcRechargeOrderService; import org.springframework.beans.factory.annotation.Autowired; @@ -131,13 +130,14 @@ public class XhpcRechargeOrderServiceImpl implements IXhpcRechargeOrderService { */ @Override @Transactional - public XhpcRechargeOrder addRechargeOrder(String appUserId, BigDecimal amount, String type, String orderNumber) { + public XhpcRechargeOrder addRechargeOrder(String appUserId, BigDecimal amount, String type, String orderNumber,Integer userType) { XhpcRechargeOrder xhpcRechargeOrder = new XhpcRechargeOrder(); xhpcRechargeOrder.setUserId(Long.parseLong(appUserId)); xhpcRechargeOrder.setAmount(amount); xhpcRechargeOrder.setRechargeOrderNumber(orderNumber); xhpcRechargeOrder.setType(Integer.parseInt(type)); xhpcRechargeOrder.setCreateTime(new Date()); + xhpcRechargeOrder.setSource(userType); xhpcRechargeOrderMapper.insert(xhpcRechargeOrder); return xhpcRechargeOrder; } diff --git a/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/service/impl/XhpcRefundAuditServiceImpl.java b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/service/impl/XhpcRefundAuditServiceImpl.java index eae17c61..1c8fad74 100644 --- a/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/service/impl/XhpcRefundAuditServiceImpl.java +++ b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/service/impl/XhpcRefundAuditServiceImpl.java @@ -3,7 +3,7 @@ package com.xhpc.payment.service.impl; import com.xhpc.common.core.constant.StatusConstants; import com.xhpc.common.core.web.domain.AjaxResult; import com.xhpc.payment.domain.XhpcRefundAudit; -import com.xhpc.payment.domain.XhpcRefundOrder; +import com.xhpc.common.domain.XhpcRefundOrder; import com.xhpc.payment.mapper.XhpcRefundAuditMapper; import com.xhpc.payment.mapper.XhpcRefundOrderMapper; import com.xhpc.payment.service.IXhpcRefundAuditService; diff --git a/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/service/impl/XhpcRefundOrderServiceImpl.java b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/service/impl/XhpcRefundOrderServiceImpl.java index 7f1fb66b..4551bfe4 100644 --- a/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/service/impl/XhpcRefundOrderServiceImpl.java +++ b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/service/impl/XhpcRefundOrderServiceImpl.java @@ -8,7 +8,7 @@ import com.xhpc.common.core.constant.StatusConstants; import com.xhpc.common.core.utils.StringUtils; import com.xhpc.common.core.web.domain.AjaxResult; import com.xhpc.payment.domain.XhpcAppUser; -import com.xhpc.payment.domain.XhpcRefundOrder; +import com.xhpc.common.domain.XhpcRefundOrder; import com.xhpc.payment.mapper.XhpcRefundOrderMapper; import com.xhpc.payment.mapper.XhpcUserAccountStatementMapper; import com.xhpc.payment.service.IXhpcRefundOrderService; @@ -171,8 +171,8 @@ public class XhpcRefundOrderServiceImpl implements IXhpcRefundOrderService { * @return 结果 */ @Override - public Map getNotRefundOrder(Long userId) { - return xhpcRefundOrderMapper.getNotRefundOrder(userId); + public Map getNotRefundOrder(Long userId,Integer userType,String tenantId) { + return xhpcRefundOrderMapper.getNotRefundOrder(userId,userType,tenantId); } /** diff --git a/xhpc-modules/xhpc-payment/src/main/resources/bootstrap.yml b/xhpc-modules/xhpc-payment/src/main/resources/bootstrap.yml index 339e2e7c..c399f305 100644 --- a/xhpc-modules/xhpc-payment/src/main/resources/bootstrap.yml +++ b/xhpc-modules/xhpc-payment/src/main/resources/bootstrap.yml @@ -28,7 +28,7 @@ logging: com.xhpc.order.mapper: debug ##获取微信openid地址 -WXGETJSCODE: "https://api.weixin.qq.com/sns/jscode2session?appid=wxb14ef93e9b7901f3&secret=b5c5672141b5930c30a1abee95a2dcbf&js_code=" +WXGETJSCODE: "https://api.weixin.qq.com/sns/jscode2session?appid=wxd0a48e00319ef8a7&secret=e26d9088b58e24af69411d5933cece47&js_code=" ##阿里云身份证验证地址 VERIFYCARD: "http://idenauthen.market.alicloudapi.com/idenAuthentication" #阿里云身份证验证地址appcode @@ -43,7 +43,7 @@ KEY: "sichuanxianghuakejiyouxiangongsi" WXPAYUNIFIEDORDER: "https://api.mch.weixin.qq.com/pay/unifiedorder" #微信支付回调地址 SERVERDOMAIN: "http://www.scxhua.cn/prod-api/xhpc-payment/wx/paymentCallback" -#微信小程序支付地址 +#向微信用户个人付款 WXTRANSFERS: "https://api.mch.weixin.qq.com/mmpaymkttransfers/promotion/transfers" #支付宝支付回调地址 diff --git a/xhpc-modules/xhpc-payment/src/main/resources/mapper/XhpcCommonPaymentMapper.xml b/xhpc-modules/xhpc-payment/src/main/resources/mapper/XhpcCommonPaymentMapper.xml new file mode 100644 index 00000000..9f095052 --- /dev/null +++ b/xhpc-modules/xhpc-payment/src/main/resources/mapper/XhpcCommonPaymentMapper.xml @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/xhpc-modules/xhpc-payment/src/main/resources/mapper/XhpcRechargeOrderMapper.xml b/xhpc-modules/xhpc-payment/src/main/resources/mapper/XhpcRechargeOrderMapper.xml index 0702afed..65890bde 100644 --- a/xhpc-modules/xhpc-payment/src/main/resources/mapper/XhpcRechargeOrderMapper.xml +++ b/xhpc-modules/xhpc-payment/src/main/resources/mapper/XhpcRechargeOrderMapper.xml @@ -4,7 +4,7 @@ "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> - + @@ -22,7 +22,7 @@ - INSERT INTO xhpc_recharge_order @@ -115,7 +115,7 @@ - + UPDATE xhpc_recharge_order user_id = #{userId}, diff --git a/xhpc-modules/xhpc-payment/src/main/resources/mapper/XhpcRefundOrderMapper.xml b/xhpc-modules/xhpc-payment/src/main/resources/mapper/XhpcRefundOrderMapper.xml index 9d644b08..99a16e8e 100644 --- a/xhpc-modules/xhpc-payment/src/main/resources/mapper/XhpcRefundOrderMapper.xml +++ b/xhpc-modules/xhpc-payment/src/main/resources/mapper/XhpcRefundOrderMapper.xml @@ -4,7 +4,7 @@ "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> - + @@ -28,7 +28,7 @@ - INSERT INTO xhpc_refund_order @@ -127,7 +127,7 @@ - + UPDATE xhpc_refund_order refund_order_number =#{refundOrderNumber}, @@ -153,7 +153,7 @@ WHERE refund_order_id = #{refundOrderId} - + UPDATE xhpc_refund_order status = #{status}, @@ -162,7 +162,7 @@ WHERE refund_order_id = #{refundOrderId} and examine_status = 0 - + UPDATE xhpc_refund_order examine_status = #{examineStatus}, @@ -233,6 +233,9 @@ and xro.type = #{type} + + and xro.user_id = #{userId} + ORDER BY xro.create_time DESC @@ -279,15 +282,20 @@ select xro.refund_order_id refundOrderId ,xro.refund_order_number refundOrderNumber, xro.alipay_id alipayId ,xro.open_id openId,xro.user_id userId,xro.amount, xro.type,xro.examine_status examineStatus,xro.`status`,xro.create_time createTime, - xro.source source,xau.phone,sdd.dict_label statusName,sdds.dict_label examineStatusName + xro.source source,sdd.dict_label statusName,sdds.dict_label examineStatusName from xhpc_refund_order xro - LEFT JOIN xhpc_app_user xau on xau.app_user_id = xro.user_id LEFT JOIN sys_dict_data sdd on sdd.`dict_type` = 'refund_order_status' and sdd.dict_value = xro.`status` LEFT JOIN sys_dict_data sdds on sdds.`dict_type` = 'refund_examine_status' and sdds.dict_value = xro.examine_status where xro.del_flag = 0 and xro.examine_status = 0 and xro.status = 0 - and xau.app_user_id = #{userId} + and xro.user_id = #{userId} + + + and xro.tenant_id = #{tenantId} + + + and xro.source = #{userType} ORDER BY xro.create_time DESC LIMIT 1 diff --git a/xhpc-modules/xhpc-payment/src/main/resources/mapper/XhpcUserAccountStatementMapper.xml b/xhpc-modules/xhpc-payment/src/main/resources/mapper/XhpcUserAccountStatementMapper.xml index 8e5f12d2..ce2dd28a 100644 --- a/xhpc-modules/xhpc-payment/src/main/resources/mapper/XhpcUserAccountStatementMapper.xml +++ b/xhpc-modules/xhpc-payment/src/main/resources/mapper/XhpcUserAccountStatementMapper.xml @@ -193,6 +193,6 @@ select serial_number as serialMumber from xhpc_terminal - where terminal_id =(select terminal_id from xhpc_charge_order where user_id = #{userId} and status=0 and del_flag =0 limit 1) + where terminal_id =(select terminal_id from xhpc_charge_order where user_id = #{userId} and source=#{source} and tenant_id=#{tenantId} and status=0 and del_flag =0 limit 1) \ No newline at end of file diff --git a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/mapper/XhpcMessageMapper.java b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/mapper/XhpcMessageMapper.java index a19c7938..0537b6c9 100644 --- a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/mapper/XhpcMessageMapper.java +++ b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/mapper/XhpcMessageMapper.java @@ -13,4 +13,8 @@ import org.apache.ibatis.annotations.Mapper; public interface XhpcMessageMapper { int insertItemsBy(XhpcMessage xhpcMessage); + +// void deleteByLastThreeMonth(String expireDate); + + void deleteByLastThreeMonth(String expireDate); } diff --git a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/controller/ChargingController.java b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/controller/ChargingController.java index 44ca9d91..adf450b4 100644 --- a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/controller/ChargingController.java +++ b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/controller/ChargingController.java @@ -1,5 +1,6 @@ package com.xhpc.pp.controller; +import cn.hutool.core.util.StrUtil; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.xhpc.common.api.PowerPileService; @@ -7,7 +8,10 @@ import com.xhpc.common.api.dto.ChargingStationDto; import com.xhpc.common.core.domain.R; import com.xhpc.common.core.utils.HttpUtils; import com.xhpc.common.data.down.StartChargingData; +import com.xhpc.common.enums.StationDeviceEnum; +import com.xhpc.pp.domain.XhpcDeviceMessage; import com.xhpc.pp.logic.RateModelRequestLogic; +import com.xhpc.pp.mapper.XhpcDeviceMessageMapper; import com.xhpc.pp.server.ChargingPileServer; import com.xhpc.pp.utils.HexUtils; import com.xhpc.pp.utils.security.CRCCalculator; @@ -20,6 +24,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; +import javax.annotation.Resource; import java.io.IOException; import java.time.Instant; import java.time.ZoneId; @@ -41,6 +46,10 @@ public class ChargingController { @Autowired private PowerPileService powerPileService; + + @Resource + XhpcDeviceMessageMapper deviceMessageMapper; + private static final List etable = Arrays.asList((new String[]{"离线", "故障"}).clone()); @PostMapping("test/pile/charging/order") @@ -328,6 +337,15 @@ public class ChargingController { String msg = HexUtils.toHex(data); msg = msg.concat(CRCCalculator.calcCrc(msg)); log.debug("start charging order[{}], send msg >>>> |{}|", startChargingData.getOrderNo(), msg); + + // 写入设备日志表数据 + XhpcDeviceMessage deviceMessage = new XhpcDeviceMessage(); + deviceMessage.setType(StationDeviceEnum.PILE.getCode()); + deviceMessage.setSerialNumber(startChargingData.getPileNo()); + deviceMessage.setRemark("平台下发开机指令"); + deviceMessage.setStatus(0); + deviceMessage.setContent(msg); + deviceMessageMapper.insertByDomain(deviceMessage); return HexUtils.toBytes(msg); } @@ -341,6 +359,14 @@ public class ChargingController { String msg = HexUtils.toHex(data); msg = msg.concat(CRCCalculator.calcCrc(msg)); log.debug("stop charging, send msg to terminal ({}) >>>> {}", connectorId, msg); + // 写入设备日志表数据 + XhpcDeviceMessage deviceMessage = new XhpcDeviceMessage(); + deviceMessage.setType(StationDeviceEnum.PILE.getCode()); + deviceMessage.setSerialNumber(StrUtil.sub(connectorId, 0, -2)); + deviceMessage.setRemark("平台下发停机指令"); + deviceMessage.setStatus(0); + deviceMessage.setContent(msg.toString()); + deviceMessageMapper.insertByDomain(deviceMessage); return HexUtils.toBytes(msg); } diff --git a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/domain/XhpcDeviceMessage.java b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/domain/XhpcDeviceMessage.java new file mode 100644 index 00000000..7f35d596 --- /dev/null +++ b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/domain/XhpcDeviceMessage.java @@ -0,0 +1,32 @@ +package com.xhpc.pp.domain; + + +import lombok.Data; + +import java.util.Date; + +@Data +public class XhpcDeviceMessage { + + private Long deviceMessageId; + + private String type; + + private String serialNumber; + + private String content; + + private String replyContent; + + private Integer status; + + private Date createTime; + + private String createBy; + + private Date updateTime; + + private String updateBy; + + private String remark; +} diff --git a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/BalanceUpdateReplyDataLogic.java b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/BalanceUpdateReplyDataLogic.java index bcef848f..ba79e1ae 100644 --- a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/BalanceUpdateReplyDataLogic.java +++ b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/BalanceUpdateReplyDataLogic.java @@ -2,6 +2,9 @@ package com.xhpc.pp.logic; import com.fasterxml.jackson.databind.ObjectMapper; import com.xhpc.common.data.up.BalanceUpdateReplyData; +import com.xhpc.common.enums.StationDeviceEnum; +import com.xhpc.pp.domain.XhpcDeviceMessage; +import com.xhpc.pp.mapper.XhpcDeviceMessageMapper; import com.xhpc.pp.tx.ServiceParameter; import com.xhpc.pp.tx.ServiceResult; import com.xhpc.pp.tx.logic.ServiceLogic; @@ -10,6 +13,7 @@ import org.slf4j.LoggerFactory; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Component; +import javax.annotation.Resource; import java.util.Map; @Lazy @@ -18,6 +22,9 @@ public class BalanceUpdateReplyDataLogic implements ServiceLogic { private static final Logger log = LoggerFactory.getLogger(BalanceUpdateReplyDataLogic.class); + @Resource + XhpcDeviceMessageMapper deviceMessageMapper; + @Override public ServiceResult service(ServiceParameter sp) throws Exception { @@ -25,6 +32,16 @@ public class BalanceUpdateReplyDataLogic implements ServiceLogic { ObjectMapper objectMapper = new ObjectMapper(); BalanceUpdateReplyData balanceUpdateReplyData = objectMapper.convertValue(req, BalanceUpdateReplyData.class); log.debug("balanceUpdateResult({}) [{}]", balanceUpdateReplyData.getPileNo(), balanceUpdateReplyData.getModifyResult()); + + String remark = "充电桩余额更新应答"; + XhpcDeviceMessage deviceMessage = new XhpcDeviceMessage(); + deviceMessage.setType(StationDeviceEnum.PILE.getCode()); + deviceMessage.setSerialNumber(sp.getPileNo()); + deviceMessage.setRemark(remark); + deviceMessage.setStatus(0); + deviceMessage.setContent((String) req.get("hex")); + deviceMessageMapper.insertByDomain(deviceMessage); + return new ServiceResult(false); } diff --git a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/BmsChargerInterruptDataLogic.java b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/BmsChargerInterruptDataLogic.java index 2388ca63..5b10bc89 100644 --- a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/BmsChargerInterruptDataLogic.java +++ b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/BmsChargerInterruptDataLogic.java @@ -1,7 +1,10 @@ package com.xhpc.pp.logic; +import com.xhpc.common.enums.StationDeviceEnum; import com.xhpc.mapper.XhpcMessageMapper; +import com.xhpc.pp.domain.XhpcDeviceMessage; import com.xhpc.pp.domain.XhpcMessage; +import com.xhpc.pp.mapper.XhpcDeviceMessageMapper; import com.xhpc.pp.tx.ServiceParameter; import com.xhpc.pp.tx.ServiceResult; import com.xhpc.pp.tx.logic.ServiceLogic; @@ -11,6 +14,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Component; +import javax.annotation.Resource; import java.util.Map; @Lazy @@ -20,16 +24,26 @@ public class BmsChargerInterruptDataLogic implements ServiceLogic { private static final Logger log = LoggerFactory.getLogger(BmsChargerInterruptDataLogic.class); @Autowired private XhpcMessageMapper xhpcMessageMapper; + @Resource + XhpcDeviceMessageMapper deviceMessageMapper; @Override public ServiceResult service(ServiceParameter sp) throws Exception { - + String remark = "充电桩与 BMS 充电阶段充电机中止报文"; Map req = sp.getParameters(); XhpcMessage msg = new XhpcMessage(); msg.setContent((String) req.get("hex")); msg.setChargeOrderNo((String) req.get("orderNo")); - msg.setRemark("充电桩与 BMS 充电阶段充电机中止报文"); + msg.setRemark(remark); xhpcMessageMapper.insertItemsBy(msg); + + XhpcDeviceMessage deviceMessage = new XhpcDeviceMessage(); + deviceMessage.setType(StationDeviceEnum.PILE.getCode()); + deviceMessage.setSerialNumber(sp.getPileNo()); + deviceMessage.setRemark(remark); + deviceMessage.setStatus(0); + deviceMessage.setContent((String) req.get("hex")); + deviceMessageMapper.insertByDomain(deviceMessage); return new ServiceResult(false); } diff --git a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/BmsChargingCompletedDataLogic.java b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/BmsChargingCompletedDataLogic.java index 77473385..8920327f 100644 --- a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/BmsChargingCompletedDataLogic.java +++ b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/BmsChargingCompletedDataLogic.java @@ -1,7 +1,10 @@ package com.xhpc.pp.logic; +import com.xhpc.common.enums.StationDeviceEnum; import com.xhpc.mapper.XhpcMessageMapper; +import com.xhpc.pp.domain.XhpcDeviceMessage; import com.xhpc.pp.domain.XhpcMessage; +import com.xhpc.pp.mapper.XhpcDeviceMessageMapper; import com.xhpc.pp.tx.ServiceParameter; import com.xhpc.pp.tx.ServiceResult; import com.xhpc.pp.tx.logic.ServiceLogic; @@ -11,6 +14,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Component; +import javax.annotation.Resource; import java.util.Map; @Lazy @@ -21,15 +25,28 @@ public class BmsChargingCompletedDataLogic implements ServiceLogic { @Autowired private XhpcMessageMapper xhpcMessageMapper; + @Resource + XhpcDeviceMessageMapper deviceMessageMapper; + @Override public ServiceResult service(ServiceParameter sp) throws Exception { - + String remark = "充电桩与 BMS 充电结束阶段报文"; Map req = sp.getParameters(); XhpcMessage msg = new XhpcMessage(); msg.setContent((String) req.get("hex")); msg.setChargeOrderNo((String) req.get("orderNo")); - msg.setRemark("充电桩与 BMS 充电结束阶段报文"); + msg.setRemark(remark); xhpcMessageMapper.insertItemsBy(msg); + + + XhpcDeviceMessage deviceMessage = new XhpcDeviceMessage(); + deviceMessage.setType(StationDeviceEnum.PILE.getCode()); + deviceMessage.setSerialNumber(sp.getPileNo()); + deviceMessage.setRemark(remark); + deviceMessage.setStatus(0); + deviceMessage.setContent((String) req.get("hex")); + deviceMessageMapper.insertByDomain(deviceMessage); + return new ServiceResult(false); } diff --git a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/BmsChargingConfigDataLogic.java b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/BmsChargingConfigDataLogic.java index 5ed1d189..a8107214 100644 --- a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/BmsChargingConfigDataLogic.java +++ b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/BmsChargingConfigDataLogic.java @@ -1,7 +1,10 @@ package com.xhpc.pp.logic; +import com.xhpc.common.enums.StationDeviceEnum; import com.xhpc.mapper.XhpcMessageMapper; +import com.xhpc.pp.domain.XhpcDeviceMessage; import com.xhpc.pp.domain.XhpcMessage; +import com.xhpc.pp.mapper.XhpcDeviceMessageMapper; import com.xhpc.pp.tx.ServiceParameter; import com.xhpc.pp.tx.ServiceResult; import com.xhpc.pp.tx.logic.ServiceLogic; @@ -11,6 +14,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Component; +import javax.annotation.Resource; import java.util.Map; @Lazy @@ -21,15 +25,28 @@ public class BmsChargingConfigDataLogic implements ServiceLogic { @Autowired private XhpcMessageMapper xhpcMessageMapper; + @Resource + XhpcDeviceMessageMapper deviceMessageMapper; + @Override public ServiceResult service(ServiceParameter sp) throws Exception { + String remark = "充电桩与 BMS 参数配置阶段报文"; Map req = sp.getParameters(); XhpcMessage msg = new XhpcMessage(); msg.setContent((String) req.get("hex")); msg.setChargeOrderNo((String) req.get("orderNo")); - msg.setRemark("充电桩与 BMS 参数配置阶段报文"); + msg.setRemark(remark); xhpcMessageMapper.insertItemsBy(msg); + + XhpcDeviceMessage deviceMessage = new XhpcDeviceMessage(); + deviceMessage.setType(StationDeviceEnum.PILE.getCode()); + deviceMessage.setSerialNumber(sp.getPileNo()); + deviceMessage.setRemark(remark); + deviceMessage.setStatus(0); + deviceMessage.setContent((String) req.get("hex")); + deviceMessageMapper.insertByDomain(deviceMessage); + return new ServiceResult(false); } diff --git a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/BmsChargingHandshakeDataLogic.java b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/BmsChargingHandshakeDataLogic.java index de34f523..6b25ec30 100644 --- a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/BmsChargingHandshakeDataLogic.java +++ b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/BmsChargingHandshakeDataLogic.java @@ -1,7 +1,10 @@ package com.xhpc.pp.logic; +import com.xhpc.common.enums.StationDeviceEnum; import com.xhpc.mapper.XhpcMessageMapper; +import com.xhpc.pp.domain.XhpcDeviceMessage; import com.xhpc.pp.domain.XhpcMessage; +import com.xhpc.pp.mapper.XhpcDeviceMessageMapper; import com.xhpc.pp.tx.ServiceParameter; import com.xhpc.pp.tx.ServiceResult; import com.xhpc.pp.tx.logic.ServiceLogic; @@ -11,6 +14,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Component; +import javax.annotation.Resource; import java.util.Map; @Lazy @@ -21,15 +25,28 @@ public class BmsChargingHandshakeDataLogic implements ServiceLogic { @Autowired private XhpcMessageMapper xhpcMessageMapper; + @Resource + XhpcDeviceMessageMapper deviceMessageMapper; + @Override public ServiceResult service(ServiceParameter sp) throws Exception { + String remark = "充电桩与 BMS 充电握手阶段报文"; Map req = sp.getParameters(); XhpcMessage msg = new XhpcMessage(); msg.setContent((String) req.get("hex")); msg.setChargeOrderNo((String) req.get("orderNo")); - msg.setRemark("充电桩与 BMS 充电握手阶段报文"); + msg.setRemark(remark); xhpcMessageMapper.insertItemsBy(msg); + + XhpcDeviceMessage deviceMessage = new XhpcDeviceMessage(); + deviceMessage.setType(StationDeviceEnum.PILE.getCode()); + deviceMessage.setSerialNumber(sp.getPileNo()); + deviceMessage.setRemark(remark); + deviceMessage.setStatus(0); + deviceMessage.setContent((String) req.get("hex")); + deviceMessageMapper.insertByDomain(deviceMessage); + return new ServiceResult(false); } diff --git a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/BmsErrorDataLogic.java b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/BmsErrorDataLogic.java index 8bf5f3f9..c335450d 100644 --- a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/BmsErrorDataLogic.java +++ b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/BmsErrorDataLogic.java @@ -1,7 +1,10 @@ package com.xhpc.pp.logic; +import com.xhpc.common.enums.StationDeviceEnum; import com.xhpc.mapper.XhpcMessageMapper; +import com.xhpc.pp.domain.XhpcDeviceMessage; import com.xhpc.pp.domain.XhpcMessage; +import com.xhpc.pp.mapper.XhpcDeviceMessageMapper; import com.xhpc.pp.tx.ServiceParameter; import com.xhpc.pp.tx.ServiceResult; import com.xhpc.pp.tx.logic.ServiceLogic; @@ -11,6 +14,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Component; +import javax.annotation.Resource; import java.util.Map; @Lazy @@ -20,16 +24,26 @@ public class BmsErrorDataLogic implements ServiceLogic { private static final Logger log = LoggerFactory.getLogger(BmsErrorDataLogic.class); @Autowired private XhpcMessageMapper xhpcMessageMapper; + @Resource + XhpcDeviceMessageMapper deviceMessageMapper; @Override public ServiceResult service(ServiceParameter sp) throws Exception { - + String remark = "充电桩与 BMS 充电错误报文"; Map req = sp.getParameters(); XhpcMessage msg = new XhpcMessage(); msg.setContent((String) req.get("hex")); msg.setChargeOrderNo((String) req.get("orderNo")); - msg.setRemark("充电桩与 BMS 充电错误报文"); + msg.setRemark(remark); xhpcMessageMapper.insertItemsBy(msg); + + XhpcDeviceMessage deviceMessage = new XhpcDeviceMessage(); + deviceMessage.setType(StationDeviceEnum.PILE.getCode()); + deviceMessage.setSerialNumber(sp.getPileNo()); + deviceMessage.setRemark(remark); + deviceMessage.setStatus(0); + deviceMessage.setContent((String) req.get("hex")); + deviceMessageMapper.insertByDomain(deviceMessage); return new ServiceResult(false); } diff --git a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/BmsInterruptDataLogic.java b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/BmsInterruptDataLogic.java index d54a5a4b..568f7af9 100644 --- a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/BmsInterruptDataLogic.java +++ b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/BmsInterruptDataLogic.java @@ -1,7 +1,10 @@ package com.xhpc.pp.logic; +import com.xhpc.common.enums.StationDeviceEnum; import com.xhpc.mapper.XhpcMessageMapper; +import com.xhpc.pp.domain.XhpcDeviceMessage; import com.xhpc.pp.domain.XhpcMessage; +import com.xhpc.pp.mapper.XhpcDeviceMessageMapper; import com.xhpc.pp.tx.ServiceParameter; import com.xhpc.pp.tx.ServiceResult; import com.xhpc.pp.tx.logic.ServiceLogic; @@ -11,6 +14,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Component; +import javax.annotation.Resource; import java.util.Map; @Lazy @@ -20,16 +24,27 @@ public class BmsInterruptDataLogic implements ServiceLogic { private static final Logger log = LoggerFactory.getLogger(BmsInterruptDataLogic.class); @Autowired private XhpcMessageMapper xhpcMessageMapper; + @Resource + XhpcDeviceMessageMapper deviceMessageMapper; @Override public ServiceResult service(ServiceParameter sp) throws Exception { - + String remark = "充电桩与 BMS 充电阶段 BMS 中止报文"; Map req = sp.getParameters(); XhpcMessage msg = new XhpcMessage(); msg.setContent((String) req.get("hex")); msg.setChargeOrderNo((String) req.get("orderNo")); - msg.setRemark("充电桩与 BMS 充电阶段 BMS 中止报文"); + msg.setRemark(remark); xhpcMessageMapper.insertItemsBy(msg); + + XhpcDeviceMessage deviceMessage = new XhpcDeviceMessage(); + deviceMessage.setType(StationDeviceEnum.PILE.getCode()); + deviceMessage.setSerialNumber(sp.getPileNo()); + deviceMessage.setRemark(remark); + deviceMessage.setStatus(0); + deviceMessage.setContent((String) req.get("hex")); + deviceMessageMapper.insertByDomain(deviceMessage); + return new ServiceResult(false); } diff --git a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/OfflineCardEraseReplyDataLogic.java b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/OfflineCardEraseReplyDataLogic.java index 603f0762..bb063596 100644 --- a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/OfflineCardEraseReplyDataLogic.java +++ b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/OfflineCardEraseReplyDataLogic.java @@ -1,5 +1,8 @@ package com.xhpc.pp.logic; +import com.xhpc.common.enums.StationDeviceEnum; +import com.xhpc.pp.domain.XhpcDeviceMessage; +import com.xhpc.pp.mapper.XhpcDeviceMessageMapper; import com.xhpc.pp.tx.ServiceParameter; import com.xhpc.pp.tx.ServiceResult; import com.xhpc.pp.tx.logic.ServiceLogic; @@ -8,16 +11,30 @@ import org.slf4j.LoggerFactory; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Component; +import javax.annotation.Resource; + @Lazy @Component("OfflineCardEraseReplyDataLogic") public class OfflineCardEraseReplyDataLogic implements ServiceLogic { private static Logger log = LoggerFactory.getLogger(OfflineCardEraseReplyDataLogic.class); + @Resource + XhpcDeviceMessageMapper deviceMessageMapper; + + @Override public ServiceResult service(ServiceParameter sp) throws Exception { //todo + String remark = "充电桩下发离线卡数据清除"; + XhpcDeviceMessage deviceMessage = new XhpcDeviceMessage(); + deviceMessage.setType(StationDeviceEnum.PILE.getCode()); + deviceMessage.setSerialNumber(sp.getPileNo()); + deviceMessage.setRemark(remark); + deviceMessage.setStatus(0); + deviceMessage.setContent((String) sp.getParameters().get("hex")); + deviceMessageMapper.insertByDomain(deviceMessage); return new ServiceResult(false); } diff --git a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/OfflineCardInquiryReplyDataLogic.java b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/OfflineCardInquiryReplyDataLogic.java index 4aaab37d..35cc7aac 100644 --- a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/OfflineCardInquiryReplyDataLogic.java +++ b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/OfflineCardInquiryReplyDataLogic.java @@ -1,5 +1,8 @@ package com.xhpc.pp.logic; +import com.xhpc.common.enums.StationDeviceEnum; +import com.xhpc.pp.domain.XhpcDeviceMessage; +import com.xhpc.pp.mapper.XhpcDeviceMessageMapper; import com.xhpc.pp.tx.ServiceParameter; import com.xhpc.pp.tx.ServiceResult; import com.xhpc.pp.tx.logic.ServiceLogic; @@ -8,16 +11,29 @@ import org.slf4j.LoggerFactory; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Component; +import javax.annotation.Resource; + @Lazy @Component("OfflineCardInquiryReplyDataLogic") public class OfflineCardInquiryReplyDataLogic implements ServiceLogic { private static Logger log = LoggerFactory.getLogger(OfflineCardInquiryReplyDataLogic.class); + @Resource + XhpcDeviceMessageMapper deviceMessageMapper; + @Override public ServiceResult service(ServiceParameter sp) throws Exception { //todo + String remark = "充电桩下发离线卡数据查询"; + XhpcDeviceMessage deviceMessage = new XhpcDeviceMessage(); + deviceMessage.setType(StationDeviceEnum.PILE.getCode()); + deviceMessage.setSerialNumber(sp.getPileNo()); + deviceMessage.setRemark(remark); + deviceMessage.setStatus(0); + deviceMessage.setContent((String) sp.getParameters().get("hex")); + deviceMessageMapper.insertByDomain(deviceMessage); return new ServiceResult(false); } diff --git a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/OfflineCardSyncReplyDataLogic.java b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/OfflineCardSyncReplyDataLogic.java index 77509aa9..58722743 100644 --- a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/OfflineCardSyncReplyDataLogic.java +++ b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/OfflineCardSyncReplyDataLogic.java @@ -2,6 +2,9 @@ package com.xhpc.pp.logic; import com.fasterxml.jackson.databind.ObjectMapper; import com.xhpc.common.data.up.OfflineCardSyncReplyData; +import com.xhpc.common.enums.StationDeviceEnum; +import com.xhpc.pp.domain.XhpcDeviceMessage; +import com.xhpc.pp.mapper.XhpcDeviceMessageMapper; import com.xhpc.pp.tx.ServiceParameter; import com.xhpc.pp.tx.ServiceResult; import com.xhpc.pp.tx.logic.ServiceLogic; @@ -10,6 +13,7 @@ import org.slf4j.LoggerFactory; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Component; +import javax.annotation.Resource; import java.util.Map; @Lazy @@ -18,6 +22,9 @@ public class OfflineCardSyncReplyDataLogic implements ServiceLogic { private static Logger log = LoggerFactory.getLogger(OfflineCardSyncReplyDataLogic.class); + @Resource + XhpcDeviceMessageMapper deviceMessageMapper; + @Override public ServiceResult service(ServiceParameter sp) throws Exception { @@ -25,6 +32,14 @@ public class OfflineCardSyncReplyDataLogic implements ServiceLogic { ObjectMapper objectMapper = new ObjectMapper(); OfflineCardSyncReplyData offlineCardSyncReplyData = objectMapper.convertValue(req, OfflineCardSyncReplyData.class); //todo + String remark = "充电桩下发离线卡数据同步应答"; + XhpcDeviceMessage deviceMessage = new XhpcDeviceMessage(); + deviceMessage.setType(StationDeviceEnum.PILE.getCode()); + deviceMessage.setSerialNumber(sp.getPileNo()); + deviceMessage.setRemark(remark); + deviceMessage.setStatus(0); + deviceMessage.setContent((String) req.get("hex")); + deviceMessageMapper.insertByDomain(deviceMessage); return new ServiceResult(false); } diff --git a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/PileConfigReplyDataLogic.java b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/PileConfigReplyDataLogic.java index 17b899aa..26ea5a1d 100644 --- a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/PileConfigReplyDataLogic.java +++ b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/PileConfigReplyDataLogic.java @@ -2,6 +2,9 @@ package com.xhpc.pp.logic; import com.fasterxml.jackson.databind.ObjectMapper; import com.xhpc.common.data.up.PileConfigReplyData; +import com.xhpc.common.enums.StationDeviceEnum; +import com.xhpc.pp.domain.XhpcDeviceMessage; +import com.xhpc.pp.mapper.XhpcDeviceMessageMapper; import com.xhpc.pp.tx.ServiceParameter; import com.xhpc.pp.tx.ServiceResult; import com.xhpc.pp.tx.logic.ServiceLogic; @@ -10,6 +13,7 @@ import org.slf4j.LoggerFactory; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Component; +import javax.annotation.Resource; import java.util.Map; @Lazy @@ -18,6 +22,9 @@ public class PileConfigReplyDataLogic implements ServiceLogic { private static Logger log = LoggerFactory.getLogger(PileConfigReplyDataLogic.class); + @Resource + XhpcDeviceMessageMapper deviceMessageMapper; + @Override public ServiceResult service(ServiceParameter sp) throws Exception { @@ -25,6 +32,14 @@ public class PileConfigReplyDataLogic implements ServiceLogic { ObjectMapper objectMapper = new ObjectMapper(); PileConfigReplyData pileConfigReplyData = objectMapper.convertValue(req, PileConfigReplyData.class); //todo + String remark = "充电桩工作参数设置"; + XhpcDeviceMessage deviceMessage = new XhpcDeviceMessage(); + deviceMessage.setType(StationDeviceEnum.PILE.getCode()); + deviceMessage.setSerialNumber(sp.getPileNo()); + deviceMessage.setRemark(remark); + deviceMessage.setStatus(0); + deviceMessage.setContent((String) req.get("hex")); + deviceMessageMapper.insertByDomain(deviceMessage); return new ServiceResult(false); } diff --git a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/PileStartChargingDataLogic.java b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/PileStartChargingDataLogic.java index 29d54cde..d6b0b655 100644 --- a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/PileStartChargingDataLogic.java +++ b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/PileStartChargingDataLogic.java @@ -2,6 +2,9 @@ package com.xhpc.pp.logic; import com.fasterxml.jackson.databind.ObjectMapper; import com.xhpc.common.data.up.PileStartChargingData; +import com.xhpc.common.enums.StationDeviceEnum; +import com.xhpc.pp.domain.XhpcDeviceMessage; +import com.xhpc.pp.mapper.XhpcDeviceMessageMapper; import com.xhpc.pp.tx.ServiceParameter; import com.xhpc.pp.tx.ServiceResult; import com.xhpc.pp.tx.logic.ServiceLogic; @@ -10,6 +13,7 @@ import org.slf4j.LoggerFactory; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Component; +import javax.annotation.Resource; import java.util.Map; @Lazy @@ -18,6 +22,9 @@ public class PileStartChargingDataLogic implements ServiceLogic { private static Logger log = LoggerFactory.getLogger(PileStartChargingDataLogic.class); + @Resource + XhpcDeviceMessageMapper deviceMessageMapper; + @Override public ServiceResult service(ServiceParameter sp) throws Exception { @@ -25,6 +32,14 @@ public class PileStartChargingDataLogic implements ServiceLogic { ObjectMapper objectMapper = new ObjectMapper(); PileStartChargingData pileStartChargingData = objectMapper.convertValue(req, PileStartChargingData.class); //todo + String remark = "充电桩主动申请起动充电"; + XhpcDeviceMessage deviceMessage = new XhpcDeviceMessage(); + deviceMessage.setType(StationDeviceEnum.PILE.getCode()); + deviceMessage.setSerialNumber(sp.getPileNo()); + deviceMessage.setRemark(remark); + deviceMessage.setStatus(0); + deviceMessage.setContent((String) req.get("hex")); + deviceMessageMapper.insertByDomain(deviceMessage); return new ServiceResult(false); } diff --git a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/PileTimeConfigReplyDataLogic.java b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/PileTimeConfigReplyDataLogic.java index f531f84b..8f3c89a0 100644 --- a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/PileTimeConfigReplyDataLogic.java +++ b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/PileTimeConfigReplyDataLogic.java @@ -3,6 +3,9 @@ package com.xhpc.pp.logic; import cn.hutool.core.date.DateUtil; import com.fasterxml.jackson.databind.ObjectMapper; import com.xhpc.common.data.up.PileTimeConfigReplyData; +import com.xhpc.common.enums.StationDeviceEnum; +import com.xhpc.pp.domain.XhpcDeviceMessage; +import com.xhpc.pp.mapper.XhpcDeviceMessageMapper; import com.xhpc.pp.tx.ServiceParameter; import com.xhpc.pp.tx.ServiceResult; import com.xhpc.pp.tx.logic.ServiceLogic; @@ -11,6 +14,7 @@ import org.slf4j.LoggerFactory; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Component; +import javax.annotation.Resource; import java.util.Map; import static cn.hutool.core.date.DatePattern.NORM_DATETIME_FORMAT; @@ -23,6 +27,9 @@ public class PileTimeConfigReplyDataLogic implements ServiceLogic { private static final Logger log = LoggerFactory.getLogger(PileTimeConfigReplyDataLogic.class); + @Resource + XhpcDeviceMessageMapper deviceMessageMapper; + @Override public ServiceResult service(ServiceParameter sp) throws Exception { @@ -36,6 +43,15 @@ public class PileTimeConfigReplyDataLogic implements ServiceLogic { cachePile.put("configTime", configTime); REDIS.setCacheMap(pk, cachePile); log.debug("({}) set time success√: [{}]", pileNo, configTime); + + String remark = "充电桩同步时钟"; + XhpcDeviceMessage deviceMessage = new XhpcDeviceMessage(); + deviceMessage.setType(StationDeviceEnum.PILE.getCode()); + deviceMessage.setSerialNumber(sp.getPileNo()); + deviceMessage.setRemark(remark); + deviceMessage.setStatus(0); + deviceMessage.setContent((String) req.get("hex")); + deviceMessageMapper.insertByDomain(deviceMessage); return new ServiceResult(false); } diff --git a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/RateModelConfigReplyDataLogic.java b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/RateModelConfigReplyDataLogic.java index cdceb07a..ba98ca30 100644 --- a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/RateModelConfigReplyDataLogic.java +++ b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/RateModelConfigReplyDataLogic.java @@ -3,6 +3,9 @@ package com.xhpc.pp.logic; import com.fasterxml.jackson.databind.ObjectMapper; import com.xhpc.common.api.dto.ChargingStationDto; import com.xhpc.common.data.up.PileConfigReplyData; +import com.xhpc.common.enums.StationDeviceEnum; +import com.xhpc.pp.domain.XhpcDeviceMessage; +import com.xhpc.pp.mapper.XhpcDeviceMessageMapper; import com.xhpc.pp.tx.ServiceParameter; import com.xhpc.pp.tx.ServiceResult; import com.xhpc.pp.tx.logic.ServiceLogic; @@ -11,6 +14,7 @@ import org.slf4j.LoggerFactory; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Component; +import javax.annotation.Resource; import java.util.Map; import static com.xhpc.common.data.redis.StaticBeanUtil.REDIS; @@ -22,6 +26,9 @@ public class RateModelConfigReplyDataLogic implements ServiceLogic { private static Logger log = LoggerFactory.getLogger(RateModelConfigReplyDataLogic.class); + @Resource + XhpcDeviceMessageMapper deviceMessageMapper; + @Override public ServiceResult service(ServiceParameter sp) throws Exception { @@ -29,6 +36,8 @@ public class RateModelConfigReplyDataLogic implements ServiceLogic { ObjectMapper objectMapper = new ObjectMapper(); PileConfigReplyData pileRateModelConfigReplyData = objectMapper.convertValue(req, PileConfigReplyData.class); String configResult = pileRateModelConfigReplyData.getConfigResult(); + + String result = FAIL; if (HEX_01.equals(configResult)) { // 确定设置成功的rateModelId 可能涉及协议修改 final String pkey = "pile:".concat(pileRateModelConfigReplyData.getPileNo()); @@ -36,9 +45,20 @@ public class RateModelConfigReplyDataLogic implements ServiceLogic { ChargingStationDto cacheStation = REDIS.getCacheObject("station:".concat(cachePile.get("stationId").toString())); cachePile.put("rateModelId", cacheStation.getRateModelId()); REDIS.setCacheMap(pkey, cachePile); - return new ServiceResult(OK); + result = OK; } - return new ServiceResult(FAIL); + + String remark = "充电桩收到计费模型应答"; + XhpcDeviceMessage deviceMessage = new XhpcDeviceMessage(); + deviceMessage.setType(StationDeviceEnum.PILE.getCode()); + deviceMessage.setSerialNumber(sp.getPileNo()); + deviceMessage.setRemark(remark); + deviceMessage.setStatus(0); + deviceMessage.setContent((String) req.get("hex")); + deviceMessage.setReplyContent(result); + deviceMessageMapper.insertByDomain(deviceMessage); + + return new ServiceResult(result); } } diff --git a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/RateModelRequestLogic.java b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/RateModelRequestLogic.java index a2deb45c..3a1a6f0d 100644 --- a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/RateModelRequestLogic.java +++ b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/RateModelRequestLogic.java @@ -4,6 +4,9 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.node.ObjectNode; import com.xhpc.common.api.dto.ChargingStationDto; import com.xhpc.common.data.redis.CacheRateModel; +import com.xhpc.common.enums.StationDeviceEnum; +import com.xhpc.pp.domain.XhpcDeviceMessage; +import com.xhpc.pp.mapper.XhpcDeviceMessageMapper; import com.xhpc.pp.tx.ServiceParameter; import com.xhpc.pp.tx.ServiceResult; import com.xhpc.pp.tx.logic.ServiceLogic; @@ -14,6 +17,7 @@ import org.slf4j.LoggerFactory; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Component; +import javax.annotation.Resource; import java.util.Map; import static com.xhpc.common.data.redis.StaticBeanUtil.REDIS; @@ -26,6 +30,9 @@ public class RateModelRequestLogic implements ServiceLogic { private static Logger log = LoggerFactory.getLogger(RateModelRequestLogic.class); + @Resource + XhpcDeviceMessageMapper deviceMessageMapper; + @Override public ServiceResult service(ServiceParameter sp) throws Exception { @@ -42,6 +49,16 @@ public class RateModelRequestLogic implements ServiceLogic { return new ServiceResult((byte[]) null, ServiceResult.FAIL, json); } String resultStr = translate(pileNo, stationRateModelId, "000A"); + + XhpcDeviceMessage deviceMessage = new XhpcDeviceMessage(); + deviceMessage.setType(StationDeviceEnum.PILE.getCode()); + deviceMessage.setSerialNumber(pileNo); + deviceMessage.setRemark("充电桩计费模型请求"); + deviceMessage.setStatus(0); + deviceMessage.setContent((String) req.get("hex")); + deviceMessage.setReplyContent(resultStr); + deviceMessageMapper.insertByDomain(deviceMessage); + return new ServiceResult(HexUtils.toBytes(resultStr), ServiceResult.OK); } diff --git a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/RateModelValidateLogic.java b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/RateModelValidateLogic.java index ea88cf00..236272b0 100644 --- a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/RateModelValidateLogic.java +++ b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/RateModelValidateLogic.java @@ -1,6 +1,9 @@ package com.xhpc.pp.logic; import com.xhpc.common.api.dto.ChargingStationDto; +import com.xhpc.common.enums.StationDeviceEnum; +import com.xhpc.pp.domain.XhpcDeviceMessage; +import com.xhpc.pp.mapper.XhpcDeviceMessageMapper; import com.xhpc.pp.tx.ServiceParameter; import com.xhpc.pp.tx.ServiceResult; import com.xhpc.pp.tx.logic.ServiceLogic; @@ -11,6 +14,7 @@ import org.slf4j.LoggerFactory; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Component; +import javax.annotation.Resource; import java.util.Map; import static cn.hutool.core.util.NumberUtil.isInteger; @@ -23,6 +27,9 @@ public class RateModelValidateLogic implements ServiceLogic { private static Logger log = LoggerFactory.getLogger(RateModelValidateLogic.class); + @Resource + XhpcDeviceMessageMapper deviceMessageMapper; + @Override public ServiceResult service(ServiceParameter sp) throws Exception { @@ -58,6 +65,16 @@ public class RateModelValidateLogic implements ServiceLogic { String resultStr = "680E".concat(seq).concat("0006").concat(pileNo).concat(String.format("%04X", csRateModelId)).concat(hexCode); resultStr = resultStr.concat(CRCCalculator.calcCrc(resultStr)); + + XhpcDeviceMessage deviceMessage = new XhpcDeviceMessage(); + deviceMessage.setType(StationDeviceEnum.PILE.getCode()); + deviceMessage.setSerialNumber(pileNo); + deviceMessage.setRemark("计费模型验证请求"); + deviceMessage.setStatus(0); + deviceMessage.setContent((String) req.get("hex")); + deviceMessage.setReplyContent(resultStr); + deviceMessageMapper.insertByDomain(deviceMessage); + return new ServiceResult(HexUtils.toBytes(resultStr), resultCode); } diff --git a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/RegisterLogic.java b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/RegisterLogic.java index 04ba2d57..f9205cb8 100644 --- a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/RegisterLogic.java +++ b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/RegisterLogic.java @@ -1,6 +1,9 @@ package com.xhpc.pp.logic; +import com.xhpc.common.enums.StationDeviceEnum; import com.xhpc.evcs.dto.ConnectorStatusInfo; +import com.xhpc.pp.domain.XhpcDeviceMessage; +import com.xhpc.pp.mapper.XhpcDeviceMessageMapper; import com.xhpc.pp.tx.ServiceParameter; import com.xhpc.pp.tx.ServiceResult; import com.xhpc.pp.tx.logic.ServiceLogic; @@ -11,6 +14,7 @@ import org.slf4j.LoggerFactory; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Component; +import javax.annotation.Resource; import java.util.Collection; import java.util.Map; import java.util.Set; @@ -27,6 +31,9 @@ public class RegisterLogic implements ServiceLogic { public static final String REGISTERED = "已注册"; private static final Logger log = LoggerFactory.getLogger(RegisterLogic.class); + @Resource + XhpcDeviceMessageMapper deviceMessageMapper; + @Override public ServiceResult service(ServiceParameter sp) throws Exception { @@ -76,6 +83,17 @@ public class RegisterLogic implements ServiceLogic { String seq = seqHex(skey); String resultStr = "680C".concat(seq).concat("0002").concat(pileNo).concat(hexCode); resultStr = resultStr.concat(CRCCalculator.calcCrc(resultStr)); + + // 写入设备日志表数据 + XhpcDeviceMessage deviceMessage = new XhpcDeviceMessage(); + deviceMessage.setType(StationDeviceEnum.PILE.getCode()); + deviceMessage.setSerialNumber(pileNo); + deviceMessage.setRemark("充电桩登录认证"); + deviceMessage.setStatus(0); + deviceMessage.setContent((String) req.get("hex")); + deviceMessage.setReplyContent(resultStr); + deviceMessageMapper.insertByDomain(deviceMessage); + return new ServiceResult(HexUtils.toBytes(resultStr), resultCode); } diff --git a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/RemoteRestartReplyDataLogic.java b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/RemoteRestartReplyDataLogic.java index 6bc07564..12137040 100644 --- a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/RemoteRestartReplyDataLogic.java +++ b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/RemoteRestartReplyDataLogic.java @@ -2,6 +2,9 @@ package com.xhpc.pp.logic; import com.fasterxml.jackson.databind.ObjectMapper; import com.xhpc.common.data.up.PileConfigReplyData; +import com.xhpc.common.enums.StationDeviceEnum; +import com.xhpc.pp.domain.XhpcDeviceMessage; +import com.xhpc.pp.mapper.XhpcDeviceMessageMapper; import com.xhpc.pp.tx.ServiceParameter; import com.xhpc.pp.tx.ServiceResult; import com.xhpc.pp.tx.logic.ServiceLogic; @@ -10,6 +13,7 @@ import org.slf4j.LoggerFactory; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Component; +import javax.annotation.Resource; import java.util.Map; @Lazy @@ -18,6 +22,9 @@ public class RemoteRestartReplyDataLogic implements ServiceLogic { private static Logger log = LoggerFactory.getLogger(RemoteRestartReplyDataLogic.class); + @Resource + XhpcDeviceMessageMapper deviceMessageMapper; + @Override public ServiceResult service(ServiceParameter sp) throws Exception { @@ -25,6 +32,15 @@ public class RemoteRestartReplyDataLogic implements ServiceLogic { ObjectMapper objectMapper = new ObjectMapper(); PileConfigReplyData pileConfigReplyData = objectMapper.convertValue(req, PileConfigReplyData.class); //todo + String remark = "充电桩收到远程重启应答"; + XhpcDeviceMessage deviceMessage = new XhpcDeviceMessage(); + deviceMessage.setType(StationDeviceEnum.PILE.getCode()); + deviceMessage.setSerialNumber(sp.getPileNo()); + deviceMessage.setRemark(remark); + deviceMessage.setStatus(0); + deviceMessage.setContent((String) req.get("hex")); + deviceMessageMapper.insertByDomain(deviceMessage); + return new ServiceResult(false); } diff --git a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/RemoteUpgradeReplyDataLogic.java b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/RemoteUpgradeReplyDataLogic.java index 92f9844b..e28856fa 100644 --- a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/RemoteUpgradeReplyDataLogic.java +++ b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/RemoteUpgradeReplyDataLogic.java @@ -2,6 +2,9 @@ package com.xhpc.pp.logic; import com.fasterxml.jackson.databind.ObjectMapper; import com.xhpc.common.data.up.PileConfigReplyData; +import com.xhpc.common.enums.StationDeviceEnum; +import com.xhpc.pp.domain.XhpcDeviceMessage; +import com.xhpc.pp.mapper.XhpcDeviceMessageMapper; import com.xhpc.pp.tx.ServiceParameter; import com.xhpc.pp.tx.ServiceResult; import com.xhpc.pp.tx.logic.ServiceLogic; @@ -10,6 +13,7 @@ import org.slf4j.LoggerFactory; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Component; +import javax.annotation.Resource; import java.util.Map; @Lazy @@ -18,6 +22,9 @@ public class RemoteUpgradeReplyDataLogic implements ServiceLogic { private static Logger log = LoggerFactory.getLogger(RemoteUpgradeReplyDataLogic.class); + @Resource + XhpcDeviceMessageMapper deviceMessageMapper; + @Override public ServiceResult service(ServiceParameter sp) throws Exception { @@ -25,6 +32,16 @@ public class RemoteUpgradeReplyDataLogic implements ServiceLogic { ObjectMapper objectMapper = new ObjectMapper(); PileConfigReplyData pileRateModelConfigReplyData = objectMapper.convertValue(req, PileConfigReplyData.class); //todo + + String remark = "充电桩收到远程更新应答"; + XhpcDeviceMessage deviceMessage = new XhpcDeviceMessage(); + deviceMessage.setType(StationDeviceEnum.PILE.getCode()); + deviceMessage.setSerialNumber(sp.getPileNo()); + deviceMessage.setRemark(remark); + deviceMessage.setStatus(0); + deviceMessage.setContent((String) req.get("hex")); + deviceMessageMapper.insertByDomain(deviceMessage); + return new ServiceResult(false); } diff --git a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/mapper/XhpcDeviceMessageMapper.java b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/mapper/XhpcDeviceMessageMapper.java new file mode 100644 index 00000000..a0f2fb54 --- /dev/null +++ b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/mapper/XhpcDeviceMessageMapper.java @@ -0,0 +1,14 @@ +package com.xhpc.pp.mapper; + + +import com.xhpc.pp.domain.XhpcDeviceMessage; +import org.apache.ibatis.annotations.Mapper; + +@Mapper +public interface XhpcDeviceMessageMapper { + + int insertByDomain(XhpcDeviceMessage xhpcDeviceMessage); + + + void deleteByLastThreeMonth(String expireDate); +} diff --git a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/server/HBCheckTask.java b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/server/HBCheckTask.java index f3f0ebcf..6fc1d521 100644 --- a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/server/HBCheckTask.java +++ b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/server/HBCheckTask.java @@ -1,8 +1,14 @@ package com.xhpc.pp.server; +import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSON; +import com.xhpc.common.enums.StationDeviceEnum; +import com.xhpc.pp.domain.XhpcDeviceMessage; +import com.xhpc.pp.mapper.XhpcDeviceMessageMapper; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; +import javax.annotation.Resource; import java.util.Calendar; import java.util.Map; import java.util.Set; @@ -15,6 +21,9 @@ import static com.xhpc.pp.logic.RegisterLogic.DISCONNECTED; @Component public class HBCheckTask { + @Resource + XhpcDeviceMessageMapper deviceMessageMapper; + @Scheduled(fixedRate = 10000) protected void run() { @@ -29,6 +38,16 @@ public class HBCheckTask { cacheGun.put("statusInt", OFF_LINE); cacheGun.put("status", DISCONNECTED); REDIS.setCacheMap(gunkey, cacheGun); + + XhpcDeviceMessage deviceMessage = new XhpcDeviceMessage(); + deviceMessage.setType(StationDeviceEnum.PILE.getCode()); + + String pileId= StrUtil.sub(gunkey.substring(gunkey.lastIndexOf(":") + 1), 0, -2); + deviceMessage.setSerialNumber(pileId); + deviceMessage.setContent(JSON.toJSONString(cacheGun)); + deviceMessage.setStatus(0); + deviceMessage.setRemark("充电桩心跳掉线"); + deviceMessageMapper.insertByDomain(deviceMessage); } } } diff --git a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/server/MessageCLeanTask.java b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/server/MessageCLeanTask.java new file mode 100644 index 00000000..9110b6ef --- /dev/null +++ b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/server/MessageCLeanTask.java @@ -0,0 +1,29 @@ +package com.xhpc.pp.server; + + +import cn.hutool.core.convert.Convert; +import com.xhpc.common.util.DateUtil; +import com.xhpc.mapper.XhpcMessageMapper; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Component; + +import javax.annotation.Resource; +import java.util.Date; + +@Component +public class MessageCLeanTask { + + @Resource + XhpcMessageMapper messageMapper; + + /** + * 每天定时清理message表三个月前的数据 + */ + @Scheduled(cron = "0 0 05 1/1 * ?") + private void run(){ + + String expireDate = DateUtil.date2String(DateUtil.addDay(new Date(), -90), DateUtil.DATE_FORMAT_DATE_TIME) ; + messageMapper.deleteByLastThreeMonth(expireDate); + + } +} diff --git a/xhpc-modules/xhpc-power-pile/src/main/resources/bootstrap.yml b/xhpc-modules/xhpc-power-pile/src/main/resources/bootstrap.yml index 8c12f14b..df3a5bc9 100644 --- a/xhpc-modules/xhpc-power-pile/src/main/resources/bootstrap.yml +++ b/xhpc-modules/xhpc-power-pile/src/main/resources/bootstrap.yml @@ -18,10 +18,10 @@ spring: nacos: discovery: # 服务注册地址 - server-addr: 127.0.0.1:8848 + server-addr: 172.31.183.135:8848 config: # 配置中心地址 - server-addr: 127.0.0.1:8848 + server-addr: 172.31.183.135:8848 # 配置文件格式 file-extension: yml # 共享配置 diff --git a/xhpc-modules/xhpc-power-pile/src/main/resources/mapper/XhpcDeviceMessageMapper.xml b/xhpc-modules/xhpc-power-pile/src/main/resources/mapper/XhpcDeviceMessageMapper.xml new file mode 100644 index 00000000..e454c7c6 --- /dev/null +++ b/xhpc-modules/xhpc-power-pile/src/main/resources/mapper/XhpcDeviceMessageMapper.xml @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + + + + + + + insert into xhpc_device_message( + type, + serial_number, + content, + reply_content, + status, + create_by, + remark, + update_by, + create_time, + update_time + )values( + #{type}, + #{serialNumber}, + #{content}, + #{replyContent}, + #{status}, + #{createBy}, + #{remark}, + #{updateBy}, + sysdate(), + sysdate() + ) + + + + delete from xhpc_message + where create_time #{expireDate}; + + diff --git a/xhpc-modules/xhpc-power-pile/src/main/resources/mapper/XhpcMessageMapper.xml b/xhpc-modules/xhpc-power-pile/src/main/resources/mapper/XhpcMessageMapper.xml index f6baafcb..c0687249 100644 --- a/xhpc-modules/xhpc-power-pile/src/main/resources/mapper/XhpcMessageMapper.xml +++ b/xhpc-modules/xhpc-power-pile/src/main/resources/mapper/XhpcMessageMapper.xml @@ -38,4 +38,9 @@ sysdate() ) + + + delete from xhpc_message + where create_time #{expireDate}; + diff --git a/xhpc-modules/xhpc-tradebill/src/main/java/com/xhpc/tradebill/controller/CommonController.java b/xhpc-modules/xhpc-tradebill/src/main/java/com/xhpc/tradebill/controller/CommonController.java index 1ccf7dc0..8eb09059 100644 --- a/xhpc-modules/xhpc-tradebill/src/main/java/com/xhpc/tradebill/controller/CommonController.java +++ b/xhpc-modules/xhpc-tradebill/src/main/java/com/xhpc/tradebill/controller/CommonController.java @@ -29,7 +29,7 @@ public class CommonController extends BaseController { return AjaxResult.success(commonService.ossUpload(domain)); } - @Log(title = "上传对账单(OSS方式)", businessType = BusinessType.INSERT) + @Log(title = "上传对账单(文件方式)", businessType = BusinessType.INSERT) @PostMapping("/file/upload") public AjaxResult fileUpload(MultipartFile file, int type) throws Exception { if (file ==null || type < 1){ diff --git a/xhpc-modules/xhpc-tradebill/src/main/java/com/xhpc/tradebill/domain/XhpcTradebillUploadRecordDomain.java b/xhpc-modules/xhpc-tradebill/src/main/java/com/xhpc/tradebill/domain/XhpcTradebillUploadRecordDomain.java index 96e6f219..47219b5f 100644 --- a/xhpc-modules/xhpc-tradebill/src/main/java/com/xhpc/tradebill/domain/XhpcTradebillUploadRecordDomain.java +++ b/xhpc-modules/xhpc-tradebill/src/main/java/com/xhpc/tradebill/domain/XhpcTradebillUploadRecordDomain.java @@ -41,6 +41,8 @@ public class XhpcTradebillUploadRecordDomain implements Serializable { private Integer checkedCount; + private String tenantId; + private static final long serialVersionUID = 1L; } \ No newline at end of file diff --git a/xhpc-modules/xhpc-tradebill/src/main/java/com/xhpc/tradebill/service/CommonService.java b/xhpc-modules/xhpc-tradebill/src/main/java/com/xhpc/tradebill/service/CommonService.java index a61ad5af..3cd69133 100644 --- a/xhpc-modules/xhpc-tradebill/src/main/java/com/xhpc/tradebill/service/CommonService.java +++ b/xhpc-modules/xhpc-tradebill/src/main/java/com/xhpc/tradebill/service/CommonService.java @@ -1,7 +1,6 @@ package com.xhpc.tradebill.service; -import com.xhpc.tradebill.domain.XhpcTradebillPaymentCheckRecordDomain; import com.xhpc.tradebill.domain.XhpcTradebillUploadRecordDomain; import org.springframework.web.multipart.MultipartFile; diff --git a/xhpc-modules/xhpc-tradebill/src/main/resources/mapper/XhpcTradebillUploadRecordMapper.xml b/xhpc-modules/xhpc-tradebill/src/main/resources/mapper/XhpcTradebillUploadRecordMapper.xml index 922f5f99..75cfec26 100644 --- a/xhpc-modules/xhpc-tradebill/src/main/resources/mapper/XhpcTradebillUploadRecordMapper.xml +++ b/xhpc-modules/xhpc-tradebill/src/main/resources/mapper/XhpcTradebillUploadRecordMapper.xml @@ -17,10 +17,11 @@ + id, create_time, create_by, update_time, update_by, `source`, file_name, url, `type`, - `status`, del_flag, success_count, fail_count, uncheck_count, checked_count + `status`, del_flag, success_count, fail_count, uncheck_count, checked_count, tenant_id @@ -62,12 +63,12 @@ update_by, `source`, file_name, url, `type`, `status`, del_flag, success_count, fail_count, - uncheck_count, checked_count) + uncheck_count, checked_count, tenant_id) values (now(), #{createBy,jdbcType=VARCHAR}, now(), #{updateBy,jdbcType=VARCHAR}, #{source,jdbcType=VARCHAR}, #{fileName,jdbcType=VARCHAR}, #{url,jdbcType=VARCHAR}, #{type,jdbcType=SMALLINT}, #{status,jdbcType=SMALLINT}, #{delFlag,jdbcType=SMALLINT}, #{successCount,jdbcType=INTEGER}, #{failCount,jdbcType=INTEGER}, - #{uncheckCount,jdbcType=INTEGER}, #{checkedCount,jdbcType=INTEGER}) + #{uncheckCount,jdbcType=INTEGER}, #{checkedCount,jdbcType=INTEGER}, #{tenantId, jdbcType=VARCHAR}) insert into xhpc_tradebill_upload_record @@ -110,6 +111,9 @@ checked_count, + + tenant_id, + now(), @@ -150,6 +154,9 @@ #{checkedCount,jdbcType=INTEGER}, + + #{tenantId, jdbcType=VARCHAR}, + diff --git a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/aspect/UserDaoAspect.java b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/aspect/UserDaoAspect.java index c63e46d4..df932d4a 100644 --- a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/aspect/UserDaoAspect.java +++ b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/aspect/UserDaoAspect.java @@ -121,7 +121,9 @@ public class UserDaoAspect { BeanUtils.setProperty(arg, UPDATE_TIME, date); } - BeanUtils.setProperty(arg, TENANT_ID, loginUser.getTenantId()); + if (isProperty(arg, TENANT_ID) && StringUtils.isEmpty(BeanUtils.getProperty(arg, TENANT_ID))) { + BeanUtils.setProperty(arg, TENANT_ID, loginUser.getTenantId()); + } } } } catch (Exception e) { diff --git a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/controller/XhpcAppUserController.java b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/controller/XhpcAppUserController.java index 84cc89dc..146449dc 100644 --- a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/controller/XhpcAppUserController.java +++ b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/controller/XhpcAppUserController.java @@ -135,7 +135,7 @@ public class XhpcAppUserController extends BaseController { @ApiOperation("小程序用户详情") @GetMapping("/appInfo") public AjaxResult appInfo(HttpServletRequest request) { - return AjaxResult.success(iXhpcAppUserUserService.appInfo(request)); + return iXhpcAppUserUserService.appInfo(request); } /** @@ -287,7 +287,6 @@ public class XhpcAppUserController extends BaseController { @ApiOperation("注销账号") @PostMapping("/logout") public R logout(String phone, String code) { - return iXhpcAppUserUserService.logout(phone, code); } @@ -308,4 +307,22 @@ public class XhpcAppUserController extends BaseController { return R.fail(HttpStatus.ERROR_STATUS, "修改失败"); } + /** + * 设置小程序用户电池保护 + * @param + */ + @ApiOperation("设置小程序用户电池保护") + @PostMapping("/batteryProtect") + public R batteryProtect(HttpServletRequest request,@RequestBody Map map) { + if(map !=null){ + + Integer soc = Integer.parseInt(map.get("soc").toString()); + Integer socProtect = Integer.parseInt(map.get("socProtect").toString()); + Integer userType = Integer.parseInt(map.get("userType").toString()); + return iXhpcAppUserUserService.batteryProtect(request,soc,socProtect,userType); + } + return R.fail(HttpStatus.ERROR_STATUS, "修改失败"); + } + + } diff --git a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/controller/XhpcCommonController.java b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/controller/XhpcCommonController.java index e9f532e4..3280d413 100644 --- a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/controller/XhpcCommonController.java +++ b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/controller/XhpcCommonController.java @@ -9,6 +9,8 @@ import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import java.math.BigDecimal; + /** * 公共的内 * @author yuyang @@ -26,7 +28,7 @@ public class XhpcCommonController extends BaseController { * @param phone * @param userId * @param userType - * @param SerialNumber 桩号 + * @param serialNumber 桩号 * @return */ @GetMapping(value = "/getUser") @@ -35,13 +37,13 @@ public class XhpcCommonController extends BaseController { if(phone !=null || "".equals(phone)){ if(!UserTypeUtil.COMMUNIT.equals(phone.substring(0,2)) && !UserTypeUtil.CUSTOMERS.equals(phone.substring(0,2))){ //C端用户 - return AjaxResult.success(xhpcCommonService.getLandUser(phone,null,0,serialNumber,tenantId)); + return AjaxResult.success(xhpcCommonService.getLandUser(phone,null,UserTypeUtil.USER_TYPE,serialNumber,tenantId)); }else if (UserTypeUtil.COMMUNIT.equals(phone.substring(0,2))){ //社区用户 - return AjaxResult.success(xhpcCommonService.getLandUser(phone,null,2,serialNumber,tenantId)); + return AjaxResult.success(xhpcCommonService.getLandUser(phone,null,UserTypeUtil.COMMUNIT_TYPE,serialNumber,tenantId)); }else if (UserTypeUtil.CUSTOMERS.equals(phone.substring(0,2))){ //大客户用户 - return AjaxResult.success(xhpcCommonService.getLandUser(phone,null,3,serialNumber,tenantId)); + return AjaxResult.success(xhpcCommonService.getLandUser(phone,null,UserTypeUtil.CUSTOMERS_TYPE,serialNumber,tenantId)); } }else{ return AjaxResult.success(xhpcCommonService.getLandUser(null,userId,userType,serialNumber,tenantId)); @@ -50,8 +52,20 @@ public class XhpcCommonController extends BaseController { } /** - * 修改用户信息 + * 根据用户类型,用户id,充值记录,增加流水 + * @param money 充值金额 + * @param userId 充值用户 + * @param userType 用户类型 + * @param tenantId 租户id + * @param type 充值渠道(1微信 2支付宝 3平台) + * @param status 1 充值 2退款 + * @param remark 备注 + * @return */ + @GetMapping(value = "/insertUserBalance") + public AjaxResult insertUserBalance(BigDecimal money, Long userId, Integer userType, String tenantId, Integer type, Integer status,String remark,Long moneyOrderId) { + return xhpcCommonService.insertUserBalance(money,userId,userType,tenantId,type,status,remark,moneyOrderId); + } } diff --git a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/controller/XhpcCustomersController.java b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/controller/XhpcCustomersController.java index d38ce91f..a372f622 100644 --- a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/controller/XhpcCustomersController.java +++ b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/controller/XhpcCustomersController.java @@ -9,6 +9,8 @@ import com.xhpc.user.service.IXhpcCustomersService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; import java.util.List; import java.util.Map; @@ -39,8 +41,8 @@ public class XhpcCustomersController extends BaseController { * @return */ @PostMapping(value = "/addCustomers") - public AjaxResult addCustomers(@RequestBody XhpcCustomers xhpcCustomers) { - return xhpcCustomersService.addCustomers(xhpcCustomers); + public AjaxResult addCustomers(HttpServletRequest request, @RequestBody XhpcCustomers xhpcCustomers) { + return xhpcCustomersService.addCustomers(request,xhpcCustomers); } /** diff --git a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/domain/XhpcAppUser.java b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/domain/XhpcAppUser.java index 0108aa8d..2da36b38 100644 --- a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/domain/XhpcAppUser.java +++ b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/domain/XhpcAppUser.java @@ -79,6 +79,12 @@ public class XhpcAppUser extends BaseEntity { private Integer soc; + private Integer isRefund; + + private Integer socProtect; + + private String tenantId; + public Long getAppUserId() { return appUserId; } @@ -185,4 +191,29 @@ public class XhpcAppUser extends BaseEntity { this.soc = soc; } + public Integer getIsRefund() { + return isRefund; + } + + public void setIsRefund(Integer isRefund) { + this.isRefund = isRefund; + } + + public Integer getSocProtect() { + return socProtect; + } + + public void setSocProtect(Integer socProtect) { + this.socProtect = socProtect; + } + + @Override + public String getTenantId() { + return tenantId; + } + + @Override + public void setTenantId(String tenantId) { + this.tenantId = tenantId; + } } diff --git a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/domain/XhpcCommunityPersonnel.java b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/domain/XhpcCommunityPersonnel.java index 5d8699f8..d4d62bf6 100644 --- a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/domain/XhpcCommunityPersonnel.java +++ b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/domain/XhpcCommunityPersonnel.java @@ -69,4 +69,14 @@ public class XhpcCommunityPersonnel extends BaseEntity { * 支付宝是否登录(0未登录 1已登录) */ private Integer alipayLogin; + + /** + * 充值渠道(1微信 2支付宝 3平台) + */ + private Integer rechargeType; + + /** + * 充值订单id、退款订单id + */ + private Long moneyOrderId; } diff --git a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/domain/XhpcCustomersPersonnel.java b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/domain/XhpcCustomersPersonnel.java index 2bf4cc10..8403471e 100644 --- a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/domain/XhpcCustomersPersonnel.java +++ b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/domain/XhpcCustomersPersonnel.java @@ -69,4 +69,12 @@ public class XhpcCustomersPersonnel extends BaseEntity { * 支付宝是否登录(0未登录 1已登录) */ private Integer alipayLogin; + /** + * 充值渠道(1微信 2支付宝 3平台) + */ + private Integer rechargeType; + /** + * 充值订单id、退款订单id + */ + private Long moneyOrderId; } diff --git a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/dto/MechanismDto.java b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/dto/MechanismDto.java index 2e18a86a..aea58ae8 100644 --- a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/dto/MechanismDto.java +++ b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/dto/MechanismDto.java @@ -11,7 +11,7 @@ import java.util.List; @Data public class MechanismDto { - private Integer id; + private String id; private String label; diff --git a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/mapper/MechanismMapper.java b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/mapper/MechanismMapper.java index b84cdff2..361e8768 100644 --- a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/mapper/MechanismMapper.java +++ b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/mapper/MechanismMapper.java @@ -1,5 +1,6 @@ package com.xhpc.user.mapper; +import com.xhpc.common.domain.XhpcRechargeOrder; import org.apache.ibatis.annotations.Param; import java.math.BigDecimal; @@ -73,5 +74,8 @@ public interface MechanismMapper { * @param date * @return */ - int addRechargeOrder(@Param("userId")Long userId, @Param("amount")BigDecimal amount, @Param("orderNumber")String orderNumber, @Param("type")Integer type, @Param("source")Integer source,@Param("date") String date); + int insertRechargeOrder(XhpcRechargeOrder xhpcRechargeOrder); + + + int insertUserAccount(@Param("userId")Long userId,@Param("amount")BigDecimal amount,@Param("remainingSum")BigDecimal remainingSum,@Param("chargeOrderId")Long chargeOrderId,@Param("rechargeOrderId")Long rechargeOrderId,@Param("refundOrderId")Long refundOrderId,@Param("type")Integer type,@Param("tenantId")String tenantId,@Param("source")Integer source); } diff --git a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/mapper/XhpcAppUserMapper.java b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/mapper/XhpcAppUserMapper.java index 1b628587..6d28be21 100644 --- a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/mapper/XhpcAppUserMapper.java +++ b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/mapper/XhpcAppUserMapper.java @@ -75,8 +75,9 @@ public interface XhpcAppUserMapper { int updateUserIsRefund(@Param("userId")Long userId, @Param("isRefund")Integer isRefund); - int updateCommunityIsRefund(@Param("userId")Long userId, @Param("isRefund")Integer isRefund); + int updateCommunityIsRefund(@Param("userId")Long userId, @Param("isRefund")Integer isRefund, @Param("socProtect")Integer socProtect, @Param("soc")Integer soc); + int updateCustomersSocProtect(@Param("userId")Long userId, @Param("socProtect")Integer socProtect, @Param("soc")Integer soc); /** * 记录登录用户的最后一次数据 */ diff --git a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/IMechanismService.java b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/IMechanismService.java index 854bf4d2..c1111911 100644 --- a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/IMechanismService.java +++ b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/IMechanismService.java @@ -35,7 +35,26 @@ public interface IMechanismService { * @param userId 充值的用户 * @param source 0 C端用户 1 流量方用户 2社区用户 3B端用户 * @param amount 金额 + * @param remainingSum 剩余金额 + * @param type 充值渠道(1微信 2支付宝 3平台) * @return */ - int addRechargeOrder(Long userId,Integer source, BigDecimal amount); + Long addRechargeOrder(Long userId,Integer source, BigDecimal amount,BigDecimal remainingSum,Integer type); + + + /** + * 用户流水记录 + * @param userId 用户id + * @param amount 流水金额 + * @param remainingSum 余额 + * @param chargeOrderId 充电订单id + * @param rechargeOrderId 充值订单id + * @param refundOrderId 退款订单id + * @param type 1充值 2退款 3充电 + * @param tenantId 租户id + * @param source 订单来源(0 C端用户 1 流量方用户 2社区用户 3B端用户) + * @return + */ + int insertUserAccount(Long userId,BigDecimal amount,BigDecimal remainingSum,Long chargeOrderId,Long rechargeOrderId,Long refundOrderId,Integer type,String tenantId,Integer source); + } diff --git a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/IXhpcAppUserUserService.java b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/IXhpcAppUserUserService.java index 15814e66..42812998 100644 --- a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/IXhpcAppUserUserService.java +++ b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/IXhpcAppUserUserService.java @@ -104,4 +104,10 @@ public interface IXhpcAppUserUserService { * @return */ public R updateIsRefund(Long userId, Integer userType,Integer isRefund); + + /** + * 设置小程序用户电池保护 + * @return + */ + public R batteryProtect(HttpServletRequest request, Integer soc,Integer socProtect,Integer userType); } diff --git a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/IXhpcCommonService.java b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/IXhpcCommonService.java index 3cf0b017..a93e20b3 100644 --- a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/IXhpcCommonService.java +++ b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/IXhpcCommonService.java @@ -1,5 +1,8 @@ package com.xhpc.user.service; +import com.xhpc.common.core.web.domain.AjaxResult; + +import java.math.BigDecimal; import java.util.Map; /** @@ -12,4 +15,17 @@ public interface IXhpcCommonService { * 根据用户手机号获取用户信息 */ Map getLandUser(String phone,Long userId,Integer type,String serialNumber,String tenantId); + + /** + * 根据用户类型,用户id,充值记录,增加流水 + * @param money 充值金额 + * @param userId 充值用户 + * @param userType 用户类型 + * @param tenantId 租户id + * @param type 充值渠道(1微信 2支付宝 3平台) + * @param status 1 充值 2退款 + * @param remark 备注 + * @return + */ + AjaxResult insertUserBalance(BigDecimal money, Long userId, Integer userType, String tenantId, Integer type,Integer status,String remark,Long moneyOrderId); } diff --git a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/IXhpcCommunityService.java b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/IXhpcCommunityService.java index 1f39401f..f1a12a81 100644 --- a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/IXhpcCommunityService.java +++ b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/IXhpcCommunityService.java @@ -90,7 +90,7 @@ public interface IXhpcCommunityService { void updateCommunityPersonnelStatus(XhpcCommunityPersonnel xhpcCommunityPersonnel); /** - * 社区人员状态改变 + * 充值 */ AjaxResult addRecharge(XhpcCommunityPersonnel xhpcCommunityPersonnel); diff --git a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/IXhpcCustomersService.java b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/IXhpcCustomersService.java index 6a6d86a3..a55526bc 100644 --- a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/IXhpcCustomersService.java +++ b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/IXhpcCustomersService.java @@ -4,6 +4,8 @@ import com.xhpc.common.core.web.domain.AjaxResult; import com.xhpc.user.domain.XhpcCustomers; import com.xhpc.user.domain.XhpcCustomersPersonnel; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; import java.util.List; import java.util.Map; @@ -27,7 +29,7 @@ public interface IXhpcCustomersService { * @param * @return */ - AjaxResult addCustomers(XhpcCustomers xhpcCustomers); + AjaxResult addCustomers(HttpServletRequest request, XhpcCustomers xhpcCustomers); /** * 删除大客户组树 diff --git a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/IMechanismServiceImpl.java b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/IMechanismServiceImpl.java index f73238fd..b83ca544 100644 --- a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/IMechanismServiceImpl.java +++ b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/IMechanismServiceImpl.java @@ -5,6 +5,9 @@ import com.xhpc.common.core.constant.StatusConstants; import com.xhpc.common.core.utils.SecurityUtils; import com.xhpc.common.core.utils.StringUtils; import com.xhpc.common.core.web.domain.AjaxResult; +import com.xhpc.common.domain.XhpcRechargeOrder; +import com.xhpc.common.domain.XhpcRefundOrder; +import com.xhpc.common.util.UserTypeUtil; import com.xhpc.user.dto.MechanismDto; import com.xhpc.user.mapper.MechanismMapper; import com.xhpc.user.service.IMechanismService; @@ -12,11 +15,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.math.BigDecimal; -import java.sql.Date; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; /** * @author yuyang @@ -69,9 +68,40 @@ public class IMechanismServiceImpl implements IMechanismService { } @Override - public int addRechargeOrder(Long userId, Integer source, BigDecimal amount) { + public Long addRechargeOrder(Long userId, Integer source, BigDecimal amount,BigDecimal remainingSum,Integer type) { String orderNumber = StringUtils.numFormat(userId, 1, StatusConstants.FLOWING_WATER_RECHARGE_TYPE); - return mechanismMapper.addRechargeOrder(userId,amount,orderNumber,3,source, DateUtil.date().toString()); + + XhpcRechargeOrder xhpcRechargeOrder =new XhpcRechargeOrder(); + xhpcRechargeOrder.setUserId(userId); + xhpcRechargeOrder.setRechargeOrderNumber(orderNumber); + xhpcRechargeOrder.setAmount(amount); + if(UserTypeUtil.RECHARGE_PT.equals(type)){ + xhpcRechargeOrder.setStatus(UserTypeUtil.RECHARGE_STATUS_ONE); + }else{ + xhpcRechargeOrder.setStatus(UserTypeUtil.RECHARGE_STATUS_ZERO); + } + xhpcRechargeOrder.setType(type); + xhpcRechargeOrder.setSource(source); + xhpcRechargeOrder.setCreateTime(new Date()); + mechanismMapper.insertRechargeOrder(xhpcRechargeOrder); + return xhpcRechargeOrder.getRechargeOrderId(); + } + + /** + * 用户流水记录 + * @param amount 流水金额 + * @param remainingSum 余额 + * @param chargeOrderId 充电订单id + * @param rechargeOrderId 充值订单id + * @param refundOrderId 退款订单id + * @param type 1充值 2退款 3充电 + * @param tenantId 租户id + * @param source 订单来源(0 C端用户 1 流量方用户 2社区用户 3B端用户) + * @return + */ + @Override + public int insertUserAccount(Long userId,BigDecimal amount,BigDecimal remainingSum,Long chargeOrderId,Long rechargeOrderId,Long refundOrderId,Integer type,String tenantId,Integer source) { + return mechanismMapper.insertUserAccount(userId, amount, remainingSum, chargeOrderId, rechargeOrderId, refundOrderId, type, tenantId, source); } @@ -89,7 +119,7 @@ public class IMechanismServiceImpl implements IMechanismService { for (Map map:list) { MechanismDto mechanismDto =new MechanismDto(); String code = map.get("code").toString(); - mechanismDto.setId(Integer.valueOf(code)); + mechanismDto.setId("Shen"+code); mechanismDto.setLabel(map.get("name").toString()); List mechanismCityList =new ArrayList<>(); //市 @@ -97,7 +127,7 @@ public class IMechanismServiceImpl implements IMechanismService { for (Map cityMap:cityList) { MechanismDto mechanismCity =new MechanismDto(); String codeCity = cityMap.get("code").toString(); - mechanismCity.setId(Integer.valueOf(codeCity)); + mechanismCity.setId("Shi"+codeCity); mechanismCity.setLabel(cityMap.get("name").toString()); List mechanismAreaList =new ArrayList<>(); //区 @@ -105,7 +135,7 @@ public class IMechanismServiceImpl implements IMechanismService { for (Map areaMap:areaList) { MechanismDto mechanismArea =new MechanismDto(); String codeArea = areaMap.get("code").toString(); - mechanismArea.setId(Integer.valueOf(codeArea)); + mechanismArea.setId("Qu"+codeArea); mechanismArea.setLabel(areaMap.get("name").toString()); List mechanismOperatorList =new ArrayList<>(); //运营商 @@ -113,7 +143,7 @@ public class IMechanismServiceImpl implements IMechanismService { for (Map operatorMap:operatorList) { MechanismDto mechanismOperator =new MechanismDto(); String operatorId = operatorMap.get("operatorId").toString(); - mechanismOperator.setId(Integer.valueOf(operatorId)); + mechanismOperator.setId("Yun"+operatorId); mechanismOperator.setLabel(operatorMap.get("name").toString()); List mechanismdataList =new ArrayList<>(); //场站 @@ -121,7 +151,7 @@ public class IMechanismServiceImpl implements IMechanismService { for (Map dataMap:dataList) { MechanismDto mechanismData =new MechanismDto(); String codeData = dataMap.get("chargingStationId").toString(); - mechanismData.setId(Integer.valueOf(codeData)); + mechanismData.setId(codeData); mechanismData.setLabel(dataMap.get("name").toString()); mechanismdataList.add(mechanismData); } @@ -151,7 +181,7 @@ public class IMechanismServiceImpl implements IMechanismService { for (Map operatorMap:operatorList) { MechanismDto mechanismOperator =new MechanismDto(); String operatorId = operatorMap.get("operatorId").toString(); - mechanismOperator.setId(Integer.valueOf(operatorId)); + mechanismOperator.setId("Yun"+operatorId); mechanismOperator.setLabel(operatorMap.get("name").toString()); List mechanismdataList =new ArrayList<>(); //场站 @@ -159,7 +189,7 @@ public class IMechanismServiceImpl implements IMechanismService { for (Map dataMap:dataList) { MechanismDto mechanismData =new MechanismDto(); String codeData = dataMap.get("chargingStationId").toString(); - mechanismData.setId(Integer.valueOf(codeData)); + mechanismData.setId(codeData); mechanismData.setLabel(dataMap.get("name").toString()); mechanismdataList.add(mechanismData); } @@ -184,7 +214,7 @@ public class IMechanismServiceImpl implements IMechanismService { for (Map operatorMap:operatorList) { MechanismDto mechanismOperator =new MechanismDto(); String operatorId = operatorMap.get("operatorId").toString(); - mechanismOperator.setId(Integer.valueOf(operatorId)); + mechanismOperator.setId("Yun"+operatorId); mechanismOperator.setLabel(operatorMap.get("name").toString()); List mechanismdataList =new ArrayList<>(); //省 @@ -192,7 +222,7 @@ public class IMechanismServiceImpl implements IMechanismService { for (Map map:list) { MechanismDto mechanismDto =new MechanismDto(); String code = map.get("code").toString(); - mechanismDto.setId(Integer.valueOf(code)); + mechanismDto.setId("Shen"+code); mechanismDto.setLabel(map.get("name").toString()); List mechanismCityList =new ArrayList<>(); //市 @@ -200,7 +230,7 @@ public class IMechanismServiceImpl implements IMechanismService { for (Map cityMap:cityList) { MechanismDto mechanismCity =new MechanismDto(); String codeCity = cityMap.get("code").toString(); - mechanismCity.setId(Integer.valueOf(codeCity)); + mechanismCity.setId("Shi"+codeCity); mechanismCity.setLabel(cityMap.get("name").toString()); List mechanismAreaList =new ArrayList<>(); //区 @@ -208,7 +238,7 @@ public class IMechanismServiceImpl implements IMechanismService { for (Map areaMap:areaList) { MechanismDto mechanismArea =new MechanismDto(); String codeArea = areaMap.get("code").toString(); - mechanismArea.setId(Integer.valueOf(codeArea)); + mechanismArea.setId("Qu"+codeArea); mechanismArea.setLabel(areaMap.get("name").toString()); List mechanismOperatorList =new ArrayList<>(); //场站 @@ -216,7 +246,7 @@ public class IMechanismServiceImpl implements IMechanismService { for (Map dataMap:dataList) { MechanismDto mechanismData =new MechanismDto(); String codeData = dataMap.get("chargingStationId").toString(); - mechanismData.setId(Integer.valueOf(codeData)); + mechanismData.setId(codeData); mechanismData.setLabel(dataMap.get("name").toString()); mechanismOperatorList.add(mechanismData); } diff --git a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/XhpcAppUserServiceImpl.java b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/XhpcAppUserServiceImpl.java index becb25b4..d527c3c7 100644 --- a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/XhpcAppUserServiceImpl.java +++ b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/XhpcAppUserServiceImpl.java @@ -358,7 +358,7 @@ public class XhpcAppUserServiceImpl implements IXhpcAppUserUserService { //添加最后一次登录数据 xhpcAppUserMapper.addUserLoginTime(appUser.getAppUserId(),username,userType,openId,Integer.valueOf(type),UserConstants.NO_LOGIN,tenantId); } - }else if(UserTypeUtil.COMMUNIT_TYPE==userType){ + }else if(UserTypeUtil.COMMUNIT_TYPE.equals(userType)){ if (StatusConstants.OPERATION_WX_TYPE.equals(type)) { xhpcAppUserMapper.updateCommunityPersonnel(userid,null,null,UserConstants.NO_LOGIN,null); } else { @@ -366,7 +366,7 @@ public class XhpcAppUserServiceImpl implements IXhpcAppUserUserService { } //添加最后一次登录数据 xhpcAppUserMapper.addUserLoginTime(userid,username,userType,openId,Integer.valueOf(type),UserConstants.NO_LOGIN,tenantId); - }else if(UserTypeUtil.CUSTOMERS_TYPE==userType){ + }else if(UserTypeUtil.CUSTOMERS_TYPE.equals(userType)){ if (StatusConstants.OPERATION_WX_TYPE.equals(type)) { xhpcAppUserMapper.updateCustomersPersonnel(userid,null,null,UserConstants.NO_LOGIN,null); } else { @@ -438,6 +438,13 @@ public class XhpcAppUserServiceImpl implements IXhpcAppUserUserService { map.put("guestbook","0"); map.put("version",version); map.put("servicePhone",servicePhone); + map.put("activity",1); + map.put("activitySize",1); + map.put("activityImg","https://www.scxhua.cn/static/img/logo1.8460b7f4.png"); + map.put("socSize",98); + map.put("socUser",80); + map.put("socProtect",1); + return AjaxResult.success(map); }else{ return AjaxResult.error("请重新登录"); @@ -487,7 +494,7 @@ public class XhpcAppUserServiceImpl implements IXhpcAppUserUserService { return R.fail(HttpStatus.ERROR_STATUS, "修改失败"); } }else if(userType==2){ - int i = xhpcAppUserMapper.updateCommunityIsRefund(userId, isRefund); + int i = xhpcAppUserMapper.updateCommunityIsRefund(userId, isRefund,null,null); if(i>0){ return R.ok(); }else{ @@ -496,4 +503,32 @@ public class XhpcAppUserServiceImpl implements IXhpcAppUserUserService { } return R.fail(HttpStatus.ERROR_STATUS, "参数错误"); } + + @Override + public R batteryProtect(HttpServletRequest request, Integer soc,Integer socProtect,Integer userType) { + LoginUser loginUser = logUserUtils.getLogUser(request); + Object version = redisService.getCacheObject("global:version"); + Object servicePhone = redisService.getCacheObject("global:phone"); + //根据不同的用户类型查询不同的信息 + Long userid = loginUser.getUserid(); + + R user = userTypeService.getUser(null, loginUser.getUserid(), loginUser.getUserType(), null,loginUser.getTenantId()); + if(user !=null && user.getData() !=null){ + Map map = (Map)user.getData(); + if(UserTypeUtil.USER_TYPE.equals(userType)){ + XhpcAppUser appUser = xhpcAppUserMapper.getAppUserByPhone(map.get("phone").toString()); + appUser.setSocProtect(socProtect); + appUser.setSoc(soc); + xhpcAppUserMapper.update(appUser); + }else if(UserTypeUtil.COMMUNIT_TYPE.equals(userType)){ + xhpcAppUserMapper.updateCommunityIsRefund(userid, null,socProtect,soc); + }else if(UserTypeUtil.CUSTOMERS_TYPE.equals(userType)){ + xhpcAppUserMapper.updateCustomersSocProtect(userid,socProtect,soc); + } + return R.fail(HttpStatus.ERROR_STATUS, "设置失败"); + } + return R.fail(HttpStatus.ERROR_STATUS, "设置失败"); + } + + } diff --git a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/XhpcCommonServiceImpl.java b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/XhpcCommonServiceImpl.java index 01555ce1..f97db2cf 100644 --- a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/XhpcCommonServiceImpl.java +++ b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/XhpcCommonServiceImpl.java @@ -1,11 +1,18 @@ package com.xhpc.user.service.impl; +import com.xhpc.common.core.web.domain.AjaxResult; +import com.xhpc.common.util.UserTypeUtil; +import com.xhpc.user.domain.XhpcCommunityPersonnel; +import com.xhpc.user.domain.XhpcCustomersPersonnel; import com.xhpc.user.mapper.XhpcCommonMapper; import com.xhpc.user.service.IXhpcCommonService; +import com.xhpc.user.service.IXhpcCommunityService; +import com.xhpc.user.service.IXhpcCustomersService; import org.checkerframework.checker.units.qual.A; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.math.BigDecimal; import java.util.HashMap; import java.util.Map; @@ -18,16 +25,58 @@ public class XhpcCommonServiceImpl implements IXhpcCommonService { @Autowired private XhpcCommonMapper xhpcCommonMapper; + @Autowired + private IXhpcCommunityService xhpcCommunityService; + @Autowired + private IXhpcCustomersService xhpcCustomersService; + @Override public Map getLandUser(String phone,Long userId, Integer type,String serialNumber,String tenantId) { - if(type==0){ + if(UserTypeUtil.USER_TYPE.equals(type)){ return xhpcCommonMapper.getAppUser(phone,userId,tenantId); - }else if(type==2){ + }else if(UserTypeUtil.COMMUNIT_TYPE.equals(type)){ return xhpcCommonMapper.getCommunityUser(phone,userId,serialNumber,tenantId); - }else if(type==3){ + }else if(UserTypeUtil.CUSTOMERS_TYPE.equals(type)){ return xhpcCommonMapper.getCustomersUser(phone,userId,serialNumber,tenantId); } return new HashMap<>(); } + + @Override + public AjaxResult insertUserBalance(BigDecimal money, Long userId, Integer userType, String tenantId, Integer type,Integer status,String remark,Long moneyOrderId) { + if(UserTypeUtil.USER_TYPE.equals(userType)){ + //C端用户暂不考虑 + + }else if(UserTypeUtil.COMMUNIT_TYPE.equals(userType)){ + Map communityUser = xhpcCommonMapper.getCommunityUser(null, userId, null, tenantId); + if(communityUser!=null){ + if(UserTypeUtil.INSERT_BALANCE.equals(status)){ + XhpcCommunityPersonnel xhpcCommunityPersonnel=new XhpcCommunityPersonnel(); + xhpcCommunityPersonnel.setCommunityPersonnelId(Long.valueOf(communityUser.get("communityUser").toString())); + xhpcCommunityPersonnel.setRechargeMoney(money); + xhpcCommunityPersonnel.setRemark(remark); + xhpcCommunityPersonnel.setRechargeType(type); + xhpcCommunityPersonnel.setTenantId(tenantId); + xhpcCommunityPersonnel.setMoneyOrderId(moneyOrderId); + return xhpcCommunityService.addRecharge(xhpcCommunityPersonnel); + } + } + }else if(UserTypeUtil.CUSTOMERS_TYPE.equals(userType)){ + Map customersUser = xhpcCommonMapper.getCustomersUser(null, userId, null, tenantId); + if(customersUser!=null){ + if(UserTypeUtil.INSERT_BALANCE.equals(status)){ + XhpcCustomersPersonnel xhpcCustomersPersonnel =new XhpcCustomersPersonnel(); + xhpcCustomersPersonnel.setCustomersPersonnelId(Long.valueOf(customersUser.get("communityUser").toString())); + xhpcCustomersPersonnel.setRechargeMoney(money); + xhpcCustomersPersonnel.setRemark(remark); + xhpcCustomersPersonnel.setRechargeType(type); + xhpcCustomersPersonnel.setTenantId(tenantId); + xhpcCustomersPersonnel.setMoneyOrderId(moneyOrderId); + return xhpcCustomersService.addRecharge(xhpcCustomersPersonnel); + } + } + } + return AjaxResult.error(); + } } diff --git a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/XhpcCommunityServiceImpl.java b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/XhpcCommunityServiceImpl.java index 70bb2fac..a1dcd9ab 100644 --- a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/XhpcCommunityServiceImpl.java +++ b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/XhpcCommunityServiceImpl.java @@ -2,6 +2,7 @@ package com.xhpc.user.service.impl; import com.xhpc.common.core.utils.SecurityUtils; import com.xhpc.common.core.web.domain.AjaxResult; +import com.xhpc.common.util.UserTypeUtil; import com.xhpc.user.domain.XhpcCommunity; import com.xhpc.user.domain.XhpcCommunityPersonnel; import com.xhpc.user.mapper.XhpcCommunityMapper; @@ -136,7 +137,7 @@ public class XhpcCommunityServiceImpl implements IXhpcCommunityService { xhpcCommunityMapper.addCommunityPersonnel(xhpcCommunityPersonnel); //增加一条充值记录 if(new BigDecimal(0).compareTo(rechargeMoney)==-1){ - mechanismService.addRechargeOrder(xhpcCommunityPersonnel.getCommunityPersonnelId(),2,rechargeMoney); + mechanismService.addRechargeOrder(xhpcCommunityPersonnel.getCommunityPersonnelId(),UserTypeUtil.COMMUNIT_TYPE,rechargeMoney,rechargeMoney,UserTypeUtil.RECHARGE_PT); } return AjaxResult.success(); } @@ -197,14 +198,23 @@ public class XhpcCommunityServiceImpl implements IXhpcCommunityService { XhpcCommunityPersonnel xhpcCommunityPersonnel1=new XhpcCommunityPersonnel(); xhpcCommunityPersonnel1.setCommunityPersonnelId(communityPersonnelId); - xhpcCommunityPersonnel1.setSurplusMoney(surplusMoney.add(rechargeMoney)); + BigDecimal remainingSum = surplusMoney.add(rechargeMoney); + xhpcCommunityPersonnel1.setSurplusMoney(remainingSum); xhpcCommunityPersonnel1.setRechargeMoney(rechargeMoney1.add(rechargeMoney)); xhpcCommunityMapper.updateCommunityPersonnel(xhpcCommunityPersonnel1); - //增加充值记录 - mechanismService.addRechargeOrder(communityPersonnelId,2,rechargeMoney); + + Long rechargeOrderId=null; + if(UserTypeUtil.RECHARGE_PT.equals(xhpcCommunityPersonnel.getRechargeType())){ + //增加充值记录 + rechargeOrderId = mechanismService.addRechargeOrder(communityPersonnelId, UserTypeUtil.COMMUNIT_TYPE, rechargeMoney, remainingSum, xhpcCommunityPersonnel1.getRechargeType()); + }else{ + rechargeOrderId=xhpcCommunityPersonnel.getMoneyOrderId(); + } + //增加用户流水 + mechanismService.insertUserAccount(communityPersonnelId,rechargeMoney,remainingSum,null,rechargeOrderId,null,UserTypeUtil.INSERT_BALANCE,xhpcCommunityPersonnel1.getTenantId(),UserTypeUtil.COMMUNIT_TYPE); return AjaxResult.success(); } } - return AjaxResult.error("充值金额大于0"); + return AjaxResult.error("充值金额必需大于0"); } } diff --git a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/XhpcCustomersServiceImpl.java b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/XhpcCustomersServiceImpl.java index d97e025e..6e0a20c8 100644 --- a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/XhpcCustomersServiceImpl.java +++ b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/XhpcCustomersServiceImpl.java @@ -2,6 +2,9 @@ package com.xhpc.user.service.impl; import com.xhpc.common.core.utils.SecurityUtils; import com.xhpc.common.core.web.domain.AjaxResult; +import com.xhpc.common.security.service.TokenService; +import com.xhpc.common.util.UserTypeUtil; +import com.xhpc.system.api.model.LoginUser; import com.xhpc.user.domain.XhpcCustomers; import com.xhpc.user.domain.XhpcCustomersPersonnel; import com.xhpc.user.mapper.XhpcCustomersMapper; @@ -10,6 +13,8 @@ import com.xhpc.user.service.IXhpcCustomersService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; import java.math.BigDecimal; import java.util.ArrayList; import java.util.Arrays; @@ -27,7 +32,8 @@ public class XhpcCustomersServiceImpl implements IXhpcCustomersService { private XhpcCustomersMapper xhpcCustomersMapper; @Autowired private IMechanismService mechanismService; - + @Autowired + private TokenService tokenService; @Override public List> list(String name) { Long userId = SecurityUtils.getUserId(); @@ -46,7 +52,7 @@ public class XhpcCustomersServiceImpl implements IXhpcCustomersService { } @Override - public AjaxResult addCustomers(XhpcCustomers xhpcCustomers) { + public AjaxResult addCustomers(HttpServletRequest request, XhpcCustomers xhpcCustomers) { //名称重复不能入库 Map communityById = xhpcCustomersMapper.getCustomersById(null, xhpcCustomers.getName(), null); @@ -55,7 +61,8 @@ public class XhpcCustomersServiceImpl implements IXhpcCustomersService { } Long userId = SecurityUtils.getUserId(); if(userId !=null){ - Map landUser = xhpcCustomersMapper.getLandUser(userId); + LoginUser loginUser = tokenService.getLoginUser(request); + Map landUser = xhpcCustomersMapper.getLandUser(loginUser.getUserid()); if(landUser !=null && landUser.get("userType") !=null){ if("00".equals(landUser.get("userType").toString()) ){ xhpcCustomers.setType(1); @@ -116,7 +123,7 @@ public class XhpcCustomersServiceImpl implements IXhpcCustomersService { xhpcCustomersMapper.updateCustomers(xhpcCustomers); mechanismService.updateMechanism(xhpcCustomers.getCustomersId(),1); if(!"".equals(chargingStationIds) && chargingStationIds !=null){ - mechanismService.addMechanism(Arrays.asList(chargingStationIds.split(",")),xhpcCustomers.getCustomersId(),0); + mechanismService.addMechanism(Arrays.asList(chargingStationIds.split(",")),xhpcCustomers.getCustomersId(),1); } return AjaxResult.success(); } @@ -147,7 +154,7 @@ public class XhpcCustomersServiceImpl implements IXhpcCustomersService { xhpcCustomersMapper.addCustomersPersonnel(xhpcCustomersPersonnel); //增加一条充值记录 if(new BigDecimal(0).compareTo(rechargeMoney)==-1){ - mechanismService.addRechargeOrder(xhpcCustomersPersonnel.getCustomersPersonnelId(),3,rechargeMoney); + mechanismService.addRechargeOrder(xhpcCustomersPersonnel.getCustomersPersonnelId(),UserTypeUtil.CUSTOMERS_TYPE,rechargeMoney,rechargeMoney,UserTypeUtil.RECHARGE_PT); } return AjaxResult.success(); } @@ -201,11 +208,19 @@ public class XhpcCustomersServiceImpl implements IXhpcCustomersService { XhpcCustomersPersonnel xhpcCustomersPersonnel1=new XhpcCustomersPersonnel(); xhpcCustomersPersonnel1.setCustomersPersonnelId(customersPersonnelId); - xhpcCustomersPersonnel1.setSurplusMoney(surplusMoney.add(rechargeMoney)); + BigDecimal remainingSum = surplusMoney.add(rechargeMoney); + xhpcCustomersPersonnel1.setSurplusMoney(remainingSum); xhpcCustomersPersonnel1.setRechargeMoney(rechargeMoney1.add(rechargeMoney)); xhpcCustomersMapper.updateCustomersPersonnel(xhpcCustomersPersonnel1); - //增加充值记录 - mechanismService.addRechargeOrder(customersPersonnelId,3,rechargeMoney); + Long rechargeOrderId=null; + if(UserTypeUtil.RECHARGE_PT.equals(xhpcCustomersPersonnel.getRechargeType())){ + //增加充值记录 + rechargeOrderId =mechanismService.addRechargeOrder(customersPersonnelId, UserTypeUtil.CUSTOMERS_TYPE,rechargeMoney,remainingSum,xhpcCustomersPersonnel1.getRechargeType()); + }else{ + rechargeOrderId= xhpcCustomersPersonnel.getMoneyOrderId(); + } + //增加用户流水 + mechanismService.insertUserAccount(customersPersonnelId,rechargeMoney,remainingSum,null,rechargeOrderId,null,UserTypeUtil.INSERT_BALANCE,xhpcCustomersPersonnel1.getTenantId(),UserTypeUtil.CUSTOMERS_TYPE); return AjaxResult.success(); } } diff --git a/xhpc-modules/xhpc-user/src/main/resources/bootstrap.yml b/xhpc-modules/xhpc-user/src/main/resources/bootstrap.yml index c570dc4f..b8d77722 100644 --- a/xhpc-modules/xhpc-user/src/main/resources/bootstrap.yml +++ b/xhpc-modules/xhpc-user/src/main/resources/bootstrap.yml @@ -23,6 +23,9 @@ spring: # 共享配置 shared-configs: - application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension} +logging: + level: + com.xhpc.user.mapper: debug #获取微信openid地址 WXGETJSCODE: "https://api.weixin.qq.com/sns/jscode2session?appid=wxd0a48e00319ef8a7&secret=e26d9088b58e24af69411d5933cece47&js_code=" #支付宝公钥 diff --git a/xhpc-modules/xhpc-user/src/main/resources/mapper/MechanismMapper.xml b/xhpc-modules/xhpc-user/src/main/resources/mapper/MechanismMapper.xml index a651dab8..fae76807 100644 --- a/xhpc-modules/xhpc-user/src/main/resources/mapper/MechanismMapper.xml +++ b/xhpc-modules/xhpc-user/src/main/resources/mapper/MechanismMapper.xml @@ -139,7 +139,162 @@ - - INSERT INTO xhpc_recharge_order(user_id,recharge_order_number,amount,type,status,source,create_time) values (#{userId},#{orderNumber},#{amount},#{type},1,#{source},#{date}) + + INSERT INTO xhpc_recharge_order + + + user_id, + + + recharge_order_number, + + + prepay_id, + + + alipay_number, + + + amount, + + + type, + + + status, + + + del_flag, + + + create_time, + + + create_by, + + + update_time, + + + update_by, + + + remark, + + + source + + + + + #{userId}, + + + #{rechargeOrderNumber}, + + + #{prepayId}, + + + #{alipayNumber}, + + + #{amount}, + + + #{type}, + + + #{status}, + + + #{delFlag}, + + + #{createTime}, + + + #{createBy}, + + + #{updateTime}, + + + #{updateBy}, + + + #{remark}, + + + #{source} + + + + + + + + + insert into xhpc_user_account_statement + + + user_id, + + + amount, + + + remaining_sum, + + + charge_order_id, + + + recharge_order_id, + + + refund_order_id, + + + type, + + + tenant_id, + + + source, + + + + + #{userId}, + + + #{amount}, + + + #{remainingSum}, + + + #{chargeOrderId}, + + + #{rechargeOrderId}, + + + #{refundOrderId}, + + + #{type}, + + + #{tenantId}, + + + #{source}, + + += diff --git a/xhpc-modules/xhpc-user/src/main/resources/mapper/XhpcAppUserMapper.xml b/xhpc-modules/xhpc-user/src/main/resources/mapper/XhpcAppUserMapper.xml index d7baa72b..77f5dadb 100644 --- a/xhpc-modules/xhpc-user/src/main/resources/mapper/XhpcAppUserMapper.xml +++ b/xhpc-modules/xhpc-user/src/main/resources/mapper/XhpcAppUserMapper.xml @@ -167,7 +167,9 @@ update_by = #{updateBy}, update_time = #{updateTime}, remark = #{remark}, - soc = #{soc} + soc = #{soc} + is_refund = #{isRefund} + soc_protect = #{socProtect} WHERE app_user_id = #{appUserId} @@ -235,7 +237,22 @@ - update xhpc_community_personnel set is_refund=#{isRefund} where community_personnel_id=#{userId} + UPDATE xhpc_community_personnel + + is_refund = #{isRefund}, + soc_protect = #{socProtect}, + soc = #{soc}, + + WHERE community_personnel_id = #{userId} + + + + UPDATE xhpc_customers_personnel + + soc_protect = #{socProtect}, + soc = #{soc}, + + WHERE customers_personnel_id = #{userId} diff --git a/xhpc-modules/xhpc-user/src/main/resources/mapper/XhpcCommonMapper.xml b/xhpc-modules/xhpc-user/src/main/resources/mapper/XhpcCommonMapper.xml index b3339669..c100293e 100644 --- a/xhpc-modules/xhpc-user/src/main/resources/mapper/XhpcCommonMapper.xml +++ b/xhpc-modules/xhpc-user/src/main/resources/mapper/XhpcCommonMapper.xml @@ -22,6 +22,7 @@ alipay_login as alipayLogin, del_flag delFlag, concat(0) as userType, + concat("C") as userTypeName, tenant_id tenantId, create_time as createTime from xhpc_app_user @@ -55,6 +56,7 @@ tenant_id tenantId, del_flag delFlag, concat(2) as userType, + concat("ST") as userTypeName, (select count(charging_station_id) from xhpc_mechanism where community_id=mechanism_id and source=0 and charging_station_id in (select charging_station_id from xhpc_terminal where 1=1 and del_flag=0 and serial_number=#{serialNumber})) as number, @@ -90,6 +92,7 @@ del_flag delFlag, tenant_id tenantId, concat(3) as userType, + concat("BE") as userTypeName, (select count(charging_station_id) from xhpc_mechanism where customers_id=mechanism_id and source=1 and charging_station_id in (select charging_station_id from xhpc_terminal where 1=1 and del_flag=0 and serial_number=#{serialNumber})) as number, diff --git a/xhpc-modules/xhpc-user/src/main/resources/mapper/XhpcCommunityMapper.xml b/xhpc-modules/xhpc-user/src/main/resources/mapper/XhpcCommunityMapper.xml index e94e67f7..c5849223 100644 --- a/xhpc-modules/xhpc-user/src/main/resources/mapper/XhpcCommunityMapper.xml +++ b/xhpc-modules/xhpc-user/src/main/resources/mapper/XhpcCommunityMapper.xml @@ -219,7 +219,7 @@ and status=#{status} - order by create_time desc. + order by create_time desc