Merge pull request 'test-dyb' (#66) from test-dyb into test

Reviewed-on: https://git.oa00.com/recook/backend_v2/pulls/66
master
杨赟 3 years ago
commit 61abfcef91

@ -1,12 +1,11 @@
package order
import (
"git.oa00.com/go/mysql"
"github.com/gin-gonic/gin"
"recook/internal/back"
"recook/internal/dbc"
"recook/internal/model/order"
"recook/tools"
"github.com/gin-gonic/gin"
)
type deleteOrderParam struct {
@ -21,16 +20,16 @@ func DeleteOrder(c *gin.Context) {
back.Fail(c, err.Error())
return
}
var orderInfo order.Information
dbc.DB.First(&orderInfo, p.OrderID)
mysql.Db.First(&orderInfo, p.OrderID)
//dbc.DB.First(&orderInfo, p.OrderID)
if orderInfo.Status != 2 && orderInfo.Status != 3 {
if orderInfo.Status != 2 && orderInfo.Status != 3 && orderInfo.Status != 5 {
back.Fail(c, "订单不可删除")
return
}
tx := dbc.DB.Begin()
tx := mysql.Db.Begin()
{
if err = tx.Delete(&orderInfo).Error; err != nil {
back.Err(c, err.Error())
@ -38,19 +37,19 @@ func DeleteOrder(c *gin.Context) {
return
}
if err = tx.Where("order_id = ?", orderInfo.ID).Delete(order.Addr{}).Error; err != nil {
if err = tx.Where("order_id = ?", orderInfo.ID).Delete(&order.Addr{}).Error; err != nil {
back.Err(c, err.Error())
tx.Rollback()
return
}
if err = tx.Where("order_id = ?", orderInfo.ID).Delete(order.CouponDetail{}).Error; err != nil {
if err = tx.Where("order_id = ?", orderInfo.ID).Delete(&order.CouponDetail{}).Error; err != nil {
back.Err(c, err.Error())
tx.Rollback()
return
}
if err = tx.Where("order_id = ?", orderInfo.ID).Delete(order.GoodsDetail{}).Error; err != nil {
if err = tx.Where("order_id = ?", orderInfo.ID).Delete(&order.GoodsDetail{}).Error; err != nil {
back.Err(c, err.Error())
tx.Rollback()
return

@ -1,6 +1,7 @@
package order
import (
"git.oa00.com/go/mysql"
"log"
"recook/internal/dbc"
"recook/internal/model/order"
@ -17,7 +18,7 @@ func PlanMonitorTradeSucOrderTask() {
var orderListGoods order.GoodsDetail
has := 0
dbc.DB.Find(&successOrderList, "status = 1 AND express_status = 1 AND created_at <= ?", t.Format("2006-01-02 15:04:05"))
mysql.Db.Find(&successOrderList, "status = 1 AND express_status = 1 AND created_at <= ?", t.Format("2006-01-02 15:04:05"))
for _, orderInfo := range successOrderList {
@ -46,7 +47,7 @@ func PlanMonitorTradeSucOrderTask() {
func PlanMonitorExpireOrderTask() {
now := time.Now()
var expireOrderList []order.Information
dbc.DB.Find(&expireOrderList, "status = 0 AND expire_time <= ? and order_type = 1", now)
mysql.Db.Find(&expireOrderList, "status = 0 AND expire_time <= ? and order_type = 1", now)
for _, v := range expireOrderList {
err := CancelOrExpireOrder(&v, false)

@ -50,7 +50,7 @@ func QueryAllOrders(c *gin.Context) {
}
var orderInfoList []order.Information
SearchOrderList(p.OrderType, p.Page, p.UserID, p.IsSale, nil).Find(&orderInfoList, "user_id = ?", p.UserID)
SearchOrderList(p.OrderType, p.Page, p.UserID, p.IsSale, nil).Find(&orderInfoList, "user_id = ? and deleted_at is null", p.UserID)
list := make([]queryOrderListResponse, 0, 0)
for i1, v1 := range orderInfoList {

@ -1,6 +1,7 @@
package order
import (
"gorm.io/gorm"
"recook/internal/model/order_preview"
)
@ -14,6 +15,7 @@ type Addr struct {
Address string `gorm:"column:address" json:"address"`
ReceiverName string `gorm:"column:receiver_name" json:"receiverName"`
Mobile string `gorm:"column:mobile" json:"mobile"`
DeletedAt gorm.DeletedAt
}
// TableName sets the insert table name for this struct type

@ -3,6 +3,7 @@ package order
import (
"github.com/golangkit/formatime"
"github.com/shopspring/decimal"
"gorm.io/gorm"
"recook/internal/model/order_preview"
)
@ -16,6 +17,7 @@ type CouponDetail struct {
CouponName string `gorm:"column:coupon_name" json:"couponName"`
DeductedAmount decimal.Decimal `gorm:"column:deducted_amount" json:"deductedAmount"`
EndTime formatime.Second `gorm:"column:end_time" json:"-"`
DeletedAt gorm.DeletedAt
}
// TableName sets the insert table name for this struct type

@ -1,6 +1,7 @@
package order
import (
"gorm.io/gorm"
"recook/internal/define"
"recook/internal/model/order_preview"
"recook/internal/v2/model/recook/goods"
@ -82,6 +83,7 @@ type GoodsDetail struct {
Sku goods.RecookGoodsSkuModel `json:"-" gorm:"foreignKey:sku_id"`
Income decimal.Decimal `json:"income"`
Tax decimal.Decimal `json:"tax"`
DeletedAt gorm.DeletedAt
}
// TableName sets the insert table name for this struct type

@ -1,6 +1,7 @@
package order
import (
"gorm.io/gorm"
"recook/internal/model/order_preview"
"recook/internal/model/user"
"time"
@ -58,6 +59,7 @@ type Information struct {
CanPay bool `gorm:"column:can_pay" json:"-"`
OrderSku []GoodsDetail `json:"-" gorm:"foreignKey:order_id"`
Address Addr `json:"-" gorm:"foreignKey:order_id"`
DeletedAt gorm.DeletedAt
}
const (

@ -787,8 +787,10 @@ func SyncPageData(page, size uint, brand string, categories []RecookJCookCategor
}
attrMap := make(map[uint][]goods.RecookGoodsAttributeModel)
for k, attr := range skuAttrMap {
data1 := make([]goods.RecookGoodsAttributeModel, 0)
dataAttr := make([]goods.RecookGoodsAttributeModel, 0)
for index, a := range attr {
aName := "规格"
if index == 1 {
@ -798,17 +800,26 @@ func SyncPageData(page, size uint, brand string, categories []RecookJCookCategor
if aValue == "" {
aValue = "标准"
}
var aa goods.RecookGoodsAttributeModel
tx.First(&aa, "goods_id = ? and value = ?", gs1.Id, aValue) //查找重复数据
if aa.Id > 0 {
dataAttr = append(attrMap[k], aa) //使用已有数据
} else {
data1 = append(data1, goods.RecookGoodsAttributeModel{
GoodsId: gs1.Id,
Name: aName,
Value: aValue,
})
attrMap[k] = data1
dataAttr = data1
}
attrMap[k] = dataAttr
}
if len(data1) != 0 {
if err := tx.Create(&data1).Error; err != nil {
return err
}
}
}
data := make([]goods.RecookGoodsSkuModel, 0)
for _, value := range gsk1 {
idStr := make([]string, 0)
@ -820,6 +831,7 @@ func SyncPageData(page, size uint, brand string, categories []RecookJCookCategor
value.CombineId = strings.Join(idStr, ",")
data = append(data, value)
}
if err := tx.Create(&data).Error; err != nil {
return err
}

Loading…
Cancel
Save