...
|
...
|
@@ -33,140 +33,140 @@ func (c *OrderInfoController) Prepare() { |
|
|
}
|
|
|
|
|
|
//PageListOrderPurpose 分页获取意向订单列表
|
|
|
func (c *OrderInfoController) PageListOrderPurpose() {
|
|
|
type Parameter struct {
|
|
|
SearchText string `json:"searchText"`
|
|
|
Partner int64 `json:"partner"`
|
|
|
PageSize int `json:"pageSize"`
|
|
|
PageNumber int `json:"pageNumber"`
|
|
|
}
|
|
|
var (
|
|
|
param Parameter
|
|
|
err error
|
|
|
)
|
|
|
if err = c.BindJsonData(¶m); err != nil {
|
|
|
logs.Error(err)
|
|
|
c.ResponseError(errors.New("json数据解析失败"))
|
|
|
return
|
|
|
}
|
|
|
if param.PageNumber == 0 {
|
|
|
param.PageNumber = 1
|
|
|
}
|
|
|
if param.PageSize == 0 {
|
|
|
param.PageSize = 20
|
|
|
}
|
|
|
companyId := c.GetUserCompany()
|
|
|
orderSrv := orderService.NewOrderInfoService(nil)
|
|
|
orderinfos, cnt, err := orderSrv.PageListOrderBase(orderQuery.ListOrderBaseQuery{
|
|
|
PartnerId: param.Partner,
|
|
|
OrderCode: param.SearchText,
|
|
|
OrderType: domain.OrderIntention,
|
|
|
Limit: param.PageSize,
|
|
|
Offset: (param.PageNumber - 1) * param.PageSize,
|
|
|
CompanyId: companyId,
|
|
|
})
|
|
|
if err != nil {
|
|
|
c.ResponseError(err)
|
|
|
return
|
|
|
}
|
|
|
rsp := []map[string]interface{}{}
|
|
|
for i := range orderinfos {
|
|
|
orderinfo := orderinfos[i]
|
|
|
m := map[string]interface{}{
|
|
|
"createTime": orderinfo.CreateTime.Local().Format("2006-01-02 15:04:05"),
|
|
|
"updateTime": orderinfo.UpdateTime.Local().Format("2006-01-02 15:04:05"),
|
|
|
"buyer": orderinfo.Buyer.BuyerName,
|
|
|
"id": orderinfo.Id,
|
|
|
"orderId": orderinfo.OrderCode,
|
|
|
"partner": orderinfo.PartnerInfo.PartnerName,
|
|
|
"orderNum": orderinfo.OrderCompute.PlanOrderCount,
|
|
|
"orderPrice": orderinfo.OrderCompute.PlanOrderAmount,
|
|
|
"orderDist": orderinfo.RegionInfo.RegionName,
|
|
|
}
|
|
|
rsp = append(rsp, m)
|
|
|
}
|
|
|
c.ResponsePageList(rsp, cnt, param.PageNumber)
|
|
|
}
|
|
|
// func (c *OrderInfoController) PageListOrderPurpose() {
|
|
|
// type Parameter struct {
|
|
|
// SearchText string `json:"searchText"`
|
|
|
// Partner int64 `json:"partner"`
|
|
|
// PageSize int `json:"pageSize"`
|
|
|
// PageNumber int `json:"pageNumber"`
|
|
|
// }
|
|
|
// var (
|
|
|
// param Parameter
|
|
|
// err error
|
|
|
// )
|
|
|
// if err = c.BindJsonData(¶m); err != nil {
|
|
|
// logs.Error(err)
|
|
|
// c.ResponseError(errors.New("json数据解析失败"))
|
|
|
// return
|
|
|
// }
|
|
|
// if param.PageNumber == 0 {
|
|
|
// param.PageNumber = 1
|
|
|
// }
|
|
|
// if param.PageSize == 0 {
|
|
|
// param.PageSize = 20
|
|
|
// }
|
|
|
// companyId := c.GetUserCompany()
|
|
|
// orderSrv := orderService.NewOrderInfoService(nil)
|
|
|
// orderinfos, cnt, err := orderSrv.PageListOrderBase(orderQuery.ListOrderBaseQuery{
|
|
|
// PartnerId: param.Partner,
|
|
|
// OrderCode: param.SearchText,
|
|
|
// OrderType: domain.OrderIntention,
|
|
|
// Limit: param.PageSize,
|
|
|
// Offset: (param.PageNumber - 1) * param.PageSize,
|
|
|
// CompanyId: companyId,
|
|
|
// })
|
|
|
// if err != nil {
|
|
|
// c.ResponseError(err)
|
|
|
// return
|
|
|
// }
|
|
|
// rsp := []map[string]interface{}{}
|
|
|
// for i := range orderinfos {
|
|
|
// orderinfo := orderinfos[i]
|
|
|
// m := map[string]interface{}{
|
|
|
// "createTime": orderinfo.CreateTime.Local().Format("2006-01-02 15:04:05"),
|
|
|
// "updateTime": orderinfo.UpdateTime.Local().Format("2006-01-02 15:04:05"),
|
|
|
// "buyer": orderinfo.Buyer.BuyerName,
|
|
|
// "id": orderinfo.Id,
|
|
|
// "orderId": orderinfo.OrderCode,
|
|
|
// "partner": orderinfo.PartnerInfo.PartnerName,
|
|
|
// "orderNum": orderinfo.OrderCompute.PlanOrderCount,
|
|
|
// "orderPrice": orderinfo.OrderCompute.PlanOrderAmount,
|
|
|
// "orderDist": orderinfo.RegionInfo.RegionName,
|
|
|
// }
|
|
|
// rsp = append(rsp, m)
|
|
|
// }
|
|
|
// c.ResponsePageList(rsp, cnt, param.PageNumber)
|
|
|
// }
|
|
|
|
|
|
//GetOrderPurpose 获取意向订单详情
|
|
|
func (c *OrderInfoController) GetOrderPurpose() {
|
|
|
type Parameter struct {
|
|
|
Id string `json:"id"`
|
|
|
}
|
|
|
var (
|
|
|
param Parameter
|
|
|
err error
|
|
|
)
|
|
|
if err = c.BindJsonData(¶m); err != nil {
|
|
|
logs.Error(err)
|
|
|
c.ResponseError(errors.New("json数据解析失败"))
|
|
|
return
|
|
|
}
|
|
|
orderid, _ := strconv.ParseInt(param.Id, 10, 64)
|
|
|
companyId := c.GetUserCompany()
|
|
|
orderSrv := orderService.NewOrderInfoService(nil)
|
|
|
orderinfo, err := orderSrv.GetOrderDetail(orderQuery.GetOrderQuery{
|
|
|
OrderId: orderid,
|
|
|
CompanyId: companyId,
|
|
|
})
|
|
|
if err != nil {
|
|
|
c.ResponseError(err)
|
|
|
return
|
|
|
}
|
|
|
if orderinfo.OrderType != domain.OrderIntention {
|
|
|
c.ResponseError(errors.New("参数错误"))
|
|
|
return
|
|
|
}
|
|
|
allGoods := []map[string]interface{}{}
|
|
|
for _, v := range orderinfo.Goods {
|
|
|
m := map[string]interface{}{
|
|
|
"id": v.Id,
|
|
|
"productName": v.GoodName,
|
|
|
"orderNum": v.PlanGoodNumber,
|
|
|
"univalence": v.Price,
|
|
|
"partnerRatio": v.PartnerBonusPercent,
|
|
|
"orderPrice": v.GoodCompute.PlanAmount,
|
|
|
}
|
|
|
allGoods = append(allGoods, m)
|
|
|
}
|
|
|
rsp := map[string]interface{}{
|
|
|
"buyer": orderinfo.Buyer.BuyerName,
|
|
|
"id": orderinfo.Id,
|
|
|
"partnerID": orderinfo.PartnerInfo.Id,
|
|
|
"partner": orderinfo.PartnerInfo.PartnerName,
|
|
|
"orderDist": orderinfo.RegionInfo.RegionName,
|
|
|
"orderId": orderinfo.OrderCode,
|
|
|
"product": allGoods,
|
|
|
"commissionProportion": orderinfo.SalesmanBonusPercent,
|
|
|
"orderNumCount": orderinfo.OrderCompute.PlanOrderCount,
|
|
|
"orderAmountAdjustmentCount": orderinfo.OrderCompute.PlanOrderAmount,
|
|
|
}
|
|
|
c.ResponseData(rsp)
|
|
|
}
|
|
|
// func (c *OrderInfoController) GetOrderPurpose() {
|
|
|
// type Parameter struct {
|
|
|
// Id string `json:"id"`
|
|
|
// }
|
|
|
// var (
|
|
|
// param Parameter
|
|
|
// err error
|
|
|
// )
|
|
|
// if err = c.BindJsonData(¶m); err != nil {
|
|
|
// logs.Error(err)
|
|
|
// c.ResponseError(errors.New("json数据解析失败"))
|
|
|
// return
|
|
|
// }
|
|
|
// orderid, _ := strconv.ParseInt(param.Id, 10, 64)
|
|
|
// companyId := c.GetUserCompany()
|
|
|
// orderSrv := orderService.NewOrderInfoService(nil)
|
|
|
// orderinfo, err := orderSrv.GetOrderDetail(orderQuery.GetOrderQuery{
|
|
|
// OrderId: orderid,
|
|
|
// CompanyId: companyId,
|
|
|
// })
|
|
|
// if err != nil {
|
|
|
// c.ResponseError(err)
|
|
|
// return
|
|
|
// }
|
|
|
// if orderinfo.OrderType != domain.OrderIntention {
|
|
|
// c.ResponseError(errors.New("参数错误"))
|
|
|
// return
|
|
|
// }
|
|
|
// allGoods := []map[string]interface{}{}
|
|
|
// for _, v := range orderinfo.Goods {
|
|
|
// m := map[string]interface{}{
|
|
|
// "id": v.Id,
|
|
|
// "productName": v.GoodName,
|
|
|
// "orderNum": v.PlanGoodNumber,
|
|
|
// "univalence": v.Price,
|
|
|
// "partnerRatio": v.PartnerBonusPercent,
|
|
|
// "orderPrice": v.GoodCompute.PlanAmount,
|
|
|
// }
|
|
|
// allGoods = append(allGoods, m)
|
|
|
// }
|
|
|
// rsp := map[string]interface{}{
|
|
|
// "buyer": orderinfo.Buyer.BuyerName,
|
|
|
// "id": orderinfo.Id,
|
|
|
// "partnerID": orderinfo.PartnerInfo.Id,
|
|
|
// "partner": orderinfo.PartnerInfo.PartnerName,
|
|
|
// "orderDist": orderinfo.RegionInfo.RegionName,
|
|
|
// "orderId": orderinfo.OrderCode,
|
|
|
// "product": allGoods,
|
|
|
// "commissionProportion": orderinfo.SalesmanBonusPercent,
|
|
|
// "orderNumCount": orderinfo.OrderCompute.PlanOrderCount,
|
|
|
// "orderAmountAdjustmentCount": orderinfo.OrderCompute.PlanOrderAmount,
|
|
|
// }
|
|
|
// c.ResponseData(rsp)
|
|
|
// }
|
|
|
|
|
|
//RemoveOrderPurpose 删除意向订单
|
|
|
func (c *OrderInfoController) RemoveOrderPurpose() {
|
|
|
type Parameter struct {
|
|
|
Id int64 `json:"id"`
|
|
|
}
|
|
|
var (
|
|
|
param Parameter
|
|
|
err error
|
|
|
)
|
|
|
if err = c.BindJsonData(¶m); err != nil {
|
|
|
logs.Error(err)
|
|
|
c.ResponseError(errors.New("json数据解析失败"))
|
|
|
return
|
|
|
}
|
|
|
companyId := c.GetUserCompany()
|
|
|
orderSrv := orderService.NewOrderInfoService(nil)
|
|
|
err = orderSrv.DeleteOrder(param.Id, companyId)
|
|
|
if err != nil {
|
|
|
c.ResponseError(err)
|
|
|
return
|
|
|
}
|
|
|
c.ResponseData(nil)
|
|
|
}
|
|
|
// func (c *OrderInfoController) RemoveOrderPurpose() {
|
|
|
// type Parameter struct {
|
|
|
// Id int64 `json:"id"`
|
|
|
// }
|
|
|
// var (
|
|
|
// param Parameter
|
|
|
// err error
|
|
|
// )
|
|
|
// if err = c.BindJsonData(¶m); err != nil {
|
|
|
// logs.Error(err)
|
|
|
// c.ResponseError(errors.New("json数据解析失败"))
|
|
|
// return
|
|
|
// }
|
|
|
// companyId := c.GetUserCompany()
|
|
|
// orderSrv := orderService.NewOrderInfoService(nil)
|
|
|
// err = orderSrv.DeleteOrder(param.Id, companyId)
|
|
|
// if err != nil {
|
|
|
// c.ResponseError(err)
|
|
|
// return
|
|
|
// }
|
|
|
// c.ResponseData(nil)
|
|
|
// }
|
|
|
|
|
|
//postPurposeOrderDetail 请求添加/更新的订单数据
|
|
|
type postPurposeOrderDetail struct {
|
...
|
...
|
@@ -252,92 +252,92 @@ func (postData *postOrderGood) Valid() error { |
|
|
return nil
|
|
|
}
|
|
|
|
|
|
//UpdateOrderPurpose 更新意向订单
|
|
|
func (c *OrderInfoController) UpdateOrderPurpose() {
|
|
|
//用与适配前端定义的数据结构
|
|
|
var (
|
|
|
param postPurposeOrderDetail
|
|
|
err error
|
|
|
)
|
|
|
if err = c.BindJsonData(¶m); err != nil {
|
|
|
logs.Error(err)
|
|
|
c.ResponseError(errors.New("json数据解析失败"))
|
|
|
return
|
|
|
}
|
|
|
|
|
|
if err := param.Valid(); err != nil {
|
|
|
c.ResponseError(err)
|
|
|
return
|
|
|
}
|
|
|
if param.Id == 0 {
|
|
|
err = c.addOrderPurpose(param)
|
|
|
} else {
|
|
|
err = c.editOrderPurpose(param)
|
|
|
}
|
|
|
if err != nil {
|
|
|
c.ResponseError(err)
|
|
|
}
|
|
|
c.ResponseData(nil)
|
|
|
return
|
|
|
}
|
|
|
|
|
|
func (c *OrderInfoController) addOrderPurpose(param postPurposeOrderDetail) error {
|
|
|
|
|
|
newGoods := []orderCmd.OrderGoodData{}
|
|
|
for _, v := range param.Product {
|
|
|
g := orderCmd.OrderGoodData{
|
|
|
GoodName: v.ProductName,
|
|
|
PlanGoodNumber: v.OrderNum,
|
|
|
Price: v.Univalence,
|
|
|
PartnerBonusPercent: v.PartnerRatio,
|
|
|
}
|
|
|
newGoods = append(newGoods, g)
|
|
|
}
|
|
|
companyId := c.GetUserCompany()
|
|
|
createcmd := orderCmd.CreateOrderCommand{
|
|
|
OrderType: domain.OrderIntention,
|
|
|
OrderCode: param.OrderId,
|
|
|
DeliveryCode: "",
|
|
|
BuyerName: param.BuyerName,
|
|
|
OrderRegion: param.OrderDist,
|
|
|
PartnerId: param.PartnerId,
|
|
|
SalesmanBonusPercent: param.CommissionProportion,
|
|
|
Goods: newGoods,
|
|
|
CompanyId: companyId,
|
|
|
}
|
|
|
orderSrv := orderService.NewOrderInfoService(nil)
|
|
|
_, err := orderSrv.CreateNewOrder(createcmd)
|
|
|
return err
|
|
|
}
|
|
|
|
|
|
func (c *OrderInfoController) editOrderPurpose(param postPurposeOrderDetail) error {
|
|
|
orderSrv := orderService.NewOrderInfoService(nil)
|
|
|
newGoods := []orderCmd.OrderGoodData{}
|
|
|
for _, v := range param.Product {
|
|
|
g := orderCmd.OrderGoodData{
|
|
|
GoodName: v.ProductName,
|
|
|
PlanGoodNumber: v.OrderNum,
|
|
|
Price: v.Univalence,
|
|
|
PartnerBonusPercent: v.PartnerRatio,
|
|
|
}
|
|
|
newGoods = append(newGoods, g)
|
|
|
}
|
|
|
companyId := c.GetUserCompany()
|
|
|
updatecmd := orderCmd.UpdateOrderCommand{
|
|
|
Id: param.Id,
|
|
|
OrderType: domain.OrderIntention,
|
|
|
OrderCode: param.OrderId,
|
|
|
DeliveryCode: "",
|
|
|
BuyerName: param.BuyerName,
|
|
|
OrderRegion: param.OrderDist,
|
|
|
PartnerId: param.PartnerId,
|
|
|
SalesmanBonusPercent: param.CommissionProportion,
|
|
|
Goods: newGoods,
|
|
|
CompanyId: companyId,
|
|
|
}
|
|
|
_, err := orderSrv.UpdateOrderData(updatecmd)
|
|
|
return err
|
|
|
}
|
|
|
// //UpdateOrderPurpose 更新意向订单
|
|
|
// func (c *OrderInfoController) UpdateOrderPurpose() {
|
|
|
// //用与适配前端定义的数据结构
|
|
|
// var (
|
|
|
// param postPurposeOrderDetail
|
|
|
// err error
|
|
|
// )
|
|
|
// if err = c.BindJsonData(¶m); err != nil {
|
|
|
// logs.Error(err)
|
|
|
// c.ResponseError(errors.New("json数据解析失败"))
|
|
|
// return
|
|
|
// }
|
|
|
|
|
|
// if err := param.Valid(); err != nil {
|
|
|
// c.ResponseError(err)
|
|
|
// return
|
|
|
// }
|
|
|
// if param.Id == 0 {
|
|
|
// err = c.addOrderPurpose(param)
|
|
|
// } else {
|
|
|
// err = c.editOrderPurpose(param)
|
|
|
// }
|
|
|
// if err != nil {
|
|
|
// c.ResponseError(err)
|
|
|
// }
|
|
|
// c.ResponseData(nil)
|
|
|
// return
|
|
|
// }
|
|
|
|
|
|
// func (c *OrderInfoController) addOrderPurpose(param postPurposeOrderDetail) error {
|
|
|
|
|
|
// newGoods := []orderCmd.OrderGoodData{}
|
|
|
// for _, v := range param.Product {
|
|
|
// g := orderCmd.OrderGoodData{
|
|
|
// GoodName: v.ProductName,
|
|
|
// PlanGoodNumber: v.OrderNum,
|
|
|
// Price: v.Univalence,
|
|
|
// PartnerBonusPercent: v.PartnerRatio,
|
|
|
// }
|
|
|
// newGoods = append(newGoods, g)
|
|
|
// }
|
|
|
// companyId := c.GetUserCompany()
|
|
|
// createcmd := orderCmd.CreateOrderCommand{
|
|
|
// OrderType: domain.OrderIntention,
|
|
|
// OrderCode: param.OrderId,
|
|
|
// DeliveryCode: "",
|
|
|
// BuyerName: param.BuyerName,
|
|
|
// OrderRegion: param.OrderDist,
|
|
|
// PartnerId: param.PartnerId,
|
|
|
// SalesmanBonusPercent: param.CommissionProportion,
|
|
|
// Goods: newGoods,
|
|
|
// CompanyId: companyId,
|
|
|
// }
|
|
|
// orderSrv := orderService.NewOrderInfoService(nil)
|
|
|
// _, err := orderSrv.CreateNewOrder(createcmd)
|
|
|
// return err
|
|
|
// }
|
|
|
|
|
|
// func (c *OrderInfoController) editOrderPurpose(param postPurposeOrderDetail) error {
|
|
|
// orderSrv := orderService.NewOrderInfoService(nil)
|
|
|
// newGoods := []orderCmd.OrderGoodData{}
|
|
|
// for _, v := range param.Product {
|
|
|
// g := orderCmd.OrderGoodData{
|
|
|
// GoodName: v.ProductName,
|
|
|
// PlanGoodNumber: v.OrderNum,
|
|
|
// Price: v.Univalence,
|
|
|
// PartnerBonusPercent: v.PartnerRatio,
|
|
|
// }
|
|
|
// newGoods = append(newGoods, g)
|
|
|
// }
|
|
|
// companyId := c.GetUserCompany()
|
|
|
// updatecmd := orderCmd.UpdateOrderCommand{
|
|
|
// Id: param.Id,
|
|
|
// OrderType: domain.OrderIntention,
|
|
|
// OrderCode: param.OrderId,
|
|
|
// DeliveryCode: "",
|
|
|
// BuyerName: param.BuyerName,
|
|
|
// OrderRegion: param.OrderDist,
|
|
|
// PartnerId: param.PartnerId,
|
|
|
// SalesmanBonusPercent: param.CommissionProportion,
|
|
|
// Goods: newGoods,
|
|
|
// CompanyId: companyId,
|
|
|
// }
|
|
|
// _, err := orderSrv.UpdateOrderData(updatecmd)
|
|
|
// return err
|
|
|
// }
|
|
|
|
|
|
type postOrderPurposeDelivery struct {
|
|
|
ShipmentsId string `json:"shipmentsId"` //发货单号
|
...
|
...
|
@@ -364,57 +364,58 @@ func (postData *postOrderPurposeDelivery) Valid() error { |
|
|
}
|
|
|
|
|
|
//OrderPurposeDelivery 发货 意向订单转实发单
|
|
|
func (c *OrderInfoController) OrderPurposeDelivery() {
|
|
|
//用与适配前端定义的数据结构
|
|
|
|
|
|
var (
|
|
|
param postOrderPurposeDelivery
|
|
|
err error
|
|
|
)
|
|
|
if err = c.BindJsonData(¶m); err != nil {
|
|
|
logs.Error(err)
|
|
|
c.ResponseError(errors.New("json数据解析失败"))
|
|
|
return
|
|
|
}
|
|
|
param.ShipmentsId = strings.TrimSpace(param.ShipmentsId)
|
|
|
orderid, _ := strconv.ParseInt(param.Id, 10, 64)
|
|
|
if orderid <= 0 {
|
|
|
c.ResponseError(errors.New("参数错误"))
|
|
|
return
|
|
|
}
|
|
|
if err = param.Valid(); err != nil {
|
|
|
c.ResponseError(err)
|
|
|
return
|
|
|
}
|
|
|
goods := []orderCmd.OrderGoodData{}
|
|
|
for _, v := range param.ProductDetail {
|
|
|
g := orderCmd.OrderGoodData{
|
|
|
Id: v.Id, GoodName: v.ProductName, PlanGoodNumber: v.OrderNum,
|
|
|
Price: v.Univalence, PartnerBonusPercent: v.PartnerRatio,
|
|
|
}
|
|
|
goods = append(goods, g)
|
|
|
}
|
|
|
companyId := c.GetUserCompany()
|
|
|
deliveryCommand := orderCmd.OrderDeliveryCommand{
|
|
|
OrderId: orderid, DeliveryCode: param.ShipmentsId,
|
|
|
DeliveryTime: time.Now(), Goods: goods, CompanyId: companyId,
|
|
|
}
|
|
|
orderSrv := orderService.NewOrderInfoService(nil)
|
|
|
err = orderSrv.Delivery(deliveryCommand)
|
|
|
if err != nil {
|
|
|
c.ResponseError(err)
|
|
|
}
|
|
|
c.ResponseData(nil)
|
|
|
return
|
|
|
}
|
|
|
// func (c *OrderInfoController) OrderPurposeDelivery() {
|
|
|
// //用与适配前端定义的数据结构
|
|
|
|
|
|
// var (
|
|
|
// param postOrderPurposeDelivery
|
|
|
// err error
|
|
|
// )
|
|
|
// if err = c.BindJsonData(¶m); err != nil {
|
|
|
// logs.Error(err)
|
|
|
// c.ResponseError(errors.New("json数据解析失败"))
|
|
|
// return
|
|
|
// }
|
|
|
// param.ShipmentsId = strings.TrimSpace(param.ShipmentsId)
|
|
|
// orderid, _ := strconv.ParseInt(param.Id, 10, 64)
|
|
|
// if orderid <= 0 {
|
|
|
// c.ResponseError(errors.New("参数错误"))
|
|
|
// return
|
|
|
// }
|
|
|
// if err = param.Valid(); err != nil {
|
|
|
// c.ResponseError(err)
|
|
|
// return
|
|
|
// }
|
|
|
// goods := []orderCmd.OrderGoodData{}
|
|
|
// for _, v := range param.ProductDetail {
|
|
|
// g := orderCmd.OrderGoodData{
|
|
|
// Id: v.Id, GoodName: v.ProductName, PlanGoodNumber: v.OrderNum,
|
|
|
// Price: v.Univalence, PartnerBonusPercent: v.PartnerRatio,
|
|
|
// }
|
|
|
// goods = append(goods, g)
|
|
|
// }
|
|
|
// companyId := c.GetUserCompany()
|
|
|
// deliveryCommand := orderCmd.OrderDeliveryCommand{
|
|
|
// OrderId: orderid, DeliveryCode: param.ShipmentsId,
|
|
|
// DeliveryTime: time.Now(), Goods: goods, CompanyId: companyId,
|
|
|
// }
|
|
|
// orderSrv := orderService.NewOrderInfoService(nil)
|
|
|
// err = orderSrv.Delivery(deliveryCommand)
|
|
|
// if err != nil {
|
|
|
// c.ResponseError(err)
|
|
|
// }
|
|
|
// c.ResponseData(nil)
|
|
|
// return
|
|
|
// }
|
|
|
|
|
|
//PageListOrderReal 获取实发订单列表
|
|
|
func (c *OrderInfoController) PageListOrderReal() {
|
|
|
type Parameter struct {
|
|
|
SearchText string `json:"searchText"`
|
|
|
Partner int64 `json:"partner"`
|
|
|
PartnerCategory int `json:"PartnerCategory"`
|
|
|
PageSize int `json:"pageSize"`
|
|
|
PageNumber int `json:"pageNumber"`
|
|
|
UpdateTime []string `json:"updateTime"`
|
|
|
}
|
|
|
var (
|
|
|
param Parameter
|
...
|
...
|
@@ -431,47 +432,49 @@ func (c *OrderInfoController) PageListOrderReal() { |
|
|
if param.PageSize == 0 {
|
|
|
param.PageSize = 20
|
|
|
}
|
|
|
var (
|
|
|
updateTimeBegin string
|
|
|
updateTimeEnd string
|
|
|
)
|
|
|
if len(param.UpdateTime) > 0 {
|
|
|
if len(param.UpdateTime[0]) > 0 {
|
|
|
t, err := time.ParseInLocation("2006-01-02", param.UpdateTime[0], time.Local)
|
|
|
if err != nil {
|
|
|
c.ResponseError(errors.New("UpdateTimeBegin 时间格式错误"))
|
|
|
return
|
|
|
}
|
|
|
updateTimeBegin = t.Format("2006-01-02 15:04:05-07")
|
|
|
}
|
|
|
}
|
|
|
if len(param.UpdateTime) > 1 {
|
|
|
if len(param.UpdateTime[1]) > 0 {
|
|
|
t, err := time.ParseInLocation("2006-01-02", param.UpdateTime[1], time.Local)
|
|
|
if err != nil {
|
|
|
c.ResponseError(errors.New("UpdateTimeEnd 时间格式错误"))
|
|
|
return
|
|
|
}
|
|
|
//设定时间边界
|
|
|
t = t.Add(86399 * time.Second)
|
|
|
updateTimeEnd = t.Format("2006-01-02 15:04:05-07")
|
|
|
}
|
|
|
}
|
|
|
companyId := c.GetUserCompany()
|
|
|
orderSrv := orderService.NewOrderInfoService(nil)
|
|
|
orderinfos, cnt, err := orderSrv.PageListOrderBase(orderQuery.ListOrderBaseQuery{
|
|
|
PartnerId: param.Partner,
|
|
|
DeliveryCode: param.SearchText,
|
|
|
PartnerOrCode: param.SearchText,
|
|
|
OrderType: domain.OrderReal,
|
|
|
Limit: param.PageSize,
|
|
|
Offset: (param.PageNumber - 1) * param.PageSize,
|
|
|
CompanyId: companyId,
|
|
|
PartnerCategory: param.PartnerCategory,
|
|
|
UpdateTimeBegin: updateTimeBegin,
|
|
|
UpdateTimeEnd: updateTimeEnd,
|
|
|
})
|
|
|
if err != nil {
|
|
|
c.ResponseError(err)
|
|
|
return
|
|
|
}
|
|
|
rsp := []map[string]interface{}{}
|
|
|
for i := range orderinfos {
|
|
|
orderinfo := orderinfos[i]
|
|
|
m := map[string]interface{}{
|
|
|
"createTime": orderinfo.CreateTime.Local().Format("2006-01-02 15:04:05"),
|
|
|
"updateTime": orderinfo.UpdateTime.Local().Format("2006-01-02 15:04:05"),
|
|
|
"buyer": orderinfo.Buyer.BuyerName,
|
|
|
"id": orderinfo.Id,
|
|
|
"orderId": orderinfo.OrderCode,
|
|
|
"shipmentsId": orderinfo.DeliveryCode,
|
|
|
"partner": orderinfo.PartnerInfo.PartnerName,
|
|
|
"orderNum": orderinfo.OrderCompute.PlanOrderCount,
|
|
|
"orderPrice": orderinfo.OrderCompute.PlanOrderAmount,
|
|
|
"orderDist": orderinfo.RegionInfo.RegionName,
|
|
|
"quantityControl": "",
|
|
|
"priceControl": "",
|
|
|
"status": orderinfo.IsDisable,
|
|
|
}
|
|
|
if orderinfo.OrderCompute.UseOrderCount >= 0 {
|
|
|
m["quantityControl"] = fmt.Sprint(orderinfo.OrderCompute.UseOrderCount)
|
|
|
}
|
|
|
if orderinfo.OrderCompute.UseOrderAmount >= 0 {
|
|
|
m["priceControl"] = fmt.Sprint(orderinfo.OrderCompute.UseOrderAmount)
|
|
|
}
|
|
|
rsp = append(rsp, m)
|
|
|
}
|
|
|
c.ResponsePageList(rsp, cnt, param.PageNumber)
|
|
|
c.ResponsePageList(orderinfos, cnt, param.PageNumber)
|
|
|
return
|
|
|
}
|
|
|
|
...
|
...
|
@@ -544,6 +547,8 @@ func (c *OrderInfoController) GetOrderReal() { |
|
|
"product": allGoods,
|
|
|
"create_time": orderinfo.CreateTime.Local().Format("2006-01-02 15:04:06"),
|
|
|
"update_time": orderinfo.UpdateTime.Local().Format("2006-01-02 15:04:06"),
|
|
|
"partnerCategoryId": orderinfo.PartnerCategory.Id,
|
|
|
"partnerCategoryName": orderinfo.PartnerCategory.Name,
|
|
|
}
|
|
|
if orderinfo.OrderCompute.UseOrderAmount >= 0 {
|
|
|
rsp["orderNumCountControl"] = fmt.Sprint(orderinfo.OrderCompute.UseOrderCount)
|
...
|
...
|
@@ -558,6 +563,7 @@ func (c *OrderInfoController) GetOrderReal() { |
|
|
//实际订单
|
|
|
type postRealOrderDetail struct {
|
|
|
postPurposeOrderDetail
|
|
|
PartnerCategoryId int64 `json:"partnerCategoryId"`
|
|
|
ShipmentsId string `json:"shipmentsId"` //发货单号
|
|
|
}
|
|
|
|
...
|
...
|
@@ -623,6 +629,7 @@ func (c *OrderInfoController) addOrderReal(param postRealOrderDetail) error { |
|
|
SalesmanBonusPercent: param.CommissionProportion,
|
|
|
Goods: newGoods,
|
|
|
CompanyId: companyId,
|
|
|
PartnerCategory: param.PartnerCategoryId,
|
|
|
}
|
|
|
_, err := orderSrv.CreateNewOrder(createcmd)
|
|
|
return err
|
...
|
...
|
@@ -652,6 +659,7 @@ func (c *OrderInfoController) editOrderReal(param postRealOrderDetail) error { |
|
|
SalesmanBonusPercent: param.CommissionProportion,
|
|
|
Goods: newGoods,
|
|
|
CompanyId: companyId,
|
|
|
PartnerCategory: param.PartnerCategoryId,
|
|
|
}
|
|
|
orderSrv := orderService.NewOrderInfoService(nil)
|
|
|
_, err := orderSrv.UpdateOrderData(updatecmd)
|
...
|
...
|
|