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

This commit is contained in:
gazebo
2019-11-12 18:11:48 +08:00
5 changed files with 168 additions and 2 deletions

View File

@@ -626,7 +626,7 @@ func (c *OrderManager) RefreshHistoryOrdersEarningPrice(ctx *jxcontext.Context,
if fromDate != "" && toDate != "" {
fromDateParam = utils.Str2Time(fromDate)
toDateParam = utils.Str2Time(toDate)
actList, _ := dao.QueryActs(db, actID, 0, math.MaxInt32, 0, "", 0, nil, nil, nil, 0, 0, 0, time.Time{}, time.Time{}, time.Time{}, time.Time{})
actList, _ := dao.QueryActs(db, actID, 0, math.MaxInt32, 0, "", -1, nil, nil, nil, 0, 0, 0, time.Time{}, time.Time{}, time.Time{}, time.Time{})
if len(actList.Data) > 0 {
actBeginAt := actList.Data[0].BeginAt
actEndAt := actList.Data[0].EndAt
@@ -656,7 +656,7 @@ func (c *OrderManager) RefreshHistoryOrdersEarningPrice(ctx *jxcontext.Context,
return "", errors.New(fmt.Sprintf("未查询到相关结算活动活动ID[%d]", actID))
}
} else if fromDate == "" && toDate == "" {
actList, _ := dao.QueryActs(db, actID, 0, math.MaxInt32, 0, "", 0, nil, nil, nil, 0, 0, 0, time.Time{}, time.Time{}, time.Time{}, time.Time{})
actList, _ := dao.QueryActs(db, actID, 0, math.MaxInt32, 0, "", -1, nil, nil, nil, 0, 0, 0, time.Time{}, time.Time{}, time.Time{}, time.Time{})
if len(actList.Data) > 0 {
orderList, _ = dao.QueryOrders(db, vendorOrderID, actID, vendorIDs, storeID, actList.Data[0].BeginAt, actList.Data[0].EndAt)
} else {

View File

@@ -0,0 +1,125 @@
package yonghui
import (
"fmt"
"mime/multipart"
"unicode"
"git.rosy.net.cn/baseapi/platformapi/jdapi"
"git.rosy.net.cn/baseapi/platformapi/weimobapi"
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
"github.com/360EntSecGroup-Skylar/excelize"
)
var (
sheetNames = []string{"蔬菜", "水果", "肉禽", "净配", "水产", "干货", "MINI肉禽价格"}
)
//sheet1 蔬菜
var (
sheet1SkuIdCol = 0
sheet1SkuPriceCol = 14
sheet1OrgSkuIdCol = 5
sheet1OrgSkuPriceCol = 8
)
func SendFilesToStores(ctx *jxcontext.Context, files []*multipart.FileHeader) (hint string, err error) {
var (
// skuId string
// skuPrice string
skuMap = make(map[string]string)
)
param := &weimobapi.QueryGoodsListParam{
PageNum: 1,
PageSize: jdapi.MaxSkuIDsCount4QueryListBySkuIds,
}
// if len(files) == 0 {
// return "", errors.New("没有文件上传!")
// }
xlsx, err := excelize.OpenFile("111.xlsx")
if err != nil {
fmt.Println(err)
return
}
for _, v := range sheetNames {
// goodsParam := &weimobapi.GoodsParameter{}
rows, _ := xlsx.GetRows(v)
switch v {
case "蔬菜":
for _, row := range rows {
for k, _ := range row {
if k == sheet1SkuIdCol {
}
// if !IsChineseChar(colCell) {
// }
}
fmt.Println()
}
}
}
// xlFile, err := xlsx.OpenFile("111.xlsx")
// if err != nil {
// errors.New(err.Error())
// }
// excelize
// for _, sheet := range xlFile.Sheets {
// if sheet.Name == "蔬菜" {
// for j := 0; j < len(sheet.Rows); j++ {
// cells := sheet.Rows[j].Cells
// for i := 0; i < len(cells); i++ {
// cell := cells[i]
// if i == 0 {
// if _, err := strconv.Atoi(cell.String()); err != nil || cell.String() == "" {
// continue
// }
// skuId = cell.String()
// }
// if i == 14 {
// skuPrice = cell.String()
// }
// skuMap[skuId] = skuPrice
// }
// }
// }
// }
for k, v := range skuMap {
fmt.Println(k)
fmt.Println(v)
}
GetWeiMoGoodsList(param)
return "", err
}
func GetWeiMoGoodsList(param *weimobapi.QueryGoodsListParam) {
// for {
// skuList, _, err2 := getAPI("").QuerySkuInfos(param)
// if err = err2; err != nil {
// return nil, err
// }
// if len(skuList) > 0 {
// batchSkuNameList := make([]*partner.SkuNameInfo, len(skuList))
// for k, v := range skuList {
// batchSkuNameList[k] = vendorSku2Jx(v)
// }
// setSkuNameListPic(batchSkuNameList)
// skuNameList = append(skuNameList, batchSkuNameList...)
// }
// if len(skuList) < param.PageSize {
// break
// }
// param.PageNum++
// }
}
func IsChineseChar(str string) bool {
for _, r := range str {
if unicode.Is(unicode.Scripts["Han"], r) {
return true
}
}
return false
}

27
controllers/yonghui.go Normal file
View File

@@ -0,0 +1,27 @@
package controllers
import (
"git.rosy.net.cn/jx-callback/business/jxstore/yonghui"
"github.com/astaxie/beego"
)
//读取永辉excelAPI
type YongHuiController struct {
beego.Controller
}
// @Title 读取永辉excel文件
// @Description 读取永辉excel文件
// @Param token header string true "认证token"
// @Param isAsync query bool false "是否异步,缺省是同步"
// @Success 200 {object} controllers.CallResult
// @Failure 200 {object} controllers.CallResult
// @router /LoadExcelByYongHui [post]
func (c *YongHuiController) LoadExcelByYongHui() {
c.callLoadExcelByYongHui(func(params *tYonghuiLoadExcelByYongHuiParams) (retVal interface{}, errCode string, err error) {
r := c.Ctx.Request
files := r.MultipartForm.File["userfiles"]
retVal, err = yonghui.SendFilesToStores(params.Ctx, files)
return retVal, "", err
})
}

View File

@@ -1998,4 +1998,13 @@ func init() {
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:YongHuiController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:YongHuiController"],
beego.ControllerComments{
Method: "LoadExcelByYongHui",
Router: `/LoadExcelByYongHui`,
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
}

View File

@@ -126,6 +126,11 @@ func init() {
&controllers.ReportController{},
),
),
beego.NSNamespace("/yonghui",
beego.NSInclude(
&controllers.YongHuiController{},
),
),
)
beego.AddNamespace(ns)