This commit is contained in:
邹宗楠
2023-05-19 18:26:23 +08:00
parent 7c7def7436
commit 20cda2be44
4 changed files with 31 additions and 9 deletions

View File

@@ -122,3 +122,16 @@ func (a *Auther) getAPI() *weixinapi.API {
func (a *Auther) GetUserType() (userType int8) {
return model.UserTypeStoreBoss
}
func GetAPI(authType string) *weixinapi.API {
if authType == AuthTypeWeixin {
return api.WeixinPageAPI
}
if authType == AuthTypeWxApp {
return api.WeixinApp
}
if authType == AuthTypeWxAppCaishi {
return api.WeixinApp2
}
return api.WeixinAPI
}

View File

@@ -324,7 +324,7 @@ func Pay4Order(ctx *jxcontext.Context, orderID int64, payType int, vendorPayType
//if subAppID == tiktok.TiktokAppId || subAppID == tiktok.TiktokJXDJAppID {
// subAppID = model.JXC4AppId // 京西商城
//}
if orderPay, err = pay4OrderByTL(ctx, order, payType, vendorPayType, subAppID); err == nil && orderPay != nil {
if orderPay, err = pay4OrderByTL(ctx, order, payType, vendorPayType, subAppID, ""); err == nil && orderPay != nil {
dao.WrapAddIDCULDEntity(orderPay, ctx.GetUserName())
err = dao.CreateEntity(dao.GetDB(), orderPay)
}
@@ -351,7 +351,7 @@ func Pay4Order(ctx *jxcontext.Context, orderID int64, payType int, vendorPayType
ActualPayPrice: priceDefendOrders[0].ActualPayPrice,
VendorID: model.VendorIDJX,
}
if orderPay, err = pay4OrderByTL(ctx, order2, payType, vendorPayType, subAppID); err == nil && orderPay != nil {
if orderPay, err = pay4OrderByTL(ctx, order2, payType, vendorPayType, subAppID, ""); err == nil && orderPay != nil {
dao.WrapAddIDCULDEntity(orderPay, ctx.GetUserName())
err = dao.CreateEntity(dao.GetDB(), orderPay)
}
@@ -359,7 +359,7 @@ func Pay4Order(ctx *jxcontext.Context, orderID int64, payType int, vendorPayType
return orderPay, err
}
func Pay4User(ctx *jxcontext.Context, thingID int, vendorOrderID string, payType int, vendorPayType, subAppID string) (orderPay *model.OrderPay, err error) {
func Pay4User(ctx *jxcontext.Context, thingID int, vendorOrderID string, payType int, vendorPayType, subAppID, code string) (orderPay *model.OrderPay, err error) {
var (
db = dao.GetDB()
order *model.GoodsOrder
@@ -383,7 +383,7 @@ func Pay4User(ctx *jxcontext.Context, thingID int, vendorOrderID string, payType
ActualPayPrice: int64(discountCard.Price),
VendorID: model.VendorIDJX,
}
if orderPay, err = pay4OrderByTL(ctx, order, payType, vendorPayType, subAppID); err == nil && orderPay != nil {
if orderPay, err = pay4OrderByTL(ctx, order, payType, vendorPayType, subAppID, code); err == nil && orderPay != nil {
dao.WrapAddIDCULDEntity(orderPay, ctx.GetUserName())
err = dao.CreateEntity(dao.GetDB(), orderPay)
}
@@ -416,7 +416,7 @@ func Pay4User(ctx *jxcontext.Context, thingID int, vendorOrderID string, payType
ActualPayPrice: int64(storeOrder.ActualPayPrice),
VendorID: model.VendorIDJX,
}
if orderPay, err = pay4OrderByTL(ctx, order, payType, vendorPayType, subAppID); err == nil && orderPay != nil {
if orderPay, err = pay4OrderByTL(ctx, order, payType, vendorPayType, subAppID, code); err == nil && orderPay != nil {
dao.WrapAddIDCULDEntity(orderPay, ctx.GetUserName())
err = dao.CreateEntity(dao.GetDB(), orderPay)
}
@@ -431,7 +431,7 @@ func Pay4User(ctx *jxcontext.Context, thingID int, vendorOrderID string, payType
ActualPayPrice: int64(brandOrder.ActualPayPrice),
VendorID: model.VendorIDJX,
}
if orderPay, err = pay4OrderByTL(ctx, order, payType, vendorPayType, subAppID); err == nil && orderPay != nil {
if orderPay, err = pay4OrderByTL(ctx, order, payType, vendorPayType, subAppID, code); err == nil && orderPay != nil {
dao.WrapAddIDCULDEntity(orderPay, ctx.GetUserName())
err = dao.CreateEntity(dao.GetDB(), orderPay)
}
@@ -841,7 +841,7 @@ func generateOrder(ctx *jxcontext.Context, jxOrder *JxOrderInfo, addressID int64
if jxOrder.OrderType != model.OrderTypeMatter || (jxOrder.OrderType == model.OrderTypeMatter && fromStoreID == -1) {
outJxOrder.Skus = append(outJxOrder.Skus, jxSku)
outJxOrder.OrderPrice += int64(jxSku.Count) * jxSku.SalePrice
} else { //以下else为物料订单袋子金额和数量处理
} else { //以下else为物料订单袋子金额和数量处理
if !result.Flag { //只要flag是false就按原价申请是true再按订单量
outJxOrder.Skus = append(outJxOrder.Skus, jxSku)
outJxOrder.OrderPrice += int64(jxSku.Count) * jxSku.SalePrice

View File

@@ -19,7 +19,7 @@ import (
"git.rosy.net.cn/jx-callback/globals/api"
)
func pay4OrderByTL(ctx *jxcontext.Context, order *model.GoodsOrder, payType int, vendorPayType, subAppID string) (orderPay *model.OrderPay, err error) {
func pay4OrderByTL(ctx *jxcontext.Context, order *model.GoodsOrder, payType int, vendorPayType, subAppID, code string) (orderPay *model.OrderPay, err error) {
// if order.FromStoreID != 0 {
// result, _ := orderman.GetMatterStoreOrderCount(nil, order.FromStoreID)
// if !result.Flag {
@@ -45,6 +45,14 @@ func pay4OrderByTL(ctx *jxcontext.Context, order *model.GoodsOrder, payType int,
if err == nil && authInfo.GetAuthType() == weixin.AuthTypeMini && authInfo.GetAuthTypeID() == subAppID {
param.Acct = authInfo.GetAuthID()
}
if code != "" {
appAuth := strings.Split(code, "_")
sessionInfo, err := weixin.GetAPI(appAuth[0]).SNSCode2Session(appAuth[1])
if err != nil {
return nil, err
}
param.Acct = sessionInfo.OpenID
}
}
if vendorPayType == tonglianpayapi.PayTypeZfbJS || vendorPayType == tonglianpayapi.PayTypeZfbApp {
if authInfo, err := ctx.GetV2AuthInfo(); err == nil {

View File

@@ -123,12 +123,13 @@ func (c *JxOrderController) Pay4StoreMyselfDeliverOrder() {
// @Param vendorOrderID formData string false "订单ID"
// @Param payType formData int true "支付类型"
// @Param vendorPayType formData string true "平台支付类型"
// @Param code formData string false "app吊起微信支付时,需要code获取openID"
// @Success 200 {object} controllers.CallResult
// @Failure 200 {object} controllers.CallResult
// @router /Pay4User [post]
func (c *JxOrderController) Pay4User() {
c.callPay4User(func(params *tJxorderPay4UserParams) (retVal interface{}, errCode string, err error) {
retVal, err = localjx.Pay4User(params.Ctx, params.ThingID, params.VendorOrderID, params.PayType, params.VendorPayType, params.SubAppID)
retVal, err = localjx.Pay4User(params.Ctx, params.ThingID, params.VendorOrderID, params.PayType, params.VendorPayType, params.SubAppID, params.Code)
return retVal, "", err
})
}