|
@@ -6,17 +6,18 @@ import com.miaxis.common.config.WxpayConfig;
|
|
|
import com.miaxis.common.constant.Constants;
|
|
|
import com.miaxis.common.exception.CustomException;
|
|
|
import com.miaxis.common.utils.AesUtil;
|
|
|
-import com.miaxis.common.utils.DateUtils;
|
|
|
-import com.miaxis.newgzpt.domain.GzptUserInfo;
|
|
|
import com.miaxis.newgzpt.domain.GzptVideoVip;
|
|
|
import com.miaxis.newgzpt.dto.GzptVideoVipDTO;
|
|
|
import com.miaxis.newgzpt.service.IGzptUserInfoService;
|
|
|
import com.miaxis.newgzpt.service.IGzptVideoVipService;
|
|
|
-import com.miaxis.system.service.ISysUserService;
|
|
|
+import com.miaxis.order.domain.OrderInfo;
|
|
|
+import com.miaxis.order.service.IOrderInfoService;
|
|
|
+import com.miaxis.userInfo.domain.UserVip;
|
|
|
+import com.miaxis.userInfo.service.IUserVipService;
|
|
|
import com.miaxis.wx.domain.RefundRecord;
|
|
|
import com.miaxis.wx.domain.WxJsOrder;
|
|
|
-import com.miaxis.wx.domain.WxOrder;
|
|
|
-import com.miaxis.wx.dto.*;
|
|
|
+import com.miaxis.wx.dto.WxNotifyReturnDTO;
|
|
|
+import com.miaxis.wx.dto.WxpayNotifyDTO;
|
|
|
import com.miaxis.wx.service.IRefundRecordService;
|
|
|
import com.miaxis.wx.service.IWxJsOrderService;
|
|
|
import com.wechat.pay.contrib.apache.httpclient.auth.AutoUpdateCertificatesVerifier;
|
|
@@ -27,7 +28,6 @@ import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.joda.time.DateTime;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.util.Base64Utils;
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
@@ -68,6 +68,13 @@ public class WxNotifyController {
|
|
|
|
|
|
@Autowired
|
|
|
private IGzptVideoVipService videoVipService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IOrderInfoService orderInfoService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IUserVipService userVipService;
|
|
|
+
|
|
|
/**
|
|
|
* 微信支付回调接口
|
|
|
*/
|
|
@@ -274,8 +281,20 @@ public class WxNotifyController {
|
|
|
wxJsOrder.setOrderStatus("2");
|
|
|
|
|
|
//插入VIP信息
|
|
|
- writeVipDataToDb(wxJsOrder);
|
|
|
+ writeVipDataToDb2(wxJsOrder);
|
|
|
wxJsOrderService.updateById(wxJsOrder);
|
|
|
+
|
|
|
+ //插入订单主表
|
|
|
+ OrderInfo orderInfo = new OrderInfo();
|
|
|
+ orderInfo.setGoodsName(wxJsOrder.getGoodsName());
|
|
|
+ orderInfo.setUserId(wxJsOrder.getUserId());
|
|
|
+ orderInfo.setOutTradeNo(wxJsOrder.getOutTradeNo());
|
|
|
+ orderInfo.setTradeType(1);
|
|
|
+ orderInfo.setSuccessTime(wxJsOrder.getSuccessTime());
|
|
|
+ orderInfo.setPayType(1);
|
|
|
+ orderInfo.setCreateTime(new Date());
|
|
|
+ orderInfoService.save(orderInfo);
|
|
|
+
|
|
|
}
|
|
|
|
|
|
|
|
@@ -398,6 +417,211 @@ public class WxNotifyController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+ @Transactional
|
|
|
+ public void writeVipDataToDb2(WxJsOrder wxJsOrder) {
|
|
|
+ long oneYearLong = 1000 * 60 * 60 * 24 * 365l;
|
|
|
+ Date now = new Date();
|
|
|
+
|
|
|
+ if ("科一专项VIP".equals(wxJsOrder.getGoodsName())) {
|
|
|
+ UserVip userVip = userVipService.getUserVipByUserId(wxJsOrder.getUserId());
|
|
|
+ if (userVip != null) {
|
|
|
+ //修改会员信息
|
|
|
+ Date km1Date = userVip.getSubject1();
|
|
|
+ if (km1Date != null) { //存在会员时间
|
|
|
+ if (km1Date.compareTo(now) < 0) { //会员已过期
|
|
|
+ long x = now.getTime() + oneYearLong;
|
|
|
+ Date km1oneYear = new Date(x);
|
|
|
+ userVip.setSubject1(km1oneYear);
|
|
|
+ userVipService.updateById(userVip);
|
|
|
+ } else { //会员时间延长
|
|
|
+ long x = km1Date.getTime() + oneYearLong;
|
|
|
+ Date km1oneYear = new Date(x);
|
|
|
+ userVip.setSubject1(km1oneYear);
|
|
|
+ userVipService.updateById(userVip);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ long x = now.getTime() + oneYearLong;
|
|
|
+ Date km1oneYear = new Date(x);
|
|
|
+ userVip.setSubject1(km1oneYear);
|
|
|
+ userVipService.updateById(userVip);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ //新增会员信息
|
|
|
+ UserVip uv = new UserVip();
|
|
|
+ uv.setUserId(wxJsOrder.getUserId());
|
|
|
+ uv.setUserName(wxJsOrder.getUserName());
|
|
|
+ long x = now.getTime() + oneYearLong;
|
|
|
+ Date km1oneYear = new Date(x);
|
|
|
+ uv.setSubject1(km1oneYear);
|
|
|
+ userVipService.save(uv);
|
|
|
+ }
|
|
|
+
|
|
|
+ } else if ("科二专项VIP".equals(wxJsOrder.getGoodsName())) {
|
|
|
+ UserVip userVip = userVipService.getUserVipByUserId(wxJsOrder.getUserId());
|
|
|
+ if (userVip != null) {
|
|
|
+ //修改会员信息
|
|
|
+ Date km2Date = userVip.getSubject2();
|
|
|
+ if (km2Date != null) { //存在会员时间
|
|
|
+ if (km2Date.compareTo(now) < 0) { //会员已过期
|
|
|
+ long x = now.getTime() + oneYearLong;
|
|
|
+ Date km2oneYear = new Date(x);
|
|
|
+ userVip.setSubject2(km2oneYear);
|
|
|
+ userVipService.updateById(userVip);
|
|
|
+ } else { //会员时间延长
|
|
|
+ long x = km2Date.getTime() + oneYearLong;
|
|
|
+ Date km2oneYear = new Date(x);
|
|
|
+ userVip.setSubject2(km2oneYear);
|
|
|
+ userVipService.updateById(userVip);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ long x = now.getTime() + oneYearLong;
|
|
|
+ Date km2oneYear = new Date(x);
|
|
|
+ userVip.setSubject2(km2oneYear);
|
|
|
+ userVipService.updateById(userVip);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ //新增会员信息
|
|
|
+ UserVip uv = new UserVip();
|
|
|
+ uv.setUserId(wxJsOrder.getUserId());
|
|
|
+ uv.setUserName(wxJsOrder.getUserName());
|
|
|
+ long x = now.getTime() + oneYearLong;
|
|
|
+ Date km2oneYear = new Date(x);
|
|
|
+ uv.setSubject2(km2oneYear);
|
|
|
+ userVipService.save(uv);
|
|
|
+ }
|
|
|
+ } else if ("科三专项VIP".equals(wxJsOrder.getGoodsName())) {
|
|
|
+ UserVip userVip = userVipService.getUserVipByUserId(wxJsOrder.getUserId());
|
|
|
+ if (userVip != null) {
|
|
|
+ //修改会员信息
|
|
|
+ Date km3Date = userVip.getSubject2();
|
|
|
+ if (km3Date != null) { //存在会员时间
|
|
|
+ if (km3Date.compareTo(now) < 0) { //会员已过期
|
|
|
+ long x = now.getTime() + oneYearLong;
|
|
|
+ Date km3oneYear = new Date(x);
|
|
|
+ userVip.setSubject3(km3oneYear);
|
|
|
+ userVipService.updateById(userVip);
|
|
|
+ } else { //会员时间延长
|
|
|
+ long x = km3Date.getTime() + oneYearLong;
|
|
|
+ Date km3oneYear = new Date(x);
|
|
|
+ userVip.setSubject3(km3oneYear);
|
|
|
+ userVipService.updateById(userVip);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ long x = now.getTime() + oneYearLong;
|
|
|
+ Date km3oneYear = new Date(x);
|
|
|
+ userVip.setSubject3(km3oneYear);
|
|
|
+ userVipService.updateById(userVip);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ //新增会员信息
|
|
|
+ UserVip uv = new UserVip();
|
|
|
+ uv.setUserId(wxJsOrder.getUserId());
|
|
|
+ uv.setUserName(wxJsOrder.getUserName());
|
|
|
+ long x = now.getTime() + oneYearLong;
|
|
|
+ Date km3oneYear = new Date(x);
|
|
|
+ uv.setSubject3(km3oneYear);
|
|
|
+ userVipService.save(uv);
|
|
|
+ }
|
|
|
+
|
|
|
+ } else if ("科四专项VIP".equals(wxJsOrder.getGoodsName())) {
|
|
|
+ UserVip userVip = userVipService.getUserVipByUserId(wxJsOrder.getUserId());
|
|
|
+ if (userVip != null) {
|
|
|
+ //修改会员信息
|
|
|
+ Date km4Date = userVip.getSubject2();
|
|
|
+ if (km4Date != null) { //存在会员时间
|
|
|
+ if (km4Date.compareTo(now) < 0) { //会员已过期
|
|
|
+ long x = now.getTime() + oneYearLong;
|
|
|
+ Date km4oneYear = new Date(x);
|
|
|
+ userVip.setSubject4(km4oneYear);
|
|
|
+ userVipService.updateById(userVip);
|
|
|
+ } else { //会员时间延长
|
|
|
+ long x = km4Date.getTime() + oneYearLong;
|
|
|
+ Date km4oneYear = new Date(x);
|
|
|
+ userVip.setSubject4(km4oneYear);
|
|
|
+ userVipService.updateById(userVip);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ long x = now.getTime() + oneYearLong;
|
|
|
+ Date km4oneYear = new Date(x);
|
|
|
+ userVip.setSubject4(km4oneYear);
|
|
|
+ userVipService.updateById(userVip);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ //新增会员信息
|
|
|
+ UserVip uv = new UserVip();
|
|
|
+ uv.setUserId(wxJsOrder.getUserId());
|
|
|
+ uv.setUserName(wxJsOrder.getUserName());
|
|
|
+ long x = now.getTime() + oneYearLong;
|
|
|
+ Date km4oneYear = new Date(x);
|
|
|
+ uv.setSubject4(km4oneYear);
|
|
|
+ userVipService.save(uv);
|
|
|
+ }
|
|
|
+
|
|
|
+ } else if ("科目一二三四所有付费权益".equals(wxJsOrder.getGoodsName())) {
|
|
|
+ UserVip userVip = userVipService.getUserVipByUserId(wxJsOrder.getUserId());
|
|
|
+ if(userVip!=null) {
|
|
|
+ //修改会员信息
|
|
|
+ Date km1Date = userVip.getSubject1();
|
|
|
+ Date km2Date = userVip.getSubject2();
|
|
|
+ Date km3Date = userVip.getSubject3();
|
|
|
+ Date km4Date = userVip.getSubject4();
|
|
|
+ if(km1Date!=null) { //科目一处理
|
|
|
+ long x = km1Date.getTime() + oneYearLong;
|
|
|
+ Date km1oneYear = new Date(x);
|
|
|
+ userVip.setSubject1(km1oneYear);
|
|
|
+ } else {
|
|
|
+ long x = now.getTime() + oneYearLong;
|
|
|
+ Date km1oneYear = new Date(x);
|
|
|
+ userVip.setSubject1(km1oneYear);
|
|
|
+ }
|
|
|
+ if(km2Date!=null) { //科目二处理
|
|
|
+ long x = km2Date.getTime() + oneYearLong;
|
|
|
+ Date km2oneYear = new Date(x);
|
|
|
+ userVip.setSubject2(km2oneYear);
|
|
|
+ } else {
|
|
|
+ long x = now.getTime() + oneYearLong;
|
|
|
+ Date km2oneYear = new Date(x);
|
|
|
+ userVip.setSubject2(km2oneYear);
|
|
|
+ }
|
|
|
+ if(km3Date!=null) { //科目三处理
|
|
|
+ long x = km3Date.getTime() + oneYearLong;
|
|
|
+ Date km3oneYear = new Date(x);
|
|
|
+ userVip.setSubject3(km3oneYear);
|
|
|
+ } else {
|
|
|
+ long x = now.getTime() + oneYearLong;
|
|
|
+ Date km3oneYear = new Date(x);
|
|
|
+ userVip.setSubject3(km3oneYear);
|
|
|
+ }
|
|
|
+ if(km4Date!=null) { //科目四处理
|
|
|
+ long x = km4Date.getTime() + oneYearLong;
|
|
|
+ Date km4oneYear = new Date(x);
|
|
|
+ userVip.setSubject4(km4oneYear);
|
|
|
+ } else {
|
|
|
+ long x = now.getTime() + oneYearLong;
|
|
|
+ Date km4oneYear = new Date(x);
|
|
|
+ userVip.setSubject4(km4oneYear);
|
|
|
+ }
|
|
|
+ userVipService.updateById(userVip);
|
|
|
+ } else {
|
|
|
+ //新增会员信息
|
|
|
+ UserVip uv = new UserVip();
|
|
|
+ uv.setUserId(wxJsOrder.getUserId());
|
|
|
+ uv.setUserName(wxJsOrder.getUserName());
|
|
|
+ long x = now.getTime() + oneYearLong;
|
|
|
+ Date oneYear = new Date(x);
|
|
|
+ uv.setSubject1(oneYear);
|
|
|
+ uv.setSubject2(oneYear);
|
|
|
+ uv.setSubject3(oneYear);
|
|
|
+ uv.setSubject4(oneYear);
|
|
|
+ userVipService.updateById(uv);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
private String getSourString(WxpayNotifyDTO wxpayNotifyDTO) throws GeneralSecurityException, IOException {
|
|
|
AesUtil aesUtil = new AesUtil(wxpayConfig.getV3key().getBytes());
|
|
|
WxpayNotifyDTO.WxpaySource wxpaySource = wxpayNotifyDTO.getResource();
|