优化查询

master
kanade 3 years ago
parent 9a1983bf30
commit 2f67afa4e3

@ -389,7 +389,7 @@ func JdOrderSubmit(tx *gorm.DB, ip string, data map[uint][]order_preview.GoodsDe
}
for _, t := range res {
var sku goods2.RecookGoodsSkuModel
if err := mysql.Db.Table(sku.TableName()).Where("third_party_sku_id = ? and third_party_type=3", t.SkuID).Updates(map[string]interface{}{
if err := mysql.Db.Table(sku.TableName()).Where("third_party_sku_id = ? and third_party_type=3", strconv.FormatUint(uint64(t.SkuID), 10)).Updates(map[string]interface{}{
"purchase_price": t.SupplyPrice,
}).Error; err != nil {
log.Println(err.Error())

@ -237,7 +237,7 @@ func CreatePreviewNormalOrder(c *gin.Context) {
t := res[0]
var sku goods2.RecookGoodsSkuModel
if err := mysql.Db.Table(sku.TableName()).Where("third_party_sku_id = ? and third_party_type=3", t.SkuID).Updates(map[string]interface{}{
if err := mysql.Db.Table(sku.TableName()).Where("third_party_sku_id = ? and third_party_type=3", strconv.FormatUint(uint64(t.SkuID), 10)).Updates(map[string]interface{}{
"purchase_price": t.SupplyPrice,
}).Error; err != nil {
log.Println(err.Error())

@ -131,7 +131,7 @@ func ShaMaSkuPrice() {
t := res[0]
var sku goods2.RecookGoodsSkuModel
if err := mysql.Db.Table(sku.TableName()).Where("third_party_sku_id = ? and third_party_type=4", t.SkuDetailBase.SkuID).Updates(map[string]interface{}{
if err := mysql.Db.Table(sku.TableName()).Where("third_party_sku_id = ? and third_party_type=4", strconv.FormatUint(uint64(t.SkuDetailBase.SkuID), 10)).Updates(map[string]interface{}{
"sale_purchase_price": t.SkuDetailBase.SupplyPrice,
}).Error; err != nil {
log.Println(err.Error())
@ -557,9 +557,9 @@ func orderCreate() {
return err
}
var ids []uint64
var ids []string
for _, v := range m.SkuList {
ids = append(ids, v.SkuID)
ids = append(ids, strconv.FormatUint(v.SkuID, 10))
}
var orderSku []manage.RecookOrderGoodsDetailModel
var sku []goods2.RecookGoodsSkuModel
@ -718,7 +718,7 @@ func skuPrice() {
t := res[0]
var sku goods2.RecookGoodsSkuModel
if err := mysql.Db.Table(sku.TableName()).Where("third_party_sku_id = ? and third_party_type=3", t.SkuID).Updates(map[string]interface{}{
if err := mysql.Db.Table(sku.TableName()).Where("third_party_sku_id = ? and third_party_type=3", strconv.FormatUint(uint64(t.SkuID), 10)).Updates(map[string]interface{}{
"purchase_price": t.SupplyPrice,
}).Error; err != nil {
log.Println(err.Error())

@ -528,7 +528,7 @@ func (s *supplyLogic) SyncPrice(skuIds []uint) error {
if mSkuPrice[partySupply.SupplySkuId].Status == manage.RecookThirdPartySupplySupplyStatusUp {
inventory = 500
}
if tx.Model(&goods.RecookGoodsSkuModel{}).Where("goods_id = ? and third_party_type = ? and third_party_sku_id = ?", partySupply.GoodsId, goods.RecookGoodsInfoThirdPartyTypeSupply, partySupply.SupplySkuId).Updates(map[string]interface{}{
if tx.Model(&goods.RecookGoodsSkuModel{}).Where("goods_id = ? and third_party_type = ? and third_party_sku_id = ?", partySupply.GoodsId, goods.RecookGoodsInfoThirdPartyTypeSupply, strconv.FormatUint(uint64(partySupply.SupplySkuId), 10)).Updates(map[string]interface{}{
"purchase_price": partySupply.Price,
"inventory": inventory,
}).Error != nil {
@ -670,7 +670,7 @@ func (s *supplyLogic) SyncData(skuIds []uint) error {
if err == nil {
// 获取sku信息
recookGoodsSkuModel := goods.RecookGoodsSkuModel{}
mysql.Db.Where("goods_id = ? and third_party_type = ? and third_party_sku_id = ?", partySupply.GoodsId, goods.RecookGoodsInfoThirdPartyTypeSupply, partySupply.SupplySkuId).First(&recookGoodsSkuModel)
mysql.Db.Where("goods_id = ? and third_party_type = ? and third_party_sku_id = ?", partySupply.GoodsId, goods.RecookGoodsInfoThirdPartyTypeSupply, strconv.FormatUint(uint64(partySupply.SupplySkuId), 10)).First(&recookGoodsSkuModel)
if recookGoodsSkuModel.Id > 0 {
// 发票税率
skuInvoiceModel := goods.RecookSkuInvoiceModel{}
@ -711,7 +711,7 @@ func (s *supplyLogic) SyncData(skuIds []uint) error {
if skuInfo.Status == manage.RecookThirdPartySupplySupplyStatusUp {
inventory = 500
}
if tx.Model(&goods.RecookGoodsSkuModel{}).Where("goods_id = ? and third_party_type = ? and third_party_sku_id = ?", partySupply.GoodsId, goods.RecookGoodsInfoThirdPartyTypeSupply, partySupply.SupplySkuId).Updates(map[string]interface{}{
if tx.Model(&goods.RecookGoodsSkuModel{}).Where("goods_id = ? and third_party_type = ? and third_party_sku_id = ?", partySupply.GoodsId, goods.RecookGoodsInfoThirdPartyTypeSupply, strconv.FormatUint(uint64(partySupply.SupplySkuId), 10)).Updates(map[string]interface{}{
"purchase_price": partySupply.Price,
"inventory": inventory,
"pic_url": skuInfo.ImgUrl,
@ -815,9 +815,9 @@ func (s *supplyLogic) OrderSplit(orderSplit supply.OrderSplit) error {
if err := tx.Table((&order4.Profit{}).TableName()).Where("order_id = ?", parentOrderInfo.Id).Update("status", 1).Error; err != nil {
return err
}
var skuIds []uint
var skuIds []string
for _, sku := range orderSplit.Skus {
skuIds = append(skuIds, sku.SkuId)
skuIds = append(skuIds, strconv.FormatUint(uint64(sku.SkuId), 10))
}
var orderSku []manage2.RecookOrderGoodsDetailModel

Loading…
Cancel
Save