新增系列配置
This commit is contained in:
@@ -12,6 +12,7 @@ import (
|
||||
"pet-house.com/core/server/web"
|
||||
"pet-house.com/core/server/web/web_iris"
|
||||
"pet-house.com/core/server/zap_server"
|
||||
"time"
|
||||
)
|
||||
|
||||
type LoginRequest struct {
|
||||
@@ -91,8 +92,9 @@ func (p DefParty) login() web_iris.Party {
|
||||
if coupons.SendStatus == 2 {
|
||||
//新注册用户下发优惠券
|
||||
newUserCoupons := models.UserCoupons{
|
||||
Uid: userInfo.Id,
|
||||
Cid: coupons.Id,
|
||||
Uid: userInfo.Id,
|
||||
Cid: coupons.Id,
|
||||
LastExpireTime: time.Now().AddDate(0, 0, coupons.DrawDay),
|
||||
}
|
||||
database.Instance().Create(&newUserCoupons)
|
||||
}
|
||||
|
||||
+4
-8
@@ -7,7 +7,6 @@ import (
|
||||
"gorm.io/gorm/clause"
|
||||
"io"
|
||||
"pet-house.com/business/models"
|
||||
"pet-house.com/business/utils"
|
||||
"pet-house.com/core/server/database"
|
||||
"pet-house.com/core/server/web/web_iris"
|
||||
"time"
|
||||
@@ -126,18 +125,15 @@ func (p DefParty) carServiceProcess() web_iris.Party {
|
||||
var orderUserInfo *models.User
|
||||
database.Instance().Model(&models.User{}).Where("id = ?", mainOrder.Uid).Find(&orderUserInfo)
|
||||
var processPayAmount = carServiceProcessRequest.PayAmount
|
||||
var originTotalAmount = float64(subOrderInfo.TotalAmount)
|
||||
var originTotalAmount = float64(subOrderInfo.PayAmount) / 10.0
|
||||
if processPayAmount > 0 && originTotalAmount != processPayAmount {
|
||||
//原价
|
||||
originAmount := subOrderInfo.PayAmount
|
||||
userOriginAmount := orderUserInfo.Amount
|
||||
p := int(utils.RoundToOneDecimalPlace(processPayAmount))
|
||||
p1 := int(processPayAmount * 10)
|
||||
mainOrder.TotalAmount = mainOrder.TotalAmount - subOrderInfo.TotalAmount + p
|
||||
if mainOrder.PayTotalAmount > 0 && originTotalAmount != processPayAmount {
|
||||
mainOrder.PayTotalAmount = mainOrder.PayTotalAmount - originAmount + p1
|
||||
}
|
||||
subOrderInfo.TotalAmount = p
|
||||
subOrderInfo.PayAmount = p1
|
||||
if mainOrder.PayStatus == 1 {
|
||||
recordType := 2
|
||||
@@ -187,7 +183,6 @@ func (p DefParty) carServiceProcess() web_iris.Party {
|
||||
}
|
||||
subOrderInfo.PayTime = time.Now()
|
||||
subOrderInfo.PayStatus = 1
|
||||
|
||||
}
|
||||
if carServiceProcessRequest.Type == 1 {
|
||||
subOrderInfo.OrderStatus = 2
|
||||
@@ -225,8 +220,9 @@ func (p DefParty) carServiceProcess() web_iris.Party {
|
||||
if coupons.SendStatus == 3 {
|
||||
//完成订单给邀请用户发送优惠券
|
||||
newUserCoupons := models.UserCoupons{
|
||||
Uid: orderUserInfo.InviteUserId,
|
||||
Cid: coupons.Id,
|
||||
Uid: orderUserInfo.InviteUserId,
|
||||
Cid: coupons.Id,
|
||||
LastExpireTime: time.Now().AddDate(0, 0, coupons.DrawDay),
|
||||
}
|
||||
database.Instance().Create(&newUserCoupons)
|
||||
}
|
||||
|
||||
@@ -60,6 +60,9 @@ var (
|
||||
OrderUpdateBalanceNotEnough = Error{Code: 217, Msg: "当前余额不足"}
|
||||
CouponsNotExistError = Error{Code: 218, Msg: "优惠券不存在"}
|
||||
UserCouponsNExistError = Error{Code: 219, Msg: "已领取同类型优惠券"}
|
||||
UserCouponsNExistOrUseError = Error{Code: 220, Msg: "用户不存在优惠券或已使用"}
|
||||
PayError = Error{Code: 221, Msg: "支付失败"}
|
||||
OrderNotPayError = Error{Code: 222, Msg: "订单未支付定金"}
|
||||
)
|
||||
|
||||
func Success(ctx *context.Context, request any, data any) {
|
||||
@@ -152,7 +155,6 @@ func DataInit() {
|
||||
//--------------------------------------------------宠物商品关联数据---------------------------------------------------------
|
||||
var petGoodsList []models.PetGoods
|
||||
database.Instance().Model(&models.PetGoods{}).Where("status = 1").Find(&petGoodsList)
|
||||
zap_server.ZAPLOG.Info("111111", zap.Any("222", petGoodsList))
|
||||
var PetGoodsMapC1 = make(map[string][]models.PetGoods)
|
||||
for _, value := range petGoodsList {
|
||||
key := strconv.Itoa(value.Assortment) + strconv.Itoa(value.PetType) + strconv.Itoa(value.Weight) + strconv.Itoa(value.Hair)
|
||||
|
||||
@@ -11,6 +11,7 @@ var CarBase = "/car"
|
||||
var Admin = "/admin"
|
||||
var System = "/system"
|
||||
var CouponsBase = "/coupons"
|
||||
var PayBase = "/pay"
|
||||
|
||||
func (p DefParty) RegisterList() []web_iris.Party {
|
||||
ps := []web_iris.Party{
|
||||
@@ -51,6 +52,10 @@ func (p DefParty) RegisterList() []web_iris.Party {
|
||||
p.getCouponsList(),
|
||||
p.getUserCouponsList(),
|
||||
p.drawCoupons(),
|
||||
//支付
|
||||
p.rechargeInfoList(),
|
||||
p.toPay(),
|
||||
p.payNotify(),
|
||||
//系统
|
||||
p.systemConfigInfo(),
|
||||
p.systemBanners(),
|
||||
|
||||
+30
-6
@@ -23,9 +23,21 @@ func (p DefParty) getCouponsList() web_iris.Party {
|
||||
UserNotExistError.Fail(ctx, nil)
|
||||
return
|
||||
}
|
||||
|
||||
var userCoupons []*models.UserCoupons
|
||||
database.Instance().Model(&models.UserCoupons{}).Where("uid = ? and coupons_status = 1", headerInfo.Uid).Find(&userCoupons)
|
||||
var userCouponsMap = make(map[int]*models.UserCoupons)
|
||||
for _, value := range userCoupons {
|
||||
userCouponsMap[value.Cid] = value
|
||||
}
|
||||
|
||||
var coupons []models.Coupons
|
||||
database.Instance().Model(&models.Coupons{}).Where("status = 1 and expire_time > ?", time.Now().UnixNano()/int64(time.Millisecond)).Find(&coupons)
|
||||
database.Instance().Model(&models.Coupons{}).Where("status = 1 and send_status = 1 and expire_time > ?", time.Now().UnixNano()/int64(time.Millisecond)).Find(&coupons)
|
||||
for index, coupon := range coupons {
|
||||
m := userCouponsMap[coupon.Id]
|
||||
if m != nil && m.Id > 0 {
|
||||
coupons[index].ReceiverStatus = 1
|
||||
}
|
||||
coupons[index].PeriodInfo = strings.Split(coupon.Period, ",")
|
||||
}
|
||||
Success(ctx, headerInfo, coupons)
|
||||
@@ -55,10 +67,20 @@ func (p DefParty) getUserCouponsList() web_iris.Party {
|
||||
return
|
||||
}
|
||||
|
||||
var userCoupons []models.UserCoupons
|
||||
var coupons []models.Coupons
|
||||
database.Instance().Model(&models.Coupons{}).Joins("JOIN user_coupons on coupons.id = user_coupons.cid and coupons.expire_time > ? and coupons.send_status = 1", time.Now().UnixNano()/int64(time.Millisecond)).Where(" user_coupons.coupons_status = ? and user_coupons.uid = ?", getUserCouponsListRequest.Status, headerInfo.Uid).Find(&coupons)
|
||||
for index, coupon := range coupons {
|
||||
coupons[index].PeriodInfo = strings.Split(coupon.Period, ",")
|
||||
database.Instance().Model(&models.UserCoupons{}).Where("uid = ? and coupons_status = ?", headerInfo.Uid, getUserCouponsListRequest.Status).Find(&userCoupons)
|
||||
for _, userCoupon := range userCoupons {
|
||||
uc := CouponsMap[userCoupon.Cid]
|
||||
if uc.Id == 0 {
|
||||
var couponsData *models.Coupons
|
||||
database.Instance().Model(&models.Coupons{}).Where("id = ?", userCoupon.Cid).Find(&couponsData)
|
||||
uc = models.Coupons{Id: couponsData.Id, Name: couponsData.Name, Source: couponsData.Source, Discount: couponsData.Discount, GoodsSubType: couponsData.GoodsSubType}
|
||||
}
|
||||
uc.LastExpireTime = userCoupon.LastExpireTime.Format("2006-01-02")
|
||||
uc.PeriodInfo = strings.Split(uc.Period, ",")
|
||||
uc.Id = userCoupon.Id
|
||||
coupons = append(coupons, uc)
|
||||
}
|
||||
Success(ctx, headerInfo, coupons)
|
||||
})
|
||||
@@ -88,7 +110,7 @@ func (p DefParty) drawCoupons() web_iris.Party {
|
||||
}
|
||||
|
||||
var coupons *models.Coupons
|
||||
database.Instance().Model(&models.Coupons{}).Where("id = ?", drawCouponsRequest.Cid).Find(&coupons)
|
||||
database.Instance().Model(&models.Coupons{}).Where("id = ? and status = 1", drawCouponsRequest.Cid).Find(&coupons)
|
||||
if coupons.Id == 0 {
|
||||
CouponsNotExistError.Fail(ctx, nil)
|
||||
return
|
||||
@@ -96,7 +118,7 @@ func (p DefParty) drawCoupons() web_iris.Party {
|
||||
lockMap := &utils.KeyedMutex{}
|
||||
lockMap.Lock(headerInfo.Token)
|
||||
var userCoupons *models.UserCoupons
|
||||
database.Instance().Model(&models.UserCoupons{}).Where("uid = ? and cid = ?", headerInfo.Uid, drawCouponsRequest.Cid).Find(&userCoupons)
|
||||
database.Instance().Model(&models.UserCoupons{}).Where("uid = ? and cid = ? and coupons_status = 1", headerInfo.Uid, drawCouponsRequest.Cid).Find(&userCoupons)
|
||||
if userCoupons.Id > 0 {
|
||||
UserCouponsNExistError.Fail(ctx, nil)
|
||||
lockMap.Unlock(headerInfo.Token)
|
||||
@@ -105,6 +127,8 @@ func (p DefParty) drawCoupons() web_iris.Party {
|
||||
newUserCoupons := models.UserCoupons{
|
||||
Uid: headerInfo.Uid,
|
||||
Cid: drawCouponsRequest.Cid,
|
||||
//领取后最后过期时间
|
||||
LastExpireTime: time.Now().AddDate(0, 0, coupons.DrawDay),
|
||||
}
|
||||
err := database.Instance().Create(&newUserCoupons).Error
|
||||
if err != nil {
|
||||
|
||||
@@ -47,6 +47,8 @@ func ModuleInit() {
|
||||
//&models.UserAmountRecord{},
|
||||
//&models.Coupons{},
|
||||
//&models.UserCoupons{},
|
||||
//&models.RechargeInfo{},
|
||||
//&models.PayOrder{},
|
||||
)
|
||||
zap_server.ZAPLOG.Info("data init ", zap.Any("err", _err))
|
||||
DataInit()
|
||||
|
||||
+211
-51
@@ -29,6 +29,7 @@ type OrderCreateRequest struct {
|
||||
PetGoodsInfos []PetGoodsInfo //宠物商品信息列表
|
||||
ServiceTime string //预约时间 yyyy-MM-dd HH:mm
|
||||
ServiceAddrId int64 //预约服务地址
|
||||
PayOrderId string //支付单号
|
||||
}
|
||||
|
||||
type OrderCreateResponse struct {
|
||||
@@ -53,20 +54,35 @@ func (p DefParty) orderCreatePreCheck() web_iris.Party {
|
||||
}
|
||||
var userInfo *models.User
|
||||
database.Instance().Model(&models.User{}).Where("id = ?", headerBaseInfo.Uid).Find(&userInfo)
|
||||
var orderTotalAmount = 0
|
||||
var goodsDiscountAmount = 0
|
||||
var goodsNotDiscountAmount = 0
|
||||
for _, value := range orderCreateRequest.PetGoodsInfos {
|
||||
for _, value := range value.GoodsIds {
|
||||
goods := GoodsMap[value]
|
||||
orderTotalAmount = orderTotalAmount + goods.Price
|
||||
for _, gid := range value.GoodsIds {
|
||||
goods := GoodsMap[gid]
|
||||
if value.Cid > 0 {
|
||||
var userCouponsInfo models.UserCoupons
|
||||
database.Instance().Model(&models.UserCoupons{}).Where("id = ?", value.Cid).Order(clause.OrderByColumn{Column: clause.Column{Name: "update_time"}, Desc: true}).Find(&userCouponsInfo)
|
||||
var coupons = CouponsMap[userCouponsInfo.Cid]
|
||||
if coupons.Id == 0 {
|
||||
var couponsData *models.Coupons
|
||||
database.Instance().Model(&models.Coupons{}).Where("id = ?", coupons.Id).Find(&couponsData)
|
||||
coupons = models.Coupons{Id: couponsData.Id, Discount: couponsData.Discount, GoodsSubType: couponsData.GoodsSubType}
|
||||
}
|
||||
if goods.GoodsSubType == coupons.GoodsSubType {
|
||||
goodsDiscountAmount = goodsDiscountAmount + int(utils.RoundToOneDecimalPlace(float64(goods.Price)*(float64(coupons.Discount)/100.0))*10)
|
||||
} else {
|
||||
goodsNotDiscountAmount = goodsNotDiscountAmount + goods.Price
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
orderCreatePreCheckResponse := OrderCreatePreCheckResponse{
|
||||
HasAlert: false,
|
||||
}
|
||||
var discountAmount = orderTotalAmount
|
||||
if userInfo.Discount > 0 {
|
||||
discount := float64(userInfo.Discount)
|
||||
discountAmount = int(utils.RoundToOneDecimalPlace(float64(orderTotalAmount)*(discount/100.0)) * 10)
|
||||
//此处计算享受会员折扣及优惠券折扣的价格
|
||||
var discountAmount = int(utils.RoundToOneDecimalPlace(float64(goodsNotDiscountAmount)*(discount/100.0))*10) + goodsDiscountAmount
|
||||
if userInfo.Amount < discountAmount {
|
||||
orderCreatePreCheckResponse.HasAlert = true
|
||||
orderCreatePreCheckResponse.AlertMsg = "您的会员余额不够,需要进行线下支付,当前订单将不享受会员折扣优惠价格"
|
||||
@@ -94,16 +110,18 @@ func (p DefParty) orderCreate() web_iris.Party {
|
||||
UserServiceAddrNotExistError.Fail(ctx, nil)
|
||||
return
|
||||
}
|
||||
var userCouponsList []*models.UserCoupons
|
||||
var projectionServiceTime = 0
|
||||
var userCoupons *models.UserCoupons
|
||||
for _, value := range orderCreateRequest.PetGoodsInfos {
|
||||
var userCoupons *models.UserCoupons
|
||||
database.Instance().Model(&models.UserCoupons{}).Where("uid = ? and cid = ? and coupons_status = 1", headerBaseInfo.Uid, value.Cid).Find(&userCoupons)
|
||||
database.Instance().Model(&models.UserCoupons{}).Where("id = ? and coupons_status = 1", value.Cid).Find(&userCoupons)
|
||||
userCouponsList = append(userCouponsList, userCoupons)
|
||||
if value.Cid > 0 {
|
||||
if userCoupons.Id == 0 {
|
||||
CouponsNotExistError.Fail(ctx, nil)
|
||||
return
|
||||
}
|
||||
coupons := CouponsMap[value.Cid]
|
||||
coupons := CouponsMap[userCoupons.Cid]
|
||||
if coupons.Id == 0 {
|
||||
CouponsNotExistError.Fail(ctx, nil)
|
||||
return
|
||||
@@ -145,12 +163,16 @@ func (p DefParty) orderCreate() web_iris.Party {
|
||||
}
|
||||
}
|
||||
|
||||
var payOrder *models.PayOrder
|
||||
database.Instance().Model(&models.PayOrder{}).Where("order_id = ? and order_status = 0", orderCreateRequest.PayOrderId).Find(&payOrder)
|
||||
if payOrder.Id > 0 {
|
||||
OrderNotPayError.DefFail(ctx, orderCreateRequest, nil)
|
||||
return
|
||||
}
|
||||
|
||||
//订单总金额
|
||||
var orderTotalAmount = 0
|
||||
//可以参与会员折扣的金额
|
||||
var needDiscountAmount = 0
|
||||
//不可参与会员折扣的金额
|
||||
var notDiscountAmount = 0
|
||||
|
||||
orderLock.Lock()
|
||||
orderId := NextId.Generate().String()
|
||||
orderMain := models.OrderMain{
|
||||
@@ -167,8 +189,17 @@ func (p DefParty) orderCreate() web_iris.Party {
|
||||
var orderSubList []models.OrderSub
|
||||
var orderSubDetailList []models.OrderDetail
|
||||
var mainGoods = 0
|
||||
|
||||
var coupons models.Coupons
|
||||
for _, value := range orderCreateRequest.PetGoodsInfos {
|
||||
coupons := CouponsMap[value.Cid]
|
||||
//可以参与会员折扣的金额
|
||||
var needDiscountAmount = 0
|
||||
//不可参与会员折扣的金额
|
||||
var notDiscountAmount = 0
|
||||
|
||||
var userCouponsInfo models.UserCoupons
|
||||
database.Instance().Model(&models.UserCoupons{}).Where("id = ?", value.Cid).Order(clause.OrderByColumn{Column: clause.Column{Name: "update_time"}, Desc: true}).Find(&userCouponsInfo)
|
||||
coupons = CouponsMap[userCouponsInfo.Cid]
|
||||
subOrderId := NextId.Generate().String()
|
||||
var totalAmount = 0
|
||||
var projectionServiceTime = 0
|
||||
@@ -193,18 +224,28 @@ func (p DefParty) orderCreate() web_iris.Party {
|
||||
mainGoods++
|
||||
}
|
||||
goodsName = goods.Name + "、" + goodsName
|
||||
}
|
||||
userPetInfo := GetUserPet(headerBaseInfo.Uid, value.PetId)
|
||||
var petInfo = "宠物名称:" + userPetInfo.PetInfo.NickName + "</br>品种:" + userPetInfo.PetBaseInfo.Assortment + "</br>服务项目:" + goodsName
|
||||
projectionServiceTimeAll += projectionServiceTime
|
||||
|
||||
for _, orderDetail := range orderSubDetailList {
|
||||
if orderDetail.Cid > 0 {
|
||||
//符合折扣金额才计入折扣价
|
||||
if orderDetail.Cid > 0 && coupons.GoodsSubType == goods.GoodsSubType {
|
||||
notDiscountAmount = notDiscountAmount + orderDetail.DiscountAmount
|
||||
} else {
|
||||
needDiscountAmount = needDiscountAmount + orderDetail.Amount
|
||||
}
|
||||
}
|
||||
userPetInfo := GetUserPet(headerBaseInfo.Uid, value.PetId)
|
||||
var weightStr = "无"
|
||||
if userPetInfo.PetBaseInfo.PetType == 1 {
|
||||
weightStr = CatWeightMap[userPetInfo.PetInfo.Weight]
|
||||
} else {
|
||||
weightStr = DogWeightMap[userPetInfo.PetInfo.Weight]
|
||||
}
|
||||
var petInfo = "宠物名称:" + userPetInfo.PetInfo.NickName + "</br>品种:" + userPetInfo.PetBaseInfo.Assortment + "</br>体重:" + weightStr + "</br>服务项目:" + goodsName
|
||||
|
||||
projectionServiceTimeAll += projectionServiceTime
|
||||
|
||||
/*for _, orderDetail := range orderSubDetailList {
|
||||
goods := GoodsMap[orderDetail.GoodsId]
|
||||
|
||||
}*/
|
||||
|
||||
orderSub := models.OrderSub{
|
||||
OrderId: subOrderId,
|
||||
@@ -214,7 +255,8 @@ func (p DefParty) orderCreate() web_iris.Party {
|
||||
PayType: 1,
|
||||
Discount: 100,
|
||||
TotalAmount: totalAmount,
|
||||
PayAmount: totalAmount,
|
||||
//折扣价格 默认*10
|
||||
PayAmount: notDiscountAmount + needDiscountAmount*10,
|
||||
//设置商品折扣金额用于后续打折计算
|
||||
GoodsDiscountAmount: notDiscountAmount,
|
||||
//设置商品非折扣金额
|
||||
@@ -223,7 +265,10 @@ func (p DefParty) orderCreate() web_iris.Party {
|
||||
PetInfo: petInfo,
|
||||
Status: 1,
|
||||
ProjectionServiceTime: projectionServiceTime,
|
||||
Cid: coupons.Id,
|
||||
Ucid: userCoupons.Id,
|
||||
}
|
||||
//订单总金额
|
||||
orderTotalAmount = orderTotalAmount + totalAmount
|
||||
orderSubList = append(orderSubList, orderSub)
|
||||
}
|
||||
@@ -253,7 +298,6 @@ func (p DefParty) orderCreate() web_iris.Party {
|
||||
} else {
|
||||
discountAmount = int(utils.RoundToOneDecimalPlace(float64(inDiscountAmount) * 10))
|
||||
}
|
||||
|
||||
orderMain.TotalAmount = orderTotalAmount
|
||||
tx := database.Instance().Begin()
|
||||
var db4 *gorm.DB
|
||||
@@ -282,19 +326,26 @@ func (p DefParty) orderCreate() web_iris.Party {
|
||||
ProScene: "下单",
|
||||
Status: 1,
|
||||
}
|
||||
for index_, orderSub := range orderSubList {
|
||||
if userInfo.Discount > 0 {
|
||||
discount := float64(userInfo.Discount)
|
||||
discountAmount1 := int(utils.RoundToOneDecimalPlace(float64(orderSub.GoodsOriginAmount)*(discount/100.0)) * 10)
|
||||
orderSubList[index_].PayAmount = discountAmount1 + orderSub.GoodsDiscountAmount
|
||||
}
|
||||
}
|
||||
tx.Model(&models.UserAmountRecord{}).Create(&userAmountRecord)
|
||||
zap_server.ZAPLOG.Info("会员金额扣除", zap.Any("用户ID", userInfo.Id), zap.Any("订单号", orderMain.OrderId), zap.Any("当前余额", currAmount), zap.Any("扣除余额", discountAmount+orderGoodsDiscountAmount), zap.Any("剩余余额", userInfo.Amount), zap.Any("折扣", userInfo.Discount))
|
||||
for index, _ := range orderSubList {
|
||||
orderSubList[index].Discount = userInfo.Discount
|
||||
zap_server.ZAPLOG.Info("会员金额扣除", zap.Any("用户ID", userInfo.Id), zap.Any("订单号", orderMain.OrderId), zap.Any("当前余额", currAmount), zap.Any("扣除余额", discountAmount+orderGoodsDiscountAmount), zap.Any("剩余余额", userInfo.Amount), zap.Any("折扣", userInfo.Discount), zap.Any("优惠券折扣信息", coupons))
|
||||
for index_, _ := range orderSubList {
|
||||
orderSubList[index_].Discount = userInfo.Discount
|
||||
//orderSubList[index].PayAmount = int32(math.Round(float64(orderSubList[index].TotalAmount) * (discount / 100.0)))
|
||||
orderSubList[index].PayAmount = discountAmount + orderGoodsDiscountAmount
|
||||
//orderSubList[index].PayAmount = discountAmount + orderGoodsDiscountAmount
|
||||
}
|
||||
} else {
|
||||
userAmountRecord := models.UserAmountRecord{
|
||||
UserId: userInfo.Id,
|
||||
Type: 3,
|
||||
OriginAmount: userInfo.Amount,
|
||||
ProAmount: discountAmount + orderGoodsDiscountAmount,
|
||||
ProAmount: inDiscountAmount*10 + orderGoodsDiscountAmount,
|
||||
CurrAmount: userInfo.Amount,
|
||||
OrderId: orderId,
|
||||
ProScene: "下单",
|
||||
@@ -302,6 +353,7 @@ func (p DefParty) orderCreate() web_iris.Party {
|
||||
}
|
||||
tx.Model(&models.UserAmountRecord{}).Create(&userAmountRecord)
|
||||
}
|
||||
orderMain.PayOrderId = orderCreateRequest.PayOrderId
|
||||
var findUserServiceAddr models.UserServiceAddr
|
||||
database.Instance().Model(&models.UserServiceAddr{}).Where("id = ? and uid = ?", orderCreateRequest.ServiceAddrId, headerBaseInfo.Uid).Find(&findUserServiceAddr)
|
||||
userInfo.Mobile = findUserServiceAddr.Mobile
|
||||
@@ -312,6 +364,13 @@ func (p DefParty) orderCreate() web_iris.Party {
|
||||
db := tx.Model(&models.OrderDetail{}).CreateInBatches(&orderSubDetailList, len(orderSubDetailList))
|
||||
db1 := tx.Model(&models.OrderSub{}).CreateInBatches(&orderSubList, len(orderSubList))
|
||||
db2 := tx.Model(&models.OrderMain{}).Create(&orderMain)
|
||||
for _, userCoupons := range userCouponsList {
|
||||
updateUserCoupons := map[string]interface{}{
|
||||
"CouponsStatus": 2,
|
||||
}
|
||||
//更新用户优惠券状态
|
||||
tx.Model(&userCoupons).Updates(&updateUserCoupons)
|
||||
}
|
||||
if (db4 != nil && db4.Error != nil) || db.Error != nil || db1.Error != nil || db2.Error != nil {
|
||||
tx.Callback()
|
||||
orderLock.Unlock()
|
||||
@@ -361,10 +420,39 @@ func GetOrderDetail(orderId string) OrderDetail {
|
||||
var orderDetailList []models.OrderDetail
|
||||
database.Instance().Model(&models.OrderDetail{}).Where("sub_order_id = ? ", orderSub.OrderId).Find(&orderDetailList)
|
||||
var goods []models.Goods
|
||||
var couponsGoods models.Goods
|
||||
var coupons models.Coupons
|
||||
for _, orderDetail := range orderDetailList {
|
||||
good := GoodsMap[orderDetail.GoodsId]
|
||||
goods = append(goods, good)
|
||||
coupons = CouponsMap[orderSub.Cid]
|
||||
if coupons.Id == 0 {
|
||||
var couponsS *models.Coupons
|
||||
database.Instance().Model(&models.Coupons{}).Where("id = ?", orderSub.Cid).Find(&couponsS)
|
||||
coupons = models.Coupons{
|
||||
Id: couponsS.Id,
|
||||
Name: couponsS.Name,
|
||||
GoodsSubType: couponsS.GoodsSubType,
|
||||
Discount: couponsS.Discount,
|
||||
Source: couponsS.Source,
|
||||
PeriodType: couponsS.PeriodType,
|
||||
Period: couponsS.Period,
|
||||
PeriodInfo: couponsS.PeriodInfo,
|
||||
ExpireTime: couponsS.ExpireTime,
|
||||
CreateTime: couponsS.CreateTime,
|
||||
UpdateTime: couponsS.UpdateTime,
|
||||
Status: couponsS.Status,
|
||||
SendStatus: couponsS.SendStatus,
|
||||
ReceiverStatus: couponsS.ReceiverStatus,
|
||||
}
|
||||
}
|
||||
if orderSub.Cid > 0 {
|
||||
if coupons.GoodsSubType == good.GoodsSubType {
|
||||
couponsGoods = good
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
orderSubR1 := SubOrder{
|
||||
OrderId: orderSub.OrderId,
|
||||
Status: orderSub.OrderStatus,
|
||||
@@ -373,20 +461,39 @@ func GetOrderDetail(orderId string) OrderDetail {
|
||||
PayAmount: strconv.Itoa(orderSub.PayAmount),
|
||||
Discount: float64(orderSub.Discount),
|
||||
Goods: goods,
|
||||
Coupons: nil,
|
||||
}
|
||||
if coupons.Id > 0 {
|
||||
orderSubR1.Coupons = &models.Coupons{
|
||||
Id: coupons.Id,
|
||||
Name: coupons.Name,
|
||||
GoodsSubType: coupons.GoodsSubType,
|
||||
Discount: coupons.Discount,
|
||||
Source: coupons.Source,
|
||||
PeriodType: coupons.PeriodType,
|
||||
Period: coupons.Period,
|
||||
PeriodInfo: coupons.PeriodInfo,
|
||||
SendStatus: coupons.SendStatus,
|
||||
}
|
||||
orderSubR1.CouponsAmount = strconv.FormatFloat(float64(couponsGoods.Price*10-orderSub.GoodsDiscountAmount)/10, 'f', 1, 64)
|
||||
} else {
|
||||
orderSubR1.Coupons = nil
|
||||
}
|
||||
discountTotalAmount = discountTotalAmount + orderSub.GoodsOriginAmount*10 + orderSub.GoodsDiscountAmount
|
||||
if orderSub.PayType == 3 {
|
||||
if orderSub.PayType == 3 || orderSubR1.Coupons != nil {
|
||||
x := float64(orderSub.PayAmount) / 10
|
||||
orderSubR1.PayAmount = strconv.FormatFloat(x, 'f', 1, 64)
|
||||
}
|
||||
if orderSubR1.Discount < 100 {
|
||||
//orderSubR1.PayAmount = int32(math.Round(float64(orderSubR1.TotalAmount) * (orderSubR1.Discount / 100.0)))
|
||||
//x := float64(orderSubR1.TotalAmount) * (orderSubR1.Discount / 100.0) / 10
|
||||
if orderSubR1.Discount < 100 || orderSubR1.Coupons != nil {
|
||||
orderSubR1.DiscountAmount = orderSubR1.PayAmount
|
||||
} else {
|
||||
orderSubR1.DiscountAmount = strconv.Itoa(orderSubR1.TotalAmount)
|
||||
if orderSub.PayAmount > 0 {
|
||||
orderSubR1.DiscountAmount = strconv.FormatFloat(float64(orderSub.PayAmount)/10, 'f', 1, 64)
|
||||
} else {
|
||||
orderSubR1.DiscountAmount = strconv.Itoa(orderSubR1.TotalAmount)
|
||||
}
|
||||
}
|
||||
if orderSub.PayType == 1 {
|
||||
if orderSub.PayType == 1 && orderSubR1.Coupons == nil {
|
||||
orderSubR1.PayAmount = strconv.Itoa(orderSubR1.TotalAmount)
|
||||
}
|
||||
subOrderList = append(subOrderList, orderSubR1)
|
||||
@@ -437,14 +544,16 @@ type OrderListRequest struct {
|
||||
}
|
||||
|
||||
type SubOrder struct {
|
||||
OrderId string `json:"orderId"` //子订单ID
|
||||
Status int `json:"status"` //子订单状态 0待派单 1待服务 2服务中 3已完成 4已取消
|
||||
UserPetInfo UserPetInfo `json:"userPetInfo"` //用户宠物信息
|
||||
TotalAmount int `json:"totalAmount"` //总金额
|
||||
PayAmount string `json:"payAmount"` //实际支付金额
|
||||
DiscountAmount string `json:"discountAmount"` //折扣金额
|
||||
Discount float64 `json:"discount"` //用户折扣
|
||||
Goods []models.Goods `json:"goods"` //商品信息
|
||||
OrderId string `json:"orderId"` //子订单ID
|
||||
Status int `json:"status"` //子订单状态 0待派单 1待服务 2服务中 3已完成 4已取消
|
||||
UserPetInfo UserPetInfo `json:"userPetInfo"` //用户宠物信息
|
||||
TotalAmount int `json:"totalAmount"` //总金额
|
||||
PayAmount string `json:"payAmount"` //实际支付金额
|
||||
DiscountAmount string `json:"discountAmount"` //折扣金额
|
||||
Discount float64 `json:"discount"` //用户折扣
|
||||
Goods []models.Goods `json:"goods"` //商品信息
|
||||
Coupons *models.Coupons `json:"coupons"` //优惠券信息
|
||||
CouponsAmount string `json:"couponsAmount"` //优惠券减免金额
|
||||
}
|
||||
|
||||
type OrderDetail struct {
|
||||
@@ -613,6 +722,16 @@ func (p DefParty) orderCancel() web_iris.Party {
|
||||
"OrderStatus": 4,
|
||||
}
|
||||
database.Instance().Model(&orderSub).Updates(&updateValuesSub)
|
||||
//返还优惠券
|
||||
if orderSub.Cid > 0 {
|
||||
var userCoupons []models.UserCoupons
|
||||
database.Instance().Model(&models.UserCoupons{}).Where("uid = ? and cid = ? and coupons_status = 2", headerBaseInfo.Uid, orderSub.Cid).Order(clause.OrderByColumn{Column: clause.Column{Name: "update_time"}, Desc: true}).Find(&userCoupons)
|
||||
coupons := userCoupons[0]
|
||||
updateValuesCoupons := map[string]interface{}{
|
||||
"CouponsStatus": 1,
|
||||
}
|
||||
database.Instance().Model(&coupons).Updates(updateValuesCoupons)
|
||||
}
|
||||
}
|
||||
Success(ctx, orderCancelRequest, OrderCancelResponse{GetOrderDetail(orderMain.OrderId)})
|
||||
})
|
||||
@@ -774,8 +893,23 @@ func (p DefParty) orderGoodsUpdate() web_iris.Party {
|
||||
database.Instance().Model(&models.OrderMain{}).Where("order_id = ? and status = 1", orderSub.MainOrderId).Find(&orderMain)
|
||||
var nowOrderTotalAmount = 0
|
||||
var projectionServiceTime = 0
|
||||
|
||||
//商品优惠券价格
|
||||
var goodsDiscountAmount = 0
|
||||
//商品非优惠券价格
|
||||
var goodsNotDiscountAmount = 0
|
||||
var coupons models.Coupons
|
||||
for _, value := range orderGoodsUpdateRequest.GoodsIds {
|
||||
goods := GoodsMap[value]
|
||||
if orderSub.Cid > 0 {
|
||||
coupons = CouponsMap[orderSub.Cid]
|
||||
}
|
||||
if coupons.Id > 0 && coupons.GoodsSubType == goods.GoodsSubType {
|
||||
goodsDiscountAmount = goodsDiscountAmount + int(utils.RoundToOneDecimalPlace(float64(goods.Price)*(float64(coupons.Discount)/100.0))*10)
|
||||
} else {
|
||||
goodsNotDiscountAmount = goodsNotDiscountAmount + goods.Price
|
||||
}
|
||||
|
||||
nowOrderTotalAmount = nowOrderTotalAmount + goods.Price
|
||||
if goods.Time != "/" && len(goods.Time) > 0 {
|
||||
goodsTime, _ := strconv.Atoi(goods.Time)
|
||||
@@ -808,13 +942,15 @@ func (p DefParty) orderGoodsUpdate() web_iris.Party {
|
||||
|
||||
if userInfo.Discount > 0 {
|
||||
discount := float64(userInfo.Discount)
|
||||
subOrderAmount = int(utils.RoundToOneDecimalPlace(float64(subOrderAmount)*(discount/100.0)) * 10)
|
||||
//计算非折扣商品
|
||||
subOrderAmount = int(utils.RoundToOneDecimalPlace(float64(goodsNotDiscountAmount)*(discount/100.0)) * 10)
|
||||
} else {
|
||||
subOrderAmount = goodsNotDiscountAmount * 10
|
||||
}
|
||||
orderMain.PayTotalAmount = orderMain.PayTotalAmount - originOrderPayAmount + subOrderAmount
|
||||
orderMain.TotalAmount = orderMain.TotalAmount - originOrderTotalAmount + nowOrderTotalAmount
|
||||
orderMain.PayTotalAmount = orderMain.PayTotalAmount - originOrderPayAmount + subOrderAmount + goodsDiscountAmount
|
||||
|
||||
//余额不足
|
||||
if userInfo.Amount < subOrderAmount {
|
||||
if userInfo.Amount < subOrderAmount+goodsDiscountAmount {
|
||||
OrderUpdateBalanceNotEnough.DefFail(ctx, orderGoodsUpdateRequest, "原订单金额:"+strconv.FormatFloat(float64(orderMain.PayTotalAmount)/10, 'f', 1, 64)+" 修改后订单金额:"+strconv.FormatFloat(float64(orderMain.PayTotalAmount)/10, 'f', 1, 64)+";修改服务项目后余额不足,请充值后再支付")
|
||||
return
|
||||
}
|
||||
@@ -822,13 +958,13 @@ func (p DefParty) orderGoodsUpdate() web_iris.Party {
|
||||
var amountType = 2
|
||||
var proAmount = 0
|
||||
//原始价格小于新价格 扣,原始价格大于新价格 加
|
||||
if originOrderPayAmount < subOrderAmount {
|
||||
if originOrderPayAmount < subOrderAmount+goodsDiscountAmount {
|
||||
} else {
|
||||
amountType = 1
|
||||
}
|
||||
|
||||
var preAmount = orderMain.PayTotalAmount
|
||||
userInfo.Amount = userInfo.Amount - subOrderAmount
|
||||
userInfo.Amount = userInfo.Amount - (subOrderAmount + goodsDiscountAmount)
|
||||
updateValues := map[string]interface{}{
|
||||
"Amount": userInfo.Amount,
|
||||
}
|
||||
@@ -854,6 +990,7 @@ func (p DefParty) orderGoodsUpdate() web_iris.Party {
|
||||
database.Instance().Model(&models.UserAmountRecord{}).Create(&userAmountRecord)
|
||||
zap_server.ZAPLOG.Info("会员金额扣除", zap.Any("用户ID", userInfo.Id), zap.Any("订单ID", orderMain.OrderId), zap.Any("用户修改之前余额", originAmount), zap.Any("当前余额", userInfo.Amount), zap.Any("商品修改之前金额", preAmount), zap.Any("商品修改之后金额", orderMain.PayTotalAmount), zap.Any("折扣", userInfo.Discount))
|
||||
}
|
||||
orderSub.PayAmount = subOrderAmount + goodsDiscountAmount
|
||||
} else {
|
||||
var x = 0
|
||||
if originOrderTotalAmount > nowOrderTotalAmount {
|
||||
@@ -873,35 +1010,58 @@ func (p DefParty) orderGoodsUpdate() web_iris.Party {
|
||||
Status: 1,
|
||||
}
|
||||
database.Instance().Model(&models.UserAmountRecord{}).Create(&userAmountRecord)
|
||||
orderSub.PayAmount = goodsNotDiscountAmount*10 + goodsDiscountAmount
|
||||
}
|
||||
|
||||
database.Instance().Where("sub_order_id = ?", orderGoodsUpdateRequest.OrderId).Delete(&models.OrderDetail{})
|
||||
var goodsName = ""
|
||||
for _, value := range orderGoodsUpdateRequest.GoodsIds {
|
||||
goods := GoodsMap[value]
|
||||
orderDetail := models.OrderDetail{
|
||||
SubOrderId: orderGoodsUpdateRequest.OrderId,
|
||||
GoodsId: goods.Id,
|
||||
Amount: goods.Price,
|
||||
Cid: orderSub.Cid,
|
||||
}
|
||||
goodsName = goods.Name + "、" + goodsName
|
||||
database.Instance().Model(&models.OrderDetail{}).Create(&orderDetail)
|
||||
}
|
||||
|
||||
userPetInfo := GetUserPet(orderMain.Uid, orderSub.PetId)
|
||||
var weightStr = "无"
|
||||
if userPetInfo.PetBaseInfo.PetType == 1 {
|
||||
weightStr = CatWeightMap[userPetInfo.PetInfo.Weight]
|
||||
} else {
|
||||
weightStr = DogWeightMap[userPetInfo.PetInfo.Weight]
|
||||
}
|
||||
var petInfo = "宠物名称:" + userPetInfo.PetInfo.NickName + "</br>品种:" + userPetInfo.PetBaseInfo.Assortment + "</br>体重:" + weightStr + "</br>服务项目:" + goodsName
|
||||
orderSub.PetInfo = petInfo
|
||||
orderSub.TotalAmount = nowOrderTotalAmount
|
||||
orderSub.PayAmount = subOrderAmount
|
||||
orderSub.ProjectionServiceTime = projectionServiceTime
|
||||
updateValues := map[string]interface{}{
|
||||
"TotalAmount": orderSub.TotalAmount,
|
||||
"PayAmount": orderSub.PayAmount,
|
||||
"ProjectionServiceTime": orderSub.ProjectionServiceTime,
|
||||
"GoodsDiscountAmount": goodsDiscountAmount,
|
||||
"GoodsOriginAmount": goodsNotDiscountAmount,
|
||||
"PetInfo": orderSub.PetInfo,
|
||||
}
|
||||
database.Instance().Model(&orderSub).Updates(&updateValues)
|
||||
//当前所有订单
|
||||
var orderSubListAll []models.OrderSub
|
||||
database.Instance().Model(&models.OrderSub{}).Where("main_order_id = ?", orderMain.OrderId).Find(&orderSubListAll)
|
||||
var totalAmount = 0
|
||||
for _, sub := range orderSubListAll {
|
||||
totalAmount = totalAmount + sub.TotalAmount
|
||||
}
|
||||
|
||||
orderMain.ProjectionServiceTime = allProjectionServiceTime
|
||||
orderMain.TotalAmount = totalAmount
|
||||
updateValues1 := map[string]interface{}{
|
||||
"PayTotalAmount": orderMain.PayTotalAmount,
|
||||
"TotalAmount": orderMain.TotalAmount,
|
||||
"ProjectionServiceTime": orderMain.ProjectionServiceTime,
|
||||
}
|
||||
database.Instance().Model(&orderMain).Updates(&updateValues1)
|
||||
database.Instance().Model(&orderSub).Updates(&updateValues)
|
||||
Success(ctx, orderGoodsUpdateRequest, OrderDetailResponse{GetOrderDetail(orderSub.MainOrderId)})
|
||||
})
|
||||
}}
|
||||
|
||||
@@ -0,0 +1,110 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"crypto/x509"
|
||||
"encoding/json"
|
||||
"github.com/kataras/iris/v12"
|
||||
"github.com/kataras/iris/v12/context"
|
||||
"github.com/wechatpay-apiv3/wechatpay-go/core"
|
||||
"github.com/wechatpay-apiv3/wechatpay-go/core/auth/verifiers"
|
||||
"github.com/wechatpay-apiv3/wechatpay-go/core/notify"
|
||||
"github.com/wechatpay-apiv3/wechatpay-go/services/payments"
|
||||
"github.com/wechatpay-apiv3/wechatpay-go/services/payments/jsapi"
|
||||
utils2 "github.com/wechatpay-apiv3/wechatpay-go/utils"
|
||||
"go.uber.org/zap"
|
||||
"io"
|
||||
"pet-house.com/business/models"
|
||||
"pet-house.com/business/utils"
|
||||
"pet-house.com/core/server/database"
|
||||
"pet-house.com/core/server/web"
|
||||
"pet-house.com/core/server/web/web_iris"
|
||||
"pet-house.com/core/server/zap_server"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
// 充值挡位列表
|
||||
func (p DefParty) rechargeInfoList() web_iris.Party {
|
||||
return web_iris.Party{Prefix: p.Prefix, PartyFunc: func(index iris.Party) {
|
||||
index.Post(PayBase+"/rechargeInfoList", func(ctx *context.Context) {
|
||||
var rechargeInfoList []models.RechargeInfo
|
||||
database.Instance().Model(&models.RechargeInfo{}).Where("type = 1 and status = 1").Find(&rechargeInfoList)
|
||||
Success(ctx, nil, rechargeInfoList)
|
||||
})
|
||||
}}
|
||||
}
|
||||
|
||||
type ToPayRequest struct {
|
||||
PayId int //支付ID
|
||||
}
|
||||
|
||||
type ToPayResponse struct {
|
||||
Content *jsapi.PrepayWithRequestPaymentResponse `json:"content"`
|
||||
PayOrderId string
|
||||
}
|
||||
|
||||
// 充值
|
||||
func (p DefParty) toPay() web_iris.Party {
|
||||
return web_iris.Party{Prefix: p.Prefix, PartyFunc: func(index iris.Party) {
|
||||
index.Post(PayBase+"/toPay", func(ctx *context.Context) {
|
||||
headerBaseInfo := GetHeaderBaseInfo(ctx)
|
||||
body, _ := io.ReadAll(ctx.Request().Body)
|
||||
var toPayRequest ToPayRequest
|
||||
json.Unmarshal(body, &toPayRequest)
|
||||
var userInfo *models.User
|
||||
database.Instance().Model(&models.User{}).Where("id = ?", headerBaseInfo.Uid).Find(&userInfo)
|
||||
var rechargeInfo *models.RechargeInfo
|
||||
database.Instance().Model(&models.RechargeInfo{}).Where("id = ?", toPayRequest.PayId).Find(&rechargeInfo)
|
||||
svc := jsapi.JsapiApiService{Client: utils.GetWxPayService()}
|
||||
price, _ := strconv.ParseInt(rechargeInfo.Price, 10, 64)
|
||||
orderId := NextId.Generate().String()
|
||||
// 得到prepay_id,以及调起支付所需的参数和签名
|
||||
resp, _, err := svc.PrepayWithRequestPayment(ctx,
|
||||
jsapi.PrepayRequest{
|
||||
Appid: core.String(utils.CONFIG.AppId),
|
||||
Mchid: core.String(utils.CONFIG.MchId),
|
||||
Description: core.String(rechargeInfo.Name),
|
||||
OutTradeNo: core.String(orderId),
|
||||
NotifyUrl: core.String(web.CONFIG.System.Domain + "/pet-house/pay/payNotify"),
|
||||
Amount: &jsapi.Amount{
|
||||
Total: core.Int64(price * 100),
|
||||
},
|
||||
Payer: &jsapi.Payer{
|
||||
Openid: core.String(userInfo.OpenId),
|
||||
},
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
PayError.DefFail(ctx, toPayRequest, nil)
|
||||
return
|
||||
}
|
||||
payOrder := models.PayOrder{
|
||||
OrderId: orderId,
|
||||
OrderName: rechargeInfo.Name,
|
||||
OrderPrice: rechargeInfo.Price,
|
||||
PayId: "",
|
||||
}
|
||||
database.Instance().Model(&models.PayOrder{}).Create(&payOrder)
|
||||
Success(ctx, toPayRequest, ToPayResponse{Content: resp, PayOrderId: orderId})
|
||||
})
|
||||
}}
|
||||
}
|
||||
|
||||
// 充值通知
|
||||
func (p DefParty) payNotify() web_iris.Party {
|
||||
return web_iris.Party{Prefix: p.Prefix, PartyFunc: func(index iris.Party) {
|
||||
index.Post(PayBase+"/payNotify", func(ctx *context.Context) {
|
||||
wechatPayCert, _ := utils2.LoadCertificate(utils.CONFIG.WechatCert)
|
||||
// 2. 使用本地管理的微信支付平台证书获取微信支付平台证书访问器
|
||||
certificateVisitor := core.NewCertificateMapWithList([]*x509.Certificate{wechatPayCert})
|
||||
// 3. 使用apiv3 key、证书访问器初始化 `notify.Handler`
|
||||
handler := notify.NewNotifyHandler(utils.CONFIG.MchAPIv3Key, verifiers.NewSHA256WithRSAVerifier(certificateVisitor))
|
||||
transaction := new(payments.Transaction)
|
||||
notifyReq, err := handler.ParseNotifyRequest(ctx, ctx.Request(), transaction)
|
||||
zap_server.ZAPLOG.Info("payNotify", zap.Any("notifyReq", notifyReq), zap.Any("transaction", transaction), zap.Any("err", err))
|
||||
var payOrder *models.PayOrder
|
||||
database.Instance().Model(&models.PayOrder{}).Where("order_id = ?", transaction.OutTradeNo).Find(&payOrder)
|
||||
payOrder.Status = 1
|
||||
database.Instance().Model(&models.PayOrder{}).Updates(&payOrder)
|
||||
})
|
||||
}}
|
||||
}
|
||||
@@ -25,7 +25,9 @@ func (p DefParty) systemConfigInfo() web_iris.Party {
|
||||
}
|
||||
|
||||
type SystemBannersResponse struct {
|
||||
Banners []models.SystemConfig `json:"banners"`
|
||||
Banners []models.SystemConfig `json:"banners"`
|
||||
ShareText string `json:"shareText"`
|
||||
ShareImg string `json:"shareImg"`
|
||||
}
|
||||
|
||||
// 获取系统banner
|
||||
@@ -34,7 +36,9 @@ func (p DefParty) systemBanners() web_iris.Party {
|
||||
index.Post(System+"/systemBanners", func(ctx *context.Context) {
|
||||
var systemConfig []models.SystemConfig
|
||||
database.Instance().Model(&models.SystemConfig{}).Where("config_type = 0").Order(clause.OrderByColumn{Column: clause.Column{Name: "sort"}, Desc: true}).Find(&systemConfig)
|
||||
Success(ctx, nil, SystemBannersResponse{systemConfig})
|
||||
var systemConfigShare models.SystemConfig
|
||||
database.Instance().Model(&models.SystemConfig{}).Where("config_type = 3").Order(clause.OrderByColumn{Column: clause.Column{Name: "sort"}, Desc: true}).Limit(1).Find(&systemConfigShare)
|
||||
Success(ctx, nil, SystemBannersResponse{systemConfig, systemConfigShare.Content, systemConfigShare.JumpUrl})
|
||||
})
|
||||
}}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user