aa
This commit is contained in:
@@ -439,7 +439,7 @@ func AcceptJob(ctx *jxcontext.Context, jobID, dropShippingDeliveryID, dropShippi
|
||||
return
|
||||
}
|
||||
dao.Commit(db, txDB)
|
||||
} else {
|
||||
} else if job.JobCategoryID != model.JobCategoryIDUnion {
|
||||
//任务限时完成
|
||||
timer := checkLimitJobOrders(db, job, jobOrder, model.JobTimerTypeAccept)
|
||||
JobTimers.s.Lock()
|
||||
@@ -1951,16 +1951,19 @@ func GetUnionActList(ctx *jxcontext.Context, vendorID, actType int) (actList []*
|
||||
|
||||
func ShareUnionLink(ctx *jxcontext.Context, jobID, linkType int) (link string, err error) {
|
||||
var (
|
||||
db = dao.GetDB()
|
||||
job = &model.Job{}
|
||||
db = dao.GetDB()
|
||||
job = &model.Job{}
|
||||
jobOrder = &model.JobOrder{}
|
||||
)
|
||||
job.ID = jobID
|
||||
err = dao.GetEntity(db, job)
|
||||
if err != nil {
|
||||
return link, err
|
||||
}
|
||||
jobOrder.JobID = job.ID
|
||||
err = dao.GetEntity(db, jobOrder, "JobID")
|
||||
if handler := partner.GetHandler(job.VendorID); handler != nil {
|
||||
handler.ShareUnionLink(ctx, linkType)
|
||||
handler.ShareUnionLink(ctx, linkType, job.UnionActID, jobOrder.UserID)
|
||||
}
|
||||
return link, err
|
||||
}
|
||||
|
||||
@@ -29,11 +29,18 @@ func CreateOrder(ctx *jxcontext.Context, type1, orderType int, way string, price
|
||||
if err = auth2.CheckWeixinminiAuthBind(ctx.GetUserID()); err != nil {
|
||||
return "", errCode, err
|
||||
}
|
||||
txDB, _ := dao.Begin(db)
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
dao.Rollback(db, txDB)
|
||||
panic(r)
|
||||
}
|
||||
}()
|
||||
if type1 == model.OrderTypeCash {
|
||||
//如果用户没有对应账单信息就给他生成一条
|
||||
userBill, err := dao.GetUserBill(db, ctx.GetUserID(), "")
|
||||
if userBill == nil {
|
||||
err = financial.AddUserBill(db, jxutils.GenBillID(), ctx.GetUserID())
|
||||
err = financial.AddUserBill(txDB, jxutils.GenBillID(), ctx.GetUserID())
|
||||
}
|
||||
if userBill.AccountBalance < price {
|
||||
return "", model.ErrCodeAccountBalanceNotEnough, fmt.Errorf("用户余额不足!")
|
||||
@@ -63,14 +70,7 @@ func CreateOrder(ctx *jxcontext.Context, type1, orderType int, way string, price
|
||||
CityCode: cCode,
|
||||
}
|
||||
dao.WrapAddIDCULEntity(order, ctx.GetUserName())
|
||||
txDB, _ := dao.Begin(db)
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
dao.Rollback(db, txDB)
|
||||
panic(r)
|
||||
}
|
||||
}()
|
||||
if err = dao.CreateEntity(db, order); err != nil {
|
||||
if err = dao.CreateEntityTx(txDB, order); err != nil {
|
||||
dao.Rollback(db, txDB)
|
||||
}
|
||||
dao.Commit(db, txDB)
|
||||
@@ -96,11 +96,19 @@ func Pay(ctx *jxcontext.Context, orderID string, payType int, vendorPayType stri
|
||||
}
|
||||
payHandler.Order = order
|
||||
//如果用户没有对应账单信息就给他生成一条
|
||||
txDB, _ := dao.Begin(db)
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
dao.Rollback(db, txDB)
|
||||
panic(r)
|
||||
}
|
||||
}()
|
||||
userBill, err := dao.GetUserBill(db, order.UserID, "")
|
||||
if userBill == nil {
|
||||
err = financial.AddUserBill(db, jxutils.GenBillID(), order.UserID)
|
||||
err = financial.AddUserBill(txDB, jxutils.GenBillID(), order.UserID)
|
||||
}
|
||||
err = payHandler.CreatePay()
|
||||
err = payHandler.CreatePay(txDB)
|
||||
dao.Commit(db, txDB)
|
||||
globals.SugarLogger.Debugf("result : %v", utils.Format4Output(payHandler.WxPayParam, false))
|
||||
return payHandler.WxPayParam, err
|
||||
}
|
||||
|
||||
@@ -601,7 +601,7 @@ func InvestMember(ctx *jxcontext.Context, memberID int, userID string, isFree bo
|
||||
}
|
||||
if !isFree {
|
||||
//支出明细
|
||||
if err = financial.AddExpendUpdateAccount(db, userBill, model.BillTypeMember, memberCard.Price, 0); err != nil {
|
||||
if err = financial.AddExpendUpdateAccount(txDB, userBill, model.BillTypeMember, memberCard.Price, 0); err != nil {
|
||||
dao.Rollback(db, txDB)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -608,12 +608,12 @@ func DeleteMessageGroup(ctx *jxcontext.Context, groupID int, userID string, flag
|
||||
}
|
||||
}()
|
||||
//账户支出
|
||||
if err = financial.AddExpendUpdateAccount(db, userBill, model.BillTypeQuitGroup, quitPrice, 0); err != nil {
|
||||
if err = financial.AddExpendUpdateAccount(txDB, userBill, model.BillTypeQuitGroup, quitPrice, 0); err != nil {
|
||||
dao.Rollback(db, txDB)
|
||||
return errCode, err
|
||||
}
|
||||
//群主收到退团金额
|
||||
if err = financial.AddIncomeUpdateAccount(db, userBillGroupMaster, model.BillTypeQuitGroup, quitPrice, 0); err != nil {
|
||||
if err = financial.AddIncomeUpdateAccount(txDB, userBillGroupMaster, model.BillTypeQuitGroup, quitPrice, 0); err != nil {
|
||||
dao.Rollback(db, txDB)
|
||||
return errCode, err
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"crypto/sha256"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/astaxie/beego/client/orm"
|
||||
"sort"
|
||||
"strings"
|
||||
"time"
|
||||
@@ -33,7 +34,7 @@ var (
|
||||
}
|
||||
)
|
||||
|
||||
func (p *PayHandler) CreatePay() (err error) {
|
||||
func (p *PayHandler) CreatePay(txDB orm.TxOrmer) (err error) {
|
||||
switch p.PayType {
|
||||
case model.PayTypeTL:
|
||||
param := &tonglianpayapi.CreateUnitorderOrderParam{
|
||||
@@ -53,7 +54,7 @@ func (p *PayHandler) CreatePay() (err error) {
|
||||
json.Unmarshal([]byte(result.PayInfo), &result2)
|
||||
p.Order.PrepayID = result2.Package[strings.LastIndex(result2.Package, "=")+1 : len(result2.Package)]
|
||||
p.Order.TransactionID = result.TrxID
|
||||
_, err = dao.UpdateEntity(dao.GetDB(), p.Order, "PrepayID", "TransactionID")
|
||||
_, err = dao.UpdateEntityTx(txDB, p.Order, "PrepayID", "TransactionID")
|
||||
}
|
||||
case model.PayTypeWX:
|
||||
param := &wxpayapi.CreateOrderParam{
|
||||
@@ -96,7 +97,7 @@ func (p *PayHandler) CreatePay() (err error) {
|
||||
p.WxPayParam = wxPay
|
||||
p.Order.PrepayID = result.PrepayID
|
||||
p.Order.Comment = result.CodeURL
|
||||
_, err = dao.UpdateEntity(dao.GetDB(), p.Order, "PrepayID", "Comment")
|
||||
_, err = dao.UpdateEntityTx(txDB, p.Order, "PrepayID", "Comment")
|
||||
} else {
|
||||
return err2
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ func OnPayFinished(order *model.Order) (err error) {
|
||||
case model.OrderTypePay:
|
||||
//如果是账户充值(发布任务等)
|
||||
//账户收入
|
||||
if err = AddIncomeUpdateAccount(db, userBill, model.BillTypeInvest, order.PayPrice, 0); err != nil {
|
||||
if err = AddIncomeUpdateAccount(txDB, userBill, model.BillTypeInvest, order.PayPrice, 0); err != nil {
|
||||
dao.Rollback(db, txDB)
|
||||
}
|
||||
default:
|
||||
@@ -93,7 +93,7 @@ func OnCashFinished(order *model.Order) (err error) {
|
||||
case model.OrderTypeCash:
|
||||
//如果是账户提现
|
||||
//账户支出
|
||||
if err = AddExpendUpdateAccount(db, userBill, model.BillTypeCash, order.PayPrice, 0); err != nil {
|
||||
if err = AddExpendUpdateAccount(txDB, userBill, model.BillTypeCash, order.PayPrice, 0); err != nil {
|
||||
dao.Rollback(db, txDB)
|
||||
}
|
||||
default:
|
||||
|
||||
@@ -17,7 +17,7 @@ func init() {
|
||||
partner.HandlerMap[model.VendorIDJDShop] = unionHandler
|
||||
}
|
||||
|
||||
func (s *UnionHandler) ShareUnionLink(ctx *jxcontext.Context, linkType int) (link string, err error) {
|
||||
func (s *UnionHandler) ShareUnionLink(ctx *jxcontext.Context, linkType, unionActID int, userID string) (link string, err error) {
|
||||
|
||||
return "jds", err
|
||||
}
|
||||
|
||||
@@ -7,8 +7,13 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
func (s *UnionHandler) ShareUnionLink(ctx *jxcontext.Context, linkType int) (link string, err error) {
|
||||
return "mt", err
|
||||
func (s *UnionHandler) ShareUnionLink(ctx *jxcontext.Context, linkType, unionActID int, userID string) (link string, err error) {
|
||||
if linkType == partner.LinkTypeWeiXinMini {
|
||||
//return api.MtUnionAPI.GenerateLink(unionActID, userID)
|
||||
} else {
|
||||
|
||||
}
|
||||
return link, err
|
||||
}
|
||||
|
||||
func (s *UnionHandler) GetUnionActList(ctx *jxcontext.Context, actType int) (actList []*partner.ActivityList, err error) {
|
||||
|
||||
@@ -31,7 +31,7 @@ func init() {
|
||||
}
|
||||
|
||||
type UnionInterface interface {
|
||||
ShareUnionLink(ctx *jxcontext.Context, linkType int) (link string, err error)
|
||||
ShareUnionLink(ctx *jxcontext.Context, linkType, unionActID int, userID string) (link string, err error)
|
||||
GetUnionActList(ctx *jxcontext.Context, actType int) (result []*ActivityList, err error)
|
||||
}
|
||||
|
||||
|
||||
@@ -125,6 +125,7 @@ type Job struct {
|
||||
BrowseCount int `json:"browseCount"` //任务浏览量,点一下加一下
|
||||
UnionImg string `json:"unionImg"` //联盟任务分享链接的背景图
|
||||
UnionQrcodePosition string `json:"unionQrcodePosition"` //联盟任务分享链接的二维码图的方位
|
||||
UnionActID int `orm:"column(union_act_id)" json:"unionActID"` //联盟任务ID
|
||||
// JobSteps []*JobStep `orm:"-" json:"jobSteps"`
|
||||
// JobImgs []*JobImg `orm:"-" json:"jobImgs"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user