1
This commit is contained in:
@@ -14,11 +14,19 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
func GetMTInfo() {
|
||||
// GetStatisticsList 京西数据查询
|
||||
func GetStatisticsList(start, end time.Time, storeIds []int, offset, pageSize int) (*model.PagedInfo, error) {
|
||||
return dao.GetStatistics(dao.GetDB(), start, end, storeIds, offset, pageSize)
|
||||
}
|
||||
|
||||
// GetMTInfo 更新美团门店信息
|
||||
func GetMTInfo() []error {
|
||||
var db = dao.GetDB()
|
||||
var errList = make([]error, 0, 0)
|
||||
// 获取当前一月有效订单的门店信息
|
||||
effectiveStores, err := dao.StoreInformationStatistics()
|
||||
effectiveStores, err := dao.StoreInformationStatistics(db)
|
||||
if err != nil {
|
||||
return
|
||||
return append(errList, err)
|
||||
}
|
||||
|
||||
var mtApi *mtwmapi.API
|
||||
@@ -40,9 +48,9 @@ func GetMTInfo() {
|
||||
//Activity: 0,
|
||||
//StoreSkuNum: 0,
|
||||
//StoreRating: 0,
|
||||
DeliveryFee: "",
|
||||
//DeliveryFee: "",
|
||||
//DeliveryFee2: "",
|
||||
PromotionFee: "",
|
||||
PromotionFee: "暂无法获取",
|
||||
//BusinessHours: "",
|
||||
}
|
||||
dao.WrapAddIDCULEntity(statistics, "system")
|
||||
@@ -52,7 +60,7 @@ func GetMTInfo() {
|
||||
statistics.Activity = int64(down + up)
|
||||
score, err := mtApi.CommentScore(v.VendorStoreID)
|
||||
if err != nil {
|
||||
globals.SugarLogger.Debugf("门店评分获取错误:%v", err)
|
||||
errList = append(errList, fmt.Errorf("%s获取评分错误:%s", v.VendorStoreID, err.Error()))
|
||||
}
|
||||
if score != nil {
|
||||
statistics.StoreRating = score.AvgPoiScore
|
||||
@@ -60,17 +68,36 @@ func GetMTInfo() {
|
||||
statistics.StoreRating = 0
|
||||
}
|
||||
|
||||
// 获取门店营业时长
|
||||
detail, _ := mtApi.PoiMGet([]string{v.VendorStoreID})
|
||||
if detail != nil {
|
||||
statistics.BusinessHours, err = getStoreShippingTime(detail[0].ShippingTime)
|
||||
if err != nil {
|
||||
errList = append(errList, fmt.Errorf("%s获取营业时长错误:%s", v.VendorStoreID, err.Error()))
|
||||
statistics.BusinessHours = err.Error()
|
||||
}
|
||||
statistics.DeliveryFee2 = utils.Float64ToStr(detail[0].ShippingFee)
|
||||
}
|
||||
// 获取门店起送价
|
||||
result, err := mtApi.ShippingList(v.VendorStoreID)
|
||||
if err != nil {
|
||||
errList = append(errList, fmt.Errorf("%s获取起送价错误:%s", v.VendorStoreID, err.Error()))
|
||||
statistics.DeliveryFee = err.Error()
|
||||
}
|
||||
shippingList := make([]ShippingList, 0, 0)
|
||||
for _, v2 := range result {
|
||||
shippingList = append(shippingList, ShippingList{
|
||||
TimeRange: utils.Interface2String(v2["time_range"]),
|
||||
MinPrice: utils.MustInterface2Float64(v2["min_price"]),
|
||||
ShippingFee: utils.MustInterface2Float64(v2["shipping_fee"]),
|
||||
})
|
||||
}
|
||||
statistics.DeliveryFee = utils.Format4Output(shippingList, false)
|
||||
|
||||
dao.CreateEntity(db, statistics)
|
||||
}
|
||||
|
||||
return errList
|
||||
}
|
||||
|
||||
// 获取门店折扣活动商品数量
|
||||
@@ -192,3 +219,9 @@ func mergeIntervals(ints []interval) []interval {
|
||||
merged = append(merged, curr)
|
||||
return merged
|
||||
}
|
||||
|
||||
type ShippingList struct {
|
||||
TimeRange string `json:"time_range"` // 配送生效时间范围
|
||||
MinPrice float64 `json:"min_price"` // 最小起送价
|
||||
ShippingFee float64 `json:"shipping_fee"` // 配送费
|
||||
}
|
||||
|
||||
@@ -208,6 +208,11 @@ func Init() {
|
||||
"05:00:00",
|
||||
})
|
||||
|
||||
ScheduleTimerFunc("UpdateMtActivityInfo", func() {
|
||||
bidding.GetMTInfo()
|
||||
}, []string{
|
||||
"13:00:00",
|
||||
})
|
||||
/// 更新淘鲜达结算信息
|
||||
//ScheduleTimerFunc("UpdateTaoTotalMoney", func() {
|
||||
// orderman.UpdateTaoSettleInfo()
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
package dao
|
||||
|
||||
import (
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils"
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
"git.rosy.net.cn/jx-print/dao"
|
||||
"time"
|
||||
)
|
||||
|
||||
// StoreInformationStatistics 门店信息统计
|
||||
func StoreInformationStatistics() (result []*model.EffectiveStores, err error) {
|
||||
func StoreInformationStatistics(db *DaoDB) (result []*model.EffectiveStores, err error) {
|
||||
sql := `
|
||||
SELECT
|
||||
gs.jx_store_id,
|
||||
@@ -21,9 +24,41 @@ func StoreInformationStatistics() (result []*model.EffectiveStores, err error) {
|
||||
`
|
||||
parma := []interface{}{time.Now().AddDate(0, -1, 0), model.VendorIDMTWM}
|
||||
|
||||
if err = GetRows(GetDB(), &result, sql, parma...); err != nil {
|
||||
if err = GetRows(db, &result, sql, parma...); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func GetStatistics(db *DaoDB, startTime, endTime time.Time, storeId []int, offset, pageSize int) (pageInfo *model.PagedInfo, err error) {
|
||||
sql := ` SELECT SQL_CALC_FOUND_ROWS * FROM activity_station WHERE 1=1 `
|
||||
param := []interface{}{}
|
||||
if !utils.IsTimeZero(startTime) {
|
||||
sql += ` AND created_at >= ?`
|
||||
param = append(param, startTime)
|
||||
}
|
||||
if !utils.IsTimeZero(endTime) {
|
||||
sql += ` AND created_at <= ?`
|
||||
param = append(param, endTime)
|
||||
}
|
||||
if len(storeId) > 0 {
|
||||
sql += " AND store_id (" + dao.GenQuestionMarks(len(storeId)) + ")"
|
||||
param = append(param, storeId)
|
||||
}
|
||||
sql += ` ORDER BY created_at desc LIMIT ? OFFSET ?`
|
||||
param = append(param, jxutils.FormalizePageSize(pageSize), offset)
|
||||
|
||||
txDB, _ := Begin(db)
|
||||
defer Commit(db, txDB)
|
||||
|
||||
var data []*model.ActivityStation
|
||||
if err := GetRowsTx(txDB, &data, sql, param...); err == nil {
|
||||
pageInfo = &model.PagedInfo{
|
||||
TotalCount: GetLastTotalRowCount2(db, txDB),
|
||||
Data: data,
|
||||
}
|
||||
}
|
||||
|
||||
return pageInfo, err
|
||||
}
|
||||
|
||||
@@ -300,3 +300,40 @@ func (c *BiddingController) UpdateStockBySkuID() {
|
||||
return
|
||||
})
|
||||
}
|
||||
|
||||
// UpdateMtActivity 更新美团任务数据
|
||||
// @Title 更新美团任务数据
|
||||
// @Description 更新美团任务数据
|
||||
// @Param token header string true "认证token"
|
||||
// @Success 200 {object} controllers.CallResult
|
||||
// @Failure 200 {object} controllers.CallResult
|
||||
// @router /UpdateMtActivity [get]
|
||||
func (c *BiddingController) UpdateMtActivity() {
|
||||
c.callUpdateMtActivity(func(params *tBindUpdateMtActivityParams) (retVal interface{}, hint string, err error) {
|
||||
retVal = bidding.GetMTInfo()
|
||||
return retVal, "", err
|
||||
})
|
||||
}
|
||||
|
||||
// GetActivityList 更新美团任务数据
|
||||
// @Title 更新美团任务数据
|
||||
// @Description 更新美团任务数据
|
||||
// @Param token header string true "认证token"
|
||||
// @Param startTime formData string true "开始时间"
|
||||
// @Param endTime formData string true "结束时间"
|
||||
// @Param storeIDs query string false "门店ID"
|
||||
// @Param offset query int false "结果起始序号(以0开始,缺省为0)"
|
||||
// @Param pageSize query int false "结果页大小(缺省为50,-1表示全部)"
|
||||
// @Success 200 {object} controllers.CallResult
|
||||
// @Failure 200 {object} controllers.CallResult
|
||||
// @router /GetActivityList [get]
|
||||
func (c *BiddingController) GetActivityList() {
|
||||
c.callGetActivityList(func(params *tBindGetActivityListParams) (retVal interface{}, hint string, err error) {
|
||||
var storeIDs []int
|
||||
if err = jxutils.Strings2Objs(params.StoreIDs, &storeIDs); err != nil {
|
||||
return nil, "", err
|
||||
}
|
||||
retVal, err = bidding.GetStatisticsList(utils.Str2Time(params.StartTime), utils.Str2Time(params.EndTime), storeIDs, params.Offset, params.PageSize)
|
||||
return
|
||||
})
|
||||
}
|
||||
|
||||
@@ -141,6 +141,8 @@ func Init() {
|
||||
orm.RegisterModel(&model.LakalaSeparateAmt{})
|
||||
orm.RegisterModel(&model.LakalaWithdrawal{})
|
||||
orm.RegisterModel(&model.InvoiceMsg{})
|
||||
// 存储获取到的美团任务信息
|
||||
orm.RegisterModel(&model.ActivityStation{})
|
||||
|
||||
//发送图文消息公众号
|
||||
orm.RegisterModel(&model.KnowledgeDepot{})
|
||||
|
||||
@@ -4708,6 +4708,24 @@ func init() {
|
||||
MethodParams: param.Make(),
|
||||
Filters: nil,
|
||||
Params: nil})
|
||||
// 更新美团任务数据
|
||||
web.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:BiddingController"] = append(web.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:BiddingController"],
|
||||
web.ControllerComments{
|
||||
Method: "UpdateMtActivity",
|
||||
Router: `/UpdateMtActivity`,
|
||||
AllowHTTPMethods: []string{"get"},
|
||||
MethodParams: param.Make(),
|
||||
Filters: nil,
|
||||
Params: nil})
|
||||
// 更新美团任务数据
|
||||
web.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:BiddingController"] = append(web.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:BiddingController"],
|
||||
web.ControllerComments{
|
||||
Method: "GetActivityList",
|
||||
Router: `/GetActivityList`,
|
||||
AllowHTTPMethods: []string{"get"},
|
||||
MethodParams: param.Make(),
|
||||
Filters: nil,
|
||||
Params: nil})
|
||||
|
||||
// 版本设置
|
||||
web.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:VersionController"] = append(web.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:VersionController"],
|
||||
|
||||
126482
swagger/param_parser.go.txt
126482
swagger/param_parser.go.txt
File diff suppressed because it is too large
Load Diff
@@ -2241,6 +2241,63 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/bind/GetActivityList": {
|
||||
"get": {
|
||||
"tags": [
|
||||
"bind"
|
||||
],
|
||||
"description": "更新美团任务数据",
|
||||
"operationId": "BiddingController.更新美团任务数据",
|
||||
"parameters": [
|
||||
{
|
||||
"in": "header",
|
||||
"name": "token",
|
||||
"description": "认证token",
|
||||
"required": true,
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"in": "formData",
|
||||
"name": "startTime",
|
||||
"description": "开始时间",
|
||||
"required": true,
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"in": "formData",
|
||||
"name": "endTime",
|
||||
"description": "结束时间",
|
||||
"required": true,
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"in": "query",
|
||||
"name": "storeIDs",
|
||||
"description": "门店ID",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"in": "query",
|
||||
"name": "offset",
|
||||
"description": "结果起始序号(以0开始,缺省为0)",
|
||||
"type": "integer",
|
||||
"format": "int64"
|
||||
},
|
||||
{
|
||||
"in": "query",
|
||||
"name": "pageSize",
|
||||
"description": "结果页大小(缺省为50,-1表示全部)",
|
||||
"type": "integer",
|
||||
"format": "int64"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "{object} controllers.CallResult"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/bind/GetBiddingMsg": {
|
||||
"get": {
|
||||
"tags": [
|
||||
@@ -2509,6 +2566,29 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/bind/UpdateMtActivity": {
|
||||
"get": {
|
||||
"tags": [
|
||||
"bind"
|
||||
],
|
||||
"description": "更新美团任务数据",
|
||||
"operationId": "BiddingController.更新美团任务数据",
|
||||
"parameters": [
|
||||
{
|
||||
"in": "header",
|
||||
"name": "token",
|
||||
"description": "认证token",
|
||||
"required": true,
|
||||
"type": "string"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "{object} controllers.CallResult"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/bind/UpdateStockBySkuID": {
|
||||
"post": {
|
||||
"tags": [
|
||||
@@ -12492,14 +12572,6 @@
|
||||
"required": true,
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"in": "formData",
|
||||
"name": "vendorID",
|
||||
"description": "订单/运单所属厂商ID",
|
||||
"required": true,
|
||||
"type": "integer",
|
||||
"format": "int64"
|
||||
},
|
||||
{
|
||||
"in": "formData",
|
||||
"name": "printType",
|
||||
@@ -15021,6 +15093,29 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/sku/BatchGetChannelCategoryMapping": {
|
||||
"get": {
|
||||
"tags": [
|
||||
"sku"
|
||||
],
|
||||
"description": "更新最新的分类树",
|
||||
"operationId": "SkuController.更新最新的分类树",
|
||||
"parameters": [
|
||||
{
|
||||
"in": "header",
|
||||
"name": "token",
|
||||
"description": "认证token",
|
||||
"required": true,
|
||||
"type": "string"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "{object} controllers.CallResult"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/sku/BatchSetBoxPrice": {
|
||||
"post": {
|
||||
"tags": [
|
||||
|
||||
@@ -1528,6 +1528,45 @@ paths:
|
||||
responses:
|
||||
"200":
|
||||
description: '{object} controllers.CallResult'
|
||||
/bind/GetActivityList:
|
||||
get:
|
||||
tags:
|
||||
- bind
|
||||
description: 更新美团任务数据
|
||||
operationId: BiddingController.更新美团任务数据
|
||||
parameters:
|
||||
- in: header
|
||||
name: token
|
||||
description: 认证token
|
||||
required: true
|
||||
type: string
|
||||
- in: formData
|
||||
name: startTime
|
||||
description: 开始时间
|
||||
required: true
|
||||
type: string
|
||||
- in: formData
|
||||
name: endTime
|
||||
description: 结束时间
|
||||
required: true
|
||||
type: string
|
||||
- in: query
|
||||
name: storeIDs
|
||||
description: 门店ID
|
||||
type: string
|
||||
- in: query
|
||||
name: offset
|
||||
description: 结果起始序号(以0开始,缺省为0)
|
||||
type: integer
|
||||
format: int64
|
||||
- in: query
|
||||
name: pageSize
|
||||
description: 结果页大小(缺省为50,-1表示全部)
|
||||
type: integer
|
||||
format: int64
|
||||
responses:
|
||||
"200":
|
||||
description: '{object} controllers.CallResult'
|
||||
/bind/GetBiddingMsg:
|
||||
get:
|
||||
tags:
|
||||
@@ -1709,6 +1748,21 @@ paths:
|
||||
responses:
|
||||
"200":
|
||||
description: '{object} controllers.CallResult'
|
||||
/bind/UpdateMtActivity:
|
||||
get:
|
||||
tags:
|
||||
- bind
|
||||
description: 更新美团任务数据
|
||||
operationId: BiddingController.更新美团任务数据
|
||||
parameters:
|
||||
- in: header
|
||||
name: token
|
||||
description: 认证token
|
||||
required: true
|
||||
type: string
|
||||
responses:
|
||||
"200":
|
||||
description: '{object} controllers.CallResult'
|
||||
/bind/UpdateStockBySkuID:
|
||||
post:
|
||||
tags:
|
||||
@@ -8467,12 +8521,6 @@ paths:
|
||||
description: 订单/运单ID
|
||||
required: true
|
||||
type: string
|
||||
- in: formData
|
||||
name: vendorID
|
||||
description: 订单/运单所属厂商ID
|
||||
required: true
|
||||
type: integer
|
||||
format: int64
|
||||
- in: formData
|
||||
name: printType
|
||||
description: 打印类型[1-取消/0-售后]
|
||||
@@ -10186,6 +10234,21 @@ paths:
|
||||
responses:
|
||||
"200":
|
||||
description: '{object} controllers.CallResult'
|
||||
/sku/BatchGetChannelCategoryMapping:
|
||||
get:
|
||||
tags:
|
||||
- sku
|
||||
description: 更新最新的分类树
|
||||
operationId: SkuController.更新最新的分类树
|
||||
parameters:
|
||||
- in: header
|
||||
name: token
|
||||
description: 认证token
|
||||
required: true
|
||||
type: string
|
||||
responses:
|
||||
"200":
|
||||
description: '{object} controllers.CallResult'
|
||||
/sku/BatchSetBoxPrice:
|
||||
post:
|
||||
tags:
|
||||
|
||||
Reference in New Issue
Block a user