作者 唐旭辉

Merge branch 'dev' into 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
... ...
... ... @@ -83,7 +83,7 @@ spec:
- name: UCENTER_CHECK_ALT
value: "6DwjBO735"
- name: BUSINESS_ADMIN_HOST
value: "http://suplus-business-admin-dev.fjmaimaimai.com"
value: "https://suplus-business-admin-dev.fjmaimaimai.com"
- name: KAFKA_HOST
value: ""
- name: KAFKA_CONSUMER_ID
... ...
... ... @@ -80,7 +80,7 @@ spec:
- name: UCENTER_CHECK_ALT
value: "rsF0pL!6DwjBO735"
- name: BUSINESS_ADMIN_HOST
value: "http://suplus-business-admin-prd.fjmaimaimai.com"
value: "https://suplus-business-admin-prd.fjmaimaimai.com"
- name: KAFKA_HOST
value: "192.168.0.250:9092;192.168.0.251:9092;192.168.0.252:9092"
- name: KAFKA_CONSUMER_ID
... ...
... ... @@ -80,7 +80,7 @@ spec:
- name: UCENTER_CHECK_ALT
value: "rsF0pL!6DwjBO735"
- name: BUSINESS_ADMIN_HOST
value: "http://suplus-business-admin-test.fjmaimaimai.com"
value: "https://suplus-business-admin-test.fjmaimaimai.com"
- name: KAFKA_HOST
value: "192.168.0.250:9092;192.168.0.251:9092;192.168.0.252:9092"
- name: KAFKA_CONSUMER_ID
... ...
... ... @@ -142,7 +142,10 @@ func (columnSettingService *ColumnSettingService) ListColumnSetting(listColumnSe
} else {
columnSettingRepository = value
}
if count, columnSettings, err := columnSettingRepository.Find(tool_funs.SimpleStructToMap(listColumnSettingQuery)); err != nil {
if count, columnSettings, err := columnSettingRepository.Find(domain.ColumnSettingFindQuery{
Offset: listColumnSettingQuery.Offset,
Limit: listColumnSettingQuery.Limit,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
if err := transactionContext.CommitTransaction(); err != nil {
... ...
/**
@author: stevechan
@date: 2021/2/2
@note:
**/
package query
type ListOrderBonusForExcelQuery struct {
Type string `json:"type"` // 操作类型 ORDER_BASE
Where BonusWhere `json:"where"` // 导出条件
IDS []int `json:"ids"` // 勾选id
}
type BonusWhere struct {
SearchWord string `json:"searchWord"`
OrderType int `json:"orderType"`
PageSize int `json:"pageSize"`
PageNumber int `json:"pageNumber"`
PartnerCategoryId int `json:"partnerCategoryId"`
CreateTime []string `json:"createTime"`
}
... ...
... ... @@ -1004,8 +1004,8 @@ func (service OrderInfoService) ListOrderForExcel(listOrderQuery query.ListOrder
"orderId": ordersData[i].OrderCode,
"shipmentsId": ordersData[i].DeliveryCode,
"partner": ordersData[i].PartnerName,
"update_time": ordersData[i].UpdateTime,
"create_time": ordersData[i].CreateTime,
"updateTime": ordersData[i].UpdateTime,
"createTime": ordersData[i].CreateTime,
"saleDate": t.Format("2006-01-02"),
"orderNum": fmt.Sprint(ordersData[i].PlanOrderCount),
"quantityControl": "",
... ...
... ... @@ -2,6 +2,7 @@ package service
import (
"fmt"
"gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/infrastructure/utils"
"github.com/linmadan/egglib-go/core/application"
"gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/application/factory"
... ... @@ -238,7 +239,7 @@ func (PartnerInfoService *PartnerInfoService) GetPartnerInfo(q query.GetPartnerI
/**
* @Author SteveChan
* @Description // 更新合伙人
* @Description //TODO 更新合伙人,判断合伙类型是否有业务数据
* @Date 00:07 2020/12/30
* @Param
* @return
... ... @@ -261,7 +262,9 @@ func (PartnerInfoService *PartnerInfoService) UpdatePartnerInfo(cmd *command.Upd
var (
partnerInfoRepository domain.PartnerInfoRepository
categoryRepository domain.PartnerCategoryRepository
orderBaseRepository domain.OrderBaseRepository
categories []domain.PartnerCategory
orders []domain.OrderBase
partnerInfoDao *dao.PartnerInfoDao
)
... ... @@ -283,6 +286,12 @@ func (PartnerInfoService *PartnerInfoService) UpdatePartnerInfo(cmd *command.Upd
return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error())
}
if orderBaseRepository, err = factory.CreateOrderBaseRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error())
}
// 获取合伙人类型
var categoryMap = make(map[int64]string)
_, categories, err = categoryRepository.Find(domain.PartnerCategoryFindQuery{
... ... @@ -349,6 +358,34 @@ func (PartnerInfoService *PartnerInfoService) UpdatePartnerInfo(cmd *command.Upd
return lib.ThrowError(lib.BUSINESS_ERROR, "异常操作")
}
partnerCategoryInfos := partnerInfo.PartnerCategoryInfos
//判断相应合伙类型下是否有订单数据
var notInPartnerCategoryInfos []int64
var categoryIdsQuery []int64
var categoryIdsCmd []int64
for _, partnerCategory := range partnerCategoryInfos {
categoryIdsQuery = append(categoryIdsQuery, partnerCategory.Id)
}
for _, category := range categories {
categoryIdsCmd = append(categoryIdsCmd, category.Id)
}
for _, v := range categoryIdsQuery {
if !utils.IsContainInt(categoryIdsCmd, v) {
notInPartnerCategoryInfos = append(notInPartnerCategoryInfos, v)
}
}
if len(notInPartnerCategoryInfos) > 0 {
orders, _, err = orderBaseRepository.Find(domain.OrderBaseFindQuery{
PartnerId: cmd.Id,
CompanyId: cmd.CompanyId,
PartnerCategoryIds: notInPartnerCategoryInfos,
})
if len(orders) > 0 {
return lib.ThrowError(lib.BUSINESS_ERROR, "该合伙类型下有业务数据,不可删除!")
}
}
partnerInfo.Partner.PartnerName = cmd.PartnerName
partnerInfo.Salesman = cmd.Salesman
partnerInfo.Status = cmd.Status
... ... @@ -372,7 +409,7 @@ func (PartnerInfoService *PartnerInfoService) UpdatePartnerInfo(cmd *command.Upd
// e := fmt.Sprintf("更新业务分红(partner_id=%d)数据失败:%s", partnerInfo.Partner.Id, err)
// return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, e)
// }
transactionContext.CommitTransaction()
_ = transactionContext.CommitTransaction()
return
}
... ...
... ... @@ -4,6 +4,7 @@ import (
"encoding/json"
"errors"
"fmt"
"gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/constant"
"time"
"github.com/astaxie/beego/logs"
... ... @@ -99,8 +100,9 @@ func (service SyncCompanyService) addCompany(data CompanytData) error {
transactionContext.RollbackTransaction()
}()
var (
companyRespository domain.CompanyRepository
userRespository domain.UsersRepository
companyRespository domain.CompanyRepository
userRespository domain.UsersRepository
columnSettingRepository domain.ColumnSettingRepository
)
if companyRespository, err = factory.CreateCompanyRepository(map[string]interface{}{
"transactionContext": transactionContext,
... ... @@ -112,6 +114,11 @@ func (service SyncCompanyService) addCompany(data CompanytData) error {
}); err != nil {
return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error())
}
if columnSettingRepository, err = factory.CreateColumnSettingRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error())
}
applets := []domain.CompanyApplets{}
for _, v := range data.Company.Applets {
app := domain.CompanyApplets{
... ... @@ -163,6 +170,21 @@ func (service SyncCompanyService) addCompany(data CompanytData) error {
if err != nil {
return fmt.Errorf("添加用户数据失败,%s", err)
}
// 初始化栏目设置
newColumnSetting := &domain.ColumnSetting{
Description: "订单管理栏目设置",
UserName: data.User.Name,
CompanyId: int(data.User.CompanyId),
Uid: data.User.Id,
Key: constant.ORDER_BASE, // 订单栏目模块名称
Value: domain.DefaultColumns, // 栏目值数组,创建用户时使用默认栏目设置
InvalidValue: domain.DefaultInvalidColumns, // 初始化无效栏目数组
CreatedAt: time.Now(),
UpdatedAt: time.Now(),
}
if _, err = columnSettingRepository.Save(newColumnSetting); err != nil {
return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error())
}
err = transactionContext.CommitTransaction()
return nil
}
... ...
... ... @@ -88,7 +88,7 @@ var _ SyncAction = (*SyncEmployeeService)(nil)
/**
* @Author SteveChan
* @Description //TODO 新增、导入用户初始化栏目设置
* @Description //新增、导入用户初始化栏目设置
* @Date 23:54 2021/1/26
* @Param
* @return
... ... @@ -263,6 +263,12 @@ func (service SyncEmployeeService) updateEmployeeData(datas []EmployeeData) erro
}); err != nil {
return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error())
}
var columnSettingRepository domain.ColumnSettingRepository
if columnSettingRepository, err = factory.CreateColumnSettingRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error())
}
for i := range datas {
data := datas[i]
var (
... ... @@ -302,6 +308,21 @@ func (service SyncEmployeeService) updateEmployeeData(datas []EmployeeData) erro
if err = usersRepository.Add(&newUser); err != nil {
return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error())
}
// 添加用户数据时初始化栏目设置
newColumnSetting := &domain.ColumnSetting{
Description: "订单管理栏目设置",
UserName: data.Name,
CompanyId: int(data.CompanyId),
Uid: data.Id,
Key: constant.ORDER_BASE, // 订单栏目模块名称
Value: domain.DefaultColumns, // 栏目值数组,创建用户时使用默认栏目设置
InvalidValue: domain.DefaultInvalidColumns, // 初始化无效栏目数组
CreatedAt: time.Now(),
UpdatedAt: time.Now(),
}
if _, err = columnSettingRepository.Save(newColumnSetting); err != nil {
return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error())
}
continue
} else {
entryTime, _ := time.Parse("2006-01-02", data.EntryTime)
... ... @@ -352,7 +373,7 @@ func (service SyncEmployeeService) deleteEmployeeData(data DeleteUserData) error
if err = usersRepository.Remove(data.Ids); err != nil {
return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error())
}
// TODO 删除栏目设置
// 删除栏目设置
var columnSettingRepository domain.ColumnSettingRepository
if value, errFac := factory.CreateColumnSettingRepository(map[string]interface{}{
"transactionContext": transactionContext,
... ... @@ -361,7 +382,14 @@ func (service SyncEmployeeService) deleteEmployeeData(data DeleteUserData) error
} else {
columnSettingRepository = value
}
_, columnSettingsFound, err := columnSettingRepository.Find(map[string]interface{}{"ids": data.Ids, "companyId": data.CompanyId})
var ids []int64
for _, d := range data.Ids {
ids = append(ids, d)
}
_, columnSettingsFound, err := columnSettingRepository.Find(domain.ColumnSettingFindQuery{
Ids: ids,
CompanyId: int(data.CompanyId),
})
if err != nil {
return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error())
}
... ...
... ... @@ -92,11 +92,20 @@ type ColumnSetting struct {
InvalidValue []Column `json:"invalidValue"`
}
type ColumnSettingFindQuery struct {
Ids []int64
Uid int64
CompanyId int
Offset int
Limit int
}
type ColumnSettingRepository interface {
Save(columnSetting *ColumnSetting) (*ColumnSetting, error)
Remove(columnSetting *ColumnSetting, columnSettings []*ColumnSetting) (*ColumnSetting, []*ColumnSetting, error)
FindOne(queryOptions map[string]interface{}) (*ColumnSetting, error)
Find(queryOptions map[string]interface{}) (int64, []*ColumnSetting, error)
//Find(queryOptions map[string]interface{}) (int64, []*ColumnSetting, error)
Find(queryOptions ColumnSettingFindQuery) (int64, []*ColumnSetting, error)
}
func (columnSetting *ColumnSetting) Identify() interface{} {
... ...
... ... @@ -308,13 +308,14 @@ type OrderBaseFindOneQuery struct {
}
type OrderBaseFindQuery struct {
PartnerId int64
OrderCode string
DeliveryCode string
Offset int
Limit int
OrderType int
CompanyId int64
PartnerId int64
OrderCode string
DeliveryCode string
Offset int
Limit int
OrderType int
CompanyId int64
PartnerCategoryIds []int64
}
// 导入错误信息
... ...
... ... @@ -325,7 +325,8 @@ func (dao OrderBaseDao) OrderListForExcel(companyId int64, partnerName string, o
sqlstr += ` AND t1.partner_category@>'{"id":?}' `
}
if len(partnerCategoryName) > 0 {
params = append(params, partnerCategoryName)
like := "%" + partnerCategoryName + "%"
params = append(params, like)
sqlstr += ` AND t1.partner_category->> 'name' like ?`
}
if len(updateTime[0]) > 0 {
... ...
... ... @@ -2,7 +2,7 @@ package repository
import (
"fmt"
"github.com/go-pg/pg"
"github.com/go-pg/pg/v10"
"gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/domain"
"gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/infrastructure/pg/models"
... ... @@ -38,23 +38,7 @@ func (repository *ColumnSettingRepository) Save(columnSetting *domain.ColumnSett
if err != nil {
return nil, err
}
//_, err := repository.nextIdentify()
//if err != nil {
// return columnSetting, err
//}
//if _, errInsert := tx.QueryOne(
// pg.Scan(&columnSetting.Id, &columnSetting.CompanyId, &columnSetting.CreatedAt, &columnSetting.Description, &columnSetting.Key, &columnSetting.Uid, &columnSetting.UpdatedAt, &columnSetting.UserName, pg.Array(&columnSetting.Value), pg.Array(&columnSetting.InvalidValue)),
// "INSERT INTO column_settings (company_id, created_at, description, key, uid, updated_at, user_name, value, invalid_value) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING id, company_id, created_at, description, key, uid, updated_at, user_name, value, invalid_value",
// columnSetting.CompanyId, columnSetting.CreatedAt, columnSetting.Description, columnSetting.Key, columnSetting.Uid, columnSetting.UpdatedAt, columnSetting.UserName, pg.Array(columnSetting.Value), pg.Array(columnSetting.InvalidValue)); errInsert != nil {
// return columnSetting, errInsert
//}
} else {
//if _, errUpdate := tx.QueryOne(
// pg.Scan(&columnSetting.Id, &columnSetting.CompanyId, &columnSetting.CreatedAt, &columnSetting.Description, &columnSetting.Key, &columnSetting.Uid, &columnSetting.UpdatedAt, &columnSetting.UserName, pg.Array(&columnSetting.Value), pg.Array(&columnSetting.InvalidValue)),
// "UPDATE column_settings SET company_id=?, created_at=?, description=?, key=?, uid=?, updated_at=?, user_name=?, value=?, invalid_value=? WHERE id=? RETURNING id, company_id, created_at, description, key, uid, updated_at, user_name, value, invalid_value",
// columnSetting.CompanyId, columnSetting.CreatedAt, columnSetting.Description, columnSetting.Key, columnSetting.Uid, columnSetting.UpdatedAt, columnSetting.UserName, pg.Array(columnSetting.Value), pg.Array(columnSetting.InvalidValue), columnSetting.Identify()); errUpdate != nil {
// return columnSetting, errUpdate
//}
_, err := tx.Model(columnSettingModel).WherePK().
Column("company_id", "created_at", "description", "key", "uid", "updated_at", "user_name", "value", "invalid_value").Update()
if err != nil {
... ... @@ -67,27 +51,26 @@ func (repository *ColumnSettingRepository) Save(columnSetting *domain.ColumnSett
func (repository *ColumnSettingRepository) Remove(columnSetting *domain.ColumnSetting, columnSettings []*domain.ColumnSetting) (*domain.ColumnSetting, []*domain.ColumnSetting, error) {
tx := repository.transactionContext.PgTx
// 单个删除
if columnSetting != nil {
// 单个删除
columnSettingModel := new(models.ColumnSetting)
columnSettingModel.Id = columnSetting.Identify().(int64)
if _, err := tx.Model(columnSettingModel).WherePK().Delete(); err != nil {
if _, err := tx.Model(&columnSettingModel).WherePK().Delete(); err != nil {
return columnSetting, nil, err
}
}
// 批量删除
if len(columnSettings) > 0 {
var columnSettingModels []*models.ColumnSetting
var ids []int64
for _, setting := range columnSettings {
columnSettingModels = append(columnSettingModels, &models.ColumnSetting{
Id: setting.Identify().(int64),
})
ids = append(ids, setting.Identify().(int64))
}
if _, err := tx.Model(columnSettingModels).WherePK().Delete(); err != nil {
if _, err := tx.Model((*models.ColumnSetting)(nil)).Where("id IN (?)", pg.In(ids)).Delete(); err != nil {
return nil, columnSettings, err
}
}
return columnSetting, columnSettings, nil
}
... ... @@ -118,33 +101,25 @@ func (repository *ColumnSettingRepository) FindOne(queryOptions map[string]inter
}
}
func (repository *ColumnSettingRepository) Find(queryOptions map[string]interface{}) (int64, []*domain.ColumnSetting, error) {
func (repository *ColumnSettingRepository) Find(queryOptions domain.ColumnSettingFindQuery) (int64, []*domain.ColumnSetting, error) {
tx := repository.transactionContext.PgTx
var columnSettingModels []*models.ColumnSetting
var columnSettingModels []models.ColumnSetting
columnSettings := make([]*domain.ColumnSetting, 0)
query := tx.Model(&columnSettingModels)
if ids, ok := queryOptions["ids"]; ok {
query = query.Where("column_setting.uid IN (?)", pg.In(ids.([]int64)))
if len(queryOptions.Ids) > 0 {
query = query.Where("column_setting.uid IN (?)", pg.In(queryOptions.Ids))
}
if uid, ok := queryOptions["uid"]; ok {
query = query.Where("column_setting.uid = ?", uid)
if queryOptions.Uid > 0 {
query = query.Where("column_setting.uid = ?", queryOptions.Uid)
}
if companyId, ok := queryOptions["companyId"]; ok {
query = query.Where("column_setting.company_id = ?", companyId)
if queryOptions.CompanyId > 0 {
query = query.Where("column_setting.company_id = ?", queryOptions.CompanyId)
}
if offset, ok := queryOptions["offset"]; ok {
queryOffset := offset.(int)
if queryOffset > -1 {
query = query.Offset(queryOffset)
}
} else {
query = query.Offset(0)
if queryOptions.Offset > -1 {
query = query.Offset(queryOptions.Offset)
}
if limit, ok := queryOptions["limit"]; ok {
queryLimit := limit.(int)
if queryLimit > -1 {
query = query.Limit(queryLimit)
}
if queryOptions.Limit > 0 {
query = query.Limit(queryOptions.Limit)
} else {
query = query.Limit(20)
}
... ... @@ -152,7 +127,7 @@ func (repository *ColumnSettingRepository) Find(queryOptions map[string]interfac
return 0, columnSettings, err
} else {
for _, columnSettingModel := range columnSettingModels {
if columnSetting, errTrans := repository.transformPgModelToDomainModel(columnSettingModel); errTrans != nil {
if columnSetting, errTrans := repository.transformPgModelToDomainModel(&columnSettingModel); errTrans != nil {
return 0, columnSettings, errTrans
} else {
columnSettings = append(columnSettings, columnSetting)
... ...
... ... @@ -2,6 +2,7 @@ package repository
import (
"fmt"
"github.com/go-pg/pg/v10"
"gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/domain"
"gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/infrastructure/pg/models"
... ... @@ -84,9 +85,6 @@ func (repository OrderBaseRepository) Save(orderInfo *domain.OrderBase) error {
Remark: orderInfo.Remark,
PartnerCategory: orderInfo.PartnerCategory,
}
//if m.OrderType > 2 { // TODO 非平台自建订单,默认销售日期取订单创建日期
// m.SaleDate = orderInfo.CreateTime
//}
if m.Id == 0 {
_, err = tx.Model(m).
Returning("*").
... ... @@ -124,6 +122,9 @@ func (repository OrderBaseRepository) Find(queryOption domain.OrderBaseFindQuery
if queryOption.CompanyId > 0 {
query = query.Where("company_id=?", queryOption.CompanyId)
}
if len(queryOption.PartnerCategoryIds) > 0 {
query = query.Where(`(order_base.partner_category->>'id')::int IN (?)`, pg.In(queryOption.PartnerCategoryIds))
}
if queryOption.Offset > -1 {
query = query.Offset(queryOption.Offset)
}
... ...
... ... @@ -47,3 +47,19 @@ func IsContain(items []string, item string) bool {
}
return false
}
/**
* @Author SteveChan
* @Description //TODO
* @Date 23:34 2021/2/2
* @Param
* @return
**/
func IsContainInt(items []int64, item int64) bool {
for _, eachItem := range items {
if eachItem == item {
return true
}
}
return false
}
... ...
... ... @@ -23,7 +23,7 @@ func (controller *ColumnSettingController) Prepare() {
if ok := controller.ValidJWTToken(); !ok {
return
}
if ok := controller.ValidAdminPermission(domain.PERMINSSION_PARTNER); !ok {
if ok := controller.ValidAdminPermission(domain.PERMISSION_ORDER); !ok {
return
}
}
... ... @@ -54,7 +54,7 @@ func (controller *ColumnSettingController) CreateColumnSetting() {
/**
* @Author SteveChan
* @Description // 更新栏目设置
* @Description 更新栏目设置
* @Date 22:52 2021/1/26
* @Param
* @return
... ...
... ... @@ -292,16 +292,18 @@ func (c *OrderDividendController) EditOrderRemarkBonus() {
}
func (c *OrderDividendController) ListOrderBonusForExcel() {
type Parameter struct {
SearchWord string `json:"searchWord"`
OrderType int `json:"orderType"`
PageSize int `json:"pageSize"`
PageNumber int `json:"pageNumber"`
PartnerCategoryId int `json:"partnerCategoryId"`
CreateTime []string `json:"createTime"`
}
//type Parameter struct {
// SearchWord string `json:"searchWord"`
// OrderType int `json:"orderType"`
// PageSize int `json:"pageSize"`
// PageNumber int `json:"pageNumber"`
// PartnerCategoryId int `json:"partnerCategoryId"`
// CreateTime []string `json:"createTime"`
//}
var (
param Parameter
//param Parameter
param orderQuery.ListOrderBonusForExcelQuery
err error
)
if err = c.BindJsonData(&param); err != nil {
... ... @@ -309,9 +311,14 @@ func (c *OrderDividendController) ListOrderBonusForExcel() {
c.ResponseError(errors.New("json数据解析失败"))
return
}
if !(param.OrderType == 0 ||
param.OrderType == domain.OrderReal ||
param.OrderType == domain.OrderTypeBestShop) {
if param.Type != "ORDER_DIVIDEND" {
logs.Error(err)
c.ResponseError(errors.New("错误的操作类型"))
return
}
if !(param.Where.OrderType == 0 ||
param.Where.OrderType == domain.OrderReal ||
param.Where.OrderType == domain.OrderTypeBestShop) {
c.ResponseError(errors.New("参数异常"))
return
}
... ... @@ -319,9 +326,9 @@ func (c *OrderDividendController) ListOrderBonusForExcel() {
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
... ... @@ -329,9 +336,9 @@ func (c *OrderDividendController) ListOrderBonusForExcel() {
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
... ... @@ -345,10 +352,10 @@ func (c *OrderDividendController) ListOrderBonusForExcel() {
orderSrv := orderService.NewOrderInfoService(nil)
dataResult, column, err := orderSrv.ListOrderBonusForExcel(
orderQuery.ListOrderBonusQuery{
OrderType: param.OrderType,
PartnerOrCode: param.SearchWord,
OrderType: param.Where.OrderType,
PartnerOrCode: param.Where.SearchWord,
CompanyId: companyId,
PartnerCategory: param.PartnerCategoryId,
PartnerCategory: param.Where.PartnerCategoryId,
CreateTimeBegin: createTimeBegin,
CreateTimeEnd: createTimeEnd,
})
... ...
... ... @@ -1146,12 +1146,15 @@ func (c *OrderInfoController) ImportOrderFromExcel() {
// 销售日期时间格式转换
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
var tmpRow []string
tmpRow = append(tmpRow, "无效的销售日期") // 错误信息
s := strconv.Itoa(i + 1)
tmpRow = append(tmpRow, s) // 行号
tmpRow = append(tmpRow, row...) // 错误行数据
partnerDataList = append(partnerDataList, tmpRow)
break
}
//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")
... ...
不能预览此文件类型