Merge branch 'sxy' into dev
This commit is contained in:
commit
df96102509
@ -289,7 +289,17 @@ 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,9 +332,14 @@ 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)
|
||||||
}
|
}
|
||||||
@ -424,14 +429,18 @@ 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)
|
||||||
@ -447,6 +456,17 @@ 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