作者 yangfu

Merge branch 'dev' of http://gitlab.fjmaimaimai.com/allied-creation/allied-creat…

…ion-cooperation into dev
... ... @@ -297,7 +297,7 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD
}
// 必填项校验
nullCellError := make([]interface{}, 0)
nullCellError := make([]*domain.FailInfo, 0)
// 数据行计数
rowCnt := 0
... ... @@ -308,7 +308,6 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD
for i, dividendsOrder := range importDividendsOrderCommand.DividendsOrderData {
rowCnt++
nullCell := make([]interface{}, 0)
//var myRow []string
t := reflect.TypeOf(dividendsOrder)
v := reflect.ValueOf(dividendsOrder)
for k := 0; k < t.NumField(); k++ {
... ... @@ -323,7 +322,7 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD
}
if nullFlag {
myRow := &domain.FailInfo{
FailReason: "订单日期格式错误,请输入正确的订单日期",
FailReason: "必填项为空",
}
myRow.ImportDividendsOrderData = &importDividendsOrderCommand.DividendsOrderData[i]
nullCellError = append(nullCellError, myRow)
... ... @@ -459,7 +458,6 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD
// 订单日期时间格式转换
timeValue, err := time.ParseInLocation("2006/01/02", dividendsOrder.OrderTime, time.Local)
if err != nil {
//s := strconv.Itoa(i + 1)
tmpRow := &domain.FailInfo{
FailReason: "无效的订单日期",
}
... ... @@ -477,9 +475,13 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD
if err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
expense, err := strconv.ParseFloat(dividendsOrder.Expense, 64)
if err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
var expense float64
if dividendsOrder.Expense != "" {
if expenseParse, err := strconv.ParseFloat(dividendsOrder.Expense, 64); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
} else {
expense = expenseParse
}
}
// 初始化新建分红订单命令集
... ... @@ -518,9 +520,13 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD
if err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
expense, err := strconv.ParseFloat(dividendsOrder.Expense, 64)
if err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
var expense float64
if dividendsOrder.Expense != "" {
if expenseParse, err := strconv.ParseFloat(dividendsOrder.Expense, 64); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
} else {
expense = expenseParse
}
}
dividendsOrderCommands[hashString].OrderGoods = append(dividendsOrderCommands[hashString].OrderGoods, command.OrderGoods{
... ...
... ... @@ -16,7 +16,6 @@ import (
"reflect"
"regexp"
"strconv"
"strings"
"time"
)
... ... @@ -347,7 +346,7 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide
for i, dividendsReturnedOrder := range importDividendsReturnedOrderCommand.DividendsReturnedOrderData {
rowCnt++
nullCell := make([]interface{}, 0)
var myRow []string
var myRow *domain.FailReturnedInfo
t := reflect.TypeOf(dividendsReturnedOrder)
v := reflect.ValueOf(dividendsReturnedOrder)
for k := 0; k < t.NumField(); k++ {
... ... @@ -361,11 +360,12 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide
}
}
if nullFlag {
s := strconv.Itoa(i + 1)
b := strings.Replace(strings.Trim(fmt.Sprint(nullCell), "[]"), " ", ",", -1)
myRow = append(myRow, "第"+s+"行的第"+b+"列必填项为空") // 错误信息
myRow = append(myRow, s) // 行号
myRow = append(myRow, fmt.Sprintf("%v", v.Interface())) // 错误行数据
//s := strconv.Itoa(i + 1)
//b := strings.Replace(strings.Trim(fmt.Sprint(nullCell), "[]"), " ", ",", -1)
myRow = &domain.FailReturnedInfo{
FailReason: "必填项为空",
ImportDividendsReturnedOrderData: &importDividendsReturnedOrderCommand.DividendsReturnedOrderData[i],
}
nullCellError = append(nullCellError, myRow)
nullFlag = false
}
... ... @@ -384,24 +384,22 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide
// 单元格类型校验
typeError := make([]interface{}, 0)
for i, dividendsReturnedOrder := range importDividendsReturnedOrderCommand.DividendsReturnedOrderData { // 行
var myRow []string
for _, dividendsReturnedOrder := range importDividendsReturnedOrderCommand.DividendsReturnedOrderData { // 行
var myRow *domain.FailReturnedInfo
t := reflect.TypeOf(dividendsReturnedOrder)
v := reflect.ValueOf(dividendsReturnedOrder)
for k := 0; k < t.NumField(); k++ { // 列
r := strconv.Itoa(i + 1)
col := strconv.Itoa(k + 1)
switch k {
case 3: // 退货日期校验
{
regexpStr := `(\d{4})/(\d{2})/(\d{2})`
ok := regexp.MustCompile(regexpStr).MatchString(fmt.Sprintf("%v", v.Field(k).Interface()))
if !ok {
var tmpRow []string
tmpRow = append(tmpRow, "第"+r+"行第"+col+"列退货日期格式错误,请输入正确的退货日期") // 错误信息
tmpRow = append(tmpRow, r) // 行号
tmpRow = append(tmpRow, fmt.Sprintf("%v", v.Interface())) // 错误行数据
var tmpRow *domain.FailReturnedInfo
tmpRow = &domain.FailReturnedInfo{
FailReason: "退货日期格式错误,请输入正确的退货日期",
ImportDividendsReturnedOrderData: &dividendsReturnedOrder,
}
myRow = tmpRow
}
}
... ... @@ -410,10 +408,11 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide
regexpStr := `(\d{4})/(\d{2})/(\d{2})`
ok := regexp.MustCompile(regexpStr).MatchString(fmt.Sprintf("%v", v.Field(k).Interface()))
if !ok {
var tmpRow []string
tmpRow = append(tmpRow, "第"+r+"行第"+col+"列订单日期格式错误,请输入正确的订单日期") // 错误信息
tmpRow = append(tmpRow, r) // 行号
tmpRow = append(tmpRow, fmt.Sprintf("%v", v.Interface())) // 错误行数据
var tmpRow *domain.FailReturnedInfo
tmpRow = &domain.FailReturnedInfo{
FailReason: "订单日期格式错误,请输入正确的订单日期",
ImportDividendsReturnedOrderData: &dividendsReturnedOrder,
}
myRow = tmpRow
}
}
... ... @@ -422,18 +421,20 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide
//参数类型转换
orderGoodQuantity, err := strconv.ParseInt(fmt.Sprintf("%v", v.Field(k).Interface()), 10, 64)
if err != nil {
var tmpRow []string
tmpRow = append(tmpRow, "第"+r+"行第"+col+"列退货数量格式错误,退货数量必须整数") // 错误信息
tmpRow = append(tmpRow, r) // 行号
tmpRow = append(tmpRow, fmt.Sprintf("%v", v.Interface())) // 错误行数据
var tmpRow *domain.FailReturnedInfo
tmpRow = &domain.FailReturnedInfo{
FailReason: "退货数量格式错误,退货数量必须整数",
ImportDividendsReturnedOrderData: &dividendsReturnedOrder,
}
myRow = tmpRow
}
// 正负判断
if orderGoodQuantity < 0 {
var tmpRow []string
tmpRow = append(tmpRow, "第"+r+"行第"+col+"列退货数量必须大于0,请重新填写") // 错误信息
tmpRow = append(tmpRow, r) // 行号
tmpRow = append(tmpRow, fmt.Sprintf("%v", v.Interface())) // 错误行数据
var tmpRow *domain.FailReturnedInfo
tmpRow = &domain.FailReturnedInfo{
FailReason: "退货数量必须大于0,请重新填写",
ImportDividendsReturnedOrderData: &dividendsReturnedOrder,
}
myRow = tmpRow
}
}
... ... @@ -442,19 +443,21 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide
// 参数类型转换
univalent, typeErr := strconv.ParseFloat(fmt.Sprintf("%v", v.Field(k).Interface()), 64)
if typeErr != nil {
var tmpRow []string
tmpRow = append(tmpRow, "第"+r+"行第"+col+"列退货价格格式错误,退货价格必须为数字类型") // 错误信息
tmpRow = append(tmpRow, r) // 行号
tmpRow = append(tmpRow, fmt.Sprintf("%v", v.Interface())) // 错误行数据
var tmpRow *domain.FailReturnedInfo
tmpRow = &domain.FailReturnedInfo{
FailReason: "退货价格格式错误,退货价格必须为数字类型",
ImportDividendsReturnedOrderData: &dividendsReturnedOrder,
}
myRow = tmpRow
}
// 长度校验
if univalent >= 1e16 {
var tmpRow []string
tmpRow = append(tmpRow, "第"+r+"行第"+col+"列退货价格超过最大限制,退货价格小数点前面不能超过十六位数字,并保留两位小数") // 错误信息
tmpRow = append(tmpRow, r) // 行号
tmpRow = append(tmpRow, fmt.Sprintf("%v", v.Interface())) // 错误行数据
var tmpRow *domain.FailReturnedInfo
tmpRow = &domain.FailReturnedInfo{
FailReason: "退货价格超过最大限制,退货价格小数点前面不能超过十六位数字,并保留两位小数",
ImportDividendsReturnedOrderData: &dividendsReturnedOrder,
}
myRow = tmpRow
}
}
... ...
... ... @@ -61,15 +61,6 @@ type ImportInfo struct {
// FailInfo 返回的失败信息
type FailInfo struct {
FailReason string `json:"failReason"`
//OriginalOrderNum string `json:"originalOrderNum"`
//DividendsCustomerName string `json:"dividendsCustomerName"`
//OrderGoodName string `json:"orderGoodName"`
//OrderTime string `json:"orderTime"`
//RegionName string `json:"regionName"`
//OrderGoodQuantity string `json:"orderGoodQuantity"`
//OrderGoodPrice string `json:"orderGoodPrice"`
//Expense string `json:"expense"`
//CooperationContractNumber string `json:"cooperationContractNumber"`
*command.ImportDividendsOrderData
}
... ...
package domain
import "time"
import (
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/dividendsReturnedOrder/command"
"time"
)
// DividendsReturnedOrder 分红退货单实体
type DividendsReturnedOrder struct {
... ... @@ -46,6 +49,12 @@ type DividendsReturnedOrder struct {
OperateTime time.Time `json:"operateTime"`
}
// FailReturnedInfo 返回的失败信息
type FailReturnedInfo struct {
FailReason string `json:"failReason"`
*command.ImportDividendsReturnedOrderData
}
type DividendsReturnedOrderRepository interface {
Save(dividendsReturnedOrder *DividendsReturnedOrder) (*DividendsReturnedOrder, error)
UpdateMany(dividendsReturnedOrder []*DividendsReturnedOrder) ([]*DividendsReturnedOrder, error)
... ...