|
@@ -86,7 +86,7 @@ func (this *BusinessTrip) ApplyAdd() {
|
|
|
|
|
|
//校验出差日期冲突
|
|
|
{
|
|
|
- businessApplyCount, err := business_trip.CheckBusinessApplyDate(req.ArriveDate, req.ReturnDate, "'待审批','已审批'", sysUser.AdminId, 0)
|
|
|
+ businessApplyCount, err := business_trip.CheckBusinessApplyDate(req.ArriveDate, req.ReturnDate, "'待审批','已通过'", sysUser.AdminId, 0)
|
|
|
if err != nil {
|
|
|
this.FailWithMessage("时间冲突检测失败", "时间冲突检测失败-CheckBusinessApplyDate!Err:"+err.Error())
|
|
|
return
|
|
@@ -99,7 +99,7 @@ func (this *BusinessTrip) ApplyAdd() {
|
|
|
|
|
|
//校验申请人,是否被邀请为同行人,并且出差日期冲突
|
|
|
{
|
|
|
- peerCount, err := business_trip.CheckBusinessApplyPeerDate(req.ArriveDate, req.ReturnDate, "'待审批','已审批'", sysUser.AdminId, 0)
|
|
|
+ peerCount, err := business_trip.CheckBusinessApplyPeerDate(req.ArriveDate, req.ReturnDate, "'待审批','已通过'", sysUser.AdminId, 0)
|
|
|
if err != nil {
|
|
|
this.FailWithMessage("时间冲突检测失败", "时间冲突检测失败-CheckBusinessApplyPeerDate!Err:"+err.Error())
|
|
|
return
|
|
@@ -125,7 +125,7 @@ func (this *BusinessTrip) ApplyAdd() {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- peerCount, err := business_trip.CheckBusinessApplyPeerDate(req.ArriveDate, req.ReturnDate, "'待审批','已审批'", peerId, 0)
|
|
|
+ peerCount, err := business_trip.CheckBusinessApplyPeerDate(req.ArriveDate, req.ReturnDate, "'待审批','已通过'", peerId, 0)
|
|
|
if err != nil {
|
|
|
this.FailWithMessage("时间冲突检测失败", "时间冲突检测失败-CheckBusinessApplyPeerDate!Err:"+err.Error())
|
|
|
return
|
|
@@ -301,7 +301,7 @@ func (this *BusinessTrip) ApplyEdit() {
|
|
|
|
|
|
//校验出差日期冲突
|
|
|
{
|
|
|
- businessApplyCount, err := business_trip.CheckBusinessApplyDate(req.ArriveDate, req.ReturnDate, "'待审批','已审批'", sysUser.AdminId, req.BusinessApplyId)
|
|
|
+ businessApplyCount, err := business_trip.CheckBusinessApplyDate(req.ArriveDate, req.ReturnDate, "'待审批','已通过'", sysUser.AdminId, req.BusinessApplyId)
|
|
|
if err != nil {
|
|
|
this.FailWithMessage("时间冲突检测失败", "时间冲突检测失败-CheckBusinessApplyDate!Err:"+err.Error())
|
|
|
return
|
|
@@ -314,7 +314,7 @@ func (this *BusinessTrip) ApplyEdit() {
|
|
|
|
|
|
//校验申请人,是否被邀请为同行人,并且出差日期冲突
|
|
|
{
|
|
|
- peerCount, err := business_trip.CheckBusinessApplyPeerDate(req.ArriveDate, req.ReturnDate, "'待审批','已审批'", sysUser.AdminId, 0)
|
|
|
+ peerCount, err := business_trip.CheckBusinessApplyPeerDate(req.ArriveDate, req.ReturnDate, "'待审批','已通过'", sysUser.AdminId, 0)
|
|
|
if err != nil {
|
|
|
this.FailWithMessage("时间冲突检测失败", "时间冲突检测失败-CheckBusinessApplyPeerDate!Err:"+err.Error())
|
|
|
return
|
|
@@ -340,7 +340,7 @@ func (this *BusinessTrip) ApplyEdit() {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- peerCount, err := business_trip.CheckBusinessApplyPeerDate(req.ArriveDate, req.ReturnDate, "'待审批','已审批'", peerId, req.BusinessApplyId)
|
|
|
+ peerCount, err := business_trip.CheckBusinessApplyPeerDate(req.ArriveDate, req.ReturnDate, "'待审批','已通过'", peerId, req.BusinessApplyId)
|
|
|
if err != nil {
|
|
|
this.FailWithMessage("时间冲突检测失败", "时间冲突检测失败-CheckBusinessApplyPeerDate!Err:"+err.Error())
|
|
|
return
|
|
@@ -371,8 +371,8 @@ func (this *BusinessTrip) ApplyEdit() {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- if businessApplyItem.Status == "已审批" {
|
|
|
- this.FailWithMessage("已审批,不可进行重新申请操作!", "已审批,不可进行重新申请操作!")
|
|
|
+ if businessApplyItem.Status == "已通过" {
|
|
|
+ this.FailWithMessage("已通过,不可进行重新申请操作!", "已通过,不可进行重新申请操作!")
|
|
|
return
|
|
|
} else if businessApplyItem.Status == "已过期" {
|
|
|
this.FailWithMessage("已过期,不可进行重新申请操作!", "已过期,不可进行重新申请操作!")
|
|
@@ -581,6 +581,13 @@ func (this *BusinessTrip) Delete() {
|
|
|
this.FailWithMessage("删除失败!", "删除失败!DeleteBusinessApply:"+err.Error())
|
|
|
return
|
|
|
}
|
|
|
+ if businessApplyItem.PeerPeopleId != "" {
|
|
|
+ err = business_trip.DeleteBusinessApplyPeer(businessApplyItem.BusinessApplyId)
|
|
|
+ if err != nil {
|
|
|
+ this.FailWithMessage("删除失败!", "删除失败!DeleteBusinessApplyPeer:"+err.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
//删除系统消息
|
|
|
go company_approval_message.DeleteCompanyApprovalMessage(req.BusinessApplyId, 10)
|
|
|
this.OkWithMessage("删除成功")
|
|
@@ -616,8 +623,8 @@ func (this *BusinessTrip) Back() {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- if businessApplyItem.Status == "已审批" {
|
|
|
- this.FailWithMessage("已审批,不可进行撤回操作!", "已审批,不可进行撤回操作!")
|
|
|
+ if businessApplyItem.Status == "已通过" {
|
|
|
+ this.FailWithMessage("已通过,不可进行撤回操作!", "已通过,不可进行撤回操作!")
|
|
|
return
|
|
|
} else if businessApplyItem.Status == "已驳回" {
|
|
|
this.FailWithMessage("已驳回,不可进行撤回操作!", "已驳回,不可进行撤回操作!")
|
|
@@ -645,6 +652,23 @@ func (this *BusinessTrip) Back() {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
+ if businessApplyItem.PeerPeopleId != "" {
|
|
|
+ peerWhereParams := make(map[string]interface{})
|
|
|
+ peerUpdateParams := make(map[string]interface{})
|
|
|
+
|
|
|
+ whereParams["business_apply_id"] = req.BusinessApplyId
|
|
|
+
|
|
|
+ peerUpdateParams["status"] = "已撤回"
|
|
|
+ peerUpdateParams["modify_time"] = time.Now()
|
|
|
+
|
|
|
+ err = business_trip.UpdateBusinessApplyPeer(peerWhereParams, peerUpdateParams)
|
|
|
+
|
|
|
+ if err != nil {
|
|
|
+ this.FailWithMessage("撤回失败", "撤回失败!UpdateBusinessApplyPeer:"+err.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
//删除系统消息
|
|
|
go company_approval_message.DeleteCompanyApprovalMessage(req.BusinessApplyId, 10)
|
|
|
|
|
@@ -678,3 +702,86 @@ func (this *BusinessTrip) ApplyDetail() {
|
|
|
}
|
|
|
this.OkDetailed(item, "获取成功")
|
|
|
}
|
|
|
+
|
|
|
+// @Title 关闭接口
|
|
|
+// @Description 关闭接口
|
|
|
+// @Param request body business_trip.BusinessApplyCloseReq true "type json string"
|
|
|
+// @Success Ret=200 保存成功
|
|
|
+// @router /apply/close [post]
|
|
|
+func (this *BusinessTrip) Close() {
|
|
|
+ sysUser := this.AdminWx
|
|
|
+ sysUserId := sysUser.AdminId
|
|
|
+ var req business_trip.BusinessApplyCloseReq
|
|
|
+ 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("出差申请已被删除,请刷新页面!", "出差申请已被删除,请刷新页面:"+strconv.Itoa(req.BusinessApplyId))
|
|
|
+ return
|
|
|
+ }
|
|
|
+ this.FailWithMessage("获取数据失败!", "获取数据失败!GetBusinessApplyById:"+err.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ fmt.Println(req.BusinessApplyId)
|
|
|
+ fmt.Println(req.CloseReason)
|
|
|
+
|
|
|
+ whereParams := make(map[string]interface{})
|
|
|
+ updateParams := make(map[string]interface{})
|
|
|
+
|
|
|
+ whereParams["business_apply_id"] = req.BusinessApplyId
|
|
|
+ updateParams["status"] = "已关闭"
|
|
|
+ updateParams["close_reason"] = req.CloseReason
|
|
|
+ updateParams["modify_time"] = time.Now()
|
|
|
+ updateParams["close_time"] = time.Now()
|
|
|
+
|
|
|
+ err = business_trip.UpdateBusinessApply(whereParams, updateParams)
|
|
|
+ if err != nil {
|
|
|
+ this.FailWithMessage("关闭失败!", "关闭失败!UpdateBusinessApply:"+err.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ peerWhereParams := make(map[string]interface{})
|
|
|
+ peerUpdateParams := make(map[string]interface{})
|
|
|
+
|
|
|
+ peerWhereParams["business_apply_id"] = req.BusinessApplyId
|
|
|
+
|
|
|
+ peerUpdateParams["status"] = "已关闭"
|
|
|
+ peerUpdateParams["modify_time"] = time.Now()
|
|
|
+
|
|
|
+ err = business_trip.UpdateBusinessApplyPeer(peerWhereParams, peerUpdateParams)
|
|
|
+ if err != nil {
|
|
|
+ this.FailWithMessage("关闭失败!", "关闭失败!UpdateBusinessApplyPeer:"+err.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ {
|
|
|
+ //系统消息
|
|
|
+ sourceType := 10
|
|
|
+ content := businessApplyItem.ApplyRealName + " " + businessApplyItem.Province + businessApplyItem.City + businessApplyItem.Reason + "出差申请已关闭"
|
|
|
+ go services.AddCompanyApprovalMessage(sysUserId, businessApplyItem.ApplyAdminId, 0, businessApplyItem.BusinessApplyId, 1, sourceType, 1, "", content, content, "", "")
|
|
|
+ }
|
|
|
+
|
|
|
+ //模板消息
|
|
|
+ {
|
|
|
+ status := "已关闭"
|
|
|
+ applyItem, _ := admin.GetAdminById(businessApplyItem.ApplyAdminId)
|
|
|
+ wxAppPath := "pages-approve/businessTrip/detail?id=" + strconv.Itoa(req.BusinessApplyId)
|
|
|
+ first := "您的出差申请已被关闭"
|
|
|
+ keyword1 := businessApplyItem.Reason + "出差申请" + status
|
|
|
+ keyword2 := status
|
|
|
+ var remark string
|
|
|
+ go services.SendWxMsgWithRoadshowDeleteNotice(first, keyword1, keyword2, remark, wxAppPath, applyItem.Mobile)
|
|
|
+ }
|
|
|
+ this.OkWithMessage("关闭成功")
|
|
|
+}
|