132 lines
5.0 KiB
Go
132 lines
5.0 KiB
Go
package jdshop
|
|
|
|
import (
|
|
"encoding/base64"
|
|
"encoding/json"
|
|
|
|
"git.rosy.net.cn/baseapi/platformapi/jdshopapi"
|
|
"git.rosy.net.cn/baseapi/utils"
|
|
"git.rosy.net.cn/jx-callback/business/jxutils"
|
|
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
|
"git.rosy.net.cn/jx-callback/business/jxutils/tasksch"
|
|
"git.rosy.net.cn/jx-callback/business/model"
|
|
"git.rosy.net.cn/jx-callback/business/model/dao"
|
|
"git.rosy.net.cn/jx-callback/globals/api"
|
|
)
|
|
|
|
func (p *PurchaseHandler) ReadStore(ctx *jxcontext.Context, vendorOrgCode, vendorStoreID string) (storeDetail *dao.StoreDetail, err error) {
|
|
return storeDetail, err
|
|
}
|
|
|
|
// stoerIDs为nil表示所有
|
|
func (p *PurchaseHandler) UpdateStore(db *dao.DaoDB, storeID int, userName string) (err error) {
|
|
store, err := dao.GetStoreDetail(db, storeID, model.VendorIDJDShop)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
data, _, err := jxutils.DownloadFileByURL(jdshopapi.JdsStoreImg)
|
|
timeMap := map[string]string{
|
|
"businessBeginTime": int2TimeStr(int(store.OpenTime1)),
|
|
"businessEndTime": int2TimeStr(int(store.CloseTime1)),
|
|
}
|
|
timeJSON, _ := json.Marshal(timeMap)
|
|
updateEntityStoreParam := &jdshopapi.UpdateEntityStoreParam{
|
|
StoreID: utils.Str2Int(store.VendorStoreID),
|
|
Name: store.Name,
|
|
AddCode: store.JdsCode,
|
|
AddCodeName: store.DistrictName,
|
|
AddName: store.ProvinceName + store.CityName + store.DistrictName + "@!" + store.Address,
|
|
Coordinate: utils.Float64ToStr(jxutils.IntCoordinate2Standard(store.Lat)) + "," + utils.Float64ToStr(jxutils.IntCoordinate2Standard(store.Lng)),
|
|
Phone: store.Tel1,
|
|
ExtendJSON: string(timeJSON),
|
|
ImageFile: base64.StdEncoding.EncodeToString(data),
|
|
}
|
|
err = api.JdShopAPI.UpdateEntityStore(updateEntityStoreParam)
|
|
if err == nil {
|
|
if store.SyncStatus&(model.SyncFlagNewMask|model.SyncFlagStoreStatus) != 0 {
|
|
mergeStatus := jxutils.MergeStoreStatus(store.Status, store.VendorStatus)
|
|
err = api.JdShopAPI.UpdateStoreStatus(utils.Str2Int(store.VendorStoreID), jxStatus2JdsStatus(mergeStatus))
|
|
}
|
|
}
|
|
return err
|
|
}
|
|
|
|
func (p *PurchaseHandler) CreateStore2(db *dao.DaoDB, storeID int, userName string) (vendorStoreID string, err error) {
|
|
store, err := dao.GetStoreDetail(db, storeID, model.VendorIDJDShop)
|
|
if err != nil {
|
|
return vendorStoreID, err
|
|
}
|
|
data, _, err := jxutils.DownloadFileByURL(jdshopapi.JdsStoreImg)
|
|
timeMap := map[string]string{
|
|
"businessBeginTime": int2TimeStr(int(store.OpenTime1)),
|
|
"businessEndTime": int2TimeStr(int(store.CloseTime1)),
|
|
}
|
|
timeJSON, _ := json.Marshal(timeMap)
|
|
createEntityStoreParam := &jdshopapi.CreateEntityStoreParam{
|
|
Name: store.Name,
|
|
AddCode: store.JdsCode,
|
|
AddCodeName: store.DistrictName,
|
|
AddName: store.ProvinceName + store.CityName + store.DistrictName + "@!" + store.Address,
|
|
Coordinate: utils.Float64ToStr(jxutils.IntCoordinate2Standard(store.Lat)) + "," + utils.Float64ToStr(jxutils.IntCoordinate2Standard(store.Lng)),
|
|
Phone: store.Tel1,
|
|
ExtendJSON: string(timeJSON),
|
|
ImageFile: base64.StdEncoding.EncodeToString(data),
|
|
CategoryName: jdshopapi.JdsStoreCategoryName,
|
|
CustomerID: utils.Int2Str(store.ID),
|
|
}
|
|
vendorStoreID, err = api.JdShopAPI.CreateEntityStore(createEntityStoreParam)
|
|
return vendorStoreID, err
|
|
}
|
|
|
|
func (p *PurchaseHandler) DeleteStore(db *dao.DaoDB, storeID int, userName string) (err error) {
|
|
return err
|
|
}
|
|
|
|
func (p *PurchaseHandler) RefreshAllStoresID(ctx *jxcontext.Context, parentTask tasksch.ITask, isAsync bool) (hint string, err error) {
|
|
return hint, err
|
|
}
|
|
|
|
func (p *PurchaseHandler) GetStoreStatus(ctx *jxcontext.Context, vendorOrgCode string, storeID int, vendorStoreID string) (storeStatus int, err error) {
|
|
return storeStatus, err
|
|
}
|
|
|
|
func (p *PurchaseHandler) EnableAutoAcceptOrder(ctx *jxcontext.Context, vendorOrgCode string, storeID int, vendorStoreID string, isSetEnable bool) (err error) {
|
|
return err
|
|
}
|
|
|
|
func (c *PurchaseHandler) UpdateStoreStatus(ctx *jxcontext.Context, vendorOrgCode string, storeID int, vendorStoreID string, status int) (err error) {
|
|
return err
|
|
}
|
|
|
|
func (c *PurchaseHandler) UpdateStoreOpTime(ctx *jxcontext.Context, vendorOrgCode string, storeID int, vendorStoreID string, opTimeList []int16) (err error) {
|
|
return err
|
|
}
|
|
|
|
func (c *PurchaseHandler) GetAllStoresVendorID(ctx *jxcontext.Context, vendorOrgCode string) (vendorStoreIDs []string, err error) {
|
|
return vendorStoreIDs, err
|
|
}
|
|
|
|
func (c *PurchaseHandler) UpdateStoreCustomID(ctx *jxcontext.Context, vendorOrgCode, vendorStoreID string, storeID int64) (err error) {
|
|
return err
|
|
}
|
|
|
|
func int2TimeStr(time int) (str string) {
|
|
str += utils.Int2Str(time / 1000)
|
|
str += utils.Int2Str(time % 1000 / 100)
|
|
str += ":"
|
|
str += utils.Int2Str(time % 100 / 10)
|
|
str += utils.Int2Str(time % 10)
|
|
return str
|
|
}
|
|
|
|
func jxStatus2JdsStatus(status int) (result int) {
|
|
if status == model.StoreStatusOpened {
|
|
result = jdshopapi.JdsStoreStatusOnline
|
|
} else if status == model.StoreStatusHaveRest || status == model.StoreStatusClosed {
|
|
result = jdshopapi.JdsStoreStatusRest
|
|
} else {
|
|
result = jdshopapi.JdsStoreStatusDisable
|
|
}
|
|
return result
|
|
}
|