Merge branch 'dev' of http://139.159.177.244:3000/hurui/hai-server into dev
commit
8f1b5892c7
File diff suppressed because one or more lines are too long
@ -0,0 +1,91 @@ |
||||
package com.bweb.excelListener; |
||||
|
||||
import com.alibaba.excel.context.AnalysisContext; |
||||
import com.alibaba.excel.event.AnalysisEventListener; |
||||
import com.bweb.model.ExportOutRechargeOrder; |
||||
import com.bweb.model.ImportCouponModel; |
||||
import com.hai.common.utils.DateUtil; |
||||
import com.hai.entity.OutRechargeOrder; |
||||
import com.hai.service.OutRechargeOrderService; |
||||
import org.apache.commons.lang3.StringUtils; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.Date; |
||||
import java.util.List; |
||||
import java.util.Objects; |
||||
|
||||
public class ImportRechargeOrderListener extends AnalysisEventListener<ExportOutRechargeOrder> { |
||||
|
||||
List<ExportOutRechargeOrder> errorData = new ArrayList<>(); |
||||
List<OutRechargeOrder> successData = new ArrayList<>(); |
||||
|
||||
private OutRechargeOrderService outRechargeOrderService; |
||||
|
||||
/** |
||||
* @Author Sum1Dream |
||||
* @name invoke.java |
||||
* @Description // 解析到的每一条数据都会调用此方法
|
||||
* @Date 4:03 下午 2022/1/24 |
||||
* @Param [com.bweb.model.ExportOutRechargeOrder, com.alibaba.excel.context.AnalysisContext] |
||||
* @return void |
||||
*/ |
||||
@Override |
||||
public void invoke(ExportOutRechargeOrder data, AnalysisContext context) { |
||||
if (StringUtils.isBlank(data.getOrderNo()) |
||||
|| StringUtils.isBlank(data.getStatusName()) ) { |
||||
data.setErrorMessage("有必填项未填写"); |
||||
errorData.add(data); |
||||
return; |
||||
} |
||||
|
||||
OutRechargeOrder rechargeOrder = outRechargeOrderService.findByOrderNo(data.getOrderNo()); |
||||
|
||||
if (rechargeOrder.getStatus() != 2) { |
||||
data.setErrorMessage("当前订单状态错误。"); |
||||
errorData.add(data); |
||||
return; |
||||
} |
||||
|
||||
if (rechargeOrder.getRechargeType() != 2) { |
||||
data.setErrorMessage("当前话费订单充值类型为快充。"); |
||||
errorData.add(data); |
||||
return; |
||||
} |
||||
|
||||
if (Objects.equals(data.getStatusName(), "已完成")) { |
||||
outRechargeOrderService.finishOrder(rechargeOrder.getId()); |
||||
} else if (Objects.equals(data.getStatusName(), "失败")){ |
||||
try { |
||||
outRechargeOrderService.rechargeOrderToRefund(rechargeOrder.getId()); |
||||
} catch (Exception exception) { |
||||
data.setErrorMessage("退款失败。"); |
||||
errorData.add(data); |
||||
return; |
||||
} |
||||
|
||||
} |
||||
|
||||
|
||||
successData.add(rechargeOrder); |
||||
} |
||||
|
||||
@Override |
||||
public void doAfterAllAnalysed(AnalysisContext context) { |
||||
if (successData.size() > 0) { |
||||
try { |
||||
// outRechargeOrderService.updateOrderList(successData);
|
||||
} catch (Exception e) { |
||||
e.printStackTrace(); |
||||
} |
||||
} |
||||
this.successData.clear(); |
||||
} |
||||
|
||||
public List<ExportOutRechargeOrder> getErrorData() { |
||||
return errorData; |
||||
} |
||||
|
||||
public void initData(OutRechargeOrderService outRechargeOrderService) { |
||||
this.outRechargeOrderService = outRechargeOrderService; |
||||
} |
||||
} |
File diff suppressed because one or more lines are too long
Loading…
Reference in new issue