123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- // 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/consts"
- "adm-ads/model"
- "encoding/json"
- "strings"
- "adm-ads/common.in/clinit"
- "gorm.io/gorm"
- )
- // 处理任务23的删除
- func handleTask23Delete(ads23 *model.Ads23) error {
- err := ads23.Delete(clinit.DB(), map[string]interface{}{"vin": ads23.Vin, "third_style_id": ads23.ThirdStyleId, "source": ads23.Source})
- if err == gorm.ErrRecordNotFound {
- return nil
- }
- return err
- }
- // 处理任务23的插入
- func handleTask23InsertOrUpdate(ads23 *model.Ads23) error {
- err := ads23.Insert(clinit.DB())
- if err != nil && !strings.Contains(err.Error(), "Duplicate") {
- return err
- }
- return nil
- }
- // vin模糊定型
- func Task23(adsMsg *apis.AdsMessage) (err error) {
- ads23 := &model.Ads23{}
- json.Unmarshal([]byte(adsMsg.Content), &ads23)
- if ads23.Vin == "" || ads23.ThirdStyleId == "" {
- return nil
- }
- if adsMsg.Action == consts.ACTIONDELETE {
- // 删除
- err = handleTask23Delete(ads23)
- } else {
- // 新增或插入
- err = handleTask23InsertOrUpdate(ads23)
- }
- return err
- }
|