Files
jx-callback/controllers/jx_order2.go
苏尹岚 7ce41f81d3 aa
2021-01-11 14:48:31 +08:00

330 lines
15 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package controllers
import (
"git.rosy.net.cn/baseapi/utils"
"git.rosy.net.cn/jx-callback/business/jxutils"
"git.rosy.net.cn/jx-callback/business/model"
"git.rosy.net.cn/jx-callback/business/partner/purchase/jx/localjx"
"github.com/astaxie/beego"
)
type JxOrderController struct {
beego.Controller
}
// @Title 创建京西商城订单
// @Description 创建京西商城订单
// @Param token header string true "认证token"
// @Param jxOrder formData string true "订单信息"
// @Param addressID formData int64 true "配送地址ID"
// @Param fromStoreID formData int fasle "物料配送门店"
// @Param createType formData int false "创建类型, 0:预创建, 1:创建"
// @Param isDeliverySelf formData bool false "是否是自提单"
// @Success 200 {object} controllers.CallResult
// @Failure 200 {object} controllers.CallResult
// @router /CreateOrder [post]
func (c *JxOrderController) CreateOrder() {
c.callCreateOrder(func(params *tJxorderCreateOrderParams) (retVal interface{}, errCode string, err error) {
var jxOrder *localjx.JxOrderInfo
if err = utils.UnmarshalUseNumber([]byte(params.JxOrder), &jxOrder); err == nil {
retVal, err = localjx.CreateOrder(params.Ctx, jxOrder, int64(params.AddressID), params.CreateType, params.FromStoreID, params.IsDeliverySelf)
}
return retVal, "", err
})
}
// @Title 请求支付京西商城订单
// @Description 请求支付京西商城订单
// @Param token header string true "认证token"
// @Param vendorOrderID formData string true "订单ID"
// @Param payType formData int true "支付类型"
// @Param vendorPayType formData string true "平台支付类型"
// @Success 200 {object} controllers.CallResult
// @Failure 200 {object} controllers.CallResult
// @router /Pay4Order [post]
func (c *JxOrderController) Pay4Order() {
c.callPay4Order(func(params *tJxorderPay4OrderParams) (retVal interface{}, errCode string, err error) {
retVal, err = localjx.Pay4Order(params.Ctx, utils.Str2Int64(params.VendorOrderID), params.PayType, params.VendorPayType)
return retVal, "", err
})
}
// @Title 请求支付京西商城相关用户支付项目
// @Description 请求支付京西商城相关用户支付项目
// @Param token header string true "认证token"
// @Param thingID formData int true "项目ID"
// @Param payType formData int true "支付类型"
// @Param vendorPayType formData string true "平台支付类型"
// @Success 200 {object} controllers.CallResult
// @Failure 200 {object} controllers.CallResult
// @router /Pay4User [post]
func (c *JxOrderController) Pay4User() {
c.callPay4User(func(params *tJxorderPay4UserParams) (retVal interface{}, errCode string, err error) {
retVal, err = localjx.Pay4User(params.Ctx, params.ThingID, params.PayType, params.VendorPayType)
return retVal, "", err
})
}
// @Title 买家取消(或申请取消)订单
// @Description 买家取消(或申请取消)订单
// @Param token header string true "认证token"
// @Param vendorOrderID formData string true "订单ID"
// @Param reason formData string true "原因"
// @Success 200 {object} controllers.CallResult
// @Failure 200 {object} controllers.CallResult
// @router /BuyerCancelOrder [post]
func (c *JxOrderController) BuyerCancelOrder() {
c.callBuyerCancelOrder(func(params *tJxorderBuyerCancelOrderParams) (retVal interface{}, errCode string, err error) {
retVal, err = localjx.BuyerCancelOrder(params.Ctx, utils.Str2Int64(params.VendorOrderID), params.Reason)
return retVal, "", err
})
}
// @Title 得到门店营业时间配送列表
// @Description 得到门店营业时间配送列表
// @Param token header string true "认证token"
// @Param storeID query int true "门店ID"
// @Success 200 {object} controllers.CallResult
// @Failure 200 {object} controllers.CallResult
// @router /GetAvailableDeliverTime [get]
func (c *JxOrderController) GetAvailableDeliverTime() {
c.callGetAvailableDeliverTime(func(params *tJxorderGetAvailableDeliverTimeParams) (retVal interface{}, errCode string, err error) {
retVal, err = localjx.GetAvailableDeliverTime(params.Ctx, params.StoreID)
return retVal, "", err
})
}
// @Title 得到一个订单的支付信息
// @Description 得到一个订单的支付信息
// @Param token header string true "认证token"
// @Param vendorOrderID query string true "订单号,如果此项不为空,忽略其它所有查询条件"
// @Success 200 {object} controllers.CallResult
// @Failure 200 {object} controllers.CallResult
// @router /GetOrderPay [get]
func (c *JxOrderController) GetOrderPay() {
c.callGetOrderPay(func(params *tJxorderGetOrderPayParams) (retVal interface{}, errCode string, err error) {
retVal, err = localjx.GetOrderPay(params.Ctx, params.VendorOrderID)
return retVal, "", err
})
}
// @Title 查询自己的订单
// @Description 查询自己的订单
// @Param token header string true "认证token"
// @Param vendorOrderID query string false "订单号,如果此项不为空,忽略其它所有查询条件"
// @Param keyword query string false "查询关键字"
// @Param fromDate query string false "开始日期包含格式2006-01-02如果订单号为空此项必须要求"
// @Param toDate query string false "结束日期包含格式2006-01-02如果订单号为空此项必须要求"
// @Param statuss query string false "订单状态列表[1,2,3],缺省不限制"
// @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 /GetMyOrders [get]
func (c *JxOrderController) GetMyOrders() {
c.callGetMyOrders(func(params *tJxorderGetMyOrdersParams) (retVal interface{}, errCode string, err error) {
retVal, err = localjx.GetMyOrders(params.Ctx, params.FromDate, params.ToDate, params.MapData, params.Offset, params.PageSize)
return retVal, "", err
})
}
// @Title 查询自己的售后单
// @Description 查询自己的售后单
// @Param token header string true "认证token"
// @Param vendorOrderID query string false "订单号,如果此项不为空,忽略其它所有查询条件"
// @Param afsOrderID query string false "售后单号"
// @Param userID query string false "用户ID"
// @Param fromTime query string false "开始日期包含格式2006-01-02如果订单号为空此项必须要求"
// @Param toTime query string false "结束日期包含格式2006-01-02如果订单号为空此项必须要求"
// @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 /GetMyAfsOrders [get]
func (c *JxOrderController) GetMyAfsOrders() {
c.callGetMyAfsOrders(func(params *tJxorderGetMyAfsOrdersParams) (retVal interface{}, errCode string, err error) {
retVal, err = localjx.GetMyAfsOrders(params.Ctx, params.VendorOrderID, params.AfsOrderID, params.UserID, params.FromTime, params.ToTime, params.Offset, params.PageSize)
return retVal, "", err
})
}
// @Title 查询自己的订单状态数量信息
// @Description 查询自己的订单状态数量信息
// @Param token header string true "认证token"
// @Param fromDate query string false "开始日期包含格式2006-01-02如果订单号为空此项必须要求"
// @Param toDate query string false "结束日期包含格式2006-01-02如果订单号为空此项必须要求"
// @Param statuss query string false "订单状态列表[1,2,3],缺省不限制"
// @Success 200 {object} controllers.CallResult
// @Failure 200 {object} controllers.CallResult
// @router /GetMyOrderCountInfo [get]
func (c *JxOrderController) GetMyOrderCountInfo() {
c.callGetMyOrderCountInfo(func(params *tJxorderGetMyOrderCountInfoParams) (retVal interface{}, errCode string, err error) {
timeList, err := jxutils.BatchStr2Time(params.FromDate, params.ToDate)
if err == nil {
var statuss []int
if err = jxutils.Strings2Objs(params.Statuss, &statuss); err == nil {
retVal, err = localjx.GetMyOrderCountInfo(params.Ctx, timeList[0], timeList[1], statuss)
}
}
return retVal, "", err
})
}
// @Title 每日订单打款
// @Description 每日订单打款
// @Param token header string true "认证token"
// @Success 200 {object} controllers.CallResult
// @Failure 200 {object} controllers.CallResult
// @router /AutoPayForPopluarMan [post]
func (c *JxOrderController) AutoPayForPopluarMan() {
c.callAutoPayForPopluarMan(func(params *tJxorderAutoPayForPopluarManParams) (retVal interface{}, errCode string, err error) {
err = localjx.AutoPayForPopluarMan(params.Ctx)
return retVal, "", err
})
}
// @Title 订单打款
// @Description 订单打款
// @Param token header string true "认证token"
// @Param vendorOrderID formData string true "订单ID"
// @Param userID formData string true "userID"
// @Param price formData int true "钱"
// @Success 200 {object} controllers.CallResult
// @Failure 200 {object} controllers.CallResult
// @router /PayForPopluarMan [post]
func (c *JxOrderController) PayForPopluarMan() {
c.callPayForPopluarMan(func(params *tJxorderPayForPopluarManParams) (retVal interface{}, errCode string, err error) {
err = localjx.PayForPopluarMan(params.Ctx, params.VendorOrderID, params.UserID, params.Price)
return retVal, "", err
})
}
// @Title 查询物料订单状态
// @Description 查询物料订单状态
// @Param token header string true "认证token"
// @Param vendorOrderID query string true "订单ID"
// @Success 200 {object} controllers.CallResult
// @Failure 200 {object} controllers.CallResult
// @router /GetMatterOrderStatus [get]
func (c *JxOrderController) GetMatterOrderStatus() {
c.callGetMatterOrderStatus(func(params *tJxorderGetMatterOrderStatusParams) (retVal interface{}, errCode string, err error) {
retVal, err = localjx.GetMatterOrderStatus(params.Ctx, params.VendorOrderID)
return retVal, "", err
})
}
// @Title 刷新所有物料订单状态
// @Description 刷新所有物料订单状态
// @Param token header string true "认证token"
// @Success 200 {object} controllers.CallResult
// @Failure 200 {object} controllers.CallResult
// @router /RefreshAllMatterOrderStatus [put]
func (c *JxOrderController) RefreshAllMatterOrderStatus() {
c.callRefreshAllMatterOrderStatus(func(params *tJxorderRefreshAllMatterOrderStatusParams) (retVal interface{}, errCode string, err error) {
err = localjx.RefreshAllMatterOrderStatus(params.Ctx)
return retVal, "", err
})
}
// @Title 重发物料订单
// @Description 重发物料订单
// @Param token header string true "认证token"
// @Param vendorOrderID formData string true "订单ID"
// @Success 200 {object} controllers.CallResult
// @Failure 200 {object} controllers.CallResult
// @router /SendFailedMatterOrder [post]
func (c *JxOrderController) SendFailedMatterOrder() {
c.callSendFailedMatterOrder(func(params *tJxorderSendFailedMatterOrderParams) (retVal interface{}, errCode string, err error) {
err = localjx.SendFailedMatterOrder(params.Ctx, params.VendorOrderID)
return retVal, "", err
})
}
// @Title 根据时间获取进货辅助工具里的商品,用于加入购物车
// @Description 根据时间获取进货辅助工具里的商品,用于加入购物车
// @Param token header string true "认证token"
// @Param fromDate query string false "开始日期包含格式2006-01-02如果订单号为空此项必须要求"
// @Param toDate query string false "结束日期包含格式2006-01-02如果订单号为空此项必须要求"
// @Param fromStoreID query int false "进货门店ID"
// @Param storeID query int false "货源门店ID"
// @Param percentage query string false "销量比例11.051.1"
// @Success 200 {object} controllers.CallResult
// @Failure 200 {object} controllers.CallResult
// @router /GetSupplySupportStoreSkus [get]
func (c *JxOrderController) GetSupplySupportStoreSkus() {
c.callGetSupplySupportStoreSkus(func(params *tJxorderGetSupplySupportStoreSkusParams) (retVal interface{}, errCode string, err error) {
retVal, err = localjx.GetSupplySupportStoreSkus(params.Ctx, params.FromDate, params.ToDate, params.FromStoreID, params.StoreID, params.Percentage)
return retVal, "", err
})
}
// @Title 得到自己的守价订单列表
// @Description 得到自己的守价订单列表
// @Param token header string true "认证token"
// @Param fromTime query string false "开始日期包含格式2006-01-02 00:00:00"
// @Param toTime query string false "结束日期包含格式2006-01-02 00:00:00"
// @Success 200 {object} controllers.CallResult
// @Failure 200 {object} controllers.CallResult
// @router /GetMyPriceDefendOrders [get]
func (c *JxOrderController) GetMyPriceDefendOrders() {
c.callGetMyPriceDefendOrders(func(params *tJxorderGetMyPriceDefendOrdersParams) (retVal interface{}, errCode string, err error) {
retVal, err = localjx.GetMyPriceDefendOrders(params.Ctx, params.FromTime, params.ToTime)
return retVal, "", err
})
}
// @Title 测试立马生成守价订单
// @Description 测试立马生成守价订单
// @Param token header string true "认证token"
// @Success 200 {object} controllers.CallResult
// @Failure 200 {object} controllers.CallResult
// @router /TestDefend [get]
func (c *JxOrderController) TestDefend() {
c.callTestDefend(func(params *tJxorderTestDefendParams) (retVal interface{}, errCode string, err error) {
err = localjx.CreateOrderByPriceDefend(params.Ctx)
return retVal, "", err
})
}
// @Title 查询优惠券
// @Description 查询优惠券
// @Param token header string true "认证token"
// @Param couponType query int false "优惠券类型1为商品总额满减2为运费优惠"
// @Param couponStatuss query string false "优惠券状态0为正常可使用-1为已过期 -2为还没开始"
// @Param storeIDs query string false "门店IDs"
// @Param keyword query string false "关键字"
// @Success 200 {object} controllers.CallResult
// @Failure 200 {object} controllers.CallResult
// @router /GetCoupons [get]
func (c *JxOrderController) GetCoupons() {
c.callGetCoupons(func(params *tJxorderGetCouponsParams) (retVal interface{}, errCode string, err error) {
var statuss, storeIDs []int
if err = jxutils.Strings2Objs(params.CouponStatuss, &statuss, params.StoreIDs, &storeIDs); err == nil {
retVal, err = localjx.GetCoupons(params.Ctx, params.CouponType, statuss, storeIDs, params.Keyword)
}
return retVal, "", err
})
}
// @Title 添加优惠券
// @Description 添加优惠券
// @Param token header string true "认证token"
// @Param payload formData string true "优惠券类型 payload"
// @Param storeIDs formData string false "门店IDs"
// @Param count formData int false "优惠券数量默认1"
// @Success 200 {object} controllers.CallResult
// @Failure 200 {object} controllers.CallResult
// @router /AddCoupons [post]
func (c *JxOrderController) AddCoupons() {
c.callAddCoupons(func(params *tJxorderAddCouponsParams) (retVal interface{}, errCode string, err error) {
coupons := &model.Coupons{}
var storeIDs []int
if err = utils.UnmarshalUseNumber([]byte(params.Payload), coupons); err == nil {
if err = jxutils.Strings2Objs(params.StoreIDs, &storeIDs); err == nil {
err = localjx.AddCoupons(params.Ctx, coupons, params.Count, storeIDs)
}
}
return retVal, "", err
})
}