|
@@ -3,6 +3,7 @@ package com.hys.app.controller.erp.use;
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
import cn.hutool.http.HttpUtil;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
@@ -67,7 +68,7 @@ import java.util.stream.Collectors;
|
|
|
@Validated
|
|
|
@AllArgsConstructor
|
|
|
public class PayController extends HttpServlet {
|
|
|
-// private OrderManager orderManager;
|
|
|
+ // private OrderManager orderManager;
|
|
|
private AliPayService aliPayService;
|
|
|
private WxPayServiceMy wxPayServiceMy;
|
|
|
private CompanyErpManager companyManager;
|
|
@@ -81,6 +82,7 @@ public class PayController extends HttpServlet {
|
|
|
@PostMapping("/getPayUrl")
|
|
|
public Object getListByScan(@RequestBody @Validated PayTypeUrl payTypeUrl) throws UnknownHostException, WxPayException {
|
|
|
CompanyErp company = companyManager.getById(payTypeUrl.getId());
|
|
|
+ AdminUser user = adminUserMapper.selectById(payTypeUrl.getId());
|
|
|
if (ObjectUtil.isNull(company)) {
|
|
|
throw new ServiceException("未查询到公司信息");
|
|
|
}
|
|
@@ -88,13 +90,18 @@ public class PayController extends HttpServlet {
|
|
|
payOrder.setTraceNo(company.getId().toString());
|
|
|
payOrder.setSubject("购买公司使用权账号");
|
|
|
payOrder.setTimeExpire(LocalDateTime.now().plusMinutes(30));
|
|
|
- payOrder.setTotalAmount(company.getThisMoney().doubleValue());
|
|
|
+// payOrder.setTotalAmount(company.getThisMoney().doubleValue());
|
|
|
+ payOrder.setTotalAmount(0.01);
|
|
|
payOrder.setOrderPayType("company");
|
|
|
switch (payTypeUrl.getPayType()) {
|
|
|
case "ali":
|
|
|
return aliPayService.pay(payOrder);
|
|
|
case "wx":
|
|
|
- return "暂未开通";
|
|
|
+ if (StrUtil.isBlank(user.getOpenid())) {
|
|
|
+ throw new WxPayException("当前用户未绑定微信,请前往我的个人信息里面绑定微信后再支付");
|
|
|
+ }
|
|
|
+ payOrder.setOpenId(user.getOpenid());
|
|
|
+ return wxPayServiceMy.pay(payOrder);
|
|
|
default:
|
|
|
return "不支持的支付方式";
|
|
|
}
|
|
@@ -231,7 +238,7 @@ public class PayController extends HttpServlet {
|
|
|
.addData(new WxMpTemplateData("character_string6", "A14010001688", "#173177"))
|
|
|
.addData(new WxMpTemplateData("thing8", "贸易通订单流程待处理通知", "#173177"))
|
|
|
.addData(new WxMpTemplateData("character_string13", "202308060001!", "#173177"));
|
|
|
- WxMpService wxService = new WxMpServiceImpl();
|
|
|
+ WxMpService wxService = new WxMpServiceImpl();
|
|
|
WxMpDefaultConfigImpl config = new WxMpDefaultConfigImpl();
|
|
|
config.setAppId("wx51e98f2dee35237d"); // 替换为你的 AppID
|
|
|
config.setSecret("13803c1b0d911e023c7da0b300cbce89"); // 替换为你的 AppSecret
|