feat: 添加版本号显示, 最低书价改为读取kfz_config表
This commit is contained in:
parent
e26d7a027e
commit
811c8ab457
@ -12,6 +12,8 @@ import (
|
|||||||
"unsafe"
|
"unsafe"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const version = "v1.0.0"
|
||||||
|
|
||||||
// Win32 常量
|
// Win32 常量
|
||||||
const (
|
const (
|
||||||
WS_OVERLAPPEDWINDOW = 0x00CF0000
|
WS_OVERLAPPEDWINDOW = 0x00CF0000
|
||||||
@ -198,7 +200,7 @@ func runGUI() {
|
|||||||
hInstance, _, _ := pGetModuleHandleW.Call(0)
|
hInstance, _, _ := pGetModuleHandleW.Call(0)
|
||||||
|
|
||||||
className, _ := syscall.UTF16PtrFromString("KfzLogWnd")
|
className, _ := syscall.UTF16PtrFromString("KfzLogWnd")
|
||||||
windowTitle, _ := syscall.UTF16PtrFromString("孔网商品定价 - 日志")
|
windowTitle, _ := syscall.UTF16PtrFromString("孔网商品定价 " + version + " - 日志")
|
||||||
editClass, _ := syscall.UTF16PtrFromString("EDIT")
|
editClass, _ := syscall.UTF16PtrFromString("EDIT")
|
||||||
|
|
||||||
hCursor, _, _ := pLoadCursorW.Call(0, IDC_ARROW)
|
hCursor, _, _ := pLoadCursorW.Call(0, IDC_ARROW)
|
||||||
|
|||||||
@ -17,6 +17,8 @@ func main() {
|
|||||||
// 日志输出到GUI窗口
|
// 日志输出到GUI窗口
|
||||||
log.SetOutput(&guiLogWriter{})
|
log.SetOutput(&guiLogWriter{})
|
||||||
|
|
||||||
|
log.Printf("孔网商品定价 %s 启动中...", version)
|
||||||
|
|
||||||
// 加载配置
|
// 加载配置
|
||||||
cfg, err := config.Load("./config/config.yaml")
|
cfg, err := config.Load("./config/config.yaml")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Binary file not shown.
@ -106,7 +106,7 @@ func (s *GoodsService) rateLimitWait() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// sendCallback 发送回调请求
|
// sendCallback 发送回调请求
|
||||||
func (s *GoodsService) sendCallback(outID, userID string, price, shippingFee float64) {
|
func (s *GoodsService) sendCallback(outID, userID string, price, shippingFee float64, minPrice float64) {
|
||||||
if s.callbackURL == "" {
|
if s.callbackURL == "" {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -128,6 +128,7 @@ func (s *GoodsService) sendCallback(outID, userID string, price, shippingFee flo
|
|||||||
if len(errs) > 0 {
|
if len(errs) > 0 {
|
||||||
log.Printf("回调失败: %v", errs)
|
log.Printf("回调失败: %v", errs)
|
||||||
} else {
|
} else {
|
||||||
|
log.Printf("最低书价:%v", minPrice)
|
||||||
log.Printf("回调成功: product_id=%s, user_id=%s, sale_price=%d, cost=%d", outID, userID, salePrice, cost)
|
log.Printf("回调成功: product_id=%s, user_id=%s, sale_price=%d, cost=%d", outID, userID, salePrice, cost)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -185,8 +186,8 @@ func (s *GoodsService) syncGoodsPricing() {
|
|||||||
shippingFee, _ = strconv.ParseFloat(bookInfo.ShippingFee, 64)
|
shippingFee, _ = strconv.ParseFloat(bookInfo.ShippingFee, 64)
|
||||||
totalPrice := price + shippingFee
|
totalPrice := price + shippingFee
|
||||||
finalPrice = totalPrice - record.PlaceholderDownPrice - record.MinShippingFee
|
finalPrice = totalPrice - record.PlaceholderDownPrice - record.MinShippingFee
|
||||||
if finalPrice < record.MinPrice {
|
if finalPrice < kfzConfig.MinPrice {
|
||||||
finalPrice = record.MinPrice
|
finalPrice = kfzConfig.MinPrice
|
||||||
}
|
}
|
||||||
// 保留两位小数
|
// 保留两位小数
|
||||||
finalPrice, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", finalPrice), 64)
|
finalPrice, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", finalPrice), 64)
|
||||||
@ -200,7 +201,7 @@ func (s *GoodsService) syncGoodsPricing() {
|
|||||||
log.Printf("定时任务[%d]更新成功: price=%.2f, shipping_fee=%.2f", record.ID, price, shippingFee)
|
log.Printf("定时任务[%d]更新成功: price=%.2f, shipping_fee=%.2f", record.ID, price, shippingFee)
|
||||||
|
|
||||||
// 调用回调
|
// 调用回调
|
||||||
s.sendCallback(record.OutID, record.UserID, finalPrice, record.MinShippingFee)
|
s.sendCallback(record.OutID, record.UserID, finalPrice, record.MinShippingFee, kfzConfig.MinPrice)
|
||||||
}
|
}
|
||||||
|
|
||||||
// outGetAllGoods 爬取孔网所有商品页面
|
// outGetAllGoods 爬取孔网所有商品页面
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user