فهرست منبع

结算单核销

guoweisong 2 سال پیش
والد
کامیت
835bd8cdc3

+ 19 - 5
src/main/java/com/ydtech/modules/fnc/controller/InsPlySettleController.java

@@ -4,7 +4,6 @@ import com.ydtech.core.page.HttpResult;
 import com.ydtech.modules.base.controller.BaseController;
 import com.ydtech.modules.fnc.entity.InsPlyIncome;
 import com.ydtech.modules.fnc.entity.InsPlySettle;
-import com.ydtech.modules.fnc.entity.InsPlySettleDetail;
 import com.ydtech.modules.fnc.entity.InsPlySettleHx;
 import com.ydtech.modules.fnc.service.InsPlyIncomeService;
 import com.ydtech.modules.fnc.service.InsPlySettleService;
@@ -14,14 +13,12 @@ import com.ydtech.modules.order.entity.BasePageResult;
 import com.ydtech.utils.StringUtils;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
-import io.swagger.annotations.ApiParam;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
-import javax.servlet.http.HttpServletRequest;
 import javax.validation.Valid;
 import java.util.List;
 
@@ -104,16 +101,33 @@ public class InsPlySettleController extends BaseController {
      * @return
      */
     @ApiOperation(value = "[5]结算单核销")
-    @PostMapping("/enterSettle")
+    @PostMapping("/hxSettle")
     public HttpResult enterSettle( @RequestBody InsPlySettleHx insPlySettleHx){
 
         HttpResult result = null;
         try {
-            result = insPlySettleService.enterSettle(insPlySettleHx);
+            result = insPlySettleService.hxSettle(insPlySettleHx);
         } catch (Exception e) {
             result = HttpResult.error("结算单确认时发生错误!"+e.getMessage());
             e.printStackTrace();
         }
         return result;
     }
+    /**
+     *结算单核销明细查询
+     * @return
+     */
+    @ApiOperation(value = "[6]结算单核销明细查询")
+    @PostMapping("/queryHxDetail")
+    public HttpResult queryHxDetail( @RequestBody String settleno){
+
+        HttpResult result = null;
+        try {
+            result = insPlySettleService.queryHxDetail(settleno);
+        } catch (Exception e) {
+            result = HttpResult.error("系统错误!"+e.getMessage());
+            e.printStackTrace();
+        }
+        return result;
+    }
 }

+ 12 - 1
src/main/java/com/ydtech/modules/fnc/dao/InsPlySettleMapper.java

@@ -26,10 +26,11 @@ public interface InsPlySettleMapper extends BaseMapper<InsPlySettle> {
     String getMaxBatch(InsPlySettle insPlySettle);
 
     @Select({"<script>"," " +
-            "select a.*,b.`name` dept_name ,c.`name` companyName " +
+            "select a.*,b.`name` dept_name ,c.`name` companyName,d.hxamount " +
             "from ins_ply_settle a " +
             "left join sys_dept b on a.dept_id=b.id " +
             "left join esm_ins_company c on a.company_id=c.id " +
+            "left join (select t.settleno,SUM(amount) hxamount from ins_ply_settle_hx t group by t.settleno ) d on d.settleno=a.settleno " +
             "where 1=1 " +
             "<if test='startDate!=\"\" and endDate!=\"\" and startDate!=null and endDate!=null'>" +
             "and DATE_FORMAT(a.create_time, '%Y-%m-%d') " +
@@ -45,5 +46,15 @@ public interface InsPlySettleMapper extends BaseMapper<InsPlySettle> {
     )
     List<InsPlySettle> selectByCondition(InsPlySettleVo insPlySettleVo);
 
+    @Select({
+            "select a.*,b.`name` dept_name ,c.`name` companyName,d.hxamount " +
+            "from ins_ply_settle a " +
+            "left join sys_dept b on a.dept_id=b.id " +
+            "left join esm_ins_company c on a.company_id=c.id " +
+            "left join (select t.settleno,SUM(amount) hxamount from ins_ply_settle_hx t group by t.settleno ) d on d.settleno=a.settleno " +
+            "where a.settleno =#{settleno}"
+            }
+    )
+    InsPlySettle selectBySettleno(String settleno);
 
 }

+ 4 - 0
src/main/java/com/ydtech/modules/fnc/entity/InsPlySettle.java

@@ -58,6 +58,10 @@ public class InsPlySettle implements Serializable {
     @TableField("all_fee_value")
     private BigDecimal allFeeValue;
 
+    @ApiModelProperty("核销金额")
+    @TableField(exist = false)
+    private BigDecimal hxamount;
+
     @ApiModelProperty("机构")
     @TableField("dept_id")
     private String deptId;

+ 1 - 1
src/main/java/com/ydtech/modules/fnc/entity/InsPlySettleHx.java

@@ -31,7 +31,7 @@ public class InsPlySettleHx implements Serializable {
     @TableField("settleno")
     private String settleno;
 
-    @ApiModelProperty("核销费用类型(手续费、其他费用、手续费+其他费用)")
+    @ApiModelProperty("核销费用类型(S手续费、O其他费用、A手续费+其他费用)")
     @TableField("fee_type")
     private String feeType;
 

+ 3 - 1
src/main/java/com/ydtech/modules/fnc/service/InsPlySettleService.java

@@ -28,6 +28,8 @@ public interface InsPlySettleService extends IService<InsPlySettle> {
 
     public HttpResult<BasePageResult<InsPlyIncome>> selectSettleDetail(InsPlySettleVo insPlySettle);
 
-    public HttpResult enterSettle(InsPlySettleHx insPlySettle);
+    public HttpResult hxSettle(InsPlySettleHx insPlySettle);
+
+    public HttpResult queryHxDetail(String settleno);
 
 }

+ 32 - 4
src/main/java/com/ydtech/modules/fnc/service/impl/InsPlySettleServiceImpl.java

@@ -1,12 +1,14 @@
 package com.ydtech.modules.fnc.service.impl;
 
 import cn.dev33.satoken.stp.StpUtil;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
 import com.ydtech.core.page.HttpResult;
 import com.ydtech.modules.fnc.dao.InsPlyIncomeMapper;
 import com.ydtech.modules.fnc.dao.InsPlySettleDetailMapper;
+import com.ydtech.modules.fnc.dao.InsPlySettleHxMapper;
 import com.ydtech.modules.fnc.entity.InsPlyIncome;
 import com.ydtech.modules.fnc.entity.InsPlySettle;
 import com.ydtech.modules.fnc.dao.InsPlySettleMapper;
@@ -25,6 +27,7 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import java.math.BigDecimal;
+import java.sql.Wrapper;
 import java.time.LocalDate;
 import java.time.LocalDateTime;
 import java.time.YearMonth;
@@ -46,7 +49,8 @@ public class InsPlySettleServiceImpl extends ServiceImpl<InsPlySettleMapper, Ins
     private InsPlySettleDetailMapper insPlySettleDetailMapper;
     @Autowired
     private InsPlyIncomeMapper insPlyIncomeMapper;
-
+    @Autowired
+    private InsPlySettleHxMapper insPlySettleHxMapper;
     @Override
     @Transactional
     public HttpResult generateSettleAndDetail(List<InsPlyIncome> plyList) {
@@ -73,7 +77,7 @@ public class InsPlySettleServiceImpl extends ServiceImpl<InsPlySettleMapper, Ins
             insPlySettleDetail.setCreateTime(LocalDateTime.now());
             insPlySettleDetailMapper.insert(insPlySettleDetail);
             //修改ins_ply_income
-            insPlyIncome.setDoingFeeValue(insPlyIncome.getAllFeeValue());
+            insPlyIncome.setFinalFeeValue(insPlyIncome.getAllFeeValue());
             insPlyIncomeMapper.updateById(insPlyIncome);
 
             commissionFeevalue=commissionFeevalue.add(insPlyIncome.getCommissionFeevalue());
@@ -134,7 +138,31 @@ public class InsPlySettleServiceImpl extends ServiceImpl<InsPlySettleMapper, Ins
         }
     }
     @Override
-    public HttpResult enterSettle(InsPlySettleHx insPlySettle) {
-        return null;
+    public HttpResult hxSettle(InsPlySettleHx insPlySettleHx) {
+
+        //必填校验
+        if(StringUtils.isNullOrEmpty(insPlySettleHx.getSettleno())
+        ||StringUtils.isNullOrEmpty(insPlySettleHx.getFeeType())
+        ||StringUtils.isNullOrEmpty(insPlySettleHx.getCheckno())
+        ||StringUtils.isNullOrEmpty(insPlySettleHx.getAmount())){
+            return HttpResult.error("结算单号、费用类型、核销金额、发票号不能为空");
+        }
+        //核销金额不能超总费用
+        InsPlySettle insPlySettle=this.baseMapper.selectBySettleno(insPlySettleHx.getSettleno());
+        if(insPlySettle.getHxamount().add(insPlySettleHx.getAmount()).compareTo(insPlySettle.getAllFeeValue())>0){
+            return HttpResult.error("核销金额已超过总费用,请修改");
+        }
+
+        insPlySettleHx.setOperator(StpUtil.getLoginId().toString());
+        insPlySettleHx.setCreateTime(LocalDateTime.now());
+        insPlySettleHxMapper.insert(insPlySettleHx);
+        return HttpResult.ok("核销成功");
+    }
+    @Override
+    public HttpResult queryHxDetail(String settleno) {
+        LambdaQueryWrapper<InsPlySettleHx> queryWrapper=new LambdaQueryWrapper();
+        queryWrapper.eq(InsPlySettleHx::getSettleno,settleno);
+        List<InsPlySettleHx> list=insPlySettleHxMapper.selectList(queryWrapper);
+        return HttpResult.ok(list);
     }
 }