|
@@ -5,10 +5,14 @@ import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.miaxis.common.config.WxpayConfig;
|
|
|
import com.miaxis.common.constant.Constants;
|
|
|
+import com.miaxis.common.core.domain.entity.SysDictData;
|
|
|
import com.miaxis.common.core.domain.entity.UserInfo;
|
|
|
import com.miaxis.common.exception.CustomException;
|
|
|
import com.miaxis.common.utils.AesUtil;
|
|
|
import com.miaxis.common.utils.SecurityUtils;
|
|
|
+import com.miaxis.system.service.ISysConfigService;
|
|
|
+import com.miaxis.system.service.ISysDictDataService;
|
|
|
+import com.miaxis.system.service.ISysDictTypeService;
|
|
|
import com.miaxis.user.service.IUserInfoService;
|
|
|
import com.miaxis.vip.domain.VipCode;
|
|
|
import com.miaxis.vip.service.IVipCodeService;
|
|
@@ -41,6 +45,8 @@ import java.nio.charset.StandardCharsets;
|
|
|
import java.security.*;
|
|
|
import java.security.cert.X509Certificate;
|
|
|
import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Optional;
|
|
|
import java.util.Random;
|
|
|
|
|
|
@RestController
|
|
@@ -72,6 +78,8 @@ public class WxNotifyController {
|
|
|
@Autowired
|
|
|
private AutoUpdateCertificatesVerifier verifier;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ISysDictTypeService sysDictTypeService;
|
|
|
|
|
|
/**
|
|
|
* 微信支付回调接口
|
|
@@ -96,36 +104,36 @@ public class WxNotifyController {
|
|
|
return wxNotifyReturnDTO;
|
|
|
}
|
|
|
|
|
|
- private void avtivityCode(String outTradeNo, String vipCode) {
|
|
|
- WxOrder wxOrder = wxOrderService.getByOutTradeNo(outTradeNo);
|
|
|
- if (wxOrder == null){
|
|
|
- throw new CustomException("改订单不存在");
|
|
|
- }
|
|
|
- UserInfo userInfo = userInfoService.getOne(new QueryWrapper<UserInfo>().eq("app_openid", wxOrder.getAppOpenid()));
|
|
|
- QueryWrapper<VipCode> queryWrapper = new QueryWrapper<VipCode>();
|
|
|
- queryWrapper.eq("vip_code", vipCode);
|
|
|
- VipCode vipCodeEntity = vipCodeService.getOne(queryWrapper);
|
|
|
- if (vipCodeEntity == null){
|
|
|
- throw new CustomException("该激活码不存在");
|
|
|
- }
|
|
|
- if (vipCodeEntity.getStatus() == 1){
|
|
|
- throw new CustomException("该激活码已被激活");
|
|
|
- }
|
|
|
- if (vipCodeEntity.getStatus() == 2){
|
|
|
- throw new CustomException("该激活码已作废");
|
|
|
- }
|
|
|
- vipCodeEntity.setStatus(1);
|
|
|
- vipCodeEntity.setActivationUserId(userInfo.getId());
|
|
|
- vipCodeEntity.setActivationTime(new Date());
|
|
|
- vipCodeService.updateById(vipCodeEntity);
|
|
|
-
|
|
|
-
|
|
|
- userInfoService.updateById(userInfo);
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- }
|
|
|
+// private void avtivityCode(String outTradeNo, String vipCode) {
|
|
|
+// WxOrder wxOrder = wxOrderService.getByOutTradeNo(outTradeNo);
|
|
|
+// if (wxOrder == null){
|
|
|
+// throw new CustomException("改订单不存在");
|
|
|
+// }
|
|
|
+// UserInfo userInfo = userInfoService.getOne(new QueryWrapper<UserInfo>().eq("app_openid", wxOrder.getAppOpenid()));
|
|
|
+// QueryWrapper<VipCode> queryWrapper = new QueryWrapper<VipCode>();
|
|
|
+// queryWrapper.eq("vip_code", vipCode);
|
|
|
+// VipCode vipCodeEntity = vipCodeService.getOne(queryWrapper);
|
|
|
+// if (vipCodeEntity == null){
|
|
|
+// throw new CustomException("该激活码不存在");
|
|
|
+// }
|
|
|
+// if (vipCodeEntity.getStatus() == 1){
|
|
|
+// throw new CustomException("该激活码已被激活");
|
|
|
+// }
|
|
|
+// if (vipCodeEntity.getStatus() == 2){
|
|
|
+// throw new CustomException("该激活码已作废");
|
|
|
+// }
|
|
|
+// vipCodeEntity.setStatus(1);
|
|
|
+// vipCodeEntity.setActivationUserId(userInfo.getId());
|
|
|
+// vipCodeEntity.setActivationTime(new Date());
|
|
|
+// vipCodeService.updateById(vipCodeEntity);
|
|
|
+//
|
|
|
+//
|
|
|
+// userInfoService.updateById(userInfo);
|
|
|
+//
|
|
|
+//
|
|
|
+//
|
|
|
+//
|
|
|
+// }
|
|
|
|
|
|
private String createCode() {
|
|
|
VipCode vipCode = new VipCode();
|
|
@@ -261,7 +269,7 @@ public class WxNotifyController {
|
|
|
if (sceneInfo != null){
|
|
|
wxOrder.setDeviceId(sceneInfo.getString("device_id"));
|
|
|
}
|
|
|
- wxOrderService.updateById(wxOrder);
|
|
|
+
|
|
|
//如果回调是订单状态是SUCCESS的话
|
|
|
if ("SUCCESS".equals(wxOrder.getTradeState())){
|
|
|
UserInfo userInfo = userInfoService.getOne(new QueryWrapper<UserInfo>().eq("union_id", wxOrder.getUnionId()));
|
|
@@ -270,6 +278,30 @@ public class WxNotifyController {
|
|
|
Integer isVip = Integer.valueOf(s);
|
|
|
userInfo.setIsVip(isVip);
|
|
|
userInfoService.updateById(userInfo);
|
|
|
+ //充值普通会员 进行分佣
|
|
|
+ if (isVip == 2){
|
|
|
+ //根据订单查询推荐主播
|
|
|
+ UserInfo zhubo = userInfoService.getById(wxOrder.getReferralUserId());
|
|
|
+ //根据主播查询合伙人
|
|
|
+ UserInfo hehuoren = userInfoService.getOne(new QueryWrapper<UserInfo>().eq("union_id",zhubo.getUnionId()));
|
|
|
+ //根据合伙人查询合伙人以及主播的分佣
|
|
|
+ List<SysDictData> partnerConfigs = sysDictTypeService.selectDictDataByType("partner_config");
|
|
|
+ Optional<SysDictData> first = partnerConfigs.stream().filter(o -> hehuoren.getUnionId().equals(o.getDictLabel())).findFirst();
|
|
|
+ String[] partnerConfig = first.get().getDictValue().split(",");
|
|
|
+ Integer hehuorenPencents = Integer.valueOf(partnerConfig[1]);
|
|
|
+ Integer zhuboPencents =Integer.valueOf(partnerConfig[2]);
|
|
|
+ Integer pay = wxOrder.getTotal();
|
|
|
+ Integer hehuorenFencheng =pay*hehuorenPencents/100;
|
|
|
+ Integer zhuboFencheng =pay*zhuboPencents/100;
|
|
|
+ wxOrder.setCommissionPrice(zhuboFencheng);
|
|
|
+ zhubo.setProfitPrice(zhubo.getProfitPrice()+zhuboFencheng);
|
|
|
+ hehuoren.setProfitPrice(hehuoren.getProfitPrice()+hehuorenFencheng);
|
|
|
+ userInfoService.updateById(zhubo);
|
|
|
+ userInfoService.updateById(hehuoren);
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ wxOrderService.updateById(wxOrder);
|
|
|
}
|
|
|
return outTradeNo;
|
|
|
|