Merge branch 'jdshop' of https://e.coding.net/rosydev/jx-callback into jdshop

This commit is contained in:
richboo111
2023-08-16 13:57:23 +08:00
5 changed files with 117 additions and 9 deletions

View File

@@ -861,12 +861,43 @@ func (c *OrderManager) GetOrdersFinancial(ctx *jxcontext.Context, fromDateStr, t
}
func (c *OrderManager) GetStoresOrderSaleInfo(ctx *jxcontext.Context, storeIDList []int, fromTime time.Time, toTime time.Time, statusList []int) (saleInfoList []*dao.StoresOrderSaleInfo, err error) {
// if globals.IsProductEnv() {
// return dao.GetStoresOrderSaleInfo(dao.GetDB(), storeIDList, fromTime, toTime, statusList)
// }
//if globals.IsProductEnv() {
// return dao.GetStoresOrderSaleInfo(dao.GetDB(), storeIDList, fromTime, toTime, statusList)
//}
return c.GetStoresOrderSaleInfoNew(ctx, storeIDList, fromTime, toTime, statusList)
}
func (c *OrderManager) GetStoresOrderSaleInfo2(ctx *jxcontext.Context, fromTime time.Time, toTime time.Time, storeId int) (map[string]interface{}, error) {
year, month, day := time.Now().Date()
if fromTime.IsZero() {
fromTime = time.Date(year, month, day, 0, 0, 0, 0, time.Local)
}
if toTime.IsZero() {
toTime = time.Date(year, month, day, 23, 59, 59, 0, time.Local)
}
db := dao.GetDB()
// 门店统计
storeStatus, err := dao.StatisticsStoreInfo(db)
if err != nil {
return nil, err
}
// 订单统计
orderStatus, err := dao.StatisticsOrderInfo(db, fromTime, toTime, storeId)
if err != nil {
return nil, err
}
// 售后单统计
afsOrderStatus, err := dao.StatisticsAfsOrderInfo(db, fromTime, toTime, storeId)
if err != nil {
return nil, err
}
return map[string]interface{}{"storeStatus": storeStatus, "orderStatus": orderStatus, "afsOrderStatus": afsOrderStatus}, nil
}
func (c *OrderManager) GetStoresOrderSaleInfoNew(ctx *jxcontext.Context, storeIDList []int, fromTime time.Time, toTime time.Time, statusList []int) (saleInfoList []*dao.StoresOrderSaleInfo, err error) {
db := dao.GetDB()
var isLongTime = false

View File

@@ -2,7 +2,6 @@ package misc
import (
"fmt"
"git.rosy.net.cn/jx-callback/business/jxutils/enterprise_msg"
"sync"
"time"
@@ -650,11 +649,6 @@ func syncStoreSkuTao() {
db := dao.GetDB()
switch step {
case 0:
if err := ddmsg.SendUserMessage(dingdingapi.MsgTyeText, "2452A93EEB9111EC9B06525400E86DC0", "淘鲜达消息:", utils.Format4Output("开始同步", false)); err != nil {
globals.SugarLogger.Debugf("SendUserMessage := %s", utils.Format4Output(err, false))
}
enterprise_msg.SendUserMessage("18981810340", "淘鲜达同步消息", utils.Format4Output("开始同步", false), utils.Format4Output("开始同步", false))
_, err = cms.CurVendorSync.SyncStoresSkus2(jxcontext.AdminCtx, nil, 0, db, []int{model.VendorIDTaoVegetable}, nil, false, nil, nil, syncFlag, true, true)
errList.AddErr(err)
case 1:

View File

@@ -1691,3 +1691,57 @@ func GetStoreBaseByVendorStoreID(vendorStoreID string, vendorID int) (storeDetai
}
return storeDetail, err
}
type StatisticsStore struct {
Count int `json:"count"` // 条数
Status int `json:"status"` // 状态
}
// StatisticsStoreInfo 统计所有的门店信息
func StatisticsStoreInfo(db *DaoDB) ([]*StatisticsStore, error) {
statistics := make([]*StatisticsStore, 0, 0)
sql := ` SELECT count(s.status) count, s.status FROM store s GROUP BY s.status `
if err := GetRows(db, &statistics, sql, nil); err != nil {
return nil, err
}
return statistics, nil
}
type StatisticsOrder struct {
Count int `json:"count"` // 条数
Status int `json:"status"` // 状态
TotalShopMoney int `json:"total_shop_money"` // 订单金额
}
// StatisticsOrderInfo 统计订单信息
func StatisticsOrderInfo(db *DaoDB, startTime, endTime time.Time, storeId int) ([]*StatisticsOrder, error) {
sql := ` SELECT count(g.vendor_order_id) count,g.status status ,sum(g.total_shop_money) total_shop_money FROM goods_order g WHERE g.order_created_at >= ? AND g.order_created_at <= ? `
parma := []interface{}{startTime, endTime}
if storeId != model.NO {
sql += ` AND IF(g.store_id <> 0,g.store_id,g.jx_store_id) = ?`
parma = append(parma, storeId)
}
sql += ` GROUP BY g.status `
orderStatistics := make([]*StatisticsOrder, 0, 0)
if err := GetRows(GetDB(), &orderStatistics, sql, parma...); err != nil {
return nil, err
}
return orderStatistics, nil
}
// StatisticsAfsOrderInfo 售后单信息统计
func StatisticsAfsOrderInfo(db *DaoDB, startTime, endTime time.Time, storeId int) ([]*StatisticsOrder, error) {
sql := `SELECT count(a.vendor_order_id) count,a.status status ,sum(a.afs_total_shop_money) total_shop_money FROM afs_order a WHERE a.afs_created_at >= ? AND a.afs_created_at <= ? `
parma := []interface{}{startTime, endTime}
if storeId != model.NO {
sql += ` AND IF(a.store_id <> 0,a.store_id,a.jx_store_id) = 100743`
parma = append(parma, storeId)
}
sql += ` GROUP BY a.status`
orderStatistics := make([]*StatisticsOrder, 0, 0)
if err := GetRows(GetDB(), &orderStatistics, sql, parma...); err != nil {
return nil, err
}
return orderStatistics, nil
}