|
@@ -678,3 +678,83 @@ 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
|
|
|
+ }
|
|
|
+
|
|
|
+ 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("关闭成功")
|
|
|
+}
|