|
@@ -6,8 +6,10 @@ import cn.hutool.core.lang.Validator;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.google.zxing.BarcodeFormat;
|
|
|
import com.google.zxing.client.j2se.MatrixToImageWriter;
|
|
|
import com.google.zxing.common.BitMatrix;
|
|
@@ -37,6 +39,7 @@ import com.zhongzheng.modules.course.service.ICourseProjectTypeService;
|
|
|
import com.zhongzheng.modules.course.service.ICourseService;
|
|
|
import com.zhongzheng.modules.distribution.domain.*;
|
|
|
import com.zhongzheng.modules.distribution.service.*;
|
|
|
+import com.zhongzheng.modules.exam.domain.ExamApplyUser;
|
|
|
import com.zhongzheng.modules.goods.domain.Goods;
|
|
|
import com.zhongzheng.modules.goods.domain.GoodsQuestionRel;
|
|
|
import com.zhongzheng.modules.goods.domain.QuestionMerchant;
|
|
@@ -52,11 +55,9 @@ import com.zhongzheng.modules.grade.service.IStudyCountLogService;
|
|
|
import com.zhongzheng.modules.order.bo.OrderShareMoneyAddBo;
|
|
|
import com.zhongzheng.modules.order.domain.Order;
|
|
|
import com.zhongzheng.modules.order.domain.OrderGoods;
|
|
|
+import com.zhongzheng.modules.order.domain.OrderHandle;
|
|
|
import com.zhongzheng.modules.order.domain.OrderPay;
|
|
|
-import com.zhongzheng.modules.order.service.IOrderGoodsService;
|
|
|
-import com.zhongzheng.modules.order.service.IOrderPayService;
|
|
|
-import com.zhongzheng.modules.order.service.IOrderService;
|
|
|
-import com.zhongzheng.modules.order.service.IOrderShareMoneyService;
|
|
|
+import com.zhongzheng.modules.order.service.*;
|
|
|
import com.zhongzheng.modules.order.vo.OrderShareGoodsVo;
|
|
|
import com.zhongzheng.modules.order.vo.OrderShareToOldVo;
|
|
|
import com.zhongzheng.modules.system.domain.SysTenant;
|
|
@@ -89,6 +90,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
import java.io.ByteArrayOutputStream;
|
|
|
import java.io.IOException;
|
|
|
import java.math.BigDecimal;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
import java.util.stream.Collectors;
|
|
@@ -131,6 +133,9 @@ public class WxPayServiceImpl implements IWxPayService {
|
|
|
@Autowired
|
|
|
private RedisCache redisCache;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private IOrderHandleService iOrderHandleService;
|
|
|
+
|
|
|
@Autowired
|
|
|
private IUserExamGoodsService userExamGoodsService;
|
|
|
|
|
@@ -312,17 +317,14 @@ public class WxPayServiceImpl implements IWxPayService {
|
|
|
data.put("out_trade_no", out_trade_no);
|
|
|
data.put("device_info", "");
|
|
|
data.put("fee_type", "CNY");
|
|
|
- data.put("total_fee", price.intValue() + "");
|
|
|
+ data.put("total_fee", price.longValue() + "");
|
|
|
// data.put("openid", openid);
|
|
|
data.put("spbill_create_ip", IpUtils.getIpAddr(ServletUtils.getRequest()));
|
|
|
data.put("notify_url", notifyUrl);
|
|
|
data.put("trade_type", "NATIVE");
|
|
|
- Calendar calendar = Calendar .getInstance();
|
|
|
- calendar.setTime(new Date());
|
|
|
- calendar.add(calendar.MINUTE, 10);
|
|
|
- Date date = calendar.getTime();
|
|
|
- String time_expire = DateUtil.format(date,"yyyy-MM-dd'T' HH:mm:ssXXX");
|
|
|
- data.put("time_expire", time_expire);
|
|
|
+ Date date = new Date();
|
|
|
+ Date newDate = new Date(date.getTime() + 60000*30);
|
|
|
+ // data.put("time_expire", DateUtils.formatDateV3(newDate ,"yyyy-MM-dd'T'HH:mm:ssXXX"));
|
|
|
String TenantId = ServletUtils.getRequest().getHeader("TenantId");
|
|
|
data.put("attach", TenantId);
|
|
|
Map<String, String> resp = wxpay.unifiedOrder(data);
|
|
@@ -342,7 +344,7 @@ public class WxPayServiceImpl implements IWxPayService {
|
|
|
String urlBase64 = "data:image/jpeg;base64,"
|
|
|
+ encoder1.encodeToString(outputStream.toByteArray());
|
|
|
result.put("urlBase64", urlBase64);
|
|
|
- Integer overTime = (int)calendar.getTimeInMillis()/1000;
|
|
|
+ Long overTime = (long)(newDate.getTime()/1000);
|
|
|
result.put("overTime", overTime.toString());
|
|
|
return result;
|
|
|
} catch (Exception e) {
|
|
@@ -440,9 +442,16 @@ public class WxPayServiceImpl implements IWxPayService {
|
|
|
orderPay.setStatus(1);
|
|
|
orderPay.setUpdateTime(DateUtils.getNowTime());
|
|
|
iOrderPayService.updateById(orderPay);
|
|
|
- if (dealOrder(orderSn, transaction_id)) {
|
|
|
- xmlBack = "<xml><return_code><![CDATA[SUCCESS]]></return_code><return_msg><![CDATA[OK]]></return_msg></xml>";
|
|
|
- return xmlBack;
|
|
|
+ if(orderPay.getOrderFrom()==2){
|
|
|
+ if (dealHandleOrder(orderSn, transaction_id)) {
|
|
|
+ xmlBack = "<xml><return_code><![CDATA[SUCCESS]]></return_code><return_msg><![CDATA[OK]]></return_msg></xml>";
|
|
|
+ return xmlBack;
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ if (dealOrder(orderSn, transaction_id)) {
|
|
|
+ xmlBack = "<xml><return_code><![CDATA[SUCCESS]]></return_code><return_msg><![CDATA[OK]]></return_msg></xml>";
|
|
|
+ return xmlBack;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -494,6 +503,29 @@ public class WxPayServiceImpl implements IWxPayService {
|
|
|
return access_token;
|
|
|
}
|
|
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public boolean dealHandleOrder(String out_trade_no, String transaction_id) {
|
|
|
+ String key = out_trade_no;
|
|
|
+ String ticket = redisCache.getCacheObject(key);
|
|
|
+ if (Validator.isNotEmpty(ticket)) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ redisCache.setCacheObject(key, "dealing", 30, TimeUnit.SECONDS);//30秒
|
|
|
+ OrderHandle orderHandle = iOrderHandleService.queryBySn(out_trade_no);
|
|
|
+ if (orderHandle != null && orderHandle.getPayStauts() == 0) {
|
|
|
+ orderHandle.setPayTime(DateUtils.getNowTime());
|
|
|
+ orderHandle.setPayStauts(1);
|
|
|
+ orderHandle.setUpdateTime(DateUtils.getNowTime());
|
|
|
+ if (iOrderHandleService.updateById(orderHandle)) {
|
|
|
+ List<Order> list = iOrderService.list(new LambdaQueryWrapper<Order>().eq(Order::getHandleOrderSn, out_trade_no));
|
|
|
+ for(Order order : list){
|
|
|
+ dealOrder(order.getOrderSn(),transaction_id);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public boolean dealOrder(String out_trade_no, String transaction_id) {
|
|
|
String key = out_trade_no;
|