소스 검색

[CODE]: 财务模块:确认接口、更新费用明细

maxianghua 4 년 전
부모
커밋
94374e8781

+ 15 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/warehouse/finance/TChargeController.java

@@ -129,5 +129,20 @@ public class TChargeController extends BaseController {
     }
 
 
+    /**
+     *   撤销收费
+     */
+    @PreAuthorize("@ss.hasPermi('finance:charge:add')")
+    @Log(title = "财务数据主", businessType = BusinessType.INSERT)
+    @PostMapping(value = "/revoke")
+    @RepeatSubmit
+    public AjaxResult revoke(@RequestParam("tFee") String tFee,
+                              @RequestParam("tFeeDo") String tFeeDo ) {
+        String billsType = "DCRevoke";
+        // 获取当前的用户
+        LoginUser loginUser = SpringUtils.getBean(TokenService.class).getLoginUser(ServletUtils.getRequest());
+        return tFeeService.revoke(tFee,tFeeDo,loginUser,billsType);
+    }
+
 
 }

+ 30 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/warehouse/finance/TContrastController.java

@@ -112,4 +112,34 @@ public class TContrastController extends BaseController {
         return getDataTable(list);
     }
 
+    /**
+     *   确认对账
+     */
+    @PreAuthorize("@ss.hasPermi('finance:contrast:add')")
+    @Log(title = "财务数据主", businessType = BusinessType.INSERT)
+    @PostMapping(value = "/confirm")
+    @RepeatSubmit
+    public AjaxResult confirm(@RequestParam("tFee") String tFee,
+                              @RequestParam("tFeeDo") String tFeeDo ) {
+        String billsType = "DZ";
+        // 获取当前的用户
+        LoginUser loginUser = SpringUtils.getBean(TokenService.class).getLoginUser(ServletUtils.getRequest());
+        return tFeeService.confirm(tFee,tFeeDo,loginUser,billsType);
+    }
+
+    /**
+     *   撤销对账
+     */
+    @PreAuthorize("@ss.hasPermi('finance:contrast:add')")
+    @Log(title = "财务数据主", businessType = BusinessType.INSERT)
+    @PostMapping(value = "/revoke")
+    @RepeatSubmit
+    public AjaxResult revoke(@RequestParam("tFee") String tFee,
+                             @RequestParam("tFeeDo") String tFeeDo ) {
+        String billsType = "DZRevoke";
+        // 获取当前的用户
+        LoginUser loginUser = SpringUtils.getBean(TokenService.class).getLoginUser(ServletUtils.getRequest());
+        return tFeeService.revoke(tFee,tFeeDo,loginUser,billsType);
+    }
+
 }

+ 30 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/warehouse/finance/TPaymentController.java

@@ -113,4 +113,34 @@ public class TPaymentController extends BaseController {
         return getDataTable(list);
     }
 
+    /**
+     *   确认付费
+     */
+    @PreAuthorize("@ss.hasPermi('finance:payment:add')")
+    @Log(title = "财务数据主", businessType = BusinessType.INSERT)
+    @PostMapping(value = "/confirm")
+    @RepeatSubmit
+    public AjaxResult confirm(@RequestParam("tFee") String tFee,
+                              @RequestParam("tFeeDo") String tFeeDo ) {
+        String billsType = "FF";
+        // 获取当前的用户
+        LoginUser loginUser = SpringUtils.getBean(TokenService.class).getLoginUser(ServletUtils.getRequest());
+        return tFeeService.confirm(tFee,tFeeDo,loginUser,billsType);
+    }
+
+    /**
+     *   撤销付费
+     */
+    @PreAuthorize("@ss.hasPermi('finance:payment:add')")
+    @Log(title = "财务数据主", businessType = BusinessType.INSERT)
+    @PostMapping(value = "/revoke")
+    @RepeatSubmit
+    public AjaxResult revoke(@RequestParam("tFee") String tFee,
+                             @RequestParam("tFeeDo") String tFeeDo ) {
+        String billsType = "DCRevoke";
+        // 获取当前的用户
+        LoginUser loginUser = SpringUtils.getBean(TokenService.class).getLoginUser(ServletUtils.getRequest());
+        return tFeeService.revoke(tFee,tFeeDo,loginUser,billsType);
+    }
+
 }

+ 5 - 2
ruoyi-warehouse/src/main/java/com/ruoyi/finance/service/ITFeeService.java

@@ -84,11 +84,14 @@ public interface ITFeeService {
     public List<Map<String, Object>> warehouseBillsFeesList(TWareHouseFees tWareHouseFees);
 
     /**
-     *    财务: 对账、收费、付费   流程确认
-     * @param fid
+     *  财务: 对账、收费、付费   流程确认
+     * @param tfee
+     * @param tfeeDo
      * @param loginUser
      * @param fBilltype
      * @return
      */
     public AjaxResult confirm(String tfee, String tfeeDo ,LoginUser loginUser,String fBilltype);
+
+    public AjaxResult revoke(String tfee, String tfeeDo ,LoginUser loginUser,String fBilltype);
 }

+ 56 - 22
ruoyi-warehouse/src/main/java/com/ruoyi/finance/service/impl/TFeeServiceImpl.java

@@ -23,6 +23,8 @@ import com.ruoyi.warehouseBusiness.mapper.TWarehousebillsfeesMapper;
 import com.ruoyi.warehouseBusiness.service.impl.BillnoSerialServiceImpl;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.transaction.interceptor.TransactionAspectSupport;
 
 import java.math.BigDecimal;
 import java.util.*;
@@ -59,6 +61,7 @@ public class TFeeServiceImpl implements ITFeeService {
     @Autowired
     private TWarehousebillsfeesMapper tWarehousebillsfeesMapper;
 
+
     /**
      * 查询财务数据主
      *
@@ -290,6 +293,7 @@ public class TFeeServiceImpl implements ITFeeService {
     }
 
     @Override
+    @Transactional
     public AjaxResult confirm(String tfee, String tfeeDo, LoginUser loginUser, String fBilltype) {
         // 更新 主表、从表
         TFee tFee = JSONArray.parseObject(tfee, TFee.class);
@@ -307,38 +311,68 @@ public class TFeeServiceImpl implements ITFeeService {
                 tFeeDo.setCreateBy(loginUser.getUser().getUserName());
                 tFeeDo.setCreateTime(new Date());
                 tFeeDoMapper.insertTFeeDo(tFeeDo);
+                // 跟新费用明细
+                int m = updateBillsFees(tFee.getfId(),tFeeDo,fBilltype);
+                if (m == 0) {
+                    TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+                    return AjaxResult.error("更新费用明细失败");
+                }
             }
         }
-        // 更新费用明细
-        updateBillsFees(tFee.getfId(),fBilltype);
-
         // 审批流程
 
+        return AjaxResult.success();
+    }
 
-
-        return null;
+    @Override
+    @Transactional
+    public AjaxResult revoke(String tfee, String tfeeDo, LoginUser loginUser, String fBilltype) {
+        // 更新 主表、从表
+        TFee tFee = JSONArray.parseObject(tfee, TFee.class);
+        tFee.setUpdateBy(loginUser.getUser().getUserName());
+        tFee.setUpdateTime(new Date());
+        tFeeMapper.updateTFee(tFee);
+        // 删除从表
+        tFeeDoMapper.deleteByFPid(tFee.getfId());
+        //  财务从表
+        if (StringUtils.isNotNull(tfeeDo)) {
+            JSONArray jsonDrArray = JSONArray.parseArray(tfeeDo);
+            List<TFeeDo> tFeeDoList = JSONObject.parseArray(jsonDrArray.toJSONString(), TFeeDo.class);
+            for (TFeeDo tFeeDo : tFeeDoList) {
+                tFeeDo.setfPid(tFee.getfId());
+                tFeeDo.setCreateBy(loginUser.getUser().getUserName());
+                tFeeDo.setCreateTime(new Date());
+                tFeeDoMapper.insertTFeeDo(tFeeDo);
+                // 跟新费用明细
+                int m = updateBillsFees(tFee.getfId(),tFeeDo,fBilltype);
+                if (m == 0) {
+                    TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+                    return AjaxResult.error("更新费用明细失败");
+                }
+            }
+        }
+        return AjaxResult.success();
     }
 
-    public  void  updateBillsFees(Long fid,String billsType){
+    /**
+     *  更新费用明细
+     * @param fid
+     * @param tFeeDo
+     * @param billsType
+     * @return
+     */
+    @Transactional
+    public  int  updateBillsFees(Long fid,TFeeDo tFeeDo,String billsType){
         // 查询从表数据
         TFee tFee=tFeeMapper.selectTFeeById(fid);
-        TFeeDo tFeeDo = new TFeeDo();
-        tFeeDo.setfPid(fid);
-        List<TFeeDo> tFeeDoList=  tFeeDoMapper.selectTFeeDoList(tFeeDo);
-        // 更新费用明细
-        for (TFeeDo tFeeDo1 : tFeeDoList ){
-            // 查询仓库费用明细表数据
-            TWarehousebillsfees tWarehousebillsfees=new TWarehousebillsfees();
-            tWarehousebillsfees.setfId(tFeeDo1.getfSrcid());
-            if(billsType.equals("DZ")){
-                tWarehousebillsfees.setfStatementNo(tFee.getfBillno());
-                tWarehousebillsfees.setfAccamountDate(tFee.getfAccbilldate());
-            } else {
-                tWarehousebillsfees.setfStlamountNo(tFee.getfBillno());
-                // tWarehousebillsfees.setfStlamount();
-                tWarehousebillsfees.setfStlamountDate(tFee.getfAccbilldate());
-            }
+        if(billsType.equals("SF") || billsType.equals("FF")){
+            billsType="DC";
         }
+        Map<String, Object> map = new HashMap<>();
+        map.put("tFee", tFee);
+        map.put("billType", billsType);
+        map.put("tFeeDo", tFeeDo);
+        return tWarehousebillsfeesMapper.updateTWarehousebillsfee(map);
     }
 
 

+ 4 - 0
ruoyi-warehouse/src/main/java/com/ruoyi/warehouseBusiness/mapper/TWarehousebillsfeesMapper.java

@@ -6,6 +6,7 @@ import com.ruoyi.warehouseBusiness.domain.TWarehousebillsfees;
 import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
+import java.util.Map;
 
 /**
  * 仓库费用明细Mapper接口
@@ -72,4 +73,7 @@ public interface TWarehousebillsfeesMapper extends BaseMapper<TWarehousebillsfee
      * @return  结果
      */
     int warehouseFeesFollowUpdate(@Param("fPid") Long fPid, @Param("fettle") Long fettle);
+
+
+    public int updateTWarehousebillsfee(@Param("map") Map<String, Object> map);
 }

+ 30 - 0
ruoyi-warehouse/src/main/resources/mapper/warehouseBusiness/TWarehousebillsfeesMapper.xml

@@ -209,4 +209,34 @@
         where f_pid = #{fPid}
     </update>
 
+    <update id="updateTWarehousebillsfee" parameterType="Map">
+        update t_warehousebillsfees
+        <trim prefix="SET" suffixOverrides=",">
+            /*判断确认对账*/
+            <if test="map.billType == 'DZ'">
+                f_statement_no = #{map.tFee.fBillno},
+                f_accamount = f_accamount + #{map.tFee.fAmtcr},
+                f_accamount_date =  #{map.tFee.fAccbilldate}
+            </if>
+            /*判断撤销对账*/
+            <if test="map.billType == 'DZRevoke'">
+                f_statement_no =  #{map.tFee.fBillno},
+                f_accamount_date = #{map.tFee.fAccbilldate}
+            </if>
+            /*判断收付款*/
+            <if test="map.billType == 'DC'">
+                f_stlamount_no = #{map.tFee.fBillno},
+                f_stlamount = f_stlamount +  #{map.tFee.fAmtcr},
+                f_stlamount_date =#{map.tFee.fAccbilldate}
+            </if>
+            /*判断撤销收付款*/
+            <if test="map.billType == 'DCRevoke'">
+                f_stlamount_no = #{map.tFee.fBillno},
+                f_stlamount = f_stlamount -  #{map.tFee.fAmtcr},
+                f_stlamount_date =#{map.tFee.fAccbilldate}
+            </if>
+        </trim>
+        where f_id = #{map.tFeeDo.fSrcid}
+    </update>
+
 </mapper>