作者 陈志颖

chore:增加栏目设置领域描述语言

正在显示 33 个修改的文件 包含 424 行增加49 行删除
  1 +version: v1
  2 +kind: HttpApi
  3 +metadata:
  4 + service: column_setting
  5 + path: /column-settings
  6 + endpoints:
  7 + - method: createColumn
  8 + route:
  9 + post: /
  10 + - method: updateColumn
  11 + route:
  12 + post: /{columnSettingId}
  13 + - method: getColumnSetting
  14 + route:
  15 + post: /{columnSettingId}
  16 + - method: resetColumn
  17 + route:
  18 + post: /
  19 + - method: listColumn
  20 + route:
  21 + post: /
  22 + params:
  23 + - name: offset
  24 + - name: limit
  1 +version: v1
  2 +kind: Attribute
  3 +metadata:
  4 + name: columnId
  5 + description: 列标记
  6 + type:
  7 + primitive: string
  1 +version: v1
  2 +kind: Attribute
  3 +metadata:
  4 + name: paramCn
  5 + description: 列标记中文
  6 + type:
  7 + primitive: string
  1 +version: v1
  2 +kind: Attribute
  3 +metadata:
  4 + name: paramFix
  5 + description: 列标记是否固定,1:固定,2:不固定
  6 + type:
  7 + primitive: int
  1 +version: v1
  2 +kind: Attribute
  3 +metadata:
  4 + name: columnSettingId
  5 + description: 栏目设置id
  6 + type:
  7 + primitive: int64
  1 +version: v1
  2 +kind: Attribute
  3 +metadata:
  4 + name: companyId
  5 + description: 栏目设置关联用户公司id
  6 + type:
  7 + primitive: int32
  1 +version: v1
  2 +kind: Attribute
  3 +metadata:
  4 + name: createdAt
  5 + description: 栏目设置创建时间
  6 + type:
  7 + primitive: datetime
  1 +version: v1
  2 +kind: Attribute
  3 +metadata:
  4 + name: description
  5 + description: 栏目设置描述
  6 + type:
  7 + primitive: string
  1 +version: v1
  2 +kind: Attribute
  3 +metadata:
  4 + name: key
  5 + description: 栏目设置模块名称
  6 + type:
  7 + primitive: string
  1 +version: v1
  2 +kind: Attribute
  3 +metadata:
  4 + name: uid
  5 + description: 栏目设置关联用户uid
  6 + type:
  7 + primitive: int64
  1 +version: v1
  2 +kind: Attribute
  3 +metadata:
  4 + name: updatedAt
  5 + description: 栏目设置更新时间
  6 + type:
  7 + primitive: datetime
  1 +version: v1
  2 +kind: Attribute
  3 +metadata:
  4 + name: userName
  5 + description: 栏目设置关联用户名称
  6 + type:
  7 + primitive: string
  1 +version: v1
  2 +kind: Attribute
  3 +metadata:
  4 + name: value
  5 + description: 栏目设置项
  6 + type:
  7 + array: column
  1 +package domain
  2 +
  3 +// 栏目项
  4 +type Column struct {
  5 + // 列标记
  6 + ColumnId string `json:"columnId"`
  7 + // 列标记中文
  8 + ParamCn string `json:"paramCn"`
  9 + // 列标记是否固定,1:固定,2:不固定
  10 + ParamFix int `json:"paramFix"`
  11 +}
  1 +version: v1
  2 +kind: Schema
  3 +metadata:
  4 + name: column
  5 + description: 栏目项
  6 + attributes:
  7 + - ref: columnId
  8 + required: true
  9 + - ref: paramCn
  10 + required: true
  11 + - ref: paramFix
  12 + required: true
  1 +version: v1
  2 +kind: Schema
  3 +metadata:
  4 + name: column_setting
  5 + description: 栏目设置
  6 + attributes:
  7 + - ref: companyId
  8 + required: true
  9 + - ref: createdAt
  10 + required: true
  11 + - ref: description
  12 + required: true
  13 + - ref: key
  14 + required: true
  15 + - ref: settingId
  16 + required: true
  17 + - ref: uid
  18 + required: true
  19 + - ref: updatedAt
  20 + required: true
  21 + - ref: userName
  22 + required: true
  23 + - ref: value
  24 + required: true
  1 +version: v1
  2 +kind: Method
  3 +metadata:
  4 + name: createColumnSetting
  5 + type: command
  6 + description: 创建
  7 + payload:
  8 + - ref: companyId
  9 + required: true
  10 + - ref: description
  11 + required: true
  12 + - ref: createdAt
  13 + required: true
  14 + - ref: key
  15 + required: true
  16 + - ref: settingId
  17 + required: true
  18 + - ref: uid
  19 + required: true
  20 + - ref: updatedAt
  21 + required: true
  22 + - ref: userName
  23 + required: true
  24 + - ref: value
  25 + required: true
  26 + - ref: count
  27 + required: true
  28 + - ref: limit
  29 + required: true
  30 + - ref: offset
  31 + required: true
  32 + result:
  33 + - name: column_setting
  34 + type:
  35 + schema: column_setting
  1 +version: v1
  2 +kind: Method
  3 +metadata:
  4 + name: getColumnSetting
  5 + type: query
  6 + description: 返回
  7 + payload:
  8 + - ref: columnSettingId
  9 + required: true
  10 + result:
  11 + - name: column_setting
  12 + type:
  13 + schema: column_setting
  1 +version: v1
  2 +kind: Method
  3 +metadata:
  4 + name: listColumnSetting
  5 + type: query
  6 + description: 返回列表
  7 + payload:
  8 + - ref: offset
  9 + required: true
  10 + - ref: limit
  11 + required: true
  12 + result:
  13 + - ref: count
  14 + required: true
  15 + - name: column_setting
  16 + type:
  17 + schema: column_setting
  1 +version: v1
  2 +kind: Method
  3 +metadata:
  4 + name: removeColumnSetting
  5 + type: command
  6 + description: 移除
  7 + payload:
  8 + - ref: columnSettingId
  9 + required: true
  10 + result:
  11 + - name: column_setting
  12 + type:
  13 + schema: column_setting
  1 +version: v1
  2 +kind: Method
  3 +metadata:
  4 + name: resetColumn
  5 + type: command
  6 + description: 重置栏目
  7 + result:
  8 + - name: column_setting
  9 + type:
  10 + schema: column_setting
  1 +version: v1
  2 +kind: Method
  3 +metadata:
  4 + name: updateColumnSetting
  5 + type: command
  6 + description: 更新
  7 + payload:
  8 + - ref: companyId
  9 + required: true
  10 + - ref: description
  11 + required: true
  12 + - ref: createdAt
  13 + required: true
  14 + - ref: key
  15 + required: true
  16 + - ref: settingId
  17 + required: true
  18 + - ref: uid
  19 + required: true
  20 + - ref: updatedAt
  21 + required: true
  22 + - ref: userName
  23 + required: true
  24 + - ref: value
  25 + required: true
  26 + - ref: count
  27 + required: true
  28 + - ref: limit
  29 + required: true
  30 + - ref: offset
  31 + required: true
  32 + - ref: columnSettingId
  33 + required: true
  34 + result:
  35 + - name: column_setting
  36 + type:
  37 + schema: column_setting
  1 +version: v1
  2 +kind: Service
  3 +metadata:
  4 + name: column_setting
  5 + description: 栏目设置服务
1 package command 1 package command
2 2
3 -import "errors" 3 +import (
  4 + "errors"
  5 + "time"
  6 +)
4 7
5 //创建订单 8 //创建订单
6 type CreateOrderCommand struct { 9 type CreateOrderCommand struct {
@@ -32,6 +35,8 @@ type CreateOrderCommand struct { @@ -32,6 +35,8 @@ type CreateOrderCommand struct {
32 Code string `json:"code"` 35 Code string `json:"code"`
33 //合伙人类型名称-错误信息返回 36 //合伙人类型名称-错误信息返回
34 PartnerCategoryName string `json:"partnerCategoryName"` 37 PartnerCategoryName string `json:"partnerCategoryName"`
  38 + //销售日期
  39 + SaleDate time.Time `json:"saleDate"`
35 } 40 }
36 41
37 func (postData *CreateOrderCommand) Valid() error { 42 func (postData *CreateOrderCommand) Valid() error {
1 package command 1 package command
2 2
  3 +import "time"
  4 +
3 //UpdateOrderPurposeCommand 更新订单单 5 //UpdateOrderPurposeCommand 更新订单单
4 type UpdateOrderCommand struct { 6 type UpdateOrderCommand struct {
5 Id int64 `json:"id"` 7 Id int64 `json:"id"`
@@ -21,6 +23,8 @@ type UpdateOrderCommand struct { @@ -21,6 +23,8 @@ type UpdateOrderCommand struct {
21 Goods []OrderGoodData `json:"goods"` 23 Goods []OrderGoodData `json:"goods"`
22 //公司id 24 //公司id
23 CompanyId int64 `json:"companyId"` 25 CompanyId int64 `json:"companyId"`
24 - // 合伙人类型 26 + //合伙人类型
25 PartnerCategory int64 `json:"partner_category"` 27 PartnerCategory int64 `json:"partner_category"`
  28 + //销售日期
  29 + SaleDate time.Time `json:"saleDate"`
26 } 30 }
@@ -28,4 +28,8 @@ type ListOrderBaseQuery struct { @@ -28,4 +28,8 @@ type ListOrderBaseQuery struct {
28 CreateTimeBegin string `json:"createTimeBegin"` 28 CreateTimeBegin string `json:"createTimeBegin"`
29 //创建时间截止 29 //创建时间截止
30 CreateTimeEnd string `json:"createTimeEnd"` 30 CreateTimeEnd string `json:"createTimeEnd"`
  31 + //销售时间开始
  32 + SaleDateStart string `json:"saleDateStart"`
  33 + //销售时间结束
  34 + SaleDateEnd string `json:"sateDateEnd"`
31 } 35 }
@@ -62,8 +62,9 @@ func (service OrderInfoService) PageListOrderBase(listOrderQuery query.ListOrder @@ -62,8 +62,9 @@ func (service OrderInfoService) PageListOrderBase(listOrderQuery query.ListOrder
62 listOrderQuery.PartnerName, // 合伙人姓名 62 listOrderQuery.PartnerName, // 合伙人姓名
63 listOrderQuery.OrderCode, // 订单号 63 listOrderQuery.OrderCode, // 订单号
64 listOrderQuery.DeliveryCode, // 发货单号 64 listOrderQuery.DeliveryCode, // 发货单号
65 - [2]string{listOrderQuery.UpdateTimeBegin, listOrderQuery.UpdateTimeEnd},  
66 - [2]string{listOrderQuery.CreateTimeBegin, listOrderQuery.CreateTimeEnd}, 65 + [2]string{listOrderQuery.UpdateTimeBegin, listOrderQuery.UpdateTimeEnd}, // 订单创建时间
  66 + [2]string{listOrderQuery.CreateTimeBegin, listOrderQuery.CreateTimeEnd}, // 订单更新时间
  67 + [2]string{listOrderQuery.SaleDateStart, listOrderQuery.SaleDateEnd}, // 销售日期
67 listOrderQuery.PartnerCategory, 68 listOrderQuery.PartnerCategory,
68 listOrderQuery.Limit, listOrderQuery.Offset, 69 listOrderQuery.Limit, listOrderQuery.Offset,
69 ) 70 )
@@ -94,6 +95,7 @@ func (service OrderInfoService) PageListOrderBase(listOrderQuery query.ListOrder @@ -94,6 +95,7 @@ func (service OrderInfoService) PageListOrderBase(listOrderQuery query.ListOrder
94 "index": listIndex, 95 "index": listIndex,
95 "createTime": orders[i].CreateTime.Local().Format("2006-01-02 15:04:05"), 96 "createTime": orders[i].CreateTime.Local().Format("2006-01-02 15:04:05"),
96 "updateTime": orders[i].UpdateTime.Local().Format("2006-01-02 15:04:05"), 97 "updateTime": orders[i].UpdateTime.Local().Format("2006-01-02 15:04:05"),
  98 + "saleDate": orders[i].SaleDate.Local().Format("2006-01-02 15:04:05"),
97 "buyer": orders[i].Buyer.BuyerName, 99 "buyer": orders[i].Buyer.BuyerName,
98 "id": fmt.Sprint(orders[i].Id), 100 "id": fmt.Sprint(orders[i].Id),
99 "orderId": orders[i].OrderCode, 101 "orderId": orders[i].OrderCode,
@@ -188,7 +190,13 @@ func (service OrderInfoService) GetOrderDetail(getOrderQuery query.GetOrderQuery @@ -188,7 +190,13 @@ func (service OrderInfoService) GetOrderDetail(getOrderQuery query.GetOrderQuery
188 return order, nil 190 return order, nil
189 } 191 }
190 192
191 -//CreateNewOrder 创建订单 193 +/**
  194 + * @Author SteveChan
  195 + * @Description //TODO 创建订单,增加销售日期
  196 + * @Date 11:57 2021/1/26
  197 + * @Param
  198 + * @return
  199 + **/
192 func (service OrderInfoService) CreateNewOrder(cmd command.CreateOrderCommand) (*domain.OrderBase, error) { 200 func (service OrderInfoService) CreateNewOrder(cmd command.CreateOrderCommand) (*domain.OrderBase, error) {
193 var ( 201 var (
194 transactionContext, _ = factory.CreateTransactionContext(nil) 202 transactionContext, _ = factory.CreateTransactionContext(nil)
@@ -255,7 +263,8 @@ func (service OrderInfoService) CreateNewOrder(cmd command.CreateOrderCommand) ( @@ -255,7 +263,8 @@ func (service OrderInfoService) CreateNewOrder(cmd command.CreateOrderCommand) (
255 goodMap[goodname] = 1 263 goodMap[goodname] = 1
256 } 264 }
257 newOrder := &domain.OrderBase{ 265 newOrder := &domain.OrderBase{
258 - OrderType: cmd.OrderType, OrderCode: cmd.OrderCode, 266 + OrderType: cmd.OrderType,
  267 + OrderCode: cmd.OrderCode,
259 DeliveryCode: cmd.DeliveryCode, 268 DeliveryCode: cmd.DeliveryCode,
260 Buyer: domain.Buyer{ 269 Buyer: domain.Buyer{
261 BuyerName: cmd.BuyerName, 270 BuyerName: cmd.BuyerName,
@@ -263,6 +272,7 @@ func (service OrderInfoService) CreateNewOrder(cmd command.CreateOrderCommand) ( @@ -263,6 +272,7 @@ func (service OrderInfoService) CreateNewOrder(cmd command.CreateOrderCommand) (
263 RegionInfo: domain.RegionInfo{ 272 RegionInfo: domain.RegionInfo{
264 RegionName: cmd.OrderRegion, 273 RegionName: cmd.OrderRegion,
265 }, 274 },
  275 + SaleDate: cmd.SaleDate,
266 PartnerId: cmd.PartnerId, 276 PartnerId: cmd.PartnerId,
267 PartnerInfo: partnerData.Partner, 277 PartnerInfo: partnerData.Partner,
268 SalesmanBonusPercent: cmd.SalesmanBonusPercent, 278 SalesmanBonusPercent: cmd.SalesmanBonusPercent,
@@ -277,15 +287,15 @@ func (service OrderInfoService) CreateNewOrder(cmd command.CreateOrderCommand) ( @@ -277,15 +287,15 @@ func (service OrderInfoService) CreateNewOrder(cmd command.CreateOrderCommand) (
277 var cmdPartnerCategoryOk bool 287 var cmdPartnerCategoryOk bool
278 for _, v := range partnerData.PartnerCategoryInfos { 288 for _, v := range partnerData.PartnerCategoryInfos {
279 if v.Id == cmd.PartnerCategory { 289 if v.Id == cmd.PartnerCategory {
280 - _, categorys, err := categoryRepository.Find(domain.PartnerCategoryFindQuery{ 290 + _, categories, err := categoryRepository.Find(domain.PartnerCategoryFindQuery{
281 Ids: []int64{v.Id}, 291 Ids: []int64{v.Id},
282 }) 292 })
283 if err != nil { 293 if err != nil {
284 e := fmt.Sprintf("获取合伙人分类数据失败:%s", err) 294 e := fmt.Sprintf("获取合伙人分类数据失败:%s", err)
285 return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, e) 295 return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, e)
286 } 296 }
287 - if len(categorys) > 0 {  
288 - newOrder.PartnerCategory = categorys[0] 297 + if len(categories) > 0 {
  298 + newOrder.PartnerCategory = categories[0]
289 cmdPartnerCategoryOk = true 299 cmdPartnerCategoryOk = true
290 } 300 }
291 break 301 break
@@ -511,6 +521,7 @@ func (service OrderInfoService) UpdateOrderData(cmd command.UpdateOrderCommand) @@ -511,6 +521,7 @@ func (service OrderInfoService) UpdateOrderData(cmd command.UpdateOrderCommand)
511 oldOrderData.DeliveryCode = cmd.DeliveryCode 521 oldOrderData.DeliveryCode = cmd.DeliveryCode
512 oldOrderData.Buyer.BuyerName = cmd.BuyerName 522 oldOrderData.Buyer.BuyerName = cmd.BuyerName
513 oldOrderData.RegionInfo.RegionName = cmd.OrderRegion 523 oldOrderData.RegionInfo.RegionName = cmd.OrderRegion
  524 + oldOrderData.SaleDate = cmd.SaleDate
514 oldOrderData.PartnerId = cmd.PartnerId 525 oldOrderData.PartnerId = cmd.PartnerId
515 oldOrderData.PartnerInfo = partnerData.Partner 526 oldOrderData.PartnerInfo = partnerData.Partner
516 oldOrderData.SalesmanBonusPercent = cmd.SalesmanBonusPercent 527 oldOrderData.SalesmanBonusPercent = cmd.SalesmanBonusPercent
  1 +/**
  2 + @author: stevechan
  3 + @date: 2021/1/26
  4 + @note:
  5 +**/
  6 +
  7 +package domain
  1 +/**
  2 + @author: stevechan
  3 + @date: 2021/1/26
  4 + @note:
  5 +**/
  6 +
  7 +package domain
@@ -191,7 +191,7 @@ func (dao OrderBaseDao) OrderBonusListForExcel(companyId int64, orderType int, p @@ -191,7 +191,7 @@ func (dao OrderBaseDao) OrderBonusListForExcel(companyId int64, orderType int, p
191 //@param updateTime 订单更新时间范围"[开始时间,结束时间]",时间格式"2006-01-02 15:04:05+07" 191 //@param updateTime 订单更新时间范围"[开始时间,结束时间]",时间格式"2006-01-02 15:04:05+07"
192 //@param createTime 订单的创建时间范围"[开始时间,结束时间]" 时间格式"2006-01-02 15:04:05+07" 192 //@param createTime 订单的创建时间范围"[开始时间,结束时间]" 时间格式"2006-01-02 15:04:05+07"
193 func (dao OrderBaseDao) OrderListByCondition(companyId int64, orderType int, partnerName string, orderCode string, deliveryCode string, 193 func (dao OrderBaseDao) OrderListByCondition(companyId int64, orderType int, partnerName string, orderCode string, deliveryCode string,
194 - updateTime [2]string, createTime [2]string, partnerCategory int, limit, offset int) ([]models.OrderBase, int, error) { 194 + updateTime [2]string, createTime [2]string, saleDate [2]string, partnerCategory int, limit, offset int) ([]models.OrderBase, int, error) {
195 tx := dao.transactionContext.GetDB() 195 tx := dao.transactionContext.GetDB()
196 var orders []models.OrderBase 196 var orders []models.OrderBase
197 query := tx.Model(&orders).Where("order_base.company_id=?", companyId) 197 query := tx.Model(&orders).Where("order_base.company_id=?", companyId)
@@ -45,6 +45,8 @@ type OrderBase struct { @@ -45,6 +45,8 @@ type OrderBase struct {
45 DeliveryTime time.Time 45 DeliveryTime time.Time
46 //更新时间 46 //更新时间
47 UpdateTime time.Time 47 UpdateTime time.Time
  48 + //销售时间
  49 + SaleDate time.Time
48 //合伙人应收分红 50 //合伙人应收分红
49 PlanPartnerBonus float64 `pg:",use_zero"` 51 PlanPartnerBonus float64 `pg:",use_zero"`
50 //调整后的合伙人应收分红 (初始值=-1); 52 //调整后的合伙人应收分红 (初始值=-1);
@@ -62,7 +64,8 @@ type OrderBase struct { @@ -62,7 +64,8 @@ type OrderBase struct {
62 IsDisable int `pg:",use_zero"` 64 IsDisable int `pg:",use_zero"`
63 //分红支付状态 65 //分红支付状态
64 BonusStatus int 66 BonusStatus int
65 - CompanyId int64 67 + //公司id
  68 + CompanyId int64
66 //数据来源 69 //数据来源
67 DataFrom domain.OrderDataFrom `` 70 DataFrom domain.OrderDataFrom ``
68 //备注 71 //备注
@@ -29,6 +29,7 @@ func (reponsitory OrderBaseRepository) transformPgModelToDomainModel(orderModel @@ -29,6 +29,7 @@ func (reponsitory OrderBaseRepository) transformPgModelToDomainModel(orderModel
29 DeliveryCode: orderModel.DeliveryCode, Buyer: orderModel.Buyer, RegionInfo: orderModel.RegionInfo, 29 DeliveryCode: orderModel.DeliveryCode, Buyer: orderModel.Buyer, RegionInfo: orderModel.RegionInfo,
30 PartnerId: orderModel.PartnerId, SalesmanBonusPercent: orderModel.SalesmanBonusPercent, 30 PartnerId: orderModel.PartnerId, SalesmanBonusPercent: orderModel.SalesmanBonusPercent,
31 CreateTime: orderModel.CreateTime, DeliveryTime: orderModel.DeliveryTime, UpdateTime: orderModel.UpdateTime, 31 CreateTime: orderModel.CreateTime, DeliveryTime: orderModel.DeliveryTime, UpdateTime: orderModel.UpdateTime,
  32 + SaleDate: orderModel.SaleDate,
32 IsDisable: orderModel.IsDisable, 33 IsDisable: orderModel.IsDisable,
33 OrderCompute: domain.OrderCompute{ 34 OrderCompute: domain.OrderCompute{
34 PlanPartnerBonus: orderModel.PlanPartnerBonus, UsePartnerBonus: orderModel.UsePartnerBonus, 35 PlanPartnerBonus: orderModel.PlanPartnerBonus, UsePartnerBonus: orderModel.UsePartnerBonus,
@@ -49,10 +50,10 @@ func (reponsitory OrderBaseRepository) transformPgModelToDomainModel(orderModel @@ -49,10 +50,10 @@ func (reponsitory OrderBaseRepository) transformPgModelToDomainModel(orderModel
49 return order, nil 50 return order, nil
50 } 51 }
51 52
52 -func (repository OrderBaseRepository) Save(orderInfo *domain.OrderBase) error { 53 +func (reponsitory OrderBaseRepository) Save(orderInfo *domain.OrderBase) error {
53 var ( 54 var (
54 err error 55 err error
55 - tx = repository.transactionContext.PgTx 56 + tx = reponsitory.transactionContext.PgTx
56 ) 57 )
57 m := &models.OrderBase{ 58 m := &models.OrderBase{
58 Id: orderInfo.Id, OrderType: orderInfo.OrderType, OrderCode: orderInfo.OrderCode, 59 Id: orderInfo.Id, OrderType: orderInfo.OrderType, OrderCode: orderInfo.OrderCode,
@@ -68,6 +69,9 @@ func (repository OrderBaseRepository) Save(orderInfo *domain.OrderBase) error { @@ -68,6 +69,9 @@ func (repository OrderBaseRepository) Save(orderInfo *domain.OrderBase) error {
68 CompanyId: orderInfo.CompanyId, DataFrom: orderInfo.DataFrom, 69 CompanyId: orderInfo.CompanyId, DataFrom: orderInfo.DataFrom,
69 Remark: orderInfo.Remark, PartnerCategory: orderInfo.PartnerCategory, 70 Remark: orderInfo.Remark, PartnerCategory: orderInfo.PartnerCategory,
70 } 71 }
  72 + if m.OrderType > 2 { // TODO 非平台自建订单,默认销售日期取订单创建日期
  73 + m.SaleDate = orderInfo.CreateTime
  74 + }
71 if m.Id == 0 { 75 if m.Id == 0 {
72 _, err = tx.Model(m). 76 _, err = tx.Model(m).
73 Returning("*"). 77 Returning("*").
@@ -75,6 +79,7 @@ func (repository OrderBaseRepository) Save(orderInfo *domain.OrderBase) error { @@ -75,6 +79,7 @@ func (repository OrderBaseRepository) Save(orderInfo *domain.OrderBase) error {
75 orderInfo.Id = m.Id 79 orderInfo.Id = m.Id
76 orderInfo.CreateTime = m.CreateTime 80 orderInfo.CreateTime = m.CreateTime
77 orderInfo.UpdateTime = m.UpdateTime 81 orderInfo.UpdateTime = m.UpdateTime
  82 + orderInfo.SaleDate = m.CreateTime
78 } else { 83 } else {
79 _, err = tx.Model(m). 84 _, err = tx.Model(m).
80 WherePK(). 85 WherePK().
@@ -85,8 +90,8 @@ func (repository OrderBaseRepository) Save(orderInfo *domain.OrderBase) error { @@ -85,8 +90,8 @@ func (repository OrderBaseRepository) Save(orderInfo *domain.OrderBase) error {
85 return err 90 return err
86 } 91 }
87 92
88 -func (repository OrderBaseRepository) Find(queryOption domain.OrderBaseFindQuery) ([]domain.OrderBase, int, error) {  
89 - db := repository.transactionContext.GetDB() 93 +func (reponsitory OrderBaseRepository) Find(queryOption domain.OrderBaseFindQuery) ([]domain.OrderBase, int, error) {
  94 + db := reponsitory.transactionContext.GetDB()
90 orderModels := []models.OrderBase{} 95 orderModels := []models.OrderBase{}
91 query := db.Model(&orderModels) 96 query := db.Model(&orderModels)
92 if queryOption.PartnerId > 0 { 97 if queryOption.PartnerId > 0 {
@@ -122,7 +127,7 @@ func (repository OrderBaseRepository) Find(queryOption domain.OrderBaseFindQuery @@ -122,7 +127,7 @@ func (repository OrderBaseRepository) Find(queryOption domain.OrderBaseFindQuery
122 return ordersReturn, 0, err 127 return ordersReturn, 0, err
123 } 128 }
124 for i := range orderModels { 129 for i := range orderModels {
125 - domainOrder, err := repository.transformPgModelToDomainModel(&orderModels[i]) 130 + domainOrder, err := reponsitory.transformPgModelToDomainModel(&orderModels[i])
126 if err != nil { 131 if err != nil {
127 return ordersReturn, 0, err 132 return ordersReturn, 0, err
128 } 133 }
@@ -131,10 +136,10 @@ func (repository OrderBaseRepository) Find(queryOption domain.OrderBaseFindQuery @@ -131,10 +136,10 @@ func (repository OrderBaseRepository) Find(queryOption domain.OrderBaseFindQuery
131 return ordersReturn, count, nil 136 return ordersReturn, count, nil
132 } 137 }
133 138
134 -func (repository OrderBaseRepository) FindOne(qureyOptions domain.OrderBaseFindOneQuery) (*domain.OrderBase, error) { 139 +func (reponsitory OrderBaseRepository) FindOne(qureyOptions domain.OrderBaseFindOneQuery) (*domain.OrderBase, error) {
135 var ( 140 var (
136 err error 141 err error
137 - tx = repository.transactionContext.PgDd 142 + tx = reponsitory.transactionContext.PgDd
138 ) 143 )
139 m := new(models.OrderBase) 144 m := new(models.OrderBase)
140 query := tx.Model(m). 145 query := tx.Model(m).
@@ -146,14 +151,14 @@ func (repository OrderBaseRepository) FindOne(qureyOptions domain.OrderBaseFindO @@ -146,14 +151,14 @@ func (repository OrderBaseRepository) FindOne(qureyOptions domain.OrderBaseFindO
146 if err != nil { 151 if err != nil {
147 return nil, err 152 return nil, err
148 } 153 }
149 - result, err := repository.transformPgModelToDomainModel(m) 154 + result, err := reponsitory.transformPgModelToDomainModel(m)
150 return &result, err 155 return &result, err
151 } 156 }
152 157
153 -func (repository OrderBaseRepository) Remove(id int64, companyId int64) error { 158 +func (reponsitory OrderBaseRepository) Remove(id int64, companyId int64) error {
154 var ( 159 var (
155 err error 160 err error
156 - tx = repository.transactionContext.PgTx 161 + tx = reponsitory.transactionContext.PgTx
157 ) 162 )
158 m := &models.OrderBase{ 163 m := &models.OrderBase{
159 Id: id, 164 Id: id,
@@ -160,15 +160,15 @@ func (postData *postOrderPurposeDelivery) Valid() error { @@ -160,15 +160,15 @@ func (postData *postOrderPurposeDelivery) Valid() error {
160 **/ 160 **/
161 func (c *OrderInfoController) PageListOrderReal() { 161 func (c *OrderInfoController) PageListOrderReal() {
162 type Parameter struct { 162 type Parameter struct {
163 - //SearchText string `json:"searchText"`  
164 - PartnerName string `json:"partnerName"` // 合伙人姓名  
165 - OrderCode string `json:"orderCode"` // 订单号  
166 - DeliveryCode string `json:"deliveryCode"` // 发货单号  
167 - PartnerCategory int `json:"PartnerCategory"` 163 + PartnerName string `json:"partnerName"` // 合伙人姓名
  164 + OrderCode string `json:"orderCode"` // 订单号
  165 + DeliveryCode string `json:"deliveryCode"` // 发货单号
  166 + PartnerCategory int `json:"PartnerCategory"` // 合伙人类型id
168 PageSize int `json:"pageSize"` 167 PageSize int `json:"pageSize"`
169 PageNumber int `json:"pageNumber"` 168 PageNumber int `json:"pageNumber"`
170 - UpdateTime []string `json:"updateTime"`  
171 - CreateTime []string `json:"createTime"` 169 + UpdateTime []string `json:"updateTime"` // 订单更新时间
  170 + CreateTime []string `json:"createTime"` // 订单创建时间
  171 + SaleDate []string `json:"saleDate"` // 销售时间
172 } 172 }
173 var ( 173 var (
174 param Parameter 174 param Parameter
@@ -185,6 +185,7 @@ func (c *OrderInfoController) PageListOrderReal() { @@ -185,6 +185,7 @@ func (c *OrderInfoController) PageListOrderReal() {
185 if param.PageSize == 0 { 185 if param.PageSize == 0 {
186 param.PageSize = 20 186 param.PageSize = 20
187 } 187 }
  188 + // 订单更新时间处理
188 var ( 189 var (
189 updateTimeBegin string 190 updateTimeBegin string
190 updateTimeEnd string 191 updateTimeEnd string
@@ -211,6 +212,7 @@ func (c *OrderInfoController) PageListOrderReal() { @@ -211,6 +212,7 @@ func (c *OrderInfoController) PageListOrderReal() {
211 updateTimeEnd = t.Format("2006-01-02 15:04:05-07") 212 updateTimeEnd = t.Format("2006-01-02 15:04:05-07")
212 } 213 }
213 } 214 }
  215 + // 订单创建时间处理
214 var ( 216 var (
215 createTimeBegin string 217 createTimeBegin string
216 createTimeEnd string 218 createTimeEnd string
@@ -237,11 +239,36 @@ func (c *OrderInfoController) PageListOrderReal() { @@ -237,11 +239,36 @@ func (c *OrderInfoController) PageListOrderReal() {
237 createTimeEnd = t.Format("2006-01-02 15:04:05-07") 239 createTimeEnd = t.Format("2006-01-02 15:04:05-07")
238 } 240 }
239 } 241 }
240 - 242 + // 订单销售时间处理
  243 + var (
  244 + saleDateBegin string
  245 + saleDateEnd string
  246 + )
  247 + if len(param.SaleDate) > 0 {
  248 + if len(param.SaleDate[0]) > 0 {
  249 + t, err := time.ParseInLocation("2006-01-02", param.SaleDate[0], time.Local)
  250 + if err != nil {
  251 + c.ResponseError(errors.New("销售开始时间格式错误"))
  252 + return
  253 + }
  254 + saleDateBegin = t.Format("2006-01-02 15:04:05-07")
  255 + }
  256 + }
  257 + if len(param.SaleDate) > 1 {
  258 + if len(param.SaleDate[1]) > 0 {
  259 + t, err := time.ParseInLocation("2006-01-02", param.SaleDate[1], time.Local)
  260 + if err != nil {
  261 + c.ResponseError(errors.New("销售结束时间格式错误"))
  262 + return
  263 + }
  264 + //设定时间边界
  265 + t = t.Add(86399 * time.Second)
  266 + saleDateEnd = t.Format("2006-01-02 15:04:05-07")
  267 + }
  268 + }
241 companyId := c.GetUserCompany() 269 companyId := c.GetUserCompany()
242 orderSrv := orderService.NewOrderInfoService(nil) 270 orderSrv := orderService.NewOrderInfoService(nil)
243 - orderinfos, cnt, err := orderSrv.PageListOrderBase(orderQuery.ListOrderBaseQuery{  
244 - //PartnerOrCode: param.SearchText, 271 + orderInfos, cnt, err := orderSrv.PageListOrderBase(orderQuery.ListOrderBaseQuery{
245 PartnerName: param.PartnerName, 272 PartnerName: param.PartnerName,
246 OrderCode: param.OrderCode, 273 OrderCode: param.OrderCode,
247 DeliveryCode: param.DeliveryCode, 274 DeliveryCode: param.DeliveryCode,
@@ -254,12 +281,14 @@ func (c *OrderInfoController) PageListOrderReal() { @@ -254,12 +281,14 @@ func (c *OrderInfoController) PageListOrderReal() {
254 UpdateTimeEnd: updateTimeEnd, 281 UpdateTimeEnd: updateTimeEnd,
255 CreateTimeBegin: createTimeBegin, 282 CreateTimeBegin: createTimeBegin,
256 CreateTimeEnd: createTimeEnd, 283 CreateTimeEnd: createTimeEnd,
  284 + SaleDateStart: saleDateBegin,
  285 + SaleDateEnd: saleDateEnd,
257 }) 286 })
258 if err != nil { 287 if err != nil {
259 c.ResponseError(err) 288 c.ResponseError(err)
260 return 289 return
261 } 290 }
262 - c.ResponsePageList(orderinfos, cnt, param.PageNumber) 291 + c.ResponsePageList(orderInfos, cnt, param.PageNumber)
263 return 292 return
264 } 293 }
265 294
@@ -332,6 +361,7 @@ func (c *OrderInfoController) GetOrderReal() { @@ -332,6 +361,7 @@ func (c *OrderInfoController) GetOrderReal() {
332 "product": allGoods, 361 "product": allGoods,
333 "create_time": orderinfo.CreateTime.Local().Format("2006-01-02 15:04:06"), 362 "create_time": orderinfo.CreateTime.Local().Format("2006-01-02 15:04:06"),
334 "update_time": orderinfo.UpdateTime.Local().Format("2006-01-02 15:04:06"), 363 "update_time": orderinfo.UpdateTime.Local().Format("2006-01-02 15:04:06"),
  364 + "sale_date": orderinfo.SaleDate.Local().Format("2006-01-02 15:04:06"),
335 "partnerCategoryId": orderinfo.PartnerCategory.Id, 365 "partnerCategoryId": orderinfo.PartnerCategory.Id,
336 "partnerCategoryName": orderinfo.PartnerCategory.Name, 366 "partnerCategoryName": orderinfo.PartnerCategory.Name,
337 } 367 }
@@ -862,7 +892,16 @@ func (c *OrderInfoController) ImportOrderFromExcel() { @@ -862,7 +892,16 @@ func (c *OrderInfoController) ImportOrderFromExcel() {
862 } 892 }
863 case 4: // TODO 销售日期格式和有效性校验 893 case 4: // TODO 销售日期格式和有效性校验
864 { 894 {
865 - 895 + regexpStr := `(\d{4})/(\d{2})/(\d{2})`
  896 + //cellStr := strings.TrimSpace(cell)
  897 + ok := regexp.MustCompile(regexpStr).MatchString(cell)
  898 + if !ok {
  899 + var tmpRow []string
  900 + tmpRow = append(tmpRow, "第"+r+"行第"+col+"列销售日期格式错误,请输入正确的销售日期") // 错误信息
  901 + tmpRow = append(tmpRow, r) // 行号
  902 + tmpRow = append(tmpRow, row...) // 错误行数据
  903 + myRow = tmpRow
  904 + }
866 } 905 }
867 case 7: // 合伙人类型校验(事业合伙、业务合伙、研发合伙、业务-产品应用合伙) 906 case 7: // 合伙人类型校验(事业合伙、业务合伙、研发合伙、业务-产品应用合伙)
868 { 907 {
@@ -1015,29 +1054,30 @@ func (c *OrderInfoController) ImportOrderFromExcel() { @@ -1015,29 +1054,30 @@ func (c *OrderInfoController) ImportOrderFromExcel() {
1015 var orderCommands = make(map[string]*orderCmd.CreateOrderCommand, 0) 1054 var orderCommands = make(map[string]*orderCmd.CreateOrderCommand, 0)
1016 for i, row := range rows { 1055 for i, row := range rows {
1017 if i > 2 && len(row) == constant.EXCEL_COLUMN { 1056 if i > 2 && len(row) == constant.EXCEL_COLUMN {
1018 - hashValue := md5.Sum([]byte(row[0] + row[1] + row[4] + row[6])) // 根据:订单号+发货单号+合伙人编号+合伙类型计算哈希值 1057 + hashValue := md5.Sum([]byte(row[0] + row[1] + row[5] + row[7])) // 根据:订单号+发货单号+合伙人编号+合伙类型计算哈希值
1019 hashString := hex.EncodeToString(hashValue[:]) 1058 hashString := hex.EncodeToString(hashValue[:])
1020 1059
1021 if _, ok := orderCommands[hashString]; !ok { 1060 if _, ok := orderCommands[hashString]; !ok {
1022 - //订单相关,0: 订单号, 1: 发货单号, 2: 客户名称, 3: 订单区域, 4: 编号, 5: 合伙人, 6: 类型, 7: 业务抽成比例,  
1023 - sbPercent, _ := strconv.ParseFloat(row[7], 64) //业务抽成比例 1061 + //订单相关,0: 订单号, 1: 发货单号, 2: 客户名称, 3: 订单区域, 4: 销售日期, 5: 编号, 6: 合伙人, 7: 类型, 8: 业务抽成比例,
  1062 + sbPercent, _ := strconv.ParseFloat(row[8], 64) //业务抽成比例
1024 1063
1025 - //产品相关,8: 产品名称, 9: 数量, 10: 单价, 11: 合伙人分红比例  
1026 - amount, _ := strconv.ParseInt(row[9], 10, 64) // 数量  
1027 - price, _ := strconv.ParseFloat(row[10], 64) // 单价  
1028 - percent, _ := strconv.ParseFloat(row[11], 64) // 合伙人分红比例 1064 + //产品相关,9: 产品名称, 10: 数量, 11: 单价, 12: 合伙人分红比例
  1065 + amount, _ := strconv.ParseInt(row[10], 10, 64) // 数量
  1066 + price, _ := strconv.ParseFloat(row[11], 64) // 单价
  1067 + percent, _ := strconv.ParseFloat(row[12], 64) // 合伙人分红比例
1029 1068
1030 // 获取partnerId 1069 // 获取partnerId
1031 var partnerInfo *domain.PartnerInfo 1070 var partnerInfo *domain.PartnerInfo
1032 1071
  1072 + // 5: 合伙人编号
1033 orderQueryData := orderQuery.GetPartnerIdQuery{ 1073 orderQueryData := orderQuery.GetPartnerIdQuery{
1034 - Code: row[4], 1074 + Code: row[5],
1035 PartnerCategory: 0, 1075 PartnerCategory: 0,
1036 CompanyId: companyId, 1076 CompanyId: companyId,
1037 } 1077 }
1038 1078
1039 - // 1: 事业合伙、2: 业务合伙、3: 研发合伙、4: 业务-产品应用合伙  
1040 - switch row[6] { 1079 + // 7: 合伙人类型 1: 事业合伙、2: 业务合伙、3: 研发合伙、4: 业务-产品应用合伙
  1080 + switch row[7] {
1041 case "事业合伙": 1081 case "事业合伙":
1042 orderQueryData.PartnerCategory = 1 1082 orderQueryData.PartnerCategory = 1
1043 case "业务合伙": 1083 case "业务合伙":
@@ -1050,6 +1090,9 @@ func (c *OrderInfoController) ImportOrderFromExcel() { @@ -1050,6 +1090,9 @@ func (c *OrderInfoController) ImportOrderFromExcel() {
1050 orderQueryData.PartnerCategory = 0 1090 orderQueryData.PartnerCategory = 0
1051 } 1091 }
1052 1092
  1093 + //TODO 销售日期时间格式转换
  1094 + timeValue, _ := time.Parse(row[4], "2015/02/08")
  1095 +
1053 // 初始化建订单命令集 1096 // 初始化建订单命令集
1054 orderCommands[hashString] = &orderCmd.CreateOrderCommand{ 1097 orderCommands[hashString] = &orderCmd.CreateOrderCommand{
1055 OrderType: 0, 1098 OrderType: 0,
@@ -1057,11 +1100,12 @@ func (c *OrderInfoController) ImportOrderFromExcel() { @@ -1057,11 +1100,12 @@ func (c *OrderInfoController) ImportOrderFromExcel() {
1057 DeliveryCode: row[1], 1100 DeliveryCode: row[1],
1058 BuyerName: row[2], 1101 BuyerName: row[2],
1059 OrderRegion: row[3], 1102 OrderRegion: row[3],
  1103 + SaleDate: timeValue,
1060 PartnerId: 0, // 根据合伙人类型+合伙人编号查找合伙人id 1104 PartnerId: 0, // 根据合伙人类型+合伙人编号查找合伙人id
1061 SalesmanBonusPercent: sbPercent, 1105 SalesmanBonusPercent: sbPercent,
1062 Goods: []orderCmd.OrderGoodData{ 1106 Goods: []orderCmd.OrderGoodData{
1063 { 1107 {
1064 - GoodName: row[8], 1108 + GoodName: row[9],
1065 PlanGoodNumber: int(amount), 1109 PlanGoodNumber: int(amount),
1066 Price: price, 1110 Price: price,
1067 PartnerBonusPercent: percent, 1111 PartnerBonusPercent: percent,
@@ -1086,14 +1130,14 @@ func (c *OrderInfoController) ImportOrderFromExcel() { @@ -1086,14 +1130,14 @@ func (c *OrderInfoController) ImportOrderFromExcel() {
1086 orderCommands[hashString].PartnerId = partnerInfo.Partner.Id 1130 orderCommands[hashString].PartnerId = partnerInfo.Partner.Id
1087 } 1131 }
1088 } else { 1132 } else {
1089 - //产品相关,8: 产品名称, 9: 数量, 10: 单价, 11: 合伙人分红比例  
1090 - amount, _ := strconv.ParseInt(row[9], 10, 64) // 数量  
1091 - price, _ := strconv.ParseFloat(row[10], 64) // 单价  
1092 - percent, _ := strconv.ParseFloat(row[11], 64) // 合伙人分红比例 1133 + //产品相关,9: 产品名称, 10: 数量, 11: 单价, 12: 合伙人分红比例
  1134 + amount, _ := strconv.ParseInt(row[10], 10, 64) // 数量
  1135 + price, _ := strconv.ParseFloat(row[11], 64) // 单价
  1136 + percent, _ := strconv.ParseFloat(row[12], 64) // 合伙人分红比例
1093 1137
1094 // 记录同一笔订单产品 1138 // 记录同一笔订单产品
1095 orderCommands[hashString].Goods = append(orderCommands[hashString].Goods, orderCmd.OrderGoodData{ 1139 orderCommands[hashString].Goods = append(orderCommands[hashString].Goods, orderCmd.OrderGoodData{
1096 - GoodName: row[8], 1140 + GoodName: row[9],
1097 PlanGoodNumber: int(amount), 1141 PlanGoodNumber: int(amount),
1098 Price: price, 1142 Price: price,
1099 PartnerBonusPercent: percent, 1143 PartnerBonusPercent: percent,