This commit is contained in:
邹宗楠
2024-01-16 16:24:50 +08:00
parent e3eff8739b
commit 1fe0ca13b0
7 changed files with 85 additions and 41 deletions

View File

@@ -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
}

View File

@@ -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)
}

View File

@@ -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

View File

@@ -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
}

View File

@@ -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),
},
},
})