饿鲜达商品分类id增加,每日打款修改authid

This commit is contained in:
苏尹岚
2020-02-14 11:02:09 +08:00
parent 05f79bd146
commit 871151201e
4 changed files with 51 additions and 40 deletions

View File

@@ -1204,24 +1204,19 @@ func getSkuSaleStatus(inSkuBind *StoreSkuBindSkuInfo, skuNameBindInfo *StoreSkuB
}
func AddEventDetail(db *dao.DaoDB, ctx *jxcontext.Context, operateType, thingID, thingType, storeID int, beforeData, afterData string) (err error) {
req := ctx.GetRequest()
if req != nil {
url := req.URL.Path
apiFunction := url[strings.LastIndex(url, "/")+1 : len(url)]
if ctx.GetUserName() == "jxadmin" && !strings.Contains(apiFunction, "AutoPayForPopluarMan") {
return err
}
operateEventDetail := &model.OperateEventDetail{
OperateType: operateType,
ThingID: thingID,
ThingType: thingType,
StoreID: storeID,
AccessUUID: ctx.GetTrackInfo()[0:strings.Index(ctx.GetTrackInfo(), ",")],
BeforeData: beforeData,
AfterData: afterData,
}
err = event.AddOperateEventDetail(db, operateEventDetail)
if ctx.GetUserName() == "jxadmin" {
return err
}
operateEventDetail := &model.OperateEventDetail{
OperateType: operateType,
ThingID: thingID,
ThingType: thingType,
StoreID: storeID,
AccessUUID: ctx.GetTrackInfo()[0:strings.Index(ctx.GetTrackInfo(), ",")],
BeforeData: beforeData,
AfterData: afterData,
}
err = event.AddOperateEventDetail(db, operateEventDetail)
return err
}

View File

@@ -134,6 +134,7 @@ var (
"UpdateStoreCourierMap": "门店修改三方配送平台绑定信息",
"Login": "登录",
"RegisterUser": "注册",
"AutoPayForPopluarMan": "每日订单打款",
}
MultiStoresVendorMap = map[int]int{

View File

@@ -335,6 +335,7 @@ func genSkuParamsFromStoreSkuInfo2(storeSku *dao.StoreSkuSyncInfo, isCreate, isE
params["upc"] = storeSku.Upc
params["name"] = storeSku.Name
params["cat3_id"] = storeSku.ExdCategoryThirdID
params["category_id"] = utils.Str2Int64(storeSku.VendorCatID)
}
if storeSku.DescImg != "" {
params["rtf"] = storeSku.DescImg

View File

@@ -35,6 +35,8 @@ const (
DingShiDaMinTime = 1 * time.Hour
specialStoreID = 100274
wxAppID = "wx4b5930c13f8b1170"
)
type JxSkuInfo struct {
@@ -676,8 +678,9 @@ func AutoPayForPopluarMan(ctx *jxcontext.Context) (err error) {
errMsg string
errCode string
db = dao.GetDB()
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"
fromDateStr = time.Now().AddDate(0, 0, -5).Format("2006-1-2") + " 00:00:00"
toDateStr = time.Now().AddDate(0, 0, -5).Format("2006-1-2") + " 23:59:59"
mapResult = make(map[string]interface{})
)
result, err := dao.GetOrdersForJxPay(db, utils.Str2Time(fromDateStr), utils.Str2Time(toDateStr))
for _, goods := range result {
@@ -695,47 +698,57 @@ func AutoPayForPopluarMan(ctx *jxcontext.Context) (err error) {
return err
}
user2, err := dao.GetUserByID(db, "mobile", user.ParentMobile)
auth, err := dao.GetUserBindAuthInfo(db, user2.UserID, model.AuthBindTypeAuth, []string{"weixinmini"}, "", "")
auths, err := dao.GetUserBindAuthInfo(db, user2.UserID, model.AuthBindTypeAuth, []string{"weixinmini"}, "", "")
if err != nil {
return err
}
if len(auth) == 0 {
if len(auths) == 0 {
errMsg += fmt.Sprintf("打款失败!未找到此用户的微信验证方式!订单号:[%v]用户ID[%v]\n", goods.VendorOrderID, user2.UserID)
} else {
var openID string
for _, auth := range auths {
if auth.TypeID == wxAppID {
openID = auth.AuthID
}
}
payPrice1 = int(goods.ActualPayPrice) * user2.DividePercentage / 100
//表示这个人之前有欠款,意思是取消订单退款时,这个推广人的分成收不回来,算作欠款,打钱的时候要扣除
//表示这个人之前有小于3毛钱的款没有打微信付款api付款最低3毛记录下来加到以后的款项中
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 = updateUserAndTransfers(db, param, user2, openID, rPrice)
if err != nil {
errMsg += err.Error()
}
err = cms.AddEventDetail(db, ctx, model.OperateAdd, user2.ID, model.ThingTypeUser, goods.StoreID, "", cms.BuildDiffData(mapAfter))
mapResult["打款人1"] = user2.Name
mapResult["打款人金额1"] = rPrice
mapResult["打款人电话1"] = user2.Mobile
mapResult["打款人1userID"] = user2.UserID
}
if user2.ParentMobile != "" {
user3, err := dao.GetUserByID(db, "mobile", user2.ParentMobile)
auth, err := dao.GetUserBindAuthInfo(db, user3.UserID, model.AuthBindTypeAuth, []string{"weixinmini"}, "", "")
auths, err := dao.GetUserBindAuthInfo(db, user3.UserID, model.AuthBindTypeAuth, []string{"weixinmini"}, "", "")
if err != nil {
return err
}
if len(auth) == 0 {
if len(auths) == 0 {
errMsg += fmt.Sprintf("打款失败!未找到此用户的微信验证方式!订单号:[%v]用户ID[%v]\n", goods.VendorOrderID, user3.UserID)
} else {
var openID string
for _, auth := range auths {
if auth.TypeID == wxAppID {
openID = auth.AuthID
}
}
payPrice2 = (int(goods.ActualPayPrice) - payPrice1) * user3.DividePercentage / 100
rPrice := payPrice2 - user3.Arrears + user3.Profit
err = updateUserAndTransfers(db, param, user3, auth[0].AuthID, rPrice)
mapAfter := map[string]interface{}{
"user_id": user3.UserID,
"price": rPrice,
"open_id": auth[0].AuthID,
"name": user3.Name,
"mobile": user3.Mobile,
err = updateUserAndTransfers(db, param, user3, openID, rPrice)
if err != nil {
errMsg += err.Error()
}
err = cms.AddEventDetail(db, ctx, model.OperateAdd, user3.ID, model.ThingTypeUser, goods.StoreID, "", cms.BuildDiffData(mapAfter))
mapResult["打款人2"] = user3.Name
mapResult["打款人金额2"] = rPrice
mapResult["打款人电话2"] = user3.Mobile
mapResult["打款人2userID"] = user3.UserID
}
}
}
@@ -744,11 +757,12 @@ func AutoPayForPopluarMan(ctx *jxcontext.Context) (err error) {
ddmsg.SendUserMessage(dingdingapi.MsgTyeText, user.UserID, "每日打款错误", errMsg)
}
if err != nil || errMsg != "" {
errMsg += err.Error()
errCode = model.ErrCodeGeneralFailed
} else {
errCode = model.ErrCodeSuccess
}
err = event.AddOperateEvent(ctx, ctx.GetTrackInfo(), `{"fromDateStr":`+fromDateStr+`,"toDateStr":`+toDateStr+`}`, errCode, err.Error(), 0)
err = event.AddOperateEvent(ctx, ctx.GetTrackInfo(), cms.BuildDiffData(mapResult), errCode, errMsg, 0)
return err
}