haungfuli 2 gadi atpakaļ
vecāks
revīzija
bee0e3ddc4

+ 4 - 0
winsea-haixin-plugin-wangluohuoyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/entity/HyCargoOwnerAddressInfo.java

@@ -80,6 +80,10 @@ public class HyCargoOwnerAddressInfo extends BaseModel<HyCargoOwnerAddressInfo>
      * 置顶标识(1是)
      */
     private String toppingFlag;
+    /**
+     * 排序(倒序)
+     */
+    private Integer sort;
 
     /**
      * 模糊查询

+ 57 - 2
winsea-haixin-plugin-wangluohuoyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/service/impl/CargoOwnerAddressInfoServiceImpl.java

@@ -62,6 +62,31 @@ public class CargoOwnerAddressInfoServiceImpl extends ServiceImpl<CargoOwnerAddr
      */
     @Override
     public String addCargoOwnerAddress(HyCargoOwnerAddressInfo hyCargoOwnerAddressInfo){
+        //查询货主有没有置顶地址
+        List<HyCargoOwnerAddressInfo> hyCargoOwnerAddressInfoList = this.selectList(new EntityWrapper<HyCargoOwnerAddressInfo>()
+        .eq("common_id",hyCargoOwnerAddressInfo.getCommonId()).eq("delete_flag","0")
+                .eq("topping_flag","1").orderBy("sort",true));
+        //没有置顶地址的时候,新增的地址序号最大
+        if (CollectionUtils.isEmpty(hyCargoOwnerAddressInfoList)){
+            //查询货主所有地址,倒序
+            List<HyCargoOwnerAddressInfo> hyCargoOwnerAddressInfoList1 = this.selectList(new EntityWrapper<HyCargoOwnerAddressInfo>()
+                    .eq("common_id",hyCargoOwnerAddressInfo.getCommonId()).eq("delete_flag","0").orderBy("sort",false));
+            if (hyCargoOwnerAddressInfoList1.size()==0){
+                //第一个地址
+                hyCargoOwnerAddressInfo.setSort(1);
+            }else {
+                hyCargoOwnerAddressInfo.setSort(hyCargoOwnerAddressInfoList1.get(0).getSort()+1);
+            }
+        }
+        //有置顶地址
+        else {
+            hyCargoOwnerAddressInfo.setSort(hyCargoOwnerAddressInfoList.get(0).getSort());
+            for (int i=0;i<hyCargoOwnerAddressInfoList.size();i++){
+                int t = hyCargoOwnerAddressInfoList.get(i).getSort();
+                hyCargoOwnerAddressInfoList.get(i).setSort(t+1);
+            }
+            this.updateBatchById(hyCargoOwnerAddressInfoList);
+        }
         //新增主键id
         hyCargoOwnerAddressInfo.setId(IdGenerator.generateUUID());
         this.insert(hyCargoOwnerAddressInfo);
@@ -86,6 +111,21 @@ public class CargoOwnerAddressInfoServiceImpl extends ServiceImpl<CargoOwnerAddr
     @Override
     public void deleteCargoOwnerAddress(String id) {
         HyCargoOwnerAddressInfo hyCargoOwnerAddressInfo = this.selectById(id);
+        //查询货主所有地址,倒序
+        List<HyCargoOwnerAddressInfo> hyCargoOwnerAddressInfoList = this.selectList(new EntityWrapper<HyCargoOwnerAddressInfo>()
+                .eq("common_id",hyCargoOwnerAddressInfo.getCommonId()).eq("delete_flag","0")
+                .orderBy("sort",false));
+        //要删除的地址不是序号最大的
+        if (hyCargoOwnerAddressInfo.getId() != hyCargoOwnerAddressInfoList.get(0).getId()){
+            for (HyCargoOwnerAddressInfo hyCargoOwnerAddressInfo1 : hyCargoOwnerAddressInfoList){
+                //该地址比要删除的地址序号大,序号-1
+                if (hyCargoOwnerAddressInfo1.getSort() > hyCargoOwnerAddressInfo.getSort()){
+                    int t = hyCargoOwnerAddressInfo1.getSort();
+                    hyCargoOwnerAddressInfo1.setSort(t-1);
+                    this.updateById(hyCargoOwnerAddressInfo1);
+                }
+            }
+        }
         this.deleteById(hyCargoOwnerAddressInfo.getId());
     }
 
@@ -96,10 +136,10 @@ public class CargoOwnerAddressInfoServiceImpl extends ServiceImpl<CargoOwnerAddr
     @Override
     @Transactional(rollbackFor = Exception.class)
     public String setDefault(HyCargoOwnerAddressInfo hyCargoOwnerAddressInfo) {
-        //查询货主所有地址
+        //查询货主所有地址,倒序
         List<HyCargoOwnerAddressInfo> hyCargoOwnerAddressInfoList = this.selectList(new EntityWrapper<HyCargoOwnerAddressInfo>()
                 .eq(HyCargoOwnerAddressInfo.QueryFiles.COMMON_ID, hyCargoOwnerAddressInfo.getCommonId())
-                .eq(HyCargoOwnerAddressInfo.QueryFiles.DELETE_FLAG, NumberConstant.CONSTANT0));
+                .eq(HyCargoOwnerAddressInfo.QueryFiles.DELETE_FLAG, NumberConstant.CONSTANT0).orderBy("sort",false));
         if(!CollectionUtils.isEmpty(hyCargoOwnerAddressInfoList)){
             for (HyCargoOwnerAddressInfo hyCargoOwnerAddressInfo1 : hyCargoOwnerAddressInfoList){
                 //id相等设置默认,其余数据取消默认
@@ -115,6 +155,21 @@ public class CargoOwnerAddressInfoServiceImpl extends ServiceImpl<CargoOwnerAddr
                     }else {
                         //设置置顶
                         hyCargoOwnerAddressInfo1.setToppingFlag("1");
+                        //货主不止一条地址的时候
+                        if (hyCargoOwnerAddressInfoList.size() != 1){
+                            //要置顶的地址不是序号最大的
+                            if (hyCargoOwnerAddressInfo1.getId() != hyCargoOwnerAddressInfoList.get(0).getId()){
+                                for (HyCargoOwnerAddressInfo hyCargoOwnerAddressInfo2 : hyCargoOwnerAddressInfoList){
+                                    //比此地址序号大的-1
+                                    if (hyCargoOwnerAddressInfo2.getSort() > hyCargoOwnerAddressInfo1.getSort()){
+                                        int t = hyCargoOwnerAddressInfo2.getSort();
+                                        hyCargoOwnerAddressInfo2.setSort(t-1);
+                                        this.updateById(hyCargoOwnerAddressInfo2);
+                                    }
+                                }
+                                hyCargoOwnerAddressInfo1.setSort(hyCargoOwnerAddressInfoList.size());
+                            }
+                        }
                     }
                     this.updateById(hyCargoOwnerAddressInfo1);
                 }else {

+ 4 - 0
winsea-haixin-plugin-wangluohuoyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/service/impl/OrderInfoServiceImpl.java

@@ -9,6 +9,7 @@ import com.google.common.collect.Lists;
 import com.itextpdf.text.DocumentException;
 import com.winsea.svc.base.base.util.DateUtils;
 import com.yh.saas.common.support.util.IdGenerator;
+import com.yh.saas.common.support.util.StringUtils;
 import com.yh.saas.plugin.yiliangyiyun.constant.StatusEnum;
 import com.yh.saas.plugin.yiliangyiyun.entity.*;
 import com.yh.saas.plugin.yiliangyiyun.exception.YException;
@@ -1147,6 +1148,9 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
                     hyFreightSettlementInfo.setBankDeposit(orderInfo1.getBankDeposit());
                     hyFreightSettlementInfo.setBankDepositBranch(orderInfo1.getBankDepositBranch());
                     hyFreightSettlementInfo.setPaymentType("尾款");
+                    if (freightInfo.getPrepaidFreight() == null){
+                        throw new YException(YExceptionEnum.PAY_ADVANCE_PAYMENT);
+                    }
                     hyFreightSettlementInfo.setAmountMoney(freightInfo.getActualFreight() - freightInfo.getPrepaidFreight() - freightInfo.getDriverServiceCharge());
                     hyFreightSettlementInfo.setStatusKey(StatusEnum.NO_PAYMENT.getFlag());
                     hyFreightSettlementInfo.setStatus(StatusEnum.NO_PAYMENT.getName());

+ 1 - 1
winsea-haixin-plugin-wangluohuoyun/src/main/resources/mapper/CargoOwnerAddressInfoMapper.xml

@@ -48,7 +48,7 @@
             OR lower(contacts) like lower(CONCAT('%',#{searchKeyWord},'%'))
             OR lower(contact_phone) like lower(CONCAT('%',#{searchKeyWord},'%')))
         </if>
-        ORDER BY topping_flag DESC ,create_date DESC
+        ORDER BY sort DESC
         <if test="currentPage != null and currentPage != ''">
             LIMIT ${startRecord}, ${pageSize}
         </if>