Browse Source

交易保存bug

Newspaper 1 year ago
parent
commit
892b3713a6

+ 102 - 101
admin/src/main/java/com/huimv/farm/damsubsidy/service/impl/BillBuyInfoServiceImpl.java

@@ -57,7 +57,7 @@ public class BillBuyInfoServiceImpl extends ServiceImpl<BillBuyInfoMapper, BillB
         SysUser sysUser = sysUserMapper.selectOne(new QueryWrapper<SysUser>().eq("id", userId));
 
         QueryWrapper<BillLandingInspection> landingInspectionQueryWrapper = new QueryWrapper<>();
-        landingInspectionQueryWrapper.eq("inspection_num", inspectionNum).ne("inspection_sch",5);
+        landingInspectionQueryWrapper.eq("inspection_num", inspectionNum).notIn("inspection_sch",5,6);
         if (billLandingInspectionMapper.selectCount(landingInspectionQueryWrapper) != 0) {
             return new Result(10001, "存在相同检疫证号!", false);
         }
@@ -106,26 +106,47 @@ public class BillBuyInfoServiceImpl extends ServiceImpl<BillBuyInfoMapper, BillB
         content3 = getUrl(content3,buyImage3);
         content3 = getUrl(content3,buyImage4);
         content3 = getUrl(content3,buyImage5);
-
-        BillLandingInspection billLandingInspection = new BillLandingInspection();
-        billLandingInspection.setInspectionNum(inspectionNum);
-        billLandingInspection.setInspectionName(buyer+"的产地检疫");
-        billLandingInspection.setCargoOwner(cargoOwner);
-        billLandingInspection.setOwnerPhone(ownerPhone);
-        billLandingInspection.setAnimalType(Integer.parseInt(animalType));
-        billLandingInspection.setAnimalNumberUp(animalNumberUp);
-        billLandingInspection.setUseTo(useTo);
-        billLandingInspection.setStartTran(startTran);
-        billLandingInspection.setReachTran(reachTran);
-        billLandingInspection.setEartags(eartags);
-        billLandingInspection.setInspectionSch(4);
-        billLandingInspection.setInspectionType(1);
-        billLandingInspection.setReviewed(sysUser.getUserName());
-        billLandingInspection.setReviewedTime(DateTime.now());
-        billLandingInspection.setCreateUser(Long.valueOf(buyerId));
-        billLandingInspection.setCreateTime(DateTime.now());
-        billLandingInspectionMapper.insert(billLandingInspection);
-
+        BillLandingInspection billLandingInspection = billLandingInspectionMapper.selectOne(new QueryWrapper<BillLandingInspection>()
+                .eq("create_user", buyerId)
+                .eq("inspection_sch", 6));
+        if (ObjectUtil.isNotEmpty(billLandingInspection)){
+            billLandingInspection.setInspectionNum(inspectionNum);
+            billLandingInspection.setInspectionName(buyer+"的产地检疫");
+            billLandingInspection.setCargoOwner(cargoOwner);
+            billLandingInspection.setOwnerPhone(ownerPhone);
+            billLandingInspection.setAnimalType(Integer.parseInt(animalType));
+            billLandingInspection.setAnimalNumberUp(animalNumberUp);
+            billLandingInspection.setUseTo(useTo);
+            billLandingInspection.setStartTran(startTran);
+            billLandingInspection.setReachTran(reachTran);
+            billLandingInspection.setEartags(eartags);
+            billLandingInspection.setInspectionSch(4);
+            billLandingInspection.setInspectionType(1);
+            billLandingInspection.setReviewed(sysUser.getUserName());
+            billLandingInspection.setReviewedTime(DateTime.now());
+            billLandingInspection.setCreateUser(Long.valueOf(buyerId));
+            billLandingInspection.setCreateTime(DateTime.now());
+            billLandingInspectionMapper.updateById(billLandingInspection);
+        }else {
+            BillLandingInspection billLandingInspection1 = new BillLandingInspection();
+            billLandingInspection1.setInspectionNum(inspectionNum);
+            billLandingInspection1.setInspectionName(buyer+"的产地检疫");
+            billLandingInspection1.setCargoOwner(cargoOwner);
+            billLandingInspection1.setOwnerPhone(ownerPhone);
+            billLandingInspection1.setAnimalType(Integer.parseInt(animalType));
+            billLandingInspection1.setAnimalNumberUp(animalNumberUp);
+            billLandingInspection1.setUseTo(useTo);
+            billLandingInspection1.setStartTran(startTran);
+            billLandingInspection1.setReachTran(reachTran);
+            billLandingInspection1.setEartags(eartags);
+            billLandingInspection1.setInspectionSch(4);
+            billLandingInspection1.setInspectionType(1);
+            billLandingInspection1.setReviewed(sysUser.getUserName());
+            billLandingInspection1.setReviewedTime(DateTime.now());
+            billLandingInspection1.setCreateUser(Long.valueOf(buyerId));
+            billLandingInspection1.setCreateTime(DateTime.now());
+            billLandingInspectionMapper.insert(billLandingInspection1);
+        }
 
         if (ObjectUtil.isEmpty(billBuyInfo1)){
             BillBuyInfo billBuyInfo = new BillBuyInfo();
@@ -147,7 +168,7 @@ public class BillBuyInfoServiceImpl extends ServiceImpl<BillBuyInfoMapper, BillB
             billBuyInfo.setBillBuyStatus(2);
             this.save(billBuyInfo);
         }else {
-            billBuyInfo1.setBuyName(seller+"和"+buyer+"的交易信息");
+            billBuyInfo1.setBuyName(buyer+"和"+seller+"的交易信息");
             billBuyInfo1.setInspectionNum(inspectionNum);
             billBuyInfo1.setBuyerName(buyer);
             billBuyInfo1.setSellerName(seller);
@@ -183,104 +204,84 @@ public class BillBuyInfoServiceImpl extends ServiceImpl<BillBuyInfoMapper, BillB
     @Override
     @Transactional
     public Result saveTransaction(HttpServletRequest httpServletRequest,Map<String, String> paramsMap) {
-        String seller = paramsMap.get("sellerName");
-        String buyer = paramsMap.get("buyerName");
+        String inspectionNum = paramsMap.get("inspectionNum");
+        String cargoOwner = paramsMap.get("cargoOwner");
+        String ownerphone = paramsMap.get("ownerPhone");
+        String animalType = paramsMap.get("animalType");
+        String animalNumberUp = paramsMap.get("animalNumberUp");
+        String useTo = paramsMap.get("useTo");
+        String startTran = paramsMap.get("startTran");
+        String reachTran = paramsMap.get("reachTran");
+        String eartags = paramsMap.get("eartags");
+        String sellerId = paramsMap.get("sellerId");
+        String buyerId = paramsMap.get("buyerId");
+        String seller = paramsMap.get("seller");
+        String buyer = paramsMap.get("buyer");
         String sellerPhone = paramsMap.get("sellerPhone");
         String buyerPhone = paramsMap.get("buyerPhone");
-//        String imgname = "成功";
-//        String originalFilename = image1.getOriginalFilename();
-//        String filenameExtension = StringUtils.getFilenameExtension(originalFilename);
-//        String path = DateUtil.format(new Date(),"yyyy-MM");
-//        try {
-//            InputStream inputStream = image1.getInputStream();
-//            BufferedInputStream in = new BufferedInputStream(inputStream);
-//            ByteArrayOutputStream out = new ByteArrayOutputStream(1024);
-//
-//            byte[] temp = new byte[1024];
-//            int size = 0;
-//            while ((size = in.read(temp)) != -1) {
-//                out.write(temp, 0, size);
-//            }
-//            in.close();
-//            byte[] content = out.toByteArray();
-//            imgname = UUID.randomUUID()+"."+filenameExtension;
-//            UploadImage.sshSftp(content,path, imgname);
-//        } catch (Exception e) {
-//            e.printStackTrace();
-//        }
-//        String content = "https://dam.img.ifarmcloud.com:8030/images/"+path +"/"+imgname;
-//
-//        String imgname2 = "成功";
-//        String originalFilename2 = image2.getOriginalFilename();
-//        String filenameExtension2 = StringUtils.getFilenameExtension(originalFilename2);
-//        String path2 = DateUtil.format(new Date(),"yyyy-MM");
-//        try {
-//            InputStream inputStream = image2.getInputStream();
-//            BufferedInputStream in = new BufferedInputStream(inputStream);
-//            ByteArrayOutputStream out = new ByteArrayOutputStream(1024);
-//
-//            byte[] temp = new byte[1024];
-//            int size = 0;
-//            while ((size = in.read(temp)) != -1) {
-//                out.write(temp, 0, size);
-//            }
-//            in.close();
-//            byte[] content2 = out.toByteArray();
-//            imgname2 = UUID.randomUUID()+"."+filenameExtension2;
-//            UploadImage.sshSftp(content2,path2, imgname2);
-//        } catch (Exception e) {
-//            e.printStackTrace();
-//        }
-//        String content2 = "https://dam.img.ifarmcloud.com:8030/images/"+path2 +"/"+imgname2;
-//
-//        String imgname3 = "成功";
-//        String originalFilename3 = image3.getOriginalFilename();
-//        String filenameExtension3 = StringUtils.getFilenameExtension(originalFilename3);
-//        String path3 = DateUtil.format(new Date(),"yyyy-MM");
-//        try {
-//            InputStream inputStream = image3.getInputStream();
-//            BufferedInputStream in = new BufferedInputStream(inputStream);
-//            ByteArrayOutputStream out = new ByteArrayOutputStream(1024);
-//
-//            byte[] temp = new byte[1024];
-//            int size = 0;
-//            while ((size = in.read(temp)) != -1) {
-//                out.write(temp, 0, size);
-//            }
-//            in.close();
-//            byte[] content3 = out.toByteArray();
-//            imgname3 = UUID.randomUUID()+"."+filenameExtension3;
-//            UploadImage.sshSftp(content3,path3, imgname3);
-//        } catch (Exception e) {
-//            e.printStackTrace();
-//        }
-//        String content3 = "https://dam.img.ifarmcloud.com:8030/images/"+path3 +"/"+imgname3;
 
-        BillBuyInfo billBuyInfo1 = billBuyInfoMapper.selectOne(new QueryWrapper<BillBuyInfo>().eq("create_user", TokenSign.getUserName(httpServletRequest)).eq("bill_buy_status",1));
+        if (billLandingInspectionMapper.selectCount(new QueryWrapper<BillLandingInspection>().eq("inspection_num",inspectionNum)) != 0) {
+            return new Result(10001,"该检疫证号已存在!",false);
+        }
+
+        BillLandingInspection billLandingInspection = billLandingInspectionMapper.selectOne(new QueryWrapper<BillLandingInspection>()
+                .eq("create_user", buyerId)
+                .eq("inspection_sch", 6));
+        if (ObjectUtil.isNotEmpty(billLandingInspection)){
+            billLandingInspection.setInspectionNum(inspectionNum);
+            billLandingInspection.setCargoOwner(cargoOwner);
+            billLandingInspection.setOwnerPhone(ownerphone);
+            billLandingInspection.setAnimalType(Integer.parseInt(animalType));
+            billLandingInspection.setAnimalNumberUp(animalNumberUp);
+            billLandingInspection.setInspectionType(1);
+            billLandingInspection.setUseTo(useTo);
+            billLandingInspection.setStartTran(startTran);
+            billLandingInspection.setReachTran(reachTran);
+            billLandingInspection.setEartags(eartags);
+            billLandingInspectionMapper.updateById(billLandingInspection);
+        }else {
+            BillLandingInspection billLandingInspection1 = new BillLandingInspection();
+            billLandingInspection1.setInspectionNum(inspectionNum);
+            billLandingInspection1.setCargoOwner(cargoOwner);
+            billLandingInspection1.setOwnerPhone(ownerphone);
+            billLandingInspection1.setAnimalType(Integer.parseInt(animalType));
+            billLandingInspection1.setAnimalNumberUp(animalNumberUp);
+            billLandingInspection1.setInspectionType(1);
+            billLandingInspection1.setUseTo(useTo);
+            billLandingInspection1.setStartTran(startTran);
+            billLandingInspection1.setReachTran(reachTran);
+            billLandingInspection1.setEartags(eartags);
+            billLandingInspection1.setCreateTime(DateTime.now());
+            billLandingInspection1.setCreateUser(Long.valueOf(buyerId));
+            billLandingInspection1.setInspectionSch(6);
+            billLandingInspectionMapper.insert(billLandingInspection1);
+        }
+
+        BillBuyInfo billBuyInfo1 = billBuyInfoMapper.selectOne(new QueryWrapper<BillBuyInfo>().eq("create_user", TokenSign.getMemberIdByJwtToken(httpServletRequest)).eq("bill_buy_status",1));
         if (ObjectUtil.isEmpty(billBuyInfo1)){
             BillBuyInfo billBuyInfo = new BillBuyInfo();
-            billBuyInfo.setBuyName(seller+"和"+buyer+"的交易信息");
+            billBuyInfo.setInspectionNum(inspectionNum);
+            billBuyInfo.setBuyName(buyer+"和"+seller+"的交易信息");
+            billBuyInfo.setBuyerId(Long.valueOf(buyerId));
+            billBuyInfo.setSellerId(Long.valueOf(sellerId));
             billBuyInfo.setBuyerName(buyer);
             billBuyInfo.setBuyerPhone(buyerPhone);
             billBuyInfo.setSellerName(seller);
             billBuyInfo.setCreateUser(TokenSign.getMemberIdByJwtToken(httpServletRequest));
             billBuyInfo.setCreateTime(DateTime.now());
-//            billBuyInfo.setBuyPicUrl(content);
-//            billBuyInfo.setPayPicUrl(content2);
-//            billBuyInfo.setBuyPayGoodsPicUrl(content3);
             billBuyInfo.setBillBuyStatus(1);
             this.save(billBuyInfo);
         }else {
-            billBuyInfo1.setBuyName(seller+"和"+buyer+"的交易信息");
+            billBuyInfo1.setBuyName(buyer+"和"+seller+"的交易信息");
+            billBuyInfo1.setInspectionNum(inspectionNum);
+            billBuyInfo1.setBuyerId(Long.valueOf(buyerId));
+            billBuyInfo1.setSellerId(Long.valueOf(sellerId));
             billBuyInfo1.setBuyerName(buyer);
             billBuyInfo1.setBuyerPhone(buyerPhone);
             billBuyInfo1.setSellerName(seller);
             billBuyInfo1.setSellerPhone(sellerPhone);
             billBuyInfo1.setCreateUser(TokenSign.getMemberIdByJwtToken(httpServletRequest));
             billBuyInfo1.setCreateTime(DateTime.now());
-//            billBuyInfo1.setBuyPicUrl(content);
-//            billBuyInfo1.setPayPicUrl(content2);
-//            billBuyInfo1.setBuyPayGoodsPicUrl(content3);
             billBuyInfo1.setBillBuyStatus(1);
             this.updateById(billBuyInfo1);
         }

+ 2 - 2
admin/src/main/resources/com/huimv/farm/damsubsidy/mapper/BillBuyInfoMapper.xml

@@ -27,8 +27,8 @@
     </select>
 
     <select id="getLast" resultType="com.huimv.farm.damsubsidy.entity.vo.BillBuyInfoVo">
-        SELECT l.inspection_num,l.cargo_owner,l.owner_phone,l.animal_type,l.animal_number_up,l.use_to,l.start_tran,l.reach_tran,l.eartags,b.buyer_name,b.seller_name,b.real_num_up,real_eartag
- FROM `bill_buy_info` b LEFT JOIN `bill_landing_inspection` l ON b.inspection_num = l.inspection_num WHERE b.create_user = #{userName} and b.bill_buy_status = 1
+        SELECT l.inspection_num,l.cargo_owner,l.owner_phone,l.animal_type,l.animal_number_up,l.use_to,l.start_tran,l.reach_tran,l.eartags,b.buyer_name as buyerName,b.seller_name as sellerName,b.buyer_id,b.seller_id,b.buyer_phone,b.seller_phone
+ FROM `bill_buy_info` b LEFT JOIN `bill_landing_inspection` l ON b.inspection_num = l.inspection_num WHERE b.create_user = #{userName} and b.bill_buy_status = 1 and l.inspection_sch = 6 and l.inspection_type = 1
     </select>
 
     <select id="listTransaction" resultType="com.huimv.farm.damsubsidy.entity.vo.BillBuyInfoVo">