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

Commit 25c04940 authored by jiangxiulong's avatar jiangxiulong

copy 2

下单 支付回调 超时支付退款
parent 2933a92a
...@@ -118,6 +118,12 @@ public class GoblinRedisConst { ...@@ -118,6 +118,12 @@ public class GoblinRedisConst {
public static final String REDIS_GOBLIN_TEMP_COUPON_MARKET = PREFIX.concat("temp:coupon:marketId:");//id 列表 $key:$marketId public static final String REDIS_GOBLIN_TEMP_COUPON_MARKET = PREFIX.concat("temp:coupon:marketId:");//id 列表 $key:$marketId
public static final String REDIS_GOBLIN_TEMP_COUPON = PREFIX.concat("temp:coupon:");//详情 $key:$ucouponId public static final String REDIS_GOBLIN_TEMP_COUPON = PREFIX.concat("temp:coupon:");//详情 $key:$ucouponId
/* --------------------------------NFT--------------------------------- */
public static final String REDIS_GOBLIN_NFT_ORDER_INFO = PREFIX.concat("nftOrder:");// nft订单详情
public static final String REDIS_GOBLIN_NFT_ORDER_USER_ID_LIST = PREFIX.concat("nftOrder:idList:user:");// nft用户订单id列表
public static final String REDIS_GOBLIN_NFT_ORDER_REFUND_INFO = PREFIX.concat("nftOrder:refund:");// nft退款订单详情
/* ----------------------------------------------------------------- */ /* ----------------------------------------------------------------- */
/** /**
* SKU剩余库存 * SKU剩余库存
......
...@@ -184,7 +184,35 @@ public class GoblinStatusConst { ...@@ -184,7 +184,35 @@ public class GoblinStatusConst {
} }
/* ----------------------------------------------------------------- */ /* -----------------------------NFT订单状态------------------------------------ */
public enum NftStatus {
ORDER_STATUS_1(1, "待付款(用户刚下单)"),
ORDER_STATUS_2(2, "已付款(用户付完款 等待商城发货)"),
ORDER_STATUS_3(3, "已取消(未付款取消订单"),
ORDER_STATUS_4(4, "已退款(超时支付)"),
ORDER_REFUND_STATUS_1(1, "申请"),
ORDER_REFUND_STATUS_2(2, "退款成功"),
ORDER_REFUND_STATUS_3(3, "退款失败"),
;
private final int value;
private final String desc;
NftStatus(int value, String desc) {
this.value = value;
this.desc = desc;
}
public int getValue() {
return value;
}
public String getDesc() {
return desc;
}
}
......
package com.liquidnet.service.goblin.dto.vo;
import com.liquidnet.service.goblin.entity.GoblinNftOrderRefund;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;
/**
* <p>
* NFT订单退单退款表
* </p>
*
* @author jiangxiulong
* @since 2022-03-24
*/
@ApiModel(value = "GoblinNftOrderCallBackVo", description = "退款订单vo")
@Data
@EqualsAndHashCode(callSuper = false)
public class GoblinNftOrderCallBackVo implements Serializable, Cloneable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "订单退单表id")
private String orderRefundId;
@ApiModelProperty(value = "退款单号")
private String refundCode;
@ApiModelProperty(value = "订单id")
private String orderId;
@ApiModelProperty(value = "订单编号")
private String orderCode;
@ApiModelProperty(value = "商铺id")
private String storeId;
@ApiModelProperty(value = "用户id")
private String userId;
@ApiModelProperty(value = "skuIdNums")
private String skuIdNums;
@ApiModelProperty(value = "退货时候实际退款金额")
private BigDecimal realBackPrice;
@ApiModelProperty(value = "退款状态 1申请|2退款成功|3退款失败")
private Integer status;
@ApiModelProperty(value = "退款时间")
private LocalDateTime refundAt;
@ApiModelProperty(value = "退款失败原因")
private String errorReason;
@ApiModelProperty(value = "创建时间")
private LocalDateTime createdAt;
@ApiModelProperty(value = "更新时间")
private LocalDateTime updatedAt;
public GoblinNftOrderCallBackVo copy(GoblinNftOrderRefund source) {
this.setOrderRefundId(source.getOrderRefundId());
this.setRefundCode(source.getRefundCode());
this.setOrderId(source.getOrderId());
this.setOrderCode(source.getOrderCode());
this.setStoreId(source.getStoreId());
this.setUserId(source.getUserId());
this.setSkuIdNums(source.getSkuIdNums());
this.setRealBackPrice(source.getRealBackPrice());
this.setStatus(source.getStatus());
this.setRefundAt(source.getRefundAt());
this.setErrorReason(source.getErrorReason());
this.setCreatedAt(source.getCreatedAt());
this.setUpdatedAt(source.getUpdatedAt());
return this;
}
private static final GoblinNftOrderCallBackVo obj = new GoblinNftOrderCallBackVo();
public static GoblinNftOrderCallBackVo getNew() {
try {
return (GoblinNftOrderCallBackVo) obj.clone();
} catch (CloneNotSupportedException e) {
e.printStackTrace();
}
return new GoblinNftOrderCallBackVo();
}
}
package com.liquidnet.service.goblin.dto.vo;
import com.liquidnet.service.goblin.entity.GoblinNftOrder;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;
/**
* <p>
* NFT订单表
* </p>
*
* @author jiangxiulong
* @since 2022-03-24
*/
@ApiModel(value = "GoblinNftOrderVo", description = "订单详情信息")
@Data
@EqualsAndHashCode(callSuper = false)
public class GoblinNftOrderVo implements Serializable, Cloneable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "订单id")
private String orderId;
@ApiModelProperty(value = "商品id")
private String spuId;
@ApiModelProperty(value = "款式id")
private String skuId;
@ApiModelProperty(value = "数量")
private Integer num;
@ApiModelProperty(value = "店铺id")
private String storeId;
@ApiModelProperty(value = "商铺名称")
private String storeName;
@ApiModelProperty(value = "订单号")
private String orderCode;
@ApiModelProperty(value = "用户id")
private String userId;
@ApiModelProperty(value = "用户昵称")
private String userName;
@ApiModelProperty(value = "用户手机号")
private String userMobile;
@ApiModelProperty(value = "是否会员")
private Integer isMember;
@ApiModelProperty(value = "应付金额")
private BigDecimal priceTotal;
@ApiModelProperty(value = "券优惠金额")
private BigDecimal priceCoupon;
@ApiModelProperty(value = "商铺券优惠金额")
private BigDecimal storePriceCoupon;
@ApiModelProperty(value = "红包优惠金额")
private BigDecimal priceRedEnvelope;
@ApiModelProperty(value = "总优惠价格")
private BigDecimal priceVoucher;
@ApiModelProperty(value = "实付金额")
private BigDecimal priceActual;
@ApiModelProperty(value = "券id")
private String ucouponId;
@ApiModelProperty(value = "商铺券id")
private String storeCouponId;
@ApiModelProperty(value = "红包code")
private String redEnvelopeCode;
@ApiModelProperty(value = "订单状态 0-待付款(用户刚下单)|1-已付款|2-已取消(未付款取消订单)|3-已退款(超时支付)")
private Integer status;
@ApiModelProperty(value = "订单来源 app|h5|applet")
private String source;
@ApiModelProperty(value = "订单类型 0-购买订单|1-兑换订单|2-演出赠送订单")
private Integer orderType;
@ApiModelProperty(value = "支付时间")
private LocalDateTime payTime;
@ApiModelProperty(value = "支付单号")
private String payCode;
@ApiModelProperty(value = "支付类型 wepay-微信支付|alipay-阿里支付|douyinpay-抖音支付|unionpay-银联支付")
private String payType;
@ApiModelProperty(value = "支付类型来源[wap|js]")
private String deviceFrom;
@ApiModelProperty(value = "支付中心返回实际支付类型")
private String paymentType;
@ApiModelProperty(value = "支付中心返回支付id")
private String paymentId;
@ApiModelProperty(value = "钱到了哪个支付平台 平台的订单id为")
private String payStoreId;
@ApiModelProperty(value = "订单过期时间(分钟)")
private Integer payCountdownMinute;
@ApiModelProperty(value = "取消原因")
private String cancelReason;
@ApiModelProperty(value = "取消时间")
private LocalDateTime cancelTime;
@ApiModelProperty(value = "版本号")
private String version;
@ApiModelProperty(value = "ip地址")
private String ipAddress;
@ApiModelProperty(value = "ip地域全名称")
private String area;
@ApiModelProperty(value = "ip地域省")
private String areaProvince;
@ApiModelProperty(value = "ip地域市")
private String areaCity;
@ApiModelProperty(value = "ip地域县")
private String areaCounty;
@ApiModelProperty(value = "创建时间")
private LocalDateTime createdAt;
@ApiModelProperty(value = "更新时间")
private LocalDateTime updatedAt;
public GoblinNftOrderVo copy(GoblinNftOrder source) {
if (null == source) return this;
this.setOrderId(source.getOrderId());
this.setStoreId(source.getStoreId());
this.setStoreName(source.getStoreName());
this.setOrderCode(source.getOrderCode());
this.setPayCode(source.getPayCode());
this.setUserId(source.getUserId());
this.setUserName(source.getUserName());
this.setUserMobile(source.getUserMobile());
this.setPriceTotal(source.getPriceTotal());
this.setPriceActual(source.getPriceActual());
this.setPriceCoupon(source.getPriceCoupon());
this.setStorePriceCoupon(source.getStorePriceCoupon());
this.setPriceVoucher(source.getPriceVoucher());
this.setStatus(source.getStatus());
this.setUcouponId(source.getUcouponId());
this.setStoreCouponId(source.getStoreCouponId());
this.setPayType(source.getPayType());
this.setDeviceFrom(source.getDeviceFrom());
this.setCancelReason(source.getCancelReason());
this.setSource(source.getSource());
this.setVersion(source.getVersion());
this.setIsMember(source.getIsMember());
this.setOrderType(source.getOrderType());
this.setPayCountdownMinute(source.getPayCountdownMinute());
this.setIpAddress(source.getIpAddress());
this.setPaymentId(source.getPaymentId());
this.setPaymentType(source.getPaymentType());
this.setCreatedAt(source.getCreatedAt());
return this;
}
private static final GoblinNftOrderVo obj = new GoblinNftOrderVo();
public static GoblinNftOrderVo getNew() {
try {
return (GoblinNftOrderVo) obj.clone();
} catch (CloneNotSupportedException e) {
return new GoblinNftOrderVo();
}
}
}
...@@ -7,9 +7,9 @@ import lombok.Data; ...@@ -7,9 +7,9 @@ import lombok.Data;
import java.io.Serializable; import java.io.Serializable;
import java.math.BigDecimal; import java.math.BigDecimal;
@ApiModel(value = "GoblinNtfPayResultVo", description = "下单唤起支付参数信息") @ApiModel(value = "GoblinNftPayResultVo", description = "下单唤起支付参数信息")
@Data @Data
public class GoblinNtfPayResultVo implements Serializable, Cloneable { public class GoblinNftPayResultVo implements Serializable, Cloneable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
...@@ -25,9 +25,6 @@ public class GoblinNtfPayResultVo implements Serializable, Cloneable { ...@@ -25,9 +25,6 @@ public class GoblinNtfPayResultVo implements Serializable, Cloneable {
@ApiModelProperty(position = 12, value = "orderCode") @ApiModelProperty(position = 12, value = "orderCode")
private String orderCode; private String orderCode;
@ApiModelProperty(position = 13, value = "orderMasterCode")
private String orderMasterCode;
@ApiModelProperty(position = 19, value = "金额") @ApiModelProperty(position = 19, value = "金额")
private BigDecimal price; private BigDecimal price;
...@@ -43,13 +40,13 @@ public class GoblinNtfPayResultVo implements Serializable, Cloneable { ...@@ -43,13 +40,13 @@ public class GoblinNtfPayResultVo implements Serializable, Cloneable {
@ApiModelProperty(position = 20, value = "payData") @ApiModelProperty(position = 20, value = "payData")
private Object payData; private Object payData;
private static final GoblinNtfPayResultVo obj = new GoblinNtfPayResultVo(); private static final GoblinNftPayResultVo obj = new GoblinNftPayResultVo();
public static GoblinNtfPayResultVo getNew() { public static GoblinNftPayResultVo getNew() {
try { try {
return (GoblinNtfPayResultVo) obj.clone(); return (GoblinNftPayResultVo) obj.clone();
} catch (CloneNotSupportedException e) { } catch (CloneNotSupportedException e) {
return new GoblinNtfPayResultVo(); return new GoblinNftPayResultVo();
} }
} }
......
...@@ -6,9 +6,9 @@ import lombok.Data; ...@@ -6,9 +6,9 @@ import lombok.Data;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
@ApiModel(value = "GoblinNtfOrderPayAgainParam", description = "再次支付所需参数") @ApiModel(value = "GoblinNftOrderPayAgainParam", description = "再次支付所需参数")
@Data @Data
public class GoblinNtfOrderPayAgainParam { public class GoblinNftOrderPayAgainParam {
@ApiModelProperty(value = "openId") @ApiModelProperty(value = "openId")
private String openId; private String openId;
......
...@@ -6,9 +6,9 @@ import lombok.Data; ...@@ -6,9 +6,9 @@ import lombok.Data;
import java.math.BigDecimal; import java.math.BigDecimal;
@ApiModel(value = "GoblinNtfOrderPayCallbackParam", description = "支付成功回调所需参数") @ApiModel(value = "GoblinNftOrderPayCallbackParam", description = "支付成功回调所需参数")
@Data @Data
public class GoblinNtfOrderPayCallbackParam implements Cloneable { public class GoblinNftOrderPayCallbackParam implements Cloneable {
@ApiModelProperty(value = "支付状态[1-成功|0-失败]") @ApiModelProperty(value = "支付状态[1-成功|0-失败]")
private Integer status; private Integer status;
...@@ -16,37 +16,34 @@ public class GoblinNtfOrderPayCallbackParam implements Cloneable { ...@@ -16,37 +16,34 @@ public class GoblinNtfOrderPayCallbackParam implements Cloneable {
@ApiModelProperty(value = "订单ID") @ApiModelProperty(value = "订单ID")
private String orderId; private String orderId;
@ApiModelProperty(value = "masterOrderCode") @ApiModelProperty(value = "订单编号")
private String orderCode; private String orderCode;
@ApiModelProperty(value = "不用管") @ApiModelProperty(value = "支付code")
private String orderCodeId;
@ApiModelProperty(value = "[写死]HUIFU_PAY_CODE")
private String code; private String code;
@ApiModelProperty(value = "不用管") @ApiModelProperty(value = "price")
private BigDecimal price; private BigDecimal price;
@ApiModelProperty(value = "不用管") @ApiModelProperty(value = "type")
private String type; private String type;
@ApiModelProperty(value = "汇付相关id") @ApiModelProperty(value = "汇付相关id")
private String paymentId; private String paymentId;
@ApiModelProperty(value = "[写死]huifu") @ApiModelProperty(value = "paymentType")
private String paymentType; private String paymentType;
@ApiModelProperty(value = "支付时间") @ApiModelProperty(value = "支付时间")
private String paymentAt; private String paymentAt;
private static final GoblinNtfOrderPayCallbackParam obj = new GoblinNtfOrderPayCallbackParam(); private static final GoblinNftOrderPayCallbackParam obj = new GoblinNftOrderPayCallbackParam();
public static GoblinNtfOrderPayCallbackParam getNew() { public static GoblinNftOrderPayCallbackParam getNew() {
try { try {
return (GoblinNtfOrderPayCallbackParam) obj.clone(); return (GoblinNftOrderPayCallbackParam) obj.clone();
} catch (CloneNotSupportedException e) { } catch (CloneNotSupportedException e) {
return new GoblinNtfOrderPayCallbackParam(); return new GoblinNftOrderPayCallbackParam();
} }
} }
} }
package com.liquidnet.service.goblin.param;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
/**
* <p>
* NFT下单所需商品相关参数
* </p>
*
* @author jiangxiulong
* @since 2022-03-24
*/
@ApiModel(value = "GoblinNftOrderPayGoodsParam", description = "下单所需商品相关参数")
@Data
public class GoblinNftOrderPayGoodsParam {
@ApiModelProperty(position = 10, required = true, value = "商铺id")
@NotBlank(message = "storeId不能为空")
private String storeId;
@ApiModelProperty(position = 11, required = true, value = "spuId")
@NotBlank(message = "spuId不能为空")
private String spuId;
@ApiModelProperty(position = 12, required = true, value = "skuId")
@NotBlank(message = "skuId不能为空")
private String skuId;
@ApiModelProperty(position = 13, value = "平台券码")
private String platVoucherCode;
@ApiModelProperty(position = 14, value = "商品券码")
private String storeVoucherCode;
}
package com.liquidnet.service.goblin.param;
import com.liquidnet.commons.lang.constant.LnsRegex;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Pattern;
@ApiModel(value = "GoblinNftOrderPayParam", description = "下单所需参数")
@Data
public class GoblinNftOrderPayParam {
@ApiModelProperty(position = 10, value = "openId微信内网页及小程序支付必传")
private String openId;
@ApiModelProperty(position = 11, required = true, value = "支付方式", allowableValues = "alipay,wepay,douyinpay,unionpay")
@Pattern(regexp = LnsRegex.Valid.TRIPLE_PF_FOR_PAY, message = "支付方式无效")
@NotBlank(message = "支付方式不能为空")
private String payType;
@ApiModelProperty(position = 12, required = true, value = "支付终端", allowableValues = "app,wap,js,applet")
@Pattern(regexp = LnsRegex.Valid.TRIPLE_PF_FOR_PAY_TERMINAL, message = "支付终端类型无效")
@NotBlank(message = "支付终端不能为空")
private String deviceFrom;
@ApiModelProperty(position = 13, value = "showUrl 之前h5需要 app不需要再说")
private String showUrl;
@ApiModelProperty(position = 14, value = "returnUrl 之前h5需要 app不需要再说")
private String returnUrl;
@ApiModelProperty(position = 15, required = true, value = "下单所需商品相关参数")
@Valid
private GoblinNftOrderPayGoodsParam goblinNtfOrderPayGoodsParam;
}
...@@ -16,9 +16,9 @@ import java.math.BigDecimal; ...@@ -16,9 +16,9 @@ import java.math.BigDecimal;
* @since 2021-05-31 11:19 上午 * @since 2021-05-31 11:19 上午
*/ */
@ApiModel(value = "GoblinNtfOrderRefundCallbackParam", description = "退款回调所需参数") @ApiModel(value = "GoblinNftOrderRefundCallbackParam", description = "退款回调所需参数")
@Data @Data
public class GoblinNtfOrderRefundCallbackParam implements Serializable { public class GoblinNftOrderRefundCallbackParam implements Serializable {
@ApiModelProperty(value = "状态 1成功 0失败") @ApiModelProperty(value = "状态 1成功 0失败")
private Integer status; private Integer status;
......
package com.liquidnet.service.goblin.param;
import com.liquidnet.service.goblin.dto.manage.AddressVo;
import com.liquidnet.service.goblin.dto.manage.GoblinOrderStoreParam;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotNull;
import java.util.ArrayList;
import java.util.List;
@ApiModel(value = "GoblinNtfOrderPayParam", description = "下单所需参数")
@Data
public class GoblinNtfOrderPayParam {
@ApiModelProperty(value = "openId")
private String openId;
@ApiModelProperty(value = "用户id")
private String uid;
@ApiModelProperty(value = "扫码枪code")
private String authCode;
@ApiModelProperty(value = "支付类型")
@NotNull(message = "支付类型不能为空")
private String payType;
@ApiModelProperty(value = "支付来源 [新增micropay-微信扫码支付]")
@NotNull(message = "支付来源不能为空")
private String deviceFrom;
@ApiModelProperty(value = "代理id")
private String agentId;
@ApiModelProperty(value = "收货地址id[虚拟物品不需要]")
private ArrayList<String> addressIds;
@ApiModelProperty(value = "入场人地址vo")
private AddressVo addressesVo;
@ApiModelProperty(value = "showUrl")
private String showUrl;
@ApiModelProperty(value = "returnUrl")
private String returnUrl;
@ApiModelProperty(value = "商品相关参数集合")
private List<GoblinOrderStoreParam> goblinOrderStoreParamList;
}
package com.liquidnet.service.goblin.service; package com.liquidnet.service.goblin.service;
import com.liquidnet.service.base.ResponseDto; import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.goblin.dto.vo.GoblinNtfPayResultVo; import com.liquidnet.service.goblin.dto.vo.GoblinNftPayResultVo;
import com.liquidnet.service.goblin.param.GoblinNtfOrderPayAgainParam; import com.liquidnet.service.goblin.param.GoblinNftOrderPayAgainParam;
import com.liquidnet.service.goblin.param.GoblinNtfOrderPayCallbackParam; import com.liquidnet.service.goblin.param.GoblinNftOrderPayCallbackParam;
import com.liquidnet.service.goblin.param.GoblinNtfOrderPayParam; import com.liquidnet.service.goblin.param.GoblinNftOrderPayParam;
import com.liquidnet.service.goblin.param.GoblinNtfOrderRefundCallbackParam; import com.liquidnet.service.goblin.param.GoblinNftOrderRefundCallbackParam;
/** /**
* <p> * <p>
...@@ -16,13 +16,13 @@ import com.liquidnet.service.goblin.param.GoblinNtfOrderRefundCallbackParam; ...@@ -16,13 +16,13 @@ import com.liquidnet.service.goblin.param.GoblinNtfOrderRefundCallbackParam;
* @since 2022-03-23 * @since 2022-03-23
*/ */
public interface IGoblinNftOrderService { public interface IGoblinNftOrderService {
ResponseDto<GoblinNtfPayResultVo> checkOrder(GoblinNtfOrderPayParam param, String uid); ResponseDto<GoblinNftPayResultVo> checkOrder(GoblinNftOrderPayParam payParam);
ResponseDto<GoblinNtfPayResultVo> payAgain(GoblinNtfOrderPayAgainParam param); ResponseDto<GoblinNftPayResultVo> payAgain(GoblinNftOrderPayAgainParam payParam);
ResponseDto<Integer> checkOrderResult(String orderId); ResponseDto<Integer> checkOrderResult(String orderId);
String syncOrder(GoblinNtfOrderPayCallbackParam syncOrderParam); String syncOrder(GoblinNftOrderPayCallbackParam syncOrderParam);
String refundSyncOrder(GoblinNtfOrderRefundCallbackParam refundCallbackParam); String refundSyncOrder(GoblinNftOrderRefundCallbackParam refundCallbackParam);
} }
package com.liquidnet.service.order.controller; package com.liquidnet.service.order.controller;
import com.liquidnet.commons.lang.util.CurrentUtil;
import com.liquidnet.service.base.ResponseDto; import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.base.codec.vo.EncryptedReq; import com.liquidnet.service.base.codec.vo.EncryptedReq;
import com.liquidnet.service.goblin.dto.vo.GoblinNtfPayResultVo; import com.liquidnet.service.goblin.dto.vo.GoblinNftPayResultVo;
import com.liquidnet.service.goblin.param.GoblinNtfOrderPayAgainParam; import com.liquidnet.service.goblin.param.GoblinNftOrderPayAgainParam;
import com.liquidnet.service.goblin.param.GoblinNtfOrderPayCallbackParam; import com.liquidnet.service.goblin.param.GoblinNftOrderPayCallbackParam;
import com.liquidnet.service.goblin.param.GoblinNtfOrderPayParam; import com.liquidnet.service.goblin.param.GoblinNftOrderPayParam;
import com.liquidnet.service.goblin.param.GoblinNtfOrderRefundCallbackParam; import com.liquidnet.service.goblin.param.GoblinNftOrderRefundCallbackParam;
import com.liquidnet.service.goblin.service.IGoblinNftOrderService; import com.liquidnet.service.goblin.service.IGoblinNftOrderService;
import io.swagger.annotations.*; import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -26,24 +25,21 @@ public class GoblinNftOrderController { ...@@ -26,24 +25,21 @@ public class GoblinNftOrderController {
@PostMapping("pre") @PostMapping("pre")
@ApiOperation("下单(加密)") @ApiOperation("下单(加密)")
@ApiResponse(code = 200, message = "接口返回对象参数") @ApiResponse(code = 200, message = "接口返回对象参数")
public ResponseDto<GoblinNtfPayResultVo> checkOrder(@RequestBody EncryptedReq<GoblinNtfOrderPayParam> param) { public ResponseDto<GoblinNftPayResultVo> checkOrder(@RequestBody EncryptedReq<GoblinNftOrderPayParam> payParam) {
GoblinNtfOrderPayParam payOrderParam = param.getData(); return iGoblinNftOrderService.checkOrder(payParam.getData());
String uid = CurrentUtil.getCurrentUid();
return iGoblinNftOrderService.checkOrder(payOrderParam, uid);
} }
@PostMapping("fc7bce6d6c2213b866f76493f92224b8") @PostMapping("fc7bce6d6c2213b866f76493f92224b8")
@ApiOperation("下单(非加密)") @ApiOperation("下单(非加密)")
@ApiResponse(code = 200, message = "接口返回对象参数") @ApiResponse(code = 200, message = "接口返回对象参数")
public ResponseDto<GoblinNtfPayResultVo> checkOrder(@RequestBody GoblinNtfOrderPayParam param) { public ResponseDto<GoblinNftPayResultVo> checkOrder(@RequestBody GoblinNftOrderPayParam payParam) {
String uid = CurrentUtil.getCurrentUid(); return iGoblinNftOrderService.checkOrder(payParam);
return iGoblinNftOrderService.checkOrder(param, uid);
} }
@PostMapping("payAgain") @PostMapping("payAgain")
@ApiOperation("再次支付") @ApiOperation("再次支付")
@ApiResponse(code = 200, message = "接口返回对象参数") @ApiResponse(code = 200, message = "接口返回对象参数")
public ResponseDto<GoblinNtfPayResultVo> payAgain(@RequestBody @Valid GoblinNtfOrderPayAgainParam param) { public ResponseDto<GoblinNftPayResultVo> payAgain(@RequestBody @Valid GoblinNftOrderPayAgainParam param) {
return iGoblinNftOrderService.payAgain(param); return iGoblinNftOrderService.payAgain(param);
} }
...@@ -60,14 +56,14 @@ public class GoblinNftOrderController { ...@@ -60,14 +56,14 @@ public class GoblinNftOrderController {
@PostMapping("syncOrder") @PostMapping("syncOrder")
@ApiOperation("支付回调") @ApiOperation("支付回调")
@ApiResponse(code = 200, message = "接口返回对象参数") @ApiResponse(code = 200, message = "接口返回对象参数")
public String syncOrder(@ModelAttribute @Valid GoblinNtfOrderPayCallbackParam syncOrderParam) { public String syncOrder(@ModelAttribute @Valid GoblinNftOrderPayCallbackParam syncOrderParam) {
return iGoblinNftOrderService.syncOrder(syncOrderParam); return iGoblinNftOrderService.syncOrder(syncOrderParam);
} }
@ApiOperation(value = "退款回调") @ApiOperation(value = "退款回调")
@PostMapping(value = "refundSyncOrder") @PostMapping(value = "refundSyncOrder")
@ApiResponse(code = 200, message = "接口返回对象参数") @ApiResponse(code = 200, message = "接口返回对象参数")
public String refundSyncOrder(GoblinNtfOrderRefundCallbackParam refundCallbackParam) { public String refundSyncOrder(GoblinNftOrderRefundCallbackParam refundCallbackParam) {
return iGoblinNftOrderService.refundSyncOrder(refundCallbackParam); return iGoblinNftOrderService.refundSyncOrder(refundCallbackParam);
} }
......
package com.liquidnet.service.order.service.impl; package com.liquidnet.service.order.service.impl;
import com.alibaba.fastjson.JSON;
import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.core.type.TypeReference;
import com.liquidnet.commons.lang.util.*; import com.liquidnet.commons.lang.util.*;
import com.liquidnet.service.base.ErrorMapping; import com.liquidnet.service.base.ErrorMapping;
...@@ -9,13 +8,8 @@ import com.liquidnet.service.base.SqlMapping; ...@@ -9,13 +8,8 @@ import com.liquidnet.service.base.SqlMapping;
import com.liquidnet.service.base.UserPathDto; import com.liquidnet.service.base.UserPathDto;
import com.liquidnet.service.base.constant.MQConst; import com.liquidnet.service.base.constant.MQConst;
import com.liquidnet.service.goblin.constant.GoblinStatusConst; import com.liquidnet.service.goblin.constant.GoblinStatusConst;
import com.liquidnet.service.goblin.dto.manage.AddressVo;
import com.liquidnet.service.goblin.dto.manage.GoblinOrderSkuParam;
import com.liquidnet.service.goblin.dto.manage.GoblinOrderStoreParam;
import com.liquidnet.service.goblin.dto.vo.*; import com.liquidnet.service.goblin.dto.vo.*;
import com.liquidnet.service.goblin.entity.GoblinOrderAttr; import com.liquidnet.service.goblin.entity.GoblinNftOrder;
import com.liquidnet.service.goblin.entity.GoblinOrderSku;
import com.liquidnet.service.goblin.entity.GoblinStoreOrder;
import com.liquidnet.service.goblin.param.*; import com.liquidnet.service.goblin.param.*;
import com.liquidnet.service.goblin.service.IGoblinNftOrderService; import com.liquidnet.service.goblin.service.IGoblinNftOrderService;
import com.liquidnet.service.order.utils.*; import com.liquidnet.service.order.utils.*;
...@@ -30,28 +24,24 @@ import org.springframework.util.MultiValueMap; ...@@ -30,28 +24,24 @@ import org.springframework.util.MultiValueMap;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.HashMap; import java.util.*;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import static com.liquidnet.commons.lang.util.DateUtil.DTF_YMD_HMS; import static com.liquidnet.commons.lang.util.DateUtil.DTF_YMD_HMS;
import static com.liquidnet.commons.lang.util.DateUtil.getNowTime;
@Service @Service
@Slf4j @Slf4j
public class GoblinNftOrderServiceImpl implements IGoblinNftOrderService { public class GoblinNftOrderServiceImpl implements IGoblinNftOrderService {
@Autowired @Autowired
GoblinRedisUtils redisUtils; GoblinRedisUtils goblinRedisUtils;
@Autowired @Autowired
GoblinMongoUtils mongoUtils; GoblinMongoUtils goblinMongoUtils;
@Autowired @Autowired
QueueUtils queueUtils; QueueUtils queueUtils;
@Autowired @Autowired
GoblinOrderUtils orderUtils; GoblinOrderUtils goblinOrderUtils;
@Autowired @Autowired
GoblinNtfOrderUtils ntfOrderUtils; GoblinNftOrderUtils nftOrderUtils;
@Value("${liquidnet.service.order.url-pay.pay}") @Value("${liquidnet.service.order.url-pay.pay}")
private String payUrl; private String payUrl;
...@@ -61,584 +51,254 @@ public class GoblinNftOrderServiceImpl implements IGoblinNftOrderService { ...@@ -61,584 +51,254 @@ public class GoblinNftOrderServiceImpl implements IGoblinNftOrderService {
private String synUrl; private String synUrl;
@Override @Override
public ResponseDto<GoblinNtfPayResultVo> checkOrder(GoblinNtfOrderPayParam param, String uid) { public ResponseDto<GoblinNftPayResultVo> checkOrder(GoblinNftOrderPayParam payParam) {
List<String> skuAndPreListAndNumber = CollectionUtil.arrayListString(); // 基础参数
List<String> platformCodeList = CollectionUtil.arrayListString(); GoblinNftOrderPayGoodsParam payGoodsParam = payParam.getGoblinNtfOrderPayGoodsParam();
List<String> storeCodeList = CollectionUtil.arrayListString();
List<GoblinOrderSqlParam> orderSqlParams = ObjectUtil.getGoblinOrderSqlParamArrayListList(); // 判断库存
String orderMasterCode = IDGenerator.storeMasterCode();//总订单id String skuId = payGoodsParam.getSkuId();
int number = 1;
GoblinOrderPreParam preParam = GoblinOrderPreParam.getNew(); int surplusGeneral = nftOrderUtils.decrSkuStock(skuId, number);
preParam.setAuthCode(param.getAuthCode());
preParam.setPayType(param.getPayType());
preParam.setDeviceFrom(param.getDeviceFrom());
preParam.setOpenId(param.getOpenId());
preParam.setReturnUrl(param.getReturnUrl());
preParam.setShowUrl(param.getShowUrl());
preParam.setOrderMasterCode(orderMasterCode);
preParam.setExpireTime(5);
preParam.setPriceActual(BigDecimal.ZERO);
preParam.setStoreName("");
preParam.setSkuName("");
preParam.setOrderIdList("");
try {
List<GoblinOrderStoreParam> goblinOrderStoreParamList = param.getGoblinOrderStoreParamList();//分订单
boolean isMember;
AddressVo addressesVo = null;
if (orderUtils.noZhengzaiOrder(uid)) {
addressesVo = param.getAddressesVo();
if (orderUtils.getMember(uid) != null) {
isMember = true;
} else {
isMember = false;
}
} else {
isMember = false;
}
for (GoblinOrderStoreParam storeParam : goblinOrderStoreParamList) {//商铺维度循环
String orderId = IDGenerator.nextSnowId();
String orderCode = IDGenerator.storeCode(orderId);
for (GoblinOrderSkuParam skuParam : storeParam.getGoblinOrderSkuParamArrayList()) {//商品维度循环
String skuId = skuParam.getSkuId();
int number = skuParam.getNumber();
String pre = GoblinStatusConst.MarketPreStatus.getPre(skuId);
int surplusGeneral = redisUtils.decrSkuStock(pre, skuId, number);
skuAndPreListAndNumber.add(skuId + "," + pre + "," + number);
//库存回滚
if (surplusGeneral < 0) { if (surplusGeneral < 0) {
return ntfOrderUtils.orderException(skuAndPreListAndNumber, platformCodeList, storeCodeList, uid, "库存不足"); nftOrderUtils.incrSkuStock(skuId, number);
// throw new Exception("库存不足"); return ResponseDto.failure("库存不足啦~");
}
}//GoblinOrderSkuParam
//下单
GoblinOrderPreParam pre = order(param, storeParam, uid, isMember, addressesVo, orderMasterCode, orderId, orderCode, platformCodeList, storeCodeList);
preParam.setPriceActual(preParam.getPriceActual().add(pre.getPriceActual()));
preParam.setStoreName(pre.getStoreName() + "," + preParam.getStoreName());
preParam.setSkuName(preParam.getSkuName() + "," + pre.getSkuName());
preParam.setOrderIdList(preParam.getOrderIdList() + "," + pre.getOrderIdList());
preParam.setPlatformSpuIds(pre.getPlatformSpuIds());
preParam.setStoreSpuIds(pre.getStoreSpuIds());
GoblinOrderSqlParam sqlParam = GoblinOrderSqlParam.getNew();
sqlParam.setStoreOrder(pre.getStoreOrder());
sqlParam.setOrderAttr(pre.getOrderAttr());
sqlParam.setOrderSkuList(pre.getOrderSkuList());
orderSqlParams.add(sqlParam);
}//GoblinOrderStoreParam
if (preParam.getOrderIdList().equals("")) {
return ntfOrderUtils.orderException(skuAndPreListAndNumber, platformCodeList, storeCodeList, uid, "参数异常");
// throw new Exception("参数异常");
}
return payOrder(preParam, orderSqlParams, uid);
} catch (Exception e) {
log.error("Kylin Order Pay Error = {}", e);
Long time3 = System.currentTimeMillis();
//回顾限购 回滚库存
for (String item : skuAndPreListAndNumber) {
String[] array = item.split(",");
String skuId = array[0];
String pre = array[1];
int number = Integer.parseInt(array[2]);
redisUtils.incrSkuStock(pre, skuId, number);
if (orderUtils.noZhengzaiOrder(uid)) {
redisUtils.decrSkuCountByUid(uid, skuId, number);
}
}
//回退平台券
for (String platformCode : platformCodeList) {
orderUtils.backCoupon(platformCode, uid);
}
//回退店铺券
List<BackCouponParam> params = ObjectUtil.getBackCouponParam();
for (String storeCode : storeCodeList) {
BackCouponParam backCouponParam = BackCouponParam.getNew();
backCouponParam.setuCouponIds(storeCode);
backCouponParam.setUid(uid);
params.add(backCouponParam);
}
if (params.size() > 0) {
orderUtils.backStoreCoupon(params);
}
if (e.getMessage() == null) {
return ResponseDto.failure(ErrorMapping.get("20018"));//乱七八糟异常
} else if (e.getMessage().equals("平台券不可用")) {
return ResponseDto.failure(e.getMessage());
} else if (e.getMessage().equals("无权购买")) {
return ResponseDto.failure(e.getMessage());
} else if (e.getMessage().equals("平台券店铺券不可一起使用")) {
return ResponseDto.failure(e.getMessage());
} else if (e.getMessage().equals("平台券店铺券不可一起使用")) {
return ResponseDto.failure(e.getMessage());
} else if (e.getMessage().equals("跨店铺购物平台券不可用")) {
return ResponseDto.failure(e.getMessage());
} else if (e.getMessage().equals("店铺券不可用")) {
return ResponseDto.failure(e.getMessage());
} else if (e.getMessage().equals("不可购买")) {
return ResponseDto.failure(e.getMessage());
} else if (e.getMessage().equals("参数异常")) {
return ResponseDto.failure(e.getMessage());
} else if (e.getMessage().equals("库存不足")) {
return ResponseDto.failure(e.getMessage());
} else if (e.getMessage().equals("已超出限购数量")) {
return ResponseDto.failure(e.getMessage());
} else if (e.getMessage().equals("非法参数")) {
return ResponseDto.failure(e.getMessage());
} else {
return ResponseDto.failure(ErrorMapping.get("20018"));//乱七八糟异常
} }
// 是店铺商品可购买
String storeId = payGoodsParam.getStoreId();
String spuId = payGoodsParam.getSpuId();
GoblinGoodsInfoVo spuVo = goblinRedisUtils.getGoodsInfoVo(spuId);
GoblinGoodsSkuInfoVo skuVo = goblinRedisUtils.getGoodsSkuInfoVo(skuId);
if (!storeId.equals(spuVo.getStoreId()) || !storeId.equals(skuVo.getStoreId())) {
log.info("NFT-storeId错误 相关参数:[storeId:{}, spuId:{}, skuId:{}]", storeId, spuId, skuId);
return ResponseDto.failure("非法参数~");
}
// 3审核通过 3已上架 0未删除 才可购买
if (!skuVo.getStatus().equals("3") || !skuVo.getShelvesStatus().equals("3") || skuVo.getDelFlg().equals("1")) {
return ResponseDto.failure("该商品当前不可购买~");
} }
// TODO: jxl 2022/3/23 是否开售
// 数量限购
String uid = CurrentUtil.getCurrentUid();
int limitCount = skuVo.getBuyLimit() == 0 ? Integer.MAX_VALUE : skuVo.getBuyLimit();
String isOutLimt = goblinOrderUtils.judgeOrderLimit(uid, skuId, 1, limitCount);
if (!StringUtils.isEmpty(isOutLimt)) {
goblinRedisUtils.decrSkuCountByUid(uid, skuId, number);
return ResponseDto.failure("已超出限购数量~");
} }
private GoblinOrderPreParam order(GoblinNtfOrderPayParam param, GoblinOrderStoreParam storeParam, String uid, boolean isMember, AddressVo addressesVo, String orderMasterCode, String orderId, String orderCode, List<String> platformCodeList, List<String> storeCodeList) throws Exception { // 权限限购
String platVoucherCode = storeParam.getPlatVoucherCode(); String mobile = StringUtils.defaultString(((String) CurrentUtil.getTokenClaims().get(CurrentUtil.TOKEN_MOBILE)), "");
String storeVoucherCode = storeParam.getStoreVoucherCode(); boolean isVip = nftOrderUtils.isVipMember(uid);
String storeId = storeParam.getStoreId(); Boolean isAuthBuy = goblinOrderUtils.judgeOrderRose(isVip, skuId, mobile, Integer.parseInt(skuVo.getBuyFactor()));
Map token = CurrentUtil.getTokenClaims(); if (!isAuthBuy) {
String headerCliSource = CurrentUtil.getHeaderCliSource(), headerCliVersion = CurrentUtil.getHeaderCliVersion(); return ResponseDto.failure("该商品仅限特定用户购买~");
String source = headerCliSource == null ? "" : headerCliSource;
String version = headerCliVersion == null ? "" : headerCliVersion;
LocalDateTime now = LocalDateTime.now();
String skuName = "";
BigDecimal price;//sku应付价格
BigDecimal priceBase;//sku原价
BigDecimal storeTotalPrice = BigDecimal.ZERO;//订单总金额
String writeOffCode = ""; //取货码
List<GoblinOrderSku> goblinOrderSkuList = ObjectUtil.getGoblinOrderSkuArrayList();
List<String> storeSpuIds = CollectionUtil.linkedListString();
List<String> platformSpuIds = CollectionUtil.linkedListString();
String marketId = "";
String marketType = "";
for (GoblinOrderSkuParam skuParam : storeParam.getGoblinOrderSkuParamArrayList()) {
String pre = GoblinStatusConst.MarketPreStatus.getPre(skuParam.getSkuId());
GoblinGoodsSkuInfoVo skuVo = redisUtils.getGoodsSkuInfoVo(skuParam.getSkuId());
GoblinGoodsInfoVo spuVo = redisUtils.getGoodsInfoVo(skuParam.getSpuId());
if (!spuVo.getStoreId().equals(storeParam.getStoreId()) || !skuVo.getStoreId().equals(storeParam.getStoreId())) {
throw new Exception("非法参数");
}
if (!(skuVo.getStatus().equals("3") && skuVo.getShelvesStatus().equals("3")) || skuVo.getDelFlg().equals("1")) {
throw new Exception("不可购买");
} }
// 判断库存
int limitCount = skuVo.getBuyLimit() == 0 ? Integer.MAX_VALUE : skuVo.getBuyLimit(); // 判断优惠券
//判断限购 String platVoucherCode = payGoodsParam.getPlatVoucherCode();
if (orderUtils.noZhengzaiOrder(uid)) { String storeVoucherCode = payGoodsParam.getStoreVoucherCode();
String res1 = orderUtils.judgeOrderLimit(uid, skuParam.getSkuId(), skuParam.getNumber(), limitCount); if (!StringUtils.isEmpty(platVoucherCode) && !StringUtils.isEmpty(storeVoucherCode)) {
if (!res1.equals("")) { return ResponseDto.failure("平台券与店铺券不可一起使用哦~");
throw new Exception("已超出限购数量");
}
//权限限购
Boolean res2 = orderUtils.judgeOrderRose(isMember, skuParam.getSkuId(), StringUtils.defaultString(((String) CurrentUtil.getTokenClaims().get("mobile")), ""), Integer.parseInt(skuVo.getBuyFactor()));
if (!res2) {
throw new Exception("无权购买");
}
}
marketId = spuVo.getMarketId();
marketType = pre;
skuName = skuName.concat(skuVo.getName()).concat(",");
if (pre != null && pre.equals(GoblinStatusConst.MarketPreStatus.MARKET_PRE_ZHENGZAI.getValue())) {
writeOffCode = "EMPTY";
}
//获得 活动原价
price = skuVo.getPrice();
if (isMember) {
price = skuVo.getPriceMember();
}
//活动价格
// if (pre != null) {
// GoblinGoodsSkuInfoVo skuMarketVo = redisUtils.getGoodsSkuInfoVo(skuParam.getSkuId().split(pre)[0]);
// priceBase = skuMarketVo.getPrice();
// if (isMember) {
// priceBase = skuMarketVo.getPriceMember();
// }
// } else {
priceBase = skuVo.getPrice();
if (isMember) {
priceBase = skuVo.getPriceMember();
} }
// }
//todo
//获得活动优惠价格
// priceBase = priceBase.multiply(BigDecimal.valueOf(skuParam.getNumber()));
price = price.multiply(BigDecimal.valueOf(skuParam.getNumber()));
storeTotalPrice = storeTotalPrice.add(price);
//订单sku
GoblinOrderSku orderSku = GoblinOrderSku.getNew();
orderSku.setOrderSkuId(IDGenerator.nextTimeId2());
orderSku.setOrderId(orderId);
orderSku.setStatus(GoblinStatusConst.Status.ORDER_STATUS_0.getValue());
orderSku.setSpuId(skuParam.getSpuId());
orderSku.setSpuName(spuVo.getName());
orderSku.setSkuId(skuParam.getSkuId());
orderSku.setNum(skuParam.getNumber());
orderSku.setSkuPrice(priceBase);
orderSku.setSkuPriceActual(price);
orderSku.setSkuName(skuVo.getName());
orderSku.setSkuNo(skuVo.getSkuNo());
orderSku.setSkuImage(skuVo.getSkuPic());
orderSku.setSkuSpecs(JSON.toJSONString(skuVo.getSkuSpecList()));
orderSku.setPriceVoucher(BigDecimal.ZERO);
// orderSku.setPriceVoucher(priceBase.subtract(price));
orderSku.setCreatedAt(now);
orderSku.setSpuName(spuVo.getName());
orderSku.setSpuPic(spuVo.getCoverPic());
goblinOrderSkuList.add(orderSku);
}
if ((platVoucherCode != null && !platVoucherCode.equals("")) && (storeVoucherCode != null && !storeVoucherCode.equals(""))) {
throw new Exception("平台券店铺券不可一起使用");
}
if (param.getGoblinOrderStoreParamList().size() > 1 && (platVoucherCode != null && !platVoucherCode.equals(""))) {
throw new Exception("跨店铺购物平台券不可用");
}
//优惠券
BigDecimal voucherPrice = BigDecimal.ZERO; BigDecimal voucherPrice = BigDecimal.ZERO;
if (platVoucherCode != null && !platVoucherCode.equals("")) { String orderId = IDGenerator.nextSnowId();
String spuIds = ""; String orderCode = IDGenerator.storeCode(orderId);
for (GoblinOrderSkuParam item : storeParam.getGoblinOrderSkuParamArrayList()) { BigDecimal totalPrice = skuVo.getPrice();
String pre = GoblinStatusConst.MarketPreStatus.getPre(item.getSpuId()); if (isVip) {
if (pre != null) { totalPrice = skuVo.getPriceMember();
spuIds = spuIds.concat(item.getSpuId().split(pre)[0] + ",");
} else {
spuIds = spuIds.concat(item.getSpuId() + ",");
}
} }
HashMap<String, Object> hashMap = orderUtils.useCoupon(platVoucherCode, "购买商品[" + orderCode + "]", storeTotalPrice, spuIds, uid, goblinOrderSkuList); if (!StringUtils.isEmpty(platVoucherCode)) {// 平台券
HashMap<String, Object> hashMap = nftOrderUtils.useCoupon(platVoucherCode, "购买NFT商品[" + orderCode + "]", totalPrice, spuId, uid);
if (hashMap != null) { if (hashMap != null) {
voucherPrice = (BigDecimal) hashMap.get("voucher"); voucherPrice = (BigDecimal) hashMap.get("voucher");
Integer typeVoucher = (Integer) hashMap.get("type"); Integer typeVoucher = (Integer) hashMap.get("type");
if (typeVoucher.equals(-1)) { if (typeVoucher.equals(-1)) {
throw new Exception("平台券不可用"); return ResponseDto.failure("当前平台券不允许使用~");
} else { } else {
platformCodeList.add(platVoucherCode); // TODO: jxl 2022/3/24 错误回退
platformSpuIds = (List<String>) hashMap.get("spuIds");
} }
} }
} }
//商铺券
BigDecimal storeVoucherPrice = BigDecimal.ZERO; BigDecimal storeVoucherPrice = BigDecimal.ZERO;
if (storeVoucherCode != null && !storeVoucherCode.equals("")) { if (!StringUtils.isEmpty(storeVoucherCode)) {// 店铺券
GoblinUseResultVo storeCouponVo = orderUtils.useStoreCoupon(storeVoucherCode, "购买商品[" + orderCode + "]", storeTotalPrice, goblinOrderSkuList, uid); GoblinUseResultVo storeCouponVo = nftOrderUtils.useStoreCoupon(storeVoucherCode, "购买NFT商品[" + orderCode + "]", totalPrice, spuId, uid);
String typeVoucher; String typeVoucher;
if (storeCouponVo != null) { if (storeCouponVo != null) {
storeVoucherPrice = storeCouponVo.getValue(); storeVoucherPrice = storeCouponVo.getValue();
typeVoucher = storeCouponVo.getCouType(); typeVoucher = storeCouponVo.getCouType();
if (typeVoucher.equals("-1")) { if (typeVoucher.equals("-1")) {
throw new Exception("店铺券不可用"); return ResponseDto.failure("当前店铺券不允许使用~");
} else { } else {
storeCodeList.add(storeVoucherCode); // TODO: jxl 2022/3/24 错误回退
storeSpuIds = storeCouponVo.getSpuIds();
} }
} }
} }
GoblinStoreInfoVo storeInfoVo = redisUtils.getStoreInfoVo(storeId);
// 下单数据
GoblinNftOrder nftOrder = order(payParam, payGoodsParam, uid, orderId, orderCode, totalPrice, voucherPrice, storeVoucherPrice, isVip);
// 下单唤起支付
GoblinNftPayResultVo nftPayResultVo = payOrder(nftOrder, uid, payParam);
return ResponseDto.success(nftPayResultVo);
}
private GoblinNftOrder order(
GoblinNftOrderPayParam payParam, GoblinNftOrderPayGoodsParam payGoodsParam, String uid,
String orderId, String orderCode,
BigDecimal totalPrice, BigDecimal voucherPrice, BigDecimal storeVoucherPrice,
boolean isVip
) {
String storeId = payGoodsParam.getStoreId();
LocalDateTime now = LocalDateTime.now();
Map token = CurrentUtil.getTokenClaims();
String headerCliSource = CurrentUtil.getHeaderCliSource(), headerCliVersion = CurrentUtil.getHeaderCliVersion();
String source = headerCliSource == null ? "" : headerCliSource;
String version = headerCliVersion == null ? "" : headerCliVersion;
GoblinStoreInfoVo storeInfoVo = goblinRedisUtils.getStoreInfoVo(storeId);
String storeName = storeInfoVo.getStoreName();
//生成订单 //生成订单
GoblinStoreOrder storeOrder = GoblinStoreOrder.getNew(); GoblinNftOrder nftOrder = GoblinNftOrder.getNew();
storeOrder.setMasterOrderCode(orderMasterCode); nftOrder.setOrderId(orderId);
storeOrder.setOrderId(orderId); nftOrder.setOrderCode(orderCode);
storeOrder.setStoreId(storeId); nftOrder.setStoreId(storeId);
storeOrder.setStoreName(storeInfoVo.getStoreName()); nftOrder.setStoreName(storeName);
storeOrder.setOrderCode(orderCode); nftOrder.setUserId(uid);
storeOrder.setUserId(uid); nftOrder.setUserName(StringUtils.defaultString(((String) token.get(CurrentUtil.TOKEN_NICKNAME)), ""));
storeOrder.setUserName(StringUtils.defaultString(((String) token.get("nickname")), "")); nftOrder.setUserMobile(StringUtils.defaultString(((String) token.get(CurrentUtil.TOKEN_MOBILE)), ""));
storeOrder.setUserMobile(StringUtils.defaultString(((String) token.get("mobile")), "")); nftOrder.setPriceTotal(totalPrice);
if (addressesVo == null) { BigDecimal priceActual = totalPrice.subtract(voucherPrice).subtract(storeVoucherPrice);
storeOrder.setPriceExpress(BigDecimal.ZERO); nftOrder.setPriceActual(priceActual.compareTo(BigDecimal.ZERO) < 0 ? BigDecimal.ZERO : priceActual);
} else { nftOrder.setPriceCoupon(voucherPrice);
storeOrder.setPriceExpress(BigDecimal.TEN); nftOrder.setStorePriceCoupon(storeVoucherPrice);
} nftOrder.setPriceVoucher(voucherPrice.add(storeVoucherPrice));
storeOrder.setPriceTotal(storeTotalPrice.add(storeOrder.getPriceExpress())); nftOrder.setStatus(GoblinStatusConst.NftStatus.ORDER_STATUS_1.getValue());
BigDecimal priceActual = storeOrder.getPriceTotal().subtract(voucherPrice).subtract(storeVoucherPrice); nftOrder.setUcouponId(payGoodsParam.getPlatVoucherCode());
if (priceActual.compareTo(storeOrder.getPriceExpress()) < 0) { nftOrder.setStoreCouponId(payGoodsParam.getStoreVoucherCode());
priceActual = storeOrder.getPriceExpress(); nftOrder.setPayType(payParam.getPayType());
} nftOrder.setDeviceFrom(payParam.getDeviceFrom());
storeOrder.setPriceActual(priceActual.compareTo(BigDecimal.ZERO) < 0 ? BigDecimal.ZERO : priceActual); nftOrder.setSource(source);
storeOrder.setPriceRefund(BigDecimal.ZERO); nftOrder.setVersion(version);
storeOrder.setPriceCoupon(voucherPrice); nftOrder.setIsMember(isVip ? 1 : 0);
storeOrder.setStorePriceCoupon(storeVoucherPrice); nftOrder.setOrderType(0);
storeOrder.setPriceVoucher(voucherPrice.add(storeVoucherPrice)); nftOrder.setPayCountdownMinute(5);
storeOrder.setStatus(0); nftOrder.setIpAddress(CurrentUtil.getCliIpAddr());
storeOrder.setUcouponId(platVoucherCode); nftOrder.setCreatedAt(now);
storeOrder.setStoreCouponId(storeVoucherCode);
storeOrder.setPayType(param.getPayType()); return nftOrder;
storeOrder.setDeviceFrom(param.getDeviceFrom()); }
storeOrder.setSource(source);
storeOrder.setVersion(version); private GoblinNftPayResultVo payOrder(GoblinNftOrder nftOrder, String uid, GoblinNftOrderPayParam payParam) {
storeOrder.setIsMember(isMember ? 1 : 0); // 是否免费
storeOrder.setOrderType(0);
storeOrder.setWriteOffCode(writeOffCode);
if (marketType != null && marketType.equals(GoblinStatusConst.MarketPreStatus.MARKET_PRE_ZHENGZAI.getValue())) {
storeOrder.setPayCountdownMinute(1);
} else {
storeOrder.setPayCountdownMinute(5);
}
storeOrder.setIpAddress(CurrentUtil.getCliIpAddr());
storeOrder.setCreatedAt(now);
storeOrder.setMarketId(marketId);
storeOrder.setMarketType(marketType);
//订单attr
GoblinOrderAttr orderAttr = GoblinOrderAttr.getNew();
orderAttr.setOrderAttrId(IDGenerator.nextTimeId2());
orderAttr.setOrderId(orderId);
if (!writeOffCode.equals("EMPTY")) {
orderAttr.setExpressContacts(addressesVo.getName());
orderAttr.setExpressAddress(addressesVo.getProvince() + "," + addressesVo.getCounty() + "," + addressesVo.getCity());
orderAttr.setExpressAddressDetail(addressesVo.getAddress());
orderAttr.setExpressPhone(addressesVo.getPhone());
orderAttr.setExpressType(1);
orderAttr.setCreatedAt(now);
}
//返回值
GoblinOrderPreParam preParam = GoblinOrderPreParam.getNew();
preParam.setPriceActual(storeOrder.getPriceActual());
preParam.setStoreName(storeInfoVo.getStoreName());
preParam.setSkuName(skuName);
preParam.setOrderIdList(storeOrder.getOrderId());
preParam.setStoreOrder(storeOrder);
preParam.setOrderAttr(orderAttr);
preParam.setOrderSkuList(goblinOrderSkuList);
preParam.setStoreSpuIds(storeSpuIds);
preParam.setPlatformSpuIds(platformSpuIds);
return preParam;
}
private ResponseDto<GoblinNtfPayResultVo> payOrder(GoblinOrderPreParam preParam, List<GoblinOrderSqlParam> sqlParams, String uid) {
//是否免费
boolean isFree = false; boolean isFree = false;
GoblinNtfPayResultVo ntfPayResultVo; GoblinNftPayResultVo NftPayResultVo = GoblinNftPayResultVo.getNew();
String payCode; String payCode;
if (preParam.getPriceActual().compareTo(BigDecimal.valueOf(0)) > 0 && !preParam.getPayType().equals("huifu")) { if (nftOrder.getPriceActual().compareTo(BigDecimal.valueOf(0)) > 0) {// 调用支付
// 调用支付
LinkedMultiValueMap<String, String> httpData = CollectionUtil.linkedMultiValueMapStringString(); LinkedMultiValueMap<String, String> httpData = CollectionUtil.linkedMultiValueMapStringString();
httpData.add("type", "PRODUCT"); httpData.add("type", "PRODUCT");
httpData.add("price", preParam.getPriceActual().toString()); httpData.add("price", nftOrder.getPriceActual().toString());
// 测试0.01
// httpData.add("price","0.01"); // httpData.add("price","0.01");
httpData.add("name", preParam.getStoreName()); httpData.add("name", nftOrder.getStoreName());
httpData.add("detail", preParam.getSkuName()); GoblinGoodsSkuInfoVo skuVo = goblinRedisUtils.getGoodsSkuInfoVo(nftOrder.getSkuId());
httpData.add("orderCode", preParam.getOrderMasterCode()); httpData.add("detail", skuVo.getName());
httpData.add("orderId", preParam.getOrderIdList().substring(1)); httpData.add("orderCode", nftOrder.getOrderCode());
httpData.add("orderId", nftOrder.getOrderId());
httpData.add("clientIp", CurrentUtil.getCliIpAddr()); httpData.add("clientIp", CurrentUtil.getCliIpAddr());
httpData.add("notifyUrl", synUrl); httpData.add("notifyUrl", synUrl);
httpData.add("createDate", LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); httpData.add("createDate", LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
httpData.add("expireTime", preParam.getExpireTime() + ""); httpData.add("expireTime", "5");
httpData.add("payType", preParam.getPayType()); httpData.add("payType", nftOrder.getPayType());
httpData.add("deviceFrom", preParam.getDeviceFrom()); httpData.add("deviceFrom", nftOrder.getDeviceFrom());
if (nftOrder.getDeviceFrom().equals("js") || nftOrder.getDeviceFrom().equals("applet")) {
httpData.add("openId", payParam.getOpenId());
}
String showUrl = payParam.getShowUrl().concat(nftOrder.getOrderCode());
String returnUrl = payParam.getReturnUrl().concat(nftOrder.getOrderCode());
httpData.add("showUrl", showUrl);
httpData.add("returnUrl", returnUrl);
if (preParam.getDeviceFrom().equals("micropay")) {
httpData.add("authCode", preParam.getAuthCode());
}
if (preParam.getDeviceFrom().equals("js") || preParam.getDeviceFrom().equals("applet")) {
httpData.add("openId", preParam.getOpenId());
}
// if (preParam.getPayType().equals("alipay") && preParam.getDeviceFrom().equals("wap")) {
// httpData.add("showUrl", preParam.getShowUrl() + preParam.getOrderMasterCode());
// httpData.add("returnUrl", preParam.getReturnUrl() + preParam.getOrderMasterCode());
// }
// if (preParam.getPayType().equals("douyinpay")) {
// httpData.add("showUrl", preParam.getShowUrl() + preParam.getOrderMasterCode());
// httpData.add("returnUrl", preParam.getReturnUrl() + preParam.getOrderMasterCode());
// }
// if (preParam.getPayType().equals("unionpay")) {
// httpData.add("returnUrl", preParam.getReturnUrl() + preParam.getOrderMasterCode());
// }
httpData.add("showUrl", preParam.getShowUrl() + preParam.getOrderMasterCode());
httpData.add("returnUrl", preParam.getReturnUrl() + preParam.getOrderMasterCode());
LinkedMultiValueMap<String, String> header = CollectionUtil.linkedMultiValueMapStringString(); LinkedMultiValueMap<String, String> header = CollectionUtil.linkedMultiValueMapStringString();
header.add("Accept", "application/json;charset=UTF-8"); header.add("Accept", "application/json;charset=UTF-8");
String returnData = HttpUtil.post(payUrl, httpData, header); String returnData = HttpUtil.post(payUrl, httpData, header);
log.info("调用 DRAGON 结果 = " + returnData); log.info("调用 DRAGON 结果 = " + returnData);
ResponseDto<GoblinPayInnerResultVo> dto = JsonUtils.fromJson(returnData, new TypeReference<ResponseDto<GoblinPayInnerResultVo>>() { ResponseDto<GoblinPayInnerResultVo> dto = JsonUtils.fromJson(returnData, new TypeReference<ResponseDto<GoblinPayInnerResultVo>>() {
}); });
ntfPayResultVo = GoblinNtfPayResultVo.getNew(); GoblinPayInnerResultVo dtoData = dto.getData();
ntfPayResultVo.setCode(dto.getData().getCode());
ntfPayResultVo.setOrderCode(dto.getData().getOrderCode()); payCode = dtoData.getCode();
ntfPayResultVo.setPayData(dto.getData().getPayData()); NftPayResultVo.setCode(payCode);
ntfPayResultVo.setPayType(preParam.getPayType()); NftPayResultVo.setOrderCode(dtoData.getOrderCode());
ntfPayResultVo.setPrice(preParam.getPriceActual()); NftPayResultVo.setPayData(dtoData.getPayData());
payCode = ntfPayResultVo.getCode(); NftPayResultVo.setPayType(nftOrder.getPayType());
ntfPayResultVo.setShowUrl(preParam.getShowUrl()); NftPayResultVo.setPrice(nftOrder.getPriceActual());
ntfPayResultVo.setReturnUrl(preParam.getReturnUrl()); NftPayResultVo.setShowUrl(showUrl);
} else if (preParam.getPayType() == null) { NftPayResultVo.setReturnUrl(returnUrl);
isFree = true;
preParam.setPayType("FREE");
payCode = "FREE_PAY_CODE";
ntfPayResultVo = GoblinNtfPayResultVo.getNew();
ntfPayResultVo.setPrice(BigDecimal.valueOf(0));
ntfPayResultVo.setPayType(preParam.getPayType());
} else if (preParam.getPayType().equals("huifu")) {
isFree = true;
preParam.setPayType("huifu");
payCode = "HUIFU_PAY_CODE";
ntfPayResultVo = GoblinNtfPayResultVo.getNew();
ntfPayResultVo.setPrice(preParam.getPriceActual());
ntfPayResultVo.setPayType(preParam.getPayType());
} else { } else {
isFree = true; isFree = true;
preParam.setPayType("FREE"); nftOrder.setPayType("FREE");
payCode = "FREE_PAY_CODE"; payCode = "FREE_PAY_CODE";
ntfPayResultVo = GoblinNtfPayResultVo.getNew(); NftPayResultVo.setPrice(BigDecimal.valueOf(0));
ntfPayResultVo.setPrice(BigDecimal.valueOf(0)); NftPayResultVo.setPayType(nftOrder.getPayType());
ntfPayResultVo.setPayType(preParam.getPayType());
} }
ntfPayResultVo.setOrderMasterCode(preParam.getOrderMasterCode());
LinkedList<String> sqls = CollectionUtil.linkedListString(); LinkedList<String> sqls = CollectionUtil.linkedListString();
sqls.add(SqlMapping.get("goblin.order.create.sku_insert")); sqls.add(SqlMapping.get("goblin_nft_order.insert"));
sqls.add(SqlMapping.get("goblin.order.create.order_insert"));
sqls.add(SqlMapping.get("goblin.order.create.attr_insert"));
LinkedList<Object[]> sqlDataSku = CollectionUtil.linkedListObjectArr();
LinkedList<Object[]> sqlDataOrder = CollectionUtil.linkedListObjectArr(); LinkedList<Object[]> sqlDataOrder = CollectionUtil.linkedListObjectArr();
LinkedList<Object[]> sqlDataAttr = CollectionUtil.linkedListObjectArr();
List<GoblinStoreOrderVo> orderVoList = ObjectUtil.getGoblinStoreOrderVoArrayList(); nftOrder.setPayCode(payCode);
List<GoblinOrderSkuVo> skuVoList = ObjectUtil.getGoblinOrderSkuVoArrayList();
for (GoblinOrderSqlParam item : sqlParams) {
List<String> goblinOrderSkuIdList = CollectionUtil.linkedListString();
BigDecimal restVoucherPrice = item.getStoreOrder().getPriceVoucher();
for (int i = 0; i < item.getOrderSkuList().size(); i++) {
GoblinOrderSku orderSku = item.getOrderSkuList().get(i);
if (item.getStoreOrder().getPriceVoucher().compareTo(BigDecimal.ZERO) > 0) {
if (preParam.getStoreSpuIds().size() > 0 || preParam.getPlatformSpuIds().size() > 0) {//指定范围商品券
String spuId = orderSku.getSpuId();
String pre = GoblinStatusConst.MarketPreStatus.getPre(spuId);
if (pre != null) {
spuId = spuId.split(pre)[0];
}
if (preParam.getStoreSpuIds().contains(spuId) || preParam.getPlatformSpuIds().contains(spuId)) {
if (restVoucherPrice.compareTo(BigDecimal.ZERO) <= 0) {
restVoucherPrice = BigDecimal.ZERO;
}
if (restVoucherPrice.compareTo(BigDecimal.ZERO) > 0) {
restVoucherPrice = restVoucherPrice.subtract(orderSku.getSkuPrice());
if (restVoucherPrice.compareTo(BigDecimal.ZERO) >= 0) {
orderSku.setPriceVoucher(orderSku.getSkuPrice());
} else {
orderSku.setPriceVoucher(restVoucherPrice.add(orderSku.getSkuPrice()));
}
BigDecimal skuPriceActual = orderSku.getSkuPrice().subtract(orderSku.getPriceVoucher());
orderSku.setSkuPriceActual(skuPriceActual.compareTo(BigDecimal.ZERO) > 0 ? skuPriceActual : BigDecimal.ZERO);
} else if (restVoucherPrice.compareTo(BigDecimal.ZERO) == 0) {
orderSku.setPriceVoucher(BigDecimal.ZERO);
BigDecimal skuPriceActual = orderSku.getSkuPrice().subtract(orderSku.getPriceVoucher());
orderSku.setSkuPriceActual(skuPriceActual.compareTo(BigDecimal.ZERO) > 0 ? skuPriceActual : BigDecimal.ZERO);
} else {
orderSku.setPriceVoucher(restVoucherPrice.add(orderSku.getSkuPrice()));
BigDecimal skuPriceActual = orderSku.getSkuPrice().subtract(orderSku.getPriceVoucher());
orderSku.setSkuPriceActual(skuPriceActual.compareTo(BigDecimal.ZERO) > 0 ? skuPriceActual : BigDecimal.ZERO);
}
}
} else {//全部商品券
if (restVoucherPrice.compareTo(BigDecimal.ZERO) <= 0) {
restVoucherPrice = BigDecimal.ZERO;
}
if (restVoucherPrice.compareTo(BigDecimal.ZERO) > 0) {
restVoucherPrice = restVoucherPrice.subtract(orderSku.getSkuPrice());
if (restVoucherPrice.compareTo(BigDecimal.ZERO) >= 0) {
orderSku.setPriceVoucher(orderSku.getSkuPrice());
} else {
orderSku.setPriceVoucher(restVoucherPrice.add(orderSku.getSkuPrice()));
}
BigDecimal skuPriceActual = orderSku.getSkuPrice().subtract(orderSku.getPriceVoucher());
orderSku.setSkuPriceActual(skuPriceActual.compareTo(BigDecimal.ZERO) > 0 ? skuPriceActual : BigDecimal.ZERO);
} else if (restVoucherPrice.compareTo(BigDecimal.ZERO) == 0) {
orderSku.setPriceVoucher(BigDecimal.ZERO);
BigDecimal skuPriceActual = orderSku.getSkuPrice().subtract(orderSku.getPriceVoucher());
orderSku.setSkuPriceActual(skuPriceActual.compareTo(BigDecimal.ZERO) > 0 ? skuPriceActual : BigDecimal.ZERO);
} else {
orderSku.setPriceVoucher(restVoucherPrice.add(orderSku.getSkuPrice()));
BigDecimal skuPriceActual = orderSku.getSkuPrice().subtract(orderSku.getPriceVoucher());
orderSku.setSkuPriceActual(skuPriceActual.compareTo(BigDecimal.ZERO) > 0 ? skuPriceActual : BigDecimal.ZERO);
}
}
}
sqlDataSku.add(new Object[]{
orderSku.getOrderSkuId(), orderSku.getOrderId(), orderSku.getSpuId(), orderSku.getSpuName(), orderSku.getSpuPic(), orderSku.getSkuId(), orderSku.getNum(), orderSku.getSkuPrice(), orderSku.getSkuPriceActual(), orderSku.getSkuName(),
orderSku.getSkuNo(), orderSku.getSkuImage(), orderSku.getSkuSpecs(), orderSku.getPriceVoucher(), orderSku.getCreatedAt()
});
//订单 orderSku Vo
GoblinOrderSkuVo orderSkuVo = GoblinOrderSkuVo.getNew().copy(orderSku);
redisUtils.setGoblinOrderSku(orderSkuVo.getOrderSkuId(), orderSkuVo);
goblinOrderSkuIdList.add(orderSkuVo.getOrderSkuId());
skuVoList.add(orderSkuVo);
}
GoblinStoreOrder storeOrder = item.getStoreOrder();
storeOrder.setPayCode(payCode);
sqlDataOrder.add(new Object[]{ sqlDataOrder.add(new Object[]{
storeOrder.getMasterOrderCode(), storeOrder.getOrderId(), storeOrder.getStoreId(), storeOrder.getStoreName(), storeOrder.getOrderCode(), storeOrder.getUserId(), storeOrder.getUserName(), storeOrder.getUserMobile(), storeOrder.getPriceTotal(), storeOrder.getPayCode(), nftOrder.getOrderId(), nftOrder.getStoreId(), nftOrder.getStoreName(), nftOrder.getOrderCode(), nftOrder.getUserId(), nftOrder.getUserName(), nftOrder.getUserMobile(), nftOrder.getPriceTotal(), nftOrder.getPayCode(),
storeOrder.getPriceActual(), storeOrder.getPriceRefund(), storeOrder.getPriceExpress(), storeOrder.getPriceCoupon(), storeOrder.getStorePriceCoupon(), storeOrder.getPriceVoucher(), storeOrder.getStatus(), storeOrder.getUcouponId(), storeOrder.getStoreCouponId(), storeOrder.getPayType(), storeOrder.getDeviceFrom(), nftOrder.getPriceActual(), nftOrder.getPriceCoupon(), nftOrder.getStorePriceCoupon(), nftOrder.getPriceVoucher(), nftOrder.getStatus(), nftOrder.getUcouponId(), nftOrder.getStoreCouponId(), nftOrder.getPayType(), nftOrder.getDeviceFrom(),
storeOrder.getSource(), storeOrder.getVersion(), storeOrder.getIsMember(), storeOrder.getOrderType(), storeOrder.getWriteOffCode(), storeOrder.getPayCountdownMinute(), storeOrder.getIpAddress(), storeOrder.getMarketId(), storeOrder.getMarketType(), storeOrder.getCreatedAt() nftOrder.getSource(), nftOrder.getVersion(), nftOrder.getIsMember(), nftOrder.getOrderType(), nftOrder.getPayCountdownMinute(), nftOrder.getIpAddress(), nftOrder.getCreatedAt()
});
GoblinOrderAttr orderAttr = item.getOrderAttr();
sqlDataAttr.add(new Object[]{
orderAttr.getOrderAttrId(), orderAttr.getOrderId(), orderAttr.getExpressContacts(), orderAttr.getExpressAddress(), orderAttr.getExpressAddressDetail(), orderAttr.getExpressPhone(), orderAttr.getExpressType(), orderAttr.getCreatedAt()
}); });
//订单vo
GoblinStoreOrderVo orderVo = GoblinStoreOrderVo.getNew().copy(storeOrder); // 订单vo
//订单attr vo GoblinNftOrderVo orderVo = GoblinNftOrderVo.getNew().copy(nftOrder);
GoblinOrderAttrVo orderAttrVo = GoblinOrderAttrVo.getNew().copy(orderAttr); orderVo.setCreatedAt(nftOrder.getCreatedAt());
//待支付发送队列 // 待支付发送队列
queueUtils.sendMsgByRedisGoblinStock(orderVo.getMasterOrderCode(), storeOrder.getCreatedAt()); queueUtils.sendMsgByRedisGoblinStock(orderVo.getOrderCode(), nftOrder.getCreatedAt(), "NFT");
//redis 赋值
orderVo.setOrderAttrVo(orderAttrVo); // redis 订单详情
orderVo.setOrderSkuVoIds(goblinOrderSkuIdList); nftOrderUtils.setNftOrder(orderVo);
orderVo.setCreatedAt(getNowTime()); // redis 订单列表
redisUtils.setGoblinOrder(orderVo.getOrderId(), orderVo); nftOrderUtils.addNftOrderList(uid, orderVo.getOrderId());
redisUtils.setMasterCode(orderVo.getMasterOrderCode(), preParam.getOrderIdList().substring(1));
orderVoList.add(orderVo); // mongo
goblinMongoUtils.setGoblinNftOrderVo(orderVo);
//redis 订单列表
if (orderUtils.noZhengzaiOrder(uid)) { // 执行sql
if (orderVo.getMarketType() == null) { String sqlData = SqlMapping.gets(sqls, sqlDataOrder);
redisUtils.addOrderList(uid, orderVo.getOrderId());
} else if (orderVo.getMarketType().equals(GoblinStatusConst.MarketPreStatus.MARKET_PRE_ZHENGZAI.getValue())) {
redisUtils.addZhengzaiOrderList(uid, orderVo.getOrderId());
}
}
}
mongoUtils.insertGoblinOrderSkuVoList(skuVoList);
mongoUtils.insertGoblinStoreOrderVos(orderVoList);
//mysql 执行sql
String sqlData = SqlMapping.gets(sqls, sqlDataSku, sqlDataOrder, sqlDataAttr);
queueUtils.sendMsgByRedis(MQConst.GoblinQueue.GOBLIN_ORDER_CREATE_PAY.getKey(), sqlData); queueUtils.sendMsgByRedis(MQConst.GoblinQueue.GOBLIN_ORDER_CREATE_PAY.getKey(), sqlData);
log.info(UserPathDto.setData("下单(唤起支付)", preParam, ntfPayResultVo)); log.info(UserPathDto.setData("下单(唤起支付)", nftOrder, NftPayResultVo));
if (isFree && preParam.getPayType().equals("huifu")) { if (isFree) {// 免费直接回调
// SyncOrderParam syncOrderParam = SyncOrderParam.getNew(); GoblinNftOrderPayCallbackParam NftOrderPayCallbackParam = GoblinNftOrderPayCallbackParam.getNew();
// syncOrderParam.setOrderCode(preParam.getOrderMasterCode()); NftOrderPayCallbackParam.setCode(payCode);
// syncOrderParam.setPaymentAt(DateUtil.format(LocalDateTime.now(), DateUtil.Formatter.yyyyMMddHHmmss)); NftOrderPayCallbackParam.setOrderCode(nftOrder.getOrderCode());
// syncOrderParam.setCode(payCode); NftOrderPayCallbackParam.setPaymentAt(DateUtil.format(LocalDateTime.now(), DateUtil.Formatter.yyyyMMddHHmmss));
// syncOrderParam.setPrice(preParam.getPriceActual()); NftOrderPayCallbackParam.setPrice(nftOrder.getPriceActual());
// syncOrderParam.setPaymentId("FREE_PAYMENT_ID"); NftOrderPayCallbackParam.setPaymentId("FREE_PAYMENT_ID");
// syncOrderParam.setPaymentType(null); NftOrderPayCallbackParam.setPaymentType(null);
// syncOrderParam.setStatus(1); NftOrderPayCallbackParam.setStatus(1);
// syncOrder(syncOrderParam); syncOrder(NftOrderPayCallbackParam);
return ResponseDto.success(ntfPayResultVo);
} else if (isFree) {
GoblinNtfOrderPayCallbackParam ntfOrderPayCallbackParam = GoblinNtfOrderPayCallbackParam.getNew();
ntfOrderPayCallbackParam.setOrderCode(preParam.getOrderMasterCode());
ntfOrderPayCallbackParam.setPaymentAt(DateUtil.format(LocalDateTime.now(), DateUtil.Formatter.yyyyMMddHHmmss));
ntfOrderPayCallbackParam.setCode(payCode);
ntfOrderPayCallbackParam.setPrice(preParam.getPriceActual());
ntfOrderPayCallbackParam.setPaymentId("FREE_PAYMENT_ID");
ntfOrderPayCallbackParam.setPaymentType(null);
ntfOrderPayCallbackParam.setStatus(1);
syncOrder(ntfOrderPayCallbackParam);
return ResponseDto.success(ntfPayResultVo);
} else {
return ResponseDto.success(ntfPayResultVo);
} }
return NftPayResultVo;
} }
@Override @Override
public ResponseDto<GoblinNtfPayResultVo> payAgain(GoblinNtfOrderPayAgainParam param) { public ResponseDto<GoblinNftPayResultVo> payAgain(GoblinNftOrderPayAgainParam param) {
String uid = CurrentUtil.getCurrentUid(); String uid = CurrentUtil.getCurrentUid();
LocalDateTime now = LocalDateTime.now(); LocalDateTime now = LocalDateTime.now();
//检查订单时间 是否关闭 //检查订单时间 是否关闭
GoblinStoreOrderVo storeOrderVo = redisUtils.getGoblinOrder(param.getOrderId()); GoblinStoreOrderVo storeOrderVo = goblinRedisUtils.getGoblinOrder(param.getOrderId());
if (storeOrderVo == null) { if (storeOrderVo == null) {
return ResponseDto.failure("订单不存在"); return ResponseDto.failure("订单不存在");
...@@ -660,12 +320,12 @@ public class GoblinNftOrderServiceImpl implements IGoblinNftOrderService { ...@@ -660,12 +320,12 @@ public class GoblinNftOrderServiceImpl implements IGoblinNftOrderService {
return ResponseDto.failure("订单已支付"); return ResponseDto.failure("订单已支付");
} }
BigDecimal price = BigDecimal.ZERO; BigDecimal price = BigDecimal.ZERO;
String[] orderIds = redisUtils.getMasterCode(storeOrderVo.getMasterOrderCode()); String[] orderIds = goblinRedisUtils.getMasterCode(storeOrderVo.getMasterOrderCode());
for (String orderId : orderIds) { for (String orderId : orderIds) {
GoblinStoreOrderVo orderVo = redisUtils.getGoblinOrder(orderId); GoblinStoreOrderVo orderVo = goblinRedisUtils.getGoblinOrder(orderId);
price = price.add(orderVo.getPriceActual()); price = price.add(orderVo.getPriceActual());
} }
GoblinNtfPayResultVo ntfPayResultVo = GoblinNtfPayResultVo.getNew(); GoblinNftPayResultVo NftPayResultVo = GoblinNftPayResultVo.getNew();
// if (!storeOrderVo.getPayType().equals("FREE") && storeOrderVo.getPayType().equals(param.getPayType()) && storeOrderVo.getDeviceFrom().equals(param.getDeviceFrom())) { // if (!storeOrderVo.getPayType().equals("FREE") && storeOrderVo.getPayType().equals(param.getPayType()) && storeOrderVo.getDeviceFrom().equals(param.getDeviceFrom())) {
// payInnerResultVo.setCode(checkVo.getData().getCode()); // payInnerResultVo.setCode(checkVo.getData().getCode());
// payInnerResultVo.setOrderCode(checkVo.getData().getOrderCode()); // payInnerResultVo.setOrderCode(checkVo.getData().getOrderCode());
...@@ -683,7 +343,7 @@ public class GoblinNftOrderServiceImpl implements IGoblinNftOrderService { ...@@ -683,7 +343,7 @@ public class GoblinNftOrderServiceImpl implements IGoblinNftOrderService {
LinkedMultiValueMap<String, String> httpData = CollectionUtil.linkedMultiValueMapStringString(); LinkedMultiValueMap<String, String> httpData = CollectionUtil.linkedMultiValueMapStringString();
httpData.add("type", "PRODUCT"); httpData.add("type", "PRODUCT");
httpData.add("price", price.toString()); httpData.add("price", price.toString());
httpData.add("name", redisUtils.getStoreInfoVo(storeOrderVo.getStoreId()).getStoreName()); httpData.add("name", goblinRedisUtils.getStoreInfoVo(storeOrderVo.getStoreId()).getStoreName());
httpData.add("detail", "查找最初订单"); httpData.add("detail", "查找最初订单");
httpData.add("orderCode", storeOrderVo.getMasterOrderCode()); httpData.add("orderCode", storeOrderVo.getMasterOrderCode());
// httpData.add("orderId", storeOrderVo.getOrderId()); // httpData.add("orderId", storeOrderVo.getOrderId());
...@@ -714,34 +374,33 @@ public class GoblinNftOrderServiceImpl implements IGoblinNftOrderService { ...@@ -714,34 +374,33 @@ public class GoblinNftOrderServiceImpl implements IGoblinNftOrderService {
log.debug("调用 DRAGON 结果 = " + returnData); log.debug("调用 DRAGON 结果 = " + returnData);
ResponseDto<GoblinPayInnerResultVo> dto = JsonUtils.fromJson(returnData, new TypeReference<ResponseDto<GoblinPayInnerResultVo>>() { ResponseDto<GoblinPayInnerResultVo> dto = JsonUtils.fromJson(returnData, new TypeReference<ResponseDto<GoblinPayInnerResultVo>>() {
}); });
ntfPayResultVo.setCode(dto.getData().getCode()); NftPayResultVo.setCode(dto.getData().getCode());
ntfPayResultVo.setOrderCode(storeOrderVo.getMasterOrderCode()); NftPayResultVo.setOrderCode(storeOrderVo.getMasterOrderCode());
ntfPayResultVo.setOrderMasterCode(storeOrderVo.getMasterOrderCode()); NftPayResultVo.setPayData(dto.getData().getPayData());
ntfPayResultVo.setPayData(dto.getData().getPayData()); NftPayResultVo.setOrderId(storeOrderVo.getMasterOrderCode());
ntfPayResultVo.setOrderId(storeOrderVo.getMasterOrderCode()); NftPayResultVo.setPayType(param.getPayType());
ntfPayResultVo.setPayType(param.getPayType()); NftPayResultVo.setPrice(price);
ntfPayResultVo.setPrice(price); NftPayResultVo.setShowUrl(param.getShowUrl() + storeOrderVo.getMasterOrderCode());
ntfPayResultVo.setShowUrl(param.getShowUrl() + storeOrderVo.getMasterOrderCode()); NftPayResultVo.setReturnUrl(param.getReturnUrl() + storeOrderVo.getMasterOrderCode());
ntfPayResultVo.setReturnUrl(param.getReturnUrl() + storeOrderVo.getMasterOrderCode());
//redis //redis
storeOrderVo.setPayType(param.getPayType()); storeOrderVo.setPayType(param.getPayType());
storeOrderVo.setDeviceFrom(param.getDeviceFrom()); storeOrderVo.setDeviceFrom(param.getDeviceFrom());
storeOrderVo.setPayCode(ntfPayResultVo.getCode()); storeOrderVo.setPayCode(NftPayResultVo.getCode());
redisUtils.setGoblinOrder(storeOrderVo.getOrderId(), storeOrderVo); goblinRedisUtils.setGoblinOrder(storeOrderVo.getOrderId(), storeOrderVo);
//mongo //mongo
mongoUtils.updateGoblinStoreOrderVo(storeOrderVo.getOrderId(), storeOrderVo); goblinMongoUtils.updateGoblinStoreOrderVo(storeOrderVo.getOrderId(), storeOrderVo);
//mysql //mysql
queueUtils.sendMsgByRedis(MQConst.GoblinQueue.GOBLIN_ORDER_AGAIN.getKey(), queueUtils.sendMsgByRedis(MQConst.GoblinQueue.GOBLIN_ORDER_AGAIN.getKey(),
SqlMapping.get("goblin_order.pay.again", param.getPayType(), param.getDeviceFrom(), ntfPayResultVo.getCode(), param.getOrderId(), now, now)); SqlMapping.get("goblin_order.pay.again", param.getPayType(), param.getDeviceFrom(), NftPayResultVo.getCode(), param.getOrderId(), now, now));
log.info(UserPathDto.setData("再次支付[新支付方式]", param, ntfPayResultVo)); log.info(UserPathDto.setData("再次支付[新支付方式]", param, NftPayResultVo));
} }
return ResponseDto.success(ntfPayResultVo); return ResponseDto.success(NftPayResultVo);
} }
@Override @Override
public ResponseDto<Integer> checkOrderResult(String orderId) { public ResponseDto<Integer> checkOrderResult(String orderId) {
String uid = CurrentUtil.getCurrentUid(); String uid = CurrentUtil.getCurrentUid();
GoblinStoreOrderVo storeOrderVo = redisUtils.getGoblinOrder(orderId); GoblinStoreOrderVo storeOrderVo = goblinRedisUtils.getGoblinOrder(orderId);
if (storeOrderVo == null) { if (storeOrderVo == null) {
return ResponseDto.failure("订单不存在"); return ResponseDto.failure("订单不存在");
} else { } else {
...@@ -749,7 +408,7 @@ public class GoblinNftOrderServiceImpl implements IGoblinNftOrderService { ...@@ -749,7 +408,7 @@ public class GoblinNftOrderServiceImpl implements IGoblinNftOrderService {
return null; return null;
} }
String returnCheckData = HttpUtil.get(checkUrl + "?code=" + storeOrderVo.getPayCode(), null); String returnCheckData = HttpUtil.get(checkUrl + "?code=" + storeOrderVo.getPayCode(), null);
ResponseDto<GoblinNtfOrderPayCallbackParam> syncOrderDtoParam = JsonUtils.fromJson(returnCheckData, new TypeReference<ResponseDto<GoblinNtfOrderPayCallbackParam>>() { ResponseDto<GoblinNftOrderPayCallbackParam> syncOrderDtoParam = JsonUtils.fromJson(returnCheckData, new TypeReference<ResponseDto<GoblinNftOrderPayCallbackParam>>() {
}); });
if (syncOrderDtoParam.getData().getStatus() == 1) { if (syncOrderDtoParam.getData().getStatus() == 1) {
//处理订单 //处理订单
...@@ -762,148 +421,82 @@ public class GoblinNftOrderServiceImpl implements IGoblinNftOrderService { ...@@ -762,148 +421,82 @@ public class GoblinNftOrderServiceImpl implements IGoblinNftOrderService {
} }
@Override @Override
public String syncOrder(GoblinNtfOrderPayCallbackParam syncOrderParam) { public String syncOrder(GoblinNftOrderPayCallbackParam syncOrderParam) {
log.debug("SYNC PARAM = " + syncOrderParam.toString()); log.info("SYNC PARAM = " + syncOrderParam.toString());
//支付时间
LocalDateTime now = LocalDateTime.now(); String orderCode = syncOrderParam.getOrderCode();
String[] array = redisUtils.getMasterCode(syncOrderParam.getOrderCode()); String orderId = syncOrderParam.getOrderId();
String uid;
BigDecimal priceActual = BigDecimal.ZERO; GoblinNftOrderVo orderVo = nftOrderUtils.getNftOrder(orderId);
for (String orderId : array) { if (null == orderVo) {
GoblinStoreOrderVo orderVo = redisUtils.getGoblinOrder(orderId); log.error("Nft订单不存在 param:[orderCode:{}]", orderCode);
if (orderVo == null) { return "fail";
log.error("订单号:" + syncOrderParam.getOrderCode() + " 订单不存在"); }
return "fail";//订单不存在
}
if (orderVo.getStatus() == GoblinStatusConst.Status.ORDER_STATUS_2.getValue()) {
if (orderVo.getPayCode().equals(syncOrderParam.getCode())) { if (orderVo.getPayCode().equals(syncOrderParam.getCode())) {
log.error("订单号:" + syncOrderParam.getOrderCode() + " 重复支付"); log.error("Nft订单payCode不匹配 param:[orderCode:{}, payCode:{}]", orderCode, syncOrderParam.getCode());
return "fail";//重复支付 return "fail";
} }
if (!Objects.equals(orderVo.getStatus(), GoblinStatusConst.NftStatus.ORDER_STATUS_2.getValue())) {
log.error("Nft订单当前状态不能支付回调 param:[orderCode:{}, status:{}]", orderCode, orderVo.getStatus());
return "fail";
} }
// if (orderVo.getPriceActual().compareTo(syncOrderParam.getPrice()) != 0) {
// log.error("订单号:" + syncOrderParam.getOrderCode() + " 价格不符"); if (Objects.equals(1, syncOrderParam.getStatus())) {// 超时支付
// return "fail";//价格不符 if (Objects.equals(orderVo.getStatus(), GoblinStatusConst.NftStatus.ORDER_STATUS_3.getValue())) {
// } log.error("Nft订单超时支付 param:[orderCode:{}]", orderCode);
priceActual = priceActual.add(orderVo.getPriceActual()); // 退款
uid = orderVo.getUserId(); nftOrderUtils.refundOrderSku(orderId, syncOrderParam.getPaymentId(), syncOrderParam.getPaymentType());
} else if (syncOrderParam.getStatus().equals(1)) {// 正常流程
LocalDateTime now = LocalDateTime.now();
String uid = orderVo.getUserId();
GoblinNftOrder nftOrder = GoblinNftOrder.getNew();
nftOrder.setPaymentType(syncOrderParam.getPaymentType());
nftOrder.setPaymentId(syncOrderParam.getPaymentId());
nftOrder.setPayCode(syncOrderParam.getCode());
LocalDateTime payTime = LocalDateTime.parse(syncOrderParam.getPaymentAt(), DTF_YMD_HMS);
nftOrder.setPayTime(payTime);
nftOrder.setStatus(GoblinStatusConst.NftStatus.ORDER_STATUS_2.getValue());
nftOrder.setUpdatedAt(now);
LinkedList<String> sqls = CollectionUtil.linkedListString(); LinkedList<String> sqls = CollectionUtil.linkedListString();
LinkedList<Object[]> sqlDataOrder = CollectionUtil.linkedListObjectArr(); LinkedList<Object[]> sqlDataOrder = CollectionUtil.linkedListObjectArr();
LinkedList<Object[]> sqlDataSku = CollectionUtil.linkedListObjectArr(); sqls.add(SqlMapping.get("goblin_nft_order.update.pay"));
GoblinStoreOrder storeOrder = GoblinStoreOrder.getNew();
if (orderVo.getStatus() == GoblinStatusConst.Status.ORDER_STATUS_5.getValue() && syncOrderParam.getStatus().equals(1)) {
log.error("订单号为 {} 的订单超时支付", syncOrderParam.getOrderCode());
// 商铺退款逻辑
orderUtils.refundOrderSku(orderId, syncOrderParam.getPaymentId(), syncOrderParam.getPaymentType());
// orderVo.setStatus(GoblinStatusConst.OrderStatus.ORDER_STATUS_61.getValue());
// redisUtils.setGoblinOrder(orderVo.getOrderId(),orderVo);
} else if ((orderVo.getStatus() == GoblinStatusConst.Status.ORDER_STATUS_6.getValue() || orderVo.getStatus() == GoblinStatusConst.Status.ORDER_STATUS_7.getValue()) && syncOrderParam.getStatus().equals(1)) {
log.error("订单号为 {} 的订单正在退款 或者已退款", syncOrderParam.getOrderCode());
} else if (syncOrderParam.getStatus().equals(1)) {
log.error("订单号为 {} 的订单正常流程", syncOrderParam.getOrderCode());
storeOrder.setPaymentType(syncOrderParam.getPaymentType());
storeOrder.setPaymentId(syncOrderParam.getPaymentId());
storeOrder.setPayCode(syncOrderParam.getCode());
LocalDateTime payTime = LocalDateTime.parse(syncOrderParam.getPaymentAt(), DTF_YMD_HMS);
storeOrder.setPayTime(payTime);
if (orderVo.getWriteOffCode().equals("EMPTY")) {
storeOrder.setWriteOffCode(IDGenerator.getWriteOffCode());
} else {
storeOrder.setWriteOffCode("");
}
storeOrder.setStatus(GoblinStatusConst.Status.ORDER_STATUS_2.getValue());
storeOrder.setUpdatedAt(now);
sqls.add(SqlMapping.get("goblin_order.pay.order"));
sqlDataOrder.add(new Object[]{ sqlDataOrder.add(new Object[]{
storeOrder.getPaymentType(), storeOrder.getPaymentId(), storeOrder.getPayCode(), storeOrder.getPayTime(), storeOrder.getWriteOffCode(), storeOrder.getStatus(), storeOrder.getUpdatedAt(), nftOrder.getPaymentType(), nftOrder.getPaymentId(), nftOrder.getPayCode(),
nftOrder.getPayTime(), nftOrder.getStatus(), nftOrder.getUpdatedAt(),
orderId, now, now orderId, now, now
}); });
sqls.add(SqlMapping.get("goblin_order.pay.sku"));
List<String> skuList = orderVo.getOrderSkuVoIds(); // redis
for (String orderSkuVoIds : skuList) { orderVo.setStatus(GoblinStatusConst.NftStatus.ORDER_STATUS_2.getValue());
GoblinOrderSkuVo orderSkuVo = redisUtils.getGoblinOrderSkuVo(orderSkuVoIds); orderVo.setPayCode(syncOrderParam.getCode());
//增加销量 DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
log.debug("增加销量 spuId=" + orderSkuVo.getSpuId() + ",skuId=" + orderSkuVo.getSkuId()); LocalDateTime parsedDate = LocalDateTime.parse(syncOrderParam.getPaymentAt(), formatter);
redisUtils.incrSkuSaleCount(orderSkuVo.getSpuId(), orderSkuVo.getSkuId(), orderSkuVo.getNum()); orderVo.setPayTime(parsedDate);
orderSkuVo.setStatus(GoblinStatusConst.Status.ORDER_STATUS_2.getValue());
//redis
redisUtils.setGoblinOrderSku(orderSkuVo.getOrderSkuId(), orderSkuVo);
//mongo
mongoUtils.updateGoblinOrderSkuVo(orderSkuVo.getOrderSkuId(), orderSkuVo);
//mongo 添加操作日志
GoblinOrderLogVo logVo = GoblinOrderLogVo.getNew();
logVo.setOrderId(orderVo.getOrderId());
logVo.setOrderCode(orderVo.getOrderCode());
logVo.setPayCode(orderVo.getPayCode());
logVo.setStoreId(orderVo.getStoreId());
if (orderSkuVo.getSkuId().indexOf(GoblinStatusConst.MarketPreStatus.MARKET_PRE_ZHENGZAI.getValue()) > 0) {
logVo.setOrderType("zhengzai");
} else {
logVo.setOrderType("order");
}
logVo.setSpuId(orderSkuVo.getSpuId());
logVo.setSkuId(orderSkuVo.getSkuId());
logVo.setSkuPriceActual(orderSkuVo.getSkuPriceActual().multiply(new BigDecimal(100)).longValue());
logVo.setStatus(GoblinStatusConst.Status.ORDER_LOG_STATUS_11.getValue());
logVo.setRemark(GoblinStatusConst.Status.ORDER_LOG_STATUS_11.getDesc());
logVo.setOperationId(uid);
logVo.setOperationName(orderVo.getUserName());
logVo.setOperationType(GoblinStatusConst.Type.OPERATION_TYPE_1.getValue());
logVo.setCreatedAt(LocalDateTime.now());
mongoUtils.insertGoblinOrderLogVo(logVo);
//mysql
sqlDataSku.add(new Object[]{
GoblinStatusConst.Status.ORDER_STATUS_2.getValue(), now,
orderSkuVo.getOrderSkuId(), now, now
});
}
//redis
orderVo.setPayCode(storeOrder.getPayCode());
orderVo.setPayTime(syncOrderParam.getPaymentAt());
orderVo.setWriteOffCode(storeOrder.getWriteOffCode());
orderVo.setStatus(storeOrder.getStatus());
orderVo.setPaymentId(syncOrderParam.getPaymentId()); orderVo.setPaymentId(syncOrderParam.getPaymentId());
orderVo.setPaymentType(syncOrderParam.getPaymentType()); orderVo.setPaymentType(syncOrderParam.getPaymentType());
orderVo.setOrderSkuVoIds(skuList); nftOrderUtils.setNftOrder(orderVo);
redisUtils.setGoblinOrder(orderId, orderVo); // mongo
redisUtils.setOffCode(orderVo.getWriteOffCode(), orderVo.getMasterOrderCode()); goblinMongoUtils.updateGoblinNftOrderVo(orderVo);
//mongo // mysql
mongoUtils.updateGoblinStoreOrderVo(orderId, orderVo);
//mysql
queueUtils.sendMsgByRedis(MQConst.GoblinQueue.GOBLIN_ORDER_CREATE_PAY.getKey(), queueUtils.sendMsgByRedis(MQConst.GoblinQueue.GOBLIN_ORDER_CREATE_PAY.getKey(),
SqlMapping.gets(sqls, sqlDataOrder, sqlDataSku)); SqlMapping.gets(sqls, sqlDataOrder));
}
//发短信 // 加积分
// SmsEnum.ADTemplate adTemplate = null; goblinOrderUtils.doTask(uid, orderVo.getPriceActual());
// if (orderTicketData.getGetTicketType().equals("express")) {
// adTemplate = SmsEnum.ADTemplate.SMS_225995308;
// } else if (orderTicketData.getGetTicketType().equals("electronic")) {
// adTemplate = ticketData.getIsShowCode() == 1 ? SmsEnum.ADTemplate.SMS_225995308 : SmsEnum.ADTemplate.SMS_225995308;
// }
//
// if (null != adTemplate) {
// queueUtils.sendMsgByRedis(MQConst.KylinQueue.SMS_NOTICE.getKey(),
// SmsMessage.builder().setPhone(orderTicketData.getUserMobile())
// .setSignName(SmsEnum.ADSignName.M02.getVal())
// .setTemplateCode(adTemplate.name())
// .setTemplateParam("name", orderTicketData.getPerformanceTitle())
// .setTemplateParam("time", time1 + " " + time2).toJson()
// );
// }
//加分
if (orderUtils.noZhengzaiOrder(uid)) {
orderUtils.doTask(uid, priceActual);
} }
} }
return "success"; return "success";
} }
@Override @Override
public String refundSyncOrder(GoblinNtfOrderRefundCallbackParam refundCallbackParam) { public String refundSyncOrder(GoblinNftOrderRefundCallbackParam refundCallbackParam) {
LocalDateTime now = LocalDateTime.now(); LocalDateTime now = LocalDateTime.now();
String nowStr = DateUtil.getNowTime(); String nowStr = DateUtil.getNowTime();
log.info("refundCallback订单退款回调参数: [RefundCallbackParam={}]", refundCallbackParam); log.info("refundCallback订单退款回调参数: [RefundCallbackParam={}]", refundCallbackParam);
GoblinBackOrderVo backOrderVo = mongoUtils.getGoblinBackOrderVoByBackCode(refundCallbackParam.getOrderRefundCode()); GoblinBackOrderVo backOrderVo = goblinMongoUtils.getGoblinBackOrderVoByBackCode(refundCallbackParam.getOrderRefundCode());
if (backOrderVo == null) { if (backOrderVo == null) {
log.info("refundCallback: 退款订单查询失败,编号{}", refundCallbackParam.getOrderRefundCode()); log.info("refundCallback: 退款订单查询失败,编号{}", refundCallbackParam.getOrderRefundCode());
return "fail"; return "fail";
...@@ -927,13 +520,13 @@ public class GoblinNftOrderServiceImpl implements IGoblinNftOrderService { ...@@ -927,13 +520,13 @@ public class GoblinNftOrderServiceImpl implements IGoblinNftOrderService {
sqls.add(SqlMapping.get("goblin_order.store.refundBackOrder")); sqls.add(SqlMapping.get("goblin_order.store.refundBackOrder"));
String orderId = backOrderVo.getOrderId(); String orderId = backOrderVo.getOrderId();
List<GoblinBackOrderSkuVo> backOrderSkuVos = backOrderVo.getBackOrderSkuVos(); List<GoblinBackOrderSkuVo> backOrderSkuVos = backOrderVo.getBackOrderSkuVos();
GoblinStoreOrderVo orderVo = redisUtils.getGoblinOrder(orderId); GoblinStoreOrderVo orderVo = goblinRedisUtils.getGoblinOrder(orderId);
orderVo.setPriceRefund(orderVo.getPriceRefund() == null ? BigDecimal.ZERO : orderVo.getPriceRefund().add(refundCallbackParam.getRefundPrice())); orderVo.setPriceRefund(orderVo.getPriceRefund() == null ? BigDecimal.ZERO : orderVo.getPriceRefund().add(refundCallbackParam.getRefundPrice()));
if (orderVo.getPriceRefund().compareTo(orderVo.getPriceActual()) >= 0) { if (orderVo.getPriceRefund().compareTo(orderVo.getPriceActual()) >= 0) {
//整单退款 退券 //整单退款 退券
orderVo.setStatus(GoblinStatusConst.Status.ORDER_STATUS_6.getValue()); orderVo.setStatus(GoblinStatusConst.Status.ORDER_STATUS_6.getValue());
if (!(orderVo.getUcouponId() == null || orderVo.getUcouponId().equals(""))) { if (!(orderVo.getUcouponId() == null || orderVo.getUcouponId().equals(""))) {
orderUtils.backCoupon(orderVo.getUcouponId(), orderVo.getUserId()); goblinOrderUtils.backCoupon(orderVo.getUcouponId(), orderVo.getUserId());
} }
if (!(orderVo.getStoreCouponId() == null || orderVo.getStoreCouponId().equals(""))) { if (!(orderVo.getStoreCouponId() == null || orderVo.getStoreCouponId().equals(""))) {
...@@ -942,24 +535,24 @@ public class GoblinNftOrderServiceImpl implements IGoblinNftOrderService { ...@@ -942,24 +535,24 @@ public class GoblinNftOrderServiceImpl implements IGoblinNftOrderService {
backCouponParam.setuCouponIds(orderVo.getStoreCouponId()); backCouponParam.setuCouponIds(orderVo.getStoreCouponId());
backCouponParam.setUid(orderVo.getUserId()); backCouponParam.setUid(orderVo.getUserId());
params.add(backCouponParam); params.add(backCouponParam);
orderUtils.backStoreCoupon(params); goblinOrderUtils.backStoreCoupon(params);
} }
} }
backOrderVo.setStatus(GoblinStatusConst.Status.ORDER_BACK_STATUS_2.getValue()); backOrderVo.setStatus(GoblinStatusConst.Status.ORDER_BACK_STATUS_2.getValue());
backOrderVo.setRefundAt(nowStr); backOrderVo.setRefundAt(nowStr);
for (GoblinBackOrderSkuVo backOrderSkuVo : backOrderSkuVos) { for (GoblinBackOrderSkuVo backOrderSkuVo : backOrderSkuVos) {
GoblinOrderSkuVo orderSkuVo = redisUtils.getGoblinOrderSkuVo(backOrderSkuVo.getOrderSkuId()); GoblinOrderSkuVo orderSkuVo = goblinRedisUtils.getGoblinOrderSkuVo(backOrderSkuVo.getOrderSkuId());
BigDecimal refundSkuPrice = backOrderSkuVo.getRefundPrice(); BigDecimal refundSkuPrice = backOrderSkuVo.getRefundPrice();
orderSkuVo.setPriceRefund(orderSkuVo.getPriceRefund() == null ? refundSkuPrice : orderSkuVo.getPriceRefund().add(refundSkuPrice)); orderSkuVo.setPriceRefund(orderSkuVo.getPriceRefund() == null ? refundSkuPrice : orderSkuVo.getPriceRefund().add(refundSkuPrice));
if (orderSkuVo.getPriceRefund().compareTo(orderSkuVo.getSkuPriceActual()) >= 0) { if (orderSkuVo.getPriceRefund().compareTo(orderSkuVo.getSkuPriceActual()) >= 0) {
orderSkuVo.setStatus(GoblinStatusConst.Status.ORDER_STATUS_6.getValue()); orderSkuVo.setStatus(GoblinStatusConst.Status.ORDER_STATUS_6.getValue());
String pre = GoblinStatusConst.MarketPreStatus.getPre(orderSkuVo.getSkuId()); String pre = GoblinStatusConst.MarketPreStatus.getPre(orderSkuVo.getSkuId());
String skuId = orderSkuVo.getSkuId(); String skuId = orderSkuVo.getSkuId();
redisUtils.incrSkuStock(pre, skuId, orderSkuVo.getNum()); goblinRedisUtils.incrSkuStock(pre, skuId, orderSkuVo.getNum());
redisUtils.decrSkuCountByUid(orderVo.getUserId(), skuId, orderSkuVo.getNum()); goblinRedisUtils.decrSkuCountByUid(orderVo.getUserId(), skuId, orderSkuVo.getNum());
} }
redisUtils.setGoblinOrderSku(backOrderSkuVo.getOrderSkuId(), orderSkuVo); goblinRedisUtils.setGoblinOrderSku(backOrderSkuVo.getOrderSkuId(), orderSkuVo);
mongoUtils.updateGoblinOrderSkuVo(backOrderSkuVo.getOrderSkuId(), orderSkuVo); goblinMongoUtils.updateGoblinOrderSkuVo(backOrderSkuVo.getOrderSkuId(), orderSkuVo);
sqlsOrderSku.add(new Object[]{ sqlsOrderSku.add(new Object[]{
orderSkuVo.getPriceRefund(), orderSkuVo.getStatus(), now, orderSkuVo.getPriceRefund(), orderSkuVo.getStatus(), now,
backOrderSkuVo.getOrderSkuId(), now, now backOrderSkuVo.getOrderSkuId(), now, now
...@@ -986,14 +579,14 @@ public class GoblinNftOrderServiceImpl implements IGoblinNftOrderService { ...@@ -986,14 +579,14 @@ public class GoblinNftOrderServiceImpl implements IGoblinNftOrderService {
logVo.setOperationId(backOrderVo.getUserId()); logVo.setOperationId(backOrderVo.getUserId());
logVo.setOperationType(GoblinStatusConst.Type.OPERATION_TYPE_2.getValue()); logVo.setOperationType(GoblinStatusConst.Type.OPERATION_TYPE_2.getValue());
logVo.setCreatedAt(now); logVo.setCreatedAt(now);
mongoUtils.insertGoblinOrderLogVo(logVo); goblinMongoUtils.insertGoblinOrderLogVo(logVo);
} }
//redis //redis
redisUtils.setGoblinOrder(orderId, orderVo); goblinRedisUtils.setGoblinOrder(orderId, orderVo);
redisUtils.setBackOrderVo(backOrderVo.getBackOrderId(), backOrderVo); goblinRedisUtils.setBackOrderVo(backOrderVo.getBackOrderId(), backOrderVo);
//mongo //mongo
mongoUtils.updateGoblinStoreOrderVo(orderId, orderVo); goblinMongoUtils.updateGoblinStoreOrderVo(orderId, orderVo);
mongoUtils.updateGoblinBackOrderVo(backOrderVo.getBackOrderId(), backOrderVo); goblinMongoUtils.updateGoblinBackOrderVo(backOrderVo.getBackOrderId(), backOrderVo);
//mysql //mysql
sqlsOrder.add(new Object[]{ sqlsOrder.add(new Object[]{
orderVo.getPriceRefund(), orderVo.getStatus(), now, orderVo.getPriceRefund(), orderVo.getStatus(), now,
...@@ -1005,7 +598,7 @@ public class GoblinNftOrderServiceImpl implements IGoblinNftOrderService { ...@@ -1005,7 +598,7 @@ public class GoblinNftOrderServiceImpl implements IGoblinNftOrderService {
queueUtils.sendMsgByRedis(MQConst.GoblinQueue.GOBLIN_STORE_ORDER_OPERA.getKey(), queueUtils.sendMsgByRedis(MQConst.GoblinQueue.GOBLIN_STORE_ORDER_OPERA.getKey(),
SqlMapping.gets(sqls, sqlsOrder, sqlsOrderSku, sqlsBackOrder)); SqlMapping.gets(sqls, sqlsOrder, sqlsOrderSku, sqlsBackOrder));
//减积分 //减积分
orderUtils.desTask(orderVo.getUserId(), backOrderVo.getRealBackPrice()); goblinOrderUtils.desTask(orderVo.getUserId(), backOrderVo.getRealBackPrice());
} else if (0 == status) { } else if (0 == status) {
return "fail"; return "fail";
} }
......
package com.liquidnet.service.order.utils; package com.liquidnet.service.order.utils;
import com.liquidnet.commons.lang.util.CollectionUtil;
import com.liquidnet.commons.lang.util.DateUtil;
import com.liquidnet.service.base.PagedResult;
import com.liquidnet.service.goblin.constant.GoblinStatusConst;
import com.liquidnet.service.goblin.dto.manage.GoblinStoreMgtCouponFilterParam;
import com.liquidnet.service.goblin.dto.manage.GoblinStoreMgtGoodsFilterParam;
import com.liquidnet.service.goblin.dto.manage.GoblinStoreMgtNoticeFilterParam;
import com.liquidnet.service.goblin.dto.manage.vo.GoblinMgtCategorySpecVo;
import com.liquidnet.service.goblin.dto.manage.vo.GoblinStoreMgtCouponListVo;
import com.liquidnet.service.goblin.dto.manage.vo.GoblinStoreMgtGoodsListVo;
import com.liquidnet.service.goblin.dto.vo.*; import com.liquidnet.service.goblin.dto.vo.*;
import com.liquidnet.service.goblin.entity.GoblinFrontBanner;
import com.liquidnet.service.goblin.entity.GoblinFrontHotWord;
import com.liquidnet.service.goblin.entity.GoblinFrontNavigation;
import com.mongodb.BasicDBObject; import com.mongodb.BasicDBObject;
import com.mongodb.bulk.BulkWriteResult;
import com.mongodb.client.model.UpdateOneModel;
import com.mongodb.client.model.WriteModel;
import com.mongodb.client.result.DeleteResult;
import com.mongodb.client.result.UpdateResult; import com.mongodb.client.result.UpdateResult;
import org.apache.commons.lang3.StringUtils;
import org.bson.Document;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.mongodb.core.BulkOperations;
import org.springframework.data.mongodb.core.MongoTemplate; import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.aggregation.Aggregation;
import org.springframework.data.mongodb.core.aggregation.AggregationResults;
import org.springframework.data.mongodb.core.convert.MongoConverter; import org.springframework.data.mongodb.core.convert.MongoConverter;
import org.springframework.data.mongodb.core.query.Criteria; import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query; import org.springframework.data.mongodb.core.query.Query;
import org.springframework.data.mongodb.core.query.Update;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
@Component @Component
public class GoblinMongoUtils { public class GoblinMongoUtils {
...@@ -140,4 +107,22 @@ public class GoblinMongoUtils { ...@@ -140,4 +107,22 @@ public class GoblinMongoUtils {
return mongoTemplate.insert(vo, GoblinBackOrderVo.class.getSimpleName()); return mongoTemplate.insert(vo, GoblinBackOrderVo.class.getSimpleName());
} }
/* --------------------------------NFT--------------------------------- */
// 订单详情vo
public void setGoblinNftOrderVo(GoblinNftOrderVo vo) {
mongoTemplate.insert(vo, GoblinNftOrderVo.class.getSimpleName());
}
public UpdateResult updateGoblinNftOrderVo(GoblinNftOrderVo data) {
BasicDBObject object = ObjectUtil.cloneBasicDBObject().append("$set", mongoConverter.convertToMongoType(data));
return mongoTemplate.getCollection(GoblinNftOrderVo.class.getSimpleName()).updateOne(
Query.query(Criteria.where("orderId").is(data.getOrderId())).getQueryObject(),
object);
}
//添加 订单退款数据
public GoblinNftOrderCallBackVo insertGoblinNftOrderRefundVo(GoblinNftOrderCallBackVo vo) {
return mongoTemplate.insert(vo, GoblinNftOrderCallBackVo.class.getSimpleName());
}
} }
package com.liquidnet.service.order.utils; package com.liquidnet.service.order.utils;
import com.alibaba.fastjson.JSON;
import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.core.type.TypeReference;
import com.liquidnet.common.cache.redis.util.RedisUtil;
import com.liquidnet.commons.lang.util.*; import com.liquidnet.commons.lang.util.*;
import com.liquidnet.service.base.ErrorMapping;
import com.liquidnet.service.base.ResponseDto; import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.base.SqlMapping; import com.liquidnet.service.base.SqlMapping;
import com.liquidnet.service.base.constant.MQConst; import com.liquidnet.service.base.constant.MQConst;
import com.liquidnet.service.candy.param.BackCouponParam;
import com.liquidnet.service.candy.vo.CandyUseResultVo; import com.liquidnet.service.candy.vo.CandyUseResultVo;
import com.liquidnet.service.goblin.constant.GoblinRedisConst;
import com.liquidnet.service.goblin.constant.GoblinStatusConst; import com.liquidnet.service.goblin.constant.GoblinStatusConst;
import com.liquidnet.service.goblin.dto.vo.*; import com.liquidnet.service.goblin.dto.vo.GoblinNftOrderCallBackVo;
import com.liquidnet.service.goblin.entity.GoblinBackOrder; import com.liquidnet.service.goblin.dto.vo.GoblinNftOrderVo;
import com.liquidnet.service.goblin.entity.GoblinBackOrderLog; import com.liquidnet.service.goblin.dto.vo.GoblinUseResultVo;
import com.liquidnet.service.goblin.entity.GoblinOrderSku; import com.liquidnet.service.goblin.dto.vo.GoblinUserCouponVo;
import com.liquidnet.service.goblin.entity.GoblinNftOrderRefund;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
...@@ -22,13 +22,13 @@ import org.springframework.util.MultiValueMap; ...@@ -22,13 +22,13 @@ import org.springframework.util.MultiValueMap;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Objects;
@Component @Component
@Slf4j @Slf4j
public class GoblinNtfOrderUtils { public class GoblinNftOrderUtils {
@Value("${liquidnet.service.adam.url}") @Value("${liquidnet.service.adam.url}")
private String adamUrl; private String adamUrl;
...@@ -42,49 +42,95 @@ public class GoblinNtfOrderUtils { ...@@ -42,49 +42,95 @@ public class GoblinNtfOrderUtils {
private String refundApply; private String refundApply;
@Autowired @Autowired
QueueUtils queueUtils; private QueueUtils queueUtils;
@Autowired @Autowired
GoblinRedisUtils redisUtils; private GoblinRedisUtils goblinRedisUtils;
@Autowired @Autowired
GoblinMongoUtils goblinMongoUtils; private RedisUtil redisUtil;
@Autowired
private GoblinMongoUtils goblinMongoUtils;
@Autowired
private GoblinOrderUtils goblinOrderUtils;
// 库存
public int decrSkuStock(String skuId, Integer stock) {
String redisKey = GoblinRedisConst.REAL_STOCK_SKU.concat(skuId);
return (int) redisUtil.decr(redisKey, stock);
}
//判断 数量限购 public int incrSkuStock(String skuId, Integer stock) {
public String judgeOrderLimit(String uid, String skuId, int number, int limitCount) { String redisKey = GoblinRedisConst.REAL_STOCK_SKU.concat(skuId);
int buyCount = redisUtils.incrSkuCountByUid(uid, skuId, number); return (int) redisUtil.incr(redisKey, stock);
if (buyCount > limitCount) { }
// redisUtils.decrSkuCountByUid(uid, skuId, number);
return "已超出限购数量"; // 是否是会员
public boolean isVipMember(String uid) {
Integer member = goblinRedisUtils.getMember(uid);
if (null == member) {
return false;
} else { } else {
return ""; return true;
} }
} }
//判断指定人群购买 // 订单详情vo
public Boolean judgeOrderRose(Boolean isMember, String skuId, String mobile, int buyFactor) { public void setNftOrder(GoblinNftOrderVo vo) {
Boolean result = false; String redisKey = GoblinRedisConst.REDIS_GOBLIN_NFT_ORDER_INFO.concat(vo.getOrderId());
switch (buyFactor) { redisUtil.set(redisKey, vo);
case 0: }
result = true;
break; // 获取 订单详情vo
case 1: public GoblinNftOrderVo getNftOrder(String orderId) {
result = isMember; String redisKey = GoblinRedisConst.REDIS_GOBLIN_NFT_ORDER_INFO.concat(orderId);
break; Object obj = redisUtil.get(redisKey);
case 2: if (obj == null) {
result = redisUtils.getSkuCanBuyByUid(mobile, skuId); return null;
break; } else {
return (GoblinNftOrderVo) obj;
}
}
// 添加 订单id列表
public void addNftOrderList(String uid, String orderId) {
String redisKey = GoblinRedisConst.REDIS_GOBLIN_NFT_ORDER_USER_ID_LIST.concat(uid);
List<String> list = getNftOrderList(uid);
if (list.size() >= 40) {
list.remove(0);
list.add(orderId);
} else {
list.add(orderId);
} }
return result; redisUtil.set(redisKey, list);
}
// 获取 订单id列表
public List<String> getNftOrderList(String uid) {
String redisKey = GoblinRedisConst.REDIS_GOBLIN_NFT_ORDER_USER_ID_LIST.concat(uid);
Object obj = redisUtil.get(redisKey);
if (obj == null) {
return CollectionUtil.arrayListString();
} else {
return (List<String>) obj;
}
}
// 退款订单vo
public void setBackOrderVo(GoblinNftOrderCallBackVo vo) {
String redisKey = GoblinRedisConst.REDIS_GOBLIN_NFT_ORDER_REFUND_INFO.concat(vo.getOrderRefundId());
redisUtil.set(redisKey, vo);
} }
/** /**
* 使用优惠券 * 使用平台优惠券
* *
* @param uCouponId 券id * @param uCouponId 券id
* @param content 消费内容 * @param content 消费内容
* @param totalPrice 订单总价 * @param totalPrice 订单总价
* @param spuId spuId
* @param uid uid
* @return * @return
*/ */
public HashMap<String, Object> useCoupon(String uCouponId, String content, BigDecimal totalPrice, String spuId, String uid, List<GoblinOrderSku> goblinOrderSkuList) { public HashMap<String, Object> useCoupon(String uCouponId, String content, BigDecimal totalPrice, String spuId, String uid) {
HashMap<String, Object> hashMap = CollectionUtil.mapStringObject(); HashMap<String, Object> hashMap = CollectionUtil.mapStringObject();
try { try {
MultiValueMap<String, String> params = CollectionUtil.linkedMultiValueMapStringString(); MultiValueMap<String, String> params = CollectionUtil.linkedMultiValueMapStringString();
...@@ -96,21 +142,22 @@ public class GoblinNtfOrderUtils { ...@@ -96,21 +142,22 @@ public class GoblinNtfOrderUtils {
params.add("timeId", "null"); params.add("timeId", "null");
params.add("ticketId", "null"); params.add("ticketId", "null");
params.add("uid", uid); params.add("uid", uid);
MultiValueMap<String, String> header = CollectionUtil.linkedMultiValueMapStringString(); MultiValueMap<String, String> header = CollectionUtil.linkedMultiValueMapStringString();
header.add("Authorization", "Bearer " + CurrentUtil.getToken()); header.add("Authorization", "Bearer " + CurrentUtil.getToken());
header.add("Accept", "application/json;charset=UTF-8"); header.add("Accept", "application/json;charset=UTF-8");
log.debug("url=" + candyUrl + "/candy-coupon/use");
String returnData = HttpUtil.post(candyUrl + "/candy-coupon/use", params, header); String returnData = HttpUtil.post(candyUrl.concat("/candy-coupon/use"), params, header);
ResponseDto<CandyUseResultVo> innerReturnVo = JsonUtils.fromJson(returnData, new TypeReference<ResponseDto<CandyUseResultVo>>() { ResponseDto<CandyUseResultVo> useResultVo = JsonUtils.fromJson(returnData, new TypeReference<ResponseDto<CandyUseResultVo>>() {
}); });
CandyUseResultVo candyUseResultVo = innerReturnVo.getData(); CandyUseResultVo candyUseResultVo = useResultVo.getData();
Integer type = candyUseResultVo.getCouType(); Integer type = candyUseResultVo.getCouType();
List<String> targetList = candyUseResultVo.getTargetIds(); List<String> targetList = candyUseResultVo.getTargetIds();
BigDecimal fullValue = candyUseResultVo.getFullValue(); BigDecimal fullValue = candyUseResultVo.getFullValue();
BigDecimal value = candyUseResultVo.getValue(); BigDecimal value = candyUseResultVo.getValue();
BigDecimal voucher = BigDecimal.ZERO; BigDecimal voucher = BigDecimal.ZERO;
BigDecimal targetPrice = BigDecimal.ZERO; BigDecimal targetPrice = BigDecimal.ZERO;
switch (type) { switch (type) {// 券类型[-1-不可用 | 1-代金券|2-满减券|3-兑换券|4-折扣券|101-优先券]
case -1: case -1:
voucher = BigDecimal.valueOf(-1); voucher = BigDecimal.valueOf(-1);
break; break;
...@@ -119,15 +166,8 @@ public class GoblinNtfOrderUtils { ...@@ -119,15 +166,8 @@ public class GoblinNtfOrderUtils {
targetPrice = totalPrice; targetPrice = totalPrice;
} else { } else {
for (String targetId : targetList) { for (String targetId : targetList) {
for (GoblinOrderSku skuOrderVo : goblinOrderSkuList) { if (targetId.equals(spuId)) {
String orderVoSpuId = skuOrderVo.getSpuId(); targetPrice = totalPrice;
String pre = GoblinStatusConst.MarketPreStatus.getPre(orderVoSpuId);
if (pre != null) {
orderVoSpuId = orderVoSpuId.split(pre)[0];
}
if (targetId.equals(orderVoSpuId)) {
targetPrice = targetPrice.add(skuOrderVo.getSkuPriceActual());
}
} }
} }
} }
...@@ -137,27 +177,20 @@ public class GoblinNtfOrderUtils { ...@@ -137,27 +177,20 @@ public class GoblinNtfOrderUtils {
voucher = voucher.add(targetPrice); voucher = voucher.add(targetPrice);
} }
break; break;
case 2://满减 case 2:
if (targetList.size() == 0) { if (targetList.size() == 0) {
targetPrice = totalPrice; targetPrice = totalPrice;
} else { } else {
for (String targetId : targetList) { for (String targetId : targetList) {
for (GoblinOrderSku skuOrderVo : goblinOrderSkuList) { if (targetId.equals(spuId)) {
String orderVoSpuId = skuOrderVo.getSpuId(); targetPrice = totalPrice;
String pre = GoblinStatusConst.MarketPreStatus.getPre(orderVoSpuId);
if (pre != null) {
orderVoSpuId = orderVoSpuId.split(pre)[0];
}
if (targetId.equals(orderVoSpuId)) {
targetPrice = targetPrice.add(skuOrderVo.getSkuPriceActual());
}
} }
} }
} }
if (fullValue.compareTo(targetPrice) <= 0) { if (fullValue.compareTo(targetPrice) <= 0) {
voucher = voucher.add(value); voucher = voucher.add(value);
} else { } else {
backCoupon(uCouponId, uid); goblinOrderUtils.backCoupon(uCouponId, uid);
hashMap.put("type", -1); hashMap.put("type", -1);
hashMap.put("voucher", BigDecimal.ZERO); hashMap.put("voucher", BigDecimal.ZERO);
return hashMap; return hashMap;
...@@ -166,15 +199,13 @@ public class GoblinNtfOrderUtils { ...@@ -166,15 +199,13 @@ public class GoblinNtfOrderUtils {
case 3: case 3:
voucher = voucher.add(totalPrice); voucher = voucher.add(totalPrice);
break; break;
case 4://折扣 case 4:
if (targetList.size() == 0) { if (targetList.size() == 0) {
targetPrice = totalPrice; targetPrice = totalPrice;
} else { } else {
for (String targetId : targetList) { for (String targetId : targetList) {
for (GoblinOrderSku skuOrderVo : goblinOrderSkuList) { if (targetId.equals(spuId)) {
if (targetId.equals(skuOrderVo.getSpuId())) { targetPrice = totalPrice;
targetPrice = targetPrice.add(skuOrderVo.getSkuPriceActual());
}
} }
} }
} }
...@@ -194,64 +225,26 @@ public class GoblinNtfOrderUtils { ...@@ -194,64 +225,26 @@ public class GoblinNtfOrderUtils {
} }
} }
public void backCoupon(String uCouponId, String uid) { /**
try { * 使用店铺优惠券
BackCouponParam param = BackCouponParam.getNew(); *
param.setuCouponIds(uCouponId); * @param uCouponId 券id
param.setUid(uid); * @param content 消费内容
* @param totalPrice 订单总价
MultiValueMap<String, String> header = CollectionUtil.linkedMultiValueMapStringString(); * @param spuId spuId
header.add("Authorization", "Bearer " + CurrentUtil.getToken()); * @param uid uid
header.add("Accept", "application/json;charset=UTF-8"); * @return
ArrayList<BackCouponParam> params = new ArrayList(); */
params.add(param); public GoblinUseResultVo useStoreCoupon(String uCouponId, String content, BigDecimal totalPrice, String spuId, String uid) {
String jsonString = JSON.toJSONString(params);
String returnData = HttpUtil.postRaw(candyUrl + "/candy-coupon/useBack", jsonString, header);
} catch (Exception e) {
log.error("回退券ERROR:{}", e);
}
}
public void doTask(String uid, BigDecimal price) {
try {
MultiValueMap<String, String> header = CollectionUtil.linkedMultiValueMapStringString();
header.add("Accept", "application/json;charset=UTF-8");
MultiValueMap<String, String> params = CollectionUtil.linkedMultiValueMapStringString();
params.add("score", price.intValue() + "");
params.add("content", "购买商品:");
params.add("uid", uid);
String resultData = HttpUtil.post(stoneUrl + "/user/logs/in2111", params, header);
} catch (Exception e) {
log.error("添加积分失败,e:{}", e);
e.printStackTrace();
}
}
public void desTask(String uid, BigDecimal price) {
try {
MultiValueMap<String, String> header = CollectionUtil.linkedMultiValueMapStringString();
header.add("Accept", "application/json;charset=UTF-8");
MultiValueMap<String, String> params = CollectionUtil.linkedMultiValueMapStringString();
params.add("score", price.intValue() + "");
params.add("content", "购买商品:");
params.add("uid", uid);
String resultData = HttpUtil.post(stoneUrl + "/user/logs/de2111", params, header);
} catch (Exception e) {
log.error("添加积分失败,e:{}", e);
e.printStackTrace();
}
}
public GoblinUseResultVo useStoreCoupon(String ucouponId, String content, BigDecimal totalPrice, List<GoblinOrderSku> goblinOrderSkuList, String uid) {
try { try {
List<GoblinUserCouponVo> voList = redisUtils.getUserCouponVos(uid); List<GoblinUserCouponVo> voList = goblinRedisUtils.getUserCouponVos(uid);
GoblinUseResultVo returnVo = GoblinUseResultVo.getNew(); GoblinUseResultVo returnVo = GoblinUseResultVo.getNew();
returnVo.setValue(BigDecimal.ZERO); returnVo.setValue(BigDecimal.ZERO);
returnVo.setCouType("-1"); returnVo.setCouType("-1");
LocalDateTime now = LocalDateTime.now(); LocalDateTime now = LocalDateTime.now();
List<String> spuIds = CollectionUtil.linkedListString(); List<String> spuIds = CollectionUtil.linkedListString();
for (GoblinUserCouponVo vo : voList) { for (GoblinUserCouponVo vo : voList) {
if (vo.getUcouponId().equals(ucouponId) && vo.getDuedAt().isAfter(now)) { if (vo.getUcouponId().equals(uCouponId) && vo.getDuedAt().isAfter(now)) {
//判断券状态 和 触发金额 //判断券状态 和 触发金额
if ((vo.getState().equals(1))) { if ((vo.getState().equals(1))) {
if (vo.getUseScope().equals("0") && vo.getTriggers().compareTo(totalPrice) <= 0) { if (vo.getUseScope().equals("0") && vo.getTriggers().compareTo(totalPrice) <= 0) {
...@@ -276,22 +269,15 @@ public class GoblinNtfOrderUtils { ...@@ -276,22 +269,15 @@ public class GoblinNtfOrderUtils {
SqlMapping.get("goblin_user_coupon.updateState", vo.getState(), vo.getUsedFor(), LocalDateTime.now(), vo.getUcouponId())); SqlMapping.get("goblin_user_coupon.updateState", vo.getState(), vo.getUsedFor(), LocalDateTime.now(), vo.getUcouponId()));
break; break;
} else { } else {
spuIds = redisUtils.getStoreCouponSpuIds(vo.getStoreCouponId()); spuIds = goblinRedisUtils.getStoreCouponSpuIds(vo.getStoreCouponId());
if (spuIds == null || spuIds.size() == 0) { if (spuIds == null || spuIds.size() == 0) {
continue; continue;
} }
//判断是否在可用商品内 //判断是否在可用商品内
BigDecimal contentPrice = BigDecimal.ZERO; BigDecimal contentPrice = BigDecimal.ZERO;
for (String item : spuIds) { for (String item : spuIds) {
for (GoblinOrderSku param : goblinOrderSkuList) {
String spuId = param.getSpuId();
String pre = GoblinStatusConst.MarketPreStatus.getPre(spuId);
if (pre != null) {
spuId = spuId.split(pre)[0];
}
if (spuId.equals(item)) { if (spuId.equals(item)) {
contentPrice = contentPrice.add(param.getSkuPriceActual()); contentPrice = totalPrice;
}
} }
} }
if (vo.getTriggers().compareTo(contentPrice) <= 0) { if (vo.getTriggers().compareTo(contentPrice) <= 0) {
...@@ -330,7 +316,7 @@ public class GoblinNtfOrderUtils { ...@@ -330,7 +316,7 @@ public class GoblinNtfOrderUtils {
} }
} }
if (!returnVo.getCouType().equals("-1")) { if (!returnVo.getCouType().equals("-1")) {
redisUtils.setUserCouponVos(uid, voList); goblinRedisUtils.setUserCouponVos(uid, voList);
} }
returnVo.setSpuIds(spuIds); returnVo.setSpuIds(spuIds);
return returnVo; return returnVo;
...@@ -340,125 +326,56 @@ public class GoblinNtfOrderUtils { ...@@ -340,125 +326,56 @@ public class GoblinNtfOrderUtils {
} }
} }
public Boolean backStoreCoupon(List<com.liquidnet.service.goblin.param.BackCouponParam> params) {
try {
for (com.liquidnet.service.goblin.param.BackCouponParam item : params) {
List<GoblinUserCouponVo> voList = redisUtils.getUserCouponVos(item.getUid());
for (GoblinUserCouponVo vo : voList) {
if (vo.getUcouponId().equals(item.getuCouponIds())) {
if (LocalDateTime.now().isBefore(vo.getDuedAt())) {
vo.setState(1);
vo.setUsedFor("");
redisUtils.setUserCouponVos(item.getUid(), voList);
goblinMongoUtils.changeCouponVos(vo.getUcouponId(), vo);
queueUtils.sendMsgByRedis(MQConst.GoblinQueue.SQL_COUPON.getKey(),
SqlMapping.get("goblin_user_coupon.updateState", vo.getState(), vo.getUsedFor(), LocalDateTime.now(), vo.getUcouponId()));
}
break;
}
}
}
return true;
} catch (Exception e) {
e.printStackTrace();
return false;
}
}
public Integer getMember(String uid) {
return redisUtils.getMember(uid);
}
//超时支付自动退款 //超时支付自动退款
public Boolean refundOrderSku(String orderId, String paymentId, String paymentType) { public Boolean refundOrderSku(String orderId, String paymentId, String paymentType) {
int autoSize = redisUtils.getBackOrderByOrderId(orderId).size();
if (autoSize > 0) {
return true;
}
String uid = CurrentUtil.getCurrentUid(); String uid = CurrentUtil.getCurrentUid();
LocalDateTime now = LocalDateTime.now(); LocalDateTime now = LocalDateTime.now();
String nowStr = DateUtil.getNowTime(); String nowStr = DateUtil.getNowTime();
List<GoblinBackOrderSkuVo> orderSkuVoList = ObjectUtil.goblinBackOrderSkuVoArrayList(); GoblinNftOrderVo NftOrder = getNftOrder(orderId);
GoblinStoreOrderVo orderVo = redisUtils.getGoblinOrder(orderId); BigDecimal refundPrice = NftOrder.getPriceActual();
BigDecimal refundPrice = BigDecimal.ZERO;
for (String orderSkuIdItem : orderVo.getOrderSkuVoIds()) {
GoblinOrderSkuVo orderSkuVo = redisUtils.getGoblinOrderSkuVo(orderSkuIdItem);
GoblinBackOrderSkuVo backOrderSkuVo = GoblinBackOrderSkuVo.getNew();
backOrderSkuVo.setOrderSkuId(orderSkuIdItem);
backOrderSkuVo.setSpuId(orderSkuVo.getSpuId());
backOrderSkuVo.setSpuName(orderSkuVo.getSpuName());
backOrderSkuVo.setSkuId(orderSkuVo.getSkuId());
backOrderSkuVo.setSkuName(orderSkuVo.getSkuName());
backOrderSkuVo.setRefundPrice(orderSkuVo.getSkuPriceActual());
backOrderSkuVo.setSkuSpecs(orderSkuVo.getSkuSpecs());
backOrderSkuVo.setCreatedAt(nowStr);
backOrderSkuVo.setSkuPic(orderSkuVo.getSkuImage());
orderSkuVoList.add(backOrderSkuVo);
refundPrice = refundPrice.add(orderSkuVo.getSkuPriceActual().subtract(orderSkuVo.getPriceRefund()));
}
//记录退款单 //记录退款单
String refundCode = IDGenerator.storeRefundCode(orderVo.getMasterOrderCode()); String refundCode = IDGenerator.storeRefundCode(NftOrder.getOrderCode());
GoblinBackOrder goblinBackOrder = GoblinBackOrder.getNew(); GoblinNftOrderRefund nftBackOrder = GoblinNftOrderRefund.getNew();
goblinBackOrder.setBackOrderId(IDGenerator.nextTimeId2()); nftBackOrder.setOrderRefundId(IDGenerator.nextTimeId2());
goblinBackOrder.setBackCode(refundCode); nftBackOrder.setRefundCode(refundCode);
goblinBackOrder.setOrderId(orderVo.getOrderId()); nftBackOrder.setOrderId(orderId);
goblinBackOrder.setOrderCode(orderVo.getOrderCode()); nftBackOrder.setOrderCode(NftOrder.getOrderCode());
goblinBackOrder.setStoreId(orderVo.getStoreId()); nftBackOrder.setStoreId(NftOrder.getStoreId());
goblinBackOrder.setUserId(orderVo.getUserId()); nftBackOrder.setUserId(NftOrder.getUserId());
// goblinBackOrder.setSkuIdNums(orderSkuId); nftBackOrder.setSkuIdNums(NftOrder.getSkuId());
goblinBackOrder.setType(GoblinStatusConst.Type.BACK_TYPE_1.getValue()); nftBackOrder.setRealBackPrice(refundPrice);
goblinBackOrder.setReason(GoblinStatusConst.Type.BACK_REASON_TYPE_10.getDesc()); nftBackOrder.setStatus(GoblinStatusConst.NftStatus.ORDER_REFUND_STATUS_1.getValue());
goblinBackOrder.setDescribes("超时支付自动退款"); nftBackOrder.setCreatedAt(now);
refundPrice = refundPrice.add(orderVo.getPriceExpress()); nftBackOrder.setUpdatedAt(now);
goblinBackOrder.setRealBackPrice(refundPrice);
goblinBackOrder.setStatus(GoblinStatusConst.Status.ORDER_BACK_STATUS_0.getValue()); GoblinNftOrderCallBackVo backOrderVo = GoblinNftOrderCallBackVo.getNew().copy(nftBackOrder);
goblinBackOrder.setAuditAt(now);
goblinBackOrder.setCreatedAt(now);
GoblinBackOrderVo backOrderVo = GoblinBackOrderVo.getNew().copy(goblinBackOrder);
backOrderVo.setCreatedAt(nowStr);
backOrderVo.setBackOrderSkuVos(orderSkuVoList);
//添加日志
GoblinBackOrderLog backOrderLog = initBackLog(goblinBackOrder.getBackOrderId(), uid, now);
backOrderLog.setStatus(GoblinStatusConst.Status.ORDER_LOG_STATUS_22.getValue());
backOrderLog.setOperationType(GoblinStatusConst.Type.OPERATION_TYPE_2.getValue());
backOrderLog.setMessage("商户发起[自动退款]:orderId=[" + orderId + "],refundPrice=[" + refundPrice + "],[refundCode=" + refundCode + "]");
//调用退款 //调用退款
orderVo.setPaymentId(paymentId); NftOrder.setPaymentId(paymentId);
orderVo.setPaymentType(paymentType); NftOrder.setPaymentType(paymentType);
String returnString = initRefund(orderVo, refundPrice, refundCode); String returnString = initRefund(NftOrder, refundPrice, refundCode);
HashMap hashMapResult = JsonUtils.fromJson(returnString, HashMap.class); HashMap hashMapResult = JsonUtils.fromJson(returnString, HashMap.class);
Boolean success = (Boolean) hashMapResult.get("success"); Boolean success = (Boolean) hashMapResult.get("success");
String message = (String) hashMapResult.get("message"); String message = (String) hashMapResult.get("message");
if (!success) { if (!success) {
if (!(backOrderVo.getStatus() == GoblinStatusConst.Status.ORDER_BACK_STATUS_8.getValue() || backOrderVo.getStatus() == GoblinStatusConst.Status.ORDER_BACK_STATUS_2.getValue())) { if (!Objects.equals(backOrderVo.getStatus(), GoblinStatusConst.NftStatus.ORDER_REFUND_STATUS_2.getValue())) {
backOrderVo.setStatus(GoblinStatusConst.Status.ORDER_BACK_STATUS_10.getValue()); backOrderVo.setStatus(GoblinStatusConst.NftStatus.ORDER_REFUND_STATUS_3.getValue());
backOrderVo.setErrorReason(backOrderVo.getErrorReason() + ",失败原因:" + message); backOrderVo.setErrorReason(backOrderVo.getErrorReason() + ",失败原因:" + message);
log.error("REFUND DATA = " + returnString); log.error("REFUND DATA = " + returnString);
} }
} }
//redis // redis
redisUtils.setBackOrderVo(backOrderVo.getBackOrderId(), backOrderVo); setBackOrderVo(backOrderVo);
redisUtils.addBackOrderByOrderId(orderVo.getOrderId(), backOrderVo.getBackOrderId()); // mongo
//mongo goblinMongoUtils.insertGoblinNftOrderRefundVo(backOrderVo);
goblinMongoUtils.insertGoblinBackOrderVo(backOrderVo); // 添加退款
//添加退款
queueUtils.sendMsgByRedis( queueUtils.sendMsgByRedis(
MQConst.GoblinQueue.GOBLIN_STORE_ORDER_OPERA.getKey(), MQConst.GoblinQueue.GOBLIN_STORE_ORDER_OPERA.getKey(),
SqlMapping.get("goblin_order.store.backOrder", SqlMapping.get("goblin_nft_order_refund.insert",
goblinBackOrder.getBackOrderId(), goblinBackOrder.getBackCode(), goblinBackOrder.getOrderId(), nftBackOrder.getOrderRefundId(), nftBackOrder.getRefundCode(), nftBackOrder.getOrderId(),
goblinBackOrder.getOrderCode(), goblinBackOrder.getStoreId(), goblinBackOrder.getUserId(), nftBackOrder.getOrderCode(), nftBackOrder.getStoreId(), nftBackOrder.getUserId(),
goblinBackOrder.getSkuIdNums(), goblinBackOrder.getType(), goblinBackOrder.getReason(), nftBackOrder.getSkuIdNums(), nftBackOrder.getRealBackPrice(), nftBackOrder.getStatus(),
goblinBackOrder.getDescribes(), goblinBackOrder.getRealBackPrice(), goblinBackOrder.getStatus(), nftBackOrder.getRefundAt(), nftBackOrder.getErrorReason()
goblinBackOrder.getCreatedAt(), goblinBackOrder.getAuditAt(), goblinBackOrder.getErrorReason()
)
);
//添加日志
queueUtils.sendMsgByRedis(
MQConst.GoblinQueue.GOBLIN_STORE_ORDER_OPERA.getKey(),
SqlMapping.get("goblin_order.store.refundLog",
backOrderLog.getBackOrderLogId(), backOrderLog.getBackOrderId(), backOrderLog.getOperationType(),
backOrderLog.getMessage(), backOrderLog.getOperationName(), backOrderLog.getStatus(), now
) )
); );
if (success) { if (success) {
...@@ -469,28 +386,17 @@ public class GoblinNtfOrderUtils { ...@@ -469,28 +386,17 @@ public class GoblinNtfOrderUtils {
} }
} }
private GoblinBackOrderLog initBackLog(String orderId, String uid, LocalDateTime now) { private String initRefund(GoblinNftOrderVo orderVo, BigDecimal price, String refundCode) {
GoblinBackOrderLog log = GoblinBackOrderLog.getNew();
log.setBackOrderId(orderId);
log.setOperationName(uid);
log.setBackOrderLogId(IDGenerator.nextTimeId2());
log.setCreatedAt(now);
return log;
}
private String initRefund(GoblinStoreOrderVo orderVo, BigDecimal price, String refundCode) {
MultiValueMap<String, String> params = CollectionUtil.linkedMultiValueMapStringString(); MultiValueMap<String, String> params = CollectionUtil.linkedMultiValueMapStringString();
params.add("code", orderVo.getPayCode()); params.add("code", orderVo.getPayCode());
params.add("notifyUrl", synUrl); params.add("notifyUrl", synUrl);
params.add("orderCode", orderVo.getMasterOrderCode()); params.add("orderCode", orderVo.getOrderCode());
params.add("orderRefundCode", refundCode); params.add("orderRefundCode", refundCode);
params.add("paymentId", orderVo.getPaymentId()); params.add("paymentId", orderVo.getPaymentId());
params.add("paymentType", orderVo.getPaymentType()); params.add("paymentType", orderVo.getPaymentType());
params.add("price", String.valueOf(price)); params.add("price", String.valueOf(price));
BigDecimal totalPrice = BigDecimal.ZERO; params.add("priceTotal", String.valueOf(price));
totalPrice = totalPrice.add(price); params.add("reason", "NFT超时支付");
params.add("priceTotal", String.valueOf(totalPrice));
params.add("reason", "超时支付");
MultiValueMap<String, String> headers = CollectionUtil.linkedMultiValueMapStringString(); MultiValueMap<String, String> headers = CollectionUtil.linkedMultiValueMapStringString();
headers.add("Accept", "application/json;charset=UTF-8"); headers.add("Accept", "application/json;charset=UTF-8");
String returnString = HttpUtil.post(refundApply, params, headers); String returnString = HttpUtil.post(refundApply, params, headers);
...@@ -498,44 +404,4 @@ public class GoblinNtfOrderUtils { ...@@ -498,44 +404,4 @@ public class GoblinNtfOrderUtils {
return returnString; return returnString;
} }
//订单异常处理
public ResponseDto<GoblinNtfPayResultVo> orderException(List<String> skuAndPreListAndNumber, List<String> platformCodeList, List<String> storeCodeList, String uid, String message) {
long time3 = System.currentTimeMillis();
//回顾限购 回滚库存
for (String item : skuAndPreListAndNumber) {
String[] array = item.split(",");
String skuId = array[0];
String pre = array[1];
int number = Integer.parseInt(array[2]);
redisUtils.incrSkuStock(pre, skuId, number);
if (noZhengzaiOrder(uid)) {
redisUtils.decrSkuCountByUid(uid, skuId, number);
}
}
//回退平台券
for (String platformCode : platformCodeList) {
backCoupon(platformCode, uid);
}
//回退店铺券
List<com.liquidnet.service.goblin.param.BackCouponParam> params = ObjectUtil.getBackCouponParam();
for (String storeCode : storeCodeList) {
com.liquidnet.service.goblin.param.BackCouponParam backCouponParam = com.liquidnet.service.goblin.param.BackCouponParam.getNew();
backCouponParam.setuCouponIds(storeCode);
backCouponParam.setUid(uid);
params.add(backCouponParam);
}
if (params.size() > 0) {
backStoreCoupon(params);
}
log.info("回滚逻辑 " + (System.currentTimeMillis() - time3) + "ms");
if (message == null && !message.equals("")) {
return ResponseDto.failure(ErrorMapping.get("20018"));//乱七八糟异常
} else {
return ResponseDto.failure(message);//乱七八糟异常
}
}
public boolean noZhengzaiOrder(String uid) {
return !uid.equals("zhengzai");
}
} }
...@@ -45,3 +45,8 @@ goblin_user_coupon.updateState=UPDATE goblin_user_coupon SET state = ? , used_fo ...@@ -45,3 +45,8 @@ goblin_user_coupon.updateState=UPDATE goblin_user_coupon SET state = ? , used_fo
#---- #----
goblin_order.store.refundLog=INSERT INTO goblin_back_order_log (`back_order_log_id`,`back_order_id`,`operation_type`,`message`,`operation_name`,`status`,`created_at`) VALUES(?,?,?,?,?,?,?) goblin_order.store.refundLog=INSERT INTO goblin_back_order_log (`back_order_log_id`,`back_order_id`,`operation_type`,`message`,`operation_name`,`status`,`created_at`) VALUES(?,?,?,?,?,?,?)
goblin_order.store.backOrder=INSERT INTO goblin_back_order (`back_order_id`,`back_code`,`order_id`,`order_code`,`store_id`,`user_id`,`sku_id_nums`,`type`,`reason`,`describes`,`real_back_price`,`status`,`created_at`,`audit_at`,`error_reason`) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) goblin_order.store.backOrder=INSERT INTO goblin_back_order (`back_order_id`,`back_code`,`order_id`,`order_code`,`store_id`,`user_id`,`sku_id_nums`,`type`,`reason`,`describes`,`real_back_price`,`status`,`created_at`,`audit_at`,`error_reason`) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
#-------- NFT -------
goblin_nft_order.insert=INSERT INTO goblin_nft_order (`order_id`,`store_id`,`store_name`,`order_code`,`user_id`,`user_name`,`user_mobile`,`price_total`,`pay_code`,`price_actual`,`price_coupon`,`store_price_coupon`,`price_voucher`,`status`,`ucoupon_id`,`store_coupon_id`,`pay_type`,`device_from`,`source`,`version`,`is_member`,`order_type`,`pay_countdown_minute`,`ip_address`,`created_at`) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
goblin_nft_order.update.pay=UPDATE goblin_nft_order SET payment_type = ?, payment_id=?, pay_code = ?, pay_time = ?, status = ?, updated_at = ? WHERE order_id = ? and (updated_at <= ? or created_at = ? or updated_at is null)
goblin_nft_order_refund.insert=INSERT INTO goblin_nft_order_refund (`order_refund_id`,`refund_code`,`order_id`,`order_code`,`store_id`,`user_id`,`sku_id_nums`,`real_back_price`,`status`,`refund_at`,`error_reason`) VALUES (?,?,?,?,?,?,?,?,?,?,?)
\ No newline at end of file
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