作者 唐旭辉

日常保存

... ... @@ -38,6 +38,8 @@ type Buyer struct {
ContactInfo string `json:"contactInfo"`
//收获地址
ShippingAddress string `json:"shippingAddress"`
//买家备注
Remark string `json:"remark"`
}
//OrderDataFrom 订单数据来源
... ... @@ -76,6 +78,10 @@ type OrderCompute struct {
UseOrderAmount float64 `json:"useOrderAmount"`
}
type OrderBaseRemark struct {
Remark string
}
//OrderBase 订单基础
type OrderBase struct {
//表id
... ... @@ -113,6 +119,8 @@ type OrderBase struct {
CompanyId int64 `json:"companyId"`
//数据来源
DataFrom OrderDataFrom `json:"dataFrom"`
//备注
Remark OrderBaseRemark `json:"remark"`
}
//Update 更新订单数据
... ...
... ... @@ -43,6 +43,10 @@ type GoodCompute struct {
//合伙人分红支出
PartnerBonusExpense float64 `json:"partnerBonusExpense"`
}
type OrderGoodRemarkReason struct {
ModifyGoodNumber string `json:"modifyGoodNumber"` //货品数量变更的理由
ModifyPartnerBonusPercent string `json:"modifyPartnerBonusPercent"` //合伙人分红比例变更的理由
}
//OrderGood 订单中的货品
type OrderGood struct {
... ... @@ -71,7 +75,9 @@ type OrderGood struct {
///核算订单相关数据
GoodCompute GoodCompute `json:"goodCompute"`
//公司
CompanyId int64
CompanyId int64 `json:"companyId"`
//原因备注
RemarkReason OrderGoodRemarkReason `json:"remarkReason"`
}
//Update 更新商品相关的数据
... ...
... ... @@ -16,16 +16,17 @@ const (
//OrderLogDescript 描述日志内容
type OrderLogDescript struct {
Title string `json:"title"` //标题
Item string `json:"item"` //修改的项目
Modifyitem []string `json:"modifyItem"` //动作执行结果
Title string `json:"title"` //标题
Item string `json:"item"` //修改的项目
Action string `json:"action"` //执行的操作
Result string `json:"result"` //结果
}
//OrderLogContentItem 记录订单的相关属性值的修改
type OrderLogContent struct {
OrderId string `json:"orderId"` //订单id
GoodId string `json:"goodId"` //货品id
Title string `json:"title"` //名称标题
Table string `json:"Table"` //名称标题
Item string `json:"item"` //修改的数据字段
FormerValue string `json:"formerValue"` //旧值
NewValue string `json:"newValue"` //新值
... ... @@ -43,3 +44,12 @@ type OrderLog struct {
Content []OrderLogContent `json:"content"` //记录订单的操作动作
DataFrom string `json:"dataFrom"` //修改操作的来源:"web_admin"
}
type OrderLogFindQuery struct {
OrderId int64 `json:"orderId"`
}
type OrderLogRepository interface {
Add(*OrderLog) error
Find(queryOptions OrderLogFindQuery) ([]OrderLog, error)
}
... ...
... ... @@ -63,9 +63,10 @@ type OrderBase struct {
//分红支付状态
BonusStatus int
CompanyId int64
//数据来源
DataFrom domain.OrderDataFrom ``
//备注
Remark domain.OrderBaseRemark ``
}
var _ pg.BeforeUpdateHook = (*OrderBase)(nil)
... ...
package models
import "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/domain"
//OrderGood 订单中的货品
type OrderGood struct {
tableName struct{} `pg:"order_good"`
... ... @@ -36,6 +38,9 @@ type OrderGood struct {
//分红状态
BonusStatus int
//备注信息
Remark string
Remark string
//公司id
CompanyId int64
//原因备注
RemarkReason domain.OrderGoodRemarkReason ``
}
... ...
... ... @@ -82,7 +82,7 @@ func (repository OrderBaseRepository) Save(orderInfo *domain.OrderBase) error {
}
func (repository OrderBaseRepository) Find(queryOption domain.OrderBaseFindQuery) ([]domain.OrderBase, int, error) {
db := repository.transactionContext.PgDd
db := repository.transactionContext.GetDB()
orderModels := []models.OrderBase{}
query := db.Model(&orderModels)
if queryOption.PartnerId > 0 {
... ...
... ... @@ -13,6 +13,8 @@ type OrderLogRepository struct {
transactionContext *transaction.TransactionContext
}
var _ domain.OrderLogRepository = (*OrderLogRepository)(nil)
func NewOrderInfoRepository(transactionContext *transaction.TransactionContext) (*OrderLogRepository, error) {
if transactionContext == nil {
return nil, fmt.Errorf("transactionContext参数不能为nil")
... ... @@ -20,7 +22,7 @@ func NewOrderInfoRepository(transactionContext *transaction.TransactionContext)
return &OrderLogRepository{transactionContext: transactionContext}, nil
}
func (reponsitory OrderLogRepository) transformPgModelToDomainModel(m *models.OrderLog) (data domain.OrderLog, err error) {
func (repository OrderLogRepository) transformPgModelToDomainModel(m *models.OrderLog) (data domain.OrderLog, err error) {
return domain.OrderLog{
OrderId: m.OrderId,
Operator: m.Operator,
... ... @@ -34,10 +36,43 @@ func (reponsitory OrderLogRepository) transformPgModelToDomainModel(m *models.Or
}, nil
}
func (reponsitory OrderLogRepository) Add(data domain.OrderLog) error {
return nil
func (repository OrderLogRepository) Add(data *domain.OrderLog) error {
db := repository.transactionContext.GetDB()
m := models.OrderLog{
OrderId: data.OrderId,
Operator: data.Operator,
OperatorId: data.OperatorId,
OperatorType: data.OperatorType,
LogAction: data.LogAction,
Descript: data.Descript,
Content: data.Content,
DataFrom: data.DataFrom,
}
_, err := db.Model(&m).Insert()
data.AlterTime = m.AlterTime
return err
}
func (reponsitory OrderLogRepository) Find(data domain.OrderLog) ([]domain.OrderLog, int, error) {
return nil, 0, nil
func (repository OrderLogRepository) Find(queryOptions domain.OrderLogFindQuery) ([]domain.OrderLog, error) {
db := repository.transactionContext.GetDB()
logModels := []models.OrderLog{}
var err error
query := db.Model(&logModels)
if queryOptions.OrderId > 0 {
query = query.Where("order_id=?", queryOptions.OrderId)
}
query.Limit(1000)
err = query.Select()
if err != nil {
return nil, err
}
logReturn := []domain.OrderLog{}
for i := range logModels {
domainLog, err := repository.transformPgModelToDomainModel(&logModels[i])
if err != nil {
return logReturn, err
}
logReturn = append(logReturn, domainLog)
}
return logReturn, nil
}
... ...