Browse Source

fixed 员工提成计算公式

fushengqian 1 year ago
parent
commit
5a32925cac

+ 41 - 7
fuint-application/src/main/java/com/fuint/common/service/impl/CommissionCashServiceImpl.java

@@ -71,11 +71,9 @@ public class CommissionCashServiceImpl extends ServiceImpl<MtCommissionCashMappe
      * @return
      */
     @Override
-    public PaginationResponse<CommissionCashDto> queryCommissionCashByPagination(PaginationRequest paginationRequest) {
+    public PaginationResponse<CommissionCashDto> queryCommissionCashByPagination(PaginationRequest paginationRequest) throws BusinessCheckException {
         Page<MtCommissionCash> pageHelper = PageHelper.startPage(paginationRequest.getCurrentPage(), paginationRequest.getPageSize());
         LambdaQueryWrapper<MtCommissionCash> lambdaQueryWrapper = Wrappers.lambdaQuery();
-        lambdaQueryWrapper.ne(MtCommissionCash::getStatus, StatusEnum.DISABLE.getKey());
-
         String status = paginationRequest.getSearchParams().get("status") == null ? "" : paginationRequest.getSearchParams().get("status").toString();
         if (StringUtils.isNotBlank(status)) {
             lambdaQueryWrapper.eq(MtCommissionCash::getStatus, status);
@@ -88,10 +86,40 @@ public class CommissionCashServiceImpl extends ServiceImpl<MtCommissionCashMappe
         if (StringUtils.isNotBlank(storeId)) {
             lambdaQueryWrapper.eq(MtCommissionCash::getStoreId, storeId);
         }
+        String realName = paginationRequest.getSearchParams().get("realName") == null ? "" : paginationRequest.getSearchParams().get("realName").toString();
+        if (StringUtils.isNotEmpty(realName)) {
+            Map<String, Object> params = new HashMap<>();
+            params.put("REAL_NAME", realName);
+            params.put("AUDITED_STATUS", StatusEnum.ENABLED.getKey());
+            List<MtStaff> staffList = staffService.queryStaffByParams(params);
+            if (staffList != null && staffList.size() > 0) {
+                lambdaQueryWrapper.eq(MtCommissionCash::getStaffId, staffList.get(0).getId());
+            } else {
+                lambdaQueryWrapper.eq(MtCommissionCash::getStaffId, -1);
+            }
+        }
+        String mobile = paginationRequest.getSearchParams().get("mobile") == null ? "" : paginationRequest.getSearchParams().get("mobile").toString();
+        if (StringUtils.isNotEmpty(mobile)) {
+            MtStaff mtStaff = staffService.queryStaffByMobile(mobile);
+            if (mtStaff != null) {
+                lambdaQueryWrapper.eq(MtCommissionCash::getStaffId, mtStaff.getId());
+            } else {
+                lambdaQueryWrapper.eq(MtCommissionCash::getStaffId, -1);
+            }
+        }
         String uuid = paginationRequest.getSearchParams().get("uuid") == null ? "" : paginationRequest.getSearchParams().get("uuid").toString();
         if (StringUtils.isNotBlank(uuid)) {
             lambdaQueryWrapper.eq(MtCommissionCash::getUuid, uuid);
         }
+        // 开始时间、结束时间
+        String startTime = paginationRequest.getSearchParams().get("startTime") == null ? "" : paginationRequest.getSearchParams().get("startTime").toString();
+        String endTime = paginationRequest.getSearchParams().get("endTime") == null ? "" : paginationRequest.getSearchParams().get("endTime").toString();
+        if (StringUtil.isNotEmpty(startTime)) {
+            lambdaQueryWrapper.ge(MtCommissionCash::getCreateTime, startTime);
+        }
+        if (StringUtil.isNotEmpty(endTime)) {
+            lambdaQueryWrapper.le(MtCommissionCash::getCreateTime, endTime);
+        }
         lambdaQueryWrapper.orderByDesc(MtCommissionCash::getId);
         List<MtCommissionCash> commissionCashList = mtCommissionCashMapper.selectList(lambdaQueryWrapper);
         List<CommissionCashDto> dataList = new ArrayList<>();
@@ -265,23 +293,29 @@ public class CommissionCashServiceImpl extends ServiceImpl<MtCommissionCashMappe
        if (StringUtil.isEmpty(requestParam.getUuid())) {
            throw new BusinessCheckException("请求有误.");
        }
-       mtCommissionCashMapper.confirmCommissionCash(requestParam.getMerchantId(), requestParam.getUuid(), requestParam.getOperator());
+       boolean flag = mtCommissionCashMapper.confirmCommissionCash(requestParam.getMerchantId(), requestParam.getUuid(), requestParam.getOperator());
+       if (flag) {
+           mtCommissionLogMapper.confirmCommissionLog(requestParam.getMerchantId(), requestParam.getUuid(), requestParam.getOperator());
+       }
     }
 
     /**
      * 结算确认
      *
-     * @param requestParam 确认参数
+     * @param requestParam 取消参数
      * @throws BusinessCheckException
      * @return
      */
     @Override
     @Transactional
-    @OperationServiceLog(description = "结算确认")
+    @OperationServiceLog(description = "取消结算")
     public void cancelCommissionCash(CommissionSettleConfirmRequest requestParam) throws BusinessCheckException {
         if (StringUtil.isEmpty(requestParam.getUuid())) {
             throw new BusinessCheckException("请求有误.");
         }
-        mtCommissionCashMapper.cancelCommissionCash(requestParam.getMerchantId(), requestParam.getUuid(), requestParam.getOperator());
+        boolean flag = mtCommissionCashMapper.cancelCommissionCash(requestParam.getMerchantId(), requestParam.getUuid(), requestParam.getOperator());
+        if (flag) {
+            mtCommissionLogMapper.cancelCommissionLog(requestParam.getMerchantId(), requestParam.getUuid(), requestParam.getOperator());
+        }
     }
 }

+ 4 - 0
fuint-application/src/main/java/com/fuint/common/service/impl/CommissionLogServiceImpl.java

@@ -93,6 +93,8 @@ public class CommissionLogServiceImpl extends ServiceImpl<MtCommissionLogMapper,
             List<MtStaff> staffList = staffService.queryStaffByParams(params);
             if (staffList != null && staffList.size() > 0) {
                 lambdaQueryWrapper.eq(MtCommissionLog::getStaffId, staffList.get(0).getId());
+            } else {
+                lambdaQueryWrapper.eq(MtCommissionLog::getStaffId, -1);
             }
         }
         String mobile = paginationRequest.getSearchParams().get("mobile") == null ? "" : paginationRequest.getSearchParams().get("mobile").toString();
@@ -100,6 +102,8 @@ public class CommissionLogServiceImpl extends ServiceImpl<MtCommissionLogMapper,
             MtStaff mtStaff = staffService.queryStaffByMobile(mobile);
             if (mtStaff != null) {
                 lambdaQueryWrapper.eq(MtCommissionLog::getStaffId, mtStaff.getId());
+            } else {
+                lambdaQueryWrapper.eq(MtCommissionLog::getStaffId, -1);
             }
         }
         String status = paginationRequest.getSearchParams().get("status") == null ? "" : paginationRequest.getSearchParams().get("status").toString();

+ 15 - 3
fuint-application/src/main/java/com/fuint/module/backendApi/controller/BackendCommissionCashController.java

@@ -65,10 +65,13 @@ public class BackendCommissionCashController extends BaseController {
         String token = request.getHeader("Access-Token");
         Integer page = request.getParameter("page") == null ? Constants.PAGE_NUMBER : Integer.parseInt(request.getParameter("page"));
         Integer pageSize = request.getParameter("pageSize") == null ? Constants.PAGE_SIZE : Integer.parseInt(request.getParameter("pageSize"));
-        String title = request.getParameter("title");
+        String realName = request.getParameter("realName");
+        String mobile = request.getParameter("mobile");
         String status = request.getParameter("status");
         String searchStoreId = request.getParameter("storeId");
         String uuid = request.getParameter("uuid");
+        String startTime = request.getParameter("startTime") == null ? "" : request.getParameter("startTime");
+        String endTime = request.getParameter("endTime") == null ? "" : request.getParameter("endTime");
 
         AccountInfo accountInfo = TokenUtil.getAccountInfoByToken(token);
         Integer storeId;
@@ -83,8 +86,11 @@ public class BackendCommissionCashController extends BaseController {
         paginationRequest.setPageSize(pageSize);
 
         Map<String, Object> params = new HashMap<>();
-        if (StringUtil.isNotEmpty(title)) {
-            params.put("title", title);
+        if (StringUtil.isNotEmpty(realName)) {
+            params.put("realName", realName);
+        }
+        if (StringUtil.isNotEmpty(mobile)) {
+            params.put("mobile", mobile);
         }
         if (StringUtil.isNotEmpty(status)) {
             params.put("status", status);
@@ -98,6 +104,12 @@ public class BackendCommissionCashController extends BaseController {
         if (StringUtil.isNotEmpty(uuid)) {
             params.put("uuid", uuid);
         }
+        if (StringUtil.isNotEmpty(startTime)) {
+            params.put("startTime", startTime);
+        }
+        if (StringUtil.isNotEmpty(endTime)) {
+            params.put("endTime", endTime);
+        }
         paginationRequest.setSearchParams(params);
         PaginationResponse<CommissionCashDto> paginationResponse = commissionCashService.queryCommissionCashByPagination(paginationRequest);
 

+ 6 - 1
fuint-repository/src/main/java/com/fuint/repository/mapper/MtCommissionLogMapper.java

@@ -2,6 +2,7 @@ package com.fuint.repository.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.fuint.repository.model.MtCommissionLog;
+import org.apache.ibatis.annotations.Param;
 
 /**
  *  佣金记录 Mapper 接口
@@ -10,5 +11,9 @@ import com.fuint.repository.model.MtCommissionLog;
  * CopyRight https://www.fuint.cn
  */
 public interface MtCommissionLogMapper extends BaseMapper<MtCommissionLog> {
-   // empty
+
+    Boolean confirmCommissionLog(@Param("merchantId") Integer merchantId, @Param("uuid") String uuid, @Param("operator") String operator);
+
+    Boolean cancelCommissionLog(@Param("merchantId") Integer merchantId, @Param("uuid") String uuid, @Param("operator") String operator);
+
 }

+ 13 - 0
fuint-repository/src/main/resources/mapper/MtCommissionLogMapper.xml

@@ -1,4 +1,17 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.fuint.repository.mapper.MtCommissionLogMapper">
+    <update id="confirmCommissionLog">
+        update mt_commission_log t set t.STATUS = 'B',t.OPERATOR = #{operator} where t.SETTLE_UUID = #{uuid}
+        <if test="merchantId != null and merchantId > 0">
+            AND t.MERCHANT_ID = #{merchantId}
+        </if>
+    </update>
+
+    <update id="cancelCommissionLog">
+        update mt_commission_log t set t.STATUS = 'A',t.OPERATOR = #{operator} where t.SETTLE_UUID = #{uuid}
+        <if test="merchantId != null and merchantId > 0">
+            AND t.MERCHANT_ID = #{merchantId}
+        </if>
+    </update>
 </mapper>

+ 1 - 1
fuint-repository/src/main/resources/mapper/MtUserMapper.xml

@@ -16,7 +16,7 @@
     </select>
 
     <select id="queryMemberByOpenId" resultType="com.fuint.repository.model.MtUser">
-        select * from mt_user t where t.OPEN_ID = #{openId} and t.STATUS = 'A'
+        select * from mt_user t where t.OPEN_ID = #{openId} and t.STATUS != 'D'
         <if test="merchantId != null and merchantId > 0">
             AND t.MERCHANT_ID = #{merchantId}
         </if>