Bläddra i källkod

Merge remote-tracking branch 'origin/master'

LiFei 5 år sedan
förälder
incheckning
1c4bbfa774

+ 5 - 6
happy-boot-module-powerjob/src/main/java/org/jeecg/modules/hlgaccount/service/impl/HlgAccountDetailServiceImpl.java

@@ -26,6 +26,7 @@ import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.Resource;
 import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.text.DecimalFormat;
 import java.util.Date;
 import java.util.List;
@@ -137,9 +138,8 @@ public class HlgAccountDetailServiceImpl extends ServiceImpl<HlgAccountDetailMap
         //本次服务费
         Double serviceFee = businessAccountUtils.mul(hlgAccountDetail.getTotalAmount(), hlgAccountDetail.getServiceRate() * 0.01);
         //取俩位小数(注意:不是四舍五入)
-        DecimalFormat df = new DecimalFormat("#.00");
-        String serviceFeeStr = df.format(serviceFee);
-        serviceFee = Double.parseDouble(serviceFeeStr);
+        BigDecimal bg = BigDecimal.valueOf(serviceFee).setScale(2, RoundingMode.DOWN);
+        serviceFee = bg.doubleValue();
         hlgAccountDetail.setServiceFee(serviceFee);
         //项目金额 = 充值总金额 - serviceFee
         hlgAccountDetail.setAmount(businessAccountUtils.sub(hlgAccountDetail.getTotalAmount(), serviceFee));
@@ -192,9 +192,8 @@ public class HlgAccountDetailServiceImpl extends ServiceImpl<HlgAccountDetailMap
         //本次退款服务费
         Double refundServiceFee = businessAccountUtils.mul(hlgAccountDetail.getRefundAmount(), hlgAccountDetailNew.getServiceRate() * 0.01);
         //取俩位小数(注意:不是四舍五入)
-        DecimalFormat df = new DecimalFormat("#.00");
-        String refundServiceFeeStr = df.format(refundServiceFee);
-        refundServiceFee = Double.parseDouble(refundServiceFeeStr);
+        BigDecimal bg = BigDecimal.valueOf(refundServiceFee).setScale(2, RoundingMode.DOWN);
+        refundServiceFee = bg.doubleValue();
         hlgRefundDetail.setRefundServiceFee(refundServiceFee);
         hlgRefundDetail.setRefundAmount(businessAccountUtils.sub(hlgAccountDetail.getRefundAmount(), refundServiceFee));
         hlgRefundDetail.setIsDisplay(hlgAccountDetail.getIsDisplay());

+ 1 - 1
happy-boot-module-powerjob/src/main/java/org/jeecg/modules/hlgpayment/controller/HlgPaymentController.java

@@ -193,7 +193,7 @@ public class HlgPaymentController {
         if (hlgPaymentEntity == null) {
             result.error500("未找到对应实体");
         } else {
-            result = hlgPaymentService.deleteByLogic(hlgPayment);
+            result = hlgPaymentService.deleteByLogic(hlgPaymentEntity);
         }
         return result;
     }

+ 3 - 0
happy-boot-module-powerjob/src/main/java/org/jeecg/modules/hlgpayment/mapper/HlgPaymentDetailMapper.java

@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Constants;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import org.apache.ibatis.annotations.Param;
+import org.jeecg.modules.hlgpayment.entity.HlgPayment;
 import org.jeecg.modules.hlgpayment.entity.HlgPaymentDetail;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import org.jeecg.modules.hlgpayment.entity.HlgPaymentDetailStatistics;
@@ -31,4 +32,6 @@ public interface HlgPaymentDetailMapper extends BaseMapper<HlgPaymentDetail> {
     List<HlgPaymentDetailStatistics> getPaymentDetailStatisticsList(@Param("hlgPaymentDetailStatistics")HlgPaymentDetailStatistics hlgPaymentDetailStatistics, @Param(Constants.WRAPPER)QueryWrapper<HlgPaymentDetailStatistics> queryWrapper);
 
     List<HlgPaymentDetail> findHlgPaymentDetailListByPaymentId(Integer id);
+
+    void deleteByLogic(@Param("hlgPayment") HlgPayment hlgPayment);
 }

+ 3 - 12
happy-boot-module-powerjob/src/main/java/org/jeecg/modules/hlgpayment/mapper/xml/HlgPaymentDetailMapper.xml

@@ -140,16 +140,6 @@
 		group by a.id
 	</select>
 
-    <select id="findAllList" resultType="org.jeecg.modules.hlgpayment.entity.HlgPaymentDetail" >
-        SELECT
-        <include refid="hlgPaymentDetailColumns"/>
-        FROM hlg_payment_detail a
-        <include refid="hlgPaymentDetailJoins"/>
-        <where>
-            a.del_flag = #{DEL_FLAG_NORMAL}
-        </where>
-		ORDER BY a.update_time DESC
-    </select>
 
     <insert id="savePaymentDetail">
 		INSERT INTO hlg_payment_detail(
@@ -242,8 +232,8 @@
     <!--逻辑删除-->
     <update id="deleteByLogic">
 		UPDATE hlg_payment_detail SET
-			del_flag = #{DEL_FLAG_DELETE}
-		WHERE id = #{id}
+			del_flag = '1'
+		WHERE payment_id = #{hlgPayment.id}
 	</update>
 
 	<!--该付款明细用户本月累计已打款-->
@@ -256,6 +246,7 @@
 			a.idcard_number = #{hlgPaymentDetail.idcardNumber}
 			and DATE_FORMAT(a.payment_time, '%Y%m') = DATE_FORMAT( CURDATE( ) , '%Y%m' )
 			and (a.status = 1 or a.status = 2)
+			and a.del_flag = '0'
 		</where>
 	</select>
 

+ 3 - 0
happy-boot-module-powerjob/src/main/java/org/jeecg/modules/hlgpayment/service/IHlgPaymentDetailService.java

@@ -2,6 +2,7 @@ package org.jeecg.modules.hlgpayment.service;
 
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import org.jeecg.modules.hlgpayment.entity.HlgPayment;
 import org.jeecg.modules.hlgpayment.entity.HlgPaymentDetail;
 import com.baomidou.mybatisplus.extension.service.IService;
 import org.jeecg.modules.hlgpayment.entity.HlgPaymentDetailStatistics;
@@ -30,4 +31,6 @@ public interface IHlgPaymentDetailService extends IService<HlgPaymentDetail> {
     List<HlgPaymentDetailStatistics> getPaymentDetailStatisticsList(HlgPaymentDetailStatistics hlgPaymentDetailStatistics,QueryWrapper<HlgPaymentDetailStatistics> queryWrapper);
 
     List<HlgPaymentDetail> findHlgPaymentDetailListByPaymentId(Integer id);
+
+    void deleteByLogic(HlgPayment hlgPayment);
 }

+ 10 - 0
happy-boot-module-powerjob/src/main/java/org/jeecg/modules/hlgpayment/service/impl/HlgPaymentDetailServiceImpl.java

@@ -4,6 +4,7 @@ import com.baomidou.dynamic.datasource.annotation.DS;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.google.common.collect.Lists;
+import org.jeecg.modules.hlgpayment.entity.HlgPayment;
 import org.jeecg.modules.hlgpayment.entity.HlgPaymentDetail;
 import org.jeecg.modules.hlgpayment.entity.HlgPaymentDetailStatistics;
 import org.jeecg.modules.hlgpayment.mapper.HlgPaymentDetailMapper;
@@ -113,4 +114,13 @@ public class HlgPaymentDetailServiceImpl extends ServiceImpl<HlgPaymentDetailMap
     public List<HlgPaymentDetail> findHlgPaymentDetailListByPaymentId(Integer id) {
         return baseMapper.findHlgPaymentDetailListByPaymentId(id);
     }
+
+    /**
+     * 逻辑删除付款单下的所有明细
+     * @param hlgPayment
+     */
+    @Override
+    public void deleteByLogic(HlgPayment hlgPayment) {
+        baseMapper.deleteByLogic(hlgPayment);
+    }
 }

+ 35 - 11
happy-boot-module-powerjob/src/main/java/org/jeecg/modules/hlgpayment/service/impl/HlgPaymentServiceImpl.java

@@ -11,6 +11,7 @@ import org.apache.poi.ss.usermodel.Sheet;
 import org.apache.poi.ss.usermodel.Workbook;
 import org.apache.shiro.SecurityUtils;
 import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.constant.CommonConstant;
 import org.jeecg.common.system.vo.LoginUser;
 import org.jeecg.common.util.StringUtils;
 import org.jeecg.common.util.businessAccountUtils;
@@ -54,6 +55,7 @@ import org.springframework.web.multipart.MultipartFile;
 import javax.annotation.Resource;
 import java.io.IOException;
 import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.text.DecimalFormat;
 import java.util.*;
 import java.util.regex.Matcher;
@@ -152,7 +154,17 @@ public class HlgPaymentServiceImpl extends ServiceImpl<HlgPaymentMapper, HlgPaym
     @Transactional(rollbackFor = Exception.class)
     public Result<HlgPayment> payment(HlgPayment hlgPayment) {
         Result<HlgPayment> result = new Result<HlgPayment>();
-
+        HlgPayment hlgPaymentEntity = getById(hlgPayment.getId());
+        //付款单是否已删除
+        if (CommonConstant.DEL_FLAG_1.toString().equals(hlgPaymentEntity.getDelFlag())) {
+            result.error500("该付款单已删除,请刷新后重试!");
+            return result;
+        }
+        //付款单状态不是待付款
+        if (hlgPaymentEntity.getStatus() != 0) {
+            result.error500("该付款单状态已变更,请刷新后重试!");
+            return result;
+        }
         /**
          * 1、
          * 状态为复核通过
@@ -281,8 +293,8 @@ public class HlgPaymentServiceImpl extends ServiceImpl<HlgPaymentMapper, HlgPaym
             }
 
             //四舍五入,保留俩位小数
-            DecimalFormat df = new DecimalFormat("#.00");
-            String totalPaymenStr = df.format(totalPayment);
+            BigDecimal bg = BigDecimal.valueOf(totalPayment).setScale(2, RoundingMode.HALF_UP);
+            String totalPaymenStr = bg.toString();
 
             //服务商信息
             HlgSubcontractor hlgSubcontractor = hlgSubcontractorService.getById(hlgPayment.getSubcontractorId());
@@ -373,8 +385,14 @@ public class HlgPaymentServiceImpl extends ServiceImpl<HlgPaymentMapper, HlgPaym
     @Transactional(rollbackFor = Exception.class)
     public Result<HlgPayment> deleteByLogic(HlgPayment hlgPayment) {
         Result<HlgPayment> result = new Result<HlgPayment>();
-        baseMapper.deleteByLogic(hlgPayment);
-        result.success("删除成功");
+        if (hlgPayment.getStatus() == 0 || hlgPayment.getStatus() == 2) {
+            baseMapper.deleteByLogic(hlgPayment);
+            //同步逻辑删除付款明细
+            hlgPaymentDetailService.deleteByLogic(hlgPayment);
+            result.success("删除成功");
+        } else {
+            result.error500("删除失败");
+        }
         return result;
     }
 
@@ -458,8 +476,8 @@ public class HlgPaymentServiceImpl extends ServiceImpl<HlgPaymentMapper, HlgPaym
         }
 
         //四舍五入,保留俩位小数
-        DecimalFormat df = new DecimalFormat("#.00");
-        String totalPaymenStr = df.format(totalPayment);
+        BigDecimal bg = BigDecimal.valueOf(totalPayment).setScale(2, RoundingMode.HALF_UP);
+        String totalPaymenStr = bg.toString();
 
         //服务商信息
         HlgSubcontractor hlgSubcontractor = hlgSubcontractorService.getById(hlgPayment.getSubcontractorId());
@@ -683,7 +701,7 @@ public class HlgPaymentServiceImpl extends ServiceImpl<HlgPaymentMapper, HlgPaym
                         HlgUser hlgUser = hlgUserMapper.getUserByIdcardNumber(idcardNumber);
                         if (hlgUser == null) {
                             //获取当前平台id
-                            HlgCompany hlgCompany=hlgCompanyService.getById(hlgPayment.getCompanyId());
+                            HlgCompany hlgCompany = hlgCompanyService.getById(hlgPayment.getCompanyId());
                             HlgPlatform hlgPlatform = hlgPlatformMapper.selectById(hlgCompany.getPlatformId());
                             HlgUser hlgUser1 = new HlgUser();
                             hlgUser1.setPlatformId(hlgPlatform.getId());
@@ -743,7 +761,7 @@ public class HlgPaymentServiceImpl extends ServiceImpl<HlgPaymentMapper, HlgPaym
                 }
             }
         }
-        if(resultlist.size()>0){
+        if (resultlist.size() > 0) {
             return resultlist;
         }
         //定义导入付款总金额
@@ -795,6 +813,12 @@ public class HlgPaymentServiceImpl extends ServiceImpl<HlgPaymentMapper, HlgPaym
         Result<HlgPaymentDetail> result = new Result<>();
         //旧实体
         HlgPaymentDetail hlgPaymentDetailO = hlgPaymentDetailService.getById(hlgPaymentDetailN.getId());
+        //该付款明细是否满足补发条件
+        if (hlgPaymentDetailO.getStatus() != 3) {
+            result.error500("该付款明细不满足补发条件!");
+            return result;
+        }
+
         //更新的身份证号是否存在
         QueryWrapper<HlgUser> queryWrapper = new QueryWrapper<>();
         queryWrapper.eq("idcard_number", hlgPaymentDetailN.getIdcardNumber());
@@ -867,8 +891,8 @@ public class HlgPaymentServiceImpl extends ServiceImpl<HlgPaymentMapper, HlgPaym
         }
 
         //四舍五入,保留俩位小数
-        DecimalFormat df = new DecimalFormat("#.00");
-        String totalPaymenStr = df.format(totalPayment);
+        BigDecimal bg = BigDecimal.valueOf(totalPayment).setScale(2, RoundingMode.HALF_UP);
+        String totalPaymenStr = bg.toString();
 
         //服务商信息
         HlgSubcontractor hlgSubcontractor = hlgSubcontractorService.getById(hlgPayment.getSubcontractorId());

+ 6 - 3
happy-boot-module-powerjob/src/main/java/org/jeecg/modules/util/PayCommon.java

@@ -13,6 +13,8 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
 import javax.annotation.PostConstruct;
+import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.text.DecimalFormat;
 import java.util.ArrayList;
 import java.util.List;
@@ -162,14 +164,15 @@ public class PayCommon {
         obj_body.put("trxrmk", "代发");        //用途
         //代发明细
         JSONArray trsreq = new JSONArray();
-        //四舍五入,保留俩位小数
-        DecimalFormat df = new DecimalFormat("#.00");
+
         for (int i = 0; i < payLength; i++) {
             JSONObject trs = new JSONObject();
             HlgPaymentDetail hlgPaymentDetail = hlgPaymentDetailList.get(i);
             trs.put("eacnbr", hlgPaymentDetail.getCardNumber());      //账号
             trs.put("eacnam", hlgPaymentDetail.getUserName());      //户名
-            trs.put("trxamt", df.format(hlgPaymentDetail.getPayment()));      //金额
+            //四舍五入,保留俩位小数
+            BigDecimal bg = BigDecimal.valueOf(hlgPaymentDetail.getPayment()).setScale(2, RoundingMode.HALF_UP);
+            trs.put("trxamt", bg.toString());      //金额
             trs.put("bnkflg", hlgPaymentDetail.getBnkflg());       //系统内标志(Y:开户行是招商银行;N:开户行是他行)
             if ("N".equals(hlgPaymentDetail.getBnkflg())) {
                 trs.put("eacbnk", hlgPaymentDetail.getEacbnk());        //他行开户行