作者 Administrator

合并分支 'test' 到 'master'

Test



查看合并请求 !9
FROM 192.168.0.243:5000/mmm/allied-creation-gateway:libfontconfig
ENV APP_DIR $GOPATH/src/project-20211210
ENV APP_DIR $GOPATH/src/project-20211221
RUN mkdir -p $APP_DIR
WORKDIR $APP_DIR/
COPY ./pkg pkg
COPY ./config config
#COPY ./cmd/pdftopng cmd/pdftopng
COPY ./cmd/pdftopng cmd/pdftopng
COPY ./go.mod go.mod
COPY ./go.sum go.sum
COPY ./main.go main.go
... ...
... ... @@ -17,6 +17,8 @@ type UserSignUpCommand struct {
Password string `cname:"密码" json:"password" valid:"Required"`
// 密码
SmsCode string `cname:"短信验证码" json:"smsCode" valid:"Required"`
// 推荐人
Referrer string `cname:"推荐人" json:"referrer"`
}
func (companySignUpCommand *UserSignUpCommand) Valid(validation *validation.Validation) {
... ...
... ... @@ -427,6 +427,7 @@ func (svr AuthService) UserSignUp(signUpCommand *command.UserSignUpCommand) (int
Name: signUpCommand.Name,
Phone: signUpCommand.Phone,
Password: signUpCommand.Password,
Referrer: signUpCommand.Referrer,
})
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
... ...
... ... @@ -245,8 +245,8 @@ func (srv CooperationProjectService) PersonSearchCooperationProjectShareInfoAtta
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
// 不是本人查看需要做模糊处理
if response.Attachment != nil && len(response.Attachment.Url) > 0 {
// 不是本人查看需要做模糊处理,支付凭证不做模糊处理,合同需要模糊
if response.Attachment != nil && len(response.Attachment.Url) > 0 && projectQuery.AttachmentType == 1 {
if response.UserBaseId != projectQuery.Operator.UserBaseId {
// 大文件报错
if response.Attachment.FileSize != 0 && response.Attachment.FileSize > 10*1024*1024 {
... ...
... ... @@ -98,6 +98,86 @@ func (srv PersonStatisticsService) IndexStatistics(cmd *command.IndexStatisticsC
}, nil
}
// IndexStatistics 个人端 - 首页统计 (入口页面统计数据)
func (srv PersonStatisticsService) IndexStatisticsV2(cmd *command.IndexStatisticsCommand) (interface{}, error) {
gateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation(
cmd.Operator)
// 1.项目概览统计
contractStatisticsResult, err := gateway.CooperationStatistics(allied_creation_cooperation.PersonCooperationContractStatistics, map[string]interface{}{
"userBaseId": cmd.Operator.UserBaseId,
})
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
type contractStatistics struct {
ContractSum int `json:"contractSum"`
ContractStoppedSum int `json:"contractStoppedSum"`
}
var cs = &contractStatistics{}
if err := json.UnmarshalFromString(json.MarshalToString(contractStatisticsResult), cs); err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
var response = struct {
OrgIds []int `json:"orgIds"`
}{}
err = gateway.CooperationStatisticsWithObject(allied_creation_cooperation.PersonCooperationCompany, map[string]interface{}{
"userBaseId": cmd.Operator.UserBaseId,
}, &response)
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
var overview = map[string]interface{}{
"contractSum": cs.ContractSum, //总合约数
"contractStoppedSum": cs.ContractStoppedSum, //停止的合约数
"companySum": len(response.OrgIds), //共创企业数
}
year, month, _ := time.Now().Date()
beginTime := time.Date(year, month, 1, 0, 0, 0, 0, time.Local)
endTime := beginTime.AddDate(0, 1, 0)
// 2.本月分红统计 - 个人
unPaidResult, err := gateway.CooperationStatistics(allied_creation_cooperation.CreditAccountStatistics, map[string]interface{}{
"userBaseId": cmd.Operator.UserBaseId,
"beginTime": beginTime,
"endTime": endTime,
})
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
type AnnualDividend struct {
Total float64 `json:"total"`
Accounting float64 `json:"accounting"`
Accounted float64 `json:"accounted"`
Paid float64 `json:"paid"`
Unpaid float64 `json:"unpaid"`
}
var annualUnPaidDividend = &AnnualDividend{}
if err := json.UnmarshalFromString(json.MarshalToString(unPaidResult), annualUnPaidDividend); err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
// 2.本月分红统计 - 个人
paymentResult, err := gateway.CooperationStatistics(allied_creation_cooperation.CreditAccountStatistics, map[string]interface{}{
"userBaseId": cmd.Operator.UserBaseId,
"paymentBeginTime": beginTime,
"paymentEndTime": endTime,
})
var annualPaymentDividend = &AnnualDividend{}
if err := json.UnmarshalFromString(json.MarshalToString(paymentResult), annualPaymentDividend); err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
dividendStatistics := map[string]interface{}{
"dividendAmount": annualPaymentDividend.Paid + annualUnPaidDividend.Unpaid, // 分红金额 annualDividend.Total
"paidAmount": annualPaymentDividend.Paid, // 已支付
"unPaidAmount": annualUnPaidDividend.Unpaid, // 未支付
}
return map[string]interface{}{
"overview": overview,
"dividendStatistics": dividendStatistics,
}, nil
}
// CompanyStatistics 共创用户-共创企业统计
func (srv PersonStatisticsService) CompanyStatistics(cmd *command.CooperationPersonStatisticsCommand) (interface{}, error) {
... ... @@ -181,6 +261,85 @@ func (srv PersonStatisticsService) CompanyStatistics(cmd *command.CooperationPer
}, nil
}
// CompanyStatistics 共创用户-共创企业统计
func (srv PersonStatisticsService) CompanyStatisticsV2(cmd *command.CooperationPersonStatisticsCommand) (interface{}, error) {
gateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation(
cmd.Operator)
var response = struct {
OrgIds []int `json:"orgIds"`
}{}
err := gateway.CooperationStatisticsWithObject(allied_creation_cooperation.PersonCooperationCompany, map[string]interface{}{
"userBaseId": cmd.Operator.UserBaseId,
}, &response)
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
var companyList []int = response.OrgIds
if len(companyList) == 0 {
return map[string]interface{}{
"list": []struct{}{},
}, nil
}
result, err := gateway.CooperationStatistics(allied_creation_cooperation.CooperationCompanyStatistics, map[string]interface{}{
"userBaseId": cmd.Operator.UserBaseId,
"companyList": companyList,
})
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
type cooperationCompanyStatisticsResponse struct {
// 当天统计的企业id
OrgId int64 `json:"orgId"`
// 共创项目数
CooperationProjectCount int64 `json:"cooperationProjectCount"`
// 共创合约数
CooperationContractCount int64 `json:"cooperationContractCount"`
// 分红占比
DividendsRatio float64 `json:"dividendsRatio"`
// 分红支出
DividendsIncome float64 `json:"dividendsIncome"`
// 企业信息
Company domain.Company `json:"company"`
}
var cooperationCompanyStatisticsResponses []cooperationCompanyStatisticsResponse
if err := json.UnmarshalFromString(json.MarshalToString(result), &cooperationCompanyStatisticsResponses); err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
var values = make([]interface{}, 0)
gatewayUser := allied_creation_user.NewHttplibAlliedCreationUser(
cmd.Operator)
for i := range companyList {
for j := range cooperationCompanyStatisticsResponses {
if cooperationCompanyStatisticsResponses[j].OrgId == int64(companyList[i]) {
orgData, err := gatewayUser.OrgGet(allied_creation_user.ReqOrgGet{
OrgId: companyList[i],
FetchFlag: 1,
})
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
var companyLog string
if orgData.Company != nil {
companyLog = orgData.Company.Logo
}
cooperationCompanyStatisticsResponses[j].Company = domain.Company{
CompanyID: orgData.OrgID,
CompanyName: orgData.OrgName,
Logo: companyLog,
}
values = append(values, cooperationCompanyStatisticsResponses[j])
}
}
}
return map[string]interface{}{
"list": values,
}, nil
}
// CooperationProjectRecommend TODO:其他公司按公开的项目查 猜你喜欢(共创项目)
func (srv PersonStatisticsService) CooperationProjectRecommend(projectQuery *command.ListCooperationProjectQuery) (int64, interface{}, error) {
if projectQuery.Operator.UserBaseId > 0 {
... ...
... ... @@ -47,7 +47,7 @@ func init() {
LOG_TYPE = os.Getenv("LOG_TYPE")
}
if os.Getenv("SUPLUS_ADMIN_BASE_HOST") != "" {
ALLIED_CREATION_GATEWAY_HOST = os.Getenv("SUPLUS_ADMIN_BASE_HOST")
SUPLUS_ADMIN_BASE_HOST = os.Getenv("SUPLUS_ADMIN_BASE_HOST")
}
if os.Getenv("ALLIED_CREATION_GATEWAY_HOST") != "" {
ALLIED_CREATION_GATEWAY_HOST = os.Getenv("ALLIED_CREATION_GATEWAY_HOST")
... ...
... ... @@ -43,6 +43,8 @@ const (
PersonCooperationProjectSharedInfo = "PersonCooperationProjectSharedInfo"
// 个人 - 共创项目共享信息数据 - 附件
PersonCooperationProjectSharedInfoAttachment = "PersonCooperationProjectSharedInfoAttachment"
// 个人 - 共创企业
PersonCooperationCompany = "PersonCooperationCompany"
// 账期结算单统计
CreditAccountStatistics = "CreditAccountStatistics"
... ...
... ... @@ -167,6 +167,9 @@ func (gateway HttplibAlliedCreationUser) OrgEnable(param ReqOrgEnable) (*DataOrg
// Org[orgId} 返回组织
func (gateway HttplibAlliedCreationUser) OrgGet(param ReqOrgGet) (*DataOrgGet, error) {
url := gateway.baseUrL + "/org/" + strconv.Itoa(param.OrgId)
if param.FetchFlag > 0 {
url += fmt.Sprintf("?fetchFlag=%v", param.FetchFlag)
}
method := "get"
req := gateway.CreateRequest(url, method)
log.Logger.Debug("向用户模块请求数据:返回组织。", map[string]interface{}{
... ...
... ... @@ -24,6 +24,8 @@ type (
Phone string `cname:"手机号码" json:"phone" valid:"Required"`
// 密码
Password string `cname:"密码" json:"password" valid:"Required"`
// 推荐人
Referrer string `cname:"推荐人" json:"referrer"`
}
DataAuthUserSignUp struct {
... ...
package allied_creation_user
import "time"
//创建组织
type (
ReqOrgCreate struct {
... ... @@ -84,6 +86,8 @@ type (
type (
ReqOrgGet struct {
OrgId int `json:"orgId"`
// 获取标记 bit 0:获取企业数据
FetchFlag int `json:"fetchFlag"`
}
DataOrgGet struct {
... ... @@ -103,6 +107,17 @@ type (
ParentID int `json:"parentId"`
ParentPath string `json:"parentPath"`
//} `json:"org"`
Company *struct {
CompanyId int `json:"companyId"`
CompanyName string `json:"companyName"`
Scale string `json:"scale"`
IndustryCategory string `json:"industryCategory"`
RegisteredTime time.Time `json:"registeredTime"`
Status int64 `json:"status"`
Logo string `json:"logo"`
Address string `json:"address"`
SystemName string `json:"systemName"`
} `json:"company,omitempty"`
}
)
... ...
... ... @@ -2,6 +2,7 @@ package beego
import (
"encoding/json"
"net/http"
"os"
"strconv"
... ... @@ -45,7 +46,7 @@ func init() {
}
filters.SecureKeyMap["token"] = "x-mmm-accesstoken"
web.InsertFilter("/*", web.BeforeRouter, filters.AllowCors())
web.InsertFilter("/*", web.BeforeRouter, AllowCors())
web.InsertFilter("/*", web.BeforeRouter, filters.CreateRequstLogFilter(log.Logger))
web.InsertFilter("/v1/web/*", web.BeforeExec, middleware.CheckAccessToken2())
web.InsertFilter("/v1/app/*", web.BeforeExec, middleware.CheckAccessToken2())
... ... @@ -60,3 +61,19 @@ func init() {
))
//web.InsertFilterChain("/v1/*", middleware.CheckAccessToken)
}
func AllowCors() func(ctx *context.Context) {
return func(ctx *context.Context) {
ctx.Output.Header("Access-Control-Allow-Methods", "OPTIONS,DELETE,POST,GET,PUT,PATCH")
//ctx.Output.Header("Access-Control-Max-Age", "3600")
//ctx.Output.Header("Access-Control-Allow-Headers", "*,x-mmm-version")
ctx.Output.Header("Access-Control-Allow-Headers", "Content-Type,X-Mmm-Accesstoken,X-Mmm-Devicetype,X-Mmm-Sign,X-Mmm-Timestamp,X-Mmm-Uuid,X-Mmm-Version,x-mmm-appname,*")
ctx.Output.Header("Access-Control-Allow-Credentials", "true")
ctx.Output.Header("Access-Control-Allow-Origin", "*") //origin
if ctx.Input.Method() == http.MethodOptions {
// options请求,返回200
ctx.Output.SetStatus(http.StatusOK)
_ = ctx.Output.Body([]byte("options support"))
}
}
}
... ...
... ... @@ -391,6 +391,19 @@ func (controller *CooperationController) PersonCreditAccountPaySearch() {
controller.Response(data, err)
}
func (controller *CooperationController) PersonCreditAccountGet() {
svr := service.CompanyCreditAccountService{}
cmd := &command.CreditAccountGetCommand{}
err := controller.Unmarshal(cmd)
if err != nil {
log.Logger.Error(err.Error())
}
cmd.CreditAccountId, _ = controller.GetInt(":creditAccountId")
cmd.Operator = controller.GetOperator()
data, err := svr.CreditAccountGet(cmd)
controller.Response(data, err)
}
func (controller *CooperationController) PersonPaymentHistoryStatistics() {
svr := service.PersonCreditAccountService{}
cmd := &command.CreditAccountPaySearchCommand{}
... ... @@ -588,7 +601,7 @@ func (controller *CooperationController) PersonIndexStatistics() {
return
}
cmd.Operator = controller.GetOperator()
data, err := svr.IndexStatistics(cmd)
data, err := svr.IndexStatisticsV2(cmd)
controller.Response(data, err)
}
... ... @@ -601,7 +614,7 @@ func (controller *CooperationController) PersonCompanyStatistics() {
return
}
cmd.Operator = controller.GetOperator()
data, err := svr.CompanyStatistics(cmd)
data, err := svr.CompanyStatisticsV2(cmd)
controller.Response(data, err)
}
... ...
... ... @@ -53,6 +53,7 @@ func init() {
web.Router("/v1/app/company/credit-accounts/pay/search/person", &mobile_client.CooperationController{}, "Post:PersonCreditAccountPaySearch")
web.Router("/v1/app/credit-accounts/payment-history/statistics", &mobile_client.CooperationController{}, "Post:PersonPaymentHistoryStatistics")
web.Router("/v1/app/credit-accounts/payment-history/histogram-statistics", &mobile_client.CooperationController{}, "Post:PersonPaymentHistoryHistogramStatistics")
web.Router("/v1/app/credit-accounts/:creditAccountId", &mobile_client.CooperationController{}, "Get:PersonCreditAccountGet")
/***** CompanyDividends 企业端合约分红 *****/
web.Router("/v1/app/cooperation/company/dividends/contracts", &mobile_client.CooperationController{}, "Post:SearchDividendContracts")
... ...
... ... @@ -7,6 +7,7 @@ import (
"github.com/pdfcpu/pdfcpu/pkg/api"
"io/fs"
"io/ioutil"
"math/rand"
"net/http"
"os"
"os/exec"
... ... @@ -14,6 +15,7 @@ import (
"runtime"
"sort"
"strings"
"time"
)
const (
... ... @@ -113,8 +115,10 @@ func ImageBlur(filePath string) (string, error) {
// PDFBlur PDF 模糊处理
func PDFBlur(pdfPath string) (string, error) {
rand.Seed(time.Now().UnixNano())
filename := filepath.Base(pdfPath)
blurFilename := filepath.Join(outPath, BlurPrefix+filename)
tmpblurFilename := filepath.Join(outPath, BlurPrefix+fmt.Sprintf("%v-", rand.Int())+filename)
tmpImagePath, err := ioutil.TempDir("", "image-")
tmpImagePathBlur, err := ioutil.TempDir("", "image-"+BlurPrefix)
cmd := exec.Command(cmdPath, pdfPath, tmpImagePath+"/")
... ... @@ -132,10 +136,13 @@ func PDFBlur(pdfPath string) (string, error) {
_ = imaging.Save(dst, filepath.Join(tmpImagePathBlur, f.Name()))
}
sort.Strings(blurFiles)
err = api.ImportImagesFile(blurFiles, blurFilename, nil, nil)
err = api.ImportImagesFile(blurFiles, tmpblurFilename, nil, nil)
if err != nil {
return "", err
}
if err = os.Rename(tmpblurFilename, blurFilename); err != nil {
return "", nil
}
//clear
os.RemoveAll(tmpImagePath)
os.RemoveAll(tmpImagePathBlur)
... ...