1
This commit is contained in:
7
business/model/dao/print_bill.go
Normal file
7
business/model/dao/print_bill.go
Normal 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
|
||||
}
|
||||
32
business/model/dao/print_bill_record.go
Normal file
32
business/model/dao/print_bill_record.go
Normal 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)
|
||||
}
|
||||
13
business/model/print_bill.go
Normal file
13
business/model/print_bill.go
Normal 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"` // 打印机所属用户
|
||||
}
|
||||
15
business/model/print_bill_record.go
Normal file
15
business/model/print_bill_record.go
Normal file
@@ -0,0 +1,15 @@
|
||||
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"` // 打印机所属用户
|
||||
}
|
||||
Reference in New Issue
Block a user