|
@@ -6,12 +6,15 @@ import cn.hutool.core.util.StrUtil;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
|
import com.zhongzheng.common.core.domain.model.LoginUser;
|
|
|
import com.zhongzheng.common.exception.CustomException;
|
|
|
import com.zhongzheng.common.utils.DateUtils;
|
|
|
import com.zhongzheng.common.utils.SecurityUtils;
|
|
|
import com.zhongzheng.common.utils.ToolsUtils;
|
|
|
import com.zhongzheng.common.utils.http.HttpUtils;
|
|
|
+import com.zhongzheng.modules.activity.domain.ActivityOrder;
|
|
|
+import com.zhongzheng.modules.activity.service.IActivityOrderService;
|
|
|
import com.zhongzheng.modules.goods.domain.Goods;
|
|
|
import com.zhongzheng.modules.goods.service.IGoodsService;
|
|
|
import com.zhongzheng.modules.goods.vo.GoodsVo;
|
|
@@ -85,6 +88,8 @@ public class OrderGoodsRefundServiceImpl extends ServiceImpl<OrderGoodsRefundMap
|
|
|
private IUserService iUserService;
|
|
|
@Autowired
|
|
|
private IOrderShareMoneyService iOrderShareMoneyService;
|
|
|
+ @Autowired
|
|
|
+ private IActivityOrderService iActivityOrderService;
|
|
|
@Value("${oldStudySys.shareCanclePath}")
|
|
|
private String SHARE_CANCLE_PATH;
|
|
|
|
|
@@ -156,6 +161,10 @@ public class OrderGoodsRefundServiceImpl extends ServiceImpl<OrderGoodsRefundMap
|
|
|
if(orderGoods.getRefundStatus()!=0){
|
|
|
throw new CustomException("订单商品目前无法退款");
|
|
|
}
|
|
|
+ int count = iActivityOrderService.count(new LambdaQueryWrapper<ActivityOrder>().eq(ActivityOrder::getOrderSn, bo.getOrderSn()).eq(ActivityOrder::getStatus, 1));
|
|
|
+ if (count > 0){
|
|
|
+ throw new CustomException("该订单已参与红包活动,无法退款!");
|
|
|
+ }
|
|
|
//订单商品
|
|
|
Order order = iOrderService.getOne(new LambdaQueryWrapper<Order>().eq(Order::getOrderSn,bo.getOrderSn()));
|
|
|
if(order.getStatus()==0){
|
|
@@ -475,6 +484,7 @@ public class OrderGoodsRefundServiceImpl extends ServiceImpl<OrderGoodsRefundMap
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public Boolean confirmPeriod(List<OrderGoodsRefundEditBo> bos) {
|
|
|
for(OrderGoodsRefundEditBo bo : bos){
|
|
|
if(Validator.isEmpty(bo.getPeriodStatus())||Validator.isEmpty(bo.getRefundId())){
|
|
@@ -499,6 +509,10 @@ public class OrderGoodsRefundServiceImpl extends ServiceImpl<OrderGoodsRefundMap
|
|
|
if(orderGoodsRefund.getPeriodStatus()==3&&bo.getPeriodStatus()==2){
|
|
|
throw new CustomException("操作状态错误");
|
|
|
}
|
|
|
+ if (ObjectUtils.isNull(bo.getRealRefundFee())){
|
|
|
+ //如果实际退款金额为空 则默认全部退款
|
|
|
+ bo.setRealRefundFee(bo.getRefundFee());
|
|
|
+ }
|
|
|
LambdaUpdateWrapper<OrderGoodsRefund> objectLambdaUpdateWrapper = Wrappers.lambdaUpdate();
|
|
|
objectLambdaUpdateWrapper.eq(OrderGoodsRefund::getRefundId, bo.getRefundId());
|
|
|
objectLambdaUpdateWrapper.set(OrderGoodsRefund::getPeriodStatus, bo.getPeriodStatus());
|
|
@@ -514,7 +528,8 @@ public class OrderGoodsRefundServiceImpl extends ServiceImpl<OrderGoodsRefundMap
|
|
|
}
|
|
|
//上一次是初审状态,本次已退款
|
|
|
if(orderGoodsRefund.getPeriodStatus()==1&&bo.getPeriodStatus()==3){
|
|
|
- objectLambdaUpdateWrapper.set(OrderGoodsRefund::getRefundTime,DateUtils.getNowTime());
|
|
|
+ objectLambdaUpdateWrapper.set(OrderGoodsRefund::getRefundTime,DateUtils.getNowTime())
|
|
|
+ .set(OrderGoodsRefund::getRealRefundFee,bo.getRealRefundFee());
|
|
|
}
|
|
|
//上一次是初审状态,本次待退款
|
|
|
if(orderGoodsRefund.getPeriodStatus()==1&&bo.getPeriodStatus()==2){
|
|
@@ -531,10 +546,26 @@ public class OrderGoodsRefundServiceImpl extends ServiceImpl<OrderGoodsRefundMap
|
|
|
orderGoodsUpdate.setRefundStatus(2); //同意退款
|
|
|
orderGoodsUpdate.setUpdateTime(DateUtils.getNowTime());
|
|
|
iOrderGoodsService.updateById(orderGoodsUpdate);
|
|
|
- //清除数据
|
|
|
- OrderGoods orderGoods = iOrderGoodsService.getOne(new LambdaQueryWrapper<OrderGoods>().eq(OrderGoods::getOrderGoodsId,orderGoodsRefund.getOrderGoodsId()));
|
|
|
- Goods goods = iGoodsService.getOne(new LambdaQueryWrapper<Goods>().eq(Goods::getGoodsId,orderGoodsRefund.getGoodsId()));
|
|
|
- clearData(orderGoods.getGradeId(),orderGoodsRefund.getUserId(),orderGoods.getOrderGoodsId(),orderGoodsRefund.getGoodsId(),goods.getGoodsType());
|
|
|
+ if (ObjectUtils.isNotNull(bo.getType()) && bo.getType() == 1){
|
|
|
+ //小程序/H5/PC 同意退款处理
|
|
|
+ Order order = iOrderService.getOne(new LambdaQueryWrapper<Order>().eq(Order::getOrderSn, bo.getOrderSn()));
|
|
|
+ Map<String, String> payResult = iWxPayService.refund(bo.getOrderSn(),order.getTransid(),bo.getRealRefundFee(),order.getPayPrice());
|
|
|
+ if("OK".equals(payResult.get("return_msg"))&&Validator.isNotEmpty(payResult.get("refund_id"))){
|
|
|
+ OrderGoods orderGoods = iOrderGoodsService.getById(bo.getOrderGoodsId());
|
|
|
+ Goods goods = iGoodsService.getById(bo.getGoodsId());
|
|
|
+ refundCall(payResult.get("refund_id"),bo.getRefundId(),orderGoods.getOrderGoodsId(),order,goods.getGoodsType(),orderGoods.getGradeId(),bo.getUserId(),goods.getGoodsId());
|
|
|
+ //关闭C端用户的分销返利
|
|
|
+ shareClientCancelOldSys(order,orderGoods,bo.getRealRefundFee());
|
|
|
+ return true;
|
|
|
+ }else{
|
|
|
+ throw new CustomException("退款错误"+ JSON.toJSONString(payResult));
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ //清除数据
|
|
|
+ OrderGoods orderGoods = iOrderGoodsService.getOne(new LambdaQueryWrapper<OrderGoods>().eq(OrderGoods::getOrderGoodsId,orderGoodsRefund.getOrderGoodsId()));
|
|
|
+ Goods goods = iGoodsService.getOne(new LambdaQueryWrapper<Goods>().eq(Goods::getGoodsId,orderGoodsRefund.getGoodsId()));
|
|
|
+ clearData(orderGoods.getGradeId(),orderGoodsRefund.getUserId(),orderGoods.getOrderGoodsId(),orderGoodsRefund.getGoodsId(),goods.getGoodsType());
|
|
|
+ }
|
|
|
}
|
|
|
if(bo.getPeriodStatus()==-2){
|
|
|
//修改订单商品退款状态
|