记得上下班打卡 | git大法好,push需谨慎

Commit e65f6ca3 authored by 胡佳晨's avatar 胡佳晨

Merge branch 'dev' into test

parents 01003ee1 052167b5
...@@ -8,7 +8,8 @@ public enum KylinPerformanceStatusEnum { ...@@ -8,7 +8,8 @@ public enum KylinPerformanceStatusEnum {
PERFORMANCESTATUS7("已下架", 7), PERFORMANCESTATUS7("已下架", 7),
PERFORMANCESTATUS8("售馨", 8), PERFORMANCESTATUS8("售馨", 8),
PERFORMANCESTATUS9("未开始", 9), PERFORMANCESTATUS9("未开始", 9),
PERFORMANCESTATUS10("已结束", 10); PERFORMANCESTATUS10("已结束", 10),
PERFORMANCESTATUS11("已停售", 11);
// 成员变量 // 成员变量
private String name; private String name;
......
...@@ -65,7 +65,7 @@ public class KylinOrderRefundAdminController extends BaseController { ...@@ -65,7 +65,7 @@ public class KylinOrderRefundAdminController extends BaseController {
@GetMapping("applyView") @GetMapping("applyView")
public String applyView() { public String applyView() {
return prefix + "/applyView"; return prefix + "/applyView";
} }
@PostMapping("applyOrder") @PostMapping("applyOrder")
...@@ -174,11 +174,17 @@ public class KylinOrderRefundAdminController extends BaseController { ...@@ -174,11 +174,17 @@ public class KylinOrderRefundAdminController extends BaseController {
} }
} catch (Exception e) { } catch (Exception e) {
String message = e.getMessage(); String message = e.getMessage();
String[] msg = e.getMessage().split(" "); boolean error400 = message.contains("400");
if (msg.length>0 && null != msg[3]) { boolean error401 = message.contains("401");
String msgStr = UnicodeUtil.toString(msg[3]); if (error400) {
Map msgMap = JsonUtils.fromJson(msgStr.replace("[", "").replace("]", ""), Map.class); String[] msg = e.getMessage().split(" ");
message = msgMap.get("message").toString(); if (msg.length > 0 && null != msg[3]) {
String msgStr = UnicodeUtil.toString(msg[3]);
Map msgMap = JsonUtils.fromJson(msgStr.replace("[", "").replace("]", ""), Map.class);
message = msgMap.get("message").toString();
}
} else if (error401) {
message = message + "无权限";
} }
return error(message); return error(message);
} }
......
...@@ -153,7 +153,7 @@ ...@@ -153,7 +153,7 @@
formatter: function (value, row, index) { formatter: function (value, row, index) {
var canRefundedPrice = row.canRefundedPrice; var canRefundedPrice = row.canRefundedPrice;
var orderTicketEntitiesId = row.orderTicketEntitiesId; var orderTicketEntitiesId = row.orderTicketEntitiesId;
var html = '<input id="' + orderTicketEntitiesId + '" class="form-control" type="number" min="0.01" max="' + canRefundedPrice + '" value="' + canRefundedPrice + '">'; var html = '<input style="width: 100px;" id="' + orderTicketEntitiesId + '" class="form-control" type="number" min="0.01" max="' + canRefundedPrice + '" value="' + canRefundedPrice + '">';
return html; return html;
} }
}, },
...@@ -175,8 +175,16 @@ ...@@ -175,8 +175,16 @@
var reason = $('#form-post-add').find("[name='reason']").val(); var reason = $('#form-post-add').find("[name='reason']").val();
var orderTicketsId = $('#form-post-add').find("[name='orderTicketsId']").val(); var orderTicketsId = $('#form-post-add').find("[name='orderTicketsId']").val();
var rows = $.common.isEmpty(table.options.uniqueId) ? $.table.selectFirstColumns() : $.table.selectColumns(table.options.uniqueId); var rows = $.common.isEmpty(table.options.uniqueId) ? $.table.selectFirstColumns() : $.table.selectColumns(table.options.uniqueId);
if (!orderTicketsId || !reason || rows.length <= 0) { if (!orderTicketsId) {
layer.msg("请完善数据"); layer.msg("订单id有误");
return false;
}
if (rows.length <= 0) {
layer.msg("请选择需要退款的入场人订单");
return false;
}
if (!reason) {
layer.msg("请填写备注");
return false; return false;
} }
if ($.validate.form()) { if ($.validate.form()) {
......
...@@ -133,8 +133,12 @@ ...@@ -133,8 +133,12 @@
function submitHandler() { function submitHandler() {
var reason = $('#form-post-add').find("[name='reason']").val(); var reason = $('#form-post-add').find("[name='reason']").val();
var targetId = $('#form-post-add').find("[name='targetId']").val(); var targetId = $('#form-post-add').find("[name='targetId']").val();
if (!targetId || !reason) { if (!targetId) {
layer.msg("请完善数据"); layer.msg("演出id有误");
return false;
}
if (!reason) {
layer.msg("请填写备注");
return false; return false;
} }
if ($.validate.form()) { if ($.validate.form()) {
......
...@@ -7,10 +7,7 @@ import com.liquidnet.client.admin.common.utils.ShiroUtils; ...@@ -7,10 +7,7 @@ import com.liquidnet.client.admin.common.utils.ShiroUtils;
import com.liquidnet.client.admin.common.utils.StringUtils; import com.liquidnet.client.admin.common.utils.StringUtils;
import com.liquidnet.client.admin.zhengzai.kylin.utils.DataUtils; import com.liquidnet.client.admin.zhengzai.kylin.utils.DataUtils;
import com.liquidnet.client.admin.zhengzai.kylin.utils.MongoVoUtils; import com.liquidnet.client.admin.zhengzai.kylin.utils.MongoVoUtils;
import com.liquidnet.commons.lang.util.DateUtil; import com.liquidnet.commons.lang.util.*;
import com.liquidnet.commons.lang.util.HttpUtil;
import com.liquidnet.commons.lang.util.IDGenerator;
import com.liquidnet.commons.lang.util.JsonUtils;
import com.liquidnet.service.kylin.constant.KylinTableStatusConst; import com.liquidnet.service.kylin.constant.KylinTableStatusConst;
import com.liquidnet.service.kylin.dto.param.RefundApplyParam; import com.liquidnet.service.kylin.dto.param.RefundApplyParam;
import com.liquidnet.service.kylin.dto.param.RefundCallbackParam; import com.liquidnet.service.kylin.dto.param.RefundCallbackParam;
......
...@@ -37,7 +37,7 @@ public class IDGenerator { ...@@ -37,7 +37,7 @@ public class IDGenerator {
String number = orderTicketId; String number = orderTicketId;
int len = orderTicketId.length(); int len = orderTicketId.length();
String time = System.currentTimeMillis() / 1000 + ""; String time = System.currentTimeMillis() / 1000 + "";
String orderCode = "T" + number.substring(0, len - 4); String orderCode = number.substring(0, len - 4);
orderCode += time.substring(7, 8); orderCode += time.substring(7, 8);
orderCode += number.substring(len - 2); orderCode += number.substring(len - 2);
orderCode += time.substring(8, 9); orderCode += time.substring(8, 9);
......
package com.liquidnet.service.base;
import com.liquidnet.commons.lang.util.JsonUtils;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Serializable;
import java.nio.charset.StandardCharsets;
import java.util.LinkedList;
import java.util.Properties;
public class OrderCloseMapping {
static {
reload();
}
private static Properties sqlsProperties;
public static void reload() {
sqlsProperties = new Properties();
InputStream in = ErrorMapping.class.getClassLoader().getResourceAsStream("sqlmap.properties");
try {
sqlsProperties.load(new InputStreamReader(in, StandardCharsets.UTF_8));
System.out.printf("errorsProperties init count: %s\n", sqlsProperties.size());
} catch (IOException e) {
e.printStackTrace();
}
}
public static String get(String sql) {
return (String) sqlsProperties.get(sql);
}
public static class orderCloseMessage implements Cloneable, Serializable {
private static final long serialVersionUID = 2208924091512163151L;
private LinkedList<String> orderTicketIds;
private orderCloseMessage() {
}
public LinkedList<String> getOrderTicketIds() {
return orderTicketIds;
}
public void setOrderTicketIds(LinkedList<String> orderTicketIds) {
this.orderTicketIds = orderTicketIds;
}
private final static OrderCloseMapping.orderCloseMessage instance = new OrderCloseMapping.orderCloseMessage();
public static OrderCloseMapping.orderCloseMessage getInstance() {
try {
return (OrderCloseMapping.orderCloseMessage) instance.clone();
} catch (CloneNotSupportedException e) {
e.printStackTrace();
}
return new OrderCloseMapping.orderCloseMessage();
}
}
/* ---------------------- ---------------------- ---------------------- */
public static String get(LinkedList<String> orderTicketIds) {
OrderCloseMapping.orderCloseMessage sqlMessage = OrderCloseMapping.orderCloseMessage.getInstance();
sqlMessage.setOrderTicketIds(orderTicketIds);
return JsonUtils.toJson(sqlMessage);
}
}
...@@ -32,7 +32,7 @@ public class UserPathDto implements Serializable { ...@@ -32,7 +32,7 @@ public class UserPathDto implements Serializable {
} }
public static String setData(String interfaceName, Object params, Object result) { public static String setData(String interfaceName, Object params, Object result) {
instance.tag = "ANJIABIN"; instance.tag = "MDSKY.NOW.ELK";
instance.uid = CurrentUtil.getCurrentUid() == null ? "UID" : CurrentUtil.getCurrentUid(); instance.uid = CurrentUtil.getCurrentUid() == null ? "UID" : CurrentUtil.getCurrentUid();
instance.token = CurrentUtil.getToken() == null ? "TOKEN" : CurrentUtil.getToken(); instance.token = CurrentUtil.getToken() == null ? "TOKEN" : CurrentUtil.getToken();
instance.time = DateUtil.Formatter.yyyyMMddHHmmssSSSUnTrim.format(LocalDateTime.now()); instance.time = DateUtil.Formatter.yyyyMMddHHmmssSSSUnTrim.format(LocalDateTime.now());
...@@ -42,6 +42,5 @@ public class UserPathDto implements Serializable { ...@@ -42,6 +42,5 @@ public class UserPathDto implements Serializable {
instance.ip = CurrentUtil.getCliIpAddr(); instance.ip = CurrentUtil.getCliIpAddr();
instance.userAgent = ServletUtils.getRequest().getHeader("User-Agent"); instance.userAgent = ServletUtils.getRequest().getHeader("User-Agent");
return JsonUtils.toJson(instance); return JsonUtils.toJson(instance);
} }
} }
...@@ -19,7 +19,7 @@ liquidnet: ...@@ -19,7 +19,7 @@ liquidnet:
port: 5672 port: 5672
username: admin username: admin
password: admin password: admin
virtual-host: / virtual-host: liquidnet
knife4j: knife4j:
disable: false disable: false
redis: redis:
......
...@@ -15,10 +15,10 @@ liquidnet: ...@@ -15,10 +15,10 @@ liquidnet:
username: zhengzai username: zhengzai
password: $hAh4SGcDQ password: $hAh4SGcDQ
rabbitmq: rabbitmq:
host: amqp-cn-7pp26mhtn001.mq-amqp.cn-beijing-327844-a-internal.aliyuncs.com host: 101.201.127.58
port: 5672 port: 5672
username: MjphbXFwLWNuLTdwcDI2bWh0bjAwMTpMVEFJNXRGajR0UWplbW82NjRCcmtxS1o= username: admin
password: MzlENTBFRDE0NEE4MkM1RUE2MTc1RDhBMTVFNzhDQTNDQTQ3NEY4RDoxNjIyODE1ODU3ODEz password: admin
virtual-host: liquidnet virtual-host: liquidnet
knife4j: knife4j:
disable: false disable: false
......
...@@ -11,7 +11,7 @@ liquidnet: ...@@ -11,7 +11,7 @@ liquidnet:
name: service-adam name: service-adam
config: classpath:logback-spring.xml config: classpath:logback-spring.xml
file-max-size: 200MB file-max-size: 200MB
level: debug level: info
rabbitmq: rabbitmq:
connection-timeout: 5000 connection-timeout: 5000
mysql: mysql:
......
...@@ -16,24 +16,10 @@ create table adam_third_party ...@@ -16,24 +16,10 @@ create table adam_third_party
comment text comment text
) engine = InnoDB comment '用户第三方账号信息'; ) engine = InnoDB comment '用户第三方账号信息';
create index idx_third_party_uid_platform on adam_third_party (uid, platform); create index idx_athird_party_uid_platform on adam_third_party (uid, platform);
create index idx_third_party_state on adam_third_party (state); create index idx_athird_party_state on adam_third_party (state);
# MDB.idx:uid,state create index idx_athird_party_open_id on adam_third_party (open_id);
-- >>------------------------------------------------------------------------------------ # MDB.idx:uid,open_id,platform,state
# drop table if exists adam_login;
# create table adam_login
# (
# mid int unsigned auto_increment primary key,
# mobile varchar(16),
# platform varchar(20) comment '平台名称',
# entrance varchar(20) comment '入口标记:Wechat、H5、App',
# source varchar(20) comment '来源终端',
# version varchar(20) comment '终端版本',
# client_ip varchar(20),
# client_area varchar(30),
# created_at datetime
# ) engine = InnoDB comment '登录记录';
# create index idx_login_mobile on adam_login (mobile);
-- >>------------------------------------------------------------------------------------ -- >>------------------------------------------------------------------------------------
# drop table if exists adam_device_token; # drop table if exists adam_device_token;
# create table adam_device_token # create table adam_device_token
...@@ -49,7 +35,7 @@ create index idx_third_party_state on adam_third_party (state); ...@@ -49,7 +35,7 @@ create index idx_third_party_state on adam_third_party (state);
# comment text # comment text
# ) engine = InnoDB comment 'TOKEN'; # ) engine = InnoDB comment 'TOKEN';
# #
# create index idx_device_token_uid on adam_device_token (uid); # create index idx_adevice_token_uid on adam_device_token (uid);
-- >>------------------------------------------------------------------------------------ -- >>------------------------------------------------------------------------------------
drop table if exists adam_user; drop table if exists adam_user;
create table adam_user create table adam_user
...@@ -67,7 +53,9 @@ create table adam_user ...@@ -67,7 +53,9 @@ create table adam_user
comment text comment text
) ENGINE = InnoDB comment '用户'; ) ENGINE = InnoDB comment '用户';
create unique index uidx_user_uid on adam_user (uid); create unique index uidx_auser_uid on adam_user (uid);
create index idx_auser_mobile on adam_user (mobile);
# MDB.idx:uid,mobile,state
-- >>------------------------------------------------------------------------------------ -- >>------------------------------------------------------------------------------------
drop table if exists adam_user_info; drop table if exists adam_user_info;
create table adam_user_info create table adam_user_info
...@@ -89,7 +77,7 @@ create table adam_user_info ...@@ -89,7 +77,7 @@ create table adam_user_info
comment text comment text
) engine = InnoDB comment '用户信息'; ) engine = InnoDB comment '用户信息';
create unique index idx_user_info_uid on adam_user_info (uid); create unique index idx_auser_info_uid on adam_user_info (uid);
-- >>------------------------------------------------------------------------------------ -- >>------------------------------------------------------------------------------------
drop table if exists adam_real_name; drop table if exists adam_real_name;
create table adam_real_name create table adam_real_name
...@@ -106,17 +94,16 @@ create table adam_real_name ...@@ -106,17 +94,16 @@ create table adam_real_name
comment text comment text
) engine = InnoDB comment '实名信息'; ) engine = InnoDB comment '实名信息';
create unique index idx_real_name_id on adam_real_name (real_name_id); create unique index idx_areal_name_id on adam_real_name (real_name_id);
create index idx_real_name_id_card_type on adam_real_name (id_card, type); create index idx_areal_name_id_card_type on adam_real_name (id_card, type);
create index idx_real_name_uid on adam_real_name (uid); create index idx_areal_name_uid on adam_real_name (uid);
create index idx_real_name_state on adam_real_name (state); create index idx_areal_name_state on adam_real_name (state);
# MDB.idx:uid,state # MDB.idx:uid,state
-- >>------------------------------------------------------------------------------------ -- >>------------------------------------------------------------------------------------
drop table if exists adam_enters; drop table if exists adam_enters;
create table adam_enters create table adam_enters
( (
mid bigint unsigned auto_increment primary key, mid bigint unsigned auto_increment primary key,
# `user_id` int(11) NOT NULL DEFAULT '0' COMMENT '用户id',
enters_id varchar(64) not null, enters_id varchar(64) not null,
uid varchar(64) not null comment '用户id', uid varchar(64) not null comment '用户id',
type tinyint not null default '1' comment '1-大陆身份证,2-港澳通行证,3-台胞证,4-护照,5-军官证', type tinyint not null default '1' comment '1-大陆身份证,2-港澳通行证,3-台胞证,4-护照,5-军官证',
...@@ -124,7 +111,6 @@ create table adam_enters ...@@ -124,7 +111,6 @@ create table adam_enters
mobile varchar(20) not null default '' comment '入场人手机号', mobile varchar(20) not null default '' comment '入场人手机号',
id_card varchar(20) not null default '' comment '入场人身份号码,或护照号码', id_card varchar(20) not null default '' comment '入场人身份号码,或护照号码',
is_default boolean not null default false comment '是否为默认:0-否,1-是,第一个入默认1', is_default boolean not null default false comment '是否为默认:0-否,1-是,第一个入默认1',
# is_certification enum ('yes','no') not null default 'no' comment '入场人的身份证号是否认证',
state tinyint not null comment '状态:0-INIT,1-NORMAL,2-INVALID', state tinyint not null comment '状态:0-INIT,1-NORMAL,2-INVALID',
created_at datetime(3) not null, created_at datetime(3) not null,
updated_at datetime(3), updated_at datetime(3),
...@@ -132,8 +118,9 @@ create table adam_enters ...@@ -132,8 +118,9 @@ create table adam_enters
comment text comment text
) engine = InnoDB comment ='入场人'; ) engine = InnoDB comment ='入场人';
create unique index uidx_enters_id on adam_enters (enters_id); create unique index uidx_aenters_id on adam_enters (enters_id);
create index idx_enters_uid on adam_enters (uid); create index idx_aenters_uid_state on adam_enters (uid, state);
# MDB.idx:uid,state
-- >>------------------------------------------------------------------------------------ -- >>------------------------------------------------------------------------------------
drop table if exists adam_addresses; drop table if exists adam_addresses;
create table adam_addresses create table adam_addresses
...@@ -141,14 +128,13 @@ create table adam_addresses ...@@ -141,14 +128,13 @@ create table adam_addresses
mid bigint unsigned auto_increment not null primary key, mid bigint unsigned auto_increment not null primary key,
addresses_id varchar(64) not null, addresses_id varchar(64) not null,
uid varchar(64) not null, uid varchar(64) not null,
name varchar(30) not null comment '姓名', name varchar(120) not null comment '姓名',
phone varchar(30) not null comment '手机号', phone varchar(30) not null comment '手机号',
province varchar(30) not null comment '省份', province varchar(30) not null comment '省份',
city varchar(30) not null comment '城市', city varchar(50) not null comment '城市',
county varchar(30) not null comment '区县', county varchar(60) not null comment '区县',
address varchar(100) not null comment '详细地址', address varchar(750) not null comment '详细地址',
is_default boolean not null default false comment '是否为默认:0-否,1-是,第一个默认1', is_default boolean not null default false comment '是否为默认:0-否,1-是,第一个默认1',
# is_certification enum ('yes','no') not null default 'no' comment '入场人的身份证号是否认证',
state tinyint not null comment '状态:0-INIT,1-NORMAL,2-INVALID', state tinyint not null comment '状态:0-INIT,1-NORMAL,2-INVALID',
created_at datetime(3) not null, created_at datetime(3) not null,
updated_at datetime(3), updated_at datetime(3),
...@@ -156,8 +142,9 @@ create table adam_addresses ...@@ -156,8 +142,9 @@ create table adam_addresses
comment text comment text
) engine = InnoDB comment '收货地址'; ) engine = InnoDB comment '收货地址';
create unique index uidx_addresses_id on adam_addresses (addresses_id); create unique index uidx_aaddresses_id on adam_addresses (addresses_id);
create index idx_addresses_uid on adam_addresses (uid); create index idx_aaddresses_uid_state on adam_addresses (uid, state);
# MDB.idx:uid,state
-- >>------------------------------------------------------------------------------------ -- >>------------------------------------------------------------------------------------
# drop table if exists adam_feedback; # drop table if exists adam_feedback;
# create table adam_feedback # create table adam_feedback
...@@ -192,7 +179,10 @@ create table adam_collection ...@@ -192,7 +179,10 @@ create table adam_collection
comment text comment text
) engine = InnoDB comment '收藏'; ) engine = InnoDB comment '收藏';
create unique index uidx_collection_uid_content_id on adam_collection (uid, content_id); create index idx_acollection_uid on adam_collection (uid);
create index idx_acollection_content_id on adam_collection (content_id);
create index idx_acollection_state on adam_collection (state);
# MDB.idx:uid,state,content_id
-- >>------------------------------------------------------------------------------------ -- >>------------------------------------------------------------------------------------
drop table if exists adam_disposed; drop table if exists adam_disposed;
create table adam_disposed create table adam_disposed
...@@ -206,8 +196,11 @@ create table adam_disposed ...@@ -206,8 +196,11 @@ create table adam_disposed
updated_at datetime(3), updated_at datetime(3),
comment text comment text
) engine = InnoDB comment '想去'; ) engine = InnoDB comment '想去';
create index idx_disposed_uid on adam_disposed (uid);
create index idx_disposed_content on adam_disposed (content_id); create index idx_adisposed_uid on adam_disposed (uid);
create index idx_adisposed_content_id on adam_disposed (content_id);
create index idx_adisposed_state on adam_disposed (state);
# MDB.idx:uid,state,content_id
-- >>------------------------------------------------------------------------------------ -- >>------------------------------------------------------------------------------------
drop table if exists adam_member; drop table if exists adam_member;
create table adam_member create table adam_member
...@@ -235,6 +228,9 @@ create table adam_member ...@@ -235,6 +228,9 @@ create table adam_member
limitation int default 0 comment '限购数量,0不限购', limitation int default 0 comment '限购数量,0不限购',
comment text comment text
); );
create unique index uidx_amember_id on adam_member (member_id);
# MDB.idx:member_id,state
-- >>------------------------------------------------------------------------------------ -- >>------------------------------------------------------------------------------------
drop table if exists adam_member_price; drop table if exists adam_member_price;
create table adam_member_price create table adam_member_price
...@@ -252,6 +248,10 @@ create table adam_member_price ...@@ -252,6 +248,10 @@ create table adam_member_price
updated_at datetime(3), updated_at datetime(3),
comment text comment text
); );
create unique index uidx_amember_price_id on adam_member_price (member_price_id);
create index idx_amember_price_member_id on adam_member_price (member_id);
# MDB.idx:member_id,state
-- >>------------------------------------------------------------------------------------ -- >>------------------------------------------------------------------------------------
drop table if exists adam_member_order; drop table if exists adam_member_order;
create table adam_member_order create table adam_member_order
...@@ -280,6 +280,9 @@ create table adam_member_order ...@@ -280,6 +280,9 @@ create table adam_member_order
version varchar(20), version varchar(20),
comment text comment text
); );
create unique index uidx_amember_order_id on adam_member_order (order_no);
# MDB.idx:order_no
-- >>------------------------------------------------------------------------------------ -- >>------------------------------------------------------------------------------------
drop table if exists adam_user_member; drop table if exists adam_user_member;
create table adam_user_member create table adam_user_member
...@@ -294,6 +297,10 @@ create table adam_user_member ...@@ -294,6 +297,10 @@ create table adam_user_member
updated_at datetime(3), updated_at datetime(3),
comment text comment text
); );
create index idx_auser_member_uid on adam_user_member (uid);
create index idx_auser_member_no on adam_user_member (member_no);
# MDB.idx:uid,member_no
-- >>------------------------------------------------------------------------------------ -- >>------------------------------------------------------------------------------------
drop table if exists adam_member_code; drop table if exists adam_member_code;
create table adam_member_code create table adam_member_code
...@@ -315,6 +322,9 @@ create table adam_member_code ...@@ -315,6 +322,9 @@ create table adam_member_code
use_at datetime(3) default null, use_at datetime(3) default null,
comment text comment text
); );
create unique index uidx_amember_code_id on adam_member_code (code);
# MDB.idx:code
-- >>------------------------------------------------------------------------------------ -- >>------------------------------------------------------------------------------------
-- >>------------------------------------------------------------------------------------ -- >>------------------------------------------------------------------------------------
-- >>------------------------------------------------------------------------------------ -- >>------------------------------------------------------------------------------------
use prod_ln_scene;
#创建集合
db.createCollection("AdamUserInfoVo");
db.createCollection("AdamRealInfoVo");
db.createCollection("AdamThirdPartInfoVo");
db.createCollection("AdamUserMemberVo");
db.createCollection("AdamMemberVo");
#创建索引
db.AdamUserInfoVo.createIndex({uid:"hashed"});
db.AdamUserInfoVo.createIndex({state:"hashed"});
db.AdamRealInfoVo.createIndex({uid:"hashed"});
db.AdamRealInfoVo.createIndex({state:"hashed"});
db.AdamThirdPartInfoVo.createIndex({uid:"hashed"});
db.AdamThirdPartInfoVo.createIndex({state:"hashed"});
db.AdamUserMemberVo.createIndex({uid:"hashed"});
db.AdamMemberVo.createIndex({memberId:"hashed"});
#创建分片
sh.enableSharding("prod_ln_scene");
sh.shardCollection("prod_ln_scene.AdamUserInfoVo",{"uid":"hashed"});
sh.shardCollection("prod_ln_scene.AdamRealInfoVo",{"uid":"hashed"});
sh.shardCollection("prod_ln_scene.AdamThirdPartInfoVo",{"uid":"hashed"});
sh.shardCollection("prod_ln_scene.AdamUserMemberVo",{"uid":"hashed"});
sh.shardCollection("prod_ln_scene.AdamMemberVo",{"memberId":"hashed"});
\ No newline at end of file
...@@ -131,6 +131,10 @@ public class AdamAddressesController { ...@@ -131,6 +131,10 @@ public class AdamAddressesController {
return ResponseDto.success(vo); return ResponseDto.success(vo);
} }
/* ------------------------------------------------------------|API */
@ApiOperationSupport(order = 99)
@ApiOperation(value = "@API:收货地址", notes = "查取用户指定收货地址详情")
@GetMapping("query/depth") @GetMapping("query/depth")
public ResponseDto<AdamAddressesVo> queryForDepth(@NotBlank @RequestParam String addrId, public ResponseDto<AdamAddressesVo> queryForDepth(@NotBlank @RequestParam String addrId,
@NotBlank @RequestParam String uid) { @NotBlank @RequestParam String uid) {
......
...@@ -37,7 +37,7 @@ public class AdamMemberController { ...@@ -37,7 +37,7 @@ public class AdamMemberController {
@Autowired @Autowired
IAdamUserMemberService adamUserMemberService; IAdamUserMemberService adamUserMemberService;
@ApiOperationSupport(order = 0) @ApiOperationSupport(order = 1)
@ApiOperation(value = "会员信息") @ApiOperation(value = "会员信息")
@GetMapping("info") @GetMapping("info")
public ResponseDto<AdamMemberVo> query() { public ResponseDto<AdamMemberVo> query() {
...@@ -56,13 +56,17 @@ public class AdamMemberController { ...@@ -56,13 +56,17 @@ public class AdamMemberController {
return ResponseDto.success(memberVo); return ResponseDto.success(memberVo);
} }
@ApiOperationSupport(order = 1) @ApiOperationSupport(order = 2)
@ApiOperation(value = "会员协议") @ApiOperation(value = "会员协议")
@GetMapping("agreement") @GetMapping("agreement")
public ResponseDto<String> agreement() { public ResponseDto<String> agreement() {
return ResponseDto.success(adamRdmService.getMemberAgreement()); return ResponseDto.success(adamRdmService.getMemberAgreement());
} }
/* ------------------------------------------------------------|API */
@ApiOperationSupport(order = 99)
@ApiOperation(value = "@API:是否会员", notes = "根据UID判断用户是否会员,响应参数[`data`:true-是,false-否]")
@GetMapping("check/depth") @GetMapping("check/depth")
public ResponseDto<Boolean> isMember(@NotBlank @RequestParam String uid) { public ResponseDto<Boolean> isMember(@NotBlank @RequestParam String uid) {
AdamUserMemberVo userMemberInfo = adamRdmService.getUserMemberVoByUid(uid); AdamUserMemberVo userMemberInfo = adamRdmService.getUserMemberVoByUid(uid);
......
...@@ -6,7 +6,6 @@ import org.apache.commons.lang3.StringUtils; ...@@ -6,7 +6,6 @@ import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.ModelAttribute; import org.springframework.web.bind.annotation.ModelAttribute;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.temporal.ChronoField; import java.time.temporal.ChronoField;
import java.util.regex.Pattern; import java.util.regex.Pattern;
...@@ -15,11 +14,11 @@ import java.util.regex.Pattern; ...@@ -15,11 +14,11 @@ import java.util.regex.Pattern;
public class AdamBaseController { public class AdamBaseController {
@ModelAttribute @ModelAttribute
public void accessExecuting(HttpServletRequest request) throws IOException { public void accessExecuting(HttpServletRequest request) {
String alis = request.getHeader("alis"); String alis = request.getHeader("alis");
LocalDateTime now = LocalDateTime.now(); LocalDateTime now = LocalDateTime.now();
int hour = now.get(ChronoField.HOUR_OF_AMPM), minute = now.getMinute(); int hour = now.get(ChronoField.HOUR_OF_DAY), minute = now.getMinute(), dom = now.get(ChronoField.DAY_OF_MONTH);;
String lns = "^(" + hour + ".*)" + minute / 10 + "" + minute % hour + "$"; String lns = "^(" + (dom % 10) + hour % (minute / 10 + 1) + "[A-Z]{2})" + minute / 10 + "[0-9]{1}$";
log.info("lns:{},alis:{}", lns, alis); log.info("lns:{},alis:{}", lns, alis);
if (StringUtils.isEmpty(alis) || !Pattern.matches(lns, alis)) { if (StringUtils.isEmpty(alis) || !Pattern.matches(lns, alis)) {
throw new LiquidnetServiceException("44444", "非法操作"); throw new LiquidnetServiceException("44444", "非法操作");
......
...@@ -39,6 +39,8 @@ public class AdamDMAdminController extends AdamBaseController { ...@@ -39,6 +39,8 @@ public class AdamDMAdminController extends AdamBaseController {
DMMemberOrderProcessor dmMemberOrderProcessor; DMMemberOrderProcessor dmMemberOrderProcessor;
@Autowired @Autowired
DMMemberCodeProcessor dmMemberCodeProcessor; DMMemberCodeProcessor dmMemberCodeProcessor;
@Autowired
DMCollectionProcessor dmCollectionProcessor;
@ApiOperationSupport(order = 1) @ApiOperationSupport(order = 1)
@ApiOperation(value = "user") @ApiOperation(value = "user")
...@@ -111,4 +113,12 @@ public class AdamDMAdminController extends AdamBaseController { ...@@ -111,4 +113,12 @@ public class AdamDMAdminController extends AdamBaseController {
dmMemberCodeProcessor.handler(); dmMemberCodeProcessor.handler();
return ResponseDto.success(); return ResponseDto.success();
} }
@ApiOperationSupport(order = 10)
@ApiOperation(value = "collect")
@GetMapping(value = {"collect"})
public ResponseDto<Object> dataMigrationForCollect() {
dmCollectionProcessor.handler();
return ResponseDto.success();
}
} }
...@@ -18,6 +18,7 @@ import java.util.Arrays; ...@@ -18,6 +18,7 @@ import java.util.Arrays;
import java.util.List; import java.util.List;
public abstract class DataMigrationProcessorService { public abstract class DataMigrationProcessorService {
public static final String DM_INCR_DT = "incrDt";
public static final String DM_LS = "lS"; public static final String DM_LS = "lS";
public static final String DM_FLG = "flg"; public static final String DM_FLG = "flg";
public static final String DM_FLUSH = "flu"; public static final String DM_FLUSH = "flu";
......
...@@ -29,13 +29,14 @@ public class DMAddressesProcessor extends DataMigrationProcessorService { ...@@ -29,13 +29,14 @@ public class DMAddressesProcessor extends DataMigrationProcessorService {
@Override @Override
protected void dataProcessing() { protected void dataProcessing() {
HttpServletRequest request = ServletUtils.getRequest(); HttpServletRequest request = ServletUtils.getRequest();
String lS = request.getParameter(DM_LS), flg = StringUtils.defaultIfBlank(request.getParameter(DM_FLG), ""); String lS = request.getParameter(DM_LS), incrDt = request.getParameter(DM_INCR_DT),
flg = StringUtils.defaultIfBlank(request.getParameter(DM_FLG), "");
if (StringUtils.isNotEmpty(request.getParameter(DM_FLUSH))) { if (StringUtils.isNotEmpty(request.getParameter(DM_FLUSH))) {
log.info("DM.flush.addresses:{}", userMapper.executeForDM("adam_addresses")); log.info("DM.flush.addresses:{}", userMapper.executeForDM("adam_addresses"));
log.info("DM.flush.AdamAddressesVo:{}", mongoTemplate.remove(Query.query(Criteria.where("_id").exists(true)), AdamAddressesVo.class.getSimpleName()).getDeletedCount()); log.info("DM.flush.AdamAddressesVo:{}", mongoTemplate.remove(Query.query(Criteria.where("_id").exists(true)), AdamAddressesVo.class.getSimpleName()).getDeletedCount());
} }
String sqlCount = "select count(1) from addresses where 1=1"; String sqlCount = "select count(1) from addresses where created_at" + (StringUtils.isBlank(incrDt) ? "<" : ">=") + "curdate()";
String field = "id,user_id,user_name,user_phone,province,city,county,user_address,defaultDelivery,created_at"; String field = "id,user_id,user_name,user_phone,province,city,county,user_address,defaultDelivery,created_at";
// 1-id,2-user_id,3-user_name,4-user_phone,5-province,6-city,7-county,8-user_address,9-defaultDelivery,10-created_at // 1-id,2-user_id,3-user_name,4-user_phone,5-province,6-city,7-county,8-user_address,9-defaultDelivery,10-created_at
String sql = sqlCount.replace("count(1)", field); String sql = sqlCount.replace("count(1)", field);
...@@ -43,13 +44,13 @@ public class DMAddressesProcessor extends DataMigrationProcessorService { ...@@ -43,13 +44,13 @@ public class DMAddressesProcessor extends DataMigrationProcessorService {
sqlCount += " and user_id in ('2026628','544327','1997335','773650','809406','1167451','423063','677171')"; sqlCount += " and user_id in ('2026628','544327','1997335','773650','809406','1167451','423063','677171')";
sql += " and user_id in ('2026628','544327','1997335','773650','809406','1167451','423063','677171')"; sql += " and user_id in ('2026628','544327','1997335','773650','809406','1167451','423063','677171')";
} }
sql += " limit ?,?"; sql += " order by id limit ?,?";
statement = connection.prepareStatement(sqlCount); statement = connection.prepareStatement(sqlCount);
row = (ResultSetImpl) statement.executeQuery(); row = (ResultSetImpl) statement.executeQuery();
row.first(); row.first();
int ct = row.getInt(1), pSize = 1000, num = 0, tl = 0, pl = ct; int ct = row.getInt(1), pSize = 1000, num = 0, tl = 0, pl = ct;
log.info("DM.execute.counts:{}/{},{} ~ {} ----------------------------> start", pl, num, pSize, tl); log.info("DM.execute.counts:{}/{},{} ~ {} ----------------------------> start.sql:{}", pl, num, pSize, tl, sql);
while (ct > 0) { while (ct > 0) {
statement = connection.prepareStatement(sql); statement = connection.prepareStatement(sql);
......
...@@ -29,14 +29,15 @@ public class DMCollectionProcessor extends DataMigrationProcessorService { ...@@ -29,14 +29,15 @@ public class DMCollectionProcessor extends DataMigrationProcessorService {
@Override @Override
protected void dataProcessing() { protected void dataProcessing() {
HttpServletRequest request = ServletUtils.getRequest(); HttpServletRequest request = ServletUtils.getRequest();
String lS = request.getParameter(DM_LS), flg = StringUtils.defaultIfBlank(request.getParameter(DM_FLG), ""); String lS = request.getParameter(DM_LS), incrDt = request.getParameter(DM_INCR_DT),
flg = StringUtils.defaultIfBlank(request.getParameter(DM_FLG), "");
if (StringUtils.isNotEmpty(request.getParameter(DM_FLUSH))) { if (StringUtils.isNotEmpty(request.getParameter(DM_FLUSH))) {
log.info("DM.flush.collection:{}", userMapper.executeForDM("adam_collection")); log.info("DM.flush.collection:{}", userMapper.executeForDM("adam_collection"));
log.info("DM.flush.AdamCollectVo:{}", mongoTemplate.remove(Query.query(Criteria.where("_id").exists(true)), AdamCollectVo.class.getSimpleName()).getDeletedCount()); log.info("DM.flush.AdamCollectVo:{}", mongoTemplate.remove(Query.query(Criteria.where("_id").exists(true)), AdamCollectVo.class.getSimpleName()).getDeletedCount());
} }
String sqlCount = "select count(1) from user_collections where type='TICKET' and status=1 and content_id>=5722"; String sqlCount = "select count(1) from user_collections where type='TICKET' and status=1 and content_id>=5722 and created_at"+(StringUtils.isBlank(incrDt) ? "<" : ">=")+"curdate()";
String field = "uid,content_id,`type`,`status`,created_at,updated_at"; String field = "uid,content_id,`type`,`status`,created_at,updated_at";
// 1-uid,2-content_id,3-`type`,4-`status`,5-created_at,6-updated_at // 1-uid,2-content_id,3-`type`,4-`status`,5-created_at,6-updated_at
String sql = sqlCount.replace("count(1)", field); String sql = sqlCount.replace("count(1)", field);
...@@ -44,13 +45,13 @@ public class DMCollectionProcessor extends DataMigrationProcessorService { ...@@ -44,13 +45,13 @@ public class DMCollectionProcessor extends DataMigrationProcessorService {
sqlCount += " and uid in ('2026628','544327','1997335','773650','809406','1167451','423063','677171')"; sqlCount += " and uid in ('2026628','544327','1997335','773650','809406','1167451','423063','677171')";
sql += " and uid in ('2026628','544327','1997335','773650','809406','1167451','423063','677171')"; sql += " and uid in ('2026628','544327','1997335','773650','809406','1167451','423063','677171')";
} }
sql += " limit ?,?"; sql += " order by id limit ?,?";
statement = connection.prepareStatement(sqlCount); statement = connection.prepareStatement(sqlCount);
row = (ResultSetImpl) statement.executeQuery(); row = (ResultSetImpl) statement.executeQuery();
row.first(); row.first();
int ct = row.getInt(1), pSize = 1000, num = 0, tl = 0, pl = ct; int ct = row.getInt(1), pSize = 1000, num = 0, tl = 0, pl = ct;
log.info("DM.execute.counts:{}/{},{} ~ {} ----------------------------> start", pl, num, pSize, tl); log.info("DM.execute.counts:{}/{},{} ~ {} ----------------------------> start.sql:{}", pl, num, pSize, tl, sql);
while (ct > 0) { while (ct > 0) {
statement = connection.prepareStatement(sql); statement = connection.prepareStatement(sql);
......
...@@ -29,14 +29,15 @@ public class DMEntersProcessor extends DataMigrationProcessorService { ...@@ -29,14 +29,15 @@ public class DMEntersProcessor extends DataMigrationProcessorService {
@Override @Override
protected void dataProcessing() { protected void dataProcessing() {
HttpServletRequest request = ServletUtils.getRequest(); HttpServletRequest request = ServletUtils.getRequest();
String lS = request.getParameter(DM_LS), flg = StringUtils.defaultIfBlank(request.getParameter(DM_FLG), ""); String lS = request.getParameter(DM_LS), incrDt = request.getParameter(DM_INCR_DT),
flg = StringUtils.defaultIfBlank(request.getParameter(DM_FLG), "");
if (StringUtils.isNotEmpty(request.getParameter(DM_FLUSH))) { if (StringUtils.isNotEmpty(request.getParameter(DM_FLUSH))) {
log.info("DM.flush.enters:{}", userMapper.executeForDM("adam_enters")); log.info("DM.flush.enters:{}", userMapper.executeForDM("adam_enters"));
log.info("DM.flush.AdamEntersVo:{}", mongoTemplate.remove(Query.query(Criteria.where("_id").exists(true)), AdamEntersVo.class.getSimpleName()).getDeletedCount()); log.info("DM.flush.AdamEntersVo:{}", mongoTemplate.remove(Query.query(Criteria.where("_id").exists(true)), AdamEntersVo.class.getSimpleName()).getDeletedCount());
} }
String sqlCount = "select count(1) from enters where (type <> 1 or (type = 1 and is_certification = 'yes'))"; String sqlCount = "select count(1) from enters where (type <> 1 or (type = 1 and is_certification = 'yes')) and created_at" + (StringUtils.isBlank(incrDt) ? "<" : ">=") + "curdate()";
String field = "id,user_id,type,`name`,mobile,idcode,if(is_default='no', 0, 1),created_at"; String field = "id,user_id,type,`name`,mobile,idcode,if(is_default='no', 0, 1),created_at";
// 1-id,2-user_id,3-type,4-`name`,5-mobile,6-idcode,7-if(is_default='no', 0, 1),8-created_at // 1-id,2-user_id,3-type,4-`name`,5-mobile,6-idcode,7-if(is_default='no', 0, 1),8-created_at
String sql = sqlCount.replace("count(1)", field); String sql = sqlCount.replace("count(1)", field);
...@@ -44,13 +45,13 @@ public class DMEntersProcessor extends DataMigrationProcessorService { ...@@ -44,13 +45,13 @@ public class DMEntersProcessor extends DataMigrationProcessorService {
sqlCount += " and user_id in ('2026628','544327','1997335','773650','809406','1167451','423063','677171')"; sqlCount += " and user_id in ('2026628','544327','1997335','773650','809406','1167451','423063','677171')";
sql += " and user_id in ('2026628','544327','1997335','773650','809406','1167451','423063','677171')"; sql += " and user_id in ('2026628','544327','1997335','773650','809406','1167451','423063','677171')";
} }
sql += " limit ?,?"; sql += " order by id limit ?,?";
statement = connection.prepareStatement(sqlCount); statement = connection.prepareStatement(sqlCount);
row = (ResultSetImpl) statement.executeQuery(); row = (ResultSetImpl) statement.executeQuery();
row.first(); row.first();
int ct = row.getInt(1), pSize = 1000, num = 0, tl = 0, pl = ct; int ct = row.getInt(1), pSize = 1000, num = 0, tl = 0, pl = ct;
log.info("DM.execute.counts:{}/{},{} ~ {} ----------------------------> start", pl, num, pSize, tl); log.info("DM.execute.counts:{}/{},{} ~ {} ----------------------------> start.sql:{}", pl, num, pSize, tl, sql);
while (ct > 0) { while (ct > 0) {
statement = connection.prepareStatement(sql); statement = connection.prepareStatement(sql);
......
...@@ -182,7 +182,8 @@ public class DMMemberCodeProcessor extends DataMigrationProcessorService { ...@@ -182,7 +182,8 @@ public class DMMemberCodeProcessor extends DataMigrationProcessorService {
@Override @Override
protected void dataProcessing() { protected void dataProcessing() {
HttpServletRequest request = ServletUtils.getRequest(); HttpServletRequest request = ServletUtils.getRequest();
String lS = request.getParameter(DM_LS), flg = StringUtils.defaultIfBlank(request.getParameter(DM_FLG), ""); String lS = request.getParameter(DM_LS), incrDt = request.getParameter(DM_INCR_DT),
flg = StringUtils.defaultIfBlank(request.getParameter(DM_FLG), "");
if (StringUtils.isNotEmpty(request.getParameter(DM_FLUSH))) { if (StringUtils.isNotEmpty(request.getParameter(DM_FLUSH))) {
log.info("DM.flush.member_code:{}", userMapper.executeForDM("adam_member_code")); log.info("DM.flush.member_code:{}", userMapper.executeForDM("adam_member_code"));
...@@ -190,17 +191,17 @@ public class DMMemberCodeProcessor extends DataMigrationProcessorService { ...@@ -190,17 +191,17 @@ public class DMMemberCodeProcessor extends DataMigrationProcessorService {
} }
String sqlCount = "select count(1) from vip_card_codes where buy_order_id <> use_order_id or status=0"; String sqlCount = "select count(1) from vip_card_codes where buy_order_id <> use_order_id or status=0";
String field = "vip_card_code,`type`+1,vip_card_id,vip_card_price_id,card_number,`status`,created_at,updated_at,buy_order_id,buy_uid,buy_time,use_order_id,use_uid,use_time"; String field = "vip_card_code,`type`+1,card_number,`status`,created_at,updated_at,buy_order_id,buy_uid,buy_time,use_order_id,use_uid,use_time";
// 1-vip_card_code,2-`type`+1,3-card_number,4-`status`,5-created_at,6-updated_at, // 1-vip_card_code,2-`type`+1,3-card_number,4-`status`,5-created_at,6-updated_at,
// 7-buy_order_id,8-buy_uid,9-buy_time,10-use_order_id,11-use_uid,12-use_time // 7-buy_order_id,8-buy_uid,9-buy_time,10-use_order_id,11-use_uid,12-use_time
String sql = sqlCount.replace("count(1)", field); String sql = sqlCount.replace("count(1)", field);
sql += " limit ?,?"; sql += " order by id limit ?,?";
statement = connection.prepareStatement(sqlCount); statement = connection.prepareStatement(sqlCount);
row = (ResultSetImpl) statement.executeQuery(); row = (ResultSetImpl) statement.executeQuery();
row.first(); row.first();
int ct = row.getInt(1), pSize = 1000, num = 0, tl = 0, pl = ct; int ct = row.getInt(1), pSize = 1000, num = 0, tl = 0, pl = ct;
log.info("DM.execute.counts:{}/{},{} ~ {} ----------------------------> start", pl, num, pSize, tl); log.info("DM.execute.counts:{}/{},{} ~ {} ----------------------------> start.sql:{}", pl, num, pSize, tl, sql);
while (ct > 0) { while (ct > 0) {
statement = connection.prepareStatement(sql); statement = connection.prepareStatement(sql);
......
...@@ -30,6 +30,7 @@ public class DMMemberOrderProcessor extends DataMigrationProcessorService { ...@@ -30,6 +30,7 @@ public class DMMemberOrderProcessor extends DataMigrationProcessorService {
// APPWEPAY|APPALIPAY|WAPWEPAY|WAPALIPAY|JSWEPAY|GIFT_CODE|VIP_CODE|APPLETWEPAY // APPWEPAY|APPALIPAY|WAPWEPAY|WAPALIPAY|JSWEPAY|GIFT_CODE|VIP_CODE|APPLETWEPAY
public static final Map<String, String> dfMap = new HashMap<>(); public static final Map<String, String> dfMap = new HashMap<>();
public static final Map<String, String> ptMap = new HashMap<>(); public static final Map<String, String> ptMap = new HashMap<>();
static { static {
dfMap.put("APPWEPAY", "app"); dfMap.put("APPWEPAY", "app");
dfMap.put("APPALIPAY", "app"); dfMap.put("APPALIPAY", "app");
...@@ -52,14 +53,15 @@ public class DMMemberOrderProcessor extends DataMigrationProcessorService { ...@@ -52,14 +53,15 @@ public class DMMemberOrderProcessor extends DataMigrationProcessorService {
@Override @Override
protected void dataProcessing() { protected void dataProcessing() {
HttpServletRequest request = ServletUtils.getRequest(); HttpServletRequest request = ServletUtils.getRequest();
String lS = request.getParameter(DM_LS), flg = StringUtils.defaultIfBlank(request.getParameter(DM_FLG), ""); String lS = request.getParameter(DM_LS), incrDt = request.getParameter(DM_INCR_DT),
flg = StringUtils.defaultIfBlank(request.getParameter(DM_FLG), "");
if (StringUtils.isNotEmpty(request.getParameter(DM_FLUSH))) { if (StringUtils.isNotEmpty(request.getParameter(DM_FLUSH))) {
log.info("DM.flush.member_order:{}", userMapper.executeForDM("adam_member_order")); log.info("DM.flush.member_order:{}", userMapper.executeForDM("adam_member_order"));
log.info("DM.flush.AdamMemberOrderVo:{}", mongoTemplate.remove(Query.query(Criteria.where("_id").exists(true)), AdamMemberOrderVo.class.getSimpleName()).getDeletedCount()); log.info("DM.flush.AdamMemberOrderVo:{}", mongoTemplate.remove(Query.query(Criteria.where("_id").exists(true)), AdamMemberOrderVo.class.getSimpleName()).getDeletedCount());
} }
String sqlCount = "select count(1) from user_vip_card_orders where status in (1,5)"; String sqlCount = "select count(1) from user_vip_card_orders where status in (1,5) and created_at" + (StringUtils.isBlank(incrDt) ? "<" : ">=") + "curdate()";
String field = "order_code,uid,order_sub_type,vip_card_price,price,status,card_number,birthday,pay_type,pay_code,pay_at,created_at,updated_at,client_ip,source,version"; String field = "order_code,uid,order_sub_type,vip_card_price,price,status,card_number,birthday,pay_type,pay_code,pay_at,created_at,updated_at,client_ip,source,version";
// 1-order_code,2-uid,3-order_sub_type,4-vip_card_price,5-price,6-status,7-card_number,8-birthday, // 1-order_code,2-uid,3-order_sub_type,4-vip_card_price,5-price,6-status,7-card_number,8-birthday,
// 9-pay_type,10-pay_code,11-pay_at,12-created_at,13-updated_at,14-client_ip,15-source,16-version // 9-pay_type,10-pay_code,11-pay_at,12-created_at,13-updated_at,14-client_ip,15-source,16-version
...@@ -68,13 +70,13 @@ public class DMMemberOrderProcessor extends DataMigrationProcessorService { ...@@ -68,13 +70,13 @@ public class DMMemberOrderProcessor extends DataMigrationProcessorService {
sqlCount += " and uid in ('2026628','544327','1997335','773650','809406','1167451','423063','677171')"; sqlCount += " and uid in ('2026628','544327','1997335','773650','809406','1167451','423063','677171')";
sql += " and uid in ('2026628','544327','1997335','773650','809406','1167451','423063','677171')"; sql += " and uid in ('2026628','544327','1997335','773650','809406','1167451','423063','677171')";
} }
sql += " limit ?,?"; sql += " order by id limit ?,?";
statement = connection.prepareStatement(sqlCount); statement = connection.prepareStatement(sqlCount);
row = (ResultSetImpl) statement.executeQuery(); row = (ResultSetImpl) statement.executeQuery();
row.first(); row.first();
int ct = row.getInt(1), pSize = 1000, num = 0, tl = 0, pl = ct; int ct = row.getInt(1), pSize = 1000, num = 0, tl = 0, pl = ct;
log.info("DM.execute.counts:{}/{},{} ~ {} ----------------------------> start", pl, num, pSize, tl); log.info("DM.execute.counts:{}/{},{} ~ {} ----------------------------> start.sql:{}", pl, num, pSize, tl, sql);
while (ct > 0) { while (ct > 0) {
statement = connection.prepareStatement(sql); statement = connection.prepareStatement(sql);
......
...@@ -29,14 +29,15 @@ public class DMRealNameProcessor extends DataMigrationProcessorService { ...@@ -29,14 +29,15 @@ public class DMRealNameProcessor extends DataMigrationProcessorService {
@Override @Override
protected void dataProcessing() { protected void dataProcessing() {
HttpServletRequest request = ServletUtils.getRequest(); HttpServletRequest request = ServletUtils.getRequest();
String lS = request.getParameter(DM_LS), flg = StringUtils.defaultIfBlank(request.getParameter(DM_FLG), ""); String lS = request.getParameter(DM_LS), incrDt = request.getParameter(DM_INCR_DT),
flg = StringUtils.defaultIfBlank(request.getParameter(DM_FLG), "");
if (StringUtils.isNotEmpty(request.getParameter(DM_FLUSH))) { if (StringUtils.isNotEmpty(request.getParameter(DM_FLUSH))) {
log.info("DM.flush.real_name:{}", userMapper.executeForDM("adam_real_name")); log.info("DM.flush.real_name:{}", userMapper.executeForDM("adam_real_name"));
log.info("DM.flush.AdamRealInfoVo:{}", mongoTemplate.remove(Query.query(Criteria.where("_id").exists(true)), AdamRealInfoVo.class.getSimpleName()).getDeletedCount()); log.info("DM.flush.AdamRealInfoVo:{}", mongoTemplate.remove(Query.query(Criteria.where("_id").exists(true)), AdamRealInfoVo.class.getSimpleName()).getDeletedCount());
} }
String sqlCount = "select count(1) from user_real_name where 1=1"; String sqlCount = "select count(1) from user_real_name where id not in (9145,7456,7448,7197,7194,4137,4138,4139,269,261,262,263,264,265,266,267,251) and created_at" + (StringUtils.isBlank(incrDt) ? "<" : ">=") + "curdate()";
String field = "id,uid,real_name,id_card,ifnull(created_at, '1970-01-01 00:00:00') created_at,updated_at"; String field = "id,uid,real_name,id_card,ifnull(created_at, '1970-01-01 00:00:00') created_at,updated_at";
// 1-id,2-uid,3-real_name,4-id_card,5-created_at,6-updated_at // 1-id,2-uid,3-real_name,4-id_card,5-created_at,6-updated_at
String sql = sqlCount.replace("count(1)", field); String sql = sqlCount.replace("count(1)", field);
...@@ -44,13 +45,13 @@ public class DMRealNameProcessor extends DataMigrationProcessorService { ...@@ -44,13 +45,13 @@ public class DMRealNameProcessor extends DataMigrationProcessorService {
sqlCount += " and uid in ('2026628','544327','1997335','773650','809406','1167451','423063','677171')"; sqlCount += " and uid in ('2026628','544327','1997335','773650','809406','1167451','423063','677171')";
sql += " and uid in ('2026628','544327','1997335','773650','809406','1167451','423063','677171')"; sql += " and uid in ('2026628','544327','1997335','773650','809406','1167451','423063','677171')";
} }
sql += " limit ?,?"; sql += " order by id limit ?,?";
statement = connection.prepareStatement(sqlCount); statement = connection.prepareStatement(sqlCount);
row = (ResultSetImpl) statement.executeQuery(); row = (ResultSetImpl) statement.executeQuery();
row.first(); row.first();
int ct = row.getInt(1), pSize = 1000, num = 0, tl = 0, pl = ct; int ct = row.getInt(1), pSize = 1000, num = 0, tl = 0, pl = ct;
log.info("DM.execute.counts:{}/{},{} ~ {} ----------------------------> start", pl, num, pSize, tl); log.info("DM.execute.counts:{}/{},{} ~ {} ----------------------------> start.sql:{}", pl, num, pSize, tl, sql);
while (ct > 0) { while (ct > 0) {
statement = connection.prepareStatement(sql); statement = connection.prepareStatement(sql);
......
...@@ -29,7 +29,8 @@ public class DMThirdPartsProcessor extends DataMigrationProcessorService { ...@@ -29,7 +29,8 @@ public class DMThirdPartsProcessor extends DataMigrationProcessorService {
@Override @Override
protected void dataProcessing() { protected void dataProcessing() {
HttpServletRequest request = ServletUtils.getRequest(); HttpServletRequest request = ServletUtils.getRequest();
String lS = request.getParameter(DM_LS), flg = StringUtils.defaultIfBlank(request.getParameter(DM_FLG), ""); String lS = request.getParameter(DM_LS), incrDt = request.getParameter(DM_INCR_DT),
flg = StringUtils.defaultIfBlank(request.getParameter(DM_FLG), "");
if (StringUtils.isNotEmpty(request.getParameter(DM_FLUSH))) { if (StringUtils.isNotEmpty(request.getParameter(DM_FLUSH))) {
log.info("DM.flush.third_party:{}", userMapper.executeForDM("adam_third_party")); log.info("DM.flush.third_party:{}", userMapper.executeForDM("adam_third_party"));
...@@ -37,8 +38,8 @@ public class DMThirdPartsProcessor extends DataMigrationProcessorService { ...@@ -37,8 +38,8 @@ public class DMThirdPartsProcessor extends DataMigrationProcessorService {
} }
String sqlCount = "select count(1) from (\n" + String sqlCount = "select count(1) from (\n" +
" select row_number() over (partition by uid,type order by created_at desc) rn,uid,open_id,avatar,nickname,type,created_at,updated_at from user_third_parts where `status`=1 and delete_tag in (0,1) and open_id<>'' and uid>0\n" + " select row_number() over (partition by uid,type order by created_at desc) rn,id,uid,open_id,avatar,nickname,type,created_at,updated_at from user_third_parts where `status`=1 and delete_tag in (0,1) and open_id<>'' and uid>0 and created_at"+(StringUtils.isBlank(incrDt) ? "<" : ">=")+"curdate()\n" +
" ) t where t.rn = 1"; " ) t where t.rn=1";
String field = "uid,open_id,avatar,nickname,type,created_at,updated_at"; String field = "uid,open_id,avatar,nickname,type,created_at,updated_at";
// 1-uid,2-open_id,3-avatar,4-nickname,5-type,6-created_at,7-updated_at // 1-uid,2-open_id,3-avatar,4-nickname,5-type,6-created_at,7-updated_at
String sql = sqlCount.replace("count(1)", field); String sql = sqlCount.replace("count(1)", field);
...@@ -46,13 +47,13 @@ public class DMThirdPartsProcessor extends DataMigrationProcessorService { ...@@ -46,13 +47,13 @@ public class DMThirdPartsProcessor extends DataMigrationProcessorService {
sqlCount += " and uid in ('2026628','544327','1997335','773650','809406','1167451','423063','677171')"; sqlCount += " and uid in ('2026628','544327','1997335','773650','809406','1167451','423063','677171')";
sql += " and uid in ('2026628','544327','1997335','773650','809406','1167451','423063','677171')"; sql += " and uid in ('2026628','544327','1997335','773650','809406','1167451','423063','677171')";
} }
sql += " limit ?,?"; sql += " order by id limit ?,?";
statement = connection.prepareStatement(sqlCount); statement = connection.prepareStatement(sqlCount);
row = (ResultSetImpl) statement.executeQuery(); row = (ResultSetImpl) statement.executeQuery();
row.first(); row.first();
int ct = row.getInt(1), pSize = 1000, num = 0, tl = 0, pl = ct; int ct = row.getInt(1), pSize = 1000, num = 0, tl = 0, pl = ct;
log.info("DM.execute.counts:{}/{},{} ~ {} ----------------------------> start", pl, num, pSize, tl); log.info("DM.execute.counts:{}/{},{} ~ {} ----------------------------> start.sql:{}", pl, num, pSize, tl, sql);
while (ct > 0) { while (ct > 0) {
statement = connection.prepareStatement(sql); statement = connection.prepareStatement(sql);
......
...@@ -40,6 +40,7 @@ public class DMUserInformationProcessor extends DataMigrationProcessorService { ...@@ -40,6 +40,7 @@ public class DMUserInformationProcessor extends DataMigrationProcessorService {
public static final String DM_FAILED_USER = "dm:failed:uid"; public static final String DM_FAILED_USER = "dm:failed:uid";
public static final String DM_EXISTS_USER = "dm:exists:uid"; public static final String DM_EXISTS_USER = "dm:exists:uid";
public static Map<String, AdamTagVo> sexMap = new HashMap<>(); public static Map<String, AdamTagVo> sexMap = new HashMap<>();
static { static {
sexMap.put("SECRET", AdamTagVo.getNew().setVal("MS00").setDesc("保密")); sexMap.put("SECRET", AdamTagVo.getNew().setVal("MS00").setDesc("保密"));
sexMap.put("MALE", AdamTagVo.getNew().setVal("MS01").setDesc("男性")); sexMap.put("MALE", AdamTagVo.getNew().setVal("MS01").setDesc("男性"));
...@@ -50,7 +51,8 @@ public class DMUserInformationProcessor extends DataMigrationProcessorService { ...@@ -50,7 +51,8 @@ public class DMUserInformationProcessor extends DataMigrationProcessorService {
@Override @Override
protected void dataProcessing() { protected void dataProcessing() {
HttpServletRequest request = ServletUtils.getRequest(); HttpServletRequest request = ServletUtils.getRequest();
String lS = request.getParameter(DM_LS), flg = StringUtils.defaultIfBlank(request.getParameter(DM_FLG), ""); String lS = request.getParameter(DM_LS), incrDt = request.getParameter(DM_INCR_DT),
flg = StringUtils.defaultIfBlank(request.getParameter(DM_FLG), "");
if (StringUtils.isNotEmpty(request.getParameter(DM_FLUSH))) { if (StringUtils.isNotEmpty(request.getParameter(DM_FLUSH))) {
log.info("DM.flush.user:{}", userMapper.executeForDM("adam_user")); log.info("DM.flush.user:{}", userMapper.executeForDM("adam_user"));
log.info("DM.flush.user_info:{}", userMapper.executeForDM("adam_user_info")); log.info("DM.flush.user_info:{}", userMapper.executeForDM("adam_user_info"));
...@@ -58,7 +60,7 @@ public class DMUserInformationProcessor extends DataMigrationProcessorService { ...@@ -58,7 +60,7 @@ public class DMUserInformationProcessor extends DataMigrationProcessorService {
log.info("DM.flush.AdamUserInfoVo:{}", mongoTemplate.remove(Query.query(Criteria.where("_id").exists(true)), AdamUserInfoVo.class.getSimpleName()).getDeletedCount()); log.info("DM.flush.AdamUserInfoVo:{}", mongoTemplate.remove(Query.query(Criteria.where("_id").exists(true)), AdamUserInfoVo.class.getSimpleName()).getDeletedCount());
} }
String sqlCount = "select count(1) from users where delete_tag in (0,1) and length(mobile)=11 "; String sqlCount = "select count(1) from users where delete_tag in (0,1) and length(mobile)=11 and created_at" + (StringUtils.isBlank(incrDt) ? "<" : ">=") + "curdate()";
String field = "uid,mobile,username,sex,birthday,area,sign,face_url,back_url,created_at,updated_at,is_complete,rong_cloud_token,rong_cloud_tag"; String field = "uid,mobile,username,sex,birthday,area,sign,face_url,back_url,created_at,updated_at,is_complete,rong_cloud_token,rong_cloud_tag";
// 1-uid,2-mobile,3-username,4-sex,5-birthday,6-area,7-sign,8-face_url,9-back_url,10-created_at,11-updated_at,12-is_complete,13-rong_cloud_token,14-rong_cloud_tag // 1-uid,2-mobile,3-username,4-sex,5-birthday,6-area,7-sign,8-face_url,9-back_url,10-created_at,11-updated_at,12-is_complete,13-rong_cloud_token,14-rong_cloud_tag
String sql = sqlCount.replace("count(1)", field); String sql = sqlCount.replace("count(1)", field);
...@@ -66,13 +68,13 @@ public class DMUserInformationProcessor extends DataMigrationProcessorService { ...@@ -66,13 +68,13 @@ public class DMUserInformationProcessor extends DataMigrationProcessorService {
sqlCount += "and mobile in ('13753596360','17701223310','18518013286','18548596019','15901093014','17382319723','13631444097','13671737873')"; sqlCount += "and mobile in ('13753596360','17701223310','18518013286','18548596019','15901093014','17382319723','13631444097','13671737873')";
sql += " and mobile in ('13753596360','17701223310','18518013286','18548596019','15901093014','17382319723','13631444097','13671737873')"; sql += " and mobile in ('13753596360','17701223310','18518013286','18548596019','15901093014','17382319723','13631444097','13671737873')";
} }
sql += " limit ?,?"; sql += " order by uid limit ?,?";
statement = connection.prepareStatement(sqlCount); statement = connection.prepareStatement(sqlCount);
row = (ResultSetImpl) statement.executeQuery(); row = (ResultSetImpl) statement.executeQuery();
row.first(); row.first();
int ct = row.getInt(1), pSize = 1000, num = 0, tl = 0, pl = ct; int ct = row.getInt(1), pSize = 1000, num = 0, tl = 0, pl = ct;
log.info("DM.execute.counts:{}/{},{} ~ {} ----------------------------> start", pl, num, pSize, tl); log.info("DM.execute.counts:{}/{},{} ~ {} ----------------------------> start.sql:{}", pl, num, pSize, tl, sql);
while (ct > 0) { while (ct > 0) {
statement = connection.prepareStatement(sql); statement = connection.prepareStatement(sql);
...@@ -93,45 +95,45 @@ public class DMUserInformationProcessor extends DataMigrationProcessorService { ...@@ -93,45 +95,45 @@ public class DMUserInformationProcessor extends DataMigrationProcessorService {
// if (userMapper.selectCount(Wrappers.lambdaQuery(AdamUser.class).eq(AdamUser::getUid, uid)) > 0) { // if (userMapper.selectCount(Wrappers.lambdaQuery(AdamUser.class).eq(AdamUser::getUid, uid)) > 0) {
// redisUtil.lSet(DM_EXISTS_USER, uid); // redisUtil.lSet(DM_EXISTS_USER, uid);
// } else { // } else {
AdamUser user = new AdamUser(); AdamUser user = new AdamUser();
user.setUid(uid); user.setUid(uid);
user.setMobile(row.getString(2)); user.setMobile(row.getString(2));
user.setCreatedAt(row.getLocalDateTime(10)); user.setCreatedAt(row.getLocalDateTime(10));
user.setUpdatedAt(row.getLocalDateTime(11)); user.setUpdatedAt(row.getLocalDateTime(11));
user.setState(1); user.setState(1);
AdamUserInfo userInfo = new AdamUserInfo(); AdamUserInfo userInfo = new AdamUserInfo();
userInfo.setUid(user.getUid()); userInfo.setUid(user.getUid());
userInfo.setNickname(row.getString(3)); userInfo.setNickname(row.getString(3));
userInfo.setSex(JsonUtils.toJson(sex)); userInfo.setSex(JsonUtils.toJson(sex));
userInfo.setBirthday(row.getLocalDate(5)); userInfo.setBirthday(row.getLocalDate(5));
userInfo.setArea(row.getString(6)); userInfo.setArea(row.getString(6));
userInfo.setSignature(row.getString(7)); userInfo.setSignature(row.getString(7));
userInfo.setAvatar(row.getString(8)); userInfo.setAvatar(row.getString(8));
userInfo.setBackground(row.getString(9)); userInfo.setBackground(row.getString(9));
userInfo.setQrCode("lN".concat(userInfo.getUid()).concat(RandomStringUtils.randomAlphanumeric(5).toUpperCase())); userInfo.setQrCode("lN".concat(userInfo.getUid()).concat(RandomStringUtils.randomAlphanumeric(5).toUpperCase()));
userInfo.setRongCloudToken(row.getString(13)); userInfo.setRongCloudToken(row.getString(13));
userInfo.setRongCloudTag(row.getInt(14)); userInfo.setRongCloudTag(row.getInt(14));
AdamUserInfoVo vo = AdamUserInfoVo.getNew(); AdamUserInfoVo vo = AdamUserInfoVo.getNew();
vo.setUid(user.getUid()); vo.setUid(user.getUid());
vo.setMobile(user.getMobile()); vo.setMobile(user.getMobile());
vo.setNickname(userInfo.getNickname()); vo.setNickname(userInfo.getNickname());
vo.setState(user.getState()); vo.setState(user.getState());
vo.setSex(sex); vo.setSex(sex);
vo.setBirthday(DateUtil.Formatter.yyyy_MM_dd.format(userInfo.getBirthday())); vo.setBirthday(DateUtil.Formatter.yyyy_MM_dd.format(userInfo.getBirthday()));
vo.setArea(userInfo.getArea()); vo.setArea(userInfo.getArea());
vo.setSignature(userInfo.getSignature()); vo.setSignature(userInfo.getSignature());
vo.setAvatar(userInfo.getAvatar()); vo.setAvatar(userInfo.getAvatar());
vo.setBackground(userInfo.getBackground()); vo.setBackground(userInfo.getBackground());
vo.setCreateAt(user.getCreatedAt()); vo.setCreateAt(user.getCreatedAt());
vo.setUpdatedAt(user.getUpdatedAt()); vo.setUpdatedAt(user.getUpdatedAt());
vo.setIsComplete(row.getInt(12)); vo.setIsComplete(row.getInt(12));
vo.setQrCode(userInfo.getQrCode()); vo.setQrCode(userInfo.getQrCode());
userList.add(user); userList.add(user);
userInfoList.add(userInfo); userInfoList.add(userInfo);
vos.add(vo); vos.add(vo);
// } // }
} }
} catch (SQLException throwables) { } catch (SQLException throwables) {
......
...@@ -29,14 +29,15 @@ public class DMUserMemberProcessor extends DataMigrationProcessorService { ...@@ -29,14 +29,15 @@ public class DMUserMemberProcessor extends DataMigrationProcessorService {
@Override @Override
protected void dataProcessing() { protected void dataProcessing() {
HttpServletRequest request = ServletUtils.getRequest(); HttpServletRequest request = ServletUtils.getRequest();
String lS = request.getParameter(DM_LS), flg = StringUtils.defaultIfBlank(request.getParameter(DM_FLG), ""); String lS = request.getParameter(DM_LS), incrDt = request.getParameter(DM_INCR_DT),
flg = StringUtils.defaultIfBlank(request.getParameter(DM_FLG), "");
if (StringUtils.isNotEmpty(request.getParameter(DM_FLUSH))) { if (StringUtils.isNotEmpty(request.getParameter(DM_FLUSH))) {
log.info("DM.flush.user_member:{}", userMapper.executeForDM("adam_user_member")); log.info("DM.flush.user_member:{}", userMapper.executeForDM("adam_user_member"));
log.info("DM.flush.AdamUserMemberVo:{}", mongoTemplate.remove(Query.query(Criteria.where("_id").exists(true)), AdamUserMemberVo.class.getSimpleName()).getDeletedCount()); log.info("DM.flush.AdamUserMemberVo:{}", mongoTemplate.remove(Query.query(Criteria.where("_id").exists(true)), AdamUserMemberVo.class.getSimpleName()).getDeletedCount());
} }
String sqlCount = "select count(1) from user_cards where 1=1"; String sqlCount = "select count(1) from user_cards where created_at" + (StringUtils.isBlank(incrDt) ? "<" : ">=") + "curdate()";
String field = "uid,card_id,card_number,`status`,expired_at,created_at,updated_at"; String field = "uid,card_id,card_number,`status`,expired_at,created_at,updated_at";
// 1-uid,2-card_id,3-card_number,4-status,5-expired_at,6-created_at,7-updated_at // 1-uid,2-card_id,3-card_number,4-status,5-expired_at,6-created_at,7-updated_at
String sql = sqlCount.replace("count(1)", field); String sql = sqlCount.replace("count(1)", field);
...@@ -44,13 +45,13 @@ public class DMUserMemberProcessor extends DataMigrationProcessorService { ...@@ -44,13 +45,13 @@ public class DMUserMemberProcessor extends DataMigrationProcessorService {
sqlCount += " and uid in ('2026628','544327','1997335','773650','809406','1167451','423063','677171')"; sqlCount += " and uid in ('2026628','544327','1997335','773650','809406','1167451','423063','677171')";
sql += " and uid in ('2026628','544327','1997335','773650','809406','1167451','423063','677171')"; sql += " and uid in ('2026628','544327','1997335','773650','809406','1167451','423063','677171')";
} }
sql += " limit ?,?"; sql += " order by id limit ?,?";
statement = connection.prepareStatement(sqlCount); statement = connection.prepareStatement(sqlCount);
row = (ResultSetImpl) statement.executeQuery(); row = (ResultSetImpl) statement.executeQuery();
row.first(); row.first();
int ct = row.getInt(1), pSize = 1000, num = 0, tl = 0, pl = ct; int ct = row.getInt(1), pSize = 1000, num = 0, tl = 0, pl = ct;
log.info("DM.execute.counts:{}/{},{} ~ {} ----------------------------> start", pl, num, pSize, tl); log.info("DM.execute.counts:{}/{},{} ~ {} ----------------------------> start.sql:{}", pl, num, pSize, tl, sql);
while (ct > 0) { while (ct > 0) {
statement = connection.prepareStatement(sql); statement = connection.prepareStatement(sql);
......
package com.liquidnet.service.adam.test;
import com.liquidnet.common.mq.constant.MQConst;
import com.liquidnet.service.adam.dto.vo.AdamThirdPartInfoVo;
import com.liquidnet.service.adam.dto.vo.AdamUserInfoVo;
import com.liquidnet.service.adam.dto.vo.AdamUserMemberVo;
import com.liquidnet.service.base.SqlMapping;
import lombok.extern.slf4j.Slf4j;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.util.CollectionUtils;
import java.time.LocalDateTime;
import java.util.LinkedList;
import java.util.List;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: TODO
* @class: TestRabbitMq
* @Package com.liquidnet.service.adam.test
* @Copyright: LightNet @ Copyright (c) 2021
* @date 2021/6/24 14:18
*/
@Slf4j
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest
public class TestRabbitMq {
@Autowired
RabbitTemplate rabbitTemplate;
@Test
public void testRibbitMqConn(){
LocalDateTime now = LocalDateTime.now();
LinkedList<String> toMqSqls = new LinkedList<>();
toMqSqls.add(SqlMapping.get("adam_user.close"));
LinkedList<Object[]> objsUser = new LinkedList<>();
objsUser.add(new Object[]{now, now, "0001"});
objsUser.add(new Object[]{now, now, "0002"});
objsUser.add(new Object[]{now, now, "0003"});
for(int i=0;i<100000;i++){
try {
Thread.sleep(200l);
} catch (InterruptedException e) {
e.printStackTrace();
}
objsUser.add(new Object[]{now, now, "000"+i});
}
long s = System.currentTimeMillis();
rabbitTemplate.convertAndSend(MQConst.EX_LNS_SQL_UCENTER, MQConst.RK_SQL_UCENTER,
SqlMapping.gets(toMqSqls, objsUser));
log.debug("#MQ耗时:{}ms", System.currentTimeMillis() - s);
}
}
...@@ -36,6 +36,11 @@ ...@@ -36,6 +36,11 @@
<artifactId>liquidnet-common-cache-redis</artifactId> <artifactId>liquidnet-common-cache-redis</artifactId>
<version>1.0-SNAPSHOT</version> <version>1.0-SNAPSHOT</version>
</dependency> </dependency>
<dependency>
<groupId>com.liquidnet</groupId>
<artifactId>liquidnet-service-kylin-api</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies> </dependencies>
<build> <build>
......
package com.liquidnet.service.consumer.service.Utils;
import com.liquidnet.common.cache.redis.util.RedisUtil;
import com.liquidnet.service.kylin.constant.KylinRedisConst;
import com.liquidnet.service.kylin.dto.vo.middle.KylinTicketTimesVo;
import com.liquidnet.service.kylin.dto.vo.middle.KylinTicketVo;
import com.liquidnet.service.kylin.dto.vo.mongo.KylinOrderTicketVo;
import com.liquidnet.service.kylin.dto.vo.mongo.KylinPerformanceVo;
import com.liquidnet.service.kylin.dto.vo.returns.KylinOrderListVo;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@Component
public class KylinUtils {
@Autowired
private RedisUtil redisUtil;
/**
* @param userId 用户id
* @param type 1新增 2修改
* @param orderId 订单id [需要新增或者修改的订单id]
*/
public Boolean resetOrderListVo(String userId, Integer type, String orderId, KylinOrderTicketVo dataSingle) {
List<KylinOrderListVo> vo = new ArrayList<>();
List<KylinOrderListVo> redisVo = new ArrayList();
KylinOrderListVo voItem = new KylinOrderListVo();
KylinOrderTicketVo data;
if (dataSingle == null) {
data = (KylinOrderTicketVo)redisUtil.get(KylinRedisConst.ORDER + orderId);
} else {
data = dataSingle;
}
BeanUtils.copyProperties(data, voItem);
List<KylinOrderListVo> redisData = (List<KylinOrderListVo>) redisUtil.get(KylinRedisConst.ORDER_LIST + userId);
if(type == 1) {
redisVo.add(voItem);
if (redisData.size() > 0) {
if (redisData.get(0).getOrderTicketsId().equals(orderId)) {
redisData.remove(0);
}
}
}
redisVo.addAll(redisData);
switch (type) {
case 1:
for (int i = 0; i < redisVo.size(); i++) {
if (i == 40) {
break;
}
if (i == 0) {
vo.add(voItem);
} else {
vo.add(redisVo.get(i));
}
}
if (redisVo.size() == 0) {
vo.add(voItem);
}
redisUtil.set(KylinRedisConst.ORDER_LIST + userId,vo);
return true;
case 2:
for (int i = 0; i < redisVo.size(); i++) {
if (i == 40) {
break;
}
if (redisVo.get(i).getOrderTicketsId().equals(orderId)) {
vo.add(voItem);
} else {
vo.add(redisVo.get(i));
}
}
redisUtil.set(KylinRedisConst.ORDER_LIST + userId,vo);
return true;
default:
return false;
}
}
public void changeBuyInfo(String userId, String idCard, String performanceId, String ticketId, int buyCount) {
String redisKey;
KylinPerformanceVo vo = (KylinPerformanceVo) redisUtil.get(KylinRedisConst.PERFORMANCES + performanceId);
int isTrueName = vo.getIsTrueName();
int ticketType = 0;
String useTime = "";
HashMap<String, ArrayList<String>> allTicketId = new HashMap<>();
for (int x = 0; x < vo.getTicketTimeList().size(); x++) {
KylinTicketTimesVo timeItem = vo.getTicketTimeList().get(x);
ArrayList<String> ticketList = new ArrayList<>();
for (int y = 0; y < timeItem.getTicketList().size(); y++) {
KylinTicketVo ticketItem = timeItem.getTicketList().get(y);
if (ticketItem.getType() == 1) {
ticketList.add(ticketItem.getTicketsId());
}
if (ticketItem.getTicketsId().equals(ticketId)) {
useTime = ticketItem.getUseStart();
ticketType = ticketItem.getType();
}
}
allTicketId.put(timeItem.getUseStart(), ticketList);
}
if (0 == isTrueName) {
redisKey = KylinRedisConst.USERID_BUY_INFO + userId;
} else {
redisKey = KylinRedisConst.IDCARD_BUY_INFO + idCard;
}
String performanceIdKey = redisKey + ":" + KylinRedisConst.PERFORMANCE_ID + ":" + performanceId;
String ticketIdKey = redisKey + ":" + KylinRedisConst.TICKET_ID + ":" + ticketId;
String ticketUseTimeKey = ticketIdKey + ":" + KylinRedisConst.USE_TIME;
redisUtil.set(ticketUseTimeKey, useTime);
if (buyCount > 0) {
redisUtil.incr(ticketIdKey, buyCount);
if (1 == ticketType) {
int count = 0;
for (int i = 0; i < allTicketId.get(useTime).size(); i++) {
String item = allTicketId.get(useTime).get(i);
if (allTicketId.get(useTime).size() == 1) {
redisUtil.incr(performanceIdKey, buyCount);
break;
}
if (null == redisUtil.get(redisKey + ":" + KylinRedisConst.TICKET_ID + ":" + item)) {
redisUtil.set(redisKey + ":" + KylinRedisConst.TICKET_ID + ":" + item, 0);
}
if (i == 0) {
count = (int) redisUtil.get(redisKey + ":" + KylinRedisConst.TICKET_ID + ":" + item);
} else {
if (count != (int) redisUtil.get(redisKey + ":" + KylinRedisConst.TICKET_ID + ":" + item)) {
redisUtil.incr(performanceIdKey, buyCount);
break;
}
}
}
} else {
redisUtil.incr(performanceIdKey, buyCount);
}
} else {
redisUtil.decr(ticketIdKey, Math.abs(buyCount));
if (1 == ticketType) {
int count = 0;
for (int i = 0; i < allTicketId.get(useTime).size(); i++) {
String item = allTicketId.get(useTime).get(i);
if (allTicketId.get(useTime).size() == 1) {
redisUtil.decr(performanceIdKey, Math.abs(buyCount));
break;
}
if (null == redisUtil.get(redisKey + ":" + KylinRedisConst.TICKET_ID + ":" + item)) {
redisUtil.set(redisKey + ":" + KylinRedisConst.TICKET_ID + ":" + item, 0);
}
if (i == 0) {
count = (int) redisUtil.get(redisKey + ":" + KylinRedisConst.TICKET_ID + ":" + item);
} else {
if (count != (int) redisUtil.get(redisKey + ":" + KylinRedisConst.TICKET_ID + ":" + item)) {
redisUtil.decr(performanceIdKey, Math.abs(buyCount));
break;
}
}
}
} else {
redisUtil.decr(performanceIdKey, Math.abs(buyCount));
}
}
}
}
...@@ -3,10 +3,15 @@ package com.liquidnet.service.consumer.service.processor; ...@@ -3,10 +3,15 @@ package com.liquidnet.service.consumer.service.processor;
import com.liquidnet.common.cache.redis.util.RedisUtil; import com.liquidnet.common.cache.redis.util.RedisUtil;
import com.liquidnet.common.mq.constant.MQConst; import com.liquidnet.common.mq.constant.MQConst;
import com.liquidnet.commons.lang.util.JsonUtils; import com.liquidnet.commons.lang.util.JsonUtils;
import com.liquidnet.service.base.OrderCloseMapping;
import com.liquidnet.service.base.SqlMapping; import com.liquidnet.service.base.SqlMapping;
import com.liquidnet.service.consumer.service.IBaseDao; import com.liquidnet.service.consumer.service.IBaseDao;
import com.liquidnet.service.consumer.service.Utils.KylinUtils;
import com.liquidnet.service.kylin.dto.vo.mongo.KylinOrderTicketEntitiesVo;
import com.liquidnet.service.kylin.dto.vo.mongo.KylinOrderTicketVo;
import com.rabbitmq.client.Channel; import com.rabbitmq.client.Channel;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringEscapeUtils;
import org.springframework.amqp.rabbit.annotation.Exchange; import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue; import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding; import org.springframework.amqp.rabbit.annotation.QueueBinding;
...@@ -17,8 +22,6 @@ import org.springframework.amqp.core.Message; ...@@ -17,8 +22,6 @@ import org.springframework.amqp.core.Message;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList;
import java.util.LinkedList;
/** /**
* ConsumerProcessor.class * ConsumerProcessor.class
...@@ -33,6 +36,8 @@ public class ConsumerProcessor { ...@@ -33,6 +36,8 @@ public class ConsumerProcessor {
IBaseDao baseDao; IBaseDao baseDao;
@Autowired @Autowired
private RedisUtil redisUtil; private RedisUtil redisUtil;
@Autowired
private KylinUtils kylinUtils;
// @RabbitListener(bindings = @QueueBinding( // @RabbitListener(bindings = @QueueBinding(
// exchange = @Exchange(MQConst.EXCHANGES_LIQUIDNET_SQL), key = MQConst.ROUTING_KEY_SQL, // exchange = @Exchange(MQConst.EXCHANGES_LIQUIDNET_SQL), key = MQConst.ROUTING_KEY_SQL,
...@@ -80,20 +85,28 @@ public class ConsumerProcessor { ...@@ -80,20 +85,28 @@ public class ConsumerProcessor {
} }
// 处理长sql语句 // 处理长sql语句
private void consumerSqlDaoHandlerLongSql(Message msg, Channel channel) { private void consumerOperationOrderClose(Message msg, Channel channel) {
String redisKey = new String(msg.getBody()).replaceAll("\"",""); String jsonStr = StringEscapeUtils.unescapeJava(new String(msg.getBody()));
OrderCloseMapping.orderCloseMessage mqMessage = JsonUtils.fromJson(jsonStr.substring(1,jsonStr.length()-1), OrderCloseMapping.orderCloseMessage.class);
log.debug("consumer ==> redisKey:{}", redisKey); log.debug("consumer ==> mqMessage:{}", mqMessage);
try { try {
LinkedList<String> sqlList = (LinkedList<String>) redisUtil.get(redisKey); mqMessage.getOrderTicketIds().forEach(t -> {
Boolean rstBatchSqls = baseDao.batchSqlNoArgs(sqlList); String orderTicketId = t.split(",")[0];
log.debug("consumer sql result of execution:{}", rstBatchSqls); String uid = t.split(",")[1];
if (rstBatchSqls) { KylinOrderTicketVo vo = (KylinOrderTicketVo) redisUtil.get("kylin:order:id:" + orderTicketId);
channel.basicAck(msg.getMessageProperties().getDeliveryTag(), false); vo.setStatus(2);
} else { redisUtil.set("kylin:order:id:" + orderTicketId, vo);
channel.basicReject(msg.getMessageProperties().getDeliveryTag(), true);
} kylinUtils.resetOrderListVo(uid, 2, orderTicketId, vo);
} catch (IOException e) { // redis 限购
for (int i = 0; i < vo.getEntitiesVoList().size(); i++) {
KylinOrderTicketEntitiesVo items = vo.getEntitiesVoList().get(i);
kylinUtils.changeBuyInfo(items.getUserId(), items.getEnterIdCode(), items.getPerformanceId(), items.getTicketId(), -1);
}
});
channel.basicAck(msg.getMessageProperties().getDeliveryTag(), false);
} catch (Exception e) {
e.printStackTrace();
log.error("error:consumer sql:Channel.msg.tag:{}", msg.getMessageProperties().getDeliveryTag(), e); log.error("error:consumer sql:Channel.msg.tag:{}", msg.getMessageProperties().getDeliveryTag(), e);
} }
} }
...@@ -242,7 +255,7 @@ public class ConsumerProcessor { ...@@ -242,7 +255,7 @@ public class ConsumerProcessor {
)) ))
public void consumerOrderClose(Message msg, Channel channel) { public void consumerOrderClose(Message msg, Channel channel) {
log.info("=== CONSUMER_ORDER_CLOSE ==="); log.info("=== CONSUMER_ORDER_CLOSE ===");
this.consumerSqlDaoHandlerLongSql(msg, channel); this.consumerOperationOrderClose(msg, channel);
} }
@RabbitListener(bindings = @QueueBinding( @RabbitListener(bindings = @QueueBinding(
...@@ -251,7 +264,7 @@ public class ConsumerProcessor { ...@@ -251,7 +264,7 @@ public class ConsumerProcessor {
)) ))
public void consumerOrderClose1(Message msg, Channel channel) { public void consumerOrderClose1(Message msg, Channel channel) {
log.info("=== CONSUMER_ORDER_CLOSE ==="); log.info("=== CONSUMER_ORDER_CLOSE ===");
this.consumerSqlDaoHandlerLongSql(msg, channel); this.consumerOperationOrderClose(msg, channel);
} }
@RabbitListener(bindings = @QueueBinding( @RabbitListener(bindings = @QueueBinding(
...@@ -260,7 +273,7 @@ public class ConsumerProcessor { ...@@ -260,7 +273,7 @@ public class ConsumerProcessor {
)) ))
public void consumerOrderClose2(Message msg, Channel channel) { public void consumerOrderClose2(Message msg, Channel channel) {
log.info("=== CONSUMER_ORDER_CLOSE ==="); log.info("=== CONSUMER_ORDER_CLOSE ===");
this.consumerSqlDaoHandlerLongSql(msg, channel); this.consumerOperationOrderClose(msg, channel);
} }
@RabbitListener(bindings = @QueueBinding( @RabbitListener(bindings = @QueueBinding(
...@@ -269,7 +282,7 @@ public class ConsumerProcessor { ...@@ -269,7 +282,7 @@ public class ConsumerProcessor {
)) ))
public void consumerOrderClose3(Message msg, Channel channel) { public void consumerOrderClose3(Message msg, Channel channel) {
log.info("=== CONSUMER_ORDER_CLOSE ==="); log.info("=== CONSUMER_ORDER_CLOSE ===");
this.consumerSqlDaoHandlerLongSql(msg, channel); this.consumerOperationOrderClose(msg, channel);
} }
@RabbitListener(bindings = @QueueBinding( @RabbitListener(bindings = @QueueBinding(
...@@ -278,7 +291,7 @@ public class ConsumerProcessor { ...@@ -278,7 +291,7 @@ public class ConsumerProcessor {
)) ))
public void consumerOrderClose4(Message msg, Channel channel) { public void consumerOrderClose4(Message msg, Channel channel) {
log.info("=== CONSUMER_ORDER_CLOSE ==="); log.info("=== CONSUMER_ORDER_CLOSE ===");
this.consumerSqlDaoHandlerLongSql(msg, channel); this.consumerOperationOrderClose(msg, channel);
} }
@RabbitListener(bindings = @QueueBinding( @RabbitListener(bindings = @QueueBinding(
...@@ -287,7 +300,7 @@ public class ConsumerProcessor { ...@@ -287,7 +300,7 @@ public class ConsumerProcessor {
)) ))
public void consumerOrderClose5(Message msg, Channel channel) { public void consumerOrderClose5(Message msg, Channel channel) {
log.info("=== CONSUMER_ORDER_CLOSE ==="); log.info("=== CONSUMER_ORDER_CLOSE ===");
this.consumerSqlDaoHandlerLongSql(msg, channel); this.consumerOperationOrderClose(msg, channel);
} }
@RabbitListener(bindings = @QueueBinding( @RabbitListener(bindings = @QueueBinding(
...@@ -296,7 +309,7 @@ public class ConsumerProcessor { ...@@ -296,7 +309,7 @@ public class ConsumerProcessor {
)) ))
public void consumerOrderClose6(Message msg, Channel channel) { public void consumerOrderClose6(Message msg, Channel channel) {
log.info("=== CONSUMER_ORDER_CLOSE ==="); log.info("=== CONSUMER_ORDER_CLOSE ===");
this.consumerSqlDaoHandlerLongSql(msg, channel); this.consumerOperationOrderClose(msg, channel);
} }
@RabbitListener(bindings = @QueueBinding( @RabbitListener(bindings = @QueueBinding(
...@@ -305,7 +318,7 @@ public class ConsumerProcessor { ...@@ -305,7 +318,7 @@ public class ConsumerProcessor {
)) ))
public void consumerOrderClose7(Message msg, Channel channel) { public void consumerOrderClose7(Message msg, Channel channel) {
log.info("=== CONSUMER_ORDER_CLOSE ==="); log.info("=== CONSUMER_ORDER_CLOSE ===");
this.consumerSqlDaoHandlerLongSql(msg, channel); this.consumerOperationOrderClose(msg, channel);
} }
@RabbitListener(bindings = @QueueBinding( @RabbitListener(bindings = @QueueBinding(
...@@ -314,7 +327,7 @@ public class ConsumerProcessor { ...@@ -314,7 +327,7 @@ public class ConsumerProcessor {
)) ))
public void consumerOrderClose8(Message msg, Channel channel) { public void consumerOrderClose8(Message msg, Channel channel) {
log.info("=== CONSUMER_ORDER_CLOSE ==="); log.info("=== CONSUMER_ORDER_CLOSE ===");
this.consumerSqlDaoHandlerLongSql(msg, channel); this.consumerOperationOrderClose(msg, channel);
} }
@RabbitListener(bindings = @QueueBinding( @RabbitListener(bindings = @QueueBinding(
...@@ -323,7 +336,7 @@ public class ConsumerProcessor { ...@@ -323,7 +336,7 @@ public class ConsumerProcessor {
)) ))
public void consumerOrderClose9(Message msg, Channel channel) { public void consumerOrderClose9(Message msg, Channel channel) {
log.info("=== CONSUMER_ORDER_CLOSE ==="); log.info("=== CONSUMER_ORDER_CLOSE ===");
this.consumerSqlDaoHandlerLongSql(msg, channel); this.consumerOperationOrderClose(msg, channel);
} }
......
use prod_ln_scene;
#创建集合
db.createCollection("KylinOrderTicketVo");
db.createCollection("KylinOrderTicketEntitiesVo");
#创建索引
db.KylinOrderTicketVo.createIndex({orderTicketsId:"hashed"});
db.KylinOrderTicketVo.createIndex({orderCode:"hashed"});
db.KylinOrderTicketVo.createIndex({userId:"hashed"});
db.KylinOrderTicketEntitiesVo.createIndex({orderTicketEntitiesId:"hashed"});
db.KylinOrderTicketEntitiesVo.createIndex({orderId:"hashed"});
#创建分片
sh.enableSharding("prod_ln_scene");
sh.shardCollection("prod_ln_scene.KylinOrderTicketVo",{"orderTicketsId":"hashed"});
sh.shardCollection("prod_ln_scene.KylinOrderTicketEntitiesVo",{"orderTicketEntitiesId":"hashed"});
\ No newline at end of file
...@@ -33,4 +33,11 @@ public class DataController { ...@@ -33,4 +33,11 @@ public class DataController {
return ResponseDto.success(result); return ResponseDto.success(result);
} }
@PostMapping("roadShow")
@ApiOperation("巡演数据迁移")
public ResponseDto<Boolean> roadShow() {
Boolean result = data.roadShow();
return ResponseDto.success(result);
}
} }
...@@ -11,10 +11,7 @@ import com.liquidnet.service.kylin.dto.vo.partner.KylinTicketPartnerVo; ...@@ -11,10 +11,7 @@ import com.liquidnet.service.kylin.dto.vo.partner.KylinTicketPartnerVo;
import com.liquidnet.service.kylin.dto.vo.partner.KylinTicketTimesPartnerVo; import com.liquidnet.service.kylin.dto.vo.partner.KylinTicketTimesPartnerVo;
import com.liquidnet.service.kylin.entity.*; import com.liquidnet.service.kylin.entity.*;
import com.liquidnet.service.kylin.mapper.*; import com.liquidnet.service.kylin.mapper.*;
import com.liquidnet.service.kylin.service.IKylinOrderTicketEntitiesService; import com.liquidnet.service.kylin.service.*;
import com.liquidnet.service.kylin.service.IKylinOrderTicketRelationsService;
import com.liquidnet.service.kylin.service.IKylinOrderTicketStatusService;
import com.liquidnet.service.kylin.service.IKylinOrderTicketsService;
import com.liquidnet.service.kylin.timerTask.PerformanceVoTask; import com.liquidnet.service.kylin.timerTask.PerformanceVoTask;
import com.liquidnet.service.kylin.utils.DataUtils; import com.liquidnet.service.kylin.utils.DataUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -60,6 +57,9 @@ public class DataImpl { ...@@ -60,6 +57,9 @@ public class DataImpl {
@Autowired @Autowired
private IKylinOrderTicketEntitiesService kylinOrderTicketEntitiesService; private IKylinOrderTicketEntitiesService kylinOrderTicketEntitiesService;
@Autowired
private IKylinRoadShowsService kylinRoadShowsService;
@Autowired @Autowired
private DataUtils dataUtils; private DataUtils dataUtils;
@Autowired @Autowired
...@@ -197,7 +197,7 @@ public class DataImpl { ...@@ -197,7 +197,7 @@ public class DataImpl {
performancePartnerVo.setDetails(performances.getDetails()); performancePartnerVo.setDetails(performances.getDetails());
performancePartnerVo.setApprovalUrl(performances.getApprovalUrl()); performancePartnerVo.setApprovalUrl(performances.getApprovalUrl());
performancePartnerVo.setPayCountdownMinute(5); performancePartnerVo.setPayCountdownMinute(5);
performancePartnerVo.setNoticeIds(new ArrayList<String>(){{ performancePartnerVo.setNoticeIds(new ArrayList<String>() {{
add("1"); add("1");
add("3"); add("3");
add("7"); add("7");
...@@ -457,7 +457,7 @@ public class DataImpl { ...@@ -457,7 +457,7 @@ public class DataImpl {
con = DriverManager.getConnection(url, username, password); //获取连接 con = DriverManager.getConnection(url, username, password); //获取连接
String sqlAllCount = "select count(0) as 'allCount' from order_tickets where performance_id > 5721 and status != 2 and created_at like '2021-" + month + "%'"; //设置的预编译语句格式 String sqlAllCount = "select count(0) as 'allCount' from order_tickets where performance_id > 5721 and status != 2 and created_at like '2021-" + month + "%'"; //设置的预编译语句格式
// String sqlAllCount = "select count(0) as 'allCount' from order_tickets where performance_id = "+month + " and status != 2 and status !=-1"; //设置的预编译语句格式 // String sqlAllCount = "select count(0) as 'allCount' from order_tickets where performance_id = "+month + " and status != 2 and status !=-1"; //设置的预编译语句格式
System.out.println(" SQL COUNT = "+sqlAllCount); System.out.println(" SQL COUNT = " + sqlAllCount);
pstmt = con.prepareStatement(sqlAllCount); pstmt = con.prepareStatement(sqlAllCount);
ResultSet allCount = pstmt.executeQuery(); ResultSet allCount = pstmt.executeQuery();
int allCountResult = 0;//共多少条 int allCountResult = 0;//共多少条
...@@ -478,7 +478,7 @@ public class DataImpl { ...@@ -478,7 +478,7 @@ public class DataImpl {
//订单 //订单
String sql = "select * from order_tickets where performance_id > 5721 and status != 2 and created_at like '2021-" + month + "%' limit " + count * page + " ," + count; //设置的预编译语句格式 String sql = "select * from order_tickets where performance_id > 5721 and status != 2 and created_at like '2021-" + month + "%' limit " + count * page + " ," + count; //设置的预编译语句格式
// String sql = "select * from order_tickets where performance_id = "+month +" and status != 2 limit " + count * page + " ," + count; // String sql = "select * from order_tickets where performance_id = "+month +" and status != 2 limit " + count * page + " ," + count;
System.out.println(" SQL DATA = "+sql); System.out.println(" SQL DATA = " + sql);
pstmt = con.prepareStatement(sql); pstmt = con.prepareStatement(sql);
ResultSet orderData = pstmt.executeQuery(); ResultSet orderData = pstmt.executeQuery();
while (orderData.next()) { while (orderData.next()) {
...@@ -506,14 +506,14 @@ public class DataImpl { ...@@ -506,14 +506,14 @@ public class DataImpl {
} }
//退款 //退款
String refundSql = "select refund_table_id,sum(refund_number) as 'refund_number',sum(refund_price) as 'refund_price' from order_refunds where refund_table = 'order_ticket_entities' and order_id = " + orderData.getInt("id")+" group by refund_table_id"; //设置的预编译语句格式 String refundSql = "select refund_table_id,sum(refund_number) as 'refund_number',sum(refund_price) as 'refund_price' from order_refunds where refund_table = 'order_ticket_entities' and order_id = " + orderData.getInt("id") + " group by refund_table_id"; //设置的预编译语句格式
pstmt = con.prepareStatement(refundSql); pstmt = con.prepareStatement(refundSql);
int refundNumber = 0; int refundNumber = 0;
BigDecimal refundPrice = new BigDecimal("0.00"); BigDecimal refundPrice = new BigDecimal("0.00");
ResultSet refundData = pstmt.executeQuery(); ResultSet refundData = pstmt.executeQuery();
while (refundData.next()) { while (refundData.next()) {
refundNumber+=refundData.getInt("refund_number"); refundNumber += refundData.getInt("refund_number");
refundPrice=refundPrice.add(refundData.getBigDecimal("refund_price")); refundPrice = refundPrice.add(refundData.getBigDecimal("refund_price"));
} }
//演出 //演出
...@@ -526,9 +526,9 @@ public class DataImpl { ...@@ -526,9 +526,9 @@ public class DataImpl {
String notice = ""; String notice = "";
while (performanceData.next()) { while (performanceData.next()) {
performanceTimeStart = DateUtil.Formatter.yyyyMMddHHmmss.format(DateUtil.Formatter.yyyyMMddHHmmssS.parse(performanceData.getTimestamp("time_start").toString())); performanceTimeStart = DateUtil.Formatter.yyyyMMddHHmmss.format(DateUtil.Formatter.yyyyMMddHHmmssS.parse(performanceData.getTimestamp("time_start").toString()));
performanceImg=performanceData.getString("img_poster"); performanceImg = performanceData.getString("img_poster");
isTrueName=performanceData.getString("need_id_card").equals("yes")?1:0; isTrueName = performanceData.getString("need_id_card").equals("yes") ? 1 : 0;
notice=performanceData.getString("notice"); notice = performanceData.getString("notice");
} }
orderTickets.setOrderTicketsId(orderData.getInt("id") + ""); orderTickets.setOrderTicketsId(orderData.getInt("id") + "");
...@@ -661,7 +661,7 @@ public class DataImpl { ...@@ -661,7 +661,7 @@ public class DataImpl {
while (enterData.next()) { while (enterData.next()) {
KylinOrderTicketEntitiesVo entitiesVo = new KylinOrderTicketEntitiesVo(); KylinOrderTicketEntitiesVo entitiesVo = new KylinOrderTicketEntitiesVo();
orderTicketEntities.setOrderTicketEntitiesId(enterData.getInt("id")+""); orderTicketEntities.setOrderTicketEntitiesId(enterData.getInt("id") + "");
orderTicketEntities.setOrderId(orderTickets.getOrderTicketsId()); orderTicketEntities.setOrderId(orderTickets.getOrderTicketsId());
orderTicketEntities.setTicketId(enterData.getInt("ticket_id") + ""); orderTicketEntities.setTicketId(enterData.getInt("ticket_id") + "");
orderTicketEntities.setUserId(enterData.getInt("user_id") + ""); orderTicketEntities.setUserId(enterData.getInt("user_id") + "");
...@@ -739,7 +739,7 @@ public class DataImpl { ...@@ -739,7 +739,7 @@ public class DataImpl {
kylinOrderTicketEntitiesService.saveBatch(orderEntitiesList); kylinOrderTicketEntitiesService.saveBatch(orderEntitiesList);
mongoTemplate.insert(orderListVo, KylinOrderTicketVo.class.getSimpleName()); mongoTemplate.insert(orderListVo, KylinOrderTicketVo.class.getSimpleName());
mongoTemplate.insert(orderEntitiesListVo,KylinOrderTicketEntitiesVo.class.getSimpleName()); mongoTemplate.insert(orderEntitiesListVo, KylinOrderTicketEntitiesVo.class.getSimpleName());
orderData.last(); orderData.last();
rowCount += orderData.getRow(); rowCount += orderData.getRow();
...@@ -766,4 +766,51 @@ public class DataImpl { ...@@ -766,4 +766,51 @@ public class DataImpl {
} }
} }
} }
public boolean roadShow() {
String driverClassName = "com.mysql.cj.jdbc.Driver"; //启动驱动
String url = "jdbc:mysql://zhengzai.mysql.polardb.rds.aliyuncs.com:3306/mall"; //设置连接路径
String username = "readonly"; //数据库用户名
String password = "ZWDsf8Fy"; //数据库连接密码
Connection con = null; //连接
PreparedStatement pstmt = null; //使用预编译语句
ResultSet rs = null; //获取的结果集
try {
ArrayList<KylinRoadShows> roadShowsList = new ArrayList();
Class.forName(driverClassName); //执行驱动
con = DriverManager.getConnection(url, username, password); //获取连接
String sql = "select rs.id,rs.title,rs.img_poster,rs.created_at,rs.updated_at,count(p.id) as 'count' from road_shows as rs left join performances as p on p.road_show_id = rs.id where p.id > 5721 group by rs.id,rs.title having count>0";
pstmt = con.prepareStatement(sql);
ResultSet resultData = pstmt.executeQuery();
//演出数据
while (resultData.next()) {
KylinRoadShows roadShows = new KylinRoadShows();
roadShows.setRoadShowsId(resultData.getInt("id")+"");
roadShows.setTitle(resultData.getString("title"));
roadShows.setImgPoster(resultData.getString("img_poster"));
roadShows.setStatus(1);
roadShows.setComment("");
roadShows.setCreatedAt(DateUtil.Formatter.yyyyMMddHHmmssS.parse(resultData.getTimestamp("created_at").toString()));
if (null != resultData.getTimestamp("updated_at")) {
roadShows.setUpdatedAt(DateUtil.Formatter.yyyyMMddHHmmssS.parse(resultData.getTimestamp("updated_at").toString()));
}
roadShowsList.add(roadShows);
}
return true;
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException(e);
} finally {
//关闭资源,倒关
try {
if (rs != null) rs.close();
if (pstmt != null) pstmt.close();
if (con != null) con.close(); //必须要关
} catch (Exception e) {
}
}
}
} }
package com.liquidnet.service.kylin.service.impl; package com.liquidnet.service.kylin.service.impl;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import com.liquidnet.common.cache.redis.util.RedisUtil; import com.liquidnet.common.cache.redis.util.RedisUtil;
import com.liquidnet.common.cache.redisson.util.RedisLockUtil; import com.liquidnet.common.cache.redisson.util.RedisLockUtil;
...@@ -7,10 +8,7 @@ import com.liquidnet.common.mq.constant.MQConst; ...@@ -7,10 +8,7 @@ import com.liquidnet.common.mq.constant.MQConst;
import com.liquidnet.commons.lang.util.*; import com.liquidnet.commons.lang.util.*;
import com.liquidnet.service.adam.dto.vo.AdamAddressesVo; import com.liquidnet.service.adam.dto.vo.AdamAddressesVo;
import com.liquidnet.service.adam.dto.vo.AdamEntersVo; import com.liquidnet.service.adam.dto.vo.AdamEntersVo;
import com.liquidnet.service.base.ErrorMapping; import com.liquidnet.service.base.*;
import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.base.SqlMapping;
import com.liquidnet.service.base.UserPathDto;
import com.liquidnet.service.kylin.constant.KylinRedisConst; import com.liquidnet.service.kylin.constant.KylinRedisConst;
import com.liquidnet.service.kylin.constant.KylinTableStatusConst; import com.liquidnet.service.kylin.constant.KylinTableStatusConst;
import com.liquidnet.service.kylin.dao.OrderScriptDto; import com.liquidnet.service.kylin.dao.OrderScriptDto;
...@@ -26,6 +24,8 @@ import com.liquidnet.service.kylin.dto.vo.returns.KylinOrderListVo; ...@@ -26,6 +24,8 @@ import com.liquidnet.service.kylin.dto.vo.returns.KylinOrderListVo;
import com.liquidnet.service.kylin.dto.vo.returns.OrderDetailsVo; import com.liquidnet.service.kylin.dto.vo.returns.OrderDetailsVo;
import com.liquidnet.service.kylin.dto.vo.returns.PayResultVo; import com.liquidnet.service.kylin.dto.vo.returns.PayResultVo;
import com.liquidnet.service.kylin.entity.*; import com.liquidnet.service.kylin.entity.*;
import com.liquidnet.service.kylin.mapper.KylinOrderTicketRelationsMapper;
import com.liquidnet.service.kylin.mapper.KylinOrderTicketStatusMapper;
import com.liquidnet.service.kylin.mapper.KylinOrderTicketsMapper; import com.liquidnet.service.kylin.mapper.KylinOrderTicketsMapper;
import com.liquidnet.service.kylin.service.IKylinOrderTicketsService; import com.liquidnet.service.kylin.service.IKylinOrderTicketsService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
...@@ -102,8 +102,13 @@ public class KylinOrderTicketsServiceImpl extends ServiceImpl<KylinOrderTicketsM ...@@ -102,8 +102,13 @@ public class KylinOrderTicketsServiceImpl extends ServiceImpl<KylinOrderTicketsM
@Autowired @Autowired
private KylinOrderTicketsMapper orderTicketsMapper; private KylinOrderTicketsMapper orderTicketsMapper;
@Autowired @Autowired
private KylinOrderTicketStatusMapper orderTicketStatusMapper;
@Autowired
private KylinOrderTicketRelationsMapper orderTicketRelationsMapper;
@Autowired
private OrderRefundsCallbackServiceImpl orderRefundsCallbackService; private OrderRefundsCallbackServiceImpl orderRefundsCallbackService;
ArrayList<Integer> canBuyStatus = new ArrayList() {{ ArrayList<Integer> canBuyStatus = new ArrayList() {{
add(6); add(6);
add(8); add(8);
...@@ -621,7 +626,7 @@ public class KylinOrderTicketsServiceImpl extends ServiceImpl<KylinOrderTicketsM ...@@ -621,7 +626,7 @@ public class KylinOrderTicketsServiceImpl extends ServiceImpl<KylinOrderTicketsM
sqlData); sqlData);
currentTime = System.currentTimeMillis() - currentTime; currentTime = System.currentTimeMillis() - currentTime;
log.debug("MQ 发送 -> time:" + (currentTime) + "毫秒"); log.debug("MQ 发送 -> time:" + (currentTime) + "毫秒");
log.info(UserPathDto.setData("下单(唤起支付)",payOrderParam,payResultVo)); log.info(UserPathDto.setData("下单(唤起支付)", payOrderParam, payResultVo));
return ResponseDto.success(payResultVo); return ResponseDto.success(payResultVo);
} }
...@@ -629,7 +634,7 @@ public class KylinOrderTicketsServiceImpl extends ServiceImpl<KylinOrderTicketsM ...@@ -629,7 +634,7 @@ public class KylinOrderTicketsServiceImpl extends ServiceImpl<KylinOrderTicketsM
public ResponseDto<PayResultVo> payAgain(PayAgainParam payAgainParam) { public ResponseDto<PayResultVo> payAgain(PayAgainParam payAgainParam) {
try { try {
String uid = CurrentUtil.getCurrentUid(); String uid = CurrentUtil.getCurrentUid();
checkOrderTime(uid); // checkOrderTime(uid);
//检查订单时间 是否关闭 //检查订单时间 是否关闭
KylinOrderTicketVo orderTicketData = dataUtils.getOrderTicketVo(payAgainParam.getOrderId()); KylinOrderTicketVo orderTicketData = dataUtils.getOrderTicketVo(payAgainParam.getOrderId());
if (!orderTicketData.getUserId().equals(uid)) { if (!orderTicketData.getUserId().equals(uid)) {
...@@ -723,7 +728,7 @@ public class KylinOrderTicketsServiceImpl extends ServiceImpl<KylinOrderTicketsM ...@@ -723,7 +728,7 @@ public class KylinOrderTicketsServiceImpl extends ServiceImpl<KylinOrderTicketsM
String sqlData = SqlMapping.gets(sqls, sqlsDataA, sqlsDataB, sqlsDataC); String sqlData = SqlMapping.gets(sqls, sqlsDataA, sqlsDataB, sqlsDataC);
rabbitTemplate.convertAndSend(MQConst.EXCHANGES_LIQUIDNET_SQL_ORDER_AGAIN, MQConst.ROUTING_KEY_SQL_ORDER_AGAIN, sqlData); rabbitTemplate.convertAndSend(MQConst.EXCHANGES_LIQUIDNET_SQL_ORDER_AGAIN, MQConst.ROUTING_KEY_SQL_ORDER_AGAIN, sqlData);
log.info(UserPathDto.setData("再次支付",payAgainParam,payResultVo)); log.info(UserPathDto.setData("再次支付", payAgainParam, payResultVo));
return ResponseDto.success(payResultVo); return ResponseDto.success(payResultVo);
} }
return ResponseDto.failure("未选择支付方式"); return ResponseDto.failure("未选择支付方式");
...@@ -879,7 +884,7 @@ public class KylinOrderTicketsServiceImpl extends ServiceImpl<KylinOrderTicketsM ...@@ -879,7 +884,7 @@ public class KylinOrderTicketsServiceImpl extends ServiceImpl<KylinOrderTicketsM
sycDamaiOrder(orderTickets.getOrderTicketsId()); sycDamaiOrder(orderTickets.getOrderTicketsId());
} }
redisLockUtil.unlock(lock); redisLockUtil.unlock(lock);
log.info(UserPathDto.setData("订单支付成功回调",syncOrderParam,"")); log.info(UserPathDto.setData("订单支付成功回调", syncOrderParam, ""));
return "success"; return "success";
} }
...@@ -888,7 +893,7 @@ public class KylinOrderTicketsServiceImpl extends ServiceImpl<KylinOrderTicketsM ...@@ -888,7 +893,7 @@ public class KylinOrderTicketsServiceImpl extends ServiceImpl<KylinOrderTicketsM
//TODO 缺快递 //TODO 缺快递
PageInfo<List<KylinOrderListVo>> mPageInfo = null; PageInfo<List<KylinOrderListVo>> mPageInfo = null;
String uid = CurrentUtil.getCurrentUid(); String uid = CurrentUtil.getCurrentUid();
checkOrderTime(uid); // checkOrderTime(uid);
try { try {
List<KylinOrderListVo> voList = dataUtils.getOrderList(uid); List<KylinOrderListVo> voList = dataUtils.getOrderList(uid);
for (int i = 0; i < voList.size(); i++) { for (int i = 0; i < voList.size(); i++) {
...@@ -921,7 +926,7 @@ public class KylinOrderTicketsServiceImpl extends ServiceImpl<KylinOrderTicketsM ...@@ -921,7 +926,7 @@ public class KylinOrderTicketsServiceImpl extends ServiceImpl<KylinOrderTicketsM
mPageInfo = new PageInfo(voList); mPageInfo = new PageInfo(voList);
mPageInfo.setTotal(voList.size()); mPageInfo.setTotal(voList.size());
log.info(UserPathDto.setData("订单列表","",voList)); log.info(UserPathDto.setData("订单列表", "", voList));
return mPageInfo; return mPageInfo;
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
...@@ -934,11 +939,11 @@ public class KylinOrderTicketsServiceImpl extends ServiceImpl<KylinOrderTicketsM ...@@ -934,11 +939,11 @@ public class KylinOrderTicketsServiceImpl extends ServiceImpl<KylinOrderTicketsM
OrderDetailsVo vo = new OrderDetailsVo(); OrderDetailsVo vo = new OrderDetailsVo();
try { try {
String uid = CurrentUtil.getCurrentUid(); String uid = CurrentUtil.getCurrentUid();
checkOrderTime(uid); // checkOrderTime(uid);
KylinOrderTicketVo orderTicketVo = dataUtils.getOrderTicketVo(orderId); KylinOrderTicketVo orderTicketVo = dataUtils.getOrderTicketVo(orderId);
if (!orderTicketVo.getUserId().equals(uid)) { if (!orderTicketVo.getUserId().equals(uid)) {
log.error("ORDER_TICKET_USER_ID : {}",orderTicketVo.getUserId()); log.error("ORDER_TICKET_USER_ID : {}", orderTicketVo.getUserId());
log.error("TOKEN UID : {}",uid); log.error("TOKEN UID : {}", uid);
return null; return null;
} }
if (null != orderTicketVo) { if (null != orderTicketVo) {
...@@ -970,7 +975,7 @@ public class KylinOrderTicketsServiceImpl extends ServiceImpl<KylinOrderTicketsM ...@@ -970,7 +975,7 @@ public class KylinOrderTicketsServiceImpl extends ServiceImpl<KylinOrderTicketsM
Date date = DateUtil.parse(ticketVo.getQrCodeShowTime(), DateUtil.Formatter.yyyyMMddHHmm.toString()); Date date = DateUtil.parse(ticketVo.getQrCodeShowTime(), DateUtil.Formatter.yyyyMMddHHmm.toString());
if (DateUtil.compareDay(date, DateUtil.now()) <= 0) { if (DateUtil.compareDay(date, DateUtil.now()) <= 0) {
orderTicketVo.setQrCode(""); orderTicketVo.setQrCode("");
}else{ } else {
orderTicketVo.setQrCode(orderTicketVo.getQrCode()); orderTicketVo.setQrCode(orderTicketVo.getQrCode());
} }
} else { } else {
...@@ -988,7 +993,7 @@ public class KylinOrderTicketsServiceImpl extends ServiceImpl<KylinOrderTicketsM ...@@ -988,7 +993,7 @@ public class KylinOrderTicketsServiceImpl extends ServiceImpl<KylinOrderTicketsM
} }
} }
//计算 倒计时 //计算 倒计时
if (orderTicketVo.getStatus() == KylinTableStatusConst.ORDER_STATUS0) { if (orderTicketVo.getStatus().equals(KylinTableStatusConst.ORDER_STATUS0)) {
vo.setRestTime(DateUtil.intervalSeconds( vo.setRestTime(DateUtil.intervalSeconds(
DateUtil.parse(orderTicketVo.getOverdueAt(), "yyyy-MM-dd HH:mm:ss"), DateUtil.parse(orderTicketVo.getOverdueAt(), "yyyy-MM-dd HH:mm:ss"),
DateUtil.parse(DateUtil.getNowTime(), "yyyy-MM-dd HH:mm:ss") DateUtil.parse(DateUtil.getNowTime(), "yyyy-MM-dd HH:mm:ss")
...@@ -1009,7 +1014,7 @@ public class KylinOrderTicketsServiceImpl extends ServiceImpl<KylinOrderTicketsM ...@@ -1009,7 +1014,7 @@ public class KylinOrderTicketsServiceImpl extends ServiceImpl<KylinOrderTicketsM
vo.setOrderTicketVo(orderTicketVo); vo.setOrderTicketVo(orderTicketVo);
vo.setEnterDescribe(dataUtils.getEnterInfo("1")); vo.setEnterDescribe(dataUtils.getEnterInfo("1"));
} }
log.info(UserPathDto.setData("订单列表",orderId,vo)); log.info(UserPathDto.setData("订单列表", orderId, vo));
return vo; return vo;
} catch (Exception e) { } catch (Exception e) {
return vo; return vo;
...@@ -1020,62 +1025,75 @@ public class KylinOrderTicketsServiceImpl extends ServiceImpl<KylinOrderTicketsM ...@@ -1020,62 +1025,75 @@ public class KylinOrderTicketsServiceImpl extends ServiceImpl<KylinOrderTicketsM
public boolean checkOrderTime(String userId) { public boolean checkOrderTime(String userId) {
String lock = "order_lock:checkOrderTime:" + userId; String lock = "order_lock:checkOrderTime:" + userId;
if (redisLockUtil.tryLock(lock, 1, 3600)) { if (redisLockUtil.tryLock(lock, 1, 3600)) {
try { List<OrderScriptDto> dtoData = orderTicketsMapper.orderScriptDto(userId);
List<OrderScriptDto> dtoData = orderTicketsMapper.orderScriptDto(userId); LocalDateTime now = LocalDateTime.now();
LocalDateTime now = LocalDateTime.now(); Long currentTime = System.currentTimeMillis();
Long currentTime = System.currentTimeMillis(); HashMap<String, Integer> mapSurplusGeneral = new HashMap<>();
HashMap<String, Integer> mapSurplusGeneral = new HashMap<>(); ArrayList<String> orderDataList = new ArrayList<>();
ArrayList<String> orderDataList = new ArrayList<>(); ArrayList<String> orderIdList = new ArrayList<>();
ArrayList<String> orderIdList = new ArrayList<>(); HashMap<String, Object> mapMongo = new HashMap<>();
HashMap<String, Object> mapMongo = new HashMap<>();
for (OrderScriptDto item : dtoData) {
for (OrderScriptDto item : dtoData) { if (item.getStatus().equals(KylinTableStatusConst.ORDER_STATUS0)) {
if (item.getStatus().equals(KylinTableStatusConst.ORDER_STATUS0)) { try {
try { //vo
//vo mapMongo.put("status", KylinTableStatusConst.ORDER_STATUS2);
mapMongo.put("status", KylinTableStatusConst.ORDER_STATUS2); mapMongo.put("updatedAt", DateUtil.Formatter.yyyyMMddHHmmssSSS.format(now));
mapMongo.put("updatedAt", DateUtil.Formatter.yyyyMMddHHmmssSSS.format(now)); mapMongo.put("changeDate", now);
mapMongo.put("changeDate", now); orderDataList.add(item.getOrderTicketsId() + "," + item.getUserId());
orderDataList.add(item.getOrderTicketsId() + "," + item.getUserId()); orderIdList.add(item.getOrderTicketsId());
orderIdList.add(item.getOrderTicketsId()); mapSurplusGeneral.put(item.getTicketId(), mapSurplusGeneral.get(item.getTicketId()) == null ? item.getNumber() : mapSurplusGeneral.get(item.getTicketId()) + item.getNumber());
mapSurplusGeneral.put(item.getTicketId(), mapSurplusGeneral.get(item.getTicketId()) == null ? item.getNumber() : mapSurplusGeneral.get(item.getTicketId()) + item.getNumber()); } catch (Exception e) {
} catch (Exception e) { log.debug("CHECK TIME SYNC = " + e.getMessage());
log.debug("CHECK TIME SYNC = " + e.getMessage()); e.printStackTrace();
e.printStackTrace(); return false;
return false;
}
} else {
} }
} else {
} }
currentTime = System.currentTimeMillis() - currentTime; }
log.debug("FOR 循环 -> time:" + (currentTime) + "毫秒"); currentTime = System.currentTimeMillis() - currentTime;
if (orderDataList.size() > 0) { log.debug("FOR 循环 -> time:" + (currentTime) + "毫秒");
//库存
for (Map.Entry<String, Integer> entry : mapSurplusGeneral.entrySet()) { if (orderDataList.size() > 0) {
dataUtils.changeSurplusGeneral(entry.getKey(), entry.getValue()); //mysql
} String orderStr = "";
currentTime = System.currentTimeMillis() - currentTime; for (int i = 0; i < orderIdList.size(); i++) {
log.debug("redis 库存 -> time:" + (currentTime) + "毫秒"); String orderTicketId = orderIdList.get(i);
orderStr += "'" + orderTicketId + "',";
//mysql }
String orderStr = ""; orderStr = orderStr.substring(0, orderStr.length() - 1);
for (int i = 0; i < orderIdList.size(); i++) {
String orderTicketId = orderIdList.get(i);
orderStr += "'" + orderTicketId + "',";
}
orderStr = orderStr.substring(0, orderStr.length() - 1); KylinOrderTickets orderTickets = new KylinOrderTickets();
LinkedList<String> sqls = new LinkedList(); orderTickets.setUpdatedAt(now);
sqls.add("UPDATE kylin_order_tickets SET updated_at = '" + now + "' WHERE order_tickets_id in (" + orderStr + ") "); orderTicketsMapper.update(orderTickets, new UpdateWrapper<KylinOrderTickets>().in("order_tickets_id", orderIdList));
sqls.add("UPDATE kylin_order_ticket_status SET `status` = 2,updated_at = '" + now + "' WHERE order_id in (" + orderStr + ") ");
sqls.add("UPDATE kylin_order_ticket_relations SET updated_at = '" + now + "' WHERE order_id in (" + orderStr + ")"); KylinOrderTicketStatus orderTicketStatus = new KylinOrderTicketStatus();
String redisKey = "kylin:ORDER_CLOSE:" + IDGenerator.nextMilliId(); orderTicketStatus.setStatus(2);
redisUtil.set(redisKey, sqls); orderTicketStatus.setUpdatedAt(now);
rabbitTemplate.convertAndSend(MQConst.EXCHANGES_LIQUIDNET_SQL_ORDER_CLOSE, MQConst.ROUTING_KEY_SQL_ORDER_CLOSE, redisKey); orderTicketStatusMapper.update(orderTicketStatus, new UpdateWrapper<KylinOrderTicketStatus>().in("order_id", orderIdList));
KylinOrderTicketRelations orderTicketRelations = new KylinOrderTicketRelations();
orderTicketRelations.setUpdatedAt(now);
orderTicketRelationsMapper.update(orderTicketRelations, new UpdateWrapper<KylinOrderTicketRelations>().in("order_id", orderIdList));
// LinkedList<String> sqls = new LinkedList();
// sqls.add("UPDATE kylin_order_tickets SET updated_at = '" + now + "' WHERE order_tickets_id in (" + orderStr + ") ");
// sqls.add("UPDATE kylin_order_ticket_status SET `status` = 2,updated_at = '" + now + "' WHERE order_id in (" + orderStr + ") ");
// sqls.add("UPDATE kylin_order_ticket_relations SET updated_at = '" + now + "' WHERE order_id in (" + orderStr + ")");
// String redisKey = "kylin:ORDER_CLOSE:" + IDGenerator.nextMilliId();
// redisUtil.set(redisKey, sqls);
// rabbitTemplate.convertAndSend(MQConst.EXCHANGES_LIQUIDNET_SQL_ORDER_CLOSE, MQConst.ROUTING_KEY_SQL_ORDER_CLOSE, redisKey);
currentTime = System.currentTimeMillis() - currentTime;
log.debug("mysql -> time:" + (currentTime) + "毫秒");
currentTime = System.currentTimeMillis() - currentTime; //库存
log.debug("mysql -> time:" + (currentTime) + "毫秒"); for (Map.Entry<String, Integer> entry : mapSurplusGeneral.entrySet()) {
dataUtils.changeSurplusGeneral(entry.getKey(), entry.getValue());
}
currentTime = System.currentTimeMillis() - currentTime;
log.debug("redis 库存 -> time:" + (currentTime) + "毫秒");
try {
//mongo //mongo
mongoTemplate.getCollection(KylinOrderTicketVo.class.getSimpleName()).updateMany( mongoTemplate.getCollection(KylinOrderTicketVo.class.getSimpleName()).updateMany(
Query.query(Criteria.where("orderTicketsId").in(orderIdList)).getQueryObject(), Query.query(Criteria.where("orderTicketsId").in(orderIdList)).getQueryObject(),
...@@ -1083,29 +1101,45 @@ public class KylinOrderTicketsServiceImpl extends ServiceImpl<KylinOrderTicketsM ...@@ -1083,29 +1101,45 @@ public class KylinOrderTicketsServiceImpl extends ServiceImpl<KylinOrderTicketsM
); );
currentTime = System.currentTimeMillis() - currentTime; currentTime = System.currentTimeMillis() - currentTime;
log.debug("mongo -> time:" + (currentTime) + "毫秒"); log.debug("mongo -> time:" + (currentTime) + "毫秒");
} catch (Exception e) {
Thread thread = new Thread(() -> {
//redis 列表
orderDataList.forEach(t -> {
String orderTicketId = t.split(",")[0];
String uid = t.split(",")[1];
KylinOrderTicketVo vo = dataUtils.getOrderTicketVo(orderTicketId);
vo.setStatus(2);
redisUtil.set(KylinRedisConst.ORDER + orderTicketId, vo);
mongoVoUtils.resetOrderListVo(uid, 2, orderTicketId, vo);
// redis 限购
for (int i = 0; i < vo.getEntitiesVoList().size(); i++) {
KylinOrderTicketEntitiesVo items = vo.getEntitiesVoList().get(i);
dataUtils.changeBuyInfo(items.getUserId(), items.getEnterIdCode(), items.getPerformanceId(), items.getTicketId(), -1);
}
});
});
thread.start();
} }
} catch (Exception e) {
e.printStackTrace(); int forSize = 500;
} finally { int forCount = orderDataList.size() % forSize == 0 ? orderDataList.size() / forSize : (orderDataList.size() / forSize) + 1;
for (int i = 0; i < forCount; i++) {
LinkedList<String> mqList = new LinkedList<>();
for (int y = 0; y < forSize; y++) {
try {
String t = orderDataList.get(i * 500 + y);
mqList.add(t);
} catch (Exception e) {
break;
}
}
rabbitTemplate.convertAndSend(MQConst.EXCHANGES_LIQUIDNET_SQL_ORDER_CLOSE, MQConst.ROUTING_KEY_SQL_ORDER_CLOSE, OrderCloseMapping.get(mqList));
}
// 线程循环更改限购
// kylinThreadService.checkOrderTimeThread(orderDataList);
// Thread thread = new Thread(() -> {
// //redis 列表
// orderDataList.forEach(t -> {
// String orderTicketId = t.split(",")[0];
// String uid = t.split(",")[1];
// KylinOrderTicketVo vo = dataUtils.getOrderTicketVo(orderTicketId);
// vo.setStatus(2);
// redisUtil.set(KylinRedisConst.ORDER + orderTicketId, vo);
// mongoVoUtils.resetOrderListVo(uid, 2, orderTicketId, vo);
// // redis 限购
// for (int i = 0; i < vo.getEntitiesVoList().size(); i++) {
// KylinOrderTicketEntitiesVo items = vo.getEntitiesVoList().get(i);
// dataUtils.changeBuyInfo(items.getUserId(), items.getEnterIdCode(), items.getPerformanceId(), items.getTicketId(), -1);
// }
// });
// });
// thread.start();
} }
redisLockUtil.unlock(lock); redisLockUtil.unlock(lock);
} else { } else {
log.debug("WARNING LOCKING"); log.debug("WARNING LOCKING");
......
...@@ -29,6 +29,7 @@ import org.springframework.data.mongodb.core.query.Query; ...@@ -29,6 +29,7 @@ import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -86,6 +87,21 @@ public class KylinPerformancesServiceImpl extends ServiceImpl<KylinPerformancesM ...@@ -86,6 +87,21 @@ public class KylinPerformancesServiceImpl extends ServiceImpl<KylinPerformancesM
} }
if (days > 0) { if (days > 0) {
isRecommend = 0; isRecommend = 0;
HashMap toDayTime = DateUtil.oneDayStartEnd();
String nowTimeTStr = (String) toDayTime.get("startStr");
String timeStart = info.getTimeStart();
// 今天的0点到几天后的0点
Calendar cal = Calendar.getInstance();
cal.setTime((Date) toDayTime.get("start"));
Date beforeDayEnd = DateUtil.getBeforeDayBegin(cal, days);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String daysLaterStr = sdf.format(beforeDayEnd);
if (-1 == DateUtil.compareStrDay(timeStart, nowTimeTStr) || -1 == DateUtil.compareStrDay(daysLaterStr, timeStart)) {
isShow = false;
}
} }
if (isShow) { if (isShow) {
performancesIds.add(info.getPerformancesId()); performancesIds.add(info.getPerformancesId());
...@@ -194,12 +210,14 @@ public class KylinPerformancesServiceImpl extends ServiceImpl<KylinPerformancesM ...@@ -194,12 +210,14 @@ public class KylinPerformancesServiceImpl extends ServiceImpl<KylinPerformancesM
// 会员状态 // 会员状态
Integer isMemberStatus = getIsMemberStatus(ticket); Integer isMemberStatus = getIsMemberStatus(ticket);
ticket.setIsMemberStatus(isMemberStatus); ticket.setIsMemberStatus(isMemberStatus);
if (null != isAgent && isAgent > 0) { if (null == isAgent || 0 == isAgent) {
if (ticket.getIsAgent() == isAgent) { if (0 == ticket.getIsAgent()) {
ticketListNew.add(ticket);
}
} else if(1 == isAgent) {
if (1 == ticket.getIsAgent()) {
ticketListNew.add(ticket); ticketListNew.add(ticket);
} }
} else {
ticketListNew.add(ticket);
} }
} }
partner.setTicketList(ticketListNew); partner.setTicketList(ticketListNew);
...@@ -334,7 +352,7 @@ public class KylinPerformancesServiceImpl extends ServiceImpl<KylinPerformancesM ...@@ -334,7 +352,7 @@ public class KylinPerformancesServiceImpl extends ServiceImpl<KylinPerformancesM
String nowTimeStr = DateUtil.getNowTime(); String nowTimeStr = DateUtil.getNowTime();
for (KylinPerformanceVo info : list) { for (KylinPerformanceVo info : list) {
Integer isEnd = DateUtil.compareStrDay(nowTimeStr, info.getTimeEnd()); Integer isEnd = DateUtil.compareStrDay(nowTimeStr, info.getTimeEnd());
if (3 != info.getAppStatus() && 1 != isEnd) { // 演出已结束或者未上线 if (7 != info.getAppStatus() && 3 != info.getAppStatus() && 1 != isEnd) { // 演出已结束或者未上线
String timeStart = info.getSellTime(); String timeStart = info.getSellTime();
String timeEnd = info.getStopSellTime(); String timeEnd = info.getStopSellTime();
...@@ -393,7 +411,7 @@ public class KylinPerformancesServiceImpl extends ServiceImpl<KylinPerformancesM ...@@ -393,7 +411,7 @@ public class KylinPerformancesServiceImpl extends ServiceImpl<KylinPerformancesM
// 票状态 6票可购买 8售罄 9未开始 10结束 11停售 // 票状态 6票可购买 8售罄 9未开始 10结束 11停售
// 演出状态 7下架前端不展示 // 演出状态 7下架前端不展示
if (info.getAppStatus() != 8 && info.getAppStatus() != 11) { if (info.getAppStatus() != 8 && info.getAppStatus() != 11 && 7 != info.getAppStatus()) {
String sellTime = info.getSellTime(); String sellTime = info.getSellTime();
if (1 == DateUtil.compareStrDay(sellTime, nowTimeStr)) {// 未开始 if (1 == DateUtil.compareStrDay(sellTime, nowTimeStr)) {// 未开始
info.setAppStatus(9); info.setAppStatus(9);
...@@ -403,7 +421,7 @@ public class KylinPerformancesServiceImpl extends ServiceImpl<KylinPerformancesM ...@@ -403,7 +421,7 @@ public class KylinPerformancesServiceImpl extends ServiceImpl<KylinPerformancesM
} }
} else { // 已开始 } else { // 已开始
info.setAppStatus(6); info.setAppStatus(6);
if (1 == DateUtil.compareStrDay(timeEnd, nowTimeStr)) { // 演出已结束 if (1 == DateUtil.compareStrDay(nowTimeStr, timeEnd)) { // 演出已结束
info.setAppStatus(10); info.setAppStatus(10);
} }
} }
......
...@@ -286,6 +286,7 @@ public class KylinRefundsStatusServiceImpl { ...@@ -286,6 +286,7 @@ public class KylinRefundsStatusServiceImpl {
kylinOrderRefunds.setApplicantId(authId); kylinOrderRefunds.setApplicantId(authId);
kylinOrderRefunds.setApplicantName(authName); kylinOrderRefunds.setApplicantName(authName);
kylinOrderRefunds.setApplicantAt(LocalDateTime.now()); kylinOrderRefunds.setApplicantAt(LocalDateTime.now());
kylinOrderRefunds.setType(1);
kylinOrderRefunds.setReason(reason); kylinOrderRefunds.setReason(reason);
if (RefundPriceExpress > 0 && entitiesPriceSum > 0) { if (RefundPriceExpress > 0 && entitiesPriceSum > 0) {
kylinOrderRefunds.setRefundCate(KylinTableStatusConst.ORDER_REFUND_CATE3); kylinOrderRefunds.setRefundCate(KylinTableStatusConst.ORDER_REFUND_CATE3);
......
...@@ -8,12 +8,10 @@ import com.liquidnet.service.kylin.constant.KylinTableStatusConst; ...@@ -8,12 +8,10 @@ import com.liquidnet.service.kylin.constant.KylinTableStatusConst;
import com.liquidnet.service.kylin.dao.KylinOrderTicketEntitiesDao; import com.liquidnet.service.kylin.dao.KylinOrderTicketEntitiesDao;
import com.liquidnet.service.kylin.dto.param.RefundApplyParam; import com.liquidnet.service.kylin.dto.param.RefundApplyParam;
import com.liquidnet.service.kylin.dto.param.RefundCallbackParam; import com.liquidnet.service.kylin.dto.param.RefundCallbackParam;
import com.liquidnet.service.kylin.entity.KylinOrderRefunds; import com.liquidnet.service.kylin.entity.*;
import com.liquidnet.service.kylin.entity.KylinOrderTicketEntities;
import com.liquidnet.service.kylin.entity.KylinOrderTicketStatus;
import com.liquidnet.service.kylin.entity.KylinOrderTickets;
import com.liquidnet.service.kylin.mapper.*; import com.liquidnet.service.kylin.mapper.*;
import com.liquidnet.service.kylin.service.IKylinOrderRefundsService; import com.liquidnet.service.kylin.service.IKylinOrderRefundsService;
import com.liquidnet.service.kylin.utils.DataUtils;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate; import org.springframework.data.mongodb.core.MongoTemplate;
...@@ -51,9 +49,15 @@ public class OrderRefundsCallbackServiceImpl extends ServiceImpl<KylinOrderRefun ...@@ -51,9 +49,15 @@ public class OrderRefundsCallbackServiceImpl extends ServiceImpl<KylinOrderRefun
@Autowired @Autowired
private KylinOrderTicketEntitiesMapper kylinOrderTicketEntitiesMapper; private KylinOrderTicketEntitiesMapper kylinOrderTicketEntitiesMapper;
@Autowired
private KylinOrderTicketRelationsMapper kylinOrderTicketRelationsMapper;
@Autowired @Autowired
MongoTemplate mongoTemplate; MongoTemplate mongoTemplate;
@Autowired
private DataUtils dataUtils;
public String refundCallback(RefundCallbackParam refundCallbackParam) { public String refundCallback(RefundCallbackParam refundCallbackParam) {
KylinOrderRefunds refundInfo = kylinOrderRefundsMapper.selectOne( KylinOrderRefunds refundInfo = kylinOrderRefundsMapper.selectOne(
new UpdateWrapper<KylinOrderRefunds>() new UpdateWrapper<KylinOrderRefunds>()
...@@ -103,6 +107,9 @@ public class OrderRefundsCallbackServiceImpl extends ServiceImpl<KylinOrderRefun ...@@ -103,6 +107,9 @@ public class OrderRefundsCallbackServiceImpl extends ServiceImpl<KylinOrderRefun
KylinOrderTickets orderInfo = kylinOrderTicketsMapper.selectOne( KylinOrderTickets orderInfo = kylinOrderTicketsMapper.selectOne(
new QueryWrapper<KylinOrderTickets>().eq("order_tickets_id", orderTicketsId) new QueryWrapper<KylinOrderTickets>().eq("order_tickets_id", orderTicketsId)
); );
KylinOrderTicketRelations orderRelations = kylinOrderTicketRelationsMapper.selectOne(
new QueryWrapper<KylinOrderTicketRelations>().eq("order_id", orderTicketsId)
);
// 传的快递费不能大于实际的快递费=(支付的快递费-已退的快递费) // 传的快递费不能大于实际的快递费=(支付的快递费-已退的快递费)
Double refundPriceExpressSum = kylinOrderRefundsMapper.RefundPriceExpressSum(// 已退快递费 Double refundPriceExpressSum = kylinOrderRefundsMapper.RefundPriceExpressSum(// 已退快递费
orderTicketsId, orderTicketsId,
...@@ -155,6 +162,14 @@ public class OrderRefundsCallbackServiceImpl extends ServiceImpl<KylinOrderRefun ...@@ -155,6 +162,14 @@ public class OrderRefundsCallbackServiceImpl extends ServiceImpl<KylinOrderRefun
ticketEntityIds, entitiesPrice ticketEntityIds, entitiesPrice
); );
if (res) { if (res) {
// 超时直接退还库存
for (String entitiesId : ticketEntityIds) {
dataUtils.changeSurplusGeneral(entitiesId, 1);
KylinOrderTicketEntities entitiesInfo = kylinOrderTicketEntitiesMapper.selectOne(
new QueryWrapper<KylinOrderTicketEntities>().eq("order_ticket_entities_id", entitiesId)
);
dataUtils.changeBuyInfo(orderInfo.getUserId(), "", orderRelations.getPerformanceId(), entitiesInfo.getTicketId(), -1);
}
return true; return true;
} else { } else {
return false; return false;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment