Quellcode durchsuchen

财务汇总发放管理-月结

FengChaoYu vor 9 Monaten
Ursprung
Commit
e42a78fe41

+ 69 - 0
mall-server-api/src/main/java/com/gree/mall/manager/bean/settle/repair/DailyMonthTotalBean.java

@@ -0,0 +1,69 @@
+package com.gree.mall.manager.bean.settle.repair;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+@ApiModel
+@Data
+public class DailyMonthTotalBean {
+
+    @ApiModelProperty(value = "所属网点")
+    private String websitName;
+
+    @ApiModelProperty(value = "所属网点编号")
+    private String websitNumber;
+
+    @ApiModelProperty(value = "结算名称")
+    private String summaryName;
+
+    @ApiModelProperty(value = "结算单位")
+    private String summaryNumber;
+
+    @ApiModelProperty(value = "身份证")
+    private String idCard;
+
+    @ApiModelProperty(value = "手机号")
+    private String mobile;
+
+    @ApiModelProperty(value = "维修结算费用总额")
+    private BigDecimal repairTotalAmount;
+
+    @ApiModelProperty(value = "需扣回费用")
+    private BigDecimal reduceCost;
+
+    @ApiModelProperty(value = "增减费用")
+    private BigDecimal incrDecrCost;
+
+    @ApiModelProperty(value = "日结累计已发")
+    private BigDecimal issueCost;
+
+    @ApiModelProperty(value = "月度计税总额")
+    private BigDecimal incomeTaxCost;
+
+    @ApiModelProperty(value = "暂扣累计")
+    private BigDecimal withholdTotalCost;
+
+    @ApiModelProperty(value = "服务人员名称")
+    private String serviceName;
+
+    @ApiModelProperty(value = "服务人员编号")
+    private String serviceNumber;
+
+    @ApiModelProperty(value = "工伤累计")
+    private BigDecimal empInsuranceCostC;
+
+    @ApiModelProperty(value = "残保累计")
+    private BigDecimal residualInsuranceCostC;
+
+    @ApiModelProperty(value = "商户id")
+    private String companyWechatId;
+
+    @ApiModelProperty(value = "所属商户")
+    private String companyWechatName;
+
+    @ApiModelProperty(value = "日结累计单数")
+    private Integer repairCountC;
+}

+ 82 - 0
mall-server-api/src/main/java/com/gree/mall/manager/bean/settle/repair/DailyNotMonthSummaryCountBean.java

@@ -0,0 +1,82 @@
+package com.gree.mall.manager.bean.settle.repair;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+@ApiModel
+@Data
+public class DailyNotMonthSummaryCountBean {
+
+    @ApiModelProperty(value = "所属商户")
+    private String companyWechatName;
+
+    @ApiModelProperty(value = "结算人数")
+    private Integer summaryPersonCount;
+
+    @ApiModelProperty(value = "结算工单数量")
+    private Integer summaryOrderCount;
+
+    @ApiModelProperty(value = "结算金额")
+    private BigDecimal summaryCost;
+
+    @ApiModelProperty(value = "汇总批次号")
+    private String summaryBatchNo;
+
+    @ApiModelProperty(value = "汇总批月份")
+    private String summaryMonth;
+
+    @ApiModelProperty(value = "发放状态")
+    private Integer issueStatus;
+
+    @ApiModelProperty(value = "汇总操作人")
+    private String summaryBy;
+
+    @ApiModelProperty(value = "汇总时间")
+    private Date summaryTime;
+
+    @ApiModelProperty(value = "发放操作人")
+    private String issueBy;
+
+    @ApiModelProperty(value = "发放时间")
+    private String issueTime;
+
+    @ApiModelProperty(value = "结算网点名称")
+    private String summaryName;
+
+    @ApiModelProperty(value = "结算网点编号")
+    private String summaryNumber;
+
+    @ApiModelProperty(value = "工伤,残保费用")
+    private BigDecimal empCost;
+
+    @ApiModelProperty(value = "暂扣款")
+    private BigDecimal withholdCost;
+
+    @ApiModelProperty(value = "应发总额")
+    private BigDecimal issueCostC;
+
+    @ApiModelProperty(value = "减免费用")
+    private BigDecimal decrCost;
+
+    @ApiModelProperty(value = "需扣回费用")
+    private BigDecimal reduceCost;
+
+    @ApiModelProperty(value = "个税")
+    private BigDecimal incomeCost;
+
+    @ApiModelProperty(value = "应发")
+    private BigDecimal issueCost;
+
+    @ApiModelProperty(value = "网点名称")
+    private String websitName;
+
+    @ApiModelProperty(value = "网点编号")
+    private String websitNumber;
+
+    @ApiModelProperty(value = "分组包含状态")
+    private String groupStatus;
+}

+ 46 - 0
mall-server-api/src/main/java/com/gree/mall/manager/commonmapper/DailyMapper.java

@@ -90,4 +90,50 @@ public interface DailyMapper {
                                                        @Param("issueSalaryId") Integer issueSalaryId,
                                                        @Param("companyWechatIds") List<String> companyWechatIds,
                                                        @Param("adminWebsitIds") List<String> adminWebsitIds);
+
+    @SqlParser(filter = true)
+    IPage<DailyNotMonthSummaryCountBean> cwSummaryMonthList(
+            IPage page,
+            @Param("summaryBatchNo") String summaryBatchNo,
+            @Param("summaryStartTime") String summaryStartTime,
+            @Param("summaryEndTime") String summaryEndTime,
+            @Param("issueStartTime") String issueStartTime,
+            @Param("issueEndTime") String issueEndTime,
+            @Param("status") Integer status,
+            @Param("companyWechatIds") List<String> companyWechatIds,
+            @Param("adminWebsitIds") List<String> adminWebsitIds
+    );
+
+    @SqlParser(filter = true)
+    List<DailyNotMonthSummaryCountBean> monthlySummaryList(
+            @Param("summaryBatchNo") String summaryBatchNo,
+            @Param("companyWechatIds") List<String> companyWechatIds,
+            @Param("adminWebsitIds") List<String> adminWebsitIds
+    );
+
+    @SqlParser(filter = true)
+    List<DailyNotMonthSummaryCountBean> monthlyWebsiteList(
+            @Param("summaryBatchNo") String summaryBatchNo,
+            @Param("companyWechatIds") List<String> companyWechatIds,
+            @Param("adminWebsitIds") List<String> adminWebsitIds
+    );
+
+    @SqlParser(filter = true)
+    List<DailyWorkerIssueSalaryBean> monthlyDetailList(
+            IPage page,
+            @Param("summaryMonthBatchNo") String summaryMonthBatchNo,
+            @Param("summaryNumber") String summaryNumber,
+            @Param("serviceNumber") String serviceNumber,
+            @Param("companyWechatIds") List<String> companyWechatIds,
+            @Param("adminWebsitIds") List<String> adminWebsitIds
+    );
+
+    @SqlParser(filter = true)
+    List<DailyMonthTotalBean> queryMonthTotalCost(@Param("companyWechatId") String companyWechatId);
+
+    /**
+     * 查询月度汇总数据
+     */
+    @SqlParser(filter = true)
+    DailyNotMonthSummaryCountBean queryNotMonthSummaryData(@Param("companyWechatId") String companyWechatId);
 }

+ 184 - 0
mall-server-api/src/main/java/com/gree/mall/manager/controller/settle/repair/DailyMonthSummaryController.java

@@ -0,0 +1,184 @@
+package com.gree.mall.manager.controller.settle.repair;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.gree.mall.manager.bean.ExcelData;
+import com.gree.mall.manager.bean.settle.repair.DailyNotMonthSummaryCountBean;
+import com.gree.mall.manager.bean.settle.repair.DailyWorkerIssueSalaryBean;
+import com.gree.mall.manager.helper.ResponseHelper;
+import com.gree.mall.manager.logic.settle.repair.DailyImportSummaryLogic;
+import com.gree.mall.manager.logic.settle.repair.DailyMonthSummaryLogic;
+import com.gree.mall.manager.plus.entity.SettleDailyIssueSummaryMonthRecord;
+import com.gree.mall.manager.plus.entity.SettleDailyMonthlySummary;
+import com.gree.mall.manager.utils.excel.ExcelUtils;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.util.List;
+
+@Slf4j
+@RestController
+@Api(value = "月结算API", tags = {"月结算API"})
+@RequestMapping(value = "/daily/summary", produces = "application/json; charset=utf-8")
+@RequiredArgsConstructor
+public class DailyMonthSummaryController {
+
+    private final DailyMonthSummaryLogic dailyMonthSummaryLogic;
+    private final DailyImportSummaryLogic dailyImportSummaryLogic;
+
+
+    @GetMapping("/month/salary/export")
+    @ApiOperation("月度师傅汇总-导出")
+    public void monthSalaryExport(
+            @ApiParam(required = true, value = "汇总批次号") @RequestParam String summaryBatchNo,
+            @ApiParam(required = true, value = "结算单位") @RequestParam String summaryNumber,
+            @ApiParam(value = "状态 1.待发放 2.已发放3.银行受理中") @RequestParam(required = false) Integer status,
+            @ApiParam(value = "所属网点") @RequestParam(required = false) String websiteNumber,
+            @ApiParam(value = "所属网点名称") @RequestParam(required = false) String websiteName,
+            @ApiParam(value = "服务人员") @RequestParam(required = false) String serviceName,
+            @ApiParam(value = "身份证号码") @RequestParam(required = false) String idCard,
+            @ApiParam(value = "手机号") @RequestParam(required = false) String mobile,
+            HttpServletRequest request,
+            HttpServletResponse response
+    ) throws Exception {
+        IPage<SettleDailyIssueSummaryMonthRecord> page = dailyImportSummaryLogic.workerSummaryMonthList(summaryBatchNo, summaryNumber,
+                status,websiteNumber,serviceName,idCard,mobile,websiteName,1, -1);
+        ExcelData excelData = dailyMonthSummaryLogic.monthSalaryExport(page.getRecords());
+        ExcelUtils.exportExcel(request, response, "师傅工资月度汇总.csv", excelData);
+    }
+
+    @ApiOperation("月度师傅汇总-导入")
+    @PostMapping("/month/salary/import")
+    public ResponseHelper monthSalaryImport(
+            @ApiParam(required = true, value = "附件") @RequestPart("file") MultipartFile file
+    ) throws Exception {
+        dailyMonthSummaryLogic.monthSalaryImport(file);
+        return ResponseHelper.success();
+    }
+
+
+    @GetMapping("/worker/month/list")
+    @ApiOperation(value = "师傅汇总-月结")
+    public ResponseHelper<IPage<SettleDailyIssueSummaryMonthRecord>> workerSummaryMonthList(
+            @ApiParam(required = true, value = "页号") @RequestParam Integer pageNo,
+            @ApiParam(required = true, value = "页大小") @RequestParam Integer pageSize,
+            @ApiParam(required = true, value = "汇总批次号") @RequestParam String summaryBatchNo,
+            @ApiParam(required = true, value = "结算单位") @RequestParam String summaryNumber,
+            @ApiParam(value = "状态 1.待发放 2.已发放3.银行受理中") @RequestParam(required = false) Integer status,
+            @ApiParam(value = "所属网点") @RequestParam(required = false) String websiteNumber,
+            @ApiParam(value = "所属网点名称") @RequestParam(required = false) String websiteName,
+            @ApiParam(value = "服务人员") @RequestParam(required = false) String serviceName,
+            @ApiParam(value = "身份证号码") @RequestParam(required = false) String idCard,
+            @ApiParam(value = "手机号") @RequestParam(required = false) String mobile
+
+    ) {
+        IPage<SettleDailyIssueSummaryMonthRecord> page = dailyImportSummaryLogic.workerSummaryMonthList(summaryBatchNo, summaryNumber,
+                status,websiteNumber,serviceName,idCard,mobile,websiteName,pageNo, pageSize);
+        return ResponseHelper.success(page);
+    }
+
+
+    @GetMapping("/month/list")
+    @ApiOperation(value = "月度汇总-列表")
+    public ResponseHelper<IPage<DailyNotMonthSummaryCountBean>> monthlyList(
+            @ApiParam(required = true, value = "页号") @RequestParam Integer pageNo,
+            @ApiParam(required = true, value = "页大小") @RequestParam Integer pageSize,
+            @ApiParam(value = "汇总批次号") @RequestParam(required = false) String summaryBatchNo,
+            @ApiParam(value = "汇总时间段起始") @RequestParam(required = false) String summaryStartTime,
+            @ApiParam(value = "汇总时间段结束") @RequestParam(required = false) String summaryEndTime,
+            @ApiParam(value = "发放时间段起始") @RequestParam(required = false) String issueStartTime,
+            @ApiParam(value = "发放时间段结束") @RequestParam(required = false) String issueEndTime,
+            @ApiParam(value = "状态 1.未发放 2.已发放") @RequestParam(required = false) Integer status
+
+    ) {
+        IPage<DailyNotMonthSummaryCountBean> page = dailyImportSummaryLogic.cwSummaryMonthList(summaryBatchNo, summaryStartTime,
+                summaryEndTime, issueStartTime, issueEndTime, status,pageNo, pageSize);
+        return ResponseHelper.success(page);
+    }
+
+
+    @GetMapping("/month/website/list")
+    @ApiOperation(value = "月度汇总结算网点-列表")
+    public ResponseHelper<List<DailyNotMonthSummaryCountBean>> monthlyWebsiteList(
+            @ApiParam(required = true, value = "汇总批次号") @RequestParam String summaryBatchNo
+    ) {
+        List<DailyNotMonthSummaryCountBean> page = dailyMonthSummaryLogic.monthlySummaryList(summaryBatchNo);
+        return ResponseHelper.success(page);
+    }
+
+    @GetMapping("/month/detail/list")
+    @ApiOperation(value = "月度结算师傅详情-列表")
+    public ResponseHelper<List<DailyWorkerIssueSalaryBean>> monthlyDetailList(
+            @ApiParam(required = true, value = "页号") @RequestParam Integer pageNo,
+            @ApiParam(required = true, value = "页大小") @RequestParam Integer pageSize,
+            @ApiParam(required = true, value = "月度汇总批次号") @RequestParam String summaryMonthBatchNo,
+            @ApiParam(required = true, value = "结算网点") @RequestParam String summaryNumber,
+            @ApiParam(required = true, value = "师傅编号") @RequestParam String serviceNumber
+    ) {
+        List<DailyWorkerIssueSalaryBean> page = dailyMonthSummaryLogic.monthlyDetailList(summaryMonthBatchNo,summaryNumber,
+                serviceNumber,pageNo,pageSize);
+        return ResponseHelper.success(page);
+    }
+
+
+    @PostMapping("/month/do")
+    @ApiOperation(value = "月度汇总")
+    public ResponseHelper<IPage<SettleDailyMonthlySummary>> monthlyDo(
+
+    ) {
+        dailyMonthSummaryLogic.monthlyDo();
+        return ResponseHelper.success();
+    }
+
+    @PostMapping("/month/reDo")
+    @ApiOperation(value = "重新汇总")
+    public ResponseHelper<IPage<SettleDailyMonthlySummary>> monthlyDo(
+            @ApiParam(required = true, value = "月度汇总批次号") @RequestParam String summaryMonthBatchNo
+    ) {
+        dailyMonthSummaryLogic.monthlyReDo(summaryMonthBatchNo);
+        return ResponseHelper.success();
+    }
+
+
+    @ApiOperation("月度计算费用")
+    @PostMapping("/month/salary/calculate")
+    public ResponseHelper monthSalaryCalculate(
+            @ApiParam(required = true, value = "月度汇总批次号") @RequestParam String summaryMonthBatchNo,
+            @ApiParam(required = true, value = "结算单位") @RequestParam String summaryNumber
+    ) {
+        dailyMonthSummaryLogic.monthSalaryCalculate(summaryMonthBatchNo, summaryNumber);
+        return ResponseHelper.success();
+    }
+
+
+    @ApiOperation("月度工资-发放")
+    @PostMapping("/month/salary/issue")
+    public ResponseHelper monthSalaryIssue(
+            @ApiParam(required = true, value = "月度汇总批次号") @RequestParam String summaryMonthBatchNo,
+            @ApiParam(value = "结算单位") @RequestParam(required = false) List<String> summaryNumberList
+    ) {
+        dailyMonthSummaryLogic.monthSalaryIssue(summaryMonthBatchNo,summaryNumberList);
+        return ResponseHelper.success();
+    }
+
+    @GetMapping("/month/detail/export")
+    @ApiOperation(value = "月度结算师傅详情-导出")
+    public void monthlyDetailExport(
+            @ApiParam(required = true, value = "月度汇总批次号") @RequestParam String summaryMonthBatchNo,
+            @ApiParam(required = true, value = "结算网点") @RequestParam String summaryNumber,
+            @ApiParam(required = true, value = "师傅编号") @RequestParam String serviceNumber,
+            HttpServletRequest request,
+            HttpServletResponse response
+    ) throws Exception {
+        List<DailyWorkerIssueSalaryBean> page = dailyMonthSummaryLogic.monthlyDetailList(summaryMonthBatchNo,summaryNumber,
+                serviceNumber,1,-1);
+        ExcelData excelData = dailyImportSummaryLogic.workerDetailExport(page);
+        ExcelUtils.exportExcel(request, response, "月结师傅汇总详情.xlsx", excelData);
+    }
+}

+ 106 - 4
mall-server-api/src/main/java/com/gree/mall/manager/logic/settle/repair/DailyImportSummaryLogic.java

@@ -35,10 +35,7 @@ import org.springframework.util.CollectionUtils;
 import javax.servlet.http.HttpServletRequest;
 import java.math.BigDecimal;
 import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Date;
-import java.util.List;
+import java.util.*;
 import java.util.stream.Collectors;
 
 @Service
@@ -60,6 +57,7 @@ public class DailyImportSummaryLogic {
     private final SettleDailyIncrDecrCostService settleDailyIncrDecrCostService;
     private final RedisUtil redisUtil;
     private final DailyTransferLogic dailyTransferLogic;
+    private final SettleDailyIssueSummaryMonthRecordService settleDailyIssueSummaryMonthRecordService;
 
 
     public IPage<DailyImportSummaryVO> page(ZfireParamBean zfireParamBean) {
@@ -1338,4 +1336,108 @@ public class DailyImportSummaryLogic {
         AdminUserCom adminUser = commonLogic.getAdminUser();
         return dailyMapper.workerDetailList(new Page(pageNum, pageSize), issueSalaryId, adminUser.getCompanyWechatIds(), adminUser.getAdminWebsitIds());
     }
+
+    public IPage<SettleDailyIssueSummaryMonthRecord> workerSummaryMonthList(String summaryBatchNo, String summaryNumber,
+                                                                            Integer status, String websiteNumber, String serviceName, String idCard, String mobile, String websiteName, Integer pageNo, Integer pageSize) {
+        AdminUserCom adminUser = commonLogic.getAdminUser();
+
+        IPage<SettleDailyIssueSummaryMonthRecord> page = settleDailyIssueSummaryMonthRecordService.lambdaQuery()
+                .eq(CollectionUtil.isNotEmpty(adminUser.getCompanyWechatIds()), SettleDailyIssueSummaryMonthRecord::getCompanyWechatId, adminUser.getCompanyWechatIds())
+                .eq(CollectionUtil.isNotEmpty(adminUser.getAdminWebsitIds()), SettleDailyIssueSummaryMonthRecord::getWebsitNumber, adminUser.getAdminWebsitIds())
+                .eq(StringUtils.isNotEmpty(summaryBatchNo), SettleDailyIssueSummaryMonthRecord::getSummaryBatchNo, summaryBatchNo)
+                .eq(StringUtils.isNotEmpty(summaryNumber), SettleDailyIssueSummaryMonthRecord::getSummaryNumber, summaryNumber)
+                .eq(Objects.isNull(status), SettleDailyIssueSummaryMonthRecord::getStatus, status)
+                .eq(StringUtils.isNotEmpty(websiteName), SettleDailyIssueSummaryMonthRecord::getWebsitName, websiteName)
+                .eq(StringUtils.isNotEmpty(serviceName), SettleDailyIssueSummaryMonthRecord::getServiceName, serviceName)
+                .eq(StringUtils.isNotEmpty(idCard), SettleDailyIssueSummaryMonthRecord::getIdCard, idCard)
+                .eq(StringUtils.isNotEmpty(mobile), SettleDailyIssueSummaryMonthRecord::getMobile, mobile)
+                .orderByDesc(SettleDailyIssueSummaryMonthRecord::getCreateTime, SettleDailyIssueSummaryMonthRecord::getServiceName)
+                .page(new Page<>(pageNo, pageSize));
+        return page;
+    }
+
+    public IPage<DailyNotMonthSummaryCountBean> cwSummaryMonthList(String summaryBatchNo, String summaryStartTime, String summaryEndTime,
+                                                                   String issueStartTime, String issueEndTime, Integer status, Integer pageNum, Integer pageSize) {
+        AdminUserCom adminUser = commonLogic.getAdminUser();
+        IPage<DailyNotMonthSummaryCountBean> page = dailyMapper.cwSummaryMonthList(new Page(pageNum, pageSize), summaryBatchNo, summaryStartTime, summaryEndTime, issueStartTime, issueEndTime, status,
+                adminUser.getCompanyWechatIds(), adminUser.getAdminWebsitIds());
+        return page;
+    }
+
+    public ExcelData workerDetailExport(List<DailyWorkerIssueSalaryBean> list){
+        String[] titles = new String[]{"序号", "状态","发放月份","发放时间","银行卡账号","户名","开户行","派工序号", "自编号码", "工单状态", "新结算单位号", "旧结算单位号", "结算单位名", "维修类型", "内外机",
+                "机器条码", "外机型", "外机型描述", "内机条码", "内机型", "内机型描述", "用户姓名", "区号", "移动电话", "电话号码",
+                "省份", "市县", "区县", "用户地址", "GPS定位", "邮政编码", "销售单位号", "销售单位", "发票编号", "购买日期", "安装日期",
+                "报修日期", "修复日期", "维修工ID", "维修工姓名", "维修工电话", "维修费用", "交通费", "住宿费用", "吊装费用", "其他费用", "总费用",
+                "结算单批号", "安装网点号", "安装网点名", "新维修单位号", "旧维修单位号", "维修单位名", "故障现象", "故障分析", "维修内容",
+                "备注", "转结算时间"
+        };
+        List<List<Object>> rows = new ArrayList<>();
+        for(DailyWorkerIssueSalaryBean bean : list){
+            List<Object> row = new ArrayList<>();
+            row.add(list.indexOf(bean) +1);
+            row.add(CommonUtils.getIssueStatus(bean.getIssueStatus()));
+            row.add(bean.getMonth());
+            row.add(bean.getIssueTime());
+            row.add(bean.getBankAccount());
+            row.add(bean.getBankAccountName());
+            row.add(bean.getDepositBank());
+            row.add(bean.getDispatchOrderNo());
+            row.add(bean.getSelfNo());
+            row.add(bean.getOrderStatus());
+            row.add(bean.getSummaryNumber());
+            row.add(bean.getOldSummaryNumber());
+            row.add(bean.getSummaryName());
+            row.add(bean.getRepairType());
+            row.add(bean.getInOutMachine());
+            row.add(bean.getMachineCode());
+            row.add(bean.getOutMachineType());
+            row.add(bean.getOutMachineDescribe());
+            row.add(bean.getInMachineCode());
+            row.add(bean.getInMachineType());
+            row.add(bean.getInMachineDescribe());
+            row.add(bean.getUserName());
+            row.add(bean.getAreaCode());
+            row.add(bean.getMobile());
+            row.add(bean.getTel());
+            row.add(bean.getProvince());
+            row.add(bean.getCity());
+            row.add(bean.getCounty());
+            row.add(bean.getUserAddr());
+            row.add(bean.getGpsAddr());
+            row.add(bean.getPostalCode());
+            row.add(bean.getSaleDeptNo());
+            row.add(bean.getSaleDeptName());
+            row.add(bean.getInvoiceCode());
+            row.add(DateUtils.formatDate(bean.getBuyDate()));
+            row.add(DateUtils.formatDate(bean.getInstallDate()));
+            row.add(DateUtils.formatDate(bean.getRepairDate()));
+            row.add(DateUtils.formatDate(bean.getReportDate()));
+            row.add(bean.getRepairWorkerId());
+            row.add(bean.getRepairWorkerName());
+            row.add(bean.getRepairWorkerMobile());
+            row.add(bean.getRepairFee());
+            row.add(bean.getTrafficFee());
+            row.add(bean.getAccommodationFee());
+            row.add(bean.getLiftingFee());
+            row.add(bean.getOtherFee());
+            row.add(bean.getTotalFee());
+            row.add(bean.getSettlementBatchNo());
+            row.add(bean.getInstallWebsitNo());
+            row.add(bean.getInstallWebsitName());
+            row.add(bean.getRepairUnit());
+            row.add(bean.getOldRepairUnit());
+            row.add(bean.getRepairName());
+            row.add(bean.getFaultPhenomenon());
+            row.add(bean.getFaultAnalysis());
+            row.add(bean.getRepairDetail());
+            row.add(bean.getRemark());
+            row.add(DateUtils.formatDate(bean.getSettlementTime()));
+            rows.add(row);
+        }
+        ExcelData excelData = new ExcelData();
+        excelData.setRows(rows);
+        excelData.setTitles(Arrays.asList(titles));
+        return excelData;
+    }
 }

+ 398 - 0
mall-server-api/src/main/java/com/gree/mall/manager/logic/settle/repair/DailyMonthSummaryLogic.java

@@ -0,0 +1,398 @@
+package com.gree.mall.manager.logic.settle.repair;
+
+import cn.hutool.core.collection.CollectionUtil;
+import cn.hutool.core.date.DateUtil;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.gree.mall.manager.bean.ExcelData;
+import com.gree.mall.manager.bean.admin.AdminUserCom;
+import com.gree.mall.manager.bean.settle.repair.DailyMonthTotalBean;
+import com.gree.mall.manager.bean.settle.repair.DailyNotMonthSummaryCountBean;
+import com.gree.mall.manager.bean.settle.repair.DailyWorkerIssueSalaryBean;
+import com.gree.mall.manager.commonmapper.DailyMapper;
+import com.gree.mall.manager.constant.DailyConstant;
+import com.gree.mall.manager.exception.RemoteServiceException;
+import com.gree.mall.manager.logic.common.CommonLogic;
+import com.gree.mall.manager.plus.entity.SettleDailyIssueSummaryMonthRecord;
+import com.gree.mall.manager.plus.entity.SettleDailyIssueSummaryRecord;
+import com.gree.mall.manager.plus.entity.SettleDailyMonthlySummary;
+import com.gree.mall.manager.plus.service.SettleDailyIssueSummaryMonthRecordService;
+import com.gree.mall.manager.plus.service.SettleDailyIssueSummaryRecordService;
+import com.gree.mall.manager.plus.service.SettleDailyMonthlySummaryService;
+import com.gree.mall.manager.utils.CommonUtils;
+import com.gree.mall.manager.utils.excel.ExcelUtils;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.io.IOException;
+import java.math.BigDecimal;
+import java.util.*;
+
+@Service
+@Slf4j
+@RequiredArgsConstructor
+public class DailyMonthSummaryLogic {
+
+    private final CommonLogic commonLogic;
+    private final DailyMapper dailyMapper;
+    private final SettleDailyIssueSummaryMonthRecordService issueSummaryMonthRecordService;
+    private final SettleDailyMonthlySummaryService dailyMonthlySummaryService;
+    private final SettleDailyIssueSummaryRecordService dailyIssueSummaryRecordService;
+    private final DailyTransferLogic dailyTransferLogic;
+    private final SettleDailyIssueSummaryMonthRecordService dailyIssueSummaryMonthRecordService;
+
+    /**
+     * 导出师傅月结数据汇总
+     *
+     * @param list
+     * @return
+     */
+    public ExcelData monthSalaryExport(List<SettleDailyIssueSummaryMonthRecord> list) {
+        String[] titles = new String[]{"工资条编号", "汇总月份", "状态", "所属网点", "所属网点编号", "服务人员", "服务人员编号", "身份证", "手机号",
+                "维修结算费用总额", "需扣回费用", "增减费用", "月度计税费用总额",
+                "工伤保险", "残保金", "服务费用", "个税金额", "应发工资总额", "日结累计已发", "月度实发工资",
+                "工伤保险已扣", "残保金已扣", "暂扣费用累计", "备注"};
+        List<List<Object>> rows = new ArrayList<>();
+        for (SettleDailyIssueSummaryMonthRecord bean : list) {
+            List<Object> row = new ArrayList<>();
+            row.add(bean.getSalaryNo());
+            row.add(bean.getMonth());
+            row.add(CommonUtils.getIssueStatus(bean.getStatus()));
+            row.add(bean.getWebsitName());
+            row.add(bean.getWebsitNumber());
+            row.add(bean.getServiceName());
+            row.add(bean.getServiceNumber());
+            row.add(bean.getIdCard());
+            row.add(bean.getMobile());
+            row.add(bean.getRepairTotalAmount());
+            row.add(bean.getShouldReduceCost());
+            row.add(bean.getIncrDecrCost());
+            row.add(bean.getTaxToatalCost());
+            row.add(bean.getShouldEmpInsuranceCost());
+            row.add(bean.getShouldResidualInsuranceCost());
+            row.add(bean.getServiceCost());
+            row.add(bean.getIncomeCost());
+            row.add(bean.getIssueCost());
+            row.add(bean.getDailySendCost());
+            row.add(bean.getMonthSendCost());
+            row.add(bean.getEmpInsuranceCost());
+            row.add(bean.getResidualInsuranceCost());
+            row.add(bean.getWithholdTotalCost());
+            row.add(bean.getRemark());
+            // row.add(DateUtils.formatDate(bean.getCreateTime()));
+            rows.add(row);
+        }
+        ExcelData excelData = new ExcelData();
+        excelData.setRows(rows);
+        excelData.setTitles(Arrays.asList(titles));
+        return excelData;
+    }
+
+    @Transactional
+    public void monthSalaryImport(MultipartFile file) throws IOException {
+        List<Map<String, Object>> maps = ExcelUtils.importExcelByTitle(file.getInputStream(), 0);
+        AdminUserCom adminUser = commonLogic.getAdminUser();
+
+        if (adminUser.getType() == 2) {
+            throw new RemoteServiceException("平台账号禁止操作");
+        }
+
+        String opName = adminUser.getNickName();
+
+        List<SettleDailyIssueSummaryMonthRecord> issueSummaryMonthRecords = new ArrayList<>();
+        for (Map<String, Object> map : maps) {
+            SettleDailyIssueSummaryMonthRecord tmp = issueSummaryMonthRecordService
+                    .lambdaQuery()
+                    .eq(SettleDailyIssueSummaryMonthRecord::getCompanyWechatId, adminUser.getAdminCompanyWechat().getCompanyWechatId())
+                    .eq(SettleDailyIssueSummaryMonthRecord::getSalaryNo, map.get("工资条编号").toString())
+                    .one();
+
+            if (null == tmp) {
+                throw new RemoteServiceException(map.get("工资条编号").toString() + "工资条编号不存在");
+            }
+
+            if (!DailyConstant.ISSUE_STATUS_NOT.equals(tmp.getStatus())) {
+                throw new RemoteServiceException(map.get("工资条编号").toString() + "状态为已发放");
+            }
+
+            if (tmp.getStatus() != 1) {
+                throw new RemoteServiceException("存在已发放数据");
+            }
+
+            if (map.get("工伤保险") != null) {
+                tmp.setShouldEmpInsuranceCost(new BigDecimal(map.get("工伤保险").toString()));
+            }
+            if (map.get("残保金") != null) {
+                tmp.setShouldResidualInsuranceCost(new BigDecimal(map.get("残保金").toString()));
+            }
+            if (map.get("服务费用") != null) {
+                tmp.setServiceCost(new BigDecimal(map.get("服务费用").toString()));
+            }
+
+            if (map.get("个税金额") != null) {
+                tmp.setIncomeCost(new BigDecimal(map.get("个税金额").toString()));
+            }
+
+            if (map.get("应发工资总额") != null) {
+                tmp.setIssueCost(new BigDecimal(map.get("应发工资总额").toString()));
+            }
+
+            tmp.setUpdateBy(opName);
+            tmp.setUpdateTime(new Date());
+            tmp.setCompanyWechatId(adminUser.getAdminCompanyWechat().getCompanyWechatId());
+            tmp.setCompanyWechatName(adminUser.getAdminCompanyWechat().getCompanyName());
+            issueSummaryMonthRecords.add(tmp);
+        }
+        issueSummaryMonthRecordService.updateBatchById(issueSummaryMonthRecords);
+    }
+
+    @Transactional
+    public void monthSalaryCalculate(String summaryMonthBatchNo, String summaryNumber) {
+        AdminUserCom adminUser = commonLogic.getAdminUser();
+
+        if (adminUser.getType() == 2) {
+            throw new RemoteServiceException("平台账号禁止操作");
+        }
+
+        //月度费用计算
+        List<SettleDailyIssueSummaryMonthRecord> monthRecords = issueSummaryMonthRecordService.lambdaQuery()
+                .eq(SettleDailyIssueSummaryMonthRecord::getCompanyWechatId, adminUser.getAdminCompanyWechat().getCompanyWechatId())
+                .eq(SettleDailyIssueSummaryMonthRecord::getSummaryBatchNo, summaryMonthBatchNo)
+                .eq(SettleDailyIssueSummaryMonthRecord::getSummaryNumber, summaryNumber)
+                .eq(SettleDailyIssueSummaryMonthRecord::getStatus, DailyConstant.ISSUE_STATUS_NOT).list();
+        if (monthRecords.size() == 0) {
+            throw new RemoteServiceException("没有可计算的数据");
+        }
+
+        for (SettleDailyIssueSummaryMonthRecord record : monthRecords) {
+            //月度实发工资
+            if (record.getIssueCost() == null) {
+                throw new RemoteServiceException("请先计算好月度应发工资并上传。");
+            }
+            BigDecimal actual = record.getIssueCost().subtract(record.getDailySendCost());
+            record.setMonthSendCost(actual);
+            record.setIsMonthCalculate(true);
+            record.setUpdateBy(adminUser.getNickName());
+            record.setUpdateTime(new Date());
+            record.setCompanyWechatId(adminUser.getAdminCompanyWechat().getCompanyWechatId());
+            record.setCompanyWechatName(adminUser.getAdminCompanyWechat().getCompanyName());
+        }
+        issueSummaryMonthRecordService.saveOrUpdateBatch(monthRecords, 500);
+    }
+
+    public List<DailyNotMonthSummaryCountBean> monthlySummaryList(String summaryBatchNo) {
+        AdminUserCom adminUser = commonLogic.getAdminUser();
+        List<DailyNotMonthSummaryCountBean> list = dailyMapper.monthlySummaryList(summaryBatchNo, adminUser.getCompanyWechatIds(), adminUser.getAdminWebsitIds());
+        return list;
+    }
+
+    public List<DailyNotMonthSummaryCountBean> monthlyWebsiteList(String summaryBatchNo) {
+        AdminUserCom adminUser = commonLogic.getAdminUser();
+        return dailyMapper.monthlyWebsiteList(summaryBatchNo, adminUser.getCompanyWechatIds(), adminUser.getAdminWebsitIds());
+    }
+
+    public List<DailyWorkerIssueSalaryBean> monthlyDetailList(String summaryMonthBatchNo, String summaryNumber,
+                                                              String serviceNumber, Integer pageNo, Integer pageSize) {
+        AdminUserCom adminUser = commonLogic.getAdminUser();
+        return dailyMapper.monthlyDetailList(new Page<>(pageNo, pageSize), summaryMonthBatchNo, summaryNumber, serviceNumber, adminUser.getCompanyWechatIds(), adminUser.getAdminWebsitIds());
+    }
+
+    @Transactional
+    public void monthlyReDo(String summaryMonthBatchNo) {
+        AdminUserCom adminUser = commonLogic.getAdminUser();
+
+        if (adminUser.getType() == 2) {
+            throw new RemoteServiceException("平台账号禁止操作");
+        }
+        String opName = adminUser.getNickName();
+        //拿到当前月份
+        String nowMonth = DateUtil.format(new Date(), "yyyyMM");
+
+        Integer count = dailyMonthlySummaryService.lambdaQuery()
+                .eq(SettleDailyMonthlySummary::getCompanyWechatId, adminUser.getAdminCompanyWechat().getCompanyWechatId())
+                .eq(SettleDailyMonthlySummary::getSummaryMonthBatchNo, summaryMonthBatchNo)
+                .ne(SettleDailyMonthlySummary::getIssueStatus, DailyConstant.SUMMARY_STATUS_NOT)
+                .count();
+        if (count > 0) {
+            throw new RemoteServiceException("已发放,无法重新汇总");
+        }
+        //删除所有数据
+        issueSummaryMonthRecordService.lambdaUpdate()
+                .eq(SettleDailyIssueSummaryMonthRecord::getCompanyWechatId, adminUser.getAdminCompanyWechat().getCompanyWechatId())
+                .eq(SettleDailyIssueSummaryMonthRecord::getSummaryBatchNo, summaryMonthBatchNo)
+                .remove();
+
+        List<DailyMonthTotalBean> totalBeans = dailyMapper.queryMonthTotalCost(adminUser.getAdminCompanyWechat().getCompanyWechatId());
+        //生成每人月度发放数据
+        //把所有发放成功数据汇总到当月
+        List<SettleDailyIssueSummaryMonthRecord> monthIssues = setMonthIssue(totalBeans, summaryMonthBatchNo, opName, nowMonth);
+
+        issueSummaryMonthRecordService.saveBatch(monthIssues, 500);
+
+        dailyIssueSummaryRecordService.lambdaUpdate()
+                .set(SettleDailyIssueSummaryRecord::getIsMonthSummary, true)
+                .set(SettleDailyIssueSummaryRecord::getSummaryMonthBatchNo, summaryMonthBatchNo)
+                .set(SettleDailyIssueSummaryRecord::getUpdateBy, opName)
+                .set(SettleDailyIssueSummaryRecord::getUpdateTime, new Date())
+                .set(SettleDailyIssueSummaryRecord::getMonth, nowMonth)
+                .eq(SettleDailyIssueSummaryRecord::getCompanyWechatId, adminUser.getAdminCompanyWechat().getCompanyWechatId())
+                .eq(SettleDailyIssueSummaryRecord::getIsMonthSummary, false).update();
+
+        DailyNotMonthSummaryCountBean bean = dailyMapper.queryNotMonthSummaryData(adminUser.getAdminCompanyWechat().getCompanyWechatId());
+        //将数据插入汇总表
+        SettleDailyMonthlySummary monthlySummary = dailyMonthlySummaryService.lambdaQuery()
+                .eq(SettleDailyMonthlySummary::getCompanyWechatId, adminUser.getAdminCompanyWechat().getCompanyWechatId())
+                .eq(SettleDailyMonthlySummary::getSummaryMonthBatchNo, summaryMonthBatchNo)
+                .one();
+        monthlySummary.setCompanyWechatId(adminUser.getAdminCompanyWechat().getCompanyWechatId())
+                .setCompanyWechatName(adminUser.getAdminCompanyWechat().getCompanyName())
+                .setSummaryTime(new Date())
+                .setSummaryCost(bean.getSummaryCost())
+                .setSummaryOrderCount(bean.getSummaryOrderCount())
+                .setSummaryPersonCount(bean.getSummaryPersonCount())
+                .setSummaryMonth(nowMonth)
+                .updateById();
+    }
+
+
+    public List<SettleDailyIssueSummaryMonthRecord> setMonthIssue(List<DailyMonthTotalBean> totalBeans, String summaryMonthBatchNo, String opName, String nowMonth) {
+        List<SettleDailyIssueSummaryMonthRecord> result = new ArrayList<>();
+        for (DailyMonthTotalBean totalBean : totalBeans) {
+            String monthSalaryNo = commonLogic.generateNo("SF", "monthSalaryNo", 15);
+            SettleDailyIssueSummaryMonthRecord monthIssue = new SettleDailyIssueSummaryMonthRecord();
+            //设置月度计算为空
+            monthIssue.setIsMonthCalculate(false);
+            monthIssue.setSummaryBatchNo(summaryMonthBatchNo);
+            monthIssue.setSalaryNo(monthSalaryNo);
+            monthIssue.setRepairTotalAmount(totalBean.getRepairTotalAmount());
+            monthIssue.setDailySendCost(totalBean.getIssueCost());
+            //计税金额
+            BigDecimal incomeCostTax = new BigDecimal(0);
+            if (totalBean.getRepairTotalAmount() != null) {
+                incomeCostTax = incomeCostTax.add(totalBean.getRepairTotalAmount());
+            }
+            if (totalBean.getIncrDecrCost() != null) {
+                incomeCostTax = incomeCostTax.add(totalBean.getIncrDecrCost());
+            }
+            if (totalBean.getReduceCost() != null) {
+                incomeCostTax = incomeCostTax.subtract(totalBean.getReduceCost());
+            }
+            monthIssue.setTaxToatalCost(incomeCostTax);
+            monthIssue.setReduceCost(totalBean.getReduceCost());
+            monthIssue.setShouldReduceCost(totalBean.getReduceCost());
+            monthIssue.setReduceCost(totalBean.getReduceCost());
+            monthIssue.setSummaryNumber(totalBean.getSummaryNumber());
+            monthIssue.setSummaryName(totalBean.getSummaryName());
+            monthIssue.setIncrDecrCost(totalBean.getIncrDecrCost());
+
+            monthIssue.setIdCard(totalBean.getIdCard());
+            monthIssue.setMobile(totalBean.getMobile());
+            monthIssue.setMonth(nowMonth);
+            monthIssue.setWithholdTotalCost(totalBean.getWithholdTotalCost());
+            monthIssue.setWithholdCost(totalBean.getWithholdTotalCost());
+
+            monthIssue.setShouldResidualInsuranceCost(totalBean.getResidualInsuranceCostC());
+            monthIssue.setResidualInsuranceCost(totalBean.getResidualInsuranceCostC());
+            monthIssue.setEmpInsuranceCost(totalBean.getEmpInsuranceCostC());
+            monthIssue.setShouldEmpInsuranceCost(totalBean.getEmpInsuranceCostC());
+
+            monthIssue.setServiceName(totalBean.getServiceName());
+            monthIssue.setServiceNumber(totalBean.getServiceNumber());
+            monthIssue.setWebsitName(totalBean.getWebsitName());
+            monthIssue.setWebsitNumber(totalBean.getWebsitNumber());
+
+            monthIssue.setStatus(DailyConstant.ISSUE_STATUS_NOT);
+
+            monthIssue.setSummaryBy(opName);
+            monthIssue.setSummaryTime(new Date());
+            monthIssue.setCompanyWechatId(totalBean.getCompanyWechatId());
+            monthIssue.setCompanyWechatName(totalBean.getCompanyWechatName());
+            monthIssue.setRepairCount(totalBean.getRepairCountC());
+            result.add(monthIssue);
+        }
+        return result;
+    }
+
+    @Transactional
+    public void monthlyDo() {
+        AdminUserCom adminUser = commonLogic.getAdminUser();
+
+        if (adminUser.getType() == 2) {
+            throw new RemoteServiceException("平台账号禁止操作");
+        }
+        String opName = adminUser.getJoinNickName();
+        //拿到当前月份
+        String nowMonth = DateUtil.format(new Date(), "yyyyMM");
+
+        Integer count = dailyMonthlySummaryService.lambdaQuery()
+                .eq(SettleDailyMonthlySummary::getCompanyWechatId, adminUser.getAdminCompanyWechat().getCompanyWechatId())
+                .eq(SettleDailyMonthlySummary::getSummaryMonth, nowMonth)
+                .count();
+        if (count > 0) {
+            throw new RemoteServiceException("当前月份已汇总,请勿重复汇总。");
+        }
+        //生成档次月度汇总批次号
+        String monthSummaryBatchNo = commonLogic.generateNo("CW", "monthSummary", 15);
+        //生成每人月度发放数据(发放,发放失败数据)
+        List<DailyMonthTotalBean> totalBeans = dailyMapper.queryMonthTotalCost(adminUser.getAdminCompanyWechat().getCompanyWechatId());
+        if (totalBeans.size() == 0) {
+            throw new RemoteServiceException("当前月份已汇总没有已发放数据");
+        }
+
+        //把所有发放成功数据汇总到当月
+        List<SettleDailyIssueSummaryMonthRecord> monthIssues = setMonthIssue(totalBeans, monthSummaryBatchNo, opName, nowMonth);
+        issueSummaryMonthRecordService.saveBatch(monthIssues, 500);
+
+        dailyIssueSummaryRecordService.lambdaUpdate()
+                .set(SettleDailyIssueSummaryRecord::getIsMonthSummary, true)
+                .set(SettleDailyIssueSummaryRecord::getSummaryMonthBatchNo, monthSummaryBatchNo)
+                .set(SettleDailyIssueSummaryRecord::getUpdateBy, opName)
+                .set(SettleDailyIssueSummaryRecord::getUpdateTime, new Date())
+                .set(SettleDailyIssueSummaryRecord::getMonth, nowMonth)
+                .eq(SettleDailyIssueSummaryRecord::getCompanyWechatId, adminUser.getAdminCompanyWechat().getCompanyWechatId())
+                .eq(SettleDailyIssueSummaryRecord::getIsMonthSummary, false)
+                .update();
+        DailyNotMonthSummaryCountBean bean = dailyMapper.queryNotMonthSummaryData(adminUser.getAdminCompanyWechat().getCompanyWechatId());
+        //将数据插入汇总表
+        SettleDailyMonthlySummary monthlySummary = new SettleDailyMonthlySummary();
+        monthlySummary.setCompanyWechatId(adminUser.getAdminCompanyWechat().getCompanyWechatId())
+                .setCompanyWechatName(adminUser.getAdminCompanyWechat().getCompanyName())
+                .setSummaryBy(opName)
+                .setSummaryTime(new Date())
+                .setSummaryCost(bean.getSummaryCost())
+                .setSummaryMonthBatchNo(monthSummaryBatchNo)
+                .setSummaryOrderCount(bean.getSummaryOrderCount())
+                .setSummaryPersonCount(bean.getSummaryPersonCount())
+                .setSummaryMonth(nowMonth)
+                .insert();
+    }
+
+
+    @Transactional
+    public void monthSalaryIssue(String summaryMonthBatchNo, List<String> summaryNumberList) {
+        //验证手机验证码
+//        Object validMessageCode = redisUtil.get(Constant.RedisPrefix.ISSUE_SAL_MOBILE_SMS + mobile);
+//        if (!code.equals(validMessageCode.toString())){
+//            throw new RemoteServiceException("短信验证码输入错误");
+//        }
+        AdminUserCom adminUser = commonLogic.getAdminUser();
+
+        if (adminUser.getType() == 2) {
+            throw new RemoteServiceException("平台账号禁止操作");
+        }
+
+        Integer count = dailyIssueSummaryMonthRecordService.lambdaQuery()
+                .eq(SettleDailyIssueSummaryMonthRecord::getSummaryBatchNo, summaryMonthBatchNo)
+                .in(CollectionUtil.isNotEmpty(summaryNumberList), SettleDailyIssueSummaryMonthRecord::getSummaryNumber, summaryNumberList)
+                .eq(SettleDailyIssueSummaryMonthRecord::getIsMonthCalculate, false).count();
+        if (count > 0) {
+            throw new RemoteServiceException("请先进行月度计算");
+        }
+        summaryNumberList = dailyTransferLogic.issueCheck(summaryMonthBatchNo, summaryNumberList, true, adminUser);
+        dailyTransferLogic.issueSalary(summaryMonthBatchNo, summaryNumberList, true, adminUser);
+    }
+
+
+}

+ 7 - 0
mall-server-api/src/main/java/com/gree/mall/manager/utils/CommonUtils.java

@@ -409,4 +409,11 @@ public class CommonUtils {
         return "";
     }
 
+    public static String getDoStatus(Integer status){
+        if(DailyConstant.DO_STATUS_HAS.equals(status))
+            return "已执行";
+        if(DailyConstant.DO_STATUS_NOT.equals(status))
+            return "未执行";
+        return "";
+    }
 }

+ 246 - 0
mall-server-api/src/main/resources/mapper/DailyMapper.xml

@@ -326,4 +326,250 @@
         </where>
 
     </select>
+
+    <select id="cwSummaryMonthList" resultType="com.gree.mall.manager.bean.settle.repair.DailyNotMonthSummaryCountBean">
+        select
+        t.*
+        from
+        (
+            select
+                summary_batch_no ,
+                `month` 'summaryMonth',
+                sum(repair_count) 'summaryOrderCount',
+                count(distinct service_number) 'summaryPersonCount',
+                sum(repair_total_amount) 'summaryCost',
+                sum(month_send_cost) 'issueCostC',
+                status 'groupStatus',
+                if(find_in_set('4',group_concat(distinct status)) > 0 || find_in_set('1',group_concat(distinct status)) > 0  ,1,status) 'issueStatus',
+                summary_by ,
+                summary_time ,
+                issue_time ,
+                issue_by,
+                create_time
+            from
+            settle_daily_issue_summary_month_record a
+            <where>
+
+                <if test="companyWechatIds != null and companyWechatIds.size > 0">
+                    AND a.company_wechat_id IN
+                    <foreach item="item" index="index" collection="companyWechatIds" open="(" separator="," close=")">
+                        #{item}
+                    </foreach>
+                </if>
+                <if test="adminWebsitIds != null and adminWebsitIds.size > 0">
+                    AND a.websit_number IN
+                    <foreach item="item" index="index" collection="adminWebsitIds" open="(" separator="," close=")">
+                        #{item}
+                    </foreach>
+                </if>
+                <if test="summaryStartTime != null and summaryStartTime !='' and summaryEndTime != null and summaryEndTime != ''">
+                    and summary_time between #{summaryStartTime} and concat(#{summaryEndTime},' 23:59:59')
+                </if>
+
+                <if test="issueStartTime != null and issueStartTime !='' and issueEndTime != null and issueEndTime != ''">
+                    and issue_time between #{issueStartTime} and concat(#{issueEndTime},' 23:59:59')
+                </if>
+
+                <if test="summaryBatchNo != null and summaryBatchNo != ''">
+                    and summary_batch_no = #{summaryBatchNo}
+                </if>
+
+            </where>
+            group by summary_batch_no
+        ) t
+        <where>
+            <if test="status != null and status !=''">
+                and t.issueStatus = #{status}
+            </if>
+        </where>
+        order by t.create_time desc
+
+    </select>
+
+    <select id="monthlySummaryList" resultType="com.gree.mall.manager.bean.settle.repair.DailyNotMonthSummaryCountBean">
+        select
+            summary_number,
+            summary_name ,
+            summary_batch_no ,
+            `month` 'summaryMonth',
+            sum(repair_count) 'summaryOrderCount',
+            count(distinct service_number) 'summaryPersonCount',
+            sum(repair_total_amount) 'summaryCost',
+            status 'groupStatus',
+            if(find_in_set('4',group_concat(distinct status)) > 0 || find_in_set('1',group_concat(distinct status)) > 0  ,1,status) 'issueStatus',
+            summary_by ,
+            summary_time ,
+            issue_time ,
+            issue_by,
+            sum(should_emp_insurance_cost +should_residual_insurance_cost) 'empCost',
+            sum(withhold_cost ) 'withholdCost',
+            sum(incr_decr_cost) 'decrCost',
+            sum(reduce_cost) 'reduceCost',
+            sum(income_cost) 'incomeCost',
+            sum(issue_cost) 'issueCost',
+            websit_name,
+            websit_number
+        from
+            settle_daily_issue_summary_month_record a
+        <where>
+            <if test="companyWechatIds != null and companyWechatIds.size > 0">
+                AND a.company_wechat_id IN
+                <foreach item="item" index="index" collection="companyWechatIds" open="(" separator="," close=")">
+                    #{item}
+                </foreach>
+            </if>
+            <if test="adminWebsitIds != null and adminWebsitIds.size > 0">
+                AND a.websit_number IN
+                <foreach item="item" index="index" collection="adminWebsitIds" open="(" separator="," close=")">
+                    #{item}
+                </foreach>
+            </if>
+
+            <if test="summaryBatchNo != null and summaryBatchNo !=''">
+                and a.summary_batch_no = #{summaryBatchNo}
+            </if>
+        </where>
+
+        group by summary_number
+        order by summary_time desc
+    </select>
+
+    <select id="monthlyWebsiteList" resultType="com.gree.mall.manager.bean.settle.repair.DailyNotMonthSummaryCountBean">
+        select
+        summary_number,
+        summary_name ,
+        summary_batch_no ,
+        `month` 'summaryMonth',
+        count(1) 'summaryOrderCount',
+        count(distinct service_number) 'summaryPersonCount',
+        sum(repair_total_amount) 'summaryCost',
+        status 'issueStatus',
+        summary_by ,
+        summary_time ,
+        issue_time ,
+        issue_by,
+        sum(should_emp_insurance_cost +should_residual_insurance_cost) 'empCost',
+        sum(withhold_cost ) 'withholdCost',
+        sum(incr_decr_cost) 'decrCost',
+        sum(reduce_cost) 'reduceCost',
+        sum(income_cost) 'incomeCost',
+        sum(issue_cost) 'issueCost',
+        websit_name,
+        websit_number
+        from
+        settle_daily_issue_summary_month_record a
+        <where>
+            <if test="companyWechatIds != null and companyWechatIds.size > 0">
+                AND a.company_wechat_id IN
+                <foreach item="item" index="index" collection="companyWechatIds" open="(" separator="," close=")">
+                    #{item}
+                </foreach>
+            </if>
+            <if test="adminWebsitIds != null and adminWebsitIds.size > 0">
+                AND a.websit_number IN
+                <foreach item="item" index="index" collection="adminWebsitIds" open="(" separator="," close=")">
+                    #{item}
+                </foreach>
+            </if>
+
+            <if test="summaryBatchNo != null and summaryBatchNo !=''">
+                and a.summary_batch_no = #{summaryBatchNo}
+            </if>
+
+        </where>
+
+        group by websit_number
+        order by summary_time desc
+    </select>
+
+    <select id="monthlyDetailList" resultType="com.gree.mall.manager.bean.settle.repair.DailyWorkerIssueSalaryBean">
+        select
+        a.*,b.status 'issueStatus' ,b.issue_time ,c.bank_account_name ,c.deposit_bank ,c.bank_account
+        from
+        settle_daily_import_summary_item a
+        left join
+        settle_daily_issue_summary_record b on a.issue_salary_id =b.id
+        left join (
+            SELECT
+                u.id_card,
+                wb.worker_number,
+                u.nick_name
+            FROM
+                user u, websit_user wb
+            WHERE
+                u.company_wechat_id = wb.company_wechat_id
+                AND u.user_id = wb.user_id
+                AND u.apply_type = 'WORKER'
+                AND wb.examine_status = 'OK'
+        ) aa on a.worker_number = aa.worker_number
+        left join settle_daily_bank_account c  on  aa.id_card = c.idcard
+        <where>
+            <if test="companyWechatIds != null and companyWechatIds.size > 0">
+                AND a.company_wechat_id IN
+                <foreach item="item" index="index" collection="companyWechatIds" open="(" separator="," close=")">
+                    #{item}
+                </foreach>
+            </if>
+            <if test="adminWebsitIds != null and adminWebsitIds.size > 0">
+                AND a.websit_number IN
+                <foreach item="item" index="index" collection="adminWebsitIds" open="(" separator="," close=")">
+                    #{item}
+                </foreach>
+            </if>
+
+            <if test="serviceNumber != null and serviceNumber != ''">
+                and b.service_number = #{serviceNumber}
+            </if>
+
+            <if test="summaryMonthBatchNo != null and summaryMonthBatchNo != ''">
+                and b.summary_month_batch_no = #{summaryMonthBatchNo}
+            </if>
+
+            <if test="summaryNumber != null and summaryNumber != ''">
+                and a.summary_number = #{summaryNumber}
+            </if>
+
+        </where>
+
+    </select>
+
+    <select id="queryMonthTotalCost" resultType="com.gree.mall.manager.bean.settle.repair.DailyMonthTotalBean">
+        select
+            sum(repair_total_amount) 'repairTotalAmount',
+            sum(should_reduce_cost) 'reduceCost',
+            sum(incr_decr_cost) 'incrDecrCost',
+            sum(issue_cost) 'issueCost',
+            sum(withhold_cost) 'withholdTotalCost',
+            sum(should_residual_insurance_cost) 'residualInsuranceCostC',
+            sum(should_emp_insurance_cost) 'empInsuranceCostC',
+            sum(repair_count) 'repairCountC',
+            id_card ,
+            mobile,
+            service_name,
+            service_number,
+            websit_number ,
+            websit_name ,
+            summary_name ,
+            summary_number,
+            company_wechat_id,
+            company_wechat_name
+        from
+            settle_daily_issue_summary_record a
+        where
+            status = 2 and a.install = 0 AND company_wechat_id = #{companyWechatId}
+        group by
+            service_number ,summary_number
+    </select>
+
+    <select id="queryNotMonthSummaryData" resultType="com.gree.mall.manager.bean.settle.repair.DailyNotMonthSummaryCountBean">
+        select
+            count(distinct(service_number)) 'summaryPersonCount',
+            count(1) 'summaryOrderCount',
+            sum(repair_total_amount) 'summaryCost'
+        from
+            settle_daily_issue_summary_record
+        where
+            is_month_summary = false
+            AND company_wechat_id = #{companyWechatId}
+    </select>
 </mapper>