|
@@ -19,6 +19,7 @@ import com.zhongzheng.common.exception.CustomException;
|
|
|
import com.zhongzheng.common.type.EncryptHandler;
|
|
|
import com.zhongzheng.common.utils.DateUtils;
|
|
|
import com.zhongzheng.common.utils.SecurityUtils;
|
|
|
+import com.zhongzheng.common.utils.ServletUtils;
|
|
|
import com.zhongzheng.common.utils.ToolsUtils;
|
|
|
import com.zhongzheng.common.utils.http.HttpUtils;
|
|
|
import com.zhongzheng.modules.activity.domain.ActivityOrder;
|
|
@@ -56,6 +57,8 @@ import com.zhongzheng.modules.order.vo.OrderGoodsRefundVo;
|
|
|
import com.zhongzheng.modules.order.vo.OrderGoodsVo;
|
|
|
import com.zhongzheng.modules.order.vo.OrderShareGoodsVo;
|
|
|
import com.zhongzheng.modules.order.vo.OrderShareToOldVo;
|
|
|
+import com.zhongzheng.modules.system.domain.SysTenant;
|
|
|
+import com.zhongzheng.modules.system.service.ISysTenantService;
|
|
|
import com.zhongzheng.modules.system.service.ISysUserService;
|
|
|
import com.zhongzheng.modules.top.goods.domain.TopOldOrderCheck;
|
|
|
import com.zhongzheng.modules.top.goods.domain.TopOldOrderCheckLog;
|
|
@@ -136,6 +139,8 @@ public class OrderGoodsRefundServiceImpl extends ServiceImpl<OrderGoodsRefundMap
|
|
|
private ITopOldOrderCheckService topOldOrderCheckService;
|
|
|
@Autowired
|
|
|
private ITopOldOrderCheckLogService topOldOrderCheckLogService;
|
|
|
+ @Autowired
|
|
|
+ private ISysTenantService sysTenantService;
|
|
|
@Value("${oldStudySys.shareCanclePath}")
|
|
|
private String SHARE_CANCLE_PATH;
|
|
|
|
|
@@ -196,12 +201,16 @@ public class OrderGoodsRefundServiceImpl extends ServiceImpl<OrderGoodsRefundMap
|
|
|
}
|
|
|
OrderGoods orderGoods = iOrderGoodsService.getOne(new LambdaQueryWrapper<OrderGoods>().eq(OrderGoods::getOrderSn,bo.getOrderSn())
|
|
|
.eq(OrderGoods::getGoodsId, bo.getGoodsId()).eq(OrderGoods::getOrderGoodsId, bo.getOrderGoodsId()));
|
|
|
+ Order order = iOrderService.getOne(new LambdaQueryWrapper<Order>().eq(Order::getOrderSn, bo.getOrderSn()).last("limit 1"));
|
|
|
+ if (order.getOrderType() != 3 && order.getOrderFrom() != 7){
|
|
|
+ if(orderGoods.getPayStatus()!=3){
|
|
|
+ throw new CustomException("订单商品尚未完全收费");
|
|
|
+ }
|
|
|
+ }
|
|
|
if(Validator.isEmpty(orderGoods)){
|
|
|
throw new CustomException("订单商品数据错误");
|
|
|
}
|
|
|
- if(orderGoods.getPayStatus()!=3){
|
|
|
- throw new CustomException("订单商品尚未完全收费");
|
|
|
- }
|
|
|
+
|
|
|
if(orderGoods.getRefundStatus()==2){
|
|
|
throw new CustomException("订单商品已退款");
|
|
|
}
|
|
@@ -213,12 +222,13 @@ public class OrderGoodsRefundServiceImpl extends ServiceImpl<OrderGoodsRefundMap
|
|
|
throw new CustomException("该订单已参与红包活动,无法退款!");
|
|
|
}
|
|
|
//订单商品
|
|
|
- Order order = iOrderService.getOne(new LambdaQueryWrapper<Order>().eq(Order::getOrderSn,bo.getOrderSn()));
|
|
|
if(order.getStatus()==0){
|
|
|
throw new CustomException("订单无效");
|
|
|
}
|
|
|
- if(order.getOrderFrom()!=2&&order.getOrderFrom()!=3){
|
|
|
- throw new CustomException("不支持非客户端订单退款");
|
|
|
+ if (order.getOrderType() != 3 && order.getOrderFrom() != 7){
|
|
|
+ if(order.getOrderFrom()!=2&&order.getOrderFrom()!=3){
|
|
|
+ throw new CustomException("不支持非客户端订单退款");
|
|
|
+ }
|
|
|
}
|
|
|
//是否分销订单退款
|
|
|
if (StringUtils.isNotBlank(orderGoods.getDistributionCode())){
|
|
@@ -631,8 +641,18 @@ public class OrderGoodsRefundServiceImpl extends ServiceImpl<OrderGoodsRefundMap
|
|
|
lqw.eq( ClassGradeUser::getUserId, userId);
|
|
|
iClassGradeUserService.remove(lqw);
|
|
|
//班级人数变动通知旧系统
|
|
|
- Goods goods = iGoodsService.getById(goodsId);
|
|
|
- iClassGradeService.gradeChangeEjjjPeople(goods.getBusinessId(),gradeId);
|
|
|
+ Boolean flag = true;
|
|
|
+ String tenantId = ServletUtils.getRequest().getHeader("TenantId");
|
|
|
+ if (StringUtils.isNotBlank(tenantId)){
|
|
|
+ SysTenant tenant = sysTenantService.getById(Long.valueOf(tenantId));
|
|
|
+ if (ObjectUtils.isNotNull(tenant.getSevenClass()) && tenant.getSevenClass() == 0){
|
|
|
+ flag = false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (flag){
|
|
|
+ Goods goods = iGoodsService.getById(goodsId);
|
|
|
+ iClassGradeService.gradeChangeEjjjPeople(goods.getBusinessId(),gradeId);
|
|
|
+ }
|
|
|
//清除课程所有历史
|
|
|
iUserStudyRecordService.delUserCourseHistory(userId,goodsId,gradeId,orderGoodsId);
|
|
|
}
|
|
@@ -853,6 +873,85 @@ public class OrderGoodsRefundServiceImpl extends ServiceImpl<OrderGoodsRefundMap
|
|
|
return iOrderService.updateById(order);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public boolean apiOrderCheck(List<ApiOrderCheckBo> bo) {
|
|
|
+ if (CollectionUtils.isEmpty(bo)){
|
|
|
+ throw new CustomException("退款信息不能为空!");
|
|
|
+ }
|
|
|
+ bo.forEach(item -> {
|
|
|
+ OrderGoodsRefund goodsRefund = getOne(new LambdaQueryWrapper<OrderGoodsRefund>()
|
|
|
+ .eq(OrderGoodsRefund::getOrderSn, item.getOrderSn())
|
|
|
+ .eq(OrderGoodsRefund::getOrderGoodsId, item.getOrderGoodsId())
|
|
|
+ .eq(OrderGoodsRefund::getStatus, 1)
|
|
|
+ .last("limit 1"));
|
|
|
+ if (ObjectUtils.isNull(goodsRefund)){
|
|
|
+ throw new CustomException(String.format("【%s】此订单没有退款信息,请检查!",item.getOrderSn()));
|
|
|
+ }
|
|
|
+ //退款审核
|
|
|
+ switch (item.getCheckResult()){
|
|
|
+ case 1://审核通过
|
|
|
+ goodsRefund.setPeriodStatus(3);
|
|
|
+ goodsRefund.setPeriodReviewTime(DateUtils.getNowTime());
|
|
|
+ goodsRefund.setPeriodReviewUsername("接口订单退款系统审核");
|
|
|
+ this.updateById(goodsRefund);
|
|
|
+ //修改订单商品退款状态
|
|
|
+ OrderGoods orderGoods = iOrderGoodsService.getById(item.getOrderGoodsId());
|
|
|
+ orderGoods.setRefundStatus(2); //已退款
|
|
|
+ orderGoods.setUpdateTime(DateUtils.getNowTime());
|
|
|
+ iOrderGoodsService.updateById(orderGoods);
|
|
|
+
|
|
|
+ Order order = iOrderService.getOne(new LambdaQueryWrapper<Order>().eq(Order::getOrderSn, item.getOrderSn()));
|
|
|
+ OrderGoodsQueryBo queryBo = new OrderGoodsQueryBo();
|
|
|
+ queryBo.setOrderSn(order.getOrderSn());
|
|
|
+ List<OrderGoodsVo> orderGoodsVoList = iOrderGoodsService.selectList(queryBo);
|
|
|
+ boolean allRefund = true;
|
|
|
+ for (OrderGoodsVo g : orderGoodsVoList) {
|
|
|
+ if(g.getRefundStatus()!=2){
|
|
|
+ allRefund = false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //都退款
|
|
|
+ if(allRefund){
|
|
|
+ order.setStatus(0);
|
|
|
+ order.setUpdateTime(DateUtils.getNowTime());
|
|
|
+ order.setOrderStatus(Order.REFUND_FULL);
|
|
|
+ }else {
|
|
|
+ //部分退款
|
|
|
+ order.setUpdateTime(DateUtils.getNowTime());
|
|
|
+ order.setOrderStatus(Order.REFUND_PART);
|
|
|
+ }
|
|
|
+ order.setOrderRefundStatus(3);
|
|
|
+ iOrderService.updateById(order);
|
|
|
+ Goods goods = iGoodsService.getById(orderGoods.getGoodsId());
|
|
|
+ ClassGradeUser gradeUser = iClassGradeUserService.getOne(new LambdaQueryWrapper<ClassGradeUser>()
|
|
|
+ .eq(ClassGradeUser::getOrderGoodsId, item.getOrderGoodsId())
|
|
|
+ .eq(ClassGradeUser::getStatus, 1)
|
|
|
+ .eq(ClassGradeUser::getChangeGrade, 0)
|
|
|
+ .last("limit 1"));
|
|
|
+ //清除数据
|
|
|
+ clearData(ObjectUtils.isNotNull(gradeUser)?gradeUser.getGradeId():0,order.getUserId(),item.getOrderGoodsId(),orderGoods.getGoodsId(),goods.getGoodsType());
|
|
|
+ break;
|
|
|
+ case 2://审核不通过
|
|
|
+ goodsRefund.setPeriodStatus(-2);
|
|
|
+ goodsRefund.setPeriodReviewTime(DateUtils.getNowTime());
|
|
|
+ goodsRefund.setPeriodReviewUsername("接口订单退款系统审核");
|
|
|
+ this.updateById(goodsRefund);
|
|
|
+ //修改订单商品退款状态
|
|
|
+ OrderGoods orderGoods2 = iOrderGoodsService.getById(item.getOrderGoodsId());
|
|
|
+ orderGoods2.setRefundStatus(3); //已退款
|
|
|
+ orderGoods2.setUpdateTime(DateUtils.getNowTime());
|
|
|
+ iOrderGoodsService.updateById(orderGoods2);
|
|
|
+ Order order2 = iOrderService.getOne(new LambdaQueryWrapper<Order>().eq(Order::getOrderSn, item.getOrderSn()));
|
|
|
+ order2.setUpdateTime(DateUtils.getNowTime());
|
|
|
+ order2.setOrderRefundStatus(4);
|
|
|
+ iOrderService.updateById(order2);
|
|
|
+ }
|
|
|
+
|
|
|
+ });
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
// public Boolean topOrderRefund(){
|
|
|
// if (ObjectUtils.isNull(bo.getRealRefundFee())){
|
|
|
// //如果实际退款金额为空 则默认全部退款
|