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

Commit f7200860 authored by 张国柄's avatar 张国柄

Merge remote-tracking branch 'origin/master' into dev_goblin

parents 1d51ff73 1a58f591
......@@ -26,7 +26,7 @@ liquidnet:
mobile: 13724286255
user-info: false
limit:
enters: 10
enters: 12
enters_opr: 20
#以下为spring各环境个性配置
......@@ -49,7 +49,6 @@ public class DragonServiceCommonBiz {
orders.setOrderCodeId(dragonPayBaseReqDto.getOrderId());
orders.setClientIp(dragonPayBaseReqDto.getClientIp());
orders.setNotifyUrl(dragonPayBaseReqDto.getNotifyUrl());
orders.setNotifyUrl(dragonPayBaseReqDto.getNotifyUrl());
orders.setNotifyStatus(Integer.valueOf(DragonConstant.PayNotifyStatusEnum.NOTIFY_INIT.getCode()));
orders.setPaymentType((dragonPayBaseReqDto.getDeviceFrom()+dragonPayBaseReqDto.getPayType()).toUpperCase());
// orders.setPaymentId();
......
......@@ -90,6 +90,9 @@ public class PayChannelStrategyAlipayImpl extends AbstractPayChannelStrategyImpl
String returnStr = "fail";
String code = notifyMap.get("out_trade_no");
if(StringUtil.isBlank(code)){
throw new LiquidnetServiceException(DragonErrorCodeEnum.TRADE_ERROR_NOT_EXISTS.getCode(),DragonErrorCodeEnum.TRADE_ERROR_NOT_EXISTS.getMessage());
}
//持久化通知记录
dragonServiceCommonBiz.createDragonOrderLogs(code,dragonPayBiz.getPaymentType(payType,deviceFrom),JSON.toJSONString(notifyMap));
......
......@@ -3,15 +3,12 @@ package com.liquidnet.service.dragon.channel.strategy.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.liquidnet.common.exception.LiquidnetServiceException;
import com.liquidnet.commons.lang.util.DateUtil;
import com.liquidnet.commons.lang.util.StringUtil;
import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.dragon.biz.DragonServiceCommonBiz;
import com.liquidnet.service.dragon.channel.douyinpay.strategy.DouYinayStrategyContext;
import com.liquidnet.service.dragon.channel.strategy.annotation.StrategyPayChannelHandler;
import com.liquidnet.service.dragon.channel.strategy.biz.DragonPayBiz;
import com.liquidnet.service.dragon.channel.wepay.constant.WepayConstant;
import com.liquidnet.service.dragon.channel.wepay.strategy.WepayStrategyContext;
import com.liquidnet.service.dragon.constant.DragonConstant;
import com.liquidnet.service.dragon.constant.DragonErrorCodeEnum;
import com.liquidnet.service.dragon.dto.DragonOrdersDto;
......@@ -20,18 +17,12 @@ import com.liquidnet.service.dragon.dto.DragonPayBaseRespDto;
import com.liquidnet.service.dragon.dto.DragonPayOrderQueryRespDto;
import com.liquidnet.service.dragon.utils.DataUtils;
import com.liquidnet.service.dragon.utils.PayDouYinpayUtils;
import com.liquidnet.service.dragon.utils.PayWepayUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.io.InputStream;
import java.time.LocalDateTime;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
/**
......@@ -74,6 +65,9 @@ public class PayChannelStrategyDouYinImpl extends AbstractPayChannelStrategyImpl
JSONObject msg=jsonObject.getJSONObject("msg");
// Map msg= (Map) map.get("msg");
String code =msg.get("cp_orderno").toString();
if(StringUtil.isBlank(code)){
throw new LiquidnetServiceException(DragonErrorCodeEnum.TRADE_ERROR_NOT_EXISTS.getCode(),DragonErrorCodeEnum.TRADE_ERROR_NOT_EXISTS.getMessage());
}
//持久化通知记录
dragonServiceCommonBiz.createDragonOrderLogs(code,dragonPayBiz.getPaymentType(payType,deviceFrom),JSON.toJSONString(jsonObject));
// 根据银行订单号获取支付信息
......
......@@ -2,13 +2,12 @@ package com.liquidnet.service.dragon.channel.strategy.impl;
import com.alibaba.fastjson.JSON;
import com.liquidnet.common.exception.LiquidnetServiceException;
import com.liquidnet.commons.lang.util.StringUtil;
import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.dragon.biz.DragonServiceCommonBiz;
import com.liquidnet.service.dragon.channel.alipay.constant.AlipayConstant;
import com.liquidnet.service.dragon.channel.strategy.annotation.StrategyPayChannelHandler;
import com.liquidnet.service.dragon.channel.strategy.biz.DragonPayBiz;
import com.liquidnet.service.dragon.channel.unionpay.biz.UnionpayBiz;
import com.liquidnet.service.dragon.channel.unionpay.constant.UnionpayConstant;
import com.liquidnet.service.dragon.channel.unionpay.sdk.AcpService;
import com.liquidnet.service.dragon.channel.unionpay.sdk.SDKConstants;
import com.liquidnet.service.dragon.channel.unionpay.strategy.UnionpayStrategyContext;
......@@ -26,7 +25,6 @@ import org.springframework.stereotype.Component;
import javax.servlet.http.HttpServletRequest;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.Map;
/**
......@@ -77,6 +75,9 @@ public class PayChannelStrategyUnionpayImpl extends AbstractPayChannelStrategyIm
log.info("接收到{}支付结果{}", payType, notifyMap);
//商户订单号
String code =notifyMap.get("orderId"); //获取后台通知的数据
if(StringUtil.isBlank(code)){
throw new LiquidnetServiceException(DragonErrorCodeEnum.TRADE_ERROR_NOT_EXISTS.getCode(),DragonErrorCodeEnum.TRADE_ERROR_NOT_EXISTS.getMessage());
}
//持久化通知记录
dragonServiceCommonBiz.createDragonOrderLogs(code,dragonPayBiz.getPaymentType(payType,deviceFrom),JSON.toJSONString(notifyMap));
// 根据银行订单号获取支付信息
......
......@@ -72,7 +72,9 @@ public class PayChannelStrategyWepayImpl extends AbstractPayChannelStrategyImpl
log.info("接收到{}支付结果{}", payType, notifyMap);
String code = notifyMap.get("out_trade_no");
if(StringUtil.isBlank(code)){
throw new LiquidnetServiceException(DragonErrorCodeEnum.TRADE_ERROR_NOT_EXISTS.getCode(),DragonErrorCodeEnum.TRADE_ERROR_NOT_EXISTS.getMessage());
}
//持久化通知记录
dragonServiceCommonBiz.createDragonOrderLogs(code,dragonPayBiz.getPaymentType(payType,deviceFrom),JSON.toJSONString(notifyMap));
......
......@@ -46,6 +46,7 @@ public class DragonServiceCommonBiz {
orders.setName(dragonPayBaseReqDto.getName());
orders.setDetail(dragonPayBaseReqDto.getDetail());
orders.setOrderCode(dragonPayBaseReqDto.getOrderCode());
orders.setOrderCodeId(dragonPayBaseReqDto.getOrderId());
orders.setClientIp(dragonPayBaseReqDto.getClientIp());
orders.setNotifyUrl(dragonPayBaseReqDto.getNotifyUrl());
orders.setNotifyStatus(Integer.valueOf(DragonConstant.PayNotifyStatusEnum.NOTIFY_INIT.getCode()));
......
......@@ -38,7 +38,7 @@ public class DragonPayBiz {
private DragonServiceCommonBiz dragonServiceCommonBiz;
public PayNotifyReqBo buildPayNotifyReqBo(DragonOrdersDto dragonOrdersDto){
public PayNotifyReqBo buildPayNotifyReqBo(DragonOrdersDto dragonOrdersDto) {
PayNotifyReqBo payNotifyReqBo = new PayNotifyReqBo();
payNotifyReqBo.setNotifyUrl(dragonOrdersDto.getNotifyUrl());
PayNotifyDto payNotifyDto = new PayNotifyDto();
......@@ -47,36 +47,38 @@ public class DragonPayBiz {
payNotifyDto.setCode(dragonOrdersDto.getCode());
payNotifyDto.setPaymentId(dragonOrdersDto.getPaymentId());
payNotifyDto.setOrderCode(dragonOrdersDto.getOrderCode());
payNotifyDto.setOrderCodeId(dragonOrdersDto.getOrderCodeId());
payNotifyDto.setPrice(dragonOrdersDto.getPrice());
payNotifyDto.setPaymentType(dragonOrdersDto.getPaymentType());
if(StringUtil.isNotNull(dragonOrdersDto.getPaymentAt())){
if (StringUtil.isNotNull(dragonOrdersDto.getPaymentAt())) {
payNotifyDto.setPaymentAt(DateUtil.Formatter.yyyyMMddHHmmss.format(dragonOrdersDto.getPaymentAt()));
}else{
} else {
payNotifyDto.setPaymentAt("");
}
payNotifyReqBo.setPayNotifyDto(payNotifyDto);
return payNotifyReqBo;
}
public DragonPayOrderQueryRespDto buildPayOrderQueryRespDto(DragonOrdersDto ordersDto){
public DragonPayOrderQueryRespDto buildPayOrderQueryRespDto(DragonOrdersDto ordersDto) {
DragonPayOrderQueryRespDto queryRespDto = new DragonPayOrderQueryRespDto();
queryRespDto.setStatus(ordersDto.getStatus());
queryRespDto.setType(ordersDto.getType());
queryRespDto.setCode(ordersDto.getCode());
queryRespDto.setPaymentId(ordersDto.getPaymentId());
queryRespDto.setOrderCode(ordersDto.getOrderCode());
queryRespDto.setOrderCodeId(ordersDto.getOrderCodeId());
queryRespDto.setPrice(ordersDto.getPrice());
queryRespDto.setPaymentType(ordersDto.getPaymentType());
if(StringUtil.isNotNull(ordersDto.getPaymentAt())){
if (StringUtil.isNotNull(ordersDto.getPaymentAt())) {
queryRespDto.setPaymentAt(DateUtil.Formatter.yyyyMMddHHmmss.format(ordersDto.getPaymentAt()));
}else{
} else {
queryRespDto.setPaymentAt("");
}
return queryRespDto;
}
public boolean sendNotify(PayNotifyReqBo payNotifyReqBo){
public boolean sendNotify(PayNotifyReqBo payNotifyReqBo) {
PayNotifyDto payNotifyDto = payNotifyReqBo.getPayNotifyDto();
LocalDateTime nowTime = LocalDateTime.now();
......@@ -88,25 +90,26 @@ public class DragonPayBiz {
params.add("code", payNotifyDto.getCode());
params.add("paymentId", payNotifyDto.getPaymentId());
params.add("orderCode", payNotifyDto.getOrderCode());
params.add("orderCodeId", payNotifyDto.getOrderCodeId());
params.add("price", payNotifyDto.getPrice().toString());
params.add("paymentType", payNotifyDto.getPaymentType());
params.add("paymentAt", payNotifyDto.getPaymentAt());
jsonData = JsonUtils.toJson(covertNVPS2Params(params));
log.info("dragon:notify:post url:{}",payNotifyReqBo.getNotifyUrl());
log.info("dragon:notify:post data:{}",jsonData);
log.info("dragon:notify:post url:{}", payNotifyReqBo.getNotifyUrl());
log.info("dragon:notify:post data:{}", jsonData);
//执行post请求
String response = HttpUtil.post(payNotifyReqBo.getNotifyUrl(), params);
log.debug("PAY RESPONSE=" + response);
if (response.equalsIgnoreCase("success")) {
dragonServiceCommonBiz.createDragonPayNotify(payNotifyReqBo,jsonData);
dragonServiceCommonBiz.createDragonPayNotify(payNotifyReqBo, jsonData);
//更新通知状态-通知成功
dragonServiceCommonBiz.updateNotifyStatus(payNotifyDto.getCode(),Integer.valueOf(DragonConstant.PayNotifyStatusEnum.NOTIFY_SUCCESS.getCode()));
dragonServiceCommonBiz.updateNotifyStatus(payNotifyDto.getCode(), Integer.valueOf(DragonConstant.PayNotifyStatusEnum.NOTIFY_SUCCESS.getCode()));
return true;
} else {
dragonServiceCommonBiz.createDragonPayNotifyFail(payNotifyReqBo,jsonData);
dragonServiceCommonBiz.createDragonPayNotifyFail(payNotifyReqBo, jsonData);
//更新通知状态-通知失败
dragonServiceCommonBiz.updateNotifyStatus(payNotifyDto.getCode(),Integer.valueOf(DragonConstant.PayNotifyStatusEnum.NOTIFY_FAIL.getCode()));
dragonServiceCommonBiz.updateNotifyStatus(payNotifyDto.getCode(), Integer.valueOf(DragonConstant.PayNotifyStatusEnum.NOTIFY_FAIL.getCode()));
return false;
}
......@@ -119,10 +122,10 @@ public class DragonPayBiz {
// return false;
// }
catch (Exception e) {
log.error("dragon:sendNotify 请求失败",e);
dragonServiceCommonBiz.createDragonPayNotifyFail(payNotifyReqBo,jsonData);
log.error("dragon:sendNotify 请求失败", e);
dragonServiceCommonBiz.createDragonPayNotifyFail(payNotifyReqBo, jsonData);
//更新通知状态-通知失败
dragonServiceCommonBiz.updateNotifyStatus(payNotifyDto.getCode(),Integer.valueOf(DragonConstant.PayNotifyStatusEnum.NOTIFY_FAIL.getCode()));
dragonServiceCommonBiz.updateNotifyStatus(payNotifyDto.getCode(), Integer.valueOf(DragonConstant.PayNotifyStatusEnum.NOTIFY_FAIL.getCode()));
return false;
}
}
......@@ -195,14 +198,14 @@ public class DragonPayBiz {
// }
// }
public String getPaymentType(String payType,String deviceFrom){
return (deviceFrom+payType).toUpperCase();
public String getPaymentType(String payType, String deviceFrom) {
return (deviceFrom + payType).toUpperCase();
}
private static Map<String, Object> covertNVPS2Params(List<NameValuePair> nvpList) {
Map<String, Object> rsMap = ObjectUtil.cloneHashMapStringAndObj();
for (NameValuePair nameValuePair : nvpList) {
rsMap.put(nameValuePair.getName(),nameValuePair.getValue());
rsMap.put(nameValuePair.getName(), nameValuePair.getValue());
}
return rsMap;
}
......
......@@ -90,6 +90,9 @@ public class PayChannelStrategyAlipayImpl extends AbstractPayChannelStrategyImpl
String returnStr = "fail";
String code = notifyMap.get("out_trade_no");
if(StringUtil.isBlank(code)){
throw new LiquidnetServiceException(DragonErrorCodeEnum.TRADE_ERROR_NOT_EXISTS.getCode(),DragonErrorCodeEnum.TRADE_ERROR_NOT_EXISTS.getMessage());
}
//持久化通知记录
dragonServiceCommonBiz.createDragonOrderLogs(code,dragonPayBiz.getPaymentType(payType,deviceFrom),JSON.toJSONString(notifyMap));
......
......@@ -3,6 +3,7 @@ package com.liquidnet.service.dragon.channel.strategy.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.liquidnet.common.exception.LiquidnetServiceException;
import com.liquidnet.commons.lang.util.StringUtil;
import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.dragon.biz.DragonServiceCommonBiz;
import com.liquidnet.service.dragon.channel.douyinpay.strategy.DouYinayStrategyContext;
......@@ -64,6 +65,9 @@ public class PayChannelStrategyDouYinImpl extends AbstractPayChannelStrategyImpl
JSONObject msg=jsonObject.getJSONObject("msg");
// Map msg= (Map) map.get("msg");
String code =msg.get("cp_orderno").toString();
if(StringUtil.isBlank(code)){
throw new LiquidnetServiceException(DragonErrorCodeEnum.TRADE_ERROR_NOT_EXISTS.getCode(),DragonErrorCodeEnum.TRADE_ERROR_NOT_EXISTS.getMessage());
}
//持久化通知记录
dragonServiceCommonBiz.createDragonOrderLogs(code,dragonPayBiz.getPaymentType(payType,deviceFrom),JSON.toJSONString(jsonObject));
// 根据银行订单号获取支付信息
......
......@@ -2,6 +2,7 @@ package com.liquidnet.service.dragon.channel.strategy.impl;
import com.alibaba.fastjson.JSON;
import com.liquidnet.common.exception.LiquidnetServiceException;
import com.liquidnet.commons.lang.util.StringUtil;
import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.dragon.biz.DragonServiceCommonBiz;
import com.liquidnet.service.dragon.channel.strategy.annotation.StrategyPayChannelHandler;
......@@ -74,6 +75,9 @@ public class PayChannelStrategyUnionpayImpl extends AbstractPayChannelStrategyIm
log.info("接收到{}支付结果{}", payType, notifyMap);
//商户订单号
String code =notifyMap.get("orderId"); //获取后台通知的数据
if(StringUtil.isBlank(code)){
throw new LiquidnetServiceException(DragonErrorCodeEnum.TRADE_ERROR_NOT_EXISTS.getCode(),DragonErrorCodeEnum.TRADE_ERROR_NOT_EXISTS.getMessage());
}
//持久化通知记录
dragonServiceCommonBiz.createDragonOrderLogs(code,dragonPayBiz.getPaymentType(payType,deviceFrom),JSON.toJSONString(notifyMap));
// 根据银行订单号获取支付信息
......
......@@ -72,7 +72,9 @@ public class PayChannelStrategyWepayImpl extends AbstractPayChannelStrategyImpl
log.info("接收到{}支付结果{}", payType, notifyMap);
String code = notifyMap.get("out_trade_no");
if(StringUtil.isBlank(code)){
throw new LiquidnetServiceException(DragonErrorCodeEnum.TRADE_ERROR_NOT_EXISTS.getCode(),DragonErrorCodeEnum.TRADE_ERROR_NOT_EXISTS.getMessage());
}
//持久化通知记录
dragonServiceCommonBiz.createDragonOrderLogs(code,dragonPayBiz.getPaymentType(payType,deviceFrom),JSON.toJSONString(notifyMap));
......
......@@ -42,6 +42,7 @@ public class PayController {
*/
/**
* 电脑网页支付宝支付
*
* @return
*//*
......@@ -55,6 +56,7 @@ public class PayController {
@ApiImplicitParam(type = "form", required = true, dataType = "String", name = "price", value = "支付金额", example = "0.1"),
@ApiImplicitParam(type = "form", required = true, dataType = "String", name = "name", value = "订单名称", example = "测试订单001"),
@ApiImplicitParam(type = "form", required = true, dataType = "String", name = "detail", value = "订单描述", example = "测试订单001"),
@ApiImplicitParam(type = "form", required = true, dataType = "String", name = "orderId", value = "订单id", example = "orderId"),
@ApiImplicitParam(type = "form", required = true, dataType = "String", name = "orderCode", value = "订单编号", example = "ORDER0001"),
@ApiImplicitParam(type = "form", required = true, dataType = "String", name = "clientIp", value = "客户端ip", example = "127.0.0.1"),
@ApiImplicitParam(type = "form", required = true, dataType = "String", name = "notifyUrl", value = "通知url", example = "devdragon.zhengzai.tv"),
......@@ -65,24 +67,25 @@ public class PayController {
public ResponseDto<DragonPayBaseRespDto> dragonPay(
@RequestParam(value = "payType") @NotNull(message = "支付类型不能为空") String payType,
@RequestParam(value = "deviceFrom") @NotNull(message = "设备来源不能为空") String deviceFrom,
@RequestParam(value = "openId",required = false) String openId,
@RequestParam(value = "openId", required = false) String openId,
@RequestParam(value = "type") @NotNull(message = "业务类型不能为空") String type,
@RequestParam(value = "price") @NotNull(message = "支付金额不能为空") BigDecimal price,
@RequestParam(value = "name") @NotNull(message = "订单名称不能为空") String name,
@RequestParam(value = "detail") @NotNull(message = "订单描述不能为空") String detail,
@RequestParam(value = "orderCode") @NotNull(message = "订单编号不能为空") String orderCode,
@RequestParam(value = "clientIp") @NotNull(message = "客户端ip不能为空") String clientIp,
@RequestParam(value = "notifyUrl") @NotNull(message = "通知Url不能为空") String notifyUrl,
@RequestParam(value = "returnUrl",required = false) String returnUrl,
@RequestParam(value = "price") @NotNull(message = "支付金额不能为空") BigDecimal price,
@RequestParam(value = "name") @NotNull(message = "订单名称不能为空") String name,
@RequestParam(value = "detail") @NotNull(message = "订单描述不能为空") String detail,
@RequestParam(value = "orderCode") @NotNull(message = "订单编号不能为空") String orderCode,
@RequestParam(value = "orderId", required = false) String orderId,
@RequestParam(value = "clientIp") @NotNull(message = "客户端ip不能为空") String clientIp,
@RequestParam(value = "notifyUrl") @NotNull(message = "通知Url不能为空") String notifyUrl,
@RequestParam(value = "returnUrl", required = false) String returnUrl,
// @RequestParam(value = "quitUrl",required = false) String quitUrl,
@RequestParam(value = "showUrl",required = false) String showUrl,
@RequestParam(value = "showUrl", required = false) String showUrl,
// @RequestParam(value = "code",required = false) String code,
@RequestParam(value = "createDate",required = true) String createDate,
@RequestParam(value = "expireTime",required = true) String expireTime){
@RequestParam(value = "createDate", required = true) String createDate,
@RequestParam(value = "expireTime", required = true) String expireTime) {
long startTime = System.currentTimeMillis();
//为什么在js和applet中才需要判断open_id?
if(payType.equalsIgnoreCase(DragonConstant.PayChannelEnum.WEPAY.getCode())){
if(deviceFrom.equalsIgnoreCase(DragonConstant.DeviceFromEnum.JS.getCode())||deviceFrom.equalsIgnoreCase(DragonConstant.DeviceFromEnum.APPLET.getCode())) {
if (payType.equalsIgnoreCase(DragonConstant.PayChannelEnum.WEPAY.getCode())) {
if (deviceFrom.equalsIgnoreCase(DragonConstant.DeviceFromEnum.JS.getCode()) || deviceFrom.equalsIgnoreCase(DragonConstant.DeviceFromEnum.APPLET.getCode())) {
if (StringUtil.isEmpty(openId)) {
return ResponseDto.failure("微信支付openId不能为空!");
}
......@@ -103,6 +106,9 @@ public class PayController {
// }
dragonPayBaseReqDto.setDetail("正在现场");
dragonPayBaseReqDto.setOrderCode(orderCode);
if(orderId!=null) {
dragonPayBaseReqDto.setOrderId(orderId);
}
dragonPayBaseReqDto.setClientIp(clientIp);
dragonPayBaseReqDto.setNotifyUrl(notifyUrl);
dragonPayBaseReqDto.setReturnUrl(returnUrl);
......@@ -112,7 +118,7 @@ public class PayController {
dragonPayBaseReqDto.setCreateDate(createDate);
dragonPayBaseReqDto.setExpireTime(expireTime);
ResponseDto<DragonPayBaseRespDto> responseDto = dragonOrdersService.dragonPay(dragonPayBaseReqDto);
log.info("PayController->dragonPay->总耗时:{}",(System.currentTimeMillis() - startTime)+"毫秒");
log.info("PayController->dragonPay->总耗时:{}", (System.currentTimeMillis() - startTime) + "毫秒");
return responseDto;
}
......@@ -123,7 +129,7 @@ public class PayController {
@ApiImplicitParam(type = "form", required = true, dataType = "String", name = "code", value = "", example = "PAY202107131522368438531155")
})
@ResponseBody
public ResponseDto<DragonPayOrderQueryRespDto> checkOrder(@RequestParam(value = "code") @NotNull(message = "支付编号不能为空!") String code){
public ResponseDto<DragonPayOrderQueryRespDto> checkOrder(@RequestParam(value = "code") @NotNull(message = "支付编号不能为空!") String code) {
DragonPayOrderQueryRespDto respDto = dragonOrdersService.checkOrderStatusByCode(code);
return ResponseDto.success(respDto);
}
......@@ -135,7 +141,7 @@ public class PayController {
@ApiImplicitParam(type = "form", required = true, dataType = "String", name = "code", value = "", example = "PAY202107131522368438531155")
})
@ResponseBody
public ResponseDto<DragonPayOrderQueryRespDto> thirdCheckOrder(@RequestParam(value = "code") @NotNull(message = "支付编号不能为空!") String code){
public ResponseDto<DragonPayOrderQueryRespDto> thirdCheckOrder(@RequestParam(value = "code") @NotNull(message = "支付编号不能为空!") String code) {
DragonPayOrderQueryRespDto respDto = dragonOrdersService.checkOrderStatusByCode(code);
return ResponseDto.success(respDto);
}
......@@ -147,11 +153,11 @@ public class PayController {
@ApiImplicitParam(type = "form", required = true, dataType = "String", name = "code", value = "", example = "PAY202107131522368438531155")
})
@ResponseBody
public ResponseDto<Map<String,String>> manulNotify(@RequestParam(value = "code") @NotNull(message = "支付编号不能为空!") String code){
public ResponseDto<Map<String, String>> manulNotify(@RequestParam(value = "code") @NotNull(message = "支付编号不能为空!") String code) {
boolean respDto = dragonOrdersService.manulNotify(code);
Map<String,String> rs = new HashMap<>();
rs.put("code",code);
rs.put("result",""+respDto);
Map<String, String> rs = new HashMap<>();
rs.put("code", code);
rs.put("result", "" + respDto);
return ResponseDto.success(rs);
}
}
......
......@@ -639,7 +639,7 @@ public class DragonOrderRefundsServiceImpl implements IDragonOrderRefundsService
// 没有订单号 从redids里面查
dto.setRefundCode(dataUtils.getOrderCode(msg.getString("cp_refundno")));
dto.setRefundPrice(msg.getBigDecimal("refund_amount").divide(BigDecimal.valueOf(100)).toString());
// SimpleDateFormat sdf = new SimpleDateFormat( " yyyy年MM月dd日 " );
// SimpleDateFormat sdf = new SimpleDateFormat( " yyyy年MM月dd日 " );
// 抖音没有传回时间
dto.setRefundAt(DateUtil.Formatter.yyyyMMddHHmmss.format(LocalDateTime.now()));
//抖音回调没有写错误原因
......
......@@ -11,7 +11,7 @@ public class DataUtils {
@Autowired
private RedisUtil redisUtil;
private long keyExpireTime = 3600*24*7;
private long keyExpireTime = 3600*24*30;
public void createPayOrder(String code, DragonOrdersDto ordersDto) {
redisUtil.set(DragonConstant.REDIS_KET_PAY_CODE + code, ordersDto,keyExpireTime);
......
......@@ -213,7 +213,7 @@ public class KylinTicketTimesPartnerServiceImpl implements IKylinTicketTimesPart
ticketPartnerVo.setTimesId(createTicketTimesParam.getTicketTimesId());
ticketPartnerVo.setUseEnd(kylinTicketTimesPartnerVo.getUseEnd());
ticketPartnerVo.setUseStart(kylinTicketTimesPartnerVo.getUseStart());
mongoSlimeUtils.updateTicketPartnerVo(ticketPartnerVo);
mongoSlimeUtils.updateTicketPartnerVoByTimes(ticketPartnerVo);
log.info(UserPathDto.setPartnerData("0", "changeTimes", createTicketTimesParam, "SUCCESS"));
//JsonUtils.fromJson(doc.toJson(), KylinTicketTimesPartnerVo.class)
return ResponseDto.success(null);
......
......@@ -116,6 +116,15 @@ public class MongoSlimeUtils {
);
}
public void updateTicketPartnerVoByTimes(KylinTicketPartnerVo data) {
Query query = Query.query(Criteria.where("timesId").is(data.getTimesId()));
BasicDBObject objectTicketVo = ObjectUtil.cloneBasicDBObject().append("$set", mongoConverter.convertToMongoType(data));
mongoTemplate.getCollection(KylinTicketPartnerVo.class.getSimpleName()).updateMany(
query.getQueryObject(),
objectTicketVo
);
}
public void submitTicketByTimes(KylinTicketPartnerVo data) {
Query query = Query.query(Criteria.where("timesId").is(data.getTimesId()).and("status").nin(-2, 7));
BasicDBObject objectTicketVo = ObjectUtil.cloneBasicDBObject().append("$set", mongoConverter.convertToMongoType(data));
......
package com.liquidnet.service.sweet.service.impl;
import cn.binarywang.wx.miniapp.api.WxMaService;
import cn.binarywang.wx.miniapp.bean.WxMaSubscribeMessage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.liquidnet.commons.lang.util.CollectionUtil;
import com.liquidnet.service.sweet.config.WechatMaConfigure;
import com.liquidnet.service.sweet.entity.SweetAppletSubMsg;
import com.liquidnet.service.sweet.mapper.SweetAppletSubMsgMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
/**
* <p>
* 小程序订阅消息记录表 服务实现类
* </p>
*
* @author jiangxiulong
* @since 2021-11-22
*/
@Service
@Slf4j
public class SweetAppletSubMsgSendServiceImpl {
@Autowired
private SweetAppletSubMsgMapper subMsgMapper;
@Autowired
WechatMaConfigure wechatMaConfigure;
@Async
public void toSend(List<SweetAppletSubMsg> msgList, String targetId, String title, String timeStart) {
ArrayList<String> msgIdList = CollectionUtil.arrayListString();
if (!CollectionUtils.isEmpty(msgList)) {
for (SweetAppletSubMsg info : msgList) {
try {
String msgId = info.getMsgId();
// 发送订阅消息接口
boolean subMessage = sendSubMessage(info, targetId, title, timeStart);
if (subMessage) {
msgIdList.add(msgId);
}
} catch (Exception e) {
// log.error("小程序演出订阅提醒消息处理异常", e);
}
}
if (!CollectionUtils.isEmpty(msgIdList)) {
SweetAppletSubMsg update = new SweetAppletSubMsg();
update.setIsPush(2);
update.setUpdatedAt(LocalDateTime.now());
subMsgMapper.update(
update,
Wrappers.lambdaUpdate(SweetAppletSubMsg.class)
.in(SweetAppletSubMsg::getMsgId, msgIdList)
);
}
}
}
/**
* 微信小程序推送订阅消息
*/
private boolean sendSubMessage(SweetAppletSubMsg info, String performancesId, String title, String timeStart) {
WxMaSubscribeMessage subscribeMessage = new WxMaSubscribeMessage();
subscribeMessage.setPage("pages/webview?query=showdetails&id=".concat(performancesId));
subscribeMessage.setTemplateId(info.getTemplateId());
subscribeMessage.setToUser(info.getOpenId());
ArrayList<WxMaSubscribeMessage.MsgData> wxMaSubscribeData = new ArrayList<>();
WxMaSubscribeMessage.MsgData wxMaSubscribeData1 = new WxMaSubscribeMessage.MsgData();
wxMaSubscribeData1.setName("thing1");
wxMaSubscribeData1.setValue(title);
//每个参数 存放到大集合中
wxMaSubscribeData.add(wxMaSubscribeData1);
// 第二个内容:用户昵称
WxMaSubscribeMessage.MsgData wxMaSubscribeData2 = new WxMaSubscribeMessage.MsgData();
wxMaSubscribeData2.setName("time2");
wxMaSubscribeData2.setValue(timeStart);
wxMaSubscribeData.add(wxMaSubscribeData2);
// 第三个内容:领取方式
WxMaSubscribeMessage.MsgData wxMaSubscribeData3 = new WxMaSubscribeMessage.MsgData();
wxMaSubscribeData3.setName("thing3");
wxMaSubscribeData3.setValue("您关注的演出活动门票即将开售,请准备购票");
wxMaSubscribeData.add(wxMaSubscribeData3);
subscribeMessage.setData(wxMaSubscribeData);
try {
//获取微信小程序配置:
WxMaService wxService = wechatMaConfigure.getWxMaService(info.getAppletType());
//进行推送
wxService.getMsgService().sendSubscribeMsg(subscribeMessage);
return true;
} catch (Exception e) {
// log.error("sendSubMessageException e{}", e);
}
return false;
}
}
package com.liquidnet.service.sweet.service.impl;
import cn.binarywang.wx.miniapp.api.WxMaService;
import cn.binarywang.wx.miniapp.bean.WxMaSubscribeMessage;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.liquidnet.commons.lang.util.CollectionUtil;
......@@ -19,17 +18,14 @@ import com.liquidnet.service.sweet.entity.SweetAppletSubMsg;
import com.liquidnet.service.sweet.mapper.SweetAppletSubMsgMapper;
import com.liquidnet.service.sweet.service.ISweetAppletSubMsgService;
import com.liquidnet.service.sweet.utils.QueueUtils;
import com.liquidnet.service.sweet.utils.RedisActivityUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
......@@ -58,12 +54,32 @@ public class SweetAppletSubMsgServiceImpl extends ServiceImpl<SweetAppletSubMsgM
private QueueUtils queueUtils;
@Autowired
private RedisActivityUtils redisActivityUtils;
private SweetAppletSubMsgSendServiceImpl sweetAppletSubMsgSendService;
private static final int pageSize = 2000;
@Override
public ResponseDto<Boolean> create(String openId, String unionId, String templateId, String targetId, Integer appletType, Integer activityType) {
String[] templateIdArray = templateId.split(",");
String uid = StringUtils.defaultString(CurrentUtil.getCurrentUid(), "");
LinkedList<String> sqls = CollectionUtil.linkedListString();
LinkedList<Object[]> sqlsDataA = CollectionUtil.linkedListObjectArr();
sqls.add(SqlMapping.get("sweet_applet_sub_msg.insert"));
for (String id : templateIdArray) {
sqlsDataA.add(new Object[]{
IDGenerator.nextSnowId(), openId, unionId, uid, id, targetId, appletType, activityType
});
}
queueUtils.sendMsgByRedis(MQConst.SweetQueue.SWEET_REMIND_INSERT.getKey(),
SqlMapping.gets(sqls, sqlsDataA));
return ResponseDto.success();
}
public ResponseDto sendMsg(Integer type) {
List<SweetAppletSubMsgOfTypeDto> targetIds = subMsgMapper.selectListOfType(type);
for (SweetAppletSubMsgOfTypeDto targetIdInfo : targetIds) {
String targetId = targetIdInfo.getTargetId();
ResponseDto<KylinPerformanceVo> kylinPerformanceVo = feignKylinPerformancesClient.detail(targetId, 0, 0, "");
......@@ -77,40 +93,25 @@ public class SweetAppletSubMsgServiceImpl extends ServiceImpl<SweetAppletSubMsgM
log.info("当前演出还不能推送:[状态={}]", isPush);
continue;
}
List<SweetAppletSubMsg> msgList = subMsgMapper.selectList(
Wrappers.lambdaQuery(SweetAppletSubMsg.class)
.eq(SweetAppletSubMsg::getIsPush, 1)
.eq(SweetAppletSubMsg::getActivityType, type)
.eq(SweetAppletSubMsg::getTargetId, targetId)
);
String title = performanceVoData.getTitle();
String timeStart = performanceVoData.getTimeStart();
ArrayList<String> msgIdList = CollectionUtil.arrayListString();
if (!CollectionUtils.isEmpty(msgList)) {
for (SweetAppletSubMsg info : msgList) {
try {
String msgId = info.getMsgId();
// 发送订阅消息接口
boolean subMessage = sendSubMessage(info, targetId, title, timeStart);
if (subMessage) {
msgIdList.add(msgId);
}
} catch (Exception e) {
log.error("小程序演出订阅提醒消息处理异常", e);
}
}
if (!CollectionUtils.isEmpty(msgIdList)) {
SweetAppletSubMsg update = new SweetAppletSubMsg();
update.setIsPush(2);
update.setUpdatedAt(LocalDateTime.now());
subMsgMapper.update(
update,
Wrappers.lambdaUpdate(SweetAppletSubMsg.class)
.in(SweetAppletSubMsg::getMsgId, msgIdList)
);
}
LambdaQueryWrapper<SweetAppletSubMsg> queryWrapper = Wrappers.lambdaQuery(SweetAppletSubMsg.class)
.eq(SweetAppletSubMsg::getIsPush, 1)
.eq(SweetAppletSubMsg::getActivityType, type)
.eq(SweetAppletSubMsg::getTargetId, targetId);
Integer count = subMsgMapper.selectCount(queryWrapper);
int countPage = (int) Math.ceil(count / pageSize);
countPage = countPage + 1;
for (int page = 0; page < countPage; page++) {
List<SweetAppletSubMsg> msgList = subMsgMapper.selectList(
queryWrapper.last("LIMIT "
.concat(String.valueOf(page * pageSize))
.concat(",".concat(String.valueOf(pageSize)))
)
);
sweetAppletSubMsgSendService.toSend(msgList, targetId, title, timeStart);
}
}
return ResponseDto.success();
......@@ -118,179 +119,78 @@ public class SweetAppletSubMsgServiceImpl extends ServiceImpl<SweetAppletSubMsgM
@Override
public ResponseDto sendOfActivityType(Integer activityType, String targetId, Integer timeType) {
List<SweetAppletSubMsg> msgList = subMsgMapper.selectList(
Wrappers.lambdaQuery(SweetAppletSubMsg.class)
.eq(SweetAppletSubMsg::getIsPush, 1)
.eq(SweetAppletSubMsg::getActivityType, activityType)
.eq(SweetAppletSubMsg::getTargetId, targetId)
);
KylinPerformanceVo performanceVoData = null;
if (!targetId.isEmpty()) {
ResponseDto<KylinPerformanceVo> kylinPerformanceVo = feignKylinPerformancesClient.detail(targetId, 0, 0, "");
performanceVoData = kylinPerformanceVo.getData();
if (null == performanceVoData || ObjectUtils.isEmpty(performanceVoData)) {
log.info("无演出数据:[performancesId={}]", targetId);
return ResponseDto.failure("无演出数据");
}
if (timeType == 1) {
Integer isPush = isPush(performanceVoData, targetId);
if (isPush != 3) {
return ResponseDto.failure("当前演出还不能推送,状态".concat(String.valueOf(isPush)));
}
ResponseDto<KylinPerformanceVo> kylinPerformanceVo = feignKylinPerformancesClient.detail(targetId, 0, 0, "");
KylinPerformanceVo performanceVoData = kylinPerformanceVo.getData();
if (null == performanceVoData || ObjectUtils.isEmpty(performanceVoData)) {
log.info("无演出数据:[performancesId={}]", targetId);
return ResponseDto.failure("无演出数据");
}
if (timeType == 1) {
Integer isPush = isPush(performanceVoData, targetId);
if (isPush != 3) {
return ResponseDto.failure("当前演出还不能推送,状态".concat(String.valueOf(isPush)));
}
}
String title = performanceVoData.getTitle();
String timeStart = performanceVoData.getTimeStart();
ArrayList<String> msgIdList = CollectionUtil.arrayListString();
if (!CollectionUtils.isEmpty(msgList)) {
for (SweetAppletSubMsg info : msgList) {
try {
String msgId = info.getMsgId();
// 发送订阅消息接口
boolean subMessage = sendSubMessage(info, targetId, title, timeStart);
if (subMessage) {
msgIdList.add(msgId);
}
} catch (Exception e) {
log.error("小程序演出订阅提醒消息处理异常", e);
}
}
if (!CollectionUtils.isEmpty(msgIdList)) {
SweetAppletSubMsg update = new SweetAppletSubMsg();
update.setIsPush(2);
update.setTargetId(targetId);
update.setUpdatedAt(LocalDateTime.now());
subMsgMapper.update(
update,
Wrappers.lambdaUpdate(SweetAppletSubMsg.class)
.in(SweetAppletSubMsg::getMsgId, msgIdList)
);
}
LambdaQueryWrapper<SweetAppletSubMsg> queryWrapper = Wrappers.lambdaQuery(SweetAppletSubMsg.class)
.eq(SweetAppletSubMsg::getIsPush, 1)
.eq(SweetAppletSubMsg::getActivityType, activityType)
.eq(SweetAppletSubMsg::getTargetId, targetId);
Integer count = subMsgMapper.selectCount(queryWrapper);
int countPage = (int) Math.ceil(count / pageSize);
countPage = countPage + 1;
for (int page = 0; page < countPage; page++) {
List<SweetAppletSubMsg> msgList = subMsgMapper.selectList(
queryWrapper.last("LIMIT "
.concat(String.valueOf(page * pageSize))
.concat(",".concat(String.valueOf(pageSize)))
)
);
sweetAppletSubMsgSendService.toSend(msgList, targetId, title, timeStart);
}
return ResponseDto.success();
}
@Override
public ResponseDto sendOfMid(String midList, String targetId, Integer timeType) {
String[] midListArray = midList.split(",");
List<SweetAppletSubMsg> msgList = subMsgMapper.selectList(
Wrappers.lambdaQuery(SweetAppletSubMsg.class)
.eq(SweetAppletSubMsg::getIsPush, 1)
.in(SweetAppletSubMsg::getMid, midListArray)
);
KylinPerformanceVo performanceVoData = null;
if (!targetId.isEmpty()) {
ResponseDto<KylinPerformanceVo> kylinPerformanceVo = feignKylinPerformancesClient.detail(targetId, 0, 0, "");
performanceVoData = kylinPerformanceVo.getData();
if (null == performanceVoData || ObjectUtils.isEmpty(performanceVoData)) {
log.info("无演出数据:[performancesId={}]", targetId);
return ResponseDto.failure("无演出数据");
}
if (timeType == 1) {
Integer isPush = isPush(performanceVoData, targetId);
if (isPush != 3) {
return ResponseDto.failure("当前演出还不能推送,状态".concat(String.valueOf(isPush)));
}
ResponseDto<KylinPerformanceVo> kylinPerformanceVo = feignKylinPerformancesClient.detail(targetId, 0, 0, "");
KylinPerformanceVo performanceVoData = kylinPerformanceVo.getData();
if (null == performanceVoData || ObjectUtils.isEmpty(performanceVoData)) {
log.info("无演出数据:[performancesId={}]", targetId);
return ResponseDto.failure("无演出数据");
}
if (timeType == 1) {
Integer isPush = isPush(performanceVoData, targetId);
if (isPush != 3) {
return ResponseDto.failure("当前演出还不能推送,状态".concat(String.valueOf(isPush)));
}
}
String title = performanceVoData.getTitle();
String timeStart = performanceVoData.getTimeStart();
ArrayList<String> msgIdList = CollectionUtil.arrayListString();
if (!CollectionUtils.isEmpty(msgList)) {
for (SweetAppletSubMsg info : msgList) {
try {
String msgId = info.getMsgId();
// 发送订阅消息接口
boolean subMessage = sendSubMessage(info, targetId, title, timeStart);
if (subMessage) {
msgIdList.add(msgId);
}
} catch (Exception e) {
log.error("小程序演出订阅提醒消息处理异常", e);
}
}
if (!CollectionUtils.isEmpty(msgIdList)) {
SweetAppletSubMsg update = new SweetAppletSubMsg();
update.setIsPush(2);
update.setTargetId(targetId);
update.setUpdatedAt(LocalDateTime.now());
subMsgMapper.update(
update,
Wrappers.lambdaUpdate(SweetAppletSubMsg.class)
.in(SweetAppletSubMsg::getMsgId, msgIdList)
);
}
}
return ResponseDto.success();
}
@Override
public ResponseDto<Boolean> create(String openId, String unionId, String templateId, String targetId, Integer appletType, Integer activityType) {
String[] templateIdArray = templateId.split(",");
String uid = StringUtils.defaultString(CurrentUtil.getCurrentUid(), "");
LinkedList<String> sqls = CollectionUtil.linkedListString();
LinkedList<Object[]> sqlsDataA = CollectionUtil.linkedListObjectArr();
sqls.add(SqlMapping.get("sweet_applet_sub_msg.insert"));
for (String id : templateIdArray) {
sqlsDataA.add(new Object[]{
IDGenerator.nextSnowId(), openId, unionId, uid, id, targetId, appletType, activityType
});
String[] midListArray = midList.split(",");
LambdaQueryWrapper<SweetAppletSubMsg> queryWrapper = Wrappers.lambdaQuery(SweetAppletSubMsg.class)
.eq(SweetAppletSubMsg::getIsPush, 1)
.in(SweetAppletSubMsg::getMid, midListArray);
Integer count = subMsgMapper.selectCount(queryWrapper);
int countPage = (int) Math.ceil(count / pageSize);
countPage = countPage + 1;
for (int page = 0; page < countPage; page++) {
List<SweetAppletSubMsg> msgList = subMsgMapper.selectList(
queryWrapper.last("LIMIT "
.concat(String.valueOf(page * pageSize))
.concat(",".concat(String.valueOf(pageSize)))
)
);
sweetAppletSubMsgSendService.toSend(msgList, targetId, title, timeStart);
}
queueUtils.sendMsgByRedis(MQConst.SweetQueue.SWEET_REMIND_INSERT.getKey(),
SqlMapping.gets(sqls, sqlsDataA));
return ResponseDto.success();
}
/**
* 微信小程序推送订阅消息
*/
private boolean sendSubMessage(SweetAppletSubMsg info, String performancesId, String title, String timeStart) {
WxMaSubscribeMessage subscribeMessage = new WxMaSubscribeMessage();
subscribeMessage.setPage("pages/webview?query=showdetails&id=".concat(performancesId));
subscribeMessage.setTemplateId(info.getTemplateId());
subscribeMessage.setToUser(info.getOpenId());
ArrayList<WxMaSubscribeMessage.MsgData> wxMaSubscribeData = new ArrayList<>();
WxMaSubscribeMessage.MsgData wxMaSubscribeData1 = new WxMaSubscribeMessage.MsgData();
wxMaSubscribeData1.setName("thing1");
wxMaSubscribeData1.setValue(title);
//每个参数 存放到大集合中
wxMaSubscribeData.add(wxMaSubscribeData1);
// 第二个内容:用户昵称
WxMaSubscribeMessage.MsgData wxMaSubscribeData2 = new WxMaSubscribeMessage.MsgData();
wxMaSubscribeData2.setName("time2");
wxMaSubscribeData2.setValue(timeStart);
wxMaSubscribeData.add(wxMaSubscribeData2);
// 第三个内容:领取方式
WxMaSubscribeMessage.MsgData wxMaSubscribeData3 = new WxMaSubscribeMessage.MsgData();
wxMaSubscribeData3.setName("thing3");
wxMaSubscribeData3.setValue("您关注的演出活动门票即将开售,请准备购票");
wxMaSubscribeData.add(wxMaSubscribeData3);
subscribeMessage.setData(wxMaSubscribeData);
try {
//获取微信小程序配置:
WxMaService wxService = wechatMaConfigure.getWxMaService(info.getAppletType());
//进行推送
wxService.getMsgService().sendSubscribeMsg(subscribeMessage);
return true;
} catch (Exception e) {
log.error("sendSubMessageException e{}", e);
}
return false;
}
/**
* 判断演出时间 是否可以推送
*/
......@@ -313,4 +213,5 @@ public class SweetAppletSubMsgServiceImpl extends ServiceImpl<SweetAppletSubMsgM
}
return 3;
}
}
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