重构了boss系统,添加了逻辑

This commit is contained in:
kongyuebin
2021-11-11 10:30:43 +08:00
parent 4967a137ec
commit 7cd2e963ad
62 changed files with 663 additions and 3902 deletions

View File

@@ -0,0 +1,196 @@
/***************************************************
** @Desc : This file for ...
** @Time : 2019/10/28 10:15
** @Author : yuebin
** @File : order_info
** @Last Modified by : yuebin
** @Last Modified time: 2019/10/28 10:15
** @Software: GoLand
****************************************************/
package order
import (
"fmt"
"github.com/beego/beego/v2/client/orm"
"github.com/beego/beego/v2/core/logs"
"strconv"
)
type OrderInfo struct {
Id int
ShopName string //商品名称
OrderPeriod string //订单有效时间
MerchantOrderId string //商户订单id
BankOrderId string //本系统订单id
BankTransId string //上游流水id
OrderAmount float64 //订单提交的金额
ShowAmount float64 //待支付的金额
FactAmount float64 //用户实际支付金额
RollPoolCode string //轮询池编码
RollPoolName string //轮询池名臣
RoadUid string //通道标识
RoadName string //通道名称
PayProductName string //上游支付公司的名称
PayProductCode string //上游支付公司的编码代号
PayTypeCode string //支付产品编码
PayTypeName string //支付产品名称
OsType string //操作系统类型
Status string //订单支付状态
Refund string //退款状态
RefundTime string //退款操作时间
Freeze string //冻结状态
FreezeTime string //冻结时间
Unfreeze string //是否已经解冻
UnfreezeTime string //解冻时间
ReturnUrl string //支付完跳转地址
NotifyUrl string //下游回调地址
MerchantUid string //商户id
MerchantName string //商户名称
AgentUid string //该商户所属代理
AgentName string //该商户所属代理名称
UpdateTime string
CreateTime string
}
const ORDER_INFO = "order_info"
func BankOrderIdIsEixst(bankOrderId string) bool {
o := orm.NewOrm()
exists := o.QueryTable(ORDER_INFO).Filter("bank_order_id", bankOrderId).Exist()
return exists
}
func GetOrderLenByMap(params map[string]string) int {
o := orm.NewOrm()
qs := o.QueryTable(ORDER_INFO)
for k, v := range params {
if len(v) > 0 {
qs = qs.Filter(k, v)
}
}
cnt, _ := qs.Limit(-1).Count()
return int(cnt)
}
func GetOrderByMap(params map[string]string, display, offset int) []OrderInfo {
o := orm.NewOrm()
var orderInfoList []OrderInfo
qs := o.QueryTable(ORDER_INFO)
for k, v := range params {
if len(v) > 0 {
qs = qs.Filter(k, v)
}
}
_, err := qs.Limit(display, offset).OrderBy("-create_time").All(&orderInfoList)
if err != nil {
logs.Error("get order by map fail: ", err)
}
return orderInfoList
}
func GetSuccessRateByMap(params map[string]string) string {
o := orm.NewOrm()
qs := o.QueryTable(ORDER_INFO)
for k, v := range params {
if len(v) > 0 {
qs = qs.Filter(k, v)
}
}
successRate := "0%"
allCount, _ := qs.Limit(-1).Count()
successCount, _ := qs.Filter("status", "success").Limit(-1).Count()
if allCount == 0 {
return successRate
}
tmp := float64(successCount) / float64(allCount) * 100
successRate = fmt.Sprintf("%.1f", tmp)
return successRate + "%"
}
func GetAllAmountByMap(params map[string]string) float64 {
o := orm.NewOrm()
condition := "select sum(order_amount) as allAmount from order_info "
for _, v := range params {
if len(v) > 0 {
condition = condition + "where "
break
}
}
flag := false
if params["create_time__gte"] != "" {
flag = true
condition = condition + " create_time >= '" + params["create_time__gte"] + "'"
}
if params["create_time__lte"] != "" {
if flag {
condition = condition + " and "
}
condition = condition + " create_time <= '" + params["create_time__lte"] + "'"
}
if params["merchant_name__icontains"] != "" {
if flag {
condition = condition + " and "
}
condition = condition + "merchant_name like %'" + params["merchant_name__icontains"] + "'% "
}
if params["merchant_order_id"] != "" {
if flag {
condition = condition + " and "
}
condition = condition + " merchant_order_id = '" + params["merchant_order_id"] + "'"
}
if params["bank_order_id"] != "" {
if flag {
condition = condition + " and "
}
condition = condition + " bank_order_id = '" + params["bank_order_id"] + "'"
}
if params["status"] != "" {
if flag {
condition = condition + " and "
}
condition = condition + "status = '" + params["status"] + "'"
}
if params["pay_product_code"] != "" {
if flag {
condition = condition + " and "
}
condition = condition + "pay_product_code = " + params["pay_product_code"] + "'"
}
if params["pay_type_code"] != "" {
if flag {
condition = condition + " and "
}
condition = condition + "pay_type_code = " + params["pay_type_code"]
}
logs.Info("get order amount str = ", condition)
var maps []orm.Params
allAmount := 0.00
num, err := o.Raw(condition).Values(&maps)
if err == nil && num > 0 {
allAmount, _ = strconv.ParseFloat(maps[0]["allAmount"].(string), 64)
}
return allAmount
}
func GetOrderByBankOrderId(bankOrderId string) OrderInfo {
o := orm.NewOrm()
var orderInfo OrderInfo
_, err := o.QueryTable(ORDER_INFO).Filter("bank_order_id", bankOrderId).Limit(1).All(&orderInfo)
if err != nil {
logs.Error("get order info by bankOrderId fail: ", err)
}
return orderInfo
}
func GetOneOrder(bankOrderId string) OrderInfo {
o := orm.NewOrm()
var orderInfo OrderInfo
_, err := o.QueryTable(ORDER_INFO).Filter("bank_order_id", bankOrderId).Limit(1).All(&orderInfo)
if err != nil {
logs.Error("get one order fail: ", err)
}
return orderInfo
}

View File

@@ -0,0 +1,119 @@
/***************************************************
** @Desc : This file for ...
** @Time : 2019/10/30 11:44
** @Author : yuebin
** @File : order_profit_info
** @Last Modified by : yuebin
** @Last Modified time: 2019/10/30 11:44
** @Software: GoLand
****************************************************/
package order
import (
"github.com/beego/beego/v2/client/orm"
"github.com/beego/beego/v2/core/logs"
"strings"
)
type OrderProfitInfo struct {
Id int
MerchantName string
MerchantUid string
AgentName string
AgentUid string
PayProductCode string
PayProductName string
PayTypeCode string
PayTypeName string
Status string
MerchantOrderId string
BankOrderId string
BankTransId string
OrderAmount float64
ShowAmount float64
FactAmount float64
UserInAmount float64
SupplierRate float64
PlatformRate float64
AgentRate float64
AllProfit float64
SupplierProfit float64
PlatformProfit float64
AgentProfit float64
UpdateTime string
CreateTime string
}
const ORDER_PROFIT_INFO = "order_profit_info"
func GetOrderProfitByBankOrderId(bankOrderId string) OrderProfitInfo {
o := orm.NewOrm()
var orderProfit OrderProfitInfo
_, err := o.QueryTable(ORDER_PROFIT_INFO).Filter("bank_order_id", bankOrderId).Limit(1).All(&orderProfit)
if err != nil {
logs.Error("GetOrderProfitByBankOrderId fail", err)
}
return orderProfit
}
func GetOrderProfitLenByMap(params map[string]string) int {
o := orm.NewOrm()
qs := o.QueryTable(ORDER_PROFIT_INFO)
for k, v := range params {
if len(v) > 0 {
qs = qs.Filter(k, v)
}
}
cnt, _ := qs.Limit(-1).Count()
return int(cnt)
}
func GetOrderProfitByMap(params map[string]string, display, offset int) []OrderProfitInfo {
o := orm.NewOrm()
var orderProfitInfoList []OrderProfitInfo
qs := o.QueryTable(ORDER_PROFIT_INFO)
for k, v := range params {
if len(v) > 0 {
qs = qs.Filter(k, v)
}
}
_, err := qs.Limit(display, offset).OrderBy("-update_time").All(&orderProfitInfoList)
if err != nil {
logs.Error("get order by map fail: ", err)
}
return orderProfitInfoList
}
func GetPlatformProfitByMap(params map[string]string) []PlatformProfit {
o := orm.NewOrm()
cond := "select merchant_name, agent_name, pay_product_name as supplier_name, pay_type_name, sum(fact_amount) as order_amount, count(1) as order_count, " +
"sum(platform_profit) as platform_profit, sum(agent_profit) as agent_profit from " + ORDER_PROFIT_INFO + " where status='success' "
flag := false
for k, v := range params {
if len(v) > 0 {
if flag {
cond += " and"
}
if strings.Contains(k, "create_time__gte") {
cond = cond + " create_time>='" + v + "'"
} else if strings.Contains(k, "create_time__lte") {
cond = cond + " create_time<='" + v + "'"
} else {
cond = cond + " " + k + "='" + v + "'"
}
flag = true
}
}
cond += " group by merchant_uid, agent_uid, pay_product_code, pay_type_code"
var platformProfitList []PlatformProfit
_, err := o.Raw(cond).QueryRows(&platformProfitList)
if err != nil {
logs.Error("get platform profit by map fail:", err)
}
return platformProfitList
}

View File

@@ -0,0 +1,51 @@
/***************************************************
** @Desc : This file for ...
** @Time : 2019/10/30 11:41
** @Author : yuebin
** @File : order_settle_info
** @Last Modified by : yuebin
** @Last Modified time: 2019/10/30 11:41
** @Software: GoLand
****************************************************/
package order
import (
"github.com/beego/beego/v2/client/orm"
"github.com/beego/beego/v2/core/logs"
)
type OrderSettleInfo struct {
Id int
PayProductCode string
PayProductName string
PayTypeCode string
RoadUid string
PayTypeName string
MerchantUid string
MerchantName string
MerchantOrderId string
BankOrderId string
SettleAmount float64
IsAllowSettle string
IsCompleteSettle string
UpdateTime string
CreateTime string
}
const ORDER_SETTLE_INFO = "order_settle_info"
func GetOrderSettleListByParams(params map[string]string) []OrderSettleInfo {
o := orm.NewOrm()
qs := o.QueryTable(ORDER_SETTLE_INFO)
for k, v := range params {
if len(v) > 0 {
qs = qs.Filter(k, v)
}
}
var orderSettleList []OrderSettleInfo
if _, err := qs.Limit(-1).All(&orderSettleList); err != nil {
logs.Error("get order settle list fail: ", err)
}
return orderSettleList
}

View File

@@ -0,0 +1,21 @@
/***************************************************
** @Desc : This file for ...
** @Time : 2019/12/17 17:50
** @Author : yuebin
** @File : platform_profit
** @Last Modified by : yuebin
** @Last Modified time: 2019/12/17 17:50
** @Software: GoLand
****************************************************/
package order
type PlatformProfit struct {
MerchantName string
AgentName string
SupplierName string
PayTypeName string
OrderAmount float64
OrderCount int
PlatformProfit float64
AgentProfit float64
}