feat: undeal order

master
howell 3 years ago
parent 48bd6f865b
commit 2c0549976b

@ -49,7 +49,7 @@ func QueryAllOrders(c *gin.Context) {
}
var orderInfoList []order.Information
SearchOrderList(p.OrderType, p.Page, p.UserID, p.IsSale).Find(&orderInfoList, "user_id = ?", p.UserID)
SearchOrderList(p.OrderType, p.Page, p.UserID, p.IsSale, nil).Find(&orderInfoList, "user_id = ?", p.UserID)
list := make([]queryOrderListResponse, 0, 0)
for i1, v1 := range orderInfoList {
@ -239,9 +239,42 @@ func QueryUnpaidOrders(c *gin.Context) {
}
var orderInfoList []order.Information
SearchOrderList(p.OrderType, p.Page, p.UserID, p.IsSale).Find(&orderInfoList, "user_id = ? AND status = 0 AND expire_time > ?", p.UserID, time.Now())
canpay := true
SearchOrderList(p.OrderType, p.Page, p.UserID, p.IsSale, &canpay).Find(&orderInfoList, "user_id = ? AND status = 0 AND expire_time > ?", p.UserID, time.Now())
list := make([]queryOrderListResponse, 0, 0)
list := make([]queryOrderListResponse, 0)
for i1, v1 := range orderInfoList {
var goodsList []order.GoodsDetail
dbc.DB.Find(&goodsList, "order_id = ?", v1.ID)
for i2, v2 := range goodsList {
goodsList[i2].RStatus = getStatus(v1, v2)
}
list = append(list, queryOrderListResponse{
Information: orderInfoList[i1],
CanConfirm: false,
TotalGoodsCount: uint(len(goodsList)),
GoodsList: goodsList,
OrderType: TypeMap[orderInfoList[i1].ShippingMethod],
})
}
back.Suc(c, "", list)
}
// 待处理订单
func QueryUnDealOrders(c *gin.Context) {
var p queryOrderListParam
if err := tools.ParseParams(&p, c); err != nil {
back.Fail(c, err.Error())
return
}
var orderInfoList []order.Information
canpay := false
SearchOrderList(p.OrderType, p.Page, p.UserID, p.IsSale, &canpay).Find(&orderInfoList, "user_id = ? AND status = 0 AND expire_time > ?", p.UserID, time.Now())
list := make([]queryOrderListResponse, 0)
for i1, v1 := range orderInfoList {
var goodsList []order.GoodsDetail
dbc.DB.Find(&goodsList, "order_id = ?", v1.ID)
@ -273,9 +306,9 @@ func QueryUndeliveredOrders(c *gin.Context) {
//p.Page = 0
var orderInfoList []order.Information
SearchOrderList(p.OrderType, p.Page, p.UserID, p.IsSale).Find(&orderInfoList, "user_id = ? AND status = 1 AND express_status = 0", p.UserID)
SearchOrderList(p.OrderType, p.Page, p.UserID, p.IsSale, nil).Find(&orderInfoList, "user_id = ? AND status = 1 AND express_status = 0", p.UserID)
list := make([]queryOrderListResponse, 0, 0)
list := make([]queryOrderListResponse, 0)
for i1, v1 := range orderInfoList {
var goodsList []order.GoodsDetail
dbc.DB.Find(&goodsList, "order_id = ?", v1.ID)
@ -304,9 +337,9 @@ func QueryWaitingForReceiptOrders(c *gin.Context) {
}
var orderInfoList []order.Information
SearchOrderList(p.OrderType, p.Page, p.UserID, p.IsSale).Find(&orderInfoList, "user_id = ? AND status=1 AND express_status = 1", p.UserID)
SearchOrderList(p.OrderType, p.Page, p.UserID, p.IsSale, nil).Find(&orderInfoList, "user_id = ? AND status=1 AND express_status = 1", p.UserID)
list := make([]queryOrderListResponse, 0, 0)
list := make([]queryOrderListResponse, 0)
for i1, v1 := range orderInfoList {
var goodsList []order.GoodsDetail
dbc.DB.Find(&goodsList, "order_id = ?", v1.ID)
@ -343,9 +376,9 @@ func QueryUnEvaluateOrders(c *gin.Context) {
}
var orderInfoList []order.Information
SearchOrderList(p.OrderType, p.Page, p.UserID, p.IsSale).Find(&orderInfoList, "user_id = ? AND status=4 AND evaluated_at IS NULL", p.UserID)
SearchOrderList(p.OrderType, p.Page, p.UserID, p.IsSale, nil).Find(&orderInfoList, "user_id = ? AND status=4 AND evaluated_at IS NULL", p.UserID)
list := make([]queryOrderListResponse, 0, 0)
list := make([]queryOrderListResponse, 0)
for i1, v1 := range orderInfoList {
var goodsList []order.GoodsDetail
dbc.DB.Find(&goodsList, "order_id = ?", v1.ID)
@ -607,7 +640,7 @@ func QueryOrderDetail(c *gin.Context) {
}
// 搜索订单 条件
func SearchOrderList(OrderType string, Page, UserID uint, isSale bool) *gorm.DB {
func SearchOrderList(OrderType string, Page, UserID uint, isSale bool, canPay *bool) *gorm.DB {
queryDB := dbc.DB
if len(OrderType) > 0 {
oType, _ := strconv.Atoi(OrderType)
@ -618,6 +651,9 @@ func SearchOrderList(OrderType string, Page, UserID uint, isSale bool) *gorm.DB
} else {
queryDB = queryDB.Where("order_type = 1")
}
if canPay != nil && isSale {
queryDB = queryDB.Where("can_pay = ?", *canPay)
}
queryDB = queryDB.Where("is_split = 0").Order("id desc").Limit(10).Offset(10 * Page)
return queryDB
}

@ -2,10 +2,6 @@ package alipay
import (
"errors"
"github.com/gin-gonic/gin"
"github.com/golangkit/formatime"
"github.com/jinzhu/gorm"
"github.com/shopspring/decimal"
"recook/internal/api/mobile/pay/public"
"recook/internal/back"
"recook/internal/dbc"
@ -13,6 +9,11 @@ import (
"recook/internal/model/pay"
"recook/tools"
"time"
"github.com/gin-gonic/gin"
"github.com/golangkit/formatime"
"github.com/jinzhu/gorm"
"github.com/shopspring/decimal"
)
type CreateOrderBizContentParam struct {
@ -38,6 +39,12 @@ func createOrder(virtualID uint, ip string, userID uint) (error, string) {
return err, ""
}
if len(od) != 0 {
if !od[0].CanPay && od[0].OrderType == 2 {
return errors.New("批发订单运费未确定无法支付"), ""
}
}
if err := public.UpdateVirtualPay(virtualID); err != nil {
return err, ""
}
@ -149,6 +156,12 @@ func PayOrder(c *gin.Context) {
var orderInfo order.Information
if !orderInfo.CanPay && orderInfo.OrderType == 2 {
err = errors.New("批发订单运费未确定无法支付")
back.Fail(c, err.Error())
return
}
err = dbc.DB.First(&orderInfo, "id = ?", p.OrderID).Error
if err != nil {
back.Err(c, err.Error())

@ -43,6 +43,11 @@ func createOrder(virtualID uint, ip string, userID uint, password string) error
if err := dbc.DB.Find(&od, "virtual_id = ?", virtualID).Error; err != nil {
return err
}
if len(od) != 0 {
if !od[0].CanPay && od[0].OrderType == 2 {
return errors.New("批发订单运费未确定无法支付")
}
}
var id []uint
for _, v := range od {
@ -216,6 +221,12 @@ func PayOrder(c *gin.Context) {
back.Err(c, err.Error())
return
}
if !orderInfo.CanPay && orderInfo.OrderType == 2 {
err = errors.New("批发订单运费未确定无法支付")
back.Fail(c, err.Error())
return
}
err = public.ValidateOrderInfo(&orderInfo, now)
if err != nil {
back.Fail(c, err.Error())

@ -102,6 +102,12 @@ func createOrder(orderID uint, ip string, userID uint) (error, *AppCreateOrderRe
return err, nil
}
if len(od) != 0 {
if !od[0].CanPay && od[0].OrderType == 2 {
return errors.New("批发订单运费未确定无法支付"), nil
}
}
if err := public.UpdateVirtualPay(orderID); err != nil {
return err, nil
}
@ -249,6 +255,12 @@ func PayOrder(c *gin.Context) {
back.Err(c, err.Error())
return
}
if !orderInfo.CanPay && orderInfo.OrderType == 2 {
err = errors.New("批发订单运费未确定无法支付")
back.Fail(c, err.Error())
return
}
err = public.ValidateOrderInfo(&orderInfo, now)
if err != nil {
back.Fail(c, err.Error())

@ -97,6 +97,12 @@ func createOrder(orderID uint, ip string, userID uint) (error, *AppCreateOrderRe
return err, nil
}
if len(od) != 0 {
if !od[0].CanPay && od[0].OrderType == 2 {
return errors.New("批发订单运费未确定无法支付"), nil
}
}
if err := public.UpdateVirtualPay(orderID); err != nil {
return err, nil
}
@ -229,6 +235,12 @@ func PayOrder(c *gin.Context) {
back.Err(c, err.Error())
return
}
if !orderInfo.CanPay && orderInfo.OrderType == 2 {
err = errors.New("批发订单运费未确定无法支付")
back.Fail(c, err.Error())
return
}
err = public.ValidateOrderInfo(&orderInfo, now)
if err != nil {
back.Fail(c, err.Error())

@ -4,10 +4,6 @@ import (
"encoding/xml"
"errors"
"fmt"
"github.com/gin-gonic/gin"
"github.com/jinzhu/gorm"
"github.com/json-iterator/go"
"github.com/shopspring/decimal"
"io/ioutil"
"log"
"net/http"
@ -20,6 +16,11 @@ import (
"recook/tools"
"strings"
"time"
"github.com/gin-gonic/gin"
"github.com/jinzhu/gorm"
jsoniter "github.com/json-iterator/go"
"github.com/shopspring/decimal"
)
// 统一下单参数
@ -95,6 +96,12 @@ func createOrder(orderID uint, ip string, userID uint) (error, *AppCreateOrderRe
return err, nil
}
if len(od) != 0 {
if !od[0].CanPay && od[0].OrderType == 2 {
return errors.New("批发订单运费未确定无法支付"), nil
}
}
if err := public.UpdateVirtualPay(orderID); err != nil {
return err, nil
}
@ -232,6 +239,12 @@ func PayOrder(c *gin.Context) {
back.Err(c, err.Error())
return
}
if !orderInfo.CanPay && orderInfo.OrderType == 2 {
err = errors.New("批发订单运费未确定无法支付")
back.Fail(c, err.Error())
return
}
err = public.ValidateOrderInfo(&orderInfo, now)
if err != nil {
back.Fail(c, err.Error())

@ -4,10 +4,6 @@ import (
"encoding/xml"
"errors"
"fmt"
"github.com/gin-gonic/gin"
"github.com/jinzhu/gorm"
"github.com/json-iterator/go"
"github.com/shopspring/decimal"
"io/ioutil"
"log"
"net/http"
@ -19,6 +15,11 @@ import (
"recook/tools"
"strings"
"time"
"github.com/gin-gonic/gin"
"github.com/jinzhu/gorm"
jsoniter "github.com/json-iterator/go"
"github.com/shopspring/decimal"
)
/*
@ -107,6 +108,12 @@ func createOrder(orderID uint, ip string, userID uint) (error, *AppCreateOrderRe
return err, nil
}
if len(od) != 0 {
if !od[0].CanPay && od[0].OrderType == 2 {
return errors.New("批发订单运费未确定无法支付"), nil
}
}
if err := public.UpdateVirtualPay(orderID); err != nil {
return err, nil
}
@ -251,6 +258,13 @@ func PayOrder(c *gin.Context) {
back.Err(c, err.Error())
return
}
if !orderInfo.CanPay && orderInfo.OrderType == 2 {
err = errors.New("批发订单运费未确定无法支付")
back.Fail(c, err.Error())
return
}
err = public.ValidateOrderInfo(&orderInfo, now)
if err != nil {
back.Fail(c, err.Error())

@ -304,6 +304,7 @@ func SetupRouter(v1 *gin.RouterGroup) {
orderR.POST("/normal/submit", order.SubmitOrder) // 提交订单
orderR.POST("/submit", order.SubmitOrder) // 提交订单
orderR.POST("/list/all", order.QueryAllOrders) // 查询所有订单
orderR.POST("/list/undeal", order.QueryAllOrders) // 查询所有订单
orderR.POST("/list/unpaid", order.QueryUnpaidOrders) // 查询未付款订单
orderR.POST("/list/undelivered", order.QueryUndeliveredOrders) // 查询未发货订单
orderR.POST("/list/receipt", order.QueryWaitingForReceiptOrders) // 查询待收货

Loading…
Cancel
Save