订单
This commit is contained in:
parent
f4def7f8a0
commit
f792215c2f
|
@ -6,6 +6,7 @@ import (
|
|||
"fusenapi/model/gmodel"
|
||||
"fusenapi/utils/auth"
|
||||
"fusenapi/utils/basic"
|
||||
"fusenapi/utils/configs"
|
||||
|
||||
"fusenapi/utils/format"
|
||||
"fusenapi/utils/order"
|
||||
|
@ -39,6 +40,9 @@ func (l *UserOrderListLogic) UserOrderList(req *types.UserOrderListReq, userinfo
|
|||
// 返回值必须调用Set重新返回, resp可以空指针调用 resp.SetStatus(basic.CodeOK, data)
|
||||
// userinfo 传入值时, 一定不为null
|
||||
|
||||
// 测试
|
||||
userinfo.UserId = 39
|
||||
|
||||
orderDetailModel := gmodel.NewFsOrderDetailModel(l.svcCtx.MysqlConn)
|
||||
orderModel := gmodel.NewFsOrderModel(l.svcCtx.MysqlConn)
|
||||
rowBuilder := orderModel.RowSelectBuilder(nil)
|
||||
|
@ -86,10 +90,10 @@ func (l *UserOrderListLogic) UserOrderList(req *types.UserOrderListReq, userinfo
|
|||
var respList []types.Items
|
||||
if listResLen > 0 {
|
||||
// 获取订单时间配置
|
||||
// orderTimeConfig, err := configs.GetOrderTimeConfig(l.ctx, l.svcCtx.MysqlConn)
|
||||
// if err != nil {
|
||||
// return resp.SetStatusWithMessage(basic.CodeServiceErr, "failed to get config time info")
|
||||
// }
|
||||
orderTimeConfig, err := configs.GetOrderTimeConfig(l.ctx, l.svcCtx.MysqlConn)
|
||||
if err != nil {
|
||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "failed to get config time info")
|
||||
}
|
||||
|
||||
// 数据处理
|
||||
for _, item := range listRes {
|
||||
|
@ -121,9 +125,9 @@ func (l *UserOrderListLogic) UserOrderList(req *types.UserOrderListReq, userinfo
|
|||
|
||||
fsOrderAffiliateInfo := item.FsOrderAffiliateInfo
|
||||
|
||||
statusAndLogisticsRes := order.GetOrderStatusAndLogistics(order.GetOrderStatusAndLogisticsReq{
|
||||
OrderStatus: constants.Order(*item.Status),
|
||||
DeliveryMethod: constants.DeliveryMethod(*item.DeliveryMethod),
|
||||
var getOrderStatusAndLogisticsReq = order.GetOrderStatusAndLogisticsReq{
|
||||
OrderStatus: 1,
|
||||
DeliveryMethod: 1,
|
||||
IsPayCompleted: *item.IsAllProductCompleted,
|
||||
SureTime: *fsOrderAffiliateInfo.SureTime,
|
||||
ProductTime: *fsOrderAffiliateInfo.SureTime,
|
||||
|
@ -134,9 +138,11 @@ func (l *UserOrderListLogic) UserOrderList(req *types.UserOrderListReq, userinfo
|
|||
ArrivalTime: *fsOrderAffiliateInfo.SureTime,
|
||||
RecevieTime: *fsOrderAffiliateInfo.SureTime,
|
||||
|
||||
OrderCtime: *item.Ctime,
|
||||
//WebSetTimeInfo: orderTimeConfig,
|
||||
})
|
||||
OrderCtime: *item.Ctime,
|
||||
WebSetTimeInfo: orderTimeConfig,
|
||||
}
|
||||
|
||||
statusAndLogisticsRes := order.GetOrderStatusAndLogistics(getOrderStatusAndLogisticsReq)
|
||||
|
||||
// 流程控制
|
||||
statusTime := make([]*types.StatusTime, 5)
|
||||
|
|
|
@ -1,8 +1,75 @@
|
|||
package configs
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fusenapi/constants"
|
||||
"fusenapi/model/gmodel"
|
||||
"strconv"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type WebSetTimeInfo struct {
|
||||
ProductDay int64
|
||||
FactoryDeliverDay int64
|
||||
DeliverUpsDay int64
|
||||
UpsTransDay int64
|
||||
}
|
||||
|
||||
type WebSetTimeInfoData struct {
|
||||
ProductDay string `json:"product_day"`
|
||||
FactoryDeliverDay string `json:"factory_deliver_day"`
|
||||
DeliverUpsDay string `json:"deliver_ups_day"`
|
||||
UpsTransDay string `json:"ups_trans_day"`
|
||||
}
|
||||
|
||||
func GetOrderTimeConfig(ctx context.Context, db *gorm.DB) (res WebSetTimeInfo, err error) {
|
||||
resData, err := gmodel.NewFsWebSetModel(db).FindValueByKey(ctx, string(constants.WEBSET_TIME_INFO))
|
||||
if err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
res.ProductDay = int64(constants.ORDER_PRODUCT_DAY)
|
||||
res.FactoryDeliverDay = int64(constants.ORDER_FACTORY_DELIVER_DAY)
|
||||
res.DeliverUpsDay = int64(constants.ORDER_DELIVER_UPS_DAY)
|
||||
res.UpsTransDay = int64(constants.ORDER_UPS_TRANS_DAY)
|
||||
return res, nil
|
||||
}
|
||||
logx.Error(err)
|
||||
return res, err
|
||||
} else {
|
||||
var timeInfo WebSetTimeInfoData
|
||||
err = json.Unmarshal([]byte(*resData.Value), &timeInfo)
|
||||
if err != nil {
|
||||
logx.Error(err)
|
||||
return res, err
|
||||
}
|
||||
productDay, err := strconv.Atoi(timeInfo.ProductDay)
|
||||
if err != nil {
|
||||
logx.Error(err)
|
||||
return res, err
|
||||
}
|
||||
factoryDeliverDay, err := strconv.Atoi(timeInfo.FactoryDeliverDay)
|
||||
if err != nil {
|
||||
logx.Error(err)
|
||||
return res, err
|
||||
}
|
||||
deliverUpsDay, err := strconv.Atoi(timeInfo.DeliverUpsDay)
|
||||
if err != nil {
|
||||
logx.Error(err)
|
||||
return res, err
|
||||
}
|
||||
upsTransDay, err := strconv.Atoi(timeInfo.UpsTransDay)
|
||||
if err != nil {
|
||||
logx.Error(err)
|
||||
return res, err
|
||||
}
|
||||
res.ProductDay = int64(productDay)
|
||||
res.FactoryDeliverDay = int64(factoryDeliverDay)
|
||||
res.DeliverUpsDay = int64(deliverUpsDay)
|
||||
res.UpsTransDay = int64(upsTransDay)
|
||||
}
|
||||
|
||||
return res, nil
|
||||
}
|
||||
|
|
|
@ -37,6 +37,8 @@ type GetOrderStatusAndLogisticsReq struct {
|
|||
OrderStatus constants.Order
|
||||
DeliveryMethod constants.DeliveryMethod
|
||||
IsPayCompleted int64
|
||||
OrderCtime int64
|
||||
|
||||
SureTime int64
|
||||
ProductTime int64
|
||||
ProductEndtime int64
|
||||
|
@ -46,7 +48,7 @@ type GetOrderStatusAndLogisticsReq struct {
|
|||
ArrivalTime int64
|
||||
RecevieTime int64
|
||||
|
||||
OrderCtime int64
|
||||
|
||||
WebSetTimeInfo configs.WebSetTimeInfo
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user