订单打款修改
This commit is contained in:
@@ -153,7 +153,11 @@ func (p *PurchaseHandler) CreateStoreSkus(ctx *jxcontext.Context, storeID int, v
|
||||
)
|
||||
if strings.Contains(storeSku.StoreName, model.ExdStoreName) {
|
||||
isExd = true
|
||||
customSkuID = utils.Str2Int64(storeSku.ExdSkuID)
|
||||
if storeSku.ExdSkuID == "" {
|
||||
customSkuID = 0
|
||||
} else {
|
||||
customSkuID = utils.Str2Int64(storeSku.ExdSkuID)
|
||||
}
|
||||
} else {
|
||||
isExd = false
|
||||
customSkuID = int64(storeSku.SkuID)
|
||||
|
||||
@@ -2,7 +2,6 @@ package localjx
|
||||
|
||||
import (
|
||||
"crypto/md5"
|
||||
"errors"
|
||||
"fmt"
|
||||
"math"
|
||||
"sort"
|
||||
@@ -13,7 +12,6 @@ import (
|
||||
"git.rosy.net.cn/jx-callback/globals/api"
|
||||
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/ddmsg"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/tasksch"
|
||||
|
||||
"git.rosy.net.cn/baseapi/platformapi/dingdingapi"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
@@ -629,7 +627,7 @@ func GetOrderPay(ctx *jxcontext.Context, vendorOrderID string) (payList []*model
|
||||
return payList, err
|
||||
}
|
||||
|
||||
func PayForPopluarMan(ctx *jxcontext.Context, transactionID, vendorOrderID, userID string) (err error) {
|
||||
func PayForPopluarMan(ctx *jxcontext.Context, vendorOrderID, userID string, price int) (err error) {
|
||||
db := dao.GetDB()
|
||||
user, err := dao.GetUserByID(db, "user_id", userID)
|
||||
if user == nil {
|
||||
@@ -643,85 +641,81 @@ func PayForPopluarMan(ctx *jxcontext.Context, transactionID, vendorOrderID, user
|
||||
if len(goods) == 0 {
|
||||
return fmt.Errorf("未找到此订单!订单ID:[%v]\n", vendorOrderID)
|
||||
}
|
||||
param := &wxpayapi.MultiProfitSharingParam{
|
||||
TransactionID: transactionID,
|
||||
OutOrderNo: vendorOrderID,
|
||||
param := &wxpayapi.TransfersParam{
|
||||
CheckName: wxpayapi.CheckName,
|
||||
PartnerTradeNo: vendorOrderID,
|
||||
Desc: "每日推广人订单分成分到个人",
|
||||
SpbillCreateIP: ctx.GetRealRemoteIP(),
|
||||
OpenID: auth[0].AuthID,
|
||||
Amount: price,
|
||||
}
|
||||
param.Receivers = wxpayapi.CData(`[{"type":"` + wxpayapi.AccountTypeOpen + `","account":"` + auth[0].AuthID + `","amount":` + utils.Int2Str(int(goods[0].ActualPayPrice)*user.DividePercentage/100) + `,"description":"每日订单打款分到个人"}]`)
|
||||
_, err = api.WxpayAPI.MultiProfitSharing(param)
|
||||
_, err = api.WxpayAPI.Transfers(param)
|
||||
return err
|
||||
}
|
||||
|
||||
//自动打款给市场推广人
|
||||
func AutoPayForPopluarMan(ctx *jxcontext.Context, isAsync, isContinueWhenError bool) (hint string, err error) {
|
||||
func AutoPayForPopluarMan(ctx *jxcontext.Context) (err error) {
|
||||
var (
|
||||
db = dao.GetDB()
|
||||
fromDateStr = time.Now().AddDate(0, 0, -1).Format("2006-1-2") + " 00:00:00"
|
||||
toDateStr = time.Now().AddDate(0, 0, -1).Format("2006-1-2") + " 23:59:59"
|
||||
)
|
||||
result, err := dao.GetOrdersForJxPay(db, utils.Str2Time(fromDateStr), utils.Str2Time(toDateStr))
|
||||
task := tasksch.NewParallelTask("AutoPayForPopluarMan", tasksch.NewParallelConfig().SetIsContinueWhenError(isContinueWhenError), ctx,
|
||||
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||
goods := batchItemList[0].(*dao.GoodsOrderPay)
|
||||
var (
|
||||
errMsg string
|
||||
param = &wxpayapi.MultiProfitSharingParam{
|
||||
TransactionID: goods.TransactionID,
|
||||
OutOrderNo: goods.VendorOrderID,
|
||||
}
|
||||
payPrice1 int
|
||||
payPrice2 int
|
||||
receivers string = "["
|
||||
)
|
||||
user, err := dao.GetUserByID(db, "user_id", goods.UserID)
|
||||
if user.ParentMobile == "" {
|
||||
return retVal, err
|
||||
for _, goods := range result {
|
||||
var (
|
||||
errMsg string
|
||||
param = &wxpayapi.TransfersParam{
|
||||
CheckName: wxpayapi.CheckName,
|
||||
PartnerTradeNo: goods.VendorOrderID,
|
||||
Desc: "每日推广人订单分成分到个人",
|
||||
SpbillCreateIP: ctx.GetRealRemoteIP(),
|
||||
}
|
||||
user2, err := dao.GetUserByID(db, "mobile", user.ParentMobile)
|
||||
auth, err := dao.GetUserBindAuthInfo(db, user2.UserID, model.AuthBindTypeAuth, []string{"weixinmini"}, "", "")
|
||||
payPrice1 int
|
||||
payPrice2 int
|
||||
)
|
||||
user, err := dao.GetUserByID(db, "user_id", goods.UserID)
|
||||
if user.ParentMobile == "" {
|
||||
return err
|
||||
}
|
||||
user2, err := dao.GetUserByID(db, "mobile", user.ParentMobile)
|
||||
auth, err := dao.GetUserBindAuthInfo(db, user2.UserID, model.AuthBindTypeAuth, []string{"weixinmini"}, "", "")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if len(auth) == 0 {
|
||||
errMsg += fmt.Sprintf("打款失败!未找到此用户的微信验证方式!订单号:[%v],用户ID:[%v]\n", goods.VendorOrderID, user2.UserID)
|
||||
} else {
|
||||
payPrice1 = int(goods.ActualPayPrice) * user2.DividePercentage / 100
|
||||
param.OpenID = auth[0].AuthID
|
||||
param.Amount = payPrice1
|
||||
_, err := api.WxpayAPI.Transfers(param)
|
||||
if err != nil {
|
||||
return retVal, err
|
||||
return err
|
||||
}
|
||||
}
|
||||
if user2.ParentMobile != "" {
|
||||
user3, err := dao.GetUserByID(db, "mobile", user2.ParentMobile)
|
||||
auth, err := dao.GetUserBindAuthInfo(db, user3.UserID, model.AuthBindTypeAuth, []string{"weixinmini"}, "", "")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if len(auth) == 0 {
|
||||
errMsg += fmt.Sprintf("打款失败!未找到此用户的微信验证方式!订单号:[%v],用户ID:[%v]\n", goods.VendorOrderID, user2.UserID)
|
||||
errMsg += fmt.Sprintf("打款失败!未找到此用户的微信验证方式!订单号:[%v],用户ID:[%v]\n", goods.VendorOrderID, user3.UserID)
|
||||
} else {
|
||||
payPrice1 = int(goods.ActualPayPrice) * user2.DividePercentage / 100
|
||||
receivers += `{"type":"` + wxpayapi.AccountTypeOpen + `","account":"` + auth[0].AuthID + `","amount":` + utils.Int2Str(payPrice1) + `,"description":"每日订单打款分到个人"}`
|
||||
// _, err := api.WxpayAPI.MultiProfitSharing(param)
|
||||
}
|
||||
if user2.ParentMobile != "" {
|
||||
user3, err := dao.GetUserByID(db, "mobile", user2.ParentMobile)
|
||||
auth, err := dao.GetUserBindAuthInfo(db, user3.UserID, model.AuthBindTypeAuth, []string{"weixinmini"}, "", "")
|
||||
payPrice2 = (int(goods.ActualPayPrice) - payPrice1) * user3.DividePercentage / 100
|
||||
param.OpenID = auth[0].AuthID
|
||||
param.Amount = payPrice2
|
||||
_, err := api.WxpayAPI.Transfers(param)
|
||||
if err != nil {
|
||||
return retVal, err
|
||||
}
|
||||
if len(auth) == 0 {
|
||||
errMsg += fmt.Sprintf("打款失败!未找到此用户的微信验证方式!订单号:[%v],用户ID:[%v]\n", goods.VendorOrderID, user3.UserID)
|
||||
} else {
|
||||
payPrice2 = (int(goods.ActualPayPrice) - payPrice1) * user3.DividePercentage / 100
|
||||
receivers += `,{"type":"` + wxpayapi.AccountTypeOpen + `","account":"` + auth[0].AuthID + `","amount":` + utils.Int2Str(payPrice2) + `,"description":"每日订单打款分到个人"}`
|
||||
// _, err := api.WxpayAPI.MultiProfitSharing(param)
|
||||
return err
|
||||
}
|
||||
}
|
||||
receivers += "]"
|
||||
param.Receivers = wxpayapi.CData(receivers)
|
||||
_, err = api.WxpayAPI.MultiProfitSharing(param)
|
||||
if err != nil {
|
||||
return retVal, err
|
||||
}
|
||||
return retVal, errors.New(errMsg)
|
||||
}, result)
|
||||
tasksch.HandleTask(task, nil, true).Run()
|
||||
if isAsync {
|
||||
hint = task.GetID()
|
||||
} else {
|
||||
_, err = task.GetResult(0)
|
||||
user, _ := dao.GetUserByID(dao.GetDB(), "mobile", "18160030913")
|
||||
noticeMsg := err.Error()
|
||||
if user != nil && err != nil {
|
||||
ddmsg.SendUserMessage(dingdingapi.MsgTyeText, user.UserID, "每日打款错误", noticeMsg)
|
||||
}
|
||||
hint = "1"
|
||||
}
|
||||
return hint, err
|
||||
user, _ := dao.GetUserByID(dao.GetDB(), "mobile", "18160030913")
|
||||
noticeMsg := err.Error()
|
||||
if user != nil && err != nil {
|
||||
ddmsg.SendUserMessage(dingdingapi.MsgTyeText, user.UserID, "每日打款错误", noticeMsg)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user