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

@@ -414,7 +414,11 @@ func AddUserDeliveryAddress(ctx *jxcontext.Context, address *model.UserDeliveryA
db := dao.GetDB()
lng := address.Lng
lat := address.Lat
address.AutoAddress, address.DistrictCode, address.CityCode, err = getAddressInfoFromCoord(db, lng, lat)
autoAddress := ""
autoAddress, address.DistrictCode, address.CityCode, err = getAddressInfoFromCoord(db, lng, lat)
if address.AutoAddress == "" {
address.AutoAddress = autoAddress
}
if err == nil {
globals.SugarLogger.Debugf("AddUserDeliveryAddress2 address:%s", utils.Format4Output(address, true))
txDB, _ := dao.Begin(db)

View File

@@ -4,6 +4,7 @@ import (
"encoding/hex"
"fmt"
"git.rosy.net.cn/baseapi/utils"
"git.rosy.net.cn/jx-callback/business/model"
"git.rosy.net.cn/jx-callback/business/model/dao"
"git.rosy.net.cn/jx-callback/globals"
"io"
@@ -89,6 +90,10 @@ func (t *TcpClient) handleConn(c net.Conn) {
}
changePrinterStatus(printNo, status)
t.HandleCheckTcpHeart(printNo)
// todo 证明打印机已经被激活,将激活打印机存入数据库,保证用户不能无限制绑定打印机
if err := dao.NotExistsCreate(printNo); err != nil {
globals.SugarLogger.Debugf("监听打印机心跳,不存在则创建 :[%v]", err)
}
} else {
//在加到连接池中已经更新了时间所以放在else里
t.setPrintStatusTime(printNo)
@@ -258,6 +263,29 @@ func (t *TcpClient) doPrint(key string) (err error) {
if dataStr != "" {
a, b := getCallbackMsgInfo(dataStr)
t.changePrintMsg(dataStr, a, b)
// 查询打印机是否扣费,未扣费就扣费,已经扣费不做处理
have, err := dao.QueryOrderDeductionRecord(db, b, utils.Int64ToStr(a))
if err != nil && !have {
// 扣除打印机账号金额
if err = dao.DeductionPrintBalance(db, b); err != nil {
globals.SugarLogger.Debugf("扣除用户打印机金额错误 %s", err)
} else {
// 添加打印记录(支出记录)
if err = dao.AddPrintRecord(db, &model.PrintBillRecord{
CreatedAt: time.Now(),
UpdatedAt: time.Now(),
PrintNo: b,
PayType: 2,
PayMoney: 1, // 固定支出一分钱
OrderId: utils.Int64ToStr(a),
UserId: "",
}); err != nil {
globals.SugarLogger.Debugf("添加打印机订单支付记录错误 %s", err)
}
}
} else {
globals.SugarLogger.Debugf("查询打印机扣费记录错误 %s", err)
}
//判断音频暂停?
//收到打印成功回调后,如果消息中有音频,需要等待一下,等上一个音频播完
//暂停时间就暂时取的sound标签内内容长度/2

View File

@@ -545,21 +545,21 @@ func replaceContent(content string, printMsg *model.PrintMsg) (result string) {
func checkPrintMsg(db *dao.DaoDB, printMsg *model.PrintMsg) (err error) {
if printMsg.Content == "" {
return fmt.Errorf("此打印信息内容为空printMsg printNo:[%v], orderNo :[%v]", printMsg.PrintNo, printMsg.OrderNo)
return fmt.Errorf("此打印信息内容为空printMsg printNo:[%v], orderNo :[%v] 1", printMsg.PrintNo, printMsg.OrderNo)
}
if printMsg.PrintNo == "" {
return fmt.Errorf("此打印信息打印机编号为空printMsg printNo:[%v], orderNo :[%v]", printMsg.PrintNo, printMsg.OrderNo)
return fmt.Errorf("此打印信息打印机编号为空printMsg printNo:[%v], orderNo :[%v] 2", printMsg.PrintNo, printMsg.OrderNo)
}
if printMsg.OrderNo == "" {
return fmt.Errorf("此打印信息订单序号为空printMsg printNo:[%v], orderNo :[%v]", printMsg.PrintNo, printMsg.OrderNo)
}
if printer, err := dao.GetPrinter(db, printMsg.PrintNo); err == nil {
if printer != nil {
if printer.FlowFlag == 1 {
return fmt.Errorf("此打印机当月流量已用完请及时充值printNo:[%v]", printMsg.PrintNo)
}
}
return fmt.Errorf("此打印信息订单序号为空printMsg printNo:[%v], orderNo :[%v] 3", printMsg.PrintNo, printMsg.OrderNo)
}
//if printer, err := dao.GetPrinter(db, printMsg.PrintNo); err == nil {
// if printer != nil {
// if printer.FlowFlag == 1 {
// return fmt.Errorf("此打印机当月流量已用完请及时充值printNo:[%v]", printMsg.PrintNo)
// }
// }
//}
return err
}

View File

@@ -17,7 +17,7 @@ func TestPrintMsg(t *testing.T) {
ModelIDCULD: model.ModelIDCULD{},
PrintNo: "20220707000002",
Content: "<center>居中文字</center>",
OrderNo: "11111111", // 2147483648111
OrderNo: "1", // 2147483648111
Status: 0,
Comment: "",
MsgID: "1",

View File

@@ -7,7 +7,6 @@ import (
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
"git.rosy.net.cn/jx-callback/business/model"
"git.rosy.net.cn/jx-callback/business/model/dao"
"git.rosy.net.cn/jx-callback/globals"
"github.com/astaxie/beego/client/orm"
"time"
)
@@ -42,7 +41,6 @@ func AddBillExpend(txDB orm.TxOrmer, billID int64, billType, expendPrice, jobID
ExpendPrice: expendPrice,
JobID: jobID,
}
globals.SugarLogger.Debug("进入AddBillExpend")
dao.WrapAddIDCULEntity(billExpend, jxcontext.AdminCtx.GetUserName())
return dao.CreateEntityTx(txDB, billExpend)
}
@@ -70,7 +68,6 @@ func GetUserBillDetail(ctx *jxcontext.Context, userID, fromTime, toTime string,
func AddExpendUpdateAccount(txDB orm.TxOrmer, userBill *model.UserBill, billType, price, jobID int) (err error) {
//1、账户支出增加一条记录
globals.SugarLogger.Debug("进入AddExpendUpdateAccount")
err = AddBillExpend(txDB, userBill.BillID, billType, price, jobID)
if err != nil {
return err

View File

@@ -245,7 +245,6 @@ func OnTLPayCallback(call *tonglianpayapi.CallBackResult) (err error) {
}
func onTLpayFinished(call *tonglianpayapi.CallBackResult) (err error) {
globals.SugarLogger.Debug("进入微信回调============================")
order := &model.Order{
OrderID: call.CusorderID,
TransactionID: call.TrxID,
@@ -334,8 +333,6 @@ func onTLpayFinished(call *tonglianpayapi.CallBackResult) (err error) {
}
}
dao.Commit(db, txdb)
globals.SugarLogger.Debug("call.TrxStatus======================", call.TrxStatus)
globals.SugarLogger.Debug("order.OrderType======================", order.OrderType)
if call.TrxStatus == tonglianpayapi.TrxStatusSuccess {
switch order.OrderType {
case model.PayType4Express: