|
|
@@ -15,6 +15,7 @@ import cn.cslg.permission.common.utils.LoginUtils;
|
|
|
import cn.cslg.permission.common.utils.SecurityUtils.AesUtil;
|
|
|
import cn.cslg.permission.common.utils.StringUtils;
|
|
|
import cn.cslg.permission.common.utils.common.BigDecimalUtil;
|
|
|
+import cn.cslg.permission.domain.Personnel;
|
|
|
import cn.cslg.permission.domain.qiaobi.*;
|
|
|
import cn.cslg.permission.exception.ExceptionEnum;
|
|
|
import cn.cslg.permission.exception.XiaoShiException;
|
|
|
@@ -23,6 +24,7 @@ import cn.cslg.permission.factory.goodLimit.GoodLimitFactoryImp;
|
|
|
import cn.cslg.permission.factory.strategy.StrategyFatcory;
|
|
|
import cn.cslg.permission.factory.strategy.StrategyImp;
|
|
|
import cn.cslg.permission.mapper.qiaobi.MarketStrategyMapper;
|
|
|
+import cn.cslg.permission.service.PersonnelService;
|
|
|
import cn.cslg.permission.service.qiaobi.*;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
@@ -59,15 +61,23 @@ public class WeixinPayService {
|
|
|
private AssoPersonFunctionService assoPersonFunctionService;
|
|
|
@Autowired
|
|
|
private LoginUtils loginUtils;
|
|
|
- public static String apiV3key = "9Cx7SiQb7il8Zaf8nsBw5QxSCVZkoO7p";
|
|
|
+// public static String apiV3key = "9Cx7SiQb7il8Zaf8nsBw5QxSCVZkoO7p";
|
|
|
+ public static String apiV3key = "qiaobiruanjianjishushenzhen12345";
|
|
|
+
|
|
|
@Value("${payCallBack}")
|
|
|
public String payCallBack;
|
|
|
+ @Value("${WeixinPay.merchantId}")
|
|
|
+ public String merchantId;
|
|
|
+ @Value("${WeixinPay.appId}")
|
|
|
+ public String appId ;
|
|
|
@Autowired
|
|
|
private GoodByLimitService goodByLimitService;
|
|
|
@Autowired
|
|
|
private GoodLimitFactory goodLimitFactory;
|
|
|
@Autowired
|
|
|
private AppVipTypeService appVipTypeService;
|
|
|
+ @Autowired
|
|
|
+ private PersonnelService personnelService;
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public PayOrderReVO getPayTickets(PayOrderAddMessageDTO payOrderAddMessageDTO) {
|
|
|
@@ -78,8 +88,8 @@ public class WeixinPayService {
|
|
|
String url = "https://api.mch.weixin.qq.com/v3/pay/transactions/native";
|
|
|
String tradeNo = payOrder.getTradeNo();
|
|
|
com.wechat.pay.java.service.payments.nativepay.model.PrepayRequest prepayRequest = new com.wechat.pay.java.service.payments.nativepay.model.PrepayRequest();
|
|
|
- String appId = "wxe5f9b6e3d532e6c3";
|
|
|
- String merchantId = "1718408246";
|
|
|
+// String appId = "wxe5f9b6e3d532e6c3";
|
|
|
+// String merchantId = "1718408246";
|
|
|
String notifyUrl = payCallBack;
|
|
|
prepayRequest.setAppid(appId);
|
|
|
prepayRequest.setMchid(merchantId);
|
|
|
@@ -126,7 +136,7 @@ public class WeixinPayService {
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
- PayOrderReVO payOrderReVO =new PayOrderReVO();
|
|
|
+ PayOrderReVO payOrderReVO = new PayOrderReVO();
|
|
|
payOrderReVO.setCodeUrl(codeUrl);
|
|
|
payOrderReVO.setTradeNo(tradeNo);
|
|
|
return payOrderReVO;
|
|
|
@@ -153,8 +163,9 @@ public class WeixinPayService {
|
|
|
List<Goods> goods = goodsService.queryByIds(goodsIds);
|
|
|
List<Goods> goodTypes = goods.stream().filter(item -> item.getGoodType().equals(1)).collect(Collectors.toList());
|
|
|
if (goodTypes.size() > 1) {
|
|
|
- throw new XiaoShiException(ExceptionEnum.BUSINESS_CHECK, "不购买多个不同的会员");
|
|
|
+ throw new XiaoShiException(ExceptionEnum.BUSINESS_CHECK, "不能同时购买多个不同的会员");
|
|
|
}
|
|
|
+ Goods vipGoods = goods.stream().filter(item -> item.getGoodType().equals(1)).findFirst().orElse(null);
|
|
|
for (OrderGoodDTO item : orderGoodDTOList) {
|
|
|
Integer temGoodId = item.getGoodId();
|
|
|
Goods goods1 = goods.stream().filter(tem -> tem.getId().equals(temGoodId)).findFirst().orElse(null);
|
|
|
@@ -172,27 +183,26 @@ public class WeixinPayService {
|
|
|
String goodStrategiesStr = goods1.getGoodStrategy();
|
|
|
List<Integer> goodLimitsIds = new ArrayList<>();
|
|
|
List<Integer> goodStrategyList = new ArrayList<>();
|
|
|
- if (goodLimits != null) {
|
|
|
+ if (goodLimits != null && !goodLimits.trim().equals("")) {
|
|
|
String[] temStrs = StringUtils.split(goodLimits, ",");
|
|
|
for (int i = 0; i < temStrs.length; i++) {
|
|
|
- goodLimitsIds.add(Integer.parseInt(temStrs[i]));
|
|
|
+ if (temStrs[i] != null && !temStrs[i].trim().equals("")) {
|
|
|
+ goodLimitsIds.add(Integer.parseInt(temStrs[i]));
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
if (goodLimitsIds != null && goodLimitsIds.size() > 0) {
|
|
|
- List<GoodByLimit> goodByLimits = goodByLimitService.queryGoodLimit(goodLimitsIds);
|
|
|
- for (GoodByLimit goodByLimit : goodByLimits) {
|
|
|
- String methodName = goodByLimit.getLimitMethod();
|
|
|
- GoodLimitFactoryImp goodLimitFactoryImp = goodLimitFactory.getClass(methodName);
|
|
|
- goodLimitFactoryImp.DoGoodLimit(item);
|
|
|
- }
|
|
|
+// goodByLimitService.checkGoodsLimits(vipGoods, goods1, goodLimitsIds);
|
|
|
}
|
|
|
|
|
|
if (goodStrategiesStr != null) {
|
|
|
String[] temStrs = StringUtils.split(goodStrategiesStr, ",");
|
|
|
for (int i = 0; i < temStrs.length; i++) {
|
|
|
- goodStrategyList.add(Integer.parseInt(temStrs[i]));
|
|
|
+ if (temStrs[i] != null && !temStrs[i].trim().equals("")) {
|
|
|
+ goodStrategyList.add(Integer.parseInt(temStrs[i]));
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -222,7 +232,7 @@ public class WeixinPayService {
|
|
|
public WeixinSuccessVO decryptMessage(String associatedData, String nonce, String ciphertext) throws Exception {
|
|
|
Integer q = apiV3key.length();
|
|
|
System.out.println(q);
|
|
|
- String key = "9Cx7SiQb7il8Zaf8nsBw5QxSCVZkoO7p";
|
|
|
+ String key = apiV3key;
|
|
|
AesUtil aesUtil = new AesUtil(key.getBytes(StandardCharsets.UTF_8));
|
|
|
String d = aesUtil.decryptToString(associatedData.getBytes(StandardCharsets.UTF_8), nonce.getBytes(StandardCharsets.UTF_8), ciphertext);
|
|
|
|
|
|
@@ -259,7 +269,12 @@ public class WeixinPayService {
|
|
|
assoPersonVipTypeService.addPersonVIP2(goods, personId, vipId, totalNum, goodUnit);
|
|
|
} else if (type == 2) {
|
|
|
Integer functionId = goods.getGoodId();
|
|
|
- AssoPersonFunction assoPersonFunction = assoPersonFunctionService.getPersonFunction(personId, functionId);
|
|
|
+ Personnel personnel = personnelService.getById(personId);
|
|
|
+ Integer tenantId = null;
|
|
|
+ if (personnel != null) {
|
|
|
+ tenantId = personnel.getTenantId();
|
|
|
+ }
|
|
|
+ AssoPersonFunction assoPersonFunction = assoPersonFunctionService.getPersonFunction(personId, tenantId, functionId);
|
|
|
if (assoPersonFunction != null) {
|
|
|
Integer orgNum = assoPersonFunction.getCanUseCount();
|
|
|
orgNum = orgNum + totalNum;
|
|
|
@@ -269,6 +284,9 @@ public class WeixinPayService {
|
|
|
assoPersonFunction = new AssoPersonFunction();
|
|
|
assoPersonFunction.setFunctionId(functionId);
|
|
|
assoPersonFunction.setPersonId(personId);
|
|
|
+ if (personnel != null) {
|
|
|
+ assoPersonFunction.setTenantId(personnel.getTenantId());
|
|
|
+ }
|
|
|
assoPersonFunction.setCanUseCount(totalNum);
|
|
|
assoPersonFunction.insert();
|
|
|
}
|
|
|
@@ -283,7 +301,7 @@ public class WeixinPayService {
|
|
|
QueryPersonVipDTO queryPersonVipDTO = new QueryPersonVipDTO();
|
|
|
queryPersonVipDTO.setPersonId(personId);
|
|
|
QueryPersonVipVO queryPersonVipVO = assoPersonVipTypeService.getPersonActiveVip();
|
|
|
- if (queryPersonVipVO == null ) {
|
|
|
+ if (queryPersonVipVO == null) {
|
|
|
return;
|
|
|
}
|
|
|
Integer levelOrg = queryPersonVipVO.getVipLevel();
|
|
|
@@ -308,7 +326,7 @@ public class WeixinPayService {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- Goods goods1 = JSONObject.parseObject(fromMessage, Goods.class);
|
|
|
+ Goods goods1 = JSONObject.parseObject(fromMessage, Goods.class);
|
|
|
Double disPrice = this.calculateDisPrice(goods1, queryPersonVipVO);
|
|
|
if (disPrice > orderGoodDTO.getTotalPrice()) {
|
|
|
disPrice = BigDecimalUtil.division(orderGoodDTO.getTotalPrice(), 0.1, 2);
|
|
|
@@ -323,7 +341,7 @@ public class WeixinPayService {
|
|
|
}
|
|
|
|
|
|
public Double calculateDisPrice(Goods goods, QueryPersonVipVO queryPersonVipVO) {
|
|
|
- if(goods==null){
|
|
|
+ if (goods == null) {
|
|
|
throw new XiaoShiException("计算抵消价格错误,请联系管理员进行解决");
|
|
|
}
|
|
|
Integer unit = goods.getGoodUnit();
|