|
|
@@ -4,13 +4,14 @@ import (
|
|
|
"context"
|
|
|
"encoding/json"
|
|
|
"fmt"
|
|
|
+ "strings"
|
|
|
"time"
|
|
|
|
|
|
+ baseDao "dashoo.cn/micro/app/dao/base"
|
|
|
contDao "dashoo.cn/micro/app/dao/contract"
|
|
|
custDao "dashoo.cn/micro/app/dao/cust"
|
|
|
platDao "dashoo.cn/micro/app/dao/plat"
|
|
|
projDao "dashoo.cn/micro/app/dao/proj"
|
|
|
- baseDao "dashoo.cn/micro/app/dao/base"
|
|
|
"dashoo.cn/micro/app/model/home"
|
|
|
"dashoo.cn/micro/app/model/plat"
|
|
|
"dashoo.cn/micro/app/service"
|
|
|
@@ -94,7 +95,7 @@ func (s *HomeService) QueryHomeDataReportData(param *home.SearchDataReportData)
|
|
|
// 20000-30000之间:报表数据 TODO 疑似与 sys_report 表对应?
|
|
|
func (s *HomeService) getReportData(id int64, params *map[string]interface{}) (interface{}, error) {
|
|
|
switch id {
|
|
|
- case 10000, 10001, 10002, 10003, 10004, 10005, 10006, 10007, 10008, 10009, 10010, 10011, 10012, 10013, 10014, 10015, 10016, 10017, 10018:
|
|
|
+ case 10000, 10001, 10002, 10003, 10004, 10005, 10006, 10007, 10008, 10009, 10010, 10011, 10012, 10013, 10014, 10015, 10016, 10017, 10018, 10019, 10020:
|
|
|
// 获取数值指标统计数据
|
|
|
return s.getNumStatisticsData(id, params)
|
|
|
case 20000:
|
|
|
@@ -145,6 +146,7 @@ func (s *HomeService) getNumStatisticsData(id int64, params *map[string]interfac
|
|
|
contractCollDao := contDao.NewCtrContractCollectionDao(s.Tenant)
|
|
|
distDao := baseDao.NewBaseDistributorDao(s.Tenant)
|
|
|
taskDao := platDao.NewPlatTaskDao(s.Tenant)
|
|
|
+ bidDao := custDao.NewCustCustomerBidRecordDao(s.Tenant)
|
|
|
currentTime := gtime.Now()
|
|
|
monthStart := currentTime.StartOfMonth()
|
|
|
monthEnd := currentTime.EndOfMonth()
|
|
|
@@ -227,11 +229,35 @@ func (s *HomeService) getNumStatisticsData(id int64, params *map[string]interfac
|
|
|
Sum(contractDao.C.ContractAmount + " - " + contractDao.C.CollectedAmount)
|
|
|
return gconv.String(count), err
|
|
|
case 10017: //当月新增经销商数量:统计自然月当月新创建的经销商数量。
|
|
|
- count, err := distDao.Where("dist_type = '10'").Where("created_time >= ?",monthStart).Where("created_time <= ?",monthEnd).Count()
|
|
|
+ count, err := distDao.Where("dist_type = '10'").Where("created_time >= ?", monthStart).Where("created_time <= ?", monthEnd).Count()
|
|
|
return gconv.String(count), err
|
|
|
case 10018: //进行中的督办:统计正在进行的督办数量。
|
|
|
count, err := taskDao.Where("task_status = '20'").Count()
|
|
|
return gconv.String(count), err
|
|
|
+ case 10019: //当月新增招标信息
|
|
|
+ // 数据权限
|
|
|
+ // 系统管理员、总经理、销售总监、销售助理看全部的
|
|
|
+ where := ""
|
|
|
+ if service.StringsContains(s.CxtUser.Roles, "GeneralManager") || service.StringsContains(s.CxtUser.Roles, "SalesDirector") || service.StringsContains(s.CxtUser.Roles, "SaleAssociate") || service.StringsContains(s.CxtUser.Roles, "SysAdmin") {
|
|
|
+
|
|
|
+ } else {
|
|
|
+ // 默认按照产品线
|
|
|
+ productCode, err := service.ColumnString(bidDao.DB.Model("base_product_auth").Wheref("user_id = ?", s.CxtUser.Id), "product_code")
|
|
|
+ if err != nil {
|
|
|
+ return "", err
|
|
|
+ }
|
|
|
+ g.Log().Infof("CustCustomerBidRecordService List product_code %v", productCode)
|
|
|
+ if len(productCode) > 0 {
|
|
|
+ where = fmt.Sprintf("product_line in (%v)", strings.Join(productCode, ","))
|
|
|
+ } else {
|
|
|
+ where = "1=0"
|
|
|
+ }
|
|
|
+ }
|
|
|
+ count, err := bidDao.Where(fmt.Sprintf("created_time LIKE '%v%%'", currentTime.Format("Y-m"))).Where(where).Count()
|
|
|
+ return gconv.String(count), err
|
|
|
+ case 10020: //项目来源为招标信息转化
|
|
|
+ count, err := businessDao.Where("bid_id<>0").Count()
|
|
|
+ return gconv.String(count), err
|
|
|
}
|
|
|
return "", nil
|
|
|
}
|