|
@@ -1,24 +1,28 @@
|
|
|
package com.jpsoft.picc.modules.base.controller;
|
|
|
|
|
|
import com.github.pagehelper.Page;
|
|
|
+import com.jpsoft.picc.modules.base.controller.dto.PromoterDto;
|
|
|
import com.jpsoft.picc.modules.base.entity.Company;
|
|
|
import com.jpsoft.picc.modules.base.entity.CompanyUser;
|
|
|
import com.jpsoft.picc.modules.base.service.CompanyUserService;
|
|
|
+import com.jpsoft.picc.modules.business.entity.InsuranceApplication;
|
|
|
+import com.jpsoft.picc.modules.business.service.InsuranceApplicationService;
|
|
|
+import com.jpsoft.picc.modules.common.constant.PolicyStatus;
|
|
|
import com.jpsoft.picc.modules.common.dto.MsgResult;
|
|
|
import com.jpsoft.picc.modules.common.utils.PojoUtils;
|
|
|
import com.jpsoft.picc.modules.common.dto.Sort;
|
|
|
import com.jpsoft.picc.modules.common.dto.MessageResult;
|
|
|
import com.jpsoft.picc.modules.base.service.CompanyService;
|
|
|
-import io.swagger.annotations.Api;
|
|
|
-import io.swagger.annotations.ApiImplicitParam;
|
|
|
-import io.swagger.annotations.ApiImplicitParams;
|
|
|
-import io.swagger.annotations.ApiOperation;
|
|
|
+import io.swagger.annotations.*;
|
|
|
+import lombok.Data;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
|
|
|
@RestController
|
|
@@ -33,6 +37,9 @@ public class CompanyController {
|
|
|
@Autowired
|
|
|
private CompanyUserService companyUserService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private InsuranceApplicationService insuranceApplicationService;
|
|
|
+
|
|
|
@ApiOperation(value="获取信息")
|
|
|
@GetMapping("detail")
|
|
|
@ApiImplicitParams({
|
|
@@ -290,4 +297,84 @@ public class CompanyController {
|
|
|
|
|
|
return msgResult;
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ @ApiOperation(value="推广者推广统计数据")
|
|
|
+ @RequestMapping(value = "getPromoterData",method = RequestMethod.POST)
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "promoter",value = "推广者帐号", required = true, paramType = "query")
|
|
|
+ })
|
|
|
+ public MsgResult<PromoterDto> getPromoterData(String promoter, @RequestAttribute String subject){
|
|
|
+
|
|
|
+ MsgResult<PromoterDto> msgResult = new MsgResult<PromoterDto>();
|
|
|
+
|
|
|
+ PromoterDto promoterDto = new PromoterDto();
|
|
|
+
|
|
|
+ try {
|
|
|
+
|
|
|
+ Date date = new Date();
|
|
|
+
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
|
|
|
+
|
|
|
+ Calendar calendar = Calendar.getInstance();
|
|
|
+
|
|
|
+ calendar.setTime(date);
|
|
|
+
|
|
|
+ calendar.add(Calendar.MONTH, 1);//增加一个月
|
|
|
+
|
|
|
+ Date dt1 = calendar.getTime();
|
|
|
+
|
|
|
+ String startTime = sdf.format(date) + "-01";
|
|
|
+ String endTime = sdf.format(dt1) + "-01";
|
|
|
+
|
|
|
+
|
|
|
+ //累计客户数
|
|
|
+ List<Company> companyList = companyService.findByPromoter(promoter);
|
|
|
+
|
|
|
+ BigDecimal total = new BigDecimal(0);
|
|
|
+ BigDecimal month = new BigDecimal(0);
|
|
|
+
|
|
|
+ for (Company company : companyList) {
|
|
|
+ String status = String.valueOf(PolicyStatus.SendOutPolicy.getValue());
|
|
|
+ //累计投保生效金额
|
|
|
+ List<InsuranceApplication> insuranceApplicationList = insuranceApplicationService.findByCompanyId(company.getId(),status);
|
|
|
+
|
|
|
+ for (InsuranceApplication insuranceApplication : insuranceApplicationList) {
|
|
|
+ BigDecimal insuranceFee = insuranceApplication.getInsuranceFee();
|
|
|
+ total = total.add(insuranceFee);
|
|
|
+ }
|
|
|
+
|
|
|
+ //本月投保生效金额
|
|
|
+ List<InsuranceApplication> insuranceApplicationList2 = insuranceApplicationService.findByCompanyIdAndCreatTime(company.getId(), status,startTime, endTime);
|
|
|
+
|
|
|
+ for (InsuranceApplication insuranceApplication : insuranceApplicationList2) {
|
|
|
+ BigDecimal insuranceFee = insuranceApplication.getInsuranceFee();
|
|
|
+ month = month.add(insuranceFee);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //本月客户数
|
|
|
+ List<Company> monthCompanyList = companyService.findByPromoterAndCreatTime(promoter, startTime, endTime);
|
|
|
+
|
|
|
+ promoterDto.setCompanyNum(companyList.size());
|
|
|
+ promoterDto.setMonthCompanyNum(monthCompanyList.size());
|
|
|
+ promoterDto.setTotalInsuranceFee(total);
|
|
|
+ promoterDto.setMonthInsuranceFee(month);
|
|
|
+ }
|
|
|
+ catch(Exception ex){
|
|
|
+ logger.error(ex.getMessage(),ex);
|
|
|
+
|
|
|
+ msgResult.setSuccess(false);
|
|
|
+ msgResult.setMsg(ex.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ msgResult.setSuccess(true);
|
|
|
+ msgResult.setData(promoterDto);
|
|
|
+
|
|
|
+ return msgResult;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|