|
@@ -12,43 +12,52 @@ import (
|
|
)
|
|
)
|
|
|
|
|
|
func DrawClue(this *biservice.DrawClueReq, countLimit int) *biservice.AddProjectResp {
|
|
func DrawClue(this *biservice.DrawClueReq, countLimit int) *biservice.AddProjectResp {
|
|
- count1 := JyBiTidb.Count("dwd_f_crm_open_sea", map[string]interface{}{"level": 1})
|
|
|
|
- count2 := JyBiTidb.Count("dwd_f_crm_open_sea", map[string]interface{}{"level": 2})
|
|
|
|
- // count3 := JyBiTidb.Count("dwd_f_crm_open_sea", map[string]interface{}{"level": 3})
|
|
|
|
- counts1, counts2, counts3 := int64(0), int64(0), int64(0)
|
|
|
|
- counts1 = int64(math.Ceil(float64(this.Count) / float64(10) * 2))
|
|
|
|
- if this.Count-counts1 == 0 {
|
|
|
|
- counts2 = 0
|
|
|
|
- counts3 = 0
|
|
|
|
- } else {
|
|
|
|
- counts2 = int64(math.Ceil(float64(this.Count) / float64(10) * 4))
|
|
|
|
- if this.Count-counts1-counts2 == 0 {
|
|
|
|
- counts3 = 0
|
|
|
|
- } else {
|
|
|
|
- counts3 = this.Count - counts1 - counts2
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- if counts1 > count1 {
|
|
|
|
- counts2 += counts1 - count1
|
|
|
|
- counts1 = count1
|
|
|
|
- }
|
|
|
|
- if counts2 > count2 {
|
|
|
|
- counts3 += counts2 - count2
|
|
|
|
- counts2 = count2
|
|
|
|
- }
|
|
|
|
- log.Println(count1, count2)
|
|
|
|
- log.Println(counts1, counts2, counts3)
|
|
|
|
- count := DrawClues(this.PositionId, counts1, counts2, counts3, int64(countLimit))
|
|
|
|
|
|
+ count, status := DrawClueSync(this, countLimit)
|
|
log.Println("领取数量 ", count)
|
|
log.Println("领取数量 ", count)
|
|
return &biservice.AddProjectResp{
|
|
return &biservice.AddProjectResp{
|
|
ErrorCode: 0,
|
|
ErrorCode: 0,
|
|
Data: &biservice.AddProject{
|
|
Data: &biservice.AddProject{
|
|
- Status: 1,
|
|
|
|
|
|
+ Status: int64(status),
|
|
Count: int64(count),
|
|
Count: int64(count),
|
|
},
|
|
},
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+func DrawClueSync(this *biservice.DrawClueReq, countLimit int) (int, int) {
|
|
|
|
+ if DataLock.TryLock() {
|
|
|
|
+ defer DataLock.Unlock()
|
|
|
|
+ count1 := JyBiTidb.Count("dwd_f_crm_open_sea", map[string]interface{}{"level": 1})
|
|
|
|
+ count2 := JyBiTidb.Count("dwd_f_crm_open_sea", map[string]interface{}{"level": 2})
|
|
|
|
+ // count3 := JyBiTidb.Count("dwd_f_crm_open_sea", map[string]interface{}{"level": 3})
|
|
|
|
+ counts1, counts2, counts3 := int64(0), int64(0), int64(0)
|
|
|
|
+ counts1 = int64(math.Ceil(float64(this.Count) / float64(10) * 2))
|
|
|
|
+ if this.Count-counts1 == 0 {
|
|
|
|
+ counts2 = 0
|
|
|
|
+ counts3 = 0
|
|
|
|
+ } else {
|
|
|
|
+ counts2 = int64(math.Ceil(float64(this.Count) / float64(10) * 4))
|
|
|
|
+ if this.Count-counts1-counts2 == 0 {
|
|
|
|
+ counts3 = 0
|
|
|
|
+ } else {
|
|
|
|
+ counts3 = this.Count - counts1 - counts2
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if counts1 > count1 {
|
|
|
|
+ counts2 += counts1 - count1
|
|
|
|
+ counts1 = count1
|
|
|
|
+ }
|
|
|
|
+ if counts2 > count2 {
|
|
|
|
+ counts3 += counts2 - count2
|
|
|
|
+ counts2 = count2
|
|
|
|
+ }
|
|
|
|
+ log.Println(count1, count2)
|
|
|
|
+ log.Println(counts1, counts2, counts3)
|
|
|
|
+ return DrawClues(this.PositionId, counts1, counts2, counts3, int64(countLimit)), 1
|
|
|
|
+ } else {
|
|
|
|
+ return 0, 2
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
func DrawClues(positionId, count1, count2, count3, countLimit int64) int {
|
|
func DrawClues(positionId, count1, count2, count3, countLimit int64) int {
|
|
data1, data2, data3, drawCount := &[]map[string]interface{}{}, &[]map[string]interface{}{}, &[]map[string]interface{}{}, 0
|
|
data1, data2, data3, drawCount := &[]map[string]interface{}{}, &[]map[string]interface{}{}, &[]map[string]interface{}{}, 0
|
|
if count1 > 0 {
|
|
if count1 > 0 {
|