Browse Source

运单管理-添加状态,公司管理查询本公司。

huangyan 1 tháng trước cách đây
mục cha
commit
9e90246283

+ 26 - 0
app/admin/controller/company.go

@@ -52,6 +52,32 @@ func (e CompanyController) GetPage(c *gin.Context) {
 	e.OK(list, "查询成功")
 }
 
+// GetCurrentCompany 获取当前用户的公司
+// @Summary 获取当前用户的公司
+// @Description 获取当前用户的公司
+// @Tags 公司
+// @Success 200 {object} response.Response{data=response.Page{list=[]model.SysUser}}  "{"code": 200, "data": [...]}"
+// @Router /api/company/dept [get]
+// @Security Bearer
+func (e CompanyController) GetCurrentCompany(c *gin.Context) {
+	s := service.Company{}
+	req := dto.CompanyGetPageReq{}
+	err := e.MakeContext(c).
+		MakeOrm().
+		Bind(&req, binding.Query).
+		MakeService(&s.Service).
+		Errors
+	p := actions.GetPermissionFromContext(c)
+	list := make([]model.SysDept, 0)
+	var count int64
+	err = s.GetCurrentCompany(p, &list, &req, &count)
+	if err != nil {
+		e.Error(500, err, err.Error())
+		return
+	}
+	e.PageOK(list, int(count), req.GetPageIndex(), req.GetPageSize(), "查询成功")
+}
+
 // GetUserPage 获取公司下面的用户列表
 // @Summary 获取公司下面的用户列表
 // @Description 获取公司下面的用户列表

+ 36 - 1
app/admin/controller/waybill.go

@@ -511,7 +511,7 @@ func (e WaybillController) Insert(c *gin.Context) {
 // @Security Bearer
 func (e WaybillController) UpdateStatus(c *gin.Context) {
 	s := service.Waybill{}
-	req := dto.WaybillUpdateStatusReq{}
+	req := dto.UpdateStatusReq{}
 	err := e.MakeContext(c).
 		MakeOrm().
 		Bind(&req).
@@ -568,6 +568,41 @@ func (e WaybillController) Update(c *gin.Context) {
 	e.OK(req.GetId(), "修改成功")
 }
 
+// Audit 审核订单
+// @Summary 审核订单
+// @Description 审核订单
+// @Tags 运单
+// @Accept  application/json
+// @Product application/json
+// @Param data body dto.WaybillUpdateReq true "body"
+// @Success 200 {string} string	"{"code": 200, "message": "添加成功"}"
+// @Success 200 {string} string	"{"code": -1, "message": "添加失败"}"
+// @Router /api/waybill/audit [put]
+// @Security Bearer
+func (e WaybillController) Audit(c *gin.Context) {
+	s := service.Waybill{}
+	req := dto.WaybillUpdateReqaudit{}
+	err := e.MakeContext(c).
+		MakeOrm().
+		Bind(&req).
+		MakeService(&s.Service).
+		Errors
+	if err != nil {
+		e.Logger.Error(err)
+		e.Error(500, err, err.Error())
+		return
+	}
+	p := actions.GetPermissionFromContext(c)
+
+	req.SetUpdateBy(user.GetUserId(c))
+	err = s.Audit(&req, p)
+	if err != nil {
+		e.Error(500, err, err.Error())
+		return
+	}
+	e.OK(req.GetId(), "修改成功")
+}
+
 // Delivery 派单
 // @Summary 派单
 // @Description 派单

+ 2 - 1
app/admin/model/sys_user.go

@@ -15,12 +15,13 @@ var (
 	SysUserTypeSys      = 1
 	SysUserTypeStoreSys = 2
 	SysUserTypeDriver   = 3
+	SysUserTypeSalesman = 4
 )
 
 type SysUser struct {
 	model2.Model
 	coreModel.User
-	Type       int         `json:"type" gorm:"size:128;comment:类型"` // 管理员1 门店管理员2 配送员3
+	Type       int         `json:"type" gorm:"size:128;comment:类型"` // 管理员1 门店管理员2 配送员3  4销售人员
 	UserType   string      `json:"userType" gorm:"size:128;comment:用户类型"`
 	Openid     string      `json:"openid" gorm:"size:128;comment:微信openid"`                // 微信openid
 	Dept       SysDept     `json:"dept" gorm:"->"`                                         // 部门

+ 75 - 42
app/admin/model/waybill.go

@@ -6,20 +6,42 @@ import (
 	"encoding/json"
 )
 
+// // 1未确定订单  2待审核订单  3已审核订单 4待配送 5已配送 6已签收 7已拒收
 var (
-	WaybillStatusWaitDelivery = 1 // 已下单
-	WaybillStatusInDelivery   = 2 // 配送中
-
-	WaybillStatusReceipt   = 3 // 已签收
-	WaybillStatusRejection = 4 // 已拒收
-	WaybillStatusMap       = map[int]string{
-		WaybillStatusWaitDelivery: "已下单",
-		WaybillStatusInDelivery:   "配送中",
-		WaybillStatusReceipt:      "已签收",
-		WaybillStatusRejection:    "已拒收",
+	WaybillStatusWaitDelivery = 1 // 未确定订单
+	WaybillStatusAudits       = 2 // 待审核订单
+	WaybillStatusInDeliverys  = 3 // 待配送
+	WaybillStatusInShippeds   = 4 // 配送中
+	WaybillStatusReceipts     = 5 // 已签收
+	WaybillStatusRejections   = 6 // 已拒收
+	WaybillStatusoverrule     = 7 // 已驳回
+	WaybillStatusCancel       = 8 // 取消订单
+	WaybillStatusMap          = map[int]string{
+		WaybillStatusWaitDelivery: "未确定订单",
+		WaybillStatusAudits:       "待审核订单",
+		WaybillStatusInDeliverys:  "待配送",
+		WaybillStatusInShippeds:   "配送中",
+		WaybillStatusReceipts:     "已签收",
+		WaybillStatusRejections:   "已拒收",
+		WaybillStatusoverrule:     "已驳回",
+		WaybillStatusCancel:       "取消订单",
 	}
 )
 
+//var (
+//	WaybillStatusWaitDelivery = 1 // 已下单
+//	WaybillStatusInDelivery   = 2 // 配送中
+//
+//	WaybillStatusReceipt   = 3 // 已签收
+//	WaybillStatusRejection = 4 // 已拒收
+//	WaybillStatusMap       = map[int]string{
+//		WaybillStatusWaitDelivery: "已下单",
+//		WaybillStatusInDelivery:   "配送中",
+//		WaybillStatusReceipt:      "已签收",
+//		WaybillStatusRejection:    "已拒收",
+//	}
+//)
+
 // 运单短信发送日志
 type WaybillSendLog struct {
 	Phone   string `json:"phone"`
@@ -48,38 +70,49 @@ func (e *IceRaftCode) Scan(src interface{}) error {
 // 运单
 type Waybill struct {
 	model2.Model
-	WaybillNo               string         `json:"waybillNo"  gorm:"size:128"`                    // 单号
-	OrderNo                 string         `json:"orderNo"  gorm:"size:128"`                      // 订单号
-	Status                  int            `json:"status"  gorm:"size:128"`                       // 订单状态:1已下单 2配送中 3已送达 4已拒收
-	SenderAddressDetails    string         `json:"senderAddressDetails"  gorm:"size:128"`         // 发货地址详情
-	SenderAddressName       string         `json:"senderAddressName"  gorm:"size:128"`            // 发货地址名称
-	SenderAddressPhone      string         `json:"senderAddressPhone"  gorm:"size:128"`           // 发货地址电话
-	ConsigneeAddressDetails string         `json:"consigneeAddressDetails"  gorm:"size:128"`      // 收发货地址详情
-	ConsigneeAddressName    string         `json:"consigneeAddressName"  gorm:"size:128"`         // 收发货地址名称
-	ConsigneeAddressPhone   string         `json:"consigneeAddressPhone"  gorm:"size:128"`        // 收发货地址电话
-	DeliveryName            string         `json:"deliveryName"  gorm:"size:128"`                 // 配送人名称
-	DeliveryPhone           string         `json:"deliveryPhone"  gorm:"size:128"`                // 配送人电话
-	DeliveryId              int            `json:"deliveryId"  gorm:"size:128"`                   // 配送人id
-	ReCheckId               int            `json:"reCheckId"  gorm:"size:128"`                    // 复核id
-	Remark                  string         `json:"remark"  gorm:"size:text"`                      // 运输备注
-	OrderTime               model2.Time    `json:"orderTime"  gorm:"size:128"`                    // 下单时间
-	DeliveryTime            model2.Time    `json:"deliveryTime"  gorm:"size:128"`                 // 配送时间
-	DeliveryDuration        int            `json:"deliveryDuration" gorm:"size:128;comment:冷冻时长"` // 配送耗时 单位分钟
-	ReceiptTime             model2.Time    `json:"receiptTime"  gorm:"size:128"`                  // 签收时间
-	Quantity                int            `json:"quantity"  gorm:"size:128"`                     // 药品数量
-	CoolerBoxId             int            `json:"coolerBoxId"  gorm:"size:128"`                  // 保温箱id
-	ReceiptImg              string         `json:"receiptImg"  gorm:"size:text"`                  // 签收图片
-	TamperProofLabel        string         `json:"tamperProofLabel"  gorm:"size:128"`             // 防拆标签
-	TamperProofLabelImg     string         `json:"tamperProofLabelImg"  gorm:"size:text"`         // 防拆标签
-	RejectionReason         string         `json:"rejectionReason"  gorm:"size:128"`              // 拒收原因
-	SendLog                 WaybillSendLog `json:"sendLog" gorm:"size:text"`                      // 运单短信发送日志
-	CoolerBox               CoolerBoxOmit  `json:"coolerBox" gorm:"->"`                           // 保温箱
-	Dept                    SysDeptOmit    `json:"dept" gorm:"->"`                                // 部门
-	Delivery                SysUserOmit    `json:"delivery" gorm:"->"`                            // 部门
-	ReCheck                 SysUserOmit    `json:"reCheck" gorm:"->"`                             // 部门
-	IceRaftCode             IceRaftCode    `json:"iceRaftCode" gorm:"size:text"`
-	AssessStar              int            `json:"assessStar"  gorm:"size:128"`    // 评价星星
-	AssessContent           string         `json:"assessContent"  gorm:"size:128"` // 评价内容
+	WaybillNo                  string         `json:"waybillNo"  gorm:"size:128"`                    // 单号
+	OrderNo                    string         `json:"orderNo"  gorm:"size:128"`                      // 订单号
+	Status                     int            `json:"status"  gorm:"size:128"`                       // 订单状态:1已下单 2配送中 3已送达 4已拒收   1未确定订单 2已确定订单 3待审核订单 4审核完成 5待配送 6已配送 7已签收 8已拒收
+	SenderAddressDetails       string         `json:"senderAddressDetails"  gorm:"size:128"`         // 发货地址详情
+	SenderAddressName          string         `json:"senderAddressName"  gorm:"size:128"`            // 发货地址名称
+	SenderAddressPhone         string         `json:"senderAddressPhone"  gorm:"size:128"`           // 发货地址电话
+	ConsigneeAddressDetails    string         `json:"consigneeAddressDetails"  gorm:"size:128"`      // 收发货地址详情
+	ConsigneeAddressName       string         `json:"consigneeAddressName"  gorm:"size:128"`         // 收发货地址名称
+	ConsigneeAddressPhone      string         `json:"consigneeAddressPhone"  gorm:"size:128"`        // 收发货地址电话
+	DeliveryName               string         `json:"deliveryName"  gorm:"size:128"`                 // 配送人名称
+	DeliveryPhone              string         `json:"deliveryPhone"  gorm:"size:128"`                // 配送人电话
+	DeliveryId                 int            `json:"deliveryId"  gorm:"size:128"`                   // 配送人id
+	ReCheckId                  int            `json:"reCheckId"  gorm:"size:128"`                    // 复核id
+	Remark                     string         `json:"remark"  gorm:"size:text"`                      // 运输备注
+	OrderTime                  model2.Time    `json:"orderTime"  gorm:"size:128"`                    // 下单时间
+	DeliveryTime               model2.Time    `json:"deliveryTime"  gorm:"size:128"`                 // 配送时间
+	DeliveryDuration           int            `json:"deliveryDuration" gorm:"size:128;comment:冷冻时长"` // 配送耗时 单位分钟
+	ReceiptTime                model2.Time    `json:"receiptTime"  gorm:"size:128"`                  // 签收时间
+	Quantity                   int            `json:"quantity"  gorm:"size:128"`                     // 药品数量
+	CoolerBoxId                int            `json:"coolerBoxId"  gorm:"size:128"`                  // 保温箱id
+	ReceiptImg                 string         `json:"receiptImg"  gorm:"size:text"`                  // 签收图片
+	Receiptsign                string         `json:"receiptsign" gorm:"size:text"`                  // 签收图片签字
+	TamperProofLabel           string         `json:"tamperProofLabel"  gorm:"size:128"`             // 防拆标签
+	TamperProofLabelImg        string         `json:"tamperProofLabelImg"  gorm:"size:text"`         // 防拆标签
+	RejectionReason            string         `json:"rejectionReason"  gorm:"size:128"`              // 拒收原因
+	SendLog                    WaybillSendLog `json:"sendLog" gorm:"size:text"`                      // 运单短信发送日志
+	CoolerBox                  CoolerBoxOmit  `json:"coolerBox" gorm:"->"`                           // 保温箱
+	Dept                       SysDeptOmit    `json:"dept" gorm:"->"`                                // 部门
+	Delivery                   SysUserOmit    `json:"delivery" gorm:"->"`                            // 部门
+	ReCheck                    SysUserOmit    `json:"reCheck" gorm:"->"`                             // 部门
+	IceRaftCode                IceRaftCode    `json:"iceRaftCode" gorm:"size:text"`
+	AssessStar                 int            `json:"assessStar"  gorm:"size:128"`                          // 评价星星
+	AssessContent              string         `json:"assessContent"  gorm:"size:128"`                       // 评价内容
+	PrescriptionIsAudit        int            `json:"prescriptionIssue"   gorm:"size:128;default:1"`        // 处方是否审核 1 未审核 2已审核
+	InvoiceIsAudit             int            `json:"invoiceIssue"   gorm:"size:128;default:1"`             // 发票是否审核 1 未审核 2已审核
+	InspectionReportIsAudit    int            `json:"inspectionReportIssue"   gorm:"size:128;default:1"`    // 检验报告是否审核 1 未审核 2已审核
+	DispensingMedicinesIsAudit int            `json:"dispensingMedicinesIssue"   gorm:"size:128;default:1"` //  调配药品信息是否审核  1 未审核 2已审核
+	IsCold                     int            `json:"isCold"   gorm:"size:128;default:1"`                   // 是否冷链 1 否 2 是
+	PaymentStatus              int            `json:"paymentStatus"  gorm:"size:128;default:1"`             //支付状态 1 结清 2 未结清  3 支付完成
+	PaymentType                int            `json:"paymentType"  gorm:"size:128;default:0"`               //支付方式  1现金 2线上支付 3银行卡 4医保 5其他
+	PaymentRemark              int            `json:"paymentremark"  gorm:"size:128;"`                      //支付备注
+	AssignmentStatus           int            `json:"assignmentStatus"  gorm:"size:128;default:1"`          //分配状态  1 未分配  2已分配
+	AuditRemark                string         `json:"audit_remark"  gorm:"size:255;"`                       //审核备注
 	model2.ControlBy
 	model2.ModelTime
 	model2.DeptBy

+ 1 - 0
app/admin/router/company.go

@@ -18,6 +18,7 @@ func registerCompanyRouter(v1 *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddle
 	r := v1.Group("/company").Use(authMiddleware.MiddlewareFunc()).Use(actions.PermissionAction())
 	{
 		r.GET("", cont.GetPage)
+		r.GET("/dept", cont.GetCurrentCompany)
 		r.GET("/user", cont.GetUserPage)
 		r.GET("/all", cont.GetAll)
 		r.GET("/:id", cont.Get)

+ 5 - 4
app/admin/router/waybill.go

@@ -25,10 +25,11 @@ func registerWaybillRouter(v1 *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddle
 		r.POST("/delivery", cont.Delivery)
 		r.PUT("", cont.Update)
 		r.DELETE("", cont.Delete)
-		r.POST("/receipt", cont.Receipt)         // 签收
-		r.GET("/customer", cont.GetCustomerPage) // 客户下单列表
-		r.POST("/customer", cont.CustomerInsert) // 客户下单
-
+		r.POST("/receipt", cont.Receipt)               // 签收
+		r.GET("/customer", cont.GetCustomerPage)       // 客户下单列表
+		r.POST("/customer", cont.CustomerInsert)       // 客户下单
+		r.PUT("/update-status", cont.UpdateStatus)     // 修改订单状态
+		r.PUT("/audit", cont.Audit)                    // 审核订单
 		r.GET("/applet", cont.GetAppletPage)           // app 运单列表
 		r.GET("/applet-count", cont.GetAppletCount)    // app 运单-统计
 		r.POST("/import", cont.Import)                 // 导入运单

+ 29 - 0
app/admin/service/company.go

@@ -49,6 +49,15 @@ func CompanyIdScopes(id int) func(db *gorm.DB) *gorm.DB {
 		return db.Where("id = ? ", id)
 	}
 }
+func CompanyIdScopesUser(id int) func(db *gorm.DB) *gorm.DB {
+	return func(db *gorm.DB) *gorm.DB {
+		if id == 0 {
+			return db
+		}
+		return db.Where("id = ? ", id).Or("parent_id =?", id)
+	}
+}
+
 func (e *Company) GetAll(c *dto.CompanyGetAllReq, list *[]model.SysDept, count *int64, p *actions.DataPermission) error {
 	var err error
 	var data model.SysDept
@@ -81,6 +90,26 @@ func (e *Company) Get(d *dto.CompanyGetReq, deptModel *model.SysDept) error {
 	return nil
 }
 
+// GetCurrentCompany 获取登录用户的公司信息
+func (e *Company) GetCurrentCompany(p *actions.DataPermission, list *[]model.SysDept, c *dto.CompanyGetPageReq, count *int64) error {
+	// 检查 e.Orm 是否为 nil
+	var err error
+	var data model.SysDept
+	err = e.Orm.Model(&data).
+		Scopes(
+			CompanyIdScopesUser(p.DeptId),
+			cDto.MakeCondition(c.GetNeedSearch()),
+			cDto.Paginate(c.GetPageSize(), c.GetPageIndex()),
+		).
+		Find(list).Limit(-1).Offset(-1).
+		Count(count).Error
+	if err != nil {
+		e.Log.Errorf("db error: %s", err)
+		return global.GetFailedErr
+	}
+	return nil
+}
+
 // Insert 创建SysDept对象
 func (e *Company) Insert(c *dto.CompanyInsertReq) error {
 	var err error

+ 90 - 40
app/admin/service/dto/waybill.go

@@ -2,7 +2,7 @@ package dto
 
 import (
 	"cold-delivery/app/admin/model"
-	"cold-delivery/common/dto"
+	dto2 "cold-delivery/common/dto"
 	common "cold-delivery/common/model"
 	model2 "cold-delivery/common/model"
 	"time"
@@ -11,15 +11,15 @@ import (
 // 运单
 
 type WaybillGetPageReq struct {
-	dto.Pagination `search:"-"`
-	WaybillNo      string `form:"waybillNo" search:"type:contains;column:waybill_no;table:waybill"` // 运单编号
-	OrderNo        string `form:"orderNo" search:"type:contains;column:order_no;table:waybill"`     // 运单编号
-	Status         int    `form:"status" search:"type:exact;column:status;table:waybill"`           // 状态
-	OrderStartTime string `form:"orderStartTime" search:"type:gte;column:order_time;table:waybill"` // 下单开始时间
-	OrderEndTime   string `form:"orderEndTime" search:"type:lte;column:order_time;table:waybill"`   // 下单结束时间
+	dto2.Pagination  `search:"-"`
+	WaybillNo        string `form:"waybillNo" search:"type:contains;column:waybill_no;table:waybill"`              // 运单编号
+	OrderNo          string `form:"orderNo" search:"type:contains;column:order_no;table:waybill"`                  // 运单编号
+	Status           int    `form:"status" search:"type:exact;column:status;table:waybill"`                        // 状态
+	AssignmentStatus int    `form:"assignment_status"  search:"type:exact;column:assignment_status;table:waybill"` //分配状态  1 未分配  2已分配
+	OrderStartTime   string `form:"orderStartTime" search:"type:gte;column:order_time;table:waybill"`              // 下单开始时间
+	OrderEndTime     string `form:"orderEndTime" search:"type:lte;column:order_time;table:waybill"`                // 下单结束时间
 	WaybillOrder
 }
-
 type WaybillOrder struct {
 	CreatedAtOrder string `search:"type:order;column:created_at;table:waybill" form:"createdAtOrder" default:"desc"`
 }
@@ -29,13 +29,13 @@ func (m *WaybillGetPageReq) GetNeedSearch() interface{} {
 }
 
 type WaybillGetCustomerPageReq struct {
-	dto.Pagination `search:"-"`
-	WaybillNo      string `form:"waybillNo" search:"type:contains;column:waybill_no;table:waybill"`                      // 运单编号
-	OrderNo        string `form:"orderNo" search:"type:contains;column:order_no;table:waybill"`                          // 运单编号
-	Status         int    `form:"status" search:"-"`                                                                     // 状态
-	OrderStartTime string `form:"orderStartTime" search:"type:gte;column:order_time;table:waybill"`                      // 下单开始时间
-	OrderEndTime   string `form:"orderEndTime" search:"type:lte;column:order_time;table:waybill"`                        // 下单结束时间
-	CustomerId     int    `form:"customerId" search:"type:exact;column:customer_id;table:waybill"  swaggerignore:"true"` // 客户id
+	dto2.Pagination `search:"-"`
+	WaybillNo       string `form:"waybillNo" search:"type:contains;column:waybill_no;table:waybill"`                      // 运单编号
+	OrderNo         string `form:"orderNo" search:"type:contains;column:order_no;table:waybill"`                          // 运单编号
+	Status          int    `form:"status" search:"-"`                                                                     // 状态
+	OrderStartTime  string `form:"orderStartTime" search:"type:gte;column:order_time;table:waybill"`                      // 下单开始时间
+	OrderEndTime    string `form:"orderEndTime" search:"type:lte;column:order_time;table:waybill"`                        // 下单结束时间
+	CustomerId      int    `form:"customerId" search:"type:exact;column:customer_id;table:waybill"  swaggerignore:"true"` // 客户id
 	WaybillOrder
 }
 
@@ -119,6 +119,19 @@ type WaybillUpdateReq struct {
 	model2.ControlBy        `swaggerignore:"true"`
 	model2.DeptBy           `swaggerignore:"true"`
 }
+type WaybillUpdateReqaudit struct {
+	Id                         int    `json:"id" comment:"编码" swaggerignore:"true"` // 编码
+	OrderNo                    string `json:"orderNo"`
+	Status                     int    `json:"status"`                                              // 状态
+	PrescriptionIsAudit        int    `json:"prescriptionIssue"  gorm:"size:128;default:1"`        // 处方是否审核 1 未审核 2已审核
+	InvoiceIsAudit             int    `json:"invoiceIssue"  gorm:"size:128;default:1"`             // 发票是否审核 1 未审核 2已审核
+	InspectionReportIsAudit    int    `json:"inspectionReportIssue"  gorm:"size:128;default:1"`    // 检验报告是否审核 1 未审核 2已审核
+	DispensingMedicinesIsAudit int    `json:"dispensingMedicinesIssue"  gorm:"size:128;default:1"` //  调配药品信息是否审核  1 未审核 2已审核
+	IsCold                     int    `json:"isCold"  gorm:"size:128;default:1"`                   // 是否冷链 1 否 2 是
+	AuditRemark                string `json:"audit_remark"  gorm:"size:255;default:''"`            //审核备注
+	model2.ControlBy           `swaggerignore:"true"`
+	model2.DeptBy              `swaggerignore:"true"`
+}
 
 func (s *WaybillUpdateReq) Generate(m *model.Waybill) {
 	if s.Id != 0 {
@@ -146,43 +159,76 @@ func (s *WaybillUpdateReq) Generate(m *model.Waybill) {
 		m.CreateBy = s.CreateBy
 	}
 }
+func (s *WaybillUpdateReqaudit) Generate(m *model.Waybill) {
+	if s.Id != 0 {
+		m.Id = s.Id
+	}
+	m.OrderNo = s.OrderNo
+
+	m.PrescriptionIsAudit = s.PrescriptionIsAudit
+	m.InvoiceIsAudit = s.InvoiceIsAudit
+	m.InspectionReportIsAudit = s.InspectionReportIsAudit
+	m.DispensingMedicinesIsAudit = s.DispensingMedicinesIsAudit
+	m.IsCold = s.IsCold
+	m.Status = s.Status
 
+}
 func (s *WaybillUpdateReq) GetId() interface{} {
 	return s.Id
 }
+func (s *WaybillUpdateReqaudit) GetId() interface{} {
+	return s.Id
+}
 
 type WaybillUpdateStatusReq struct {
 	Id               int `json:"id" comment:"编码" swaggerignore:"true"` // 编码
-	Status           int `json:"status"`                               //药品数量
+	Status           int `json:"status"`                               //订单状态
 	model2.ControlBy `swaggerignore:"true"`
 	model2.DeptBy    `swaggerignore:"true"`
 }
-
-func (s *WaybillUpdateStatusReq) Generate(m *model.Waybill) {
-	if s.Id != 0 {
-		m.Id = s.Id
-	}
-	m.Status = s.Status
-
-	if s.ControlBy.UpdateBy != 0 {
-		m.UpdateBy = s.UpdateBy
-	}
-	if s.ControlBy.CreateBy != 0 {
-		m.CreateBy = s.CreateBy
-	}
+type UpdateStatusReq struct {
+	Id               []int `json:"id" comment:"编码" swaggerignore:"true"` // 编码
+	Status           int   `json:"status"`
+	model2.ControlBy `swaggerignore:"true"`
+	model2.DeptBy    `swaggerignore:"true"`
 }
+type WaybillUpdateStatusReqList struct {
+	Id               []int `json:"id" comment:"编码" swaggerignore:"true"` // 编码
+	Status           int   `json:"status"`                               //订单状态
+	model2.ControlBy `swaggerignore:"true"`
+	model2.DeptBy    `swaggerignore:"true"`
+}
+
+//func (s *WaybillUpdateStatusReq) Generate(m *model.Waybill) {
+//	if s.Id != 0 {
+//		m.Id = s.Id
+//	}
+//	m.Status = s.Status
+//
+//	if s.ControlBy.UpdateBy != 0 {
+//		m.UpdateBy = s.UpdateBy
+//	}
+//	if s.ControlBy.CreateBy != 0 {
+//		m.CreateBy = s.CreateBy
+//	}
+//}
 
 func (s *WaybillUpdateStatusReq) GetId() interface{} {
 	return s.Id
 }
+func (s *UpdateStatusReq) GetId() interface{} {
+	return s.Id
+}
 
 type WaybillDeliveryReq struct {
-	WaybillIds       []int    `json:"waybillIds"`                          // 运单id
-	CoolerBoxId      int      `json:"coolerBoxId"`                         // 保温箱id
-	IceRaftCode      []string `json:"iceRaftCode"`                         // 冰排code
-	OldIceRaftCode   []string `json:"oldIceRaftCode" swaggerignore:"true"` // 旧的冰排code
-	model2.ControlBy `swaggerignore:"true"`
-	model2.DeptBy    `swaggerignore:"true"`
+	WaybillIds          []int    `json:"waybillIds"`                            // 运单id
+	CoolerBoxId         int      `json:"coolerBoxId"`                           // 保温箱id
+	IceRaftCode         []string `json:"iceRaftCode"`                           // 冰排code
+	OldIceRaftCode      []string `json:"oldIceRaftCode" swaggerignore:"true"`   // 旧的冰排code
+	TamperProofLabel    string   `json:"tamperProofLabel"  gorm:"size:128"`     // 防拆标签
+	TamperProofLabelImg string   `json:"tamperProofLabelImg"  gorm:"size:text"` // 防拆标签图片
+	model2.ControlBy    `swaggerignore:"true"`
+	model2.DeptBy       `swaggerignore:"true"`
 }
 
 func (s *WaybillDeliveryReq) GetId() interface{} {
@@ -214,18 +260,22 @@ type WaybillInOutReq struct {
 
 // 运单签收
 type WaybillReceiptReq struct {
-	Status          int    `json:"status"`          // 3 已签收 5 已拒收
+	Status          int    `json:"status"`          // 5 已签收 6 已拒收
 	RejectionReason string `json:"rejectionReason"` // 拒收原因
 	WaybillNo       string `json:"waybillNo"`       // 订单编号
-	ReceiptImg      string `json:"receiptImg"`      // 签收图片
+	ReceiptImg      string `json:"receiptImg"`      // 签收图片凭证
+	Receiptsign     string `json:"receiptsign"`     // 签收图片签字
+	PaymentStatus   int    `json:"paymentStatus"`   //支付状态 1 结清 2 未结清  3 支付完成
+	PaymentType     int    `json:"paymentType"`     //支付方式  1现金 2线上支付 3银行卡 4医保 5其他
+	PaymentRemark   int    `json:"paymentremark"`   //支付备注
 	AssessStar      int    `json:"assessStar"`      // 评价星星
 	AssessContent   string `json:"assessContent"`   // 评价内容
 }
 
 type WaybillGetAppletPageReq struct {
-	dto.Pagination `search:"-"`
-	WaybillNo      string `form:"waybillNo" search:"type:contains;column:waybill_no;table:waybill_logistics"` // 运单编号
-	Status         int    `form:"status" search:"type:exact;column:status;table:waybill_logistics"`           // 状态
+	dto2.Pagination `search:"-"`
+	WaybillNo       string `form:"waybillNo" search:"type:contains;column:waybill_no;table:waybill_logistics"` // 运单编号
+	Status          int    `form:"status" search:"type:exact;column:status;table:waybill_logistics"`           // 状态
 	WaybillOrder
 }
 

+ 1 - 0
app/admin/service/dto/waybill_task.go

@@ -7,6 +7,7 @@ import "cold-delivery/common/dto"
 type WaybillTaskGetPageReq struct {
 	//dto.Pagination `search:"-"`
 	WaybillNo string `form:"waybillNo" search:"type:contains;column:waybill_no;table:waybill_task" vd:"len($)>0;msg:'订单编号不能为空'"` // 运单编号-必填
+
 	WaybillTaskOrder
 }
 

+ 6 - 1
app/admin/service/sys_user.go

@@ -150,7 +150,12 @@ func (e *SysUser) Insert(c *dto.SysUserInsertReq, p *actions.DataPermission) err
 		e.Log.Errorf("获取操作用户信息失败: %s", err)
 		return errors.New("获取操作用户信息失败")
 	}
-	if operatingUser.Type != model.SysUserTypeSys || operatingUser.Id != 1 {
+
+	//if (operatingUser.Type != model.SysUserTypeSys) || (operatingUser.Id != 1) {
+	//	err = errors.New("无权添加用户,请联系管理员!")
+	//	return err
+	//}
+	if operatingUser.Type != model.SysUserTypeSys {
 		err = errors.New("无权添加用户,请联系管理员!")
 		return err
 	}

+ 201 - 67
app/admin/service/waybill.go

@@ -29,38 +29,116 @@ type Waybill struct {
 }
 
 // GetPage 获取Waybill列表
+//
+//	func (e *Waybill) GetPage(c *dto.WaybillGetPageReq, list *[]model.Waybill, count *int64, p *actions.DataPermission) error {
+//		var err error
+//		var data model.Waybill
+//		if c.PageSize == 9999 {
+//			err = e.Orm.Model(&data).
+//				Scopes(
+//					cDto.MakeCondition(c.GetNeedSearch()),
+//					actions.Permission(data.TableName(), p),
+//				).
+//				Preload("CoolerBox").
+//				Preload("Delivery").
+//				Preload("ReCheck").
+//				Find(list).Limit(-1).Offset(-1).
+//				Count(count).Error
+//			if err != nil {
+//				e.Log.Errorf("db error: %s", err)
+//				return global.GetFailedErr
+//			}
+//			return nil
+//		}
+//
+//		err = e.Orm.Model(&data).
+//			Scopes(
+//				cDto.MakeCondition(c.GetNeedSearch()),
+//				cDto.Paginate(c.GetPageSize(), c.GetPageIndex()),
+//				actions.Permission(data.TableName(), p),
+//			).
+//			Preload("CoolerBox").
+//			Preload("Delivery").
+//			Preload("ReCheck").
+//			Find(list).Limit(-1).Offset(-1).
+//			Count(count).Error
+//		if err != nil {
+//			e.Log.Errorf("db error: %s", err)
+//			return global.GetFailedErr
+//		}
+//		return nil
+//	}
+//
+//	func (e *Waybill) GetUserPage(c *dto.WaybillGetPageReq, list *[]model.Waybill, count *int64, p *actions.DataPermission) error {
+//		var err error
+//		var data model.Waybill
+//		if c.PageSize == 9999 {
+//			err = e.Orm.Model(&data).
+//				Scopes(
+//					cDto.MakeCondition(c.GetNeedSearch()),
+//				).
+//				Where("create_by = ?", p.UserId).
+//				Find(list).Limit(-1).Offset(-1).
+//				Count(count).Error
+//			if err != nil {
+//				e.Log.Errorf("db error: %s", err)
+//				return global.GetFailedErr
+//			}
+//			return nil
+//		}
+//
+//		err = e.Orm.Model(&data).
+//			Scopes(
+//				cDto.MakeCondition(c.GetNeedSearch()),
+//				cDto.Paginate(c.GetPageSize(), c.GetPageIndex()),
+//			).
+//			Where("delivery_id = ? or re_check_id = ? or create_by = ?", p.UserId, p.UserId, p.UserId).
+//			Preload("CoolerBox").
+//			Preload("Delivery").
+//			Preload("ReCheck").
+//			Find(list).Limit(-1).Offset(-1).
+//			Count(count).Error
+//		if err != nil {
+//			e.Log.Errorf("db error: %s", err)
+//			return global.GetFailedErr
+//		}
+//		return nil
+//	}
 func (e *Waybill) GetPage(c *dto.WaybillGetPageReq, list *[]model.Waybill, count *int64, p *actions.DataPermission) error {
 	var err error
 	var data model.Waybill
-	if c.PageSize == 9999 {
-		err = e.Orm.Model(&data).
-			Scopes(
-				cDto.MakeCondition(c.GetNeedSearch()),
-				actions.Permission(data.TableName(), p),
-			).
-			Preload("CoolerBox").
-			Preload("Delivery").
-			Preload("ReCheck").
-			Find(list).Limit(-1).Offset(-1).
-			Count(count).Error
-		if err != nil {
-			e.Log.Errorf("db error: %s", err)
-			return global.GetFailedErr
-		}
-		return nil
-	}
 
-	err = e.Orm.Model(&data).
+	// 构建基础查询
+	db := e.Orm.Model(&data).
 		Scopes(
 			cDto.MakeCondition(c.GetNeedSearch()),
-			cDto.Paginate(c.GetPageSize(), c.GetPageIndex()),
 			actions.Permission(data.TableName(), p),
 		).
 		Preload("CoolerBox").
 		Preload("Delivery").
-		Preload("ReCheck").
-		Find(list).Limit(-1).Offset(-1).
-		Count(count).Error
+		Preload("ReCheck")
+
+	// 如果Status为1,则同时查询status=1和status=7
+	if c.Status == model.WaybillStatusWaitDelivery {
+		db = db.Where("status IN (?)", []int{model.WaybillStatusWaitDelivery, model.WaybillStatusoverrule})
+	}
+
+	// 先计算总条目数
+	if err = db.Count(count).Error; err != nil {
+		e.Log.Errorf("db error: %s", err)
+		return global.GetFailedErr
+	}
+
+	// 如果PageSize设置为9999,则不分页
+	if c.PageSize == 9999 {
+		err = db.Find(list).Error
+	} else {
+		// 应用分页
+		err = db.Scopes(
+			cDto.Paginate(c.GetPageSize(), c.GetPageIndex()),
+		).Find(list).Error
+	}
+
 	if err != nil {
 		e.Log.Errorf("db error: %s", err)
 		return global.GetFailedErr
@@ -70,32 +148,41 @@ func (e *Waybill) GetPage(c *dto.WaybillGetPageReq, list *[]model.Waybill, count
 func (e *Waybill) GetUserPage(c *dto.WaybillGetPageReq, list *[]model.Waybill, count *int64, p *actions.DataPermission) error {
 	var err error
 	var data model.Waybill
-	if c.PageSize == 9999 {
-		err = e.Orm.Model(&data).
-			Scopes(
-				cDto.MakeCondition(c.GetNeedSearch()),
-			).
-			Where("create_by = ?", p.UserId).
-			Find(list).Limit(-1).Offset(-1).
-			Count(count).Error
-		if err != nil {
-			e.Log.Errorf("db error: %s", err)
-			return global.GetFailedErr
-		}
-		return nil
-	}
 
-	err = e.Orm.Model(&data).
+	// 构建基础查询
+	db := e.Orm.Model(&data).
 		Scopes(
 			cDto.MakeCondition(c.GetNeedSearch()),
+		)
+
+	// 如果Status为1,则同时查询status=1和status=7
+	if c.Status == model.WaybillStatusWaitDelivery {
+		db = db.Where("status IN (?)", []int{model.WaybillStatusWaitDelivery, model.WaybillStatusoverrule})
+	}
+
+	// 添加用户相关的条件
+	db = db.Where("create_by = ?", p.UserId)
+
+	// 先计算总条目数
+	if err = db.Count(count).Error; err != nil {
+		e.Log.Errorf("db error: %s", err)
+		return global.GetFailedErr
+	}
+
+	// 如果PageSize设置为9999,则不分页
+	if c.PageSize == 9999 {
+		err = db.Find(list).Error
+	} else {
+		// 应用分页
+		err = db.Scopes(
 			cDto.Paginate(c.GetPageSize(), c.GetPageIndex()),
 		).
-		Where("delivery_id = ? or re_check_id = ? or create_by = ?", p.UserId, p.UserId, p.UserId).
-		Preload("CoolerBox").
-		Preload("Delivery").
-		Preload("ReCheck").
-		Find(list).Limit(-1).Offset(-1).
-		Count(count).Error
+			Preload("CoolerBox").
+			Preload("Delivery").
+			Preload("ReCheck").
+			Find(list).Error
+	}
+
 	if err != nil {
 		e.Log.Errorf("db error: %s", err)
 		return global.GetFailedErr
@@ -328,9 +415,10 @@ func (e *Waybill) Update(c *dto.WaybillUpdateReq, p *actions.DataPermission) err
 	c.Id = waybillModel.Id
 	return nil
 }
-func (e *Waybill) UpdateStatus(c *dto.WaybillUpdateStatusReq, p *actions.DataPermission) error {
-	var err error
 
+// 审核订单
+func (e *Waybill) Audit(c *dto.WaybillUpdateReqaudit, p *actions.DataPermission) error {
+	var err error
 	tx := e.Orm.Begin()
 	defer func() {
 		if err != nil {
@@ -339,7 +427,6 @@ func (e *Waybill) UpdateStatus(c *dto.WaybillUpdateStatusReq, p *actions.DataPer
 			tx.Commit()
 		}
 	}()
-
 	var waybillModel = model.Waybill{}
 	// 查询运单是否存在
 	err = e.Orm.Scopes(actions.Permission(waybillModel.TableName(), p)).
@@ -351,17 +438,57 @@ func (e *Waybill) UpdateStatus(c *dto.WaybillUpdateStatusReq, p *actions.DataPer
 		}
 		return global.UpdateFailedErr
 	}
-
 	c.Generate(&waybillModel)
-	err = tx.Save(&waybillModel).Error
+	waybillModel.Status = c.Status
+	err = tx.Updates(&waybillModel).Error
 	if err != nil {
 		e.Log.Errorf("db error: %s", err)
 		return global.UpdateFailedErr
 	}
-
 	c.Id = waybillModel.Id
 	return nil
 }
+func (e *Waybill) UpdateStatus(c *dto.UpdateStatusReq, p *actions.DataPermission) error {
+	var err error
+	tx := e.Orm.Begin()
+	defer func() {
+		if err != nil {
+			tx.Rollback()
+		} else {
+			tx.Commit()
+		}
+	}()
+
+	// 查询运单是否存在
+	for _, v := range c.Id {
+		var waybillModel = model.Waybill{}
+		err = e.Orm.Scopes(actions.Permission(waybillModel.TableName(), p)).
+			First(&waybillModel, v).Error
+		if err != nil {
+			e.Log.Errorf("db error: %s", err)
+			if errors.Is(err, gorm.ErrRecordNotFound) {
+				return global.UpdateNotFoundOrNoPermissionErr
+			}
+			return global.UpdateFailedErr
+		}
+
+		waybillModel.Status = c.Status
+		err = tx.Table(waybillModel.TableName()).Where("id=?", v).Update("status", c.Status).Error
+		if err != nil {
+			e.Log.Errorf("db error: %s", err)
+			return global.UpdateFailedErr
+		}
+	}
+
+	//err = tx.Save(&waybillModel).Error
+	//if err != nil {
+	//	e.Log.Errorf("db error: %s", err)
+	//	return global.UpdateFailedErr
+	//}
+
+	//c.Id = waybillModel.Id
+	return nil
+}
 
 // 派单
 func (e *Waybill) Delivery(c *dto.WaybillDeliveryReq, p *actions.DataPermission) error {
@@ -460,11 +587,14 @@ func (e *Waybill) Delivery(c *dto.WaybillDeliveryReq, p *actions.DataPermission)
 			}
 			return global.UpdateFailedErr
 		}
+		//派单时添加
 		waybillModeStatus := waybillModel.Status
-		if waybillModel.Status == model.WaybillStatusWaitDelivery ||
-			(waybillModel.Status == model.WaybillStatusInDelivery && waybillModel.CoolerBoxId != c.CoolerBoxId) ||
-			(waybillModel.Status == model.WaybillStatusInDelivery && !lib.StrListEqual(c.IceRaftCode, c.OldIceRaftCode)) {
-			waybillModel.Status = model.WaybillStatusInDelivery
+		if waybillModel.Status == model.WaybillStatusInDeliverys ||
+			(waybillModel.Status == model.WaybillStatusInDeliverys && waybillModel.CoolerBoxId != c.CoolerBoxId) ||
+			(waybillModel.Status == model.WaybillStatusInDeliverys && !lib.StrListEqual(c.IceRaftCode, c.OldIceRaftCode)) {
+			waybillModel.Status = model.WaybillStatusInDeliverys
+			waybillModel.TamperProofLabel = c.TamperProofLabel
+			waybillModel.TamperProofLabelImg = c.TamperProofLabelImg // 防拆标签
 			waybillModel.CoolerBoxId = c.CoolerBoxId
 			waybillModel.DeliveryTime = model2.Time(time.Now())
 			waybillModel.IceRaftCode = c.IceRaftCode
@@ -476,7 +606,7 @@ func (e *Waybill) Delivery(c *dto.WaybillDeliveryReq, p *actions.DataPermission)
 
 			// 查询任务
 			var logistics model.WaybillLogistics
-			err = tx.Model(&logistics).Where("waybill_no = ? and status = ?", waybillModel.WaybillNo, model.WaybillStatusInDelivery).
+			err = tx.Model(&logistics).Where("waybill_no = ? and status = ?", waybillModel.WaybillNo, model.WaybillStatusInDeliverys).
 				Last(&logistics).Error
 			if err != nil {
 				if errors.Is(err, gorm.ErrRecordNotFound) {
@@ -552,8 +682,8 @@ func (e *Waybill) Delivery(c *dto.WaybillDeliveryReq, p *actions.DataPermission)
 
 		}
 
-		// 待派单状态下才发送短信
-		if waybillModeStatus == model.WaybillStatusWaitDelivery {
+		// 待配送时状态下才发送短信
+		if waybillModeStatus == model.WaybillStatusInDeliverys {
 			ss := sms.NewSMS(conf.ExtConfig.SubMail.Appid, conf.ExtConfig.SubMail.Signature)
 			addr := conf.ExtConfig.Applet.WaybillUrl + url.QueryEscape(lib.AesEncryptCBC(waybillModel.WaybillNo, lib.AesKey))
 			res, err1 := ss.SmsXSend(waybillModel.ConsigneeAddressPhone, addr)
@@ -653,13 +783,17 @@ func (e *Waybill) Receipt(c *dto.WaybillReceiptReq, p *actions.DataPermission) e
 		return err
 	}
 
-	if waybillModel.Status == model.WaybillStatusReceipt || waybillModel.Status == model.WaybillStatusRejection {
+	if waybillModel.Status == model.WaybillStatusReceipts || waybillModel.Status == model.WaybillStatusRejections {
 		return nil
 	}
 	waybillModel.Status = c.Status
 	waybillModel.RejectionReason = c.RejectionReason
 	waybillModel.ReceiptTime = model2.Time(time.Now())
 	waybillModel.ReceiptImg = c.ReceiptImg
+	waybillModel.Receiptsign = c.Receiptsign
+	waybillModel.PaymentStatus = c.PaymentStatus
+	waybillModel.PaymentType = c.PaymentType
+	waybillModel.PaymentRemark = c.PaymentRemark
 	waybillModel.AssessContent = c.AssessContent
 	waybillModel.AssessStar = c.AssessStar
 	waybillModel.DeliveryDuration = int(time.Now().Sub(waybillModel.DeliveryTime.Local()).Minutes())
@@ -783,14 +917,14 @@ func (e *Waybill) GetBasicsStats(c *dto.WaybillStatsReq, p *actions.DataPermissi
 
 	// 今日总运单数
 	e.Orm.Model(&data).Scopes(actions.Permission(data.TableName(), p)).Where("order_time between ? and ?", todayStartTime, todayEndTime).Count(&res.TodayNum)
-	// 待派单
+	// 待确定
 	e.Orm.Model(&data).Scopes(actions.Permission(data.TableName(), p)).Where("status = ?", model.WaybillStatusWaitDelivery).Count(&res.WaitDeliveryNum)
 	// 配送中
-	e.Orm.Model(&data).Scopes(actions.Permission(data.TableName(), p)).Where("status = ?", model.WaybillStatusInDelivery).Count(&res.InDeliveryNum)
-	// 已送达
-	e.Orm.Model(&data).Scopes(actions.Permission(data.TableName(), p)).Where("status = ?", model.WaybillStatusReceipt).Count(&res.ReceiptNum)
+	e.Orm.Model(&data).Scopes(actions.Permission(data.TableName(), p)).Where("status = ?", model.WaybillStatusInDeliverys).Count(&res.InDeliveryNum)
+	// 已签收
+	e.Orm.Model(&data).Scopes(actions.Permission(data.TableName(), p)).Where("status = ?", model.WaybillStatusReceipts).Count(&res.ReceiptNum)
 	// 已取消
-	e.Orm.Model(&data).Scopes(actions.Permission(data.TableName(), p)).Where("status = ?", model.WaybillStatusRejection).Count(&res.RejectionNum)
+	e.Orm.Model(&data).Scopes(actions.Permission(data.TableName(), p)).Where("status = ?", model.WaybillStatusRejections).Count(&res.RejectionNum)
 	// 获取本月,上月数据
 	e.Orm.Model(&data).Select("date_format(order_time,'%Y%m') date,count(1) as count ").Scopes(actions.Permission(data.TableName(), p)).
 		Where("order_time between ? and ?", monthStartTime, now).Group("date").Find(&monthCount)
@@ -939,13 +1073,13 @@ func (e *Waybill) GetUserBasicsStats(c *dto.WaybillStatsReq, p *actions.DataPerm
 		Where("status = ?", model.WaybillStatusWaitDelivery).Count(&res.WaitDeliveryNum)
 	// 配送中
 	e.Orm.Model(&data).Scopes(actions.Permission(data.TableName(), p), scopes).
-		Where("status = ?", model.WaybillStatusInDelivery).Count(&res.InDeliveryNum)
+		Where("status = ?", model.WaybillStatusInDeliverys).Count(&res.InDeliveryNum)
 	// 已送达
 	e.Orm.Model(&data).Scopes(actions.Permission(data.TableName(), p), scopes).
-		Where("status = ?", model.WaybillStatusReceipt).Count(&res.ReceiptNum)
+		Where("status = ?", model.WaybillStatusReceipts).Count(&res.ReceiptNum)
 	// 已取消
 	e.Orm.Model(&data).Scopes(actions.Permission(data.TableName(), p), scopes).
-		Where("status = ?", model.WaybillStatusRejection).Count(&res.RejectionNum)
+		Where("status = ?", model.WaybillStatusRejections).Count(&res.RejectionNum)
 	// 获取本月,上月数据
 	e.Orm.Model(&data).Select("date_format(order_time,'%Y%m') date,count(1) as count ").Scopes(actions.Permission(data.TableName(), p), scopes).
 		Where("order_time between ? and ?", monthStartTime, now).Group("date").Find(&monthCount)
@@ -1108,7 +1242,7 @@ func (e *Waybill) GetAllData(c *dto.WaybillGetByWaybillNoReq) ([]nats_server.Dev
 	}
 
 	// 未签收,不返回数据
-	if waybill.Status != model.WaybillStatusReceipt {
+	if waybill.Status != model.WaybillStatusReceipts {
 		return dataList, waybillPDF, nil
 	}
 
@@ -1175,7 +1309,7 @@ func (e *Waybill) GetAllData(c *dto.WaybillGetByWaybillNoReq) ([]nats_server.Dev
 						break
 					}
 				}
-				if waybill.Status == model.WaybillStatusReceipt {
+				if waybill.Status == model.WaybillStatusReceipts {
 					for k := len(list) - 1; k >= 0; k-- {
 						if v.T_id == list[k].T_id {
 							if taskList[i].Id == lastWaybillTask.Id && list[k].T_time != taskList[i].EndTime.String() && !time.Time(taskList[i].EndTime).IsZero() {

+ 101 - 0
common/dto/search.go

@@ -83,6 +83,107 @@ func MakeCondition(q interface{}) func(db *gorm.DB) *gorm.DB {
 	}
 }
 
+//func MakeCondition(q interface{}) func(db *gorm.DB) *gorm.DB {
+//	return func(db *gorm.DB) *gorm.DB {
+//		// 检查是否是WaybillGetPageReq类型
+//		req, ok := q.(*dto2.WaybillGetPageReq)
+//		if !ok {
+//			// 如果不是WaybillGetPageReq类型,则继续正常的处理逻辑
+//			return makeNormalCondition(q)(db)
+//		}
+//
+//		// 特别处理Status字段
+//		if req.Status == 1 {
+//			// 添加一个额外的条件来匹配status=7
+//			db = db.Or("status = ?", model.WaybillStatusoverrule)
+//		}
+//
+//		// 继续使用search.ResolveSearchQuery来处理其他条件
+//		condition := &search.GormCondition{
+//			GormPublic: search.GormPublic{},
+//			Join:       make([]*search.GormJoin, 0),
+//		}
+//		search.ResolveSearchQuery(global.Driver, q, condition)
+//
+//		for _, join := range condition.Join {
+//			if join == nil {
+//				continue
+//			}
+//			db = db.Joins(join.JoinOn)
+//			for k, v := range join.Where {
+//				db = db.Where(k, v...)
+//			}
+//			for k, v := range join.Or {
+//				db = db.Or(k, v...)
+//			}
+//			for _, o := range join.Order {
+//				db = db.Order(o)
+//			}
+//		}
+//		for k, v := range condition.Where {
+//			db = db.Where(k, v...)
+//		}
+//		for k, v := range condition.Or {
+//			db = db.Or(k, v...)
+//		}
+//		var orContains string
+//		for k, v := range condition.OrContains {
+//			orContains += fmt.Sprintf(" OR %v '%v'", k, v[0])
+//		}
+//		if len(orContains) > 0 {
+//			db = db.Where(strings.TrimLeft(orContains, " OR"))
+//		}
+//		for _, o := range condition.Order {
+//			db = db.Order(o)
+//		}
+//		return db
+//	}
+//}
+//
+//// 辅助函数:用于处理非WaybillGetPageReq类型的正常情况
+//func makeNormalCondition(q interface{}) func(db *gorm.DB) *gorm.DB {
+//	return func(db *gorm.DB) *gorm.DB {
+//		condition := &search.GormCondition{
+//			GormPublic: search.GormPublic{},
+//			Join:       make([]*search.GormJoin, 0),
+//		}
+//		search.ResolveSearchQuery(global.Driver, q, condition)
+//
+//		for _, join := range condition.Join {
+//			if join == nil {
+//				continue
+//			}
+//			db = db.Joins(join.JoinOn)
+//			for k, v := range join.Where {
+//				db = db.Where(k, v...)
+//			}
+//			for k, v := range join.Or {
+//				db = db.Or(k, v...)
+//			}
+//			for _, o := range join.Order {
+//				db = db.Order(o)
+//			}
+//		}
+//		for k, v := range condition.Where {
+//			db = db.Where(k, v...)
+//		}
+//		for k, v := range condition.Or {
+//			db = db.Or(k, v...)
+//		}
+//		var orContains string
+//		for k, v := range condition.OrContains {
+//			orContains += fmt.Sprintf(" OR %v '%v'", k, v[0])
+//		}
+//		if len(orContains) > 0 {
+//			db = db.Where(strings.TrimLeft(orContains, " OR"))
+//		}
+//		for _, o := range condition.Order {
+//			db = db.Order(o)
+//		}
+//		return db
+//	}
+//}
+
 func Paginate(pageSize, pageIndex int) func(db *gorm.DB) *gorm.DB {
 	return func(db *gorm.DB) *gorm.DB {
 		offset := (pageIndex - 1) * pageSize