refactor all service dependency injection
This commit is contained in:
@@ -3,8 +3,10 @@ package summary
|
||||
import (
|
||||
"context"
|
||||
|
||||
"bsm/full/module/ec/order/internal/impl"
|
||||
"bsm/full/module/ec/order/internal/models"
|
||||
pb "bsm/full/module/ec/order/pb"
|
||||
|
||||
"git.apinb.com/bsm-sdk/core/errcode"
|
||||
"git.apinb.com/bsm-sdk/core/printer"
|
||||
"git.apinb.com/bsm-sdk/core/service"
|
||||
@@ -25,7 +27,7 @@ func Confirm(ctx context.Context, in *pb.ConfirmRequest) (reply *pb.ConfirmReply
|
||||
coupon = new(models.OrderCoupon)
|
||||
)
|
||||
|
||||
err = models.DBService.Where("order_no = ?", in.OrderNo).First(&summary).Error
|
||||
err = impl.DBService.Where("order_no = ?", in.OrderNo).First(&summary).Error
|
||||
if err != nil {
|
||||
printer.Error(err.Error())
|
||||
return nil, errcode.ErrDB
|
||||
@@ -33,7 +35,7 @@ func Confirm(ctx context.Context, in *pb.ConfirmRequest) (reply *pb.ConfirmReply
|
||||
|
||||
if in.AddressIdentity != "" {
|
||||
/*
|
||||
err = models.DBService.Where("id=?", in.AddressId).First(&address).Error
|
||||
err = impl.DBService.Where("id=?", in.AddressId).First(&address).Error
|
||||
if err == nil {
|
||||
summary.Address = address.Detail
|
||||
summary.County = address.Country
|
||||
@@ -51,10 +53,10 @@ func Confirm(ctx context.Context, in *pb.ConfirmRequest) (reply *pb.ConfirmReply
|
||||
}
|
||||
|
||||
if in.CouponIdentity != "" {
|
||||
err = models.DBService.Where("identity=?", in.CouponIdentity).First(&coupon).Error
|
||||
err = impl.DBService.Where("identity=?", in.CouponIdentity).First(&coupon).Error
|
||||
if err == nil {
|
||||
if coupon.Status == 2 {
|
||||
models.DBService.Model(&models.OrderCoupon{}).Where("identity=?", in.CouponIdentity).Update("status", 3)
|
||||
impl.DBService.Model(&models.OrderCoupon{}).Where("identity=?", in.CouponIdentity).Update("status", 3)
|
||||
couponAmount = coupon.Amount
|
||||
} else {
|
||||
printer.Error(err.Error())
|
||||
@@ -72,7 +74,7 @@ func Confirm(ctx context.Context, in *pb.ConfirmRequest) (reply *pb.ConfirmReply
|
||||
|
||||
summary.Status = 1
|
||||
|
||||
err = models.DBService.Where("order_no = ?", in.OrderNo).Updates(summary).Error
|
||||
err = impl.DBService.Where("order_no = ?", in.OrderNo).Updates(summary).Error
|
||||
if err != nil {
|
||||
printer.Error(err.Error())
|
||||
return nil, errcode.ErrDB
|
||||
|
||||
Reference in New Issue
Block a user