This commit is contained in:
liwei 2023-06-27 16:58:32 +08:00
commit bc662e1986
2 changed files with 16 additions and 5 deletions

View File

@ -1,6 +1,7 @@
package smithy package smithy
import ( import (
"errors"
"go_dreamfactory/comm" "go_dreamfactory/comm"
"go_dreamfactory/pb" "go_dreamfactory/pb"
) )
@ -28,11 +29,21 @@ func (this *apiComp) Sell(session comm.IUserSession, req *pb.SmithySellReq) (err
cus, err := this.module.modelTrade.updateCustomer(session.GetUserId(), req.CustomerId) cus, err := this.module.modelTrade.updateCustomer(session.GetUserId(), req.CustomerId)
if err != nil { if err != nil {
errdata = &pb.ErrorData{ var customErr = new(comm.CustomError)
Code: pb.ErrorCode_ReqParameterError, if errors.As(err, &customErr) {
Title: pb.ErrorCode_ReqParameterError.ToString(), errdata = &pb.ErrorData{
Message: err.Error(), Code: customErr.Code,
Title: customErr.Code.ToString(),
Message: err.Error(),
}
} else {
errdata = &pb.ErrorData{
Code: pb.ErrorCode_DBError,
Title: pb.ErrorCode_DBError.ToString(),
Message: err.Error(),
}
} }
return return
} }

View File

@ -147,7 +147,7 @@ func (s *modelTrade) updateCustomer(uid string, customerId int32) (*pb.DBCustome
}) })
cus.LastRefreshTime = configure.Now().Unix() cus.LastRefreshTime = configure.Now().Unix()
update := map[string]interface{}{ update := map[string]interface{}{
"customerIds": cus.Customers, "customers": cus.Customers,
"total": cus.Total, "total": cus.Total,
"lastRefreshTime": cus.LastRefreshTime, "lastRefreshTime": cus.LastRefreshTime,
} }