作者 唐旭辉

订单管理 数据 多公司支持完成

... ... @@ -16,5 +16,6 @@ type CreateOrderCommand struct {
//业务员抽成比例
SalesmanBonusPercent float64 `json:"salesmanBonusPercent"`
//货品
Goods []OrderGoodData `json:"goods"`
Goods []OrderGoodData `json:"goods"`
CompanyId int64 `json:"companyId"`
}
... ...
... ... @@ -5,4 +5,5 @@ type DisableOrderCommand struct {
OrderId int64 `json:"orderId"`
IsDisable int `json:"isDisable"`
OrderType int `json:"orderType"`
CompanyId int64 `json:"companyId"`
}
... ...
... ... @@ -7,4 +7,5 @@ type OrderDeliveryCommand struct {
DeliveryTime time.Time `json:"deliveryTime"`
DeliveryCode string `json:"deliveryCode"`
Goods []OrderGoodData `json:"goods"`
CompanyId int64
}
... ...
... ... @@ -4,6 +4,7 @@ package command
type UpdateGoodBouns struct {
Id int64 `json:"id"` //订单id
GoodBouns []GoodBouns `json:"goodBouns"`
CompanyId int64 `json:"companyId"`
}
//GoodBoun 商品数量调整
... ...
... ... @@ -18,5 +18,6 @@ type UpdateOrderCommand struct {
//订单类型
OrderType int `json:"orderType"`
//货品
Goods []OrderGoodData `json:"goods"`
Goods []OrderGoodData `json:"goods"`
CompanyId int64 `json:"companyId"`
}
... ...
... ... @@ -2,5 +2,6 @@ package query
//GetOrderQuery 获取订单详情
type GetOrderQuery struct {
OrderId int64 `json:"orderId"`
OrderId int64 `json:"orderId"`
CompanyId int64 `json:"companyId"`
}
... ...
... ... @@ -14,4 +14,5 @@ type ListOrderBaseQuery struct {
OrderType int `json:"orderType"`
//发货单号
DeliveryCode string `json:"deliveryCode"`
CompanyId int64 `json:"companyId"`
}
... ...
... ... @@ -46,6 +46,7 @@ func (service OrderInfoService) PageListOrderBase(listOrderQuery query.ListOrder
Limit: listOrderQuery.Limit,
OrderType: listOrderQuery.OrderType,
DeliveryCode: listOrderQuery.DeliveryCode,
CompanyId: listOrderQuery.CompanyId,
}
orders, cnt, err = orderRepository.Find(query)
if err != nil {
... ... @@ -79,7 +80,7 @@ func (service OrderInfoService) GetOrderDetail(getOrderQuery query.GetOrderQuery
}
var (
orderBaseRepository domain.OrderBaseRepository
PartnerInfoRepository domain.PartnerInfoRepository
partnerInfoRepository domain.PartnerInfoRepository
orderGoodRepository domain.OrderGoodRepository
order *domain.OrderBase
)
... ... @@ -89,14 +90,12 @@ func (service OrderInfoService) GetOrderDetail(getOrderQuery query.GetOrderQuery
defer func() {
transactionContext.RollbackTransaction()
}()
if value, err := factory.CreateOrderBaseRepository(map[string]interface{}{
if orderBaseRepository, err = factory.CreateOrderBaseRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error())
} else {
orderBaseRepository = value
}
if PartnerInfoRepository, err = factory.CreatePartnerInfoRepository(map[string]interface{}{
if partnerInfoRepository, err = factory.CreatePartnerInfoRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error())
... ... @@ -107,7 +106,8 @@ func (service OrderInfoService) GetOrderDetail(getOrderQuery query.GetOrderQuery
return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error())
}
order, err = orderBaseRepository.FindOne(domain.OrderBaseFindOneQuery{
OrderId: getOrderQuery.OrderId,
OrderId: getOrderQuery.OrderId,
CompanyId: getOrderQuery.CompanyId,
})
if err != nil {
return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, fmt.Sprintf("获取订单数据失败:%s", err))
... ... @@ -117,13 +117,17 @@ func (service OrderInfoService) GetOrderDetail(getOrderQuery query.GetOrderQuery
goods []domain.OrderGood
)
partnerData, err = PartnerInfoRepository.FindOne(domain.PartnerFindOneQuery{UserId: order.PartnerId})
partnerData, err = partnerInfoRepository.FindOne(domain.PartnerFindOneQuery{
UserId: order.PartnerId,
CompanyId: getOrderQuery.CompanyId,
})
if err != nil {
return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, fmt.Sprintf("检索合伙人数据失败:%s", err))
}
order.PartnerInfo = partnerData.Partner
goods, _, err = orderGoodRepository.Find(domain.OrderGoodFindQuery{
OrderId: order.Id,
OrderId: order.Id,
CompanyId: getOrderQuery.CompanyId,
})
if err != nil {
return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, fmt.Sprintf("获取订单中的商品列表失败:%s", err))
... ... @@ -188,7 +192,7 @@ func (service OrderInfoService) CreateNewOrder(cmd command.CreateOrderCommand) (
// }
//检查delivery_code是否重复
if len(cmd.DeliveryCode) > 0 {
if ok, err := orderBaseDao.DeliveryCodeExist(cmd.DeliveryCode); err != nil {
if ok, err := orderBaseDao.DeliveryCodeExist(cmd.DeliveryCode, cmd.CompanyId); err != nil {
return nil, lib.ThrowError(lib.TRANSACTION_ERROR, err.Error())
} else if ok {
return nil, lib.ThrowError(lib.BUSINESS_ERROR, "发货号已存在")
... ... @@ -206,6 +210,7 @@ func (service OrderInfoService) CreateNewOrder(cmd command.CreateOrderCommand) (
PartnerId: cmd.PartnerId,
PartnerInfo: partnerData.Partner,
SalesmanBonusPercent: cmd.SalesmanBonusPercent,
CompanyId: cmd.CompanyId,
}
var orderGoods []domain.OrderGood
for _, good := range cmd.Goods {
... ... @@ -216,6 +221,7 @@ func (service OrderInfoService) CreateNewOrder(cmd command.CreateOrderCommand) (
m.Price = good.Price
m.PartnerBonusPercent = good.PartnerBonusPercent
m.Remark = good.Remark
m.CompanyId = cmd.CompanyId
err = m.Compute()
if err != nil {
return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, fmt.Sprintf("核算订单中商品的数值失败:%s", err))
... ... @@ -251,7 +257,7 @@ func (service OrderInfoService) CreateNewOrder(cmd command.CreateOrderCommand) (
}
//DeleteOrder 删除订单
func (service OrderInfoService) DeleteOrder(orderId int64) error {
func (service OrderInfoService) DeleteOrder(orderId int64, companyId int64) error {
var (
transactionContext, _ = factory.CreateTransactionContext(nil)
err error
... ... @@ -276,11 +282,11 @@ func (service OrderInfoService) DeleteOrder(orderId int64) error {
}); err != nil {
return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error())
}
err = orderBaseRepository.Remove(orderId)
err = orderBaseRepository.Remove(orderId, companyId)
if err != nil {
return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, fmt.Sprintf("删除订单数据失败:%s", err))
}
err = orderGoodRepository.Remove(orderId)
err = orderGoodRepository.Remove(orderId, companyId)
if err != nil {
return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, fmt.Sprintf("删除订单中商品数据失败:%s", err))
}
... ... @@ -312,7 +318,9 @@ func (service OrderInfoService) UpdateOrderData(cmd command.UpdateOrderCommand)
return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error())
}
var partnerData *domain.PartnerInfo
partnerData, err = PartnerInfoRepository.FindOne(domain.PartnerFindOneQuery{UserId: cmd.PartnerId})
partnerData, err = PartnerInfoRepository.FindOne(domain.PartnerFindOneQuery{
UserId: cmd.PartnerId, CompanyId: cmd.CompanyId,
})
if err != nil {
return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, fmt.Sprintf("检索合伙人数据失败"))
}
... ... @@ -337,7 +345,8 @@ func (service OrderInfoService) UpdateOrderData(cmd command.UpdateOrderCommand)
}
//获取旧的订单
oldOrderData, err = orderBaseRepository.FindOne(domain.OrderBaseFindOneQuery{
OrderId: cmd.Id,
OrderId: cmd.Id,
CompanyId: cmd.CompanyId,
})
if err != nil {
return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, fmt.Sprintf("未找到指定的订单:%s", err))
... ... @@ -359,7 +368,7 @@ func (service OrderInfoService) UpdateOrderData(cmd command.UpdateOrderCommand)
// }
//检查delivery_code是否重复
if len(cmd.DeliveryCode) > 0 {
if ok, err := orderBaseDao.DeliveryCodeExist(cmd.DeliveryCode, cmd.Id); err != nil {
if ok, err := orderBaseDao.DeliveryCodeExist(cmd.DeliveryCode, cmd.CompanyId, cmd.Id); err != nil {
return nil, lib.ThrowError(lib.TRANSACTION_ERROR, err.Error())
} else if ok {
return nil, lib.ThrowError(lib.BUSINESS_ERROR, "发货号已存在")
... ... @@ -367,7 +376,8 @@ func (service OrderInfoService) UpdateOrderData(cmd command.UpdateOrderCommand)
}
//获取旧的订单中的商品
oldOrderGoods, _, err = orderGoodRepository.Find(domain.OrderGoodFindQuery{
OrderId: cmd.Id,
OrderId: cmd.Id,
CompanyId: cmd.CompanyId,
})
if err != nil {
return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, fmt.Sprintf("未找到指定的订单中的商品列表失败:%s", err))
... ... @@ -380,6 +390,7 @@ func (service OrderInfoService) UpdateOrderData(cmd command.UpdateOrderCommand)
m.Price = good.Price
m.PartnerBonusPercent = good.PartnerBonusPercent
m.Remark = good.Remark
m.CompanyId = cmd.CompanyId
err = m.Compute()
if err != nil {
return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, fmt.Sprintf("核算订单中商品的数值失败:%s", err))
... ... @@ -414,7 +425,7 @@ func (service OrderInfoService) UpdateOrderData(cmd command.UpdateOrderCommand)
oldOrderData.Goods = newOrderGoods
//删不需要的订单总不需要的商品
delGoods = service.deleteOldOrderGoods(newOrderGoods, oldOrderGoods)
err = orderGoodRepository.Remove(oldOrderData.Id, delGoods...)
err = orderGoodRepository.Remove(oldOrderData.Id, cmd.CompanyId, delGoods...)
if err != nil {
return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, fmt.Sprintf("删除订单中的商品数据失败:%s", err))
}
... ... @@ -474,7 +485,8 @@ func (service OrderInfoService) Delivery(cmd command.OrderDeliveryCommand) error
}
//获取旧的订单
oldOrderData, err = orderBaseRepository.FindOne(domain.OrderBaseFindOneQuery{
OrderId: cmd.OrderId,
CompanyId: cmd.CompanyId,
OrderId: cmd.OrderId,
})
if err != nil {
return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, fmt.Sprintf("未找到指定的订单:%s", err))
... ... @@ -495,7 +507,8 @@ func (service OrderInfoService) Delivery(cmd command.OrderDeliveryCommand) error
}
//获取旧的订单中的商品
oldOrderGoods, _, err = orderGoodRepository.Find(domain.OrderGoodFindQuery{
OrderId: cmd.OrderId,
OrderId: cmd.OrderId,
CompanyId: cmd.CompanyId,
})
if err != nil {
return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, fmt.Sprintf("未找到指定的订单中的商品列表失败:%s", err))
... ... @@ -567,7 +580,8 @@ func (service OrderInfoService) DisableOrEnable(cmd command.DisableOrderCommand)
}
//获取旧的订单
oldOrderData, err = orderBaseRepository.FindOne(domain.OrderBaseFindOneQuery{
OrderId: cmd.OrderId,
OrderId: cmd.OrderId,
CompanyId: cmd.CompanyId,
})
if err != nil {
return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, fmt.Sprintf("未找到指定的订单:%s", err))
... ... @@ -617,7 +631,8 @@ func (service OrderInfoService) UpdateGoodBouns(cmd command.UpdateGoodBouns) err
}
//获取旧的订单
oldOrderData, err = orderBaseRepository.FindOne(domain.OrderBaseFindOneQuery{
OrderId: cmd.Id,
OrderId: cmd.Id,
CompanyId: cmd.CompanyId,
})
if err != nil {
return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, fmt.Sprintf("未找到指定的订单:%s", err))
... ...
... ... @@ -59,6 +59,8 @@ type OrderBase struct {
IsDisable int `json:"isDisable"`
//分红支付状态
BonusStatus int `json:"bonusStatus"`
//公司
CompanyId int64 `json:"companyId"`
}
type OrderCompute struct {
... ... @@ -178,7 +180,8 @@ func (order *OrderBase) Compute() error {
}
type OrderBaseFindOneQuery struct {
OrderId int64
OrderId int64
CompanyId int64
}
type OrderBaseFindQuery struct {
... ... @@ -188,11 +191,12 @@ type OrderBaseFindQuery struct {
Offset int
Limit int
OrderType int
CompanyId int64
}
type OrderBaseRepository interface {
Save(order *OrderBase) error
FindOne(qureyOptions OrderBaseFindOneQuery) (*OrderBase, error)
Find(queryOptions OrderBaseFindQuery) ([]OrderBase, int, error)
Remove(id int64) error
Remove(id int64, companyId int64) error
}
... ...
... ... @@ -48,6 +48,8 @@ type OrderGood struct {
CurrentBonusStatus OrderGoodBonusStatus `json:"-"`
///核算订单相关数据
GoodCompute GoodCompute `json:"goodCompute"`
//公司
CompanyId int64
}
type GoodCompute struct {
... ... @@ -170,13 +172,14 @@ func (good *OrderGood) Compute() error {
}
type OrderGoodFindQuery struct {
OrderId int64
Offset int
Limit int
OrderId int64
Offset int
Limit int
CompanyId int64
}
type OrderGoodRepository interface {
Save(order []OrderGood) error
Find(queryOptions OrderGoodFindQuery) ([]OrderGood, int, error)
Remove(orderid int64, ids ...int64) error
Remove(orderid int64, companyId int64, ids ...int64) error
}
... ...
... ... @@ -32,10 +32,10 @@ func (dao OrderBaseDao) OrderCodeExist(code string, notId ...int64) (bool, error
return ok, err
}
func (dao OrderBaseDao) DeliveryCodeExist(code string, notId ...int64) (bool, error) {
func (dao OrderBaseDao) DeliveryCodeExist(code string, companyId int64, notId ...int64) (bool, error) {
tx := dao.transactionContext.PgDd
m := &models.OrderBase{}
query := tx.Model(m).Where("delivery_code=?", code)
query := tx.Model(m).Where("delivery_code=?", code).Where("company_id=?", companyId)
if len(notId) > 0 {
query = query.WhereIn("id not in(?)", notId)
}
... ...
package models
import (
"context"
"time"
"github.com/go-pg/pg/v10"
"gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/domain"
)
type Order struct {
tableName struct{} `pg:"order"`
//id
Id int64 `pg:",pk"`
//订单类型 1:实际订单 2:意向订单
OrderType int `pg:",notnull,default:1"`
//订单编号
OrderCode string `pg:",unique,notnull`
//订单名称
OrderName string
//订单状态
OrderStatus int `pg:",notnull,default:1"`
//订单数量
OrderCount int
//实际订单数量
OrderActualCount int
//订单金额
OrderAmount float64
//订单实际金额
OrderActualAmount float64
//订单已支付金额(货款)
OrderPaymentAmount float64 `pg:",use_zero"`
//最后分红状态
BonusStatus int `pg:",default:1"`
//订单区域信息
OrderRegionInfo domain.RegionInfo
Buyer domain.Buyer
//合伙人编号
PartnerId int64
PartnerInfo PartnerInfo `pg:"fk:partner_id"`
//合伙人分红百分比
PartnerBonusPercent float64
//业务员分红百分比
SalesmanBonusPercent float64
//创建时间
CreateAt time.Time
//更新时间
UpdateAt time.Time
//上一次查看时间 已读情况
LastViewTime time.Time
//理由
Reason string
}
var _ pg.BeforeUpdateHook = (*Order)(nil)
func (or *Order) BeforeUpdate(ctx context.Context) (context.Context, error) {
or.UpdateAt = time.Now()
return ctx, nil
}
var _ pg.BeforeInsertHook = (*Order)(nil)
func (or *Order) BeforeInsert(ctx context.Context) (context.Context, error) {
or.CreateAt = time.Now()
or.UpdateAt = time.Now()
return ctx, nil
}
... ... @@ -62,6 +62,7 @@ type OrderBase struct {
IsDisable int `pg:",use_zero"`
//分红支付状态
BonusStatus int
CompanyId int64
}
var _ pg.BeforeUpdateHook = (*OrderBase)(nil)
... ...
... ... @@ -36,5 +36,6 @@ type OrderGood struct {
//分红状态
BonusStatus int
//备注信息
Remark string
Remark string
CompanyId int64
}
... ...
package models
import "time"
type OrderPayment struct {
tableName struct{} `pg:"order_payment"`
//编号
Id int64 `pg:",pk"`
//订单编号
OrderId int64
//合伙人编号
PartnerId int64
//支付货款
PaymentAmount float64 `pg:",notnull,default:0"`
//分红金额
BonusAmount float64
//分红状态 1.等待支付分红 2.已支付分红
BonusStatus int `pg:",notnull,default:1"`
//创建时间
CreateAt time.Time
//更新时间
UpdateAt time.Time
}
... ... @@ -41,6 +41,7 @@ func (reponsitory OrderBaseRepository) transformPgModelToDomainModel(orderModel
Id: orderModel.PartnerId,
},
BonusStatus: orderModel.BonusStatus,
CompanyId: orderModel.CompanyId,
}
return order, nil
}
... ... @@ -61,6 +62,7 @@ func (repository OrderBaseRepository) Save(orderInfo *domain.OrderBase) error {
PartnerBonusHas: orderInfo.OrderCompute.PartnerBonusHas, PartnerBonusNot: orderInfo.OrderCompute.PartnerBonusNot,
PartnerBonusExpense: orderInfo.OrderCompute.PartnerBonusExpense, IsDisable: orderInfo.IsDisable,
CreateTime: orderInfo.CreateTime, BonusStatus: orderInfo.BonusStatus,
CompanyId: orderInfo.CompanyId,
}
if m.Id == 0 {
_, err = tx.Model(m).
... ... @@ -95,6 +97,9 @@ func (repository OrderBaseRepository) Find(queryOption domain.OrderBaseFindQuery
if queryOption.OrderType > 0 {
query = query.Where("order_type=?", queryOption.OrderType)
}
if queryOption.CompanyId > 0 {
query = query.Where("company_id=?", queryOption.CompanyId)
}
if queryOption.Offset > -1 {
query = query.Offset(queryOption.Offset)
}
... ... @@ -138,7 +143,7 @@ func (repository OrderBaseRepository) FindOne(qureyOptions domain.OrderBaseFindO
return &result, err
}
func (repository OrderBaseRepository) Remove(id int64) error {
func (repository OrderBaseRepository) Remove(id int64, companyId int64) error {
var (
err error
tx = repository.transactionContext.PgTx
... ... @@ -146,6 +151,9 @@ func (repository OrderBaseRepository) Remove(id int64) error {
m := &models.OrderBase{
Id: id,
}
_, err = tx.Model(m).WherePK().Delete()
_, err = tx.Model(m).
Where("id=?", id).
Where("company_id=?", companyId).
Delete()
return err
}
... ...
... ... @@ -38,6 +38,7 @@ func (reponsitory OrderGoodRepository) transformPgModelToDomainModel(orderModel
PartnerBonusNot: orderModel.PartnerBonusNot,
PartnerBonusExpense: orderModel.PartnerBonusExpense,
},
CompanyId: orderModel.CompanyId,
}
switch orderModel.BonusStatus {
case domain.OrderGoodWaitPay:
... ... @@ -62,7 +63,8 @@ func (repository OrderGoodRepository) Save(data []domain.OrderGood) error {
PlanPartnerBonus: v.GoodCompute.PlanPartnerBonus, UsePartnerBonus: v.GoodCompute.UsePartnerBonus,
PartnerBonusHas: v.GoodCompute.PartnerBonusHas, PartnerBonusNot: v.GoodCompute.PartnerBonusNot,
PartnerBonusExpense: v.GoodCompute.PartnerBonusExpense, BonusStatus: v.BonusStatus,
Remark: v.Remark,
Remark: v.Remark,
CompanyId: v.CompanyId,
}
if v.Id == 0 {
_, err = tx.Model(m).
... ... @@ -91,6 +93,9 @@ func (repository OrderGoodRepository) Find(queryOption domain.OrderGoodFindQuery
if queryOption.OrderId > 0 {
query = query.Where("order_id=?", queryOption.OrderId)
}
if queryOption.CompanyId > 0 {
query = query.Where("company_id=?", queryOption.CompanyId)
}
if queryOption.Offset > -1 {
query = query.Offset(queryOption.Offset)
}
... ... @@ -118,13 +123,15 @@ func (repository OrderGoodRepository) Find(queryOption domain.OrderGoodFindQuery
return orderGoods, count, nil
}
func (repository OrderGoodRepository) Remove(orderId int64, goodids ...int64) error {
func (repository OrderGoodRepository) Remove(orderId int64, companyId int64, goodids ...int64) error {
var (
err error
tx = repository.transactionContext.PgTx
)
m := &models.OrderGood{}
query := tx.Model(m).Where("order_id=?", orderId)
query := tx.Model(m).
Where("order_id=?", orderId).
Where("company_id=?", companyId)
if len(goodids) > 0 {
query = query.WhereIn("id in(?)", goodids)
}
... ...
... ... @@ -21,9 +21,11 @@ func (c *CommonController) Prepare() {
// GetPartnerList 下拉选项数据通用接口,获取合伙人列表
func (c *CommonController) GetPartnerList() {
companyId := c.GetUserCompany()
query := partnerQuery.ListPartnerInfoQuery{
Limit: 5000,
Offset: 0,
Limit: 1000,
Offset: 0,
CompanyId: companyId,
}
newPartnerService := partnerInfoService.NewPartnerInfoService(nil)
_, partners, err := newPartnerService.ListPartnerInfo(&query)
... ...
... ... @@ -56,7 +56,7 @@ func (c *OrderInfoController) PageListOrderPurpose() {
if param.PageSize == 0 {
param.PageSize = 20
}
companyId := c.GetUserCompany()
orderSrv := orderService.NewOrderInfoService(nil)
orderinfos, cnt, err := orderSrv.PageListOrderBase(orderQuery.ListOrderBaseQuery{
PartnerId: param.Partner,
... ... @@ -64,6 +64,7 @@ func (c *OrderInfoController) PageListOrderPurpose() {
OrderType: domain.OrderIntention,
Limit: param.PageSize,
Offset: (param.PageNumber - 1) * param.PageSize,
CompanyId: companyId,
})
if err != nil {
c.ResponseError(err)
... ... @@ -103,9 +104,11 @@ func (c *OrderInfoController) GetOrderPurpose() {
return
}
orderid, _ := strconv.ParseInt(param.Id, 10, 64)
companyId := c.GetUserCompany()
orderSrv := orderService.NewOrderInfoService(nil)
orderinfo, err := orderSrv.GetOrderDetail(orderQuery.GetOrderQuery{
OrderId: orderid,
OrderId: orderid,
CompanyId: companyId,
})
if err != nil {
c.ResponseError(err)
... ... @@ -156,8 +159,9 @@ func (c *OrderInfoController) RemoveOrderPurpose() {
c.ResponseError(errors.New("json数据解析失败"))
return
}
companyId := c.GetUserCompany()
orderSrv := orderService.NewOrderInfoService(nil)
err = orderSrv.DeleteOrder(param.Id)
err = orderSrv.DeleteOrder(param.Id, companyId)
if err != nil {
c.ResponseError(err)
return
... ... @@ -290,6 +294,7 @@ func (c *OrderInfoController) addOrderPurpose(param postPurposeOrderDetail) erro
}
newGoods = append(newGoods, g)
}
companyId := c.GetUserCompany()
createcmd := orderCmd.CreateOrderCommand{
OrderType: domain.OrderIntention,
OrderCode: param.OrderId,
... ... @@ -299,6 +304,7 @@ func (c *OrderInfoController) addOrderPurpose(param postPurposeOrderDetail) erro
PartnerId: param.PartnerId,
SalesmanBonusPercent: param.CommissionProportion,
Goods: newGoods,
CompanyId: companyId,
}
orderSrv := orderService.NewOrderInfoService(nil)
_, err := orderSrv.CreateNewOrder(createcmd)
... ... @@ -317,6 +323,7 @@ func (c *OrderInfoController) editOrderPurpose(param postPurposeOrderDetail) err
}
newGoods = append(newGoods, g)
}
companyId := c.GetUserCompany()
updatecmd := orderCmd.UpdateOrderCommand{
Id: param.Id,
OrderType: domain.OrderIntention,
... ... @@ -327,6 +334,7 @@ func (c *OrderInfoController) editOrderPurpose(param postPurposeOrderDetail) err
PartnerId: param.PartnerId,
SalesmanBonusPercent: param.CommissionProportion,
Goods: newGoods,
CompanyId: companyId,
}
_, err := orderSrv.UpdateOrderData(updatecmd)
return err
... ... @@ -387,9 +395,10 @@ func (c *OrderInfoController) OrderPurposeDelivery() {
}
goods = append(goods, g)
}
companyId := c.GetUserCompany()
deliveryCommand := orderCmd.OrderDeliveryCommand{
OrderId: orderid, DeliveryCode: param.ShipmentsId,
DeliveryTime: time.Now(), Goods: goods,
DeliveryTime: time.Now(), Goods: goods, CompanyId: companyId,
}
orderSrv := orderService.NewOrderInfoService(nil)
err = orderSrv.Delivery(deliveryCommand)
... ... @@ -423,7 +432,7 @@ func (c *OrderInfoController) PageListOrderReal() {
if param.PageSize == 0 {
param.PageSize = 20
}
companyId := c.GetUserCompany()
orderSrv := orderService.NewOrderInfoService(nil)
orderinfos, cnt, err := orderSrv.PageListOrderBase(orderQuery.ListOrderBaseQuery{
PartnerId: param.Partner,
... ... @@ -431,6 +440,7 @@ func (c *OrderInfoController) PageListOrderReal() {
OrderType: domain.OrderReal,
Limit: param.PageSize,
Offset: (param.PageNumber - 1) * param.PageSize,
CompanyId: companyId,
})
if err != nil {
c.ResponseError(err)
... ... @@ -485,9 +495,11 @@ func (c *OrderInfoController) GetOrderReal() {
c.ResponseError(errors.New("参数错误"))
return
}
companyId := c.GetUserCompany()
orderSrv := orderService.NewOrderInfoService(nil)
orderinfo, err := orderSrv.GetOrderDetail(orderQuery.GetOrderQuery{
OrderId: orderid,
OrderId: orderid,
CompanyId: companyId,
})
if err != nil {
c.ResponseError(err)
... ... @@ -601,6 +613,7 @@ func (c *OrderInfoController) addOrderReal(param postRealOrderDetail) error {
}
newGoods = append(newGoods, g)
}
companyId := c.GetUserCompany()
createcmd := orderCmd.CreateOrderCommand{
OrderType: domain.OrderReal,
OrderCode: param.OrderId,
... ... @@ -610,6 +623,7 @@ func (c *OrderInfoController) addOrderReal(param postRealOrderDetail) error {
PartnerId: param.PartnerId,
SalesmanBonusPercent: param.CommissionProportion,
Goods: newGoods,
CompanyId: companyId,
}
_, err := orderSrv.CreateNewOrder(createcmd)
return err
... ... @@ -627,6 +641,7 @@ func (c *OrderInfoController) editOrderReal(param postRealOrderDetail) error {
}
newGoods = append(newGoods, g)
}
companyId := c.GetUserCompany()
updatecmd := orderCmd.UpdateOrderCommand{
Id: param.Id,
OrderType: domain.OrderReal,
... ... @@ -637,6 +652,7 @@ func (c *OrderInfoController) editOrderReal(param postRealOrderDetail) error {
PartnerId: param.PartnerId,
SalesmanBonusPercent: param.CommissionProportion,
Goods: newGoods,
CompanyId: companyId,
}
orderSrv := orderService.NewOrderInfoService(nil)
_, err := orderSrv.UpdateOrderData(updatecmd)
... ... @@ -668,10 +684,12 @@ func (c *OrderInfoController) OrderDisable() {
c.ResponseError(errors.New("参数错误"))
return
}
companyId := c.GetUserCompany()
cmd := orderCmd.DisableOrderCommand{
OrderId: orderId,
IsDisable: param.Status,
OrderType: domain.OrderReal,
CompanyId: companyId,
}
orderSrv := orderService.NewOrderInfoService(nil)
err = orderSrv.DisableOrEnable(cmd)
... ... @@ -696,8 +714,9 @@ func (c *OrderInfoController) RemoveOrderReal() {
c.ResponseError(errors.New("json数据解析失败"))
return
}
companyId := c.GetUserCompany()
orderSrv := orderService.NewOrderInfoService(nil)
err = orderSrv.DeleteOrder(param.Id)
err = orderSrv.DeleteOrder(param.Id, companyId)
if err != nil {
c.ResponseError(err)
return
... ...