作者 陈志颖

合并分支 'test' 到 'master'

Test



查看合并请求 !62
... ... @@ -24,3 +24,4 @@
opp
/vendor
/*.exe~
logs
... ...
... ... @@ -11,5 +11,25 @@ ENV GO111MODULE on
ENV GOPROXY https://goproxy.cn,direct
RUN ["go","mod","tidy"]
RUN ["go","build"]
EXPOSE 8082
EXPOSE 8082 443
ENTRYPOINT ["./partner"]
#############################
## STEP 1 build executable binary
#############################
#FROM golang:alpine AS builder
#
#RUN mkdir /app
#WORKDIR /app
#COPY . /app
#RUN ["ln","-sf","/usr/share/zoneinfo/Asia/Shanghai","/etc/localtime"]
##RUN GO111MODULE="on" GOPROXY="https://goproxy.cn" GOFLAGS="-mod=vendor" CGO_ENABLED=0 GOOS=linux go build -o partner
#RUN GO111MODULE="on" GOPROXY="https://goproxy.cn" CGO_ENABLED=0 GOOS=linux go build -o partner
#
#############################
## STEP 2 build a small image
############################
#FROM scratch as final
#COPY --from=builder /app/partner /app/partner
#COPY --from=builder /app/conf/ /app/conf
#ENTRYPOINT ["./app/partner"]
\ No newline at end of file
... ...
... ... @@ -2,6 +2,12 @@ appname = partner
runmode = "${RUN_MODE||dev}"
httpport = "${HTTP_PORT||8082}"
#开启https
EnableHTTPS = true
HTTPSPort = "443"
HTTPSCertFile = "conf/fjmaimaimai.com_pem.crt"
HTTPSKeyFile = "conf/fjmaimaimai.com_rsa.key"
#开启监控
EnableAdmin = false
#开启JSON请求
... ...
-----BEGIN CERTIFICATE-----
MIIGWjCCBUKgAwIBAgIQBKNf6ftifrIH+BeJ7V4uqjANBgkqhkiG9w0BAQsFADBf
MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3
d3cuZGlnaWNlcnQuY29tMR4wHAYDVQQDExVHZW9UcnVzdCBDTiBSU0EgQ0EgRzEw
HhcNMjEwMTA2MDAwMDAwWhcNMjIwMjA2MjM1OTU5WjCBgzELMAkGA1UEBhMCQ04x
EjAQBgNVBAgMCeemj+W7u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4vD+ECgYEAhk2oTPvh7OLuk+gQZk1zUMnd9IdRndHilzoX
9DCdBnghNwgTPk/hYv0YkCyN2ILO/N18qxdDTFTySG9cLMzHknKpv2aENf0mgiRj
+T0eSNKM1yFBPktnZvGJ7+gQ3+8fpzudMDyplh6jFFNMJFERzIH2qfoTvAiRwb5U
B/c4jOUCgYEAiQOXabnrnOvkfhl/RhH/WVeLs6O3c5yei0THysGc+9CqE8txnWPN
A4XI8Tu8G2ScBN+v9oPFWlLAZxbxh1m6RM6VwP4q+Y8fmdQ+d6gH/IKTdBjH7bOt
4SHS+t8Z6PSu8K1BsF3pGRS7OWPlivSJzRyP2YIgE/xtwsEqiODdRKM=
-----END RSA PRIVATE KEY-----
... ...
... ... @@ -10,6 +10,9 @@ spec:
- name: "http"
port: 80
targetPort: 8082
- name: "https"
port: 443
targetPort: 443
selector:
k8s-app: mmmpartner
---
... ... @@ -48,9 +51,10 @@ spec:
imagePullPolicy: Always
ports:
- containerPort: 8082
volumeMounts:
- mountPath: /opt/logs
name: accesslogs
- containerPort: 443
# volumeMounts:
# - mountPath: /opt/logs
# name: accesslogs
env:
- name: HTTP_PORT
value: "8082"
... ... @@ -97,6 +101,6 @@ spec:
key: redis.port
- name: REDIS_AUTH
value: ""
volumes:
- name: accesslogs
emptyDir: {}
\ No newline at end of file
# volumes:
# - name: accesslogs
# emptyDir: {}
\ No newline at end of file
... ...
... ... @@ -10,6 +10,9 @@ spec:
- name: "http"
port: 80
targetPort: 8082
- name: "https"
port: 443
targetPort: 443
selector:
k8s-app: mmmpartner
---
... ... @@ -48,6 +51,7 @@ spec:
imagePullPolicy: Always
ports:
- containerPort: 8082
- containerPort: 443
volumeMounts:
- mountPath: /opt/logs
name: accesslogs
... ...
... ... @@ -10,6 +10,9 @@ spec:
- name: "http"
port: 80
targetPort: 8082
- name: "https"
port: 443
targetPort: 443
selector:
k8s-app: mmmpartner
---
... ... @@ -48,9 +51,10 @@ spec:
imagePullPolicy: Always
ports:
- containerPort: 8082
volumeMounts:
- mountPath: /opt/logs
name: accesslogs
- containerPort: 443
# volumeMounts:
# - mountPath: /opt/logs
# name: accesslogs
env:
- name: HTTP_PORT
value: "8082"
... ... @@ -97,6 +101,6 @@ spec:
key: redis.port
- name: REDIS_AUTH
value: ""
volumes:
- name: accesslogs
emptyDir: {}
\ No newline at end of file
# volumes:
# - name: accesslogs
# emptyDir: {}
\ No newline at end of file
... ...
version: v1
kind: Attribute
metadata:
name: companyId
description: 公司id
type:
primitive: int64
... ...
version: v1
kind: Attribute
metadata:
name: deliveryCode
description: 交货编号
type:
primitive: string
... ...
version: v1
kind: Attribute
metadata:
name: orderCode
description: 订单编号
type:
primitive: string
... ...
version: v1
kind: Attribute
metadata:
name: orderId
description: 订单编号
type:
primitive: int64
... ...
version: v1
kind: Attribute
metadata:
name: orderType
description: 公司id
type:
primitive: int
... ...
version: v1
kind: Attribute
metadata:
name: partnerId
description: 订单对应的合伙人
type:
primitive: int64
... ...
version: v1
kind: Attribute
metadata:
name: salesmanBonusPercent
description: 业务员抽成比例
type:
primitive: float64
... ...
version: v1
kind: Project
metadata:
name: partner
description: 合伙人
version: 0.8.0
repository: gitlab.fjmaimaimai.com/mmm-go/partner
contact:
name: SteveChan
email: steve.d.chan@qq.com
\ No newline at end of file
... ...
不能预览此文件类型
... ... @@ -381,7 +381,7 @@ func CompaniesLogin(header *protocol.RequestHeader, request *protocolx.CenterCom
// 通过密码或校验码登录的普通用户或通过校验码登录的游客,注册一个账号到配置的公司去
if request.GrantType == protocol.LoginBySmsCode || request.GrantType == protocol.LoginByPassword {
userErr := loginSvr.RegistryUser(request.Phone)
userErr := loginSvr.RegistryGuest(request.Phone)
if userErr != nil {
log.Error(userErr)
}
... ... @@ -403,26 +403,31 @@ func CompaniesLogin(header *protocol.RequestHeader, request *protocolx.CenterCom
return
}
manageLoginErr := loginSvr.ManagerLogin(request.Phone, request.Password)
fmt.Print("用户登录:", manageLoginErr, "\n")
partnerLoginErr := loginSvr.PartnerLogin(request.Phone, request.Password)
fmt.Print("合伙人登录:", partnerLoginErr, "\n")
//manageLoginErr := loginSvr.ManagerLogin(request.Phone, request.Password)
//fmt.Print("用户登录:", manageLoginErr, "\n")
//partnerLoginErr := loginSvr.PartnerLogin(request.Phone, request.Password)
//fmt.Print("合伙人登录:", partnerLoginErr, "\n")
//
//if manageLoginErr != nil && partnerLoginErr != nil {
// //if len(loginSvr.PartnerInfo) == 0 { // 不存在有效用户
// // err = protocol.NewErrWithMessage(10008)
// // return
// //}
// err = protocol.NewCustomMessage(1, "密码输入有误!")
// return
//} else if manageLoginErr != nil && partnerLoginErr == nil {
// if len(loginSvr.PartnerInfo) == 1 && len(loginSvr.NormalUsers) == 0 {
// if loginSvr.PartnerInfo[0].CompanyId == int64(constant.DEFAULT_GUEST_COMPANY) {
// err = protocol.NewCustomMessage(1, "密码输入有误!")
// return
// }
// }
//}
if manageLoginErr != nil && partnerLoginErr != nil {
if len(loginSvr.PartnerInfo) == 0 { // 不存在有效用户
err = protocol.NewErrWithMessage(10008)
return
}
err = protocol.NewCustomMessage(1, "密码输入有误!")
return
} else if manageLoginErr != nil && partnerLoginErr == nil {
if len(loginSvr.PartnerInfo) == 1 && len(loginSvr.NormalUsers) == 0 {
if loginSvr.PartnerInfo[0].CompanyId == int64(constant.DEFAULT_GUEST_COMPANY) {
if loginSvr.ManagerLogin(request.Phone, request.Password) != nil && loginSvr.PartnerLogin(request.Phone, request.Password) != nil {
err = protocol.NewCustomMessage(1, "密码输入有误!")
return
}
}
}
break
case protocol.LoginBySmsCode:
if _, err = CheckSmsCode(request.Phone, request.Captcha); err != nil {
... ...
... ... @@ -146,7 +146,13 @@ func getJoinWays(transactionContext *transaction.TransactionContext) (joinWays [
return
}
// 获取公司统计
/**
* @Author SteveChan
* @Description //TODO 获取公司统计,增加销售日期限制
* @Date 02:45 2021/2/3
* @Param
* @return
**/
func getStatistics(userId int64, transactionContext *transaction.TransactionContext) (interface{}, error) {
var (
UsersRepository, _ = factory.CreateUsersRepository(transactionContext)
... ... @@ -174,19 +180,19 @@ func getStatistics(userId int64, transactionContext *transaction.TransactionCont
if count, e := PartnerInfoDao.PartnerStatic(map[string]interface{}{"inPartnerIds": partnerIds, "inPartnerCategory": domain.App}); e == nil {
Statistics["appCount"] = count
}
if bonus, e := OrderBaseDao.OrderBonusStatics(domain.OrderBonusQuery{InPartnerIds: partnerIds, OrderTypes: domain.UserOrderTypes(domain.Career), PartnerCategoryId: domain.Career}); e == nil {
if bonus, e := OrderBaseDao.OrderBonusStatics(domain.OrderBonusQuery{InPartnerIds: partnerIds, OrderTypes: domain.UserOrderTypes(domain.Career), PartnerCategoryId: domain.Career, EndTime: utils.GetDayEnd().Unix() * 1000}); e == nil {
Statistics["careerOrdersMoney"] = bonus.TotalOrderAmount
Statistics["careerDividend"] = bonus.Bonus
}
if bonus, e := OrderBaseDao.OrderBonusStatics(domain.OrderBonusQuery{InPartnerIds: partnerIds, OrderTypes: domain.UserOrderTypes(domain.Career), PartnerCategoryId: domain.Business}); e == nil {
if bonus, e := OrderBaseDao.OrderBonusStatics(domain.OrderBonusQuery{InPartnerIds: partnerIds, OrderTypes: domain.UserOrderTypes(domain.Career), PartnerCategoryId: domain.Business, EndTime: utils.GetDayEnd().Unix() * 1000}); e == nil {
Statistics["businessOrdersMoney"] = bonus.TotalOrderAmount
Statistics["businessDividend"] = bonus.Bonus
}
if bonus, e := OrderBaseDao.OrderBonusStatics(domain.OrderBonusQuery{InPartnerIds: partnerIds, OrderTypes: domain.UserOrderTypes(domain.Career), PartnerCategoryId: domain.Develop}); e == nil {
if bonus, e := OrderBaseDao.OrderBonusStatics(domain.OrderBonusQuery{InPartnerIds: partnerIds, OrderTypes: domain.UserOrderTypes(domain.Career), PartnerCategoryId: domain.Develop, EndTime: utils.GetDayEnd().Unix() * 1000}); e == nil {
Statistics["developOrdersMoney"] = bonus.TotalOrderAmount
Statistics["developDividend"] = bonus.Bonus
}
if bonus, e := OrderBaseDao.OrderBonusStatics(domain.OrderBonusQuery{InPartnerIds: partnerIds, OrderTypes: domain.UserOrderTypes(domain.Career), PartnerCategoryId: domain.App}); e == nil {
if bonus, e := OrderBaseDao.OrderBonusStatics(domain.OrderBonusQuery{InPartnerIds: partnerIds, OrderTypes: domain.UserOrderTypes(domain.Career), PartnerCategoryId: domain.App, EndTime: utils.GetDayEnd().Unix() * 1000}); e == nil {
Statistics["appOrdersMoney"] = bonus.TotalOrderAmount
Statistics["appDividend"] = bonus.Bonus
}
... ... @@ -261,6 +267,10 @@ func newQueryOption(request *protocolx.PartnersRequest) map[string]interface{} {
queryOption["startTime"] = request.StartTime / 1000
}
if request.EndTime > 0 {
currentDayEnd := utils.GetDayEnd().Unix() * 1000
if request.EndTime >= currentDayEnd {
request.EndTime = currentDayEnd
}
queryOption["endTime"] = request.EndTime / 1000
}
queryOption["limit"] = request.PageSize
... ...
... ... @@ -9,6 +9,7 @@ import (
"gitlab.fjmaimaimai.com/mmm-go/partner/pkg/protocol"
protocolx "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/protocol/company"
userx "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/protocol/user"
"time"
)
func PartnersV2(header *protocol.RequestHeader, request *protocolx.PartnersRequest) (rsp *protocolx.PartnersResponse, err error) {
... ... @@ -27,6 +28,9 @@ func PartnersV2(header *protocol.RequestHeader, request *protocolx.PartnersReque
log.Error(err)
return
}
if request.PageIndex == 0 {
rsp.Timestamp = time.Now().Unix() * 1000
}
if rsp.Partners == nil {
rsp.Partners = []struct{}{}
}
... ... @@ -106,6 +110,10 @@ func newQueryOptionV2(request *protocolx.PartnersRequest) map[string]interface{}
queryOption["startTime"] = request.StartTime / 1000
}
if request.EndTime > 0 {
currentDayEnd := utils.GetDayEnd().Unix() * 1000
if request.EndTime >= currentDayEnd {
request.EndTime = currentDayEnd
}
queryOption["endTime"] = request.EndTime / 1000
}
if request.Keyword != "" {
... ...
package dividend
import (
"fmt"
"gitlab.fjmaimaimai.com/mmm-go/partner/pkg/application/factory"
"gitlab.fjmaimaimai.com/mmm-go/partner/pkg/domain"
"gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/utils"
... ... @@ -24,13 +25,53 @@ func Statistics(header *protocol.RequestHeader, request *protocol.DividendStatis
}()
// 事业分红统计-查询订单
_, orderAll, e := OrderBaseResponsitory.Find(utils.ObjectJsonToMap(domain.OrderQueryOption{PartnerId: request.PartnerId, EndTime: time.Now(), SortByCreateTime: domain.DESC, OrderTypes: domain.UserOrderTypes(domain.Career)}))
_, orderAll, e := OrderBaseResponsitory.Find(utils.ObjectJsonToMap(domain.OrderQueryOption{PartnerId: request.PartnerId, EndTime: utils.GetDayEnd(), SortBySalesTime: domain.DESC, OrderTypes: domain.UserOrderTypes(domain.Career)}))
if e != nil {
log.Error(e)
}
//获取营销年
t := time.Now()
var last time.Time
var first time.Time
boundDate := time.Date(t.Year(), time.March, 31, 23, 59, 59, 0, time.Local) // 营销年界限
fmt.Println("营销年界限:", boundDate)
if t.Before(boundDate) || t.Equal(boundDate) {
first = time.Date(t.Year()-1, time.April, 1, 0, 0, 0, 0, time.Local)
last = time.Date(t.Year(), time.March, 31, 23, 59, 59, 0, time.Local)
} else if t.After(boundDate) {
first = time.Date(t.Year(), time.April, 1, 0, 0, 0, 0, time.Local)
last = time.Date(t.Year()+1, time.March, 31, 23, 59, 59, 0, time.Local)
}
fmt.Println("当前营销年起始:", first, last)
//last := time.Date(t.Year(), time.December, 31, 23, 59, 59, 0, time.Local)
//first := time.Date(t.Year(), time.January, 1, 0, 0, 0, 0, time.Local)
//last := first.AddDate(1, 0, 0)
//last := time.Date(t.Year(), t.Month(), t.Day(), t.Hour(), t.Minute(), t.Second(), t.Nanosecond(), time.Local)
//last := utils.GetDayEnd()
// 请求开始时间和结束时间都为0时,默认从营销年开始统计
if request.StartTime == 0 && request.EndTime == 0 {
request.StartTime = first.Unix() * 1000
request.EndTime = last.Unix() * 1000
} else if request.StartTime > 0 && request.EndTime > 0 { // 判断结束时间是否超过今天,超过今天的结束时间到今天为止
currentDayEnd := utils.GetDayEnd().Unix() * 1000
if request.EndTime >= currentDayEnd {
request.EndTime = currentDayEnd
}
}
//if request.EndTime > last.Unix()*1000 {
// request.EndTime = last.Unix() * 1000
//}
fmt.Print("StartTime: ", request.StartTime, "\n")
fmt.Print("EndTime: ", request.EndTime, "\n")
var orderBetween []*domain.OrderBase
for i := range orderAll {
if orderAll[i].CreateTime.Unix() >= (request.StartTime/1000) && orderAll[i].CreateTime.Unix() < (request.EndTime/1000) {
if orderAll[i].SaleDate.Unix() >= (request.StartTime/1000) && orderAll[i].SaleDate.Unix() < (request.EndTime/1000) {
orderBetween = append(orderBetween, orderAll[i])
}
}
... ... @@ -60,6 +101,8 @@ func Statistics(header *protocol.RequestHeader, request *protocol.DividendStatis
Quarters: bonusQuarters,
}
rsp.Timestamp = time.Now().Unix() * 1000
err = transactionContext.CommitTransaction()
return
}
... ... @@ -82,7 +125,7 @@ func QuartersBonusStatics(orders []*domain.OrderBase, action int) (bonus []proto
bonus = make([]protocol.Bonus, 4)
for i := range orders {
o := orders[i]
quarter := quarter(o.CreateTime)
quarter := quarter(o.SaleDate)
static := o.OrderBonusStatic()
bonus[quarter].Receivable = utils.Decimal(bonus[quarter].Receivable + static.OrderTotalReceivable())
bonus[quarter].Received = utils.Decimal(bonus[quarter].Received + static.OrderBonusReceive())
... ... @@ -123,6 +166,12 @@ func OrderList(header *protocol.RequestHeader, request *protocol.DividendOrdersR
}()
rsp = &protocol.DividendOrdersResponse{List: make([]*protocol.DividendOrderListItem, 0)}
// 判断时间是否超过今天
currentDayEnd := utils.GetDayEnd().Unix() * 1000
if request.EndTime >= currentDayEnd {
request.EndTime = currentDayEnd
}
count, orders, err = OrderDao.DividendOrders(&domain.DividendOrdersQueryOption{
OrderTypes: domain.UserOrderTypes(domain.Career),
PartnerId: request.PartnerId,
... ... @@ -132,8 +181,7 @@ func OrderList(header *protocol.RequestHeader, request *protocol.DividendOrdersR
EndTime: request.EndTime,
Offset: request.PageIndex * request.PageSize,
Limit: request.PageSize,
//SortByUpdateTime: domain.DESC,
SortByCreateTime: domain.DESC,
SortBySalesTime: domain.DESC,
JoinWays: request.JoinWays,
})
if err != nil {
... ...
... ... @@ -38,6 +38,7 @@ func Detail(header *protocol.RequestHeader, request *protocol.OrderDetailRequest
OrderStatus: orderStatus(order),
CreateTime: order.CreateTime.Unix() * 1000,
UpdateTime: order.UpdateTime.Unix() * 1000,
SalesTime: order.SaleDate.Unix() * 1000,
OrderDistrict: map[string]interface{}{"id": order.RegionInfo.RegionId, "name": order.RegionInfo.RegionName},
Customer: protocol.Customer{Uname: order.Buyer.BuyerName, Phone: order.Buyer.ContactInfo},
Products: orderProducts(order),
... ... @@ -119,6 +120,13 @@ func orderTotalStatic(order *domain.OrderBase) interface{} {
return item
}
/**
* @Author SteveChan
* @Description // 订单统计
* @Date 18:14 2021/1/28
* @Param
* @return
**/
// 订单统计
func Statistics(header *protocol.RequestHeader, request *protocol.OrderStatisticsRequest) (rsp *protocol.OrderStatisticsResponse, err error) {
var (
... ... @@ -126,15 +134,18 @@ func Statistics(header *protocol.RequestHeader, request *protocol.OrderStatistic
OrderDao, _ = factory.CreateOrderBaseDao(transactionContext)
BusinessBonusRepository, _ = factory.CreateBusinessBonusRepository(transactionContext)
)
if err = transactionContext.StartTransaction(); err != nil {
return nil, err
}
defer func() {
transactionContext.RollbackTransaction()
}()
rsp = &protocol.OrderStatisticsResponse{Statistics: &protocol.OrderStatics{}}
// 当天订单/累计订单
// 今日新增实发订单
if rsp.Statistics.TodayRealQuantity, rsp.Statistics.TodayRealMoney, err = OrderDao.OrderStatics(&domain.OrderStaticQuery{
BeginTime: utils.GetDayBegin().Unix() * 1000,
EndTime: utils.GetDayEnd().Unix() * 1000,
... ... @@ -143,19 +154,23 @@ func Statistics(header *protocol.RequestHeader, request *protocol.OrderStatistic
}); err != nil {
return
}
// 累计实发订单
if rsp.Statistics.CumulativeQuantity, rsp.Statistics.CumulativeMoney, err = OrderDao.OrderStatics(&domain.OrderStaticQuery{
EndTime: time.Now().Unix() * 1000,
//EndTime: time.Now().Unix() * 1000,
EndTime: utils.GetDayEnd().Unix() * 1000, // 累计到今天最后一刻
OrderTypes: domain.UserOrderTypes(domain.Career),
PartnerId: header.UserId,
}); err != nil {
return
}
rsp.Statistics.TodayRealMoney = utils.Decimal(rsp.Statistics.TodayRealMoney)
rsp.Statistics.CumulativeMoney = utils.Decimal(rsp.Statistics.CumulativeMoney)
//事业分红/业务分红
var careerBonus, businessBonus, total float64 //,developBonus,appBonus
if bonus, e := OrderDao.OrderBonusStatics(domain.OrderBonusQuery{PartnerId: header.UserId, OrderTypes: domain.UserOrderTypes(domain.Career)}); e == nil {
if bonus, e := OrderDao.OrderBonusStatics(domain.OrderBonusQuery{PartnerId: header.UserId, OrderTypes: domain.UserOrderTypes(domain.Career), EndTime: utils.GetDayEnd().Unix() * 1000}); e == nil {
careerBonus = bonus.Bonus
total += careerBonus
}
... ... @@ -198,17 +213,36 @@ func List(header *protocol.RequestHeader, request *protocol.OrderListRequest) (r
Limit: request.PageSize,
Offset: request.PageSize * request.PageIndex,
//SortByUpdateTime: domain.DESC,
SortByCreateTime: domain.DESC,
//SortByCreateTime: domain.DESC,
SortBySalesTime: domain.DESC,
PartnerId: request.PartnerId,
PartnerCategoryId: request.JoinWay,
OrderType: request.OrderType,
OrderTypes: request.OrderTypes,
}
if request.StartTime > 0 {
// 当月累计实发订单
d := time.Now()
if request.StartTime > 0 { // 开始时间处理
queryOption.BeginTime = time.Unix(request.StartTime/1000, 0)
} else { // 开始时间为0,默认从这个月初开始
queryOption.BeginTime = utils.GetFirstDateOfMonth(d)
}
if request.EndTime > 0 { // 结束时间处理,判断时间是否超过今天
currentDayEnd := utils.GetDayEnd().Unix() * 1000
if request.EndTime >= currentDayEnd {
request.EndTime = currentDayEnd
}
if request.EndTime > 0 {
queryOption.EndTime = time.Unix(request.EndTime/1000, 0)
} else { // 请求结束时间为0,默认到今天结束
//queryOption.EndTime = utils.GetNextMonthFirstDay(d)
queryOption.EndTime = utils.GetDayEnd()
}
// 今日新增实发订单
if request.IsToday {
queryOption.BeginTime = utils.GetZeroTime(d)
queryOption.EndTime = utils.GetNextDayZeroTime(d)
}
total, orders, _ = OrderRepository.Find(utils.ObjectJsonToMap(queryOption))
if len(orders) != 0 {
... ... @@ -222,19 +256,21 @@ func List(header *protocol.RequestHeader, request *protocol.OrderListRequest) (r
}
}
// 【特殊处理1】 查询第0页时,需要查询累计实发订单数
// 【特殊处理1】 查询第0页时,需要查询累计实发订单数,并下发时间戳
if request.PageIndex == 0 {
var (
cumulativeQuantity int
)
cumulativeQuantity, _, err = OrderDao.OrderStatics(&domain.OrderStaticQuery{
EndTime: time.Now().Unix() * 1000,
EndTime: utils.GetDayEnd().Unix() * 1000,
OrderTypes: domain.UserOrderTypes(domain.Career),
PartnerId: request.PartnerId,
PartnerCategoryId: request.JoinWay,
})
rsp.Total = cumulativeQuantity
rsp.Timestamp = time.Now().Unix() * 1000
}
//【特殊处理2】 今天累计数量特殊处理 当前查询时间段内所有订单总数(复用rsp.Total字段)
if request.StartTime > 0 && request.EndTime > 0 {
zero := time.Time(xtime.XTime(time.Now()).DayBefore(0)).Unix()
... ... @@ -243,6 +279,21 @@ func List(header *protocol.RequestHeader, request *protocol.OrderListRequest) (r
}
}
// 【特殊处理3】今日新增实发订单统计
if request.IsToday {
var (
todayQuantity int
)
todayQuantity, _, err = OrderDao.OrderStatics(&domain.OrderStaticQuery{
BeginTime: queryOption.BeginTime.Unix() * 1000,
EndTime: queryOption.EndTime.Unix() * 1000,
OrderTypes: domain.UserOrderTypes(domain.Career),
PartnerId: request.PartnerId,
PartnerCategoryId: request.JoinWay,
})
rsp.Total = todayQuantity
}
err = transactionContext.CommitTransaction()
return
}
... ... @@ -259,6 +310,7 @@ func DomainOrderToOrderListItem(order *domain.OrderBase) *protocol.OrderListItem
},
OrderAmount: order.PlanOrderAmount,
UpdateTime: order.UpdateTime.Unix() * 1000,
SalesTime: order.SaleDate.Unix() * 1000,
MyDividend: bonusStatic.OrderTotalReceivable(),
IsRead: order.IsRead(),
}
... ...
... ... @@ -6,7 +6,6 @@ import (
"gitlab.fjmaimaimai.com/mmm-go/partner/pkg/domain"
"gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/utils"
"gitlab.fjmaimaimai.com/mmm-go/partner/pkg/protocol"
"time"
)
// 订单统计
... ... @@ -25,7 +24,7 @@ func StatisticsV2(header *protocol.RequestHeader, request *protocol.OrderStatist
//事业分红/业务分红
var total float64
if bonus, e := OrderDao.OrderBonusStatics(domain.OrderBonusQuery{PartnerId: request.PartnerId, OrderTypes: domain.UserOrderTypes(domain.Career)}); e == nil {
if bonus, e := OrderDao.OrderBonusStatics(domain.OrderBonusQuery{PartnerId: request.PartnerId, OrderTypes: domain.UserOrderTypes(domain.Career), EndTime: utils.GetDayEnd().Unix() * 1000}); e == nil {
total += bonus.Bonus
}
calcOrderStatic := func(catId int, total float64) protocol.OrderStatic {
... ... @@ -37,12 +36,12 @@ func StatisticsV2(header *protocol.RequestHeader, request *protocol.OrderStatist
PartnerCategoryId: catId,
})
cumulativeQuantity, cumulativeMoney, _ := OrderDao.OrderStatics(&domain.OrderStaticQuery{
EndTime: time.Now().Unix() * 1000,
EndTime: utils.GetDayEnd().Unix() * 1000,
OrderTypes: domain.UserOrderTypes(domain.Career),
PartnerId: request.PartnerId,
PartnerCategoryId: catId,
})
bonus, _ := OrderDao.OrderBonusStatics(domain.OrderBonusQuery{PartnerId: request.PartnerId, OrderTypes: domain.UserOrderTypes(domain.Career), PartnerCategoryId: catId})
bonus, _ := OrderDao.OrderBonusStatics(domain.OrderBonusQuery{PartnerId: request.PartnerId, OrderTypes: domain.UserOrderTypes(domain.Career), PartnerCategoryId: catId, EndTime: utils.GetDayEnd().Unix() * 1000})
var percent float64 = 0
if bonus.Bonus != 0 {
percent = utils.DecimalToNumber(bonus.Bonus * 100 / total)
... ...
... ... @@ -66,12 +66,12 @@ func getDetail(userId int64, transactionContext *transaction.TransactionContext)
}
}
p.CooperateTime = partner.CooperateTime.Unix() * 1000
if bonus, e := OrderBaseDao.OrderBonusStatics(domain.OrderBonusQuery{PartnerId: userId, OrderTypes: domain.UserOrderTypes(domain.Career)}); e == nil {
if bonus, e := OrderBaseDao.OrderBonusStatics(domain.OrderBonusQuery{PartnerId: userId, OrderTypes: domain.UserOrderTypes(domain.Career), EndTime: utils.GetDayEnd().Unix() * 1000}); e == nil {
p.CareerOrdersCount = int(bonus.Total)
p.CareerOrdersMoney = utils.Decimal(bonus.TotalOrderAmount)
p.CareerDividend = utils.Decimal(bonus.Bonus)
}
if businessBonus, e := BusinessBonusDao.OrderBonusStatics(domain.OrderBonusQuery{PartnerId: userId, IsDisable: 1}); e == nil {
if businessBonus, e := BusinessBonusDao.OrderBonusStatics(domain.OrderBonusQuery{PartnerId: userId, IsDisable: 1, EndTime: utils.GetDayEnd().Unix() * 1000}); e == nil {
p.BusinessOrdersCount = int(businessBonus.Total)
p.BusinessOrdersMoney = utils.Decimal(businessBonus.TotalOrderAmount)
p.BusinessDividend = utils.Decimal(businessBonus.Bonus)
... ...
... ... @@ -8,7 +8,7 @@ import (
const SERVICE_NAME = "partner"
var LOG_LEVEL = "debug"
var LOG_File = "app.log"
var LOG_File = "logs/app.log"
var LOG_PREFIX = "[partner_dev]"
var MMM_SMS_SERVICE_HOST = "https://sms.fjmaimaimai.com:9897"
... ...
... ... @@ -4,9 +4,9 @@ import "os"
var POSTGRESQL_DB_NAME = "partner_test" //partner_test/partner_dev
var POSTGRESQL_USER = "postgres" //postgres
var POSTGRESQL_PASSWORD = "eagle1010" //pgsql@123/1993618jack
var POSTGRESQL_HOST = "114.55.200.59" //127.0.0.1/114.55.200.59
var POSTGRESQL_PORT = "31543" //5432/31543
var POSTGRESQL_PASSWORD = "1993618jack" //pgsql@123/1993618jack/eagle1010
var POSTGRESQL_HOST = "127.0.0.1" //127.0.0.1/114.55.200.59
var POSTGRESQL_PORT = "5432" //5432/31543
var DISABLE_CREATE_TABLE = true
var DISABLE_SQL_GENERATE_PRINT = false
... ...
... ... @@ -4,7 +4,7 @@ import "os"
var REDIS_HOST = "127.0.0.1"
var REDIS_PORT = "6379"
var REDIS_AUTH = ""
var REDIS_AUTH = "" // 1993618@jack
func init() {
if os.Getenv("REDIS_HOST") != "" {
... ...
... ... @@ -42,6 +42,8 @@ type OrderBase struct {
DeliveryTime time.Time
//更新时间
UpdateTime time.Time
//销售日期
SaleDate time.Time
//上一次查看时间 已读情况
LastViewTime time.Time
//合伙人应收分红
... ... @@ -157,6 +159,7 @@ type OrderQueryOption struct {
//IsDisable string `json:"isDisable,omitempty"`
SortByCreateTime string `json:"sortByCreateTime,omitempty"`
SortByUpdateTime string `json:"sortByUpdateTime,omitempty"`
SortBySalesTime string `json:"sortBySalesTime,omitempty"`
Offset int `json:"offset,omitempty"`
Limit int `json:"limit,omitempty"`
PartnerCategoryId int `json:"partnerCategoryId,omitempty"`
... ... @@ -175,6 +178,7 @@ type DividendOrdersQueryOption struct {
Limit int `json:"limit,omitempty"`
SortByUpdateTime string `json:"sortByUpdateTime,omitempty"`
SortByCreateTime string `json:"sortByCreateTime,omitempty"`
SortBySalesTime string `json:"sortBySalesTime,omitempty"`
JoinWays []*company.JoinWays `json:"joinWays,omitempty"` // 合伙类型
}
... ...
... ... @@ -32,6 +32,7 @@ type OrderBonusQuery struct {
OrderType int `json:"orderType,omitempty"`
OrderTypes []int `json:"orderTypes,omitempty"`
PartnerCategoryId int `json:"partnerCategoryId,omitempty"` //订单所属类型
EndTime int64 `json:"endTime,omitempty"`
//IsGroupByPartnerCategoryId bool `json:"isGroupByPartnerCategoryId,omitempty"`
}
... ...
... ... @@ -35,10 +35,10 @@ func (dao *OrderBaseDao) OrderStatics(option *domain.OrderStaticQuery) (count in
q.Where(`"order_base".order_type in (?)`, pg.In(option.OrderTypes))
}
if option.BeginTime > 0 {
q.Where(`"order_base".create_time >=?`, time.Unix(option.BeginTime/1000, 0))
q.Where(`"order_base".sale_date >=?`, time.Unix(option.BeginTime/1000, 0))
}
if option.EndTime > 0 {
q.Where(`"order_base".create_time <?`, time.Unix(option.EndTime/1000, 0))
q.Where(`"order_base".sale_date <?`, time.Unix(option.EndTime/1000, 0))
}
if option.PartnerCategoryId > 0 {
q.Where(`"order_base".partner_category @>'{"id":?}'`, option.PartnerCategoryId)
... ... @@ -82,6 +82,9 @@ func (dao *OrderBaseDao) OrderBonusStatics(option domain.OrderBonusQuery) (rsp d
if option.PartnerCategoryId > 0 {
q.Where(`"order_base".partner_category @>'{"id":?}'`, option.PartnerCategoryId)
}
if option.EndTime > 0 {
q.Where(`"order_base".sale_date <?`, time.Unix(option.EndTime/1000, 0))
}
//if option.IsGroupByPartnerCategoryId{
// q.Group(`partner_category`)
//}
... ... @@ -105,10 +108,10 @@ func (dao *OrderBaseDao) DividendOrders(option *domain.DividendOrdersQueryOption
q.Where(`"order_base".partner_id=?`, option.PartnerId)
}
if option.StartTime > 0 {
q.Where(`"order_base".create_time >=?`, time.Unix(option.StartTime/1000, 0))
q.Where(`"order_base".sale_date >=?`, time.Unix(option.StartTime/1000, 0))
}
if option.EndTime > 0 {
q.Where(`"order_base".create_time <?`, time.Unix(option.EndTime/1000, 0))
q.Where(`"order_base".sale_date <?`, time.Unix(option.EndTime/1000, 0))
}
if len(option.JoinWays) > 0 {
var joinWays []int64
... ... @@ -150,6 +153,9 @@ func (dao *OrderBaseDao) DividendOrders(option *domain.DividendOrdersQueryOption
if len(option.SortByCreateTime) > 0 {
q.Order(fmt.Sprintf("order_base.create_time %v", option.SortByCreateTime))
}
if len(option.SortBySalesTime) > 0 {
q.Order(fmt.Sprintf("order_base.sale_date %v", option.SortBySalesTime))
}
count, err = q.Distinct().SelectAndCount()
for i := range orders {
var domainOrder *domain.OrderBase
... ...
... ... @@ -115,7 +115,7 @@ A left join
plan_order_amount amount,
(case when use_order_count>=0 then use_partner_bonus else plan_partner_bonus end) bonus,
partner_bonus_expense bonus_expense FROM "order_base" AS "order_base"
WHERE (partner_id in (?)) and (order_type in (?))
WHERE (partner_id in (?)) and (order_type in (?) and (sale_date < ?) )
UNION ALL
SELECT partner_info_id partner_id,
0 amount, bonus bonus, bonus_expense bonus_expense FROM business_bonus
... ... @@ -132,7 +132,7 @@ GROUP BY partner_id
sql.WriteString(fmt.Sprintf(" \nOFFSET %v", offset))
}
}
_, err = tx.Query(&statics, sql.String(), pg.In(partnerIds), pg.In(partnerIds), pg.In(domain.UserOrderTypes(domain.Career)), pg.In(partnerIds))
_, err = tx.Query(&statics, sql.String(), pg.In(partnerIds), pg.In(partnerIds), pg.In(domain.UserOrderTypes(domain.Career)), GetDayEnd(), pg.In(partnerIds))
return
}
... ...
... ... @@ -153,17 +153,29 @@ func (svr *PgLoginService) CheckIsPartner(phone string, companyId int64) (ok boo
return ok, nil
}
//合伙人登录
// 合伙人登录
func (svr *PgLoginService) PartnerLogin(phone string, password string) (err error) {
if len(svr.PartnerInfo) == 0 {
//子账号
err = protocol.NewErrWithMessage(502, err) //账号不存在
return
}
if !strings.EqualFold(svr.PartnerInfo[0].Password, password) {
var misMatch bool
for _, partnerInfo := range svr.PartnerInfo {
if !strings.EqualFold(partnerInfo.Password, password) {
misMatch = true
} else {
misMatch = false
break
}
}
if misMatch {
err = protocol.NewCustomMessage(1, "密码输入错误!")
return
}
return
}
... ... @@ -226,12 +238,12 @@ func (svr *PgLoginService) PartnerStaticInfo() (interface{}, error) {
return response, nil
}
totalBonus, e := OrderDao.OrderBonusStatics(domain.OrderBonusQuery{InPartnerIds: doGetPartnerIds(), OrderTypes: domain.UserOrderTypes(domain.Career)})
totalBonus, e := OrderDao.OrderBonusStatics(domain.OrderBonusQuery{InPartnerIds: doGetPartnerIds(), OrderTypes: domain.UserOrderTypes(domain.Career), EndTime: utils.GetDayEnd().Unix() * 1000})
if e != nil {
return response, e
}
if businessBonus, e := BusinessBonusDao.OrderBonusStatics(domain.OrderBonusQuery{InPartnerIds: doGetPartnerIds(), IsDisable: 1}); e == nil {
if businessBonus, e := BusinessBonusDao.OrderBonusStatics(domain.OrderBonusQuery{InPartnerIds: doGetPartnerIds(), IsDisable: 1, EndTime: utils.GetDayEnd().Unix() * 1000}); e == nil {
totalBonus.Bonus += businessBonus.Bonus
}
... ... @@ -278,7 +290,7 @@ func (svr *PgLoginService) PartnerStaticInfo() (interface{}, error) {
continue
}
bonus, _ := OrderDao.OrderBonusStatics(domain.OrderBonusQuery{PartnerId: partner.Id, OrderTypes: domain.UserOrderTypes(domain.Career)})
bonus, _ := OrderDao.OrderBonusStatics(domain.OrderBonusQuery{PartnerId: partner.Id, OrderTypes: domain.UserOrderTypes(domain.Career), EndTime: utils.GetDayEnd().Unix() * 1000})
if v, ok := mapPartnerBussinessBonus[partner.Id]; ok {
bonus.Bonus += v.Bonus
}
... ... @@ -454,7 +466,7 @@ func (svr *PgLoginService) RegistryUser(phone string) error {
isUserSenior bool
)
partnerInfo, _ := PartnerInfoService.FindOne(map[string]interface{}{"account": phone, "isNot": constant.DEFAULT_GUEST_COMPANY}) // 合伙人在正常公司是否存在
partnerInfo, errPartner := PartnerInfoService.FindOne(map[string]interface{}{"account": phone, "isNot": constant.DEFAULT_GUEST_COMPANY}) // 合伙人在正常公司是否存在
if partnerInfo == nil {
isPartner = false
} else {
... ... @@ -480,7 +492,7 @@ func (svr *PgLoginService) RegistryUser(phone string) error {
isGuestPartnerAvailable = true
}
user, _ := UsersRepository.FindOne(map[string]interface{}{"phone": phone, "deleteAtIsNull": true}) // 用户是否存在
user, errUser := UsersRepository.FindOne(map[string]interface{}{"phone": phone, "deleteAtIsNull": true}) // 用户是否存在
if user == nil {
isUser = false
} else {
... ... @@ -571,27 +583,27 @@ func (svr *PgLoginService) RegistryUser(phone string) error {
// 合伙人不存在、用户存在、非高管(普通用户)-> 注册用户
// 合伙人不存在、用户不存在(游客)-> 注册用户
//if errPartner != nil && errUser == nil && errSenior == nil || errPartner != nil && errUser != nil {
// id := time.Now().Unix()
// errPartner = svr.transactionContext.PgDd.Insert(&models.PartnerInfo{
// Id: id,
// CompanyId: int64(constant.DEFAULT_GUEST_COMPANY),
// PartnerName: phone,
// Account: phone,
// Password: "7c4a8d09ca3762af61e59520943dc26494f8941b",
// Status: 1,
// PartnerCategory: 1,
// RegionInfo: &domain.RegionInfo{
// RegionName: "客户区域",
// RegionId: 0,
// },
// CooperateTime: time.Now(),
// CreateAt: time.Now(),
// UpdateAt: time.Now(),
// PartnerCategoryInfos: []*models.PartnerCategoryInfo{&models.PartnerCategoryInfo{Id: 1, Code: phone}},
// Salesman: []*domain.Salesman{&domain.Salesman{Name: phone, Telephone: phone}},
// })
//}
if errPartner != nil && errUser == nil {
id := time.Now().Unix()
errPartner = svr.transactionContext.PgDd.Insert(&models.PartnerInfo{
Id: id,
CompanyId: int64(constant.DEFAULT_GUEST_COMPANY),
PartnerName: phone,
Account: phone,
Password: "7c4a8d09ca3762af61e59520943dc26494f8941b",
Status: 1,
PartnerCategory: 1,
RegionInfo: &domain.RegionInfo{
RegionName: "客户区域",
RegionId: 0,
},
CooperateTime: time.Now(),
CreateAt: time.Now(),
UpdateAt: time.Now(),
PartnerCategoryInfos: []*models.PartnerCategoryInfo{&models.PartnerCategoryInfo{Id: 1, Code: phone}},
Salesman: []*domain.Salesman{&domain.Salesman{Name: phone, Telephone: phone}},
})
}
return errPartner
}
... ... @@ -627,7 +639,7 @@ func (svr *PgLoginService) RegistryGuest(phone string) error {
CooperateTime: time.Now(),
CreateAt: time.Now(),
UpdateAt: time.Now(),
PartnerCategoryInfos: []*models.PartnerCategoryInfo{&models.PartnerCategoryInfo{Id: 1}},
PartnerCategoryInfos: []*models.PartnerCategoryInfo{&models.PartnerCategoryInfo{Id: 1, Code: phone}},
Salesman: []*domain.Salesman{&domain.Salesman{Name: phone, Telephone: phone}},
})
}
... ...
... ... @@ -42,6 +42,8 @@ type OrderBase struct {
DeliveryTime time.Time
//更新时间
UpdateTime time.Time
//销售日期
SaleDate time.Time
//上一次查看时间 已读情况
LastViewTime time.Time
//合伙人应收分红
... ...
... ... @@ -79,12 +79,13 @@ func (repository *OrderBaseRepository) Find(queryOptions map[string]interface{})
query := NewQuery(tx.Model(&OrderBaseModels), queryOptions)
query.SetWhere(`"order_base".partner_id= ?`, "partnerId").
SetWhere(`"order_base".order_type= ?`, "orderType").
SetWhere(`"order_base".create_time >= ?`, "beginTime").
SetWhere(`"order_base".create_time < ?`, "endTime").
SetWhere(`"order_base".sale_date >= ?`, "beginTime").
SetWhere(`"order_base".sale_date < ?`, "endTime").
//SetWhere(`"order_base".is_disable = ?`, "isDisable").
SetLimit().
SetOrder(`order_base.create_time`, "sortByCreateTime").
SetOrder(`order_base.update_time`, "sortByUpdateTime")
SetOrder(`order_base.update_time`, "sortByUpdateTime").
SetOrder(`order_base.sale_date`, "sortBySalesTime")
if v, ok := queryOptions["orderTypes"]; ok {
query.Where(`"order_base".order_type in (?)`, pg.In(v))
}
... ...
... ... @@ -13,3 +13,25 @@ func GetDayEnd() time.Time {
nextDay := t.AddDate(0, 0, 1)
return nextDay
}
//获取传入的时间所在月份的第一天,即某月第一天的0点。如传入time.Now(), 返回当前月份的第一天0点时间。
func GetFirstDateOfMonth(d time.Time) time.Time {
d = d.AddDate(0, 0, -d.Day()+1)
return GetZeroTime(d)
}
//获取传入的时间所在月份的最后一天,即某月最后一天的23:59:59。如传入time.Now(), 返回当前月份的最后一天的23:59:59。
func GetNextMonthFirstDay(d time.Time) time.Time {
d = GetFirstDateOfMonth(d).AddDate(0, 1, 0)
return GetZeroTime(d)
}
//获取某一天的0点时间
func GetZeroTime(d time.Time) time.Time {
return time.Date(d.Year(), d.Month(), d.Day(), 0, 0, 0, 0, time.Local)
}
//获取某一天的23点59分59秒
func GetNextDayZeroTime(d time.Time) time.Time {
return time.Date(d.Year(), d.Month(), d.Day(), 0, 0, 0, 0, time.Local).AddDate(0, 0, 1)
}
... ...
... ... @@ -5,6 +5,7 @@ import (
. "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/log"
"gitlab.fjmaimaimai.com/mmm-go/partner/pkg/port/appsvr/middleware"
_ "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/port/appsvr/routers"
"time"
)
func init() {
... ... @@ -15,4 +16,8 @@ func init() {
beego.InsertFilter("/*", beego.BeforeExec, middleware.CreateRequstLogFilter(Logger))
beego.InsertFilter("/*", beego.AfterExec, middleware.CreateResponseLogFilter(Logger), false)
// 默认时区设置
timeLocal, _ := time.LoadLocation("Asia/Chongqing")
time.Local = timeLocal
}
... ...
... ... @@ -3,4 +3,5 @@ package company
type PartnersResponse struct {
// 唯一标识
Partners interface{} `json:"partners"`
Timestamp int64 `json:"timestamp"`
}
... ...
... ... @@ -9,14 +9,15 @@ const (
/*DividendStatistics 分红统计*/
type DividendStatisticsRequest struct {
StartTime int64 `json:"startTime" valid:"Required"`
EndTime int64 `json:"endTime" valid:"Required"`
StartTime int64 `json:"startTime"`
EndTime int64 `json:"endTime"`
//分红类型(0累计分红、1分红支出)
//DividendAction int `json:"dividendAction"`
PartnerId int64 `json:"partnerId"`
}
type DividendStatisticsResponse struct {
Statistics DividendStatistics `json:"statistics"`
Timestamp int64 `json:"timestamp"`
}
type DividendStatistics struct {
... ...
... ... @@ -32,6 +32,7 @@ type OrderDetail struct {
OrderStatus int `json:"orderStatus"` //订单状态 1.待支付 2.已支付 3.已支付退货 4待支付退货
CreateTime int64 `json:"createTime"`
UpdateTime int64 `json:"updateTime"`
SalesTime int64 `json:"salesTime"` // 销售日期
OrderDistrict interface{} `json:"orderDistrict"`
Customer Customer `json:"customer"`
Products interface{} `json:"products"`
... ... @@ -87,7 +88,7 @@ type OrderListRequest struct {
PageSize int `json:"pageSize" valid:"Required"`
OrderType int `json:"-"`
OrderTypes []int `json:"-"`
IsToday bool `json:"isToday"`
PartnerId int64 `json:"partnerId"`
JoinWay int `json:"joinWay"` //合伙方式(0或不传,即所有合伙方式)
}
... ... @@ -95,6 +96,7 @@ type OrderListResponse struct {
List []*OrderListItem `json:"list"`
Statistics map[string]interface{} `json:"-"`
Total int `json:"total"`
Timestamp int64 `json:"timestamp"`
}
type OrderListItem struct {
... ... @@ -118,6 +120,8 @@ type OrderListItem struct {
OrderAmount float64 `json:"orderAmount"`
// 订单更新时间
UpdateTime int64 `json:"updateTime"`
//销售时间
SalesTime int64 `json:"salesTime"`
//我的分红
MyDividend float64 `json:"dividendReceivable"`
//是否已读(0未读,1已读)
... ...