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

Commit 7420ea3d authored by anjiabin's avatar anjiabin
parents d35bcd4f 5ca13a09
......@@ -99,12 +99,10 @@ public class SqlMapping {
return JsonUtils.toJson(sqlMessage);
}
public static String get(LinkedList<String> sqls, LinkedList<Object[]> paramsList) {
LinkedList<Object[]>[] args = new LinkedList[]{paramsList};
public static String gets(LinkedList<String> sqls, LinkedList<Object[]>... paramsList) {
SqlMapping.SqlMessage sqlMessage = SqlMapping.SqlMessage.getInstance();
sqlMessage.setSqls(sqls);
sqlMessage.setArgs(args);
sqlMessage.setArgs(paramsList);
return JsonUtils.toJson(sqlMessage);
}
}
......@@ -89,7 +89,7 @@ public class KylinOrderTicketsServiceImpl extends ServiceImpl<KylinOrderTicketsM
public ResponseDto<PayResultVo> checkCanOrder(PayOrderParam payOrderParam) {
boolean isDownGeneral = false;
String uid = CurrentUtil.getCurrentUid();
if(!RedisLockUtil.tryLock("userId:" + uid,2,2)){
if (!RedisLockUtil.tryLock("userId:" + uid, 2, 2)) {
return ResponseDto.failure("请求频繁");//参数错误
}
RLock lock = RedisLockUtil.lock("userId:" + uid, 2);
......@@ -164,7 +164,7 @@ public class KylinOrderTicketsServiceImpl extends ServiceImpl<KylinOrderTicketsM
}
//快递票判断
if(payOrderParam.getIsExpress()!=null) {
if (payOrderParam.getIsExpress() != null) {
if (payOrderParam.getIsExpress() == 1 && DateUtil.compareStrDay(DateUtil.getNowTime(), timeExpressEnd) == 1) {
lock.unlock();
return ResponseDto.failure("已超过快递票截止时间");//快递票不卖
......@@ -285,7 +285,7 @@ public class KylinOrderTicketsServiceImpl extends ServiceImpl<KylinOrderTicketsM
}
}
lock.unlock();
return order(payOrderParam, uid, isMember, isTrueName, performanceData, ticketData, entersVoList,isStudent);
return order(payOrderParam, uid, isMember, isTrueName, performanceData, ticketData, entersVoList, isStudent);
}
} catch (Exception e) {
if (isDownGeneral) {
......@@ -298,19 +298,18 @@ public class KylinOrderTicketsServiceImpl extends ServiceImpl<KylinOrderTicketsM
}
}
private ResponseDto<PayResultVo> order(PayOrderParam payOrderParam, String uid, boolean isMember, int isTrueName, KylinPerformanceVo performanceData, KylinTicketVo ticketData, List<AdamEntersVo> entersVoList,Integer isStudent) {
private ResponseDto<PayResultVo> order(PayOrderParam payOrderParam, String uid, boolean isMember, int isTrueName, KylinPerformanceVo performanceData, KylinTicketVo ticketData, List<AdamEntersVo> entersVoList, Integer isStudent) {
LinkedList<String> sqls = new LinkedList<>();
LinkedList<Object[]> paramsList = new LinkedList<>();
String source = CurrentUtil.getCliSource()==null?"":CurrentUtil.getCliSource();
String version = CurrentUtil.getCliVersion()==null?"":CurrentUtil.getCliVersion();
String source = CurrentUtil.getCliSource() == null ? "" : CurrentUtil.getCliSource();
String version = CurrentUtil.getCliVersion() == null ? "" : CurrentUtil.getCliVersion();
//生成订单 order_ticket
KylinOrderTickets orderTickets = new KylinOrderTickets();
String orderTicketId = IDGenerator.nextSnowId().toString();
orderTickets.setOrderTicketsId(orderTicketId);
orderTickets.setUserId(uid);
Map token = CurrentUtil.getTokenClaims();
orderTickets.setUserName(StringUtils.defaultString(((String) token.get("nickname")),""));
orderTickets.setUserMobile(StringUtils.defaultString(((String) token.get("mobile")),""));
orderTickets.setUserName(StringUtils.defaultString(((String) token.get("nickname")), ""));
orderTickets.setUserMobile(StringUtils.defaultString(((String) token.get("mobile")), ""));
orderTickets.setPerformanceTitle(performanceData.getTitle());
orderTickets.setOrderCode(IDGenerator.ticketOrderCode(orderTicketId));
orderTickets.setPayCode("");
......@@ -352,7 +351,8 @@ public class KylinOrderTicketsServiceImpl extends ServiceImpl<KylinOrderTicketsM
orderTickets.setCreatedAt(LocalDateTime.now());
orderTickets.setUpdatedAt(null);
sqls.add(SqlMapping.get("kylin_order_ticket.add"));
paramsList.add(orderTickets.getAddObject());
LinkedList<Object[]> sqlsDataA = new LinkedList<Object[]>();
sqlsDataA.add(orderTickets.getAddObject());
//生成订单 order_ticket_status
......@@ -368,7 +368,8 @@ public class KylinOrderTicketsServiceImpl extends ServiceImpl<KylinOrderTicketsM
orderTicketStatus.setCreatedAt(LocalDateTime.now());
orderTicketStatus.setUpdatedAt(null);
sqls.add(SqlMapping.get("kylin_order_ticket_status.add"));
paramsList.add(orderTicketStatus.getAddObject());
LinkedList<Object[]> sqlsDataB = new LinkedList<Object[]>();
sqlsDataB.add(orderTicketStatus.getAddObject());
//生成订单 order_ticket_relation
KylinOrderTicketRelations orderTicketRelations = new KylinOrderTicketRelations();
......@@ -385,12 +386,14 @@ public class KylinOrderTicketsServiceImpl extends ServiceImpl<KylinOrderTicketsM
orderTicketRelations.setCreatedAt(LocalDateTime.now());
orderTicketRelations.setUpdatedAt(null);
sqls.add(SqlMapping.get("kylin_order_ticket_relation.add"));
paramsList.add(orderTicketRelations.getAddObject());
LinkedList<Object[]> sqlsDataC = new LinkedList<Object[]>();
sqlsDataC.add(orderTicketRelations.getAddObject());
//生成票
KylinOrderTicketEntities orderTicketEntities = new KylinOrderTicketEntities();
String orderTicketEntitiesId = IDGenerator.nextSnowId().toString();
LinkedList<Object[]> sqlsDataD = null;
if (isTrueName == 1) {
for (AdamEntersVo enters : entersVoList) {
orderTicketEntities.setOrderTicketEntitiesId(orderTicketEntitiesId);
......@@ -411,7 +414,8 @@ public class KylinOrderTicketsServiceImpl extends ServiceImpl<KylinOrderTicketsM
orderTicketEntities.setCreatedAt(LocalDateTime.now());
orderTicketEntities.setUpdatedAt(null);
sqls.add(SqlMapping.get("kylin_order_ticket_entities.add"));
paramsList.add(orderTicketEntities.getAddObject());
sqlsDataD = new LinkedList<Object[]>();
sqlsDataD.add(orderTicketEntities.getAddObject());
// 生成vo
KylinOrderTicketEntitiesVo orderTicketEntitiesVo = new KylinOrderTicketEntitiesVo();
BeanUtils.copyProperties(orderTicketEntities, orderTicketEntitiesVo);
......@@ -443,7 +447,8 @@ public class KylinOrderTicketsServiceImpl extends ServiceImpl<KylinOrderTicketsM
orderTicketEntities.setCreatedAt(LocalDateTime.now());
orderTicketEntities.setUpdatedAt(null);
sqls.add(SqlMapping.get("kylin_order_ticket_entities.add"));
paramsList.add(orderTicketEntities.getAddObject());
sqlsDataD = new LinkedList<Object[]>();
sqlsDataD.add(orderTicketEntities.getAddObject());
// 生成vo
KylinOrderTicketEntitiesVo orderTicketEntitiesVo = new KylinOrderTicketEntitiesVo();
BeanUtils.copyProperties(orderTicketEntities, orderTicketEntitiesVo);
......@@ -461,7 +466,7 @@ public class KylinOrderTicketsServiceImpl extends ServiceImpl<KylinOrderTicketsM
httpData.add("type", "TICKET");
if (Arrays.asList("dev", "test").contains(environment.getProperty("spring.profiles.active"))) {
httpData.add("price", orderTickets.getPriceActual().toString());
}else{
} else {
httpData.add("price", "0.01");
}
httpData.add("name", ticketData.getUseStart() + "" + ticketData.getTitle());
......@@ -502,8 +507,10 @@ public class KylinOrderTicketsServiceImpl extends ServiceImpl<KylinOrderTicketsM
orderTicketVo.setCreatedAt(orderTickets.getCreatedAt().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
mongoTemplate.insert(orderTicketVo, KylinOrderTicketVo.class.getSimpleName());
// 执行sql
String sqlData = SqlMapping.gets(sqls, sqlsDataA, sqlsDataB, sqlsDataC, sqlsDataD);
rabbitTemplate.convertAndSend(MQConst.EXCHANGES_LIQUIDNET_SQL, MQConst.ROUTING_KEY_SQL,
SqlMapping.get(sqls, paramsList));
sqlData);
return ResponseDto.success(payResultVo);
}
......@@ -542,7 +549,7 @@ public class KylinOrderTicketsServiceImpl extends ServiceImpl<KylinOrderTicketsM
httpData.add("type", "TICKET");
if (Arrays.asList("dev", "test").contains(environment.getProperty("spring.profiles.active"))) {
httpData.add("price", orderTicketData.getPriceActual().toString());
}else{
} else {
httpData.add("price", "0.01");
}
httpData.add("name", entitiesData.getUseStart() + "" + entitiesData.getPerformanceTitle());
......@@ -586,8 +593,8 @@ public class KylinOrderTicketsServiceImpl extends ServiceImpl<KylinOrderTicketsM
);
dataUtils.delOrderTicketRedis(orderTickets.getOrderTicketsId());
rabbitTemplate.convertAndSend(MQConst.EXCHANGES_LIQUIDNET_SQL, MQConst.ROUTING_KEY_SQL,
SqlMapping.get("kylin_order_ticket.payAgain", orderTickets.getPayAgainObject()));
rabbitTemplate.convertAndSend(MQConst.EXCHANGES_LIQUIDNET_SQL, MQConst.ROUTING_KEY_SQL,
SqlMapping.get("kylin_order_ticket.payAgain", orderTickets.getPayAgainObject()));
return ResponseDto.success(payResultVo);
}
return ResponseDto.failure("未选择支付方式");
......@@ -603,7 +610,7 @@ public class KylinOrderTicketsServiceImpl extends ServiceImpl<KylinOrderTicketsM
//支付时间
LocalDateTime now = LocalDateTime.now();
if(!RedisLockUtil.tryLock("order_lock:" + syncOrderParam.getOrder_code(),240,240)){
if (!RedisLockUtil.tryLock("order_lock:" + syncOrderParam.getOrder_code(), 240, 240)) {
return "fail";//参数错误
}
RLock lock = RedisLockUtil.lock("order_lock:" + syncOrderParam.getOrder_code(), 240);
......@@ -634,7 +641,6 @@ public class KylinOrderTicketsServiceImpl extends ServiceImpl<KylinOrderTicketsM
}
LinkedList<String> sqls = new LinkedList<>();
LinkedList<Object[]> paramsList = new LinkedList<>();
//sql
KylinOrderTickets orderTickets = new KylinOrderTickets();
......@@ -645,7 +651,8 @@ public class KylinOrderTicketsServiceImpl extends ServiceImpl<KylinOrderTicketsM
orderTickets.setQrCode(IDGenerator.ticketQrCode(orderTicketData.getOrderTicketsId()));
orderTickets.setUpdatedAt(now);
sqls.add(SqlMapping.get("kylin_order_ticket.synPay"));
paramsList.add(orderTickets.getSynOrderObject());
LinkedList<Object[]> sqlsDataA = new LinkedList<Object[]>();
sqlsDataA.add(orderTickets.getSynOrderObject());
KylinOrderTicketStatus orderTicketStatus = new KylinOrderTicketStatus();
orderTicketStatus.setOrderId(orderTicketData.getOrderTicketsId());
......@@ -653,14 +660,16 @@ public class KylinOrderTicketsServiceImpl extends ServiceImpl<KylinOrderTicketsM
orderTicketStatus.setPayStatus(syncOrderParam.getStatus());
orderTicketStatus.setUpdatedAt(orderTickets.getUpdatedAt());
sqls.add(SqlMapping.get("kylin_order_ticket_status.synPay"));
paramsList.add(orderTicketStatus.getSynOrderObject());
LinkedList<Object[]> sqlsDataB = new LinkedList<Object[]>();
sqlsDataB.add(orderTicketStatus.getSynOrderObject());
KylinOrderTicketEntities orderTicketEntities = new KylinOrderTicketEntities();
orderTicketEntities.setOrderId(orderTicketData.getOrderTicketsId());
orderTicketEntities.setIsPayment(KylinTableStatusConst.ENTITIES_IS_PAYMENT1);
orderTicketEntities.setUpdatedAt(orderTickets.getUpdatedAt());
sqls.add(SqlMapping.get("kylin_order_ticket_entities.synPay"));
paramsList.add(orderTicketEntities.getSynOrderObject());
LinkedList<Object[]> sqlsDataC = new LinkedList<Object[]>();
sqlsDataC.add(orderTicketEntities.getSynOrderObject());
//vo
......@@ -691,7 +700,7 @@ public class KylinOrderTicketsServiceImpl extends ServiceImpl<KylinOrderTicketsM
}
rabbitTemplate.convertAndSend(MQConst.EXCHANGES_LIQUIDNET_SQL, MQConst.ROUTING_KEY_SQL,
SqlMapping.get(sqls, paramsList));
SqlMapping.gets(sqls, sqlsDataA,sqlsDataB,sqlsDataC));
// 发短信
return "success";
......@@ -843,10 +852,10 @@ public class KylinOrderTicketsServiceImpl extends ServiceImpl<KylinOrderTicketsM
dataUtils.changeSurplusGeneral(itemData.getTicketId(), itemData.getNumber());
rabbitTemplate.convertAndSend(MQConst.EXCHANGES_LIQUIDNET_SQL, MQConst.ROUTING_KEY_SQL,
SqlMapping.get("kylin_order_ticket.close", orderTickets.getCloseOrderObject()));
rabbitTemplate.convertAndSend(MQConst.EXCHANGES_LIQUIDNET_SQL, MQConst.ROUTING_KEY_SQL,
SqlMapping.get("kylin_order_ticket_status.close", orderTicketStatus.getCloseOrderObject()));
rabbitTemplate.convertAndSend(MQConst.EXCHANGES_LIQUIDNET_SQL, MQConst.ROUTING_KEY_SQL,
SqlMapping.get("kylin_order_ticket.close", orderTickets.getCloseOrderObject()));
rabbitTemplate.convertAndSend(MQConst.EXCHANGES_LIQUIDNET_SQL, MQConst.ROUTING_KEY_SQL,
SqlMapping.get("kylin_order_ticket_status.close", orderTicketStatus.getCloseOrderObject()));
} catch (Exception e) {
lock.unlock();
......@@ -858,7 +867,7 @@ public class KylinOrderTicketsServiceImpl extends ServiceImpl<KylinOrderTicketsM
}
}
return true;
}catch (Exception e){
} catch (Exception e) {
e.printStackTrace();
return false;
}
......@@ -869,12 +878,12 @@ public class KylinOrderTicketsServiceImpl extends ServiceImpl<KylinOrderTicketsM
KylinOrderTicketVo orderTicketData = dataUtils.getOrderTicketVo(orderId);
if (orderTicketData == null) {
return ResponseDto.failure("订单不存在");
}else{
} else {
String returnCheckData = HttpUtil.get(checkUrl + "?code=" + orderTicketData.getPayCode(), null);
PayResultVo checkVo = JsonUtils.fromJson(returnCheckData, PayResultVo.class);
if (checkVo.getStatus() == 1) {
return ResponseDto.success(1);
}else{
} else {
return ResponseDto.success(0);
}
}
......
kylin_order_ticket_entities.add=INSERT INTO kylin_order_ticket_entities(order_ticket_entities_id ,order_id ,ticket_id ,user_id ,time_id ,performance_id ,enter_type ,enter_name ,enter_mobile,enter_id_code,status,sys_damai,check_client,is_payment,comment,created_at,updated_at)VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
kylin_order_ticket_entities.add=INSERT INTO kylin_order_ticket_entities(order_ticket_entities_id ,order_id ,ticket_id ,user_id ,time_id ,performance_id ,enter_type ,enter_name ,enter_mobile,enter_id_code,`status`,sys_damai,check_client,is_payment,`comment`,created_at,updated_at)VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
kylin_order_ticket_entities.synPay=UPDATE kylin_order_ticket_entities SET is_payment = ?,updated_at = ? WHERE order_tickets_id = ?
kylin_order_ticket_entities.updateStatusByStation=UPDATE kylin_order_ticket_status SET `status`=?, updated_at=?, checked_at=?, check_type=?, checkUserId=? WHERE order_ticket_entities_id =?
......@@ -6,12 +6,12 @@ kylin_order_ticket_entities.updateStatusByStation=UPDATE kylin_order_ticket_stat
kylin_order_ticket_relation.add=INSERT INTO kylin_order_ticket_relations(order_ticket_relations_id ,order_id ,transfer_id ,live_id ,agent_id ,is_member ,performance_id ,time_id ,ticket_id ,created_at ,updated_at)VALUES(?,?,?,?,?,?,?,?,?,?,?)
# ----------------------------------------------------
kylin_order_ticket_status.add=INSERT INTO kylin_order_ticket_status(order_ticket_status_id ,order_id ,express_type ,is_student ,transfer_status ,status ,pay_status ,created_at ,updated_at)VALUES(?,?,?,?,?,?,?,?,?)
kylin_order_ticket_status.synPay=UPDATE kylin_order_ticket_status SET status = ?,pay_status = ?,updated_at = ? WHERE order_tickets_id = ?
kylin_order_ticket_status.close=UPDATE kylin_order_ticket_status SET status = ?,updated_at = ? WHERE order_tickets_id = ?
kylin_order_ticket_status.add=INSERT INTO kylin_order_ticket_status(order_ticket_status_id ,order_id ,express_type ,is_student ,transfer_status ,`status` ,pay_status ,created_at ,updated_at)VALUES(?,?,?,?,?,?,?,?,?)
kylin_order_ticket_status.synPay=UPDATE kylin_order_ticket_status SET `status` = ?,pay_status = ?,updated_at = ? WHERE order_tickets_id = ?
kylin_order_ticket_status.close=UPDATE kylin_order_ticket_status SET `status` = ?,updated_at = ? WHERE order_tickets_id = ?
# ----------------------------------------------------
kylin_order_ticket.add=INSERT INTO kylin_order_tickets(order_tickets_id,user_id,user_name,user_mobile,performance_title,order_code,qr_code,order_type,order_version,number,price,price_member,price_total,price_voucher,price_actual,price_express,price_refund,refund_number,pay_type,payment_type,time_pay,express_contacts,express_address,express_phone,coupon_type,get_ticket_type,get_ticket_describe,pay_countdown_minute,comment,created_at,updated_at)VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
kylin_order_ticket.add=INSERT INTO kylin_order_tickets(order_tickets_id,user_id,user_name,user_mobile,performance_title,order_code,qr_code,order_type,order_version,`number`,price,price_member,price_total,price_voucher,price_actual,price_express,price_refund,refund_number,pay_type,payment_type,time_pay,express_contacts,express_address,express_phone,coupon_type,get_ticket_type,get_ticket_describe,pay_countdown_minute,`comment`,created_at,updated_at)VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
kylin_order_ticket.payAgain=UPDATE kylin_order_tickets SET order_type = ? ,order_code = ? , updated_at = ? WHERE order_tickets_id = ?
kylin_order_ticket.synPay=UPDATE kylin_order_tickets SET payment_type = ? ,pay_code = ? , time_pay = ?, qr_code = ? , updated_at = ? WHERE order_tickets_id = ?
kylin_order_ticket.close=UPDATE kylin_order_tickets SET updated_at = ? WHERE order_tickets_id = ?
......
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