Commit 72aa05d3355139bf4bec8b7154c0f6c6bf38c21d

Authored by 陆恒
1 parent 71aeb32b
Exists in master

脑洞过关红包需求

src/HttpServer/jsonconf/GuanRedBag.json 0 → 100644
... ... @@ -0,0 +1,902 @@
  1 +[
  2 + {
  3 + "type": 1,
  4 + "id": 1,
  5 + "cash": 12200
  6 + },
  7 + {
  8 + "type": 1,
  9 + "id": 2,
  10 + "cash": 10200
  11 + },
  12 + {
  13 + "type": 1,
  14 + "id": 3,
  15 + "cash": 10600
  16 + },
  17 + {
  18 + "type": 1,
  19 + "id": 4,
  20 + "cash": 10900
  21 + },
  22 + {
  23 + "type": 1,
  24 + "id": 5,
  25 + "cash": 10100
  26 + },
  27 + {
  28 + "type": 1,
  29 + "id": 6,
  30 + "cash": 12000
  31 + },
  32 + {
  33 + "type": 1,
  34 + "id": 7,
  35 + "cash": 11300
  36 + },
  37 + {
  38 + "type": 1,
  39 + "id": 8,
  40 + "cash": 11700
  41 + },
  42 + {
  43 + "type": 1,
  44 + "id": 9,
  45 + "cash": 10700
  46 + },
  47 + {
  48 + "type": 1,
  49 + "id": 10,
  50 + "cash": 11500
  51 + },
  52 + {
  53 + "type": 1,
  54 + "id": 11,
  55 + "cash": 11400
  56 + },
  57 + {
  58 + "type": 1,
  59 + "id": 12,
  60 + "cash": 10700
  61 + },
  62 + {
  63 + "type": 1,
  64 + "id": 13,
  65 + "cash": 10000
  66 + },
  67 + {
  68 + "type": 1,
  69 + "id": 14,
  70 + "cash": 10100
  71 + },
  72 + {
  73 + "type": 1,
  74 + "id": 15,
  75 + "cash": 10900
  76 + },
  77 + {
  78 + "type": 1,
  79 + "id": 16,
  80 + "cash": 9900
  81 + },
  82 + {
  83 + "type": 1,
  84 + "id": 17,
  85 + "cash": 10100
  86 + },
  87 + {
  88 + "type": 1,
  89 + "id": 18,
  90 + "cash": 10200
  91 + },
  92 + {
  93 + "type": 1,
  94 + "id": 19,
  95 + "cash": 11000
  96 + },
  97 + {
  98 + "type": 1,
  99 + "id": 20,
  100 + "cash": 10300
  101 + },
  102 + {
  103 + "type": 1,
  104 + "id": 21,
  105 + "cash": 7600
  106 + },
  107 + {
  108 + "type": 1,
  109 + "id": 22,
  110 + "cash": 6600
  111 + },
  112 + {
  113 + "type": 1,
  114 + "id": 23,
  115 + "cash": 6400
  116 + },
  117 + {
  118 + "type": 1,
  119 + "id": 24,
  120 + "cash": 5300
  121 + },
  122 + {
  123 + "type": 1,
  124 + "id": 25,
  125 + "cash": 5200
  126 + },
  127 + {
  128 + "type": 1,
  129 + "id": 26,
  130 + "cash": 6100
  131 + },
  132 + {
  133 + "type": 1,
  134 + "id": 27,
  135 + "cash": 2500
  136 + },
  137 + {
  138 + "type": 1,
  139 + "id": 28,
  140 + "cash": 6500
  141 + },
  142 + {
  143 + "type": 1,
  144 + "id": 29,
  145 + "cash": 3000
  146 + },
  147 + {
  148 + "type": 1,
  149 + "id": 30,
  150 + "cash": 7500
  151 + },
  152 + {
  153 + "type": 1,
  154 + "id": 31,
  155 + "cash": 7200
  156 + },
  157 + {
  158 + "type": 1,
  159 + "id": 32,
  160 + "cash": 4400
  161 + },
  162 + {
  163 + "type": 1,
  164 + "id": 33,
  165 + "cash": 7300
  166 + },
  167 + {
  168 + "type": 1,
  169 + "id": 34,
  170 + "cash": 6000
  171 + },
  172 + {
  173 + "type": 1,
  174 + "id": 35,
  175 + "cash": 5700
  176 + },
  177 + {
  178 + "type": 1,
  179 + "id": 36,
  180 + "cash": 11000
  181 + },
  182 + {
  183 + "type": 1,
  184 + "id": 37,
  185 + "cash": 5600
  186 + },
  187 + {
  188 + "type": 1,
  189 + "id": 38,
  190 + "cash": 7000
  191 + },
  192 + {
  193 + "type": 1,
  194 + "id": 39,
  195 + "cash": 5200
  196 + },
  197 + {
  198 + "type": 1,
  199 + "id": 40,
  200 + "cash": 6100
  201 + },
  202 + {
  203 + "type": 1,
  204 + "id": 41,
  205 + "cash": 3000
  206 + },
  207 + {
  208 + "type": 1,
  209 + "id": 42,
  210 + "cash": 5100
  211 + },
  212 + {
  213 + "type": 1,
  214 + "id": 43,
  215 + "cash": 7600
  216 + },
  217 + {
  218 + "type": 1,
  219 + "id": 44,
  220 + "cash": 5600
  221 + },
  222 + {
  223 + "type": 1,
  224 + "id": 45,
  225 + "cash": 5600
  226 + },
  227 + {
  228 + "type": 1,
  229 + "id": 46,
  230 + "cash": 6000
  231 + },
  232 + {
  233 + "type": 1,
  234 + "id": 47,
  235 + "cash": 2500
  236 + },
  237 + {
  238 + "type": 1,
  239 + "id": 48,
  240 + "cash": 5000
  241 + },
  242 + {
  243 + "type": 1,
  244 + "id": 49,
  245 + "cash": 5100
  246 + },
  247 + {
  248 + "type": 1,
  249 + "id": 50,
  250 + "cash": 7800
  251 + },
  252 + {
  253 + "type": 1,
  254 + "id": 51,
  255 + "cash": 5400
  256 + },
  257 + {
  258 + "type": 1,
  259 + "id": 52,
  260 + "cash": 7700
  261 + },
  262 + {
  263 + "type": 1,
  264 + "id": 53,
  265 + "cash": 6700
  266 + },
  267 + {
  268 + "type": 1,
  269 + "id": 54,
  270 + "cash": 1800
  271 + },
  272 + {
  273 + "type": 1,
  274 + "id": 55,
  275 + "cash": 1700
  276 + },
  277 + {
  278 + "type": 1,
  279 + "id": 56,
  280 + "cash": 2200
  281 + },
  282 + {
  283 + "type": 1,
  284 + "id": 57,
  285 + "cash": 1800
  286 + },
  287 + {
  288 + "type": 1,
  289 + "id": 58,
  290 + "cash": 1100
  291 + },
  292 + {
  293 + "type": 1,
  294 + "id": 59,
  295 + "cash": 1800
  296 + },
  297 + {
  298 + "type": 1,
  299 + "id": 60,
  300 + "cash": 2900
  301 + },
  302 + {
  303 + "type": 1,
  304 + "id": 61,
  305 + "cash": 2100
  306 + },
  307 + {
  308 + "type": 1,
  309 + "id": 62,
  310 + "cash": 1600
  311 + },
  312 + {
  313 + "type": 1,
  314 + "id": 63,
  315 + "cash": 11000
  316 + },
  317 + {
  318 + "type": 1,
  319 + "id": 64,
  320 + "cash": 2000
  321 + },
  322 + {
  323 + "type": 1,
  324 + "id": 65,
  325 + "cash": 2600
  326 + },
  327 + {
  328 + "type": 1,
  329 + "id": 66,
  330 + "cash": 1500
  331 + },
  332 + {
  333 + "type": 1,
  334 + "id": 67,
  335 + "cash": 2100
  336 + },
  337 + {
  338 + "type": 1,
  339 + "id": 68,
  340 + "cash": 2800
  341 + },
  342 + {
  343 + "type": 1,
  344 + "id": 69,
  345 + "cash": 2300
  346 + },
  347 + {
  348 + "type": 1,
  349 + "id": 70,
  350 + "cash": 2700
  351 + },
  352 + {
  353 + "type": 1,
  354 + "id": 71,
  355 + "cash": 2700
  356 + },
  357 + {
  358 + "type": 1,
  359 + "id": 72,
  360 + "cash": 1700
  361 + },
  362 + {
  363 + "type": 1,
  364 + "id": 73,
  365 + "cash": 1700
  366 + },
  367 + {
  368 + "type": 1,
  369 + "id": 74,
  370 + "cash": 1500
  371 + },
  372 + {
  373 + "type": 1,
  374 + "id": 75,
  375 + "cash": 2200
  376 + },
  377 + {
  378 + "type": 1,
  379 + "id": 76,
  380 + "cash": 1600
  381 + },
  382 + {
  383 + "type": 1,
  384 + "id": 77,
  385 + "cash": 1000
  386 + },
  387 + {
  388 + "type": 1,
  389 + "id": 78,
  390 + "cash": 2900
  391 + },
  392 + {
  393 + "type": 1,
  394 + "id": 79,
  395 + "cash": 2000
  396 + },
  397 + {
  398 + "type": 1,
  399 + "id": 80,
  400 + "cash": 2400
  401 + },
  402 + {
  403 + "type": 1,
  404 + "id": 81,
  405 + "cash": 1300
  406 + },
  407 + {
  408 + "type": 1,
  409 + "id": 82,
  410 + "cash": 2800
  411 + },
  412 + {
  413 + "type": 1,
  414 + "id": 83,
  415 + "cash": 1600
  416 + },
  417 + {
  418 + "type": 1,
  419 + "id": 84,
  420 + "cash": 2100
  421 + },
  422 + {
  423 + "type": 1,
  424 + "id": 85,
  425 + "cash": 1100
  426 + },
  427 + {
  428 + "type": 1,
  429 + "id": 86,
  430 + "cash": 1300
  431 + },
  432 + {
  433 + "type": 1,
  434 + "id": 87,
  435 + "cash": 1300
  436 + },
  437 + {
  438 + "type": 1,
  439 + "id": 88,
  440 + "cash": 1600
  441 + },
  442 + {
  443 + "type": 1,
  444 + "id": 89,
  445 + "cash": 1800
  446 + },
  447 + {
  448 + "type": 1,
  449 + "id": 90,
  450 + "cash": 1200
  451 + },
  452 + {
  453 + "type": 1,
  454 + "id": 91,
  455 + "cash": 1700
  456 + },
  457 + {
  458 + "type": 1,
  459 + "id": 92,
  460 + "cash": 1400
  461 + },
  462 + {
  463 + "type": 1,
  464 + "id": 93,
  465 + "cash": 1100
  466 + },
  467 + {
  468 + "type": 1,
  469 + "id": 94,
  470 + "cash": 1000
  471 + },
  472 + {
  473 + "type": 1,
  474 + "id": 95,
  475 + "cash": 2100
  476 + },
  477 + {
  478 + "type": 1,
  479 + "id": 96,
  480 + "cash": 2500
  481 + },
  482 + {
  483 + "type": 1,
  484 + "id": 97,
  485 + "cash": 2700
  486 + },
  487 + {
  488 + "type": 1,
  489 + "id": 98,
  490 + "cash": 1700
  491 + },
  492 + {
  493 + "type": 1,
  494 + "id": 99,
  495 + "cash": 2400
  496 + },
  497 + {
  498 + "type": 1,
  499 + "id": 100,
  500 + "cash": 2400
  501 + },
  502 + {
  503 + "type": 1,
  504 + "id": 101,
  505 + "cash": 1000
  506 + },
  507 + {
  508 + "type": 1,
  509 + "id": 102,
  510 + "cash": 1700
  511 + },
  512 + {
  513 + "type": 1,
  514 + "id": 103,
  515 + "cash": 1100
  516 + },
  517 + {
  518 + "type": 1,
  519 + "id": 104,
  520 + "cash": 1800
  521 + },
  522 + {
  523 + "type": 1,
  524 + "id": 105,
  525 + "cash": 1400
  526 + },
  527 + {
  528 + "type": 1,
  529 + "id": 106,
  530 + "cash": 2400
  531 + },
  532 + {
  533 + "type": 1,
  534 + "id": 107,
  535 + "cash": 1700
  536 + },
  537 + {
  538 + "type": 1,
  539 + "id": 108,
  540 + "cash": 2800
  541 + },
  542 + {
  543 + "type": 1,
  544 + "id": 109,
  545 + "cash": 1800
  546 + },
  547 + {
  548 + "type": 1,
  549 + "id": 110,
  550 + "cash": 2600
  551 + },
  552 + {
  553 + "type": 1,
  554 + "id": 111,
  555 + "cash": 1400
  556 + },
  557 + {
  558 + "type": 1,
  559 + "id": 112,
  560 + "cash": 1600
  561 + },
  562 + {
  563 + "type": 1,
  564 + "id": 113,
  565 + "cash": 1400
  566 + },
  567 + {
  568 + "type": 1,
  569 + "id": 114,
  570 + "cash": 2900
  571 + },
  572 + {
  573 + "type": 1,
  574 + "id": 115,
  575 + "cash": 2400
  576 + },
  577 + {
  578 + "type": 1,
  579 + "id": 116,
  580 + "cash": 2500
  581 + },
  582 + {
  583 + "type": 1,
  584 + "id": 117,
  585 + "cash": 2700
  586 + },
  587 + {
  588 + "type": 1,
  589 + "id": 118,
  590 + "cash": 1600
  591 + },
  592 + {
  593 + "type": 1,
  594 + "id": 119,
  595 + "cash": 2800
  596 + },
  597 + {
  598 + "type": 1,
  599 + "id": 120,
  600 + "cash": 2100
  601 + },
  602 + {
  603 + "type": 1,
  604 + "id": 121,
  605 + "cash": 1000
  606 + },
  607 + {
  608 + "type": 1,
  609 + "id": 122,
  610 + "cash": 2400
  611 + },
  612 + {
  613 + "type": 1,
  614 + "id": 123,
  615 + "cash": 1200
  616 + },
  617 + {
  618 + "type": 1,
  619 + "id": 124,
  620 + "cash": 1700
  621 + },
  622 + {
  623 + "type": 1,
  624 + "id": 125,
  625 + "cash": 1000
  626 + },
  627 + {
  628 + "type": 1,
  629 + "id": 126,
  630 + "cash": 1600
  631 + },
  632 + {
  633 + "type": 1,
  634 + "id": 127,
  635 + "cash": 1600
  636 + },
  637 + {
  638 + "type": 1,
  639 + "id": 128,
  640 + "cash": 1900
  641 + },
  642 + {
  643 + "type": 1,
  644 + "id": 129,
  645 + "cash": 2000
  646 + },
  647 + {
  648 + "type": 1,
  649 + "id": 130,
  650 + "cash": 2300
  651 + },
  652 + {
  653 + "type": 1,
  654 + "id": 131,
  655 + "cash": 2100
  656 + },
  657 + {
  658 + "type": 1,
  659 + "id": 132,
  660 + "cash": 1400
  661 + },
  662 + {
  663 + "type": 1,
  664 + "id": 133,
  665 + "cash": 2300
  666 + },
  667 + {
  668 + "type": 1,
  669 + "id": 134,
  670 + "cash": 2800
  671 + },
  672 + {
  673 + "type": 1,
  674 + "id": 135,
  675 + "cash": 200
  676 + },
  677 + {
  678 + "type": 1,
  679 + "id": 136,
  680 + "cash": 2000
  681 + },
  682 + {
  683 + "type": 1,
  684 + "id": 137,
  685 + "cash": 1200
  686 + },
  687 + {
  688 + "type": 1,
  689 + "id": 138,
  690 + "cash": 1200
  691 + },
  692 + {
  693 + "type": 1,
  694 + "id": 139,
  695 + "cash": 2900
  696 + },
  697 + {
  698 + "type": 1,
  699 + "id": 140,
  700 + "cash": 2100
  701 + },
  702 + {
  703 + "type": 1,
  704 + "id": 141,
  705 + "cash": 400
  706 + },
  707 + {
  708 + "type": 1,
  709 + "id": 142,
  710 + "cash": 2700
  711 + },
  712 + {
  713 + "type": 1,
  714 + "id": 143,
  715 + "cash": 100
  716 + },
  717 + {
  718 + "type": 1,
  719 + "id": 144,
  720 + "cash": 1300
  721 + },
  722 + {
  723 + "type": 1,
  724 + "id": 145,
  725 + "cash": 1400
  726 + },
  727 + {
  728 + "type": 1,
  729 + "id": 146,
  730 + "cash": 1200
  731 + },
  732 + {
  733 + "type": 1,
  734 + "id": 147,
  735 + "cash": 1200
  736 + },
  737 + {
  738 + "type": 1,
  739 + "id": 148,
  740 + "cash": 1000
  741 + },
  742 + {
  743 + "type": 1,
  744 + "id": 149,
  745 + "cash": 200
  746 + },
  747 + {
  748 + "type": 1,
  749 + "id": 150,
  750 + "cash": 2500
  751 + },
  752 + {
  753 + "type": 1,
  754 + "id": 151,
  755 + "cash": 1400
  756 + },
  757 + {
  758 + "type": 1,
  759 + "id": 152,
  760 + "cash": 1100
  761 + },
  762 + {
  763 + "type": 1,
  764 + "id": 153,
  765 + "cash": 1200
  766 + },
  767 + {
  768 + "type": 1,
  769 + "id": 154,
  770 + "cash": 1000
  771 + },
  772 + {
  773 + "type": 1,
  774 + "id": 155,
  775 + "cash": 2800
  776 + },
  777 + {
  778 + "type": 1,
  779 + "id": 156,
  780 + "cash": 2700
  781 + },
  782 + {
  783 + "type": 1,
  784 + "id": 157,
  785 + "cash": 1600
  786 + },
  787 + {
  788 + "type": 1,
  789 + "id": 158,
  790 + "cash": 400
  791 + },
  792 + {
  793 + "type": 1,
  794 + "id": 159,
  795 + "cash": 1000
  796 + },
  797 + {
  798 + "type": 1,
  799 + "id": 160,
  800 + "cash": 1400
  801 + },
  802 + {
  803 + "type": 1,
  804 + "id": 161,
  805 + "cash": 1700
  806 + },
  807 + {
  808 + "type": 1,
  809 + "id": 162,
  810 + "cash": 2200
  811 + },
  812 + {
  813 + "type": 1,
  814 + "id": 163,
  815 + "cash": 1200
  816 + },
  817 + {
  818 + "type": 1,
  819 + "id": 164,
  820 + "cash": 1100
  821 + },
  822 + {
  823 + "type": 1,
  824 + "id": 165,
  825 + "cash": 1100
  826 + },
  827 + {
  828 + "type": 1,
  829 + "id": 166,
  830 + "cash": 2200
  831 + },
  832 + {
  833 + "type": 1,
  834 + "id": 167,
  835 + "cash": 300
  836 + },
  837 + {
  838 + "type": 1,
  839 + "id": 168,
  840 + "cash": 1200
  841 + },
  842 + {
  843 + "type": 1,
  844 + "id": 169,
  845 + "cash": 1300
  846 + },
  847 + {
  848 + "type": 1,
  849 + "id": 170,
  850 + "cash": 2600
  851 + },
  852 + {
  853 + "type": 1,
  854 + "id": 171,
  855 + "cash": 1000
  856 + },
  857 + {
  858 + "type": 1,
  859 + "id": 172,
  860 + "cash": 2200
  861 + },
  862 + {
  863 + "type": 1,
  864 + "id": 173,
  865 + "cash": 1900
  866 + },
  867 + {
  868 + "type": 1,
  869 + "id": 174,
  870 + "cash": 2400
  871 + },
  872 + {
  873 + "type": 1,
  874 + "id": 175,
  875 + "cash": 500
  876 + },
  877 + {
  878 + "type": 1,
  879 + "id": 176,
  880 + "cash": 1000
  881 + },
  882 + {
  883 + "type": 1,
  884 + "id": 177,
  885 + "cash": 2300
  886 + },
  887 + {
  888 + "type": 1,
  889 + "id": 178,
  890 + "cash": 400
  891 + },
  892 + {
  893 + "type": 1,
  894 + "id": 179,
  895 + "cash": 1600
  896 + },
  897 + {
  898 + "type": 1,
  899 + "id": 180,
  900 + "cash": 1900
  901 + }
  902 +]
0 903 \ No newline at end of file
... ...
src/HttpServer/jsonconf/JiRedbag.json 0 → 100644
... ... @@ -0,0 +1,67 @@
  1 +[
  2 + {
  3 + "type": 2,
  4 + "id": 1,
  5 + "cash": 12600
  6 + },
  7 + {
  8 + "type": 2,
  9 + "id": 2,
  10 + "cash": 11000
  11 + },
  12 + {
  13 + "type": 2,
  14 + "id": 3,
  15 + "cash": 9000
  16 + },
  17 + {
  18 + "type": 2,
  19 + "id": 4,
  20 + "cash": 8600
  21 + },
  22 + {
  23 + "type": 2,
  24 + "id": 5,
  25 + "cash": 10100
  26 + },
  27 + {
  28 + "type": 2,
  29 + "id": 6,
  30 + "cash": 9500
  31 + },
  32 + {
  33 + "type": 2,
  34 + "id": 7,
  35 + "cash": 8800
  36 + },
  37 + {
  38 + "type": 2,
  39 + "id": 8,
  40 + "cash": 6600
  41 + },
  42 + {
  43 + "type": 2,
  44 + "id": 9,
  45 + "cash": 6600
  46 + },
  47 + {
  48 + "type": 2,
  49 + "id": 10,
  50 + "cash": 6800
  51 + },
  52 + {
  53 + "type": 2,
  54 + "id": 11,
  55 + "cash": 6600
  56 + },
  57 + {
  58 + "type": 2,
  59 + "id": 12,
  60 + "cash": 8400
  61 + },
  62 + {
  63 + "type": 2,
  64 + "id": 13,
  65 + "cash": 6600
  66 + }
  67 +]
0 68 \ No newline at end of file
... ...
src/HttpServer/jsonconf/jsonconf.go
... ... @@ -32,9 +32,24 @@ type ActiveWithdrawConfigDesc struct {
32 32 Day int `json:"day"`
33 33 }
34 34  
  35 +type GuanRedBagDesc struct {
  36 + Ctype int `json:"type"`
  37 + Id int `json:"id"`
  38 + Cash int `json:"cash"`
  39 +}
  40 +
  41 +type JiRedBagDesc struct {
  42 + Ctype int `json:"type"`
  43 + Id int `json:"id"`
  44 + Cash int `json:"cash"`
  45 +}
  46 +
35 47 type GameConfig struct {
36 48 WithDrawConfig []WithDrawDesc
37 49 ActiveWithdrawConfig []ActiveWithdrawConfigDesc
  50 + GuanRedBag []GuanRedBagDesc
  51 + JiRedBag []JiRedBagDesc
  52 +
38 53 }
39 54  
40 55 func GetJsonConf() *GameConfig {
... ... @@ -42,6 +57,24 @@ func GetJsonConf() *GameConfig {
42 57 }
43 58  
44 59  
  60 +func GetJiConf(id int) *JiRedBagDesc {
  61 + for _,val := range g_jsonconf.JiRedBag {
  62 + if val.Id == id {
  63 + return &val
  64 + }
  65 + }
  66 + return nil
  67 +}
  68 +
  69 +func GetGuanConf(id int) *GuanRedBagDesc {
  70 + for _,val := range g_jsonconf.GuanRedBag {
  71 + if val.Id == id {
  72 + return &val
  73 + }
  74 + }
  75 + return nil
  76 +}
  77 +
45 78  
46 79 func file_get_contents(path string) ([]byte, error) {
47 80 f, err := os.Open(path)
... ... @@ -81,6 +114,33 @@ func LoadJsonConf() error {
81 114 return err
82 115 }
83 116  
  117 +
  118 + path = "../jsonconf/GuanRedBag.json"
  119 + content, err = file_get_contents(path)
  120 + if err != nil {
  121 + logger.Info("loadJsonConf failed1,err=%v", err)
  122 + return err
  123 + }
  124 +
  125 + err = json.Unmarshal([]byte(content), &g_jsonconf.GuanRedBag)
  126 + if err != nil {
  127 + logger.Info("loadJsonConf failed1,err=%v", err)
  128 + return err
  129 + }
  130 +
  131 + path = "../jsonconf/JiRedbag.json"
  132 + content, err = file_get_contents(path)
  133 + if err != nil {
  134 + logger.Info("loadJsonConf failed1,err=%v", err)
  135 + return err
  136 + }
  137 +
  138 + err = json.Unmarshal([]byte(content), &g_jsonconf.JiRedBag)
  139 + if err != nil {
  140 + logger.Info("loadJsonConf failed1,err=%v", err)
  141 + return err
  142 + }
  143 +
84 144 logger.Info("loadJsonConf success pconf=%v,err=%v", *g_jsonconf, err)
85 145 return nil
86 146 }
... ...
src/HttpServer/logic/constdef.go
... ... @@ -56,6 +56,7 @@ const (
56 56 const (
57 57 WATCH_ADD_DAY_LIMIT = 50 //当天获取红包次数限制
58 58 FREE_REDBAG_NUM = 3 //玩家免费红包次数
  59 + RANDNUMLIMIT = 10 //每日随机红包此树
59 60 READGOLDMULTI = 700 //阅读量到金币转化倍数
60 61 SDKOPGOLD_TYPEWE = 302 //微转发金币类型
61 62 )
... ...
src/HttpServer/logic/datadef.go
... ... @@ -9,6 +9,11 @@ type UserLoginReq struct {
9 9  
10 10 type UserLoginData struct {
11 11 Walletgold int `json:"walletgold"`
  12 + Curji int `json:"curji"`
  13 + Curlevel int `json:"curlevel"`
  14 + Guanrednum int `json:"guanrednum"`
  15 + Jirednum int `json:"jirednum"`
  16 + Randnum int `json:"randnum"`
12 17 }
13 18  
14 19 type UserLoginResp struct {
... ... @@ -92,6 +97,28 @@ type UploadlevelResp struct {
92 97 Message string `json:"message"`
93 98 }
94 99  
  100 +
  101 +
  102 +type FetchredbagReq struct {
  103 + Rtype int `json:"rtype"`
  104 + Gameid string `json:"gameid"`
  105 + Channel string `json:"channel"`
  106 +}
  107 +
  108 +type FetchredbagData struct {
  109 + Guanrednum int `json:"guanrednum"`
  110 + Jirednum int `json:"jirednum"`
  111 + Randnum int `json:"randnum"`
  112 + Getgold int `json:"getgold"`
  113 + Walletgold int `json:"walletgold"`
  114 +}
  115 +
  116 +type FetchredbagResp struct {
  117 + Code int `json:"code"`
  118 + Message string `json:"message"`
  119 + Data FetchredbagData `json:"data"`
  120 +}
  121 +
95 122 ////////////////////////////////////////////////////////////////////////////////////////
96 123  
97 124 type GetCashListResp struct {
... ... @@ -162,6 +189,10 @@ type UserData struct {
162 189 UpLvCostTime int //上一个等级升级时间
163 190 UpLvCostTimeSec int //上一个等级升级的时间点时刻
164 191 PassLevel int //当前关卡
  192 + BigLevel int //当前等级
  193 + GuanRedNum int //关卡红包领取进度
  194 + JiRedNum int //等级红包领取进度
  195 + RandNum int //随机红包剩余次数
165 196 ReadNum int //玩家微转发阅读量
166 197 GetCashCnt int //当天提现次数
167 198 WithDraw WithDrawInfo //提现记录信息
... ...
src/HttpServer/logic/function.go
... ... @@ -118,6 +118,9 @@ func HandlerSyncuserdata(w http.ResponseWriter, data string, uuid int) {
118 118 }
119 119  
120 120  
  121 +
  122 +
  123 +
121 124 func InitUserInfo(data *UserLoginReq, resp *UserLoginResp, uuid int, uniqueuid string) error {
122 125  
123 126 var initdata UserData
... ... @@ -135,7 +138,11 @@ func InitUserInfo(data *UserLoginReq, resp *UserLoginResp, uuid int, uniqueuid s
135 138 initdata.WatchAddsTime = WATCH_ADD_DAY_LIMIT
136 139 initdata.LeftFreeRB = FREE_REDBAG_NUM
137 140 initdata.UpLvCostTime = 0
138   - initdata.PassLevel = 1
  141 + initdata.PassLevel = 0
  142 + initdata.BigLevel = 1
  143 + initdata.GuanRedNum = 0
  144 + initdata.JiRedNum = 0
  145 + initdata.RandNum = RANDNUMLIMIT
139 146 initdata.UpLvCostTimeSec = int(time.Now().Unix())
140 147  
141 148 //todo 等待提现配置表
... ... @@ -177,6 +184,11 @@ func InitUserInfo(data *UserLoginReq, resp *UserLoginResp, uuid int, uniqueuid s
177 184  
178 185 //resp.Data.Leftredbagcnt = initdata.WatchAddsTime
179 186 resp.Data.Walletgold = initdata.RealGold
  187 + resp.Data.Curji = initdata.BigLevel
  188 + resp.Data.Curlevel = initdata.PassLevel
  189 + resp.Data.Guanrednum = initdata.GuanRedNum
  190 + resp.Data.Jirednum = initdata.JiRedNum
  191 + resp.Data.Randnum = initdata.RandNum
180 192  
181 193  
182 194 err := SaveUserInfo(&initdata, uniqueuid)
... ...
src/HttpServer/logic/httpserver.go
... ... @@ -43,6 +43,9 @@ func startServerHttpServe() {
43 43 http.HandleFunc("/brainhole/getcash", Getcash) //提现
44 44 http.HandleFunc("/brainhole/getcashrecord", Getcashrecord) //提现记录列表
45 45 http.HandleFunc("/brainhole/uploadlevel", Uploadlevel) //上报当前关卡
  46 + http.HandleFunc("/brainhole/uploadbiglevel", Uploadbiglevel) //上报当前等级
  47 + http.HandleFunc("/brainhole/fetchredbag", Fetchredbag) //领取红包
  48 +
46 49  
47 50  
48 51 err := http.ListenAndServe(conf.GetServerHttpAddrConf(), nil)
... ... @@ -92,6 +95,48 @@ func Getcash(w http.ResponseWriter, r *http.Request) {
92 95 HandlerGetcash(w, s, Uuid)
93 96 }
94 97  
  98 +func Fetchredbag(w http.ResponseWriter, r *http.Request) {
  99 +
  100 + Uuid := 0
  101 + if len(r.Header) > 0 {
  102 + Uuid, _ = strconv.Atoi(r.Header.Get("Uuid"))
  103 + }
  104 +
  105 + if Uuid == 0 {
  106 + SetHeader(w)
  107 + //logger.Error("Uuid is nil!")
  108 + return
  109 + }
  110 + result, _ := ioutil.ReadAll(r.Body)
  111 + r.Body.Close()
  112 +
  113 + s := string(result)
  114 + logger.Info("Fetchredbag , body:%v,uuid=%v", s, Uuid)
  115 +
  116 + HandlerFetchredbag(w, s, Uuid)
  117 +}
  118 +
  119 +func Uploadbiglevel(w http.ResponseWriter, r *http.Request) {
  120 +
  121 + Uuid := 0
  122 + if len(r.Header) > 0 {
  123 + Uuid, _ = strconv.Atoi(r.Header.Get("Uuid"))
  124 + }
  125 +
  126 + if Uuid == 0 {
  127 + SetHeader(w)
  128 + //logger.Error("Uuid is nil!")
  129 + return
  130 + }
  131 + result, _ := ioutil.ReadAll(r.Body)
  132 + r.Body.Close()
  133 +
  134 + s := string(result)
  135 + logger.Info("Uploadbiglevel , body:%v,uuid=%v", s, Uuid)
  136 +
  137 + HandlerUploadbiglevel(w, s, Uuid)
  138 +}
  139 +
95 140 func Uploadlevel(w http.ResponseWriter, r *http.Request) {
96 141  
97 142 Uuid := 0
... ...
src/HttpServer/logic/logic.go
1 1 package logic
2 2  
3 3 import (
  4 + "HttpServer/jsonconf"
4 5 "HttpServer/redishandler"
5 6 "common/logger"
6 7 "common/redis"
7 8 "encoding/json"
8 9 "fmt"
  10 + "math/rand"
9 11 "net/http"
10 12 "strconv"
11 13 "time"
... ... @@ -204,6 +206,167 @@ func HandlerGetcash(w http.ResponseWriter, data string, uuid int) {
204 206  
205 207 }
206 208  
  209 +func HandlerFetchredbag(w http.ResponseWriter, data string, uuid int) {
  210 + SetHeader(w)
  211 + var resp FetchredbagResp
  212 + resp.Code = 0
  213 + var rdata FetchredbagReq
  214 + err := json.Unmarshal([]byte(data), &rdata)
  215 + for {
  216 + if err != nil {
  217 + logger.Info("json decode HandlerFetchredbag data failed:%v,for:%v", err, data)
  218 + resp.Message = "json解析错误"
  219 + resp.Code = 1
  220 + break
  221 + }
  222 +
  223 + uniqueuuid := strconv.Itoa(uuid) + rdata.Channel
  224 + uinfo, err := GetUserInfo(uniqueuuid)
  225 + if err != nil || uinfo == nil {
  226 + logger.Error("redis failed err=%v", err)
  227 + resp.Message = "服务器错误"
  228 + resp.Code = 1
  229 + break
  230 + }
  231 +
  232 +
  233 +
  234 + if rdata.Rtype == 1 {
  235 + //先判断一下是否可以领取
  236 + if uinfo.GuanRedNum >= uinfo.PassLevel {
  237 + logger.Error("HandlerFetchredbag failed err=%v", err)
  238 + resp.Message = "没有可以领取的关卡红包"
  239 + resp.Code = 1
  240 + break
  241 + }
  242 +
  243 + cfg := jsonconf.GetGuanConf(uinfo.GuanRedNum+1)
  244 + if cfg == nil {
  245 + logger.Error("HandlerFetchredbag failed err=%v", err)
  246 + resp.Message = "获取配置失败!"
  247 + resp.Code = 1
  248 + break
  249 + }
  250 +
  251 + realgold, err := AddCoinToSdk(uuid, cfg.Cash, rdata.Gameid, rdata.Channel, 108)
  252 + if err !=nil {
  253 + logger.Error("HandlerFetchredbag failed err=%v", err)
  254 + resp.Message = "服务器错误!"
  255 + resp.Code = 1
  256 + break
  257 + }
  258 +
  259 + resp.Data.Getgold = cfg.Cash
  260 + resp.Data.Walletgold = realgold
  261 +
  262 + uinfo.GuanRedNum ++
  263 + }else if rdata.Rtype == 2 {
  264 + if uinfo.JiRedNum+1 >= uinfo.BigLevel {
  265 + logger.Error("HandlerFetchredbag failed err=%v", err)
  266 + resp.Message = "没有可以领取的等级红包"
  267 + resp.Code = 1
  268 + break
  269 + }
  270 +
  271 + cfg := jsonconf.GetGuanConf(uinfo.JiRedNum)
  272 + if cfg == nil {
  273 + logger.Error("HandlerFetchredbag failed err=%v", err)
  274 + resp.Message = "获取配置失败!"
  275 + resp.Code = 1
  276 + break
  277 + }
  278 +
  279 + realgold, err := AddCoinToSdk(uuid, cfg.Cash, rdata.Gameid, rdata.Channel, 108)
  280 + if err !=nil {
  281 + logger.Error("HandlerFetchredbag failed err=%v", err)
  282 + resp.Message = "服务器错误!"
  283 + resp.Code = 1
  284 + break
  285 + }
  286 +
  287 + resp.Data.Getgold = cfg.Cash
  288 + resp.Data.Walletgold = realgold
  289 +
  290 + uinfo.JiRedNum ++
  291 + }else {
  292 + if uinfo.RandNum <= 0 {
  293 + logger.Error("HandlerFetchredbag failed err=%v", err)
  294 + resp.Message = "没有可以领取的随机红包次数了!"
  295 + resp.Code = 1
  296 + break
  297 + }
  298 +
  299 + getnum := rand.Intn(200) + 100
  300 + realgold, err := AddCoinToSdk(uuid, getnum, rdata.Gameid, rdata.Channel, 108)
  301 + if err !=nil {
  302 + logger.Error("HandlerFetchredbag failed err=%v", err)
  303 + resp.Message = "服务器错误!"
  304 + resp.Code = 1
  305 + break
  306 + }
  307 +
  308 + resp.Data.Getgold = getnum
  309 + resp.Data.Walletgold = realgold
  310 +
  311 + uinfo.RandNum--
  312 + }
  313 +
  314 +
  315 + SaveUserInfo(uinfo,uniqueuuid)
  316 +
  317 + resp.Data.Randnum = uinfo.RandNum
  318 + resp.Data.Guanrednum = uinfo.GuanRedNum
  319 + resp.Data.Jirednum = uinfo.JiRedNum
  320 + resp.Code = 0
  321 + break
  322 + }
  323 +
  324 + //回包
  325 + respstr, _ := json.Marshal(&resp)
  326 + fmt.Fprint(w, string(respstr))
  327 +
  328 +}
  329 +
  330 +func HandlerUploadbiglevel(w http.ResponseWriter, data string, uuid int) {
  331 + SetHeader(w)
  332 + var resp UploadlevelResp
  333 + resp.Code = 0
  334 + var rdata UploadlevelReq
  335 + err := json.Unmarshal([]byte(data), &rdata)
  336 + for {
  337 + if err != nil {
  338 + logger.Info("json decode HandlerUploadbiglevel data failed:%v,for:%v", err, data)
  339 + resp.Message = "json解析错误"
  340 + resp.Code = 1
  341 + break
  342 + }
  343 +
  344 + uniqueuuid := strconv.Itoa(uuid) + rdata.Channel
  345 + uinfo, err := GetUserInfo(uniqueuuid)
  346 + if err != nil || uinfo == nil {
  347 + logger.Error("redis failed err=%v", err)
  348 + resp.Message = "服务器错误"
  349 + resp.Code = 1
  350 + break
  351 + }
  352 +
  353 + if rdata.Level > uinfo.BigLevel {
  354 + uinfo.BigLevel = rdata.Level
  355 + }
  356 +
  357 +
  358 + SaveUserInfo(uinfo,uniqueuuid)
  359 +
  360 + resp.Code = 0
  361 + break
  362 + }
  363 +
  364 + //回包
  365 + respstr, _ := json.Marshal(&resp)
  366 + fmt.Fprint(w, string(respstr))
  367 +
  368 +}
  369 +
207 370 func HandlerUploadlevel(w http.ResponseWriter, data string, uuid int) {
208 371 SetHeader(w)
209 372 var resp UploadlevelResp
... ... @@ -376,8 +539,7 @@ func (u *UserData) HandlePassDay(uuid int, channel string) {
376 539 //todo 重置任务相关的数据
377 540 u.GetFromGuanCnt = 0
378 541 u.GetCashCnt = 0
379   -
380   -
  542 + u.RandNum = RANDNUMLIMIT
381 543  
382 544  
383 545  
... ... @@ -425,7 +587,11 @@ func GetUserData(uuid int, uniqueuid string, req *UserLoginReq, resp *UserLoginR
425 587 SaveUserInfo(data, uniqueuid)
426 588  
427 589 resp.Data.Walletgold = data.RealGold
428   - //resp.Data.Leftredbagcnt = data.WatchAddsTime
  590 + resp.Data.Curji = data.BigLevel
  591 + resp.Data.Curlevel = data.PassLevel
  592 + resp.Data.Guanrednum = data.GuanRedNum
  593 + resp.Data.Jirednum = data.JiRedNum
  594 + resp.Data.Randnum = data.RandNum
429 595  
430 596 return nil
431 597 }
432 598 \ No newline at end of file
... ...