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

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

dragon 平台 保存订单id

parent 1d11497e
ALTER TABLE dragon_orders ADD order_code_id varchar(255) DEFAULT "" COMMENT '正在现场订单id';
\ No newline at end of file
......@@ -26,6 +26,7 @@ public class DragonPayBaseReqDto implements Serializable, Cloneable{
private String name;
private String detail;
private String orderCode;
private String orderId;
private String clientIp;
private String notifyUrl;
private String code;
......
......@@ -22,6 +22,7 @@ public class DragonPayOrderQueryRespDto implements Serializable {
private String code;
private String paymentId;
private String orderCode;
private String orderCodeId;
private BigDecimal price;
private String paymentType;
private String paymentAt;
......
......@@ -13,6 +13,7 @@ public class PayNotifyDto implements Serializable {
private String code;
private String paymentId;
private String orderCode;
private String orderCodeId;
private BigDecimal price;
private String paymentType;
private String paymentAt;
......
......@@ -64,6 +64,11 @@ public class DragonOrdersDto implements Serializable, Cloneable {
*/
private String orderCode;
/**
* order_code_id
*/
private String orderCodeId;
/**
* client_ip
*/
......
......@@ -46,8 +46,10 @@ 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.setNotifyUrl(dragonPayBaseReqDto.getNotifyUrl());
orders.setNotifyStatus(Integer.valueOf(DragonConstant.PayNotifyStatusEnum.NOTIFY_INIT.getCode()));
orders.setPaymentType((dragonPayBaseReqDto.getDeviceFrom()+dragonPayBaseReqDto.getPayType()).toUpperCase());
// orders.setPaymentId();
......@@ -65,7 +67,7 @@ public class DragonServiceCommonBiz {
startTime = System.currentTimeMillis();
boolean insertResult = mqHandleUtil.sendMySqlRedis(
SqlMapping.get("dragon_orders.insert"),
new Object[]{orders.getOrderId(),orders.getStatus(), orders.getCode(), orders.getType()
new Object[]{orders.getOrderId(),orders.getStatus(), orders.getCode(),orders.getOrderCodeId(), orders.getType()
, orders.getPrice(), orders.getName(), orders.getDetail()
, orders.getOrderCode(), orders.getClientIp()
, orders.getNotifyUrl(), orders.getNotifyStatus(),orders.getPaymentType(),
......
......@@ -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;
}
......
......@@ -38,6 +38,7 @@ public class PayController {
/**
* 电脑网页支付宝支付
*
* @return
*/
@PostMapping("/dragonPay")
......@@ -50,6 +51,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"),
......@@ -60,24 +62,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不能为空!");
}
......@@ -98,6 +101,9 @@ public class PayController {
// }
dragonPayBaseReqDto.setDetail("正在现场");
dragonPayBaseReqDto.setOrderCode(orderCode);
if(orderId!=null) {
dragonPayBaseReqDto.setOrderId(orderId);
}
dragonPayBaseReqDto.setClientIp(clientIp);
dragonPayBaseReqDto.setNotifyUrl(notifyUrl);
dragonPayBaseReqDto.setReturnUrl(returnUrl);
......@@ -107,7 +113,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;
}
......@@ -118,7 +124,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);
}
......@@ -130,7 +136,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);
}
......@@ -142,11 +148,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);
}
}
......@@ -8,7 +8,7 @@ dragon_order_refund_call_back.update=UPDATE `dragon_order_refunds` SET updated_a
dragon_order_refund_log.insert=INSERT INTO `dragon_order_refund_logs`(`order_refund_id` ,`refund_type` ,`content`,`created_at`,`updated_at`)VALUES(?,?,?,?,?);
dragon_orders.insert=insert into dragon_orders(order_id, status, code, type, price, name, detail, order_code, client_ip, notify_url,notify_status, payment_type, payment_id, payment_at, finished_at, created_at, updated_at, deleted_at) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
dragon_orders.insert=insert into dragon_orders(order_id, status, code, type, price, name, detail, order_code, order_code_id, client_ip, notify_url,notify_status, payment_type, payment_id, payment_at, finished_at, created_at, updated_at, deleted_at) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
dragon_order_logs.insert=insert into dragon_order_logs(code, payment_type, content, created_at, updated_at, deleted_at) values(?,?,?,?,?,?)
dragon_pay_notify.insert=insert into dragon_pay_notify (code, order_code, notify_url, notify_data, created_at, updated_at) values(?,?,?,?,?,?)
dragon_pay_notify_fail.insert=insert into dragon_pay_notify_fail (code, order_code, notify_url, notify_data, fail_desc, created_at, updated_at) values(?,?,?,?,?,?,?)
......
......@@ -8,7 +8,7 @@ dragon_order_refund_call_back.update=UPDATE `dragon_order_refunds` SET updated_a
dragon_order_refund_log.insert=INSERT INTO `dragon_order_refund_logs`(`order_refund_id` ,`refund_type` ,`content`,`created_at`,`updated_at`)VALUES(?,?,?,?,?);
dragon_orders.insert=insert into dragon_orders(order_id, status, code, type, price, name, detail, order_code, client_ip, notify_url,notify_status, payment_type, payment_id, payment_at, finished_at, created_at, updated_at, deleted_at) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
dragon_orders.insert=insert into dragon_orders(order_id, status, code, type, price, name, detail, order_code, order_code_id, client_ip, notify_url,notify_status, payment_type, payment_id, payment_at, finished_at, created_at, updated_at, deleted_at) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
dragon_order_logs.insert=insert into dragon_order_logs(code, payment_type, content, created_at, updated_at, deleted_at) values(?,?,?,?,?,?)
dragon_pay_notify.insert=insert into dragon_pay_notify (code, order_code, notify_url, notify_data, created_at, updated_at) values(?,?,?,?,?,?)
dragon_pay_notify_fail.insert=insert into dragon_pay_notify_fail (code, order_code, notify_url, notify_data, fail_desc, created_at, updated_at) values(?,?,?,?,?,?,?)
......
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