|
@@ -17,6 +17,7 @@ import com.fasterxml.jackson.databind.JsonNode;
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
import com.google.gson.JsonObject;
|
|
|
import com.google.gson.JsonParser;
|
|
|
+import com.wechat.pay.contrib.apache.httpclient.util.AesUtil;
|
|
|
import lombok.extern.log4j.Log4j2;
|
|
|
import org.apache.commons.lang3.ObjectUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
@@ -38,6 +39,7 @@ import org.jeecg.modules.app.vo.PageOrdersVO;
|
|
|
import org.jeecg.modules.app.vo.QueryOrderVerifyRecordsVO;
|
|
|
import org.jeecg.modules.pay.config.WechatConstants;
|
|
|
import org.jeecg.modules.pay.config.WechatUrlConstants;
|
|
|
+import org.jeecg.modules.pay.serverPay.WxV3PayConfig;
|
|
|
import org.jeecg.modules.redission.RedissonDelayQueue;
|
|
|
import org.jeecg.modules.system.app.dto.receiptPaymentDetails.ReceiptPaymentDetailsInfoVo;
|
|
|
import org.jeecg.modules.system.app.entity.*;
|
|
@@ -54,9 +56,13 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+import java.io.BufferedReader;
|
|
|
import java.io.IOException;
|
|
|
+import java.io.PrintWriter;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.math.RoundingMode;
|
|
|
+import java.nio.charset.StandardCharsets;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.time.LocalDate;
|
|
|
import java.time.LocalTime;
|
|
@@ -890,15 +896,15 @@ public class OrderServiceImpl implements IOrderService {
|
|
|
.eq(AppOrderProInfo::getProductId, appCourse.getId())
|
|
|
.eq(AppOrderProInfo::getFamilyUserId, familyUserId));
|
|
|
List<AppOrderProInfo> infoList = infos.stream().filter(info -> Objects.equals(info.getOrFreePro(), CommonConstant.STATUS_0_INT)).collect(Collectors.toList());
|
|
|
- if (ObjectUtil.isNotEmpty(infoList)) {
|
|
|
- throw new JeecgBootException("当前课程已下过单,请勿重复下单");
|
|
|
- }
|
|
|
- if (Objects.equals(createOrderForm.getOrFreeOrder(), CommonConstant.STATUS_1_INT)){
|
|
|
- List<AppOrderProInfo> freeProList = infos.stream().filter(info -> Objects.equals(info.getOrFreePro(), CommonConstant.STATUS_0_INT)).collect(Collectors.toList());
|
|
|
- if (ObjectUtil.isNotEmpty(freeProList)) {
|
|
|
- throw new JeecgBootException("当前试听课课程已下过单,请勿重复下单");
|
|
|
- }
|
|
|
- }
|
|
|
+// if (ObjectUtil.isNotEmpty(infoList)) {
|
|
|
+// throw new JeecgBootException("当前课程已下过单,请勿重复下单");
|
|
|
+// }
|
|
|
+// if (Objects.equals(createOrderForm.getOrFreeOrder(), CommonConstant.STATUS_1_INT)){
|
|
|
+// List<AppOrderProInfo> freeProList = infos.stream().filter(info -> Objects.equals(info.getOrFreePro(), CommonConstant.STATUS_0_INT)).collect(Collectors.toList());
|
|
|
+// if (ObjectUtil.isNotEmpty(freeProList)) {
|
|
|
+// throw new JeecgBootException("当前试听课课程已下过单,请勿重复下单");
|
|
|
+// }
|
|
|
+// }
|
|
|
AppOrderProInfo appOrderProInfo = new AppOrderProInfo();
|
|
|
appOrderProInfo.setProductId(createOrderForm.getProductIds());
|
|
|
appOrderProInfo.setProductName(appCourse.getName());
|
|
@@ -1150,13 +1156,13 @@ public class OrderServiceImpl implements IOrderService {
|
|
|
params.put("attach", appOrder.getOrderCode()); //附加数据 选填
|
|
|
// 在查询API和支付通知中原样返回 可作为自定义参数使用
|
|
|
params.put("notify_url", WechatUrlConstants.PAY_V3_NOTIFY); //支付结果异步通知接口
|
|
|
- params.put("trade_type", WechatConstants.WECHAT_TRADE_TYPE);//JSAPI
|
|
|
+// params.put("trade_type", WechatConstants.WECHAT_TRADE_TYPE);//JSAPI
|
|
|
//分账必传参数
|
|
|
JSONObject settleInfo = new JSONObject();
|
|
|
settleInfo.put("profit_sharing", Boolean.TRUE);
|
|
|
params.put("settle_info", settleInfo);
|
|
|
//电子发票入口
|
|
|
- params.put("support_fapiao ", Boolean.TRUE);
|
|
|
+// params.put("support_fapiao ", Boolean.TRUE);
|
|
|
|
|
|
//订单金额信息
|
|
|
JSONObject amount_json = new JSONObject();
|
|
@@ -1169,12 +1175,12 @@ public class OrderServiceImpl implements IOrderService {
|
|
|
//支付者信息
|
|
|
JSONObject payer = new JSONObject();
|
|
|
//用户在小程序侧的openid
|
|
|
- payer.put("openid", sysUser.getOpenid());
|
|
|
+ payer.put("sub_openid", "oObyf7Z4-Y9P5w6_8YIKEiKSAD6I");
|
|
|
params.put("payer", payer);
|
|
|
|
|
|
//拉起支付-返回JSAPI参数
|
|
|
-// Map<String, String> result = weChatPayService.wechatPay(params);
|
|
|
-// payForm.setParams(result);
|
|
|
+ Map<String, String> result = weChatPayService.wechatPay(params);
|
|
|
+ payForm.setParams(result);
|
|
|
|
|
|
//发布任务到redission延迟队列
|
|
|
String task = CommonConstant.ORDER_TIME_OUT_TASK_PREFIX + appOrder.getId();
|
|
@@ -1426,11 +1432,7 @@ public class OrderServiceImpl implements IOrderService {
|
|
|
if (appOrder.getType().equals(CommonConstant.ORDER_TYPE_1)) {
|
|
|
//商品信息
|
|
|
String productIds = appOrder.getProductIds();
|
|
|
- AppGamePriceRules appGamePriceRules = appGamePriceRulesMapper.selectById(productIds);
|
|
|
- AppGame appGame = appGameMapper.selectById(appGamePriceRules.getGameId());
|
|
|
-
|
|
|
- //门店信息
|
|
|
- AppSite site = appSiteMapper.selectById(appGame.getSiteId());
|
|
|
+ AppGame appGame = appGameMapper.findByPriceRules(productIds);
|
|
|
//退改规则、
|
|
|
appOrderInfoDTO.setReminder(appGame.getReminder());
|
|
|
//开始时间
|
|
@@ -1443,11 +1445,17 @@ public class OrderServiceImpl implements IOrderService {
|
|
|
//赛程数
|
|
|
appOrderInfoDTO.setGameScheduleNum(appGameScheduleVOList.size());
|
|
|
//地址信息
|
|
|
- appOrderInfoDTO.setSchoolAddress(site.getAddress());
|
|
|
- appOrderInfoDTO.setLatitude(site.getLatitude());
|
|
|
- appOrderInfoDTO.setLongitude(site.getLongitude());
|
|
|
- appOrderInfoDTO.setPhone(site.getPhone());
|
|
|
- appOrderInfoDTO.setAddressSiteId(site.getId());
|
|
|
+ appOrderInfoDTO.setGameAddress(appGame.getSiteAddress());
|
|
|
+ appOrderInfoDTO.setLatitude(appGame.getLatitude());
|
|
|
+ appOrderInfoDTO.setLongitude(appGame.getLongitude());
|
|
|
+ if (appGame.getSiteType().equals(CommonConstant.STATUS_1_INT)) {
|
|
|
+ //门店信息
|
|
|
+ AppSite site = appSiteMapper.selectById(appGame.getSiteId());
|
|
|
+ if (ObjectUtils.isNotEmpty(site)){
|
|
|
+ appOrderInfoDTO.setPhone(site.getPhone());
|
|
|
+ appOrderInfoDTO.setAddressSiteId(site.getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
//课程
|
|
@@ -1713,8 +1721,42 @@ public class OrderServiceImpl implements IOrderService {
|
|
|
return "退款失败!";
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- public Map<String, String> wechatPayNotify(HttpServletRequest request) {
|
|
|
+ public Map<String, String> wechatPayNotify(HttpServletRequest request, HttpServletResponse response) {
|
|
|
+
|
|
|
+ try {
|
|
|
+ System.err.println("微信回调");
|
|
|
+ BufferedReader reader = request.getReader();
|
|
|
+ String string1 = reader.toString();
|
|
|
+ StringBuilder requestBody = new StringBuilder();
|
|
|
+ String line;
|
|
|
+ while ((line = reader.readLine()) != null) {
|
|
|
+ requestBody.append(line);
|
|
|
+ }
|
|
|
+ System.err.println("全部请求体" + requestBody);
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(requestBody.toString());
|
|
|
+ JSONObject resource = jsonObject.getJSONObject("resource");
|
|
|
+ AesUtil aesUtil = new AesUtil(WxV3PayConfig.apiV3Key.getBytes(StandardCharsets.UTF_8));
|
|
|
+ String decryptedData = aesUtil.decryptToString(resource.getString("associated_data").getBytes(StandardCharsets.UTF_8), resource.getString("nonce").getBytes(StandardCharsets.UTF_8),
|
|
|
+ resource.getString("ciphertext"));
|
|
|
+ System.err.println("微信解密的字符串信息" + decryptedData);
|
|
|
+ JSONObject jsonInfo = (JSONObject) JSONObject.parse(decryptedData);
|
|
|
+ String out_trade_no = jsonInfo.getString("out_trade_no");// 下单时传给微信的订单号
|
|
|
+ String transaction_id = jsonInfo.getString("transaction_id");// 返回的微信订单号
|
|
|
+ String trade_state = jsonInfo.getString("trade_state");// 交易状态 /*SUCCESS:支付成功 REFUND:转入退款 NOTPAY:未支付 CLOSED:已关闭 REVOKED:已撤销(仅付款码支付会返回)USERPAYING:用户支付中(仅付款码支付会返回)PAYERROR:支付失败(仅付款码支付会返回*/
|
|
|
+
|
|
|
+
|
|
|
+ if (trade_state.equals("SUCCESS")) {
|
|
|
+ // 支付成功,执行相应的代码逻辑即可
|
|
|
+ PrintWriter out = response.getWriter();
|
|
|
+ out.write("SUCCESS");
|
|
|
+ out.flush();
|
|
|
+ out.close();
|
|
|
+ }
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+
|
|
|
Map<String, String> stringStringMap = weChatPayService.wechatPayNotify(request);
|
|
|
//对订单进行封账金额统计
|
|
|
if (stringStringMap != null
|