Browse Source

更新支付状态

v1.0
Yen 2 years ago
parent
commit
622e51784f
  1. 31
      src/main/java/com/qs/serve/task/PayTask.java
  2. 2
      src/main/resources/mapper/goods/GoodsSpuMapper.xml

31
src/main/java/com/qs/serve/task/PayTask.java

@ -9,7 +9,11 @@ import com.qs.serve.modules.tbs.entity.TbsCostApply;
import com.qs.serve.modules.tbs.service.TbsCostApplyService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
@ -22,13 +26,13 @@ import java.util.stream.Collectors;
@AllArgsConstructor
public class PayTask {
private final PayPaymentService payPaymentService;
private final TbsCostApplyService costApplyService;
private final PayPaymentItemMapper payPaymentItemMapper;
/**
* 同步支付
*/
@Scheduled(cron="0 0 2 * * ?")
public void syncCostPayStatus(){
LambdaQueryWrapper<TbsCostApply> costLqw = new LambdaQueryWrapper<>();
costLqw.select(
@ -36,14 +40,37 @@ public class PayTask {
TbsCostApply::getTotalActivityAmount
);
costLqw.ne(TbsCostApply::getPayStatus,2);
costLqw.eq(TbsCostApply::getCheckState,3);
//SyFormId 代表非销路通数据
costLqw.isNotNull(TbsCostApply::getSyFormId);
costLqw.apply(" limit 2000");
List<TbsCostApply> costApplyList = costApplyService.list(costLqw);
List<String> costIds = costApplyList.stream().map(a->a.toString()).collect(Collectors.toList());
List<AmountDTO> amountDTOList = payPaymentItemMapper.selectCostTotal(costIds);
List<TbsCostApply> updatePayStateList = new ArrayList<>();
for (TbsCostApply costApply : costApplyList) {
String costId = costApply.getId().toString();
for (AmountDTO dto : amountDTOList) {
if(costId.equals(dto.getId())){
BigDecimal totalPay = dto.getAmount();
if(totalPay.compareTo(BigDecimal.ZERO)==0){
//未支付忽略
continue;
}
BigDecimal totalCost = costApply.getTotalActivityAmount();
TbsCostApply updParam = new TbsCostApply();
updParam.setId(costApply.getId());
if(totalPay.compareTo(totalCost)<0){
updParam.setPayStatus(1);
}else {
updParam.setPayStatus(2);
}
updatePayStateList.add(updParam);
}
}
}
costApplyService.updateBatchById(updatePayStateList);
}

2
src/main/resources/mapper/goods/GoodsSpuMapper.xml

@ -80,7 +80,7 @@
<if test="query.sort != null"> and `goods_spu`.`sort` = #{query.sort}</if>
<if test="query.saleNum != null"> and `goods_spu`.`sale_num` = #{query.saleNum}</if>
<if test="query.belong != null"> and `goods_spu`.`belong` = #{query.belong}</if>
<if test="query.tasteValue != null and query.tasteValue != ''"> and `goods_spu`.`taste_value` = #{query.tasteValue}</if>
<if test="query.tasteValue != null and query.tasteValue != ''"> and `goods_spu`.`taste_value` like concat('%',#{query.tasteValue},'%') </if>
<if test="query.createTime != null"> and `goods_spu`.`create_time` = #{query.createTime}</if>
<if test="query.updateTime != null"> and `goods_spu`.`update_time` = #{query.updateTime}</if>
<if test="query.createBy != null and query.createBy != ''"> and `goods_spu`.`create_by` = #{query.createBy}</if>

Loading…
Cancel
Save