unionorder
This commit is contained in:
@@ -109,6 +109,7 @@ func InitServiceInfo(version string, buildTime time.Time, gitCommit string) {
|
||||
1: "进行中的活动",
|
||||
},
|
||||
},
|
||||
"unionOrderStatusName": model.UnionOrderStatusName,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,8 @@ package cms
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"git.rosy.net.cn/jx-callback/business/jxstore/partner"
|
||||
"git.rosy.net.cn/jx-callback/business/jxstore/event"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"git.rosy.net.cn/jx-callback/business/auth2"
|
||||
@@ -188,16 +189,11 @@ func GetManageStatisticsJob(ctx *jxcontext.Context, cityCodes []int, fromTime, t
|
||||
return dao.GetManageStatisticsJob(db, cityCodes, utils.Str2Time(fromTime), utils.Str2Time(toTime), jobIDs, offset, pageSize)
|
||||
}
|
||||
|
||||
func UnionOrderCallBack(unionOrder *partner.UnionOrderInfo) (err error) {
|
||||
globals.SugarLogger.Debugf("UnionOrderCallBack unionOrder: %v", utils.Format4Output(unionOrder, true))
|
||||
func NewUnionOrder(unionOrder *model.UnionOrder, orderStatus *model.UnionOrderStatus) (err error) {
|
||||
var (
|
||||
db = dao.GetDB()
|
||||
db = dao.GetDB()
|
||||
userID string
|
||||
)
|
||||
if unionOrder.SID == "" {
|
||||
return err
|
||||
}
|
||||
mobile := unionOrder.SID[:11]
|
||||
jobID := unionOrder.SID[11:]
|
||||
txDB, _ := dao.Begin(db)
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
@@ -205,31 +201,76 @@ func UnionOrderCallBack(unionOrder *partner.UnionOrderInfo) (err error) {
|
||||
panic(r)
|
||||
}
|
||||
}()
|
||||
user, err := dao.GetUserByID(db, "mobile", mobile)
|
||||
userBinds, err := dao.GetUserUnionBind(db, "", unionOrder.VendorID, unionOrder.PID)
|
||||
if err != nil {
|
||||
dao.Rollback(db, txDB)
|
||||
return err
|
||||
}
|
||||
userBill, err := dao.GetUserBill(db, user.UserID, "")
|
||||
if userBill == nil {
|
||||
return fmt.Errorf("未查询到该用户的账单!")
|
||||
if len(userBinds) == 0 {
|
||||
userID = unionOrder.PID
|
||||
} else {
|
||||
userID = userBinds[0].UserID
|
||||
}
|
||||
if err = financial.AddIncomeUpdateAccount(txDB, userBill, model.BillTypeUnionShare, int(unionOrder.Profit), utils.Str2Int(jobID)); err != nil {
|
||||
unionOrder.UserID = userID
|
||||
dao.WrapAddIDCULEntity(unionOrder, jxcontext.AdminCtx.GetUserName())
|
||||
if err = dao.CreateEntityTx(txDB, unionOrder); err != nil {
|
||||
dao.Rollback(db, txDB)
|
||||
return err
|
||||
}
|
||||
if err = dao.CreateEntityTx(txDB, orderStatus); err != nil {
|
||||
dao.Rollback(db, txDB)
|
||||
return err
|
||||
}
|
||||
dao.Commit(db, txDB)
|
||||
//发消息
|
||||
if err == nil {
|
||||
orderMessage(unionOrder)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func NewUnionOrderStatus() (err error) {
|
||||
func ChangeUnionOrder(unionOrder *model.UnionOrder, orderStatus *model.UnionOrderStatus) (err error) {
|
||||
var (
|
||||
db = dao.GetDB()
|
||||
)
|
||||
txDB, _ := dao.Begin(db)
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
dao.Rollback(db, txDB)
|
||||
panic(r)
|
||||
}
|
||||
}()
|
||||
unionOrder.Status = orderStatus.Status
|
||||
if _, err = dao.UpdateEntityTx(txDB, unionOrder, "Status"); err != nil {
|
||||
dao.Rollback(db, txDB)
|
||||
return err
|
||||
}
|
||||
if err = dao.CreateEntityTx(txDB, orderStatus); err != nil {
|
||||
dao.Rollback(db, txDB)
|
||||
return err
|
||||
}
|
||||
dao.Commit(db, txDB)
|
||||
//发消息
|
||||
if err == nil {
|
||||
orderMessage(unionOrder)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func NewUnionOrder() (err error) {
|
||||
return err
|
||||
func orderMessage(unionOrder *model.UnionOrder) {
|
||||
content := new(strings.Builder)
|
||||
content.WriteString("您有[")
|
||||
content.WriteString(model.VendorChineseNames[unionOrder.VendorID])
|
||||
content.WriteString("]平台的推广订单:")
|
||||
content.WriteString(unionOrder.VendorOrderID)
|
||||
content.WriteString("。")
|
||||
content.WriteString(model.UnionOrderStatusName[unionOrder.Status])
|
||||
content.WriteString("。预计返佣:")
|
||||
content.WriteString(jxutils.IntPrice2StandardString(int64(unionOrder.PromotionAmount)))
|
||||
content.WriteString("元。")
|
||||
event.SendSysMessageSimple(content.String(), unionOrder.UserID)
|
||||
}
|
||||
|
||||
func ChangeUnionOrder() (err error) {
|
||||
return err
|
||||
func GetMyUnionOrders(ctx *jxcontext.Context, statuss []int, vendorID, offset, pageSize int) (page *model.PagedInfo, err error) {
|
||||
return dao.GetMyUnionOrders(dao.GetDB(), ctx.GetUserID(), statuss, vendorID, offset, pageSize)
|
||||
}
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
package mt
|
||||
|
||||
import (
|
||||
"git.rosy.net.cn/baseapi/platformapi/mtunionapi"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/business/jxstore/cms"
|
||||
"git.rosy.net.cn/jx-callback/business/jxstore/partner"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils"
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
"git.rosy.net.cn/jx-callback/globals/api"
|
||||
)
|
||||
|
||||
func OnCallback(call *mtunionapi.CallBackResult) (err error) {
|
||||
if call.Status == mtunionapi.MtUnionOrderStatusFinished {
|
||||
if order, err := api.MtUnionAPI.Rtnotify(call.Orderid, call.Type); order != nil && err == nil {
|
||||
unionOrder := &partner.UnionOrderInfo{
|
||||
SID: order.Order.Sid,
|
||||
Profit: jxutils.StandardPrice2Int(utils.Str2Float64(order.Coupon[0].Profit)),
|
||||
VendorID: model.VendorIDMTWM,
|
||||
}
|
||||
cms.UnionOrderCallBack(unionOrder)
|
||||
}
|
||||
}
|
||||
return err
|
||||
}
|
||||
@@ -1,11 +1,25 @@
|
||||
package mt
|
||||
|
||||
import (
|
||||
"git.rosy.net.cn/baseapi/platformapi/mtunionapi"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/business/jxstore/cms"
|
||||
"git.rosy.net.cn/jx-callback/business/jxstore/partner"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
"git.rosy.net.cn/jx-callback/business/model/dao"
|
||||
"git.rosy.net.cn/jx-callback/globals/api"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
var (
|
||||
orderStatusMap = map[int]int{
|
||||
mtunionapi.MtUnionOrderStatusPay: model.UnionOrderStatusPay,
|
||||
mtunionapi.MtUnionOrderStatusFinished: model.UnionOrderStatusFinish,
|
||||
mtunionapi.MtUnionOrderStatusCanceled: model.UnionOrderStatusFail,
|
||||
}
|
||||
)
|
||||
|
||||
func (s *UnionHandler) ShareUnionLink(ctx *jxcontext.Context, linkType, unionActID int, sID, userID string, resourceType int, goodsID string) (link string, err error) {
|
||||
@@ -60,3 +74,55 @@ func (s *UnionHandler) GetUnionMatterDetail(ctx *jxcontext.Context, goodsID stri
|
||||
func (s *UnionHandler) GetUnionMatterListRcmmd(ctx *jxcontext.Context, goodsID string, rcmmdType, offset, pageSize int) (result *partner.MatterList, err error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
func OnCallback(call *mtunionapi.CallBackResult) (err error) {
|
||||
var (
|
||||
db = dao.GetDB()
|
||||
)
|
||||
if order, err := api.MtUnionAPI.Rtnotify(call.Orderid, call.Type); order != nil && err == nil {
|
||||
unionOrders, err := dao.GetUnionOrdersByIDs(db, []string{order.Order.Orderid}, model.VendorIDPDD)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
orderStatus := &model.UnionOrderStatus{
|
||||
VendorOrderID: order.Order.Orderid,
|
||||
VendorID: model.VendorIDMTWM,
|
||||
Status: mtunionOrderStatus2Jx(order.Order.Status),
|
||||
VendorStatus: utils.Int2Str(order.Order.Status),
|
||||
OrderStatusAt: time.Unix(utils.Str2Int64(order.Order.Modtime), 0),
|
||||
}
|
||||
if len(order.Refund) > 0 {
|
||||
orderStatus.Comment = "售后完成"
|
||||
}
|
||||
//change
|
||||
jxutils.CallMsgHandler(func() {
|
||||
if len(unionOrders) > 0 {
|
||||
if unionOrders[0].Status != orderStatus.Status {
|
||||
cms.ChangeUnionOrder(unionOrders[0], orderStatus)
|
||||
}
|
||||
} else {
|
||||
//new
|
||||
unionOrder := &model.UnionOrder{
|
||||
VendorOrderID: order.Order.Orderid,
|
||||
VendorID: model.VendorIDMTWM,
|
||||
Status: mtunionOrderStatus2Jx(order.Order.Status),
|
||||
PID: order.Order.Sid,
|
||||
PayPrice: int(jxutils.StandardPrice2Int(utils.Str2Float64(order.Order.Direct))),
|
||||
PromotionAmount: int(jxutils.StandardPrice2Int(utils.Str2Float64(order.Coupon[0].Profit))),
|
||||
GoodsName: order.Order.Smstitle,
|
||||
GoodsID: order.Order.Dealid,
|
||||
OrderCreateAt: time.Unix(utils.Str2Int64(order.Order.Paytime), 0),
|
||||
OrderPayAt: time.Unix(utils.Str2Int64(order.Order.Paytime), 0),
|
||||
OrderReceiveAt: time.Unix(utils.Str2Int64(order.Order.Modtime), 0),
|
||||
OrderSettleAt: time.Unix(utils.Str2Int64(order.Coupon[0].Usetime), 0),
|
||||
}
|
||||
cms.NewUnionOrder(unionOrder, orderStatus)
|
||||
}
|
||||
}, jxutils.ComposeUniversalOrderID(order.Order.Orderid, model.VendorIDMTWM))
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func mtunionOrderStatus2Jx(status int) (jxstatus int) {
|
||||
return orderStatusMap[status]
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"fmt"
|
||||
"git.rosy.net.cn/baseapi/platformapi/pddapi"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/business/jxstore/cms"
|
||||
"git.rosy.net.cn/jx-callback/business/jxstore/partner"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
||||
@@ -25,6 +26,15 @@ var (
|
||||
partner.JxSortTypeXL: 5, //按销量升序;
|
||||
-partner.JxSortTypeXL: 6, //按销量降序;
|
||||
}
|
||||
|
||||
orderStatusMap = map[int]int{
|
||||
pddapi.OrderStatusPay: model.UnionOrderStatusPay,
|
||||
pddapi.OrderStatus1: model.UnionOrderStatusPay,
|
||||
pddapi.OrderStatusTakeOver: model.UnionOrderStatusTakeOver,
|
||||
pddapi.OrderStatusAuditOver: model.UnionOrderStatusAuditOver,
|
||||
pddapi.OrderStatusAuditFail: model.UnionOrderStatusFail,
|
||||
pddapi.OrderStatusEaring: model.UnionOrderStatusFinish,
|
||||
}
|
||||
)
|
||||
|
||||
func (s *UnionHandler) ShareUnionLink(ctx *jxcontext.Context, linkType, unionActID int, sID, userID string, resourceType int, goodsID string) (link string, err error) {
|
||||
@@ -188,19 +198,79 @@ func (s *UnionHandler) GetUnionMatterListRcmmd(ctx *jxcontext.Context, goodsID s
|
||||
|
||||
func GetUnionOrders() {
|
||||
var (
|
||||
page = 1
|
||||
pageSize = 50
|
||||
page = 1
|
||||
pageSize = 50
|
||||
db = dao.GetDB()
|
||||
orderIDs []string
|
||||
unionOrderIDsMap map[string]*model.UnionOrder
|
||||
)
|
||||
orders, err := api.PddAPI.OrderListIncrementGet(time.Now().Add(-time.Minute*5).Unix(), time.Now().Unix(), page, pageSize)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
task := tasksch.NewParallelTask("TempJob1", tasksch.NewParallelConfig().SetParallelCount(1).SetIsContinueWhenError(true), ctx,
|
||||
for _, v := range orders {
|
||||
orderIDs = append(orderIDs, v.OrderSn)
|
||||
}
|
||||
unionOrders, err := dao.GetUnionOrdersByIDs(db, orderIDs, model.VendorIDPDD)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
unionOrderIDsMap = make(map[string]*model.UnionOrder)
|
||||
for _, v := range unionOrders {
|
||||
unionOrderIDsMap[v.VendorOrderID] = v
|
||||
}
|
||||
task := tasksch.NewParallelTask("GetUnionOrders1", tasksch.NewParallelConfig().SetIsContinueWhenError(true), jxcontext.AdminCtx,
|
||||
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||
order := batchItemList[0].(*pddapi.OrderListIncrementGetResult)
|
||||
|
||||
detail, err := api.PddAPI.OrderDetailGet(order.OrderSn)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
orderStatus := &model.UnionOrderStatus{
|
||||
VendorOrderID: detail.OrderSn,
|
||||
VendorID: model.VendorIDPDD,
|
||||
Status: pddOrderStatus2Jx(detail.OrderStatus),
|
||||
VendorStatus: utils.Int2Str(detail.OrderStatus),
|
||||
OrderStatusAt: time.Unix(int64(detail.OrderModifyAt), 0),
|
||||
}
|
||||
if detail.ReturnStatus == 1 {
|
||||
orderStatus.Comment = "售后中"
|
||||
} else if detail.ReturnStatus == 2 {
|
||||
orderStatus.Comment = "售后完成"
|
||||
}
|
||||
//change
|
||||
jxutils.CallMsgHandler(func() {
|
||||
if unionOrderIDsMap[order.OrderSn] != nil {
|
||||
if unionOrderIDsMap[order.OrderSn].Status != orderStatus.Status {
|
||||
cms.ChangeUnionOrder(unionOrderIDsMap[order.OrderSn], orderStatus)
|
||||
}
|
||||
} else {
|
||||
//new
|
||||
unionOrder := &model.UnionOrder{
|
||||
VendorOrderID: detail.OrderSn,
|
||||
VendorID: model.VendorIDPDD,
|
||||
Status: pddOrderStatus2Jx(detail.OrderStatus),
|
||||
PID: detail.Pid,
|
||||
PayPrice: detail.OrderAmount,
|
||||
PromotionAmount: detail.PromotionAmount,
|
||||
GoodsName: detail.GoodsName,
|
||||
GoodsID: detail.GoodsSign,
|
||||
GoodsImg: detail.GoodsThumbnailURL,
|
||||
OrderCreateAt: time.Unix(int64(order.OrderCreateTime), 0),
|
||||
OrderPayAt: time.Unix(int64(order.OrderPayTime), 0),
|
||||
OrderReceiveAt: time.Unix(int64(order.OrderReceiveTime), 0),
|
||||
OrderSettleAt: time.Unix(int64(order.OrderSettleTime), 0),
|
||||
Comment: order.FailReason,
|
||||
}
|
||||
cms.NewUnionOrder(unionOrder, orderStatus)
|
||||
}
|
||||
}, jxutils.ComposeUniversalOrderID(order.OrderSn, model.VendorIDPDD))
|
||||
return retVal, err
|
||||
}, orders)
|
||||
tasksch.HandleTask(task, nil, true).Run()
|
||||
task.GetResult(0)
|
||||
tasksch.HandleTask(task, nil, false).Run()
|
||||
task.GetID()
|
||||
}
|
||||
|
||||
func pddOrderStatus2Jx(status int) (jxstatus int) {
|
||||
return orderStatusMap[status]
|
||||
}
|
||||
|
||||
@@ -90,6 +90,15 @@ var (
|
||||
OrderTypeAfsOrder: "售后单",
|
||||
}
|
||||
|
||||
UnionOrderStatusName = map[int]string{
|
||||
UnionOrderStatusNew: "新订单",
|
||||
UnionOrderStatusPay: "已支付",
|
||||
UnionOrderStatusTakeOver: "已确认收货",
|
||||
UnionOrderStatusAuditOver: "已审核",
|
||||
UnionOrderStatusFinish: "已结算",
|
||||
UnionOrderStatusFail: "结算失败",
|
||||
}
|
||||
|
||||
ComplaintReasons = map[int]string{
|
||||
ComplaintReasons1: "骑手态度恶劣",
|
||||
ComplaintReasons2: "骑手接单后未取货",
|
||||
@@ -269,9 +278,15 @@ const (
|
||||
AfsOrderStatusFailed = 190 // 售后单失败
|
||||
)
|
||||
|
||||
//联盟订单状态
|
||||
const (
|
||||
LockStatusUnlocked = 0
|
||||
LockStatusLocked = 1
|
||||
UnionOrderStatusNew = 10 //已领券?还未支付
|
||||
UnionOrderStatusPay = 15 //已支付
|
||||
UnionOrderStatusTakeOver = 20 //确认收货,已收到货
|
||||
UnionOrderStatusAuditOver = 25 //审核成功,待结算
|
||||
|
||||
UnionOrderStatusFinish = 110 //已结算
|
||||
UnionOrderStatusFail = 115 //审核失败,结算失败
|
||||
)
|
||||
|
||||
//投诉原因
|
||||
@@ -322,11 +337,6 @@ const (
|
||||
WaybillStatusEndEnd = 120
|
||||
)
|
||||
|
||||
const (
|
||||
BusinessTypeImmediate = 1
|
||||
BusinessTypeDingshida = 2
|
||||
)
|
||||
|
||||
var (
|
||||
ElmSkuPromotion = map[int]int{
|
||||
11: 1,
|
||||
@@ -334,52 +344,6 @@ var (
|
||||
}
|
||||
)
|
||||
|
||||
const (
|
||||
JdPlatformFeeRate = 10
|
||||
MtPlatformFeeRate = 10
|
||||
)
|
||||
|
||||
const (
|
||||
OrderDeliveryFlagMaskScheduleDisabled = 1 // 禁止三方配送调度
|
||||
OrderDeliveryFlagMaskPurcahseDisabled = 2 // 购物平台已不配送(一般为门店配送类型本身为自配送,或已经转自配送)
|
||||
|
||||
OrderDeliveryFlagMaskAutoPickup = 4 // 是否是自动拣货的
|
||||
|
||||
OrderDeliveryFlagMaskDada = 16 // 创建达达运单中
|
||||
OrderDeliveryFlagMaskMtps = 32 // 创建美团配送运单中
|
||||
)
|
||||
|
||||
const (
|
||||
WaybillDeliveryFlagMaskActiveCancel = 1 // 主动取消
|
||||
)
|
||||
|
||||
const (
|
||||
OrderFlagMaskPrinted = 1 // 已经打印
|
||||
|
||||
OrderFlagMaskUserApplyCancel = 6
|
||||
OrderFlagAgreeUserApplyCancel = 2
|
||||
OrderFlagRefuseUserApplyCancel = 6
|
||||
|
||||
OrderFlagMaskFailedGetGoods = 24
|
||||
OrderFlagAgreeFailedGetGoods = 8
|
||||
OrderFlagRefuseFailedGetGoods = 24
|
||||
|
||||
OrderFlagMaskFailedDeliver = 32
|
||||
OrderFlagMaskCallPMCourier = 64 // 取货失败后召唤平台配送
|
||||
OrderFlagMaskSetDelivered = 128 // 设置送达
|
||||
|
||||
OrderFlagMaskFake = 256 // 假订单,即刷单用的
|
||||
OrderFlagMaskTempJX = 512 // 临时京西订单
|
||||
)
|
||||
|
||||
const (
|
||||
AfsOrderFlagMaskUserRefund = 3 // 门店处理售后单申请
|
||||
AfsOrderFlagAgreeUserRefund = 1 // 门店同意售后单申请
|
||||
AfsOrderFlagRefuseUserRefund = 3 // 门店拒绝售后单申请
|
||||
|
||||
AfsOrderFlagMaskReturnGoods = 4 // 门店确认收到退货
|
||||
)
|
||||
|
||||
const (
|
||||
AfsAppealTypeRefund = 1 // 仅退款
|
||||
AfsAppealTypeReturnAndRefund = 2 // 退货退款
|
||||
@@ -400,12 +364,6 @@ const (
|
||||
AfsReasonNotOthers = 0 // 其它
|
||||
)
|
||||
|
||||
const (
|
||||
AfsTypeUnknown = 0 // 未知
|
||||
AfsTypePartRefund = 1 // 部分退款
|
||||
AfsTypeFullRefund = 2 // 全额退款
|
||||
)
|
||||
|
||||
const (
|
||||
DefaultEarningPricePercentage = 70 // 门店缺省结算百分比
|
||||
|
||||
@@ -420,21 +378,6 @@ const (
|
||||
DISABLED = -1
|
||||
)
|
||||
|
||||
func IsPurchaseVendorExist(vendorID int) bool {
|
||||
_, ok := VendorNames[vendorID]
|
||||
return ok && vendorID >= VendorIDPurchaseBegin && vendorID <= VendorIDPurchaseEnd
|
||||
}
|
||||
|
||||
func IsDeliveryVendorExist(vendorID int) bool {
|
||||
_, ok := VendorNames[vendorID]
|
||||
return ok && vendorID >= VendorIDDeliveryBegin && vendorID <= VendorIDDeliveryEnd
|
||||
}
|
||||
|
||||
func IsPrinterVendorExist(vendorID int) bool {
|
||||
_, ok := VendorNames[vendorID]
|
||||
return ok && vendorID >= VendorIDPrinterBegin && vendorID <= VendorIDPrinterEnd
|
||||
}
|
||||
|
||||
func IsOrderLockStatus(status int) bool {
|
||||
return status == OrderStatusLocked || status == OrderStatusApplyCancel
|
||||
}
|
||||
@@ -459,15 +402,6 @@ func IsVendorRemote(vendorID int) bool {
|
||||
return vendorID >= VendorIDJD && vendorID <= VendorIDEBAI
|
||||
}
|
||||
|
||||
func WaybillVendorID2Mask(vendorID int) (mask int8) {
|
||||
if vendorID == VendorIDDada {
|
||||
mask = OrderDeliveryFlagMaskDada
|
||||
} else if vendorID == VendorIDMTPS {
|
||||
mask = OrderDeliveryFlagMaskMtps
|
||||
}
|
||||
return mask
|
||||
}
|
||||
|
||||
func IsAfsOrderFinalStatus(status int) bool {
|
||||
return status >= AfsOrderStatusFinished && status <= AfsOrderStatusFailed
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package dao
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
@@ -77,8 +76,6 @@ func GetDeliveryOrders(db *DaoDB, userIDs []string, statuss []int, fromTime, toT
|
||||
sqlParams = append(sqlParams, pageSize, offset)
|
||||
txDB, _ := Begin(db)
|
||||
defer Commit(db, txDB)
|
||||
fmt.Println(sql)
|
||||
fmt.Println(sqlParams)
|
||||
if err = GetRowsTx(txDB, &dOrders, sql, sqlParams...); err == nil {
|
||||
pagedInfo = &model.PagedInfo{
|
||||
TotalCount: GetLastTotalRowCountTx(txDB),
|
||||
@@ -517,3 +514,60 @@ func GetManageStatisticsJob(db *DaoDB, cityCodes []int, fromTime, toTime time.Ti
|
||||
}
|
||||
return pageInfo, err
|
||||
}
|
||||
|
||||
func GetUnionOrdersByIDs(db *DaoDB, vendorOrderIDs []string, vendorID int) (orders []*model.UnionOrder, err error) {
|
||||
if len(vendorOrderIDs) == 0 {
|
||||
return nil, err
|
||||
}
|
||||
sql := `
|
||||
SELECT *
|
||||
FROM union_order
|
||||
WHERE 1 = 1
|
||||
`
|
||||
sqlParams := []interface{}{}
|
||||
if len(vendorOrderIDs) > 0 {
|
||||
sql += ` AND vendor_order_id IN (` + GenQuestionMarks(len(vendorOrderIDs)) + `)`
|
||||
sqlParams = append(sqlParams, vendorOrderIDs)
|
||||
}
|
||||
if vendorID != 0 {
|
||||
sql += ` AND vendor_id = ?`
|
||||
sqlParams = append(sqlParams, vendorID)
|
||||
}
|
||||
err = GetRows(db, &orders, sql, sqlParams)
|
||||
return orders, err
|
||||
}
|
||||
|
||||
func GetMyUnionOrders(db *DaoDB, userID string, statuss []int, vendorID, offset, pageSize int) (page *model.PagedInfo, err error) {
|
||||
var orders []*model.UnionOrder
|
||||
sql := `
|
||||
SELECT SQL_CALC_FOUND_ROWS a.*
|
||||
FROM union_order a
|
||||
WHERE 1 = 1
|
||||
`
|
||||
sqlParams := []interface{}{}
|
||||
if vendorID != -1 {
|
||||
sql += ` AND a.vendor_id = ?`
|
||||
sqlParams = append(sqlParams, vendorID)
|
||||
}
|
||||
if len(statuss) > 0 {
|
||||
sql += ` AND a.status IN (` + GenQuestionMarks(len(statuss)) + `)`
|
||||
sqlParams = append(sqlParams, statuss)
|
||||
}
|
||||
if userID != "" {
|
||||
sql += ` AND a.user_id = ?`
|
||||
sqlParams = append(sqlParams, userID)
|
||||
}
|
||||
sql += " ORDER BY a.created_at DESC"
|
||||
sql += " LIMIT ? OFFSET ?"
|
||||
pageSize = jxutils.FormalizePageSize(pageSize)
|
||||
sqlParams = append(sqlParams, pageSize, offset)
|
||||
txDB, _ := Begin(db)
|
||||
defer Commit(db, txDB)
|
||||
if err = GetRowsTx(txDB, &orders, sql, sqlParams...); err == nil {
|
||||
page = &model.PagedInfo{
|
||||
TotalCount: GetLastTotalRowCountTx(txDB),
|
||||
Data: orders,
|
||||
}
|
||||
}
|
||||
return page, err
|
||||
}
|
||||
|
||||
@@ -153,6 +153,7 @@ type UnionOrder struct {
|
||||
OrderReceiveAt time.Time `json:"orderReceiveAt"` //收货时间
|
||||
OrderSettleAt time.Time `json:"orderSettleAt"` //结算时间
|
||||
PID string `orm:"column(p_id)" json:"pID"` //推广位ID
|
||||
IsEarning int `json:"isEarning"` //是否结算此订单,1表示已结算了
|
||||
Comment string `orm:"size(255)" json:"comment"` //备注
|
||||
}
|
||||
|
||||
|
||||
@@ -167,3 +167,23 @@ func (c *OrderController) GetManageStatisticsJob() {
|
||||
return retVal, "", err
|
||||
})
|
||||
}
|
||||
|
||||
// @Title 查询我的推广订单
|
||||
// @Description 查询我的推广订单
|
||||
// @Param token header string true "认证token"
|
||||
// @Param statuss query string false "状态s"
|
||||
// @Param vendorID query int false "-1 全部"
|
||||
// @Param offset query int false "列表起始序号(以0开始,缺省为0)"
|
||||
// @Param pageSize query int false "列表页大小(缺省为50,-1表示全部)"
|
||||
// @Success 200 {object} controllers.CallResult
|
||||
// @Failure 200 {object} controllers.CallResult
|
||||
// @router /GetMyUnionOrders [get]
|
||||
func (c *OrderController) GetMyUnionOrders() {
|
||||
c.callGetMyUnionOrders(func(params *tOrderGetMyUnionOrdersParams) (retVal interface{}, errCode string, err error) {
|
||||
var statuss []int
|
||||
if err = jxutils.Strings2Objs(params.Statuss, &statuss); err == nil {
|
||||
retVal, err = cms.GetMyUnionOrders(params.Ctx, statuss, params.VendorID, params.Offset, params.PageSize)
|
||||
}
|
||||
return retVal, "", err
|
||||
})
|
||||
}
|
||||
|
||||
@@ -745,6 +745,15 @@ func init() {
|
||||
Filters: nil,
|
||||
Params: nil})
|
||||
|
||||
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:OrderController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:OrderController"],
|
||||
beego.ControllerComments{
|
||||
Method: "GetMyUnionOrders",
|
||||
Router: "/GetMyUnionOrders",
|
||||
AllowHTTPMethods: []string{"get"},
|
||||
MethodParams: param.Make(),
|
||||
Filters: nil,
|
||||
Params: nil})
|
||||
|
||||
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:OrderController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:OrderController"],
|
||||
beego.ControllerComments{
|
||||
Method: "GetOrders",
|
||||
|
||||
Reference in New Issue
Block a user