|
@@ -1,19 +1,19 @@
|
|
|
package service
|
|
|
|
|
|
import (
|
|
|
+ "app.yhyue.com/moapp/jyResourcesCenter/entity"
|
|
|
+ "app.yhyue.com/moapp/jyResourcesCenter/rpc/resourcesCenter"
|
|
|
+ "app.yhyue.com/moapp/jybase/mongodb"
|
|
|
"bytes"
|
|
|
"encoding/json"
|
|
|
"fmt"
|
|
|
+ "github.com/gogf/gf/v2/util/gconv"
|
|
|
+ "github.com/google/uuid"
|
|
|
"io/ioutil"
|
|
|
"log"
|
|
|
"net/http"
|
|
|
"strconv"
|
|
|
"time"
|
|
|
-
|
|
|
- "app.yhyue.com/moapp/jyResourcesCenter/entity"
|
|
|
- "app.yhyue.com/moapp/jyResourcesCenter/rpc/resourcesCenter"
|
|
|
- "github.com/gogf/gf/v2/util/gconv"
|
|
|
- "github.com/google/uuid"
|
|
|
)
|
|
|
|
|
|
type BalanceService struct{}
|
|
@@ -159,7 +159,7 @@ func (service *BalanceService) PurchaseUserBalance(balanceData *resourcesCenter.
|
|
|
}
|
|
|
|
|
|
// 根据账户标识使用资源
|
|
|
-func (service *BalanceService) UseUserDetailed(duplicateRemoval int64, balanceData *resourcesCenter.Balance, detailedData *resourcesCenter.Detailed, infoId, url string, producMap map[string]interface{}, vipState, entId, entUserId int64) (int64, string, int64) {
|
|
|
+func (service *BalanceService) UseUserDetailed(duplicateRemoval int64, balanceData *resourcesCenter.Balance, detailedData *resourcesCenter.Detailed, infoId, url string, producMap map[string]interface{}, vipState int64, entId, entUserId int64) (int64, string, int64) {
|
|
|
orm := entity.Engine.NewSession()
|
|
|
jyOrm := entity.JyEngine.NewSession()
|
|
|
err := orm.Begin()
|
|
@@ -647,8 +647,22 @@ func (service *BalanceService) DataExpireHandle() {
|
|
|
}
|
|
|
return string(jsonData)
|
|
|
}()
|
|
|
+ userId := gconv.String(m["accountId"])
|
|
|
+ entId := int64(0)
|
|
|
+ entUserId := int64(0)
|
|
|
+ operator := ""
|
|
|
+ if !mongodb.IsObjectIdHex(userId) {
|
|
|
+ entUserData := PositionIdToEnt(gconv.Int64(userId))
|
|
|
+ if entUserData != nil {
|
|
|
+ entId = gconv.Int64(gconv.String(entUserData["ent_id"]))
|
|
|
+ entUserId = gconv.Int64(gconv.String(entUserData["id"]))
|
|
|
+ entName := gconv.String(entUserData["name"])
|
|
|
+ entPhone := gconv.String(entUserData["phone"])
|
|
|
+ operator = fmt.Sprintf("%s(%s)", entName, entPhone)
|
|
|
+ }
|
|
|
+ }
|
|
|
detailed := entity.Detailed{
|
|
|
- AccountId: gconv.String(m["accountId"]),
|
|
|
+ AccountId: userId,
|
|
|
CompanyId: gconv.Int64(m["companyId"]),
|
|
|
DepartmentId: gconv.Int64(m["departmentId"]),
|
|
|
ResourceType: resourceType,
|
|
@@ -656,8 +670,11 @@ func (service *BalanceService) DataExpireHandle() {
|
|
|
CreateTime: time.Now().Local(),
|
|
|
UserType: 5, //作废标识
|
|
|
Remarks: remarks,
|
|
|
- UserId: gconv.String(m["userId"]),
|
|
|
+ UserId: userId,
|
|
|
Name: name,
|
|
|
+ EntId: entId,
|
|
|
+ EntUserId: entUserId,
|
|
|
+ Operator: operator,
|
|
|
}
|
|
|
_, e := orm.Table(ConsumeRecord).Insert(&detailed)
|
|
|
if e != nil {
|
|
@@ -672,3 +689,20 @@ func (service *BalanceService) DataExpireHandle() {
|
|
|
Update(&updataMap)
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+// 通过职位id获取 企业基础架构信息
|
|
|
+func PositionIdToEnt(positionId int64) map[string]interface{} {
|
|
|
+ orm := entity.JyEngine.NewSession()
|
|
|
+ dataList := []map[string]interface{}{}
|
|
|
+ orm.SQL(fmt.Sprintf(`SELECT
|
|
|
+ c.name,c.id,c.ent_id,c.phone
|
|
|
+FROM
|
|
|
+ base_service.base_position a
|
|
|
+ INNER JOIN base_service.base_user b ON a.id = %d
|
|
|
+ AND a.user_id = b.id
|
|
|
+ INNER JOIN entniche_user c on c.ent_id=a.ent_id and b.phone=c.phone `, positionId)).Find(&dataList)
|
|
|
+ if dataList != nil && len(dataList) > 0 {
|
|
|
+ return (dataList)[0]
|
|
|
+ }
|
|
|
+ return nil
|
|
|
+}
|