|
|
@@ -2,6 +2,7 @@ package cust
|
|
|
|
|
|
import (
|
|
|
"context"
|
|
|
+ "dashoo.cn/micro/app/service"
|
|
|
"database/sql"
|
|
|
"fmt"
|
|
|
"github.com/gogf/gf/frame/g"
|
|
|
@@ -58,6 +59,18 @@ func (s CustCustomerBidRecordService) List(ctx context.Context, req *model.CustC
|
|
|
ctx = context.WithValue(ctx, "contextService", s)
|
|
|
dao := s.CustomerDao.As("customer").DataScope(ctx, "sales_id").
|
|
|
LeftJoin(s.Dao.Table, "bid", "bid.cust_id=customer.id").WhereNot("bid.id", 0)
|
|
|
+ // 系统管理员、总经理、销售总监、销售助理看全部的
|
|
|
+ if service.StringsContains(s.userInfo.Roles, "GeneralManager") || service.StringsContains(s.userInfo.Roles, "SalesDirector") || service.StringsContains(s.userInfo.Roles, "SaleAssociate") || service.StringsContains(s.userInfo.Roles, "SysAdmin") {
|
|
|
+
|
|
|
+ } else {
|
|
|
+ // 默认按照产品线
|
|
|
+ productCode, err := service.ColumnString(s.Dao.DB.Table("base_product_auth").Wheref("user_id = ?", s.userInfo.Id), "product_code")
|
|
|
+ if err != nil {
|
|
|
+ return 0, nil, err
|
|
|
+ }
|
|
|
+ g.Log().Infof("CustCustomerBidRecordService List product_code %v", productCode)
|
|
|
+ dao = dao.Where("bid.product_line in (?)", productCode)
|
|
|
+ }
|
|
|
if req.SearchText != "" {
|
|
|
likestr := fmt.Sprintf("%%%s%%", req.SearchText)
|
|
|
dao = dao.Where("(bid.cuct_name LIKE ? || bid.product_name LIKE ? || bid.title LIKE ? || bid.bidder LIKE ?)", likestr, likestr, likestr, likestr)
|
|
|
@@ -134,7 +147,9 @@ func (s CustCustomerBidRecordService) Add(ctx context.Context, req *model.CustCu
|
|
|
CuctName: cust.CustName,
|
|
|
ProductName: req.ProductName,
|
|
|
PublishedTime: req.PublishedTime,
|
|
|
+ Status: "10", // 状态:(10跟进中,20待审批,30已闭环、40已超期)
|
|
|
Budget: req.Budget,
|
|
|
+ ProductLine: req.ProductLine,
|
|
|
Title: req.Title,
|
|
|
InfoType: req.InfoType,
|
|
|
Bidder: req.Bidder,
|
|
|
@@ -194,6 +209,9 @@ func (s CustCustomerBidRecordService) Update(ctx context.Context, req *model.Cus
|
|
|
if req.Budget != 0 {
|
|
|
toupdate["budget"] = req.Budget
|
|
|
}
|
|
|
+ if req.ProductLine != "" {
|
|
|
+ toupdate["product_line"] = req.ProductLine
|
|
|
+ }
|
|
|
if req.Title != "" {
|
|
|
toupdate["title"] = req.Title
|
|
|
}
|
|
|
@@ -203,6 +221,9 @@ func (s CustCustomerBidRecordService) Update(ctx context.Context, req *model.Cus
|
|
|
if req.Bidder != "" {
|
|
|
toupdate["bidder"] = req.Bidder
|
|
|
}
|
|
|
+ if req.BiddingTime != nil {
|
|
|
+ toupdate["bidding_time"] = req.BiddingTime
|
|
|
+ }
|
|
|
if req.Remark != nil {
|
|
|
toupdate["remark"] = *req.Remark
|
|
|
}
|