|
@@ -42,6 +42,10 @@ func BillProduce(r *GinRouter) {
|
|
|
|
|
|
func ProduceReview(c *gin.Context, apictx *ApiSession) (interface{}, error) {
|
|
|
_id := c.Param("id")
|
|
|
+ id, err := primitive.ObjectIDFromHex(_id)
|
|
|
+ if err != nil {
|
|
|
+ return nil, errors.New("id错误")
|
|
|
+ }
|
|
|
userId, err := primitive.ObjectIDFromHex(apictx.User.Parent)
|
|
|
if err != nil {
|
|
|
return nil, errors.New("用户异常")
|
|
@@ -53,8 +57,24 @@ func ProduceReview(c *gin.Context, apictx *ApiSession) (interface{}, error) {
|
|
|
if !isManager(user.Roles) {
|
|
|
return nil, errors.New("该用户没有权限")
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+ bill := model.ProduceBill{}
|
|
|
+ repo.RepoSeachDoc(apictx.CreateRepoCtx(), &repo.DocSearchOptions{
|
|
|
+ CollectName: repo.CollectionBillProduce,
|
|
|
+ Query: repo.Map{"_id": id, "reviewed": 1},
|
|
|
+ }, &bill)
|
|
|
signs := make([]primitive.ObjectID, 0)
|
|
|
+ if len(bill.SignUsers) > 0 {
|
|
|
+
|
|
|
+ for _, signUser := range bill.SignUsers {
|
|
|
+ if signUser == userId {
|
|
|
+ return nil, errors.New("该单据您已审核过了")
|
|
|
+ }
|
|
|
+ }
|
|
|
+ signs = bill.SignUsers
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
signs = append(signs, userId)
|
|
|
produce := model.ProduceBill{
|
|
|
Reviewed: 1,
|