|
@@ -34,8 +34,6 @@ import com.ym.mec.common.service.impl.BaseServiceImpl;
|
|
import com.ym.mec.common.tenant.TenantContextHolder;
|
|
import com.ym.mec.common.tenant.TenantContextHolder;
|
|
import com.ym.mec.thirdparty.adapay.ConfigInit;
|
|
import com.ym.mec.thirdparty.adapay.ConfigInit;
|
|
import com.ym.mec.thirdparty.adapay.entity.BaseResult;
|
|
import com.ym.mec.thirdparty.adapay.entity.BaseResult;
|
|
-import com.ym.mec.thirdparty.adapay.entity.HfMerchantConfig;
|
|
|
|
-import com.ym.mec.thirdparty.yeepay.YeepayPaymentService;
|
|
|
|
import com.ym.mec.thirdparty.yqpay.*;
|
|
import com.ym.mec.thirdparty.yqpay.*;
|
|
import com.ym.mec.util.collection.MapUtil;
|
|
import com.ym.mec.util.collection.MapUtil;
|
|
import com.ym.mec.util.date.DateUtil;
|
|
import com.ym.mec.util.date.DateUtil;
|
|
@@ -132,14 +130,10 @@ public class StudentPaymentOrderServiceImpl extends BaseServiceImpl<Long, Studen
|
|
@Resource
|
|
@Resource
|
|
private ContractService contractService;
|
|
private ContractService contractService;
|
|
@Resource
|
|
@Resource
|
|
- private HfMerchantConfigService hfMerchantConfigService;
|
|
|
|
- @Resource
|
|
|
|
private StudentDao studentDao;
|
|
private StudentDao studentDao;
|
|
@Resource
|
|
@Resource
|
|
private SysUserCashAccountDetailService sysUserCashAccountDetailService;
|
|
private SysUserCashAccountDetailService sysUserCashAccountDetailService;
|
|
@Resource
|
|
@Resource
|
|
- private YeepayPaymentService yeepayPaymentService;
|
|
|
|
- @Resource
|
|
|
|
private CourseScheduleStudentPaymentDao courseScheduleStudentPaymentDao;
|
|
private CourseScheduleStudentPaymentDao courseScheduleStudentPaymentDao;
|
|
@Resource
|
|
@Resource
|
|
private StudentRepairDao studentRepairDao;
|
|
private StudentRepairDao studentRepairDao;
|
|
@@ -164,8 +158,6 @@ public class StudentPaymentOrderServiceImpl extends BaseServiceImpl<Long, Studen
|
|
return studentPaymentOrderDao;
|
|
return studentPaymentOrderDao;
|
|
}
|
|
}
|
|
|
|
|
|
- private final static Logger LOGGER = LoggerFactory.getLogger(StudentPaymentOrderServiceImpl.class);
|
|
|
|
-
|
|
|
|
@Override
|
|
@Override
|
|
public StudentPaymentOrderDao getDao() {
|
|
public StudentPaymentOrderDao getDao() {
|
|
return studentPaymentOrderDao;
|
|
return studentPaymentOrderDao;
|
|
@@ -363,10 +355,10 @@ public class StudentPaymentOrderServiceImpl extends BaseServiceImpl<Long, Studen
|
|
@Transactional
|
|
@Transactional
|
|
public OrderCancelModel updateOrderStatus(Date date, StudentPaymentOrder payingOrder) throws Exception {
|
|
public OrderCancelModel updateOrderStatus(Date date, StudentPaymentOrder payingOrder) throws Exception {
|
|
|
|
|
|
- HfMerchantConfig hfMerchantConfig = hfMerchantConfigService.queryByTenantId(payingOrder.getTenantId(), payingOrder.getPaymentChannel());
|
|
|
|
|
|
+ /*HfMerchantConfig hfMerchantConfig = hfMerchantConfigService.queryByTenantId(payingOrder.getTenantId(), payingOrder.getPaymentChannel());
|
|
if(hfMerchantConfig == null){
|
|
if(hfMerchantConfig == null){
|
|
throw new BizException("机构[{}]汇付商户信息找不到", payingOrder.getTenantId());
|
|
throw new BizException("机构[{}]汇付商户信息找不到", payingOrder.getTenantId());
|
|
- }
|
|
|
|
|
|
+ }*/
|
|
|
|
|
|
// PaymentChannelEnum paymentChannel = PaymentChannelEnum.codeOf(payingOrder.getPaymentChannel());
|
|
// PaymentChannelEnum paymentChannel = PaymentChannelEnum.codeOf(payingOrder.getPaymentChannel());
|
|
|
|
|
|
@@ -519,13 +511,16 @@ public class StudentPaymentOrderServiceImpl extends BaseServiceImpl<Long, Studen
|
|
|
|
|
|
List<StudentPaymentRouteOrder> routeOrders = studentPaymentRouteOrderService.getDao().getRouteOrders(order.getOrderNo());
|
|
List<StudentPaymentRouteOrder> routeOrders = studentPaymentRouteOrderService.getDao().getRouteOrders(order.getOrderNo());
|
|
|
|
|
|
- HfMerchantConfig hfMerchantConfig = hfMerchantConfigService.queryByTenantId(order.getTenantId(), order.getPaymentChannel());
|
|
|
|
|
|
+ /*HfMerchantConfig hfMerchantConfig = hfMerchantConfigService.queryByTenantId(order.getTenantId(), order.getPaymentChannel());
|
|
if(hfMerchantConfig == null){
|
|
if(hfMerchantConfig == null){
|
|
throw new BizException("机构[{}][{}]商户信息找不到", order.getTenantId(), order.getPaymentChannel());
|
|
throw new BizException("机构[{}][{}]商户信息找不到", order.getTenantId(), order.getPaymentChannel());
|
|
- }
|
|
|
|
|
|
+ }*/
|
|
BasePaymentService paymentService = paymentServiceContext.getPaymentService(order.getPaymentChannel() + "_" + order.getTenantId());
|
|
BasePaymentService paymentService = paymentServiceContext.getPaymentService(order.getPaymentChannel() + "_" + order.getTenantId());
|
|
for (StudentPaymentRouteOrder routeOrder : routeOrders) {
|
|
for (StudentPaymentRouteOrder routeOrder : routeOrders) {
|
|
if (routeOrder.getRouteAmount().compareTo(BigDecimal.ZERO) == 0) {
|
|
if (routeOrder.getRouteAmount().compareTo(BigDecimal.ZERO) == 0) {
|
|
|
|
+ routeOrder.setServiceFee(BigDecimal.ZERO);
|
|
|
|
+ routeOrder.setUpdateTime(date);
|
|
|
|
+ studentPaymentRouteOrderService.getDao().update(routeOrder);
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
// 执行分账逻辑
|
|
// 执行分账逻辑
|
|
@@ -923,10 +918,10 @@ public class StudentPaymentOrderServiceImpl extends BaseServiceImpl<Long, Studen
|
|
return PayStatus.FAILED;
|
|
return PayStatus.FAILED;
|
|
}
|
|
}
|
|
|
|
|
|
- HfMerchantConfig hfMerchantConfig = hfMerchantConfigService.queryByTenantId(studentPaymentOrder.getTenantId(), studentPaymentOrder.getPaymentChannel());
|
|
|
|
|
|
+ /*HfMerchantConfig hfMerchantConfig = hfMerchantConfigService.queryByTenantId(studentPaymentOrder.getTenantId(), studentPaymentOrder.getPaymentChannel());
|
|
if(hfMerchantConfig == null){
|
|
if(hfMerchantConfig == null){
|
|
throw new BizException("机构[{}]汇付商户信息找不到", studentPaymentOrder.getTenantId());
|
|
throw new BizException("机构[{}]汇付商户信息找不到", studentPaymentOrder.getTenantId());
|
|
- }
|
|
|
|
|
|
+ }*/
|
|
PaymentResp paymentResp = paymentServiceContext.getPaymentService(paymentChannel + "_" + studentPaymentOrder.getTenantId())
|
|
PaymentResp paymentResp = paymentServiceContext.getPaymentService(paymentChannel + "_" + studentPaymentOrder.getTenantId())
|
|
.query(transNo, orderNo);
|
|
.query(transNo, orderNo);
|
|
if (paymentResp == null) {
|
|
if (paymentResp == null) {
|
|
@@ -1120,7 +1115,8 @@ public class StudentPaymentOrderServiceImpl extends BaseServiceImpl<Long, Studen
|
|
Date nowDate = new Date();
|
|
Date nowDate = new Date();
|
|
//增加商品库存
|
|
//增加商品库存
|
|
List<StudentPaymentOrderDetail> studentPaymentOrderDetailList = studentPaymentOrderDetailService.queryOrderDetail(order.getId());
|
|
List<StudentPaymentOrderDetail> studentPaymentOrderDetailList = studentPaymentOrderDetailService.queryOrderDetail(order.getId());
|
|
- String goodsIds = studentPaymentOrderDetailList.stream().filter(t -> StringUtils.isNotBlank(t.getMinuendStockGoodsIdList())).map(t -> t.getMinuendStockGoodsIdList()).collect(Collectors.joining(","));
|
|
|
|
|
|
+ String goodsIds = studentPaymentOrderDetailList.stream().map(StudentPaymentOrderDetail::getMinuendStockGoodsIdList)
|
|
|
|
+ .filter(StringUtils::isNotBlank).collect(Collectors.joining(","));
|
|
if(StringUtils.isNotBlank(goodsIds)){
|
|
if(StringUtils.isNotBlank(goodsIds)){
|
|
List<Goods> goodsList = goodsService.getGoodsWithLocked(goodsIds);
|
|
List<Goods> goodsList = goodsService.getGoodsWithLocked(goodsIds);
|
|
Map<Integer,Goods> goodsMap = goodsList.stream().collect(Collectors.toMap(Goods :: getId, t -> t));
|
|
Map<Integer,Goods> goodsMap = goodsList.stream().collect(Collectors.toMap(Goods :: getId, t -> t));
|
|
@@ -1140,7 +1136,7 @@ public class StudentPaymentOrderServiceImpl extends BaseServiceImpl<Long, Studen
|
|
|
|
|
|
batchUpdateGoodsMap.put(goods.getId(), goods);
|
|
batchUpdateGoodsMap.put(goods.getId(), goods);
|
|
}
|
|
}
|
|
- if(batchUpdateGoodsMap.size() > 0){
|
|
|
|
|
|
+ if(!batchUpdateGoodsMap.isEmpty()){
|
|
goodsService.batchUpdate(new ArrayList<Goods>(batchUpdateGoodsMap.values()));
|
|
goodsService.batchUpdate(new ArrayList<Goods>(batchUpdateGoodsMap.values()));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -1168,9 +1164,9 @@ public class StudentPaymentOrderServiceImpl extends BaseServiceImpl<Long, Studen
|
|
if (studentRegistration.getMusicGroupStatus() == StudentMusicGroupStatusEnum.APPLY) {
|
|
if (studentRegistration.getMusicGroupStatus() == StudentMusicGroupStatusEnum.APPLY) {
|
|
List<StudentPaymentOrder> oldStudentPaymentOrderList = this.queryByCondition(GroupType.MUSIC, musicGroupId, userId, SUCCESS, OrderTypeEnum.APPLY);
|
|
List<StudentPaymentOrder> oldStudentPaymentOrderList = this.queryByCondition(GroupType.MUSIC, musicGroupId, userId, SUCCESS, OrderTypeEnum.APPLY);
|
|
//判断是否有成功的订单,如果有,表示已经处理过人数
|
|
//判断是否有成功的订单,如果有,表示已经处理过人数
|
|
- if (oldStudentPaymentOrderList == null || oldStudentPaymentOrderList.size() == 0) {
|
|
|
|
|
|
+ if (CollectionUtils.isEmpty(oldStudentPaymentOrderList)) {
|
|
List<StudentPaymentOrderDetail> orderDetail = studentPaymentOrderDetailService.getOrderDetail(order.getId());
|
|
List<StudentPaymentOrderDetail> orderDetail = studentPaymentOrderDetailService.getOrderDetail(order.getId());
|
|
- if (orderDetail != null && orderDetail.size() > 0) {
|
|
|
|
|
|
+ if (CollectionUtils.isNotEmpty(orderDetail)) {
|
|
long count = orderDetail.stream().filter(e -> e.getType() == OrderDetailTypeEnum.MUSICAL || e.getType() == OrderDetailTypeEnum.CLOUD_TEACHER).count();
|
|
long count = orderDetail.stream().filter(e -> e.getType() == OrderDetailTypeEnum.MUSICAL || e.getType() == OrderDetailTypeEnum.CLOUD_TEACHER).count();
|
|
MusicGroup musicGroup = musicGroupService.get(musicGroupId);
|
|
MusicGroup musicGroup = musicGroupService.get(musicGroupId);
|
|
//如果购买了乐器或者云教练,或者不是会员团,那么关闭订单时人数减一
|
|
//如果购买了乐器或者云教练,或者不是会员团,那么关闭订单时人数减一
|
|
@@ -1376,7 +1372,7 @@ public class StudentPaymentOrderServiceImpl extends BaseServiceImpl<Long, Studen
|
|
studentGoodsSell.setGoodsJson(model.getOrderInfo());
|
|
studentGoodsSell.setGoodsJson(model.getOrderInfo());
|
|
studentGoodsSell.setOrderNo(model.getOrderNo());
|
|
studentGoodsSell.setOrderNo(model.getOrderNo());
|
|
List<Integer> couponIdList = model.getCouponIdList();
|
|
List<Integer> couponIdList = model.getCouponIdList();
|
|
- if (couponIdList != null && couponIdList.size() > 0) {
|
|
|
|
|
|
+ if (CollectionUtils.isNotEmpty(couponIdList)) {
|
|
studentGoodsSell.setCouponIds(StringUtils.join(couponIdList, ","));
|
|
studentGoodsSell.setCouponIds(StringUtils.join(couponIdList, ","));
|
|
}
|
|
}
|
|
studentGoodsSell.setTenantId(student.getTenantId());
|
|
studentGoodsSell.setTenantId(student.getTenantId());
|
|
@@ -1467,13 +1463,13 @@ public class StudentPaymentOrderServiceImpl extends BaseServiceImpl<Long, Studen
|
|
long count = goodsOrderItemVOS.stream().filter(e -> StringUtils.isEmpty(e.getOrderSn())).count();
|
|
long count = goodsOrderItemVOS.stream().filter(e -> StringUtils.isEmpty(e.getOrderSn())).count();
|
|
//如果有空的商品货号,不处理
|
|
//如果有空的商品货号,不处理
|
|
if(count == 0l){
|
|
if(count == 0l){
|
|
- List<String> productSns = goodsOrderItemVOS.stream().map(e -> e.getProductSn()).distinct().collect(Collectors.toList());
|
|
|
|
|
|
+ List<String> productSns = goodsOrderItemVOS.stream().map(GoodsOrderItemVO::getProductSn).distinct().collect(Collectors.toList());
|
|
List<Goods> goodsList = goodsService.getGoodsDao().findBySns(productSns);
|
|
List<Goods> goodsList = goodsService.getGoodsDao().findBySns(productSns);
|
|
//如果有不匹配的商品货号,不处理
|
|
//如果有不匹配的商品货号,不处理
|
|
if(CollectionUtils.isEmpty(goodsList) || goodsList.size() < productSns.size()){
|
|
if(CollectionUtils.isEmpty(goodsList) || goodsList.size() < productSns.size()){
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
- Map<String, Goods> goodsSnMap = goodsList.stream().collect(Collectors.groupingBy(e -> e.getSn(),
|
|
|
|
|
|
+ Map<String, Goods> goodsSnMap = goodsList.stream().collect(Collectors.groupingBy(Goods::getSn,
|
|
Collectors.collectingAndThen(Collectors.toList(), v -> v.get(0))));
|
|
Collectors.collectingAndThen(Collectors.toList(), v -> v.get(0))));
|
|
List<StudentPaymentOrderDetail> orderDetails = new ArrayList<>();
|
|
List<StudentPaymentOrderDetail> orderDetails = new ArrayList<>();
|
|
List<SellOrder> sellOrders = new ArrayList<>();
|
|
List<SellOrder> sellOrders = new ArrayList<>();
|