作者 唐旭辉

0.5.0 版本中移除的功能的相关代码注释清理

package service
import (
"fmt"
"gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/application/businessBonus/command"
"gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/application/businessBonus/query"
"gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/application/factory"
"gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/domain"
"gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/infrastructure/dao"
"gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/lib"
)
type BusinessBonusService struct {
}
... ... @@ -20,160 +9,160 @@ func NewBusinessBonusService(option map[string]interface{}) *BusinessBonusServic
}
// 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()
}()
// 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()
// 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
}
// 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
}
// 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) {
// 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")
}
// 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
}
// return returnData, nil
// }
... ...
... ... @@ -1246,6 +1246,7 @@ func (service OrderInfoService) ListOrderBonusForExcel(listOrderQuery query.List
[2]string{"num", "序号"},
[2]string{"order_type", "订单类型"},
[2]string{"order_code", "订单号"},
[2]string{"delivery_code", "发货单号"},
[2]string{"partner_name", "合伙人"},
[2]string{"bonus_status", "订单状态"},
[2]string{"update_time", "最后操作时间"},
... ...
package controllers
import (
"errors"
"github.com/astaxie/beego/logs"
businessCommand "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/application/businessBonus/command"
businessQuery "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/application/businessBonus/query"
businessService "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/application/businessBonus/service"
"gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/domain"
)
... ... @@ -24,95 +18,95 @@ func (c *BusinessBonusController) Prepare() {
}
}
func (c *BusinessBonusController) ListBusinessBonus() {
type Parameter struct {
PageNumber int `json:"pageNumber"`
Partner int64 `json:"partner"`
PageSize int `json:"pageSize"`
SearchText string `json:"searchText"`
}
var (
param Parameter
err error
)
if err = c.BindJsonData(&param); err != nil {
logs.Error(err)
c.ResponseError(errors.New("json数据解析失败"))
return
}
if param.PageSize == 0 {
param.PageSize = 20
}
if param.PageNumber == 0 {
param.PageNumber = 1
}
companyId := c.GetUserCompany()
srv := businessService.NewBusinessBonusService(nil)
cnt, result, err := srv.ListBusinessBonus(businessQuery.ListBusinessBonusQuery{
CompanyId: companyId,
Limit: param.PageSize,
Offset: param.PageSize * (param.PageNumber - 1),
PartnerId: param.Partner,
})
if err != nil {
c.ResponseError(err)
return
}
c.ResponsePageList(result, cnt, param.PageNumber)
}
// func (c *BusinessBonusController) ListBusinessBonus() {
// type Parameter struct {
// PageNumber int `json:"pageNumber"`
// Partner int64 `json:"partner"`
// PageSize int `json:"pageSize"`
// SearchText string `json:"searchText"`
// }
// var (
// param Parameter
// err error
// )
// if err = c.BindJsonData(&param); err != nil {
// logs.Error(err)
// c.ResponseError(errors.New("json数据解析失败"))
// return
// }
// if param.PageSize == 0 {
// param.PageSize = 20
// }
// if param.PageNumber == 0 {
// param.PageNumber = 1
// }
// companyId := c.GetUserCompany()
// srv := businessService.NewBusinessBonusService(nil)
// cnt, result, err := srv.ListBusinessBonus(businessQuery.ListBusinessBonusQuery{
// CompanyId: companyId,
// Limit: param.PageSize,
// Offset: param.PageSize * (param.PageNumber - 1),
// PartnerId: param.Partner,
// })
// if err != nil {
// c.ResponseError(err)
// return
// }
// c.ResponsePageList(result, cnt, param.PageNumber)
// }
func (c *BusinessBonusController) UpdateBusinessBonus() {
type Parameter struct {
Id int64 `json:"id"`
DividendsReceivable float64 `json:"dividendsReceivable"`
StateOfPayment int8 `json:"stateOfPayment"`
}
var (
param Parameter
err error
)
if err = c.BindJsonData(&param); err != nil {
logs.Error(err)
c.ResponseError(errors.New("json数据解析失败"))
return
}
companyId := c.GetUserCompany()
srv := businessService.NewBusinessBonusService(nil)
err = srv.UpdateBusinessBonus(businessCommand.UpdateBusinessBonusCommand{
CompanyId: companyId,
Id: param.Id,
Bonus: param.DividendsReceivable,
BonusStatus: param.StateOfPayment,
})
if err != nil {
c.ResponseError(err)
return
}
c.ResponseData(nil)
}
// func (c *BusinessBonusController) UpdateBusinessBonus() {
// type Parameter struct {
// Id int64 `json:"id"`
// DividendsReceivable float64 `json:"dividendsReceivable"`
// StateOfPayment int8 `json:"stateOfPayment"`
// }
// var (
// param Parameter
// err error
// )
// if err = c.BindJsonData(&param); err != nil {
// logs.Error(err)
// c.ResponseError(errors.New("json数据解析失败"))
// return
// }
// companyId := c.GetUserCompany()
// srv := businessService.NewBusinessBonusService(nil)
// err = srv.UpdateBusinessBonus(businessCommand.UpdateBusinessBonusCommand{
// CompanyId: companyId,
// Id: param.Id,
// Bonus: param.DividendsReceivable,
// BonusStatus: param.StateOfPayment,
// })
// if err != nil {
// c.ResponseError(err)
// return
// }
// c.ResponseData(nil)
// }
func (c *BusinessBonusController) GetBusinessBonus() {
type Parameter struct {
Id int64 `json:"id"`
}
var (
param Parameter
err error
)
if err = c.BindJsonData(&param); err != nil {
logs.Error(err)
c.ResponseError(errors.New("json数据解析失败"))
return
}
companyId := c.GetUserCompany()
srv := businessService.NewBusinessBonusService(nil)
data, err := srv.GetBusinessBonus(businessQuery.GetBusinessBonusQuery{
Id: param.Id,
CompanyId: companyId,
})
if err != nil {
c.ResponseError(err)
return
}
c.ResponseData(data)
}
// func (c *BusinessBonusController) GetBusinessBonus() {
// type Parameter struct {
// Id int64 `json:"id"`
// }
// var (
// param Parameter
// err error
// )
// if err = c.BindJsonData(&param); err != nil {
// logs.Error(err)
// c.ResponseError(errors.New("json数据解析失败"))
// return
// }
// companyId := c.GetUserCompany()
// srv := businessService.NewBusinessBonusService(nil)
// data, err := srv.GetBusinessBonus(businessQuery.GetBusinessBonusQuery{
// Id: param.Id,
// CompanyId: companyId,
// })
// if err != nil {
// c.ResponseError(err)
// return
// }
// c.ResponseData(data)
// }
... ...
... ... @@ -39,11 +39,11 @@ func init() {
// beego.NSRouter("/business/list", &controllers.BusinessBonusController{}, "POST:ListBusinessBonus"),
),
beego.NSNamespace("/order",
beego.NSRouter("/purpose/list", &controllers.OrderInfoController{}, "POST:PageListOrderPurpose"),
beego.NSRouter("/purpose/update", &controllers.OrderInfoController{}, "POST:UpdateOrderPurpose"),
beego.NSRouter("/purpose/detail", &controllers.OrderInfoController{}, "POST:GetOrderPurpose"),
beego.NSRouter("/purpose/del", &controllers.OrderInfoController{}, "POST:RemoveOrderPurpose"),
beego.NSRouter("/purpose/sendout", &controllers.OrderInfoController{}, "POST:OrderPurposeDelivery"),
// beego.NSRouter("/purpose/list", &controllers.OrderInfoController{}, "POST:PageListOrderPurpose"),
// beego.NSRouter("/purpose/update", &controllers.OrderInfoController{}, "POST:UpdateOrderPurpose"),
// beego.NSRouter("/purpose/detail", &controllers.OrderInfoController{}, "POST:GetOrderPurpose"),
// beego.NSRouter("/purpose/del", &controllers.OrderInfoController{}, "POST:RemoveOrderPurpose"),
// beego.NSRouter("/purpose/sendout", &controllers.OrderInfoController{}, "POST:OrderPurposeDelivery"),
beego.NSRouter("/actual/list", &controllers.OrderInfoController{}, "POST:PageListOrderReal"),
beego.NSRouter("/actual/detail", &controllers.OrderInfoController{}, "POST:GetOrderReal"),
beego.NSRouter("/actual/del", &controllers.OrderInfoController{}, "POST:RemoveOrderReal"),
... ...