Ver código fonte

Merge branch '0.0.1'

Roc 3 anos atrás
pai
commit
1804afff9b

+ 11 - 20
controllers/admin.go

@@ -4,7 +4,6 @@ import (
 	"encoding/json"
 	"hongze/hongze_mobile_admin/models/request/admin"
 	admin3 "hongze/hongze_mobile_admin/models/response/admin"
-	admin2 "hongze/hongze_mobile_admin/models/tables/admin"
 	"hongze/hongze_mobile_admin/models/tables/h5_admin_session"
 	"hongze/hongze_mobile_admin/services"
 	"hongze/hongze_mobile_admin/utils"
@@ -36,38 +35,30 @@ func (this *AdminCommon) Login() {
 		return
 	}
 
-	sysUser, err := admin2.CheckAdmin(req.Username, req.Password)
+	adminWx, err := services.BindWxUser(this.Session.OpenId, req.Username, req.Password, utils.WxPlatform)
 	if err != nil {
 		if err.Error() == utils.ErrNoRow() {
-			this.FailWithMessage("登录失败,账号或密码错误", "登录失败,账号或密码错误,Err:"+err.Error())
+			this.FailWithMessage("登录失败,账号或密码错误", "登录失败,账号或密码错误")
 			return
 		}
-		this.FailWithMessage("登录失败,账号或密码错误", "登录失败,Err:"+err.Error())
+		this.FailWithMessage("登录失败", "登录失败,Err:"+err.Error())
 		return
 	}
-	if sysUser == nil {
-		this.FailWithMessage("登录失败,账号或密码错误", "登录失败,admin_wx is nil")
-		return
-	}
-	if sysUser.Enabled == 0 {
-		this.FailWithMessage("您的账号已被禁用,如需登录,请联系管理员", "您的账号已被禁用,如需登录,请联系管理员")
-		return
-	}
-	err = h5_admin_session.UpdateSession(this.Session.SessionId, sysUser.AdminId, time.Now().AddDate(0, 0, 90))
+	err = h5_admin_session.UpdateSession(this.Session.SessionId, adminWx.AdminId, time.Now().AddDate(0, 0, 90))
 	if err != nil {
 		this.FailWithMessage("登录失败", "变更session信息失败,Err:"+err.Error())
 		return
 	}
 	resp := admin3.LoginResp{
-		RealName:     sysUser.RealName,
-		AdminName:    sysUser.AdminName,
-		RoleName:     sysUser.RoleName,
-		RoleTypeCode: sysUser.RoleTypeCode,
+		RealName:     adminWx.RealName,
+		AdminName:    adminWx.AdminName,
+		RoleName:     adminWx.RoleName,
+		RoleTypeCode: adminWx.RoleTypeCode,
 	}
 
-	resp.AdminId = sysUser.AdminId
+	resp.AdminId = adminWx.AdminId
 	var productName string
-	productId := services.GetProductId(sysUser.RoleTypeCode)
+	productId := services.GetProductId(adminWx.RoleTypeCode)
 
 	if productId == 1 {
 		productName = utils.COMPANY_PRODUCT_FICC_NAME
@@ -77,6 +68,6 @@ func (this *AdminCommon) Login() {
 		productName = "admin"
 	}
 	resp.ProductName = productName
-	resp.Authority = sysUser.Authority
+	resp.Authority = adminWx.Authority
 	this.OkDetailed(resp, "登录成功")
 }

+ 8 - 1
controllers/approval.go

@@ -53,7 +53,7 @@ func (this *ApprovalCommon) List() {
 
 	if status != "" {
 		if status == "已审批" {
-			condition += ` AND c.approve_status IN('已审批','驳回','已撤回') `
+			condition += ` AND c.approve_status IN('已审批','驳回') `
 		} else {
 			condition += ` AND c.approve_status=? `
 			pars = append(pars, status)
@@ -116,6 +116,9 @@ func (this *ApprovalCommon) List() {
 			}
 			list[i].DelayPermission = delayPermission
 		}
+		if item.ApproveRoleTypeCode == roleTypeCode {
+			list[i].OpButton = true
+		}
 	}
 
 	page := paging.GetPaging(currentIndex, pageSize, total)
@@ -430,6 +433,10 @@ func (this *ApprovalCommon) ApplyApprove() {
 		}
 		approveContent = "审批通过"
 	} else { //拒绝
+		if req.Remark == "" {
+			this.FailWithMessage("请填写驳回理由", "请填写驳回理由")
+			return
+		}
 		approveStatus = "驳回"
 		err = company_approval.ApproveRefuse(req.CompanyId, productId, approveStatus, req.Remark)
 		approveContent = "审批驳回"

+ 33 - 31
models/tables/company_approval/company_approval.go

@@ -82,35 +82,37 @@ func GetCompanyApprovalByApprovalId(companyApprovalId int) (item *CompanyApprova
 
 //客户审批单
 type CompanyApprovalList struct {
-	CompanyId         int
-	ProductId         int
-	CompanyName       string `description:"客户名称"`
-	CreditCode        string `description:"社会统一信用码"`
-	CompanyType       string `description:"客户类型"`
-	IndustryName      string `description:"行业名称"`
-	SellerName        string `description:"销售名称"`
-	CreateTime        string `description:"创建时间"`
-	ApprovalTime      string `description:"提交申请时间"`
-	ApproveTime       string `description:"审批时间"`
-	Status            string `description:"客户状态"`
-	ApproveContent    string `description:"待审内容"`
-	ApproveStatus     string `description:"当前状态"`
-	ApplyMethod       int    `description:"申请类型:申请类型:1:试用->正式,2:冻结—>试用,3:试用延期,4:原销售申请领取流失客户,5:正式客户申请服务更新"`
-	ApplyReasons      string `description:"申请理由"`
-	FreezeStartDate   string `description:"冻结开始日期"`
-	FreezeEndDate     string `description:"冻结结束日期"`
-	FreezeExpireDays  int    `description:"冻结到期天数"`
-	Address           string `description:"地址"`
-	Source            string `description:"客户来源"`
-	ApproveRemark     string `description:"驳回理由"`
-	StartDate         string `description:"开始日期"`
-	EndDate           string `description:"结束日期"`
-	ExpireDay         int    `description:"服务到期天数"`
-	CompanyApprovalId int    `description:"审批记录ID"`
-	ApprovalCount     int    `description:"已延期审批次数"`
-	CompanyContractId int    `description:"合同id"`
-	DelayPermission   string `description:"延期申请品种"`
-	ApplyRealName     string `description:"申请人姓名"`
+	CompanyId           int
+	ProductId           int
+	CompanyName         string `description:"客户名称"`
+	CreditCode          string `description:"社会统一信用码"`
+	CompanyType         string `description:"客户类型"`
+	IndustryName        string `description:"行业名称"`
+	SellerName          string `description:"销售名称"`
+	CreateTime          string `description:"创建时间"`
+	ApprovalTime        string `description:"提交申请时间"`
+	ApproveTime         string `description:"审批时间"`
+	Status              string `description:"客户状态"`
+	ApproveContent      string `description:"待审内容"`
+	ApproveStatus       string `description:"当前状态"`
+	ApplyMethod         int    `description:"申请类型:申请类型:1:试用->正式,2:冻结—>试用,3:试用延期,4:原销售申请领取流失客户,5:正式客户申请服务更新"`
+	ApplyReasons        string `description:"申请理由"`
+	FreezeStartDate     string `description:"冻结开始日期"`
+	FreezeEndDate       string `description:"冻结结束日期"`
+	FreezeExpireDays    int    `description:"冻结到期天数"`
+	Address             string `description:"地址"`
+	Source              string `description:"客户来源"`
+	ApproveRemark       string `description:"驳回理由"`
+	StartDate           string `description:"开始日期"`
+	EndDate             string `description:"结束日期"`
+	ExpireDay           int    `description:"服务到期天数"`
+	CompanyApprovalId   int    `description:"审批记录ID"`
+	ApprovalCount       int    `description:"已延期审批次数"`
+	CompanyContractId   int    `description:"合同id"`
+	DelayPermission     string `description:"延期申请品种"`
+	ApplyRealName       string `description:"申请人姓名"`
+	ApproveRoleTypeCode string `description:"审批人角色类型",json:"-"`
+	OpButton            bool   `description:"是否审批操作权限"`
 }
 
 func GetApprovalList(condition string, pars []interface{}, startSize, pageSize int) (items []*CompanyApprovalList, err error) {
@@ -118,7 +120,7 @@ func GetApprovalList(condition string, pars []interface{}, startSize, pageSize i
 	sql := `SELECT a.company_id,b.product_id,a.company_name,a.credit_code,a.address,b.company_type,b.industry_name,
 			b.seller_name,b.create_time,b.freeze_start_date,b.freeze_end_date,b.source,c.create_time AS approval_time,c.approve_time,b.status,
             c.approve_content,c.approve_status,c.apply_method,c.apply_reasons,c.approve_remark,b.start_date,b.end_date,c.company_approval_id,c.company_contract_id,
-            c.apply_real_name
+            c.apply_real_name,c.approve_role_type_code
 			FROM company AS a
 			INNER JOIN company_product AS b ON a.company_id=b.company_id
 			INNER JOIN company_approval AS c ON b.company_id=c.company_id AND b.product_id=c.product_id
@@ -136,7 +138,7 @@ func GetApprovalListByApprovalId(condition string, pars []interface{}, companyAp
 	sql := `SELECT a.company_id,b.product_id,a.company_name,a.credit_code,a.address,b.company_type,b.industry_name,
 			b.seller_name,b.create_time,b.freeze_start_date,b.freeze_end_date,b.source,c.create_time AS approval_time,c.approve_time,b.status,
             c.approve_content,c.approve_status,c.apply_method,c.apply_reasons,c.approve_remark,b.start_date,b.end_date,c.company_approval_id,c.company_contract_id,
-            c.apply_real_name
+            c.apply_real_name,c.approve_role_type_code
 			FROM company AS a
 			INNER JOIN company_product AS b ON a.company_id=b.company_id
 			INNER JOIN company_approval AS c ON b.company_id=c.company_id AND b.product_id=c.product_id

+ 4 - 0
services/admin.go

@@ -127,6 +127,10 @@ func BindWxUser(openid, userName, password string, registerPlatform int) (adminW
 		}
 		return
 	}
+	if adminInfo.Enabled == 0 {
+		err = errors.New("您的账号已被禁用,如需登录,请联系管理员")
+		return
+	}
 
 	//获取用户信息
 	adminWx, err = admin.GetAdminWxById(adminInfo.AdminId)