1
This commit is contained in:
@@ -876,7 +876,11 @@ func (c *OrderManager) GetStoresOrderSaleInfo(ctx *jxcontext.Context, storeIDLis
|
||||
return c.GetStoresOrderSaleInfoNew(ctx, storeIDList, fromTime, toTime, statusList)
|
||||
}
|
||||
|
||||
func (c *OrderManager) GetStoresOrderSaleInfo2(ctx *jxcontext.Context, fromTime time.Time, toTime time.Time, storeId int, brandId, vendorId []int) (map[string]interface{}, error) {
|
||||
func (c *OrderManager) GetStoresOrderSaleInfo2(ctx *jxcontext.Context, fromTime time.Time, toTime time.Time, storeId int, brandId, vendorId, storeList []int, mapStoreData map[int]int) (map[string]interface{}, error) {
|
||||
var (
|
||||
db = dao.GetDB()
|
||||
)
|
||||
|
||||
year, month, day := time.Now().Date()
|
||||
if fromTime.IsZero() {
|
||||
fromTime = time.Date(year, month, day, 0, 0, 0, 0, time.Local)
|
||||
@@ -885,21 +889,20 @@ func (c *OrderManager) GetStoresOrderSaleInfo2(ctx *jxcontext.Context, fromTime
|
||||
toTime = time.Date(year, month, day, 23, 59, 59, 0, time.Local)
|
||||
}
|
||||
|
||||
db := dao.GetDB()
|
||||
// 门店统计
|
||||
storeStatus, err := dao.StatisticsStoreInfo(db, brandId, vendorId)
|
||||
storeStatus, err := dao.StatisticsStoreInfo(db, brandId, vendorId, storeList)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// 订单统计
|
||||
orderStatus, err := dao.StatisticsOrderInfo(db, fromTime, toTime, storeId, brandId, vendorId)
|
||||
orderStatus, err := dao.StatisticsOrderInfo(db, fromTime, toTime, storeId, brandId, vendorId, storeList)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// 售后单统计
|
||||
afsOrderStatus, err := dao.StatisticsAfsOrderInfo(db, fromTime, toTime, storeId, brandId, vendorId)
|
||||
afsOrderStatus, err := dao.StatisticsAfsOrderInfo(db, fromTime, toTime, storeId, brandId, vendorId, storeList)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -6692,11 +6692,6 @@ func BatchSetRestockingPrice(ctx *jxcontext.Context, preData map[string][]mtwmap
|
||||
}
|
||||
|
||||
// BatchSetMTBoxPrice 批量修改美团包装费为0
|
||||
func BatchSetMTBoxPrice(ctx *jxcontext.Context, jxStoreId []int) error {
|
||||
var db = dao.GetDB()
|
||||
for _, v := range jxStoreId {
|
||||
mtwm.UpdateBoxPrice(ctx, db, v)
|
||||
}
|
||||
|
||||
return nil
|
||||
func BatchSetMTBoxPrice(ctx *jxcontext.Context, skuList []*mtwm.SetBoxPrice) error {
|
||||
return mtwm.UpdateBoxPrice(ctx, dao.GetDB(), skuList)
|
||||
}
|
||||
|
||||
@@ -1698,7 +1698,7 @@ type StatisticsStore struct {
|
||||
}
|
||||
|
||||
// StatisticsStoreInfo 统计所有的门店信息
|
||||
func StatisticsStoreInfo(db *DaoDB, brandId []int, vendorId []int) ([]*StatisticsStore, error) {
|
||||
func StatisticsStoreInfo(db *DaoDB, brandId, vendorId, storeList []int) ([]*StatisticsStore, error) {
|
||||
statistics := make([]*StatisticsStore, 0, 0)
|
||||
|
||||
sql := ` SELECT count(s.status) count, s.status FROM store s `
|
||||
@@ -1708,6 +1708,12 @@ func StatisticsStoreInfo(db *DaoDB, brandId []int, vendorId []int) ([]*Statistic
|
||||
param = append(param, vendorId)
|
||||
}
|
||||
sql += ` WHERE 1=1 `
|
||||
|
||||
if len(storeList) > model.NO {
|
||||
sql += ` AND s.id IN (` + GenQuestionMarks(len(storeList)) + `)`
|
||||
param = append(param, storeList)
|
||||
}
|
||||
|
||||
if len(brandId) > model.NO {
|
||||
sql += ` AND s.brand_id IN (` + GenQuestionMarks(len(brandId)) + `)`
|
||||
param = append(param, brandId)
|
||||
@@ -1727,7 +1733,7 @@ type StatisticsOrder struct {
|
||||
}
|
||||
|
||||
// StatisticsOrderInfo 统计订单信息
|
||||
func StatisticsOrderInfo(db *DaoDB, startTime, endTime time.Time, storeId int, brandId, vendorId []int) ([]*StatisticsOrder, error) {
|
||||
func StatisticsOrderInfo(db *DaoDB, startTime, endTime time.Time, storeId int, brandId, vendorId, storeList []int) ([]*StatisticsOrder, error) {
|
||||
parma := []interface{}{}
|
||||
sql := ` SELECT count(g.vendor_order_id) count,g.status status ,sum(g.total_shop_money) total_shop_money FROM goods_order g `
|
||||
|
||||
@@ -1741,21 +1747,25 @@ func StatisticsOrderInfo(db *DaoDB, startTime, endTime time.Time, storeId int, b
|
||||
if storeId != model.NO {
|
||||
sql += ` AND IF(g.store_id <> 0,g.store_id,g.jx_store_id) = ?`
|
||||
parma = append(parma, storeId)
|
||||
} else if len(storeList) != model.NO {
|
||||
sql += ` AND IF(g.store_id <> 0,g.store_id,g.jx_store_id) IN (` + GenQuestionMarks(len(storeList)) + `)`
|
||||
parma = append(parma, storeList)
|
||||
}
|
||||
|
||||
if len(vendorId) > model.NO {
|
||||
sql += ` AND g.vendor_id IN (` + GenQuestionMarks(len(vendorId)) + `)`
|
||||
parma = append(parma, vendorId)
|
||||
}
|
||||
sql += ` GROUP BY g.status `
|
||||
orderStatistics := make([]*StatisticsOrder, 0, 0)
|
||||
if err := GetRows(GetDB(), &orderStatistics, sql, parma...); err != nil {
|
||||
if err := GetRows(db, &orderStatistics, sql, parma...); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return orderStatistics, nil
|
||||
}
|
||||
|
||||
// StatisticsAfsOrderInfo 售后单信息统计
|
||||
func StatisticsAfsOrderInfo(db *DaoDB, startTime, endTime time.Time, storeId int, brandId, vendorId []int) ([]*StatisticsOrder, error) {
|
||||
func StatisticsAfsOrderInfo(db *DaoDB, startTime, endTime time.Time, storeId int, brandId, vendorId, storeList []int) ([]*StatisticsOrder, error) {
|
||||
parma := []interface{}{}
|
||||
sql := `SELECT count(a.vendor_order_id) count,a.status status ,sum(a.afs_total_shop_money) total_shop_money FROM afs_order a `
|
||||
|
||||
@@ -1769,6 +1779,9 @@ func StatisticsAfsOrderInfo(db *DaoDB, startTime, endTime time.Time, storeId int
|
||||
if storeId != model.NO {
|
||||
sql += ` AND IF(a.store_id <> 0,a.store_id,a.jx_store_id) = ?`
|
||||
parma = append(parma, storeId)
|
||||
} else if len(storeList) != model.NO {
|
||||
sql += ` AND IF(a.store_id <> 0,a.store_id,a.jx_store_id) IN (` + GenQuestionMarks(len(storeList)) + `)`
|
||||
parma = append(parma, storeList)
|
||||
}
|
||||
|
||||
if len(vendorId) > 0 {
|
||||
@@ -1778,7 +1791,7 @@ func StatisticsAfsOrderInfo(db *DaoDB, startTime, endTime time.Time, storeId int
|
||||
|
||||
sql += ` GROUP BY a.status`
|
||||
orderStatistics := make([]*StatisticsOrder, 0, 0)
|
||||
if err := GetRows(GetDB(), &orderStatistics, sql, parma...); err != nil {
|
||||
if err := GetRows(db, &orderStatistics, sql, parma...); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return orderStatistics, nil
|
||||
|
||||
@@ -397,10 +397,12 @@ func (c *PrinterHandler) UnregisterPrinter(ctx *jxcontext.Context, machineCode,
|
||||
func (c *PrinterHandler) BindPrinter(ctx *jxcontext.Context, mapData map[string]interface{}) (bindResult *partner.BindPrinterResult, err error) {
|
||||
machineCode := utils.Interface2String(mapData["machineCode"])
|
||||
qrKey := utils.Interface2String(mapData["qrKey"])
|
||||
if machineCode == "" || qrKey == "" {
|
||||
msign := utils.Interface2String(mapData["msign"])
|
||||
if machineCode == "" || (qrKey == "" && msign == "") {
|
||||
return nil, fmt.Errorf("易联云扫描数据格式不正确")
|
||||
}
|
||||
tokenInfo, err := api.YilianyunAPI2.GetPrinterToken(machineCode, qrKey)
|
||||
|
||||
tokenInfo, err := api.YilianyunAPI2.GetPrinterToken(machineCode, qrKey, msign)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -900,31 +900,34 @@ func (p *PurchaseHandler) GetSkuCategoryIdByName(vendorOrgCode, skuName string)
|
||||
return "", err
|
||||
}
|
||||
|
||||
func UpdateBoxPrice(ctx *jxcontext.Context, db *dao.DaoDB, storeId int) error {
|
||||
storeDetail, err := dao.GetStoreDetail(db, storeId, model.VendorIDMTWM, "")
|
||||
type SetBoxPrice struct {
|
||||
StoreId int `json:"store_id"` // 门店id
|
||||
SkuId int `json:"sku_id"` // 商品id
|
||||
BoxPrice float64 `json:"box_price"` // 打包价格
|
||||
}
|
||||
|
||||
func UpdateBoxPrice(ctx *jxcontext.Context, db *dao.DaoDB, list []*SetBoxPrice) error {
|
||||
storeDetail, err := dao.GetStoreDetail(db, list[0].StoreId, model.VendorIDMTWM, "")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
storeSkuList, err := dao.GetStoresSkusInfo(db, []int{storeId}, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
//storeSkuList, err := dao.GetStoresSkusInfo(db, []int{list[0].StoreId}, nil)
|
||||
//if err != nil {
|
||||
// return err
|
||||
//}
|
||||
|
||||
api := getAPI(storeDetail.VendorOrgCode, storeId, storeDetail.VendorStoreID)
|
||||
api := getAPI(storeDetail.VendorOrgCode, list[0].StoreId, storeDetail.VendorStoreID)
|
||||
foodDataList := make([]map[string]interface{}, 0)
|
||||
for _, v := range storeSkuList {
|
||||
if v.MtwmID != model.NO {
|
||||
continue
|
||||
}
|
||||
for _, v := range list {
|
||||
|
||||
foodDataList = append(foodDataList, map[string]interface{}{
|
||||
"app_spu_code": utils.Int2Str(v.SkuID),
|
||||
"app_spu_code": utils.Int2Str(v.SkuId),
|
||||
"skus": []map[string]interface{}{
|
||||
{
|
||||
"sku_id": utils.Int2Str(v.SkuID),
|
||||
"ladder_box_num": "0",
|
||||
"ladder_box_price": "0",
|
||||
"sku_id": utils.Int2Str(v.SkuId),
|
||||
"ladder_box_num": "1",
|
||||
"ladder_box_price": utils.Float64ToStr(v.BoxPrice),
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
@@ -888,17 +888,17 @@ func (c *SkuController) BatchSetRestockingPrice() {
|
||||
// @Title 批量设置美团商品打包费为零
|
||||
// @Description 批量设置美团商品打包费为零
|
||||
// @Param token header string true "认证token"
|
||||
// @Param storeIds formData string true "门店id列表"
|
||||
// @Param payload formData string true "json数据,SpuData对象()"
|
||||
// @Success 200 {object} controllers.CallResult
|
||||
// @Failure 200 {object} controllers.CallResult
|
||||
// @router /BatchSetBoxPrice [post]
|
||||
func (c *SkuController) BatchSetBoxPrice() {
|
||||
c.callBatchSetBoxPrice(func(params *tSkuBatchSetBoxPriceParams) (retVal interface{}, errCode string, err error) {
|
||||
var stores []int
|
||||
if err = jxutils.Strings2Objs(params.StoreIds, &stores); err != nil {
|
||||
return retVal, "", err
|
||||
payload := make([]*mtwm.SetBoxPrice, 0, 0)
|
||||
if err = utils.UnmarshalUseNumber([]byte(params.Payload), &payload); err != nil {
|
||||
return nil, "", err
|
||||
}
|
||||
err = cms.BatchSetMTBoxPrice(params.Ctx, stores)
|
||||
err = cms.BatchSetMTBoxPrice(params.Ctx, payload)
|
||||
return retVal, "", err
|
||||
})
|
||||
}
|
||||
|
||||
@@ -4,7 +4,9 @@ import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"git.rosy.net.cn/jx-callback/business/auth2"
|
||||
"git.rosy.net.cn/jx-callback/business/bidding"
|
||||
"git.rosy.net.cn/jx-callback/business/jxstore/cms"
|
||||
"git.rosy.net.cn/jx-callback/business/partner/delivery"
|
||||
"strings"
|
||||
"time"
|
||||
@@ -496,12 +498,38 @@ func (c *OrderController) StaleIndexInfo() {
|
||||
if err != nil {
|
||||
return nil, "", err
|
||||
}
|
||||
|
||||
ctx := params.Ctx
|
||||
if !auth2.IsV2Token(ctx.GetToken()) {
|
||||
return nil, model.ErrCodeTokenIsInvalid, model.ErrTokenIsInvalid
|
||||
}
|
||||
mobile, userID := ctx.GetMobileAndUserID()
|
||||
if mobile == "" || userID == "" || userID == "null" || userID == "NULL" {
|
||||
return nil, "", fmt.Errorf("不能得到用户手机号,%s,%s", userID, mobile)
|
||||
}
|
||||
|
||||
var storeList []*dao.StoreWithCityName
|
||||
dataList := make([]int, 0, len(storeList))
|
||||
mapDataList := make(map[int]int, len(storeList))
|
||||
if storeList, err = cms.GetStoreList4User(ctx, mobile, userID); err == nil && len(storeList) > 0 {
|
||||
// todo,应该用通用方法
|
||||
for _, v := range storeList {
|
||||
dataList = append(dataList, v.Store.ID)
|
||||
mapDataList[v.Store.ID] = model.YES
|
||||
}
|
||||
} else {
|
||||
return retVal, "", err
|
||||
}
|
||||
if params.StoreID != 0 && mapDataList[params.StoreID] != model.YES {
|
||||
return retVal, "", fmt.Errorf("此门店%d,不归属于该用户%s", params.StoreID, ctx.GetUserName())
|
||||
}
|
||||
|
||||
var vendors []int
|
||||
var brandIds []int
|
||||
if err := jxutils.Strings2Objs(params.VendorIds, &vendors, params.BrandIds, &brandIds); err != nil {
|
||||
return nil, "", err
|
||||
return retVal, "", err
|
||||
}
|
||||
retVal, err = orderman.FixedOrderManager.GetStoresOrderSaleInfo2(params.Ctx, timeList[0], timeList[1], params.StoreID, brandIds, vendors)
|
||||
retVal, err = orderman.FixedOrderManager.GetStoresOrderSaleInfo2(params.Ctx, timeList[0], timeList[1], params.StoreID, brandIds, vendors, dataList, mapDataList)
|
||||
return retVal, "", err
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user