Compare commits
No commits in common. "f3fca800ab5df93dbdf7841dd479ae97662a168b" and "cd31ca1983512c6146905dfa73814c690d72f303" have entirely different histories.
f3fca800ab
...
cd31ca1983
@ -6,7 +6,6 @@ import (
|
|||||||
"micro-bundle/internal/model"
|
"micro-bundle/internal/model"
|
||||||
"micro-bundle/pkg/app"
|
"micro-bundle/pkg/app"
|
||||||
commonErr "micro-bundle/pkg/err"
|
commonErr "micro-bundle/pkg/err"
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -670,31 +669,12 @@ func AssignTask(req *TaskAssignRequest, progressTaskCount int, completeTaskCount
|
|||||||
err := tx.Where("sub_num = ? AND tel_num = ?", req.SubNum, req.TelNum).First(&taskManagement).Error
|
err := tx.Where("sub_num = ? AND tel_num = ?", req.SubNum, req.TelNum).First(&taskManagement).Error
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err == gorm.ErrRecordNotFound {
|
if err == gorm.ErrRecordNotFound {
|
||||||
var userID int
|
// 如果不存在,创建新记录
|
||||||
if req.TelNum != "" {
|
|
||||||
var row struct{ ID int }
|
|
||||||
_ = tx.Table("`micro-account`.`user`").Unscoped().Select("id").Where("tel_num COLLATE utf8mb4_general_ci = ? COLLATE utf8mb4_general_ci AND deleted_at = 0", req.TelNum).Limit(1).Scan(&row).Error
|
|
||||||
if row.ID > 0 {
|
|
||||||
userID = row.ID
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if userID == 0 && req.SubNum != "" {
|
|
||||||
var o struct{ CustomerID string }
|
|
||||||
_ = app.ModuleClients.BundleDB.Table("bundle_order_records").Select("customer_id").
|
|
||||||
Where("customer_num COLLATE utf8mb4_general_ci = ? COLLATE utf8mb4_general_ci", req.SubNum).
|
|
||||||
Where("deleted_at is null").Where("status = 2").
|
|
||||||
Order("created_at desc").Limit(1).Scan(&o).Error
|
|
||||||
if o.CustomerID != "" {
|
|
||||||
if id64, _ := strconv.ParseInt(o.CustomerID, 10, 64); id64 > 0 {
|
|
||||||
userID = int(id64)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
taskManagement = model.TaskManagement{
|
taskManagement = model.TaskManagement{
|
||||||
UserId: userID,
|
|
||||||
SubNum: req.SubNum,
|
SubNum: req.SubNum,
|
||||||
TelNum: req.TelNum,
|
TelNum: req.TelNum,
|
||||||
ArtistName: req.ArtistName,
|
ArtistName: req.ArtistName,
|
||||||
|
// 其他字段
|
||||||
ProgressCount: 0,
|
ProgressCount: 0,
|
||||||
CompleteCount: 0,
|
CompleteCount: 0,
|
||||||
CreatedAt: time.Now(),
|
CreatedAt: time.Now(),
|
||||||
@ -809,28 +789,7 @@ func BatchAssignTasks(items []*BatchAssignItem) error {
|
|||||||
var taskManagement model.TaskManagement
|
var taskManagement model.TaskManagement
|
||||||
if err := tx.Where("sub_num = ? AND tel_num = ?", it.SubNum, it.TelNum).First(&taskManagement).Error; err != nil {
|
if err := tx.Where("sub_num = ? AND tel_num = ?", it.SubNum, it.TelNum).First(&taskManagement).Error; err != nil {
|
||||||
if err == gorm.ErrRecordNotFound {
|
if err == gorm.ErrRecordNotFound {
|
||||||
var userID int
|
|
||||||
if it.TelNum != "" {
|
|
||||||
var row struct{ ID int }
|
|
||||||
_ = tx.Table("`micro-account`.`user`").Unscoped().Select("id").Where("tel_num COLLATE utf8mb4_general_ci = ? COLLATE utf8mb4_general_ci AND deleted_at = 0", it.TelNum).Limit(1).Scan(&row).Error
|
|
||||||
if row.ID > 0 {
|
|
||||||
userID = row.ID
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if userID == 0 && it.SubNum != "" {
|
|
||||||
var o struct{ CustomerID string }
|
|
||||||
_ = app.ModuleClients.BundleDB.Table("bundle_order_records").Select("customer_id").
|
|
||||||
Where("customer_num COLLATE utf8mb4_general_ci = ? COLLATE utf8mb4_general_ci", it.SubNum).
|
|
||||||
Where("deleted_at is null").Where("status = 2").
|
|
||||||
Order("created_at desc").Limit(1).Scan(&o).Error
|
|
||||||
if o.CustomerID != "" {
|
|
||||||
if id64, _ := strconv.ParseInt(o.CustomerID, 10, 64); id64 > 0 {
|
|
||||||
userID = int(id64)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
taskManagement = model.TaskManagement{
|
taskManagement = model.TaskManagement{
|
||||||
UserId: userID,
|
|
||||||
SubNum: it.SubNum,
|
SubNum: it.SubNum,
|
||||||
TelNum: it.TelNum,
|
TelNum: it.TelNum,
|
||||||
ArtistName: it.ArtistName,
|
ArtistName: it.ArtistName,
|
||||||
|
|||||||
@ -16,7 +16,6 @@ var OrderByDataAnalysis = map[string]string{
|
|||||||
|
|
||||||
type TaskManagement struct {
|
type TaskManagement struct {
|
||||||
ID int64 `gorm:"primarykey"`
|
ID int64 `gorm:"primarykey"`
|
||||||
UserId int `gorm:"column:user_id;comment:用户ID;index:idx_user_id"`
|
|
||||||
SubNum string `gorm:"column:sub_num;comment:用户编号;index:idx_sub_num;index:idx_sub_tel,priority:1" json:"subNum"`
|
SubNum string `gorm:"column:sub_num;comment:用户编号;index:idx_sub_num;index:idx_sub_tel,priority:1" json:"subNum"`
|
||||||
TelNum string `gorm:"column:tel_num;comment:手机号;index:idx_tel_num;index:idx_sub_tel,priority:2" json:"telNum"`
|
TelNum string `gorm:"column:tel_num;comment:手机号;index:idx_tel_num;index:idx_sub_tel,priority:2" json:"telNum"`
|
||||||
ArtistName string `gorm:"column:artist_name;comment:艺人名称;index:idx_artist_name" json:"artistName"`
|
ArtistName string `gorm:"column:artist_name;comment:艺人名称;index:idx_artist_name" json:"artistName"`
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user