1
This commit is contained in:
@@ -15,8 +15,8 @@ import (
|
|||||||
"git.rosy.net.cn/jx-callback/business/model"
|
"git.rosy.net.cn/jx-callback/business/model"
|
||||||
"git.rosy.net.cn/jx-callback/business/model/dao"
|
"git.rosy.net.cn/jx-callback/business/model/dao"
|
||||||
"git.rosy.net.cn/jx-callback/globals"
|
"git.rosy.net.cn/jx-callback/globals"
|
||||||
"git.rosy.net.cn/jx-callback/globals/api"
|
//"git.rosy.net.cn/jx-callback/globals/api"
|
||||||
"github.com/qiniu/api.v7/storage"
|
//"github.com/qiniu/api.v7/storage"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -49,25 +49,26 @@ func Binary2Image(binaryData []byte, mimeType string) (img image.Image, outMimeT
|
|||||||
return img, mimeType, err
|
return img, mimeType, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetQiniuUploadToken(ctx *jxcontext.Context, suffix, hashCode string) (upTokenInfo *UploadResTokenInfo, err error) {
|
//
|
||||||
imgURL := ""
|
//func GetQiniuUploadToken(ctx *jxcontext.Context, suffix, hashCode string) (upTokenInfo *UploadResTokenInfo, err error) {
|
||||||
if hashCode != "" {
|
// imgURL := ""
|
||||||
imgURL, _ = GetDataResource(ctx, hashCode)
|
// if hashCode != "" {
|
||||||
}
|
// imgURL, _ = GetDataResource(ctx, hashCode)
|
||||||
|
// }
|
||||||
putPolicy := storage.PutPolicy{
|
//
|
||||||
Scope: globals.QiniuBucket,
|
// putPolicy := storage.PutPolicy{
|
||||||
Expires: qiniuTokenExpires,
|
// Scope: globals.QiniuBucket,
|
||||||
}
|
// Expires: qiniuTokenExpires,
|
||||||
upTokenInfo = &UploadResTokenInfo{
|
// }
|
||||||
Token: putPolicy.UploadToken(api.QiniuAPI),
|
// upTokenInfo = &UploadResTokenInfo{
|
||||||
Expires: putPolicy.Expires,
|
// Token: putPolicy.UploadToken(api.QiniuAPI),
|
||||||
FileName: jxutils.GenPicFileName(suffix),
|
// Expires: putPolicy.Expires,
|
||||||
Hit: imgURL != "",
|
// FileName: jxutils.GenPicFileName(suffix),
|
||||||
Img: imgURL,
|
// Hit: imgURL != "",
|
||||||
}
|
// Img: imgURL,
|
||||||
return upTokenInfo, err
|
// }
|
||||||
}
|
// return upTokenInfo, err
|
||||||
|
//}
|
||||||
|
|
||||||
// 此函数要求resBinary不能空,mimeType与hashCode必须是正确的
|
// 此函数要求resBinary不能空,mimeType与hashCode必须是正确的
|
||||||
func RegisterDataResource(ctx *jxcontext.Context, name, resourceURL, mimeType, hashCode string, resBinary []byte, imgType int, isAsyncUpload2Vendor bool) (dataRes *model.DataResource, err error) {
|
func RegisterDataResource(ctx *jxcontext.Context, name, resourceURL, mimeType, hashCode string, resBinary []byte, imgType int, isAsyncUpload2Vendor bool) (dataRes *model.DataResource, err error) {
|
||||||
@@ -108,10 +109,10 @@ func RegisterDataResource(ctx *jxcontext.Context, name, resourceURL, mimeType, h
|
|||||||
return dataRes, err
|
return dataRes, err
|
||||||
}
|
}
|
||||||
if imgType > 0 {
|
if imgType > 0 {
|
||||||
if globals.EnableStoreWrite {
|
//if globals.EnableStoreWrite {
|
||||||
// 忽略上传错误
|
// 忽略上传错误
|
||||||
UploadImage2Vendors(ctx, nil, dataRes, resBinary, isAsyncUpload2Vendor)
|
UploadImage2Vendors(ctx, nil, dataRes, resBinary, isAsyncUpload2Vendor)
|
||||||
}
|
//}
|
||||||
}
|
}
|
||||||
return dataRes, err
|
return dataRes, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,32 +1,25 @@
|
|||||||
package datares
|
package datares
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"git.rosy.net.cn/baseapi/utils"
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
||||||
"git.rosy.net.cn/jx-callback/business/model"
|
"git.rosy.net.cn/jx-callback/business/model"
|
||||||
"git.rosy.net.cn/jx-callback/globals/api2"
|
|
||||||
"git.rosy.net.cn/jx-callback/globals/testinit"
|
"git.rosy.net.cn/jx-callback/globals/testinit"
|
||||||
|
|
||||||
_ "git.rosy.net.cn/jx-callback/business/partner/purchase/ebai"
|
|
||||||
_ "git.rosy.net.cn/jx-callback/business/partner/purchase/jd"
|
|
||||||
_ "git.rosy.net.cn/jx-callback/business/partner/purchase/mtwm"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
testinit.Init()
|
testinit.Init()
|
||||||
api2.Init()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGetQiniuUploadToken(t *testing.T) {
|
//func TestGetQiniuUploadToken(t *testing.T) {
|
||||||
token, err := GetQiniuUploadToken(jxcontext.AdminCtx, "", "")
|
// token, err := GetQiniuUploadToken(jxcontext.AdminCtx, "", "")
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
t.Fatal(err)
|
// t.Fatal(err)
|
||||||
}
|
// }
|
||||||
fmt.Print(token)
|
// fmt.Print(token)
|
||||||
}
|
//}
|
||||||
|
|
||||||
func TestGetDataResource(t *testing.T) {
|
func TestGetDataResource(t *testing.T) {
|
||||||
dataRes, err := GetDataResource(jxcontext.AdminCtx, "1D3E4A8259F359FB4CF47D541843950D")
|
dataRes, err := GetDataResource(jxcontext.AdminCtx, "1D3E4A8259F359FB4CF47D541843950D")
|
||||||
|
|||||||
@@ -566,12 +566,12 @@ func TryAgainOrder(ctx *jxcontext.Context, oldNo string) (*model.UserVendorOrder
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 获取用户发货地址信息
|
// 获取用户发货地址信息
|
||||||
sendAddress, countSend, err := dao.QueryUserDeliveryAddress(dao.GetDB(), oldOrder.SenderAddressID, nil, 0, 1, 10)
|
sendAddress, countSend, err := dao.QueryUserDeliveryAddress(dao.GetDB(), oldOrder.SenderAddressID, nil, 0, 0, 10)
|
||||||
if err != nil || countSend != model.YES {
|
if err != nil || countSend != model.YES {
|
||||||
return nil, errors.New("查询错误/送货地址信息不正确")
|
return nil, errors.New("查询错误/送货地址信息不正确")
|
||||||
}
|
}
|
||||||
// 获取用户收货
|
// 获取用户收货
|
||||||
receiveAddress, receiveSend, err := dao.QueryUserDeliveryAddress(dao.GetDB(), oldOrder.SenderAddressID, nil, 0, 1, 10)
|
receiveAddress, receiveSend, err := dao.QueryUserDeliveryAddress(dao.GetDB(), oldOrder.ReceiveAddressID, nil, 0, 0, 10)
|
||||||
if err != nil || receiveSend != model.YES {
|
if err != nil || receiveSend != model.YES {
|
||||||
return nil, errors.New("查询错误/收货地址信息不正确")
|
return nil, errors.New("查询错误/收货地址信息不正确")
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user