2ed5dfa6a1
iotlcm-app:小程序端 + 用户端服务。 - app/:uni-app 小程序前端(基于 unibest,MIT) - 微信 AppID → YOUR_WX_APPID,uni-app AppID → __UNI__YOURAPPID - 内网后端地址 → admin.iotlcm.example.com - 应用标题与 unibest 模板 README 重写(保留上游致谢与 MIT 声明) - server/:GoFrame 用户端服务(基于 XiuAdmin,Apache-2.0) - module xiuadmin → git.5iot.com/iotlcm-public/iotlcm-app(360 文件) - 支付回调地址 → app.iotlcm.example.com,商户名与应用名泛化 - 真实手机号 → 合法 11 位编造号(保留号段前 3 位 + 后 4 位) - 依赖号码尾部的断言同步更新 - 补 server/LICENSE(Apache-2.0) - 移除内部资产:CI 触发器 - 补根 README,LF 行尾 + .gitattributes 已知:TestSysDept_RefreshDeptAncestors 在源仓同一提交上同样失败,属既有缺陷。
167 lines
4.3 KiB
Go
167 lines
4.3 KiB
Go
package app
|
|
|
|
import (
|
|
"context"
|
|
"strings"
|
|
|
|
"git.5iot.com/iotlcm-public/iotlcm-app/internal/consts"
|
|
"git.5iot.com/iotlcm-public/iotlcm-app/internal/library/batchimport"
|
|
"git.5iot.com/iotlcm-public/iotlcm-app/internal/model"
|
|
|
|
"github.com/gogf/gf/v2/database/gdb"
|
|
"github.com/gogf/gf/v2/encoding/gjson"
|
|
"github.com/gogf/gf/v2/errors/gerror"
|
|
)
|
|
|
|
type appRenewBatchProcessor struct {
|
|
batch *appRenewBatchContext
|
|
}
|
|
|
|
type appRenewBatchRow struct {
|
|
rowNo int
|
|
itemID string
|
|
snapshot *gjson.Json
|
|
errorReasons []string
|
|
}
|
|
|
|
func newAppRenewBatchProcessor(batch *appRenewBatchContext) *appRenewBatchProcessor {
|
|
return &appRenewBatchProcessor{batch: batch}
|
|
}
|
|
|
|
func appRenewBatchRows(batch *appRenewBatchContext) []batchimport.Row {
|
|
if batch == nil {
|
|
return nil
|
|
}
|
|
rows := make([]batchimport.Row, 0, len(batch.Items))
|
|
for index, item := range batch.Items {
|
|
rowNo := appRenewBatchSourceRowNo(index)
|
|
itemID := ""
|
|
var snapshot *gjson.Json
|
|
if item != nil && item.Card != nil {
|
|
itemID = strings.TrimSpace(item.Card.Iccid)
|
|
snapshot = appRenewPrepareDetailSnapshot(batch, item, rowNo)
|
|
}
|
|
rows = append(rows, &appRenewBatchRow{
|
|
rowNo: rowNo,
|
|
itemID: itemID,
|
|
snapshot: snapshot,
|
|
})
|
|
}
|
|
return rows
|
|
}
|
|
|
|
func (p *appRenewBatchProcessor) Config() batchimport.ProcessorConfig {
|
|
return batchimport.ProcessorConfig{
|
|
Code: "miniapp_card_renew",
|
|
BatchType: consts.BatchTypeRenew,
|
|
BatchNoPrefix: consts.BatchNoPrefixRenew,
|
|
TaskName: consts.ResourceBatchDownloadTaskSimCardRenew,
|
|
ExportScene: consts.ResourceExportSceneRenew,
|
|
ImportDir: consts.SimCardRenewSubDirImportExcel,
|
|
ResultDir: consts.SimCardRenewSubDirResultExcel,
|
|
MaxFileSize: 50 << 20,
|
|
TemplateHeaders: []string{"ICCID", "MSISDN", "IMSI"},
|
|
RequiredHeaders: []string{"ICCID"},
|
|
}
|
|
}
|
|
|
|
func (p *appRenewBatchProcessor) ParseRows(ctx context.Context, filePath string) ([]batchimport.Row, error) {
|
|
return nil, gerror.New("小程序续费暂不支持文件导入")
|
|
}
|
|
|
|
func (p *appRenewBatchProcessor) ValidateRows(ctx context.Context, rows []batchimport.Row) error {
|
|
seen := make(map[string]batchimport.Row, len(rows))
|
|
for _, row := range rows {
|
|
if row == nil {
|
|
continue
|
|
}
|
|
itemID := strings.TrimSpace(row.GetItemID())
|
|
if itemID == "" {
|
|
row.AddErrorReason("ICCID不能为空")
|
|
continue
|
|
}
|
|
if first, ok := seen[itemID]; ok {
|
|
row.AddErrorReason("ICCID重复")
|
|
first.AddErrorReason("ICCID重复")
|
|
continue
|
|
}
|
|
seen[itemID] = row
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (p *appRenewBatchProcessor) Execute(ctx context.Context, tx gdb.TX, req *batchimport.SubmitRequest, rows []batchimport.Row) error {
|
|
return gerror.New("小程序续费批次确认由余额支付流程触发")
|
|
}
|
|
|
|
func (p *appRenewBatchProcessor) BuildBatchInfo(ctx context.Context, req batchimport.SubmitRequest, result *batchimport.Result, importOss *model.SysOssSaveContentModel, resultOss *model.SysOssSaveContentModel, downloadId int64) *gjson.Json {
|
|
info := map[string]any{}
|
|
if p.batch != nil {
|
|
if base := appRenewPrepareBatchInfo(p.batch, "", "", 0, 0); base != nil {
|
|
for key, value := range base.Map() {
|
|
info[key] = value
|
|
}
|
|
}
|
|
}
|
|
if sourceBatchNo := strings.TrimSpace(req.SourceBatchNo); sourceBatchNo != "" {
|
|
info["sourceBatchNo"] = sourceBatchNo
|
|
}
|
|
if importOss != nil && importOss.OssId > 0 {
|
|
info["importFileOssId"] = importOss.OssId
|
|
}
|
|
if resultOss != nil && resultOss.OssId > 0 {
|
|
info["resultFileOssId"] = resultOss.OssId
|
|
}
|
|
if downloadId > 0 {
|
|
info["resultDownloadId"] = downloadId
|
|
}
|
|
if result != nil && result.FailReason != "" {
|
|
info["failReason"] = result.FailReason
|
|
}
|
|
return gjson.New(info)
|
|
}
|
|
|
|
func (r *appRenewBatchRow) GetRowNo() int {
|
|
if r == nil {
|
|
return 0
|
|
}
|
|
return r.rowNo
|
|
}
|
|
|
|
func (r *appRenewBatchRow) GetItemID() string {
|
|
if r == nil {
|
|
return ""
|
|
}
|
|
return strings.TrimSpace(r.itemID)
|
|
}
|
|
|
|
func (r *appRenewBatchRow) GetErrorReasons() []string {
|
|
if r == nil {
|
|
return nil
|
|
}
|
|
return r.errorReasons
|
|
}
|
|
|
|
func (r *appRenewBatchRow) AddErrorReason(reason string) {
|
|
if r == nil {
|
|
return
|
|
}
|
|
reason = strings.TrimSpace(reason)
|
|
if reason == "" {
|
|
return
|
|
}
|
|
for _, item := range r.errorReasons {
|
|
if item == reason {
|
|
return
|
|
}
|
|
}
|
|
r.errorReasons = append(r.errorReasons, reason)
|
|
}
|
|
|
|
func (r *appRenewBatchRow) Snapshot() *gjson.Json {
|
|
if r == nil || r.snapshot == nil {
|
|
return gjson.New(map[string]any{})
|
|
}
|
|
return r.snapshot
|
|
}
|