diff --git a/controller/mall.go b/controller/mall.go index fb095cd..37b3fae 100644 --- a/controller/mall.go +++ b/controller/mall.go @@ -157,7 +157,8 @@ type MallOrderCreateReq struct { // @Tags 商城, V1.4.5 // @Produce json // @Accept json -// @Success 200 {object} model.HomeCategoryListResp +// @Param request body MallOrderCreateReq true "新建商城订单模型" +// @Success 200 {object} RespRet // @Router /api/v1/mall/order/create [post] func MallOrderCreate(c *gin.Context) { req := MallOrderCreateReq{} @@ -449,20 +450,37 @@ func MallOrderCreate(c *gin.Context) { return } - webPay, err := wxpay.HmJsPayUnifiedOrderForBuyGoods(order.SerialNo, order.Rm, user.WxOpenID, configInfo.NotifyUrl) - if err != nil { - logger.Error(errors.New("WebPay err")) - RespJson(c, status.InternalServerError, nil) - return - } + if goods.GoodsAccountNum == model.AccountForDw { // 迪为账户收费 + webPay, err := wxpay.WebPay(order.SerialNo, order.Rm, user.WxOpenID, "N", wxpay.WxPayBuyGoods, configInfo.NotifyUrl, true) + if err != nil { + logger.Error(errors.New("WebPay err")) + RespJson(c, status.InternalServerError, nil) + return + } - ret := map[string]interface{}{ - "web_pay": webPay, - "order_id": order.ID, - "order": order, - } + ret := map[string]interface{}{ + "web_pay": webPay, + "order_id": order.ID, + "order": order, + } - RespOK(c, ret) + RespOK(c, ret) + } else { // 其他则默认明慧账户收费 + webPay, err := wxpay.HmJsPayUnifiedOrderForBuyGoods(order.SerialNo, order.Rm, user.WxOpenID, configInfo.NotifyUrl) + if err != nil { + logger.Error(errors.New("WebPay err")) + RespJson(c, status.InternalServerError, nil) + return + } + + ret := map[string]interface{}{ + "web_pay": webPay, + "order_id": order.ID, + "order": order, + } + + RespOK(c, ret) + } return } diff --git a/model/mall.go b/model/mall.go index 9991f10..b09f9a5 100644 --- a/model/mall.go +++ b/model/mall.go @@ -44,6 +44,10 @@ const ( Rmb = 100 ) +const ( + AccountForDw = 2 // 迪为账户 +) + // 商品 // gen:qs // @@ -70,13 +74,14 @@ type Goods struct { DiscountList string `json:"discount_list" gorm:"type:text;"` // 折扣 SpecIndex string `json:"spec_index" gorm:"index"` // 1_3 - PriceVm uint32 `json:"price_vm"` // 积分价格 - PriceRm uint32 `json:"price_rm"` // 人民币价格 - PriceOriginal uint32 `json:"price_original"` // 市场价 - DeliveryFee uint32 `json:"delivery_fee"` // 邮费 - DealType uint32 `json:"deal_type"` // 1-积分兑换 2-购买 3-抵扣 - VersionId uint64 `json:"version_id"` // 乐观锁 - ShowDiscount int8 `json:"show_discount"` // + PriceVm uint32 `json:"price_vm"` // 积分价格 + PriceRm uint32 `json:"price_rm"` // 人民币价格 + PriceOriginal uint32 `json:"price_original"` // 市场价 + DeliveryFee uint32 `json:"delivery_fee"` // 邮费 + DealType uint32 `json:"deal_type"` // 1-积分兑换 2-购买 3-抵扣 + VersionId uint64 `json:"version_id"` // 乐观锁 + ShowDiscount int8 `json:"show_discount"` // + GoodsAccountNum uint32 `json:"goods_account_num"` // 收款账户编号 GoodsCat *GoodsCat `json:"goods_cat" gorm:"-"` GoodsDiscount *GoodsDiscount `json:"goods_discount" gorm:"-"`