12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- package service
- import (
- "errors"
- "youngee_b_api/app/dao"
- "youngee_b_api/app/entity"
- "youngee_b_api/app/vo"
- )
- type BillService struct{}
- // 电商带货账单支付
- func (p BillService) PaySelection(param *vo.PayParam) error {
- selectionId := param.ObjectId
- selectionInfo, err1 := dao.SelectionInfoDAO{}.GetSelectionInfoById(selectionId)
- if err1 != nil {
- return err1
- }
- selectionStatus := selectionInfo.SelectionStatus
- if selectionStatus != 4 {
- return errors.New("状态异常")
- }
- _, err2 := dao.EnterpriseDao{}.UpdateEnterpriseBalanceAndFrozen(selectionInfo.EnterpriseID, selectionInfo.EstimatedCost)
- if err2 != nil {
- return err2
- }
- err3 := dao.SelectionInfoDAO{}.UpdateSelectionInfo(entity.SelectionInfo{SelectionID: selectionId, SelectionStatus: 6})
- if err3 != nil {
- return err3
- }
- return nil
- }
- // 品牌种草账单支付
- func (p BillService) PayProject(param *vo.PayParam) error {
- projectId := param.ObjectId
- projectInfo, err1 := dao.ProjectDAO{}.GetProjectById(projectId)
- if err1 != nil {
- return err1
- }
- projectStatus := projectInfo.ProjectStatus
- if projectStatus != 6 {
- return errors.New("状态异常")
- }
- _, err2 := dao.EnterpriseDao{}.UpdateEnterpriseBalanceAndFrozen(projectInfo.EnterpriseID, projectInfo.PaymentAmount)
- if err2 != nil {
- return err2
- }
- err3 := dao.ProjectDAO{}.UpdateProject(entity.Project{ProjectId: projectId, ProjectStatus: 8})
- if err3 != nil {
- return err3
- }
- return nil
- }
- // 本地生活账单支付
- func (p BillService) PayLocalLife(param *vo.PayParam) error {
- localId := param.ObjectId
- localInfo, err1 := dao.LocalLifeDao{}.GetLocalById(localId)
- if err1 != nil {
- return err1
- }
- localStatus := localInfo.TaskStatus
- if localStatus != 6 {
- return errors.New("状态异常")
- }
- _, err2 := dao.EnterpriseDao{}.UpdateEnterpriseBalanceAndFrozen(localInfo.EnterpriseID, localInfo.PaymentAmount)
- if err2 != nil {
- return err2
- }
- err3 := dao.LocalLifeDao{}.UpdateLocal(entity.LocalLifeInfo{LocalID: localId, TaskStatus: 8})
- if err3 != nil {
- return err3
- }
- return nil
- }
|