Browse Source

update:修改运单号生成逻辑,运单物流地址可编辑

zoie 2 months ago
parent
commit
4e02f7978c

+ 4 - 3
app/admin/service/dto/waybill.go

@@ -43,7 +43,7 @@ func (m *WaybillGetCustomerPageReq) GetNeedSearch() interface{} {
 
 type WaybillInsertReq struct {
 	Id                      int    `json:"id" comment:"编码" swaggerignore:"true"`                                 // 编码
-	No                      string `json:"no" swaggerignore:"true"`                                              //单号
+	No                      string `json:"no"`                                                                   //单号 可以手动输入,不输入则默认系统单号
 	Status                  int    `json:"status" swaggerignore:"true"`                                          //运单状态:1-待处理;102-待装车 103-运输中 104-已签收
 	SenderAddressDetails    string `json:"senderAddressDetails"`                                                 //发货地址详情
 	SenderAddressName       string `json:"senderAddressName"`                                                    //发货地址名称
@@ -269,8 +269,9 @@ type WaybillSendMailPdfReq struct {
 
 type WaybillLogisticsUpdateReq struct {
 	WaybillLogisticsList []struct {
-		Id   int         `json:"id" comment:"编码" swaggerignore:"true"` // 编码
-		Time model2.Time `json:"time"  gorm:"size:128"`                // 开始时间
+		Id      int         `json:"id" comment:"编码" swaggerignore:"true"` // 编码
+		Address string      `json:"address"`                              // 地址
+		Time    model2.Time `json:"time"`                                 // 开始时间
 	} `json:"waybillLogistics"`
 	model2.ControlBy `swaggerignore:"true"`
 	model2.DeptBy    `swaggerignore:"true"`

+ 2 - 2
app/admin/service/dto/waybill_task.go

@@ -51,8 +51,8 @@ type WaybillTaskGetNewestDataPageReq struct {
 type WaybillTaskUpdateReq struct {
 	WaybillTaskList []struct {
 		Id        int         `json:"id" comment:"编码" swaggerignore:"true"` // 编码
-		StartTime model2.Time `json:"startTime"  gorm:"size:128"`           // 开始时间
-		EndTime   model2.Time `json:"endTime"  gorm:"size:128"`             // 结束时间
+		StartTime model2.Time `json:"startTime"`                            // 开始时间
+		EndTime   model2.Time `json:"endTime"`                              // 结束时间
 	} `json:"waybillTaskList"`
 	model2.ControlBy `swaggerignore:"true"`
 	model2.DeptBy    `swaggerignore:"true"`

+ 10 - 1
app/admin/service/waybill.go

@@ -243,7 +243,16 @@ func (e *Waybill) Insert(c *dto.WaybillInsertReq) error {
 
 	var no string
 	for {
-		no = time.Now().Format("200601021504") + utils.GetRandString(6, "0123456789", 0)
+		now := time.Now().Unix()
+		// 取时间戳的后8位数字
+		timestampStr := fmt.Sprintf("%d", now)
+		if len(timestampStr) > 8 {
+			timestampStr = timestampStr[len(timestampStr)-8:]
+		} else {
+			timestampStr = fmt.Sprintf("%08s", timestampStr)
+		}
+		// 将时间戳转换为16进制(更紧凑的表示)
+		no = fmt.Sprintf("%s%s", time.Now().Format("2006"), timestampStr) + utils.GetRandString(6, "0123456789", 0)
 		var j int64
 		err = e.Orm.Model(&data).Where("waybill_no = ?", no).Count(&j).Error
 		if err != nil {

+ 1 - 0
app/admin/service/waybill_logistics.go

@@ -72,6 +72,7 @@ func (e *WaybillLogistics) Update(c *dto.WaybillLogisticsUpdateReq, p *actions.D
 			return global.UpdateFailedErr
 		}
 
+		waybillLogisticsModel.Address = logistics.Address
 		waybillLogisticsModel.CreatedAt = logistics.Time
 		waybillLogisticsModel.UpdateBy = c.UpdateBy
 		err = tx.Save(&waybillLogisticsModel).Error