作者 陈志颖

合并分支 'dev' 到 'test'

Dev



查看合并请求 !48
... ... @@ -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
ENTRYPOINT ["./partner"]
\ No newline at end of file
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
HhcNMjEwMTA2MDAwMDAwWhcNMjIwMjA2MjM1OTU5WjCBgzELMAkGA1UE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oHFNMaFgC
HNZ6hgU9JyHzqTeMHv4vD+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,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: partner
---
... ... @@ -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,6 +51,7 @@ spec:
imagePullPolicy: Always
ports:
- containerPort: 8082
- containerPort: 443
volumeMounts:
- mountPath: /opt/logs
name: accesslogs
... ...
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,25 +403,30 @@ 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
}
if loginSvr.ManagerLogin(request.Phone, request.Password) != nil && loginSvr.PartnerLogin(request.Phone, request.Password) != nil {
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
}
}
}
break
case protocol.LoginBySmsCode:
... ... @@ -525,20 +530,22 @@ func CompaniesLoginByCredential(header *protocol.RequestHeader, request *protoco
// loginSvr 初始化
_ = loginSvr.Init(claim.Phone)
// 真实公司有效合伙人不存在,真实公司有效用户不存在,游客公司有效合伙人存在
//if len(loginSvr.IsRealPartnerInfo) == 0 && len(loginSvr.IsRealUser) == 0 && len(loginSvr.GuestPartnerInfoAvailable) > 0 {
// err = protocol.NewErrWithMessage(10008) //账号禁用, 抱歉,企业管理员未帮您开通权限。如需访问,请联系企业管理员
// return
//} else if len(loginSvr.IsRealPartnerInfo) == 0 && len(loginSvr.IsRealUser) == 0 && len(loginSvr.GuestPartnerInfoAvailable) == 0 {
// err = protocol.NewErrWithMessage(4140, err) // refreshToken过期,需要重新登录授权
// return
//}
// 高管标志位初始化
_ = loginSvr.InitSenior(claim.Phone)
// 合伙人标志位初始化
_ = loginSvr.InitPartner(claim.Phone)
if len(loginSvr.PartnerInfo) == 0 && len(loginSvr.Users) == 0 {
err = protocol.NewErrWithMessage(4140, err)
return
}
rsp.Partner, _ = loginSvr.PartnerStaticInfo()
rsp.Manager, _ = loginSvr.ManagerStaticInfo()
if !loginSvr.HasAvailableCompany && !loginSvr.HasAvailableManagerCompany {
err = protocol.NewErrWithMessage(4140, err) //账号禁用,refreshToken过期,需要重新登录授权
err = protocol.NewErrWithMessage(4140, err) //账号禁用
return
}
... ...
... ... @@ -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{}{}
}
... ...
... ... @@ -24,13 +24,13 @@ 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: time.Now(), SortBySalesTime: domain.DESC, OrderTypes: domain.UserOrderTypes(domain.Career)}))
if e != nil {
log.Error(e)
}
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])
}
}
... ... @@ -59,6 +59,9 @@ func Statistics(header *protocol.RequestHeader, request *protocol.DividendStatis
Receivable: bonusAll.Receivable,
Quarters: bonusQuarters,
}
if request.PageIndex == 0 {
rsp.Timestamp = time.Now().Unix() * 1000
}
err = transactionContext.CommitTransaction()
return
... ... @@ -82,7 +85,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())
... ... @@ -124,17 +127,18 @@ func OrderList(header *protocol.RequestHeader, request *protocol.DividendOrdersR
rsp = &protocol.DividendOrdersResponse{List: make([]*protocol.DividendOrderListItem, 0)}
count, orders, err = OrderDao.DividendOrders(&domain.DividendOrdersQueryOption{
OrderTypes: domain.UserOrderTypes(domain.Career),
PartnerId: request.PartnerId,
DetailAction: request.DetailAction,
DividendAction: request.DividendAction,
StartTime: request.StartTime,
EndTime: request.EndTime,
Offset: request.PageIndex * request.PageSize,
Limit: request.PageSize,
OrderTypes: domain.UserOrderTypes(domain.Career),
PartnerId: request.PartnerId,
DetailAction: request.DetailAction,
DividendAction: request.DividendAction,
StartTime: request.StartTime,
EndTime: request.EndTime,
Offset: request.PageIndex * request.PageSize,
Limit: request.PageSize,
//SortByUpdateTime: domain.DESC,
SortByCreateTime: domain.DESC,
JoinWays: request.JoinWays,
//SortByCreateTime: domain.DESC,
SortBySalesTime: domain.DESC,
JoinWays: request.JoinWays,
})
if err != nil {
return
... ...
... ... @@ -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),
... ... @@ -195,10 +196,11 @@ func List(header *protocol.RequestHeader, request *protocol.OrderListRequest) (r
// 查询订单列表
queryOption := &domain.OrderQueryOption{
Limit: request.PageSize,
Offset: request.PageSize * request.PageIndex,
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,
... ... @@ -210,6 +212,15 @@ func List(header *protocol.RequestHeader, request *protocol.OrderListRequest) (r
if request.EndTime > 0 {
queryOption.EndTime = time.Unix(request.EndTime/1000, 0)
}
// 今日订单
if request.IsToday {
timeStr := time.Now().Format("2006-01-02")
t, _ := time.Parse("2006-01-02", timeStr)
beginTimeNum := t.Unix()
endTimeNum := beginTimeNum + 86400
queryOption.BeginTime = time.Unix(beginTimeNum, 0)
queryOption.EndTime = time.Unix(endTimeNum, 0)
}
total, orders, _ = OrderRepository.Find(utils.ObjectJsonToMap(queryOption))
if len(orders) != 0 {
for i := range orders {
... ... @@ -234,6 +245,7 @@ func List(header *protocol.RequestHeader, request *protocol.OrderListRequest) (r
PartnerCategoryId: request.JoinWay,
})
rsp.Total = cumulativeQuantity
rsp.Timestamp = time.Now().Unix() * 1000
}
//【特殊处理2】 今天累计数量特殊处理 当前查询时间段内所有订单总数(复用rsp.Total字段)
if request.StartTime > 0 && request.EndTime > 0 {
... ... @@ -249,17 +261,18 @@ func List(header *protocol.RequestHeader, request *protocol.OrderListRequest) (r
func DomainOrderToOrderListItem(order *domain.OrderBase) *protocol.OrderListItem {
bonusStatic := order.OrderBonusStatic()
return &protocol.OrderListItem{
Id: order.Id,
OrderType: order.OrderType,
OrderNo: order.OrderCode,
DeliveryNo: order.DeliveryCode,
OrderDistrict: map[string]interface{}{
"id": order.RegionInfo.RegionId,
Id: order.Id,
OrderType: order.OrderType,
OrderNo: order.OrderCode,
DeliveryNo: order.DeliveryCode,
OrderDistrict: map[string]interface{}{
"id": order.RegionInfo.RegionId,
"name": order.RegionInfo.RegionName,
},
OrderAmount: order.PlanOrderAmount,
UpdateTime: order.UpdateTime.Unix() * 1000,
MyDividend: bonusStatic.OrderTotalReceivable(),
IsRead: order.IsRead(),
OrderAmount: order.PlanOrderAmount,
UpdateTime: order.UpdateTime.Unix() * 1000,
SalesTime: order.SaleDate.Unix() * 1000,
MyDividend: bonusStatic.OrderTotalReceivable(),
IsRead: order.IsRead(),
}
}
... ...
... ... @@ -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,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,25 +159,27 @@ 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"`
}
type DividendOrdersQueryOption struct {
PartnerId int64 `json:"partnerId"`
OrderType int `json:"orderType"` //订单类型
OrderTypes []int `json:"orderTypes,omitempty"`
DetailAction int `json:"detailAction"` //明细类型(0已收明细、1未收明细)
DividendAction int `json:"dividendAction"` //分红类型(0累计分红、1分红支出)
IsDisable string `json:"isDisable,omitempty"`
StartTime int64 `json:"startTime" `
EndTime int64 `json:"endTime"`
Offset int `json:"offset,omitempty"`
Limit int `json:"limit,omitempty"`
SortByUpdateTime string `json:"sortByUpdateTime,omitempty"`
SortByCreateTime string `json:"sortByCreateTime,omitempty"`
JoinWays []*company.JoinWays `json:"joinWays,omitempty"` // 合伙类型
PartnerId int64 `json:"partnerId"`
OrderType int `json:"orderType"` //订单类型
OrderTypes []int `json:"orderTypes,omitempty"`
DetailAction int `json:"detailAction"` //明细类型(0已收明细、1未收明细)
DividendAction int `json:"dividendAction"` //分红类型(0累计分红、1分红支出)
IsDisable string `json:"isDisable,omitempty"`
StartTime int64 `json:"startTime" `
EndTime int64 `json:"endTime"`
Offset int `json:"offset,omitempty"`
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"` // 合伙类型
}
//买家
... ...
... ... @@ -105,10 +105,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 +150,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
... ...
... ... @@ -25,12 +25,11 @@ type PgLoginService struct {
GuestPartnerInfo []*domain.PartnerInfo // 游客公司合伙人
GuestPartnerInfoAvailable []*domain.PartnerInfo // 游客公司有效合伙人
NormalPartnerInfo []*domain.PartnerInfo // 所有公司合伙人
IsRealPartnerInfo []*domain.PartnerInfo // 真实公司有效合伙人
IsPartnerInfo []*domain.PartnerInfo // 真实公司有效合伙人
Users []*domain.Users // 所有公司有效用户
NormalUsers []*domain.Users // 所有公司用户
IsSenior []*domain.Users // 所有公司有效高管
IsRealSenior []*domain.Users // 真实公司的有效高管
IsRealUser []*domain.Users // 真实公司有效用户,有效高管和有效用户二者其中一个为空则非高管
transactionContext *transaction.TransactionContext
// 标识:登录的账号信息是否有可用的公司, true:有 false:没有
HasAvailableCompany bool // 是否有可访问的合伙公司
... ... @@ -50,7 +49,7 @@ func (svr *PgLoginService) Init(phone string) (err error) {
// 所有公司有效合伙人
_, svr.PartnerInfo, err = PartnerInfoService.Find(map[string]interface{}{"account": phone, "status": 1, "sortByCreateTime": "ASC"})
// 真实公司有效合伙人
_, svr.IsRealPartnerInfo, err = PartnerInfoService.Find(map[string]interface{}{"account": phone, "status": 1, "sortByCreateTime": "ASC", "isNot": constant.DEFAULT_GUEST_COMPANY})
_, svr.IsPartnerInfo, err = PartnerInfoService.Find(map[string]interface{}{"account": phone, "status": 1, "sortByCreateTime": "ASC", "isNot": constant.DEFAULT_GUEST_COMPANY})
// 游客公司合伙人
_, svr.GuestPartnerInfo, err = PartnerInfoService.Find(map[string]interface{}{"account": phone, "sortByCreateTime": "ASC", "companyId": constant.DEFAULT_GUEST_COMPANY})
// 游客公司有效合伙人
... ... @@ -64,8 +63,6 @@ func (svr *PgLoginService) Init(phone string) (err error) {
_, svr.IsSenior, err = UsersRepository.Find(map[string]interface{}{"phone": phone, "status": 1, "sortByCreateTime": "ASC", "deleteAtIsNull": true, "isSenior": 1})
// 真实公司有效高管
_, svr.IsRealSenior, err = UsersRepository.Find(map[string]interface{}{"phone": phone, "status": 1, "sortByCreateTime": "ASC", "deleteAtIsNull": true, "isSenior": 1, "isNot": constant.DEFAULT_GUEST_COMPANY})
// 真实公司有效用户
_, svr.IsRealUser, err = UsersRepository.Find(map[string]interface{}{"phone": phone, "status": 1, "sortByCreateTime": "ASC", "deleteAtIsNull": true, "isNot": constant.DEFAULT_GUEST_COMPANY})
return nil
}
... ... @@ -101,7 +98,7 @@ func (svr *PgLoginService) InitPartner(phone string) (err error) {
svr.Phone = phone
_, svr.IsRealPartnerInfo, err = PartnerInfoService.Find(map[string]interface{}{"account": phone, "status": 1, "sortByCreateTime": "ASC", "isNot": constant.DEFAULT_GUEST_COMPANY})
_, svr.IsPartnerInfo, err = PartnerInfoService.Find(map[string]interface{}{"account": phone, "status": 1, "sortByCreateTime": "ASC", "isNot": constant.DEFAULT_GUEST_COMPANY})
return nil
}
... ... @@ -362,7 +359,7 @@ func (svr *PgLoginService) ManagerStaticInfo() (interface{}, error) {
svr.HasAvailableManagerCompany = true
}
if len(companys) > 1 || len(svr.IsRealPartnerInfo) > 0 { // 有真实合伙公司或高管公司时,过滤游客公司
if len(companys) > 1 || len(svr.IsPartnerInfo) > 0 { // 有真实合伙公司或高管公司时,过滤游客公司
var companies = make([]protocol.CompanyBase, 0)
for _, company := range companys {
if company.Id != int64(constant.DEFAULT_GUEST_COMPANY) {
... ... @@ -457,7 +454,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 {
... ... @@ -483,7 +480,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 {
... ... @@ -574,27 +571,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
}
... ... @@ -630,7 +627,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))
}
... ...
... ... @@ -2,5 +2,6 @@ package company
type PartnersResponse struct {
// 唯一标识
Partners interface{} `json:"partners"`
Partners interface{} `json:"partners"`
Timestamp int64 `json:"timestamp"`
}
... ...
... ... @@ -14,9 +14,11 @@ type DividendStatisticsRequest struct {
//分红类型(0累计分红、1分红支出)
//DividendAction int `json:"dividendAction"`
PartnerId int64 `json:"partnerId"`
PageIndex int `json:"pageIndex"`
}
type DividendStatisticsResponse struct {
Statistics DividendStatistics `json:"statistics"`
Timestamp int64 `json:"timestamp"`
}
type DividendStatistics struct {
... ... @@ -41,7 +43,7 @@ type DividendOrdersRequest struct {
EndTime int64 `json:"endTime" valid:"Required"`
// 合作类型(空或不传,即所有类型)
JoinWays []*company.JoinWays `json:"joinWays"`
JoinWays []*company.JoinWays `json:"joinWays"`
PageIndex int `json:"pageIndex,omitempty"`
PageSize int `json:"pageSize,omitempty"`
... ...
... ... @@ -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,14 +88,15 @@ type OrderListRequest struct {
PageSize int `json:"pageSize" valid:"Required"`
OrderType int `json:"-"`
OrderTypes []int `json:"-"`
PartnerId int64 `json:"partnerId"`
JoinWay int `json:"joinWay"` //合伙方式(0或不传,即所有合伙方式)
IsToday bool `json:"isToday"`
PartnerId int64 `json:"partnerId"`
JoinWay int `json:"joinWay"` //合伙方式(0或不传,即所有合伙方式)
}
type OrderListResponse struct {
List []*OrderListItem `json:"list"`
Statistics map[string]interface{} `json:"-"`
Total int `json:"total"`
Timestamp int64 `json:"timestamp"`
}
type OrderListItem struct {
... ... @@ -117,7 +119,9 @@ type OrderListItem struct {
//订单金额
OrderAmount float64 `json:"orderAmount"`
// 订单更新时间
UpdateTime int64 `json:"updateTime"`
UpdateTime int64 `json:"updateTime"`
//销售时间
SalesTime int64 `json:"salesTime"`
//我的分红
MyDividend float64 `json:"dividendReceivable"`
//是否已读(0未读,1已读)
... ...