Compare commits
No commits in common. "df9610250951ec61218fd4b91e203254e286463a" and "412e679b947b8a2e6f1124e8e13064c3af21b259" have entirely different histories.
df96102509
...
412e679b94
@ -289,17 +289,7 @@ func TxUpdateBundleLang(tx *gorm.DB, uuid string, language string, columns map[s
|
|||||||
func CreateBundleToValueAddService(tx *gorm.DB, records []*model.BundleToValueAddService) error {
|
func CreateBundleToValueAddService(tx *gorm.DB, records []*model.BundleToValueAddService) error {
|
||||||
return tx.Model(&model.BundleToValueAddService{}).Create(&records).Error
|
return tx.Model(&model.BundleToValueAddService{}).Create(&records).Error
|
||||||
}
|
}
|
||||||
func UpdateBundleToValueAddService(tx *gorm.DB, records []*model.BundleToValueAddService) error {
|
|
||||||
columns := make(map[string]interface{})
|
|
||||||
for _, record := range records {
|
|
||||||
columns["is_display"] = record.IsDisplay
|
|
||||||
err := tx.Model(&model.BundleToValueAddService{}).Where("bundle_uuid = ? AND value_uid = ?", record.BundleUuid, record.ValueUid).Updates(columns).Error
|
|
||||||
if err != nil {
|
|
||||||
return commonErr.ReturnError(err, msg.ErrorUpdateBundleInfo, "更新套餐信息失败: ")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
func DeleteBundleToValueAddService(tx *gorm.DB, bundleUuid, valueUid string) error {
|
func DeleteBundleToValueAddService(tx *gorm.DB, bundleUuid, valueUid string) error {
|
||||||
return tx.Where("bundle_uuid = ? AND value_uid = ?", bundleUuid, valueUid).Delete(&model.BundleToValueAddService{}).Error
|
return tx.Where("bundle_uuid = ? AND value_uid = ?", bundleUuid, valueUid).Delete(&model.BundleToValueAddService{}).Error
|
||||||
}
|
}
|
||||||
|
@ -332,14 +332,9 @@ func BundleDetailV2(req *bundle.BundleDetailRequest) (res *bundle.BundleDetailRe
|
|||||||
bundleProfile.Contract = detail.Contract
|
bundleProfile.Contract = detail.Contract
|
||||||
if detail.BundleToValueAddService != nil && len(detail.BundleToValueAddService) > 0 {
|
if detail.BundleToValueAddService != nil && len(detail.BundleToValueAddService) > 0 {
|
||||||
for _, valueAddService := range detail.BundleToValueAddService {
|
for _, valueAddService := range detail.BundleToValueAddService {
|
||||||
valueAddDetail, err := dao.ValueAddServiceDetailByUuidAndLanguage(valueAddService.ValueUid, req.Language)
|
|
||||||
if err != nil {
|
|
||||||
return res, errors.New("查询增值服务失败")
|
|
||||||
}
|
|
||||||
selectValueAddService := &bundle.SelectValueAddService{
|
selectValueAddService := &bundle.SelectValueAddService{
|
||||||
ValueAddUuid: valueAddService.ValueUid,
|
ValueAddUuid: valueAddService.ValueUid,
|
||||||
IsDisplay: valueAddService.IsDisplay,
|
IsDisplay: valueAddService.IsDisplay,
|
||||||
ServiceName: valueAddDetail.ServiceName,
|
|
||||||
}
|
}
|
||||||
selectValueAddServices = append(selectValueAddServices, selectValueAddService)
|
selectValueAddServices = append(selectValueAddServices, selectValueAddService)
|
||||||
}
|
}
|
||||||
@ -429,18 +424,14 @@ func diffUpdateBundleToValueAddService(tx *gorm.DB, bundleUuid string, selectSer
|
|||||||
}
|
}
|
||||||
// 需要新增的
|
// 需要新增的
|
||||||
toAdd := make([]*model.BundleToValueAddService, 0)
|
toAdd := make([]*model.BundleToValueAddService, 0)
|
||||||
toDel := make([]string, 0)
|
|
||||||
toUpdate := make([]*model.BundleToValueAddService, 0)
|
|
||||||
for uid, s := range newUuids {
|
for uid, s := range newUuids {
|
||||||
if _, exist := oldSet[uid]; !exist {
|
if _, exist := oldSet[uid]; !exist {
|
||||||
s.BundleUuid = bundleUuid
|
s.BundleUuid = bundleUuid
|
||||||
toAdd = append(toAdd, s)
|
toAdd = append(toAdd, s)
|
||||||
} else {
|
|
||||||
s.BundleUuid = bundleUuid
|
|
||||||
toUpdate = append(toUpdate, s)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 需要删除的
|
// 需要删除的
|
||||||
|
toDel := make([]string, 0)
|
||||||
for _, uid := range oldUuids {
|
for _, uid := range oldUuids {
|
||||||
if _, exist := newUuids[uid]; !exist {
|
if _, exist := newUuids[uid]; !exist {
|
||||||
toDel = append(toDel, uid)
|
toDel = append(toDel, uid)
|
||||||
@ -456,17 +447,6 @@ func diffUpdateBundleToValueAddService(tx *gorm.DB, bundleUuid string, selectSer
|
|||||||
return errors.New("保存套餐与增值服务关联失败")
|
return errors.New("保存套餐与增值服务关联失败")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if len(toUpdate) > 0 {
|
|
||||||
updates := make(map[string]interface{})
|
|
||||||
var uids []string
|
|
||||||
for _, record := range toUpdate {
|
|
||||||
uids = append(uids, record.ValueUid)
|
|
||||||
updates["is_display"] = record.IsDisplay
|
|
||||||
}
|
|
||||||
if err = dao.UpdateBundleToValueAddService(tx, toUpdate); err != nil {
|
|
||||||
return errors.New("保存套餐与增值服务关联失败")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
func saveBundleHistory(tx *gorm.DB, bundleUuid string, operator string, operatorId uint64) error {
|
func saveBundleHistory(tx *gorm.DB, bundleUuid string, operator string, operatorId uint64) error {
|
||||||
|
Loading…
Reference in New Issue
Block a user