...
|
...
|
@@ -160,15 +160,15 @@ 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
|
|
|
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 +185,7 @@ func (c *OrderInfoController) PageListOrderReal() { |
|
|
if param.PageSize == 0 {
|
|
|
param.PageSize = 20
|
|
|
}
|
|
|
// 订单更新时间处理
|
|
|
var (
|
|
|
updateTimeBegin string
|
|
|
updateTimeEnd string
|
...
|
...
|
@@ -211,6 +212,7 @@ func (c *OrderInfoController) PageListOrderReal() { |
|
|
updateTimeEnd = t.Format("2006-01-02 15:04:05-07")
|
|
|
}
|
|
|
}
|
|
|
// 订单创建时间处理
|
|
|
var (
|
|
|
createTimeBegin string
|
|
|
createTimeEnd string
|
...
|
...
|
@@ -237,11 +239,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,
|
...
|
...
|
@@ -254,12 +281,14 @@ func (c *OrderInfoController) PageListOrderReal() { |
|
|
UpdateTimeEnd: updateTimeEnd,
|
|
|
CreateTimeBegin: createTimeBegin,
|
|
|
CreateTimeEnd: createTimeEnd,
|
|
|
SaleDateStart: saleDateBegin,
|
|
|
SaleDateEnd: saleDateEnd,
|
|
|
})
|
|
|
if err != nil {
|
|
|
c.ResponseError(err)
|
|
|
return
|
|
|
}
|
|
|
c.ResponsePageList(orderinfos, cnt, param.PageNumber)
|
|
|
c.ResponsePageList(orderInfos, cnt, param.PageNumber)
|
|
|
return
|
|
|
}
|
|
|
|
...
|
...
|
@@ -332,6 +361,7 @@ 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"),
|
|
|
"sale_date": orderinfo.SaleDate.Local().Format("2006-01-02 15:04:06"),
|
|
|
"partnerCategoryId": orderinfo.PartnerCategory.Id,
|
|
|
"partnerCategoryName": orderinfo.PartnerCategory.Name,
|
|
|
}
|
...
|
...
|
@@ -862,7 +892,16 @@ func (c *OrderInfoController) ImportOrderFromExcel() { |
|
|
}
|
|
|
case 4: // TODO 销售日期格式和有效性校验
|
|
|
{
|
|
|
|
|
|
regexpStr := `(\d{4})/(\d{2})/(\d{2})`
|
|
|
//cellStr := strings.TrimSpace(cell)
|
|
|
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: // 合伙人类型校验(事业合伙、业务合伙、研发合伙、业务-产品应用合伙)
|
|
|
{
|
...
|
...
|
@@ -1015,29 +1054,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 "业务合伙":
|
...
|
...
|
@@ -1050,6 +1090,9 @@ func (c *OrderInfoController) ImportOrderFromExcel() { |
|
|
orderQueryData.PartnerCategory = 0
|
|
|
}
|
|
|
|
|
|
//TODO 销售日期时间格式转换
|
|
|
timeValue, _ := time.Parse(row[4], "2015/02/08")
|
|
|
|
|
|
// 初始化建订单命令集
|
|
|
orderCommands[hashString] = &orderCmd.CreateOrderCommand{
|
|
|
OrderType: 0,
|
...
|
...
|
@@ -1057,11 +1100,12 @@ func (c *OrderInfoController) ImportOrderFromExcel() { |
|
|
DeliveryCode: row[1],
|
|
|
BuyerName: row[2],
|
|
|
OrderRegion: row[3],
|
|
|
SaleDate: timeValue,
|
|
|
PartnerId: 0, // 根据合伙人类型+合伙人编号查找合伙人id
|
|
|
SalesmanBonusPercent: sbPercent,
|
|
|
Goods: []orderCmd.OrderGoodData{
|
|
|
{
|
|
|
GoodName: row[8],
|
|
|
GoodName: row[9],
|
|
|
PlanGoodNumber: int(amount),
|
|
|
Price: price,
|
|
|
PartnerBonusPercent: percent,
|
...
|
...
|
@@ -1086,14 +1130,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,
|
...
|
...
|
|