Merge branch 'mark' of git.coding.net:XJH-Rosy/jx-callback into mark
This commit is contained in:
@@ -468,6 +468,7 @@ func WriteToExcel(task *tasksch.SeqTask, data map[int][]DiffData) {
|
||||
|
||||
if len(sheetList) > 0 {
|
||||
excelBin := excel.Obj2Excel(sheetList)
|
||||
sheetList = nil
|
||||
timeStr := utils.Int64ToStr(time.Now().Unix())
|
||||
diffFullFileName := diffFileName[IsJXCS()] + timeStr + fileExt
|
||||
if canWriteTolocal {
|
||||
|
||||
@@ -588,7 +588,7 @@ func AddCreateFlagForJxStoreSku(ctx *jxcontext.Context, parentTask tasksch.ITask
|
||||
storeSkuBindIDs = append(storeSkuBindIDs, v.BindID)
|
||||
}
|
||||
}
|
||||
storeSkuBindIDs = nil
|
||||
localSkuList = nil
|
||||
}
|
||||
case 1:
|
||||
if len(storeSkuBindIDs) > 0 {
|
||||
|
||||
@@ -11,12 +11,26 @@ import (
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"errors"
|
||||
"image"
|
||||
"image/png"
|
||||
"bytes"
|
||||
"encoding/base64"
|
||||
"git.rosy.net.cn/baseapi/platformapi"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
"git.rosy.net.cn/jx-callback/business/model/dao"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
"github.com/boombuler/barcode"
|
||||
"github.com/boombuler/barcode/qr"
|
||||
"github.com/boombuler/barcode/code128"
|
||||
)
|
||||
|
||||
const (
|
||||
MaxCodeWidth = 400
|
||||
MaxCodeHeight = 400
|
||||
CodeTypeQr = "qr"
|
||||
CodeTypeBar = "bar"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -451,3 +465,37 @@ func CaculateSkuEarningPrice(shopPrice, salePrice int64, storePayPercentage int)
|
||||
earningPrice = earningPrice * int64(storePayPercentage) / 100
|
||||
return earningPrice
|
||||
}
|
||||
|
||||
func GetImgBase64(img image.Image) (imgBase64 string, err error) {
|
||||
bufWriter := bytes.NewBuffer(nil)
|
||||
png.Encode(bufWriter, img)
|
||||
imgBase64 = "data:image/png;base64," + base64.StdEncoding.EncodeToString(bufWriter.Bytes())
|
||||
|
||||
return imgBase64, err
|
||||
}
|
||||
|
||||
func CreateQrOrBarCode(width, height int, codeType, srcData string) (imgBase64 string, err error) {
|
||||
if width > MaxCodeWidth {
|
||||
width = MaxCodeWidth
|
||||
}
|
||||
if height > MaxCodeHeight {
|
||||
height = MaxCodeHeight
|
||||
}
|
||||
|
||||
var code barcode.Barcode
|
||||
if codeType == CodeTypeQr {
|
||||
code, err = qr.Encode(srcData, qr.M, qr.Auto)
|
||||
} else if codeType == CodeTypeBar {
|
||||
code, err = code128.Encode(srcData)
|
||||
} else {
|
||||
err = errors.New(fmt.Sprintf("未知编码类型:%s", codeType))
|
||||
}
|
||||
if err == nil {
|
||||
code, err = barcode.Scale(code, width, height)
|
||||
if err == nil {
|
||||
imgBase64, err = GetImgBase64(code)
|
||||
}
|
||||
}
|
||||
|
||||
return imgBase64, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user