2026-08-09 10:43:45 +08:00
|
|
|
package summary
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"context"
|
|
|
|
|
"errors"
|
|
|
|
|
"time"
|
|
|
|
|
|
2026-08-09 12:41:08 +08:00
|
|
|
"bsm/full/module/ec/order/internal/models"
|
|
|
|
|
pb "bsm/full/module/ec/order/pb"
|
2026-08-09 10:43:45 +08:00
|
|
|
"git.apinb.com/bsm-sdk/core/errcode"
|
|
|
|
|
"git.apinb.com/bsm-sdk/core/printer"
|
|
|
|
|
"git.apinb.com/bsm-sdk/core/service"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// 模拟发货
|
|
|
|
|
func SimulateShipments(ctx context.Context, in *pb.SimulateShipmentsRequest) (reply *pb.StatusReply, err error) {
|
|
|
|
|
// parse authorization meta.
|
|
|
|
|
_, err = service.ParseMetaCtx(ctx, nil)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if in.GetMemberIdentity() == "" {
|
|
|
|
|
return nil, errcode.ErrInvalidArgument
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
err = models.DBService.Where("identity = ?", in.Identity).Updates(&models.OrderSummary{Status: 3, DeliveryIdentity: in.MemberIdentity}).Error
|
|
|
|
|
if err != nil {
|
|
|
|
|
printer.Error(err.Error())
|
|
|
|
|
if errors.Is(err, models.ErrNotFound) {
|
|
|
|
|
return nil, errcode.ErrRecordNotFound
|
|
|
|
|
}
|
|
|
|
|
return nil, errcode.ErrDB
|
|
|
|
|
}
|
|
|
|
|
return &pb.StatusReply{
|
|
|
|
|
Code: 0,
|
|
|
|
|
Message: "OK",
|
|
|
|
|
Timeseq: time.Now().UnixNano(),
|
|
|
|
|
}, nil
|
|
|
|
|
|
|
|
|
|
}
|