feat: publish member notices and balance-aware order settlement
Deploy olons-admin production / deploy (push) Successful in 8m50s
Deploy olons-admin production / deploy (push) Successful in 8m50s
This commit is contained in:
@@ -65,7 +65,7 @@ func (s *sSysAppMember) List(ctx context.Context, in *sysin.AppMemberListInp) (l
|
||||
LeftJoin(dao.UrlPool.Table()+" up", col("up", uc.Id)+"="+col("ub", bc.UrlPoolId)).
|
||||
Fields(
|
||||
col("m", mc.Id), col("m", mc.MemberNo), col("m", mc.Username), col("m", mc.Mobile),
|
||||
col("p", pc.RealNameMask), fmt.Sprintf("COALESCE(%s,0) available_amount", col("w", wc.AvailableAmount)),
|
||||
col("p", pc.RealNameCipher), col("p", pc.RealNameMask), fmt.Sprintf("COALESCE(%s,0) available_amount", col("w", wc.AvailableAmount)),
|
||||
fmt.Sprintf("COALESCE(%s,0) frozen_amount", col("w", wc.FrozenAmount)), col("m", mc.ParentId),
|
||||
fmt.Sprintf("COALESCE(%s,'') parent_username", col("parent", mc.Username)), col("m", mc.InviteCode),
|
||||
col("m", mc.MemberStatus), col("m", mc.RiskStatus), col("m", mc.AutoDispatch), col("m", mc.IsTestAccount),
|
||||
@@ -109,6 +109,19 @@ func (s *sSysAppMember) List(ctx context.Context, in *sysin.AppMemberListInp) (l
|
||||
if err != nil {
|
||||
return nil, 0, gerror.Wrap(err, "获取会员列表失败")
|
||||
}
|
||||
for _, row := range list {
|
||||
if row.RealNameCipher != "" {
|
||||
plain, decryptErr := encrypt.DecryptField(ctx, row.RealNameCipher)
|
||||
if decryptErr != nil {
|
||||
g.Log().Warningf(ctx, "会员真实姓名解密失败,列表回退为脱敏值 memberId:%d err:%+v", row.Id, decryptErr)
|
||||
row.RealName = row.RealNameMask
|
||||
continue
|
||||
}
|
||||
row.RealName = plain
|
||||
} else {
|
||||
row.RealName = row.RealNameMask
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@@ -126,6 +139,34 @@ func (s *sSysAppMember) View(ctx context.Context, in *sysin.AppMemberViewInp) (r
|
||||
if res.Id == 0 {
|
||||
return nil, gerror.New("会员不存在")
|
||||
}
|
||||
var profile *entity.AppMemberProfile
|
||||
if err = s.profileModel(ctx).Where(dao.AppMemberProfile.Columns().MemberId, in.Id).Scan(&profile); err != nil {
|
||||
return nil, gerror.Wrap(err, "读取会员实名资料失败")
|
||||
}
|
||||
if profile != nil {
|
||||
if profile.RealNameCipher != "" {
|
||||
plain, decryptErr := encrypt.DecryptField(ctx, profile.RealNameCipher)
|
||||
if decryptErr != nil {
|
||||
g.Log().Warningf(ctx, "会员姓名解密失败,详情回退为脱敏值 memberId:%d err:%+v", in.Id, decryptErr)
|
||||
res.RealName = profile.RealNameMask
|
||||
} else {
|
||||
res.RealName = plain
|
||||
}
|
||||
} else {
|
||||
res.RealName = profile.RealNameMask
|
||||
}
|
||||
if profile.IdNoCipher != "" {
|
||||
plain, decryptErr := encrypt.DecryptField(ctx, profile.IdNoCipher)
|
||||
if decryptErr != nil {
|
||||
g.Log().Warningf(ctx, "会员证件号解密失败,详情回退为脱敏值 memberId:%d err:%+v", in.Id, decryptErr)
|
||||
res.IdNo = profile.IdNoMask
|
||||
} else {
|
||||
res.IdNo = plain
|
||||
}
|
||||
} else {
|
||||
res.IdNo = profile.IdNoMask
|
||||
}
|
||||
}
|
||||
res.PaymentAccountCount, _ = s.paymentModel(ctx).Where(dao.AppMemberPaymentAccount.Columns().MemberId, in.Id).Count()
|
||||
res.AddressCount, _ = s.addressModel(ctx).Where(dao.AppMemberAddress.Columns().MemberId, in.Id).Count()
|
||||
token := "tr_" + fmt.Sprint(in.Id) + " "
|
||||
@@ -407,10 +448,68 @@ func (s *sSysAppMember) PaymentList(ctx context.Context, in *sysin.AppMemberPaym
|
||||
err = s.paymentModel(ctx).As("p").
|
||||
LeftJoin(dao.SysAttachment.Table()+" wq", col("wq", ac.Id)+"="+col("p", c.WechatQrAttachmentId)).
|
||||
LeftJoin(dao.SysAttachment.Table()+" aq", col("aq", ac.Id)+"="+col("p", c.AlipayQrAttachmentId)).
|
||||
Fields(col("p", c.Id), col("p", c.MemberId), col("p", c.AccountType), col("p", c.BankCode), col("p", c.BankName), col("p", c.HolderMask), col("p", c.IdentityNoMask), col("p", c.MobileMask), col("p", c.AccountNoMask), col("p", c.DigitalRmbCodeMask), col("p", c.QrAttachmentId), col("p", c.WechatQrAttachmentId), col("p", c.AlipayQrAttachmentId), fmt.Sprintf("COALESCE(%s,'') wechat_qr_url", col("wq", ac.FileUrl)), fmt.Sprintf("COALESCE(%s,'') alipay_qr_url", col("aq", ac.FileUrl)), col("p", c.VerifyStatus), col("p", c.IsDefault), col("p", c.CreatedAt), col("p", c.UpdatedAt)).
|
||||
Fields(col("p", c.Id), col("p", c.MemberId), col("p", c.AccountType), col("p", c.BankCode), col("p", c.BankName), col("p", c.HolderCipher), col("p", c.IdentityNoCipher), col("p", c.MobileCipher), col("p", c.AccountNoCipher), col("p", c.DigitalRmbCodeCipher), col("p", c.HolderMask), col("p", c.IdentityNoMask), col("p", c.MobileMask), col("p", c.AccountNoMask), col("p", c.DigitalRmbCodeMask), col("p", c.QrAttachmentId), col("p", c.WechatQrAttachmentId), col("p", c.AlipayQrAttachmentId), fmt.Sprintf("COALESCE(%s,'') wechat_qr_url", col("wq", ac.FileUrl)), fmt.Sprintf("COALESCE(%s,'') alipay_qr_url", col("aq", ac.FileUrl)), col("p", c.VerifyStatus), col("p", c.IsDefault), col("p", c.CreatedAt), col("p", c.UpdatedAt)).
|
||||
Where(col("p", c.MemberId), in.MemberId).OrderDesc(col("p", c.IsDefault)).OrderDesc(col("p", c.Id)).Scan(&list)
|
||||
if err != nil {
|
||||
err = gerror.Wrap(err, "获取收款账户失败")
|
||||
return
|
||||
}
|
||||
for _, row := range list {
|
||||
if row.HolderCipher != "" {
|
||||
plain, decryptErr := encrypt.DecryptField(ctx, row.HolderCipher)
|
||||
if decryptErr != nil {
|
||||
g.Log().Warningf(ctx, "收款人姓名解密失败,回退为脱敏值 memberId:%d accountId:%d err:%+v", row.MemberId, row.Id, decryptErr)
|
||||
row.Holder = row.HolderMask
|
||||
} else {
|
||||
row.Holder = plain
|
||||
}
|
||||
} else {
|
||||
row.Holder = row.HolderMask
|
||||
}
|
||||
if row.IdentityNoCipher != "" {
|
||||
plain, decryptErr := encrypt.DecryptField(ctx, row.IdentityNoCipher)
|
||||
if decryptErr != nil {
|
||||
g.Log().Warningf(ctx, "收款人证件号解密失败,回退为脱敏值 memberId:%d accountId:%d err:%+v", row.MemberId, row.Id, decryptErr)
|
||||
row.IdentityNo = row.IdentityNoMask
|
||||
} else {
|
||||
row.IdentityNo = plain
|
||||
}
|
||||
} else {
|
||||
row.IdentityNo = row.IdentityNoMask
|
||||
}
|
||||
if row.MobileCipher != "" {
|
||||
plain, decryptErr := encrypt.DecryptField(ctx, row.MobileCipher)
|
||||
if decryptErr != nil {
|
||||
g.Log().Warningf(ctx, "收款手机号解密失败,回退为脱敏值 memberId:%d accountId:%d err:%+v", row.MemberId, row.Id, decryptErr)
|
||||
row.Mobile = row.MobileMask
|
||||
} else {
|
||||
row.Mobile = plain
|
||||
}
|
||||
} else {
|
||||
row.Mobile = row.MobileMask
|
||||
}
|
||||
if row.AccountNoCipher != "" {
|
||||
plain, decryptErr := encrypt.DecryptField(ctx, row.AccountNoCipher)
|
||||
if decryptErr != nil {
|
||||
g.Log().Warningf(ctx, "收款账号解密失败,回退为脱敏值 memberId:%d accountId:%d err:%+v", row.MemberId, row.Id, decryptErr)
|
||||
row.AccountNo = row.AccountNoMask
|
||||
} else {
|
||||
row.AccountNo = plain
|
||||
}
|
||||
} else {
|
||||
row.AccountNo = row.AccountNoMask
|
||||
}
|
||||
if row.DigitalRmbCodeCipher != "" {
|
||||
plain, decryptErr := encrypt.DecryptField(ctx, row.DigitalRmbCodeCipher)
|
||||
if decryptErr != nil {
|
||||
g.Log().Warningf(ctx, "数字钱包编码解密失败,回退为脱敏值 memberId:%d accountId:%d err:%+v", row.MemberId, row.Id, decryptErr)
|
||||
row.DigitalRMBCode = row.DigitalRMBCodeMask
|
||||
} else {
|
||||
row.DigitalRMBCode = plain
|
||||
}
|
||||
} else {
|
||||
row.DigitalRMBCode = row.DigitalRMBCodeMask
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
@@ -517,9 +616,45 @@ func (s *sSysAppMember) PaymentDelete(ctx context.Context, in *sysin.AppMemberPa
|
||||
|
||||
func (s *sSysAppMember) AddressList(ctx context.Context, in *sysin.AppMemberAddressListInp) (list []*sysin.AppMemberAddressModel, err error) {
|
||||
c := dao.AppMemberAddress.Columns()
|
||||
err = s.addressModel(ctx).Fields(c.Id, c.MemberId, c.ReceiverMask, c.MobileMask, c.Province, c.City, c.District, c.AddressMask, c.IsDefault, c.CreatedAt, c.UpdatedAt).Where(c.MemberId, in.MemberId).OrderDesc(c.IsDefault).OrderDesc(c.Id).Scan(&list)
|
||||
err = s.addressModel(ctx).Fields(c.Id, c.MemberId, c.ReceiverCipher, c.MobileCipher, c.AddressCipher, c.ReceiverMask, c.MobileMask, c.Province, c.City, c.District, c.AddressMask, c.IsDefault, c.CreatedAt, c.UpdatedAt).Where(c.MemberId, in.MemberId).OrderDesc(c.IsDefault).OrderDesc(c.Id).Scan(&list)
|
||||
if err != nil {
|
||||
err = gerror.Wrap(err, "获取会员地址失败")
|
||||
return
|
||||
}
|
||||
for _, row := range list {
|
||||
if row.ReceiverCipher != "" {
|
||||
plain, decryptErr := encrypt.DecryptField(ctx, row.ReceiverCipher)
|
||||
if decryptErr != nil {
|
||||
g.Log().Warningf(ctx, "收货人姓名解密失败,地址信息回退为脱敏值 memberId:%d addressId:%d err:%+v", row.MemberId, row.Id, decryptErr)
|
||||
row.Receiver = row.ReceiverMask
|
||||
} else {
|
||||
row.Receiver = plain
|
||||
}
|
||||
} else {
|
||||
row.Receiver = row.ReceiverMask
|
||||
}
|
||||
if row.MobileCipher != "" {
|
||||
plain, decryptErr := encrypt.DecryptField(ctx, row.MobileCipher)
|
||||
if decryptErr != nil {
|
||||
g.Log().Warningf(ctx, "收货手机号解密失败,地址信息回退为脱敏值 memberId:%d addressId:%d err:%+v", row.MemberId, row.Id, decryptErr)
|
||||
row.Mobile = row.MobileMask
|
||||
} else {
|
||||
row.Mobile = plain
|
||||
}
|
||||
} else {
|
||||
row.Mobile = row.MobileMask
|
||||
}
|
||||
if row.AddressCipher != "" {
|
||||
plain, decryptErr := encrypt.DecryptField(ctx, row.AddressCipher)
|
||||
if decryptErr != nil {
|
||||
g.Log().Warningf(ctx, "收货地址解密失败,地址信息回退为脱敏值 memberId:%d addressId:%d err:%+v", row.MemberId, row.Id, decryptErr)
|
||||
row.Address = row.AddressMask
|
||||
} else {
|
||||
row.Address = plain
|
||||
}
|
||||
} else {
|
||||
row.Address = row.AddressMask
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
@@ -874,11 +1009,18 @@ func (s *sSysAppMember) NoticeList(ctx context.Context, in *sysin.MemberNoticeLi
|
||||
return
|
||||
}
|
||||
func (s *sSysAppMember) NoticeEdit(ctx context.Context, in *sysin.MemberNoticeEditInp) error {
|
||||
memberCount, err := s.memberModel(ctx).WherePri(in.MemberId).Count()
|
||||
if err != nil {
|
||||
return gerror.Wrap(err, "校验公告接收会员失败")
|
||||
}
|
||||
if memberCount == 0 {
|
||||
return gerror.New("接收会员不存在或不属于当前租户")
|
||||
}
|
||||
if in.SourceType == consts.MemberNoticeSimulation && g.Cfg().MustGet(ctx, "system.mode").String() == "product" {
|
||||
return gerror.New("生产环境禁止创建运营模拟通知")
|
||||
}
|
||||
c := dao.AppMemberNotice.Columns()
|
||||
_, err := s.noticeModel(ctx).Fields(c.MemberId, c.Title, c.Content, c.SourceType, c.StartAt, c.EndAt, c.NoticeStatus, c.CreatedBy, c.UpdatedBy).Hook(hook.SaveTenant).Data(g.Map{c.MemberId: in.MemberId, c.Title: in.Title, c.Content: in.Content, c.SourceType: in.SourceType, c.StartAt: in.StartAt, c.EndAt: in.EndAt, c.NoticeStatus: consts.MemberNoticeActive, c.CreatedBy: contexts.GetUserId(ctx), c.UpdatedBy: contexts.GetUserId(ctx)}).Insert()
|
||||
_, err = s.noticeModel(ctx).Fields(c.MemberId, c.Title, c.Content, c.SourceType, c.StartAt, c.EndAt, c.NoticeStatus, c.CreatedBy, c.UpdatedBy).Hook(hook.SaveTenant).Data(g.Map{c.MemberId: in.MemberId, c.Title: in.Title, c.Content: in.Content, c.SourceType: in.SourceType, c.StartAt: in.StartAt, c.EndAt: in.EndAt, c.NoticeStatus: consts.MemberNoticeActive, c.CreatedBy: contexts.GetUserId(ctx), c.UpdatedBy: contexts.GetUserId(ctx)}).Insert()
|
||||
if err != nil {
|
||||
return gerror.Wrap(err, "创建会员通知失败")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user