Bläddra i källkod

feature(*): 主用户、从用户、财务账号功能完善

likai 4 år sedan
förälder
incheckning
4570c74e7b

+ 51 - 24
dao/account/internal/base_account.go

@@ -25,14 +25,23 @@ type BaseAccountDao struct {
 
 // BaseAccountColumns defines and stores column names for table base_account.
 type baseAccountColumns struct {
-	Id          string // 主键
-	Account     string // 账户
-	AccountName string // 账户名称
-	Surplus     string // 账户余额
-	Available   string // 可用余额
-	Limit       string // 使用限额
-	Advance     string // 优先级
-	DeletedAt   string
+	Id            string // 主键
+	Account       string // 账户
+	AccountName   string // 账户名称
+	Surplus       string // 账户余额
+	Available     string // 可用余额
+	Limit         string // 使用限额
+	Advance       string // 优先级
+	DeletedAt     string //
+	MainUserId    string // 主用户Id
+	MainUser      string // 主用户
+	Remark        string // 备注
+	CreateUserId  string //
+	CreateBy      string //
+	CreateOn      string //
+	UpdateUserId  string // 更新者ID
+	UpdateBy      string // 更新者
+	UpdateOn      string // 更新时间
 }
 
 var (
@@ -42,14 +51,23 @@ var (
 		DB:    g.DB("default"),
 		Table: "base_account",
 		Columns: baseAccountColumns{
-			Id:          "Id",
-			Account:     "Account",
-			AccountName: "AccountName",
-			Surplus:     "Surplus",
-			Available:   "Available",
-			Limit:       "Limit",
-			Advance:     "Advance",
-			DeletedAt:   "deletedAt",
+			Id:           "Id",
+			Account:      "Account",
+			AccountName:  "AccountName",
+			Surplus:      "Surplus",
+			Available:    "Available",
+			Limit:        "Limit",
+			Advance:      "Advance",
+			DeletedAt:    "DeletedAt",
+			MainUserId:   "MainUserId",
+			MainUser:     "MainUser",
+			Remark:       "Remark",
+			CreateUserId: "CreateUserId",
+			CreateBy:     "CreateBy",
+			CreateOn:     "CreateOn",
+			UpdateUserId: "UpdateUserId",
+			UpdateBy:     "UpdateBy",
+			UpdateOn:     "UpdateOn",
 		},
 	}
 )
@@ -61,14 +79,23 @@ func NewBaseAccountDao(tenant string) BaseAccountDao {
 		DB:    g.DB(tenant),
 		Table: "base_account",
 		Columns: baseAccountColumns{
-			Id:          "Id",
-			Account:     "Account",
-			AccountName: "AccountName",
-			Surplus:     "Surplus",
-			Available:   "Available",
-			Limit:       "Limit",
-			Advance:     "Advance",
-			DeletedAt:   "deletedAt",
+			Id:           "Id",
+			Account:      "Account",
+			AccountName:  "AccountName",
+			Surplus:      "Surplus",
+			Available:    "Available",
+			Limit:        "Limit",
+			Advance:      "Advance",
+			DeletedAt:    "DeletedAt",
+			MainUserId:   "MainUserId",
+			MainUser:     "MainUser",
+			Remark:       "Remark",
+			CreateUserId: "CreateUserId",
+			CreateBy:     "CreateBy",
+			CreateOn:     "CreateOn",
+			UpdateUserId: "UpdateUserId",
+			UpdateBy:     "UpdateBy",
+			UpdateOn:     "UpdateOn",
 		},
 	}
 	return dao

+ 5 - 45
handler/account.go

@@ -6,7 +6,6 @@ import (
 	"dashoo.cn/micro_libary/micro_srv"
 	"dashoo.cn/micro_libary/myerrors"
 	"github.com/gogf/gf/frame/g"
-	"lims_adapter/model"
 	account "lims_adapter/model/account"
 	service "lims_adapter/service/account"
 )
@@ -14,57 +13,18 @@ import (
 // 结算
 type Account struct{}
 
-// 结算明细分页  代码已弃用
-func (a *Account) SettleAccountList(ctx context.Context, req *model.ListReq, rsp *comm_def.CommonMsg) error {
-	tenant, err := micro_srv.GetTenant(ctx)
-	info, err := micro_srv.GetUserInfo(ctx)
-	if err != nil {
-		return err
-	}
-	g.Log().Info("Received Account.SettleAccountList request @ " + tenant)
-	if req.Size == 0 {
-		req.Size = DefaultPageNum
-	}
-	if req.Current < 0 {
-		req.Current = DefaultPageCurrent
-	}
-
-	var list, total, errors = service.NewSrv(tenant).SettleAccountList(*req, info)
-	_, err, code, msg := myerrors.CheckError(errors)
-	if err != nil {
-		return err
-	}
-
-	rsp.Code = code
-	rsp.Msg = msg
-	rsp.Data = g.Map{"total": total, "list": list}
-	return nil
-}
-
-// AddCountMainDetail 添加结算明细主表明细表  代码已弃用
-func (a *Account) AddCountMainDetail(ctx context.Context, req *account.AppointInfoReq, rsp *comm_def.CommonMsg) error {
+// AddAccount 添加财务账号
+func (a *Account) SaveAccount(ctx context.Context, req *account.BaseAccount, rsp *comm_def.CommonMsg) error {
 	tenant, err := micro_srv.GetTenant(ctx)
 	if err != nil {
 		return err
 	}
-	g.Log().Info("Received Account.AddCountMainDetail request @ " + tenant)
-	err = service.NewSrv(tenant).AddCountMainDetail(*req)
-	_, err, code, _ := myerrors.CheckError(err)
-	if err != nil {
-		return err
-	}
-	rsp.Code = code
-	return nil
-}
-
-// AddAccount 添加财务账号
-func (a *Account) AddAccount(ctx context.Context, req *account.BaseAccount, rsp *comm_def.CommonMsg) error {
-	tenant, err := micro_srv.GetTenant(ctx)
+	user, err := micro_srv.GetUserInfo(ctx)
 	if err != nil {
 		return err
 	}
 	g.Log().Info("Received Account.AddAccount request @ " + tenant)
-	err = service.NewSrv(tenant).AddAccount(req)
+	err = service.NewAccountSrv(tenant).Save(req, user)
 	_, err, code, _ := myerrors.CheckError(err)
 	if err != nil {
 		rsp.Code = code
@@ -82,7 +42,7 @@ func (a *Account) AccountList(ctx context.Context, req *account.AccountReq, rsp
 		return err
 	}
 	g.Log().Info("Received Account.AccountList request @ " + tenant)
-	list, err := service.NewSrv(tenant).AccountList(req)
+	list, err := service.NewAccountSrv(tenant).AccountList(req)
 	_, err, code, _ := myerrors.CheckError(err)
 	if err != nil {
 		rsp.Code = code

+ 4 - 4
model/account/base_account.go

@@ -16,9 +16,9 @@ type BaseAccountResp struct {
 	Id          int    `orm:"Id,primary"             json:"id"`          // 主键
 	Account     string `orm:"Account"                json:"account"`     // 账户
 	AccountName string `orm:"AccountName"            json:"accountName"` // 账户名称
-	Surplus     int    `orm:"Surplus"                json:"surplus"`     // 账户余额
-	Available   int    `orm:"Available"              json:"available"`   // 可用余额
-	Limit       int    `orm:"Limit"                  json:"limit"`       // 使用限额
+	Surplus     float64    `orm:"Surplus"                json:"surplus"`     // 账户余额
+	Available   float64    `orm:"Available"              json:"available"`   // 可用余额
+	Limit       float64    `orm:"Limit"                  json:"limit"`       // 使用限额
 	Advance     int    `orm:"Advance"                json:"advance"`     // 优先级
 	UserId      int    `orm:"UserId"                 json:"userId"`      // 使用人Id
 	RealName    string `orm:"RealName"               json:"realName"`
@@ -33,6 +33,6 @@ type AccountReq struct {
 }
 
 type BaseAccountRsp struct {
-	Records []BaseAccountResp `json:"records"`
+	Records []BaseAccount `json:"records"`
 	Total   int               `json:"total"`
 }

+ 17 - 8
model/account/internal/base_account.go

@@ -8,12 +8,21 @@ import "github.com/gogf/gf/os/gtime"
 
 // BaseAccount is the golang structure for table base_account.
 type BaseAccount struct {
-	Id          int         `orm:"Id,primary"             json:"id"`          // 主键
-	Account     string      `orm:"Account"                json:"account"`     // 账户
-	AccountName string      `orm:"AccountName"            json:"accountName"` // 账户名称
-	Surplus     float64     `orm:"Surplus"                json:"surplus"`     // 账户余额
-	Available   float64     `orm:"Available"              json:"available"`   // 可用余额
-	Limit       float64     `orm:"Limit"                  json:"limit"`       // 使用限额
-	Advance     int         `orm:"Advance"                json:"advance"`     // 优先级
-	DeletedAt   *gtime.Time `orm:"DeletedAt"              json:"deletedAt"`
+	Id           int         `orm:"Id,primary"   json:"id"`             // 主键
+	Account      string      `orm:"Account"      json:"account"`        // 账户
+	AccountName  string      `orm:"AccountName"  json:"account_name"`   // 账户名称
+	Surplus      float64     `orm:"Surplus"      json:"surplus"`        // 账户余额
+	Available    float64     `orm:"Available"    json:"available"`      // 可用余额
+	Limit        float64     `orm:"Limit"        json:"limit"`          // 使用限额
+	Advance      int         `orm:"Advance"      json:"advance"`        // 优先级
+	DeletedAt    *gtime.Time `orm:"DeletedAt"    json:"deleted_at"`     //
+	MainUserId   int         `orm:"MainUserId"   json:"main_user_id"`   // 主用户Id
+	MainUser     string      `orm:"MainUser"     json:"main_user"`      // 主用户
+	Remark       string      `orm:"Remark"       json:"remark"`         // 备注
+	CreateUserId int         `orm:"CreateUserId" json:"create_user_id"` //
+	CreateBy     string      `orm:"CreateBy"     json:"create_by"`      //
+	CreateOn     *gtime.Time `orm:"CreateOn"     json:"create_on"`      //
+	UpdateUserId int         `orm:"UpdateUserId" json:"update_user_id"` // 更新者ID
+	UpdateBy     string      `orm:"UpdateBy"     json:"update_by"`      // 更新者
+	UpdateOn     *gtime.Time `orm:"UpdateOn"     json:"update_on"`      // 更新时间
 }

+ 2 - 0
model/user/base_user.go

@@ -32,6 +32,7 @@ type UserInfoReq struct {
 	UserName     string `json:"user_name"`
 	Mobile       string `json:"mobile"`
 	ReqType      int    `json:"req_type"` // 请求类型 设备预约(1:预约资格 2:优先预约权) 主从用户管理(1:主用户查询 2:从用户查询)
+	IsSelf       string `json:"isSelf"`
 }
 type UserInfoRsp struct {
 	Records []BaseUserInfo `json:"records"`
@@ -120,4 +121,5 @@ type BaseUserInfo struct {
 	UnitId                int         `orm:"UnitId"                json:"unitId"`                // 二级单位ID(供方字段用)
 	Unit                  string      `orm:"Unit"                  json:"unit"`                  //
 	DeletedAt             *gtime.Time `orm:"DeletedAt"             json:"deletedAt"`             // 删除时间
+	MasterId              int         `orm:"MasterId"              json:"master_id"`             // 主用户Id
 }

+ 21 - 151
service/account/account.go

@@ -2,13 +2,9 @@ package account
 
 import (
 	"dashoo.cn/micro_libary/request"
-	"database/sql"
-	"errors"
-	"github.com/gogf/gf/frame/g"
+	"fmt"
 	"github.com/gogf/gf/os/gtime"
-	"github.com/gogf/gf/util/gconv"
 	dao "lims_adapter/dao/account"
-	"lims_adapter/model"
 	account "lims_adapter/model/account"
 	"strconv"
 )
@@ -24,176 +20,50 @@ type AccountService struct {
 	Tenant string
 }
 
-// NewSrv 服务初始化
-func NewSrv(tenant string) Service {
-	return Service{Dao: dao.NewSettleAccountMainDao(tenant), Tenant: tenant}
-}
-
 func NewAccountSrv(tenant string) AccountService {
 	return AccountService{Dao: dao.NewBaseAccountDao(tenant), Tenant: tenant}
 }
 
-// 结算明细分页  代码已弃用
-func (s Service) SettleAccountList(req model.ListReq, info request.UserInfo) ([]account.SettleAccountMain, int, error) {
-	entityModel := s.Dao.DB.Model("settle_account_main s").
-		LeftJoin("appointment a", "s.AppointId = a.Id").
-		LeftJoin("Instrument i").
-		Fields("s.Id, s.BillId, s.AppointUser, s.MainUser, s.FeeType, s.TotalPrice, ").
-		Where("MainUserId = ?", info.Id)
-	if req.Entity != nil {
-		entity := new(account.SettleAccountMainReq)
-		gconv.Struct(req.Entity, entity)
-		//if strconv.Itoa(entity.AppointUserId) != "" {
-		//	entityModel = entityModel.WhereLike(s.Dao.Columns.AppointUserId, "%"+strconv.Itoa(entity.AppointUserId)+"%")
-		//}
-		//if strconv.Itoa(entity.RelevanceId) != "" {
-		//	entityModel = entityModel.WhereLike("RelevanceId", "%"+strconv.Itoa(entity.RelevanceId)+"%")
-		//}
-	}
-	total, err := entityModel.Count()
-	if err != nil {
-		return nil, 0, err
-	}
-	if total == 0 {
-		return nil, 0, nil
-	}
-	return nil, 0, nil
-	res, err := entityModel.Page(req.Current, req.Size).FindAll()
-	if err != nil {
-		return nil, 0, err
-	}
-	list := make([]account.SettleAccountMain, 0)
-	res.Structs(&list)
-	return list, total, nil
-}
-
-// 新增结算明细主表、明细子表  代码已弃用
-func (s Service) AddCountMainDetail(mobAppoint account.AppointInfoReq) error {
-	contractBreach := 1.0
-	paymentType := 1
-	// TODO 如果是已取消预约,则计算违约费用
-	if mobAppoint.Appointment.Appoint.Status == 4 {
-		contractBreachEntity := model.ContractBreach{}
-		// 计算取消时间与实验开始时间差,选择相应违约规则
-		startTime := mobAppoint.Appointment.Appoint.StartTime
-		cancelTime := mobAppoint.Appointment.Appoint.UpdateAt
-		totalMinute := (startTime.Hour()-cancelTime.Hour())*60 + (startTime.Minute() - cancelTime.Minute())
-		if err := s.Dao.DB.Model("contract_breach").
-			Where("MinPoint <= ? and MaxPoint >= ?", totalMinute, totalMinute).Scan(&contractBreachEntity); err != nil {
-			return err
-		}
-		contractBreach = contractBreachEntity.Persent
-		paymentType = 2
-	}
-	// 通过设备、用户查询优惠状态
-	var result account.AppointInfo
-	isDiscount := false
-	err := s.Dao.DB.Model("base_equipment_qualification").Fields("Qualification as IsPreferential").
-		Where("EquipmentId = " + strconv.Itoa(mobAppoint.Appointment.Instr.Id) + " and Qualification = 3 " +
-			" and UserId = " + strconv.Itoa(mobAppoint.Appointment.User.Id)).Scan(&result.User)
-	// 如果没有数据,则没有权限
-	if err == sql.ErrNoRows {
-		// TODO
-	} else {
-		if result.User.IsPreferential == "3" {
-			isDiscount = true
-		}
-	}
-	// 计算实际实验时长、费用,目前为一条明细子表数据,后期可能扩展为多条数据子表数据
-	totalMinutes := 0.0
-	//signInTime := mobAppoint.Appointment.Appoint.SignInTime
-	//hour := mobAppoint.SignOutTime.Hour() - signInTime.Hour()
-	//minute := mobAppoint.SignOutTime.Minute() - signInTime.Minute()
-	//totalMinute += hour * 60 + minute
-	totalMinutes += mobAppoint.Appointment.Appoint.RealityUseDuration * 60
-	unitCount := float64(mobAppoint.Appointment.Instr.UnitCount)
-	// 有优惠权,则按照优惠计费
-	if isDiscount {
-		unitCount = unitCount * float64(mobAppoint.Appointment.Instr.UnitCount) / 100
-	}
-	totalPrice := totalMinutes / 60 * unitCount
-
-	// 生成结算明细主表
+// AddAccount 添加财务账号
+func (s AccountService) Save(req *account.BaseAccount, user request.UserInfo) error {
 	now := gtime.Now()
-	var mainEntity = g.Map{
-		"AppointId":     mobAppoint.Appointment.Appoint.Id,
-		"AppointUserId": mobAppoint.Appointment.User.Id,
-		"AppointUser":   mobAppoint.Appointment.User.Realname,
-		"SettleStatus":  1,
-		"TotalPrice":    totalPrice * contractBreach,
-		"CreateUserId":  mobAppoint.Appointment.User.Id,
-		"CreateBy":      mobAppoint.Appointment.User.Realname,
-		"CreateOn":      now,
-	}
-	id, err := s.Dao.DB.Model("settle_account_main").InsertAndGetId(mainEntity)
-	if err != nil {
-		return err
-	} else {
-		// 生成结算明细子表
-		// TODO 判断正常支出或是违约
-		var detailEntity = g.Map{
-			"pid":            id,
-			"UnitPrice":      unitCount,
-			"Minutes":        totalMinutes,
-			"PaymentType":    paymentType,
-			"PaymentAccount": totalPrice * contractBreach,
-			"CreateUserId":   mobAppoint.Appointment.User.Id,
-			"CreateBy":       mobAppoint.Appointment.User.Realname,
-			"CreateOn":       now,
-		}
-		_, err := s.Dao.DB.Model("settle_account_detail").Insert(detailEntity)
-		if err != nil {
-			return err
-		}
-	}
-	return nil
-}
+	if req.Id == 0 {
+		req.CreateUserId = int(user.Id)
+		req.CreateBy = user.RealName
+		req.CreateOn = now
+	}
+	req.UpdateUserId = int(user.Id)
+	req.UpdateBy = user.RealName
+	req.UpdateOn = now
 
-// AddAccount 添加财务账号
-func (s Service) AddAccount(req *account.BaseAccount) error {
-	count, err := s.Dao.DB.Model("base_account").Where("Account = ?", req.Account).Count()
-	if err != nil {
-		return err
-	}
-	if count > 0 {
-		return errors.New("该账号已存在,请重新输入!")
-	}
-	_, err = s.Dao.DB.Model("base_account").Insert(req)
-	if err != nil {
-		return err
-	}
-	return nil
+	_, err := s.Dao.Save(req)
+	return err
 }
 
 // AccountList 财务账号分页查询
-func (s Service) AccountList(req *account.AccountReq) (infos account.BaseAccountRsp, err error) {
+func (s AccountService) AccountList(req *account.AccountReq) (infos account.BaseAccountRsp, err error) {
 	current := req.PageNun
 	size := req.PageSize
-	model := s.Dao.DB.Model("base_account a").
-		LeftJoin("user_account_bind b", "a.Id = b.AccountId").
-		LeftJoin("base_user c", "b.UserId = c.Id")
+	model := s.Dao.DB.Model("base_account a")
 	if req.Account != "" {
-		model = model.WhereLike("Account", req.Account)
+		model = model.WhereLike("Account", "%" + req.Account + "%")
 	}
 	if req.RealName != "" {
-		model = model.WhereLike("RealName", req.RealName)
+		model = model.WhereLike("MainUser", "%" + req.RealName + "%")
 	}
 	if req.AccountName != "" {
-		model = model.Where("AccountName", req.AccountName)
+		model = model.WhereLike("AccountName", "%" + req.AccountName + "%")
 	}
 	infos.Total, err = model.Count()
 	if err != nil {
 		return infos, err
 	}
-	err = model.Fields("a.Id, a.Account,a.AccountName,A.Surplus,a.Available,a.Limit,a.Advance,c.Id UserId,c.RealName").Page(current, size).Scan(&infos.Records)
+	err = model.Fields("a.*").Page(current, size).Scan(&infos.Records)
 	return infos, nil
 }
 
 // DepositAccount 充值账户
 func (s AccountService) DepositAccount(req *account.BaseAccountResp) error {
-	_, err := s.Dao.M.Update("Surplus = "+strconv.Itoa(req.Surplus), "Id = "+strconv.Itoa(req.Id))
-	if err != nil {
-		return err
-	}
-	return nil
+	_, err := s.Dao.M.Update(fmt.Sprintf("Surplus='%v',Available='%v'", req.Surplus, req.Available), "Id = "+strconv.Itoa(req.Id))
+	return err
 }

+ 27 - 11
service/system/system.go

@@ -84,24 +84,26 @@ func (s Service) GetUserList(req *user.UserInfoReq, userId int32) (userInfos use
 	current := req.PageNun
 	size := req.PageSize
 	count := 0
-	model := s.Dao.DB.Model("base_user a").LeftJoin("base_role b", "a.RoleId = b.Id").
-		LeftJoin("user_account_bind c", "a.Id = c.UserId").
-		LeftJoin("base_account d", "c.AccountId = d.Id")
+	fields := "a.Id, a.UserName, a.RealName, a.Mobile, a.DepartmentName"
+	model := s.Dao.DB.Model("base_user a")
 	if departmentId != "" && departmentId != "0" {
 		where += " and DepartmentId = " + departmentId
 	}
 	if req.UserName != "" {
-		where += " and a.UserName = '" + req.UserName + "' or a.RealName = '" + req.UserName + "'"
+		where += " and (a.UserName LIKE '%" + req.UserName + "%' or a.RealName LIKE '%" + req.UserName + "%')"
 	}
 	if req.Mobile != "" {
-		where += " and a.Mobile = '" + req.Mobile + "'"
+		where += " and a.Mobile LIKE '%" + req.Mobile + "%'"
 	}
 	if req.ReqType == 1 { // 获取主用户信息
-		count, err = model.LeftJoin("master_user e", "a.Id = e.UserId ").
-			Where(where + " and e.Id is not null").Count()
+		count, err = model.InnerJoin("master_user e", "a.Id = e.UserId ").Where(where + " and e.Id is not null").Count()
 	} else if req.ReqType == 2 { // 从用户信息
-		count, err = model.LeftJoin("base_user_relation e", "a.Id = e.UserId").
-			Where(where + " and e.Pid = " + strconv.Itoa(int(userId))).Count()
+		if req.IsSelf == "1" {
+			count, err = model.InnerJoin("base_user_relation e", "a.Id = e.UserId").Where(where).Count()
+		} else {
+			count, err = model.InnerJoin("base_user_relation e", "a.Id = e.UserId").Where(where + " and e.Pid = " + strconv.Itoa(int(userId))).Count()
+		}
+		fields = "a.Id, a.UserName, a.RealName, a.Mobile, a.DepartmentName,e.Pid AS MasterId"
 	} else if req.ReqType == 3 { // 不是主从用户信息
 		count, err = model.Where(where + " and a.Id not in (select UserId from master_user) and a.Id not in (select UserId from base_user_relation)").Count()
 	}
@@ -109,7 +111,7 @@ func (s Service) GetUserList(req *user.UserInfoReq, userId int32) (userInfos use
 		return userInfos, err
 	}
 	userInfos.Total = count
-	err = model.Fields("a.Id, a.UserName, a.RealName, a.Mobile, a.DepartmentName, b.RealName as RoleInfo, d.AccountName, d.Id AccountId").Page(current, size).Scan(&userInfos.Records)
+	err = model.Fields(fields).Page(current, size).Scan(&userInfos.Records)
 	return userInfos, nil
 }
 
@@ -155,6 +157,20 @@ func (s Service) DeleteMainUserOrSubUser(req *user.AddMainOrSubReq, info request
 		if count > 0 {
 			return errors.New("该用户有从用户,无法删除!")
 		}
+		count, err = s.Dao.DB.Model("settle_account_main").Where("AppointUserId = " + strconv.Itoa(req.Id) + " and SettleStatus = 0").Count()
+		if err != nil {
+			return err
+		}
+		if count > 0 {
+			return errors.New("该用户有未结账明细,无法删除!")
+		}
+		count, err = s.Dao.DB.Model("settle_account_bill").Where("MainUserId = " + strconv.Itoa(req.Id) + " and Status = 0").Count()
+		if err != nil {
+			return err
+		}
+		if count > 0 {
+			return errors.New("该用户有未结账账单,无法删除!")
+		}
 		_, err = s.Dao.DB.Model("master_user").Delete("UserId = ?", req.Id)
 		if err != nil {
 			return err
@@ -162,7 +178,7 @@ func (s Service) DeleteMainUserOrSubUser(req *user.AddMainOrSubReq, info request
 		_, err = s.Dao.DB.Model("base_user_relation").Delete("Pid = ?", req.Id)
 		return err
 	} else if req.ReqType == 2 { // 删除从用户 先判断是否有未结账
-		count, err := s.Dao.DB.Model("settle_account_main").Where("AppointUserId = " + strconv.Itoa(req.Id) + " and SettleStatus = 1").Count()
+		count, err := s.Dao.DB.Model("settle_account_main").Where("AppointUserId = " + strconv.Itoa(req.Id) + " and SettleStatus = 0").Count()
 		if err != nil {
 			return err
 		}