Accept Merge Request #185: (su -> mark)
Merge Request: 分账修改 Created By: @苏尹岚 Accepted By: @苏尹岚 URL: https://rosydev.coding.net/p/jx-callback/d/jx-callback/git/merge/185
This commit is contained in:
@@ -1443,3 +1443,58 @@ func DeleteSkuNameExPrefixOverdue(db *dao.DaoDB) (err error) {
|
|||||||
_, err = dao.DeleteSkuNameExPrefixOverdue(db)
|
_, err = dao.DeleteSkuNameExPrefixOverdue(db)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func SumExianDaDepot(ctx *jxcontext.Context) (err error) {
|
||||||
|
db := dao.GetDB()
|
||||||
|
result, err := api.EbaiAPI.GetExianDaSkuDepot()
|
||||||
|
for _, v := range result {
|
||||||
|
skus, err := api.EbaiAPI.GetExianDaSku(utils.Str2Int64(v.ElemeGoodsID))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
dao.Begin(db)
|
||||||
|
defer func() {
|
||||||
|
if r := recover(); r != nil {
|
||||||
|
dao.Rollback(db)
|
||||||
|
panic(r)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
prefix, _, _, specUnit, unit, specQuality := jxutils.SplitSkuName(v.GoodsName)
|
||||||
|
skuName := &model.SkuName{
|
||||||
|
Prefix: prefix,
|
||||||
|
Name: v.GoodsName,
|
||||||
|
CategoryID: skus.CategoryIDThird,
|
||||||
|
IsGlobal: 1,
|
||||||
|
Unit: unit,
|
||||||
|
SpecQuality: specQuality,
|
||||||
|
SpecUnit: specUnit,
|
||||||
|
Price: 100,
|
||||||
|
Img: v.ImageURL,
|
||||||
|
Upc: &v.UpcID,
|
||||||
|
Status: model.SkuStatusNormal,
|
||||||
|
}
|
||||||
|
dao.WrapAddIDCULDEntity(skuName, ctx.GetUserName())
|
||||||
|
err = dao.CreateEntity(db, skuName)
|
||||||
|
if err != nil {
|
||||||
|
dao.Rollback(db)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
sku := &model.Sku{
|
||||||
|
NameID: skuName.ID,
|
||||||
|
SpecQuality: specQuality,
|
||||||
|
SpecUnit: specUnit,
|
||||||
|
Weight: int(utils.Str2Int64(skus.Weight)),
|
||||||
|
Status: model.SkuStatusNormal,
|
||||||
|
ExdSkuID: v.ElemeGoodsID,
|
||||||
|
ExdCategoryThirdID: skus.CategoryIDThird,
|
||||||
|
}
|
||||||
|
dao.WrapAddIDCULDEntity(sku, ctx.GetUserName())
|
||||||
|
err = dao.CreateEntity(db, sku)
|
||||||
|
if err != nil {
|
||||||
|
dao.Rollback(db)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
dao.Commit(db)
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|||||||
@@ -1204,7 +1204,9 @@ func getSkuSaleStatus(inSkuBind *StoreSkuBindSkuInfo, skuNameBindInfo *StoreSkuB
|
|||||||
}
|
}
|
||||||
|
|
||||||
func AddEventDetail(db *dao.DaoDB, ctx *jxcontext.Context, operateType, thingID, thingType, storeID int, beforeData, afterData string) (err error) {
|
func AddEventDetail(db *dao.DaoDB, ctx *jxcontext.Context, operateType, thingID, thingType, storeID int, beforeData, afterData string) (err error) {
|
||||||
if ctx.GetUserName() == "jxadmin" {
|
url := ctx.GetRequest().URL.Path
|
||||||
|
apiFunction := url[strings.LastIndex(url, "/")+1 : len(url)]
|
||||||
|
if ctx.GetUserName() == "jxadmin" && !strings.Contains(apiFunction, "AutoPayForPopluarMan") {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
operateEventDetail := &model.OperateEventDetail{
|
operateEventDetail := &model.OperateEventDetail{
|
||||||
@@ -3539,7 +3541,7 @@ func SendSeckillSkusCountMsg(ctx *jxcontext.Context, vendorIDs []int, isAsync, i
|
|||||||
return hint, err
|
return hint, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func RefreshJxPriceByVendor(ctx *jxcontext.Context, jdStoreSkus []*JdStoreSkus, isAsync, isContinueWhenError bool) (hint string, err error) {
|
func RefreshJxPriceByVendor(ctx *jxcontext.Context, jdStoreSkus []*JdStoreSkus, vendorID int, isAsync, isContinueWhenError bool) (hint string, err error) {
|
||||||
var (
|
var (
|
||||||
db = dao.GetDB()
|
db = dao.GetDB()
|
||||||
jdMap = make(map[int][]*JdStoreSkus)
|
jdMap = make(map[int][]*JdStoreSkus)
|
||||||
@@ -3549,6 +3551,7 @@ func RefreshJxPriceByVendor(ctx *jxcontext.Context, jdStoreSkus []*JdStoreSkus,
|
|||||||
taskSeqFunc := func(task *tasksch.SeqTask, step int, params ...interface{}) (result interface{}, err error) {
|
taskSeqFunc := func(task *tasksch.SeqTask, step int, params ...interface{}) (result interface{}, err error) {
|
||||||
switch step {
|
switch step {
|
||||||
case 0:
|
case 0:
|
||||||
|
if vendorID == model.VendorIDJD {
|
||||||
for _, v := range jdStoreSkus {
|
for _, v := range jdStoreSkus {
|
||||||
var (
|
var (
|
||||||
pricePercentagePack []*model.PricePercentageItem
|
pricePercentagePack []*model.PricePercentageItem
|
||||||
@@ -3575,7 +3578,7 @@ func RefreshJxPriceByVendor(ctx *jxcontext.Context, jdStoreSkus []*JdStoreSkus,
|
|||||||
} else {
|
} else {
|
||||||
return result, fmt.Errorf("没有找到该京东skuID对应的京西skuID!,京东skuID :[%v]", v.JdSkuID)
|
return result, fmt.Errorf("没有找到该京东skuID对应的京西skuID!,京东skuID :[%v]", v.JdSkuID)
|
||||||
}
|
}
|
||||||
store, err := dao.GetStoreDetailByVendorStoreID(db, utils.Int2Str(v.JdStoreID), model.VendorIDJD)
|
store, err := dao.GetStoreDetailByVendorStoreID(db, utils.Int2Str(v.JdStoreID), vendorID)
|
||||||
if err != nil || store == nil {
|
if err != nil || store == nil {
|
||||||
return result, fmt.Errorf("没有找到该京东门店对应的京西门店!,京东门店ID :[%v]", v.JdStoreID)
|
return result, fmt.Errorf("没有找到该京东门店对应的京西门店!,京东门店ID :[%v]", v.JdStoreID)
|
||||||
}
|
}
|
||||||
@@ -3614,6 +3617,49 @@ func RefreshJxPriceByVendor(ctx *jxcontext.Context, jdStoreSkus []*JdStoreSkus,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else if vendorID == model.VendorIDMTWM {
|
||||||
|
for _, v := range jdStoreSkus {
|
||||||
|
var (
|
||||||
|
pricePercentagePack []*model.PricePercentageItem
|
||||||
|
)
|
||||||
|
skus, _ := dao.GetSkus(db, []int{v.JdSkuID}, nil, nil, nil)
|
||||||
|
store, _ := dao.GetStoreDetail(db, v.JdStoreID, vendorID)
|
||||||
|
err = jxutils.Strings2Objs(store.PricePercentagePackStr, &pricePercentagePack)
|
||||||
|
jxPrice := jxutils.CaculateJxPriceByPricePack(pricePercentagePack, 0, v.Price)
|
||||||
|
jdMap[v.JdStoreID] = append(jdMap[v.JdStoreID], &JdStoreSkus{
|
||||||
|
JdSkuID: skus[0].NameID,
|
||||||
|
Price: jxPrice,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
for k, v := range jdMap {
|
||||||
|
var skuNameMap = make(map[int]int)
|
||||||
|
for _, vv := range v {
|
||||||
|
if skuNameMap[vv.JdSkuID] != 0 {
|
||||||
|
if skuNameMap[vv.JdSkuID] > vv.Price {
|
||||||
|
skuNameMap[vv.JdSkuID] = vv.Price
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
skuNameMap[vv.JdSkuID] = vv.Price
|
||||||
|
}
|
||||||
|
}
|
||||||
|
jxMap[k] = skuNameMap
|
||||||
|
}
|
||||||
|
for k, v := range jxMap {
|
||||||
|
for kk, vv := range v {
|
||||||
|
result, err := dao.GetStoreSkuBindByNameID(db, k, kk, model.SkuStatusNormal)
|
||||||
|
if len(result) > 0 && err == nil {
|
||||||
|
if result[0].UnitPrice > vv {
|
||||||
|
storeSkuBindInfo := &StoreSkuBindInfo{
|
||||||
|
StoreID: k,
|
||||||
|
NameID: kk,
|
||||||
|
UnitPrice: vv,
|
||||||
|
}
|
||||||
|
param = append(param, storeSkuBindInfo)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
case 1:
|
case 1:
|
||||||
_, err = UpdateStoresSkusByBind(ctx, nil, param, isAsync, isContinueWhenError)
|
_, err = UpdateStoresSkusByBind(ctx, nil, param, isAsync, isContinueWhenError)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -414,7 +414,7 @@ func syncStoreSkuNew(ctx *jxcontext.Context, parentTask tasksch.ITask, causeFlag
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if sku.MergedStatus == model.SkuStatusNormal {
|
if sku.MergedStatus == model.SkuStatusNormal {
|
||||||
if dao.IsVendorThingIDEmpty(sku.VendorCatID) {
|
if dao.IsVendorThingIDEmpty(sku.VendorCatID) && !strings.Contains(sku.StoreName, model.ExdStoreName) {
|
||||||
globals.SugarLogger.Warnf("syncStoreSkuNew 创建门店:%d商品:%d,但没有平台分类ID", storeID, sku.SkuID)
|
globals.SugarLogger.Warnf("syncStoreSkuNew 创建门店:%d商品:%d,但没有平台分类ID", storeID, sku.SkuID)
|
||||||
} else {
|
} else {
|
||||||
createList = append(createList, sku)
|
createList = append(createList, sku)
|
||||||
|
|||||||
@@ -8,8 +8,6 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"git.rosy.net.cn/baseapi/platformapi/wxpayapi"
|
|
||||||
|
|
||||||
"git.rosy.net.cn/jx-callback/business/partner/purchase/jd"
|
"git.rosy.net.cn/jx-callback/business/partner/purchase/jd"
|
||||||
|
|
||||||
"git.rosy.net.cn/jx-callback/globals/api/apimanager"
|
"git.rosy.net.cn/jx-callback/globals/api/apimanager"
|
||||||
@@ -380,6 +378,7 @@ func CreateUser(user *model.User, creatorName string) (err error) {
|
|||||||
dao.WrapAddIDCULDEntity(user, creatorName)
|
dao.WrapAddIDCULDEntity(user, creatorName)
|
||||||
user.UserID = utils.GetUUID()
|
user.UserID = utils.GetUUID()
|
||||||
user.Status = model.UserStatusNormal
|
user.Status = model.UserStatusNormal
|
||||||
|
user.DividePercentage = 5
|
||||||
return dao.CreateEntity(nil, user)
|
return dao.CreateEntity(nil, user)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -993,61 +992,61 @@ func UpdateUserWxNoAndPercent(user *model.User, isReceiver bool) (num int64, err
|
|||||||
dao.Rollback(db)
|
dao.Rollback(db)
|
||||||
}
|
}
|
||||||
if isReceiver {
|
if isReceiver {
|
||||||
param := &wxpayapi.ProfitSharingReceiverParam{
|
// param := &wxpayapi.ProfitSharingReceiverParam{
|
||||||
Receiver: wxpayapi.CData(`{
|
// Receiver: wxpayapi.CData(`{
|
||||||
"type":"` + wxpayapi.AccountTypeOpen + `",
|
// "type":"` + wxpayapi.AccountTypeOpen + `",
|
||||||
"account":"` + auth[0].AuthID + `",
|
// "account":"` + auth[0].AuthID + `",
|
||||||
"relation_type":" ` + wxpayapi.Relation + `"
|
// "relation_type":" ` + wxpayapi.Relation + `"
|
||||||
}`),
|
// }`),
|
||||||
}
|
// }
|
||||||
_, err := api.WxpayAPI.AddProfitSharingReceiver(param)
|
// _, err := api.WxpayAPI.AddProfitSharingReceiver(param)
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
return 0, err
|
// return 0, err
|
||||||
} else {
|
// } else {
|
||||||
user2.IsReceiver = 1
|
// user2.IsReceiver = 1
|
||||||
num3, err := dao.UpdateEntity(db, user2, "IsReceiver")
|
// num3, err := dao.UpdateEntity(db, user2, "IsReceiver")
|
||||||
num += num3
|
// num += num3
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
dao.Rollback(db)
|
// dao.Rollback(db)
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
dao.Commit(db)
|
dao.Commit(db)
|
||||||
return num, err
|
return num, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func DeleteProfitSharingReceiver(ctx *jxcontext.Context, userID string) (err error) {
|
func DeleteProfitSharingReceiver(ctx *jxcontext.Context, userID string) (err error) {
|
||||||
db := dao.GetDB()
|
// db := dao.GetDB()
|
||||||
auth, err := dao.GetUserBindAuthInfo(db, userID, model.AuthBindTypeAuth, []string{"weixinmini"}, "", "")
|
// auth, err := dao.GetUserBindAuthInfo(db, userID, model.AuthBindTypeAuth, []string{"weixinmini"}, "", "")
|
||||||
if len(auth) == 0 {
|
// if len(auth) == 0 {
|
||||||
return fmt.Errorf("未找到此用户的微信验证方式!用户ID:[%v]\n", userID)
|
// return fmt.Errorf("未找到此用户的微信验证方式!用户ID:[%v]\n", userID)
|
||||||
}
|
// }
|
||||||
dao.Begin(db)
|
// dao.Begin(db)
|
||||||
defer func() {
|
// defer func() {
|
||||||
if r := recover(); r != nil || err != nil {
|
// if r := recover(); r != nil || err != nil {
|
||||||
dao.Rollback(db)
|
// dao.Rollback(db)
|
||||||
if r != nil {
|
// if r != nil {
|
||||||
panic(r)
|
// panic(r)
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}()
|
// }()
|
||||||
param := &wxpayapi.ProfitSharingReceiverParam{
|
// param := &wxpayapi.ProfitSharingReceiverParam{
|
||||||
Receiver: wxpayapi.CData(`{
|
// Receiver: wxpayapi.CData(`{
|
||||||
"type":"` + wxpayapi.AccountTypeOpen + `",
|
// "type":"` + wxpayapi.AccountTypeOpen + `",
|
||||||
"account":"` + auth[0].AuthID + `"
|
// "account":"` + auth[0].AuthID + `"
|
||||||
}`),
|
// }`),
|
||||||
}
|
// }
|
||||||
_, err = api.WxpayAPI.DeleteProfitSharingReceiver(param)
|
// _, err = api.WxpayAPI.DeleteProfitSharingReceiver(param)
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
return err
|
// return err
|
||||||
} else {
|
// } else {
|
||||||
user2, err := dao.GetUserByID(db, "user_id", userID)
|
// user2, err := dao.GetUserByID(db, "user_id", userID)
|
||||||
user2.IsReceiver = 0
|
// user2.IsReceiver = 0
|
||||||
_, err = dao.UpdateEntity(db, user2, "IsReceiver")
|
// _, err = dao.UpdateEntity(db, user2, "IsReceiver")
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
dao.Rollback(db)
|
// dao.Rollback(db)
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
dao.Commit(db)
|
// dao.Commit(db)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,8 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"git.rosy.net.cn/jx-callback/business/partner/purchase/jx/localjx"
|
||||||
|
|
||||||
"git.rosy.net.cn/jx-callback/business/jxstore/event"
|
"git.rosy.net.cn/jx-callback/business/jxstore/event"
|
||||||
|
|
||||||
"git.rosy.net.cn/jx-callback/business/jxstore/report"
|
"git.rosy.net.cn/jx-callback/business/jxstore/report"
|
||||||
@@ -91,6 +93,9 @@ var (
|
|||||||
sendSecKillWarnList = []string{
|
sendSecKillWarnList = []string{
|
||||||
"9:00:00",
|
"9:00:00",
|
||||||
}
|
}
|
||||||
|
autoPayForPopluarManList = []string{
|
||||||
|
"9:30:00",
|
||||||
|
}
|
||||||
|
|
||||||
autoSaleStoreSkuTimeList = []string{
|
autoSaleStoreSkuTimeList = []string{
|
||||||
cms.AutoSaleAtStr,
|
cms.AutoSaleAtStr,
|
||||||
@@ -170,6 +175,9 @@ func Init() {
|
|||||||
ScheduleTimerFunc("每日报警心跳", func() {
|
ScheduleTimerFunc("每日报警心跳", func() {
|
||||||
globals.SugarLogger.Warnf("每日报警心跳,这不是报警。启动时间:%s", cms.GetServiceInfo(jxcontext.AdminCtx)["startupTime"])
|
globals.SugarLogger.Warnf("每日报警心跳,这不是报警。启动时间:%s", cms.GetServiceInfo(jxcontext.AdminCtx)["startupTime"])
|
||||||
}, dailyHeartbeat)
|
}, dailyHeartbeat)
|
||||||
|
ScheduleTimerFunc("AutoPayForPopluarMan", func() {
|
||||||
|
localjx.AutoPayForPopluarMan(jxcontext.AdminCtx)
|
||||||
|
}, autoPayForPopluarManList)
|
||||||
}
|
}
|
||||||
ScheduleTimerFunc("AutoSaleStoreSku", func() {
|
ScheduleTimerFunc("AutoSaleStoreSku", func() {
|
||||||
cms.AutoSaleStoreSku(jxcontext.AdminCtx, nil, false)
|
cms.AutoSaleStoreSku(jxcontext.AdminCtx, nil, false)
|
||||||
|
|||||||
@@ -260,6 +260,9 @@ func BeginSavePriceRefer(ctx *jxcontext.Context, cityCodes, skuIDs []int, isAsyn
|
|||||||
case 3:
|
case 3:
|
||||||
priceReferSnapshotList, err = dao.GetPriceReferSnapshotNoPage(db, []int{0}, nil, nil, snapshotAt)
|
priceReferSnapshotList, err = dao.GetPriceReferSnapshotNoPage(db, []int{0}, nil, nil, snapshotAt)
|
||||||
taskFunc := func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
taskFunc := func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||||
|
v := batchItemList[0].(*model.PriceReferSnapshot)
|
||||||
|
for _, appOrg := range apimanager.CurAPIManager.GetAppOrgCodeList(model.VendorIDJD) {
|
||||||
|
directPrice, _ := jd.GetAPI(appOrg).GetJdSkuDirectPrice(v.SkuID)
|
||||||
dao.Begin(db)
|
dao.Begin(db)
|
||||||
defer func() {
|
defer func() {
|
||||||
if r := recover(); r != nil || err != nil {
|
if r := recover(); r != nil || err != nil {
|
||||||
@@ -269,17 +272,14 @@ func BeginSavePriceRefer(ctx *jxcontext.Context, cityCodes, skuIDs []int, isAsyn
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
v := batchItemList[0].(*model.PriceReferSnapshot)
|
|
||||||
for _, appOrg := range apimanager.CurAPIManager.GetAppOrgCodeList(model.VendorIDJD) {
|
|
||||||
directPrice, _ := jd.GetAPI(appOrg).GetJdSkuDirectPrice(v.SkuID)
|
|
||||||
if directPrice == 0 {
|
if directPrice == 0 {
|
||||||
continue
|
continue
|
||||||
} else {
|
} else {
|
||||||
v.JdDirectPrice = int(directPrice)
|
v.JdDirectPrice = int(directPrice)
|
||||||
dao.UpdateEntity(db, v, "JdDirectPrice")
|
dao.UpdateEntity(db, v, "JdDirectPrice")
|
||||||
}
|
}
|
||||||
}
|
|
||||||
dao.Commit(db)
|
dao.Commit(db)
|
||||||
|
}
|
||||||
return retVal, err
|
return retVal, err
|
||||||
}
|
}
|
||||||
taskParallel := tasksch.NewParallelTask("获取并更新京东指导价格", tasksch.NewParallelConfig(), ctx, taskFunc, priceReferSnapshotList)
|
taskParallel := tasksch.NewParallelTask("获取并更新京东指导价格", tasksch.NewParallelConfig(), ctx, taskFunc, priceReferSnapshotList)
|
||||||
|
|||||||
@@ -64,8 +64,8 @@ type StoreSkuSyncInfo struct {
|
|||||||
|
|
||||||
model.Sku
|
model.Sku
|
||||||
ExdSkuID string `orm:"column(exd_sku_id)"`
|
ExdSkuID string `orm:"column(exd_sku_id)"`
|
||||||
ExdSkuName string
|
ExdCategoryThirdID int `orm:"column(exd_category_third_id)"`
|
||||||
ExdUpc int
|
StoreName string
|
||||||
|
|
||||||
// sku_name
|
// sku_name
|
||||||
Prefix string
|
Prefix string
|
||||||
@@ -388,7 +388,8 @@ func GetStoreSkus2(db *DaoDB, vendorID, storeID int, skuIDs []int, mustDirty boo
|
|||||||
IF(t11.%s <> '', t11.%s, t3.img) img,
|
IF(t11.%s <> '', t11.%s, t3.img) img,
|
||||||
IF(t12.%s <> '', t12.%s, t3.img2) img2,
|
IF(t12.%s <> '', t12.%s, t3.img2) img2,
|
||||||
t13.%s desc_img,
|
t13.%s desc_img,
|
||||||
t4.%s_category_id vendor_vendor_cat_id`
|
t4.%s_category_id vendor_vendor_cat_id,
|
||||||
|
ts.name store_name`
|
||||||
fmtParams := []interface{}{
|
fmtParams := []interface{}{
|
||||||
skuVendorIDField, fieldPrefix, fieldPrefix, fieldPrefix,
|
skuVendorIDField, fieldPrefix, fieldPrefix, fieldPrefix,
|
||||||
GetDataResFieldName(vendorID), GetDataResFieldName(vendorID),
|
GetDataResFieldName(vendorID), GetDataResFieldName(vendorID),
|
||||||
@@ -413,6 +414,7 @@ func GetStoreSkus2(db *DaoDB, vendorID, storeID int, skuIDs []int, mustDirty boo
|
|||||||
sql += `
|
sql += `
|
||||||
FROM store_sku_bind t1
|
FROM store_sku_bind t1
|
||||||
JOIN store_map t14 ON t14.store_id = t1.store_id AND t14.vendor_id = ? AND t14.deleted_at = ?
|
JOIN store_map t14 ON t14.store_id = t1.store_id AND t14.vendor_id = ? AND t14.deleted_at = ?
|
||||||
|
LEFT JOIN store ts ON ts.id = t1.store_id AND ts.deleted_at = ?
|
||||||
LEFT JOIN sku t2 ON t1.sku_id = t2.id AND t2.deleted_at = ?/* AND t2.status = ?*/
|
LEFT JOIN sku t2 ON t1.sku_id = t2.id AND t2.deleted_at = ?/* AND t2.status = ?*/
|
||||||
LEFT JOIN sku_name t3 ON t2.name_id = t3.id AND t3.deleted_at = ?/* AND t3.status = ?*/
|
LEFT JOIN sku_name t3 ON t2.name_id = t3.id AND t3.deleted_at = ?/* AND t3.status = ?*/
|
||||||
LEFT JOIN sku_category t4 ON t3.category_id = t4.id AND t4.deleted_at = ?
|
LEFT JOIN sku_category t4 ON t3.category_id = t4.id AND t4.deleted_at = ?
|
||||||
@@ -425,6 +427,7 @@ func GetStoreSkus2(db *DaoDB, vendorID, storeID int, skuIDs []int, mustDirty boo
|
|||||||
utils.DefaultTimeValue, // model.SkuStatusNormal,
|
utils.DefaultTimeValue, // model.SkuStatusNormal,
|
||||||
utils.DefaultTimeValue, // model.SkuStatusNormal,
|
utils.DefaultTimeValue, // model.SkuStatusNormal,
|
||||||
utils.DefaultTimeValue,
|
utils.DefaultTimeValue,
|
||||||
|
utils.DefaultTimeValue,
|
||||||
}
|
}
|
||||||
if globals.IsStoreSkuAct {
|
if globals.IsStoreSkuAct {
|
||||||
sql += `
|
sql += `
|
||||||
|
|||||||
@@ -150,6 +150,9 @@ type SkuCategory struct {
|
|||||||
// WscCategoryID int64 `orm:"column(wsc_category_id)" json:"wscCategoryID"` // 这个是指对应的美团外卖商品类别
|
// WscCategoryID int64 `orm:"column(wsc_category_id)" json:"wscCategoryID"` // 这个是指对应的美团外卖商品类别
|
||||||
Status int8 `orm:"default(1)" json:"status"` //分类状态,0表示禁用,1表示启用
|
Status int8 `orm:"default(1)" json:"status"` //分类状态,0表示禁用,1表示启用
|
||||||
Img string `orm:"size(512)" json:"img"` //分类图片
|
Img string `orm:"size(512)" json:"img"` //分类图片
|
||||||
|
|
||||||
|
ExdName string `json:"exdName"` //饿鲜达对应分类名
|
||||||
|
ExdSeq int `json:"exdSeq"`
|
||||||
// JdID int64 `orm:"column(jd_id);index" json:"jdID"` // 这个是指商家自己的商品类别在京东平台上的ID
|
// JdID int64 `orm:"column(jd_id);index" json:"jdID"` // 这个是指商家自己的商品类别在京东平台上的ID
|
||||||
// JdSyncStatus int8 `orm:"default(2)" json:"jdSyncStatus"`
|
// JdSyncStatus int8 `orm:"default(2)" json:"jdSyncStatus"`
|
||||||
}
|
}
|
||||||
@@ -223,6 +226,9 @@ type Sku struct {
|
|||||||
Weight int `json:"weight"` // 重量/质量,单位为克,当相应的SkuName的SpecUnit为g或kg时,必须等于SpecQuality
|
Weight int `json:"weight"` // 重量/质量,单位为克,当相应的SkuName的SpecUnit为g或kg时,必须等于SpecQuality
|
||||||
Status int `json:"status"`
|
Status int `json:"status"`
|
||||||
Seq int `json:"seq"`
|
Seq int `json:"seq"`
|
||||||
|
|
||||||
|
ExdSkuID string `orm:"column(exd_sku_id)" json:"exdSkuID"`
|
||||||
|
ExdCategoryThirdID int `orm:"column(exd_category_third_id)" json:"exdCategoryThirdID"`
|
||||||
// JdID int64 `orm:"column(jd_id);null;index" json:"jdID"`
|
// JdID int64 `orm:"column(jd_id);null;index" json:"jdID"`
|
||||||
// JdSyncStatus int8 `orm:"default(2)" json:"jdSyncStatus"`
|
// JdSyncStatus int8 `orm:"default(2)" json:"jdSyncStatus"`
|
||||||
|
|
||||||
|
|||||||
@@ -55,6 +55,10 @@ const (
|
|||||||
AutoReplyDisabled = 2 // 禁止自动回复
|
AutoReplyDisabled = 2 // 禁止自动回复
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
ExdStoreName = "饿鲜达"
|
||||||
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
StoreStatusName = map[int]string{
|
StoreStatusName = map[int]string{
|
||||||
StoreStatusDisabled: "禁用",
|
StoreStatusDisabled: "禁用",
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ const (
|
|||||||
ThingTypeSkuName = 2
|
ThingTypeSkuName = 2
|
||||||
ThingTypeSku = 3
|
ThingTypeSku = 3
|
||||||
ThingTypeStore = 4
|
ThingTypeStore = 4
|
||||||
|
ThingTypeUser = 5
|
||||||
)
|
)
|
||||||
|
|
||||||
type ThingMap struct {
|
type ThingMap struct {
|
||||||
|
|||||||
@@ -52,7 +52,9 @@ type User struct {
|
|||||||
|
|
||||||
ParentMobile string `orm:"size(32)" json:"parentMobile"`
|
ParentMobile string `orm:"size(32)" json:"parentMobile"`
|
||||||
DividePercentage int `json:"dividePercentage"`
|
DividePercentage int `json:"dividePercentage"`
|
||||||
IsReceiver int `json:"isReceiver"`
|
Profit int `json:"profit"`
|
||||||
|
ProfitSum int `json:"profitSum"`
|
||||||
|
Arrears int `json:"arrears"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (*User) TableUnique() [][]string {
|
func (*User) TableUnique() [][]string {
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ import (
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
defVendorCatID = 201222934 // 其他蔬菜
|
defVendorCatID = 201222934 // 其他蔬菜
|
||||||
exdStoreName = "饿鲜达"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -120,13 +119,17 @@ func (p *PurchaseHandler) IsErrSkuNotExist(err error) (isNotExist bool) {
|
|||||||
func (p *PurchaseHandler) updateStoreSkus(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeSkuList []*dao.StoreSkuSyncInfo, isNeedMapCat bool) (failedList []*partner.StoreSkuInfoWithErr, err error) {
|
func (p *PurchaseHandler) updateStoreSkus(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeSkuList []*dao.StoreSkuSyncInfo, isNeedMapCat bool) (failedList []*partner.StoreSkuInfoWithErr, err error) {
|
||||||
storeSku := storeSkuList[0]
|
storeSku := storeSkuList[0]
|
||||||
strStoreID := utils.Int2Str(storeID)
|
strStoreID := utils.Int2Str(storeID)
|
||||||
params := genSkuParamsFromStoreSkuInfo2(storeSku, false, false)
|
isExd := false
|
||||||
|
if strings.Contains(storeSku.StoreName, model.ExdStoreName) {
|
||||||
|
isExd = true
|
||||||
|
}
|
||||||
|
params := genSkuParamsFromStoreSkuInfo2(storeSku, false, isExd)
|
||||||
if globals.EnableEbaiStoreWrite {
|
if globals.EnableEbaiStoreWrite {
|
||||||
_, err = api.EbaiAPI.SkuUpdate(ctx.GetTrackInfo(), strStoreID, utils.Str2Int64(storeSku.VendorSkuID), params)
|
_, err = api.EbaiAPI.SkuUpdate(ctx.GetTrackInfo(), strStoreID, utils.Str2Int64(storeSku.VendorSkuID), params)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
failedList = putils.GetErrMsg2FailedSingleList(storeSkuList, err, storeID, model.VendorChineseNames[model.VendorIDEBAI], "更新商品基础信息")
|
failedList = putils.GetErrMsg2FailedSingleList(storeSkuList, err, storeID, model.VendorChineseNames[model.VendorIDEBAI], "更新商品基础信息")
|
||||||
}
|
}
|
||||||
if isNeedMapCat {
|
if isNeedMapCat && !isExd {
|
||||||
utils.CallFuncAsync(func() {
|
utils.CallFuncAsync(func() {
|
||||||
api.EbaiAPI.SkuShopCategoryMap(strStoreID, utils.Str2Int64(storeSku.VendorSkuID), "", utils.Str2Int64(storeSku.VendorCatID), genSkuCatRank(storeSku))
|
api.EbaiAPI.SkuShopCategoryMap(strStoreID, utils.Str2Int64(storeSku.VendorSkuID), "", utils.Str2Int64(storeSku.VendorCatID), genSkuCatRank(storeSku))
|
||||||
})
|
})
|
||||||
@@ -148,10 +151,13 @@ func (p *PurchaseHandler) CreateStoreSkus(ctx *jxcontext.Context, storeID int, v
|
|||||||
isExd bool = false
|
isExd bool = false
|
||||||
customSkuID int64
|
customSkuID int64
|
||||||
)
|
)
|
||||||
store, _ := dao.GetStoreDetail(dao.GetDB(), storeSku.StoreID, model.VendorIDEBAI)
|
if strings.Contains(storeSku.StoreName, model.ExdStoreName) {
|
||||||
if strings.Contains(store.Name, exdStoreName) {
|
|
||||||
isExd = true
|
isExd = true
|
||||||
|
if storeSku.ExdSkuID == "" {
|
||||||
|
customSkuID = 0
|
||||||
|
} else {
|
||||||
customSkuID = utils.Str2Int64(storeSku.ExdSkuID)
|
customSkuID = utils.Str2Int64(storeSku.ExdSkuID)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
isExd = false
|
isExd = false
|
||||||
customSkuID = int64(storeSku.SkuID)
|
customSkuID = int64(storeSku.SkuID)
|
||||||
@@ -159,7 +165,7 @@ func (p *PurchaseHandler) CreateStoreSkus(ctx *jxcontext.Context, storeID int, v
|
|||||||
params := genSkuParamsFromStoreSkuInfo2(storeSku, true, isExd)
|
params := genSkuParamsFromStoreSkuInfo2(storeSku, true, isExd)
|
||||||
if globals.EnableEbaiStoreWrite {
|
if globals.EnableEbaiStoreWrite {
|
||||||
strStoreID := utils.Int2Str(storeID)
|
strStoreID := utils.Int2Str(storeID)
|
||||||
if vendorSkuID, err = api.EbaiAPI.SkuCreate(ctx.GetTrackInfo(), strStoreID, customSkuID, params); err == nil {
|
if vendorSkuID, err = api.EbaiAPI.SkuCreate(ctx.GetTrackInfo(), strStoreID, customSkuID, params); err == nil && !isExd {
|
||||||
utils.AfterFuncWithRecover(5*time.Second, func() {
|
utils.AfterFuncWithRecover(5*time.Second, func() {
|
||||||
api.EbaiAPI.SkuShopCategoryMap(strStoreID, vendorSkuID, "", utils.Str2Int64(storeSku.VendorCatID), genSkuCatRank(storeSku))
|
api.EbaiAPI.SkuShopCategoryMap(strStoreID, vendorSkuID, "", utils.Str2Int64(storeSku.VendorCatID), genSkuCatRank(storeSku))
|
||||||
// 饿百平台有BUG,会导致新建一个之前删除的商品时,信息不会及时更新,强制刷新一下
|
// 饿百平台有BUG,会导致新建一个之前删除的商品时,信息不会及时更新,强制刷新一下
|
||||||
@@ -302,16 +308,18 @@ func genSkuParamsFromStoreSkuInfo2(storeSku *dao.StoreSkuSyncInfo, isCreate, isE
|
|||||||
"left_num": model.MaxStoreSkuStockQty,
|
"left_num": model.MaxStoreSkuStockQty,
|
||||||
// "category_id": utils.Str2Int64(storeSku.VendorCatID),
|
// "category_id": utils.Str2Int64(storeSku.VendorCatID),
|
||||||
"predict_cat": 0, // 不使用推荐类目
|
"predict_cat": 0, // 不使用推荐类目
|
||||||
"cat3_id": getEbaiCat(storeSku.VendorVendorCatID),
|
// "cat3_id": getEbaiCat(storeSku.VendorVendorCatID),
|
||||||
"weight": storeSku.Weight,
|
"weight": storeSku.Weight,
|
||||||
"photos": photos,
|
"photos": photos,
|
||||||
}
|
}
|
||||||
if !isExd {
|
if !isExd {
|
||||||
params["category_id"] = utils.Str2Int64(storeSku.VendorCatID)
|
params["category_id"] = utils.Str2Int64(storeSku.VendorCatID)
|
||||||
params["name"] = utils.LimitMixedStringLen(storeSku.SkuName, ebaiapi.MaxSkuNameByteCount)
|
params["name"] = utils.LimitMixedStringLen(storeSku.SkuName, ebaiapi.MaxSkuNameByteCount)
|
||||||
|
params["cat3_id"] = getEbaiCat(storeSku.VendorVendorCatID)
|
||||||
} else {
|
} else {
|
||||||
params["upc"] = storeSku.ExdUpc
|
params["upc"] = storeSku.Upc
|
||||||
params["name"] = storeSku.ExdSkuName
|
params["name"] = storeSku.Name
|
||||||
|
params["cat3_id"] = storeSku.ExdCategoryThirdID
|
||||||
}
|
}
|
||||||
if storeSku.DescImg != "" {
|
if storeSku.DescImg != "" {
|
||||||
params["rtf"] = storeSku.DescImg
|
params["rtf"] = storeSku.DescImg
|
||||||
|
|||||||
@@ -2,18 +2,18 @@ package localjx
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"crypto/md5"
|
"crypto/md5"
|
||||||
"errors"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"math"
|
"math"
|
||||||
"sort"
|
"sort"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"git.rosy.net.cn/jx-callback/business/jxstore/event"
|
||||||
|
|
||||||
"git.rosy.net.cn/baseapi/platformapi/wxpayapi"
|
"git.rosy.net.cn/baseapi/platformapi/wxpayapi"
|
||||||
|
|
||||||
"git.rosy.net.cn/jx-callback/globals/api"
|
"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/ddmsg"
|
||||||
"git.rosy.net.cn/jx-callback/business/jxutils/tasksch"
|
|
||||||
|
|
||||||
"git.rosy.net.cn/baseapi/platformapi/dingdingapi"
|
"git.rosy.net.cn/baseapi/platformapi/dingdingapi"
|
||||||
"git.rosy.net.cn/baseapi/utils"
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
@@ -564,6 +564,21 @@ func CancelOrder(ctx *jxcontext.Context, order *model.GoodsOrder, reason string)
|
|||||||
if err2 == nil {
|
if err2 == nil {
|
||||||
dao.WrapAddIDCULDEntity(orderPayRefund, ctx.GetUserName())
|
dao.WrapAddIDCULDEntity(orderPayRefund, ctx.GetUserName())
|
||||||
errList.AddErr(dao.CreateEntity(dao.GetDB(), orderPayRefund))
|
errList.AddErr(dao.CreateEntity(dao.GetDB(), orderPayRefund))
|
||||||
|
//退款后,若此订单下单用户有推广人,则需要将分给推广人的金额记录到该推广人的欠款中
|
||||||
|
orders, _ := dao.QueryOrders(db, order.VendorOrderID, 0, []int{model.VendorIDJX}, 0, utils.DefaultTimeValue, utils.DefaultTimeValue)
|
||||||
|
if len(orders) > 0 {
|
||||||
|
user, _ := dao.GetUserByID(db, "user_id", orders[0].UserID)
|
||||||
|
if user.ParentMobile != "" {
|
||||||
|
user2, _ := dao.GetUserByID(db, "moblie", user.ParentMobile)
|
||||||
|
user2.Arrears = user2.Arrears + (orderPay.TotalFee * user2.DividePercentage / 100)
|
||||||
|
dao.UpdateEntity(db, user2, "Arrears")
|
||||||
|
if user2.ParentMobile != "" {
|
||||||
|
user3, _ := dao.GetUserByID(db, "moblie", user2.ParentMobile)
|
||||||
|
user3.Arrears = user3.Arrears + ((orderPay.TotalFee - user2.Arrears) * user3.DividePercentage / 100)
|
||||||
|
dao.UpdateEntity(db, user3, "Arrears")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
errList.AddErr(err2)
|
errList.AddErr(err2)
|
||||||
}
|
}
|
||||||
@@ -629,7 +644,7 @@ func GetOrderPay(ctx *jxcontext.Context, vendorOrderID string) (payList []*model
|
|||||||
return payList, err
|
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()
|
db := dao.GetDB()
|
||||||
user, err := dao.GetUserByID(db, "user_id", userID)
|
user, err := dao.GetUserByID(db, "user_id", userID)
|
||||||
if user == nil {
|
if user == nil {
|
||||||
@@ -643,81 +658,116 @@ func PayForPopluarMan(ctx *jxcontext.Context, transactionID, vendorOrderID, user
|
|||||||
if len(goods) == 0 {
|
if len(goods) == 0 {
|
||||||
return fmt.Errorf("未找到此订单!订单ID:[%v]\n", vendorOrderID)
|
return fmt.Errorf("未找到此订单!订单ID:[%v]\n", vendorOrderID)
|
||||||
}
|
}
|
||||||
param := &wxpayapi.MultiProfitSharingParam{
|
param := &wxpayapi.TransfersParam{
|
||||||
TransactionID: transactionID,
|
CheckName: wxpayapi.CheckName,
|
||||||
OutOrderNo: vendorOrderID,
|
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.Transfers(param)
|
||||||
_, err = api.WxpayAPI.MultiProfitSharing(param)
|
|
||||||
return err
|
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))
|
|
||||||
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 (
|
var (
|
||||||
errMsg string
|
errMsg string
|
||||||
param = &wxpayapi.MultiProfitSharingParam{
|
errCode string
|
||||||
TransactionID: goods.TransactionID,
|
db = dao.GetDB()
|
||||||
OutOrderNo: goods.VendorOrderID,
|
fromDateStr = time.Now().AddDate(0, 0, -3).Format("2006-1-2") + " 00:00:00"
|
||||||
|
toDateStr = time.Now().AddDate(0, 0, -3).Format("2006-1-2") + " 23:59:59"
|
||||||
|
)
|
||||||
|
result, err := dao.GetOrdersForJxPay(db, utils.Str2Time(fromDateStr), utils.Str2Time(toDateStr))
|
||||||
|
for _, goods := range result {
|
||||||
|
var (
|
||||||
|
param = &wxpayapi.TransfersParam{
|
||||||
|
CheckName: wxpayapi.CheckName,
|
||||||
|
Desc: "每日推广人订单分成分到个人",
|
||||||
|
SpbillCreateIP: ctx.GetRealRemoteIP(),
|
||||||
}
|
}
|
||||||
|
payPrice1 int
|
||||||
|
payPrice2 int
|
||||||
)
|
)
|
||||||
user, err := dao.GetUserByID(db, "user_id", goods.UserID)
|
user, err := dao.GetUserByID(db, "user_id", goods.UserID)
|
||||||
if user.ParentMobile == "" {
|
if user.ParentMobile == "" {
|
||||||
return retVal, err
|
return err
|
||||||
}
|
}
|
||||||
user2, err := dao.GetUserByID(db, "mobile", user.ParentMobile)
|
user2, err := dao.GetUserByID(db, "mobile", user.ParentMobile)
|
||||||
auth, err := dao.GetUserBindAuthInfo(db, user2.UserID, model.AuthBindTypeAuth, []string{"weixinmini"}, "", "")
|
auth, err := dao.GetUserBindAuthInfo(db, user2.UserID, model.AuthBindTypeAuth, []string{"weixinmini"}, "", "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return retVal, err
|
return err
|
||||||
}
|
}
|
||||||
if len(auth) == 0 {
|
if len(auth) == 0 {
|
||||||
errMsg += fmt.Sprintf("打款失败!未找到此用户的微信验证方式!订单号:[%v],用户ID:[%v]\n", goods.VendorOrderID, user2.UserID)
|
errMsg += fmt.Sprintf("打款失败!未找到此用户的微信验证方式!订单号:[%v],用户ID:[%v]\n", goods.VendorOrderID, user2.UserID)
|
||||||
} else {
|
} else {
|
||||||
param.Receivers = wxpayapi.CData(`[{"type":"` + wxpayapi.AccountTypeOpen + `","account":"` + auth[0].AuthID + `","amount":` + utils.Int2Str(int(goods.ActualPayPrice)*user2.DividePercentage/100) + `,"description":"每日订单打款分到个人"}]`)
|
payPrice1 = int(goods.ActualPayPrice) * user2.DividePercentage / 100
|
||||||
_, err := api.WxpayAPI.MultiProfitSharing(param)
|
//表示这个人之前有欠款,意思是取消订单退款时,这个推广人的分成收不回来,算作欠款,打钱的时候要扣除
|
||||||
if err != nil {
|
//表示这个人之前有小于3毛钱的款没有打(微信付款api付款最低3毛),记录下来加到以后的款项中
|
||||||
return retVal, err
|
rPrice := payPrice1 - user2.Arrears + user2.Profit
|
||||||
|
err = updateUserAndTransfers(db, param, user2, auth[0].AuthID, rPrice)
|
||||||
|
mapAfter := map[string]interface{}{
|
||||||
|
"user_id": user2.UserID,
|
||||||
|
"price": rPrice,
|
||||||
|
"open_id": auth[0].AuthID,
|
||||||
|
"name": user2.Name,
|
||||||
|
"mobile": user2.Mobile,
|
||||||
}
|
}
|
||||||
|
err = cms.AddEventDetail(db, ctx, model.OperateAdd, user2.ID, model.ThingTypeUser, goods.StoreID, "", cms.BuildDiffData(mapAfter))
|
||||||
}
|
}
|
||||||
if user2.ParentMobile != "" {
|
if user2.ParentMobile != "" {
|
||||||
user3, err := dao.GetUserByID(db, "mobile", user2.ParentMobile)
|
user3, err := dao.GetUserByID(db, "mobile", user2.ParentMobile)
|
||||||
auth, err := dao.GetUserBindAuthInfo(db, user3.UserID, model.AuthBindTypeAuth, []string{"weixinmini"}, "", "")
|
auth, err := dao.GetUserBindAuthInfo(db, user3.UserID, model.AuthBindTypeAuth, []string{"weixinmini"}, "", "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return retVal, err
|
return err
|
||||||
}
|
}
|
||||||
if len(auth) == 0 {
|
if len(auth) == 0 {
|
||||||
errMsg += fmt.Sprintf("打款失败!未找到此用户的微信验证方式!订单号:[%v],用户ID:[%v]\n", goods.VendorOrderID, user3.UserID)
|
errMsg += fmt.Sprintf("打款失败!未找到此用户的微信验证方式!订单号:[%v],用户ID:[%v]\n", goods.VendorOrderID, user3.UserID)
|
||||||
} else {
|
} else {
|
||||||
param.Receivers = wxpayapi.CData(`[{"type":"` + wxpayapi.AccountTypeOpen + `","account":"` + auth[0].AuthID + `","amount":` + utils.Int2Str(int(goods.ActualPayPrice)*user3.DividePercentage/100) + `,"description":"每日订单打款分到个人"}]`)
|
payPrice2 = (int(goods.ActualPayPrice) - payPrice1) * user3.DividePercentage / 100
|
||||||
_, err := api.WxpayAPI.MultiProfitSharing(param)
|
rPrice := payPrice2 - user3.Arrears + user3.Profit
|
||||||
if err != nil {
|
err = updateUserAndTransfers(db, param, user3, auth[0].AuthID, rPrice)
|
||||||
return retVal, err
|
mapAfter := map[string]interface{}{
|
||||||
|
"user_id": user3.UserID,
|
||||||
|
"price": rPrice,
|
||||||
|
"open_id": auth[0].AuthID,
|
||||||
|
"name": user3.Name,
|
||||||
|
"mobile": user3.Mobile,
|
||||||
|
}
|
||||||
|
err = cms.AddEventDetail(db, ctx, model.OperateAdd, user3.ID, model.ThingTypeUser, goods.StoreID, "", cms.BuildDiffData(mapAfter))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
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")
|
user, _ := dao.GetUserByID(dao.GetDB(), "mobile", "18160030913")
|
||||||
noticeMsg := err.Error()
|
if user != nil && errMsg != "" {
|
||||||
if user != nil && err != nil {
|
ddmsg.SendUserMessage(dingdingapi.MsgTyeText, user.UserID, "每日打款错误", errMsg)
|
||||||
ddmsg.SendUserMessage(dingdingapi.MsgTyeText, user.UserID, "每日打款错误", noticeMsg)
|
|
||||||
}
|
}
|
||||||
hint = "1"
|
if err != nil || errMsg != "" {
|
||||||
|
errCode = model.ErrCodeGeneralFailed
|
||||||
|
} else {
|
||||||
|
errCode = model.ErrCodeSuccess
|
||||||
}
|
}
|
||||||
return hint, err
|
err = event.AddOperateEvent(ctx, ctx.GetTrackInfo(), `{"fromDateStr":`+fromDateStr+`,"toDateStr":`+toDateStr+`}`, errCode, err.Error(), 0)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func updateUserAndTransfers(db *dao.DaoDB, param *wxpayapi.TransfersParam, user *model.User, authID string, rPrice int) (err error) {
|
||||||
|
if rPrice >= 30 {
|
||||||
|
param.OpenID = authID
|
||||||
|
param.Amount = rPrice
|
||||||
|
param.PartnerTradeNo = utils.GetUUID()
|
||||||
|
_, err = api.WxpayAPI.Transfers(param)
|
||||||
|
user.ProfitSum = user.ProfitSum + rPrice
|
||||||
|
user.Profit = 0
|
||||||
|
user.Arrears = 0
|
||||||
|
} else if rPrice >= 0 && rPrice < 30 {
|
||||||
|
user.Profit = rPrice
|
||||||
|
user.Arrears = 0
|
||||||
|
} else {
|
||||||
|
user.Profit = 0
|
||||||
|
user.Arrears = int(utils.Float64TwoInt64(math.Abs(utils.Int2Float64(rPrice))))
|
||||||
|
}
|
||||||
|
_, err = dao.UpdateEntity(db, user, "ProfitSum", "Profit", "Arrears")
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -66,6 +66,7 @@ fakeJdBaseURL = "http://test.jxc4.com/qqqq"
|
|||||||
|
|
||||||
ebaiStorePageCookieWMUSS = "B0AAFQCAAAGbhkuMCsvcyYBDkkyAxBGIBlgXAQYVwc7VwYZFkx2HDoPSmo5eV1femopWgJRawhgAALG04cg1RUmhUakBbJRdgPS0tNEhnQhNRewwuWwYYBDEFPCQSDXV5YWA6PAVRHUJ9SnVGMThYAjNjLw9pRxIbS04-XFo05AQgBl%7ERLA33vWcR73gEAKZ"
|
ebaiStorePageCookieWMUSS = "B0AAFQCAAAGbhkuMCsvcyYBDkkyAxBGIBlgXAQYVwc7VwYZFkx2HDoPSmo5eV1femopWgJRawhgAALG04cg1RUmhUakBbJRdgPS0tNEhnQhNRewwuWwYYBDEFPCQSDXV5YWA6PAVRHUJ9SnVGMThYAjNjLw9pRxIbS04-XFo05AQgBl%7ERLA33vWcR73gEAKZ"
|
||||||
ebaiStorePageCookieWMSTOKEN = "gAALgNAAAGfBI5YEBHSQdZY1InIS8CVQU9aBU1f3VLWVQqKHAAAc5LnRLZ1QLLx0S5IuzCSX8ZQ7oUwAAUr-GEm9JpRc9AQAAsLkLHHXzuhh2lZkbyrcAAAWBESKg3ZA"
|
ebaiStorePageCookieWMSTOKEN = "gAALgNAAAGfBI5YEBHSQdZY1InIS8CVQU9aBU1f3VLWVQqKHAAAc5LnRLZ1QLLx0S5IuzCSX8ZQ7oUwAAUr-GEm9JpRc9AQAAsLkLHHXzuhh2lZkbyrcAAAWBESKg3ZA"
|
||||||
|
ebaiStorePageCookieExdTOKEN = "PBE_2.0_5cd1c6141c127d4143e704e21c87c0ff2bbe1a76d55bae600bdd1c938af9261cbb4c124b22a7d124ef514bd5ef1f30742c7e17dfe4e3f38c0d79fe36a33c89ca2d204ffca7dd293cdfc7bc81bef55ca9fb6be3719c3400b8e6ba0dab4c5515213e879009c90bbff47d0b9eac924b6dddd5b1508a427efd39ed3e903aa47d5beaf4285baf4ffe7a3c39dd64bebfc3ada6935ff3283e7c1979eea5aa2d2fd5d49c2ae51e09dc8405baa37caafe3fc84a4ef3d5fbb73bd2836b2ead4127a9216c426354648be3b08894a59d400b94bf09b84afa7f1e03fb4e4337c507f1e3875474e49a8bb98aa31e297d43f59804dc067836bfd3c432098038f930981f7a0ee8fb6d7461e5c8d24873dcd32b902297600563003d772483d9f1aace7bc08d67fbc76452f086df4bc06ce1b92788858cb5caf033b5a5f9533413b3843f05ea18265733f12746177063619f91d405a8b45d6e17f249087d333754d598d86103e1fb30eb73b5f7c371e929"
|
||||||
mtpsStoreToken = "M0p9VatZSeSHfrosD5IViAVl73IcA8mlcuHIV5sG6Zpv83a7JE0wY3t26aEhrrs_MR5gtLSFF1UIkt8HAjaXow"
|
mtpsStoreToken = "M0p9VatZSeSHfrosD5IViAVl73IcA8mlcuHIV5sG6Zpv83a7JE0wY3t26aEhrrs_MR5gtLSFF1UIkt8HAjaXow"
|
||||||
|
|
||||||
weimobAppID = "319F5E7FB6784DFCA3684C9333EB7744"
|
weimobAppID = "319F5E7FB6784DFCA3684C9333EB7744"
|
||||||
@@ -280,7 +281,7 @@ weixinSecret = "ba32b269a068a5b72486a0beafd171e8"
|
|||||||
dbConnectStr = "root:WebServer@1@tcp(127.0.0.1:3306)/jxd_dev_0?charset=utf8mb4&loc=Local&parseTime=true"
|
dbConnectStr = "root:WebServer@1@tcp(127.0.0.1:3306)/jxd_dev_0?charset=utf8mb4&loc=Local&parseTime=true"
|
||||||
|
|
||||||
[alpha]
|
[alpha]
|
||||||
httpport = 8088
|
httpport = 8080
|
||||||
|
|
||||||
# xiaan
|
# xiaan
|
||||||
jdOrgCode = "82029"
|
jdOrgCode = "82029"
|
||||||
|
|||||||
@@ -415,3 +415,16 @@ func (c *SkuController) UpdateSkuNamesExPrefix() {
|
|||||||
return retVal, "", err
|
return retVal, "", err
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @Title 合并饿鲜达商品库
|
||||||
|
// @Description 合并饿鲜达商品库
|
||||||
|
// @Param token header string true "认证token"
|
||||||
|
// @Success 200 {object} controllers.CallResult
|
||||||
|
// @Failure 200 {object} controllers.CallResult
|
||||||
|
// @router /SumExianDaDepot [put]
|
||||||
|
func (c *SkuController) SumExianDaDepot() {
|
||||||
|
c.callSumExianDaDepot(func(params *tSkuSumExianDaDepotParams) (retVal interface{}, errCode string, err error) {
|
||||||
|
err = cms.SumExianDaDepot(params.Ctx)
|
||||||
|
return retVal, "", err
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|||||||
@@ -673,6 +673,7 @@ func (c *StoreSkuController) SendSeckillSkusCountMsg() {
|
|||||||
// @Description 根据平台价反算京西价
|
// @Description 根据平台价反算京西价
|
||||||
// @Param token header string true "认证token"
|
// @Param token header string true "认证token"
|
||||||
// @Param payload formData string true "json数据,JdStoreSkus对象"
|
// @Param payload formData string true "json数据,JdStoreSkus对象"
|
||||||
|
// @Param vendorID formData int true "厂商ID"
|
||||||
// @Param isAsync formData bool true "是否异步,缺省是同步"
|
// @Param isAsync formData bool true "是否异步,缺省是同步"
|
||||||
// @Param isContinueWhenError formData bool true "单个同步失败是否继续,缺省false"
|
// @Param isContinueWhenError formData bool true "单个同步失败是否继续,缺省false"
|
||||||
// @Success 200 {object} controllers.CallResult
|
// @Success 200 {object} controllers.CallResult
|
||||||
@@ -684,7 +685,7 @@ func (c *StoreSkuController) RefreshJxPriceByVendor() {
|
|||||||
if err = jxutils.Strings2Objs(params.Payload, &skuBindInfos); err != nil {
|
if err = jxutils.Strings2Objs(params.Payload, &skuBindInfos); err != nil {
|
||||||
return retVal, "", err
|
return retVal, "", err
|
||||||
}
|
}
|
||||||
retVal,err = cms.RefreshJxPriceByVendor(params.Ctx, skuBindInfos, params.IsAsync, params.IsContinueWhenError)
|
retVal, err = cms.RefreshJxPriceByVendor(params.Ctx, skuBindInfos, params.VendorID, params.IsAsync, params.IsContinueWhenError)
|
||||||
return retVal, "", err
|
return retVal, "", err
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -131,33 +131,31 @@ func (c *JxOrderController) GetMyOrderCountInfo() {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Title 每日订单分账
|
// @Title 每日订单打款
|
||||||
// @Description 每日订单分账
|
// @Description 每日订单打款
|
||||||
// @Param token header string true "认证token"
|
// @Param token header string true "认证token"
|
||||||
// @Param isAsync formData bool false "是否异步操作"
|
|
||||||
// @Param isContinueWhenError formData bool false "单个同步失败是否继续,缺省false"
|
|
||||||
// @Success 200 {object} controllers.CallResult
|
// @Success 200 {object} controllers.CallResult
|
||||||
// @Failure 200 {object} controllers.CallResult
|
// @Failure 200 {object} controllers.CallResult
|
||||||
// @router /AutoPayForPopluarMan [post]
|
// @router /AutoPayForPopluarMan [post]
|
||||||
func (c *JxOrderController) AutoPayForPopluarMan() {
|
func (c *JxOrderController) AutoPayForPopluarMan() {
|
||||||
c.callAutoPayForPopluarMan(func(params *tJxorderAutoPayForPopluarManParams) (retVal interface{}, errCode string, err error) {
|
c.callAutoPayForPopluarMan(func(params *tJxorderAutoPayForPopluarManParams) (retVal interface{}, errCode string, err error) {
|
||||||
retVal, err = localjx.AutoPayForPopluarMan(params.Ctx, params.IsAsync, params.IsContinueWhenError)
|
err = localjx.AutoPayForPopluarMan(params.Ctx)
|
||||||
return retVal, "", err
|
return retVal, "", err
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Title 订单分账
|
// @Title 订单打款
|
||||||
// @Description 订单分账
|
// @Description 订单打款
|
||||||
// @Param token header string true "认证token"
|
// @Param token header string true "认证token"
|
||||||
// @Param transactionID formData string true "微信订单ID"
|
|
||||||
// @Param vendorOrderID formData string true "订单ID"
|
// @Param vendorOrderID formData string true "订单ID"
|
||||||
// @Param userID formData string true "userID"
|
// @Param userID formData string true "userID"
|
||||||
|
// @Param price formData int true "钱"
|
||||||
// @Success 200 {object} controllers.CallResult
|
// @Success 200 {object} controllers.CallResult
|
||||||
// @Failure 200 {object} controllers.CallResult
|
// @Failure 200 {object} controllers.CallResult
|
||||||
// @router /PayForPopluarMan [post]
|
// @router /PayForPopluarMan [post]
|
||||||
func (c *JxOrderController) PayForPopluarMan() {
|
func (c *JxOrderController) PayForPopluarMan() {
|
||||||
c.callPayForPopluarMan(func(params *tJxorderPayForPopluarManParams) (retVal interface{}, errCode string, err error) {
|
c.callPayForPopluarMan(func(params *tJxorderPayForPopluarManParams) (retVal interface{}, errCode string, err error) {
|
||||||
err = localjx.PayForPopluarMan(params.Ctx, params.TransactionID, params.VendorOrderID, params.UserID)
|
err = localjx.PayForPopluarMan(params.Ctx, params.VendorOrderID, params.UserID, params.Price)
|
||||||
return retVal, "", err
|
return retVal, "", err
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -124,9 +124,11 @@ func Init() {
|
|||||||
EbaiAPI = ebaiapi.New(beego.AppConfig.String("ebaiSource"), beego.AppConfig.String("ebaiSecret"))
|
EbaiAPI = ebaiapi.New(beego.AppConfig.String("ebaiSource"), beego.AppConfig.String("ebaiSecret"))
|
||||||
ebaiStorePageCookieWMUSS := beego.AppConfig.DefaultString("ebaiStorePageCookieWMUSS", "")
|
ebaiStorePageCookieWMUSS := beego.AppConfig.DefaultString("ebaiStorePageCookieWMUSS", "")
|
||||||
ebaiStorePageCookieWMSTOKEN := beego.AppConfig.DefaultString("ebaiStorePageCookieWMSTOKEN", "")
|
ebaiStorePageCookieWMSTOKEN := beego.AppConfig.DefaultString("ebaiStorePageCookieWMSTOKEN", "")
|
||||||
if ebaiStorePageCookieWMUSS != "" && ebaiStorePageCookieWMSTOKEN != "" {
|
ebaiStorePageCookieExdTOKEN := beego.AppConfig.DefaultString("ebaiStorePageCookieExdTOKEN", "")
|
||||||
|
if ebaiStorePageCookieWMUSS != "" && ebaiStorePageCookieWMSTOKEN != "" && ebaiStorePageCookieExdTOKEN != "" {
|
||||||
EbaiAPI.SetCookie("WMUSS", ebaiStorePageCookieWMUSS)
|
EbaiAPI.SetCookie("WMUSS", ebaiStorePageCookieWMUSS)
|
||||||
EbaiAPI.SetCookie("WMSTOKEN", ebaiStorePageCookieWMSTOKEN)
|
EbaiAPI.SetCookie("WMSTOKEN", ebaiStorePageCookieWMSTOKEN)
|
||||||
|
EbaiAPI.SetCookie("PASSPORT_DELIMONT_TOKEN", ebaiStorePageCookieExdTOKEN)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
EbaiAPI = nil
|
EbaiAPI = nil
|
||||||
|
|||||||
@@ -1359,6 +1359,15 @@ func init() {
|
|||||||
Filters: nil,
|
Filters: nil,
|
||||||
Params: nil})
|
Params: nil})
|
||||||
|
|
||||||
|
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:SkuController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:SkuController"],
|
||||||
|
beego.ControllerComments{
|
||||||
|
Method: "SumExianDaDepot",
|
||||||
|
Router: `/SumExianDaDepot`,
|
||||||
|
AllowHTTPMethods: []string{"put"},
|
||||||
|
MethodParams: param.Make(),
|
||||||
|
Filters: nil,
|
||||||
|
Params: nil})
|
||||||
|
|
||||||
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:SkuController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:SkuController"],
|
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:SkuController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:SkuController"],
|
||||||
beego.ControllerComments{
|
beego.ControllerComments{
|
||||||
Method: "SyncCategory",
|
Method: "SyncCategory",
|
||||||
|
|||||||
Reference in New Issue
Block a user