Accept Merge Request #183: (su -> mark)
Merge Request: 根据京东建议售价修改京西价 Created By: @苏尹岚 Accepted By: @苏尹岚 URL: https://rosydev.coding.net/p/jx-callback/d/jx-callback/git/merge/183
This commit is contained in:
@@ -2,11 +2,20 @@ package localjx
|
||||
|
||||
import (
|
||||
"crypto/md5"
|
||||
"errors"
|
||||
"fmt"
|
||||
"math"
|
||||
"sort"
|
||||
"time"
|
||||
|
||||
"git.rosy.net.cn/baseapi/platformapi/wxpayapi"
|
||||
|
||||
"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"
|
||||
"git.rosy.net.cn/baseapi/utils/errlist"
|
||||
"git.rosy.net.cn/jx-callback/business/jxstore/cms"
|
||||
@@ -615,3 +624,96 @@ func GetOrderPay(ctx *jxcontext.Context, vendorOrderID string) (payList []*model
|
||||
payList, err = dao.GetOrderPayList(db, vendorOrderID, jxutils.GetPossibleVendorIDFromVendorOrderID(vendorOrderID))
|
||||
return payList, err
|
||||
}
|
||||
|
||||
func PayForPopluarMan(ctx *jxcontext.Context, transactionID, vendorOrderID, userID string) (err error) {
|
||||
db := dao.GetDB()
|
||||
user, err := dao.GetUserByID(db, "user_id", userID)
|
||||
if user == nil {
|
||||
return fmt.Errorf("未找到此用户!用户ID:[%v]\n", userID)
|
||||
}
|
||||
auth, err := dao.GetUserBindAuthInfo(db, userID, model.AuthBindTypeAuth, []string{"weixinmini"}, "", "")
|
||||
if len(auth) == 0 {
|
||||
return fmt.Errorf("未找到此用户的微信验证方式!用户ID:[%v]\n", userID)
|
||||
}
|
||||
goods, err := dao.QueryOrders(db, vendorOrderID, 0, []int{model.VendorIDJX}, 0, utils.ZeroTimeValue, utils.ZeroTimeValue)
|
||||
if len(goods) == 0 {
|
||||
return fmt.Errorf("未找到此订单!订单ID:[%v]\n", vendorOrderID)
|
||||
}
|
||||
param := &wxpayapi.MultiProfitSharingParam{
|
||||
TransactionID: transactionID,
|
||||
OutOrderNo: vendorOrderID,
|
||||
}
|
||||
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)
|
||||
return err
|
||||
}
|
||||
|
||||
//自动打款给市场推广人
|
||||
func AutoPayForPopluarMan(ctx *jxcontext.Context, isAsync, isContinueWhenError bool) (hint string, 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))
|
||||
fmt.Println(result)
|
||||
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,
|
||||
}
|
||||
)
|
||||
user, err := dao.GetUserByID(db, "user_id", goods.UserID)
|
||||
if user.ParentMobile == "" {
|
||||
return retVal, err
|
||||
}
|
||||
user2, err := dao.GetUserByID(db, "mobile", user.ParentMobile)
|
||||
auth, err := dao.GetUserBindAuthInfo(db, user2.UserID, model.AuthBindTypeAuth, []string{"weixinmini"}, "", "")
|
||||
if err != nil {
|
||||
return retVal, err
|
||||
}
|
||||
if len(auth) == 0 {
|
||||
errMsg += fmt.Sprintf("打款失败!未找到此用户的微信验证方式!订单号:[%v],用户ID:[%v]\n", goods.VendorOrderID, user2.UserID)
|
||||
} else {
|
||||
param.Receivers = wxpayapi.CData(`[{"type":"` + wxpayapi.AccountTypeOpen + `","account":"` + auth[0].AuthID + `","amount":` + utils.Int2Str(int(goods.ActualPayPrice)*user2.DividePercentage/100) + `,"description":"每日订单打款分到个人"}]`)
|
||||
_, err := api.WxpayAPI.MultiProfitSharing(param)
|
||||
if err != nil {
|
||||
return retVal, 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 retVal, err
|
||||
}
|
||||
if len(auth) == 0 {
|
||||
errMsg += fmt.Sprintf("打款失败!未找到此用户的微信验证方式!订单号:[%v],用户ID:[%v]\n", goods.VendorOrderID, user3.UserID)
|
||||
} else {
|
||||
param.Receivers = wxpayapi.CData(`[{"type":"` + wxpayapi.AccountTypeOpen + `","account":"` + auth[0].AuthID + `","amount":` + utils.Int2Str(int(goods.ActualPayPrice)*user3.DividePercentage/100) + `,"description":"每日订单打款分到个人"}]`)
|
||||
_, 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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user