Explorar o código

Merge branch 'aj_business_trip'

tuoling805 %!s(int64=2) %!d(string=hai) anos
pai
achega
bc34650511

+ 7 - 0
controllers/admin.go

@@ -78,6 +78,13 @@ func (c *AdminCommon) Login() {
 	resp.ProductName = productName
 	resp.Authority = adminWx.Authority
 	resp.Headimgurl = adminWx.Headimgurl
+	if adminWx.AdminId == 66 {
+		resp.IsBusinessTrip = true
+	}
+
+	if adminWx.RoleTypeCode == "rai_seller" || adminWx.RoleTypeCode == "rai_group" || adminWx.RoleTypeCode == "rai_admin" {
+		resp.IsRai = true
+	}
 	c.OkDetailed(resp, "登录成功")
 }
 

+ 680 - 0
controllers/business_trip/business_apply.go

@@ -0,0 +1,680 @@
+package business_trip
+
+import (
+	"encoding/json"
+	"fmt"
+	"github.com/rdlucklib/rdluck_tools/paging"
+	"hongze/hongze_mobile_admin/controllers"
+	"hongze/hongze_mobile_admin/models/tables/admin"
+	"hongze/hongze_mobile_admin/models/tables/business_trip"
+	"hongze/hongze_mobile_admin/models/tables/company_approval_message"
+	"hongze/hongze_mobile_admin/services"
+	"hongze/hongze_mobile_admin/utils"
+	"strconv"
+	"strings"
+	"time"
+)
+
+// 出差
+type BusinessTrip struct {
+	controllers.BaseAuth
+}
+
+// @Title 出差申请接口
+// @Description 出差申请接口
+// @Param	request	body business_trip.BusinessApplyReq true "type json string"
+// @Success Ret=200 保存成功
+// @router /apply/add [post]
+func (this *BusinessTrip) ApplyAdd() {
+	sysUser := this.AdminWx
+	sysUserId := sysUser.AdminId
+	var req business_trip.BusinessApplyReq
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		this.FailWithMessage("解析参数失败", "解析参数失败,Err:"+err.Error())
+		return
+	}
+
+	if req.ArriveDate == "" {
+		this.FailWithMessage("请填写到达日期", "请填写到达日期")
+		return
+	}
+
+	if req.ReturnDate == "" {
+		this.FailWithMessage("请填写返程日期", "请填写返程日期")
+		return
+	}
+
+	if req.Province == "" {
+		this.FailWithMessage("请填写目的地省", "请填写目的地省")
+		return
+	}
+
+	if req.City == "" {
+		this.FailWithMessage("请填写目的地市", "请填写目的地市")
+		return
+	}
+
+	if req.Reason == "" {
+		this.FailWithMessage("请填写出差事由", "请填写出差事由")
+		return
+	}
+
+	if req.Transportation == "" {
+		this.FailWithMessage("请填写交通工具", "请填写交通工具")
+		return
+	}
+
+	startP, _ := time.ParseInLocation(utils.FormatDate, req.ArriveDate, time.Local)
+	endP, _ := time.ParseInLocation(utils.FormatDate, req.ReturnDate, time.Local)
+	nowDate, _ := time.ParseInLocation(utils.FormatDate, time.Now().Format(utils.FormatDate), time.Local)
+
+	if startP.Before(nowDate) {
+		this.FailWithMessage("出差开始日期不能小于当前日期", "出差开始日期不能小于当前日期")
+		return
+	}
+
+	if !endP.Equal(nowDate) && endP.Before(nowDate) {
+		this.FailWithMessage("出差结束时间不能小于当前时间", "出差结束时间不能小于当前时间")
+		return
+	}
+
+	if !startP.Equal(endP) && (startP.After(endP) || startP.Equal(endP)) {
+		this.FailWithMessage("出差开始日期应小于结束日期", "出差开始日期应小于结束日期")
+		return
+	}
+
+	//校验出差日期冲突
+	{
+		businessApplyCount, err := business_trip.CheckBusinessApplyDate(req.ArriveDate, req.ReturnDate, "'待审批','已审批'", sysUser.AdminId, 0)
+		if err != nil {
+			this.FailWithMessage("时间冲突检测失败", "时间冲突检测失败-CheckBusinessApplyDate!Err:"+err.Error())
+			return
+		}
+		if businessApplyCount > 0 {
+			this.FailWithMessage("日期已被占用", "日期已被占用-CheckBusinessApplyDate!")
+			return
+		}
+	}
+
+	//校验申请人,是否被邀请为同行人,并且出差日期冲突
+	{
+		peerCount, err := business_trip.CheckBusinessApplyPeerDate(req.ArriveDate, req.ReturnDate, "'待审批','已审批'", sysUser.AdminId, 0)
+		if err != nil {
+			this.FailWithMessage("时间冲突检测失败", "时间冲突检测失败-CheckBusinessApplyPeerDate!Err:"+err.Error())
+			return
+		}
+		if peerCount > 0 {
+			this.FailWithMessage("所选日期您被设置为同行人,请重新选择!", "所选日期您被设置为同行人,请重新选择!")
+			return
+		}
+	}
+
+	//校验同行人,出差日期冲突
+	{
+		if req.PeerPeopleId != "" {
+			var existPeerNameArr []string
+
+			peerIdArr := strings.Split(req.PeerPeopleId, ",")
+			peerNameArr := strings.Split(req.PeerPeopleName, ",")
+
+			for k, v := range peerIdArr {
+				peerId, err := strconv.Atoi(v)
+				if err != nil {
+					this.FailWithMessage("申请失败", "同行人id失败,Err:"+err.Error())
+					return
+				}
+
+				peerCount, err := business_trip.CheckBusinessApplyPeerDate(req.ArriveDate, req.ReturnDate, "'待审批','已审批'", peerId, 0)
+				if err != nil {
+					this.FailWithMessage("时间冲突检测失败", "时间冲突检测失败-CheckBusinessApplyPeerDate!Err:"+err.Error())
+					return
+				}
+				if peerCount > 0 {
+					existPeerNameArr = append(existPeerNameArr, peerNameArr[k])
+				}
+			}
+
+			if len(existPeerNameArr) > 0 {
+				this.FailWithMessage(strings.Join(existPeerNameArr, ",")+"日期已被占用", "日期已被占用-CheckBusinessApplyDate!")
+				return
+			}
+		}
+	}
+
+	approveItem, err := admin.GetAdminById(66)
+	if err != nil {
+		this.FailWithMessage("获取审批人信息失败", "获取审批人信息失败,Err:"+err.Error())
+		return
+	}
+	item := new(business_trip.BusinessApply)
+	item.ApplyAdminId = sysUser.AdminId
+	item.ApplyRealName = sysUser.RealName
+	item.ArriveDate = req.ArriveDate
+	item.ReturnDate = req.ReturnDate
+	item.Province = req.Province
+	item.City = req.City
+	item.Reason = req.Reason
+	item.Transportation = req.Transportation
+	item.PeerPeopleId = req.PeerPeopleId
+	item.PeerPeopleName = req.PeerPeopleName
+	item.Status = "待审批"
+	item.ApproveId = approveItem.AdminId
+	item.ApproveName = approveItem.RealName
+	item.CreateTime = time.Now()
+	item.ModifyTime = time.Now()
+	applyId, err := business_trip.AddBusinessApply(item)
+	if err != nil {
+		this.FailWithMessage("申请失败", "申请失败,Err:"+err.Error())
+		return
+	}
+
+	//新增随行人
+	{
+		if req.PeerPeopleId != "" {
+			peerList := make([]*business_trip.BusinessApplyPeer, 0)
+			peerIdArr := strings.Split(req.PeerPeopleId, ",")
+			peerNameArr := strings.Split(req.PeerPeopleName, ",")
+			for k, v := range peerIdArr {
+				peerId, err := strconv.Atoi(v)
+				if err != nil {
+					this.FailWithMessage("申请失败", "同行人id失败,Err:"+err.Error())
+					return
+				}
+				peerItem := new(business_trip.BusinessApplyPeer)
+				peerItem.BusinessApplyId = int(applyId)
+				peerItem.ArriveDate = req.ArriveDate
+				peerItem.ReturnDate = req.ReturnDate
+				peerItem.Province = req.Province
+				peerItem.City = req.City
+				peerItem.Status = "待审批"
+				peerItem.PeerPeopleId = peerId
+				peerItem.PeerPeopleName = peerNameArr[k]
+				peerItem.CreateTime = time.Now()
+				peerItem.ModifyTime = time.Now()
+				peerList = append(peerList, peerItem)
+			}
+			err = business_trip.AddBusinessApplyPeer(peerList)
+			if err != nil {
+				this.FailWithMessage("申请失败", "新增同行人信息失败,Err:"+err.Error())
+				return
+			}
+		}
+	}
+
+	{
+		//系统消息
+		sourceType := 10
+		content := sysUser.RealName + " " + req.Province + req.City + req.Reason + "出差申请"
+		go services.AddCompanyApprovalMessage(sysUserId, approveItem.AdminId, 0, int(applyId), 1, sourceType, 1, "", content, content, "", "")
+	}
+
+	//模板消息
+	{
+		var wxAppPath string
+		if utils.RunMode == "debug" {
+			wxAppPath = "pages/index/index"
+		} else {
+			wxAppPath = "pages-approve/businessTrip/detail?id=" + strconv.Itoa(int(applyId))
+		}
+
+		first := "您好,有新的申请待处理"
+		keyword1 := sysUser.RealName
+		keyword2 := "--" //sysUser.Mobile
+		keyword3 := time.Now().Format(utils.FormatDateTime)
+		var keyword4 string
+		if req.PeerPeopleId != "" {
+			keyword4 = req.ArriveDate + "至" + req.ReturnDate + "," + req.Transportation + "前往" + req.Province + req.City + "," + "同行人" + req.PeerPeopleName
+		} else {
+			keyword4 = req.ArriveDate + "至" + req.ReturnDate + "," + req.Transportation + "前往" + req.Province + req.City
+		}
+		remark := "请尽快完成审批"
+		go services.SendWxMsgWithRoadshowPending(first, keyword1, keyword2, keyword3, keyword4, remark, wxAppPath, approveItem.Mobile)
+	}
+	this.OkWithMessage("保存成功")
+}
+
+// @Title 出差重新申请接口
+// @Description 出差重新申请接口
+// @Param	request	body business_trip.BusinessApplyEditReq true "type json string"
+// @Success Ret=200 保存成功
+// @router /apply/edit [post]
+func (this *BusinessTrip) ApplyEdit() {
+	sysUser := this.AdminWx
+	sysUserId := sysUser.AdminId
+
+	var req business_trip.BusinessApplyEditReq
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		this.FailWithMessage("解析参数失败", "解析参数失败,Err:"+err.Error())
+		return
+	}
+
+	if req.ArriveDate == "" {
+		this.FailWithMessage("请填写到达日期", "请填写到达日期")
+		return
+	}
+
+	if req.ReturnDate == "" {
+		this.FailWithMessage("请填写返程日期", "请填写返程日期")
+		return
+	}
+
+	if req.Province == "" {
+		this.FailWithMessage("请填写目的地省", "请填写目的地省")
+		return
+	}
+
+	if req.City == "" {
+		this.FailWithMessage("请填写目的地市", "请填写目的地市")
+		return
+	}
+
+	if req.Reason == "" {
+		this.FailWithMessage("请填写出差事由", "请填写出差事由")
+		return
+	}
+
+	if req.Transportation == "" {
+		this.FailWithMessage("请填写交通工具", "请填写交通工具")
+		return
+	}
+
+	startP, _ := time.ParseInLocation(utils.FormatDate, req.ArriveDate, time.Local)
+	endP, _ := time.ParseInLocation(utils.FormatDate, req.ReturnDate, time.Local)
+	nowDate, _ := time.ParseInLocation(utils.FormatDate, time.Now().Format(utils.FormatDate), time.Local)
+
+	if startP.Before(nowDate) {
+		fmt.Println("出差开始日期不能小于当前日期!")
+		return
+	}
+
+	if !endP.Equal(nowDate) && endP.Before(nowDate) {
+		fmt.Println("出差结束时间不能小于当前时间!")
+		return
+	}
+
+	if !startP.Equal(endP) && (startP.After(endP) || startP.Equal(endP)) {
+		fmt.Println("出差开始日期应小于结束日期!")
+		return
+	}
+
+	//校验出差日期冲突
+	{
+		businessApplyCount, err := business_trip.CheckBusinessApplyDate(req.ArriveDate, req.ReturnDate, "'待审批','已审批'", sysUser.AdminId, req.BusinessApplyId)
+		if err != nil {
+			this.FailWithMessage("时间冲突检测失败", "时间冲突检测失败-CheckBusinessApplyDate!Err:"+err.Error())
+			return
+		}
+		if businessApplyCount > 0 {
+			this.FailWithMessage("日期已被占用", "日期已被占用-CheckBusinessApplyDate!")
+			return
+		}
+	}
+
+	//校验申请人,是否被邀请为同行人,并且出差日期冲突
+	{
+		peerCount, err := business_trip.CheckBusinessApplyPeerDate(req.ArriveDate, req.ReturnDate, "'待审批','已审批'", sysUser.AdminId, 0)
+		if err != nil {
+			this.FailWithMessage("时间冲突检测失败", "时间冲突检测失败-CheckBusinessApplyPeerDate!Err:"+err.Error())
+			return
+		}
+		if peerCount > 0 {
+			this.FailWithMessage("所选日期您被设置为同行人,请重新选择!", "所选日期您被设置为同行人,请重新选择!")
+			return
+		}
+	}
+
+	//校验同行人,出差日期冲突
+	{
+		if req.PeerPeopleId != "" {
+			var existPeerNameArr []string
+
+			peerIdArr := strings.Split(req.PeerPeopleId, ",")
+			peerNameArr := strings.Split(req.PeerPeopleName, ",")
+
+			for k, v := range peerIdArr {
+				peerId, err := strconv.Atoi(v)
+				if err != nil {
+					this.FailWithMessage("申请失败", "同行人id失败,Err:"+err.Error())
+					return
+				}
+
+				peerCount, err := business_trip.CheckBusinessApplyPeerDate(req.ArriveDate, req.ReturnDate, "'待审批','已审批'", peerId, req.BusinessApplyId)
+				if err != nil {
+					this.FailWithMessage("时间冲突检测失败", "时间冲突检测失败-CheckBusinessApplyPeerDate!Err:"+err.Error())
+					return
+				}
+				if peerCount > 0 {
+					existPeerNameArr = append(existPeerNameArr, peerNameArr[k])
+				}
+			}
+
+			if len(existPeerNameArr) > 0 {
+				this.FailWithMessage(strings.Join(existPeerNameArr, ",")+"日期已被占用", "日期已被占用-CheckBusinessApplyDate!")
+				return
+			}
+		}
+	}
+
+	if req.BusinessApplyId <= 0 {
+		this.FailWithMessage("参数错误", "参数错误!BusinessApplyId:"+strconv.Itoa(req.BusinessApplyId))
+		return
+	}
+	businessApplyItem, err := business_trip.GetBusinessApplyById(req.BusinessApplyId)
+	if err != nil {
+		if err.Error() == utils.ErrNoRow() {
+			this.FailWithMessage("出差申请已被删除,请刷新页面", "出差申请已被删除,请刷新页面")
+			return
+		}
+		this.FailWithMessage("获取数据失败!", "获取数据失败!GetBusinessApplyById:"+err.Error())
+		return
+	}
+
+	if businessApplyItem.Status == "已审批" {
+		this.FailWithMessage("已审批,不可进行重新申请操作!", "已审批,不可进行重新申请操作!")
+		return
+	} else if businessApplyItem.Status == "已过期" {
+		this.FailWithMessage("已过期,不可进行重新申请操作!", "已过期,不可进行重新申请操作!")
+		return
+	}
+
+	whereParams := make(map[string]interface{})
+	updateParams := make(map[string]interface{})
+
+	whereParams["business_apply_id"] = req.BusinessApplyId
+
+	updateParams["arrive_date"] = req.ArriveDate
+	updateParams["return_date"] = req.ReturnDate
+	updateParams["province"] = req.Province
+	updateParams["city"] = req.City
+	updateParams["reason"] = req.Reason
+	updateParams["transportation"] = req.Transportation
+	updateParams["peer_people_id"] = req.PeerPeopleId
+	updateParams["peer_people_name"] = req.PeerPeopleName
+	updateParams["status"] = "待审批"
+	updateParams["refuse_reason"] = ""
+	updateParams["create_time"] = time.Now()
+	updateParams["modify_time"] = time.Now()
+
+	err = business_trip.UpdateBusinessApply(whereParams, updateParams)
+	if err != nil {
+		this.FailWithMessage("重新申请失败", "重新申请失败,Err:"+err.Error())
+		return
+	}
+
+	//新增随行人
+	{
+		if req.PeerPeopleId != "" {
+
+			err = business_trip.DeleteBusinessApplyPeer(req.BusinessApplyId)
+			if err != nil {
+				this.FailWithMessage("申请失败", "删除同行人失败,Err:"+err.Error())
+				return
+			}
+			peerList := make([]*business_trip.BusinessApplyPeer, 0)
+			peerIdArr := strings.Split(req.PeerPeopleId, ",")
+			peerNameArr := strings.Split(req.PeerPeopleName, ",")
+			for k, v := range peerIdArr {
+				peerId, err := strconv.Atoi(v)
+				if err != nil {
+					this.FailWithMessage("申请失败", "同行人id失败,Err:"+err.Error())
+					return
+				}
+				peerItem := new(business_trip.BusinessApplyPeer)
+				peerItem.BusinessApplyId = req.BusinessApplyId
+				peerItem.ArriveDate = req.ArriveDate
+				peerItem.ReturnDate = req.ReturnDate
+				peerItem.Province = req.Province
+				peerItem.City = req.City
+				peerItem.Status = "待审批"
+				peerItem.PeerPeopleId = peerId
+				peerItem.PeerPeopleName = peerNameArr[k]
+				peerItem.CreateTime = time.Now()
+				peerItem.ModifyTime = time.Now()
+				peerList = append(peerList, peerItem)
+			}
+			err = business_trip.AddBusinessApplyPeer(peerList)
+			if err != nil {
+				this.FailWithMessage("申请失败", "新增同行人信息失败,Err:"+err.Error())
+				return
+			}
+		}
+	}
+
+	approveItem, err := admin.GetAdminById(66)
+	if err != nil {
+		this.FailWithMessage("获取审批人信息失败!", "获取审批人信息失败,Err:"+err.Error())
+		return
+	}
+	{
+		//系统消息
+		sourceType := 10
+		content := sysUser.RealName + " " + req.Province + req.City + req.Reason + "出差申请"
+		go services.AddCompanyApprovalMessage(sysUserId, approveItem.AdminId, 0, req.BusinessApplyId, 1, sourceType, 1, "", content, content, "", "")
+	}
+
+	//模板消息
+	{
+		var wxAppPath string
+		if utils.RunMode == "debug" {
+			wxAppPath = "pages/index/index"
+		} else {
+			wxAppPath = "pages-approve/businessTrip/detail?id=" + strconv.Itoa(req.BusinessApplyId)
+		}
+		first := "您好,有新的申请待处理"
+		keyword1 := sysUser.RealName
+		keyword2 := "--" //sysUser.Mobile
+		keyword3 := time.Now().Format(utils.FormatDateTime)
+		var keyword4 string
+		if req.PeerPeopleId != "" {
+			keyword4 = req.ArriveDate + "至" + req.ReturnDate + "," + req.Transportation + "前往" + req.Province + req.City + "," + "同行人" + req.PeerPeopleName
+		} else {
+			keyword4 = req.ArriveDate + "至" + req.ReturnDate + "," + req.Transportation + "前往" + req.Province + req.City
+		}
+		remark := "请尽快完成审批"
+		go services.SendWxMsgWithRoadshowPending(first, keyword1, keyword2, keyword3, keyword4, remark, wxAppPath, approveItem.Mobile)
+	}
+	this.OkWithMessage("申请成功")
+}
+
+// @Title 出差申请列表
+// @Description 出差申请列表接口
+// @Param   PageSize   query   int  true       "每页数据条数"
+// @Param   CurrentIndex   query   int  true       "当前页页码,从1开始"
+// @Param   Reason   query   string  true       "出差事由"
+// @Param   Status   query   string  true       "状态"
+// @Success 200 {object} business_trip.BusinessApplyListResp
+// @router /apply/list [get]
+func (this *BusinessTrip) ApplyList() {
+	sysUser := this.AdminWx
+	sysUserId := sysUser.AdminId
+
+	pageSize, _ := this.GetInt("PageSize")
+	currentIndex, _ := this.GetInt("CurrentIndex")
+
+	var total int
+	page := paging.GetPaging(currentIndex, pageSize, total)
+
+	var startSize int
+	if pageSize <= 0 {
+		pageSize = utils.PageSize10
+	}
+	if currentIndex <= 0 {
+		currentIndex = 1
+	}
+	startSize = paging.StartIndex(currentIndex, pageSize)
+
+	reason := this.GetString("Reason")
+	status := this.GetString("Status")
+
+	var condition string
+	var pars []interface{}
+
+	condition += ` AND apply_admin_id=? `
+	pars = append(pars, sysUserId)
+
+	if reason != "" {
+		condition += ` AND reason=? `
+		pars = append(pars, reason)
+	}
+
+	if status != "" {
+		if status == "已处理" {
+			condition += ` AND status <> '待审批' `
+		} else {
+			condition += ` AND status=? `
+			pars = append(pars, status)
+		}
+	}
+
+	resp := new(business_trip.BusinessApplyListResp)
+	total, err := business_trip.GetBusinessApplyListCount(condition, pars)
+	if err != nil && err.Error() != utils.ErrNoRow() {
+		this.FailWithMessage("获取信息失败!", "获取数据总数失败,GetCalendarListCount,Err:"+err.Error())
+		return
+	}
+
+	dataList, err := business_trip.GetBusinessApplyList(condition, pars, startSize, pageSize)
+	if err != nil {
+		this.FailWithMessage("获取信息失败!", "获取数据总数失败,GetBusinessApplyList,Err:"+err.Error())
+		return
+	}
+
+	page = paging.GetPaging(currentIndex, pageSize, total)
+	resp.Paging = page
+	resp.List = dataList
+	this.OkDetailed(resp, "获取成功")
+}
+
+// @Title 删除出差申请接口
+// @Description 删除出差申请接口
+// @Param	request	body business_trip.BusinessApplyDeleteReq true "type json string"
+// @Success Ret=200 删除成功
+// @router /apply/delete [post]
+func (this *BusinessTrip) Delete() {
+	//sysUser := this.AdminWx
+	//sysUserId := sysUser.AdminId
+
+	var req business_trip.BusinessApplyDeleteReq
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		this.FailWithMessage("参数解析异常!", "参数解析失败,Err:"+err.Error())
+		return
+	}
+
+	if req.BusinessApplyId <= 0 {
+		this.FailWithMessage("参数错误!", "参数错误!BusinessApplyId:"+strconv.Itoa(req.BusinessApplyId))
+		return
+	}
+	businessApplyItem, err := business_trip.GetBusinessApplyById(req.BusinessApplyId)
+	if err != nil {
+		if err.Error() == utils.ErrNoRow() {
+			this.FailWithMessage("出差申请信息已被删除,请刷新页面!", "出差申请信息已被删除,请刷新页面!")
+			return
+		}
+		this.FailWithMessage("获取数据失败!", "获取数据失败!GetBusinessApplyById:"+err.Error())
+		return
+	}
+	err = business_trip.DeleteBusinessApply(businessApplyItem.BusinessApplyId)
+	if err != nil {
+		this.FailWithMessage("删除失败!", "删除失败!DeleteBusinessApply:"+err.Error())
+		return
+	}
+	//删除系统消息
+	go company_approval_message.DeleteCompanyApprovalMessage(req.BusinessApplyId, 10)
+	this.OkWithMessage("删除成功")
+}
+
+// @Title 撤回出差申请接口
+// @Description 撤回出差申请接口
+// @Param	request	body business_trip.BusinessApplyBackReq true "type json string"
+// @Success Ret=200 保存成功
+// @router /apply/back [post]
+func (this *BusinessTrip) Back() {
+	//sysUser := this.AdminWx
+	//sysUserId := sysUser.AdminId
+
+	var req business_trip.BusinessApplyBackReq
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		this.FailWithMessage("参数解析异常!", "参数解析失败,Err:"+err.Error())
+		return
+	}
+
+	if req.BusinessApplyId <= 0 {
+		this.FailWithMessage("参数错误!", "参数错误!BusinessApplyId:"+strconv.Itoa(req.BusinessApplyId))
+		return
+	}
+	businessApplyItem, err := business_trip.GetBusinessApplyById(req.BusinessApplyId)
+	if err != nil {
+		if err.Error() == utils.ErrNoRow() {
+			this.FailWithMessage("出差申请已被删除,请刷新页面", "出差申请已被删除,请刷新页面")
+			return
+		}
+		this.FailWithMessage("获取数据失败!", "获取数据失败!GetBusinessApplyById:"+err.Error())
+		return
+	}
+
+	if businessApplyItem.Status == "已审批" {
+		this.FailWithMessage("已审批,不可进行撤回操作!", "已审批,不可进行撤回操作!")
+		return
+	} else if businessApplyItem.Status == "已驳回" {
+		this.FailWithMessage("已驳回,不可进行撤回操作!", "已驳回,不可进行撤回操作!")
+		return
+	} else if businessApplyItem.Status == "已撤回" {
+		this.FailWithMessage("已撤回,不可重复操作!", "已撤回,不可重复操作!")
+		return
+	} else if businessApplyItem.Status == "已过期" {
+		this.FailWithMessage("已过期,不可进行重复操作!", "已过期,不可进行重复操作!")
+		return
+	}
+
+	whereParams := make(map[string]interface{})
+	updateParams := make(map[string]interface{})
+
+	whereParams["business_apply_id"] = req.BusinessApplyId
+
+	updateParams["status"] = "已撤回"
+	updateParams["modify_time"] = time.Now()
+
+	err = business_trip.UpdateBusinessApply(whereParams, updateParams)
+
+	if err != nil {
+		this.FailWithMessage("撤回失败", "撤回失败!UpdateBusinessApply:"+err.Error())
+		return
+	}
+
+	//删除系统消息
+	go company_approval_message.DeleteCompanyApprovalMessage(req.BusinessApplyId, 10)
+
+	this.OkWithMessage("撤回成功")
+}
+
+// @Title 出差申请详情
+// @Description 出差申请详情接口
+// @Param   BusinessApplyId   query   int  true       "出差申请id"
+// @Success 200 {object} business_trip.BusinessApplyView
+// @router /apply/detail [get]
+func (this *BusinessTrip) ApplyDetail() {
+	sysUser := this.AdminWx
+	sysUserId := sysUser.AdminId
+	businessApplyId, _ := this.GetInt("BusinessApplyId")
+	if businessApplyId <= 0 {
+		this.FailWithMessage("参数错误", "出差申请id错误:"+strconv.Itoa(businessApplyId))
+		return
+	}
+	item, err := business_trip.GetBusinessApplyById(businessApplyId)
+	if err != nil {
+		if err.Error() == utils.ErrNoRow() {
+			this.FailWithMessage("该出差申请已被删除", "该出差申请已被删除")
+			return
+		}
+		this.FailWithMessage("获取数据失败", "获取数据失败:"+err.Error())
+		return
+	}
+	if item.ApproveId == sysUserId {
+		item.IsApprove = true
+	}
+	this.OkDetailed(item, "获取成功")
+}

+ 167 - 0
controllers/business_trip/business_approve.go

@@ -0,0 +1,167 @@
+package business_trip
+
+import (
+	"encoding/json"
+	"github.com/rdlucklib/rdluck_tools/paging"
+	"hongze/hongze_mobile_admin/models/tables/admin"
+	"hongze/hongze_mobile_admin/models/tables/business_trip"
+	"hongze/hongze_mobile_admin/services"
+	"hongze/hongze_mobile_admin/utils"
+	"strconv"
+	"time"
+)
+
+// @Title 出差审批列表
+// @Description 出差申请列表接口
+// @Param   PageSize   query   int  true       "每页数据条数"
+// @Param   CurrentIndex   query   int  true       "当前页页码,从1开始"
+// @Param   Status   query   string  true       "状态"
+// @Success 200 {object} business_trip.BusinessApplyListResp
+// @router /approve/list [get]
+func (this *BusinessTrip) ApproveList() {
+	sysUser := this.AdminWx
+	sysUserId := sysUser.AdminId
+
+	pageSize, _ := this.GetInt("PageSize")
+	currentIndex, _ := this.GetInt("CurrentIndex")
+
+	var total int
+	page := paging.GetPaging(currentIndex, pageSize, total)
+
+	var startSize int
+	if pageSize <= 0 {
+		pageSize = utils.PageSize10
+	}
+	if currentIndex <= 0 {
+		currentIndex = 1
+	}
+	startSize = paging.StartIndex(currentIndex, pageSize)
+
+	reason := this.GetString("Reason")
+	status := this.GetString("Status")
+
+	var condition string
+	var pars []interface{}
+
+	condition += ` AND approve_id=? `
+	pars = append(pars, sysUserId)
+
+	if reason != "" {
+		condition += ` AND reason=? `
+		pars = append(pars, reason)
+	}
+
+	if status != "" {
+		if status == "已审批" {
+			condition += ` AND status IN('已审批','已驳回') `
+		} else {
+			condition += ` AND status=? `
+			pars = append(pars, status)
+		}
+	}
+
+	resp := new(business_trip.BusinessApplyListResp)
+	total, err := business_trip.GetBusinessApplyListCount(condition, pars)
+	if err != nil && err.Error() != utils.ErrNoRow() {
+		this.FailWithMessage("获取信息失败!", "获取数据总数失败,GetCalendarListCount,Err:"+err.Error())
+		return
+	}
+
+	dataList, err := business_trip.GetBusinessApplyList(condition, pars, startSize, pageSize)
+	if err != nil {
+		this.FailWithMessage("获取指标信息失败!", "获取数据失败,GetBusinessApplyList,Err:"+err.Error())
+		return
+	}
+
+	page = paging.GetPaging(currentIndex, pageSize, total)
+	resp.Paging = page
+	resp.List = dataList
+	this.OkDetailed(resp, "获取成功")
+}
+
+// @Title 出差申请,审批接口
+// @Description 出差申请,审批接口
+// @Param	request	body business_trip.BusinessApplyApproveReq true "type json string"
+// @Success Ret=200 保存成功
+// @router /apply/approve [post]
+func (this *BusinessTrip) ApplyApprove() {
+	sysUser := this.AdminWx
+	sysUserId := sysUser.AdminId
+	var req business_trip.BusinessApplyApproveReq
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		this.FailWithMessage("参数解析异常!", "参数解析失败,Err:"+err.Error())
+		return
+	}
+
+	if req.BusinessApplyId <= 0 {
+		this.FailWithMessage("参数错误!", "参数错误")
+		return
+	}
+
+	if req.ApproveStatus != 1 && req.ApproveStatus != 2 {
+		this.FailWithMessage("审批状态错误!", "审批状态错误")
+		return
+	}
+
+	if req.ApproveStatus == 2 && req.RefuseReason == "" {
+		this.FailWithMessage("请填写驳回理由!", "请填写驳回理由")
+		return
+	}
+
+	businessApplyItem, err := business_trip.GetBusinessApplyById(req.BusinessApplyId)
+	if err != nil {
+		if err.Error() == utils.ErrNoRow() {
+			this.FailWithMessage("出差申请已被删除,请刷新页面!", "出差申请已被删除,请刷新页面")
+			return
+		}
+		this.FailWithMessage("获取数据失败!", "获取数据失败!GetBusinessApplyById:"+err.Error())
+		return
+	}
+
+	whereParams := make(map[string]interface{})
+	updateParams := make(map[string]interface{})
+
+	whereParams["business_apply_id"] = req.BusinessApplyId
+
+	var status, applyStatus string
+	if req.ApproveStatus == 1 {
+		status = "已审批"
+		applyStatus = "已通过"
+	} else {
+		status = "已驳回"
+		applyStatus = "已驳回"
+	}
+	updateParams["status"] = status
+	updateParams["refuse_reason"] = req.RefuseReason
+	updateParams["modify_time"] = time.Now()
+	updateParams["approve_time"] = time.Now()
+
+	err = business_trip.UpdateBusinessApply(whereParams, updateParams)
+	if err != nil {
+		this.FailWithMessage("审批失败!", "审批失败!UpdateBusinessApply:"+err.Error())
+		return
+	}
+
+	{
+		//系统消息
+		sourceType := 10
+		content := businessApplyItem.Province + businessApplyItem.City + businessApplyItem.Reason + "出差申请" + status
+		go services.AddCompanyApprovalMessage(sysUserId, businessApplyItem.ApplyAdminId, 0, businessApplyItem.BusinessApplyId, 1, sourceType, 2, "", content, content, "", "")
+	}
+
+	//模板消息
+	{
+		applyItem, _ := admin.GetAdminById(businessApplyItem.ApplyAdminId)
+		wxAppPath := "pages-approve/businessTrip/detail?id=" + strconv.Itoa(req.BusinessApplyId)
+		first := "您的出差申请已被审批"
+		keyword1 := businessApplyItem.Reason + "出差申请" + applyStatus
+		keyword2 := status
+		var remark string
+		if status == "已驳回" {
+			remark = req.RefuseReason
+		}
+		go services.SendWxMsgWithRoadshowDeleteNotice(first, keyword1, keyword2, remark, wxAppPath, applyItem.Mobile)
+	}
+	this.OkWithMessage("审批成功")
+}

+ 144 - 0
controllers/business_trip/business_calendar.go

@@ -0,0 +1,144 @@
+package business_trip
+
+import (
+	"hongze/hongze_mobile_admin/models/tables/admin"
+	"hongze/hongze_mobile_admin/models/tables/business_trip"
+	"strconv"
+	"strings"
+)
+
+// ResearcherReportList
+// @Title 出差日历表
+// @Description 出差日历表接口
+// @Param   AdminId   query   int true       "用户id"
+// @Param   TripDate   query   string  true       "日期"
+// @Success 200 {object} roadshow.BusinessTripResp
+// @router /calendar [get]
+func (this *BusinessTrip) BusinessTripCalendar() {
+	sysUser := this.AdminWx
+	sysUserId := sysUser.AdminId
+
+	adminId, _ := this.GetInt("AdminId")
+	tripDate := this.GetString("TripDate")
+
+	var condition string
+	var pars []interface{}
+
+	if adminId > 0 {
+		condition += ` AND apply_admin_id=? `
+		pars = append(pars, adminId)
+	}
+
+	if sysUserId == 66 {
+		condition += ` AND status IN('待审批','已审批') `
+	} else {
+		condition += ` AND status=? `
+		pars = append(pars, "已审批")
+	}
+
+	if tripDate != "" {
+		condition += ` AND ? >= arrive_date `
+		pars = append(pars, tripDate)
+
+		condition += ` AND ? <= return_date `
+		pars = append(pars, tripDate)
+	}
+
+	list, err := business_trip.GetBusinessTripApproveList(condition, pars)
+	if err != nil {
+		this.FailWithMessage("获取数据失败!", "获取数据失败,GetBusinessTripApproveList,Err:"+err.Error())
+		return
+	}
+	var peerIdArr []string
+	for _, v := range list {
+		if v.PeerPeopleId != "" {
+			peerId := strings.Split(v.PeerPeopleId, ",")
+			peerIdArr = append(peerIdArr, peerId...)
+		}
+	}
+
+	adminMap := make(map[int]*admin.Admin)
+
+	if len(peerIdArr) > 0 {
+		peerIdStr := strings.Join(peerIdArr, ",")
+		adminList, err := admin.GetAdminListByIds(peerIdStr)
+		if err != nil {
+			this.FailWithMessage("获取数据失败!", "获取数据失败,GetBusinessTripApproveList,Err:"+err.Error())
+			return
+		}
+		for _, av := range adminList {
+			adminMap[av.AdminId] = av
+		}
+	}
+	approveList := make([]*business_trip.BusinessTripApproveView, 0)
+	listLen := len(list)
+	for i := 0; i < listLen; i++ {
+		item := list[i]
+		approveList = append(approveList, item)
+		dayCount := int(item.ReturnDate.Sub(item.ArriveDate).Hours()/24) + 1
+		list[i].DayTotal = dayCount
+
+		var groupName string
+		switch item.DepartmentId {
+		case 1:
+			groupName = "研究员"
+		case 2, 4, 5, 9:
+			groupName = "销售"
+		case 3, 6, 7, 8:
+			groupName = "其他"
+		default:
+			groupName = "其他"
+		}
+		list[i].GroupName = groupName
+		//if item.Status == "已审批" && item.PeerPeopleId != "" {
+		//	peerIdArr := strings.Split(item.PeerPeopleId, ",")
+		//	peerNameArr := strings.Split(item.PeerPeopleName, ",")
+		//	for k, v := range peerIdArr {
+		//		peerId, err := strconv.Atoi(v)
+		//		if err != nil {
+		//			this.FailWithMessage("申请失败!", "同行人id失败,Err:"+err.Error())
+		//			return
+		//		}
+		//		peerItem := new(business_trip.BusinessTripApproveView)
+		//		peerItem = item
+		//		peerItem.ApplyAdminId = peerId
+		//		peerItem.ApplyRealName = peerNameArr[k]
+		//		peerItem.DayTotal = dayCount
+		//		approveList = append(approveList, peerItem)
+		//	}
+		//}
+		if item.PeerPeopleId != "" {
+			PeerItems := make([]*business_trip.PeerItem, 0)
+			peerSplitIdArr := strings.Split(item.PeerPeopleId, ",")
+			for _, v := range peerSplitIdArr {
+				peerItem := new(business_trip.PeerItem)
+				peerId, err := strconv.Atoi(v)
+				if err != nil {
+					this.FailWithMessage("申请失败!", "同行人id失败,Err:"+err.Error())
+					return
+				}
+				peerAdmin := adminMap[peerId]
+				if peerAdmin != nil {
+					peerItem.PeerPeopleId = peerAdmin.AdminId
+					peerItem.PeerPeopleName = peerAdmin.RealName
+					switch peerAdmin.DepartmentId {
+					case 1:
+						groupName = "研究员"
+					case 2, 4, 5, 9:
+						groupName = "销售"
+					case 3, 6, 7, 8:
+						groupName = "其他"
+					default:
+						groupName = "其他"
+					}
+					peerItem.PeerGroupName = groupName
+				}
+				PeerItems = append(PeerItems, peerItem)
+			}
+			list[i].PeerPeopleList = PeerItems
+		}
+	}
+
+	this.OkDetailed(list, "获取成功")
+	return
+}

+ 14 - 3
controllers/message.go

@@ -5,6 +5,7 @@ import (
 	"fmt"
 	"github.com/rdlucklib/rdluck_tools/paging"
 	"hongze/hongze_mobile_admin/models/response/message"
+	"hongze/hongze_mobile_admin/models/tables/business_trip"
 	"hongze/hongze_mobile_admin/models/tables/company_approval"
 	"hongze/hongze_mobile_admin/models/tables/company_approval_message"
 	"hongze/hongze_mobile_admin/models/tables/contract_approval"
@@ -19,7 +20,7 @@ import (
 	"time"
 )
 
-//消息模块
+// 消息模块
 type MessageCommon struct {
 	BaseAuth
 }
@@ -34,7 +35,7 @@ func (c *MessageCommon) SummaryMessageList() {
 
 	//SummaryMessageListResp := message.SummaryMessageListResp{}
 	//sourceTypeList := [...]int{1, 2, 3, 5, 6}
-	sourceTypeList := [...]int{1, 2, 3, 6}	// 问答的暂时不要了
+	sourceTypeList := [...]int{1, 2, 3, 6, 10} // 问答的暂时不要了
 	messageMap := make(map[int]message.SummaryMessage)
 	timeList := make([]int, 0)
 	var err error
@@ -137,7 +138,7 @@ func (c *MessageCommon) SummaryMessageList() {
 	c.OkDetailed(messageList, "获取成功")
 }
 
-//切片数据反转
+// 切片数据反转
 func rotate(s []message.SummaryMessage) {
 	left, rigth := 0, 0
 	if len(s)%2 == 0 { //判断长度是奇数还是偶数,根据这个来确定旋转的中心
@@ -297,6 +298,16 @@ func (c *MessageCommon) MessageList() {
 				approvalInfo.ApplyTime = companyApproval.CreateTime
 				approvalInfo.ApprovalTime = companyApproval.ApproveTime
 			}
+		} else if messageInfo.SourceType == 10 {
+			applyId := messageInfo.CompanyApprovalId
+			if applyId > 0 {
+				bt, err := business_trip.GetBusinessApplyById(applyId)
+				if err != nil && err.Error() != utils.ErrNoRow() {
+					c.FailWithMessage("获取失败", "获取信息失败,GetBusinessApplyById,Err:"+err.Error())
+					return
+				}
+				messageInfo.BusinessTripInfo = bt
+			}
 		} else {
 			if newApproval, ok := newApprovalMap[messageInfo.CompanyApprovalId]; ok {
 				approvalInfo.Type = newApproval.ApplyContent

+ 123 - 0
controllers/system.go

@@ -0,0 +1,123 @@
+package controllers
+
+import (
+	"hongze/hongze_mobile_admin/models/tables/system"
+	"strconv"
+)
+
+// SystemCommon 系统模块
+type SystemCommon struct {
+	BaseAuth
+}
+
+// SellerList
+// @Title 获取未配置权限的管理员(根据部门、分组)
+// @Description 获取未配置权限的管理员(根据部门、分组)接口
+// @Success 200 {object} response.DepartmentGroupSellersResp
+// @router /role/seller/list [get]
+func (this *SystemCommon) SellerList() {
+	departmentList, err := system.GetDepartmentList()
+	if err != nil {
+		this.FailWithMessage("获取失败!", "获取部门失败,Err:"+err.Error())
+		return
+	}
+	departmentMap := make(map[int]*system.SysDepartmentList)
+	for _, v := range departmentList {
+		departmentMap[v.DepartmentId] = v
+	}
+	fullGroups, err := system.GetFullGroup()
+	if err != nil {
+		this.FailWithMessage("获取分组失败!", "获取分组失败,Err:"+err.Error())
+		return
+	}
+	fullGroupMap := make(map[int]*system.SysFullGroup)
+	for _, v := range fullGroups {
+		fullGroupMap[v.GroupId] = v
+	}
+	var list []system.DepartmentGroupSellers
+	departmentListMap := make(map[int][]system.DepartmentGroupSellers)
+	groupListMap := make(map[int][]system.DepartmentGroupSellers)
+	teamListMap := make(map[int][]system.DepartmentGroupSellers)
+	departmentHasMap := make(map[int]bool)
+	groupHasMap := make(map[int]bool)
+	teamHasMap := make(map[int]bool)
+
+	condition := " and enabled = 1 "
+	sellerList, err := system.GetSysUserItems(condition, []interface{}{})
+	if err != nil {
+		this.FailWithMessage("获取管理账号失败!", "获取管理账号失败,Err:"+err.Error())
+		return
+	}
+	for _, v := range sellerList {
+		tmp := system.DepartmentGroupSellers{
+			AdminId:  strconv.Itoa(v.AdminId),
+			RealName: v.RealName,
+		}
+		if v.GroupId > 0 {
+			if groupInfo, ok := fullGroupMap[v.GroupId]; ok {
+				if groupInfo.ParentId > 0 {
+					teamListMap[v.GroupId] = append(teamListMap[v.GroupId], tmp)
+				} else {
+					groupListMap[groupInfo.GroupId] = append(groupListMap[groupInfo.GroupId], tmp)
+				}
+			}
+		} else {
+			departmentListMap[v.DepartmentId] = append(departmentListMap[v.DepartmentId], tmp)
+		}
+	}
+	for _, groupInfo := range fullGroups {
+		var team1 system.DepartmentGroupSellers
+		//处理小组
+		if groupInfo.ParentId > 0 {
+			if _, ok2 := teamHasMap[groupInfo.GroupId]; !ok2 {
+				if len(teamListMap[groupInfo.GroupId]) > 0 {
+					team1 = system.DepartmentGroupSellers{
+						AdminId:      "team_" + strconv.Itoa(groupInfo.GroupId),
+						RealName:     groupInfo.GroupName,
+						ChildrenList: teamListMap[groupInfo.GroupId],
+					}
+					teamHasMap[groupInfo.GroupId] = true
+					groupListMap[groupInfo.ParentId] = append(groupListMap[groupInfo.ParentId], team1)
+				}
+			}
+		}
+	}
+
+	for _, groupInfo := range fullGroups {
+		var group1 system.DepartmentGroupSellers
+		//处理大组
+		if groupInfo.ParentId == 0 {
+			if _, ok2 := groupHasMap[groupInfo.GroupId]; !ok2 {
+				if len(groupListMap[groupInfo.GroupId]) > 0 {
+					group1 = system.DepartmentGroupSellers{
+						AdminId:      "group_" + strconv.Itoa(groupInfo.GroupId),
+						RealName:     groupInfo.GroupName,
+						ChildrenList: groupListMap[groupInfo.GroupId],
+					}
+					groupHasMap[groupInfo.GroupId] = true
+					departmentListMap[groupInfo.DepartmentId] = append(departmentListMap[groupInfo.DepartmentId], group1)
+				}
+			}
+		}
+	}
+
+	for _, groupInfo := range departmentList {
+		var department1 system.DepartmentGroupSellers
+		//处理部门
+		if _, ok1 := departmentHasMap[groupInfo.DepartmentId]; !ok1 {
+			if len(departmentListMap[groupInfo.DepartmentId]) > 0 {
+				department1 = system.DepartmentGroupSellers{
+					AdminId:      "department_" + strconv.Itoa(groupInfo.DepartmentId),
+					RealName:     groupInfo.DepartmentName,
+					ChildrenList: departmentListMap[groupInfo.DepartmentId],
+				}
+				departmentHasMap[groupInfo.DepartmentId] = true
+				list = append(list, department1)
+			}
+		}
+	}
+	resp := new(system.DepartmentGroupSellersResp)
+	resp.List = list
+	this.OkDetailed(resp, "获取成功")
+	return
+}

+ 12 - 0
models/db_init.go

@@ -8,6 +8,7 @@ import (
 	"hongze/hongze_mobile_admin/models/tables/admin_record"
 	"hongze/hongze_mobile_admin/models/tables/approval_flow"
 	"hongze/hongze_mobile_admin/models/tables/approval_flow_node"
+	"hongze/hongze_mobile_admin/models/tables/business_trip"
 	"hongze/hongze_mobile_admin/models/tables/chart_permission"
 	"hongze/hongze_mobile_admin/models/tables/company"
 	"hongze/hongze_mobile_admin/models/tables/company_approval"
@@ -123,6 +124,9 @@ func init() {
 
 	// 价格驱动相关
 	initPriceDriven()
+
+	//出差相关
+	initBusinessTrip()
 }
 
 // initCommunity 社区问答相关
@@ -150,3 +154,11 @@ func initPriceDriven() {
 }
 
 func InitDb() {}
+
+// 出差
+func initBusinessTrip() {
+	orm.RegisterModel(
+		new(business_trip.BusinessApply),
+		new(business_trip.BusinessApplyPeer),
+	)
+}

+ 2 - 0
models/response/admin/admin.go

@@ -11,4 +11,6 @@ type LoginResp struct {
 	GroupName      string `description:"所属分组"`
 	ProductName    string `description:"产品名称:admin,ficc,权益"`
 	Authority      int    `description:"管理权限,0:无,1:部门负责人,2:小组负责人,3:超级管理员"`
+	IsBusinessTrip bool   `description:"是否出差审批:true,审批,false:无审批"`
+	IsRai          bool   `description:"是否为权益用户:true,是,false:否"`
 }

+ 18 - 11
models/tables/admin/admin.go

@@ -44,7 +44,7 @@ func CheckAdmin(userName, password string) (item *Admin, err error) {
 	return
 }
 
-//根据管理员id获取管理员信息
+// 根据管理员id获取管理员信息
 func GetAdminById(adminId int) (item *Admin, err error) {
 	sql := `SELECT * FROM admin WHERE admin_id=? LIMIT 1`
 	o := orm.NewOrm()
@@ -52,7 +52,7 @@ func GetAdminById(adminId int) (item *Admin, err error) {
 	return
 }
 
-//根据权限code获取系统用户列表
+// 根据权限code获取系统用户列表
 func GetAdminListByRoleCode(roleTypeCode string) (items []*Admin, err error) {
 	sql := `SELECT * FROM admin WHERE role_type_code=? and enabled=1  `
 	o := orm.NewOrm()
@@ -60,7 +60,7 @@ func GetAdminListByRoleCode(roleTypeCode string) (items []*Admin, err error) {
 	return
 }
 
-//根据权限id获取系统用户列表
+// 根据权限id获取系统用户列表
 func GetAdminListByRoleId(roleId string) (items []*Admin, err error) {
 	sql := `SELECT * FROM admin WHERE role_id=? and enabled=1  `
 	o := orm.NewOrm()
@@ -68,7 +68,7 @@ func GetAdminListByRoleId(roleId string) (items []*Admin, err error) {
 	return
 }
 
-//根据用户id字符串获取系统用户列表
+// 根据用户id字符串获取系统用户列表
 func GetAdminListByIds(ids string) (items []*Admin, err error) {
 	sql := `SELECT * FROM admin WHERE admin_id in (` + ids + `) and enabled=1 `
 	o := orm.NewOrm()
@@ -76,7 +76,7 @@ func GetAdminListByIds(ids string) (items []*Admin, err error) {
 	return
 }
 
-//根据管理员id获取管理员信息(包含微信、第三方信息)
+// 根据管理员id获取管理员信息(包含微信、第三方信息)
 func GetAdminWxById(adminId int) (item *custom.AdminWx, err error) {
 	sql := `SELECT * FROM admin WHERE admin_id=? LIMIT 1`
 	o := orm.NewOrm()
@@ -137,10 +137,9 @@ type BindMobileReq struct {
 }
 type WxLoginResp struct {
 	BindToken string
-	BindFlag bool
+	BindFlag  bool
 }
 
-
 type WxSmsResp struct {
 	SmsFlag  bool
 	BindFlag bool
@@ -154,7 +153,6 @@ func GetAdminWxByAdminOpenId(openId string) (item *Admin, err error) {
 	return
 }
 
-
 // GetAdminByMobile 根据手机号 获取管理员信息
 func GetAdminByMobile(mobile string) (item *Admin, err error) {
 	sql := `SELECT * FROM admin WHERE mobile=? LIMIT 1`
@@ -162,8 +160,9 @@ func GetAdminByMobile(mobile string) (item *Admin, err error) {
 	err = o.Raw(sql, mobile).QueryRow(&item)
 	return
 }
+
 // UpdateAdminOpenIdUnionId 更新openId
-func UpdateAdminOpenIdUnionId(adminId int, openId, unionId string) (err error)  {
+func UpdateAdminOpenIdUnionId(adminId int, openId, unionId string) (err error) {
 	o := orm.NewOrm()
 	sql := `UPDATE admin
 			SET
@@ -173,10 +172,11 @@ func UpdateAdminOpenIdUnionId(adminId int, openId, unionId string) (err error)
 }
 
 type OpenIdList struct {
-	OpenId string
+	OpenId  string
 	AdminId int
 }
-//GetOpenIdListByMobile 根据手机号获取用户的openid列表
+
+// GetOpenIdListByMobile 根据手机号获取用户的openid列表
 func GetOpenIdListByMobile(mobile, openIdStr string) (items []*OpenIdList, err error) {
 	sql := `SELECT admin_id, open_id FROM admin 
           WHERE open_id != "" and mobile=? `
@@ -186,3 +186,10 @@ func GetOpenIdListByMobile(mobile, openIdStr string) (items []*OpenIdList, err e
 	_, err = orm.NewOrm().Raw(sql, mobile).QueryRows(&items)
 	return
 }
+
+func GetAdminWxByIdS(adminIdStr string) (items []*custom.AdminWx, err error) {
+	sql := `SELECT * FROM admin WHERE admin_id IN(` + adminIdStr + `)`
+	o := orm.NewOrm()
+	_, err = o.Raw(sql).QueryRows(&items)
+	return
+}

+ 217 - 0
models/tables/business_trip/business_apply.go

@@ -0,0 +1,217 @@
+package business_trip
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"github.com/rdlucklib/rdluck_tools/paging"
+	"time"
+)
+
+type BusinessApply struct {
+	BusinessApplyId int       `orm:"column(business_apply_id);pk;auto" description:"ID"`
+	ApplyAdminId    int       `description:"申请人id"`
+	ApplyRealName   string    `description:"申请人姓名"`
+	ArriveDate      string    `description:"到达日期"`
+	ReturnDate      string    `description:"返程日期"`
+	Province        string    `description:"目的地省"`
+	City            string    `description:"目的地市"`
+	Reason          string    `description:"出差事由"`
+	Transportation  string    `description:"交通工具"`
+	PeerPeopleId    string    `description:"同行人id"`
+	PeerPeopleName  string    `description:"同行人"`
+	Status          string    `description:"状态:'待审批','已审批','已驳回','已撤回','已过期'"`
+	ApproveId       int       `description:"审批人id"`
+	ApproveName     string    `description:"审批人姓名"`
+	RefuseReason    string    `description:"拒绝理由"`
+	RefuseTime      time.Time `description:"拒绝时间"`
+	ApproveTime     time.Time `description:"审批时间"`
+	CreateTime      time.Time `description:"创建时间"`
+	ModifyTime      time.Time `description:"修改时间"`
+}
+
+// 添加出差申请
+func AddBusinessApply(item *BusinessApply) (applyId int64, err error) {
+	o := orm.NewOrm()
+	applyId, err = o.Insert(item)
+	if err != nil {
+		return
+	}
+	return
+}
+
+type BusinessApplyReq struct {
+	ArriveDate     string `description:"到达日期"`
+	ReturnDate     string `description:"返程日期"`
+	Province       string `description:"目的地省"`
+	City           string `description:"目的地市"`
+	Reason         string `description:"出差事由"`
+	Transportation string `description:"交通工具"`
+	PeerPeopleId   string `description:"同行人id"`
+	PeerPeopleName string `description:"同行人"`
+}
+
+type BusinessApplyView struct {
+	BusinessApplyId int    `description:"出差申请id"`
+	ApplyAdminId    int    `description:"申请人id"`
+	ApplyRealName   string `description:"申请人姓名"`
+	ArriveDate      string `description:"到达日期"`
+	ReturnDate      string `description:"返程日期"`
+	Province        string `description:"目的地省"`
+	City            string `description:"目的地市"`
+	Reason          string `description:"出差事由"`
+	Transportation  string `description:"交通工具"`
+	PeerPeopleId    string `description:"同行人id"`
+	PeerPeopleName  string `description:"同行人"`
+	Status          string `description:"状态:'待审批','已审批','已驳回','已撤回','已过期'"`
+	ApproveId       int    `description:"审批人id"`
+	ApproveName     string `description:"审批人姓名"`
+	RefuseReason    string `description:"拒绝理由"`
+	RefuseTime      string `description:"拒绝时间"`
+	ApproveTime     string `description:"审批时间"`
+	CreateTime      string `description:"创建时间"`
+	ModifyTime      string `description:"修改时间"`
+	IsApprove       bool   `description:"是否审批人,true:是,false:否"`
+}
+
+func GetBusinessApplyListCount(condition string, pars []interface{}) (count int, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT COUNT(1) AS count FROM  business_apply AS a WHERE 1=1  `
+	if condition != "" {
+		sql += condition
+	}
+	err = o.Raw(sql, pars).QueryRow(&count)
+	return
+}
+
+func GetBusinessApplyList(condition string, pars []interface{}, startSize, pageSize int) (list []*BusinessApplyView, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM business_apply AS a WHERE 1=1 `
+	if condition != "" {
+		sql += condition
+	}
+	sql += ` ORDER BY a.create_time DESC LIMIT ?,? `
+	_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&list)
+	return
+}
+
+type BusinessApplyListResp struct {
+	Paging *paging.PagingItem
+	List   []*BusinessApplyView
+}
+
+type BusinessApplyDeleteReq struct {
+	BusinessApplyId int `description:"出差申请id"`
+}
+
+func GetBusinessApplyById(businessApplyId int) (item *BusinessApplyView, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM business_apply WHERE business_apply_id=? `
+	err = o.Raw(sql, businessApplyId).QueryRow(&item)
+	return
+}
+
+// 删除
+func DeleteBusinessApply(businessApplyId int) (err error) {
+	o := orm.NewOrm()
+	sql := ` DELETE FROM business_apply WHERE business_apply_id=? `
+	_, err = o.Raw(sql, businessApplyId).Exec()
+	if err != nil {
+		return err
+	}
+	return err
+}
+
+type BusinessApplyBackReq struct {
+	BusinessApplyId int `description:"出差申请id"`
+}
+
+// 更新
+func UpdateBusinessApply(where, updateParams map[string]interface{}) error {
+	o := orm.NewOrm()
+	ptrStructOrTableName := "business_apply"
+	qs := o.QueryTable(ptrStructOrTableName)
+	for expr, exprV := range where {
+		qs = qs.Filter(expr, exprV)
+	}
+	_, err := qs.Update(updateParams)
+	return err
+}
+
+type BusinessApplyEditReq struct {
+	BusinessApplyId int    `description:"出差申请id"`
+	ArriveDate      string `description:"到达日期"`
+	ReturnDate      string `description:"返程日期"`
+	Province        string `description:"目的地省"`
+	City            string `description:"目的地市"`
+	Reason          string `description:"出差事由"`
+	Transportation  string `description:"交通工具"`
+	PeerPeopleId    string `description:"同行人id"`
+	PeerPeopleName  string `description:"同行人"`
+}
+
+func CheckBusinessApplyDateCount(condition string, pars []interface{}) (count int, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT COUNT(1) AS count FROM  business_apply AS a
+		WHERE 1=1 `
+	if condition != "" {
+		sql += condition
+	}
+	err = o.Raw(sql, pars).QueryRow(&count)
+	return
+}
+
+func CheckBusinessApplyDate(startDateTime, endDateTime, status string, applyId, businessApplyId int) (calendarCount int, err error) {
+	var condition string
+	var pars []interface{}
+
+	if businessApplyId > 0 {
+		condition += " AND business_apply_id <> ? "
+		pars = append(pars, businessApplyId)
+	}
+
+	condition += " AND apply_admin_id = ? "
+	pars = append(pars, applyId)
+
+	condition += " AND status IN (" + status + ") "
+
+	condition += ` AND ((? >= arrive_date AND ? <= return_date) OR (? >= arrive_date AND ? <= return_date))`
+	pars = append(pars, startDateTime)
+	pars = append(pars, startDateTime)
+	pars = append(pars, endDateTime)
+	pars = append(pars, endDateTime)
+	calendarCount, err = CheckBusinessApplyDateCount(condition, pars)
+	return
+}
+
+func CheckBusinessApplyPeerDateCount(condition string, pars []interface{}) (count int, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT COUNT(1) AS count FROM  business_apply_peer AS a
+		WHERE 1=1 `
+	if condition != "" {
+		sql += condition
+	}
+	err = o.Raw(sql, pars).QueryRow(&count)
+	return
+}
+
+func CheckBusinessApplyPeerDate(startDateTime, endDateTime, status string, applyId, businessApplyId int) (calendarCount int, err error) {
+	var condition string
+	var pars []interface{}
+
+	if businessApplyId > 0 {
+		condition += " AND business_apply_id <> ? "
+		pars = append(pars, businessApplyId)
+	}
+
+	condition += " AND peer_people_id = ? "
+	pars = append(pars, applyId)
+
+	condition += " AND status IN (" + status + ") "
+
+	condition += ` AND ((? >= arrive_date AND ? <= return_date) OR (? >= arrive_date AND ? <= return_date))`
+	pars = append(pars, startDateTime)
+	pars = append(pars, startDateTime)
+	pars = append(pars, endDateTime)
+	pars = append(pars, endDateTime)
+	calendarCount, err = CheckBusinessApplyPeerDateCount(condition, pars)
+	return
+}

+ 42 - 0
models/tables/business_trip/business_apply_peer.go

@@ -0,0 +1,42 @@
+package business_trip
+
+import "time"
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+)
+
+type BusinessApplyPeer struct {
+	BusinessApplyPeerId int       `orm:"column(business_apply_peer_id);pk;auto" description:"ID"`
+	BusinessApplyId     int       `description:"出差申请id"`
+	ArriveDate          string    `description:"到达日期"`
+	ReturnDate          string    `description:"返程日期"`
+	Province            string    `description:"目的地省"`
+	City                string    `description:"目的地市"`
+	Status              string    `description:"状态:'待审批','已审批','已驳回','已撤回','已过期'"`
+	PeerPeopleId        int       `description:"同行人id"`
+	PeerPeopleName      string    `description:"同行人姓名"`
+	CreateTime          time.Time `description:"创建时间"`
+	ModifyTime          time.Time `description:"修改时间"`
+}
+
+// 添加出差申请随行人
+func AddBusinessApplyPeer(items []*BusinessApplyPeer) (err error) {
+	o := orm.NewOrm()
+	_, err = o.InsertMulti(len(items), items)
+	if err != nil {
+		return
+	}
+	return
+}
+
+// 删除
+func DeleteBusinessApplyPeer(businessApplyId int) (err error) {
+	o := orm.NewOrm()
+	sql := ` DELETE FROM business_apply_peer WHERE business_apply_id=? `
+	_, err = o.Raw(sql, businessApplyId).Exec()
+	if err != nil {
+		return err
+	}
+	return err
+}

+ 56 - 0
models/tables/business_trip/business_approve.go

@@ -0,0 +1,56 @@
+package business_trip
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"time"
+)
+
+type BusinessApplyApproveReq struct {
+	BusinessApplyId int    `description:"出差申请id"`
+	ApproveStatus   int    `description:"审批状态:1:通过,2:驳回"`
+	RefuseReason    string `description:"驳回理由"`
+}
+
+type BusinessTripApproveView struct {
+	BusinessApplyId int       `description:"出差申请id"`
+	ApplyAdminId    int       `description:"申请人id"`
+	ApplyRealName   string    `description:"申请人姓名"`
+	ArriveDate      time.Time `description:"到达日期"`
+	ReturnDate      time.Time `description:"返程日期"`
+	Province        string    `description:"目的地省"`
+	City            string    `description:"目的地市"`
+	Reason          string    `description:"出差事由"`
+	Transportation  string    `description:"交通工具"`
+	PeerPeopleId    string    `description:"同行人id"`
+	PeerPeopleName  string    `description:"同行人"`
+	PeerPeopleList  []*PeerItem
+	Status          string `description:"状态:'待审批','已审批','已驳回','已撤回','已过期'"`
+	ApproveId       int    `description:"审批人id"`
+	ApproveName     string `description:"审批人姓名"`
+	RefuseReason    string `description:"拒绝理由"`
+	RefuseTime      string `description:"拒绝时间"`
+	ApproveTime     string `description:"审批时间"`
+	CreateTime      string `description:"创建时间"`
+	ModifyTime      string `description:"修改时间"`
+	DepartmentId    int
+	GroupName       string `description:"分组"`
+	DayTotal        int    `description:"出差天数"`
+}
+
+type PeerItem struct {
+	PeerPeopleId   int    `description:"同行人id"`
+	PeerPeopleName string `description:"同行人"`
+	PeerGroupName  string
+}
+
+func GetBusinessTripApproveList(condition string, pars []interface{}) (list []*BusinessTripApproveView, err error) {
+	o := orm.NewOrm()
+	sql := ` SELECT a.*,b.department_id FROM business_apply AS a
+			 INNER JOIN admin AS b ON a.apply_admin_id=b.admin_id `
+	if condition != "" {
+		sql += condition
+	}
+	sql += ` ORDER BY a.create_time DESC `
+	_, err = o.Raw(sql, pars).QueryRows(&list)
+	return
+}

+ 60 - 0
models/tables/business_trip/business_calendar.go

@@ -0,0 +1,60 @@
+package business_trip
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+)
+
+type BusinessTripCalendarAdmin struct {
+	AdminId          int    `description:"研究员id"`
+	RealName         string `description:"研究员名称"`
+	BusinessTripList []*BusinessTripCalendar
+}
+
+type BusinessTripCalendar struct {
+	BusinessApplyId int    `description:"出差申请id"`
+	Status          string `description:"状态:'待审批','已审批','已驳回','已撤回','已过期'"`
+	WeekDate        string `description:"开始日期"`
+	City            string `description:"城市"`
+	Week            string `description:"周"`
+	WeekType        string `description:"当前周:current,下一周:next"`
+}
+
+// GetResearcherV2 获取研究员列表(冻结的也要)
+func GetBusinessTripCalendar(departmentId string) (list []*BusinessTripCalendarAdmin, err error) {
+	o := orm.NewOrm()
+	sql := ` SELECT a.admin_id,a.real_name 
+			FROM admin AS a
+			INNER JOIN sys_group AS b ON a.group_id=b.group_id
+			WHERE a.enabled=1
+			AND b.department_id IN(?)
+			ORDER BY a.admin_id ASC `
+	_, err = o.Raw(sql, departmentId).QueryRows(&list)
+	return
+}
+
+type BusinessTripCalendarGroup struct {
+	GroupId      int    `description:"分组id"`
+	GroupName    string `description:"分组名称"`
+	DepartmentId string `json:"-" description:"部门id"`
+	AdminList    []*BusinessTripCalendarAdmin
+}
+
+type BusinessTripCalendarResp struct {
+	GroupList []*BusinessTripCalendarGroup
+}
+
+func GetBusinessTripList(adminId, startDate, endDate string) (list []*BusinessApplyView, err error) {
+	o := orm.NewOrm()
+	sql := ` SELECT *
+			FROM  business_apply AS a
+			WHERE a.status IN('待审批','已审批')
+			AND ((a.arrive_date>=? AND a.arrive_date<=?) OR (a.return_date>=? AND a.return_date<=?)) `
+	if adminId != "" {
+		sql += ` AND a.apply_admin_id IN  (` + adminId + `)`
+		sql += ` ORDER BY a.apply_admin_id ASC,a.arrive_date ASC `
+	} else {
+		sql += ` ORDER BY a.apply_admin_id ASC,a.arrive_date ASC `
+	}
+	_, err = o.Raw(sql, startDate, endDate, startDate, endDate).QueryRows(&list)
+	return
+}

+ 39 - 29
models/tables/company_approval_message/company_approval_message.go

@@ -2,6 +2,7 @@ package company_approval_message
 
 import (
 	"github.com/beego/beego/v2/client/orm"
+	"hongze/hongze_mobile_admin/models/tables/business_trip"
 	"hongze/hongze_mobile_admin/utils"
 	"time"
 )
@@ -25,14 +26,14 @@ type CompanyApprovalMessage struct {
 	MessageInfo       string    `description:"消息主要内容,json数据"`
 }
 
-//添加审批消息
+// 添加审批消息
 func AddCompanyApprovalMessage(item *CompanyApprovalMessage) (err error) {
 	o := orm.NewOrm()
 	_, err = o.Insert(item)
 	return
 }
 
-//修改审批消息
+// 修改审批消息
 func ModifyCompanyApprovalMessage(companyApprovalId, sourceType int) (err error) {
 	o := orm.NewOrm()
 	sql := `UPDATE company_approval_message SET operation_status=2,modify_time=NOW() 
@@ -41,25 +42,26 @@ WHERE company_approval_id=? AND source_type=?  AND message_type=1 AND operation_
 	return
 }
 
-//消息列表结果
+// 消息列表结果
 type CompanyApprovalMessageList struct {
-	Id                int          `orm:"column(id);pk"`
-	CreateUserId      int          `description:"申请者id"`
-	MessageStatus     int          `description:"消息状态:0未读,1:已读,2:作废"`
-	MessageType       int          `description:"1:申请消息,2:审批结果,3:文字消息"`
-	ApprovalStatus    int          `description:"审批结果:1:待审批,2:已审批,3:已驳回"`
-	SourceType        int          `description:"消息来源类型,1:客户,2:合同,3:用印"`
-	Remark            string       `description:"备注信息"`
-	Content           string       `description:"消息内容"`
-	CompanyName       string       `description:"客户名称"`
-	CreateTime        time.Time    `description:"创建时间"`
-	RealName          string       `description:"销售名称"`
-	CompanyApprovalId int          `description:"审批单id"`
-	MessageInfo       string       `description:"消息主要内容,json数据" json:"-"`
-	ApprovalInfo      ApprovalInfo `description:"审批单信息"`
-}
-
-//消息审批单信息
+	Id                int                              `orm:"column(id);pk"`
+	CreateUserId      int                              `description:"申请者id"`
+	MessageStatus     int                              `description:"消息状态:0未读,1:已读,2:作废"`
+	MessageType       int                              `description:"1:申请消息,2:审批结果,3:文字消息"`
+	ApprovalStatus    int                              `description:"审批结果:1:待审批,2:已审批,3:已驳回"`
+	SourceType        int                              `description:"消息来源类型,1:客户,2:合同,3:用印"`
+	Remark            string                           `description:"备注信息"`
+	Content           string                           `description:"消息内容"`
+	CompanyName       string                           `description:"客户名称"`
+	CreateTime        time.Time                        `description:"创建时间"`
+	RealName          string                           `description:"销售名称"`
+	CompanyApprovalId int                              `description:"审批单id"`
+	MessageInfo       string                           `description:"消息主要内容,json数据" json:"-"`
+	ApprovalInfo      ApprovalInfo                     `description:"审批单信息"`
+	BusinessTripInfo  *business_trip.BusinessApplyView `description:"出差申请信息"`
+}
+
+// 消息审批单信息
 type ApprovalInfo struct {
 	ApplyName     string    `description:"申请人姓名"`
 	Type          string    `description:"类型"`
@@ -77,13 +79,13 @@ type CompanyApprovalMessageListResp struct {
 	Total int `description:"总数据条数"`
 }
 
-//待办消息列表
+// 待办消息列表
 type CompanyApprovalMessageListV2Resp struct {
 	Company  CompanyApprovalMessageListResp `description:"客户"`
 	Contract CompanyApprovalMessageListResp `description:"合同"`
 }
 
-//获取消息列表总数据
+// 获取消息列表总数据
 func GetCompanyApprovalMessageCount(sysUserId, sourceType int) (count int, err error) {
 	sql := `SELECT COUNT(1) AS count FROM company_approval_message AS a
 			INNER JOIN admin AS b ON a.create_user_id=b.admin_id
@@ -93,7 +95,7 @@ func GetCompanyApprovalMessageCount(sysUserId, sourceType int) (count int, err e
 	return
 }
 
-//消息列表页
+// 消息列表页
 func GetCompanyApprovalMessageList(sysUserId, startSize, pageSize int, sourceTypes []int) (items []*CompanyApprovalMessageList, err error) {
 	sql := `SELECT
 				a.*, b.real_name
@@ -108,7 +110,7 @@ func GetCompanyApprovalMessageList(sysUserId, startSize, pageSize int, sourceTyp
 	return
 }
 
-//获取最近一条消息
+// 获取最近一条消息
 func GetLastMessage(sysUserId, sourceType int) (item *CompanyApprovalMessageList, err error) {
 	sql := `SELECT a.*,b.real_name FROM company_approval_message AS a
 			INNER JOIN admin AS b ON a.create_user_id=b.admin_id
@@ -119,7 +121,7 @@ func GetLastMessage(sysUserId, sourceType int) (item *CompanyApprovalMessageList
 	return
 }
 
-//获取最近一条消息
+// 获取最近一条消息
 func GetLastMessageBySourceTypes(sysUserId int, sourceType []int) (item *CompanyApprovalMessageList, err error) {
 	sql := `SELECT
 				a.*, b.real_name
@@ -135,7 +137,7 @@ func GetLastMessageBySourceTypes(sysUserId int, sourceType []int) (item *Company
 	return
 }
 
-//获取未读消息数
+// 获取未读消息数
 func GetNotReadMessageTotal(sysUserId, sourceType int) (total int64, err error) {
 	sql := `SELECT count(*) total FROM company_approval_message AS a
 			INNER JOIN admin AS b ON a.create_user_id=b.admin_id
@@ -155,12 +157,12 @@ func GetCommentNotReadMessageTotal(sysUserId int, types []int) (total int64, err
 	return
 }
 
-//申请服务更新请求参数
+// 申请服务更新请求参数
 type CompanyApprovalMessageReadReq struct {
 	Id int `description:"消息id"`
 }
 
-//变更为消息已读状态
+// 变更为消息已读状态
 func ModifyCompanyApprovalMessageStatus(companyApprovalMessageId int) (err error) {
 	o := orm.NewOrm()
 	sql := `UPDATE company_approval_message SET message_status=1,modify_time=NOW() WHERE id=?`
@@ -168,7 +170,7 @@ func ModifyCompanyApprovalMessageStatus(companyApprovalMessageId int) (err error
 	return
 }
 
-//变更当前类型下所有未读消息为消息已读状态
+// 变更当前类型下所有未读消息为消息已读状态
 func ModifyAllCompanyApprovalMessageStatus(receiveUserId int, sourceTypes []int) (err error) {
 	o := orm.NewOrm()
 	sql := `UPDATE company_approval_message SET message_status=1,modify_time=NOW() WHERE receive_user_id = ? and source_type IN (` + utils.GetOrmInReplace(len(sourceTypes)) + `) and message_status=0`
@@ -185,3 +187,11 @@ WHERE company_approval_id=? AND source_type=?  AND message_type=1 AND operation_
 	_, err = o.Raw(sql, companyApprovalId, sourceType).Exec()
 	return
 }
+
+// 消息删除
+func DeleteCompanyApprovalMessage(companyApprovalId, sourceType int) (err error) {
+	o := orm.NewOrm()
+	sql := `DELETE FROM company_approval_message WHERE company_approval_id=? AND source_type=? `
+	_, err = o.Raw(sql, companyApprovalId, sourceType).Exec()
+	return
+}

+ 148 - 0
models/tables/system/sys_admin.go

@@ -0,0 +1,148 @@
+package system
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"github.com/rdlucklib/rdluck_tools/paging"
+	"time"
+)
+
+type AdminItem struct {
+	AdminId                 int    `description:"系统用户id"`
+	AdminName               string `description:"系统用户名称"`
+	RealName                string `description:"系统用户姓名"`
+	Password                string
+	LastUpdatedPasswordTime string `json:"-"`
+	Enabled                 int    `description:"1:有效,0:禁用"`
+	Email                   string `description:"系统用户邮箱"`
+	LastLoginTime           string
+	CreatedTime             time.Time
+	LastUpdatedTime         string
+	Role                    string `description:"系统用户角色"`
+	Mobile                  string `description:"手机号"`
+	RoleType                int    `description:"角色类型:1需要录入指标,0:不需要"`
+	RoleId                  int    `description:"角色id"`
+	RoleName                string `description:"角色名称"`
+	RoleTypeCode            string `description:"角色编码"`
+	DepartmentId            int    `description:"部门id"`
+	DepartmentName          string `json:"-" description:"部门名称"`
+	TeamId                  int    `description:"三级id"`
+	GroupId                 int    `description:"分组id"`
+	GroupName               string `json:"-" description:"分组名称"`
+	Authority               int    `description:"管理权限,0:无,1:部门负责人,2:小组负责人,或者ficc销售主管,4:ficc销售组长"`
+	Position                string `description:"职位"`
+	DepartmentGroup         string `description:"部门分组"`
+	LabelVal                int    `description:"标签:1:超级管理员,2:管理员,3:部门经理,4:组长,5:ficc销售主管"`
+	ResearchGroupName       string `description:"研究方向分组名称"`
+	Province                string `description:"省"`
+	ProvinceCode            string `description:"省编码"`
+	City                    string `description:"市"`
+	CityCode                string `description:"市编码"`
+}
+
+type AdminRespItem struct {
+	AdminId                 int    `description:"系统用户id"`
+	AdminName               string `description:"系统用户名称"`
+	RealName                string `description:"系统用户姓名"`
+	Password                string
+	LastUpdatedPasswordTime string `json:"-"`
+	Enabled                 int    `description:"1:有效,0:禁用"`
+	Email                   string `description:"系统用户邮箱"`
+	LastLoginTime           string
+	CreatedTime             time.Time
+	LastUpdatedTime         string
+	Role                    string `description:"系统用户角色"`
+	Mobile                  string `description:"手机号"`
+	RoleType                int    `description:"角色类型:1需要录入指标,0:不需要"`
+	RoleId                  int    `description:"角色id"`
+	RoleName                string `description:"角色名称"`
+	RoleTypeCode            string `description:"角色编码"`
+	DepartmentId            int    `description:"部门id"`
+	DepartmentName          string `json:"-" description:"部门名称"`
+	parentId                int    `description:"父级id"`
+	GroupId                 int    `description:"分组id"`
+	GroupName               string `json:"-" description:"分组名称"`
+	Authority               int    `description:"管理权限,0:无,1:部门负责人,2:小组负责人,或者ficc销售主管,4:ficc销售组长"`
+	Position                string `description:"职位"`
+	DepartmentGroup         string `description:"部门分组"`
+	LabelVal                int    `description:"标签:1:超级管理员,2:管理员,3:部门经理,4:组长,5:ficc销售主管"`
+}
+
+type SysuserListResp struct {
+	List   []*AdminItem
+	Paging *paging.PagingItem `description:"分页数据"`
+}
+
+type SysuserAddReq struct {
+	AdminName    string `description:"系统用户名称"`
+	AdminAvatar  string `description:"用户头像"`
+	RealName     string `description:"系统用户姓名"`
+	Password     string `description:"密码"`
+	Mobile       string `description:"手机号"`
+	RoleId       int    `description:"角色id"`
+	DepartmentId int    `description:"部门id"`
+	GroupId      int    `description:"分组id"`
+	TeamId       int    `description:"小组id"`
+	//Authority    int    `description:"管理权限,0:无,1:部门负责人,2:小组负责人"`
+	Position         string `description:"职位"`
+	ResearchGroupIds string `description:"研究方向分组IDs"`
+	Province         string `description:"省"`
+	ProvinceCode     string `description:"省编码"`
+	City             string `description:"市"`
+	CityCode         string `description:"市编码"`
+}
+
+type SysuserEditReq struct {
+	AdminId      int    `description:"系统用户id"`
+	AdminName    string `description:"系统用户名称"`
+	AdminAvatar  string `description:"用户头像"`
+	RealName     string `description:"系统用户姓名"`
+	Password     string `description:"密码"`
+	Mobile       string `description:"手机号"`
+	RoleId       int    `description:"角色id"`
+	DepartmentId int    `description:"部门id"`
+	GroupId      int    `description:"分组id"`
+	TeamId       int    `description:"小组id"`
+	Enabled      int    `description:"1:有效,0:禁用"`
+	//Authority    int    `description:"管理权限,0:无,1:部门负责人,2:小组负责人"`
+	Position         string `description:"职位"`
+	ResearchGroupIds string `description:"研究方向分组IDs"`
+	Province         string `description:"省"`
+	ProvinceCode     string `description:"省编码"`
+	City             string `description:"市"`
+	CityCode         string `description:"市编码"`
+}
+
+// 用户状态编辑
+type SysuserEditEnabledReq struct {
+	AdminId int `description:"系统用户id"`
+	Enabled int `description:"1:有效,0:禁用"`
+}
+
+type SysuserDeleteReq struct {
+	AdminId int `description:"系统用户id"`
+}
+
+func GetSysUserItems(condition string, pars []interface{}) (items []*AdminItem, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM admin WHERE 1=1 `
+	if condition != "" {
+		sql += condition
+	}
+	sql += `ORDER BY last_updated_time DESC `
+	_, err = o.Raw(sql, pars).QueryRows(&items)
+	return
+}
+
+type OpenIdList struct {
+	OpenId  string
+	AdminId int
+}
+
+// ResearcherAdminAndUser 研究员admin信息及wx_user信息
+type ResearcherAdminAndUser struct {
+	UserId    int    `description:"用户ID"`
+	UserName  string `description:"用户名称"`
+	AdminId   int    `description:"管理员ID"`
+	AdminName string `description:"管理员姓名"`
+	OpenId    string `description:"openid"`
+}

+ 55 - 0
models/tables/system/sys_department.go

@@ -0,0 +1,55 @@
+package system
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"time"
+)
+
+type SysDepartmentAddReq struct {
+	DepartmentName string `description:"部门名称"`
+}
+
+type SysDepartment struct {
+	DepartmentId   int       `orm:"column(department_id);pk" description:"部门Id"`
+	DepartmentName string    `description:"部门名称"`
+	CreateTime     time.Time `description:"创建时间"`
+}
+
+type SysDepartmentEditReq struct {
+	DepartmentId   int    `description:"部门Id"`
+	DepartmentName string `description:"部门名称"`
+}
+
+type SysDepartmentDeleteReq struct {
+	DepartmentId int `description:"部门Id"`
+}
+
+type SysDepartmentList struct {
+	DepartmentId   int             `orm:"column(department_id);pk" description:"部门Id"`
+	DepartmentName string          `description:"部门名称"`
+	CreateTime     time.Time       `description:"创建时间"`
+	Child          []*SysGroupList `description:"分组"`
+	IsDepartment   bool            `description:"true:部门,false:分组"`
+}
+
+func GetDepartmentList() (items []*SysDepartmentList, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM sys_department ORDER BY create_time ASC `
+	_, err = o.Raw(sql).QueryRows(&items)
+	return
+}
+
+type SysDepartmentListResp struct {
+	List []*SysDepartmentList
+}
+
+type DepartmentGroupSellers struct {
+	AdminId      string                   `description:"系统用户id"`
+	RealName     string                   `description:"用户真实名称"`
+	ChildrenList []DepartmentGroupSellers `description:"销售列表"`
+}
+
+// DepartmentGroupSellersResp 销售列表(根据部门、分组来)
+type DepartmentGroupSellersResp struct {
+	List []DepartmentGroupSellers
+}

+ 67 - 0
models/tables/system/sys_group.go

@@ -0,0 +1,67 @@
+package system
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"time"
+)
+
+type SysGroupAddReq struct {
+	DepartmentId int    `description:"部门Id"`
+	GroupName    string `description:"分组名称,多个用英文逗号隔开"`
+}
+
+type SysGroup struct {
+	GroupId      int       `orm:"column(group_id);pk" description:"分组ID"`
+	DepartmentId int       `description:"部门Id"`
+	ParentId     int       `description:"父级Id"`
+	GroupName    string    `description:"分组名称"`
+	CreateTime   time.Time `description:"创建时间"`
+}
+
+type SysGroupEditReq struct {
+	GroupId   int    `description:"分组ID"`
+	GroupName string `description:"分组名称"`
+}
+
+type SysGroupDeleteReq struct {
+	GroupId int `description:"分组ID"`
+}
+
+func DeleteSysGroup(groupId int) (err error) {
+	sql := `DELETE FROM sys_group WHERE group_id=? `
+	o := orm.NewOrm()
+	_, err = o.Raw(sql, groupId).Exec()
+	return
+}
+
+// 因前端显示需要,TopId字段用来当做一级部门id,DepartmentId为当前分组id
+type SysGroupList struct {
+	GroupId      int            `orm:"column(group_id);pk" json:"DepartmentId" description:"分组ID"`
+	ParentId     int            `json:"ParentId" description:"父级ID"`
+	DepartmentId int            `json:"TopId" description:"部门Id"`
+	GroupName    string         `json:"DepartmentName" description:"分组名称"`
+	Child        []*SysTeamList `description:"小组"`
+	CreateTime   time.Time      `description:"创建时间"`
+	IsGroup      bool           `description:"是否为二级部门"`
+}
+
+type SysFullGroup struct {
+	GroupId         int       `orm:"column(group_id);pk" description:"分组ID"`
+	DepartmentId    int       `description:"部门Id"`
+	ParentId        int       `description:"父级Id"`
+	GroupName       string    `description:"分组名称"`
+	ParentGroupName string    `description:"父级分组名称"`
+	DepartmentName  string    `description:"部门名称"`
+	CreateTime      time.Time `description:"创建时间"`
+}
+
+// GetFullGroup 获取完整的分组信息
+func GetFullGroup() (list []*SysFullGroup, err error) {
+	sql := `SELECT s.*,g.group_name as parent_group_name , d.department_name
+from sys_group s 
+LEFT JOIN sys_group g on s.parent_id=g.group_id
+LEFT JOIN sys_department d on s.department_id=d.department_id`
+	o := orm.NewOrm()
+	_, err = o.Raw(sql).QueryRows(&list)
+	return
+}

+ 35 - 0
models/tables/system/sys_team.go

@@ -0,0 +1,35 @@
+package system
+
+import (
+	"time"
+)
+
+type SysTeamAddReq struct {
+	GroupId      int    `description:"大组id"`
+	DepartmentId int    `description:"部门id"`
+	TeamName     string `description:"分组名称,多个用英文逗号隔开"`
+}
+
+type SysTeam struct {
+	GroupId      int       `orm:"column(group_id);pk" description:"分组ID"`
+	ParentId     int       `description:"父级Id"`
+	DepartmentId int       `description:"部门id"`
+	GroupName    string    `description:"分组名称"`
+	CreateTime   time.Time `description:"创建时间"`
+}
+
+type SysTeamEditReq struct {
+	TeamId   int    `description:"分组ID"`
+	TeamName string `description:"分组名称"`
+}
+
+type SysTeamDeleteReq struct {
+	TeamId int `description:"小组ID"`
+}
+
+type SysTeamList struct {
+	GroupId    int       `orm:"column(group_id);pk" json:"DepartmentId" description:"小组ID"`
+	ParentId   int       `json:"GroupId" description:"小组Id"`
+	GroupName  string    `json:"DepartmentName" description:"分组名称"`
+	CreateTime time.Time `description:"创建时间"`
+}

+ 90 - 0
routers/commentsRouter.go

@@ -7,6 +7,87 @@ import (
 
 func init() {
 
+    beego.GlobalControllerRouter["hongze/hongze_mobile_admin/controllers/business_trip:BusinessTrip"] = append(beego.GlobalControllerRouter["hongze/hongze_mobile_admin/controllers/business_trip:BusinessTrip"],
+        beego.ControllerComments{
+            Method: "ApplyAdd",
+            Router: `/apply/add`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["hongze/hongze_mobile_admin/controllers/business_trip:BusinessTrip"] = append(beego.GlobalControllerRouter["hongze/hongze_mobile_admin/controllers/business_trip:BusinessTrip"],
+        beego.ControllerComments{
+            Method: "ApplyApprove",
+            Router: `/apply/approve`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["hongze/hongze_mobile_admin/controllers/business_trip:BusinessTrip"] = append(beego.GlobalControllerRouter["hongze/hongze_mobile_admin/controllers/business_trip:BusinessTrip"],
+        beego.ControllerComments{
+            Method: "Back",
+            Router: `/apply/back`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["hongze/hongze_mobile_admin/controllers/business_trip:BusinessTrip"] = append(beego.GlobalControllerRouter["hongze/hongze_mobile_admin/controllers/business_trip:BusinessTrip"],
+        beego.ControllerComments{
+            Method: "Delete",
+            Router: `/apply/delete`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["hongze/hongze_mobile_admin/controllers/business_trip:BusinessTrip"] = append(beego.GlobalControllerRouter["hongze/hongze_mobile_admin/controllers/business_trip:BusinessTrip"],
+        beego.ControllerComments{
+            Method: "ApplyDetail",
+            Router: `/apply/detail`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["hongze/hongze_mobile_admin/controllers/business_trip:BusinessTrip"] = append(beego.GlobalControllerRouter["hongze/hongze_mobile_admin/controllers/business_trip:BusinessTrip"],
+        beego.ControllerComments{
+            Method: "ApplyEdit",
+            Router: `/apply/edit`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["hongze/hongze_mobile_admin/controllers/business_trip:BusinessTrip"] = append(beego.GlobalControllerRouter["hongze/hongze_mobile_admin/controllers/business_trip:BusinessTrip"],
+        beego.ControllerComments{
+            Method: "ApplyList",
+            Router: `/apply/list`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["hongze/hongze_mobile_admin/controllers/business_trip:BusinessTrip"] = append(beego.GlobalControllerRouter["hongze/hongze_mobile_admin/controllers/business_trip:BusinessTrip"],
+        beego.ControllerComments{
+            Method: "ApproveList",
+            Router: `/approve/list`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["hongze/hongze_mobile_admin/controllers/business_trip:BusinessTrip"] = append(beego.GlobalControllerRouter["hongze/hongze_mobile_admin/controllers/business_trip:BusinessTrip"],
+        beego.ControllerComments{
+            Method: "BusinessTripCalendar",
+            Router: `/calendar`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hongze_mobile_admin/controllers/roadshow:CalendarController"] = append(beego.GlobalControllerRouter["hongze/hongze_mobile_admin/controllers/roadshow:CalendarController"],
         beego.ControllerComments{
             Method: "Accept",
@@ -664,6 +745,15 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hongze_mobile_admin/controllers:SystemCommon"] = append(beego.GlobalControllerRouter["hongze/hongze_mobile_admin/controllers:SystemCommon"],
+        beego.ControllerComments{
+            Method: "SellerList",
+            Router: `/role/seller/list`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hongze_mobile_admin/controllers:VarietyTagController"] = append(beego.GlobalControllerRouter["hongze/hongze_mobile_admin/controllers:VarietyTagController"],
         beego.ControllerComments{
             Method: "TagTree",

+ 11 - 0
routers/router.go

@@ -11,6 +11,7 @@ package routers
 import (
 	"github.com/beego/beego/v2/server/web/filter/cors"
 	"hongze/hongze_mobile_admin/controllers"
+	"hongze/hongze_mobile_admin/controllers/business_trip"
 	"hongze/hongze_mobile_admin/controllers/roadshow"
 	"hongze/hongze_mobile_admin/controllers/yb"
 
@@ -98,6 +99,16 @@ func init() {
 				&controllers.VarietyTagController{},
 			),
 		),
+		web.NSNamespace("/business_trip",
+			web.NSInclude(
+				&business_trip.BusinessTrip{},
+			),
+		),
+		web.NSNamespace("/system",
+			web.NSInclude(
+				&controllers.SystemCommon{},
+			),
+		),
 	)
 	web.AddNamespace(ns)
 }

+ 151 - 22
utils/common.go

@@ -22,7 +22,7 @@ import (
 	"time"
 )
 
-//随机数种子
+// 随机数种子
 var rnd = rand.New(rand.NewSource(time.Now().UnixNano()))
 
 func GetRandString(size int) string {
@@ -59,13 +59,13 @@ func StringsToJSON(str string) string {
 	return jsons
 }
 
-//序列化
+// 序列化
 func ToString(v interface{}) string {
 	data, _ := json.Marshal(v)
 	return string(data)
 }
 
-//md5加密
+// md5加密
 func MD5(data string) string {
 	m := md5.Sum([]byte(data))
 	return hex.EncodeToString(m[:])
@@ -93,7 +93,7 @@ func GetToday(format string) string {
 	return today
 }
 
-//获取今天剩余秒数
+// 获取今天剩余秒数
 func GetTodayLastSecond() time.Duration {
 	today := GetToday(FormatDate) + " 23:59:59"
 	end, _ := time.ParseInLocation(FormatDateTime, today, time.Local)
@@ -115,7 +115,7 @@ func GetBrithDate(idcard string) string {
 	return GetToday(FormatDate)
 }
 
-//处理性别
+// 处理性别
 func WhichSexByIdcard(idcard string) string {
 	var sexs = [2]string{"女", "男"}
 	length := len(idcard)
@@ -129,7 +129,7 @@ func WhichSexByIdcard(idcard string) string {
 	return "男"
 }
 
-//截取小数点后几位
+// 截取小数点后几位
 func SubFloatToString(f float64, m int) string {
 	n := strconv.FormatFloat(f, 'f', -1, 64)
 	if n == "" {
@@ -148,14 +148,14 @@ func SubFloatToString(f float64, m int) string {
 	return newn[0] + "." + newn[1][:m]
 }
 
-//截取小数点后几位
+// 截取小数点后几位
 func SubFloatToFloat(f float64, m int) float64 {
 	newn := SubFloatToString(f, m)
 	newf, _ := strconv.ParseFloat(newn, 64)
 	return newf
 }
 
-//获取相差时间-年
+// 获取相差时间-年
 func GetYearDiffer(start_time, end_time string) int {
 	t1, _ := time.ParseInLocation("2006-01-02", start_time, time.Local)
 	t2, _ := time.ParseInLocation("2006-01-02", end_time, time.Local)
@@ -166,7 +166,7 @@ func GetYearDiffer(start_time, end_time string) int {
 	return age
 }
 
-//获取相差时间-秒
+// 获取相差时间-秒
 func GetSecondDifferByTime(start_time, end_time time.Time) int64 {
 	diff := end_time.Unix() - start_time.Unix()
 	return diff
@@ -193,7 +193,7 @@ func StrListToString(strList []string) (str string) {
 	return ""
 }
 
-//Token
+// Token
 func GetToken() string {
 	randStr := GetRandString(64)
 	token := MD5(randStr + Md5Key)
@@ -201,30 +201,30 @@ func GetToken() string {
 	return strings.ToUpper(token + GetRandString(tokenLen))
 }
 
-//数据没有记录
+// 数据没有记录
 func ErrNoRow() string {
 	return "<QuerySeter> no row found"
 }
 
-//校验邮箱格式
+// 校验邮箱格式
 func ValidateEmailFormatat(email string) bool {
 	reg := regexp.MustCompile(RegularEmail)
 	return reg.MatchString(email)
 }
 
-//验证是否是手机号
+// 验证是否是手机号
 func ValidateMobileFormatat(mobileNum string) bool {
 	reg := regexp.MustCompile(RegularMobile)
 	return reg.MatchString(mobileNum)
 }
 
-//判断文件是否存在
+// 判断文件是否存在
 func FileIsExist(filePath string) bool {
 	_, err := os.Stat(filePath)
 	return err == nil || os.IsExist(err)
 }
 
-//获取图片扩展名
+// 获取图片扩展名
 func GetImgExt(file string) (ext string, err error) {
 	var headerByte []byte
 	headerByte = make([]byte, 8)
@@ -267,7 +267,7 @@ func GetImgExt(file string) (ext string, err error) {
 	return ext, nil
 }
 
-//保存图片
+// 保存图片
 func SaveImage(path string, img image.Image) (err error) {
 	//需要保持的文件
 	imgfile, err := os.Create(path)
@@ -277,7 +277,7 @@ func SaveImage(path string, img image.Image) (err error) {
 	return err
 }
 
-//保存base64数据为文件
+// 保存base64数据为文件
 func SaveBase64ToFile(content, path string) error {
 	data, err := base64.StdEncoding.DecodeString(content)
 	if err != nil {
@@ -407,7 +407,7 @@ func GetWilsonScore(p, n float64) float64 {
 	return toFixed(((p+1.9208)/(p+n)-1.96*math.Sqrt(p*n/(p+n)+0.9604)/(p+n))/(1+3.8416/(p+n)), 2)
 }
 
-//将中文数字转化成数字,比如 第三百四十五章,返回第345章 不支持一亿及以上
+// 将中文数字转化成数字,比如 第三百四十五章,返回第345章 不支持一亿及以上
 func ChangeWordsToNum(str string) (numStr string) {
 	words := ([]rune)(str)
 	num := 0
@@ -554,7 +554,7 @@ func ConvertToFormatDay(excelDaysString string) string {
 	return resultTime
 }
 
-//人民币小写转大写
+// 人民币小写转大写
 func ConvertNumToCny(num float64) (str string, err error) {
 	strNum := strconv.FormatFloat(num*100, 'f', 0, 64)
 	sliceUnit := []string{"仟", "佰", "拾", "亿", "仟", "佰", "拾", "万", "仟", "佰", "拾", "元", "角", "分"}
@@ -735,7 +735,7 @@ func Implode(idIntList []int) (str string) {
 	return
 }
 
-//字符串类型时间转周几
+// 字符串类型时间转周几
 func StrDateTimeToWeek(strTime string) string {
 	var WeekDayMap = map[string]string{
 		"Monday":    "周一",
@@ -752,7 +752,7 @@ func StrDateTimeToWeek(strTime string) string {
 	return WeekDayMap[staweek_int]
 }
 
-//字符串转换为time
+// 字符串转换为time
 func StrTimeToTime(strTime string) time.Time {
 	timeLayout := "2006-01-02 15:04:05"  //转化所需模板
 	loc, _ := time.LoadLocation("Local") //重要:获取时区
@@ -813,4 +813,133 @@ func JoinStr2IntArr(str, sep string) (arr []int) {
 		arr = append(arr, v)
 	}
 	return
-}
+}
+
+// GetNextWeekMonday 获取下一周周一的时间
+func GetNextWeekMonday() time.Time {
+	nowMonday := GetNowWeekMonday()
+	return nowMonday.AddDate(0, 0, 7)
+}
+
+// GetNextWeekLastDay 获取下一周最后一天的时间
+func GetNextWeekLastDay() time.Time {
+	nowSunday := GetNowWeekLastDay()
+	return nowSunday.AddDate(0, 0, 7)
+}
+
+// GetNowWeekMonday 获取本周周一的时间
+func GetNowWeekMonday() time.Time {
+	offset := int(time.Monday - time.Now().Weekday())
+	if offset == 1 { //正好是周日,但是按照中国人的理解,周日是一周最后一天,而不是一周开始的第一天
+		offset = -6
+	}
+	mondayTime := time.Now().AddDate(0, 0, offset)
+	mondayTime = time.Date(mondayTime.Year(), mondayTime.Month(), mondayTime.Day(), 0, 0, 0, 0, mondayTime.Location())
+	return mondayTime
+}
+
+// GetNowWeekLastDay 获取本周最后一天的时间
+func GetNowWeekLastDay() time.Time {
+	offset := int(time.Monday - time.Now().Weekday())
+	if offset == 1 { //正好是周日,但是按照中国人的理解,周日是一周最后一天,而不是一周开始的第一天
+		offset = -6
+	}
+	firstDayTime := time.Now().AddDate(0, 0, offset)
+	firstDayTime = time.Date(firstDayTime.Year(), firstDayTime.Month(), firstDayTime.Day(), 0, 0, 0, 0, firstDayTime.Location()).AddDate(0, 0, 6)
+	lastDayTime := time.Date(firstDayTime.Year(), firstDayTime.Month(), firstDayTime.Day(), 23, 59, 59, 0, firstDayTime.Location())
+
+	return lastDayTime
+}
+
+// GetNowMonthFirstDay 获取本月第一天的时间
+func GetNowMonthFirstDay() time.Time {
+	nowMonthFirstDay := time.Date(time.Now().Year(), time.Now().Month(), 1, 0, 0, 0, 0, time.Now().Location())
+	return nowMonthFirstDay
+}
+
+// GetNowMonthLastDay 获取本月最后一天的时间
+func GetNowMonthLastDay() time.Time {
+	nowMonthLastDay := time.Date(time.Now().Year(), time.Now().Month(), 1, 0, 0, 0, 0, time.Now().Location()).AddDate(0, 1, -1)
+	nowMonthLastDay = time.Date(nowMonthLastDay.Year(), nowMonthLastDay.Month(), nowMonthLastDay.Day(), 23, 59, 59, 0, nowMonthLastDay.Location())
+	return nowMonthLastDay
+}
+
+// GetNowQuarterFirstDay 获取本季度第一天的时间
+func GetNowQuarterFirstDay() time.Time {
+	month := int(time.Now().Month())
+	var nowQuarterFirstDay time.Time
+	if month >= 1 && month <= 3 {
+		//1月1号
+		nowQuarterFirstDay = time.Date(time.Now().Year(), 1, 1, 0, 0, 0, 0, time.Now().Location())
+	} else if month >= 4 && month <= 6 {
+		//4月1号
+		nowQuarterFirstDay = time.Date(time.Now().Year(), 4, 1, 0, 0, 0, 0, time.Now().Location())
+	} else if month >= 7 && month <= 9 {
+		nowQuarterFirstDay = time.Date(time.Now().Year(), 7, 1, 0, 0, 0, 0, time.Now().Location())
+	} else {
+		nowQuarterFirstDay = time.Date(time.Now().Year(), 10, 1, 0, 0, 0, 0, time.Now().Location())
+	}
+	return nowQuarterFirstDay
+}
+
+// GetNowQuarterLastDay 获取本季度最后一天的时间
+func GetNowQuarterLastDay() time.Time {
+	month := int(time.Now().Month())
+	var nowQuarterLastDay time.Time
+	if month >= 1 && month <= 3 {
+		//03-31 23:59:59
+		nowQuarterLastDay = time.Date(time.Now().Year(), 3, 31, 23, 59, 59, 0, time.Now().Location())
+	} else if month >= 4 && month <= 6 {
+		//06-30 23:59:59
+		nowQuarterLastDay = time.Date(time.Now().Year(), 6, 30, 23, 59, 59, 0, time.Now().Location())
+	} else if month >= 7 && month <= 9 {
+		//09-30 23:59:59
+		nowQuarterLastDay = time.Date(time.Now().Year(), 9, 30, 23, 59, 59, 0, time.Now().Location())
+	} else {
+		//12-31 23:59:59
+		nowQuarterLastDay = time.Date(time.Now().Year(), 12, 31, 23, 59, 59, 0, time.Now().Location())
+	}
+	return nowQuarterLastDay
+}
+
+// GetNowHalfYearFirstDay 获取当前半年的第一天的时间
+func GetNowHalfYearFirstDay() time.Time {
+	month := int(time.Now().Month())
+	var nowHalfYearLastDay time.Time
+	if month >= 1 && month <= 6 {
+		//03-31 23:59:59
+		nowHalfYearLastDay = time.Date(time.Now().Year(), 1, 1, 0, 0, 0, 0, time.Now().Location())
+	} else {
+		//12-31 23:59:59
+		nowHalfYearLastDay = time.Date(time.Now().Year(), 7, 1, 0, 0, 0, 0, time.Now().Location())
+	}
+	return nowHalfYearLastDay
+}
+
+// GetNowHalfYearLastDay 获取当前半年的最后一天的时间
+func GetNowHalfYearLastDay() time.Time {
+	month := int(time.Now().Month())
+	var nowHalfYearLastDay time.Time
+	if month >= 1 && month <= 6 {
+		//03-31 23:59:59
+		nowHalfYearLastDay = time.Date(time.Now().Year(), 6, 30, 23, 59, 59, 0, time.Now().Location())
+	} else {
+		//12-31 23:59:59
+		nowHalfYearLastDay = time.Date(time.Now().Year(), 12, 31, 23, 59, 59, 0, time.Now().Location())
+	}
+	return nowHalfYearLastDay
+}
+
+// GetNowYearFirstDay 获取当前年的最后一天的时间
+func GetNowYearFirstDay() time.Time {
+	//12-31 23:59:59
+	nowYearFirstDay := time.Date(time.Now().Year(), 1, 1, 0, 0, 0, 0, time.Now().Location())
+	return nowYearFirstDay
+}
+
+// GetNowYearLastDay 获取当前年的最后一天的时间
+func GetNowYearLastDay() time.Time {
+	//12-31 23:59:59
+	nowYearLastDay := time.Date(time.Now().Year(), 12, 31, 23, 59, 59, 0, time.Now().Location())
+	return nowYearLastDay
+}