|
@@ -5,6 +5,7 @@ import cn.hutool.core.date.DateUtil;
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
import cn.hutool.core.util.RandomUtil;
|
|
import cn.hutool.core.util.RandomUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
+import com.alibaba.fastjson2.JSONObject;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
@@ -12,7 +13,6 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.fasterxml.jackson.databind.JsonNode;
|
|
import com.fasterxml.jackson.databind.JsonNode;
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
-import com.google.gson.Gson;
|
|
|
|
import com.google.gson.JsonObject;
|
|
import com.google.gson.JsonObject;
|
|
import com.google.gson.JsonParser;
|
|
import com.google.gson.JsonParser;
|
|
import lombok.extern.log4j.Log4j2;
|
|
import lombok.extern.log4j.Log4j2;
|
|
@@ -29,11 +29,13 @@ import org.jeecg.modules.app.form.InsureOrderInfoForm;
|
|
import org.jeecg.modules.app.form.PageOrdersForm;
|
|
import org.jeecg.modules.app.form.PageOrdersForm;
|
|
import org.jeecg.modules.app.form.UserPayForm;
|
|
import org.jeecg.modules.app.form.UserPayForm;
|
|
import org.jeecg.modules.app.service.IOrderService;
|
|
import org.jeecg.modules.app.service.IOrderService;
|
|
|
|
+import org.jeecg.modules.app.service.WeChatPayService;
|
|
import org.jeecg.modules.app.vo.AppGameScheduleVO;
|
|
import org.jeecg.modules.app.vo.AppGameScheduleVO;
|
|
import org.jeecg.modules.app.vo.OrderVO;
|
|
import org.jeecg.modules.app.vo.OrderVO;
|
|
import org.jeecg.modules.app.vo.PageOrdersVO;
|
|
import org.jeecg.modules.app.vo.PageOrdersVO;
|
|
import org.jeecg.modules.app.vo.QueryOrderVerifyRecordsVO;
|
|
import org.jeecg.modules.app.vo.QueryOrderVerifyRecordsVO;
|
|
-import org.jeecg.modules.pay.request.v3.labs.TradeQueryRequest;
|
|
|
|
|
|
+import org.jeecg.modules.pay.config.WechatConstants;
|
|
|
|
+import org.jeecg.modules.pay.config.WechatUrlConstants;
|
|
import org.jeecg.modules.pay.vo.NotifyRequest;
|
|
import org.jeecg.modules.pay.vo.NotifyRequest;
|
|
import org.jeecg.modules.pay.vo.NotifyResponse;
|
|
import org.jeecg.modules.pay.vo.NotifyResponse;
|
|
import org.jeecg.modules.redission.RedissonDelayQueue;
|
|
import org.jeecg.modules.redission.RedissonDelayQueue;
|
|
@@ -47,6 +49,8 @@ import org.springframework.transaction.annotation.Transactional;
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
|
|
+import java.math.RoundingMode;
|
|
|
|
+import java.text.SimpleDateFormat;
|
|
import java.time.LocalDate;
|
|
import java.time.LocalDate;
|
|
import java.time.LocalTime;
|
|
import java.time.LocalTime;
|
|
import java.time.ZoneId;
|
|
import java.time.ZoneId;
|
|
@@ -107,6 +111,8 @@ public class OrderServiceImpl implements IOrderService {
|
|
private RedissonDelayQueue redissonDelayQueue;
|
|
private RedissonDelayQueue redissonDelayQueue;
|
|
@Resource
|
|
@Resource
|
|
private AppDeviceMapper appDeviceMapper;
|
|
private AppDeviceMapper appDeviceMapper;
|
|
|
|
+ @Resource
|
|
|
|
+ private WeChatPayService weChatPayService;
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@@ -414,13 +420,14 @@ public class OrderServiceImpl implements IOrderService {
|
|
AppSite appSite = appSiteMapper.selectById(appSitePlace.getSiteId());
|
|
AppSite appSite = appSiteMapper.selectById(appSitePlace.getSiteId());
|
|
appOrder
|
|
appOrder
|
|
.setPayType(3)
|
|
.setPayType(3)
|
|
- .setOrderStatus(2)
|
|
|
|
|
|
+ .setOrderStatus(1)
|
|
.setOrgCode(appSite.getOrgCode())
|
|
.setOrgCode(appSite.getOrgCode())
|
|
.setTenantId(appSite.getTenantId())
|
|
.setTenantId(appSite.getTenantId())
|
|
.setType(CommonConstant.ORDER_TYPE_0)
|
|
.setType(CommonConstant.ORDER_TYPE_0)
|
|
//使用人IDs
|
|
//使用人IDs
|
|
.setFamilyIds(createOrderForm.getFamilyIds())
|
|
.setFamilyIds(createOrderForm.getFamilyIds())
|
|
.setOriginalPrice(priceRule.getSellingPrice())
|
|
.setOriginalPrice(priceRule.getSellingPrice())
|
|
|
|
+ .setAddressSiteId(appSite.getId())
|
|
.setPrice(totalPrice)
|
|
.setPrice(totalPrice)
|
|
.setCreateTime(new Date())
|
|
.setCreateTime(new Date())
|
|
.setUpdateTime(new Date())
|
|
.setUpdateTime(new Date())
|
|
@@ -497,7 +504,7 @@ public class OrderServiceImpl implements IOrderService {
|
|
|
|
|
|
proInfoList.add(appOrderProInfo);
|
|
proInfoList.add(appOrderProInfo);
|
|
appOrder.setOrgCode(appSitePlace.getOrgCode())
|
|
appOrder.setOrgCode(appSitePlace.getOrgCode())
|
|
- .setTenantId(appSitePlace.getTenantId());
|
|
|
|
|
|
+ .setTenantId(appSitePlace.getTenantId()).setAddressSiteId(appSite.getId());
|
|
|
|
|
|
sumPrice = sumPrice.add(priceRule.getSellingPrice()).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
sumPrice = sumPrice.add(priceRule.getSellingPrice()).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
}
|
|
}
|
|
@@ -563,6 +570,7 @@ public class OrderServiceImpl implements IOrderService {
|
|
.setType(CommonConstant.ORDER_TYPE_0)
|
|
.setType(CommonConstant.ORDER_TYPE_0)
|
|
.setTDiscounts(tDiscounts)
|
|
.setTDiscounts(tDiscounts)
|
|
.setOriginalPrice(sumPrice)
|
|
.setOriginalPrice(sumPrice)
|
|
|
|
+ .setAddressSiteId(appSite.getId())
|
|
.setCreateTime(new Date())
|
|
.setCreateTime(new Date())
|
|
.setUpdateTime(new Date())
|
|
.setUpdateTime(new Date())
|
|
.setCreateBy(user.getId())
|
|
.setCreateBy(user.getId())
|
|
@@ -587,7 +595,6 @@ public class OrderServiceImpl implements IOrderService {
|
|
|
|
|
|
for (int i = 1; i <= createOrderForm.getAmount(); i++) {
|
|
for (int i = 1; i <= createOrderForm.getAmount(); i++) {
|
|
|
|
|
|
-
|
|
|
|
String familyUserId = createOrderForm.getFamilyIds().split(",")[i - 1];
|
|
String familyUserId = createOrderForm.getFamilyIds().split(",")[i - 1];
|
|
FamilyMembers familyMembers = familyMembersMapper.selectById(familyUserId);
|
|
FamilyMembers familyMembers = familyMembersMapper.selectById(familyUserId);
|
|
AppOrderProInfo appOrderProInfo = new AppOrderProInfo();
|
|
AppOrderProInfo appOrderProInfo = new AppOrderProInfo();
|
|
@@ -621,6 +628,7 @@ public class OrderServiceImpl implements IOrderService {
|
|
|
|
|
|
appOrder
|
|
appOrder
|
|
.setType(CommonConstant.ORDER_TYPE_1)
|
|
.setType(CommonConstant.ORDER_TYPE_1)
|
|
|
|
+ .setAddressSiteId(appGame.getSiteId())
|
|
.setOriginalPrice(sumPrice)
|
|
.setOriginalPrice(sumPrice)
|
|
.setCreateTime(new Date())
|
|
.setCreateTime(new Date())
|
|
.setUpdateTime(new Date())
|
|
.setUpdateTime(new Date())
|
|
@@ -665,6 +673,7 @@ public class OrderServiceImpl implements IOrderService {
|
|
appOrderProInfo.setProductId(createOrderForm.getProductIds());
|
|
appOrderProInfo.setProductId(createOrderForm.getProductIds());
|
|
appOrderProInfo.setProductName(appCourse.getName());
|
|
appOrderProInfo.setProductName(appCourse.getName());
|
|
appOrderProInfo.setAddress(appSite.getAddress());
|
|
appOrderProInfo.setAddress(appSite.getAddress());
|
|
|
|
+ appOrderProInfo.setProductImage(appCourse.getCover());
|
|
appOrderProInfo.setType(CommonConstant.ORDER_PRO_INFO_TYPE_6);
|
|
appOrderProInfo.setType(CommonConstant.ORDER_PRO_INFO_TYPE_6);
|
|
appOrderProInfo.setFrameTimeStr(DateUtil.format(appCourse.getStartTime(), "yyyy-MM-dd") + "-" + DateUtil.format(appCourse.getEndTime(), "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.setExpireTime(DateUtil.format(appCourse.getEndTime(), "yyyy-MM-dd"));
|
|
@@ -726,6 +735,8 @@ public class OrderServiceImpl implements IOrderService {
|
|
appOrder.setOriginalPrice(sumCoursePrice);
|
|
appOrder.setOriginalPrice(sumCoursePrice);
|
|
//使用人IDs
|
|
//使用人IDs
|
|
appOrder.setFamilyIds(createOrderForm.getFamilyIds());
|
|
appOrder.setFamilyIds(createOrderForm.getFamilyIds());
|
|
|
|
+
|
|
|
|
+ appOrder.setAddressSiteId(appSite.getId());
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -749,6 +760,7 @@ public class OrderServiceImpl implements IOrderService {
|
|
.setOrderId(appOrder.getId())
|
|
.setOrderId(appOrder.getId())
|
|
.setBdOrderNo(generateOrderNumber(2))
|
|
.setBdOrderNo(generateOrderNumber(2))
|
|
.setInsureName(appInsure.getName())
|
|
.setInsureName(appInsure.getName())
|
|
|
|
+ .setCoverImg(appInsure.getCoverImg())
|
|
.setInsureCompany(appInsure.getInsuranceName_dictText())
|
|
.setInsureCompany(appInsure.getInsuranceName_dictText())
|
|
.setInsureId(appInsure.getId())
|
|
.setInsureId(appInsure.getId())
|
|
.setMoney(insurePrice.getInsurePrice())
|
|
.setMoney(insurePrice.getInsurePrice())
|
|
@@ -761,6 +773,20 @@ public class OrderServiceImpl implements IOrderService {
|
|
insureOrderInfoList.add(insureOrderInfo);
|
|
insureOrderInfoList.add(insureOrderInfo);
|
|
|
|
|
|
sumPrice = sumPrice.add(insurePrice.getInsurePrice()).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
sumPrice = sumPrice.add(insurePrice.getInsurePrice()).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
|
+ }
|
|
|
|
+ //计算总价 = 订单金额 + 保单金额
|
|
|
|
+ totalPrice = totalPrice.add(sumPrice);
|
|
|
|
+ }
|
|
|
|
+ appOrder.setPrice(totalPrice);
|
|
|
|
+ appOrderMapper.insert(appOrder);
|
|
|
|
+ saveSignFlowRecord(appOrder);
|
|
|
|
+ //todo 优化异步执行 -> 保存订单商品信息
|
|
|
|
+
|
|
|
|
+ if(!insureOrderInfoList.isEmpty()) {
|
|
|
|
+ //保存保险
|
|
|
|
+ for (InsureOrderInfo insureOrderInfo : insureOrderInfoList) {
|
|
|
|
+ insureOrderInfo.setOrderId(appOrder.getId());
|
|
|
|
+ insureOrderInfoMapper.insert(insureOrderInfo);
|
|
|
|
|
|
AppOrderProInfo appOrderProInfo = new AppOrderProInfo();
|
|
AppOrderProInfo appOrderProInfo = new AppOrderProInfo();
|
|
appOrderProInfo.setProductId(insureOrderInfo.getId());
|
|
appOrderProInfo.setProductId(insureOrderInfo.getId());
|
|
@@ -769,70 +795,65 @@ public class OrderServiceImpl implements IOrderService {
|
|
|
|
|
|
appOrderProInfo.setPrice(insureOrderInfo.getMoney());
|
|
appOrderProInfo.setPrice(insureOrderInfo.getMoney());
|
|
appOrderProInfo.setQuantity(1);
|
|
appOrderProInfo.setQuantity(1);
|
|
- FamilyMembers familyMembers = familyMembersMapper.selectById(id);
|
|
|
|
- appOrderProInfo.setFamilyUserId(id);
|
|
|
|
|
|
+ FamilyMembers familyMembers = familyMembersMapper.selectById(insureOrderInfo.getFamilyMembersId());
|
|
|
|
+ appOrderProInfo.setFamilyUserId(familyMembers.getId());
|
|
appOrderProInfo.setUserName(familyMembers.getFullName());
|
|
appOrderProInfo.setUserName(familyMembers.getFullName());
|
|
appOrderProInfo.setUserPhone(familyMembers.getPhone());
|
|
appOrderProInfo.setUserPhone(familyMembers.getPhone());
|
|
appOrderProInfo.setStatus(CommonConstant.STATUS_0_INT);
|
|
appOrderProInfo.setStatus(CommonConstant.STATUS_0_INT);
|
|
appOrderProInfo.setDelFlag(CommonConstant.DEL_FLAG_0);
|
|
appOrderProInfo.setDelFlag(CommonConstant.DEL_FLAG_0);
|
|
|
|
+
|
|
|
|
+ proInfoList.add(appOrderProInfo);
|
|
}
|
|
}
|
|
- //计算总价 = 订单金额 + 保单金额
|
|
|
|
- totalPrice = totalPrice.add(sumPrice);
|
|
|
|
}
|
|
}
|
|
- appOrder.setPrice(totalPrice);
|
|
|
|
- appOrderMapper.insert(appOrder);
|
|
|
|
- saveSignFlowRecord(appOrder);
|
|
|
|
- //todo 优化异步执行 -> 保存订单商品信息
|
|
|
|
|
|
+
|
|
for (AppOrderProInfo appOrderProInfo : proInfoList) {
|
|
for (AppOrderProInfo appOrderProInfo : proInfoList) {
|
|
- appOrderProInfo
|
|
|
|
- .setOrderId(appOrder.getId())
|
|
|
|
- .setOrderCode(appOrder.getOrderCode())
|
|
|
|
- //生成10位随机券号
|
|
|
|
- .setTicketNo(RandomUtil.randomNumbers(10))
|
|
|
|
- ;
|
|
|
|
- appOrderProInfoMapper.insert(appOrderProInfo);
|
|
|
|
- //订单券号记录
|
|
|
|
- AppIsin appIsin = new AppIsin();
|
|
|
|
- appIsin
|
|
|
|
- .setOrderId(appOrder.getId())
|
|
|
|
- .setOrgCode(appOrder.getOrgCode())
|
|
|
|
- .setOrderCode(appOrder.getOrderCode())
|
|
|
|
- .setOrderProInfoId(appOrderProInfo.getId())
|
|
|
|
- .setFamilyId(appOrderProInfo.getFamilyUserId())
|
|
|
|
- .setFamilyUserName(appOrderProInfo.getUserName())
|
|
|
|
- .setUserPhone(appOrderProInfo.getUserPhone())
|
|
|
|
- .setUseAddress(StrUtil.isBlank(appOrderProInfo.getAddress()) ? null : appOrderProInfo.getAddress())
|
|
|
|
- //过期时间
|
|
|
|
- .setExpireTime(appOrderProInfo.getExpireTime())
|
|
|
|
- //生成10位随机券号
|
|
|
|
- .setTicketNo(appOrderProInfo.getTicketNo())
|
|
|
|
- .setIsinStatus(CommonConstant.ISIN_STATUS_1);
|
|
|
|
- appIsinMapper.insert(appIsin);
|
|
|
|
- appDeviceMapper.selectList(Wrappers.<AppDevice>lambdaQuery().eq(AppDevice::getOrgCode,appOrder.getOrgCode())).forEach(appDevice -> {
|
|
|
|
- try {
|
|
|
|
- String addUser = addUser(appSitePriceRulesMapper.selectById(appOrderProInfo.getProductId()).getDateOfSale(),
|
|
|
|
- appDevice.getDeviceSerial(),
|
|
|
|
- appOrderProInfo.getUserName(),
|
|
|
|
- appOrderProInfo.getId());
|
|
|
|
- String addFace = addFace(appDevice.getDeviceSerial(), appOrderProInfo.getId(),
|
|
|
|
- familyMembersMapper.selectById(appOrderProInfo.getFamilyUserId()).getRealNameImg());
|
|
|
|
- JsonObject addUserJson = JsonParser.parseString(addUser).getAsJsonObject();
|
|
|
|
- JsonObject addFaceJson = JsonParser.parseString(addFace).getAsJsonObject();
|
|
|
|
- if(addUserJson.get("code").getAsInt() != 0 && addFaceJson.get("code").getAsInt() != 0) throw new JeecgBootException("设备录入用户信息失败!请联系管理员");
|
|
|
|
- }catch (Exception e){
|
|
|
|
- throw new JeecgBootException("设备录入用户信息失败!请联系管理员");
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
- if(!insureOrderInfoList.isEmpty()) {
|
|
|
|
- //保存保险
|
|
|
|
- for (InsureOrderInfo insureOrderInfo : insureOrderInfoList) {
|
|
|
|
- insureOrderInfo.setOrderId(appOrder.getId());
|
|
|
|
- insureOrderInfoMapper.insert(insureOrderInfo);
|
|
|
|
|
|
+ appOrderProInfo
|
|
|
|
+ .setOrderId(appOrder.getId())
|
|
|
|
+ .setOrderCode(appOrder.getOrderCode())
|
|
|
|
+ //生成10位随机券号
|
|
|
|
+ .setTicketNo(RandomUtil.randomNumbers(10))
|
|
|
|
+ ;
|
|
|
|
+ appOrderProInfoMapper.insert(appOrderProInfo);
|
|
|
|
+ if (!Objects.equals(appOrderProInfo.getType(), CommonConstant.ORDER_PRO_INFO_TYPE_7)) {
|
|
|
|
+ //订单券号记录
|
|
|
|
+ AppIsin appIsin = new AppIsin();
|
|
|
|
+ appIsin
|
|
|
|
+ .setOrderId(appOrder.getId())
|
|
|
|
+ .setOrgCode(appOrder.getOrgCode())
|
|
|
|
+ .setOrderCode(appOrder.getOrderCode())
|
|
|
|
+ .setOrderProInfoId(appOrderProInfo.getId())
|
|
|
|
+ .setFamilyId(appOrderProInfo.getFamilyUserId())
|
|
|
|
+ .setFamilyUserName(appOrderProInfo.getUserName())
|
|
|
|
+ .setUserPhone(appOrderProInfo.getUserPhone())
|
|
|
|
+ .setUseAddress(StrUtil.isBlank(appOrderProInfo.getAddress()) ? null : appOrderProInfo.getAddress())
|
|
|
|
+ //过期时间
|
|
|
|
+ .setExpireTime(appOrderProInfo.getExpireTime())
|
|
|
|
+ //生成10位随机券号
|
|
|
|
+ .setTicketNo(appOrderProInfo.getTicketNo())
|
|
|
|
+ .setIsinStatus(CommonConstant.ISIN_STATUS_1);
|
|
|
|
+ appIsinMapper.insert(appIsin);
|
|
|
|
+ }
|
|
|
|
+ if (Objects.equals(appOrderProInfo.getType(), CommonConstant.ORDER_PRO_INFO_TYPE_1)){
|
|
|
|
+ appDeviceMapper.selectList(Wrappers.<AppDevice>lambdaQuery().eq(AppDevice::getOrgCode,appOrder.getOrgCode())).forEach(appDevice -> {
|
|
|
|
+ try {
|
|
|
|
+ String addUser = addUser(appSitePriceRulesMapper.selectById(appOrderProInfo.getProductId()).getDateOfSale(),
|
|
|
|
+ appDevice.getDeviceSerial(),
|
|
|
|
+ appOrderProInfo.getUserName(),
|
|
|
|
+ appOrderProInfo.getId());
|
|
|
|
+ String addFace = addFace(appDevice.getDeviceSerial(), appOrderProInfo.getId(),
|
|
|
|
+ familyMembersMapper.selectById(appOrderProInfo.getFamilyUserId()).getRealNameImg());
|
|
|
|
+ JsonObject addUserJson = JsonParser.parseString(addUser).getAsJsonObject();
|
|
|
|
+ JsonObject addFaceJson = JsonParser.parseString(addFace).getAsJsonObject();
|
|
|
|
+ if(addUserJson.get("code").getAsInt() != 0 && addFaceJson.get("code").getAsInt() != 0) throw new JeecgBootException("设备录入用户信息失败!请联系管理员");
|
|
|
|
+ }catch (Exception e){
|
|
|
|
+ throw new JeecgBootException("设备录入用户信息失败!请联系管理员");
|
|
|
|
+ }
|
|
|
|
+ });
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
//保存核销记录
|
|
//保存核销记录
|
|
- if (CollUtil.isNotEmpty(proInfoList)) {
|
|
|
|
|
|
+ if (CollUtil.isNotEmpty(appCoursesVerificationRecordList)) {
|
|
for (AppCoursesVerificationRecord appCoursesVerificationRecord : appCoursesVerificationRecordList) {
|
|
for (AppCoursesVerificationRecord appCoursesVerificationRecord : appCoursesVerificationRecordList) {
|
|
appCoursesVerificationRecord.setOrderId(appOrder.getId());
|
|
appCoursesVerificationRecord.setOrderId(appOrder.getId());
|
|
appCoursesVerificationRecord.setOrderCode(appOrder.getOrderCode());
|
|
appCoursesVerificationRecord.setOrderCode(appOrder.getOrderCode());
|
|
@@ -846,6 +867,36 @@ public class OrderServiceImpl implements IOrderService {
|
|
.setOrderId(appOrder.getId())
|
|
.setOrderId(appOrder.getId())
|
|
.setOrderCode(orderCode)
|
|
.setOrderCode(orderCode)
|
|
;
|
|
;
|
|
|
|
+ Calendar calendar = Calendar.getInstance();
|
|
|
|
+ calendar.set(Calendar.MINUTE, calendar.get(Calendar.MINUTE) + 15);
|
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssXXX");
|
|
|
|
+
|
|
|
|
+ //构建微信支付参数
|
|
|
|
+ JSONObject params = new JSONObject();
|
|
|
|
+ params.put("appid", WechatConstants.WECHAT_MP_APPID); //小程序appid
|
|
|
|
+ params.put("mchid", WechatConstants.WECHAT_MCH_ID); //商户号
|
|
|
|
+ params.put("description", "胶片订单业务"); //商品描述
|
|
|
|
+ params.put("out_trade_no", appOrder.getOrderCode()); //商户订单号
|
|
|
|
+ params.put("time_expire", sdf.format(calendar.getTime())); //交易结束时间 选填 时间到了之后将不能再支付 遵循rfc3339标准格式
|
|
|
|
+ params.put("attach", appOrder.getOrderCode()); //附加数据 选填
|
|
|
|
+ // 在查询API和支付通知中原样返回 可作为自定义参数使用
|
|
|
|
+ params.put("notify_url", WechatUrlConstants.PAY_V3_NOTIFY); //支付结果异步通知接口
|
|
|
|
+
|
|
|
|
+ //订单金额信息
|
|
|
|
+ JSONObject amount_json = new JSONObject();
|
|
|
|
+ //支付金额 单位:分
|
|
|
|
+// amount_json.put("total", Integer.parseInt(amount_fee(Double.valueOf("0.1"))));
|
|
|
|
+ amount_json.put("total", Integer.parseInt(amount_fee(appOrder.getPrice())));
|
|
|
|
+ params.put("amount", amount_json);
|
|
|
|
+
|
|
|
|
+ //支付者信息
|
|
|
|
+ JSONObject payer = new JSONObject();
|
|
|
|
+ //用户在小程序侧的openid
|
|
|
|
+ payer.put("openid", sysUser.getOpenid());
|
|
|
|
+ params.put("payer", payer);
|
|
|
|
+
|
|
|
|
+ //拉起支付
|
|
|
|
+// Map<String, String> result = weChatPayService.wechatPay(params);
|
|
|
|
|
|
String out_trade_no = appOrder.getOrderCode();
|
|
String out_trade_no = appOrder.getOrderCode();
|
|
Integer total_amount = appOrder.getPrice().multiply(new BigDecimal(100)).intValue();
|
|
Integer total_amount = appOrder.getPrice().multiply(new BigDecimal(100)).intValue();
|
|
@@ -858,17 +909,26 @@ public class OrderServiceImpl implements IOrderService {
|
|
String goods_name = "商品名称";
|
|
String goods_name = "商品名称";
|
|
Integer quantity = appOrder.getAmount();
|
|
Integer quantity = appOrder.getAmount();
|
|
|
|
|
|
- //拉卡拉预支付订单,返回构建小程序支付拉起参数
|
|
|
|
-// String res = V3LabsApi.transPreorder_wxpay_applet(out_trade_no, total_amount, request_ip, subject, notify_url, sub_appid, user_id, goods_id, goods_name, quantity);
|
|
|
|
-// payForm.setParams(res);
|
|
|
|
|
|
+ //预支付订单,返回构建小程序支付拉起参数
|
|
|
|
|
|
//发布任务到redission延迟队列
|
|
//发布任务到redission延迟队列
|
|
String task = CommonConstant.ORDER_TIME_OUT_TASK_PREFIX + appOrder.getId();
|
|
String task = CommonConstant.ORDER_TIME_OUT_TASK_PREFIX + appOrder.getId();
|
|
- redissonDelayQueue.offerTask(task, 60 * 3);
|
|
|
|
|
|
+ redissonDelayQueue.offerTask(task, 60 * 15);
|
|
|
|
|
|
return payForm;
|
|
return payForm;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 金额元转分字符串
|
|
|
|
+ *
|
|
|
|
+ * @param cny 元
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ public String amount_fee(BigDecimal cny) {
|
|
|
|
+ BigDecimal b2 = new BigDecimal("100");
|
|
|
|
+ return cny.multiply(b2).setScale(0, RoundingMode.DOWN).toString();
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 异步走保存下单信息
|
|
* 异步走保存下单信息
|
|
* @param appOrder
|
|
* @param appOrder
|
|
@@ -1283,27 +1343,24 @@ public class OrderServiceImpl implements IOrderService {
|
|
@Override
|
|
@Override
|
|
public String orderQuery(String orderCode) throws IOException {
|
|
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);
|
|
|
|
|
|
+ //null代表查询失败 SUCCESS-成功 USERPAYING和ACCEPT为中间态 其他为支付失败
|
|
|
|
+ String s = weChatPayService.orderQueryByOutTradeNo(orderCode);
|
|
|
|
+ if ("SUCCESS".equals(s)) {
|
|
|
|
+ //查询订单
|
|
|
|
+ AppOrder appOrder = appOrderMapper.selectOne(Wrappers.<AppOrder>lambdaQuery().eq(AppOrder::getOrderCode, orderCode).last("limit 1"));
|
|
|
|
+ if (ObjectUtil.isNotEmpty(appOrder)) {
|
|
|
|
+ return "支付成功!";
|
|
|
|
+ }
|
|
}
|
|
}
|
|
-
|
|
|
|
- return "支付成功!";
|
|
|
|
|
|
+ if (s == null ) {
|
|
|
|
+ //查询订单
|
|
|
|
+ return "查询失败!";
|
|
|
|
+ }
|
|
|
|
+ if ("USERPAYING".equals(s) || "ACCEPT".equals(s) ) {
|
|
|
|
+ //查询订单
|
|
|
|
+ return "查询中!";
|
|
|
|
+ }
|
|
|
|
+ return s;
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -1336,15 +1393,44 @@ public class OrderServiceImpl implements IOrderService {
|
|
IPage<PageOrdersVO> pageOrders = appOrderMapper.pageOrders(page,pageOrdersForm);
|
|
IPage<PageOrdersVO> pageOrders = appOrderMapper.pageOrders(page,pageOrdersForm);
|
|
|
|
|
|
pageOrders.getRecords().forEach(record -> {
|
|
pageOrders.getRecords().forEach(record -> {
|
|
- List<AppOrderProInfo> proInfoList = appOrderProInfoMapper.selectList(Wrappers.<AppOrderProInfo>lambdaQuery().eq(AppOrderProInfo::getOrderId, record.getOrderId()));
|
|
|
|
- if (CollUtil.isNotEmpty(proInfoList)) {
|
|
|
|
- record.setOrderProInfoList(proInfoList);
|
|
|
|
|
|
+
|
|
|
|
+ List<AppOrderProInfo> proInfoList = appOrderProInfoMapper.selectList(Wrappers.<AppOrderProInfo>lambdaQuery()
|
|
|
|
+ .eq(AppOrderProInfo::getOrderId, record.getOrderId())
|
|
|
|
+ );
|
|
|
|
+ if(ObjectUtil.isNotEmpty(proInfoList)){
|
|
|
|
+ List<AppOrderProInfo> infoList = proInfoList.stream().filter(orderProInfo -> orderProInfo.getType() != 7).collect(Collectors.toList());
|
|
|
|
+ List<AppOrderProInfo> insureList = proInfoList.stream().filter(orderProInfo -> orderProInfo.getType() == 7).collect(Collectors.toList());
|
|
|
|
+ record.setOrderProInfoList(infoList);
|
|
|
|
+ record.setOrderInsureList(insureList);
|
|
}
|
|
}
|
|
});
|
|
});
|
|
-
|
|
|
|
return pageOrders;
|
|
return pageOrders;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public String refundOrder(String orderCode) {
|
|
|
|
+
|
|
|
|
+ //todo 分账退款
|
|
|
|
+
|
|
|
|
+ AppOrder appOrder = appOrderMapper.selectOne(Wrappers.<AppOrder>lambdaQuery().eq(AppOrder::getOrderCode, orderCode).last("limit 1"));
|
|
|
|
+ if(ObjectUtil.isNotEmpty(appOrder)){
|
|
|
|
+ if (appOrder.getOrderStatus() == 0){
|
|
|
|
+ log.info("修改订单:{},支付状态为退款中", orderCode);
|
|
|
|
+ appOrder.setOrderStatus(5);
|
|
|
|
+ appOrderMapper.updateById(appOrder);
|
|
|
|
+ List<AppOrderProInfo> appOrderProInfoList = appOrderProInfoMapper.selectList(Wrappers.<AppOrderProInfo>lambdaQuery().eq(AppOrderProInfo::getOrderId, appOrder.getId()));
|
|
|
|
+ for (AppOrderProInfo appOrderProInfo : appOrderProInfoList) {
|
|
|
|
+ appOrderProInfo.setOrderStatus(3);
|
|
|
|
+ appOrderProInfo.setAfterSaleStatus(1);
|
|
|
|
+ appOrderProInfoMapper.updateById(appOrderProInfo);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return "退款成功!";
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return "退款失败!";
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* @return String 订单号
|
|
* @return String 订单号
|
|
* @Author SheepHy
|
|
* @Author SheepHy
|