mixpay优化

This commit is contained in:
richboo111
2022-09-19 15:54:38 +08:00
19 changed files with 288 additions and 46 deletions

View File

@@ -0,0 +1,14 @@
package dao
import (
"time"
)
func NotExistsCreate(printNo string) error {
sql := `INSERT INTO print_activation (print_no,created_at) SELECT ?,? FROM dual WHERE NOT EXISTS (SELECT * FROM print_activation WHERE print_no = ?)`
param := []interface{}{printNo, time.Now(), printNo}
if _, err := ExecuteSQL(GetDB(), sql, param...); err != nil {
return err
}
return nil
}

View File

@@ -0,0 +1,7 @@
package dao
// DeductionPrintBalance 扣除打印机账号余额
func DeductionPrintBalance(db *DaoDB, printNo string) error {
_, err := ExecuteSQL(db, `UPDATE print_bill SET print_balance = print_balance -1 WHERE print_no = ?`, []interface{}{printNo}...)
return err
}

View File

@@ -0,0 +1,32 @@
package dao
import (
"git.rosy.net.cn/jx-callback/business/model"
"time"
)
// QueryOrderDeductionRecord 查询订单扣除记录
func QueryOrderDeductionRecord(db *DaoDB, printNo string, orderNo string) (bool, error) {
sql := `SELECT * FROM print_bill_record WHERE print_no = ? AND order_no = ? AND created_at > ? AND created_at < ?`
timeNow := time.Now()
startTime := time.Date(timeNow.Year(), timeNow.Month(), timeNow.Day(), 0, 0, 0, 0, timeNow.Location())
endTime := time.Date(timeNow.Year(), timeNow.Month(), timeNow.Day(), 23, 59, 59, 0, timeNow.Location())
param := []interface{}{printNo, orderNo, startTime, endTime}
var result []*model.PrintBillRecord
if err := GetRows(db, &result, sql, param...); err != nil {
return false, err
}
if len(result) == 0 {
return false, nil
}
return true, nil
}
// AddPrintRecord 添加打印记录
func AddPrintRecord(db *DaoDB, param *model.PrintBillRecord) error {
return CreateEntity(db, param)
}

View File

@@ -32,7 +32,7 @@ type Printer struct {
}
type SystemTemp struct {
ID int `json:"id" db:"id"`
ID int `orm:"column(id)" json:"id" db:"id"`
CreatedAt *time.Time `json:"created_at" db:"created_at"`
UpdatedAt *time.Time `json:"updated_at" db:"updated_at"`
LastOperator string `json:"last_operator" db:"last_operator"`
@@ -46,3 +46,97 @@ type SystemTemp struct {
PrintSn string `json:"print_sn" db:"print_sn"` // 模板所属打印机
IsUse int `json:"is_use" db:"is_use"` // 默认使用 1-使用/2-不使用
}
type Apps struct {
ID int `orm:"column(id)" json:"id" db:"id"`
CreatedAt *time.Time `json:"created_at" db:"created_at"`
UpdatedAt *time.Time `json:"updated_at" db:"updated_at"`
LastOperator string `json:"last_operator" db:"last_operator"`
DeletedAt *time.Time `json:"deleted_at" db:"deleted_at"`
UserID string `orm:"column(user_id)" json:"user_id" db:"user_id"` //属于哪个账号的
Name string `json:"name"` //应用名称
Type int `json:"type"` //应用类型
AppKey string `json:"app_key" db:"app_key"` //Key
Status int `json:"status"` //状态
Mobile string `json:"mobile"` //手机号
}
type MenuDetail struct {
ID int `orm:"column(id)" json:"id" db:"id"`
CreatedAt *time.Time `json:"created_at" db:"created_at"`
UpdatedAt *time.Time `json:"updated_at" db:"updated_at"`
LastOperator string `json:"last_operator" db:"last_operator"`
DeletedAt *time.Time `json:"deleted_at" db:"deleted_at"`
MenuID int `orm:"column(menu_id)" json:"menu_id" db:"menu_id"`
Name string `json:"name"`
Content string `json:"content"`
URL string `orm:"column(url)" json:"url" db:"url"`
Method string `json:"method"`
PublicParam string `json:"public_param" db:"public_param"`
PrivateParam string `json:"private_param" db:"private_param"`
CallParam string `json:"call_param" db:"call_param"`
ReturnParam string `json:"return_param" db:"return_param"`
ReturnEX string `orm:"column(return_ex)" json:"return_ex" db:"return_ex"`
}
//流量支出
type SimFlowExpend struct {
ID int `orm:"column(id)" json:"id" db:"id"`
CreatedAt *time.Time `json:"created_at" db:"created_at"`
UpdatedAt *time.Time `json:"updated_at" db:"updated_at"`
LastOperator string `json:"last_operator" db:"last_operator"`
IccID string `orm:"column(icc_id)" json:"icc_id" db:"icc_id"` //sim卡iccid
Flow float64 `json:"flow"` //流量数
FlowUnit string `json:"flow_unit" db:"flow_unit"` //流量单位
}
//流量划入
type SimFlowIncome struct {
ID int `orm:"column(id)" json:"id" db:"id"`
CreatedAt *time.Time `json:"created_at" db:"created_at"`
UpdatedAt *time.Time `json:"updated_at" db:"updated_at"`
LastOperator string `json:"last_operator" db:"last_operator"`
IccID string `orm:"column(icc_id)" json:"icc_id" db:"icc_id"` //sim卡iccid
Flow float64 `json:"flow"` //流量数
FlowUnit string `json:"flow_unit" db:"flow_unit"` //流量单位
IncomeType int `json:"income_type" db:"income_type"` //1 表示系统每月自动划转2 表示商户自己冲的
OrderID string `orm:"column(order_id)" json:"order_id" db:"order_id"` //订单号
}
type PayOrder struct {
ID int `orm:"column(id)" json:"id" db:"id"`
CreatedAt *time.Time `json:"created_at" db:"created_at"`
OrderID string `orm:"column(order_id)" json:"order_id" db:"order_id"` //订单号
UserID string `orm:"column(user_id)" json:"user_id" db:"user_id"` //用户ID
OrderType string `json:"order_type" db:"order_type"` //订单类型,流量充值等
Origin string `json:"origin"` //订单来源,小程序,开放后台
Status int `json:"status"` //订单状态,待支付2已支付5支付成功110支付失败115
PayPrice int64 `json:"pay_price" db:"pay_price"` //支付金额
TransactionID string `orm:"column(transaction_id)" json:"transaction_id" db:"transaction_id"` // 支付成功后支付方生成的事务ID
PayFinishedAt *time.Time `json:"pay_finished_at" db:"pay_finished_at"`
PrepayID string `orm:"column(prepay_id)" json:"prepay_id" db:"prepay_id"` // 下单后支付前支付方生成的事务ID
OriginalData *string `json:"original_data" db:"original_data"`
Comment string `json:"comment"` //备注
ThingID string `orm:"column(thing_id)" json:"thing_id" db:"thing_id"` //订单充值项目ID
TypeID string `orm:"column(type_id)" json:"type_id" db:"type_id"` //类型ID充流量就是套餐对应的id
}
type OrderPay struct {
ID int `orm:"column(id)" json:"id" db:"id"`
CreatedAt time.Time `orm:"type(datetime)" json:"created_at" db:"created_at"` // 创建时间
UpdatedAt time.Time `orm:"type(datetime)" json:"updated_at" db:"updated_at"` // 更新时间
PayOrderID string `orm:"column(pay_order_id);size(48)" json:"pay_order_id" db:"pay_order_id"` // 京西支付定单号
PayType int `orm:"type(int);size(2)" json:"pay_type" db:"pay_type"` // 支付类型[1-微信,2-通联,3-抖音]
VendorPayType string `orm:"size(48)" json:"vendorPayType"` //
VendorOrderID string `orm:"column(vendor_order_id);size(48);index" json:"vendor_order_id" db:"vendor_order_id"` // 支付对应的购物订单号
PrintNo string `orm:"column(print_no);size(48);index" json:"print_no" db:"print_no"` // 充值打印机编号
Status int `orm:"type(int);size(2)" json:"status" json:"status" db:"status"` // 订单支付状态
PayCreatedAt time.Time `orm:"type(datetime);index" json:"pay_created_at" db:"pay_created_at"` // 下单时间
PayFinishedAt time.Time `orm:"type(datetime)" json:"pay_finished_at" db:"pay_finished_at"` // 支付完成时间
TotalFee int `orm:"type(int);size(11)" json:"total_fee" db:"total_fee"` // 支付金额
PrepayID string `orm:"column(prepay_id);index;size(48)" json:"prepay_id" db:"prepay_id"` // 下单后支付前支付方生成的事务ID
TransactionID string `orm:"column(transaction_id);index;size(48)" json:"transaction_id" db:"transaction_id"` // 支付成功后支付方生成的事务ID
OriginalData string `orm:"type(text)" json:"-"` // 返回消息
VendorID int `orm:"column(vendor_id)" json:"vendor_id" db:"vendor_id"` // 购物订单所属厂商代码(当前只有京西)
CodeURL string `orm:"column(code_url);size(3200)" json:"codeURL"` //
}

View File

@@ -0,0 +1,10 @@
package model
import "time"
// PrintActivation 打印机激活记录
type PrintActivation struct {
ID int `orm:"column(id)" json:"id" db:"id"`
CreatedAt time.Time `json:"created_at" db:"created_at"`
PrintNo string `orm:"type(varchar);size(32);index" json:"print_no" db:"print_no"` // 打印机编号
}

View File

@@ -0,0 +1,13 @@
package model
import "time"
// PrintBill 打印机账户
type PrintBill struct {
ID int `orm:"column(id)" json:"id" db:"id"`
CreatedAt time.Time `json:"created_at" db:"created_at"`
UpdatedAt time.Time `json:"updated_at" db:"updated_at"`
PrintNo string `orm:"type(varchar);size(32);index" json:"print_no" db:"print_no"` // 打印机编号
PrintBalance int64 `orm:"type(int);size(16)" json:"print_balance" db:"print_balance"` // 账户余额
UserId string `orm:"type(varchar);size(125)" json:"user_id" db:"user_id"` // 打印机所属用户
}

View File

@@ -0,0 +1,28 @@
package model
import "time"
// PrintBillRecord 打印机充值/小费记录
type PrintBillRecord struct {
ID int `orm:"column(id)" json:"id" db:"id"`
CreatedAt time.Time `json:"created_at" db:"created_at"`
UpdatedAt time.Time `json:"updated_at" db:"updated_at"`
PrintNo string `orm:"type(varchar);size(32);index" json:"print_no" db:"print_no"` // 打印机编号
PayType int `orm:"type(int);size(2)" json:"pay_type" db:"pay_type"` // 支付类型[1-充值/2-支出]
PayMoney int `orm:"type(int);size(10)" json:"pay_money" db:"pay_money"` // 金额
OrderId string `orm:"type(varchar);size(64);index" json:"order_id" db:"order_id"` // 订单号
UserId string `orm:"type(varchar);size(125)" json:"user_id" db:"user_id"` // 打印机所属用户
}
type PrintBindStore struct {
ID int `orm:"column(id)" json:"id" db:"id"`
CreatedAt time.Time `orm:"type(datetime)" json:"created_at" db:"created_at"` // 创建时间
UpdatedAt time.Time `orm:"type(datetime)" json:"updated_at" db:"updated_at"` // 更新时间
StoreID int64 `orm:"column(store_id);type(int);size(11)" json:"store_id" db:"store_id"` // 门店id(为京西创建门店id)唯一
StoreName string `orm:"type(varchar);size(255)" json:"store_name" db:"store_name"` // 门店名称
StoreVendor int `orm:"type(int);size(2)" json:"store_vendor" db:"store_vendor"` // 门店平台
PrintNo string `orm:"type(varchar);size(32);index" json:"print_no" db:"print_no"` // 打印机编号
UserId string `orm:"type(varchar);size(125)" json:"user_id" db:"user_id"` // 打印机所属用户
StoreStatus int `orm:"type(int);size(2)" json:"store_status" db:"store_status"` // 门店状态
BindStatus int `orm:"type(int);size(2)" json:"bind_status" db:"bind_status"` // 绑定状态
}