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/dao"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
"git.rosy.net.cn/jx-callback/globals/api"
|
||||
"github.com/qiniu/api.v7/storage"
|
||||
//"git.rosy.net.cn/jx-callback/globals/api"
|
||||
//"github.com/qiniu/api.v7/storage"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -49,25 +49,26 @@ func Binary2Image(binaryData []byte, mimeType string) (img image.Image, outMimeT
|
||||
return img, mimeType, err
|
||||
}
|
||||
|
||||
func GetQiniuUploadToken(ctx *jxcontext.Context, suffix, hashCode string) (upTokenInfo *UploadResTokenInfo, err error) {
|
||||
imgURL := ""
|
||||
if hashCode != "" {
|
||||
imgURL, _ = GetDataResource(ctx, hashCode)
|
||||
}
|
||||
|
||||
putPolicy := storage.PutPolicy{
|
||||
Scope: globals.QiniuBucket,
|
||||
Expires: qiniuTokenExpires,
|
||||
}
|
||||
upTokenInfo = &UploadResTokenInfo{
|
||||
Token: putPolicy.UploadToken(api.QiniuAPI),
|
||||
Expires: putPolicy.Expires,
|
||||
FileName: jxutils.GenPicFileName(suffix),
|
||||
Hit: imgURL != "",
|
||||
Img: imgURL,
|
||||
}
|
||||
return upTokenInfo, err
|
||||
}
|
||||
//
|
||||
//func GetQiniuUploadToken(ctx *jxcontext.Context, suffix, hashCode string) (upTokenInfo *UploadResTokenInfo, err error) {
|
||||
// imgURL := ""
|
||||
// if hashCode != "" {
|
||||
// imgURL, _ = GetDataResource(ctx, hashCode)
|
||||
// }
|
||||
//
|
||||
// putPolicy := storage.PutPolicy{
|
||||
// Scope: globals.QiniuBucket,
|
||||
// Expires: qiniuTokenExpires,
|
||||
// }
|
||||
// upTokenInfo = &UploadResTokenInfo{
|
||||
// Token: putPolicy.UploadToken(api.QiniuAPI),
|
||||
// Expires: putPolicy.Expires,
|
||||
// FileName: jxutils.GenPicFileName(suffix),
|
||||
// Hit: imgURL != "",
|
||||
// Img: imgURL,
|
||||
// }
|
||||
// return upTokenInfo, err
|
||||
//}
|
||||
|
||||
// 此函数要求resBinary不能空,mimeType与hashCode必须是正确的
|
||||
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
|
||||
}
|
||||
if imgType > 0 {
|
||||
if globals.EnableStoreWrite {
|
||||
// 忽略上传错误
|
||||
UploadImage2Vendors(ctx, nil, dataRes, resBinary, isAsyncUpload2Vendor)
|
||||
}
|
||||
//if globals.EnableStoreWrite {
|
||||
// 忽略上传错误
|
||||
UploadImage2Vendors(ctx, nil, dataRes, resBinary, isAsyncUpload2Vendor)
|
||||
//}
|
||||
}
|
||||
return dataRes, err
|
||||
}
|
||||
|
||||
@@ -1,32 +1,25 @@
|
||||
package datares
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
||||
"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/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() {
|
||||
testinit.Init()
|
||||
api2.Init()
|
||||
}
|
||||
|
||||
func TestGetQiniuUploadToken(t *testing.T) {
|
||||
token, err := GetQiniuUploadToken(jxcontext.AdminCtx, "", "")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
fmt.Print(token)
|
||||
}
|
||||
//func TestGetQiniuUploadToken(t *testing.T) {
|
||||
// token, err := GetQiniuUploadToken(jxcontext.AdminCtx, "", "")
|
||||
// if err != nil {
|
||||
// t.Fatal(err)
|
||||
// }
|
||||
// fmt.Print(token)
|
||||
//}
|
||||
|
||||
func TestGetDataResource(t *testing.T) {
|
||||
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 {
|
||||
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 {
|
||||
return nil, errors.New("查询错误/收货地址信息不正确")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user