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.4 KiB
Go
167 lines
4.4 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 appAllocateBatchProcessor struct {
|
|
batch *appAllocateBatchContext
|
|
}
|
|
|
|
type appAllocateBatchRow struct {
|
|
rowNo int
|
|
itemID string
|
|
snapshot *gjson.Json
|
|
errorReasons []string
|
|
}
|
|
|
|
func newAppAllocateBatchProcessor(batch *appAllocateBatchContext) *appAllocateBatchProcessor {
|
|
return &appAllocateBatchProcessor{batch: batch}
|
|
}
|
|
|
|
func appAllocateBatchRows(batch *appAllocateBatchContext) []batchimport.Row {
|
|
if batch == nil {
|
|
return nil
|
|
}
|
|
rows := make([]batchimport.Row, 0, len(batch.Cards))
|
|
for _, item := range batch.Cards {
|
|
if item == nil {
|
|
continue
|
|
}
|
|
row := &appAllocateBatchRow{
|
|
rowNo: item.RowNo,
|
|
itemID: item.allocateItemId(),
|
|
snapshot: appAllocatePrepareDetailSnapshot(batch, item),
|
|
}
|
|
if reason := strings.TrimSpace(item.ErrorReason); reason != "" {
|
|
row.AddErrorReason(reason)
|
|
}
|
|
rows = append(rows, row)
|
|
}
|
|
return rows
|
|
}
|
|
|
|
func (p *appAllocateBatchProcessor) Config() batchimport.ProcessorConfig {
|
|
return batchimport.ProcessorConfig{
|
|
Code: "miniapp_card_allocate",
|
|
BatchType: consts.BatchTypeAllocate,
|
|
BatchNoPrefix: consts.BatchNoPrefixAllocate,
|
|
TaskName: consts.ResourceBatchDownloadTaskSimCardAllocate,
|
|
ExportScene: consts.ResourceExportSceneAllocate,
|
|
ImportDir: consts.SimCardAllocateSubDirImportExcel,
|
|
ResultDir: consts.SimCardAllocateSubDirResultExcel,
|
|
MaxFileSize: 50 << 20,
|
|
TemplateHeaders: []string{"ICCID", "MSISDN", "IMSI"},
|
|
RequiredHeaders: []string{"ICCID"},
|
|
}
|
|
}
|
|
|
|
func (p *appAllocateBatchProcessor) ParseRows(ctx context.Context, filePath string) ([]batchimport.Row, error) {
|
|
return nil, gerror.New("小程序划拨暂不支持文件导入")
|
|
}
|
|
|
|
func (p *appAllocateBatchProcessor) 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 *appAllocateBatchProcessor) Execute(ctx context.Context, tx gdb.TX, req *batchimport.SubmitRequest, rows []batchimport.Row) error {
|
|
return gerror.New("小程序划拨批次确认由提交接口触发")
|
|
}
|
|
|
|
func (p *appAllocateBatchProcessor) 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 := appAllocatePrepareBatchInfo(p.batch, req.BatchNo); 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 && strings.TrimSpace(result.FailReason) != "" {
|
|
info["failReason"] = strings.TrimSpace(result.FailReason)
|
|
}
|
|
return gjson.New(info)
|
|
}
|
|
|
|
func (r *appAllocateBatchRow) GetRowNo() int {
|
|
if r == nil {
|
|
return 0
|
|
}
|
|
return r.rowNo
|
|
}
|
|
|
|
func (r *appAllocateBatchRow) GetItemID() string {
|
|
if r == nil {
|
|
return ""
|
|
}
|
|
return strings.TrimSpace(r.itemID)
|
|
}
|
|
|
|
func (r *appAllocateBatchRow) GetErrorReasons() []string {
|
|
if r == nil {
|
|
return nil
|
|
}
|
|
return r.errorReasons
|
|
}
|
|
|
|
func (r *appAllocateBatchRow) 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 *appAllocateBatchRow) Snapshot() *gjson.Json {
|
|
if r == nil || r.snapshot == nil {
|
|
return gjson.New(map[string]any{})
|
|
}
|
|
return r.snapshot
|
|
}
|