1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- // 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/common.in/clinit"
- "adm-ads/consts"
- "adm-ads/model"
- "encoding/json"
- "gorm.io/gorm"
- "strings"
- )
- // 处理任务8的删除
- func handleTask17Delete(ads17 *model.Ads17) error {
- err := ads17.Delete(clinit.DB(),map[string]interface{}{"vin":ads17.Vin})
- if err == gorm.ErrRecordNotFound{
- return nil
- }
- return err
- }
- // 处理任务8的插入
- func handleTask17InsertOrUpdate(ads17 *model.Ads17)error{
- err := ads17.Insert(clinit.DB())
- if err != nil && !strings.Contains(err.Error(), "Duplicate") {
- return err
- }
- return nil
- }
- // 交强险投保记录
- func Task17(adsMsg *apis.AdsMessage) (err error) {
- ads17 := &model.Ads17{}
- json.Unmarshal([]byte(adsMsg.Content),&ads17)
- if (ads17.Vin == "") || (ads17.InsuranceDate == "" ){
- return nil
- }
- ads17.InsuranceDate = strings.Split(ads17.InsuranceDate," ")[0]
- if adsMsg.Action == consts.ACTIONDELETE{
- // 删除
- err = handleTask17Delete(ads17)
- }else{
- // 新增或插入
- err = handleTask17InsertOrUpdate(ads17)
- }
- return err
- }
|