service.go
6.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
package service
type BusinessBonusService struct {
}
func NewBusinessBonusService(option map[string]interface{}) *BusinessBonusService {
newService := new(BusinessBonusService)
return newService
}
// ListBusinessBonus 列表
// func (srv BusinessBonusService) ListBusinessBonus(queryOption query.ListBusinessBonusQuery) (int, interface{}, error) {
// var (
// transactionContext, _ = factory.CreateTransactionContext(nil)
// err error
// )
// if err = transactionContext.StartTransaction(); err != nil {
// return 0, nil, err
// }
// defer func() {
// transactionContext.RollbackTransaction()
// }()
// var (
// bonusDaoao *dao.BusinessBonusDao
// )
// if bonusDaoao, err = factory.CreateBusinessBonusDao(map[string]interface{}{
// "transactionContext": transactionContext,
// }); err != nil {
// return 0, nil, lib.ThrowError(lib.TRANSACTION_ERROR, err.Error())
// }
// result, err := bonusDaoao.SearchBusinessBonus(queryOption.PartnerId, queryOption.PartnerNameMatch,
// queryOption.CompanyId, queryOption.Limit, queryOption.Offset)
// if err != nil {
// return 0, nil, err
// }
// cnt, err := bonusDaoao.CountBusinessBonus(queryOption.PartnerId, queryOption.PartnerNameMatch,
// queryOption.CompanyId, queryOption.Limit, queryOption.Offset)
// if err != nil {
// return 0, nil, err
// }
// err = transactionContext.CommitTransaction()
// returnData := []map[string]interface{}{}
// for _, v := range result {
// m := map[string]interface{}{
// "id": v.Id,
// "uncollectedDividends": v.BonusNot,
// "receiveDividends": v.BonusHas,
// "dividendsReceivable": v.Bonus,
// "stateOfPayment": v.BonusStatus,
// "stateOfPaymentName": domain.DescribeBusinessBonusStatus(v.BonusStatus),
// "partner": v.PartnerName,
// "updateTime": "",
// }
// if !v.UpdateAt.IsZero() {
// m["updateTime"] = v.UpdateAt.Local().Format("2006-01-02 15:04:05")
// }
// returnData = append(returnData, m)
// }
// return cnt, returnData, nil
// }
// func (srv BusinessBonusService) UpdateBusinessBonus(cmd command.UpdateBusinessBonusCommand) error {
// var (
// transactionContext, _ = factory.CreateTransactionContext(nil)
// err error
// )
// if err = transactionContext.StartTransaction(); err != nil {
// return err
// }
// defer func() {
// transactionContext.RollbackTransaction()
// }()
// var (
// bonusRespository domain.BusinessBonusRepository
// bonusData *domain.BusinessBonus
// )
// if bonusRespository, err = factory.CreateBusinessBonusRepository(map[string]interface{}{
// "transactionContext": transactionContext,
// }); err != nil {
// return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error())
// }
// bonusData, err = bonusRespository.FindOne(domain.BusinessBonusFindOneQuery{
// Id: cmd.Id, CompanyId: cmd.CompanyId,
// })
// if err != nil {
// e := fmt.Sprintf("获取业务分红(id=%d;company_id=%d)数据失败:%s", cmd.Id, cmd.CompanyId, err)
// return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, e)
// }
// bonusData.Bonus = cmd.Bonus
// switch cmd.BonusStatus {
// case domain.BUSINESS_BONUS_HAS_PAY:
// bonusData.BusinessBonusPayStatus.PayPartnerBonus(bonusData)
// case domain.BUSINESS_BONUS_WAIT_PAY:
// bonusData.BusinessBonusPayStatus.WartPayPartnerBonus(bonusData)
// case domain.BUSINESS_BONUS_NULL_PAY:
// bonusData.BusinessBonusPayStatus.NullPayPartnerBonus(bonusData)
// default:
// return lib.ThrowError(lib.BUSINESS_ERROR, "支付状态错误")
// }
// err = bonusRespository.Edit(bonusData)
// if err != nil {
// e := fmt.Sprintf("更新业务分红(id=%d)数据失败:%s", bonusData.Id, err)
// return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, e)
// }
// err = transactionContext.CommitTransaction()
// return nil
// }
//GetBusinessBonus 获取详情
// func (srv BusinessBonusService) GetBusinessBonus(queryOption query.GetBusinessBonusQuery) (map[string]interface{}, error) {
// var (
// transactionContext, _ = factory.CreateTransactionContext(nil)
// err error
// )
// if err = transactionContext.StartTransaction(); err != nil {
// return nil, err
// }
// defer func() {
// transactionContext.RollbackTransaction()
// }()
// var (
// bonusRespository domain.BusinessBonusRepository
// partnerInfoRepository domain.PartnerInfoRepository
// bonusData *domain.BusinessBonus
// partnerData *domain.PartnerInfo
// )
// if bonusRespository, err = factory.CreateBusinessBonusRepository(map[string]interface{}{
// "transactionContext": transactionContext,
// }); err != nil {
// return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error())
// }
// bonusData, err = bonusRespository.FindOne(domain.BusinessBonusFindOneQuery{
// Id: queryOption.Id, CompanyId: queryOption.CompanyId,
// })
// if err != nil {
// e := fmt.Sprintf("获取业务分红(id=%d;company_id=%d)数据失败:%s", queryOption.Id, queryOption.CompanyId, err)
// return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, e)
// }
// if partnerInfoRepository, err = factory.CreatePartnerInfoRepository(map[string]interface{}{
// "transactionContext": transactionContext,
// }); err != nil {
// return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error())
// }
// partnerData, err = partnerInfoRepository.FindOne(domain.PartnerFindOneQuery{UserId: bonusData.PartnerInfoId})
// if err != nil {
// e := fmt.Sprintf("获取合伙人(id=%d)数据失败:%s", bonusData.PartnerInfoId, err)
// return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, e)
// }
// err = transactionContext.CommitTransaction()
// returnData := map[string]interface{}{
// "partner": partnerData.Partner.PartnerName,
// "dividendsReceivable": bonusData.Bonus,
// "receiveDividends": bonusData.BonusHas,
// "uncollectedDividends": bonusData.BonusNot,
// "updateTime": "",
// "stateOfPayment": bonusData.BonusStatus,
// "stateOfPaymentName": domain.DescribeBusinessBonusStatus(bonusData.BonusStatus),
// "id": bonusData.Id,
// }
// if !bonusData.UpdateAt.IsZero() {
// returnData["updateTime"] = bonusData.UpdateAt.Local().Format("2006-01-02 15:04:05")
// }
// return returnData, nil
// }