...
|
...
|
@@ -160,15 +160,16 @@ func (postData *postOrderPurposeDelivery) Valid() error { |
|
|
**/
|
|
|
func (c *OrderInfoController) PageListOrderReal() {
|
|
|
type Parameter struct {
|
|
|
//SearchText string `json:"searchText"`
|
|
|
PartnerName string `json:"partnerName"` // 合伙人姓名
|
|
|
OrderCode string `json:"orderCode"` // 订单号
|
|
|
DeliveryCode string `json:"deliveryCode"` // 发货单号
|
|
|
PartnerCategory int `json:"PartnerCategory"`
|
|
|
PartnerCategory int `json:"partnerCategory"` // 合伙人类型id
|
|
|
PartnerCategoryName string `json:"partnerCategoryName"` // 合伙人类型名称
|
|
|
PageSize int `json:"pageSize"`
|
|
|
PageNumber int `json:"pageNumber"`
|
|
|
UpdateTime []string `json:"updateTime"`
|
|
|
CreateTime []string `json:"createTime"`
|
|
|
UpdateTime []string `json:"updateTime"` // 订单更新时间
|
|
|
CreateTime []string `json:"createTime"` // 订单创建时间
|
|
|
SaleDate []string `json:"saleDate"` // 销售时间
|
|
|
}
|
|
|
var (
|
|
|
param Parameter
|
...
|
...
|
@@ -185,6 +186,7 @@ func (c *OrderInfoController) PageListOrderReal() { |
|
|
if param.PageSize == 0 {
|
|
|
param.PageSize = 20
|
|
|
}
|
|
|
// 订单更新时间处理
|
|
|
var (
|
|
|
updateTimeBegin string
|
|
|
updateTimeEnd string
|
...
|
...
|
@@ -211,6 +213,7 @@ func (c *OrderInfoController) PageListOrderReal() { |
|
|
updateTimeEnd = t.Format("2006-01-02 15:04:05-07")
|
|
|
}
|
|
|
}
|
|
|
// 订单创建时间处理
|
|
|
var (
|
|
|
createTimeBegin string
|
|
|
createTimeEnd string
|
...
|
...
|
@@ -237,11 +240,36 @@ func (c *OrderInfoController) PageListOrderReal() { |
|
|
createTimeEnd = t.Format("2006-01-02 15:04:05-07")
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 订单销售时间处理
|
|
|
var (
|
|
|
saleDateBegin string
|
|
|
saleDateEnd string
|
|
|
)
|
|
|
if len(param.SaleDate) > 0 {
|
|
|
if len(param.SaleDate[0]) > 0 {
|
|
|
t, err := time.ParseInLocation("2006-01-02", param.SaleDate[0], time.Local)
|
|
|
if err != nil {
|
|
|
c.ResponseError(errors.New("销售开始时间格式错误"))
|
|
|
return
|
|
|
}
|
|
|
saleDateBegin = t.Format("2006-01-02 15:04:05-07")
|
|
|
}
|
|
|
}
|
|
|
if len(param.SaleDate) > 1 {
|
|
|
if len(param.SaleDate[1]) > 0 {
|
|
|
t, err := time.ParseInLocation("2006-01-02", param.SaleDate[1], time.Local)
|
|
|
if err != nil {
|
|
|
c.ResponseError(errors.New("销售结束时间格式错误"))
|
|
|
return
|
|
|
}
|
|
|
//设定时间边界
|
|
|
t = t.Add(86399 * time.Second)
|
|
|
saleDateEnd = t.Format("2006-01-02 15:04:05-07")
|
|
|
}
|
|
|
}
|
|
|
companyId := c.GetUserCompany()
|
|
|
orderSrv := orderService.NewOrderInfoService(nil)
|
|
|
orderinfos, cnt, err := orderSrv.PageListOrderBase(orderQuery.ListOrderBaseQuery{
|
|
|
//PartnerOrCode: param.SearchText,
|
|
|
orderInfos, cnt, err := orderSrv.PageListOrderBase(orderQuery.ListOrderBaseQuery{
|
|
|
PartnerName: param.PartnerName,
|
|
|
OrderCode: param.OrderCode,
|
|
|
DeliveryCode: param.DeliveryCode,
|
...
|
...
|
@@ -250,16 +278,19 @@ func (c *OrderInfoController) PageListOrderReal() { |
|
|
Offset: (param.PageNumber - 1) * param.PageSize,
|
|
|
CompanyId: companyId,
|
|
|
PartnerCategory: param.PartnerCategory,
|
|
|
PartnerCategoryName: param.PartnerCategoryName,
|
|
|
UpdateTimeBegin: updateTimeBegin,
|
|
|
UpdateTimeEnd: updateTimeEnd,
|
|
|
CreateTimeBegin: createTimeBegin,
|
|
|
CreateTimeEnd: createTimeEnd,
|
|
|
SaleDateBegin: saleDateBegin,
|
|
|
SaleDateEnd: saleDateEnd,
|
|
|
})
|
|
|
if err != nil {
|
|
|
c.ResponseError(err)
|
|
|
return
|
|
|
}
|
|
|
c.ResponsePageList(orderinfos, cnt, param.PageNumber)
|
|
|
c.ResponsePageList(orderInfos, cnt, param.PageNumber)
|
|
|
return
|
|
|
}
|
|
|
|
...
|
...
|
@@ -299,7 +330,8 @@ func (c *OrderInfoController) GetOrderReal() { |
|
|
allGoods := []map[string]interface{}{}
|
|
|
for _, v := range orderinfo.Goods {
|
|
|
m := map[string]interface{}{
|
|
|
"id": fmt.Sprint(v.Id),
|
|
|
//"id": fmt.Sprint(v.Id),
|
|
|
"id": v.Id,
|
|
|
"productName": v.GoodName,
|
|
|
"orderNum": v.PlanGoodNumber,
|
|
|
"univalence": v.Price,
|
...
|
...
|
@@ -330,8 +362,9 @@ func (c *OrderInfoController) GetOrderReal() { |
|
|
"orderNumCountControl": "",
|
|
|
"orderAmountAdjustmentCountControl": "",
|
|
|
"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"),
|
|
|
"create_time": orderinfo.CreateTime.Local().Format("2006-01-02 15:04:05"),
|
|
|
"update_time": orderinfo.UpdateTime.Local().Format("2006-01-02 15:04:05"),
|
|
|
"saleDate": orderinfo.SaleDate.Local().Format("2006-01-02 15:04:05"),
|
|
|
"partnerCategoryId": orderinfo.PartnerCategory.Id,
|
|
|
"partnerCategoryName": orderinfo.PartnerCategory.Name,
|
|
|
}
|
...
|
...
|
@@ -350,6 +383,7 @@ type postRealOrderDetail struct { |
|
|
postPurposeOrderDetail
|
|
|
PartnerCategoryId int64 `json:"partnerCategoryId"`
|
|
|
ShipmentsId string `json:"shipmentsId"` //发货单号
|
|
|
SaleDate string `json:"saleDate"` // 销售日期
|
|
|
}
|
|
|
|
|
|
func (postData *postRealOrderDetail) Valid() error {
|
...
|
...
|
@@ -380,10 +414,18 @@ func (c *OrderInfoController) UpdateOrderReal() { |
|
|
return
|
|
|
}
|
|
|
var orderDataReturn *domain.OrderBase
|
|
|
saleDate, err := time.ParseInLocation("2006-01-02 15:04:05", param.SaleDate, time.Local)
|
|
|
saleDateWithTz := time.Date(saleDate.Year(), saleDate.Month(), saleDate.Day(), time.Now().Hour(), time.Now().Minute(), time.Now().Second(), time.Now().Nanosecond(), time.Local)
|
|
|
|
|
|
if err != nil {
|
|
|
e := lib.ThrowError(lib.ARG_ERROR, err.Error())
|
|
|
c.ResponseError(e)
|
|
|
return
|
|
|
}
|
|
|
if param.Id == 0 {
|
|
|
orderDataReturn, err = c.addOrderReal(param)
|
|
|
orderDataReturn, err = c.addOrderReal(param, saleDateWithTz)
|
|
|
} else {
|
|
|
err = c.editOrderReal(param)
|
|
|
err = c.editOrderReal(param, saleDateWithTz)
|
|
|
}
|
|
|
if err != nil {
|
|
|
c.ResponseError(err)
|
...
|
...
|
@@ -399,7 +441,7 @@ func (c *OrderInfoController) UpdateOrderReal() { |
|
|
return
|
|
|
}
|
|
|
|
|
|
func (c *OrderInfoController) addOrderReal(param postRealOrderDetail) (*domain.OrderBase, error) {
|
|
|
func (c *OrderInfoController) addOrderReal(param postRealOrderDetail, saleDate time.Time) (*domain.OrderBase, error) {
|
|
|
orderSrv := orderService.NewOrderInfoService(nil)
|
|
|
newGoods := []orderCmd.OrderGoodData{}
|
|
|
for _, v := range param.Product {
|
...
|
...
|
@@ -423,12 +465,13 @@ func (c *OrderInfoController) addOrderReal(param postRealOrderDetail) (*domain.O |
|
|
Goods: newGoods,
|
|
|
CompanyId: companyId,
|
|
|
PartnerCategory: param.PartnerCategoryId,
|
|
|
SaleDate: saleDate,
|
|
|
}
|
|
|
orderData, err := orderSrv.CreateNewOrder(createcmd)
|
|
|
return orderData, err
|
|
|
}
|
|
|
|
|
|
func (c *OrderInfoController) editOrderReal(param postRealOrderDetail) error {
|
|
|
func (c *OrderInfoController) editOrderReal(param postRealOrderDetail, saleDate time.Time) error {
|
|
|
|
|
|
newGoods := []orderCmd.OrderGoodData{}
|
|
|
for _, v := range param.Product {
|
...
|
...
|
@@ -453,6 +496,7 @@ func (c *OrderInfoController) editOrderReal(param postRealOrderDetail) error { |
|
|
Goods: newGoods,
|
|
|
CompanyId: companyId,
|
|
|
PartnerCategory: param.PartnerCategoryId,
|
|
|
SaleDate: saleDate,
|
|
|
}
|
|
|
orderSrv := orderService.NewOrderInfoService(nil)
|
|
|
_, err := orderSrv.UpdateOrderData(updatecmd)
|
...
|
...
|
@@ -527,17 +571,20 @@ func (c *OrderInfoController) RemoveOrderReal() { |
|
|
|
|
|
//ListOrderForExcel excel 导出实际订单的列表
|
|
|
func (c *OrderInfoController) ListOrderForExcel() {
|
|
|
type Parameter struct {
|
|
|
//SearchText string `json:"searchText"`
|
|
|
PartnerName string `json:"partnerName"` // 合伙人姓名
|
|
|
OrderCode string `json:"orderCode"` // 订单号
|
|
|
DeliveryCode string `json:"deliveryCode"` // 发货单号
|
|
|
PartnerCategory int `json:"PartnerCategory"`
|
|
|
UpdateTime []string `json:"updateTime"`
|
|
|
CreateTime []string `json:"createTime"`
|
|
|
}
|
|
|
//type Parameter struct {
|
|
|
// PartnerName string `json:"partnerName"` // 合伙人姓名
|
|
|
// OrderCode string `json:"orderCode"` // 订单号
|
|
|
// DeliveryCode string `json:"deliveryCode"` // 发货单号
|
|
|
// PartnerCategory int `json:"partnerCategory"` // 合伙人类型
|
|
|
// PartnerCategoryName string `json:"partnerCategoryName"` // 合伙人类型名称
|
|
|
// UpdateTime []string `json:"updateTime"` // 更新时间
|
|
|
// CreateTime []string `json:"createTime"` // 创建时间
|
|
|
// SaleDate []string `json:"saleDate"` // 销售日期
|
|
|
//}
|
|
|
|
|
|
var (
|
|
|
param Parameter
|
|
|
//param Parameter
|
|
|
param orderQuery.ListOrderForExcelQuery
|
|
|
err error
|
|
|
)
|
|
|
if err = c.BindJsonData(¶m); err != nil {
|
...
|
...
|
@@ -545,13 +592,19 @@ func (c *OrderInfoController) ListOrderForExcel() { |
|
|
c.ResponseError(errors.New("json数据解析失败"))
|
|
|
return
|
|
|
}
|
|
|
if param.Type != "ORDER_BASE" {
|
|
|
logs.Error(err)
|
|
|
c.ResponseError(errors.New("错误的操作类型"))
|
|
|
return
|
|
|
}
|
|
|
// 订单更新时间
|
|
|
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 len(param.Where.UpdateTime) > 0 {
|
|
|
if len(param.Where.UpdateTime[0]) > 0 {
|
|
|
t, err := time.ParseInLocation("2006-01-02", param.Where.UpdateTime[0], time.Local)
|
|
|
if err != nil {
|
|
|
c.ResponseError(errors.New("UpdateTimeBegin 时间格式错误"))
|
|
|
return
|
...
|
...
|
@@ -559,9 +612,9 @@ func (c *OrderInfoController) ListOrderForExcel() { |
|
|
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 len(param.Where.UpdateTime) > 1 {
|
|
|
if len(param.Where.UpdateTime[1]) > 0 {
|
|
|
t, err := time.ParseInLocation("2006-01-02", param.Where.UpdateTime[1], time.Local)
|
|
|
if err != nil {
|
|
|
c.ResponseError(errors.New("UpdateTimeEnd 时间格式错误"))
|
|
|
return
|
...
|
...
|
@@ -571,13 +624,14 @@ func (c *OrderInfoController) ListOrderForExcel() { |
|
|
updateTimeEnd = t.Format("2006-01-02 15:04:05-07")
|
|
|
}
|
|
|
}
|
|
|
// 订单创建时间
|
|
|
var (
|
|
|
createTimeBegin string
|
|
|
createTimeEnd string
|
|
|
)
|
|
|
if len(param.CreateTime) > 0 {
|
|
|
if len(param.CreateTime[0]) > 0 {
|
|
|
t, err := time.ParseInLocation("2006-01-02", param.CreateTime[0], time.Local)
|
|
|
if len(param.Where.CreateTime) > 0 {
|
|
|
if len(param.Where.CreateTime[0]) > 0 {
|
|
|
t, err := time.ParseInLocation("2006-01-02", param.Where.CreateTime[0], time.Local)
|
|
|
if err != nil {
|
|
|
c.ResponseError(errors.New("UpdateTimeBegin 时间格式错误"))
|
|
|
return
|
...
|
...
|
@@ -585,9 +639,9 @@ func (c *OrderInfoController) ListOrderForExcel() { |
|
|
createTimeBegin = t.Format("2006-01-02 15:04:05-07")
|
|
|
}
|
|
|
}
|
|
|
if len(param.CreateTime) > 1 {
|
|
|
if len(param.CreateTime[1]) > 0 {
|
|
|
t, err := time.ParseInLocation("2006-01-02", param.CreateTime[1], time.Local)
|
|
|
if len(param.Where.CreateTime) > 1 {
|
|
|
if len(param.Where.CreateTime[1]) > 0 {
|
|
|
t, err := time.ParseInLocation("2006-01-02", param.Where.CreateTime[1], time.Local)
|
|
|
if err != nil {
|
|
|
c.ResponseError(errors.New("UpdateTimeEnd 时间格式错误"))
|
|
|
return
|
...
|
...
|
@@ -597,21 +651,51 @@ func (c *OrderInfoController) ListOrderForExcel() { |
|
|
createTimeEnd = t.Format("2006-01-02 15:04:05-07")
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 订单销售时间处理
|
|
|
var (
|
|
|
saleDateBegin string
|
|
|
saleDateEnd string
|
|
|
)
|
|
|
if len(param.Where.SaleDate) > 0 {
|
|
|
if len(param.Where.SaleDate[0]) > 0 {
|
|
|
t, err := time.ParseInLocation("2006-01-02", param.Where.SaleDate[0], time.Local)
|
|
|
if err != nil {
|
|
|
c.ResponseError(errors.New("销售开始时间格式错误"))
|
|
|
return
|
|
|
}
|
|
|
saleDateBegin = t.Format("2006-01-02 15:04:05-07")
|
|
|
}
|
|
|
}
|
|
|
if len(param.Where.SaleDate) > 1 {
|
|
|
if len(param.Where.SaleDate[1]) > 0 {
|
|
|
t, err := time.ParseInLocation("2006-01-02", param.Where.SaleDate[1], time.Local)
|
|
|
if err != nil {
|
|
|
c.ResponseError(errors.New("销售结束时间格式错误"))
|
|
|
return
|
|
|
}
|
|
|
//设定时间边界
|
|
|
t = t.Add(86399 * time.Second)
|
|
|
saleDateEnd = t.Format("2006-01-02 15:04:05-07")
|
|
|
}
|
|
|
}
|
|
|
companyId := c.GetUserCompany()
|
|
|
uid := c.GetUserId()
|
|
|
orderSrv := orderService.NewOrderInfoService(nil)
|
|
|
orderinfos, columns, err := orderSrv.ListOrderForExcel(orderQuery.ListOrderBaseQuery{
|
|
|
//PartnerOrCode: param.SearchText,
|
|
|
PartnerName: param.PartnerName,
|
|
|
OrderCode: param.OrderCode,
|
|
|
DeliveryCode: param.DeliveryCode,
|
|
|
orderInfos, columns, err := orderSrv.ListOrderForExcel(orderQuery.ListOrderBaseQuery{
|
|
|
PartnerName: param.Where.PartnerName,
|
|
|
OrderCode: param.Where.OrderCode,
|
|
|
DeliveryCode: param.Where.DeliveryCode,
|
|
|
OrderType: domain.OrderReal,
|
|
|
CompanyId: companyId,
|
|
|
PartnerCategory: param.PartnerCategory,
|
|
|
Uid: uid,
|
|
|
PartnerCategory: param.Where.PartnerCategory,
|
|
|
PartnerCategoryName: param.Where.PartnerCategoryName,
|
|
|
UpdateTimeBegin: updateTimeBegin,
|
|
|
UpdateTimeEnd: updateTimeEnd,
|
|
|
CreateTimeBegin: createTimeBegin,
|
|
|
CreateTimeEnd: createTimeEnd,
|
|
|
SaleDateBegin: saleDateBegin,
|
|
|
SaleDateEnd: saleDateEnd,
|
|
|
})
|
|
|
if err != nil {
|
|
|
c.ResponseError(err)
|
...
|
...
|
@@ -627,8 +711,8 @@ func (c *OrderInfoController) ListOrderForExcel() { |
|
|
}
|
|
|
excelMaker := exceltool.NewExcelMaker()
|
|
|
excelMaker.SetListHead(excelHeaders)
|
|
|
excelMaker.MakeListExcel(orderinfos)
|
|
|
c.ResponseExcelByFile(c.Ctx, excelMaker)
|
|
|
_ = excelMaker.MakeListExcel(orderInfos)
|
|
|
_ = c.ResponseExcelByFile(c.Ctx, excelMaker)
|
|
|
return
|
|
|
}
|
|
|
|
...
|
...
|
@@ -667,7 +751,7 @@ func (c *OrderInfoController) DownloadTemplate() { |
|
|
}
|
|
|
|
|
|
// 获取导入模板
|
|
|
req := httplib.Get("http://suplus-file-dev.fjmaimaimai.com/upload/file/2021010803305336443.xlsx")
|
|
|
req := httplib.Get("http://suplus-file-dev.fjmaimaimai.com/upload/file/2021020111293523855.xlsx")
|
|
|
err = req.ToFile(constant.IMPORT_EXCEL)
|
|
|
if err != nil {
|
|
|
logs.Error("could not save to file: ", err)
|
...
|
...
|
@@ -708,8 +792,8 @@ func (c *OrderInfoController) ImportOrderFromExcel() { |
|
|
// 返回字段定义
|
|
|
ret := map[string]interface{}{}
|
|
|
|
|
|
// 返回信息表头定义 0: 订单号, 1: 发货单号, 2: 客户名称, 3: 订单区域, 4: 编号, 5: 合伙人, 6: 类型, 7: 业务员抽成比例, 8: 产品名称, 9: 数量, 10: 单价, 11: 合伙人分红比例
|
|
|
var tableHeader = []string{"错误详情", "行号", "订单号", "发货单号", "客户名称", "订单区域", "编号", "合伙人", "类型", "业务员抽成比例", "产品名称", "数量", "单价", "合伙人分红比例"}
|
|
|
// 返回信息表头定义 0: 订单号, 1: 发货单号, 2: 客户名称, 3: 订单区域, 4: 销售日期, 5: 编号, 6: 合伙人, 7: 类型, 8: 业务员抽成比例, 9: 产品名称, 10: 数量, 11: 单价, 12: 合伙人分红比例
|
|
|
var tableHeader = []string{"错误详情", "行号", "订单号", "发货单号", "客户名称", "订单区域", "销售日期", "编号", "合伙人", "类型", "业务员抽成比例", "产品名称", "数量", "单价", "合伙人分红比例"}
|
|
|
|
|
|
// 文件后缀名校验
|
|
|
ext := path.Ext(h.Filename)
|
...
|
...
|
@@ -781,7 +865,7 @@ func (c *OrderInfoController) ImportOrderFromExcel() { |
|
|
nullCell := make([]interface{}, 0)
|
|
|
var myRow []string
|
|
|
for j, _ := range row {
|
|
|
if j != 7 { // 业务员抽成比例非必填
|
|
|
if j != 8 { // 业务员抽成比例非必填
|
|
|
if row[j] == "" || row[j] == " " { // 空字符补位
|
|
|
tmpRow[j] = ""
|
|
|
col := strconv.Itoa(j + 1)
|
...
|
...
|
@@ -847,7 +931,7 @@ func (c *OrderInfoController) ImportOrderFromExcel() { |
|
|
col := strconv.Itoa(j + 1)
|
|
|
|
|
|
switch j {
|
|
|
case 0, 1, 2, 3, 4, 5, 8: // 订单号、发货单号、客户名称、订单区域、编号、合伙人、产品名称长度校验
|
|
|
case 0, 1, 2, 3, 5, 6, 9: // 订单号、发货单号、客户名称、订单区域、编号、合伙人、产品名称长度校验
|
|
|
{
|
|
|
cellStr := strings.TrimSpace(cell)
|
|
|
lenCellStr := utf8.RuneCountInString(cellStr)
|
...
|
...
|
@@ -860,7 +944,19 @@ func (c *OrderInfoController) ImportOrderFromExcel() { |
|
|
myRow = tmpRow
|
|
|
}
|
|
|
}
|
|
|
case 6: // 合伙人类型校验(事业合伙、业务合伙、研发合伙、业务-产品应用合伙)
|
|
|
case 4: // 销售日期格式和有效性校验
|
|
|
{
|
|
|
regexpStr := `(\d{4})/(\d{2})/(\d{2})`
|
|
|
ok := regexp.MustCompile(regexpStr).MatchString(cell)
|
|
|
if !ok {
|
|
|
var tmpRow []string
|
|
|
tmpRow = append(tmpRow, "第"+r+"行第"+col+"列销售日期格式错误,请输入正确的销售日期") // 错误信息
|
|
|
tmpRow = append(tmpRow, r) // 行号
|
|
|
tmpRow = append(tmpRow, row...) // 错误行数据
|
|
|
myRow = tmpRow
|
|
|
}
|
|
|
}
|
|
|
case 7: // 合伙人类型校验(事业合伙、业务合伙、研发合伙、业务-产品应用合伙)
|
|
|
{
|
|
|
if !utils.IsContain(partnerType, cell) {
|
|
|
var tmpRow []string
|
...
|
...
|
@@ -870,7 +966,7 @@ func (c *OrderInfoController) ImportOrderFromExcel() { |
|
|
myRow = tmpRow
|
|
|
}
|
|
|
}
|
|
|
case 7: // 业务员抽成比例,非必填,精确到小数点后两位
|
|
|
case 8: // 业务员抽成比例,非必填,精确到小数点后两位
|
|
|
{
|
|
|
if len(cell) > 0 {
|
|
|
|
...
|
...
|
@@ -905,7 +1001,7 @@ func (c *OrderInfoController) ImportOrderFromExcel() { |
|
|
}
|
|
|
}
|
|
|
}
|
|
|
case 9: // 数量不超过16位正整数
|
|
|
case 10: // 产品数量不超过16位正整数
|
|
|
{
|
|
|
//参数类型转换
|
|
|
orderNum, err := strconv.ParseInt(cell, 10, 64)
|
...
|
...
|
@@ -926,7 +1022,7 @@ func (c *OrderInfoController) ImportOrderFromExcel() { |
|
|
myRow = tmpRow
|
|
|
}
|
|
|
}
|
|
|
case 10: // 单价,精确到小数点后两位,小数点左侧最多可输入16位数字
|
|
|
case 11: // 单价,精确到小数点后两位,小数点左侧最多可输入16位数字
|
|
|
{
|
|
|
|
|
|
// 参数类型转换
|
...
|
...
|
@@ -948,7 +1044,7 @@ func (c *OrderInfoController) ImportOrderFromExcel() { |
|
|
myRow = tmpRow
|
|
|
}
|
|
|
}
|
|
|
case 11: // 合伙人分红比例,精确到小数点后两位
|
|
|
case 12: // 合伙人分红比例,精确到小数点后两位
|
|
|
{
|
|
|
//参数类型转换
|
|
|
partnerRatio, parseErr := strconv.ParseFloat(cell, 64)
|
...
|
...
|
@@ -1011,29 +1107,30 @@ func (c *OrderInfoController) ImportOrderFromExcel() { |
|
|
var orderCommands = make(map[string]*orderCmd.CreateOrderCommand, 0)
|
|
|
for i, row := range rows {
|
|
|
if i > 2 && len(row) == constant.EXCEL_COLUMN {
|
|
|
hashValue := md5.Sum([]byte(row[0] + row[1] + row[4] + row[6])) // 根据:订单号+发货单号+合伙人编号+合伙类型计算哈希值
|
|
|
hashValue := md5.Sum([]byte(row[0] + row[1] + row[5] + row[7])) // 根据:订单号+发货单号+合伙人编号+合伙类型计算哈希值
|
|
|
hashString := hex.EncodeToString(hashValue[:])
|
|
|
|
|
|
if _, ok := orderCommands[hashString]; !ok {
|
|
|
//订单相关,0: 订单号, 1: 发货单号, 2: 客户名称, 3: 订单区域, 4: 编号, 5: 合伙人, 6: 类型, 7: 业务抽成比例,
|
|
|
sbPercent, _ := strconv.ParseFloat(row[7], 64) //业务抽成比例
|
|
|
//订单相关,0: 订单号, 1: 发货单号, 2: 客户名称, 3: 订单区域, 4: 销售日期, 5: 编号, 6: 合伙人, 7: 类型, 8: 业务抽成比例,
|
|
|
sbPercent, _ := strconv.ParseFloat(row[8], 64) //业务抽成比例
|
|
|
|
|
|
//产品相关,8: 产品名称, 9: 数量, 10: 单价, 11: 合伙人分红比例
|
|
|
amount, _ := strconv.ParseInt(row[9], 10, 64) // 数量
|
|
|
price, _ := strconv.ParseFloat(row[10], 64) // 单价
|
|
|
percent, _ := strconv.ParseFloat(row[11], 64) // 合伙人分红比例
|
|
|
//产品相关,9: 产品名称, 10: 数量, 11: 单价, 12: 合伙人分红比例
|
|
|
amount, _ := strconv.ParseInt(row[10], 10, 64) // 数量
|
|
|
price, _ := strconv.ParseFloat(row[11], 64) // 单价
|
|
|
percent, _ := strconv.ParseFloat(row[12], 64) // 合伙人分红比例
|
|
|
|
|
|
// 获取partnerId
|
|
|
var partnerInfo *domain.PartnerInfo
|
|
|
|
|
|
// 5: 合伙人编号
|
|
|
orderQueryData := orderQuery.GetPartnerIdQuery{
|
|
|
Code: row[4],
|
|
|
Code: row[5],
|
|
|
PartnerCategory: 0,
|
|
|
CompanyId: companyId,
|
|
|
}
|
|
|
|
|
|
// 1: 事业合伙、2: 业务合伙、3: 研发合伙、4: 业务-产品应用合伙
|
|
|
switch row[6] {
|
|
|
// 7: 合伙人类型 1: 事业合伙、2: 业务合伙、3: 研发合伙、4: 业务-产品应用合伙
|
|
|
switch row[7] {
|
|
|
case "事业合伙":
|
|
|
orderQueryData.PartnerCategory = 1
|
|
|
case "业务合伙":
|
...
|
...
|
@@ -1046,6 +1143,19 @@ func (c *OrderInfoController) ImportOrderFromExcel() { |
|
|
orderQueryData.PartnerCategory = 0
|
|
|
}
|
|
|
|
|
|
// 销售日期时间格式转换
|
|
|
timeValue, err := time.ParseInLocation("2006/01/02", row[4], time.Local)
|
|
|
if err != nil {
|
|
|
e := lib.ThrowError(lib.ARG_ERROR, err.Error())
|
|
|
c.ResponseError(e)
|
|
|
return
|
|
|
}
|
|
|
|
|
|
//saleDate, err := time.ParseInLocation("2006-01-02 15:04:05", param.SaleDate, time.Local)
|
|
|
saleDateWithTz := time.Date(timeValue.Year(), timeValue.Month(), timeValue.Day(), time.Now().Hour(), time.Now().Minute(), time.Now().Second(), time.Now().Nanosecond(), time.Local)
|
|
|
|
|
|
fmt.Print("销售日期:", saleDateWithTz, "\n")
|
|
|
|
|
|
// 初始化建订单命令集
|
|
|
orderCommands[hashString] = &orderCmd.CreateOrderCommand{
|
|
|
OrderType: 0,
|
...
|
...
|
@@ -1053,11 +1163,12 @@ func (c *OrderInfoController) ImportOrderFromExcel() { |
|
|
DeliveryCode: row[1],
|
|
|
BuyerName: row[2],
|
|
|
OrderRegion: row[3],
|
|
|
SaleDate: saleDateWithTz,
|
|
|
PartnerId: 0, // 根据合伙人类型+合伙人编号查找合伙人id
|
|
|
SalesmanBonusPercent: sbPercent,
|
|
|
Goods: []orderCmd.OrderGoodData{
|
|
|
{
|
|
|
GoodName: row[8],
|
|
|
GoodName: row[9],
|
|
|
PlanGoodNumber: int(amount),
|
|
|
Price: price,
|
|
|
PartnerBonusPercent: percent,
|
...
|
...
|
@@ -1082,14 +1193,14 @@ func (c *OrderInfoController) ImportOrderFromExcel() { |
|
|
orderCommands[hashString].PartnerId = partnerInfo.Partner.Id
|
|
|
}
|
|
|
} else {
|
|
|
//产品相关,8: 产品名称, 9: 数量, 10: 单价, 11: 合伙人分红比例
|
|
|
amount, _ := strconv.ParseInt(row[9], 10, 64) // 数量
|
|
|
price, _ := strconv.ParseFloat(row[10], 64) // 单价
|
|
|
percent, _ := strconv.ParseFloat(row[11], 64) // 合伙人分红比例
|
|
|
//产品相关,9: 产品名称, 10: 数量, 11: 单价, 12: 合伙人分红比例
|
|
|
amount, _ := strconv.ParseInt(row[10], 10, 64) // 数量
|
|
|
price, _ := strconv.ParseFloat(row[11], 64) // 单价
|
|
|
percent, _ := strconv.ParseFloat(row[12], 64) // 合伙人分红比例
|
|
|
|
|
|
// 记录同一笔订单产品
|
|
|
orderCommands[hashString].Goods = append(orderCommands[hashString].Goods, orderCmd.OrderGoodData{
|
|
|
GoodName: row[8],
|
|
|
GoodName: row[9],
|
|
|
PlanGoodNumber: int(amount),
|
|
|
Price: price,
|
|
|
PartnerBonusPercent: percent,
|
...
|
...
|
|