支付模块
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

pay_config.go 2.0 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. package pay
  2. import (
  3. "code.fnuoos.com/go_rely_warehouse/zyos_go_pay.git/db"
  4. "code.fnuoos.com/go_rely_warehouse/zyos_go_pay.git/db/model"
  5. "code.fnuoos.com/go_rely_warehouse/zyos_go_tools.git/e"
  6. "code.fnuoos.com/go_rely_warehouse/zyos_go_tools.git/utils/cache"
  7. "xorm.io/xorm"
  8. )
  9. //支付渠道获取
  10. func JudgePayChannel(mid, paySceneIdentifier string) (model.PayChannelMaster, error) {
  11. var payChannelMaster = model.PayChannelMaster{}
  12. res, err := db.Db.Where("app_id = ?", mid).And("identifier = ?", paySceneIdentifier).Get(&payChannelMaster)
  13. if err != nil {
  14. return payChannelMaster, err
  15. }
  16. if !res {
  17. return payChannelMaster, e.NewErr(400, "查询数据失败")
  18. }
  19. if payChannelMaster.ChannelId == 0 {
  20. return payChannelMaster, e.NewErr(400, "请联系服务商绑定支付渠道")
  21. }
  22. return payChannelMaster, nil
  23. }
  24. //客户端支付宝配置
  25. func OwnCustomAlipayConfig(eg *xorm.Engine, args map[string]string) map[string]string {
  26. cache.NewRedis(args["redis_addr"])
  27. var paySet = map[string]string{
  28. "pay_app_cert_sn": db.SysCfgGetWithDb(eg, args["master_id"], "pay_app_cert_sn"),
  29. "pay_alipay_root_cert_sn": db.SysCfgGetWithDb(eg, args["master_id"], "pay_alipay_root_cert_sn"),
  30. "pay_alipayrsa_public_key": db.SysCfgGetWithDb(eg, args["master_id"], "pay_alipayrsa_public_key"),
  31. "pay_ali_use_type": db.SysCfgGetWithDb(eg, args["master_id"], "pay_ali_use_type"),
  32. "private_key": db.SysCfgGetWithDb(eg, args["master_id"], "pay_ali_private_key"),
  33. "app_id": db.SysCfgGetWithDb(eg, args["master_id"], "pay_ali_app_id"),
  34. "rsa": db.SysCfgGetWithDb(eg, args["master_id"], "pay_ali_key_len_type"),
  35. "pkcs": db.SysCfgGetWithDb(eg, args["master_id"], "pay_ali_key_format_type"),
  36. }
  37. if paySet["pay_ali_use_type"] == "1" {
  38. paySet["private_key"] = db.SysCfgGetWithDb(eg, args["master_id"], "pay_ali_new_private_key")
  39. paySet["app_id"] = db.SysCfgGetWithDb(eg, args["master_id"], "pay_ali_new_app_id")
  40. }
  41. return paySet
  42. }