|
@@ -55,7 +55,7 @@
|
|
<div id="nav">
|
|
<div id="nav">
|
|
<select id="files">
|
|
<select id="files">
|
|
|
|
|
|
- <option value="file0">bp.jydev.jianyu360.cn/BaseService/entManageApplication/service/service.go (60.1%)</option>
|
|
|
|
|
|
+ <option value="file0">bp.jydev.jianyu360.cn/BaseService/entManageApplication/service/service.go (28.9%)</option>
|
|
|
|
|
|
</select>
|
|
</select>
|
|
</div>
|
|
</div>
|
|
@@ -81,7 +81,6 @@ import (
|
|
|
|
|
|
"context"
|
|
"context"
|
|
|
|
|
|
- "app.yhyue.com/moapp/jybase/mongodb"
|
|
|
|
. "bp.jydev.jianyu360.cn/BaseService/entManageApplication/entity"
|
|
. "bp.jydev.jianyu360.cn/BaseService/entManageApplication/entity"
|
|
"bp.jydev.jianyu360.cn/BaseService/entManageApplication/rpc/entmanageapplication"
|
|
"bp.jydev.jianyu360.cn/BaseService/entManageApplication/rpc/entmanageapplication"
|
|
"bp.jydev.jianyu360.cn/BaseService/userCenter/rpc/usercenter"
|
|
"bp.jydev.jianyu360.cn/BaseService/userCenter/rpc/usercenter"
|
|
@@ -93,7 +92,14 @@ import (
|
|
|
|
|
|
func AddUsePerson(this *entmanageapplication.AddUsePersonReq) *entmanageapplication.AddUsePersonResp <span class="cov8" title="1">{
|
|
func AddUsePerson(this *entmanageapplication.AddUsePersonReq) *entmanageapplication.AddUsePersonResp <span class="cov8" title="1">{
|
|
timeStr, ok, id, msg, code := time.Now().Format("2006-01-02 15:04:05"), false, int64(0), "", int64(0)
|
|
timeStr, ok, id, msg, code := time.Now().Format("2006-01-02 15:04:05"), false, int64(0), "", int64(0)
|
|
- UserArr := strings.Split(this.EntUserId, ",")
|
|
|
|
|
|
+ if this.EntUserId == "" </span><span class="cov0" title="0">{
|
|
|
|
+ return &entmanageapplication.AddUsePersonResp{
|
|
|
|
+ ErrorCode: -1,
|
|
|
|
+ ErrorMsg: "添加失败",
|
|
|
|
+ Data: &entmanageapplication.AddUsePerson{Status: int64(-1)},
|
|
|
|
+ }
|
|
|
|
+ }</span>
|
|
|
|
+ <span class="cov8" title="1">UserArr := strings.Split(this.EntUserId, ",")
|
|
sourceData := JyMysql.FindOne(EntnicheWaitEmpower, map[string]interface{}{"id": this.WaitEmpowerId}, "", "")
|
|
sourceData := JyMysql.FindOne(EntnicheWaitEmpower, map[string]interface{}{"id": this.WaitEmpowerId}, "", "")
|
|
if sourceData != nil && len(*sourceData) > 0 </span><span class="cov8" title="1">{
|
|
if sourceData != nil && len(*sourceData) > 0 </span><span class="cov8" title="1">{
|
|
empower_count := common.IntAll((*sourceData)["empower_count"])
|
|
empower_count := common.IntAll((*sourceData)["empower_count"])
|
|
@@ -103,18 +109,31 @@ func AddUsePerson(this *entmanageapplication.AddUsePersonReq) *entmanageapplicat
|
|
code = int64(-1)
|
|
code = int64(-1)
|
|
}</span> else<span class="cov8" title="1"> {
|
|
}</span> else<span class="cov8" title="1"> {
|
|
for _, v := range UserArr </span><span class="cov8" title="1">{
|
|
for _, v := range UserArr </span><span class="cov8" title="1">{
|
|
- entUserId, _ := strconv.Atoi(v)
|
|
|
|
|
|
+ //过滤空值2023-01-04
|
|
|
|
+ if v == "" </span><span class="cov0" title="0">{
|
|
|
|
+ continue</span>
|
|
|
|
+ }
|
|
|
|
+ //
|
|
|
|
+ <span class="cov8" title="1">entUserId, _ := strconv.Atoi(v)
|
|
data := JyMysql.FindOne(EntnichePower, map[string]interface{}{"ent_user_id": entUserId}, "", "")
|
|
data := JyMysql.FindOne(EntnichePower, map[string]interface{}{"ent_user_id": entUserId}, "", "")
|
|
- if data != nil && len(*data) > 0 </span><span class="cov8" title="1">{
|
|
|
|
|
|
+ if data != nil && len(*data) > 0 </span><span class="cov0" title="0">{
|
|
dataStatus := common.IntAll((*data)["status"])
|
|
dataStatus := common.IntAll((*data)["status"])
|
|
- if dataStatus == -1 </span><span class="cov8" title="1">{
|
|
|
|
|
|
+ wait_empower_id := common.Int64All((*data)["wait_empower_id"])
|
|
|
|
+ if dataStatus == -1 </span><span class="cov0" title="0">{
|
|
ok = JyMysql.Update(EntnichePower, map[string]interface{}{"ent_user_id": entUserId}, map[string]interface{}{"wait_empower_id": this.WaitEmpowerId, "status": 1, "update_time": timeStr})
|
|
ok = JyMysql.Update(EntnichePower, map[string]interface{}{"ent_user_id": entUserId}, map[string]interface{}{"wait_empower_id": this.WaitEmpowerId, "status": 1, "update_time": timeStr})
|
|
}</span> else<span class="cov0" title="0"> {
|
|
}</span> else<span class="cov0" title="0"> {
|
|
- msg = "人员已经拥有权限,请先删除原有权限"
|
|
|
|
- code = int64(-1)
|
|
|
|
- break</span>
|
|
|
|
|
|
+ resdata := JyMysql.FindOne(EntnicheWaitEmpower, map[string]interface{}{"id": wait_empower_id}, "", "")
|
|
|
|
+ end_time := common.ObjToString((*resdata)["end_time"])
|
|
|
|
+ res, _ := time.ParseInLocation("2006-01-02 15:04:05", end_time, time.Local)
|
|
|
|
+ if res.Unix() > time.Now().Unix() </span><span class="cov0" title="0">{
|
|
|
|
+ msg = "人员已经拥有权限,请先删除原有权限"
|
|
|
|
+ code = int64(-1)
|
|
|
|
+ break</span>
|
|
|
|
+ } else<span class="cov0" title="0"> {
|
|
|
|
+ ok = JyMysql.Update(EntnichePower, map[string]interface{}{"ent_user_id": entUserId}, map[string]interface{}{"wait_empower_id": this.WaitEmpowerId, "status": 1, "update_time": timeStr})
|
|
|
|
+ }</span>
|
|
}
|
|
}
|
|
- } else<span class="cov0" title="0"> {
|
|
|
|
|
|
+ } else<span class="cov8" title="1"> {
|
|
id = JyMysql.Insert(EntnichePower, map[string]interface{}{
|
|
id = JyMysql.Insert(EntnichePower, map[string]interface{}{
|
|
"wait_empower_id": this.WaitEmpowerId,
|
|
"wait_empower_id": this.WaitEmpowerId,
|
|
"ent_id": this.EntId,
|
|
"ent_id": this.EntId,
|
|
@@ -125,7 +144,7 @@ func AddUsePerson(this *entmanageapplication.AddUsePersonReq) *entmanageapplicat
|
|
})
|
|
})
|
|
}</span>
|
|
}</span>
|
|
<span class="cov8" title="1">JyMysql.UpdateOrDeleteBySql(`update `+EntnicheWaitEmpower+` set use_count = use_count + 1 where id = ?`, this.WaitEmpowerId)
|
|
<span class="cov8" title="1">JyMysql.UpdateOrDeleteBySql(`update `+EntnicheWaitEmpower+` set use_count = use_count + 1 where id = ?`, this.WaitEmpowerId)
|
|
- addPower(this.WaitEmpowerId, entUserId)</span>
|
|
|
|
|
|
+ addPower(this.WaitEmpowerId, entUserId, this.EntId)</span>
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -156,14 +175,16 @@ func DelUsePerson(this *entmanageapplication.DelUsePersonReq) *entmanageapplicat
|
|
}
|
|
}
|
|
|
|
|
|
func UsePersonList(this *entmanageapplication.UsePersonListReq) *entmanageapplication.UsePersonListResp <span class="cov8" title="1">{
|
|
func UsePersonList(this *entmanageapplication.UsePersonListReq) *entmanageapplication.UsePersonListResp <span class="cov8" title="1">{
|
|
|
|
+ nowTime := time.Now().Format("2006-01-02 15:04:05")
|
|
data := JyMysql.SelectBySql(`select a.id,a.wait_empower_id,c.name,c.phone,c.mail,g.name as department,e.name as role from entniche_power a
|
|
data := JyMysql.SelectBySql(`select a.id,a.wait_empower_id,c.name,c.phone,c.mail,g.name as department,e.name as role from entniche_power a
|
|
INNER JOIN entniche_user c on (a.ent_user_id=c.id and a.ent_id = c.ent_id)
|
|
INNER JOIN entniche_user c on (a.ent_user_id=c.id and a.ent_id = c.ent_id)
|
|
LEFT JOIN entniche_user_role d on (c.id=d.user_id)
|
|
LEFT JOIN entniche_user_role d on (c.id=d.user_id)
|
|
LEFT JOIN entniche_role e on (d.role_id=e.id)
|
|
LEFT JOIN entniche_role e on (d.role_id=e.id)
|
|
LEFT JOIN entniche_department_user f on (a.ent_user_id=f.user_id)
|
|
LEFT JOIN entniche_department_user f on (a.ent_user_id=f.user_id)
|
|
LEFT JOIN entniche_department g on (g.id=f.dept_id)
|
|
LEFT JOIN entniche_department g on (g.id=f.dept_id)
|
|
- where a.status = 1 and a.ent_id = ?
|
|
|
|
- order by a.update_time desc`, this.EntId)
|
|
|
|
|
|
+ LEFT JOIN entniche_wait_empower h on (h.id=a.wait_empower_id)
|
|
|
|
+ where a.status = 1 and a.ent_id = ? and end_time >= ?
|
|
|
|
+ order by a.update_time desc`, this.EntId, nowTime)
|
|
arr := []*entmanageapplication.UsePersonList{}
|
|
arr := []*entmanageapplication.UsePersonList{}
|
|
if data != nil && len(*data) > 0 </span><span class="cov8" title="1">{
|
|
if data != nil && len(*data) > 0 </span><span class="cov8" title="1">{
|
|
for _, v := range *data </span><span class="cov8" title="1">{
|
|
for _, v := range *data </span><span class="cov8" title="1">{
|
|
@@ -200,20 +221,25 @@ func UsePersonList(this *entmanageapplication.UsePersonListReq) *entmanageapplic
|
|
}
|
|
}
|
|
|
|
|
|
func BuyProductList(this *entmanageapplication.BuyProductListReq) *entmanageapplication.BuyProductListResp <span class="cov8" title="1">{
|
|
func BuyProductList(this *entmanageapplication.BuyProductListReq) *entmanageapplication.BuyProductListResp <span class="cov8" title="1">{
|
|
- data := JyMysql.Find(EntnicheWaitEmpower, map[string]interface{}{"ent_id": this.EntId}, "", "create_time desc", 0, 0)
|
|
|
|
|
|
+ nowTime := time.Now().Format("2006-01-02 15:04:05")
|
|
|
|
+ data := JyMysql.SelectBySql(`select * from `+EntnicheWaitEmpower+` where ent_id = ? and end_time >= ? order by create_time desc`, this.EntId, nowTime)
|
|
arr := []*entmanageapplication.BuyProductList{}
|
|
arr := []*entmanageapplication.BuyProductList{}
|
|
if data != nil && len(*data) > 0 </span><span class="cov8" title="1">{
|
|
if data != nil && len(*data) > 0 </span><span class="cov8" title="1">{
|
|
for _, v := range *data </span><span class="cov8" title="1">{
|
|
for _, v := range *data </span><span class="cov8" title="1">{
|
|
- obj := &entmanageapplication.BuyProductList{
|
|
|
|
|
|
+ product_type := common.ObjToString(v["product_type"])
|
|
|
|
+ if product_type == "VIP订阅" </span><span class="cov8" title="1">{
|
|
|
|
+ product_type = "超级订阅"
|
|
|
|
+ }</span>
|
|
|
|
+ <span class="cov8" title="1">obj := &entmanageapplication.BuyProductList{
|
|
WaitEmpowerId: common.Int64All(v["id"]),
|
|
WaitEmpowerId: common.Int64All(v["id"]),
|
|
- ProductType: common.ObjToString(v["product_type"]),
|
|
|
|
|
|
+ ProductType: product_type,
|
|
UseCount: common.Int64All(v["use_count"]),
|
|
UseCount: common.Int64All(v["use_count"]),
|
|
EmpowerCount: common.Int64All(v["empower_count"]),
|
|
EmpowerCount: common.Int64All(v["empower_count"]),
|
|
ProvinceCount: common.Int64All(v["province_count"]),
|
|
ProvinceCount: common.Int64All(v["province_count"]),
|
|
EndTime: common.ObjToString(v["end_time"]),
|
|
EndTime: common.ObjToString(v["end_time"]),
|
|
}
|
|
}
|
|
- arr = append(arr, obj)
|
|
|
|
- }</span>
|
|
|
|
|
|
+ arr = append(arr, obj)</span>
|
|
|
|
+ }
|
|
}
|
|
}
|
|
<span class="cov8" title="1">return &entmanageapplication.BuyProductListResp{
|
|
<span class="cov8" title="1">return &entmanageapplication.BuyProductListResp{
|
|
ErrorCode: 0,
|
|
ErrorCode: 0,
|
|
@@ -221,24 +247,28 @@ func BuyProductList(this *entmanageapplication.BuyProductListReq) *entmanageappl
|
|
}</span>
|
|
}</span>
|
|
}
|
|
}
|
|
|
|
|
|
-func addPower(waitEmpowerId int64, entUserId int) <span class="cov8" title="1">{
|
|
|
|
|
|
+func addPower(waitEmpowerId int64, entUserId int, entId int64) <span class="cov8" title="1">{
|
|
data := JyMysql.FindOne(EntnicheOrder, map[string]interface{}{"wait_empower_id": waitEmpowerId}, "", "")
|
|
data := JyMysql.FindOne(EntnicheOrder, map[string]interface{}{"wait_empower_id": waitEmpowerId}, "", "")
|
|
if data != nil && len(*data) > 0 </span><span class="cov8" title="1">{
|
|
if data != nil && len(*data) > 0 </span><span class="cov8" title="1">{
|
|
orderId := common.Int64All((*data)["order_id"])
|
|
orderId := common.Int64All((*data)["order_id"])
|
|
orderData := JyMysql.FindOne(Order, map[string]interface{}{"id": orderId}, "", "")
|
|
orderData := JyMysql.FindOne(Order, map[string]interface{}{"id": orderId}, "", "")
|
|
if orderData != nil && len(*orderData) > 0 </span><span class="cov8" title="1">{
|
|
if orderData != nil && len(*orderData) > 0 </span><span class="cov8" title="1">{
|
|
productType := common.ObjToString((*orderData)["product_type"])
|
|
productType := common.ObjToString((*orderData)["product_type"])
|
|
- userId := getUserId(entUserId)
|
|
|
|
- if productType == "VIP订阅" || productType == "超级订阅" </span><span class="cov0" title="0">{
|
|
|
|
- openPowerVip(*orderData, userId)
|
|
|
|
- }</span> else<span class="cov8" title="1"> if productType == "大会员" </span><span class="cov8" title="1">{
|
|
|
|
- openPowerBig(*orderData, userId)
|
|
|
|
|
|
+
|
|
|
|
+ posititonId := getPositionId(entUserId)
|
|
|
|
+
|
|
|
|
+ if productType == "VIP订阅" </span><span class="cov8" title="1">{
|
|
|
|
+ log.Println("开通超级订阅", posititonId)
|
|
|
|
+ setRule(1, int64(entUserId), entId, *orderData, posititonId)
|
|
|
|
+ }</span> else<span class="cov0" title="0"> if productType == "大会员" </span><span class="cov0" title="0">{
|
|
|
|
+ log.Println("开通大会员", posititonId)
|
|
|
|
+ setRule(2, int64(entUserId), entId, *orderData, posititonId)
|
|
}</span>
|
|
}</span>
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-func openPowerBig(orderData map[string]interface{}, userId string) bool <span class="cov8" title="1">{
|
|
|
|
|
|
+func openPowerBig(orderData map[string]interface{}, userId string) bool <span class="cov0" title="0">{
|
|
filterMap := common.ObjToMap(orderData["filter"])
|
|
filterMap := common.ObjToMap(orderData["filter"])
|
|
startTime := common.ObjToString(orderData["vip_starttime"])
|
|
startTime := common.ObjToString(orderData["vip_starttime"])
|
|
endTime := common.ObjToString(orderData["vip_endtime"])
|
|
endTime := common.ObjToString(orderData["vip_endtime"])
|
|
@@ -247,15 +277,15 @@ func openPowerBig(orderData map[string]interface{}, userId string) bool <span cl
|
|
enddate, _ := time.ParseInLocation(tmp, endTime, time.Local)
|
|
enddate, _ := time.ParseInLocation(tmp, endTime, time.Local)
|
|
level := common.IntAll((*filterMap)["level"])
|
|
level := common.IntAll((*filterMap)["level"])
|
|
comboId := common.IntAll((*filterMap)["comboId"])
|
|
comboId := common.IntAll((*filterMap)["comboId"])
|
|
- payCycle := common.IntAll((*filterMap)["payCycle"])
|
|
|
|
|
|
+ payCycle := common.IntAll((*filterMap)["cycle"])
|
|
serversId := common.ObjToString((*filterMap)["serversId"])
|
|
serversId := common.ObjToString((*filterMap)["serversId"])
|
|
serverMap := GetServerPid()
|
|
serverMap := GetServerPid()
|
|
dataType := 1
|
|
dataType := 1
|
|
if startdate.Unix() > time.Now().Unix() </span><span class="cov0" title="0">{
|
|
if startdate.Unix() > time.Now().Unix() </span><span class="cov0" title="0">{
|
|
dataType = 2
|
|
dataType = 2
|
|
}</span>
|
|
}</span>
|
|
- <span class="cov8" title="1">sets := map[string]interface{}{
|
|
|
|
- "i_member_status": level,
|
|
|
|
|
|
+ <span class="cov0" title="0">sets := map[string]interface{}{
|
|
|
|
+ "i_member_status": common.If(dataType == 1, level, -level),
|
|
"i_member_starttime": startdate.Unix(),
|
|
"i_member_starttime": startdate.Unix(),
|
|
"i_member_endtime": enddate.Unix(),
|
|
"i_member_endtime": enddate.Unix(),
|
|
"i_mainaccount": 1,
|
|
"i_mainaccount": 1,
|
|
@@ -268,47 +298,47 @@ func openPowerBig(orderData map[string]interface{}, userId string) bool <span cl
|
|
if !ok </span><span class="cov0" title="0">{
|
|
if !ok </span><span class="cov0" title="0">{
|
|
log.Println("大会员创建订单user表大会员状态更新失败")
|
|
log.Println("大会员创建订单user表大会员状态更新失败")
|
|
}</span>
|
|
}</span>
|
|
- <span class="cov8" title="1">if comboId != 0 </span><span class="cov8" title="1">{
|
|
|
|
|
|
+ <span class="cov0" title="0">if comboId != 0 </span><span class="cov0" title="0">{
|
|
datas := JyMysql.FindOne("bigmember_combo", map[string]interface{}{"id": comboId}, "", "")
|
|
datas := JyMysql.FindOne("bigmember_combo", map[string]interface{}{"id": comboId}, "", "")
|
|
if datas == nil || len(*datas) == 0 </span><span class="cov0" title="0">{
|
|
if datas == nil || len(*datas) == 0 </span><span class="cov0" title="0">{
|
|
log.Println("未找到此套餐")
|
|
log.Println("未找到此套餐")
|
|
return false
|
|
return false
|
|
}</span>
|
|
}</span>
|
|
- <span class="cov8" title="1">s_servers := common.ObjToString((*datas)["s_servers"])
|
|
|
|
- for _, s := range strings.Split(s_servers, ",") </span><span class="cov8" title="1">{
|
|
|
|
|
|
+ <span class="cov0" title="0">s_servers := common.ObjToString((*datas)["s_servers"])
|
|
|
|
+ for _, s := range strings.Split(s_servers, ",") </span><span class="cov0" title="0">{
|
|
serverId, _ := strconv.Atoi(s)
|
|
serverId, _ := strconv.Atoi(s)
|
|
mainId := serverId
|
|
mainId := serverId
|
|
if serverMap[serverId] != 0 </span><span class="cov0" title="0">{
|
|
if serverMap[serverId] != 0 </span><span class="cov0" title="0">{
|
|
serverId = serverMap[serverId]
|
|
serverId = serverMap[serverId]
|
|
}</span>
|
|
}</span>
|
|
- <span class="cov8" title="1">serverData := JyMysql.FindOne("bigmember_service", map[string]interface{}{"id": mainId}, "", "")
|
|
|
|
|
|
+ <span class="cov0" title="0">serverData := JyMysql.FindOne("bigmember_service", map[string]interface{}{"id": mainId}, "", "")
|
|
frequency := 0
|
|
frequency := 0
|
|
- if serverData != nil && len(*serverData) > 0 </span><span class="cov8" title="1">{
|
|
|
|
- if serverId == 11 || serverId == 15 </span><span class="cov8" title="1">{
|
|
|
|
- if serverId == 15 </span><span class="cov8" title="1">{
|
|
|
|
|
|
+ if serverData != nil && len(*serverData) > 0 </span><span class="cov0" title="0">{
|
|
|
|
+ if serverId == 11 || serverId == 15 </span><span class="cov0" title="0">{
|
|
|
|
+ if serverId == 15 </span><span class="cov0" title="0">{
|
|
if payCycle >= 12 </span><span class="cov0" title="0">{
|
|
if payCycle >= 12 </span><span class="cov0" title="0">{
|
|
frequency = (payCycle / 12 * common.IntAll((*serverData)["s_count_year"])) + (payCycle % 12 * common.IntAll((*serverData)["s_count_month"]))
|
|
frequency = (payCycle / 12 * common.IntAll((*serverData)["s_count_year"])) + (payCycle % 12 * common.IntAll((*serverData)["s_count_month"]))
|
|
- }</span> else<span class="cov8" title="1"> {
|
|
|
|
|
|
+ }</span> else<span class="cov0" title="0"> {
|
|
frequency = payCycle * common.IntAll((*serverData)["s_count_month"])
|
|
frequency = payCycle * common.IntAll((*serverData)["s_count_month"])
|
|
}</span>
|
|
}</span>
|
|
} else<span class="cov0" title="0"> {
|
|
} else<span class="cov0" title="0"> {
|
|
frequency = payCycle * common.IntAll((*serverData)["s_count_month"])
|
|
frequency = payCycle * common.IntAll((*serverData)["s_count_month"])
|
|
}</span>
|
|
}</span>
|
|
- } else<span class="cov8" title="1"> {
|
|
|
|
|
|
+ } else<span class="cov0" title="0"> {
|
|
frequency = common.IntAll((*serverData)["s_count_month"])
|
|
frequency = common.IntAll((*serverData)["s_count_month"])
|
|
}</span>
|
|
}</span>
|
|
}
|
|
}
|
|
- <span class="cov8" title="1">sqls := "select * from bigmember_service_user where s_serviceid = ? and s_userid = ? and i_status = -1"
|
|
|
|
|
|
+ <span class="cov0" title="0">sqls := "select * from bigmember_service_user where s_serviceid = ? and s_userid = ? and i_status = -1"
|
|
serverDatas := JyMysql.SelectBySql(sqls, serverId, userId)
|
|
serverDatas := JyMysql.SelectBySql(sqls, serverId, userId)
|
|
- if serverDatas != nil && len(*serverDatas) > 0 </span><span class="cov8" title="1">{
|
|
|
|
|
|
+ if serverDatas != nil && len(*serverDatas) > 0 </span><span class="cov0" title="0">{
|
|
i_status := common.If(dataType == 1, 0, 1)
|
|
i_status := common.If(dataType == 1, 0, 1)
|
|
- sql := ""
|
|
|
|
- if serverId == 17 || serverId == 18 </span><span class="cov0" title="0">{
|
|
|
|
- sql = "update bigmember_service_user set i_frequency = ?,l_updatetime = ?,l_starttime = ?,l_endtime = ?,i_status = ? where s_serviceid = ? and s_userid = ?"
|
|
|
|
- }</span> else<span class="cov8" title="1"> {
|
|
|
|
- sql = "update bigmember_service_user set i_frequency = i_frequency + ?,l_updatetime = ?,l_starttime = ?,l_endtime = ?,i_status = ? where s_serviceid = ? and s_userid = ?"
|
|
|
|
- }</span>
|
|
|
|
- <span class="cov8" title="1">status1 := JyMysql.UpdateOrDeleteBySql(sql, fmt.Sprint(frequency), time.Now().Format(tmp), startdate.Format(tmp), enddate.Format(tmp), fmt.Sprint(i_status), serverId, userId)
|
|
|
|
|
|
+ // sql := ""
|
|
|
|
+ // if serverId == 17 || serverId == 18 {
|
|
|
|
+ sql := "update bigmember_service_user set i_frequency = ?,l_updatetime = ?,l_starttime = ?,l_endtime = ?,i_status = ? where s_serviceid = ? and s_userid = ?"
|
|
|
|
+ // } else {
|
|
|
|
+ // sql = "update bigmember_service_user set i_frequency = ?,l_updatetime = ?,l_starttime = ?,l_endtime = ?,i_status = ? where s_serviceid = ? and s_userid = ?"
|
|
|
|
+ // }
|
|
|
|
+ status1 := JyMysql.UpdateOrDeleteBySql(sql, fmt.Sprint(frequency), time.Now().Format(tmp), startdate.Format(tmp), enddate.Format(tmp), fmt.Sprint(i_status), serverId, userId)
|
|
if status1 < 0 </span><span class="cov0" title="0">{
|
|
if status1 < 0 </span><span class="cov0" title="0">{
|
|
log.Println("新建服务-更新服务表出错", userId)
|
|
log.Println("新建服务-更新服务表出错", userId)
|
|
return false
|
|
return false
|
|
@@ -362,7 +392,7 @@ func openPowerBig(orderData map[string]interface{}, userId string) bool <span cl
|
|
serverDatas := JyMysql.SelectBySql(sqls, serverId, userId)
|
|
serverDatas := JyMysql.SelectBySql(sqls, serverId, userId)
|
|
if serverDatas != nil && len(*serverDatas) > 0 </span><span class="cov0" title="0">{
|
|
if serverDatas != nil && len(*serverDatas) > 0 </span><span class="cov0" title="0">{
|
|
i_status := common.If(dataType == 1, 0, 1)
|
|
i_status := common.If(dataType == 1, 0, 1)
|
|
- sql := "update bigmember_service_user set i_frequency = i_frequency + ?,l_updatetime = ?,l_starttime = ?,l_endtime = ?,i_status = ? where s_serviceid = ? and s_userid = ?"
|
|
|
|
|
|
+ sql := "update bigmember_service_user set i_frequency = ?,l_updatetime = ?,l_starttime = ?,l_endtime = ?,i_status = ? where s_serviceid = ? and s_userid = ?"
|
|
status1 := JyMysql.UpdateOrDeleteBySql(sql, fmt.Sprint(frequency), time.Now().Format(tmp), startdate.Format(tmp), enddate.Format(tmp), fmt.Sprint(i_status), serverId, userId)
|
|
status1 := JyMysql.UpdateOrDeleteBySql(sql, fmt.Sprint(frequency), time.Now().Format(tmp), startdate.Format(tmp), enddate.Format(tmp), fmt.Sprint(i_status), serverId, userId)
|
|
if status1 < 0 </span><span class="cov0" title="0">{
|
|
if status1 < 0 </span><span class="cov0" title="0">{
|
|
log.Println("新建服务-更新服务表出错")
|
|
log.Println("新建服务-更新服务表出错")
|
|
@@ -389,27 +419,26 @@ func openPowerBig(orderData map[string]interface{}, userId string) bool <span cl
|
|
}</span>
|
|
}</span>
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- <span class="cov0" title="0">RedisDel(userId)
|
|
|
|
- ClearBigVipUserPower(userId)</span>
|
|
|
|
}
|
|
}
|
|
- <span class="cov8" title="1">return true</span>
|
|
|
|
|
|
+ <span class="cov0" title="0">RedisDel(userId)
|
|
|
|
+ return true</span>
|
|
}
|
|
}
|
|
|
|
|
|
-func GetServerPid() map[int]int <span class="cov8" title="1">{
|
|
|
|
|
|
+func GetServerPid() map[int]int <span class="cov0" title="0">{
|
|
pidMap := map[int]int{}
|
|
pidMap := map[int]int{}
|
|
datas := JyMysql.Find("bigmember_service", map[string]interface{}{"i_status": 0}, "id,i_pid", "", 0, 0)
|
|
datas := JyMysql.Find("bigmember_service", map[string]interface{}{"i_status": 0}, "id,i_pid", "", 0, 0)
|
|
- if datas != nil && len(*datas) > 0 </span><span class="cov8" title="1">{
|
|
|
|
- for _, v := range *datas </span><span class="cov8" title="1">{
|
|
|
|
- if v["i_pid"] != nil </span><span class="cov8" title="1">{
|
|
|
|
|
|
+ if datas != nil && len(*datas) > 0 </span><span class="cov0" title="0">{
|
|
|
|
+ for _, v := range *datas </span><span class="cov0" title="0">{
|
|
|
|
+ if v["i_pid"] != nil </span><span class="cov0" title="0">{
|
|
pidMap[common.IntAll(v["id"])] = common.IntAll(v["i_pid"])
|
|
pidMap[common.IntAll(v["id"])] = common.IntAll(v["i_pid"])
|
|
}</span>
|
|
}</span>
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- <span class="cov8" title="1">return pidMap</span>
|
|
|
|
|
|
+ <span class="cov0" title="0">return pidMap</span>
|
|
}
|
|
}
|
|
|
|
|
|
-func RedisDel(userId string) <span class="cov8" title="1">{
|
|
|
|
- redis.Del("newother", BigKey+userId)
|
|
|
|
|
|
+func RedisDel(userId string) <span class="cov0" title="0">{
|
|
|
|
+ redis.Del(NewOther, "pl_indexMessage_"+userId)
|
|
cacheKey := fmt.Sprintf(PowerCacheKey, userId)
|
|
cacheKey := fmt.Sprintf(PowerCacheKey, userId)
|
|
baseInfoCacheKey := fmt.Sprintf(IsGetUserBaseInfoRedisKey, userId)
|
|
baseInfoCacheKey := fmt.Sprintf(IsGetUserBaseInfoRedisKey, userId)
|
|
redisMenuKeyPC := fmt.Sprintf(RedisMenuKeyPC, userId)
|
|
redisMenuKeyPC := fmt.Sprintf(RedisMenuKeyPC, userId)
|
|
@@ -466,8 +495,7 @@ func StartSubVip(phone string, area map[string]interface{}, newBuyset SubvipBuyS
|
|
|
|
|
|
go func() </span><span class="cov0" title="0">{
|
|
go func() </span><span class="cov0" title="0">{
|
|
MergeKws(userId)
|
|
MergeKws(userId)
|
|
- redis.Del(NewOther, "pl_indexMessage_"+userId)
|
|
|
|
- ClearBigVipUserPower(userId)
|
|
|
|
|
|
+ RedisDel(userId)
|
|
}</span>()
|
|
}</span>()
|
|
<span class="cov0" title="0">if isOk </span><span class="cov0" title="0">{
|
|
<span class="cov0" title="0">if isOk </span><span class="cov0" title="0">{
|
|
return true
|
|
return true
|
|
@@ -493,91 +521,262 @@ func MergeKws(userId string) <span class="cov0" title="0">{
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-func ClearBigVipUserPower(userId string) <span class="cov8" title="1">{
|
|
|
|
- cacheKey := fmt.Sprintf(PowerCacheKey, userId)
|
|
|
|
- baseInfoCacheKey := fmt.Sprintf(IsGetUserBaseInfoRedisKey, userId)
|
|
|
|
- redisMenuKeyPC := fmt.Sprintf(RedisMenuKeyPC, userId)
|
|
|
|
- redisMenuKeyWX := fmt.Sprintf(RedisMenuKeyWX, userId)
|
|
|
|
- redisMenuKeyAPP := fmt.Sprintf(RedisMenuKeyAPP, userId)
|
|
|
|
- userPowerRedisKey := fmt.Sprintf(UserPowerRedisKey, time.Now().Day(), userId)
|
|
|
|
- redis.Del(NewOther, cacheKey)
|
|
|
|
- redis.Del(NewOther, baseInfoCacheKey)
|
|
|
|
- redis.Del(NewOther, redisMenuKeyPC)
|
|
|
|
- redis.Del(NewOther, redisMenuKeyWX)
|
|
|
|
- redis.Del(NewOther, redisMenuKeyAPP)
|
|
|
|
- redis.Del(NewOther, userPowerRedisKey)
|
|
|
|
-}</span>
|
|
|
|
-
|
|
|
|
func delPower(id int64) <span class="cov8" title="1">{
|
|
func delPower(id int64) <span class="cov8" title="1">{
|
|
data := JyMysql.FindOne(EntnichePower, map[string]interface{}{"id": id}, "", "")
|
|
data := JyMysql.FindOne(EntnichePower, map[string]interface{}{"id": id}, "", "")
|
|
if data != nil && len(*data) > 0 </span><span class="cov8" title="1">{
|
|
if data != nil && len(*data) > 0 </span><span class="cov8" title="1">{
|
|
waitEmpowerId := common.Int64All((*data)["wait_empower_id"])
|
|
waitEmpowerId := common.Int64All((*data)["wait_empower_id"])
|
|
- entUserId := common.IntAll((*data)["ent_user_id"])
|
|
|
|
- JyMysql.UpdateOrDeleteBySql(`update `+EntnicheWaitEmpower+` set use_count = use_count - 1 where id = ?`, waitEmpowerId)
|
|
|
|
|
|
+ // entUserId := common.IntAll((*data)["ent_user_id"])
|
|
|
|
+ JyMysql.UpdateOrDeleteBySql(`update `+EntnicheWaitEmpower+` set use_count = use_count - 1 where id = ? and use_count > 0`, waitEmpowerId)
|
|
eOData := JyMysql.FindOne(EntnicheOrder, map[string]interface{}{"wait_empower_id": waitEmpowerId}, "", "")
|
|
eOData := JyMysql.FindOne(EntnicheOrder, map[string]interface{}{"wait_empower_id": waitEmpowerId}, "", "")
|
|
if eOData != nil && len(*eOData) > 0 </span><span class="cov8" title="1">{
|
|
if eOData != nil && len(*eOData) > 0 </span><span class="cov8" title="1">{
|
|
orderId := common.Int64All((*eOData)["order_id"])
|
|
orderId := common.Int64All((*eOData)["order_id"])
|
|
orderData := JyMysql.FindOne(Order, map[string]interface{}{"id": orderId}, "", "")
|
|
orderData := JyMysql.FindOne(Order, map[string]interface{}{"id": orderId}, "", "")
|
|
if orderData != nil && len(*orderData) > 0 </span><span class="cov8" title="1">{
|
|
if orderData != nil && len(*orderData) > 0 </span><span class="cov8" title="1">{
|
|
productType := common.ObjToString((*orderData)["product_type"])
|
|
productType := common.ObjToString((*orderData)["product_type"])
|
|
- userId := getUserId(entUserId)
|
|
|
|
- if productType == "VIP订阅" || productType == "超级订阅" </span><span class="cov0" title="0">{
|
|
|
|
- Mgo.UpdateById("user", userId, map[string]interface{}{"$set": map[string]interface{}{"i_vip_status": -2}})
|
|
|
|
- ClearBigVipUserPower(userId)
|
|
|
|
- }</span> else<span class="cov8" title="1"> if productType == "大会员" </span><span class="cov8" title="1">{
|
|
|
|
- Mgo.UpdateById("user", userId, map[string]interface{}{"$set": map[string]interface{}{"i_member_status": -2}})
|
|
|
|
- RedisDel(userId)
|
|
|
|
- ClearBigVipUserPower(userId)
|
|
|
|
- JyMysql.Update(BigServiceUser, map[string]interface{}{"s_userid": userId}, map[string]interface{}{"i_status": -1})
|
|
|
|
|
|
+ //userId := getUserId(entUserId)
|
|
|
|
+ //TODO 删除
|
|
|
|
+ if productType == "VIP订阅" </span>{<span class="cov0" title="0">
|
|
|
|
+ //Mgo.UpdateById("user", userId, map[string]interface{}{"$unset": map[string]interface{}{"i_vip_status": 1, "l_vip_starttime": 1, "l_vip_endtime": 1}})
|
|
|
|
+ }</span> else<span class="cov8" title="1"> if productType == "大会员" </span>{<span class="cov8" title="1">
|
|
|
|
+ //Mgo.UpdateById("user", userId, map[string]interface{}{"$unset": map[string]interface{}{"i_member_status": 1, "i_member_starttime": 1, "i_member_endtime": 1}})
|
|
|
|
+ //JyMysql.Update(BigServiceUser, map[string]interface{}{"s_userid": userId}, map[string]interface{}{"i_status": -1})
|
|
}</span>
|
|
}</span>
|
|
|
|
+ // RedisDel(userId)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-func getUserId(entUserId int) string <span class="cov8" title="1">{
|
|
|
|
- data := JyMysql.FindOne(EntnicheUser, map[string]interface{}{"id": entUserId}, "", "")
|
|
|
|
- userId := ""
|
|
|
|
- now := time.Now()
|
|
|
|
- if data != nil && len(*data) > 0 </span><span class="cov8" title="1">{
|
|
|
|
- phone := common.ObjToString((*data)["phone"])
|
|
|
|
- userData, ok := Mgo.FindOne("user", map[string]interface{}{"s_phone": phone})
|
|
|
|
- if ok && userData != nil && len(*userData) > 0 </span><span class="cov8" title="1">{
|
|
|
|
- userId = mongodb.BsonIdToSId((*userData)["_id"])
|
|
|
|
- }</span> else<span class="cov0" title="0"> {
|
|
|
|
- userDatas, oks := Mgo.FindOne("user", map[string]interface{}{"s_m_phone": phone})
|
|
|
|
- if oks && userDatas != nil && len(*userDatas) > 0 </span><span class="cov0" title="0">{
|
|
|
|
- userId = mongodb.BsonIdToSId((*userDatas)["_id"])
|
|
|
|
- }</span> else<span class="cov0" title="0"> {
|
|
|
|
- ctx, _ := context.WithTimeout(context.Background(), 2*time.Second)
|
|
|
|
- res, _ := UserCenterRpc.UserAdd(ctx, &usercenter.UserAddReq{
|
|
|
|
- Appid: "10000",
|
|
|
|
- Phone: phone,
|
|
|
|
- })
|
|
|
|
- data := map[string]interface{}{
|
|
|
|
- "i_appid": 2,
|
|
|
|
- "s_phone": phone,
|
|
|
|
- "s_password": "",
|
|
|
|
- "l_registedate": now.Unix(),
|
|
|
|
- "i_ts_guide": 2,
|
|
|
|
- "o_jy": map[string]interface{}{
|
|
|
|
- "i_wxpush": 1,
|
|
|
|
- "i_apppush": 1,
|
|
|
|
- "i_ratemode": 2,
|
|
|
|
- "l_modifydate": now.Unix(),
|
|
|
|
- },
|
|
|
|
- "s_regsource": "qmx_admin",
|
|
|
|
- "base_user_id": res.Data.Id,
|
|
|
|
|
|
+//获取用户信息
|
|
|
|
+//return 职位id
|
|
|
|
+func getPositionId(entUserId int) int64 <span class="cov8" title="1">{
|
|
|
|
+ ctx, _ := context.WithTimeout(context.Background(), 2*time.Second)
|
|
|
|
+ res, _ := UserCenterRpc.IdentityByEntUserId(ctx, &usercenter.IdentityReq{
|
|
|
|
+ Id: int64(entUserId),
|
|
|
|
+ })
|
|
|
|
+ log.Println(res)
|
|
|
|
+ return res.PositionId
|
|
|
|
+}</span>
|
|
|
|
+
|
|
|
|
+//订阅设置
|
|
|
|
+//types:1超级订阅 2大会员
|
|
|
|
+func setRule(types int64, entUserId, entId int64, orderData map[string]interface{}, posititonId int64) bool <span class="cov8" title="1">{
|
|
|
|
+ //订阅设置
|
|
|
|
+ query := map[string]interface{}{
|
|
|
|
+ "i_entid": entId,
|
|
|
|
+ "i_userid": entUserId,
|
|
|
|
+ }
|
|
|
|
+ //orderData相关权益
|
|
|
|
+ set := map[string]interface{}{}
|
|
|
|
+ setEntUser := map[string]interface{}{}
|
|
|
|
+ //超级订阅
|
|
|
|
+ if types == 1 </span><span class="cov8" title="1">{
|
|
|
|
+ set, setEntUser = vipSetMap(orderData)
|
|
|
|
+ }</span> else<span class="cov0" title="0"> if types == 2 </span><span class="cov0" title="0">{
|
|
|
|
+ set, setEntUser = memberSetMap(posititonId, orderData)
|
|
|
|
+ }</span>
|
|
|
|
+
|
|
|
|
+ <span class="cov8" title="1">ok1 := Mgo.Update("entniche_rule", query, map[string]interface{}{
|
|
|
|
+ "$set": set,
|
|
|
|
+ }, true, false)
|
|
|
|
+ ok2 := Mgo.Update("ent_user", query, map[string]interface{}{
|
|
|
|
+ "$set": setEntUser,
|
|
|
|
+ }, true, false)
|
|
|
|
+
|
|
|
|
+ go func() </span>{<span class="cov8" title="1">
|
|
|
|
+ // MergeKws(userId)
|
|
|
|
+ // RedisDel(userId)
|
|
|
|
+ }</span>()
|
|
|
|
+ <span class="cov8" title="1">return ok1 && ok2</span>
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+//
|
|
|
|
+func vipSetMap(orderData map[string]interface{}) (set map[string]interface{}, setEntUser map[string]interface{}) <span class="cov8" title="1">{
|
|
|
|
+ set, setEntUser = map[string]interface{}{}, map[string]interface{}{}
|
|
|
|
+ startTime := common.ObjToString(orderData["vip_starttime"])
|
|
|
|
+ endTime := common.ObjToString(orderData["vip_endtime"])
|
|
|
|
+ Date_Full_Layout := "2006-01-02 15:04:05"
|
|
|
|
+ startdate, _ := time.ParseInLocation(Date_Full_Layout, startTime, time.Local)
|
|
|
|
+ enddate, _ := time.ParseInLocation(Date_Full_Layout, endTime, time.Local)
|
|
|
|
+
|
|
|
|
+ dataType := 1
|
|
|
|
+ if startdate.Unix() > time.Now().Unix() </span><span class="cov0" title="0">{
|
|
|
|
+ dataType = 2
|
|
|
|
+ }</span>
|
|
|
|
+ //为用户开通超级订阅权限
|
|
|
|
+ //是否开通超级订阅 -1 试用到期 -2 正式到期 1 试用 2 开通
|
|
|
|
+ <span class="cov8" title="1">isTrial := false
|
|
|
|
+ if dataType == 2 </span><span class="cov0" title="0">{
|
|
|
|
+ isTrial = true
|
|
|
|
+ }</span>
|
|
|
|
+
|
|
|
|
+ <span class="cov8" title="1">setEntUser["l_createtime"] = time.Now().Unix()
|
|
|
|
+ setEntUser["l_vip_starttime"] = startdate.Unix()
|
|
|
|
+ setEntUser["l_vip_endtime"] = enddate.Unix()
|
|
|
|
+ setEntUser["i_vip_status"] = common.If(isTrial, -2, 2) //1试用 2正式 -2 试用到期
|
|
|
|
+ vms := VipSimpleMsg{}
|
|
|
|
+ json.Unmarshal([]byte(common.ObjToString(orderData["filter"])), &vms)
|
|
|
|
+
|
|
|
|
+ set = map[string]interface{}{
|
|
|
|
+ "o_entniche": map[string]interface{}{
|
|
|
|
+ "i_trial": -1, //已激活试用
|
|
|
|
+ "o_area": *vms.Area, //设置地区
|
|
|
|
+ "o_buyset": *vms.NewBuyset, //购买内容 城市、省份、行业数量
|
|
|
|
+ "a_buyerclass": []interface{}{}, //设置行业
|
|
|
|
+ },
|
|
|
|
+ "i_vip_expire_tip": 0, //消息提示初始化
|
|
|
|
+ "i_type": 1,
|
|
|
|
+ }
|
|
|
|
+ return</span>
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+func memberSetMap(userId int64, orderData map[string]interface{}) (set map[string]interface{}, setEntUser map[string]interface{}) <span class="cov0" title="0">{
|
|
|
|
+ set, setEntUser = map[string]interface{}{}, map[string]interface{}{}
|
|
|
|
+ filterMap := common.ObjToMap(orderData["filter"])
|
|
|
|
+ level := common.IntAll((*filterMap)["level"])
|
|
|
|
+ comboId := common.IntAll((*filterMap)["comboId"])
|
|
|
|
+ payCycle := common.IntAll((*filterMap)["cycle"])
|
|
|
|
+ serversId := common.ObjToString((*filterMap)["serversId"])
|
|
|
|
+ startTime := common.ObjToString(orderData["vip_starttime"])
|
|
|
|
+ endTime := common.ObjToString(orderData["vip_endtime"])
|
|
|
|
+ tmp := "2006-01-02 15:04:05"
|
|
|
|
+ startdate, _ := time.ParseInLocation(tmp, startTime, time.Local)
|
|
|
|
+ enddate, _ := time.ParseInLocation(tmp, endTime, time.Local)
|
|
|
|
+ serverMap := GetServerPid()
|
|
|
|
+ dataType := 1
|
|
|
|
+ if startdate.Unix() > time.Now().Unix() </span><span class="cov0" title="0">{
|
|
|
|
+ dataType = 2
|
|
|
|
+ }</span>
|
|
|
|
+ <span class="cov0" title="0">set = map[string]interface{}{
|
|
|
|
+ "o_member_jy": map[string]interface{}{
|
|
|
|
+ "i_wxpush": 1,
|
|
|
|
+ },
|
|
|
|
+ }
|
|
|
|
+ setEntUser = map[string]interface{}{
|
|
|
|
+ "i_member_status": common.If(dataType == 1, level, -level),
|
|
|
|
+ "i_member_starttime": startdate.Unix(),
|
|
|
|
+ "i_member_endtime": enddate.Unix(),
|
|
|
|
+ "i_mainaccount": 1,
|
|
|
|
+ "l_createtime": time.Now().Unix(),
|
|
|
|
+ }
|
|
|
|
+ if comboId != 0 </span><span class="cov0" title="0">{
|
|
|
|
+ datas := JyMysql.FindOne("bigmember_combo", map[string]interface{}{"id": comboId}, "", "")
|
|
|
|
+ if datas == nil || len(*datas) == 0 </span><span class="cov0" title="0">{
|
|
|
|
+ log.Println("未找到此套餐")
|
|
|
|
+ return
|
|
|
|
+ }</span>
|
|
|
|
+ <span class="cov0" title="0">s_servers := common.ObjToString((*datas)["s_servers"])
|
|
|
|
+ for _, s := range strings.Split(s_servers, ",") </span><span class="cov0" title="0">{
|
|
|
|
+ serverId, _ := strconv.Atoi(s)
|
|
|
|
+ mainId := serverId
|
|
|
|
+ if serverMap[serverId] != 0 </span><span class="cov0" title="0">{
|
|
|
|
+ serverId = serverMap[serverId]
|
|
|
|
+ }</span>
|
|
|
|
+ <span class="cov0" title="0">serverData := JyMysql.FindOne("bigmember_service", map[string]interface{}{"id": mainId}, "", "")
|
|
|
|
+ frequency := 0
|
|
|
|
+ if serverData != nil && len(*serverData) > 0 </span><span class="cov0" title="0">{
|
|
|
|
+ if serverId == 11 || serverId == 15 </span><span class="cov0" title="0">{
|
|
|
|
+ if serverId == 15 </span><span class="cov0" title="0">{
|
|
|
|
+ if payCycle >= 12 </span><span class="cov0" title="0">{
|
|
|
|
+ frequency = (payCycle / 12 * common.IntAll((*serverData)["s_count_year"])) + (payCycle % 12 * common.IntAll((*serverData)["s_count_month"]))
|
|
|
|
+ }</span> else<span class="cov0" title="0"> {
|
|
|
|
+ frequency = payCycle * common.IntAll((*serverData)["s_count_month"])
|
|
|
|
+ }</span>
|
|
|
|
+ } else<span class="cov0" title="0"> {
|
|
|
|
+ frequency = payCycle * common.IntAll((*serverData)["s_count_month"])
|
|
|
|
+ }</span>
|
|
|
|
+ } else<span class="cov0" title="0"> {
|
|
|
|
+ frequency = common.IntAll((*serverData)["s_count_month"])
|
|
|
|
+ }</span>
|
|
|
|
+ }
|
|
|
|
+ <span class="cov0" title="0">sqls := "select * from bigmember_service_user where s_serviceid = ? and s_userid = ? and i_status = -1"
|
|
|
|
+ serverDatas := JyMysql.SelectBySql(sqls, serverId, userId)
|
|
|
|
+ if serverDatas != nil && len(*serverDatas) > 0 </span><span class="cov0" title="0">{
|
|
|
|
+ i_status := common.If(dataType == 1, 0, 1)
|
|
|
|
+ sql := "update bigmember_service_user set i_frequency = ?,l_updatetime = ?,l_starttime = ?,l_endtime = ?,i_status = ? where s_serviceid = ? and s_userid = ?"
|
|
|
|
+ status1 := JyMysql.UpdateOrDeleteBySql(sql, fmt.Sprint(frequency), time.Now().Format(tmp), startdate.Format(tmp), enddate.Format(tmp), fmt.Sprint(i_status), serverId, userId)
|
|
|
|
+ if status1 < 0 </span><span class="cov0" title="0">{
|
|
|
|
+ log.Println("新建服务-更新服务表出错", userId)
|
|
|
|
+ return
|
|
|
|
+ }</span>
|
|
|
|
+ } else<span class="cov0" title="0"> {
|
|
|
|
+ insert := map[string]interface{}{
|
|
|
|
+ "s_smainid": mainId,
|
|
|
|
+ "s_userid": userId,
|
|
|
|
+ "s_serviceid": serverId,
|
|
|
|
+ "i_frequency": frequency,
|
|
|
|
+ "l_starttime": startdate.Format(tmp),
|
|
|
|
+ "l_endtime": enddate.Format(tmp),
|
|
|
|
+ "i_status": common.If(dataType == 1, 0, 1),
|
|
|
|
+ "l_createtime": time.Now().Format(tmp),
|
|
|
|
+ "l_updatetime": time.Now().Format(tmp),
|
|
|
|
+ }
|
|
|
|
+ order_id := JyMysql.Insert(BigServiceUser, insert)
|
|
|
|
+ if order_id > 0 </span><span class="cov0" title="0">{
|
|
|
|
+ log.Println("用户服务表插入成功", userId)
|
|
|
|
+ }</span> else<span class="cov0" title="0"> {
|
|
|
|
+ log.Println("用户服务表插入失败", userId)
|
|
|
|
+ return
|
|
|
|
+ }</span>
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } else<span class="cov0" title="0"> {
|
|
|
|
+ for _, s := range strings.Split(serversId, ",") </span><span class="cov0" title="0">{
|
|
|
|
+ serverId, _ := strconv.Atoi(s)
|
|
|
|
+ mainId := serverId
|
|
|
|
+ if serverMap[serverId] != 0 </span><span class="cov0" title="0">{
|
|
|
|
+ serverId = serverMap[serverId]
|
|
|
|
+ }</span>
|
|
|
|
+ <span class="cov0" title="0">serverData := JyMysql.FindOne("bigmember_service", map[string]interface{}{"id": mainId}, "", "")
|
|
|
|
+ frequency := 0
|
|
|
|
+ if serverData != nil && len(*serverData) > 0 </span><span class="cov0" title="0">{
|
|
|
|
+ if serverId == 11 || serverId == 15 </span><span class="cov0" title="0">{
|
|
|
|
+ if serverId == 15 </span><span class="cov0" title="0">{
|
|
|
|
+ if payCycle >= 12 </span><span class="cov0" title="0">{
|
|
|
|
+ frequency = (payCycle / 12 * common.IntAll((*serverData)["s_count_year"])) + (payCycle % 12 * common.IntAll((*serverData)["s_count_month"]))
|
|
|
|
+ }</span> else<span class="cov0" title="0"> {
|
|
|
|
+ frequency = payCycle * common.IntAll((*serverData)["s_count_month"])
|
|
|
|
+ }</span>
|
|
|
|
+ } else<span class="cov0" title="0"> {
|
|
|
|
+ frequency = payCycle * common.IntAll((*serverData)["s_count_month"])
|
|
|
|
+ }</span>
|
|
|
|
+ } else<span class="cov0" title="0"> {
|
|
|
|
+ frequency = common.IntAll((*serverData)["s_count_month"])
|
|
|
|
+ }</span>
|
|
|
|
+ }
|
|
|
|
+ <span class="cov0" title="0">sqls := "select * from bigmember_service_user where s_serviceid = ? and s_userid = ? and i_status = -1"
|
|
|
|
+ serverDatas := JyMysql.SelectBySql(sqls, serverId, userId)
|
|
|
|
+ if serverDatas != nil && len(*serverDatas) > 0 </span><span class="cov0" title="0">{
|
|
|
|
+ i_status := common.If(dataType == 1, 0, 1)
|
|
|
|
+ sql := "update bigmember_service_user set i_frequency = ?,l_updatetime = ?,l_starttime = ?,l_endtime = ?,i_status = ? where s_serviceid = ? and s_userid = ?"
|
|
|
|
+ status1 := JyMysql.UpdateOrDeleteBySql(sql, fmt.Sprint(frequency), time.Now().Format(tmp), startdate.Format(tmp), enddate.Format(tmp), fmt.Sprint(i_status), serverId, userId)
|
|
|
|
+ if status1 < 0 </span><span class="cov0" title="0">{
|
|
|
|
+ log.Println("新建服务-更新服务表出错")
|
|
|
|
+ return
|
|
|
|
+ }</span>
|
|
|
|
+ } else<span class="cov0" title="0"> {
|
|
|
|
+ insert := map[string]interface{}{
|
|
|
|
+ "s_userid": userId,
|
|
|
|
+ "s_smainid": mainId,
|
|
|
|
+ "s_serviceid": serverId,
|
|
|
|
+ "i_frequency": frequency,
|
|
|
|
+ "l_starttime": startdate.Format(tmp),
|
|
|
|
+ "l_endtime": enddate.Format(tmp),
|
|
|
|
+ "i_status": common.If(dataType == 1, 0, 1),
|
|
|
|
+ "l_createtime": time.Now().Format(tmp),
|
|
|
|
+ "l_updatetime": time.Now().Format(tmp),
|
|
}
|
|
}
|
|
- _id := Mgo.Save("user", data)
|
|
|
|
- log.Println("新增用户", _id)
|
|
|
|
- if _id != "" </span><span class="cov0" title="0">{
|
|
|
|
- userId = _id
|
|
|
|
|
|
+ order_id := JyMysql.Insert(BigServiceUser, insert)
|
|
|
|
+ if order_id > 0 </span><span class="cov0" title="0">{
|
|
|
|
+ log.Println("用户服务表插入成功", userId)
|
|
|
|
+ }</span> else<span class="cov0" title="0"> {
|
|
|
|
+ log.Println("用户服务表插入失败")
|
|
|
|
+ return
|
|
}</span>
|
|
}</span>
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- <span class="cov8" title="1">return userId</span>
|
|
|
|
|
|
+ <span class="cov0" title="0">return</span>
|
|
}
|
|
}
|
|
</pre>
|
|
</pre>
|
|
|
|
|