Sfoglia il codice sorgente

Merge branch 'yun-group-buy' of k.zhang/duoduo into yun-test

k.zhang 4 settimane fa
parent
commit
4e5b793925

+ 7 - 20
apis/shanghu/active.cash.out.go

@@ -15,8 +15,7 @@ import (
 
 func ActiveCashOut(c *gin.Context) {
 	var inData models.PayCashOutRequest
-	var merchantAccountSql shanghu.MerchantAccount
-	var clientAccountSql shanghu.MerchantClientAccount
+	var clientAccountSql shanghu.ActiveClientAccount
 	var cashOut shanghu.CashOut
 	var trans []models.TransferDetailList
 	var transDetail models.TransferDetailList
@@ -67,7 +66,7 @@ func ActiveCashOut(c *gin.Context) {
 	//校验金额是否够
 	if inData.AccountType == "client" {
 		clientAccountSql.ClientOpenID = inData.OpenId
-		clientAccountInfo, err := clientAccountSql.GetClientAccount()
+		clientAccountInfo, err := clientAccountSql.GetActiveAccount()
 		if err != nil {
 			app.Error(c, 400, err, err.Error())
 			return
@@ -76,27 +75,15 @@ func ActiveCashOut(c *gin.Context) {
 			app.Error(c, 400, errors.New("账号余额不够"), "账号余额不够")
 			return
 		}
-		var client shanghu.MerchantClientUser
+		var client shanghu.ActiveUser
 		client.Code = "7jb6"
 		clientInfo, _ := client.GetUserInfoByCode()
-		if clientInfo.ClientOpenID == inData.OpenId {
+		if clientInfo.OpenID == inData.OpenId {
 			cashOut.Fee = decimal.NewFromInt(0)
 		} else {
 			cashOut.Fee = inData.Amount.Mul(decimal.NewFromFloat32(0.05))
 		}
 
-	} else if inData.AccountType == "merchant" {
-		merchantAccountSql.MerchantOpenID = inData.OpenId
-		merchantAccountInfo, err := merchantAccountSql.GetMerchantAccount()
-		if err != nil {
-			app.Error(c, 400, err, err.Error())
-			return
-		}
-		if inData.Amount.Cmp(merchantAccountInfo.Amount) > 0 {
-			app.Error(c, 400, errors.New("账号余额不够"), "账号余额不够")
-			return
-		}
-		cashOut.Fee = decimal.NewFromInt(0)
 	} else {
 		app.Error(c, 400, errors.New("账户类型错误"), "账户类型错误")
 		return
@@ -118,7 +105,7 @@ func ActiveCashOut(c *gin.Context) {
 	transDetail.TransferAmount = inData.Amount.Sub(cashOut.Fee).Mul(decimal.NewFromInt(100)).IntPart()
 	transDetail.UserName = userName
 	transDetail.Openid = inData.OpenId
-	transDetail.TransferRemark = "提现"
+	transDetail.TransferRemark = "活动提现"
 
 	trans = append(trans, transDetail)
 
@@ -144,8 +131,8 @@ func ActiveCashOut(c *gin.Context) {
 
 	bm.Set("appid", inData.Appid)
 	bm.Set("out_batch_no", partnerTradeNo)
-	bm.Set("batch_name", "提现")
-	bm.Set("batch_remark", "提现")
+	bm.Set("batch_name", "活动提现")
+	bm.Set("batch_remark", "活动提现")
 	bm.Set("total_amount", inData.Amount.Sub(cashOut.Fee).Mul(decimal.NewFromInt(100)).IntPart())
 	bm.Set("total_num", 1)
 	bMap = append(bMap, structToMap(&transDetail))

+ 5 - 2
apis/shanghu/active.pay.go

@@ -277,7 +277,10 @@ func GroupBuyCancelInfo(c *gin.Context) {
 		var activeCancelSql shanghu.ActiveCancelLog
 		activeCancelSql.ClientOpenID = payTransInfo.ClientOpenID
 		activeCancelSql.ActiveConfigID = payTransInfo.ActiveConfigID
-		num := activeCancelSql.GetActiveCancelNum()
+		activeCancelSql.GroupByProjectID = v.ID
+		num := activeCancelSql.GetActiveCancelNumByProjectID()
+		fmt.Println("num = ", num)
+
 		projectInfo.ProjectName = v.ProjectName
 		projectInfo.TotalCancelNum = v.CancelNum
 		projectInfo.PendingCancelNum = v.CancelNum - num
@@ -463,7 +466,7 @@ func GroupBuyCancel(c *gin.Context) {
 				return
 			}
 			clientAccount.ClientOpenID = activeUserInfo.OpenID
-			clientAccountInfo, err := clientAccount.GetMerchantAccount()
+			clientAccountInfo, err := clientAccount.GetActiveAccount()
 			if err != nil && err.Error() != "record not found" {
 
 				dataErr := make(map[string]interface{})

+ 1 - 1
apis/shanghu/base.go

@@ -99,7 +99,7 @@ func InitShangHuRouter(engine *gin.RouterGroup) {
 		activeV1.POST("/active/group.buy/pay", GetGroupBuyPayList)          //购买拼团列表
 		activeV1.POST("/active/draw/count", ActiveDrawCount)                //邀请客户数量统计
 		activeV1.POST("/client/user/info", GetActiveUserInfo)               //client 用户信息
-		//c端提现
+		activeV1.POST("/active/cash/out", ActiveCashOut)                    //c端提现
 
 	}
 }

+ 9 - 0
models/shanghu/active.cancel.log.go

@@ -32,6 +32,15 @@ func (m *ActiveCancelLog) GetActiveCancelNum() int {
 	return count
 }
 
+// 统计cancel数量
+func (m *ActiveCancelLog) GetActiveCancelNumByProjectID() int {
+	var count int
+
+	tableCount := orm.ShMysql.Table(m.TableName()).Where("active_config_id = ? and client_open_id = ? and group_by_project_id = ?", m.ActiveConfigID, m.ClientOpenID, m.GroupByProjectID)
+	tableCount.Count(&count)
+	return count
+}
+
 func (m *ActiveCancelLog) TXActiveCancelLogCreate(log []ActiveCancelLog) error {
 
 	var err error

+ 18 - 17
models/shanghu/active.cash.out.go

@@ -1,28 +1,29 @@
 package shanghu
 
 import (
+	"github.com/shopspring/decimal"
 	"time"
 )
 
 // 活动提现
 type ActiveCashOut struct {
-	ID               int64     `gorm:"column:id;type:bigint(20);primary_key;AUTO_INCREMENT" json:"id"` // Id
-	OpenID           string    `gorm:"column:open_id;type:varchar(255)" json:"open_id"`                // Openid
-	AppID            string    `gorm:"column:app_id;type:varchar(255)" json:"app_id"`                  // Appid
-	Status           int       `gorm:"column:status;type:int(11)" json:"status"`                       // 1-提现中 2-提现失败 3-钱已到账待账户扣减  99-提现成功
-	FailRes          string    `gorm:"column:fail_res;type:text" json:"fail_res"`                      // 失败原因
-	PartnerTradeNo   string    `gorm:"column:partner_trade_no;type:varchar(50)" json:"partner_trade_no"`
-	Amount           string    `gorm:"column:amount;type:decimal(10,2)" json:"amount"`                          // 金额
-	CornTime         time.Time `gorm:"column:corn_time;type:datetime" json:"corn_time"`                         // 定时任务下次查询状态时间
-	CreateBy         int64     `gorm:"column:create_by;type:bigint(20)" json:"create_by"`                       // 创建者
-	UpdateBy         int64     `gorm:"column:update_by;type:bigint(20)" json:"update_by"`                       // 更新者
-	CreatedAt        time.Time `gorm:"column:created_at;type:datetime(3)" json:"created_at"`                    // 创建时间
-	UpdatedAt        time.Time `gorm:"column:updated_at;type:datetime(3)" json:"updated_at"`                    // 最后更新时间
-	DeletedAt        time.Time `gorm:"column:deleted_at;type:datetime(3);default:null" json:"deleted_at"`       // 删除时间
-	Fee              string    `gorm:"column:fee;type:decimal(10,2)" json:"fee"`                                // 手续费
-	WxPartnerTradeNo string    `gorm:"column:wx_partner_trade_no;type:varchar(255)" json:"wx_partner_trade_no"` // 微信批次号
-	AccountStatus    int       `gorm:"column:account_status;type:int(11);default:0" json:"account_status"`      // 分账状态 99-分账成功 2-分账失败 0-未分账 3-分账中
-	AccountFailRes   string    `gorm:"column:account_fail_res;type:varchar(255)" json:"account_fail_res"`       // 分账失败原因
+	ID               int64           `gorm:"column:id;type:bigint(20);primary_key;AUTO_INCREMENT" json:"id"` // Id
+	OpenID           string          `gorm:"column:open_id;type:varchar(255)" json:"open_id"`                // Openid
+	AppID            string          `gorm:"column:app_id;type:varchar(255)" json:"app_id"`                  // Appid
+	Status           int             `gorm:"column:status;type:int(11)" json:"status"`                       // 1-提现中 2-提现失败 3-钱已到账待账户扣减  99-提现成功
+	FailRes          string          `gorm:"column:fail_res;type:text" json:"fail_res"`                      // 失败原因
+	PartnerTradeNo   string          `gorm:"column:partner_trade_no;type:varchar(50)" json:"partner_trade_no"`
+	Amount           decimal.Decimal `gorm:"column:amount;type:decimal(10,2)" json:"amount"`                          // 金额
+	CornTime         time.Time       `gorm:"column:corn_time;type:datetime" json:"corn_time"`                         // 定时任务下次查询状态时间
+	CreateBy         int64           `gorm:"column:create_by;type:bigint(20)" json:"create_by"`                       // 创建者
+	UpdateBy         int64           `gorm:"column:update_by;type:bigint(20)" json:"update_by"`                       // 更新者
+	CreatedAt        time.Time       `gorm:"column:created_at;type:datetime(3)" json:"created_at"`                    // 创建时间
+	UpdatedAt        time.Time       `gorm:"column:updated_at;type:datetime(3)" json:"updated_at"`                    // 最后更新时间
+	DeletedAt        time.Time       `gorm:"column:deleted_at;type:datetime(3);default:null" json:"deleted_at"`       // 删除时间
+	Fee              decimal.Decimal `gorm:"column:fee;type:decimal(10,2)" json:"fee"`                                // 手续费
+	WxPartnerTradeNo string          `gorm:"column:wx_partner_trade_no;type:varchar(255)" json:"wx_partner_trade_no"` // 微信批次号
+	AccountStatus    int             `gorm:"column:account_status;type:int(11);default:0" json:"account_status"`      // 分账状态 99-分账成功 2-分账失败 0-未分账 3-分账中
+	AccountFailRes   string          `gorm:"column:account_fail_res;type:varchar(255)" json:"account_fail_res"`       // 分账失败原因
 }
 
 func (m *ActiveCashOut) TableName() string {

+ 1 - 1
models/shanghu/actvie.client.account.go

@@ -23,7 +23,7 @@ func (m *ActiveClientAccount) TableName() string {
 	return "active_client_account"
 }
 
-func (m *ActiveClientAccount) GetMerchantAccount() (ActiveClientAccount, error) {
+func (m *ActiveClientAccount) GetActiveAccount() (ActiveClientAccount, error) {
 	var doc ActiveClientAccount
 
 	table := orm.ShMysql.Table(m.TableName())

+ 1 - 1
models/shanghu/client.active.pay.trans.go

@@ -152,7 +152,7 @@ func (m *ClientActivePayTrans) GetActivePayTransList(pageSize int, pageIndex int
 	//} else {
 	//	return doc, 0, errors.New("核销类型错误")
 	//}
-	table = table.Where("client_open_id = ? and status = 2 and account_status in (1,2)", openId)
+	table = table.Where("client_open_id = ? and status = 2 ", openId)
 
 	var count int
 	if err := table.Select("*").Order("id desc").Offset((pageIndex - 1) * pageSize).Limit(pageSize).Find(&doc).Error; err != nil {

+ 13 - 12
models/shanghu/merchant_user.go

@@ -7,18 +7,19 @@ import (
 
 // 商户账号
 type MerchantUser struct {
-	ID        int64     `gorm:"column:id;type:bigint(20);primary_key;AUTO_INCREMENT" json:"id"` // 主键
-	Code      string    `gorm:"column:code;type:varchar(255)" json:"code"`
-	OpenID    string    `gorm:"column:open_id;type:varchar(255)" json:"open_id"`                   // open_id 唯一索引
-	Phone     string    `gorm:"column:phone;type:varchar(24)" json:"phone"`                        // 手机号
-	NickName  string    `gorm:"column:nick_name;type:varchar(255)" json:"nick_name"`               // 微信用户名
-	AvatarUrl string    `gorm:"column:avatar_url;type:varchar(255)" json:"avatar_url"`             // 头像url
-	Admin     int       `gorm:"column:admin;type:int(11)" json:"admin"`                            // 1-管理员
-	CreateBy  int64     `gorm:"column:create_by;type:bigint(20)" json:"create_by"`                 // 创建者
-	UpdateBy  int64     `gorm:"column:update_by;type:bigint(20)" json:"update_by"`                 // 更新者
-	CreatedAt time.Time `gorm:"column:created_at;type:datetime(3)" json:"created_at"`              // 创建时间
-	UpdatedAt time.Time `gorm:"column:updated_at;type:datetime(3)" json:"updated_at"`              // 最后更新时间
-	DeletedAt time.Time `gorm:"column:deleted_at;type:datetime(3);default:null" json:"deleted_at"` // 删除时间
+	ID          int64     `gorm:"column:id;type:bigint(20);primary_key;AUTO_INCREMENT" json:"id"` // 主键
+	Code        string    `gorm:"column:code;type:varchar(255)" json:"code"`
+	OpenID      string    `gorm:"column:open_id;type:varchar(255)" json:"open_id"`                   // open_id 唯一索引
+	Phone       string    `gorm:"column:phone;type:varchar(24)" json:"phone"`                        // 手机号
+	NickName    string    `gorm:"column:nick_name;type:varchar(255)" json:"nick_name"`               // 微信用户名
+	AvatarUrl   string    `gorm:"column:avatar_url;type:varchar(255)" json:"avatar_url"`             // 头像url
+	Admin       int       `gorm:"column:admin;type:int(11)" json:"admin"`                            // 1-管理员
+	ActiveAdmin int       `gorm:"column:active_admin;type:int(11)" json:"active_admin"`              // 1-管理员
+	CreateBy    int64     `gorm:"column:create_by;type:bigint(20)" json:"create_by"`                 // 创建者
+	UpdateBy    int64     `gorm:"column:update_by;type:bigint(20)" json:"update_by"`                 // 更新者
+	CreatedAt   time.Time `gorm:"column:created_at;type:datetime(3)" json:"created_at"`              // 创建时间
+	UpdatedAt   time.Time `gorm:"column:updated_at;type:datetime(3)" json:"updated_at"`              // 最后更新时间
+	DeletedAt   time.Time `gorm:"column:deleted_at;type:datetime(3);default:null" json:"deleted_at"` // 删除时间
 }
 
 func (m *MerchantUser) TableName() string {

+ 2 - 0
report/cash.out.go

@@ -123,6 +123,8 @@ func CashOutAccount() {
 				accountClient.SettleAddCashOutFee(cashOutInfo.Fee, clientInfo.ClientOpenID, cashOutInfo.ID)
 			}
 
+		} else if cashOutInfo.AppID == "wx8595c589dd736486" {
+
 		} else {
 			continue
 		}