Sfoglia il codice sorgente

调整项目目录结构,
添加:结算明细主表子表方法;财务账号、主从账号分页接口;充值账户添加绑定方法

jianglw 4 anni fa
parent
commit
5a1399653e

+ 3 - 3
model/account/settle_account_detail.go

@@ -24,9 +24,8 @@ type AppointInfo struct {
 
 // 结算明细前端请求
 type AppointInfoReq struct {
-	Appointment       *AppointInfo
-	SettleCountDetail int // 结算明细类型 1正常结算 2违规结算
-	SignOutTime       *gtime.Time
+	Appointment *AppointInfo
+	SignOutTime *gtime.Time
 }
 
 // 结算明细子表信息
@@ -50,6 +49,7 @@ type SearchEntity struct {
 	SignInTime         *gtime.Time `orm:"SignInTime"         json:"sign_in_time"`         // 签到时间
 	SignOutTime        *gtime.Time `orm:"SignOutTime"        json:"sign_out_time"`        // 签退时间
 	Reason             string      `orm:"Reason"             json:"reason"`               // 拒绝原因
+	UpdateAt           *gtime.Time `orm:"UpdatedAt"          json:"UpdateAt"`             // 更新时间
 }
 
 type SearchUser struct {

+ 7 - 0
model/base.go

@@ -22,3 +22,10 @@ type ListReq struct {
 	OrderBy
 	Entity interface{} `json:"entity"`
 }
+
+// 违约规则
+type ContractBreach struct {
+	MinPoint int
+	MaxPoint int
+	Persent  float64
+}

+ 7 - 10
model/user/base_user.go

@@ -52,16 +52,13 @@ type UserBindAccountReq struct {
 }
 
 type BaseUserInfo struct {
-	Id                    int         `orm:"Id,primary"            json:"id"`       //
-	Uuid                  string      `orm:"Uuid"                  json:"uuid"`     // 用户Id标识,不易猜出
-	AccCode               string      `orm:"AccCode"               json:"accCode"`  // 区分不同App的用户
-	Code                  string      `orm:"Code"                  json:"code"`     // 编码
-	UserName              string      `orm:"UserName"              json:"userName"` // 用户登录名
-	Realname              string      `orm:"Realname"              json:"realname"` // 用户名
-	RoleId                int         `orm:"RoleId"                json:"roleId"`   // 角色id
-	RoleInfo              string      `json:"roleInfo"`                             // 角色名称
-	AccountName           string      `json:"accountName"`                          // 账号名称
-	AccountId             int         `json:"accountId"`
+	Id                    int         `orm:"Id,primary"            json:"id"`                    //
+	Uuid                  string      `orm:"Uuid"                  json:"uuid"`                  // 用户Id标识,不易猜出
+	AccCode               string      `orm:"AccCode"               json:"accCode"`               // 区分不同App的用户
+	Code                  string      `orm:"Code"                  json:"code"`                  // 编码
+	UserName              string      `orm:"UserName"              json:"userName"`              // 用户登录名
+	Realname              string      `orm:"Realname"              json:"realname"`              // 用户名
+	RoleId                int         `orm:"RoleId"                json:"roleId"`                // 角色id
 	SecurityLevel         int         `orm:"SecurityLevel"         json:"securityLevel"`         //
 	UserFrom              string      `orm:"UserFrom"              json:"userFrom"`              //
 	CompanyId             string      `orm:"CompanyId"             json:"companyId"`             // 公司id

+ 19 - 3
service/account/account.go

@@ -69,6 +69,22 @@ func (s Service) SettleAccountList(req model.ListReq, info request.UserInfo) ([]
 
 // 新增结算明细主表、明细子表
 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
@@ -104,7 +120,7 @@ func (s Service) AddCountMainDetail(mobAppoint account.AppointInfoReq) error {
 		"AppointUserId": mobAppoint.Appointment.User.Id,
 		"AppointUser":   mobAppoint.Appointment.User.Realname,
 		"SettleStatus":  1,
-		"TotalPrice":    totalPrice,
+		"TotalPrice":    totalPrice * contractBreach,
 		"CreateUserId":  mobAppoint.Appointment.User.Id,
 		"CreateBy":      mobAppoint.Appointment.User.Realname,
 		"CreateOn":      now,
@@ -119,8 +135,8 @@ func (s Service) AddCountMainDetail(mobAppoint account.AppointInfoReq) error {
 			"pid":            id,
 			"UnitPrice":      unitCount,
 			"Minutes":        totalMinutes,
-			"PaymentType":    1,
-			"PaymentAccount": 1,
+			"PaymentType":    paymentType,
+			"PaymentAccount": totalPrice * contractBreach,
 			"CreateUserId":   mobAppoint.Appointment.User.Id,
 			"CreateBy":       mobAppoint.Appointment.User.Realname,
 			"CreateOn":       now,

+ 1 - 8
service/system/system.go

@@ -120,9 +120,7 @@ func (s Service) AddMainUserOrUser(req *user.AddMainOrSubReq, userInfo request.U
 		if req.ReqType == 1 { // 新增主用户
 			s.Dao.DB.Model("master_user").
 				Insert(g.Map{"UserId": v})
-		} else if req.ReqType == 2 { // 修改用户为从用户,并添加主从用户关系
-			//s.Dao.DB.Model("base_user").
-			//	Update("IsMain = 2", "Id = " + strconv.Itoa(v))
+		} else if req.ReqType == 2 { // 添加主从用户关系
 			// 添加主从用户关系表
 			saveEntity := user.BaseUserRelation{
 				UserId:    v,
@@ -159,11 +157,6 @@ func (s Service) DeleteMainUserOrSubUser(req *user.AddMainOrSubReq, info request
 		}
 		s.Dao.DB.Model("base_user_relation").Delete("UserId = ?", req.Id)
 	}
-	//s.Dao.DB.Model("base_user").
-	//	Update("IsMain = 0 and ModifiedOn = '"+ gtime.Now().String() +
-	//		"' and ModifiedUserId = "+ strconv.Itoa(int(info.Id)) +
-	//		" and ModifiedBy = '"+ info.RealName + "'", "Id = "+ strconv.Itoa(req.Id))
-
 	return nil
 }