作者 tangxvhui

bug 修复

... ... @@ -28,6 +28,8 @@ type UpdateOrderCommand struct {
SalesmanBonusPercent float64 `json:"salesmanBonusPercent"`
//订单状态
OrderStatus int `json:"orderStatus"`
//订单类型
OrderType int `json:"orderType"`
}
func (command UpdateOrderCommand) ValidateCommand() error {
... ... @@ -46,6 +48,10 @@ func (command UpdateOrderCommand) ValidateCommand() error {
if len(command.OrderRegion) == 0 {
return lib.ThrowError(lib.ARG_ERROR, "订单区域必填")
}
if !(command.OrderType == domain.OrderReal ||
command.OrderType == domain.OrderIntention) {
return lib.ThrowError(lib.ARG_ERROR, "订单类型错误")
}
if !(command.OrderStatus == domain.OrderStatusDeliverSome ||
command.OrderStatus == domain.OrderStatusDeliverAll ||
command.OrderStatus == domain.OrderStatusReserve) {
... ...
... ... @@ -157,7 +157,7 @@ func (service OrderService) CreateOrder(command command.CreateOrderCommand) erro
}); err != nil {
return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error())
}
newOrder := &domain.Order{
newOrder := domain.Order{
//订单类型
OrderType: command.OrderType,
//订单编号
... ... @@ -269,7 +269,7 @@ func (service OrderService) UpdateOrderPurpose(command command.UpdateOrderComman
if err != nil {
return lib.ThrowError(lib.BUSINESS_ERROR, err.Error())
}
err = orderRepository.Save(orderData)
err = orderRepository.Save(*orderData)
if err != nil {
return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error())
}
... ... @@ -385,7 +385,7 @@ func (service OrderService) UpdateOrderReal(command command.UpdateOrderRealComma
if err != nil {
return lib.ThrowError(lib.BUSINESS_ERROR, err.Error())
}
err = orderRepository.Save(orderData)
err = orderRepository.Save(*orderData)
if err != nil {
return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error())
}
... ...
... ... @@ -58,7 +58,7 @@ func (PartnerInfoService *PartnerInfoService) CreatePartnerInfo(command *command
}); err != nil {
return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error())
}
newPartnerInfo := &domain.PartnerInfo{
newPartnerInfo := domain.PartnerInfo{
Partner: domain.Partner{
Account: command.Account,
PartnerName: command.PartnerName,
... ... @@ -136,7 +136,7 @@ func (PartnerInfoService *PartnerInfoService) UpdatePartnerInfo(updatePartnerInf
partnerInfo.Status = updatePartnerInfoCommand.Status
partnerInfo.RegionInfo = updatePartnerInfoCommand.RegionInfo
partnerInfo.CooperateTime = updatePartnerInfoCommand.CooperateTime
if _, err = partnerInfoRepository.Save(partnerInfo); err != nil {
if _, err = partnerInfoRepository.Save(*partnerInfo); err != nil {
return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error())
}
transactionContext.CommitTransaction()
... ... @@ -219,7 +219,7 @@ func (PartnerInfoService *PartnerInfoService) UpdateStatus(command command.Statu
return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error())
}
partnerInfo.Status = command.Status
if _, err = partnerInfoRepository.Save(partnerInfo); err != nil {
if _, err = partnerInfoRepository.Save(*partnerInfo); err != nil {
return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error())
}
transactionContext.CommitTransaction()
... ...
... ... @@ -165,7 +165,7 @@ type OrderFindQuery struct {
}
type OrderRepository interface {
Save(order *Order) error
Save(order Order) error
FindOne(qureyOptions OrderFindOneQuery) (*Order, error)
Find(queryOptions OrderFindQuery) ([]Order, error)
CountAll(queryOption OrderFindQuery) (int, error)
... ...
... ... @@ -50,7 +50,7 @@ type PartnerFindQuery struct {
}
type PartnerInfoRepository interface {
Save(dm *PartnerInfo) (*PartnerInfo, error)
Save(dm PartnerInfo) (*PartnerInfo, error)
FindOne(queryOptions PartnerFindOneQuery) (*PartnerInfo, error)
Find(queryOptions PartnerFindQuery) ([]PartnerInfo, error)
CountAll(queryOptions PartnerFindQuery) (int, error)
... ...
... ... @@ -19,7 +19,7 @@ type PartnerInfo struct {
// 登录密码
Password string
// 状态(1:启用或者0:禁用)
Status int `pg:",use_zero`
Status int `pg:",use_zero"`
// 合伙类别 (1.研发合伙人 2.业务合伙人 3.事业)
PartnerCategory int `pg:",default:1"` //partner_category
//所属区域信息
... ...
... ... @@ -50,7 +50,7 @@ func (reponsitory OrderRepository) transformPgModelToDomainModel(orderModel *mod
return result, nil
}
func (repository OrderRepository) Save(orderInfo *domain.Order) error {
func (repository OrderRepository) Save(orderInfo domain.Order) error {
var (
err error
tx = repository.transactionContext.PgTx
... ...
... ... @@ -41,7 +41,7 @@ func NewPartnerInfoRepository(transactionContext *transaction.TransactionContext
return &PartnerInfoRepository{transactionContext: transactionContext}, nil
}
func (repository *PartnerInfoRepository) Save(dm *domain.PartnerInfo) (*domain.PartnerInfo, error) {
func (repository *PartnerInfoRepository) Save(dm domain.PartnerInfo) (*domain.PartnerInfo, error) {
var (
err error
tx = repository.transactionContext.PgTx
... ... @@ -72,7 +72,7 @@ func (repository *PartnerInfoRepository) Save(dm *domain.PartnerInfo) (*domain.P
return nil, err
}
}
return dm, nil
return &dm, nil
}
func (repository *PartnerInfoRepository) FindOne(queryOptions domain.PartnerFindOneQuery) (*domain.PartnerInfo, error) {
... ...