|
@@ -3,6 +3,8 @@ package com.huimv.farm.damsubsidy.service.impl;
|
|
|
import cn.hutool.core.date.DateTime;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
|
import com.fasterxml.jackson.databind.ser.Serializers;
|
|
|
import com.huimv.farm.damsubsidy.common.token.TokenSign;
|
|
|
import com.huimv.farm.damsubsidy.common.utils.*;
|
|
@@ -200,6 +202,48 @@ public class BillBuyInfoServiceImpl extends ServiceImpl<BillBuyInfoMapper, BillB
|
|
|
return Result.SUCCESS();
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = RuntimeException.class)
|
|
|
+ public Result deleteTransaction(HttpServletRequest httpServletRequest, Map<String, String> paramsMap) {
|
|
|
+ String id = paramsMap.get("id");
|
|
|
+ BillBuyInfo billBuyInfo = billBuyInfoMapper.selectById(id);
|
|
|
+ String inspectionNum = billBuyInfo.getInspectionNum();
|
|
|
+ Long sellerId = billBuyInfo.getSellerId();
|
|
|
+ List<String> eartagList = EartagUtil.getEartagCollection(billBuyInfo.getRealEartag()).getEartagList();
|
|
|
+ for (String s : eartagList) {
|
|
|
+ BaseAnimal baseAnimal = baseAnimalMapper.selectOne(new QueryWrapper<BaseAnimal>().eq("earatg_no", s));
|
|
|
+ if (StringUtils.isBlank(baseAnimal.getInspectionNumBefore())){
|
|
|
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
+ return new Result(10001,"此交易不符合删除条件,请联系管理员.",false);
|
|
|
+ }
|
|
|
+ baseAnimal.setAnimalStatus(1);
|
|
|
+ baseAnimal.setSellerId(null);
|
|
|
+ baseAnimal.setBuyerId(null);
|
|
|
+ baseAnimal.setSellerName(null);
|
|
|
+ baseAnimal.setBuyerName(null);
|
|
|
+ baseAnimal.setBuyTime(null);
|
|
|
+ baseAnimal.setBelongToUser(sellerId);
|
|
|
+ baseAnimal.setInspectionNum(baseAnimal.getInspectionNumBefore());
|
|
|
+ int update = baseAnimalMapper.updateById(baseAnimal);
|
|
|
+ if (update != 1) {
|
|
|
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
+ return new Result(10001,"删除失败,动物信息修改失败",false);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ int delete = billLandingInspectionMapper.delete(new QueryWrapper<BillLandingInspection>().eq("inspection_num", inspectionNum).eq("inspection_type", 1));
|
|
|
+ if (delete != 1) {
|
|
|
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
+ return new Result(10001,"删除失败,受影响的检疫证数:" + delete,false);
|
|
|
+ }
|
|
|
+ int delete1 = billBuyInfoMapper.deleteById(id);
|
|
|
+ if (delete1 != 1) {
|
|
|
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
+ return new Result(10001,"删除失败,受影响的交易数量:" + delete1,false);
|
|
|
+ }
|
|
|
+ return Result.SUCCESS();
|
|
|
+ }
|
|
|
+
|
|
|
public String getUrl(String content, MultipartFile image) throws IOException {
|
|
|
if (ObjectUtil.isNotEmpty(image)){
|
|
|
if ( !"".equals(content)){
|