|
@@ -7,9 +7,12 @@ import cn.hutool.core.util.RandomUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.fasterxml.jackson.databind.JsonNode;
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
+import com.google.gson.Gson;
|
|
|
import com.google.gson.JsonObject;
|
|
|
import com.google.gson.JsonParser;
|
|
|
import lombok.extern.log4j.Log4j2;
|
|
@@ -23,17 +26,21 @@ import org.jeecg.common.util.DictAnnotationUtil;
|
|
|
import org.jeecg.modules.app.dto.AppOrderInfoDTO;
|
|
|
import org.jeecg.modules.app.form.CreateOrderForm;
|
|
|
import org.jeecg.modules.app.form.InsureOrderInfoForm;
|
|
|
+import org.jeecg.modules.app.form.PageOrdersForm;
|
|
|
import org.jeecg.modules.app.form.UserPayForm;
|
|
|
import org.jeecg.modules.app.service.IOrderService;
|
|
|
import org.jeecg.modules.app.vo.AppGameScheduleVO;
|
|
|
import org.jeecg.modules.app.vo.OrderVO;
|
|
|
+import org.jeecg.modules.app.vo.PageOrdersVO;
|
|
|
import org.jeecg.modules.app.vo.QueryOrderVerifyRecordsVO;
|
|
|
+import org.jeecg.modules.pay.request.v3.labs.TradeQueryRequest;
|
|
|
import org.jeecg.modules.pay.vo.NotifyRequest;
|
|
|
import org.jeecg.modules.pay.vo.NotifyResponse;
|
|
|
import org.jeecg.modules.redission.RedissonDelayQueue;
|
|
|
import org.jeecg.modules.system.app.entity.*;
|
|
|
import org.jeecg.modules.system.app.mapper.*;
|
|
|
-import org.jeecg.modules.system.mapper.SysDepartMapper;
|
|
|
+import org.jeecg.modules.system.entity.SysUser;
|
|
|
+import org.jeecg.modules.system.mapper.SysUserMapper;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
@@ -65,7 +72,7 @@ public class OrderServiceImpl implements IOrderService {
|
|
|
@Resource
|
|
|
private AppOrderMapper appOrderMapper;
|
|
|
@Resource
|
|
|
- private SysDepartMapper sysDepartMapper;
|
|
|
+ private SysUserMapper sysUserMapper;
|
|
|
@Resource
|
|
|
private AppSiteMapper appSiteMapper;
|
|
|
@Resource
|
|
@@ -372,6 +379,8 @@ public class OrderServiceImpl implements IOrderService {
|
|
|
//获取登录用户
|
|
|
LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
|
|
|
|
|
+ SysUser sysUser = sysUserMapper.selectById(user.getId());
|
|
|
+
|
|
|
String orderCode = generateOrderNumber(0);
|
|
|
|
|
|
//创建订单
|
|
@@ -380,6 +389,7 @@ public class OrderServiceImpl implements IOrderService {
|
|
|
.setOrderType(createOrderForm.getOrderType())
|
|
|
.setOrderCode(orderCode)
|
|
|
.setUserId(user.getId())
|
|
|
+ .setUserOpenId(sysUser.getOpenid())
|
|
|
.setUserPhone(user.getPhone())
|
|
|
.setOrderStatus(0)
|
|
|
.setProductIds(createOrderForm.getProductIds())
|
|
@@ -656,7 +666,7 @@ public class OrderServiceImpl implements IOrderService {
|
|
|
appOrderProInfo.setProductName(appCourse.getName());
|
|
|
appOrderProInfo.setAddress(appSite.getAddress());
|
|
|
appOrderProInfo.setType(CommonConstant.ORDER_PRO_INFO_TYPE_6);
|
|
|
- appOrderProInfo.setFrameTimeStr(DateUtil.format(appCourse.getStartTime(), "yyyy-MM-dd") + "-" + DateUtil.format(appCourse.getEndTime(), "yyyy-MM-dd"));
|
|
|
+ appOrderProInfo.setFrameTimeStr(DateUtil.format(appCourse.getStartTime(), "yyyy-MM-dd") + "-" + DateUtil.format(appCourse.getEndTime(), "MM-dd"));
|
|
|
appOrderProInfo.setExpireTime(DateUtil.format(appCourse.getEndTime(), "yyyy-MM-dd"));
|
|
|
appOrderProInfo.setOriginalPrice(appCourse.getOriginalPrice());
|
|
|
appOrderProInfo.setPrice(appCourse.getSellingPrice());
|
|
@@ -822,10 +832,12 @@ public class OrderServiceImpl implements IOrderService {
|
|
|
}
|
|
|
}
|
|
|
//保存核销记录
|
|
|
- for (AppCoursesVerificationRecord appCoursesVerificationRecord : appCoursesVerificationRecordList) {
|
|
|
- appCoursesVerificationRecord.setOrderId(appOrder.getId());
|
|
|
- appCoursesVerificationRecord.setOrderCode(appOrder.getOrderCode());
|
|
|
- appCoursesVerificationRecordMapper.insert(appCoursesVerificationRecord);
|
|
|
+ if (CollUtil.isNotEmpty(proInfoList)) {
|
|
|
+ for (AppCoursesVerificationRecord appCoursesVerificationRecord : appCoursesVerificationRecordList) {
|
|
|
+ appCoursesVerificationRecord.setOrderId(appOrder.getId());
|
|
|
+ appCoursesVerificationRecord.setOrderCode(appOrder.getOrderCode());
|
|
|
+ appCoursesVerificationRecordMapper.insert(appCoursesVerificationRecord);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
//构建支付表单返回给前端支撑JsApi支付调用
|
|
@@ -1261,11 +1273,78 @@ public class OrderServiceImpl implements IOrderService {
|
|
|
.setPayTime(DateUtil.parse(notifyRequestForm.getTrade_time(),"yyyyMMddHHmmss"))
|
|
|
.setCallbackStatus(1);
|
|
|
}
|
|
|
+
|
|
|
NotifyResponse notifyResponse = new NotifyResponse();
|
|
|
notifyResponse.setCode("SUCCESS").setMessage("执行成功");
|
|
|
+
|
|
|
return notifyResponse;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public String orderQuery(String orderCode) throws IOException {
|
|
|
+
|
|
|
+ // 初始化查询交易接口请求报文
|
|
|
+ TradeQueryRequest request = new TradeQueryRequest();
|
|
|
+ // 商户交易流水号
|
|
|
+ request.setOut_trade_no(orderCode);
|
|
|
+// String res = V3LabsApi.queryTradeQuery(request);
|
|
|
+ String res = "";
|
|
|
+ Gson gson = new Gson();
|
|
|
+ NotifyRequest notifyRequest = gson.fromJson(res, NotifyRequest.class);
|
|
|
+
|
|
|
+ //查询订单
|
|
|
+ AppOrder appOrder = appOrderMapper.selectOne(Wrappers.<AppOrder>lambdaQuery().eq(AppOrder::getOrderCode, notifyRequest.getOut_trade_no()).last("limit 1"));
|
|
|
+ if (ObjectUtil.isNotEmpty(appOrder)) {
|
|
|
+ appOrder
|
|
|
+ .setPayId(notifyRequest.getAcc_trade_no())
|
|
|
+ .setOrderStatus(2)
|
|
|
+ .setPayStatus(2)
|
|
|
+ .setPayTime(DateUtil.parse(notifyRequest.getTrade_time(),"yyyyMMddHHmmss"))
|
|
|
+ .setCallbackStatus(1);
|
|
|
+ }
|
|
|
+
|
|
|
+ return "支付成功!";
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public String cancelOrder(String orderId) {
|
|
|
+ AppOrder appOrder = appOrderMapper.selectById(orderId);
|
|
|
+ if(ObjectUtil.isNotEmpty(appOrder)){
|
|
|
+ if (appOrder.getOrderStatus() == 0){
|
|
|
+ log.info("修改订单:{},支付状态为已取消", orderId);
|
|
|
+ appOrder.setOrderStatus(4);
|
|
|
+ appOrderMapper.updateById(appOrder);
|
|
|
+ List<AppOrderProInfo> appOrderProInfoList = appOrderProInfoMapper.selectList(Wrappers.<AppOrderProInfo>lambdaQuery().eq(AppOrderProInfo::getOrderId, orderId));
|
|
|
+ for (AppOrderProInfo appOrderProInfo : appOrderProInfoList) {
|
|
|
+ appOrderProInfo.setOrderStatus(2);
|
|
|
+ appOrderProInfoMapper.updateById(appOrderProInfo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return "取消成功!";
|
|
|
+ }
|
|
|
+ return "取消失败!未查询到订单!";
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public IPage<PageOrdersVO> pageOrders(PageOrdersForm pageOrdersForm) {
|
|
|
+
|
|
|
+ LoginUser loginUser = (LoginUser)SecurityUtils.getSubject().getPrincipal();
|
|
|
+ pageOrdersForm.setUserId(loginUser.getId());
|
|
|
+
|
|
|
+ Page<PageOrdersVO> page = new Page<>(pageOrdersForm.getPageNum(), pageOrdersForm.getPageSize());
|
|
|
+
|
|
|
+ IPage<PageOrdersVO> pageOrders = appOrderMapper.pageOrders(page,pageOrdersForm);
|
|
|
+
|
|
|
+ pageOrders.getRecords().forEach(record -> {
|
|
|
+ List<AppOrderProInfo> proInfoList = appOrderProInfoMapper.selectList(Wrappers.<AppOrderProInfo>lambdaQuery().eq(AppOrderProInfo::getOrderId, record.getOrderId()));
|
|
|
+ if (CollUtil.isNotEmpty(proInfoList)) {
|
|
|
+ record.setOrderProInfoList(proInfoList);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ return pageOrders;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* @return String 订单号
|
|
|
* @Author SheepHy
|