1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- // Copyright 2019 getensh.com. All rights reserved.
- // Use of this source code is governed by getensh.com.
- package task
- import (
- "adm-ads/apis"
- "adm-ads/model"
- "encoding/json"
- "strings"
- "adm-ads/common.in/clinit"
- "gorm.io/gorm"
- )
- // vin码model_no关系
- func Task21(adsMsg *apis.AdsMessage) (err error) {
- ads21 := &model.Ads21{}
- err = json.Unmarshal([]byte(adsMsg.Content), ads21)
- if err != nil {
- return nil
- }
- if ads21.ModelNo == "" || ads21.VinRule == "" || ads21.Uniq == "" {
- return nil
- }
- db := clinit.DB()
- err = ads21.Query(db, map[string]interface{}{"uniq": ads21.Uniq})
- if err != nil {
- if err != gorm.ErrRecordNotFound {
- return err
- }
- } else {
- return nil
- }
- err = ads21.Insert(db)
- if err != nil {
- if !strings.Contains(err.Error(), "Duplicate") {
- return err
- } else {
- return nil
- }
- }
- return nil
- }
|