发送未设置售价商品至邮箱

master
datang 3 years ago
parent c884a8fa36
commit c3d300a531

@ -92,7 +92,9 @@ func init() {
//诺诺企业税号
ConfigNuoTaxNum = "91330212MA2AE2QQXR"
ConfigJTEmail = "zhjq@cn-recook.com"
//新增sku邮件地址
ConfigJTEmail = "monsoon.zhu@akuhome.com" //"zhjq@cn-recook.com"
ConfigImageUrl = "https://jyycdn.reecook.cn/static"
ConfigEsAddress = "http://127.0.0.1:9200/recook/_analyze?pretty=true"
@ -136,7 +138,7 @@ func init() {
//诺诺企业税号
//ConfigNuoTaxNum = "339901999999824"
ConfigNuoTaxNum = "339901999999142"
ConfigJTEmail = "792209833@qq.com"
ConfigJTEmail = "monsoon.zhu@akuhome.com"
ConfigImageUrl = "https://testcdn.reecook.cn/static"
////诺诺身份认证

@ -26,7 +26,7 @@ type queryOrderGoodsListParam struct {
SecondCategoryID uint `json:"secondCategoryID"`
BrandID uint `json:"brandID"`
Page uint `json:"page"`
Order string `json:"order"` /*asc 序 desc 降序*/
Order string `json:"order"` /*asc 序 desc 降序*/
Keyword string `json:"keyword" form:"keyword"` /* 搜索的关键字 */
CountryId uint `json:"country_id"`
UserId uint `json:"user_id"`
@ -191,6 +191,7 @@ func QueryGoodsListByDiscountPrice(c *gin.Context) {
back.Fail(c, err.Error())
return
}
if p.SecondCategoryID == 0 && p.BrandID == 0 && len(p.Keyword) == 0 && p.ActivityID == 0 {
back.Fail(c, "参数不全")
return

@ -4,6 +4,9 @@ import (
"errors"
"fmt"
"git.oa00.com/go/mysql"
"github.com/gin-gonic/gin"
"github.com/jinzhu/gorm"
"github.com/shopspring/decimal"
"log"
"math"
"recook/configs"
@ -22,10 +25,6 @@ import (
"recook/tools"
"strconv"
"time"
"github.com/gin-gonic/gin"
"github.com/jinzhu/gorm"
"github.com/shopspring/decimal"
)
/*普通订单预览的参数*/

@ -16,7 +16,7 @@ type Sku struct {
CombineID string `gorm:"column:combine_id" json:"combineId"`
PicURL string `gorm:"column:pic_url" json:"picUrl"`
Code string `gorm:"column:code" json:"code"`
PurchasePrice decimal.Decimal `gorm:"column:purchase_price" json:"purchasePrice"`
PurchasePrice decimal.Decimal `gorm:"column:purchase_price" json:"purchasePrice"` //采购价
OriginalPrice decimal.Decimal `gorm:"column:original_price" json:"originalPrice"` // 原价
DiscountPrice decimal.Decimal `gorm:"column:discount_price" json:"discountPrice"` // 折扣价
CommissionRate decimal.Decimal `gorm:"column:commission_rate" json:"commissionRate"` // 佣金比

@ -50,7 +50,8 @@ func init() {
}
}
} else {
f.Root = "/Users/mac/Desktop/recookMain/static"
f.Root = "/Users/datang/backend_v2/static"
//f.Root = "/Users/mac/Desktop/recookMain/static"
//f.Root = "/Users/apple/go/src/recookMain/static"
}

@ -135,8 +135,8 @@ func (a ControllerActive) ActivityList(c *gin.Context) {
func (a ControllerActive) AddCountryId(c *gin.Context) {
var jt []manage.RecookThirdPartyJingtongDetailModel
mysql2.Db.Table((&manage.RecookThirdPartyJingtongDetailModel{}).TableName()).Find(&jt)
var jt []manage.RecookThirdPartyDetailModel
mysql2.Db.Table((&manage.RecookThirdPartyDetailModel{}).TableName()).Find(&jt)
for _, v := range jt {
var contry1 manage.ThirdCountry
mysql2.Db.Table(contry1.TableName()).Where("id=?", v.CountryId).First(&contry1)

@ -0,0 +1,566 @@
package task
import (
"encoding/base64"
"errors"
"fmt"
mysql2 "git.oa00.com/go/mysql"
"github.com/360EntSecGroup-Skylar/excelize/v2"
"github.com/gin-gonic/gin"
"github.com/golangkit/formatime"
"github.com/jinzhu/gorm"
"github.com/shopspring/decimal"
"gopkg.in/gomail.v2"
"log"
"path/filepath"
"recook/configs"
"recook/internal/static_path"
"recook/internal/v2/lib/back"
"recook/internal/v2/lib/common"
"recook/internal/v2/lib/excel"
"recook/internal/v2/lib/jingtong"
"recook/internal/v2/model/gys/enterprise"
"recook/internal/v2/model/recook/goods"
manage2 "recook/internal/v2/model/recook/order"
"recook/internal/v2/model/recook/user"
manage "recook/internal/v2/model/third"
"recook/tools"
"regexp"
"strconv"
"strings"
"time"
)
type PushNewGoods struct {
}
type argsAddGoods struct {
Step uint `json:"step" form:"step"`
}
// @Style 添加新商品
//func (p *PushNewGoods) AddGoods(c *gin.Context) {
// stepStr, _ := c.GetQuery("step")
// step, _ := strconv.Atoi(stepStr)
// //if step <= 0 {
// // http.Fail(c, "间隔时长不能为空")
// // return
// //}
// if dbc.Rds.Get(configs.Config_Jingtong_Task_AddGoods_redis_key).Val() != "" {
// back.Fail(c, "任务还在进行中,请勿重复运行")
// return
// }
// dbc.Rds.Set(configs.Config_Jingtong_Task_AddGoods_redis_key, "1", 0)
// go p.addGoods(step)
//
// back.Suc(c, "任务运行成功", "")
// return
//}
//邮件提醒
type newResponse struct {
GysName string `json:"gys_name"`
GoodsName string `json:"goods_name"`
Coke string `json:"coke"`
SkuID uint `json:"sku_id"`
}
func (p *PushNewGoods) UpdateTask(c *gin.Context) {
go func() {
index := 0
for true {
recookGoodsInfoModel := &goods.RecookGoodsInfoModel{}
lists := recookGoodsInfoModel.List(index, 100, "id asc", "publish_status = ?", goods.RecookGoodsInfoPublishStatusTrue)
index += 100
for _, list := range lists {
if err := p.goods(list.ThirdPartyId, 0); err != nil {
log.Println("taskError: err:", err)
}
}
if len(lists) != 100 {
break
}
}
p.SendNewGoods()
//更新完商品数据发邮件提醒售价为0的商品
if configs.IsProductionEnv() { //是否为正式环境
p.SendNewGoods()
}
}()
back.Suc(c, "任务运行成功", "")
return
}
//func (p *PushNewGoods) addGoods(step int) {
// defer func() {
// dbc.Rds.Del(configs.Config_Jingtong_Task_AddGoods_redis_key)
// }()
// recookThirdPartyModel := &manage.RecookThirdPartyModel{}
// log.Println("推送新商品任务开始")
// for {
// lists := recookThirdPartyModel.GetLimit(100)
// if len(lists) == 0 {
// log.Println("推送新商品任务结束")
// return
// }
// idsSuc := []uint{}
// idsFail := []uint{}
// for _, list := range lists {
// if err := p.goods(list.GoodsId, step); err != nil {
// log.Println("推送新商品接口错误")
// idsFail = append(idsFail, list.Id)
// } else {
// idsSuc = append(idsSuc, list.Id)
// }
// if step > 0 {
// time.Sleep(time.Duration(step) * time.Second)
// }
// }
// if len(idsSuc) > 0 {
// recookThirdPartyModel.UpdateSucByIds(idsSuc)
// }
// if len(idsFail) > 0 {
// recookThirdPartyModel.UpdateFailByIds(idsFail)
// }
// }
//}
func (p *PushNewGoods) goods(goodsId uint, step int) error {
defer func() {
if r := recover(); r != nil {
log.Println(r)
}
}()
info, err := jingtong.Jingtong.Info(goodsId)
if err != nil {
return err
}
if info.Name == "" {
return errors.New("该商品正在补货中")
}
// 已下架
//if info.Marketable == 0 {
// //return errors.New("已下架")
//}
if step > 0 {
time.Sleep(time.Duration(step) * time.Second)
}
price, err := jingtong.Jingtong.Price(goodsId)
if err != nil {
return err
}
brandName := strings.TrimSpace(info.BrandName)
recookGoodsBrandModel := &goods.RecookGoodsBrandModel{}
brandInfo := recookGoodsBrandModel.FindByName(brandName)
if brandInfo.Id <= 0 {
// 创建品牌信息
brandInfo.Name = brandName
recookGoodsBrandModel.Create(&brandInfo)
if brandInfo.Id <= 0 {
return errors.New("网络异常1")
}
}
recookGoodsInfoModel := &goods.RecookGoodsInfoModel{}
// 处理仓库
//if strings.Index(info.Warehouse, "国内") != -1 || strings.Index(info.Warehouse, "上海") != -1 {
// info.Type = "国内仓库"
//} else if strings.Index(info.Warehouse, "保税") != -1 {
// info.Type = "自贸区"
//} else {
// info.Type = "海外直邮"
//}
recookThirdPartyDetailModel := &manage.RecookThirdPartyDetailModel{}
goodsDetail := recookGoodsInfoModel.FindByThirdIdType(info.GoodsId, goods.RecookGoodsInfoJCook)
if err := recookGoodsInfoModel.Transaction(func(tx *gorm.DB) error {
recookThirdPartyDetailModel.SetDb(tx)
fmt.Println("商品:", info)
data := manage.RecookThirdPartyDetailModel{
LastModify: formatime.NewSecond(info.LastModify),
CatId: info.CatId,
CatName: info.CategoryName,
BrandId: info.BrandId,
BrandName: info.BrandName,
Price: decimal.NewFromFloat32(info.Price),
Bn: info.Bn,
Name: info.Name,
Weight: decimal.NewFromFloat32(info.Weight),
Store: info.Store,
Score: info.Score,
Uptime: formatime.NewSecond(info.Uptime),
GoodsLink: info.GoodsLink,
Unit: info.Unit,
GoodsId: info.GoodsId,
Type: info.Type,
IsShipping: info.IsShipping,
DutyFree: info.DutyFree,
WarehouseId: info.WarehouseId,
CountryId: info.CountryId,
CountryAbbreviation: info.CountryAbbreviation,
Warehouse: info.Warehouse,
DetailPrice: decimal.NewFromFloat32(price.Price),
DetailStore: price.Store,
DetailIsShipping: price.IsShipping,
DetailMarketPrice: decimal.NewFromFloat32(price.MarketPrice),
}
if goodsDetail.Id > 0 {
row := recookThirdPartyDetailModel.UpdateByGoodsId(info.GoodsId, &data)
if row <= 0 {
}
} else {
fmt.Println("data:", data)
recookThirdPartyDetailModel.Create(&data)
if data.Id <= 0 {
return errors.New("网络异常2-新商品")
}
}
recookGoodsInfoModel.SetDb(tx)
haxAuth := 0
if info.Type == "自贸区" || info.Type == "海外直邮" {
haxAuth = 1
}
storehouse := goods.RecookGoodsInfoStorehouseNone
isFerme := goods.RecookGoodsInfoIsFermeFalse
//switch info.Type {
//case "国内仓库":
// storehouse = goods.RecookGoodsInfoStorehouseDomestic
//case "海外直邮":
// storehouse = goods.RecookGoodsInfoStorehouseDirectMail
// isFerme = goods.RecookGoodsInfoIsFermeTrue
//case "自贸区":
// storehouse = goods.RecookGoodsInfoStorehouseBonded
// isFerme = goods.RecookGoodsInfoIsFermeTrue
//}
// 插入商品信息
goodsInfo := goods.RecookGoodsInfoModel{
BrandID: brandInfo.Id,
VendorID: configs.Config_Third_Party_Jingtong_Vender_Id,
GoodsName: strings.TrimSpace(info.Name),
Description: "",
Material: "", // 材质
FirstCategoryID: configs.Config_Third_Party_Jingtong_Main_Category,
SecondCategoryID: configs.Config_Third_Party_Jingtong_Sub_Category,
PublishStatus: 0,
FreightID: 1, // 包邮
Hash: tools.GenerateGoodsHashSign(),
IsJoinTeamPerformance: 1, //是否有分成,默认有
ThirdPartyId: info.GoodsId,
ThirdPartyType: goods.RecookGoodsInfoJCook,
HasAuth: haxAuth,
IsImport: goods.RecookGoodsInfoIsImportTrue,
Storehouse: storehouse,
IsFerme: isFerme,
}
if goodsDetail.Id > 0 {
// 插入商品信息
goodsData := map[string]interface{}{
//"hash": tools.GenerateGoodsHashSign(),
"goods_name": strings.TrimSpace(info.Name),
"has_auth": haxAuth,
"is_import": goods.RecookGoodsInfoIsImportTrue,
"storehouse": storehouse,
"is_ferme": isFerme,
}
//goods.RecookGoodsInfoModel{
// GoodsName: strings.TrimSpace(info.name),
// HasAuth: haxAuth,
// IsImport: goods.RecookGoodsInfoIsImportTrue,
// Storehouse: storehouse,
// IsFerme: isFerme,
//}
// 已下架
if info.Marketable == 0 {
goodsData["publish_status"] = 0
}
row := recookGoodsInfoModel.UpdateByThirdIdType(info.GoodsId, goods.RecookGoodsInfoJCook, goodsData)
if row <= 0 {
}
// 已下架
if info.Marketable == 0 {
return nil
}
goodsInfo.Id = goodsDetail.Id
} else {
// 已下架
if info.Marketable == 0 {
return errors.New("已下架")
}
recookGoodsInfoModel.Create(&goodsInfo)
if goodsInfo.Id <= 0 {
return errors.New("网络错误")
}
}
// ---------------------------更新商品品牌属性---------------------------------
if goodsDetail.Id <= 0 {
recookGoodsBrandModel.SetDb(tx)
row := recookGoodsBrandModel.AddGoodsCount(brandInfo.Id)
if row <= 0 {
return errors.New("网络错误")
}
}
tempUrl := ""
if goodsDetail.Id == 0 {
// 不需要更新图片
// -----------------------------存储主图-------------------------------
//这边要将主图保存在本地
mainImgs := []goods.RecookGoodsMainPhotoModel{}
tempUrls, width, height := common.UrlToImg(info.ImageDefault, "jingtong")
tempUrl = tempUrls
if tempUrl == "" {
//return errors.New("网络错误")
}
mainImgs = append(mainImgs, goods.RecookGoodsMainPhotoModel{
GoodsId: goodsInfo.Id,
Url: tempUrl,
Name: "api",
IsMaster: 1,
Width: width,
Height: height,
})
for _, img := range info.ImgUrl {
tempUrl1, width1, height1 := common.UrlToImg("https://www.jtgloble.com/"+img, "jingtong")
if tempUrl1 == "" {
continue
}
mainImgs = append(mainImgs, goods.RecookGoodsMainPhotoModel{
GoodsId: goodsInfo.Id,
Url: tempUrl1,
Name: "api",
Width: width1,
Height: height1,
})
}
recookGoodsMainPhotoModel := &goods.RecookGoodsMainPhotoModel{}
recookGoodsMainPhotoModel.SetDb(tx)
if goodsDetail.Id > 0 {
recookGoodsMainPhotoModel.DeleteByGoodsId(goodsInfo.Id)
}
row := recookGoodsMainPhotoModel.CreateAll(&mainImgs)
if row <= 0 {
return errors.New("网络异常3")
}
}
// ---------------------------存储属性---------------------------------
recookGoodsAttributeModel := &goods.RecookGoodsAttributeModel{}
recookGoodsAttributeModel.SetDb(tx)
attr := goods.RecookGoodsAttributeModel{
GoodsId: goodsInfo.Id,
Name: "规格",
Value: "标准",
}
if goodsDetail.Id == 0 {
recookGoodsAttributeModel.Create(&attr)
if attr.Id <= 0 {
return errors.New("网络异常5")
}
}
// ------------------------------存储sku------------------------------
purchasePrice := decimal.NewFromFloat32(price.Price)
discountPrice := decimal.NewFromFloat32(price.MarketPrice)
if info.DutyFree == 0 {
tmp := decimal.NewFromFloat32(1.091)
purchasePrice = purchasePrice.Mul(tmp)
discountPrice = discountPrice.Mul(tmp)
}
hundred := decimal.NewFromInt(100)
sku := goods.RecookGoodsSkuModel{
GoodsId: goodsInfo.Id,
Name: "标准",
CombineId: strconv.FormatUint(uint64(attr.Id), 10),
PicURL: tempUrl,
Code: info.Bn,
PurchasePrice: purchasePrice.Mul(hundred).Ceil().Div(hundred),
OriginalPrice: purchasePrice.Mul(hundred).Ceil().Div(hundred),
DiscountPrice: discountPrice.Mul(hundred).Ceil().Div(hundred),
Inventory: price.Store,
ThirdPartySkuId: strconv.FormatUint(uint64(info.GoodsId), 10),
ThirdPartyType: goods.RecookGoodsInfoJCook,
}
recookGoodsSkuModel := &goods.RecookGoodsSkuModel{}
recookGoodsSkuModel.SetDb(tx)
if goodsDetail.Id > 0 {
sku := goods.RecookGoodsSkuModel{
//PicURL: tempUrl,// 不需要更新图片
Inventory: price.Store,
Code: info.Bn,
PurchasePrice: purchasePrice.Mul(hundred).Ceil().Div(hundred),
}
row := recookGoodsSkuModel.UpdateByGoodsId(goodsInfo.Id, &sku)
if row <= 0 {
}
} else {
recookGoodsSkuModel.Create(&sku)
if sku.Id <= 0 {
return errors.New("网络异常6")
}
}
// -----------------------------存储详情图-------------------------------
if goodsDetail.Id > 0 {
// 不需要更新图片
return nil
}
detailPhotos := []goods.RecookGoodsDetailPhotoModel{}
imgExp := regexp.MustCompile(`(?U)<img.*src="(.*)"`)
index := 0
for _, s := range imgExp.FindAllStringSubmatch(info.Intro, -1) {
if len(s) > 1 {
url := s[1]
if !strings.HasPrefix(url, "http") {
url = "https://www.jtgloble.com" + url
}
tempUrl1, width1, height1 := common.UrlToImg(url, "jingtong")
if tempUrl1 == "" {
continue
}
detailPhotos = append(detailPhotos, goods.RecookGoodsDetailPhotoModel{
GoodsID: goodsInfo.Id,
Url: tempUrl1,
OrderNo: index,
Name: "api",
Width: width1,
Height: height1,
})
index++
}
}
if len(detailPhotos) > 0 {
recookGoodsDetailPhotoModel := &goods.RecookGoodsDetailPhotoModel{}
if goodsDetail.Id > 0 {
recookGoodsDetailPhotoModel.DeleteByGoodsId(goodsInfo.Id)
}
row := recookGoodsDetailPhotoModel.CreateAll(&detailPhotos)
if row <= 0 {
return errors.New("网络异常7")
}
}
// -----------------------------存储详情图end-------------------------------
return nil
}); err != nil {
return err
}
return nil
}
func (p *PushNewGoods) SendEmail(email string, one []newResponse) error {
m := gomail.NewMessage()
m.SetHeader("From", configs.Config_Gys_Email_Setting_Mail)
m.SetHeader("To", email, "austin@akuhome.com")
//m.SetHeader("To", "792209833@qq.com")
m.SetHeader("Subject", "未设置售价商品通知")
if (len(one)) <= 10 {
str := "<br/><br/>\n您好\n<br/><br/>"
if len(one) > 0 {
for i, v := range one {
fmt.Printf("%v:%v,%v,%v,%v\n", i, v.GysName, v.GoodsName, v.Coke, v.SkuID)
str += v.GysName + "," + v.GoodsName + "," + v.Coke + "," + fmt.Sprintf("%v", v.SkuID) + "<br/><br/>"
}
}
m.SetBody("text/html", str)
} else {
str := "具体数据请看表格"
m.SetBody("text/html", str)
// 把资料整合成Excel
f := excelize.NewFile()
// Create a new sheet.
//index2 := f.NewSheet("Sheet2")
f.SetColWidth("Sheet1", "A", "A", 35)
f.SetColWidth("Sheet1", "B", "B", 50)
f.SetColWidth("Sheet1", "C", "C", 20)
f.SetCellValue("Sheet1", "A1", "供应商")
f.SetCellValue("Sheet1", "B1", "商品名称")
f.SetCellValue("Sheet1", "C1", "条形码")
f.SetCellValue("Sheet1", "D1", "skuId")
for i, v := range one {
fmt.Printf("%v:%v,%v,%v,%v\n", i, v.GysName, v.GoodsName, v.Coke, v.SkuID)
f.SetCellValue("Sheet1", "A"+strconv.Itoa(i+2), v.GysName)
f.SetCellValue("Sheet1", "B"+strconv.Itoa(i+2), v.GoodsName)
f.SetCellValue("Sheet1", "C"+strconv.Itoa(i+2), v.Coke)
f.SetCellValue("Sheet1", "D"+strconv.Itoa(i+2), v.SkuID)
}
//f.SetActiveSheet(index2)
name := time.Now().Format("20060102-150405") + tools.GenerateGoodsHashSign() + ".xlsx"
f.Path = filepath.Join(static_path.Dir.Root, static_path.Dir.Temp, name)
if err := f.SaveAs(f.Path); err != nil {
fmt.Println(err)
}
fmt.Println(f.Path)
m.Attach(f.Path, gomail.Rename("=?utf-8?B?"+base64.StdEncoding.EncodeToString([]byte("未设置售价商品通知.xlsx"))+"?="))
}
d := gomail.NewDialer(configs.Config_Gys_Email_Setting_Smtp, configs.Config_Gys_Email_Setting_Port, configs.Config_Gys_Email_Setting_User, configs.Config_Gys_Email_Setting_Pass)
if err := d.DialAndSend(m); err != nil {
return err
}
return nil
}
func (p *PushNewGoods) SendNewGoods() {
var goodsList []newResponse
var all []goods.RecookGoodsInfoModel //推送新商品上架中的全部商品
gys := enterprise.GysEnterpriseStateModel{}
sku := goods.RecookGoodsSkuModel{}
mysql2.Db.Preload("GoodsSku", "discount_price = 0").Where("publish_status = ?", goods.RecookGoodsInfoPublishStatusTrue).Find(&all)
for _, v := range all {
code := sku.FindByGoods(v.Id)
for _, k := range code {
name := gys.FindByUserId(v.VendorID)
goodsList = append(goodsList, newResponse{
GysName: name.EnterpriseName,
GoodsName: v.GoodsName,
Coke: k.Code,
SkuID: k.Id,
})
}
}
err := p.SendEmail(configs.ConfigJTEmail, goodsList)
if err != nil {
fmt.Println(err.Error())
}
}
type order struct {
manage2.RecookOrderGoodsDetailModel
Sku goods.RecookGoodsSkuModel `gorm:"foreignKey:sku_id"`
Addr manage2.RecookOrderAddrModel `gorm:"foreignKey:order_id;references:order_id"`
User user.RecookUserInfoModel `gorm:"foreignKey:user_id"`
Order manage2.RecookOrderInfoModel `gorm:"foreignKey:order_id"`
}
func genStyle(s *excel.Sheet) int {
styleStr := `{
"fill":{
"type":"pattern",
"pattern":2,
"color":["#325000"]
},
"font":{
"bold":true,
"italic":false,
"family":"微软雅黑",
"size":9,
"color":"#000000"
},
"alignment":{
"horizontal":"center",
"vertical":"center",
"wrap_text":true
}
}`
style, _ := s.File.NewStyle(styleStr)
return style
}

@ -15,7 +15,7 @@ const (
RecookGoodsInfoThirdPartyTypeNone = 0 // 供应商提报
RecookGoodsInfoThirdPartyTypeBomao = 1 // 舶茂
RecookGoodsInfoThirdPartyTypeJingtong = 2 // 景彤
RecookGoodsInfoJCook = 3
RecookGoodsInfoJCook = 3 //京库客
RecookGoodsInfoBomaoStatusOn = 1 // 舶茂上架
RecookGoodsInfoBomaoStatusOff = 0 // 舶茂下架

@ -145,6 +145,12 @@ func (r *RecookGoodsSkuModel) FindByGoodsId(goodsId uint) (result []RecookGoodsS
return
}
// @Style 查询售价为0的商品
func (r *RecookGoodsSkuModel) FindByGoods(goodsId uint) (result []RecookGoodsSkuModel) {
r.GetDb().Find(&result, "goods_id = ? and discount_price = 0", goodsId)
return
}
// @Style 查询
func (r *RecookGoodsSkuModel) FindByGoodsIds(goodsIds []uint) (result []RecookGoodsSkuModel) {
r.GetDb().Find(&result, "goods_id in (?)", goodsIds)

@ -0,0 +1,36 @@
package manage
import "recook/internal/v2/lib/db"
const (
RecookThirdPartyJingtongStatusNone = 0
RecookThirdPartyJingtongStatusSuc = 1
RecookThirdPartyJingtongStatusFail = 2
)
type RecookThirdPartyModel struct {
db.BaseModel
Id uint `gorm:"column:id;primary_key" json:"id"`
GoodsId uint `json:"goodsId"`
Status int `json:"status"`
}
// TableName sets the insert table name for this struct type
func (r *RecookThirdPartyModel) TableName() string {
return "recook_third_party_jingtong"
}
func (r *RecookThirdPartyModel) GetLimit(limit int) (result []RecookThirdPartyModel) {
r.GetDb().Model(&RecookThirdPartyModel{}).Limit(limit).Find(&result, "status = ?", RecookThirdPartyJingtongStatusNone)
return
}
func (r *RecookThirdPartyModel) UpdateSucByIds(ids []uint) (result []RecookThirdPartyModel) {
r.GetDb().Model(&RecookThirdPartyModel{}).Where("id in (?)", ids).Update("status", RecookThirdPartyJingtongStatusSuc)
return
}
func (r *RecookThirdPartyModel) UpdateFailByIds(ids []uint) (result []RecookThirdPartyModel) {
r.GetDb().Model(&RecookThirdPartyModel{}).Where("id in (?)", ids).Update("status", RecookThirdPartyJingtongStatusFail)
return
}

@ -7,7 +7,7 @@ import (
"recook/internal/v2/lib/db"
)
type RecookThirdPartyJingtongDetailModel struct {
type RecookThirdPartyDetailModel struct {
db.BaseModel
Id uint `gorm:"column:id;primary_key" json:"id"`
LastModify formatime.Second `json:"lastModify"`
@ -39,15 +39,15 @@ type RecookThirdPartyJingtongDetailModel struct {
}
// TableName sets the insert table name for this struct type
func (r *RecookThirdPartyJingtongDetailModel) TableName() string {
return "recook_third_party_jingtong_detail"
func (r *RecookThirdPartyDetailModel) TableName() string {
return "recook_third_party_detail"
}
func (r *RecookThirdPartyJingtongDetailModel) Create(data *RecookThirdPartyJingtongDetailModel) {
func (r *RecookThirdPartyDetailModel) Create(data *RecookThirdPartyDetailModel) {
err := r.GetDb().Create(data).Error
log.Println(err.Error())
}
func (r *RecookThirdPartyJingtongDetailModel) UpdateByGoodsId(goodsId uint, data *RecookThirdPartyJingtongDetailModel) int64 {
return r.GetDb().Model(&RecookThirdPartyJingtongDetailModel{}).Where("goods_id = ?", goodsId).Update(data).RowsAffected
func (r *RecookThirdPartyDetailModel) UpdateByGoodsId(goodsId uint, data *RecookThirdPartyDetailModel) int64 {
return r.GetDb().Model(&RecookThirdPartyDetailModel{}).Where("goods_id = ?", goodsId).Update(data).RowsAffected
}

@ -1,36 +0,0 @@
package manage
import "recook/internal/v2/lib/db"
const (
RecookThirdPartyJingtongStatusNone = 0
RecookThirdPartyJingtongStatusSuc = 1
RecookThirdPartyJingtongStatusFail = 2
)
type RecookThirdPartyJingtongModel struct {
db.BaseModel
Id uint `gorm:"column:id;primary_key" json:"id"`
GoodsId uint `json:"goodsId"`
Status int `json:"status"`
}
// TableName sets the insert table name for this struct type
func (r *RecookThirdPartyJingtongModel) TableName() string {
return "recook_third_party_jingtong"
}
func (r *RecookThirdPartyJingtongModel) GetLimit(limit int) (result []RecookThirdPartyJingtongModel) {
r.GetDb().Model(&RecookThirdPartyJingtongModel{}).Limit(limit).Find(&result, "status = ?", RecookThirdPartyJingtongStatusNone)
return
}
func (r *RecookThirdPartyJingtongModel) UpdateSucByIds(ids []uint) (result []RecookThirdPartyJingtongModel) {
r.GetDb().Model(&RecookThirdPartyJingtongModel{}).Where("id in (?)", ids).Update("status", RecookThirdPartyJingtongStatusSuc)
return
}
func (r *RecookThirdPartyJingtongModel) UpdateFailByIds(ids []uint) (result []RecookThirdPartyJingtongModel) {
r.GetDb().Model(&RecookThirdPartyJingtongModel{}).Where("id in (?)", ids).Update("status", RecookThirdPartyJingtongStatusFail)
return
}

@ -16,6 +16,6 @@ func Router(router *gin.RouterGroup) {
// app端路由
routerApp(router.Group("app"))
// app端路由
// 微信端路由
routerWxapp(router.Group("wxapp"))
}

@ -1,19 +1,20 @@
package router
import (
"recook/internal/v2/controller/task"
"github.com/gin-gonic/gin"
"recook/internal/v2/controller/task"
)
// @Style recook任务
func routerTask(taskRouter *gin.RouterGroup) {
goodsController := &task.Goods{}
taskRouter.GET("goods/associate", goodsController.Update) // 关联更新
taskRouter.GET("goods/sync", goodsController.Sync) // jcook商品更新
taskRouter.GET("goods/fix", goodsController.Fix) // jcook图片修复
taskRouter.GET("goods/publish", goodsController.Publish) // 更新商品上下级状态
goodsController := task.Goods{}
pushNewGoods := task.PushNewGoods{}
//taskRouter.GET("goods/AddGoods", pushNewGoods.AddGoods)
taskRouter.GET("goods/update_all", pushNewGoods.UpdateTask) // 发送未设置售价商品邮件
taskRouter.GET("goods/associate", goodsController.Update) // 关联更新
taskRouter.GET("goods/sync", goodsController.Sync) // jcook商品更新
taskRouter.GET("goods/fix", goodsController.Fix) // jcook图片修复
taskRouter.GET("goods/publish", goodsController.Publish) // 更新商品上下级状态
taskRouter.GET("goods/openSearchV2", goodsController.OpenSearchV2)
taskRouter.GET("goods/attr", goodsController.AttrSync) // jcook规格修复
taskRouter.GET("goods/tax", goodsController.TaxSync) // jcook tax修复

Loading…
Cancel
Save