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

Commit 1ffd034c authored by 张国柄's avatar 张国柄

Merge remote-tracking branch 'origin/dev' into dev

parents 413b04e2 88a594a2
package com.liquidnet.client.admin.common.utils; package com.liquidnet.client.admin.common.utils;
import java.util.Collection; import java.io.UnsupportedEncodingException;
import java.util.Map; import java.net.URLDecoder;
import java.util.*;
import com.liquidnet.client.admin.common.core.text.StrFormatter; import com.liquidnet.client.admin.common.core.text.StrFormatter;
import org.springframework.util.MultiValueMap;
/** /**
* 字符串工具类 * 字符串工具类
* *
* @author ruoyi * @author ruoyi
*/ */
public class StringUtils extends org.apache.commons.lang3.StringUtils public class StringUtils extends org.apache.commons.lang3.StringUtils
...@@ -19,7 +22,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils ...@@ -19,7 +22,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils
/** /**
* 获取参数不为空值 * 获取参数不为空值
* *
* @param value defaultValue 要判断的value * @param value defaultValue 要判断的value
* @return value 返回值 * @return value 返回值
*/ */
...@@ -30,7 +33,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils ...@@ -30,7 +33,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils
/** /**
* * 判断一个Collection是否为空, 包含List,Set,Queue * * 判断一个Collection是否为空, 包含List,Set,Queue
* *
* @param coll 要判断的Collection * @param coll 要判断的Collection
* @return true:为空 false:非空 * @return true:为空 false:非空
*/ */
...@@ -41,7 +44,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils ...@@ -41,7 +44,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils
/** /**
* * 判断一个Collection是否非空,包含List,Set,Queue * * 判断一个Collection是否非空,包含List,Set,Queue
* *
* @param coll 要判断的Collection * @param coll 要判断的Collection
* @return true:非空 false:空 * @return true:非空 false:空
*/ */
...@@ -52,7 +55,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils ...@@ -52,7 +55,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils
/** /**
* * 判断一个对象数组是否为空 * * 判断一个对象数组是否为空
* *
* @param objects 要判断的对象数组 * @param objects 要判断的对象数组
** @return true:为空 false:非空 ** @return true:为空 false:非空
*/ */
...@@ -63,7 +66,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils ...@@ -63,7 +66,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils
/** /**
* * 判断一个对象数组是否非空 * * 判断一个对象数组是否非空
* *
* @param objects 要判断的对象数组 * @param objects 要判断的对象数组
* @return true:非空 false:空 * @return true:非空 false:空
*/ */
...@@ -74,7 +77,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils ...@@ -74,7 +77,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils
/** /**
* * 判断一个Map是否为空 * * 判断一个Map是否为空
* *
* @param map 要判断的Map * @param map 要判断的Map
* @return true:为空 false:非空 * @return true:为空 false:非空
*/ */
...@@ -85,7 +88,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils ...@@ -85,7 +88,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils
/** /**
* * 判断一个Map是否为空 * * 判断一个Map是否为空
* *
* @param map 要判断的Map * @param map 要判断的Map
* @return true:非空 false:空 * @return true:非空 false:空
*/ */
...@@ -96,7 +99,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils ...@@ -96,7 +99,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils
/** /**
* * 判断一个字符串是否为空串 * * 判断一个字符串是否为空串
* *
* @param str String * @param str String
* @return true:为空 false:非空 * @return true:为空 false:非空
*/ */
...@@ -107,7 +110,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils ...@@ -107,7 +110,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils
/** /**
* * 判断一个字符串是否为非空串 * * 判断一个字符串是否为非空串
* *
* @param str String * @param str String
* @return true:非空串 false:空串 * @return true:非空串 false:空串
*/ */
...@@ -118,7 +121,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils ...@@ -118,7 +121,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils
/** /**
* * 判断一个对象是否为空 * * 判断一个对象是否为空
* *
* @param object Object * @param object Object
* @return true:为空 false:非空 * @return true:为空 false:非空
*/ */
...@@ -129,7 +132,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils ...@@ -129,7 +132,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils
/** /**
* * 判断一个对象是否非空 * * 判断一个对象是否非空
* *
* @param object Object * @param object Object
* @return true:非空 false:空 * @return true:非空 false:空
*/ */
...@@ -140,7 +143,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils ...@@ -140,7 +143,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils
/** /**
* * 判断一个对象是否是数组类型(Java基本型别的数组) * * 判断一个对象是否是数组类型(Java基本型别的数组)
* *
* @param object 对象 * @param object 对象
* @return true:是数组 false:不是数组 * @return true:是数组 false:不是数组
*/ */
...@@ -159,7 +162,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils ...@@ -159,7 +162,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils
/** /**
* 截取字符串 * 截取字符串
* *
* @param str 字符串 * @param str 字符串
* @param start 开始 * @param start 开始
* @return 结果 * @return 结果
...@@ -190,7 +193,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils ...@@ -190,7 +193,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils
/** /**
* 截取字符串 * 截取字符串
* *
* @param str 字符串 * @param str 字符串
* @param start 开始 * @param start 开始
* @param end 结束 * @param end 结束
...@@ -242,7 +245,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils ...@@ -242,7 +245,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils
* 通常使用:format("this is {} for {}", "a", "b") -> this is a for b<br> * 通常使用:format("this is {} for {}", "a", "b") -> this is a for b<br>
* 转义{}: format("this is \\{} for {}", "a", "b") -> this is \{} for a<br> * 转义{}: format("this is \\{} for {}", "a", "b") -> this is \{} for a<br>
* 转义\: format("this is \\\\{} for {}", "a", "b") -> this is \a for b<br> * 转义\: format("this is \\\\{} for {}", "a", "b") -> this is \a for b<br>
* *
* @param template 文本模板,被替换的部分用 {} 表示 * @param template 文本模板,被替换的部分用 {} 表示
* @param params 参数值 * @param params 参数值
* @return 格式化后的文本 * @return 格式化后的文本
...@@ -306,7 +309,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils ...@@ -306,7 +309,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils
/** /**
* 是否包含字符串 * 是否包含字符串
* *
* @param str 验证字符串 * @param str 验证字符串
* @param strs 字符串组 * @param strs 字符串组
* @return 包含返回true * @return 包含返回true
...@@ -328,7 +331,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils ...@@ -328,7 +331,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils
/** /**
* 将下划线大写方式命名的字符串转换为驼峰式。如果转换前的下划线大写方式命名的字符串为空,则返回空字符串。 例如:HELLO_WORLD->HelloWorld * 将下划线大写方式命名的字符串转换为驼峰式。如果转换前的下划线大写方式命名的字符串为空,则返回空字符串。 例如:HELLO_WORLD->HelloWorld
* *
* @param name 转换前的下划线大写方式命名的字符串 * @param name 转换前的下划线大写方式命名的字符串
* @return 转换后的驼峰式命名的字符串 * @return 转换后的驼峰式命名的字符串
*/ */
...@@ -405,4 +408,52 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils ...@@ -405,4 +408,52 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils
{ {
return (T) obj; return (T) obj;
} }
public static String httpBuildQuery(MultiValueMap<String, String> array) {
String reString = null;
//遍历数组形成akey=avalue&bkey=bvalue&ckey=cvalue形式的的字符串
Iterator it = array.entrySet().iterator();
while (it.hasNext()){
Map.Entry<String,Object> entry =(Map.Entry) it.next();
String key = entry.getKey();
Object value = entry.getValue();
reString += key+"="+value+"&";
}
reString = reString.substring(0, reString.length()-1);
//将得到的字符串进行处理得到目标格式的字符串
reString = URLDecoder.decode(reString);
try {
reString = URLDecoder.decode(reString, "UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
reString = reString.replace("%3D", "=").replace("%26", "&");
return reString;
}
public static String Ksort(MultiValueMap<String, String> map) {
String sb = "";
String[] key = new String[map.size()];
int index = 0;
for (String k : map.keySet()) {
key[index] = k;
index++;
}
// Arrays.sort(key);
for (String s : key) {
sb += s + "=" + map.get(s).get(0) + "&";
}
sb = sb.substring(0, sb.length() - 1);
// 将得到的字符串进行处理得到目标格式的字符串
try {
sb = URLDecoder.decode(sb, "UTF-8");
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}// 使用常见的UTF-8编码
sb = sb.replace("%3D", "=").replace("%26", "&");
return sb;
}
} }
...@@ -157,6 +157,7 @@ public class KylinOrderRefundAdminController extends BaseController { ...@@ -157,6 +157,7 @@ public class KylinOrderRefundAdminController extends BaseController {
return error("审核退款失败"); return error("审核退款失败");
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace();
return error(e.getMessage()); return error(e.getMessage());
} }
} }
......
...@@ -38,7 +38,6 @@ import org.springframework.util.MultiValueMap; ...@@ -38,7 +38,6 @@ import org.springframework.util.MultiValueMap;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -316,41 +315,33 @@ public class KylinRefundsStatusServiceImpl { ...@@ -316,41 +315,33 @@ public class KylinRefundsStatusServiceImpl {
kylinOrderRefunds.setExecutorName(authName); kylinOrderRefunds.setExecutorName(authName);
kylinOrderRefunds.setExecutorAt(LocalDateTime.now()); kylinOrderRefunds.setExecutorAt(LocalDateTime.now());
kylinOrderRefunds.setRefuse(refuse); kylinOrderRefunds.setRefuse(refuse);
// List<String> refundIds = refundList.stream().map(KylinOrderRefunds -> KylinOrderRefunds.getOrderRefundsId()).collect(Collectors.toList());
List<String> refundIds = refundList.stream().map(KylinOrderRefunds -> KylinOrderRefunds.getOrderRefundsId()).collect(Collectors.toList());
kylinOrderRefundsMapper.update(
kylinOrderRefunds,
new UpdateWrapper<KylinOrderRefunds>().in("order_refunds_id", refundIds)
);
// 开始执行退款 // 开始执行退款
String postUrl = "sss"; String postUrl = "http://testpay.zhengzai.tv/refund/single";
String token = "sss";
MultiValueMap<String, String> headers = new LinkedMultiValueMap();
headers.add("token", token);
for (KylinOrderRefunds refund : refundList) { for (KylinOrderRefunds refund : refundList) {
KylinOrderTickets oderInfo = kylinOrderTicketsMapper.selectOne( KylinOrderTickets oderInfo = kylinOrderTicketsMapper.selectOne(
new QueryWrapper<KylinOrderTickets>() new QueryWrapper<KylinOrderTickets>()
.eq("order_tickets_id", refund.getOrderTicketsId()) .eq("order_tickets_id", refund.getOrderTicketsId())
); );
HashMap<String, Object> params = new HashMap(); MultiValueMap<String, String> params = new LinkedMultiValueMap();
params.put("code", oderInfo.getPayCode()); params.add("code", oderInfo.getPayCode());
params.put("order_refund_code", refund.getOrderRefundCode()); params.add("order_refund_code", refund.getOrderRefundCode());
params.put("price", refund.getPrice()); params.add("price", refund.getPrice().toString());
params.put("reason", refund.getReason()); params.add("reason", refund.getReason());
params.put("notify_url", "sdadurl"); params.add("notify_url", "http://zuul.zhengzai.tv/kylin/refund/callback");
params.put("sign", "qwrertasf");
MultiValueMap<String, String> allParams = new LinkedMultiValueMap(); String sign = StringUtils.Ksort(params);
allParams.put("headers", (List<String>) headers); sign = sign.concat("&key=").concat("R7tXY9smPQPG9Ku5yI0u6sfnlckmk04V");
allParams.put("form_params", (List<String>) params); // sign = MD5.getStrMD5(sign);
sign = sign.toUpperCase();
params.add("sign", sign);
// start // start
// TODO: 2021/5/31 待整理 // TODO: 2021/5/31 待整理
params.put("form_params", "qwrertasf"); String postResult = HttpUtil.post(postUrl, params);
String postResult = HttpUtil.post(postUrl, allParams, headers);
JsonNode postResultNew = JsonUtils.fromJson(postResult, JsonNode.class); JsonNode postResultNew = JsonUtils.fromJson(postResult, JsonNode.class);
// 请求提审接口结果 // 请求提审接口结果
if (postResultNew.get("message").toString() != "OK") { if (postResultNew.get("message").toString() != "OK") {
...@@ -360,7 +351,12 @@ public class KylinRefundsStatusServiceImpl { ...@@ -360,7 +351,12 @@ public class KylinRefundsStatusServiceImpl {
kylinOrderRefundsErr.setRefundAt(LocalDateTime.now()); kylinOrderRefundsErr.setRefundAt(LocalDateTime.now());
kylinOrderRefundsMapper.update( kylinOrderRefundsMapper.update(
kylinOrderRefundsErr, kylinOrderRefundsErr,
new UpdateWrapper<KylinOrderRefunds>().eq("order_refunds_id", refund.getOrderTicketsId()) new UpdateWrapper<KylinOrderRefunds>().eq("order_refunds_id", refund.getOrderRefundsId())
);
} else {
kylinOrderRefundsMapper.update(
kylinOrderRefunds,
new UpdateWrapper<KylinOrderRefunds>().in("order_refunds_id", refund.getOrderRefundsId())
); );
} }
} }
...@@ -387,16 +383,10 @@ public class KylinRefundsStatusServiceImpl { ...@@ -387,16 +383,10 @@ public class KylinRefundsStatusServiceImpl {
newStatus = KylinTableStatusConst.ORDER_STATUS6; newStatus = KylinTableStatusConst.ORDER_STATUS6;
} }
orderStatusTable.setStatus(newStatus); orderStatusTable.setStatus(newStatus);
kylinOrderTicketStatusMapper.update(
KylinOrderTicketVo kylinOrderTicketVo = new KylinOrderTicketVo(); orderStatusTable, new UpdateWrapper<KylinOrderTicketStatus>()
kylinOrderTicketVo.setStatus(newStatus); .eq("order_id", orderTicketsId)
BasicDBObject orderObject = new BasicDBObject("$set", JSON.parse(JsonUtils.toJson(kylinOrderTicketVo)));
Document orderDoc = mongoTemplate.getCollection(KylinOrderTicketVo.class.getSimpleName()).findOneAndUpdate(
Query.query(Criteria.where("orderTicketsId").is(orderTicketsId)).getQueryObject(),
orderObject,
new FindOneAndUpdateOptions().returnDocument(ReturnDocument.AFTER)
); );
dataUtils.delOrderTicketRedis(orderTicketsId);
// 订单表 // 订单表
double price = orderInfo.getPriceRefund().doubleValue() + refundInfo.getPrice().doubleValue(); double price = orderInfo.getPriceRefund().doubleValue() + refundInfo.getPrice().doubleValue();
...@@ -409,14 +399,16 @@ public class KylinRefundsStatusServiceImpl { ...@@ -409,14 +399,16 @@ public class KylinRefundsStatusServiceImpl {
.eq("order_tickets_id", orderTicketsId) .eq("order_tickets_id", orderTicketsId)
); );
KylinOrderTicketVo kylinOrderTicketVoOrder = new KylinOrderTicketVo(); KylinOrderTicketVo kylinOrderTicketVoOrder = new KylinOrderTicketVo();
kylinOrderTicketVoOrder.setStatus(newStatus);
kylinOrderTicketVoOrder.setRefundNumber(num); kylinOrderTicketVoOrder.setRefundNumber(num);
kylinOrderTicketVoOrder.setPriceRefund(BigDecimal.valueOf(price)); kylinOrderTicketVoOrder.setPriceRefund(BigDecimal.valueOf(price));
BasicDBObject orderEntitiesObject = new BasicDBObject("$set", JSON.parse(JsonUtils.toJson(kylinOrderTicketVoOrder))); BasicDBObject orderEntitiesObject = new BasicDBObject("$set", JSON.parse(JsonUtils.toJson(kylinOrderTicketVoOrder)));
Document entitiesDocOrder = mongoTemplate.getCollection(KylinOrderTicketVo.class.getSimpleName()).findOneAndUpdate( Document docOrder = mongoTemplate.getCollection(KylinOrderTicketVo.class.getSimpleName()).findOneAndUpdate(
Query.query(Criteria.where("orderTicketsId").is(orderTicketsId)).getQueryObject(), Query.query(Criteria.where("orderTicketsId").is(orderTicketsId)).getQueryObject(),
orderEntitiesObject, orderEntitiesObject,
new FindOneAndUpdateOptions().returnDocument(ReturnDocument.AFTER) new FindOneAndUpdateOptions().returnDocument(ReturnDocument.AFTER)
); );
dataUtils.delOrderTicketRedis(orderTicketsId);
// 入场人 // 入场人
for (String entitiesId : orderTicketEntitiesIdsArr) { for (String entitiesId : orderTicketEntitiesIdsArr) {
......
...@@ -71,7 +71,7 @@ public class OrderRefundDao implements Serializable { ...@@ -71,7 +71,7 @@ public class OrderRefundDao implements Serializable {
this.statusName="请求退款"; this.statusName="请求退款";
break; break;
case 1: case 1:
this.statusName="审核通过"; this.statusName="一审通过";
break; break;
case 2: case 2:
this.statusName="取消退款"; this.statusName="取消退款";
...@@ -83,13 +83,16 @@ public class OrderRefundDao implements Serializable { ...@@ -83,13 +83,16 @@ public class OrderRefundDao implements Serializable {
this.statusName="完成退款"; this.statusName="完成退款";
break; break;
case 5: case 5:
this.statusName="驳回退款"; this.statusName="一审驳回退款";
break; break;
case 6: case 6:
this.statusName="退款失败"; this.statusName="退款失败";
break; break;
case 7: case 7:
this.statusName="等待退款"; this.statusName="二审通过等待退款";
break;
case 8:
this.statusName="二审驳回退款";
break; break;
default: default:
this.statusName="其他"; this.statusName="其他";
......
package com.liquidnet.service.feign.kylin.api;
import com.liquidnet.service.base.ResponseDto;
import feign.hystrix.FallbackFactory;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import java.util.List;
@Component
@FeignClient(name = "liquidnet-service-kylin",
contextId = "FeignKylinOrderRefundClient", path = "",
fallback = FallbackFactory.Default.class)
public interface FeignKylinOrderRefundClient {
@PostMapping("admin/refund/apply")
ResponseDto<Object> refundApply(
@RequestBody String orderTicketsId,
@RequestBody String orderRefundBatchesId,
@RequestBody String refundData,
@RequestBody String reason
);
@PostMapping("admin/refund/cancel")
@ApiOperation("取消退款")
ResponseDto<Object> refundApply(@RequestBody List orderRefundsIdList);
@PostMapping("admin/refund/reapply")
@ApiOperation("再次提交审核")
ResponseDto<Object> refundReapply(@RequestBody List orderRefundsIdList);
@PostMapping("admin/refund/review")
@ApiOperation("一审运营 审核/驳回")
ResponseDto<Object> refundReview(@RequestBody List orderRefundsIdList, @RequestBody Integer status, @RequestBody String reject);
@PostMapping("admin/refund/execute")
@ApiOperation("二审财务 审核(执行退款)/驳回")
ResponseDto<Object> refundExecute(@RequestBody List orderRefundsIdList, @RequestBody Integer status, @RequestBody String refuse);
}
...@@ -24,5 +24,5 @@ public interface FeignKylinTaskClient { ...@@ -24,5 +24,5 @@ public interface FeignKylinTaskClient {
ResponseDto<Boolean> checkOrderTime(); ResponseDto<Boolean> checkOrderTime();
@PostMapping("performance/checkPerformanceTime") @PostMapping("performance/checkPerformanceTime")
void checkPerformanceTime(); ResponseDto<String> checkPerformanceTime();
} }
...@@ -4,10 +4,13 @@ import lombok.extern.slf4j.Slf4j; ...@@ -4,10 +4,13 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner; import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.amqp.RabbitAutoConfiguration;
import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration; import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration;
import org.springframework.boot.autoconfigure.data.redis.RedisRepositoriesAutoConfiguration; import org.springframework.boot.autoconfigure.data.redis.RedisRepositoriesAutoConfiguration;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.cloud.bus.BusAutoConfiguration;
import org.springframework.cloud.openfeign.EnableFeignClients; import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.core.env.Environment; import org.springframework.core.env.Environment;
...@@ -20,6 +23,7 @@ import java.util.Arrays; ...@@ -20,6 +23,7 @@ import java.util.Arrays;
@SpringBootApplication( @SpringBootApplication(
scanBasePackages = {"com.liquidnet"} scanBasePackages = {"com.liquidnet"}
) )
@EnableAutoConfiguration(exclude = {BusAutoConfiguration.class,RabbitAutoConfiguration.class})
public class ServiceExecutorMainApplication implements CommandLineRunner { public class ServiceExecutorMainApplication implements CommandLineRunner {
@Autowired @Autowired
private Environment environment; private Environment environment;
......
package com.liquidnet.service.executor.main.handler;
import com.liquidnet.service.feign.kylin.task.FeignKylinTaskClient;
import com.rabbitmq.client.Return;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.annotation.XxlJob;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* XxlJob开发示例(Bean模式)
* <p>
* 开发步骤:
* 1、在Spring Bean实例中,开发Job方法,方式格式要求为 "public ReturnT<String> execute(String param)"
* 2、为Job方法添加注解 "@XxlJob(value="自定义jobhandler名称", init = "JobHandler初始化方法", destroy = "JobHandler销毁方法")",注解value值对应的是调度中心新建任务的JobHandler属性的值。
* 3、执行日志:需要通过 "XxlJobLogger.log" 打印执行日志;
*/
@Component
public class KylinTaskHandler {
private static final Logger log = LoggerFactory.getLogger(KylinTaskHandler.class);
@Autowired
private FeignKylinTaskClient feignKylinTaskClient;
@XxlJob(value = "sev-kylin:checkOrderTimeHandler")
public ReturnT<String> checkOrderTimeHandler() {
try {
boolean result = feignKylinTaskClient.checkOrderTime().getData();
log.info("checkOrderTimeHandler:结果:"+result);
return ReturnT.SUCCESS;
} catch (Exception e) {
return ReturnT.FAIL;
}
}
@XxlJob(value = "sev-kylin:checkPerformanceTimeHandler")
public ReturnT<String> checkPerformanceTimeHandler() {
try {
String result = feignKylinTaskClient.checkPerformanceTime().getData();
log.info("checkPerformanceTimeHandler:结果:"+result);
return ReturnT.SUCCESS;
} catch (Exception e) {
return ReturnT.FAIL;
}
}
// @Autowired
// private FeignSequenceClient feignSequenceClient;
//
// @XxlJob(value = "sev-sequence:mainDemoJobHandler")
// public ReturnT<String> mainDemoJobHandler(String param) {
// log.info("liquidnet.mainDemoJobHandler");
// Long test = feignSequenceClient.nextId();
// log.info("test : " + test);
// Long[] tests = feignSequenceClient.nextId(2);
// log.info("tests: " + JSON.toJSONString(tests));
// Long nextIncrId = feignSequenceClient.nextIncrId("SEQ_WL_N01_1784");
// log.info("incrid:" + nextIncrId);
// return ReturnT.SUCCESS;
// }
// @XxlJob(value = "sev-recon:accountCheckTask")
// public ReturnT<String> accountCheckTask(String param) {
// XxlJobLogger.log("start:liquidnet.accountCheckTask:[{}]", param);
//
// String bankChannel = null;
// String billDate = null;
// if (!StringUtils.isEmpty(param)) {
// JSONObject jsonParam = JSON.parseObject(param);
// bankChannel = jsonParam.getString("bankChannel");
// billDate = jsonParam.getString("billDate");
// }
// feignTaskReconAccountCheckClient.accountCheck(bankChannel,billDate);
// XxlJobLogger.log("end:liquidnet.accountCheckTask:[{}]", JSON.toJSONString(ResponseDto.success()));
// return ReturnT.SUCCESS;
// }
}
...@@ -83,7 +83,7 @@ public class KylinOrderTicketsController { ...@@ -83,7 +83,7 @@ public class KylinOrderTicketsController {
@GetMapping("checkOrderTime") @PostMapping("checkOrderTime")
@ApiOperation("订单过期脚本") @ApiOperation("订单过期脚本")
@ApiResponse(code = 200, message = "接口返回对象参数") @ApiResponse(code = 200, message = "接口返回对象参数")
public ResponseDto<Boolean> checkOrderTime() { public ResponseDto<Boolean> checkOrderTime() {
......
...@@ -215,7 +215,7 @@ public class KylinPerformancesController { ...@@ -215,7 +215,7 @@ public class KylinPerformancesController {
} }
@PostMapping("/checkPerformanceTime") @PostMapping("/checkPerformanceTime")
public void checkPerformanceTime(){ public ResponseDto<String> checkPerformanceTime(){
kylinPerformancesService.checkPerformanceTime(); return ResponseDto.success(kylinPerformancesService.checkPerformanceTime());
} }
} }
...@@ -787,44 +787,45 @@ public class KylinOrderTicketsServiceImpl extends ServiceImpl<KylinOrderTicketsM ...@@ -787,44 +787,45 @@ public class KylinOrderTicketsServiceImpl extends ServiceImpl<KylinOrderTicketsM
@Override @Override
public boolean checkOrderTime(String userId) { public boolean checkOrderTime(String userId) {
Query query = new Query(); try {
query.addCriteria(Criteria.where("status").is(0).and("overdueAt").lte(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")))); Query query = new Query();
if (null != userId) { query.addCriteria(Criteria.where("status").is(0).and("overdueAt").lte(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))));
query.addCriteria(Criteria.where("userId").is(userId)); if (null != userId) {
} query.addCriteria(Criteria.where("userId").is(userId));
List<KylinOrderTicketVo> orderTicketVo = mongoTemplate.find(query,
KylinOrderTicketVo.class, KylinOrderTicketVo.class.getSimpleName());
for (KylinOrderTicketVo item : orderTicketVo) {
if(!RedisLockUtil.tryLock("order_lock:" + item.getOrderCode(),240,240)){
continue;
} }
RLock lock = redisLockUtil.lock("order_lock:" + item.getOrderCode(), 240); List<KylinOrderTicketVo> orderTicketVo = mongoTemplate.find(query,
KylinOrderTicketVo itemData = dataUtils.getOrderTicketVo(item.getOrderTicketsId()); KylinOrderTicketVo.class, KylinOrderTicketVo.class.getSimpleName());
if (itemData.getStatus() == 0) {
LocalDateTime now = LocalDateTime.now(); for (KylinOrderTicketVo item : orderTicketVo) {
try { if (!RedisLockUtil.tryLock("order_lock:" + item.getOrderCode(), 240, 240)) {
//mysql continue;
KylinOrderTickets orderTickets = new KylinOrderTickets(); }
orderTickets.setOrderTicketsId(item.getOrderTicketsId()); RLock lock = redisLockUtil.lock("order_lock:" + item.getOrderCode(), 240);
orderTickets.setUpdatedAt(now); KylinOrderTicketVo itemData = dataUtils.getOrderTicketVo(item.getOrderTicketsId());
if (itemData.getStatus() == 0) {
KylinOrderTicketStatus orderTicketStatus = new KylinOrderTicketStatus(); LocalDateTime now = LocalDateTime.now();
orderTicketStatus.setOrderId(item.getOrderTicketsId()); try {
orderTicketStatus.setStatus(2); //mysql
orderTicketStatus.setUpdatedAt(now); KylinOrderTickets orderTickets = new KylinOrderTickets();
orderTickets.setOrderTicketsId(item.getOrderTicketsId());
//vo orderTickets.setUpdatedAt(now);
HashMap<String, Object> map = new HashMap<>();
map.put("status", 2); KylinOrderTicketStatus orderTicketStatus = new KylinOrderTicketStatus();
map.put("updatedAt", now.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); orderTicketStatus.setOrderId(item.getOrderTicketsId());
mongoTemplate.getCollection(KylinOrderTicketVo.class.getSimpleName()).updateOne( orderTicketStatus.setStatus(2);
Query.query(Criteria.where("orderTicketsId").is(orderTickets.getOrderTicketsId())).getQueryObject(), orderTicketStatus.setUpdatedAt(now);
new BasicDBObject("$set", mongoConverter.convertToMongoType(map))
); //vo
dataUtils.delOrderTicketRedis(orderTickets.getOrderTicketsId()); HashMap<String, Object> map = new HashMap<>();
map.put("status", 2);
dataUtils.changeSurplusGeneral(itemData.getTicketId(), itemData.getNumber()); map.put("updatedAt", now.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
mongoTemplate.getCollection(KylinOrderTicketVo.class.getSimpleName()).updateOne(
Query.query(Criteria.where("orderTicketsId").is(orderTickets.getOrderTicketsId())).getQueryObject(),
new BasicDBObject("$set", mongoConverter.convertToMongoType(map))
);
dataUtils.delOrderTicketRedis(orderTickets.getOrderTicketsId());
dataUtils.changeSurplusGeneral(itemData.getTicketId(), itemData.getNumber());
// rabbitTemplate.convertAndSend(MQConst.EXCHANGES_LIQUIDNET_SQL, MQConst.ROUTING_KEY_SQL, // rabbitTemplate.convertAndSend(MQConst.EXCHANGES_LIQUIDNET_SQL, MQConst.ROUTING_KEY_SQL,
...@@ -832,16 +833,20 @@ public class KylinOrderTicketsServiceImpl extends ServiceImpl<KylinOrderTicketsM ...@@ -832,16 +833,20 @@ public class KylinOrderTicketsServiceImpl extends ServiceImpl<KylinOrderTicketsM
// rabbitTemplate.convertAndSend(MQConst.EXCHANGES_LIQUIDNET_SQL, MQConst.ROUTING_KEY_SQL, // rabbitTemplate.convertAndSend(MQConst.EXCHANGES_LIQUIDNET_SQL, MQConst.ROUTING_KEY_SQL,
// SqlMapping.get("kylin_order_ticket_status.close", orderTicketStatus.getCloseOrderObject())); // SqlMapping.get("kylin_order_ticket_status.close", orderTicketStatus.getCloseOrderObject()));
} catch (Exception e) { } catch (Exception e) {
lock.unlock();
e.printStackTrace();
return false;
}
} else {
lock.unlock(); lock.unlock();
e.printStackTrace();
return false;
} }
} else {
lock.unlock();
} }
return true;
}catch (Exception e){
e.printStackTrace();
return false;
} }
return true;
} }
@Override @Override
......
...@@ -440,7 +440,13 @@ public class KylinPerformancesServiceImpl extends ServiceImpl<KylinPerformancesM ...@@ -440,7 +440,13 @@ public class KylinPerformancesServiceImpl extends ServiceImpl<KylinPerformancesM
return payDetailVo; return payDetailVo;
} }
public void checkPerformanceTime(){ public String checkPerformanceTime(){
task.performanceVoStatus(null); try {
task.performanceVoStatus(null);
return "成功";
}catch (Exception e){
e.printStackTrace();
return "失败";
}
} }
} }
...@@ -92,7 +92,7 @@ public class PerformanceVoTask { ...@@ -92,7 +92,7 @@ public class PerformanceVoTask {
LocalDateTime timeNow = LocalDateTime.now(); LocalDateTime timeNow = LocalDateTime.now();
List<String> performanceIdList = new ArrayList<>(); List<String> performanceIdList = new ArrayList<>();
if (performanceSingleId.isEmpty()) { if (performanceSingleId==null) {
List<KylinPerformanceVo> kylinPerformanceVoList = mongoTemplate.findAll(KylinPerformanceVo.class); List<KylinPerformanceVo> kylinPerformanceVoList = mongoTemplate.findAll(KylinPerformanceVo.class);
for (KylinPerformanceVo kylinPerformanceVoItem : kylinPerformanceVoList) { for (KylinPerformanceVo kylinPerformanceVoItem : kylinPerformanceVoList) {
performanceIdList.add(kylinPerformanceVoItem.getPerformancesId()); performanceIdList.add(kylinPerformanceVoItem.getPerformancesId());
......
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