饿鲜达商品库合并测试,订单分账修改
This commit is contained in:
@@ -1444,11 +1444,60 @@ func DeleteSkuNameExPrefixOverdue(db *dao.DaoDB) (err error) {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func SumExianDaDepot() (err error) {
|
func SumExianDaDepot(ctx *jxcontext.Context) (err error) {
|
||||||
// result, err := api.EbaiAPI.GetExianDaSkuDepot()
|
db := dao.GetDB()
|
||||||
// for _, v := range result {
|
result, err := api.EbaiAPI.GetExianDaSkuDepot()
|
||||||
// v.ElemeGoodsID
|
for _, v := range result {
|
||||||
// v.ImageURL
|
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, name, _, specUnit, unit, specQuality := jxutils.SplitSkuName(v.GoodsName)
|
||||||
|
skuName := &model.SkuName{
|
||||||
|
Prefix: prefix,
|
||||||
|
Name: name,
|
||||||
|
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,
|
||||||
|
ExdSkuName: v.GoodsName,
|
||||||
|
ExdUpc: int(utils.Str2Int64(v.UpcID)),
|
||||||
|
ExdCategoryThirdID: skus.CategoryIDThird,
|
||||||
|
}
|
||||||
|
dao.WrapAddIDCULDEntity(sku, ctx.GetUserName())
|
||||||
|
err = dao.CreateEntity(db, &sku)
|
||||||
|
if err != nil {
|
||||||
|
dao.Rollback(db)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
dao.Commit(db)
|
||||||
|
break
|
||||||
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -201,6 +201,17 @@ func RegisterUserWithMobile(ctx *jxcontext.Context, user *model.User, mobileVeri
|
|||||||
user.Avatar = inAuthInfo.GetAvatar()
|
user.Avatar = inAuthInfo.GetAvatar()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//注册时默认商城用户就加入分账接收方
|
||||||
|
if strings.Contains(ctx.GetRequest().Referer(), "wx4b5930c13f8b1170") {
|
||||||
|
param := &wxpayapi.ProfitSharingReceiverParam{
|
||||||
|
Receiver: wxpayapi.CData(`{
|
||||||
|
"type":"` + wxpayapi.AccountTypeOpen + `",
|
||||||
|
"account":"` + inAuthInfo.GetAuthID() + `",
|
||||||
|
"relation_type":" ` + wxpayapi.Relation + `"
|
||||||
|
}`),
|
||||||
|
}
|
||||||
|
_, err = api.WxpayAPI.AddProfitSharingReceiver(param)
|
||||||
|
}
|
||||||
if err = CreateUser(user, utils.LimitUTF8StringLen(createName, 32)); err == nil {
|
if err = CreateUser(user, utils.LimitUTF8StringLen(createName, 32)); err == nil {
|
||||||
userProvider.UpdateLastLogin(user.GetID(), authType, ctx.GetRealRemoteIP())
|
userProvider.UpdateLastLogin(user.GetID(), authType, ctx.GetRealRemoteIP())
|
||||||
TryAddStoreBossRole4User(ctx, user)
|
TryAddStoreBossRole4User(ctx, user)
|
||||||
@@ -380,6 +391,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)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -260,26 +260,26 @@ 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) {
|
||||||
dao.Begin(db)
|
|
||||||
defer func() {
|
|
||||||
if r := recover(); r != nil || err != nil {
|
|
||||||
dao.Rollback(db)
|
|
||||||
if r != nil {
|
|
||||||
panic(r)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
v := batchItemList[0].(*model.PriceReferSnapshot)
|
v := batchItemList[0].(*model.PriceReferSnapshot)
|
||||||
for _, appOrg := range apimanager.CurAPIManager.GetAppOrgCodeList(model.VendorIDJD) {
|
for _, appOrg := range apimanager.CurAPIManager.GetAppOrgCodeList(model.VendorIDJD) {
|
||||||
directPrice, _ := jd.GetAPI(appOrg).GetJdSkuDirectPrice(v.SkuID)
|
directPrice, _ := jd.GetAPI(appOrg).GetJdSkuDirectPrice(v.SkuID)
|
||||||
|
dao.Begin(db)
|
||||||
|
defer func() {
|
||||||
|
if r := recover(); r != nil || err != nil {
|
||||||
|
dao.Rollback(db)
|
||||||
|
if r != nil {
|
||||||
|
panic(r)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}()
|
||||||
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)
|
||||||
|
|||||||
@@ -223,6 +223,11 @@ 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"`
|
||||||
|
ExdSkuName string `json:"exdSkuName"`
|
||||||
|
ExdUpc int `json:"exdUpc"`
|
||||||
|
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"`
|
||||||
|
|
||||||
|
|||||||
@@ -660,7 +660,6 @@ func AutoPayForPopluarMan(ctx *jxcontext.Context, isAsync, isContinueWhenError b
|
|||||||
toDateStr = time.Now().AddDate(0, 0, -1).Format("2006-1-2") + " 23:59:59"
|
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))
|
result, err := dao.GetOrdersForJxPay(db, utils.Str2Time(fromDateStr), utils.Str2Time(toDateStr))
|
||||||
fmt.Println(result)
|
|
||||||
task := tasksch.NewParallelTask("AutoPayForPopluarMan", tasksch.NewParallelConfig().SetIsContinueWhenError(isContinueWhenError), ctx,
|
task := tasksch.NewParallelTask("AutoPayForPopluarMan", tasksch.NewParallelConfig().SetIsContinueWhenError(isContinueWhenError), ctx,
|
||||||
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||||
goods := batchItemList[0].(*dao.GoodsOrderPay)
|
goods := batchItemList[0].(*dao.GoodsOrderPay)
|
||||||
@@ -670,6 +669,9 @@ func AutoPayForPopluarMan(ctx *jxcontext.Context, isAsync, isContinueWhenError b
|
|||||||
TransactionID: goods.TransactionID,
|
TransactionID: goods.TransactionID,
|
||||||
OutOrderNo: goods.VendorOrderID,
|
OutOrderNo: goods.VendorOrderID,
|
||||||
}
|
}
|
||||||
|
payPrice1 int
|
||||||
|
payPrice2 int
|
||||||
|
receivers string = "["
|
||||||
)
|
)
|
||||||
user, err := dao.GetUserByID(db, "user_id", goods.UserID)
|
user, err := dao.GetUserByID(db, "user_id", goods.UserID)
|
||||||
if user.ParentMobile == "" {
|
if user.ParentMobile == "" {
|
||||||
@@ -683,11 +685,9 @@ func AutoPayForPopluarMan(ctx *jxcontext.Context, isAsync, isContinueWhenError b
|
|||||||
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)
|
receivers += `{"type":"` + wxpayapi.AccountTypeOpen + `","account":"` + auth[0].AuthID + `","amount":` + utils.Int2Str(payPrice1) + `,"description":"每日订单打款分到个人"}`
|
||||||
if err != nil {
|
// _, err := api.WxpayAPI.MultiProfitSharing(param)
|
||||||
return retVal, err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if user2.ParentMobile != "" {
|
if user2.ParentMobile != "" {
|
||||||
user3, err := dao.GetUserByID(db, "mobile", user2.ParentMobile)
|
user3, err := dao.GetUserByID(db, "mobile", user2.ParentMobile)
|
||||||
@@ -698,13 +698,17 @@ func AutoPayForPopluarMan(ctx *jxcontext.Context, isAsync, isContinueWhenError b
|
|||||||
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)
|
receivers += `,{"type":"` + wxpayapi.AccountTypeOpen + `","account":"` + auth[0].AuthID + `","amount":` + utils.Int2Str(payPrice2) + `,"description":"每日订单打款分到个人"}`
|
||||||
if err != nil {
|
// _, err := api.WxpayAPI.MultiProfitSharing(param)
|
||||||
return retVal, err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
receivers += "]"
|
||||||
|
param.Receivers = wxpayapi.CData(receivers)
|
||||||
|
_, err = api.WxpayAPI.MultiProfitSharing(param)
|
||||||
|
if err != nil {
|
||||||
|
return retVal, err
|
||||||
|
}
|
||||||
return retVal, errors.New(errMsg)
|
return retVal, errors.New(errMsg)
|
||||||
}, result)
|
}, result)
|
||||||
tasksch.HandleTask(task, nil, true).Run()
|
tasksch.HandleTask(task, nil, true).Run()
|
||||||
|
|||||||
Reference in New Issue
Block a user