feat(supplier): add balance validation before card redemption

- Added returnIfAmountErr parameter to control error handling
- Implemented GetBalance query for order amount verification
- Return early with error message when balance check fails
- Updated card face type with validated order amount
- Removed unused login and queue system logic in batch six implementation
- Cleaned up debug log statements in middle open and trade cat implementations
This commit is contained in:
danial
2025-11-15 16:43:28 +08:00
parent c49365a1a8
commit ed1a063f02
20 changed files with 113 additions and 167 deletions

View File

@@ -37,70 +37,6 @@ func (c *BatchSixImpl) HasDependencyHTML() bool {
return false
}
// // 登录
// func (c *BatchSixImpl) login(ctx context.Context, jsonStr string) (bool, string, []*http.Cookie) {
// username := gojson.Json(jsonStr).Get("username").Tostring()
// loginCookieInterface, ok := c.cookie.Load(username)
// if ok {
// loginCookie, ok := loginCookieInterface.([]*http.Cookie)
// if ok {
// return true, "", loginCookie
// }
// }
// request := httplib.NewBeegoRequest("https://duika.666dkw.com/getLogin", "POST").
// SetTransport(otelhttp.NewTransport(http.DefaultTransport)).
// SetTimeout(time.Second*3, time.Second*30).Retries(30)
// loginReq := struct {
// Type int `json:"type"`
// Username string `json:"username"`
// CardKey string `json:"password"`
// }{
// Type: 0,
// Username: gojson.Json(jsonStr).Get("username").Tostring(),
// CardKey: gojson.Json(jsonStr).Get("password").Tostring(),
// }
// request, err := request.JSONBody(loginReq)
// if err != nil {
// otelTrace.Logger.WithContext(ctx).Error("JSONBody失败", zap.Error(err))
// return false, "登录请求格式失败", nil
// }
// response, err := request.Response()
// if err != nil {
// otelTrace.Logger.WithContext(ctx).Error("请求失败", zap.Error(err))
// return false, "登录返回数据错误", nil
// }
// var loginResp struct {
// Code int `json:"code"`
// Msg string `json:"msg"`
// Data string `json:"data"`
// }
// body, err := io.ReadAll(response.Body)
// if err != nil {
// otelTrace.Logger.WithContext(ctx).Error("读取响应体失败", zap.Error(err))
// return false, "登录返回数据错误", nil
// }
// otelTrace.Logger.WithContext(ctx).Info("登录响应", zap.Any("loginReq", loginReq), zap.String("body", string(body)))
// err = json.Unmarshal(body, &loginResp)
// if err != nil {
// otelTrace.Logger.WithContext(ctx).Error("解析失败", zap.Error(err))
// return false, "登录返回数据错误:" + string(body), nil
// }
// if loginResp.Code != 200 {
// otelTrace.Logger.WithContext(ctx).Error("登录失败", zap.String("msg", loginResp.Msg))
// return false, "登录失败:" + loginResp.Data, nil
// }
// otelTrace.Logger.WithContext(ctx).Info("登录成功", zap.String("data", loginResp.Data))
// loginCookie := response.Cookies()
// c.cookie.Store(gojson.Json(jsonStr).Get("username").Tostring(), loginCookie)
// return true, loginResp.Data, loginCookie
// }
func (c *BatchSixImpl) SendCard(ctx context.Context, jsonStr string, cardInfo supplier.RedeemCardInfo, attach string) (bool, string) {
ctx, span := otelTrace.Span(ctx, "BatchSixImpl", "sendCard", trace.WithAttributes(
attribute.String("jsonStr", jsonStr),
@@ -153,89 +89,6 @@ func (c *BatchSixImpl) SendCard(ctx context.Context, jsonStr string, cardInfo su
return true, "等待兑换"
}
// // 如果队列系统未初始化,使用原来的方式
// for range 3 {
// ok, data, loginCookie := c.login(ctx, jsonStr)
// if !ok {
// return false, data
// }
// otelTrace.Logger.WithContext(ctx).Info("发送卡密", zap.String("jsonStr", jsonStr), zap.Any("cardInfo", cardInfo), zap.String("attach", attach))
// request := httplib.NewBeegoRequest("https://duika.666dkw.com/apitocard", "POST").
// SetTransport(otelhttp.NewTransport(http.DefaultTransport)).
// SetTimeout(time.Second*3, time.Second*3).Retries(3)
// slice.ForEach(loginCookie, func(index int, item *http.Cookie) {
// otelTrace.Logger.WithContext(ctx).Info("cookie", zap.String("name", item.String()))
// if item.Name == "PHPSESSID" {
// request = request.SetCookie(item)
// }
// })
// id := gojson.Json(jsonStr).Get("id").Tostring()
// if id == "" {
// otelTrace.Logger.WithContext(ctx).Error("id为空")
// return false, "id为空"
// }
// idInt, err := strconv.ParseInt(id, 10, 64)
// if err != nil {
// otelTrace.Logger.WithContext(ctx).Error("解析失败", zap.Error(err))
// return false, "卡编码设置错误"
// }
// cardReq := struct {
// Id int64 `json:"id"`
// Cardlist []string `json:"cardlist"`
// Cardno string `json:"cardno"`
// Cardpwd string `json:"cardpwd"`
// Cardprice string `json:"cardprice"`
// Type int `json:"type"`
// Urgent int `json:"urgent"`
// Feilv string `json:"feilv"`
// }{
// Id: idInt,
// Cardlist: []string{},
// Cardno: cardInfo.CardNo,
// Cardpwd: cardInfo.Data,
// Cardprice: cardInfo.FaceType,
// Type: 0,
// Urgent: 0,
// Feilv: "",
// }
// request, err = request.JSONBody(cardReq)
// if err != nil {
// otelTrace.Logger.WithContext(ctx).Error("JSONBody失败", zap.Error(err))
// return false, "兑卡请求格式失败"
// }
// responseStr, err := request.String()
// if err != nil {
// otelTrace.Logger.WithContext(ctx).Error("请求失败", zap.Error(err))
// return false, "兑卡请求失败"
// }
// otelTrace.Logger.WithContext(ctx).Info("请求结果", zap.String("response", responseStr))
// var resp struct {
// Code json.Number `json:"code"`
// Msg string `json:"msg"`
// Data string `json:"data"`
// OrderNo string `json:"orderNo,omitempty"`
// }
// err = json.Unmarshal([]byte(responseStr), &resp)
// if err != nil {
// otelTrace.Logger.WithContext(ctx).Error("解析失败", zap.Error(err))
// return false, "兑卡返回数据错误:" + string(responseStr)
// }
// if resp.Code == "201" && resp.Data == "请先登录后再来提交" {
// c.cookie.Delete(gojson.Json(jsonStr).Get("username").Tostring())
// continue
// }
// if resp.Code != "200" {
// return false, resp.Data
// }
// return true, resp.Data
// }
return false, "兑换失败"
}

View File

@@ -38,6 +38,18 @@ func (c *CarelessImpl) HasDependencyHTML() bool {
}
func (c *CarelessImpl) SendCard(ctx context.Context, jsonStr string, cardInfo supplier.RedeemCardInfo, attach string, merchantInfo merchant.MerchantInfo, roadInfo road.RoadInfo) (bool, string) {
returnIfAmountErr := gojson.Json(jsonStr).Get("returnIfAmountErr").Tostring()
orderAmount, err := (&cardTypeQuery{
OrderNo: attach,
QueryType: gojson.Json(roadInfo.Params).Get("queryType").Tostring(),
CardNo: cardInfo.CardNo,
CardPwd: cardInfo.Data,
Balance: cardInfo.GetFaceTypeFloat(ctx),
}).GetBalance(ctx)
if returnIfAmountErr == "1" && err != nil {
return false, err.Error()
}
cardInfo.FaceType = strconv.FormatFloat(orderAmount, 'f', 2, 64)
merchantDeploy := merchant_deploy.GetMerchantDeployByUidAndRoadUid(ctx, merchantInfo.MerchantUid, roadInfo.RoadUid)
if merchantDeploy.MerchantUid == "" {
return false, "商户不存在"

View File

@@ -51,13 +51,17 @@ func sign(params map[string]any, keys []string, paySecret string) string {
}
func (f *FatSixImpl) sendCard(ctx context.Context, cardInfo supplier.RedeemCardInfo, orderInfo order.OrderInfo, roadInfo road.RoadInfo, merchantInfo merchant.MerchantInfo) (bool, string) {
orderAmount, _ := (&cardTypeQuery{
returnIfAmountErr := gojson.Json(roadInfo.Params).Get("returnIfAmountErr").Tostring()
orderAmount, err := (&cardTypeQuery{
OrderNo: orderInfo.BankOrderId,
QueryType: gojson.Json(roadInfo.Params).Get("queryType").Tostring(),
CardNo: cardInfo.CardNo,
CardPwd: cardInfo.Data,
Balance: cardInfo.GetFaceTypeFloat(ctx),
}).GetBalance(ctx)
if returnIfAmountErr == "1" && err != nil {
return false, err.Error()
}
cardInfo.FaceType = strconv.FormatFloat(orderAmount, 'f', 2, 64)
merchantDeploy := merchant_deploy.GetMerchantDeployByUidAndRoadUid(ctx, merchantInfo.MerchantUid, roadInfo.RoadUid)
if merchantDeploy.MerchantUid == "" {

View File

@@ -38,13 +38,17 @@ type FavorableCloudsCardImpl struct {
// SendCard 发送卡密
func (c *FavorableCloudsCardImpl) SendCard(ctx context.Context, jsonStr string, orderInfo order.OrderInfo, cardInfo supplier.RedeemCardInfo, attach string, roadInfo road.RoadInfo, merchantInfo merchant.MerchantInfo) (bool, string) {
orderAmount, _ := (&cardTypeQuery{
OrderNo: attach,
returnIfAmountErr := gojson.Json(roadInfo.Params).Get("returnIfAmountErr").Tostring()
orderAmount, err := (&cardTypeQuery{
OrderNo: orderInfo.BankOrderId,
QueryType: gojson.Json(roadInfo.Params).Get("queryType").Tostring(),
CardNo: cardInfo.CardNo,
CardPwd: cardInfo.Data,
Balance: cardInfo.GetFaceTypeFloat(ctx),
}).GetBalance(ctx)
if returnIfAmountErr == "1" && err != nil {
return false, err.Error()
}
cardInfo.FaceType = strconv.FormatFloat(orderAmount, 'f', 2, 64)
merchantDeploy := merchant_deploy.GetMerchantDeployByUidAndRoadUid(ctx, merchantInfo.MerchantUid, roadInfo.RoadUid)
if merchantDeploy.MerchantUid == "" {

View File

@@ -40,6 +40,18 @@ func (c *FlyFishImpl) HasDependencyHTML() bool {
}
func (c *FlyFishImpl) SendCard(ctx context.Context, jsonStr string, cardInfo supplier.RedeemCardInfo, attach string, merchantInfo merchant.MerchantInfo, roadInfo road.RoadInfo) (bool, string) {
returnIfAmountErr := gojson.Json(roadInfo.Params).Get("returnIfAmountErr").Tostring()
orderAmount, err := (&cardTypeQuery{
OrderNo: attach,
QueryType: gojson.Json(roadInfo.Params).Get("queryType").Tostring(),
CardNo: cardInfo.CardNo,
CardPwd: cardInfo.Data,
Balance: cardInfo.GetFaceTypeFloat(ctx),
}).GetBalance(ctx)
if returnIfAmountErr == "1" && err != nil {
return false, err.Error()
}
cardInfo.FaceType = strconv.FormatFloat(orderAmount, 'f', 2, 64)
merchantDeploy := merchant_deploy.GetMerchantDeployByUidAndRoadUid(ctx, merchantInfo.MerchantUid, roadInfo.RoadUid)
if merchantDeploy.MerchantUid == "" {
return false, "商户不存在"

View File

@@ -38,13 +38,17 @@ func (c *FlyFishV2Impl) HasDependencyHTML() bool {
}
func (c *FlyFishV2Impl) SendCard(ctx context.Context, jsonStr string, cardInfo supplier.RedeemCardInfo, attach string, merchantInfo merchant.MerchantInfo, roadInfo road.RoadInfo) (bool, string) {
orderAmount, _ := (&cardTypeQuery{
returnIfAmountErr := gojson.Json(roadInfo.Params).Get("returnIfAmountErr").Tostring()
orderAmount, err := (&cardTypeQuery{
OrderNo: attach,
QueryType: gojson.Json(roadInfo.Params).Get("queryType").Tostring(),
CardNo: cardInfo.CardNo,
CardPwd: cardInfo.Data,
Balance: cardInfo.GetFaceTypeFloat(ctx),
}).GetBalance(ctx)
if returnIfAmountErr == "1" && err != nil {
return false, err.Error()
}
cardInfo.FaceType = strconv.FormatFloat(orderAmount, 'f', 2, 64)
merchantDeploy := merchant_deploy.GetMerchantDeployByUidAndRoadUid(ctx, merchantInfo.MerchantUid, roadInfo.RoadUid)
if merchantDeploy.MerchantUid == "" {

View File

@@ -79,14 +79,18 @@ type HeepayProduct struct {
}
func (c *HeepayImpl) SendCard(ctx context.Context, jsonStr string, cardInfo supplier.RedeemCardInfo, attach string, merchantId string, orderInfo order.OrderInfo, roadInfo road.RoadInfo) (bool, string, string) {
orderAmount, _ := (&cardTypeQuery{
returnIfAmountErr := gojson.Json(roadInfo.Params).Get("returnIfAmountErr").Tostring()
orderAmount, err := (&cardTypeQuery{
OrderNo: attach,
QueryType: gojson.Json(roadInfo.Params).Get("queryType").Tostring(),
CardNo: cardInfo.CardNo,
CardPwd: cardInfo.Data,
Balance: cardInfo.GetFaceTypeFloat(ctx),
}).GetBalance(ctx)
if returnIfAmountErr == "1" && err != nil {
return false, err.Error(), err.Error()
}
cardInfo.FaceType = strconv.FormatFloat(orderAmount, 'f', 2, 64)
cardInfo.FaceType = strconv.FormatFloat(orderAmount, 'f', 2, 64)
agentID, err := convertor.ToInt(gojson.Json(jsonStr).Get("agent_id").Tostring())
if err != nil {

View File

@@ -37,13 +37,17 @@ func (c *LianInsImpl) HasDependencyHTML() bool {
}
func (c *LianInsImpl) SendCard(ctx context.Context, jsonStr string, cardInfo supplier.RedeemCardInfo, attach string, merchantInfo merchant.MerchantInfo, roadInfo road.RoadInfo) (bool, string) {
orderAmount, _ := (&cardTypeQuery{
returnIfAmountErr := gojson.Json(roadInfo.Params).Get("returnIfAmountErr").Tostring()
orderAmount, err := (&cardTypeQuery{
OrderNo: attach,
QueryType: gojson.Json(roadInfo.Params).Get("queryType").Tostring(),
CardNo: cardInfo.CardNo,
CardPwd: cardInfo.Data,
Balance: cardInfo.GetFaceTypeFloat(ctx),
}).GetBalance(ctx)
if returnIfAmountErr == "1" && err != nil {
return false, err.Error()
}
cardInfo.FaceType = strconv.FormatFloat(orderAmount, 'f', 2, 64)
otelTrace.Logger.WithContext(ctx).Info("获取订单金额", zap.Any("orderAmount", cardInfo))
merchantDeploy := merchant_deploy.GetMerchantDeployByUidAndRoadUid(ctx, merchantInfo.MerchantUid, roadInfo.RoadUid)

View File

@@ -46,13 +46,17 @@ func (c *LubanImpl) SendCard(ctx context.Context, jsonStr string, cardInfo suppl
if strings.HasPrefix(cardInfo.CardNo, "9529") {
queryType = "juheCard"
}
orderAmount, _ := (&cardTypeQuery{
returnIfAmountErr := gojson.Json(roadInfo.Params).Get("returnIfAmountErr").Tostring()
orderAmount, err := (&cardTypeQuery{
OrderNo: attach,
QueryType: queryType,
CardNo: cardInfo.CardNo,
CardPwd: cardInfo.Data,
Balance: cardInfo.GetFaceTypeFloat(ctx),
}).GetBalance(ctx)
if returnIfAmountErr == "1" && err != nil {
return false, err.Error()
}
cardInfo.FaceType = strconv.FormatFloat(orderAmount, 'f', 2, 64)
otelTrace.Logger.WithContext(ctx).Info("获取订单金额", zap.Any("orderAmount", cardInfo))
merchantDeploy := merchant_deploy.GetMerchantDeployByUidAndRoadUid(ctx, merchantInfo.MerchantUid, roadInfo.RoadUid)

View File

@@ -37,13 +37,18 @@ func (c *MagicFishImpl) HasDependencyHTML() bool {
}
func (c *MagicFishImpl) SendCard(ctx context.Context, jsonStr string, cardInfo supplier.RedeemCardInfo, attach string, merchantInfo merchant.MerchantInfo, roadInfo road.RoadInfo) (bool, string) {
orderAmount, _ := (&cardTypeQuery{
returnIfAmountErr := gojson.Json(roadInfo.Params).Get("returnIfAmountErr").Tostring()
orderAmount, err := (&cardTypeQuery{
OrderNo: attach,
QueryType: gojson.Json(roadInfo.Params).Get("queryType").Tostring(),
CardNo: cardInfo.CardNo,
CardPwd: cardInfo.Data,
Balance: cardInfo.GetFaceTypeFloat(ctx),
}).GetBalance(ctx)
if returnIfAmountErr == "1" && err != nil {
return false, err.Error()
}
cardInfo.FaceType = strconv.FormatFloat(orderAmount, 'f', 2, 64)
cardInfo.FaceType = strconv.FormatFloat(orderAmount, 'f', 2, 64)
otelTrace.Logger.WithContext(ctx).Info("获取订单金额", zap.Any("orderAmount", cardInfo))

View File

@@ -59,7 +59,6 @@ func (c *MiddleOpenImpl) generateSign(ctx context.Context, params map[string]int
sign_ += key2 + "=" + convertor.ToString(params[key2]) + "&"
}
sign_ += "key=" + key
otelTrace.Logger.WithContext(ctx).Info("构造sign参数", zap.Any("sign", sign_))
return utils.EncodeMd5Str(sign_)
}

View File

@@ -38,13 +38,17 @@ func (c *MyselfCardImpl) HasDependencyHTML() bool {
}
func (c *MyselfCardImpl) SendCard(ctx context.Context, jsonStr string, cardInfo supplier.RedeemCardInfo, orderInfo *order.OrderInfo, merchantInfo merchant.MerchantInfo, roadInfo road.RoadInfo) (bool, string) {
orderAmount, _ := (&cardTypeQuery{
returnIfAmountErr := gojson.Json(roadInfo.Params).Get("returnIfAmountErr").Tostring()
orderAmount, err := (&cardTypeQuery{
OrderNo: orderInfo.BankOrderId,
QueryType: gojson.Json(roadInfo.Params).Get("queryType").Tostring(),
CardNo: cardInfo.CardNo,
CardPwd: cardInfo.Data,
Balance: cardInfo.GetFaceTypeFloat(ctx),
}).GetBalance(ctx)
if returnIfAmountErr == "1" && err != nil {
return false, err.Error()
}
cardInfo.FaceType = strconv.FormatFloat(orderAmount, 'f', 2, 64)
merchantDeploy := merchant_deploy.GetMerchantDeployByUidAndRoadUid(ctx, merchantInfo.MerchantUid, roadInfo.RoadUid)
if merchantDeploy.MerchantUid == "" {

View File

@@ -58,13 +58,18 @@ func (c *NuclearImpl) generateSign(ctx context.Context, params map[string]string
}
func (c *NuclearImpl) sendCard(ctx context.Context, jsonStr string, cardInfo supplier.RedeemCardInfo, attach string, road road.RoadInfo, merchantInfo merchant.MerchantInfo, roadInfo road.RoadInfo) (bool, string) {
orderAmount, _ := (&cardTypeQuery{
returnIfAmountErr := gojson.Json(roadInfo.Params).Get("returnIfAmountErr").Tostring()
orderAmount, err := (&cardTypeQuery{
OrderNo: attach,
QueryType: gojson.Json(roadInfo.Params).Get("queryType").Tostring(),
CardNo: cardInfo.CardNo,
CardPwd: cardInfo.Data,
Balance: cardInfo.GetFaceTypeFloat(ctx),
}).GetBalance(ctx)
if returnIfAmountErr == "1" && err != nil {
return false, err.Error()
}
cardInfo.FaceType = strconv.FormatFloat(orderAmount, 'f', 2, 64)
cardInfo.FaceType = strconv.FormatFloat(orderAmount, 'f', 2, 64)
merchantDeployInfo := merchant_deploy.GetMerchantDeployByUidAndRoadUid(ctx, merchantInfo.MerchantUid, road.RoadUid)

View File

@@ -34,13 +34,17 @@ func (c *OriginImpl) HasDependencyHTML() bool {
}
func (c *OriginImpl) sendCard(ctx context.Context, jsonStr string, cardInfo supplier.RedeemCardInfo, attach string, road road.RoadInfo, merchantInfo merchant.MerchantInfo, roadInfo road.RoadInfo) (bool, string) {
orderAmount, _ := (&cardTypeQuery{
returnIfAmountErr := gojson.Json(jsonStr).Get("returnIfAmountErr").Tostring()
orderAmount, err := (&cardTypeQuery{
OrderNo: attach,
QueryType: gojson.Json(roadInfo.Params).Get("queryType").Tostring(),
CardNo: cardInfo.CardNo,
CardPwd: cardInfo.Data,
Balance: cardInfo.GetFaceTypeFloat(ctx),
}).GetBalance(ctx)
if returnIfAmountErr == "1" && err != nil {
return false, err.Error()
}
cardInfo.FaceType = strconv.FormatFloat(orderAmount, 'f', 2, 64)
merchantDeployInfo := merchant_deploy.GetMerchantDeployByUidAndRoadUid(ctx, merchantInfo.MerchantUid, road.RoadUid)

View File

@@ -43,6 +43,18 @@ func (c *ShanFuImpl) HasDependencyHTML() bool {
// SendCard 异步投递任务到线程池
func (c *ShanFuImpl) SendCard(ctx context.Context, jsonStr string, cardInfo supplier.RedeemCardInfo, attach string, merchantInfo merchant.MerchantInfo, roadInfo road.RoadInfo) (bool, string) {
returnIfAmountErr := gojson.Json(roadInfo.Params).Get("returnIfAmountErr").Tostring()
orderAmount, err := (&cardTypeQuery{
OrderNo: attach,
QueryType: gojson.Json(roadInfo.Params).Get("queryType").Tostring(),
CardNo: cardInfo.CardNo,
CardPwd: cardInfo.Data,
Balance: cardInfo.GetFaceTypeFloat(ctx),
}).GetBalance(ctx)
if returnIfAmountErr == "1" && err != nil {
return false, err.Error()
}
cardInfo.FaceType = strconv.FormatFloat(orderAmount, 'f', 2, 64)
merchantDeploy := merchant_deploy.GetMerchantDeployByUidAndRoadUid(ctx, merchantInfo.MerchantUid, roadInfo.RoadUid)
if merchantDeploy.MerchantUid == "" {
return false, "商户不存在"

View File

@@ -34,13 +34,18 @@ type ShengtianImpl struct {
}
func (f *ShengtianImpl) sendCard(ctx context.Context, cardInfo supplier.RedeemCardInfo, orderInfo order.OrderInfo, roadInfo road.RoadInfo, merchantInfo merchant.MerchantInfo) (bool, string) {
orderAmount, _ := (&cardTypeQuery{
returnIfAmountErr := gojson.Json(roadInfo.Params).Get("returnIfAmountErr").Tostring()
orderAmount, err := (&cardTypeQuery{
OrderNo: orderInfo.BankOrderId,
QueryType: gojson.Json(roadInfo.Params).Get("queryType").Tostring(),
CardNo: cardInfo.CardNo,
CardPwd: cardInfo.Data,
Balance: cardInfo.GetFaceTypeFloat(ctx),
}).GetBalance(ctx)
if returnIfAmountErr == "1" && err != nil {
return false, err.Error()
}
cardInfo.FaceType = strconv.FormatFloat(orderAmount, 'f', 2, 64)
cardInfo.FaceType = strconv.FormatFloat(orderAmount, 'f', 2, 64)
merchantDeploy := merchant_deploy.GetMerchantDeployByUidAndRoadUid(ctx, merchantInfo.MerchantUid, roadInfo.RoadUid)

View File

@@ -58,7 +58,6 @@ func (c *TradeCatCardImpl) generateSign(ctx context.Context, params map[string]i
sign_ += key2 + "=" + convertor.ToString(params[key2]) + "&"
}
sign_ += "key=" + key
fmt.Println("sign", sign_)
return strings.ToUpper(utils.EncodeMd5Str(sign_))
}

View File

@@ -34,13 +34,18 @@ type UpImpl struct {
}
func (f *UpImpl) sendCard(ctx context.Context, cardInfo supplier.RedeemCardInfo, orderInfo order.OrderInfo, roadInfo road.RoadInfo, merchantInfo merchant.MerchantInfo) (bool, string) {
orderAmount, _ := (&cardTypeQuery{
returnIfAmountErr := gojson.Json(roadInfo.Params).Get("returnIfAmountErr").Tostring()
orderAmount, err := (&cardTypeQuery{
OrderNo: orderInfo.BankOrderId,
QueryType: gojson.Json(roadInfo.Params).Get("queryType").Tostring(),
CardNo: cardInfo.CardNo,
CardPwd: cardInfo.Data,
Balance: cardInfo.GetFaceTypeFloat(ctx),
}).GetBalance(ctx)
if returnIfAmountErr == "1" && err != nil {
return false, err.Error()
}
cardInfo.FaceType = strconv.FormatFloat(orderAmount, 'f', 2, 64)
cardInfo.FaceType = strconv.FormatFloat(orderAmount, 'f', 2, 64)
merchantDeploy := merchant_deploy.GetMerchantDeployByUidAndRoadUid(ctx, merchantInfo.MerchantUid, roadInfo.RoadUid)

View File

@@ -40,14 +40,17 @@ func (w *WowsPayImpl) HasDependencyHTML() bool {
}
func (w *WowsPayImpl) sendCard(ctx context.Context, jsonStr string, cardInfo supplier.RedeemCardInfo, attach string, orderInfo order.OrderInfo, roadInfo road.RoadInfo, merchantInfo merchant.MerchantInfo) (bool, string) {
orderAmount, _ := (&cardTypeQuery{
returnIfAmountErr := gojson.Json(roadInfo.Params).Get("returnIfAmountErr").Tostring()
orderAmount, err := (&cardTypeQuery{
OrderNo: attach,
QueryType: gojson.Json(roadInfo.Params).Get("queryType").Tostring(),
CardNo: cardInfo.CardNo,
CardPwd: cardInfo.Data,
Balance: cardInfo.GetFaceTypeFloat(ctx),
}).GetBalance(ctx)
if returnIfAmountErr == "1" && err != nil {
return false, err.Error()
}
cardInfo.FaceType = strconv.FormatFloat(orderAmount, 'f', 2, 64)
merchantDeploy := merchant_deploy.GetMerchantDeployByUidAndRoadUid(ctx, merchantInfo.MerchantUid, roadInfo.RoadUid)
if merchantDeploy.MerchantUid == "" {

View File

@@ -34,15 +34,19 @@ type WtrImpl struct {
}
func (f *WtrImpl) sendCard(ctx context.Context, cardInfo supplier.RedeemCardInfo, orderInfo order.OrderInfo, roadInfo road.RoadInfo, merchantInfo merchant.MerchantInfo) (bool, string) {
orderAmount, _ := (&cardTypeQuery{
returnIfAmountErr := gojson.Json(roadInfo.Params).Get("returnIfAmountErr").Tostring()
orderAmount, err := (&cardTypeQuery{
OrderNo: orderInfo.BankOrderId,
QueryType: gojson.Json(roadInfo.Params).Get("queryType").Tostring(),
CardNo: cardInfo.CardNo,
CardPwd: cardInfo.Data,
Balance: cardInfo.GetFaceTypeFloat(ctx),
}).GetBalance(ctx)
if returnIfAmountErr == "1" && err != nil {
return false, err.Error()
}
cardInfo.FaceType = strconv.FormatFloat(orderAmount, 'f', 2, 64)
merchantDeploy := merchant_deploy.GetMerchantDeployByUidAndRoadUid(ctx, merchantInfo.MerchantUid, roadInfo.RoadUid)
if merchantDeploy.MerchantUid == "" {
return false, "商户不存在"