作者 tangxvhui

Merge branch 'test'

# Config file for [Air](https://github.com/cosmtrek/air) in TOML format
# Working directory
# . or absolute path, please note that the directories following must be under root.
root = "."
tmp_dir = "tmp"
[build]
# Just plain old shell command. You could use `make` as well.
cmd = "go build -o ./tmp/main ."
# Binary file yields from `cmd`.
bin = "tmp/main"
# Customize binary.
full_bin = "APP_ENV=dev APP_USER=air ./tmp/main"
# Watch these filename extensions.
include_ext = ["go", "tpl", "tmpl", "html"]
# Ignore these filename extensions or directories.
exclude_dir = ["assets", "tmp", "vendor", "frontend/node_modules"]
# Watch these directories if you specified.
include_dir = []
# Exclude files.
exclude_file = []
# Exclude unchanged files.
exclude_unchanged = true
# This log file places in your tmp_dir.
log = "air.log"
# It's not necessary to trigger build each time file changes if it's too frequent.
delay = 1000 # ms
# Stop running old binary when build errors occur.
stop_on_error = true
# Send Interrupt signal before killing process (windows does not support this feature)
send_interrupt = false
# Delay after sending Interrupt signal
kill_delay = 500 # ms
[log]
# Show log time
time = false
[color]
# Customize each part's color. If no color found, use the raw app log.
main = "magenta"
watcher = "cyan"
build = "yellow"
runner = "green"
[misc]
# Delete tmp directory on exit
clean_on_exit = true
\ No newline at end of file
... ... @@ -2,10 +2,11 @@ package service
import (
"fmt"
"github.com/linmadan/egglib-go/core/application"
"strconv"
"time"
"github.com/linmadan/egglib-go/core/application"
"github.com/astaxie/beego/logs"
"gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/application/event/subscriber"
... ... @@ -20,7 +21,7 @@ import (
"gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/lib"
)
//OrderService 自建订单,意向单,实发订单
// OrderService 自建订单,意向单,实发订单
type OrderInfoService struct {
}
... ... @@ -125,7 +126,7 @@ func (service OrderInfoService) PageListOrderBase(listOrderQuery query.ListOrder
return orderDataReturn, cnt, nil
}
//GetOrderDetail 获取订单详情
// GetOrderDetail 获取订单详情
func (service OrderInfoService) GetOrderDetail(getOrderQuery query.GetOrderQuery) (*domain.OrderBase, error) {
//实际业务
transactionContext, err := factory.CreateTransactionContext(nil)
... ... @@ -352,7 +353,7 @@ func (service OrderInfoService) CreateNewOrder(cmd command.CreateOrderCommand) (
return newOrder, nil
}
//DeleteOrder 删除订单
// DeleteOrder 删除订单
func (service OrderInfoService) DeleteOrder(orderId int64, companyId int64) error {
var (
transactionContext, _ = factory.CreateTransactionContext(nil)
... ... @@ -393,7 +394,7 @@ func (service OrderInfoService) DeleteOrder(orderId int64, companyId int64) erro
return nil
}
//UpdateOrderData 编辑订单
// UpdateOrderData 编辑订单
func (service OrderInfoService) UpdateOrderData(cmd command.UpdateOrderCommand) (*domain.OrderBase, error) {
var (
transactionContext, _ = factory.CreateTransactionContext(nil)
... ... @@ -581,7 +582,7 @@ func (service OrderInfoService) UpdateOrderData(cmd command.UpdateOrderCommand)
return oldOrderData, nil
}
//deleteOldOrderGoods 新旧商品列表对比
// deleteOldOrderGoods 新旧商品列表对比
func (service OrderInfoService) deleteOldOrderGoods(newGoods []domain.OrderGood, oldGoods []domain.OrderGood) (goodIds []int64) {
for _, old := range oldGoods {
var hasIn bool
... ... @@ -598,7 +599,7 @@ func (service OrderInfoService) deleteOldOrderGoods(newGoods []domain.OrderGood,
return
}
//DisableOrEnable 开启关闭订单
// DisableOrEnable 开启关闭订单
func (service OrderInfoService) DisableOrEnable(cmd command.DisableOrderCommand) error {
var (
transactionContext, _ = factory.CreateTransactionContext(nil)
... ... @@ -642,7 +643,7 @@ func (service OrderInfoService) DisableOrEnable(cmd command.DisableOrderCommand)
return nil
}
//PageListOrderBouns 获取订单的分红列表
// PageListOrderBouns 获取订单的分红列表
func (service OrderInfoService) PageListOrderBonus(listOrderQuery query.ListOrderBonusQuery) ([]map[string]interface{}, int, error) {
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
... ... @@ -692,6 +693,7 @@ func (service OrderInfoService) PageListOrderBonus(listOrderQuery query.ListOrde
PartnerInfo: domain.Partner{
Id: orderModel.PartnerId,
},
SaleDate: orderModel.SaleDate,
BonusStatus: orderModel.BonusStatus,
CompanyId: orderModel.CompanyId,
}
... ... @@ -726,10 +728,11 @@ func (service OrderInfoService) PageListOrderBonus(listOrderQuery query.ListOrde
goods []domain.OrderGood
hasBonusPercent bool
)
goods, _, err = orderGoodRepository.Find(domain.OrderGoodFindQuery{OrderId: orders[i].Id})
goods, _, _ = orderGoodRepository.Find(domain.OrderGoodFindQuery{OrderId: orders[i].Id})
for ii := range goods {
if goods[ii].PartnerBonusPercent >= 0 {
hasBonusPercent = true
break
}
}
listIndex := listOrderQuery.Offset + (1 + i)
... ... @@ -738,6 +741,7 @@ func (service OrderInfoService) PageListOrderBonus(listOrderQuery query.ListOrde
"createTime": orders[i].CreateTime.Local().Format("2006-01-02 15:04:05"),
"updateTime": orders[i].UpdateTime.Local().Format("2006-01-02 15:04:05"),
"id": fmt.Sprint(orders[i].Id),
"saleDate": orders[i].SaleDate.Local().Format("2006-01-02"),
"shipmentsId": orders[i].DeliveryCode,
"partner": orders[i].PartnerInfo.PartnerName,
"dividendsReceivable": fmt.Sprint(orders[i].GetCurrentPartnerBonus()),
... ... @@ -764,7 +768,7 @@ func (service OrderInfoService) PageListOrderBonus(listOrderQuery query.ListOrde
return resp, cnt, nil
}
//PayPartnerBonusWithOrderBestshop 支付分红
// PayPartnerBonusWithOrderBestshop 支付分红
func (service OrderInfoService) PayPartnerBonus(orderId int64, goodId int64, adminId int64) error {
var (
transactionContext, _ = factory.CreateTransactionContext(nil)
... ... @@ -799,7 +803,7 @@ func (service OrderInfoService) PayPartnerBonus(orderId int64, goodId int64, adm
return nil
}
//UpdateOrderRemarkBonus 订单分红详情,更新备注
// UpdateOrderRemarkBonus 订单分红详情,更新备注
func (service OrderInfoService) UpdateOrderRemarkBonus(orderId int64, adminId int64, remark string) error {
var (
transactionContext, _ = factory.CreateTransactionContext(nil)
... ... @@ -878,6 +882,7 @@ func (service OrderInfoService) ListOrderBonusForExcel(listOrderQuery query.List
"delivery_code": result[i].DeliveryCode,
"partner_name": result[i].PartnerName,
"bonus_status": "",
"sale_date": result[i].SaleDate,
"update_time": result[i].UpdateTime,
"create_time": result[i].CreateTime,
"partner_bonus": fmt.Sprintf("%10.2f", result[i].PartnerBonus),
... ... @@ -910,6 +915,7 @@ func (service OrderInfoService) ListOrderBonusForExcel(listOrderQuery query.List
[2]string{"partner_name", "合伙人"},
[2]string{"bonus_status", "支付状态"},
[2]string{"create_time", "创建时间"},
[2]string{"sale_date", "销售时间"},
[2]string{"partner_bonus", "应收分红"},
[2]string{"partner_bonus_has", "已收分红"},
[2]string{"partner_bonus_not", "未收分红"},
... ...
... ... @@ -23,12 +23,12 @@ func NewOrderBaseDao(transactionContext *transaction.TransactionContext) (*Order
}
}
//CheckOrderUnique 检查订单的是否已存在
//@companyId 公司id
//@orderCode 订单号
//@deliveryCode 发货单号
//@partnerCategoryCode 合伙人类型编号
//@goodNames 货品名称列表
// CheckOrderUnique 检查订单的是否已存在
// @companyId 公司id
// @orderCode 订单号
// @deliveryCode 发货单号
// @partnerCategoryCode 合伙人类型编号
// @goodNames 货品名称列表
func (dao OrderBaseDao) CheckOrderExist(companyId int64, orderCode string,
deliveryCode string, partnerCategory int64, partnerId int64, notId int64, goodNames []string) (bool, error) {
tx := dao.transactionContext.GetDB()
... ... @@ -45,12 +45,12 @@ func (dao OrderBaseDao) CheckOrderExist(companyId int64, orderCode string,
return ok, err
}
//OrderBonusListByCondition 根据条件获取订单分红列表
//@param orderType 订单类型
//@param partnerOrCode 合伙人姓名或订单号或发货单号
//@param companyId 公司id
//@param partnerCategory 合伙人类型
//@param createTime 创建时间
// OrderBonusListByCondition 根据条件获取订单分红列表
// @param orderType 订单类型
// @param partnerOrCode 合伙人姓名或订单号或发货单号
// @param companyId 公司id
// @param partnerCategory 合伙人类型
// @param createTime 创建时间
func (dao OrderBaseDao) OrderBonusListByCondition(companyId int64, orderType int, partnerOrCode string,
partnerCategory int, createTime [2]string, limit, offset int) ([]models.OrderBase, int, error) {
tx := dao.transactionContext.GetDB()
... ... @@ -90,7 +90,7 @@ func (dao OrderBaseDao) OrderBonusListByCondition(companyId int64, orderType int
return orders, cnt, err
}
//CustomOrderBonusForExcel 导出分红列表所用的结构
// CustomOrderBonusForExcel 导出分红列表所用的结构
type CustomOrderBonusForExcel struct {
OrderId int64
OrderType int
... ... @@ -99,6 +99,7 @@ type CustomOrderBonusForExcel struct {
DeliveryCode string
UpdateTime string
CreateTime string
SaleDate string
PartnerBonus float64
PartnerBonusHas float64
PartnerBonusNot float64
... ... @@ -107,13 +108,13 @@ type CustomOrderBonusForExcel struct {
PartnerName string
}
//OrderBonusListForExcel 导出分红列表所用
//@param companyId 公司id
//@param orderType 订单类型
//@param partnerOrCode 合伙人姓名或订单号或发货单号
//@param partnerCategory 合伙人类型id
//@param createTime 订单的创建时间范围"[开始时间,结束时间]" 时间格式"2006-01-02 15:04:05+07"
//@return result 查询结果数据
// OrderBonusListForExcel 导出分红列表所用
// @param companyId 公司id
// @param orderType 订单类型
// @param partnerOrCode 合伙人姓名或订单号或发货单号
// @param partnerCategory 合伙人类型id
// @param createTime 订单的创建时间范围"[开始时间,结束时间]" 时间格式"2006-01-02 15:04:05+07"
// @return result 查询结果数据
func (dao OrderBaseDao) OrderBonusListForExcel(companyId int64, orderType int, partnerOrCode string,
partnerCategory int, createTime [2]string) (result []CustomOrderBonusForExcel, err error) {
//导出分红列表所用的sql
... ... @@ -123,8 +124,9 @@ func (dao OrderBaseDao) OrderBonusListForExcel(companyId int64, orderType int, p
t1.order_code,
t1.delivery_code,
t1.bonus_status,
to_char(t1.update_time AT TIME ZONE 'CCT' ,'YYYY-MM-DD HH24:MI:SS') AS update_time,
to_char(t1.create_time AT TIME ZONE 'CCT' ,'YYYY-MM-DD HH24:MI:SS') AS create_time,
to_char(t1.update_time AT TIME ZONE 'PRC' ,'YYYY-MM-DD HH24:MI:SS') AS update_time,
to_char(t1.create_time AT TIME ZONE 'PRC' ,'YYYY-MM-DD HH24:MI:SS') AS create_time,
to_char(t1.sale_date AT TIME ZONE 'PRC' ,'YYYY-MM-DD') AS sale_date,
(CASE
WHEN t1.use_partner_bonus>0
THEN
... ... @@ -183,13 +185,13 @@ func (dao OrderBaseDao) OrderBonusListForExcel(companyId int64, orderType int, p
return result, nil
}
//OrderListByCondition 获取实际订单列表
//@param companyId 公司id
//@param orderType 订单类型
//@param partnerOrCode 合伙人姓名或订单号或发货单号
//@param partnerCategory 合伙人类型id
//@param updateTime 订单更新时间范围"[开始时间,结束时间]",时间格式"2006-01-02 15:04:05+07"
//@param createTime 订单的创建时间范围"[开始时间,结束时间]" 时间格式"2006-01-02 15:04:05+07"
// OrderListByCondition 获取实际订单列表
// @param companyId 公司id
// @param orderType 订单类型
// @param partnerOrCode 合伙人姓名或订单号或发货单号
// @param partnerCategory 合伙人类型id
// @param updateTime 订单更新时间范围"[开始时间,结束时间]",时间格式"2006-01-02 15:04:05+07"
// @param createTime 订单的创建时间范围"[开始时间,结束时间]" 时间格式"2006-01-02 15:04:05+07"
func (dao OrderBaseDao) OrderListByCondition(companyId int64, orderType int, partnerName string, orderCode string, deliveryCode string,
updateTime [2]string, createTime [2]string, saleDate [2]string, partnerCategory int, partnerCategoryName string, limit, offset int) ([]models.OrderBase, int, error) {
tx := dao.transactionContext.GetDB()
... ... @@ -252,7 +254,7 @@ func (dao OrderBaseDao) OrderListByCondition(companyId int64, orderType int, par
}
//CustomOrderListForExcel 导出实际订单列表所用的结构
// CustomOrderListForExcel 导出实际订单列表所用的结构
type CustomOrderListForExcel struct {
OrderCode string //订单编号
DeliveryCode string //发货编号
... ...
... ... @@ -72,13 +72,24 @@ func (controller BaseController) ResponsePageList(data interface{}, totalRow int
if data == nil {
data = []interface{}{}
}
// controller.Data["json"] = protocol.ResponseData{
// Code: 0,
// Msg: "ok",
// Data: map[string]map[string]interface{}{
// "gridResult": map[string]interface{}{
// "lists": data,
// "totalRow": totalRow,
// "pageNumber": pageNumber,
// },
// },
// }
controller.Data["json"] = protocol.ResponseData{
Code: 0,
Msg: "ok",
Data: map[string]map[string]interface{}{
"gridResult": map[string]interface{}{
"lists": data,
"totalRow": totalRow,
"grid": {
"list": data,
"total": totalRow,
"pageNumber": pageNumber,
},
},
... ... @@ -86,7 +97,7 @@ func (controller BaseController) ResponsePageList(data interface{}, totalRow int
controller.ServeJSON()
}
//Finish 重写 beego.Controller 的Finish 方法
// Finish 重写 beego.Controller 的Finish 方法
func (controller *BaseController) Finish() {
strByte, _ := json.Marshal(controller.Data["json"])
length := len(strByte)
... ... @@ -97,7 +108,7 @@ func (controller *BaseController) Finish() {
}
}
////Prepare 重写 beego.Controller 的Prepare方法
// //Prepare 重写 beego.Controller 的Prepare方法
func (controller *BaseController) Prepare() {
logs.Info("====>Recv Request:", controller.Ctx.Input.URI())
if controller.Ctx.Input.IsPost() || controller.Ctx.Input.IsPut() {
... ...