cid
This commit is contained in:
parent
9bda1116fa
commit
4b9a6e5108
|
@ -113,6 +113,39 @@ func (d *ApprovalPaymentDao) Query(page, size int, corpId int64, username, start
|
|||
return u, count, nil
|
||||
}
|
||||
|
||||
func (d *ApprovalPaymentDao) QueryAmount(corpId int64, username, startDay, endDay, payer, payee string) (int64, error) {
|
||||
|
||||
tx := GetDB().Table(d.TableName())
|
||||
tx.Where("corp_id = ?", corpId)
|
||||
if username != "" {
|
||||
tx.Where("username = ?", username)
|
||||
}
|
||||
if startDay != "" {
|
||||
tx.Where("payment_date >= ?", startDay)
|
||||
}
|
||||
if endDay != "" {
|
||||
tx.Where("payment_date <= ?", endDay)
|
||||
}
|
||||
if payer != "" {
|
||||
tx.Where("payment_pyer <= ?", payer)
|
||||
}
|
||||
if payee != "" {
|
||||
tx.Where("payment_pyee <= ?", payee)
|
||||
}
|
||||
|
||||
var sumAmount float64
|
||||
var count int64
|
||||
tx.Count(&count)
|
||||
if count != 0 {
|
||||
tx.Select("SUM(payment_amount) AS payment_amount").Pluck("payment_amount", &sumAmount)
|
||||
if tx.Error != nil {
|
||||
return 0, tx.Error
|
||||
}
|
||||
}
|
||||
|
||||
return int64(100 * sumAmount), nil
|
||||
}
|
||||
|
||||
func (d *ApprovalPaymentDao) Count(corpId int64, startDay, endDay string, field string) ([]*CountValue, error) {
|
||||
var u []*CountValue
|
||||
tx := GetDB().Table(d.TableName())
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"salary_latest": 9,
|
||||
"salary_latest": 31,
|
||||
"staff_config": [
|
||||
{
|
||||
"name": "目标绩效",
|
||||
|
|
|
@ -24,11 +24,11 @@ type Payment struct {
|
|||
|
||||
type ListPaymentReq struct {
|
||||
BaseRequest
|
||||
StartDay string `from:"start_day"`
|
||||
EndDay string `from:"end_day"`
|
||||
Username string `from:"username"`
|
||||
Payer string `from:"payer"`
|
||||
Payee string `from:"payee"`
|
||||
StartDay string `form:"start_day"`
|
||||
EndDay string `form:"end_day"`
|
||||
Username string `form:"username"`
|
||||
Payer string `form:"payer"`
|
||||
Payee string `form:"payee"`
|
||||
}
|
||||
|
||||
func (p *Payment) From(m *model.ApprovalPayment) {
|
||||
|
|
|
@ -22,11 +22,12 @@ func NewQyWeixin() *QyWeixin {
|
|||
func (q *QyWeixin) Approve(ctx *gin.Context) {
|
||||
|
||||
sess := ctx.Keys[session.ContextSession].(*session.AdminSession)
|
||||
corp, err := dao.NewCorpDao().GetByHost(sess.GetHeader().Host)
|
||||
|
||||
cid := cast.ToInt64(ctx.Param("cid"))
|
||||
corp, err := dao.NewCorpDao().Get(cid)
|
||||
session.CheckDBError(err)
|
||||
if corp == nil {
|
||||
cid := cast.ToInt64(ctx.Param("cid"))
|
||||
corp, err = dao.NewCorpDao().Get(cid)
|
||||
corp, err = dao.NewCorpDao().GetByHost(sess.GetHeader().Host)
|
||||
session.CheckDBError(err)
|
||||
session.CheckNilError(corp, "企业不存在")
|
||||
}
|
||||
|
|
|
@ -29,7 +29,24 @@ func NewSalaryCalculator1000(corp *model.Corp, user *model.StaffUser) registry.S
|
|||
}
|
||||
|
||||
func (s *SalaryCalculator1000) Calculate(salary *model.StaffSalary) map[string]interface{} {
|
||||
return nil
|
||||
|
||||
monthTime, _ := time.ParseInLocation("200601", salary.Month, time.Local)
|
||||
startDay := monthTime.Format("2006-01-02")
|
||||
endDay := monthTime.AddDate(0, 1, -1).Format("2006-01-02")
|
||||
datas, err := dao.NewUnifyAdData().QueryOwnerData(s.user.Username, startDay, endDay)
|
||||
if err != nil {
|
||||
log.Errorf("db error :%s", err.Error())
|
||||
return nil
|
||||
}
|
||||
sumProfitAmount := int64(0)
|
||||
for _, data := range datas {
|
||||
sumProfitAmount += data.PayAmount - data.Cost
|
||||
}
|
||||
data := make(map[string]interface{})
|
||||
totalProfit := cast.ToFloat64(goutil.FormatMoney(sumProfitAmount))
|
||||
data["adProfit"] = totalProfit
|
||||
|
||||
return data
|
||||
}
|
||||
|
||||
func (s *SalaryCalculator1000) CalculateDe(salary *model.StaffSalary) {
|
||||
|
|
Loading…
Reference in New Issue