parent
054f1ed06e
commit
27f8910a5b
@ -0,0 +1,94 @@
|
||||
package jyy
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"git.oa00.com/go/mysql"
|
||||
"github.com/golangkit/formatime"
|
||||
"github.com/shopspring/decimal"
|
||||
"gorm.io/gorm"
|
||||
after2 "recook/internal/v2/model/recook/after"
|
||||
manage "recook/internal/v2/model/recook/order"
|
||||
"time"
|
||||
)
|
||||
|
||||
type OrderEntry struct {
|
||||
OrderID uint `json:"order_id" validate:"required"`
|
||||
Amount decimal.Decimal `json:"amount"`
|
||||
Reason string `json:"reason"`
|
||||
Photo string `json:"photo"`
|
||||
}
|
||||
|
||||
func (o logic) OrderCancel(args OrderEntry) (err error) {
|
||||
// 发起未发货售后,并退款
|
||||
var od manage.RecookOrderInfoModel
|
||||
mysql.Db.Preload("OrderSku").First(&od, "id = ?", args.OrderID)
|
||||
if od.OrderType != 2 {
|
||||
err = fmt.Errorf("不是批发订单无法取消")
|
||||
return
|
||||
}
|
||||
if err = mysql.Db.Transaction(func(tx *gorm.DB) error {
|
||||
for _, v := range od.OrderSku {
|
||||
after := after2.RecookAfterSalesGoodsModel{
|
||||
AncestorId: v.AncestorId,
|
||||
ParentId: v.ParentId,
|
||||
SharerId: v.SharerId,
|
||||
UserId: v.UserId,
|
||||
UserRole: 0,
|
||||
OrderId: v.OrderId,
|
||||
OrderGoodsId: v.Id,
|
||||
VendorId: v.VendorId,
|
||||
VendorName: v.VendorName,
|
||||
BrandName: v.BrandName,
|
||||
CategoryName: v.CategoryName,
|
||||
GoodsId: v.GoodsId,
|
||||
GoodsName: v.GoodsName,
|
||||
SkuName: v.SkuName,
|
||||
SkuCode: v.SkuCode,
|
||||
MainPhotoUrl: v.MainPhotoURL,
|
||||
Quantity: v.Quantity,
|
||||
OrderTime: v.OrderTime,
|
||||
OrderTotalAmount: od.ActualTotalAmount,
|
||||
RefundAmount: v.ActualAmount,
|
||||
RefundCoin: decimal.Zero,
|
||||
TradeNo: od.TradeNo,
|
||||
PayMethod: od.PayMethod,
|
||||
IsShip: v.ExpressStatus,
|
||||
AssType: 1,
|
||||
ReturnStatus: 1,
|
||||
ApplyTime: formatime.NewSecondNow(),
|
||||
RefundNo: fmt.Sprintf("%d_%vA%d", time.Now().Unix(), od.TradeNo, v.Id),
|
||||
}
|
||||
if e := tx.Create(&after).Error; e != nil {
|
||||
return e
|
||||
}
|
||||
lo := after2.RecookAfterSalesLogsModel{
|
||||
AsID: after.Id,
|
||||
Title: "系统申请仅退款",
|
||||
Content: "退款原因:系统自动发起" + "|退款金额:" + (after.RefundAmount).String() + "|退回瑞币:" + after.RefundCoin.String(),
|
||||
CTime: formatime.Second{},
|
||||
User: "system",
|
||||
UserId: 0,
|
||||
}
|
||||
if e := tx.Create(&lo).Error; e != nil {
|
||||
return e
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func (o logic) OrderConfirm(args OrderEntry) (err error) {
|
||||
// 发货, 只修改状态, 没有物流信息
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func (o logic) OrderMakeUp(args OrderEntry) (err error) {
|
||||
//
|
||||
return
|
||||
}
|
Loading…
Reference in new issue