|
|
@@ -2,6 +2,8 @@ |
|
|
|
|
|
|
|
import ( |
|
|
|
"code.fnuoos.com/zhimeng/model.git/src/super/dao" |
|
|
|
"code.fnuoos.com/zhimeng/model.git/src/super/model" |
|
|
|
zhios_order_relate_logx "code.fnuoos.com/zhimeng/model.git/utils/logx" |
|
|
|
"xorm.io/xorm" |
|
|
|
) |
|
|
|
|
|
|
@@ -12,3 +14,31 @@ func NewMediumSettlementDb(engine *xorm.Engine) dao.MediumSettlementDao { |
|
|
|
type MediumSettlementDb struct { |
|
|
|
Db *xorm.Engine |
|
|
|
} |
|
|
|
|
|
|
|
func (m MediumSettlementDb) UpdateMediumSettlementBySession(session *xorm.Session, mediumSettlement *model.MediumSettlement, columns ...string) (int64, error) { |
|
|
|
affected, err := session.Where("id =?", mediumSettlement.Id).Cols(columns...).Update(m) |
|
|
|
if err != nil { |
|
|
|
return 0, err |
|
|
|
} |
|
|
|
return affected, nil |
|
|
|
} |
|
|
|
|
|
|
|
func (m MediumSettlementDb) MediumSettlementInsertBySession(session *xorm.Session, mediumSettlement *model.MediumSettlement) (int64, error) { |
|
|
|
insertAffected, err := session.InsertOne(mediumSettlement) |
|
|
|
if err != nil { |
|
|
|
return 0, err |
|
|
|
} |
|
|
|
return insertAffected, nil |
|
|
|
} |
|
|
|
|
|
|
|
func (m MediumSettlementDb) GetMediumSettlementForAvailable(mediumId int) (mediumSettlement *model.MediumSettlement, err error) { |
|
|
|
mediumSettlement = new(model.MediumSettlement) |
|
|
|
has, err := m.Db.Where("medium_id =?", mediumId).And("state =?", 0).Get(mediumSettlement) |
|
|
|
if err != nil { |
|
|
|
return nil, zhios_order_relate_logx.Error(err) |
|
|
|
} |
|
|
|
if has == false { |
|
|
|
return nil, nil |
|
|
|
} |
|
|
|
return mediumSettlement, nil |
|
|
|
} |