This commit is contained in:
邹宗楠
2024-09-19 16:16:32 +08:00
parent ffe43d627b
commit 9d68cb15ed
3 changed files with 88 additions and 5 deletions

View File

@@ -2,9 +2,11 @@ package bidding
import (
"fmt"
"git.rosy.net.cn/baseapi/platformapi/dingdingapi"
"git.rosy.net.cn/baseapi/platformapi/tiktok_shop/ascription_place"
"git.rosy.net.cn/baseapi/utils"
"git.rosy.net.cn/jx-callback/business/jxcallback/orderman"
"git.rosy.net.cn/jx-callback/business/jxutils/ddmsg"
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
"git.rosy.net.cn/jx-callback/business/model"
"git.rosy.net.cn/jx-callback/business/model/dao"
@@ -145,6 +147,7 @@ func CreateSupermarketSign(supermarket []*model.SupermarketSign, lastOperator st
return errors
}
// QuerySupermarketSign 查询签约门店数据
func QuerySupermarketSign(storeId, storeName, cityName, storeType, signPeople string, start, end, expirationStart, expirationEnd, page, size int) (result []*model.SupermarketSign, totalCount int, err error) {
sql := `SELECT SQL_CALC_FOUND_ROWS * FROM supermarket_sign WHERE 1 = 1 `
param := make([]interface{}, 0, 0)
@@ -190,7 +193,8 @@ func QuerySupermarketSign(storeId, storeName, cityName, storeType, signPeople st
sql += ` AND sign_people = ?`
param = append(param, signPeople)
}
sql += ` AND deleted_at = ?`
param = append(param, utils.DefaultTimeValue)
sql += " limit ? offset ? "
param = append(param, size)
param = append(param, (utils.MustInterface2Int64(page)-1)*utils.MustInterface2Int64(size))
@@ -205,3 +209,53 @@ func QuerySupermarketSign(storeId, storeName, cityName, storeType, signPeople st
return nil, 0, err
}
// DeleteSignData 删除签约数据
func DeleteSignData(storeId string) (int64, error) {
store := &model.SupermarketSign{StoreID: storeId}
if err := dao.GetEntity(dao.GetDB(), store, "StoreID"); err != nil {
return 0, err
}
store.DeletedAt = time.Now()
return dao.UpdateEntity(dao.GetDB(), store, "DeletedAt")
}
// GetExpireShopNoticeUser 获取到期的签约门店数据并且通知给老板
func GetExpireShopNoticeUser() {
start := time.Now().AddDate(0, 0, -3)
end := time.Now().AddDate(0, 0, 3)
sql := ` SELECT * FROM supermarket_sign s WHERE s.sign_end_time >= ? AND s.sign_end_time <= ? AND s.deleted_at = ? `
param := []interface{}{start, end, utils.DefaultTimeValue}
result := make([]*model.SupermarketSign, 0, 0)
err := dao.GetRows(dao.GetDB(), &result, sql, param...)
if err != nil {
return
}
if len(result) == model.NO {
return
}
userStore := make(map[string][]string, 0)
for _, v := range result {
userStore[v.SignPeople] = append(userStore[v.SignPeople], v.StoreID)
}
for userName, us := range userStore {
userList, _, err := dao.GetUsers(dao.GetDB(), 31, userName, nil, nil, nil, 0, 50)
if err == nil && len(userList) > 0 {
// 通知给用户
err2 := ddmsg.SendUserMessage(dingdingapi.MsgTyeText, userList[0].UserID, "以下超市签约门店即将到期请注意续签", strings.Join(us, ","))
if err2 != nil {
// 石锋
ddmsg.SendUserMessage(dingdingapi.MsgTyeText, "DDC5657B43EE11E9A9FF525400E86DC0", fmt.Sprintf("以下超市签约门店即将到期请注意续签(用户:%s通知错误)", userName), strings.Join(us, ",")+fmt.Sprintf("%v", err2))
}
} else {
// 通知给石锋
ddmsg.SendUserMessage(dingdingapi.MsgTyeText, "DDC5657B43EE11E9A9FF525400E86DC0", fmt.Sprintf("以下超市签约门店即将到期请注意续签(用户:%s查询不到)", userName), strings.Join(us, ","))
}
}
}

View File

@@ -176,6 +176,13 @@ func Init() {
report.RefreshStoreManageState(jxcontext.AdminCtx, nil, []int{model.VendorIDJD})
}, 5*time.Second, 1*time.Hour)
// 定时任务通知:签约门店过期通知
ScheduleTimerFunc("GetExpireShopNoticeUser", func() {
bidding.GetExpireShopNoticeUser()
}, []string{
"10:00:00",
})
//每天晚上23:00更新抖店 审核状态
ScheduleTimerFunc("UpdateStorePoiStatus", func() {
cms.UpdateStorePoiStatus(jxcontext.AdminCtx)

View File

@@ -3,10 +3,13 @@ package controllers
import (
"encoding/json"
"errors"
"fmt"
"git.rosy.net.cn/baseapi/platformapi/dingdingapi"
"git.rosy.net.cn/baseapi/utils"
"git.rosy.net.cn/jx-callback/business/bidding"
"git.rosy.net.cn/jx-callback/business/jxcallback/scheduler"
"git.rosy.net.cn/jx-callback/business/jxutils"
"git.rosy.net.cn/jx-callback/business/jxutils/ddmsg"
"git.rosy.net.cn/jx-callback/business/jxutils/excel"
"git.rosy.net.cn/jx-callback/business/jxutils/tasksch"
"git.rosy.net.cn/jx-callback/business/model"
@@ -136,7 +139,7 @@ func (c *BiddingController) JXPrintAfsOrder() {
// @Title 创建超市签约信息
// @Description 创建超市签约信息:记录已经签约的门店信息
// @Param signObj formData string true "model.SupermarketSign"
// @Param token header string false "认证token"
// @Param token header string true "认证token"
// @Success 200 {object} controllers.CallResult
// @Failure 200 {object} controllers.CallResult
// @router /CreateSupermarketSign [post]
@@ -147,7 +150,7 @@ func (c *BiddingController) CreateSupermarketSign() {
return nil, "", err
}
retVal = bidding.CreateSupermarketSign(supermarket, params.Ctx.GetUserName())
retVal = bidding.CreateSupermarketSign(supermarket, params.Ctx.GetUserID())
return retVal, "", nil
})
}
@@ -166,7 +169,7 @@ func (c *BiddingController) CreateSupermarketSign() {
// @Param signPeople formData string false "签约人"
// @Param page formData int64 true "页码"
// @Param size formData int64 true "页数"
// @Param token header string false "认证token"
// @Param token header string true "认证token"
// @Success 200 {object} controllers.CallResult
// @Failure 200 {object} controllers.CallResult
// @router /GetSupermarketSign [post]
@@ -178,6 +181,21 @@ func (c *BiddingController) GetSupermarketSign() {
})
}
// DeleteSignData 查询超市签约信息
// @Title 查询超市签约信息
// @Description 查询超市签约信息:记录已经签约的门店信息
// @Param storeID formData string true "美团门店ID"
// @Param token header string true "认证token"
// @Success 200 {object} controllers.CallResult
// @Failure 200 {object} controllers.CallResult
// @router /DeleteSignData [delete]
func (c *BiddingController) DeleteSignData() {
c.callDeleteSignData(func(params *tBindDeleteSignDataParams) (retVal interface{}, hint string, err error) {
retVal, err = bidding.DeleteSignData(params.StoreID)
return retVal, hint, err
})
}
// DownSupermarketSign 下载超市签约信息
// @Title 下载超市签约信息
// @Description 下载超市签约信息
@@ -237,7 +255,11 @@ func (c *BiddingController) DownSupermarketSign() {
key := "export/" + strings.Join(keyPart, "_")
excelURL, err2 := jxutils.UploadExportContent(excelBin, key)
if err = err2; err == nil {
task.SetNoticeMsg(excelURL)
//task.SetNoticeMsg(excelURL)
if authInfo, err := params.Ctx.GetV2AuthInfo(); err == nil {
noticeMsg := fmt.Sprintf("path=%s\n", excelURL)
ddmsg.SendUserMessage(dingdingapi.MsgTyeText, authInfo.UserID, "导出签约门店数据", noticeMsg)
}
}
}
return nil, err