| | |
| | | ctx.Fail(errCode) |
| | | return |
| | | } |
| | | if params.CodeRule.Method != 1 { |
| | | count, err := model.NewSaleChanceSearch().SetNumber(saleChance.Number).Count() |
| | | if err != nil { |
| | | ctx.FailWithMsg(ecode.UnknownErr, "编码验证失败") |
| | | return |
| | | } |
| | | if count > 0 { |
| | | ctx.FailWithMsg(ecode.UnknownErr, "销售机会编码已存在") |
| | | return |
| | | } |
| | | |
| | | count, err := model.NewSaleChanceSearch().SetNumber(saleChance.Number).Count() |
| | | if err != nil { |
| | | ctx.FailWithMsg(ecode.UnknownErr, "编码验证失败") |
| | | return |
| | | } |
| | | if count > 0 { |
| | | ctx.FailWithMsg(ecode.UnknownErr, "销售机会编码已存在") |
| | | return |
| | | } |
| | | |
| | | if saleChance.MemberId == 0 { |
| | |
| | | if errCode != ecode.OK { |
| | | ctx.Fail(errCode) |
| | | return |
| | | } |
| | | |
| | | if params.CodeRule.Method == 1 { |
| | | autoCode := model.GetAutoCode(saleChance.Id, ¶ms.CodeRule) |
| | | m := map[string]interface{}{ |
| | | "number": autoCode, |
| | | } |
| | | _ = model.NewSaleChanceSearch().SetId(saleChance.Id).UpdateByMap(m) |
| | | } |
| | | |
| | | ctx.Ok() |
| | |
| | | sc.Address.CountryId = saleChance.Address.CountryId |
| | | sc.Address.ProvinceId = saleChance.Address.ProvinceId |
| | | sc.CodeStandID = saleChance.CodeStandID |
| | | sc.Products = saleChance.Products |
| | | |
| | | return ecode.OK, sc |
| | | } |