xingzai před 1 rokem
rodič
revize
5f979da4d7

+ 3 - 3
controllers/company_apply.go

@@ -166,7 +166,7 @@ func (this *CompanyApplyController) ApplyContractHistoryList() {
 							} else if expensiveYx == 2 {
 								n.PermissionName += "(10w)"
 							} else if expensiveYx == 0 {
-								n.PermissionName += "(3w)"
+								//n.PermissionName += "(3w)"
 							}
 						}
 						checkList = append(checkList, n.ChartPermissionId)
@@ -196,7 +196,7 @@ func (this *CompanyApplyController) ApplyContractHistoryList() {
 						} else if expensiveYx == 2 {
 							n.PermissionName += "(10w)"
 						} else if expensiveYx == 0 {
-							n.PermissionName += "(3w)"
+							//n.PermissionName += "(3w)"
 						}
 						//n.PermissionName += expMap[match.ExpensiveYx]
 						checkList = append(checkList, n.ChartPermissionId)
@@ -2047,7 +2047,7 @@ func (this *CompanyApplyController) ApplyContract() {
 			if n.PermissionName == utils.CHART_PERMISSION_NAME_MF_YANXUAN {
 				m3, m5, m10 := new(company.PermissionLookItem), new(company.PermissionLookItem), new(company.PermissionLookItem)
 				m3.ChartPermissionId = n.ChartPermissionId
-				m3.PermissionName = fmt.Sprint(n.PermissionName, "(3w)")
+				m3.PermissionName = n.PermissionName
 				plist.Items = append(plist.Items, m3)
 
 				m5.ChartPermissionId = n.ChartPermissionId + utils.PERMISSION_ID_YANXUAN_DIFF

+ 39 - 16
controllers/cygx/contract_allocation.go

@@ -507,7 +507,7 @@ func (this *ContractAllocationController) CompanyContracDetail() {
 	}
 
 	//var contractPermissionList []*company.ContractPermissionList
-	expMap := map[int]string{0: "(3w)", 1: "(5w)", 2: "(10w)"} // 买方研选价格
+	//expMap := map[int]string{0: "(3w)", 1: "(5w)", 2: "(10w)"} // 买方研选价格
 	hasPermissions, e := company.GetCompanyContractPermissionByCompanyContractId(companyContractId)
 	if e != nil {
 		br.Msg = "获取失败"
@@ -515,8 +515,12 @@ func (this *ContractAllocationController) CompanyContracDetail() {
 		return
 	}
 	hasMap := make(map[int]*company.CompanyContractPermission)
+	var pointMoney float64
 	for _, p := range hasPermissions {
 		hasMap[p.ChartPermissionId] = p
+		if p.ChartPermissionId == utils.YAN_XUAN_KOU_DIAN_BAO_ID {
+			pointMoney = 0.2 * p.Points
+		}
 	}
 
 	raiPermissions, e := company.GetPermissionLookItemsExt("2", utils.COMPANY_PRODUCT_RAI_NAME)
@@ -528,6 +532,7 @@ func (this *ContractAllocationController) CompanyContracDetail() {
 	mapPermissionNameHave := make(map[string]bool) // 判断合同是否存在某一行业权限种类
 	var expensiveYx int
 	for _, n := range raiPermissions {
+
 		match := hasMap[n.ChartPermissionId]
 		if match == nil {
 			continue
@@ -537,32 +542,44 @@ func (this *ContractAllocationController) CompanyContracDetail() {
 		// 买方研选(3w/5w/10w)
 		if n.PermissionName == utils.CHART_PERMISSION_NAME_MF_YANXUAN {
 			expensiveYx = match.ExpensiveYx
-			n.PermissionName += expMap[match.ExpensiveYx]
+			//n.PermissionName += expMap[match.ExpensiveYx]
 			continue
 		}
 	}
 
 	resp.Money = contractItem.Money / 10000
 	//有研选时,对研选套餐类型做文案处理
-	respItemYx := new(cygx.AllocationPermissionListResp)
-	if mapPermissionNameHave[utils.CHART_PERMISSION_NAME_MF_YANXUAN] {
+	respItemYx := new(cygx.AllocationPermissionListResp)        // 研选订阅
+	respItemYxKouDian := new(cygx.AllocationPermissionListResp) //  研选扣点
+	if mapPermissionNameHave[utils.CHART_PERMISSION_NAME_MF_YANXUAN] || mapPermissionNameHave[utils.YAN_XUAN_KOU_DIAN_BAO_NAME] {
 		var moneyYx float64
-		if expensiveYx == 0 {
-			moneyYx = 3
-		} else if expensiveYx == 1 {
-			moneyYx = 5
-		} else if expensiveYx == 2 {
-			moneyYx = 10
+		if mapPermissionNameHave[utils.CHART_PERMISSION_NAME_MF_YANXUAN] {
+			if expensiveYx == 0 {
+				moneyYx = 3
+			} else if expensiveYx == 1 {
+				moneyYx = 5
+			} else if expensiveYx == 2 {
+				moneyYx = 10
+			}
+			respItemYx.Proportion = 0
+			respItemYx.Money = moneyYx
+			respItemYx.ChartPermissionName = utils.CHART_PERMISSION_NAME_MF_YANXUAN
+			respItemYx.List = append(respItemYx.List, &cygx.AllocationRealNameListResp{utils.CHART_PERMISSION_NAME_MF_YANXUAN, 0, moneyYx})
+		}
+
+		if mapPermissionNameHave[utils.YAN_XUAN_KOU_DIAN_BAO_NAME] {
+			respItemYxKouDian.Proportion = 0
+			respItemYxKouDian.Money = pointMoney
+			respItemYxKouDian.ChartPermissionName = utils.YAN_XUAN_KOU_DIAN_BAO_NAME
+			respItemYxKouDian.List = append(respItemYxKouDian.List, &cygx.AllocationRealNameListResp{utils.YAN_XUAN_KOU_DIAN_BAO_NAME, 0, pointMoney})
 		}
-		resp.TotalPointsContent = fmt.Sprint(resp.Money, "W,", "其中", moneyYx, "w默认归属买方研选,请对剩余", resp.Money-moneyYx, "w按照100%进行比值分配")
+
+		resp.TotalPointsContent = fmt.Sprint(resp.Money, "W,", "其中", moneyYx+pointMoney, "w默认归属买方研选,请对剩余", resp.Money-moneyYx-pointMoney, "w按照100%进行比值分配")
 		if showDetail {
 			resp.TotalPointsContent = fmt.Sprint(resp.Money, "W")
 		}
 		resp.Money = resp.Money - moneyYx
-		respItemYx.Proportion = 0
-		respItemYx.Money = moneyYx
-		respItemYx.ChartPermissionName = utils.CHART_PERMISSION_NAME_MF_YANXUAN
-		respItemYx.List = append(respItemYx.List, &cygx.AllocationRealNameListResp{utils.CHART_PERMISSION_NAME_MF_YANXUAN, 0, moneyYx})
+
 	} else {
 		resp.TotalPointsContent = fmt.Sprint(resp.Money, "W")
 	}
@@ -591,9 +608,15 @@ func (this *ContractAllocationController) CompanyContracDetail() {
 			respItem.List = v
 			respList = append(respList, respItem)
 		}
+		//研选订阅
 		if respItemYx.ChartPermissionName != "" {
 			respList = append(respList, respItemYx)
 		}
+		//研选扣点
+		if respItemYxKouDian.ChartPermissionName != "" {
+			respList = append(respList, respItemYxKouDian)
+		}
+
 	} else {
 		listUser, err := cygx.GetCygxAllocationCompanyContractListById(companyContractId)
 		if err != nil {
@@ -637,7 +660,7 @@ func (this *ContractAllocationController) CompanyContracDetail() {
 		return
 	}
 
-	permissionNameArr := []string{"医药", "消费", "科技", "智造", "策略", "买方研选"}
+	permissionNameArr := []string{"医药", "消费", "科技", "智造", "策略", utils.CHART_PERMISSION_NAME_MF_YANXUAN, utils.YAN_XUAN_KOU_DIAN_BAO_NAME}
 	for _, v := range permissionNameArr {
 		for _, v2 := range respList {
 			if v2.ChartPermissionName == v {

+ 42 - 17
services/company_approval_message.go

@@ -8,6 +8,7 @@ import (
 	"hongze/hz_crm_api/models/system"
 	"hongze/hz_crm_api/services/alarm_msg"
 	"hongze/hz_crm_api/utils"
+	"strings"
 	"time"
 )
 
@@ -224,32 +225,56 @@ func AddCompanyApprovalMessageWangYang(companyId, companyContractId int, applyRe
 			go alarm_msg.SendAlarmMsg("客户研选行业转正时(王芳审批通过),模板消息提醒汪洋,Err:"+err.Error()+fmt.Sprint("companyId:", companyId, "companyContractId:", companyContractId, "applyRealName:", applyRealName, "companyName:", companyName), 3)
 		}
 	}()
-	//如果是研选的就推送给汪洋
-	count, e := company.GetCompanyContractPermissionCheckByContractId(companyId, companyContractId, utils.CHART_PERMISSION_ID_YANXUAN)
+	var mobiles []string
+	cnf, e := cygx.GetCygxConfigDetailByCode(utils.TPL_MSG_YANXAUN_APPROVAL)
 	if e != nil {
-		err = errors.New("GetCompanyContractPermissionCheckByContractId, Err: " + e.Error())
+		err = errors.New("GetCygxConfigDetailByCode, Err: " + e.Error())
 		return
 	}
-	if count == 0 {
+	mobiles = strings.Split(cnf.ConfigValue, ",")
+	openIdList, e := cygx.GetUserRecordListByMobileArr(mobiles)
+	if e != nil && e.Error() != utils.ErrNoRow() {
+		err = errors.New("GetUserRecordListByMobileArr, Err: " + e.Error())
 		return
 	}
-	var keyword1, keyword2, keyword3, keyword4 string
-	keyword1 = companyName + "(" + applyRealName + ")"
-	keyword2 = "买方研选转正"
-	var mobiles []string
-	cnf, e := cygx.GetCygxConfigDetailByCode(utils.TPL_MSG_WANG_YANG)
-	if e != nil {
-		err = errors.New("GetConfigByCode, Err: " + e.Error())
+	if len(openIdList) == 0 {
 		return
 	}
-	mobiles = append(mobiles, cnf.ConfigValue)
-	openIdList, err := cygx.GetUserRecordListByMobileArr(mobiles)
-	if err != nil && err.Error() != utils.ErrNoRow() {
-		return err
+
+	list, e := company.GetCompanyContractPermissionByCompanyContractId(companyContractId)
+	if e != nil && e.Error() != utils.ErrNoRow() {
+		err = errors.New("GetCompanyContractPermissionByCompanyContractId, Err: " + e.Error())
+		return
 	}
-	if len(openIdList) == 0 {
+
+	if len(list) == 0 {
 		return
 	}
-	go SendWxMsgWithRaiWangYang(keyword1, keyword2, keyword3, keyword4, openIdList)
+
+	var haveDingYue bool // 是否签约了研选订阅
+	var points float64   // 是否签约了研选扣点包,以及对应的点数
+	for _, v := range list {
+		if v.ChartPermissionId == utils.CHART_PERMISSION_ID_YANXUAN {
+			haveDingYue = true
+		}
+		if v.ChartPermissionId == utils.YAN_XUAN_KOU_DIAN_BAO_ID {
+			points = v.Points
+		}
+	}
+	var keyword1, keyword2, keyword3, keyword4 string
+	if haveDingYue {
+		keyword1 = companyName + "(" + applyRealName + ")"
+		keyword2 = time.Now().Format(utils.FormatDateTime)
+		keyword3 = "签约【研选订阅】"
+		go SendWxMsgWithRaiWangYang(keyword1, keyword2, keyword3, keyword4, openIdList)
+	}
+
+	if points > 0 {
+		keyword1 = companyName + "(" + applyRealName + ")"
+		keyword2 = time.Now().Format(utils.FormatDateTime)
+		keyword3 = "签约【研选扣点包(" + fmt.Sprint(points) + "个点)】"
+		go SendWxMsgWithRaiWangYang(keyword1, keyword2, keyword3, keyword4, openIdList)
+	}
+
 	return
 }

+ 50 - 38
services/cygx/contract_allocation.go

@@ -120,7 +120,7 @@ func GetCompanyContractPermissionNameMapById(companyContractIds []int) (mapContr
 				} else if v.ExpensiveYx == 2 {
 					mapContractIdPerssion[(v.CompanyContractId)] += utils.CHART_PERMISSION_NAME_MF_YANXUAN + "(10w),"
 				} else {
-					mapContractIdPerssion[(v.CompanyContractId)] += utils.CHART_PERMISSION_NAME_MF_YANXUAN + "(3w),"
+					mapContractIdPerssion[(v.CompanyContractId)] += utils.CHART_PERMISSION_NAME_MF_YANXUAN + ","
 				}
 			} else {
 				mapContractIdPerssion[(v.CompanyContractId)] += mappermissionName[v.ChartPermissionId] + ","
@@ -139,7 +139,7 @@ func GetCompanyContractPermissionNameMapById(companyContractIds []int) (mapContr
 				} else if v.ExpensiveYx == 2 {
 					mapContractIdPerssion[(v.CompanyContractId)] += utils.CHART_PERMISSION_NAME_MF_YANXUAN + "(10w),"
 				} else {
-					mapContractIdPerssion[(v.CompanyContractId)] += utils.CHART_PERMISSION_NAME_MF_YANXUAN + "(3w),"
+					mapContractIdPerssion[(v.CompanyContractId)] += utils.CHART_PERMISSION_NAME_MF_YANXUAN + ","
 				}
 			}
 		}
@@ -303,51 +303,63 @@ func HandleAllocationCompanyContractByYanXuan(companyContractId int) (err error)
 		return
 	}
 
-	if len(companyContractPermissionList) > 1 {
+	if len(companyContractPermissionList) > 2 {
 		return
 	}
 	var expensiveYxmoney float64
+	//for _, v := range companyContractPermissionList {
+	//	if v.ChartPermissionId != utils.CHART_PERMISSION_ID_YANXUAN {
+	//		err = errors.New("没有发现研选权限: ")
+	//		return
+	//	}
+	//	if v.ExpensiveYx == 1 {
+	//		expensiveYxmoney = 5
+	//	} else if v.ExpensiveYx == 2 {
+	//		expensiveYxmoney = 10
+	//	} else {
+	//		expensiveYxmoney = 3
+	//	}
+	//}
+
+	var items []*cygx.CygxAllocationCompanyContract
+	var itemsPermission []*cygx.CygxAllocationCompanyContractPermission
+
 	for _, v := range companyContractPermissionList {
-		if v.ChartPermissionId != utils.CHART_PERMISSION_ID_YANXUAN {
-			err = errors.New("没有发现研选权限: ")
+		if v.ChartPermissionId != utils.CHART_PERMISSION_ID_YANXUAN && v.ChartPermissionId != utils.YAN_XUAN_KOU_DIAN_BAO_ID {
 			return
 		}
-		if v.ExpensiveYx == 1 {
-			expensiveYxmoney = 5
-		} else if v.ExpensiveYx == 2 {
-			expensiveYxmoney = 10
-		} else {
+
+		if v.ChartPermissionId == utils.CHART_PERMISSION_ID_YANXUAN {
 			expensiveYxmoney = 3
 		}
-	}
-
-	var items []*cygx.CygxAllocationCompanyContract
-	var itemsPermission []*cygx.CygxAllocationCompanyContractPermission
-
-	itemPermission := new(cygx.CygxAllocationCompanyContractPermission)
-	itemPermission.CompanyContractId = companyContractId
-	//itemPermission.AdminId = sysUser.AdminId
-	//itemPermission.AdminName = sysUser.RealName
-	itemPermission.Proportion = 0
-	itemPermission.Money = expensiveYxmoney
-	itemPermission.MoneyAvg = 0
-	itemPermission.ChartPermissionName = utils.CHART_PERMISSION_NAME_MF_YANXUAN
-	itemPermission.CreateTime = time.Now()
-	itemPermission.ModifyTime = time.Now()
-	itemsPermission = append(itemsPermission, itemPermission)
-
-	item := new(cygx.CygxAllocationCompanyContract)
-	item.CompanyContractId = companyContractId
-	//item.AdminId = sysUser.AdminId
-	//item.AdminName = sysUser.RealName
-	item.Proportion = 0
-	item.Money = expensiveYxmoney
-	item.RealName = utils.CHART_PERMISSION_NAME_MF_YANXUAN
-	item.ChartPermissionName = utils.CHART_PERMISSION_NAME_MF_YANXUAN
-	item.CreateTime = time.Now()
-	item.ModifyTime = time.Now()
-	items = append(items, item)
 
+		if v.ChartPermissionId == utils.YAN_XUAN_KOU_DIAN_BAO_ID {
+			expensiveYxmoney = 0.2 * v.Points
+		}
+		itemPermission := new(cygx.CygxAllocationCompanyContractPermission)
+		itemPermission.CompanyContractId = companyContractId
+		//itemPermission.AdminId = sysUser.AdminId
+		//itemPermission.AdminName = sysUser.RealName
+		itemPermission.Proportion = 0
+		itemPermission.Money = expensiveYxmoney
+		itemPermission.MoneyAvg = 0
+		itemPermission.ChartPermissionName = v.PermissionName
+		itemPermission.CreateTime = time.Now()
+		itemPermission.ModifyTime = time.Now()
+		itemsPermission = append(itemsPermission, itemPermission)
+
+		item := new(cygx.CygxAllocationCompanyContract)
+		item.CompanyContractId = companyContractId
+		//item.AdminId = sysUser.AdminId
+		//item.AdminName = sysUser.RealName
+		item.Proportion = 0
+		item.Money = expensiveYxmoney
+		item.RealName = v.PermissionName
+		item.ChartPermissionName = v.PermissionName
+		item.CreateTime = time.Now()
+		item.ModifyTime = time.Now()
+		items = append(items, item)
+	}
 	e = cygx.AddAndUpdateCygxAllocationCompanyContract(items, itemsPermission, companyContractId)
 	if e != nil {
 		err = errors.New("AddAndUpdateCygxAllocationCompanyContract, Err: " + e.Error())

+ 1 - 1
services/wechat_send_msg.go

@@ -2201,7 +2201,7 @@ func SendWxMsgWithRaiWangYang(keyword1, keyword2, keyword3, keyword4 string, ope
 	sendInfo.Keyword2 = keyword2
 	sendInfo.Keyword3 = keyword3
 	sendInfo.Keyword4 = keyword4
-	sendInfo.TemplateId = utils.WxMsgTemplateIdActivityChangeApply
+	sendInfo.TemplateId = utils.WxMsgTemplateIdCompanyApprovalMessageRai
 	sendInfo.RedirectUrl = ""
 	sendInfo.RedirectTarget = 3
 	sendInfo.SendType = utils.TEMPLATE_MSG_APPLY

+ 4 - 2
utils/constants.go

@@ -376,8 +376,9 @@ const (
 	CHART_PERMISSION_NAME_MF_YANXUAN        string = "研选订阅"
 	LU_YAN_FU_WU                            string = "路演服务"
 	CHART_PERMISSION_NAME_YANXUAN           string = "研选"
-	CHART_PERMISSION_ID_YANXUAN             int    = 31 //权限研选订阅id
-	YAN_XUAN_KOU_DIAN_BAO_ID                int    = 52 //研选扣点包ID
+	CHART_PERMISSION_ID_YANXUAN             int    = 31      //权限研选订阅id
+	YAN_XUAN_KOU_DIAN_BAO_ID                int    = 52      //研选扣点包ID
+	YAN_XUAN_KOU_DIAN_BAO_NAME              string = "研选扣点包" //研选扣点包名称
 	CE_LUE_NAME                             string = "策略"
 	CE_LUE_ID                               int    = 23
 	YI_YAO_NAME                             string = "医药"
@@ -402,6 +403,7 @@ const (
 	YI_DONG_ZHENG_TONG_YUN_TOKEN_KEY        string = "YI_DONG_ZHENG_TONG_YUN_TOKEN_KEY" //易董证通云的token,存Redis使用
 	CYGX_USER_KEY_LABEL                            = "CYGX_USER_KEY_LABEL"              //查研观向用户标签
 	TPL_MSG_WANG_YANG                              = "tpl_msg_wang_yang"                //汪洋手机号地址参数
+	TPL_MSG_YANXAUN_APPROVAL                       = "tpl_msg_yanxaun_approval"         //【研选订阅】和【研选扣点包】转正/续约审批通过后,给冯柯然和汪洋和沈涛发送模板消息
 	MicroRoadshowDefaultImgKey                     = "micro_roadshow_default_img"       // 音视频封面图
 	TPL_MSG_NEI_RONG_ZU                            = "tpl_msg_nei_rong_zu"              //内容组四人
 	TPL_MSG_WANG_FANG_WANG_YANG                    = "tpl_msg_wang_fang_wang_yang"      //权限模板消息接收人,王芳,汪洋