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

This commit is contained in:
richboo111
2023-08-11 14:17:58 +08:00
4 changed files with 32 additions and 267 deletions

View File

@@ -1221,7 +1221,7 @@ func jxOrder2GoodsOrder(ctx *jxcontext.Context, jxOrder *JxOrderInfo, deliveryAd
order.Flag = 1
if jxOrder.OrderType == model.OrderTypeMatter {
order.WaybillVendorID = model.VendorIDJDWL
order.ConsigneeAddress = deliveryAddress.Address
order.ConsigneeAddress = fmt.Sprintf("%s%s", deliveryAddress.Address, deliveryAddress.DetailAddress)
}
}
//如果是自提单就设置

View File

@@ -1,13 +1,8 @@
package tao_vegetable
import (
"bytes"
"fmt"
"io/ioutil"
"net/http"
"regexp"
"strings"
"time"
"git.rosy.net.cn/baseapi/platformapi/mtwmapi"
"git.rosy.net.cn/baseapi/platformapi/tao_vegetable"
request1475 "git.rosy.net.cn/baseapi/platformapi/tao_vegetable/sdk/ability1475/request"
@@ -26,6 +21,12 @@ import (
"git.rosy.net.cn/jx-callback/business/partner"
"git.rosy.net.cn/jx-callback/business/partner/putils"
"git.rosy.net.cn/jx-callback/globals"
"image/jpeg"
"io/ioutil"
"net/http"
"regexp"
"strings"
"time"
)
const (
@@ -445,6 +446,22 @@ func checkNameLength(name string, weight int, uint string) string {
return lastName[0:60]
}
// 图片压缩,大于3M
func decodeImg(data []byte) []byte {
if float64(len(data))/float64(1024)/float64(1024) > float64(3) {
jpgimg, err := jpeg.Decode(strings.NewReader(string(data))) // 文件解码成图像对象
if err != nil {
return nil
}
var buf bytes.Buffer
err = jpeg.Encode(&buf, jpgimg, &jpeg.Options{Quality: 30})
if err != nil {
return nil
}
return buf.Bytes()
}
return data
}
func uploadImg(api *tao_vegetable.API, skuId, vendorId int, imgs []string) *string {
vendorImg, _ := dao.GetVendorImg(skuId, vendorId)
result := make([]string, 0, 0)
@@ -468,6 +485,8 @@ func uploadImg(api *tao_vegetable.API, skuId, vendorId int, imgs []string) *stri
if strings.Contains(string(body), "Document not found") || len(body) == 0 {
continue
}
// 检查图片大小
body = decodeImg(body)
newImg, _ := api.UploadImg(&request1475.AlibabaWdkPictureUploadRequest{
PictureCategoryId: utils.Int64ToPointer(0),
Img: &body,
@@ -563,6 +582,7 @@ func (p *PurchaseHandler) UpdateStoreSkusStatus(ctx *jxcontext.Context, vendorOr
SkuCode: utils.String2Pointer(utils.Int2Str(v.SkuID)),
OnlineSaleFlag: utils.Int64ToPointer(onlineStatus),
SubTitle: utils.String2Pointer("小时达"),
AllowAppSale: utils.Int64ToPointer(onlineStatus),
//CleanSkuMemberPrice: utils.Int64ToPointer(model.YES),
}
updateSkuList = append(updateSkuList, updateSku)