|
@@ -38,6 +38,9 @@ func (e *Waybill) GetPage(c *dto.WaybillGetPageReq, list *[]model.Waybill, count
|
|
|
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 {
|
|
@@ -54,6 +57,8 @@ func (e *Waybill) GetPage(c *dto.WaybillGetPageReq, list *[]model.Waybill, count
|
|
|
actions.Permission(data.TableName(), p),
|
|
|
).
|
|
|
Preload("CoolerBox").
|
|
|
+ Preload("Delivery").
|
|
|
+ Preload("ReCheck").
|
|
|
Find(list).Limit(-1).Offset(-1).
|
|
|
Count(count).Error
|
|
|
if err != nil {
|
|
@@ -85,8 +90,10 @@ func (e *Waybill) GetUserPage(c *dto.WaybillGetPageReq, list *[]model.Waybill, c
|
|
|
cDto.MakeCondition(c.GetNeedSearch()),
|
|
|
cDto.Paginate(c.GetPageSize(), c.GetPageIndex()),
|
|
|
).
|
|
|
- Where("create_by = ?", p.UserId).
|
|
|
+ Where("delivery_id = ? or re_check_id = ?", p.UserId, p.UserId).
|
|
|
Preload("CoolerBox").
|
|
|
+ Preload("Delivery").
|
|
|
+ Preload("ReCheck").
|
|
|
Find(list).Limit(-1).Offset(-1).
|
|
|
Count(count).Error
|
|
|
if err != nil {
|
|
@@ -240,24 +247,24 @@ func (e *Waybill) Insert(c *dto.WaybillInsertReq) error {
|
|
|
c.Id = data.Id
|
|
|
|
|
|
// 保存收货地址
|
|
|
- if c.SaveSenderAddress {
|
|
|
- // 查询地址是否存在
|
|
|
- address := model.Address{}
|
|
|
- err = e.Orm.Where("address = ? and phone = ? and name = ? and dept_id = ? and address_type = 'sender'",
|
|
|
- c.SenderAddressDetails, c.SenderAddressPhone, c.SenderAddressName, c.DeptId).First(&address).Error
|
|
|
- if err != nil && errors.Is(err, gorm.ErrRecordNotFound) {
|
|
|
- address.Address = c.SenderAddressDetails
|
|
|
- address.Phone = c.SenderAddressPhone
|
|
|
- address.Name = c.SenderAddressName
|
|
|
- address.DeptId = c.DeptId
|
|
|
- address.AddressType = "sender"
|
|
|
- err = tx.Create(&address).Error
|
|
|
- if err != nil {
|
|
|
- e.Log.Errorf("创建地址失败: %s", err)
|
|
|
- return global.CreateFailedErr
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ //if c.SaveSenderAddress {
|
|
|
+ // // 查询地址是否存在
|
|
|
+ // address := model.Address{}
|
|
|
+ // err = e.Orm.Where("address = ? and phone = ? and name = ? and dept_id = ? and address_type = 'sender'",
|
|
|
+ // c.SenderAddressDetails, c.SenderAddressPhone, c.SenderAddressName, c.DeptId).First(&address).Error
|
|
|
+ // if err != nil && errors.Is(err, gorm.ErrRecordNotFound) {
|
|
|
+ // address.Address = c.SenderAddressDetails
|
|
|
+ // address.Phone = c.SenderAddressPhone
|
|
|
+ // address.Name = c.SenderAddressName
|
|
|
+ // address.DeptId = c.DeptId
|
|
|
+ // address.AddressType = "sender"
|
|
|
+ // err = tx.Create(&address).Error
|
|
|
+ // if err != nil {
|
|
|
+ // e.Log.Errorf("创建地址失败: %s", err)
|
|
|
+ // return global.CreateFailedErr
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ //}
|
|
|
|
|
|
// 保存发货地址
|
|
|
if c.SaveConsigneeAddress {
|
|
@@ -352,6 +359,8 @@ func (e *Waybill) UpdateStatus(c *dto.WaybillUpdateStatusReq, p *actions.DataPer
|
|
|
c.Id = waybillModel.Id
|
|
|
return nil
|
|
|
}
|
|
|
+
|
|
|
+// 派单
|
|
|
func (e *Waybill) Delivery(c *dto.WaybillDeliveryReq, p *actions.DataPermission) error {
|
|
|
var err error
|
|
|
|
|
@@ -364,6 +373,64 @@ func (e *Waybill) Delivery(c *dto.WaybillDeliveryReq, p *actions.DataPermission)
|
|
|
}
|
|
|
}()
|
|
|
|
|
|
+ if !lib.StrListEqual(c.IceRaftCode, c.OldIceRaftCode) {
|
|
|
+ // 获取删除的冰排列表
|
|
|
+ //missingIceRaftCode = lib.FindStrListMissingData(c.OldIceRaftCode, c.IceRaftCode)
|
|
|
+
|
|
|
+ //if len(missingIceRaftCode) > 0 {
|
|
|
+ // // 删除冰排出库记录
|
|
|
+ // IceRaftList := []model.IceRaft{}
|
|
|
+ // err = tx.Model(&model.IceRaft{}).Where("code in (?)", missingIceRaftCode).Find(&IceRaftList).Error
|
|
|
+ // if err != nil {
|
|
|
+ // e.Log.Errorf("db error: %s", err)
|
|
|
+ // return errors.New("获取冰排列表失败")
|
|
|
+ // }
|
|
|
+ // for _, iceRaft := range IceRaftList {
|
|
|
+ // // 获取冰排记录
|
|
|
+ // err = tx.Model(&model.IceRaftRecord{}).
|
|
|
+ // Where("ice_raft_id = ? and status = ?", iceRaft.Id, model.IceRaftRecordStatusUsing).
|
|
|
+ // Updates(map[string]interface{}{
|
|
|
+ // "status": model.IceRaftRecordStatusWaitUse,
|
|
|
+ // "out_storage_time": nil,
|
|
|
+ // "cooler_box_id": 0,
|
|
|
+ // }).Error
|
|
|
+ // if err != nil {
|
|
|
+ // e.Log.Errorf("db error: %s", err)
|
|
|
+ // return errors.New(fmt.Sprintf("冰排【%s】返库失败", iceRaft.Code))
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ //}
|
|
|
+ // 获取新增的冰排列表
|
|
|
+ extraData := lib.FindStrListExtraData(c.OldIceRaftCode, c.IceRaftCode)
|
|
|
+ if len(extraData) > 0 {
|
|
|
+ for _, code := range extraData {
|
|
|
+ var iceRaft model.IceRaft
|
|
|
+ err = tx.Model(&model.IceRaft{}).Where("code = ?", code).First(&iceRaft).Error
|
|
|
+ if err != nil {
|
|
|
+ e.Log.Errorf("db error: %s", err)
|
|
|
+ if errors.Is(err, gorm.ErrRecordNotFound) {
|
|
|
+ return errors.New(fmt.Sprintf("冰排【%s】不存在", code))
|
|
|
+ } else {
|
|
|
+ return errors.New(fmt.Sprintf("获取冰排【%s】信息失败", code))
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ // 获取冰排记录
|
|
|
+ err = tx.Model(&model.IceRaftRecord{}).
|
|
|
+ Where("ice_raft_id = ? and status = ?", iceRaft.Id, model.IceRaftRecordStatusWaitUse).
|
|
|
+ Updates(map[string]interface{}{
|
|
|
+ "status": model.IceRaftRecordStatusUsing,
|
|
|
+ "out_storage_time": time.Now(),
|
|
|
+ "cooler_box_id": c.CoolerBoxId,
|
|
|
+ }).Error
|
|
|
+ if err != nil {
|
|
|
+ e.Log.Errorf("db error: %s", err)
|
|
|
+ return errors.New(fmt.Sprintf("冰排【%s】出库失败", iceRaft.Code))
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
var coolerBox = model.CoolerBox{}
|
|
|
// 查询保温箱信息
|
|
|
err = tx.Scopes(actions.Permission(coolerBox.TableName(), p)).
|
|
@@ -386,10 +453,14 @@ func (e *Waybill) Delivery(c *dto.WaybillDeliveryReq, p *actions.DataPermission)
|
|
|
}
|
|
|
return global.UpdateFailedErr
|
|
|
}
|
|
|
- if waybillModel.Status == model.WaybillStatusWaitDelivery || (waybillModel.Status == model.WaybillStatusInDelivery && waybillModel.CoolerBoxId != c.CoolerBoxId) {
|
|
|
+ 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
|
|
|
waybillModel.CoolerBoxId = c.CoolerBoxId
|
|
|
waybillModel.DeliveryTime = model2.Time(time.Now())
|
|
|
+ waybillModel.IceRaftCode = c.IceRaftCode
|
|
|
err = tx.Save(&waybillModel).Error
|
|
|
if err != nil {
|
|
|
e.Log.Errorf("db error: %s", err)
|
|
@@ -472,21 +543,16 @@ func (e *Waybill) Delivery(c *dto.WaybillDeliveryReq, p *actions.DataPermission)
|
|
|
return errors.New(fmt.Sprintf("保存运单任务信息失败:%s", err))
|
|
|
}
|
|
|
|
|
|
- //if logistics.Id == 0 {
|
|
|
- // ss := sms.NewSMS(conf.ExtConfig.SubMail.Appid, conf.ExtConfig.SubMail.Signature)
|
|
|
- // res, err1 := ss.SmsXSend(waybillModel.ConsigneeAddressPhone, lib.AesEncryptCBC(waybillModel.WaybillNo, lib.AesKey))
|
|
|
- // if err1 != nil || res.Status != sms.SUCCESS {
|
|
|
- // e.Log.Errorf("发送短信验证码出现异常", zap.Any("res", res), zap.Error(err1))
|
|
|
- // err = errors.New("验证吗发送失败,请重试")
|
|
|
- // return err
|
|
|
- // }
|
|
|
- //}
|
|
|
+ }
|
|
|
+
|
|
|
+ // 待派单状态下才发送短信
|
|
|
+ if waybillModeStatus == model.WaybillStatusWaitDelivery {
|
|
|
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)
|
|
|
if err1 != nil || res.Status != sms.SUCCESS {
|
|
|
- e.Log.Errorf("发送短信验证码出现异常", zap.Any("res", res), zap.Error(err1))
|
|
|
- err = errors.New("验证吗发送失败,请重试")
|
|
|
+ e.Log.Errorf("派单短信发送失败", zap.Any("res", res), zap.Error(err1))
|
|
|
+ err = errors.New("派单短信发送失败,请重试")
|
|
|
return err
|
|
|
}
|
|
|
waybillModel.SendLog = model.WaybillSendLog{
|
|
@@ -587,6 +653,9 @@ func (e *Waybill) Receipt(c *dto.WaybillReceiptReq, p *actions.DataPermission) e
|
|
|
waybillModel.RejectionReason = c.RejectionReason
|
|
|
waybillModel.ReceiptTime = model2.Time(time.Now())
|
|
|
waybillModel.ReceiptImg = c.ReceiptImg
|
|
|
+ waybillModel.AssessContent = c.AssessContent
|
|
|
+ waybillModel.AssessStar = c.AssessStar
|
|
|
+ waybillModel.DeliveryDuration = int(time.Now().Sub(waybillModel.DeliveryTime.Local()).Minutes())
|
|
|
err = tx.Save(&waybillModel).Error
|
|
|
if err != nil {
|
|
|
e.Log.Errorf("db error: %s", err)
|
|
@@ -611,7 +680,7 @@ func (e *Waybill) Receipt(c *dto.WaybillReceiptReq, p *actions.DataPermission) e
|
|
|
// 未下车 直接点签收
|
|
|
if time.Time(task.EndTime).IsZero() {
|
|
|
task.EndTime = model2.Time(time.Now())
|
|
|
- //task.UpdateBy = p.UserId
|
|
|
+ //task.UpdateBy = p.UserIds
|
|
|
err = tx.Save(&task).Error
|
|
|
if err != nil {
|
|
|
e.Log.Errorf("db error: %s", err)
|
|
@@ -764,6 +833,193 @@ func (e *Waybill) GetBasicsStats(c *dto.WaybillStatsReq, p *actions.DataPermissi
|
|
|
return res
|
|
|
}
|
|
|
|
|
|
+func GetDeliveryStatsScopes(userId int) func(db *gorm.DB) *gorm.DB {
|
|
|
+
|
|
|
+ return func(db *gorm.DB) *gorm.DB {
|
|
|
+ if userId == 0 {
|
|
|
+ return db
|
|
|
+ }
|
|
|
+ return db.Where("delivery_id = ?", userId)
|
|
|
+ }
|
|
|
+}
|
|
|
+func GetReCheckStatsScopes(userId int) func(db *gorm.DB) *gorm.DB {
|
|
|
+
|
|
|
+ return func(db *gorm.DB) *gorm.DB {
|
|
|
+ if userId == 0 {
|
|
|
+ return db
|
|
|
+ }
|
|
|
+ return db.Where("re_check_id = ?", userId)
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// 获取配送员统计信息
|
|
|
+func (e *Waybill) GetDeliveryStats(c *dto.WaybillUserStatsReq, p *actions.DataPermission) (res []dto.WaybillUserStats) {
|
|
|
+ // 获取用户列表
|
|
|
+ var userList []model.SysUser
|
|
|
+ if err := e.Orm.Model(&userList).Scopes(actions.Permission(model.SysUser{}.TableName(), p), WaybillUserStatsUserIdScopes(c.UserIds)).
|
|
|
+ Where("status = 2").Find(&userList).Error; err != nil {
|
|
|
+ return nil
|
|
|
+ }
|
|
|
+ for _, user := range userList {
|
|
|
+ stats := e.GetUserStats(c, p, GetDeliveryStatsScopes(user.Id))
|
|
|
+ stats.Name = user.NickName
|
|
|
+ res = append(res, stats)
|
|
|
+ }
|
|
|
+ return
|
|
|
+}
|
|
|
+func (e *Waybill) GetReCheckStats(c *dto.WaybillUserStatsReq, p *actions.DataPermission) (res []dto.WaybillUserStats) {
|
|
|
+ // 获取用户列表
|
|
|
+ var userList []model.SysUser
|
|
|
+ if err := e.Orm.Model(&userList).Scopes(actions.Permission(model.SysUser{}.TableName(), p), WaybillUserStatsUserIdScopes(c.UserIds)).
|
|
|
+ Where("status = 2").Find(&userList).Error; err != nil {
|
|
|
+ return nil
|
|
|
+ }
|
|
|
+ for _, user := range userList {
|
|
|
+ stats := e.GetUserStats(c, p, GetReCheckStatsScopes(user.Id))
|
|
|
+ stats.Name = user.NickName
|
|
|
+ res = append(res, stats)
|
|
|
+ }
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+func WaybillUserStatsUserIdScopes(userIds []int) func(db *gorm.DB) *gorm.DB {
|
|
|
+ return func(db *gorm.DB) *gorm.DB {
|
|
|
+ if len(userIds) == 0 {
|
|
|
+ return db
|
|
|
+ }
|
|
|
+ if len(userIds) == 1 {
|
|
|
+ return db.Where("user_id = ?", userIds[0])
|
|
|
+ }
|
|
|
+ return db.Where("user_id in (?)", userIds)
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+func GetUserBasicsStatsScopes(userId int) func(db *gorm.DB) *gorm.DB {
|
|
|
+
|
|
|
+ return func(db *gorm.DB) *gorm.DB {
|
|
|
+ if userId == 0 {
|
|
|
+ return db
|
|
|
+ }
|
|
|
+ return db.Where("delivery_id = ? or re_check_id = ? ", userId, userId)
|
|
|
+ }
|
|
|
+}
|
|
|
+func (e *Waybill) GetUserBasicsStats(c *dto.WaybillStatsReq, p *actions.DataPermission, scopes func(*gorm.DB) *gorm.DB) dto.WaybillStatsRes {
|
|
|
+ var res dto.WaybillStatsRes
|
|
|
+ var data model.Waybill
|
|
|
+ type DateCount struct {
|
|
|
+ Date string
|
|
|
+ Count int64
|
|
|
+ }
|
|
|
+ yearCount := make([]DateCount, 0)
|
|
|
+ monthCount := make([]DateCount, 0)
|
|
|
+ now := time.Now()
|
|
|
+ todayStartTime := now.Format("2006-01-02") + " 00:00:00"
|
|
|
+ todayEndTime := now.Format("2006-01-02") + " 23:59:59"
|
|
|
+
|
|
|
+ // 获取上个月第一天
|
|
|
+ firstDayOfLastMonth := time.Date(now.Year(), now.Month()-1, 1, 0, 0, 0, 0, now.Location())
|
|
|
+
|
|
|
+ // 获取去年的第一天
|
|
|
+ firstDayOfLastYear := time.Date(now.Year()-1, time.January, 1, 0, 0, 0, 0, now.Location())
|
|
|
+ monthStartTime := firstDayOfLastMonth.Format("2006-01-02") + " 00:00:00"
|
|
|
+ yearStartTime := firstDayOfLastYear.Format("2006-01-02") + " 00:00:00"
|
|
|
+
|
|
|
+ // 今日总运单数
|
|
|
+ e.Orm.Model(&data).Scopes(actions.Permission(data.TableName(), p), scopes).
|
|
|
+ Where("order_time between ? and ?", todayStartTime, todayEndTime).Count(&res.TodayNum)
|
|
|
+ // 待派单
|
|
|
+ e.Orm.Model(&data).Scopes(actions.Permission(data.TableName(), p), scopes).
|
|
|
+ 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)
|
|
|
+ // 已送达
|
|
|
+ e.Orm.Model(&data).Scopes(actions.Permission(data.TableName(), p), scopes).
|
|
|
+ Where("status = ?", model.WaybillStatusReceipt).Count(&res.ReceiptNum)
|
|
|
+ // 已取消
|
|
|
+ e.Orm.Model(&data).Scopes(actions.Permission(data.TableName(), p), scopes).
|
|
|
+ Where("status = ?", model.WaybillStatusRejection).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)
|
|
|
+
|
|
|
+ for _, month := range monthCount {
|
|
|
+ if month.Date == now.Format("200601") {
|
|
|
+ res.ThisMonthNum = month.Count
|
|
|
+ }
|
|
|
+ if month.Date == firstDayOfLastMonth.Format("200601") {
|
|
|
+ res.LastMonthNum = month.Count
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 获取本年,上年数据
|
|
|
+ e.Orm.Model(&data).Select("date_format(order_time,'%Y') date,count(1) as count ").Scopes(actions.Permission(data.TableName(), p), scopes).
|
|
|
+ Where("order_time between ? and ?", yearStartTime, now).Group("date").Find(&yearCount)
|
|
|
+
|
|
|
+ for _, month := range yearCount {
|
|
|
+ if month.Date == now.Format("2006") {
|
|
|
+ res.ThisYearNum = month.Count
|
|
|
+ }
|
|
|
+ if month.Date == firstDayOfLastYear.Format("2006") {
|
|
|
+ res.LastYearNum = month.Count
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if c.Type == "year" {
|
|
|
+ // 获取上个月第一天
|
|
|
+ year, _ := strconv.Atoi(c.Date)
|
|
|
+ firstDayOfyear := time.Date(year, 1, 1, 0, 0, 0, 0, now.Location())
|
|
|
+ lastDayOfyear := time.Date(year, 12, 31, 23, 59, 59, 0, now.Location())
|
|
|
+
|
|
|
+ // 年度数据统计
|
|
|
+ e.Orm.Model(&data).Select("date_format(order_time,'%Y-%m') date,count(1) as num ").Scopes(actions.Permission(data.TableName(), p), scopes).
|
|
|
+ Where("order_time between ? and ?", firstDayOfyear, lastDayOfyear).Group("date").Find(&res.Stats)
|
|
|
+ }
|
|
|
+
|
|
|
+ if c.Type == "month" {
|
|
|
+ // 获取上个月第一天
|
|
|
+ month, _ := time.Parse("2006-01", c.Date)
|
|
|
+ firstDayOfMonth := time.Date(month.Year(), month.Month(), 1, 0, 0, 0, 0, now.Location())
|
|
|
+ lastDayOfMonth := time.Date(month.Year(), month.Month()+1, 1, 23, 59, 59, 0, now.Location()).Add(-time.Hour * 24)
|
|
|
+ e.Orm.Model(&data).Select("date_format(order_time,'%Y-%m-%d') date,count(1) as num ").Scopes(actions.Permission(data.TableName(), p), scopes).
|
|
|
+ Where("order_time between ? and ?", firstDayOfMonth, lastDayOfMonth).Group("date").Find(&res.Stats)
|
|
|
+ }
|
|
|
+
|
|
|
+ return res
|
|
|
+}
|
|
|
+func (e *Waybill) GetUserStats(c *dto.WaybillUserStatsReq, p *actions.DataPermission, scopes func(*gorm.DB) *gorm.DB) dto.WaybillUserStats {
|
|
|
+ var res dto.WaybillUserStats
|
|
|
+ var data model.Waybill
|
|
|
+ type DateCount struct {
|
|
|
+ Date string
|
|
|
+ Count int64
|
|
|
+ }
|
|
|
+
|
|
|
+ now := time.Now()
|
|
|
+
|
|
|
+ if c.Type == "year" {
|
|
|
+ // 获取上个月第一天
|
|
|
+ year, _ := strconv.Atoi(c.Date)
|
|
|
+ firstDayOfyear := time.Date(year, 1, 1, 0, 0, 0, 0, now.Location())
|
|
|
+ lastDayOfyear := time.Date(year, 12, 31, 23, 59, 59, 0, now.Location())
|
|
|
+
|
|
|
+ // 年度数据统计
|
|
|
+ e.Orm.Model(&data).Select("date_format(order_time,'%Y-%m') date,count(1) as num ").Scopes(actions.Permission(data.TableName(), p), scopes).
|
|
|
+ Where("order_time between ? and ?", firstDayOfyear, lastDayOfyear).Group("date").Find(&res.Stats)
|
|
|
+ }
|
|
|
+
|
|
|
+ if c.Type == "month" {
|
|
|
+ // 获取上个月第一天
|
|
|
+ month, _ := time.Parse("2006-01", c.Date)
|
|
|
+ firstDayOfMonth := time.Date(month.Year(), month.Month(), 1, 0, 0, 0, 0, now.Location())
|
|
|
+ lastDayOfMonth := time.Date(month.Year(), month.Month()+1, 1, 23, 59, 59, 0, now.Location()).Add(-time.Hour * 24)
|
|
|
+ e.Orm.Model(&data).Select("date_format(order_time,'%Y-%m-%d') date,count(1) as num ").Scopes(actions.Permission(data.TableName(), p), scopes).
|
|
|
+ Where("order_time between ? and ?", firstDayOfMonth, lastDayOfMonth).Group("date").Find(&res.Stats)
|
|
|
+ }
|
|
|
+
|
|
|
+ return res
|
|
|
+}
|
|
|
+
|
|
|
// 获取运单所有温湿度素具
|
|
|
func (e *Waybill) GetAllData(c *dto.WaybillGetByWaybillNoReq) ([]nats_server.DeviceData_R, []WaybillPDF, error) {
|
|
|
var err error
|