Browse Source

update

add_mode
DengBiao 1 year ago
parent
commit
e8ea09d840
8 changed files with 199 additions and 38 deletions
  1. +48
    -0
      app/customer/hdl/hdl_demo.go
  2. +106
    -0
      app/customer/svc/svc_central_kitchen_for_school_package.go
  3. +1
    -1
      app/customer/svc/svc_pay.go
  4. +12
    -6
      app/enum/enum_sys_cfg.go
  5. +1
    -0
      app/router/customer_router.go
  6. +4
    -4
      app/svc/svc_wx_pay.go
  7. +1
    -1
      app/task/svc/svc_central_kitchen_for_school_user_with_day.go
  8. +26
    -26
      static/wx/merchant/apiclient_key.pem

+ 48
- 0
app/customer/hdl/hdl_demo.go View File

@@ -5,14 +5,19 @@ import (
svc2 "applet/app/admin/svc/enterprise_manage"
"applet/app/customer/md"
"applet/app/customer/svc"
"applet/app/db"
"applet/app/e"
"applet/app/enum"
svc3 "applet/app/svc"
"context"
"github.com/chromedp/chromedp"
"github.com/chromedp/chromedp/device"
"github.com/gin-gonic/gin"
"github.com/wechatpay-apiv3/wechatpay-go/core"
"github.com/wechatpay-apiv3/wechatpay-go/services/certificates"
"github.com/wechatpay-apiv3/wechatpay-go/services/partnerpayments/jsapi"
"io/ioutil"
"time"
)

func CurlAlipayPlanetEcocampusApiRosterSignUpInfo(c *gin.Context) {
@@ -54,6 +59,49 @@ func DownloadCertificates(c *gin.Context) {
return
}

func WxPay(c *gin.Context) {
client, err := svc3.NewWxPayClient(c)
if err != nil {
e.OutErr(c, e.ERR, err.Error())
return
}
wxSvc := jsapi.JsapiApiService{Client: client}
sysCfgDb := db.SysCfgDb{}
sysCfgDb.Set()
sysCfg := sysCfgDb.SysCfgFindWithDb(enum.WxSpAppId, enum.WxSpMchId, enum.WxAppletAppId, enum.WxMchId)

resp, result, err := wxSvc.Prepay(c,
jsapi.PrepayRequest{
SpAppid: core.String(sysCfg[enum.WxSpAppId]),
SpMchid: core.String(sysCfg[enum.WxSpMchId]),
SubAppid: core.String(sysCfg[enum.WxAppletAppId]),
SubMchid: core.String(sysCfg[enum.WxMchId]),
Description: core.String("Image形象店-深圳腾大-QQ公仔"),
OutTradeNo: core.String("1217752501201407033233368018"),
TimeExpire: core.Time(time.Now()),
Attach: core.String("自定义数据说明"),
NotifyUrl: core.String("https://www.weixin.qq.com/wxpay/pay.php"),
Amount: &jsapi.Amount{
Currency: core.String("CNY"),
Total: core.Int64(100),
},
Payer: &jsapi.Payer{
//SpOpenid: core.String("oUpF8uMuAJO_M2pxb1Q9zNjWeS6o"),
SubOpenid: core.String("o0mnM4nlX9W5HXbagffM9eTDHaPo"),
},
},
)
if err != nil {
// 处理错误
e.OutErr(c, e.ERR, err.Error())
return
} else {
// 处理返回结果
println("status=%d resp=%s", result.Response.StatusCode, resp)
}
return
}

func Demo(c *gin.Context) {
ordNo := c.DefaultQuery("ord_no", "")
svc2.JudgePackageOrdOrdState(ordNo)


+ 106
- 0
app/customer/svc/svc_central_kitchen_for_school_package.go View File

@@ -357,3 +357,109 @@ func CalcByDay(uid int, isTeacher bool, buyPackageReq md2.BuyPackageReq) (totalP

return
}

func CalcSupplementaryByDay(uid int, isTeacher bool, buyPackageReq md2.BuyPackageReq) (totalPrice float64, data []*model.CentralKitchenForSchoolUserWithDay, err error) {
//sysCfgDb := db.SysCfgDb{}
//sysCfgDb.Set()
//cfg, err := sysCfgDb.SysCfgGetOne(enum.CentralKitchenForSchoolReserveMealTime)
//if err != nil {
// return
//}

//1、查询出套餐基础设置
centralKitchenForSchoolWithSpec := db.CentralKitchenForSchoolWithSpec{}
centralKitchenForSchoolWithSpec.Set(buyPackageReq.EnterpriseId)
centralKitchenForSchoolWithSpecData, err := centralKitchenForSchoolWithSpec.GetCentralKitchenForSchoolWithSpec()
if err != nil {
return
}
classWithUserDb := db.ClassWithUserDb{}
classWithUserDb.Set()
classWithUserInfo, err := classWithUserDb.GetInfoByUserIdentityId(buyPackageReq.UserIdentityId)
if err != nil {
return
}

//now := time.Now()
//today, _ := time.ParseInLocation("2006-01-02", time.Now().Format("2006-01-02"), time.Local)
//tomorrowDay := today.AddDate(0, 0, 1)

//centralKitchenForSchoolReserveMealTime, _ := time.ParseInLocation("2006-01-02 15:04:05", now.Format("2006-01-02")+" "+cfg.Val+":00", time.Local)

//2、循环拼接数据
for _, v1 := range buyPackageReq.WithDays {
//2.1、判断是否小于今天
//date, _ := time.ParseInLocation("2006-01-02", v1.Date, time.Local)
//if today.After(date) || today.Equal(date) {
// continue
//}
//if tomorrowDay.Equal(date) {
// //2.2、判断是否过了今日可订餐时间
// if now.After(centralKitchenForSchoolReserveMealTime) {
// continue
// }
//}

//2.3、计算价格 && 组装数据
if v1.IsBuyBreakfast == 1 && buyPackageReq.IsBuyBreakfast == 1 {
//早餐
var amount string
if isTeacher {
amount = centralKitchenForSchoolWithSpecData.BreakfastUnitPriceForTeacher
} else {
amount = classWithUserInfo.Period.BreakfastUnitPrice
}

data = append(data, &model.CentralKitchenForSchoolUserWithDay{
Uid: uid,
EnterpriseId: buyPackageReq.EnterpriseId,
IdentityId: buyPackageReq.UserIdentityId,
Kind: enum.CentralKitchenForSchoolUserWithDayKindForBreakfast,
Date: v1.Date,
Amount: amount,
State: enum.CentralKitchenForSchoolUserWithDayStateForWait,
})
totalPrice += utils.StrToFloat64(amount)
}

if v1.IsBuyLunch == 1 && buyPackageReq.IsBuyLunch == 1 {
var amount string
if isTeacher {
amount = centralKitchenForSchoolWithSpecData.LunchUnitPriceForTeacher
} else {
amount = classWithUserInfo.Period.LunchUnitPrice
}
totalPrice += utils.StrToFloat64(amount)
data = append(data, &model.CentralKitchenForSchoolUserWithDay{
Uid: uid,
EnterpriseId: buyPackageReq.EnterpriseId,
IdentityId: buyPackageReq.UserIdentityId,
Kind: enum.CentralKitchenForSchoolUserWithDayKindForLunch,
Date: v1.Date,
State: enum.CentralKitchenForSchoolUserWithDayStateForWait,
Amount: amount,
})
}

if v1.IsBuyDinner == 1 && buyPackageReq.IsBuyDinner == 1 {
var amount string
if isTeacher {
amount = centralKitchenForSchoolWithSpecData.DinnerUnitPriceForTeacher
} else {
amount = classWithUserInfo.Period.DinnerUnitPrice
}
totalPrice += utils.StrToFloat64(amount)
data = append(data, &model.CentralKitchenForSchoolUserWithDay{
Uid: uid,
EnterpriseId: buyPackageReq.EnterpriseId,
IdentityId: buyPackageReq.UserIdentityId,
Kind: enum.CentralKitchenForSchoolUserWithDayKindForDinner,
Amount: amount,
Date: v1.Date,
State: enum.CentralKitchenForSchoolUserWithDayStateForWait,
})
}
}

return
}

+ 1
- 1
app/customer/svc/svc_pay.go View File

@@ -64,7 +64,7 @@ func BuyPackage(c *gin.Context, req md.BuyPackageReq) (outTradeNo, tradeNo, tota
}
}
if req.Kind == 4 {
totalPrice, data, err = CalcByDay(user.Id, isTeacher, req)
totalPrice, data, err = CalcSupplementaryByDay(user.Id, isTeacher, req)
if err != nil {
return
}


+ 12
- 6
app/enum/enum_sys_cfg.go View File

@@ -34,8 +34,10 @@ const (
WxAppletAppId = "wx_applet_app_id"
WxAppletAppSecret = "wx_applet_app_secret"
WxMchId = "wx_mch_id"
WxMchApiV3Key = "wx_mch_api_v3_key"
WxMchCertificateSerialNumber = "wx_mch_certificate_serial_number"
WxSpMchApiV3Key = "wx_sp_mch_api_v3_key"
WxSpMchCertificateSerialNumber = "wx_sp_mch_certificate_serial_number"
WxSpAppId = "wx_sp_app_id"
WxSpMchId = "wx_sp_mch_id"
)

func (gt SysCfg) String() string {
@@ -98,10 +100,14 @@ func (gt SysCfg) String() string {
return "微信-小程序-appSecret"
case WxMchId:
return "微信商户id"
case WxMchApiV3Key:
return "微信商户apiV3密钥"
case WxMchCertificateSerialNumber:
return "微信商户证书序列号"
case WxSpMchApiV3Key:
return "微信服务商-商户apiV3密钥"
case WxSpMchCertificateSerialNumber:
return "微信服务商-商户证书序列号"
case WxSpAppId:
return "微信服务商-appid"
case WxSpMchId:
return "微信服务商-商户id"
default:
return "未知"
}


+ 1
- 0
app/router/customer_router.go View File

@@ -26,6 +26,7 @@ func CustomerInit(r *gin.RouterGroup) {
r.GET("/wxGetAccessToken", hdl.WxGetAccessToken)
r.POST("/wxDecryptUserInfo", hdl.WxDecryptUserInfo)
r.POST("/wxDecryptMobile", hdl.WxDecryptMobile)
r.POST("/wxPay", hdl.WxPay)

r.POST("/register", hdl.Register)
r.POST("/aesDecrypt", hdl.AesDecrypt)


+ 4
- 4
app/svc/svc_wx_pay.go View File

@@ -12,12 +12,12 @@ import (
func NewWxPayClient(ctx *gin.Context) (client *core.Client, err error) {
sysCfgDb := db.SysCfgDb{}
sysCfgDb.Set()
sysCfg := sysCfgDb.SysCfgFindWithDb(enum.WxMchId, enum.WxMchApiV3Key, enum.WxMchCertificateSerialNumber)
sysCfg := sysCfgDb.SysCfgFindWithDb(enum.WxSpAppId, enum.WxSpMchApiV3Key, enum.WxSpMchCertificateSerialNumber)

var (
mchID string = sysCfg[enum.WxMchId] // 商户号
mchCertificateSerialNumber string = sysCfg[enum.WxMchCertificateSerialNumber] // 商户证书序列号
mchAPIv3Key string = sysCfg[enum.WxMchApiV3Key] // 商户APIv3密钥
mchID string = sysCfg[enum.WxSpAppId] // 商户号
mchCertificateSerialNumber string = sysCfg[enum.WxSpMchCertificateSerialNumber] // 商户证书序列号
mchAPIv3Key string = sysCfg[enum.WxSpMchApiV3Key] // 商户APIv3密钥
)

// 使用 utils 提供的函数从本地文件中加载商户私钥,商户私钥会用来生成请求的签名


+ 1
- 1
app/task/svc/svc_central_kitchen_for_school_user_with_day.go View File

@@ -18,7 +18,7 @@ func SyncCentralKitchenForSchoolUserWithDayState(eg *xorm.Engine) {
}()

now := time.Now()
today, _ := time.ParseInLocation("2006-01-02", time.Now().Format("2006-01-02"), time.Local)
today := now.Format("2006-01-02")
breakfastMealTime, _ := time.ParseInLocation("2006-01-02 15:04:05", now.Format("2006-01-02")+" 06:30", time.Local)
lunchMealTime, _ := time.ParseInLocation("2006-01-02 15:04:05", now.Format("2006-01-02")+" 12:00", time.Local)
dinnerMealTime, _ := time.ParseInLocation("2006-01-02 15:04:05", now.Format("2006-01-02")+" 17:00", time.Local)


+ 26
- 26
static/wx/merchant/apiclient_key.pem View File

@@ -1,28 +1,28 @@
-----BEGIN PRIVATE KEY-----
MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDGgwnKlRY+VV+O
JPsHjOMqwD5xUmX5aEZyI/LwL4xG7eRntSRh+iEGZFHAhS14oaSUokPeeJBB3UIP
UTvGzANQysLF7n52K9MCst2rzEdqP2eCIZZxzdr78AbnSqP41CbDaEOG8tBtAYg1
AWUA8vej8BpyPS66UeoL8cZ6ymHW3eT9lUno6jmQ6U+aZDKDKVoXNMdlVr9E3TWy
fa9FI63nzvXu3XKftrfXkupAE+KDdHS0cyYHWHJrRSSfqR3ibSeXJILs0fZbUWtz
JdbZJhMqZ7oGlxFb06kvAEkHUmfbBKBvqMUjWoBDYfdT2EfAYQukXBXk4qjn1HP6
OSsMMpMXAgMBAAECggEAFscyeGxjAQQK0uSraVJhPqaQg7BQwy2T58T4O1c5YWoq
qzu90QBCidk5CD4/2XeyyttTrlNnOieJTPilQ0pllv+tGckj+atNqyGbDfuCtk5Q
Mj5oZOaaGg6QvDl0VzkAuatdFD8Ia3mhh3OBg3pdsBH89t7OXdLIaFZ1z+EpGN5p
hS9j/pL63/ND/zbUsTinXlvnki5T55TPJQgSTG9Kaa9bFg4ovcPTjceKlgx5CbXO
0qp+2AAM5JKSFry1uLnaata8lgHAb2trki8xWp8nLV3SvIHY67owVacy44SnXcqw
/lU0RrQDWAjhCDsnbYUcIeV+2VzAcrPZEZXJ82ETAQKBgQDo2UewxxcbfUNUcJnn
OW7hHliRpjUY//N2/G7uiBskVrRxdJxSihVPcnvWqQbu6BXopfs6jpBXAic9N9i9
ONlMfNIFHsiSeRUw+sMJCXFj8LKf7qwp/O4i4s82FInZjhESLiBytry5SJB26SHn
ntmXYIKwV5virUtrJF9DJvml9QKBgQDaP8dLT+KXcNoi1yy/k1nFiItlMvKZilXo
UQvHqnXI/SmbK4FwSpTV0jF7KVRV+9EvLBvRPf5omREm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